.. 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 ============== Fly through a cloud of cololoured points. This example demonstrates the fly controller, as well as the GaussianBlob point material, with size_space set to 'world'. Tip: try using different values for alpha_mode. .. GENERATED FROM PYTHON SOURCE LINES 11-62 .. image-sg:: /_gallery/feature_demo/images/sphx_glr_fly_controller_001.webp :alt: fly controller :srcset: /_gallery/feature_demo/images/sphx_glr_fly_controller_001.webp :class: sphx-glr-single-img .. code-block:: Python from rendercanvas.auto import RenderCanvas, loop import pygfx as gfx import numpy as np canvas = RenderCanvas() renderer = gfx.renderers.WgpuRenderer(canvas) scene = gfx.Scene() scene.add(gfx.Background.from_color("#000")) grid = gfx.Grid( None, gfx.GridMaterial( major_step=100, minor_step=10, thickness_space="world", major_thickness=2, minor_thickness=0.1, infinite=True, ), orientation="xz", ) grid.local.y = -120 scene.add(grid) # Create a bunch of points n = 1000 positions = np.random.normal(0, 50, (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.PointsGaussianBlobMaterial( color_mode="vertex", size_mode="vertex", size_space="world", alpha_mode="dither", ) 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)) loop.run() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.602 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-jupyter :download:`Download Jupyter notebook: fly_controller.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: fly_controller.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: fly_controller.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_ .. only:: html Interactive example ------------------- Try this example in your browser using Pyodide. Might not work with all examples and all devices. Check the output and your browser's console for details. .. raw:: html