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]);
}