Reputation: 89
When applying a texture to a flat GLTF model (Floor) I only get a single colour from the texture rather than the desired yellow & black stripe effect. Any help is much appreciated!
Texture used:
Example of texture applied to child within GLTF model:
new THREE.TextureLoader().load( textures[2], function(texture){
texture.flipY = false;
var material = new THREE.MeshBasicMaterial({map: texture});
child.material = material;
});
Upvotes: 1
Views: 458
Reputation: 31026
When this happens it usually means there are no texture coordinates defined. It's best to check this with a tool like Blender and add add texture coordinates if necessary.
Besides, if you replace or add a color texture to a loaded glTF asset in three.js
, you have to add an additional line of code:
texture.flipY = false;
texture.encoding = THREE.sRGBEncoding; // define color space
const material = new THREE.MeshBasicMaterial({map: texture});
Upvotes: 2