Tresjs / tres

Declarative ThreeJS using Vue Components
https://tresjs.org
MIT License
2.27k stars 107 forks source link

Routing Jump - Problem Occurring #475

Closed zhangyijie0214 closed 9 months ago

zhangyijie0214 commented 11 months ago

Describe the bug

"Hello, I have two questions:

1.In the custom rendering, it seems that Vue's unmount hooks, 'onUnmounted' and 'onBeforeUnmount', are not working. I'm using 'onLoop', and when I navigate to another page and then return, it creates a new 'onLoop' which runs alongside the previous one, including the 'onLoop' inside 'useFBO'. Currently, I can only unmount them by using 'onLoop.off' at the root canvas component. 2.I am using version 3.5.1, and I've noticed significant frame drops with touch and other events. I'm not sure if this has been optimized in newer versions. 3.I encounter a problem when using 'Tres' on two different pages. When I navigate from page 1 with 'tres' to page 2 with 'tres', nothing is displayed. However, if I go from page 1 with 'tres' to page 3 without 'tres', and then to page 2 with 'tres', this problem does not occur."

Reproduction

https://github.com/zhangyijie0214/nuxt-tres-test

Steps to reproduce

npm install npm run dev

System Info

No response

Used Package Manager

npm

Code of Conduct

zhangyijie0214 commented 10 months ago

11481703758094_ pic image

"I finally had time to study this, and I found that the 'onUnmounted' from the old page is triggered after the 'onMounted' of the new page, which causes the 'useRenderer' inside to pause the 'Loop'."

zhangyijie0214 commented 10 months ago

Could it be considered to change 'onUnmounted' to 'onBeforeUnmount'?🤔

zhangyijie0214 commented 10 months ago

I will solve it this way for now.😓 watch(()=> isActive.value,()=>{ if (!isActive.value) { resume() } })

Sea-DH1 commented 9 months ago

Is there any progress on this issue?

alvarosabu commented 9 months ago

Is there any progress on this issue?

Depends on which of the 3 issues inside the ticket you mean 😅, if it is the nuxt router issue is being handled here https://github.com/Tresjs/nuxt/issues/41

alvarosabu commented 9 months ago

Hi @zhangyijie0214 since this ticket covers several bugs I would ask you to please create a ticket per issue:

  1. New ticket
  2. Probably related to https://github.com/Tresjs/tres/issues/436, we are refactoring the pointer event manager on v4
  3. For nuxt related issues please open in the correspondent repository, there is one already for the nuxt router issues https://github.com/Tresjs/nuxt/issues/41

Please edit the title and the description of the video to cover only the first question or close this one and open a new one.

zhangyijie0214 commented 9 months ago

Sure, I will close this issue and then try the latest version of Tres to see if the first problem still exists, and provide videos and reproduction code.