You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Vue reactivity is based on Proxy. This allows Vue 3 to automatically track changes to data objects and update the corresponding DOM elements whenever the data changes.
Since we are rendering a scene and updating it in every frame (60FPS), that means that we are updating the scene 60 times per second. If the object to be updated is reactive, Vue will try to update the scene 60 times per second. This is not a good idea 😅 and will be detrimental to performance, especially in big scenes
Here is a benchmark of the difference between using a Proxy object and a plain object.
Here we are getting the ref for the mesh with the Mesh instance so we can update the rotation, but boxRef remains a Proxy, a solution would be to unref or use a shallowRef since Direct template ref are not available see vuejs/core#1227
Vue reactivity is based on Proxy. This allows Vue 3 to automatically track changes to data objects and update the corresponding DOM elements whenever the data changes.
Since we are rendering a scene and updating it in every frame (60FPS), that means that we are updating the scene 60 times per second. If the object to be updated is reactive, Vue will try to update the scene 60 times per second. This is not a good idea 😅 and will be detrimental to performance, especially in big scenes
Here is a benchmark of the difference between using a Proxy object and a plain object.
Source: Proxy vs Plain Object
To discuss
shallowRef
instead ofref
) See Reactivity Advanced APIOne real world example is updating an instance for animation:
Here we are getting the ref for the mesh with the Mesh instance so we can update the rotation, but
boxRef
remains a Proxy, a solution would be tounref
or use a shallowRef since Direct template ref are not available see vuejs/core#1227I would love to have your input here @wheatjs @kissu @Astanusic
Food for though
https://discoverthreejs.com/tips-and-tricks/#performance
The text was updated successfully, but these errors were encountered: