nglviewer / ngl

WebGL protein viewer
http://nglviewer.org/ngl/
MIT License
669 stars 170 forks source link

Subscription to render completion #945

Closed StLeonidas closed 2 years ago

StLeonidas commented 2 years ago

Thanks a lot for great tool! Could you advise if there is a way to subscribe event responsible for rendering completion?

fredludlow commented 2 years ago

NGL mostly uses the signals library internally.

You can access a ticked (fired before rendering) and a rendered (after rendering) signal via stage.viewer.signals.ticked or stage.viewer.signals.rendered,

If you want to dig in the code it's around here, rendered signal is fired at the bottom of the render method: https://github.com/nglviewer/ngl/blob/138fa2cbe469bf9277d8d42cde2977976e14a1cc/src/viewer/viewer.ts#L999-L1014

So, something like stage.viewer.signals.rendered.add(yourCallback) ought to fire after each render.

StLeonidas commented 2 years ago

Thanks a lot!