I'm still pretty new at Three.JS, I'm pretty happy where I have gotten so far, but just need some help.
I have an GLTF object loaded into the scene, I want to be able to load different textures onto the object on the website by the user selecting a style, (like a customization feature).
Below is my code, at the moment it outputs nothing and I get the following error:
In Chrome:
"TypeError: Cannot set property 'map' of undefined"
In Firefox:
"TypeError: model.material is undefined"
var textureLoader = new THREE.TextureLoader();
var texture = textureLoader.load('../gtf/green/green.png');
texture.flipY = false;
var loader = new THREE.GLTFLoader();
loader.load( '../gtf/Box.gltf', function ( gltf ) {
model = gltf.scene;
scene.add( model );
});
model.material.map = texture;
Any help would be greatly appreciated.