jupyter-widgets / pythreejs

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

return from exec_three_obj_method #193

Closed tingelst closed 6 years ago

tingelst commented 6 years ago

How can I capture the return value when calling exec_three_obj_method?

vidartf commented 6 years ago

There is currently not an official API for this (suggestions / PR welcome). As a workaround / hack, you can override the class / instance method def _on_ret_val(self, method_name, ret_val): .... Note that this gets called asynchronously (i.e. possibly after the cell has finished executing), so you need to be mindful of this!

tingelst commented 6 years ago

Thank you! Is this the reason why matrixWorld isn't updated directly when calling exec_three_obj_method('updateMatrixWorld') in the same cell?

vidartf commented 6 years ago

Yes, all syncs / updates are asynchronous. If you set up an traitlets change notification on the matrixWorld property, you should be notified when it changes.

tingelst commented 6 years ago

Takk!