Hi
I load images on 3d models layers by decal .But in some layers it appears flip.
Can you help me what is reason ? in my code or 3d model.
check this video please:
and this is my code
async function addNewDecal(decalMaterial, imageFile, normalTextureURL, id) {
const newMesh = activeMeshRef.current
newMesh.geometry.computeBoundingBox();
var boundingBox = newMesh.geometry.boundingBox;
var position = new THREE.Vector3();
position.subVectors(boundingBox.max, boundingBox.min);
position.multiplyScalar(0.5);
position.add(boundingBox.min);
position.applyMatrix4(newMesh.matrixWorld);
const meshSize = getMeshSize(newMesh);
let newDecal = new DecalGeometry(activeMeshRef.current, position, new THREE.Euler(0, 0, 0), meshSize);
newDecal.name = id
console.log('new decal>>',newDecal)
selectedDecalID.current = id
const decalMesh = new THREE.Mesh(newDecal, decalMaterial);
decalMesh.name = id
scene.current.add(decalMesh);
})
}
function imageTextureManager(file, normalTextureURL, id) {
const textureLoader = new THREE.TextureLoader();
const texture = textureLoader.load(file)
texture.encoding = THREE.sRGBEncoding;
const normalTexture = textureLoader.load(normalTextureURL);
normalTexture.wrapS = THREE.RepeatWrapping;
normalTexture.wrapT = THREE.RepeatWrapping;
normalTexture.repeat.set(5, 5);
const decalMaterial = new THREE.MeshStandardMaterial(
{
normalMap: normalTexture,
normalScale: new THREE.Vector2(0.3, 0.3),
map: texture,
transparent: true,
depthTest: true,
depthWrite: false,
polygonOffset: true,
polygonOffsetUnits: 1,
polygonOffsetFactor: -4,
});
decalMaterial.map.encoding = THREE.sRGBEncoding;
decalMaterial.needsUpdate = true;
addNewDecal(decalMaterial, file, normalTextureURL, id)
tick()
}
and this is 3d models that I am working with>>