function loadModel(path, objName, mtlName)
{
var onProgress = function(xhr) {
if (xhr.lengthComputable) {
var percentComplete = xhr.loaded / xhr.total * 100;
console.log(Math.round(percentComplete, 2) + '% downloaded' );
}
};
var onError = function(xhr) { };
var mtlLoader = new THREE.MTLLoader();
mtlLoader.setPath(path);
mtlLoader.load(mtlName, function(materials)
{
materials.preload();
var objLoader = new THREE.OBJLoader();
objLoader.setMaterials(materials);
objLoader.setPath(path);
objLoader.load(objName, function (object)
{
object.position.x = 0;
object.position.y = 0;
object.position.z = 0;
object.scale.set(0.2, 0.2, 0.2);
scene.add(object);
}, onProgress, onError);
});
}
<script type="module" src="./js/libs/MTLLoader.js"></script>
<script type="module" src="./js/libs/OBJLoader.js"></script>
I have exhausted all possible solutions I could find online, but none of them have resolved my issue. It seems that every fix creates a new problem. Rest assured, I am using the most up-to-date versions of all required libraries.