Decal gradually disapears on changing it's position

I am currently working on a software where I am changing properties of the decal.
I do that by cloning the decal and all it’s properties so I just put them into new decal but with new added property.
The problem I have is that on moving decal it gradually disapears. I think the problem is that I dont change it’s z position and it’s face object, so when I clone it with these properties it will stay behind the mesh.
To understand better I have this repo of simulation.
If you run it go to editor page.
To add the decal just click on the mesh.
To move decal, click on a button in X or Y and then click on canvas before you press shift to make a clone.
I appreciate any thought. Thanks.

Moving a decal after it has been created won’t work in the general case, because a decal is a new mesh that is created based on the geometry of the mesh at the creation point.

If you move the decal, the geometry of the underlying mesh will probably be different than the geometry at the creation point (except if your mesh is a flat plane), so the decal won’t show up properly. You should recreate the decal at the new location if you need to move it.

1 Like

What should be the best practice here?
Since I have to know it’s previous position and I cant click and to take those properties by pickInfo.

You can try to use scene.pickWithRay if you are able to create a ray at the new location. Or scene.pick() if you can provide updated 2D coordinates.

1 Like

is there a way to provide X or Y and automatically get Z and Face based on those X or Y positions and the mesh?
When I click it knows all the properties to set it.
By using ray I dont solve the problem. It is still quite similar.
I am looking for something similar to this. If there is any way to do it which i dont know I would like to try.

I think in the video they always use the same point for the decal projection.

For the torso, it’s the point in the middle of the torso. They copy the image into the decal texture in the right place, depending on the size and position of the image in the canvas, and use that texture to create the decal.

This method simplifies things because you don’t have to figure out where to create the decal (it’s a given, depending on which side of the shirt you want to place the decal on), and the size of the decal is fixed (also depending on the side of the shirt).

You want to say that I just copy all the properties and paste them into canvas to the decal.
I would have to know the position of the left side images to be able to provide it to the canvas,
How can I meassure it?
Is the left side where he is adding images canvas?

What I mean is something like that:

When you click, it adds some random pixels in the texture which is projected onto the torso.

The position and the direction of projection is always the same (decalPos and decalNormal in the PG), even if you rotate the mesh (as shown by the red projector).

What you need to do is to fill the texture (textureDecal) appropriately.

what is he using on the left side, and how is he getting the position of added images?

It seems he is doing it in HTML but that’s difficult to know for sure from a video.

Maybe you can post a comment to the video to ask how he did it?

1 Like