Skip to content

Commit

Permalink
refactor: rename similar methods
Browse files Browse the repository at this point in the history
  • Loading branch information
saw-jan committed Oct 14, 2024
1 parent f044327 commit 5507203
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
6 changes: 1 addition & 5 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
29 changes: 15 additions & 14 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,13 @@ onMounted(async () => {
await renderModel(unref(fileType))
loadLights()
} catch (e) {
cleanup3dScene()
teardown3dScene()
hasError.value = true
}
}
})
onBeforeUnmount(() => {
cleanup3dScene()
teardown3dScene()
})
// =====================
Expand Down Expand Up @@ -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()
}
Expand Down Expand Up @@ -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))
Expand All @@ -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<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 toggleFullscreenMode() {
const activateFullscreen = !unref(isFullScreenModeActivated)
const el = unref(sceneWrapper)
Expand Down

0 comments on commit 5507203

Please sign in to comment.