Recently, I incorporated my model using the JSONLoader in some sample code. Loading objects with a single texture works perfectly fine, but when I imported a more complex object like a house with multiple textures/materials (such as grass, roof, windows), my model just appeared in plain gray.
You can see my example in action here:
This is how the model (.3ds) looked in Blender before exporting it as .js: Image of model in Blender with textures
Below is the main code snippet I'm currently utilizing:
<script>
// Main code block
// Include essential global variables and functions
init();
animate();
function init() {
// Set up scene, camera, renderer, controls, etc.
// Load the floor and skybox
// Add something to the scene
}
function addSomething(posx,posy,posz) {
// Load the 3D model using JSONLoader
}
function addObject(geometry,posx,posy,posz) {
// Assign materials/textures to different parts of the object and add it to the scene
}
function animate() {
requestAnimationFrame( animate );
render();
update();
}
function update() {
// Handle user input and update controls
}
function render() {
renderer.render( scene, camera );
}
</script>
If you have any insights on properly loading materials/textures for an object like mine, I would greatly appreciate it.
Thank you for your assistance.