Fix optimizations
authorLanius Trolling <lanius@laniustrolling.dev>
Fri, 24 Feb 2023 17:36:30 +0000 (12:36 -0500)
committerLanius Trolling <lanius@laniustrolling.dev>
Fri, 24 Feb 2023 17:36:30 +0000 (12:36 -0500)
src/main/resources/static/init.js

index 6b3f6cd4bcde52eb17ed8d48dc0791007efef68c..0b8e41c82977f12f78cc18f7e238228006923f80 100644 (file)
        });
 
        window.addEventListener("load", function () {
-               const mtlLoader = (new THREE.MTLLoader()).setPath("/assets/meshes/").setResourcePath("/assets/meshes/");
-               const objLoader = (new THREE.OBJLoader()).setPath("/assets/meshes/").setResourcePath("/assets/meshes/");
-
                async function loadObj(modelName) {
-                       const mtlLib = await mtlLoader.loadAsync(modelName + ".mtl");
+                       const mtlLib = await (new THREE.MTLLoader()).setPath("/assets/meshes/").setResourcePath("/assets/meshes/").loadAsync(modelName + ".mtl");
                        mtlLib.preload();
-                       return await objLoader.setMaterials(mtlLib).loadAsync(modelName + ".obj");
+                       return await (new THREE.OBJLoader()).setPath("/assets/meshes/").setResourcePath("/assets/meshes/").setMaterials(mtlLib).loadAsync(modelName + ".obj");
                }
 
                // Mesh viewing