Decal Projection changes despite same input

Hello I’m trying to allow a user to scale or rotate a decal after it has been placed. However I’m running into an issue where if I try to create a new decal with the same position and normal as the previous decal, I don’t get the same appearance, and this gets worse if the mesh that the decal is parented to is rotated from when the decal was originally placed. Any idea how I can fix this?

Playground example:Babylon.js Playground
Click to place a decal, hold right click to rotate the cat, middle mouse to scale the decal.
Observation: after placement, scaling the decal causes the new decal to have a different orientation. This can be further reproduced if the cat is rotated and then the decal is scaled again.

@Evgeni_Popov might have some ideas ?

Welcome aboard!

You should recompute the world matrix of the projector before generating the decal:

There are still some small shift of orientations sometimes when you rotate the cat, I think because the computations are not exactly the same as the vertices (as well as the projector position) have been transformed by the rotation of the cat.

Ah thanks, recomputing the world matrix does improve the issue.

Hm any ideas how to reproduce the same orientation if the cat is rotated?

No ideas for this one…