I'm encountering an issue while attempting to incorporate a .obj level into my program as it appears black when rendered. The associated .mtl file necessitates multiple images spread throughout, leaving no untextured spaces. Strangely, the same object worked flawlessly in my previous project, yet fails to do so in my current one. Oddly enough, when I omit the materials, the lighting behaves as expected, but as soon as I include them, the object turns pitch black. Interestingly, the renderer continues to render without any disruption, and the console displays no errors.
Below is the code utilized in my current project, with MaterialLoader representing an instance of MTLLoader and ObjectLoader representing an instance of OBJLoader:
MaterialLoader.load("bbb/bbb.mtl",
function(materials) {
materials.preload()
ObjectLoader.setMaterials(materials)
ObjectLoader.load("bbb.obj",
function(model) {
let mesh = model.children[0]
scene.add(mesh)
}, null,
function(error) { alert(error) }
)
}, null,
function(error) { alert(error) }
)
And here is the code from my prior project, with the loader variable denoting an OBJLoader instance with successful material loading:
mtlLoader.load(
"bbb.mtl",
function(materials) {
materials.preload()
loader.setMaterials(materials)
loader.load("bbb.obj",
function(obj) {
level = obj.children[0]
scene.add(level)
}, null,
function(error) { alert(error) }
)
}, null,
function(error) { alert(error) }
)