Hi,
I have problem using images’ path url to load the texture. If I use the url the process is rejected and doesn’t load any image as texture.
I’ve wrote this piece of code using asynchronous methods:
const textureLoader = new THREE.TextureLoader();
const sphere = textureLoader.loadAsync('../assets/img/image.jpg').then(
(t) => {
console.log('Ok');
console.log(t);
const geometry = new THREE.BoxGeometry(1, 1, 1);
const material = new THREE.MeshBasicMaterial({map: t});
return new THREE.Mesh(geometry, material);
},
() => { console.log('Rejected') },
);
sphere.then(
(s) => {
scene.add(s)},
() => { console.log("Problem") }
);
But if instead of url’s image I import the image using import image from '../assets/img/image.jpg'
at the top of code and I pass image
in .loadAsync()
it works.
Anyone knows why?
(P.s. The same issue happen with classic .load()
)