Currently, I am working on enhancing my Project by addressing all the issues highlighted by sonar. However, I have hit a roadblock with the error mentioned in the title. The issue is related to a function that loads a blender model using three.js, and sonar advises against utilizing the function multiple times. Nevertheless, I need to load multiple models using this particular function.
function weatherUpdate(condition, area) {
let climate = [];
function loadGLTF() {
let Loader = new GLTFLoader();
Loader.load("./model/weather.gltf", (gltf) => {
Mesh = gltf.scene;
Mesh.scale.set(0.2, 0.2, 0.2);
scene.add(Mesh);
camera.target = Mesh;
Mesh.position.x = 0;
Mesh.position.y = -0.4;
Mesh.position.z = 0;
});
}
I could move the loadGLTF function outside of the weatherUpdate function. However, I'm unsure how to reuse the function for loading another model such as ./model/rain.gltf