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

[Question] computed value inst #558

Open
WTDuck opened this issue Jun 4, 2019 · 1 comment
Open

[Question] computed value inst #558

WTDuck opened this issue Jun 4, 2019 · 1 comment

Comments

@WTDuck
Copy link
Contributor

WTDuck commented Jun 4, 2019

In this project, ThreeJS native objects are stored in a computed function called inst.
Knowing how big and complex those objects are, I guess they are stored this way for a reason.

My first guess was about removing VueJS observers on objects that doesn't required direct reactivity.
Obviously we don't need Vue to tell us about every single changes in this ThreeJS object.
The main reason for that is performance and by using a computed function it's a clever way to do so. (no-cached computed)

If that is the case, I would like to ask why don't we just declare the instance during created() ?

As explained in this post, var declaration on this during created doesn't provide reactivity !
This trick is really useful on complex objects and also datas that get modified a lot in a few seconds (like live mouse position) and has a huge performance benefits for ThreeJS objects !

@h-ikeda
Copy link
Member

h-ikeda commented Jun 18, 2019

Some components of VueGL are computed inst with props, not just a constructor. It's for recreating THREE's object when the props change. Some of THREE's class accept properties when only creation, so I thought this way makes managing instance easier. (Otherwise, we should recreate objects manually and trigger functions to register namespaces, to manage object trees...)

inst computed properties have just references to THREE's object, but could that be an obstacle to performance?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants