I'm struggling to apply an image onto an object using the following code:
var texture = new THREE.TextureLoader().load( 'crate.gif' );
var geometry = new THREE.BoxBufferGeometry( 200, 200, 200 );
var material = new THREE.MeshBasicMaterial( { map: texture } );
mesh = new THREE.Mesh( geometry, material );
scene.add( mesh );
Even though I have "crate.gif" in my local folder, it doesn't display on the box.
The developer mentioned that local image loading won't work and suggested using a web server or data URL as a solution.
- However, setting up a web server is not an option for me.
- I might consider converting images to Base64, but I don't know how to implement this.
I suspect the image isn't showing because it hasn't finished loading. What's the simplest way to load an image?