diff --git a/.eslintrc.cjs b/.eslintrc.cjs index ee187ef..1d99097 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -15,11 +15,7 @@ module.exports = { sourceType: 'module' }, rules: { - /** - * TODO: fix project import issues and then enable it - * 'sort-imports': 'warn', - */ - 'require-await': 'warn', + 'require-await': 'error', 'no-new': 'off', 'node/no-callback-literal': 'off', 'unused-imports/no-unused-imports': 'error', diff --git a/src/App.vue b/src/App.vue index 3a5be49..207fd81 100644 --- a/src/App.vue +++ b/src/App.vue @@ -154,13 +154,13 @@ onMounted(async () => { await renderModel(unref(fileType)) loadLights() } catch (e) { - cleanup3dScene() + teardown3dScene() hasError.value = true } } }) onBeforeUnmount(() => { - cleanup3dScene() + teardown3dScene() }) // ===================== @@ -326,8 +326,18 @@ async function renderNewModel() { await renderModel(unref(fileType)) } -function cleanup3dScene() { +function unloadCurrentModel(): void { + for (let i = scene.children.length - 1; i >= 0; i--) { + let obj = scene.children[i] + if (unref(obj.type) === 'Group' || unref(obj.type) === 'Mesh') { + scene.remove(obj) + } + } +} + +function teardown3dScene() { cancelAnimationFrame(unref(animationId)) + unloadCurrentModel() renderer.dispose() } @@ -379,7 +389,7 @@ async function next() { } updateLocalHistory() - await unloadModels() + unloadCurrentModel() // TODO: how to prevent activeFiles from being reduced // load activeFiles await loadFolderForFileContext(unref(currentFileContext)) @@ -398,22 +408,13 @@ async function prev() { } updateLocalHistory() - await unloadModels() + unloadCurrentModel() // TODO: how to prevent activeFiles from being reduced // load activeFiles await loadFolderForFileContext(unref(currentFileContext)) await renderNewModel() } -async function unloadModels(): Promise { - for (let i = scene.children.length - 1; i >= 0; i--) { - let obj = scene.children[i] - if (unref(obj.type) === 'Group' || unref(obj.type) === 'Mesh') { - scene.remove(obj) - } - } -} - function toggleFullscreenMode() { const activateFullscreen = !unref(isFullScreenModeActivated) const el = unref(sceneWrapper)