jupyter-widgets / pythreejs

A Jupyter - Three.js bridge
https://pythreejs.readthedocs.io
Other
934 stars 185 forks source link

Autoresize Renderer #362

Open akaszynski opened 2 years ago

akaszynski commented 2 years ago

First off, I'd like to thank the developers of this project. I've been able to make great strides plotting within jupyterlab and extending pyvista through pythreejs.

Is there any way to automatically resize the Renderer widget? This has been implemented in GanyJS: https://github.com/QuantStack/GanyJS/blob/08deb4b9689ebf03e5b09985feb6677fe25858d8/src/Scene.ts#L126-L138

I'm having issues building this locally in a "development version" (see #361). Would this be that hard to implement on your end? Otherwise, I'd like to contribute.

6A61736F6E206E61646572 commented 2 years ago

@akaszynski Did you manage to get the local build working?

vidartf commented 2 years ago

This should be possible to do, yes. You would need to listen for the lumino resize event (e.g. like this), and then trigger the auto-resize function. After measuring the dimensions, you would set the _height and _width traits on the renderer model from the JS side. I would probably recommend putting this behind a autoresize trait that controls whether this feature is active or not.

vidartf commented 2 years ago

Would this be that hard to implement on your end?

It isn't technically hard, but it is hard to put the time in for it.

akaszynski commented 2 years ago

@akaszynski Did you manage to get the local build working?

Eventually, yes.