I’m new to three.js, I want to load different textures on different sides on my GLB model, is that possible?
I tried it like this with a normal cube:
var geometry_cube = new THREE.BoxGeometry(2,2,2);
var materials = [
new THREE.MeshBasicMaterial({ color: 0xff0000}),
new THREE.MeshBasicMaterial({ color: 0x0000ff }),
new THREE.MeshBasicMaterial({ color: 0x00ff00 }),
new THREE.MeshBasicMaterial({ color: 0xffff00 }),
new THREE.MeshBasicMaterial({ map: texture_1 }),
new THREE.MeshBasicMaterial({ map: texture_2 })
];
var cube = new THREE.Mesh(geometry_cube, materials);
scene.add(cube);
and then I wanted to do it like this with the glb model:
Note: the glb model has also 6 sides.
gltfLoader.load('glb_model.glb', (gltf) => {
const model = gltf.scene;
model.traverse((child) => {
if (child.isMesh) {
child.material = materials;
}
}),
});
The model does not load, but there is no error message.
Then I tried child.material.map = texture_1
and it works, but it renders on all sides.
Hope you can help me, thanks in advance.