Within this block of code, my goal is to load multiple 3D models using the asynchronous .load
method.
async function loadModels(lights, roomWidth, roomHeight) {
// Initializing an empty array to store the loaded models
models = []
/* Loading the first model: "Sci-Fi Light 11" */
const loader = new GLTFLoader(loadingManager);
loader.load('./models/scifi_light_11.glb', function (gltf) {
// Transforming and positioning the model in various rooms
gltf.scene.scale.set(0.02, 0.02, 0.02)
gltf.scene.rotateZ(-0.7 * Math.PI);
gltf.scene.receiveShadow = true;
gltf.scene.castShadow = true;
// Code snippet to position the model in different rooms goes here...
// Adding the loaded model to the scene and the models array
scene.add(gltf.scene);
models.push(gltf);
});
/* Loading the second model: "Terminal" */
const loader1 = new GLTFLoader(loadingManager);
// Additional description for the source of the model goes here...
loader1.load('./models/terminal/scene.gltf', function (gltf) {
// Similar process of transforming, positioning, and adding the model to the scene
// Code for handling the second model goes here...
});
// The loading process for other models continues similarly...
}