Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unmount the Canvas component instant mount children again even if canvas is not mounted #796

Closed
5 tasks done
dghez opened this issue Aug 8, 2024 · 1 comment · Fixed by #799
Closed
5 tasks done
Assignees
Labels
bug Something isn't working p4-important-bug Violate documented behavior or significantly improve performance (priority)

Comments

@dghez
Copy link

dghez commented Aug 8, 2024

Describe the bug

When you unmount the Canvas component, it instant re-mount it again, triggering onMounted callback.
I thought it was a nuxt issue but is actually unrelated, nuxt was just mount/unmount the page tha was causing the problem.

Canvas is in /about.

Screen.Recording.2024-08-08.at.12.54.15.mov

Reproduction

https://stackblitz.com/edit/nuxt-starter-k7pfzc?file=pages%2Findex.vue

Steps to reproduce

No response

System Info

No response

Used Package Manager

npm

Code of Conduct

@dghez
Copy link
Author

dghez commented Aug 8, 2024

@alvarosabu Completely random hint that might be completely wrong: https://github.com/Tresjs/tres/blob/main/src/components/TresCanvas.vue#L144

Why are we calling mountCustomRenderer in the dispose function that is called in the onUnmounted?

const dispose = (context: TresContext, force = false) => {
  disposeObject3D(context.scene.value as unknown as TresObject)
  if (force) {
    context.renderer.value.dispose()
    context.renderer.value.renderLists.dispose()
    context.renderer.value.forceContextLoss()
  }
  (scene.value as TresScene).__tres = {
    root: context,
  }
  mountCustomRenderer(context)
}

@dghez dghez changed the title Unmount the Canvas component instant mount it again Unmount the Canvas component instant mount children again even if canvas is not mounted Aug 14, 2024
@alvarosabu alvarosabu self-assigned this Aug 14, 2024
@alvarosabu alvarosabu added bug Something isn't working p4-important-bug Violate documented behavior or significantly improve performance (priority) labels Aug 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working p4-important-bug Violate documented behavior or significantly improve performance (priority)
Projects
Status: Done
2 participants