stagerightlabs / Vue-Three-Demo

An example of a Vue.js / Three.js integration
https://vuethree.stagerightlabs.com/
MIT License
35 stars 8 forks source link

Strict mode #1

Closed educkf closed 2 years ago

educkf commented 4 years ago

Hello!

I have been studying your project, to understand more about using Three.js with Vuex. I know you have build it more than a year ago, and maybe don't remember it much. But anyway, I thought of discussing some aspects of it.

I have been poking it around, trying to make it work on strict mode. Moving everything that visibly changes state to a mutation and everything, but I could not make it work, it never finishes loading the page once I activate strict mode...

When reading about strict mode on Vuex, it is said:

Do not enable strict mode when deploying for production! Strict mode runs a synchronous deep watcher on the state tree for detecting inappropriate mutations, and it can be quite expensive when you make large amount of mutations to the state. Make sure to turn it off in production to avoid the performance cost.

Maybe it never stop loading because of the expense of those deep watchers? Is the code you have now already "ok" with strict mode and state mutability only on commits? Or is it something not doable with Vuex and Three.js maybe?

Do you have any thoughts on that?

thanks!

rydurham commented 4 years ago

Hello,

I have not tried using this code in strict mode, so I can't speak from experience here. However, I can say that even without strict mode I had a fair amount of trouble getting Three.js to work well with Vuex. It was very easy to overwhelm vuex with a large number of state change commits and bring down the whole page. My guess is that with the watcher in place this balance becomes even more tenuous.

I don't know for sure, but if I had to guess I would say that it is not possible to get Vue and Three.js working together with strict mode enabled.

rydurham commented 2 years ago

This may or may not be a moot point in Vue 3, which has been implemented in PR #6. I am going to close this for now but feel free to reopen it if you would like.