Decal position within a mesh but not the entire mesh

hello,
My issue is that i am projecting a decal into a mesh and i do that with predefined position from an svg i apply as texture. So i got the positioning down by normalizing the svg coordinates and calculatin x and y in x y z for the 3d model. My issue is that when i apply the decal and scale or move it inside the mesh i need the decal to be limited by a zone that exists inside the svg. In other words i dont want the decal to be able to take the entire mesh as a surface in which it can move but a part of it. To be more clear if there is a square and i project the decal into it when i move it i would like that the decal would not be able to touch the edges but it should be confined to a smaller square inside the first one. If it makes sense. I am not very familiar with babylon js but i dont expect an out of box solution just to point me in the right direction.

Welcome aboard!

I don’t really see how to do it in general given your description, but if you can create a reproduction in the Playground, we may be able to find a solution tailored to your use case.

That is the issue i dont know how :(. In theory i just want to limit my decal mouvement inside the mesh to not reach the edges. Like if its a square (cube in 3d :p) and i project a decal in a face than in that face it should be able to move around but lets say 2cm of the edges max so if the cube is 10X10, in the face is projectced the decal, it should be able to move in a surface 8x8. I cant really provide the code cuz i am not at ll familiar with playground .

OOOOOO i might have a solution i’ll let you know if someone will have the same problem. I will test and share the findings. (but most likely there is a easier way that ppl already apply :p)

it works :smiley: so i have an svg that i apply as texture but within it have a safezone in which i want to apply logo that is a surface defined by a path/polygon. When i apply the svg (after converting to png) the svg maps to the 3dmodel as it should and i have a few meshes in this model. What i needed is that when i apply an image as a decal to one of the meshes, had to have some marging in the edges as to never touch them. But the marges were defined in the svg. So what i did is converted path-> M l c ect to M L C ect. I added point to L and C with a few tricks (splitBezierCurve,splitLineSegment) and created a uv map of each point. after that i from each uv i create 3d cordinates (i tested by creating some spheres to check if the safe zone was as i have it in the svg) and there it was my safezone defined. Now i can perform all kind of cheks when i move, rotate, resize my image so that it stays within those params. ( 3 days for that , i still welcome if anyone has a better idea or less complex solution). If anyone needs the code just tell me (keep in mind i use svg as texture so it might be your case but if it can help i’ll share it)

1 Like