Binding Props
There are times when the underlying PixiJS instance of a component gets updated externally (e.g, a physics system that applies forces on collision). In such a scenario, it would be helpful to bind our component props to the instance properties so that they are in sync. However, the bind:
syntax will have no effect for instance-related properties on SveltePixi components (such as x
or y
) . This is to improve performance as the components would have to sync all props all the time regardless if they are bound, causing a large performance hit.
Instead, SveltePixi provides a track utility function that will allow you to achieve similar behaviour. It returns a writable store that updates on every tick with the passed in function. We can use this to grab instance values and pass them back down as props (effectively creating a bind).