'm using DecalGeometry in Three.js to project a logo onto a mesh. It works fine if the model hasn't been moved after loading. But if I translate the model or its parent group (e.g., along the Y axis), then apply the decal, the decal appears in the wrong position — either above or below the intended surface.
// Move model group
group.position.y += 0.005;
// Create decal
const box = new THREE.Box3().setFromObject(targetMesh);
const center = box.getCenter(new THREE.Vector3());
const decalGeometry = new DecalGeometry(
targetMesh,
center, // Seems incorrect after movement
orientation,
size
);
const decal = new THREE.Mesh(decalGeometry, decalMaterial);
group.add(decal);
What’s the correct way to compute the decal position after the model or its parent group has been moved, so that the decal aligns properly with the mesh surface?
Any insight would be greatly appreciated!