Hi all, I’m trying to make the texture of a cube composed of 2 Meshes to not stretch. This is my code:
const firstMesh = object.children[ 0 ].children[ 0 ].clone();
const secondMesh = object.children[ 0 ].children[ 1 ].clone();
const loader = new THREE.TextureLoader();
const colorTexture = loader.load( woodTextureFile );
colorTexture.wrapS = THREE.RepeatWrapping;
colorTexture.wrapT = THREE.RepeatWrapping;
const oldMaterialParams1 = firstMesh.material.clone();
const oldGeoParams1 = firstMesh.geometry.clone();
const newMaterial1 = new MeshStandardMaterial( {
map: colorTexture,
} ).clone( oldMaterialParams1 );
const oldMaterialParams2 = secondMesh.material.clone();
const oldGeoParams2 = secondMesh.geometry.clone();
const newMaterial2 = new MeshStandardMaterial( {
map: colorTexture,
} ).clone( oldMaterialParams2 );
object.children[ 0 ].children[ 0 ] = new THREE.Mesh( oldGeoParams1, newMaterial1 );
object.children[ 0 ].children[ 1 ] = new THREE.Mesh( oldGeoParams2, newMaterial2 );
And my results attached. The texture gets stretched. The image itself is 1024 x 1005, so not a power of 2 (I’m limited to this size for reasons). I believe this shouldnt give me any problem besides a weird repeat, right? Or the repeat cancels because I do not have a power of 2 image? Is something wrong with my code?. Thanks in advance (edited)