mmatl / pyrender

Easy-to-use glTF 2.0-compliant OpenGL renderer for visualization of 3D scenes.
http://pyrender.readthedocs.io/
MIT License
1.31k stars 225 forks source link

Ability to disable auto-start #213

Closed bakwc closed 2 years ago

bakwc commented 2 years ago

Ability to disable auto-start, workaround for running rendering in a custom thread: #27, #11

bakwc commented 2 years ago

It's impossible to take lock in a custom thread without this fix. Now I can do:

viewer = None

def my_thread():
    global viewer
    while True:
        if viewer is None:
            time.sleep(0.1)
            continue

        viewer.render_lock.acquire()

        // MyCode

        scene.set_pose(points_node, obj_pos)

        viewer.render_lock.release()

        time.sleep(0.05)

def createRunViewer():
    global viewer
    viewer = Viewer(scene, auto_start=False, viewport_size=(1200, 1200))
    viewer.start()

thr = threading.Thread(target=my_thread)
thr.start()

createRunViewer()