Hey there, I've been working on rendering an image onto a model object using a JSON file. While I've successfully rendered the model itself, I'm facing an issue with getting the image to render from the JSON file.
var loader1 = new THREE.AssimpJSONLoader();
loader1.load(modelUrl, function(assimpjson){
// console.log(assimpjson.geometry);
assimpjson.traverse(function(child){
if(child instanceof THREE.Mesh) {
// newMesh = new THREE.Mesh(assimpjson, mat);
object_json = assimpjson;
assimpjson.traverse(function(child) {
if(child instanceof THREE.Mesh){
// I am able to set the color of the child
// but how can i set the image on the model?
// I tried loading the image like this
// var image = new THREE.TextureLoader().load('assets/images/image1.jpg');
// Is there a way than i can directly set the image to the mesh child in here
// and give a custom height and width to the image.
// child.material.color.setHex(0xFFFFFF);
}
});
assimpjson.scale.x = 30;
assimpjson.scale.y = 30;
assimpjson.scale.z = 30;
assimpjson.position.x = 120;
assimpjson.position.y = -200;
assimpjson.position.z = 0;
assimpjson.updateMatrix();
if (previous) scene.remove(previous);
scene.add(assimpjson);
previous = assimpjson;
}
});
});
Any assistance on this would be greatly appreciated! Thanks a lot!!!