Changing decals properties

I want to change decals properties after it is placed.

First I tried to scale up the decal with set and it worked but then it gets Y value which makes decal not sticking to the mesh, same with the rotation and position.

The next think I tried is to clone existing decal with new properties and remove previous one. I believe that would be the right way to do that, but the problem that occured is
‘Cannot read properties of undefined (reading ‘x’)’

This occured when I made clone function and I think it is because of inappropriate value I provided to point and face. In the object of point and face their values are vector3 but it doesnt work when I provide vector3.

I am not sure if I am using this clone function right, I wanted to add decal with new properties from existing one just with differente size.

Here is that part of the code

const [decalsPoint, setPoint] = useState([]);

  const Ssize = new Vector3(5, 5, 5);
  const size = new Vector3(2, 2, 2);

  function cloneDecal(size) {
    if (decalsPoint.length > 0 && Object.keys(selectedMesh).length !== 0) {
      const res = selectedMesh.clone(); //from setSelected
      addDecal(decalsPoint[0], decalsPoint[1], res, size);
    }
  }

  cloneDecal(Ssize);

  function addDecal(point, face, decal, decalSize) {
    const m = new Mesh(
      new DecalGeometry(shirt.current, point, face.normal, decalSize),
      decal
    );
    state.scene.add(m);
    setMeshes([
      ...allMeshes,
      m,
    ]);
    setSelected(m)
    setPoint([...decalsPoint, point, face.normal]);
  }
1 Like

Hello
Did you find anyway?

DecalGeometry is just a Geometry, it will create a new geometry that matches the targeted area, a sort of mold or patch over the selected point and its surrounding. Wish means, it has to be fixed, you can’t transform it (move, rotate or scale).

You’ll need to dispose of the old decal/geometry, and create a new one for each update.

This does not apply to the Material, you can freely update its parameters as long as it does not affect the geometry.

The Texture can also be updated or transformed (moved rotated or scaled) without affecting the geometry.