.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_gallery/feature_demo/fly_controller.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr__gallery_feature_demo_fly_controller.py: Fly controller ============== Show the fly controller in action. .. GENERATED FROM PYTHON SOURCE LINES 7-36 .. image-sg:: /_gallery/feature_demo/images/sphx_glr_fly_controller_001.png :alt: fly controller :srcset: /_gallery/feature_demo/images/sphx_glr_fly_controller_001.png :class: sphx-glr-single-img .. code-block:: default from wgpu.gui.auto import WgpuCanvas, run import pygfx as gfx import numpy as np canvas = WgpuCanvas() renderer = gfx.renderers.WgpuRenderer(canvas) scene = gfx.Scene() # Create a bunch of points n = 1000 positions = np.random.normal(0, 0.5, (n, 3)).astype(np.float32) sizes = np.random.rand(n).astype(np.float32) * 50 colors = np.random.rand(n, 4).astype(np.float32) geometry = gfx.Geometry(positions=positions, sizes=sizes, colors=colors) material = gfx.PointsMaterial(color_mode="vertex", vertex_sizes=True) points = gfx.Points(geometry, material) scene.add(points) camera = gfx.PerspectiveCamera(70) camera.show_object(scene) controller = gfx.FlyController(camera, register_events=renderer) if __name__ == "__main__": canvas.request_draw(lambda: renderer.render(scene, camera)) run() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.353 seconds) .. _sphx_glr_download__gallery_feature_demo_fly_controller.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: fly_controller.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: fly_controller.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_