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

Blank Canvas when navigating between two pages that have a TresCanvas #41

Closed
5 tasks done
T-Mike opened this issue Sep 26, 2023 · 9 comments · Fixed by #84
Closed
5 tasks done

Blank Canvas when navigating between two pages that have a TresCanvas #41

T-Mike opened this issue Sep 26, 2023 · 9 comments · Fixed by #84
Labels
bug Something isn't working help wanted Extra attention is needed investigation

Comments

@T-Mike
Copy link

T-Mike commented Sep 26, 2023

Describe the bug

TresJS scene does not display when you navigate between two pages that have a <TresCanvas>

When the current page has a <TresCanvas> and you navigate to another page that has a <TresCanvas>, new page displays a blank canvas.
When the current page does not have a <TresCanvas> and you navigate to another page that has a <TresCanvas>, new page works as expected.

Same behaviour on latest Chromium and Firefox.
Only Firefox outputs a warning: "WebGL Context lost"

Reproduction

https://stackblitz.com/edit/nuxt-starter-tg1cya

Steps to reproduce

Create a nuxt Project.
Add a "pages" folder to enable routing.
Inside "pages" folder, add 3 .vue files. On two of them, add a TresCanvas with a basic scene inside.
Then navigate between the pages to experience the bug.

On my reproduction, just use the three links to navigate between pages.
Home does not have a <TresCanvas>
Page1 and Page2 have a <TresCanvas>

System Info

@tresjs/nuxt 1.1.7
nuxt 3.7.4

Used Package Manager

yarn

Code of Conduct

@markus-gx
Copy link

markus-gx commented Oct 18, 2023

Have you resolved this issue?
I am currently facing it too.

     "nuxt": "^3.7.4",
    "@tresjs/cientos": "^3.5.0",
    "@tresjs/core": "^3.3.0",
    "@tresjs/nuxt": "^1.2.0",
    "@tresjs/post-processing": "^0.4.0",

#edit

Solved with a neat hack 🤣
When using useState the key must be unique across your canvas instances.

const mountedFix = useState(`mounted-fix-${props.blok._uid}`, () => false)
onMounted(() => {
  mountedFix.value = true
})
onUnmounted(() => {
  mountedFix.value = false
})

@alvarosabu we don't have access to @trejs/core right?
It seems that it can be solved in the TresCanvas instance coming from /core. Maybe this helps somehow.

@alvarosabu
Copy link
Member

Hey there, @T-Mike @markus-gx did you guys tried out latest version v1.2.0?

Daniel and I made some changes that might solve this issue, I had it too in the playground and now it works.

Could you please update and try again to see if it works?

@markus-gx
Copy link

Hey there, @T-Mike @markus-gx did you guys tried out latest version v1.2.0?

Daniel and I made some changes that might solve this issue, I had it too in the playground and now it works.

Could you please update and try again to see if it works?

Sadly not. Already on the latest version.

     "nuxt": "^3.7.4",
    "@tresjs/cientos": "^3.5.0",
    "@tresjs/core": "^3.3.0",
    "@tresjs/nuxt": "^1.2.0",
    "@tresjs/post-processing": "^0.4.0",

@T-Mike
Copy link
Author

T-Mike commented Oct 18, 2023

I confirm, problem still here with version 1.2.0

@alvarosabu
Copy link
Member

Yep it's reproducible, I will investigate further. Its weird because the playground its done with Nuxt module and works. 😅

https://playground.tresjs.org/

@alvarosabu
Copy link
Member

@T-Mike could you confirm if this still happens in v2?

@T-Mike
Copy link
Author

T-Mike commented Dec 14, 2023

Yes still happens. https://stackblitz.com/edit/nuxt-starter-jreyrm

And for your previous comment, I checked the playground and this is not the same situation. If I'm not mistaken, the home doesn't have a tresjs animation and nowhere on the playground you go from an experiment to another experiment (ie. from a page with a Tres canvas to another page with a Tres canvas).

@alvarosabu alvarosabu added bug Something isn't working help wanted Extra attention is needed investigation and removed investigation waiting for author labels Dec 15, 2023 — with Volta.net
Copy link
Member

@T-Mike gotcha! Thanks

@alvarosabu
Copy link
Member

Hey everyone @T-Mike @markus-gx sorry took so long to get back to you. I've been trying to figure out this bug the last 3 weeks and the only workaround I found was to wrap the TresCanvas on each page with a <ClientOnly> 😥

My rough guess is that the SSR version of the component is causing the issue, but now after the new version of nuxt 3.10.0 is completely broken #83 , I already reach out to the nuxt team for help.

Sorry for the inconvenience

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed investigation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants