def __init__(self,
                 scene,
                 smooth=True,
                 flags=None,
                 visible=True,
                 resolution=None,
                 start_loop=True,
                 callback=None,
                 callback_period=None,
                 caption=None,
                 fixed=None,
                 **kwargs):
        """
        Create a window that will display a trimesh.Scene object
        in an OpenGL context via pyglet.

        Parameters
        ---------------
        scene : trimesh.scene.Scene
          Scene with geometry and transforms
        smooth : bool
          If True try to smooth shade things
        flags : dict
          If passed apply keys to self.view:
          ['cull', 'wireframe', etc]
        visible : bool
          Display window or not
        resolution : (2,) int
          Initial resolution of window
        start_loop : bool
          Call pyglet.app.run() at the end of init
        callback : function
          A function which can be called periodically to
          update things in the scene
        callback_period : float
          How often to call the callback, in seconds
        fixed : None or iterable
          List of keys in scene.geometry to skip view
          transform on to keep fixed relative to camera
        kwargs : dict
          Additional arguments to pass, including
          'background' for to set background color
        """
        self.scene = self._scene = scene
        self.callback = callback
        self.callback_period = callback_period
        self.scene._redraw = self._redraw

        # save initial camera transform
        self._initial_camera_transform = scene.camera.transform.copy()

        self.reset_view(flags=flags)
        self.batch = pyglet.graphics.Batch()
        self._smooth = smooth

        # store kwargs
        self.kwargs = kwargs

        # store a vertexlist for an axis marker
        self._axis = None
        # store scene geometry as vertex lists
        self.vertex_list = {}
        # store geometry hashes
        self.vertex_list_hash = {}
        # store geometry rendering mode
        self.vertex_list_mode = {}
        # store meshes that don't rotate relative to viewer
        self.fixed = fixed
        # name : texture
        self.textures = {}

        # if resolution isn't defined set a default value
        if resolution is None:
            resolution = scene.camera.resolution
        else:
            scene.camera.resolution = resolution

        try:
            # try enabling antialiasing
            # if you have a graphics card this will probably work
            conf = gl.Config(sample_buffers=1,
                             samples=4,
                             depth_size=24,
                             double_buffer=True)
            super(SceneViewer, self).__init__(config=conf,
                                              visible=visible,
                                              resizable=True,
                                              width=resolution[0],
                                              height=resolution[1],
                                              caption=caption)
        except pyglet.window.NoSuchConfigException:
            conf = gl.Config(double_buffer=True)
            super(SceneViewer, self).__init__(config=conf,
                                              resizable=True,
                                              visible=visible,
                                              width=resolution[0],
                                              height=resolution[1],
                                              caption=caption)

        # add scene geometry to viewer geometry
        self._update_vertex_list()

        # call after geometry is added
        self.init_gl()
        self.set_size(*resolution)
        self.update_flags()

        # someone has passed a callback to be called periodically
        if self.callback is not None:
            # if no callback period is specified set it to default
            if callback_period is None:
                callback_period = 1.0 / 100.0
            # set up a do-nothing periodic task which will
            # trigger `self.on_draw` every `callback_period`
            # seconds if someone has passed a callback
            pyglet.clock.schedule_interval(lambda x: x,
                                           callback_period)
        if start_loop:
            pyglet.app.run()
def __init__ ( self , scene , smooth = True , flags = None , visible = True , resolution = None , start_loop = True , callback = None , callback_period = None , caption = None , fixed = None , ** kwargs ) : self . scene = self . _scene = scene self . callback = callback self . callback_period = callback_period self . scene . _redraw = self . _redraw self . _initial_camera_transform = scene . camera . transform . copy ( ) self . reset_view ( flags = flags ) self . batch = pyglet . graphics . Batch ( ) self . _smooth = smooth self . kwargs = kwargs self . _axis = None self . vertex_list = { } self . vertex_list_hash = { } self . vertex_list_mode = { } self . fixed = fixed self . textures = { } if resolution is None : resolution = scene . camera . resolution else : scene . camera . resolution = resolution try : conf = gl . Config ( sample_buffers = 1 , samples = 4 , depth_size = 24 , double_buffer = True ) super ( SceneViewer , self ) . __init__ ( config = conf , visible = visible , resizable = True , width = resolution [ 0 ] , height = resolution [ 1 ] , caption = caption ) except pyglet . window . NoSuchConfigException : conf = gl . Config ( double_buffer = True ) super ( SceneViewer , self ) . __init__ ( config = conf , resizable = True , visible = visible , width = resolution [ 0 ] , height = resolution [ 1 ] , caption = caption ) self . _update_vertex_list ( ) self . init_gl ( ) self . set_size ( * resolution ) self . update_flags ( ) if self . callback is not None : if callback_period is None : callback_period = 1.0 / 100.0 pyglet . clock . schedule_interval ( lambda x : x , callback_period ) if start_loop : pyglet . app . run ( )
Create a window that will display a trimesh.Scene object
        in an OpenGL context via pyglet.

        Parameters
        ---------------
        scene : trimesh.scene.Scene
          Scene with geometry and transforms
        smooth : bool
          If True try to smooth shade things
        flags : dict
          If passed apply keys to self.view:
          ['cull', 'wireframe', etc]
        visible : bool
          Display window or not
        resolution : (2,) int
          Initial resolution of window
        start_loop : bool
          Call pyglet.app.run() at the end of init
        callback : function
          A function which can be called periodically to
          update things in the scene
        callback_period : float
          How often to call the callback, in seconds
        fixed : None or iterable
          List of keys in scene.geometry to skip view
          transform on to keep fixed relative to camera
        kwargs : dict
          Additional arguments to pass, including
          'background' for to set background color