When is the
requestData() function called in representations?
As I’m currently using:
this.planeWidget.getWidgetState().setSlices(slices) to set an array of 3 values in my widget state to the desired values. But after that I’m not getting any calls to my corresponding vtkRepresentation:requestData(). I feel this has to do with no no re-render is being triggered?
When I spam
this.planeWidget.getWidgetState().setSlices(slices) it does update sometimes
Does anyone know why this happens?
Triggering a render will call
requestData(), whether that be manually calling
render() or triggering some animation event (e.g. mouse movement over the scene). Just setting data on the state object won’t trigger renders by itself.
Thank you very much for this insight!
I was confused as this is written on the vtk-js website:
Representations are automatically recomputed when sub-states are modified. They are implemented as VTK.js filters since all the rendering computations happen in the
requestData(inData, outData) method where
inData is the list of states coming from sub-states and
outData is a
vtkPolyData representing the geometry to render.
Is there a difference then in setting data on a state object and/or setting a sub-state?
I think that documentation wording needs adjustment. It’s true that representations are recomputed, but only when a render is needed and the input data (in this case, the widget states) has been updated.
So if I understand it correctly, it’s important to have this render AND updated widgetState?
Is there a way to have automatic re-renders? I read a bit on
requestAnimation(publicAPI) but not sure what this does?
Or is it better to just manually render the views using the
You can certainly run renders when widget state updates, i.e.
widgetState.onModified(() => renderWindow.render()). The purpose of the separation is to provide more control over when you choose to render.