Resolves #143 and resolves #156: use tweakpane more responsibly.
How tweakpane is used currently:
The user may press Ctrl+Alt+1 to open the tweakpane. Internally, the tweakpane element already existed (built on construction of View3d), and this action just reveals it with CSS.
On every data load, the tweakpane is fully rebuilt.
How tweakpane is used after this PR:
The tweakpane does not exist before it is opened - it is (re)built whenever the user toggles it to visible, and destroyed when they toggle to invisible.
On every data load, we call the pane's refresh method.
We destroy the tweakpane with its own dispose method, rather than just unmounting it in the DOM.
I believe the original strategy of rebuilding the tweakpane on data loads was to anticipate when objects were replaced and rebind everything to new objects. But that seems to be pretty rare - it should currently just happen on switching to an entirely new volume (though other, deeper objects we could bind controls to in the future, e.g. Channel or MeshVolume, may be recreated more frequently and cause confusion). Hopefully a user who knows to open the tweakpane can deal with reopening it when a desync occurs. I'd still be grateful for a bit of extra testing here though. In particular, @toloudis I'm seeing different and better numbers in the heap profiler with this change versus the current state, but I'd be interested in a bit of verification since you did the tests that prompted #143 in the first place.
Review time: really little (5-10min)
Resolves #143 and resolves #156: use tweakpane more responsibly.
How tweakpane is used currently:
View3d
), and this action just reveals it with CSS.How tweakpane is used after this PR:
refresh
method.dispose
method, rather than just unmounting it in the DOM.I believe the original strategy of rebuilding the tweakpane on data loads was to anticipate when objects were replaced and rebind everything to new objects. But that seems to be pretty rare - it should currently just happen on switching to an entirely new volume (though other, deeper objects we could bind controls to in the future, e.g.
Channel
orMeshVolume
, may be recreated more frequently and cause confusion). Hopefully a user who knows to open the tweakpane can deal with reopening it when a desync occurs. I'd still be grateful for a bit of extra testing here though. In particular, @toloudis I'm seeing different and better numbers in the heap profiler with this change versus the current state, but I'd be interested in a bit of verification since you did the tests that prompted #143 in the first place.