Updating options dynamically?

Hi, first time posting here. I’m working on a panel plugin where the data is displayed in a 3d (webgl) scene. I’m facing a situation where I would like to save some settings from the panel back to the panel settings.

A simple example use case; when I load in a 3d scene where the data will be visualised in, I would like to move the 3d view (camera) to a position in the scene that displays the data nicely. When the camera is in a place I like, I can read the position from the scene but now I’d like to save this somewhere that can be loaded in when the dashboard/panel is opened up later. My initial thought was to add a text input setting using the PanelOptionsEditorBuilder and saving the value there, but so far I’ve been unable to find a way to update it from “outside”.

So basically if I add a text input using the builder something like this

  path: 'cameraPosition',
  name: 'Default camera position',
  defaultValue: "0,0,0"

Is there a way to update the option value of ‘cameraPosition’ from the plugin itself?

Let me know if the explanation is unclear and I’ll try and elaborate more.

Been wanting to experiment with WebGL for panel plugin. Fingers crossed you’ll make it public one day :slight_smile:

If I understand your question correctly, you’d like to update a panel option from within the panel itself?

In your panel, you have access to the onOptionsChange from the panel props. You should be able to use it to update the panel options.

Here’s an example on how to do this:

Aha I don’t think this will be public. Been mostly just experimenting and doing a poc for a colleague :slight_smile:

Yeah exactly, you put it better than I could. Seems like I was already really close, somehow I guess I was expecting the update to propagate immediately to the corresponding fields when in edit mode so I didn’t test it properly. But managed to get it working exactly as I wanted thanks to that.

Thanks for your help :slight_smile:

1 Like