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: https://playground.babylonjs.com/#WIR77Z#765

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

Hey there, it’s because you’re using setParent that the position is wrong - setParent is handy when you want the child’s current absolute position to be the same as it was before setting its parent, but in this case it works better to skip that part and just set decal.parent equal to the sphere like below I think. :slight_smile:

1 Like