Viewer.on

Viewer.on(interval, timeout=None, frames=None)[source]

Decorator for callbacks of a dynamic drawing process.

Parameters:
intervalint

Interval between subsequent calls to this function, in milliseconds.

timeoutint, optional

Timeout between subsequent calls to this function, in milliseconds.

framesint, optional

The number of frames of the process. If no frame number is provided, the process continues until the viewer is closed.

Returns:
Callable

Notes

The difference between interval and timeout is that the former indicates the time between subsequent calls to the callback, without taking into account the duration of the execution of the call, whereas the latter indicates a pause after the completed execution of the previous call, before starting the next one.

Examples

angle = math.radians(5)

@viewer.on(interval=1000)
def rotate(frame):
    obj.rotation = [0, 0, frame * angle]
    obj.update()