Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support changing scene geometries in SceneViewer.callback #362

Merged
merged 1 commit into from
Mar 31, 2019

Conversation

wkentaro
Copy link
Contributor

Below script doesn't work without this change.
I guess there were some regressions because it had worked before.

import numpy as np
import pyglet
import trimesh
import trimesh.viewer


def callback(scene):
    if scene.pause:
        return

    translation = np.random.uniform(0, 1, (3,))
    axis = trimesh.creation.axis()
    axis.apply_translation(translation)
    scene.add_geometry(axis)
    scene.set_camera()


def main():
    scene = trimesh.Scene()
    scene.add_geometry(trimesh.creation.axis())
    window = trimesh.viewer.SceneViewer(
        scene=scene,
        callback=callback,
        callback_period=0.1,
        start_loop=False,
    )
    scene.pause = True
    scene.window = window

    @window.event
    def on_key_press(symbol, modifiers):
        if symbol == pyglet.window.key.Q:
            window.close()
        if symbol == pyglet.window.key.S:
            scene.pause = not scene.pause

    pyglet.app.run()


if __name__ == '__main__':
    main()

@wkentaro
Copy link
Contributor Author

wkentaro commented Mar 30, 2019

It looks like below. scene is updated in the callback.

Screencast 2019-03-30 21:23:37

@coveralls
Copy link

coveralls commented Mar 30, 2019

Coverage Status

Coverage increased (+0.02%) to 84.184% when pulling 3d169d1 on wkentaro:fix_scene_updates into 1b8c387 on mikedh:master.

@mikedh
Copy link
Owner

mikedh commented Mar 31, 2019

Oh, I must have accidentally removed that in a refactor. It's too bad CI would be such a pain to test this. Thanks for the PR!

@mikedh mikedh merged commit f312235 into mikedh:master Mar 31, 2019
@wkentaro wkentaro deleted the fix_scene_updates branch March 31, 2019 01:07
@wkentaro
Copy link
Contributor Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants