I want to achieve a fixed size sprite, for this I use a plane with shaderMaterial to achieve this requirement, and it needs to always face me like a sprite, but when I found that I used non-uniform scaling, it would produce strange phenomena at certain viewing angles
To make it always face me, I assign camera.absoluteRotation to the rotationQuaternion of this plane.
Why not using the billboardMode property of the plane mesh? It should take care of the world matrix calculation for you, even when using non uniform scaling.
okay i write a demo,You can use mouse wheel to zoom. It always maintains a fixed size, but when you rotate the view, you will see the phenomenon of squeezing. billboard test
here is unity forum’ way ,this ensures that the mouse will not deform and remain fixed in size when zooming or rotating, but the position is limited to 0,0,0 https://playground.babylonjs.com/#MZDRAY#5
But it will get smaller as the mouse wheel zooms in and out. I want it to be fixed in size and not get bigger or smaller as the mouse zooms in and out.
I have solved this problem. It is because there is a difference in accessing matrix elements in glsl and js, so according to the practice of the unity forum, I need to get the correct translation vector and scale vector in the world matrix.
Here is new PG,leave it for reference for people who want to use this method to implement billboard in the future