Decals not in the mesh

Hello everyone!

It’s been a while that I’m searching a response regarding a decal problem that I have, but haven’t found any one.

To start I have a sphere mesh not in the center of the world, but a little bit higher (position.y = 16).

I wanted to add to it a decal, but the decal isn’t on the sphere, but in the coordinates 0 of the world.

I tried a few things:

  • Adding it as child of the sphere, but didn’t work
  • Changing the decal position manually, but it didn’t work
  • And some black magic I don’t remember, but hasn’t worked as well.

I think I’m missing something, but don’t wait, do you know how doing it?

Here is the playground where I’m working:

Put sphere.computeWorldMatrix(true) before placing the decal.

1 Like

This is the problem and solution I met this afternoon! I tried to print mesh.getWorldMatrix() before and after mesh transform and found worldMatrix did change, it confused me this whole afternoon… reading your solution, in my understanding, decal uses the worldMatrix in cache which doesn’t update but the one from getWorldMatrix updates. And this line of code focus the worldMatrix in cache recalculate