.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/04_demos/viz_billboard_spheres.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_auto_examples_04_demos_viz_billboard_spheres.py: ============================= Billboard vs Geometry Spheres ============================= This example demonstrates the difference between billboard-based sphere impostors and traditional geometry-based spheres. Billboard spheres are rendered as textured quads that always face the camera, making them more efficient for rendering many spheres at a distance. .. GENERATED FROM PYTHON SOURCE LINES 12-17 .. code-block:: Python import numpy as np from fury import actor, window .. GENERATED FROM PYTHON SOURCE LINES 18-19 Create sphere data with positions, colors, and radii. .. GENERATED FROM PYTHON SOURCE LINES 19-24 .. code-block:: Python centers = np.array([[0, 0, 0], [2, 0, 2], [-1, 0, 0]]) colors = np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1]]) radii = np.array([1.2, 1, 1]) .. GENERATED FROM PYTHON SOURCE LINES 25-27 Create billboard spheres (shader-based impostors). These are rendered as textured quads that face the camera. .. GENERATED FROM PYTHON SOURCE LINES 27-32 .. code-block:: Python billboard_spheres = actor.sphere( centers=centers, colors=colors, radii=radii, opacity=1, impostor=True ) .. GENERATED FROM PYTHON SOURCE LINES 33-35 Create geometry-based spheres (traditional mesh). These are actual 3D mesh spheres with vertices and faces. .. GENERATED FROM PYTHON SOURCE LINES 35-44 .. code-block:: Python geometry_spheres = actor.sphere( centers=centers + np.array([[0, -2, 0]]), colors=colors, radii=radii, opacity=1, impostor=False, ) .. GENERATED FROM PYTHON SOURCE LINES 45-46 Create descriptive text labels to identify each type. .. GENERATED FROM PYTHON SOURCE LINES 46-61 .. code-block:: Python billboard_text = actor.text( "Billboard Spheres (Shader-based)", position=[-5, 0, 0], colors=(1, 1, 1), anchor="middle-right", ) geometry_text = actor.text( "Geometry Spheres (Mesh-based)", position=[-5, -4, 0], colors=(1, 1, 1), anchor="middle-right", ) .. GENERATED FROM PYTHON SOURCE LINES 62-63 Add ground planes for visual reference. .. GENERATED FROM PYTHON SOURCE LINES 63-72 .. code-block:: Python ground_top = actor.box( centers=np.array([[0, 0, 0]]), colors=(0.5, 0.5, 0.5), scales=(7, 0.1, 7) ) ground_bottom = actor.box( centers=np.array([[0, -2, 0]]), colors=(0.5, 0.5, 0.5), scales=(7, 0.1, 7) ) .. GENERATED FROM PYTHON SOURCE LINES 73-74 Create scene and add all actors. .. GENERATED FROM PYTHON SOURCE LINES 74-85 .. code-block:: Python scene = window.Scene() scene.background = (0.1, 0.1, 0.15) scene.add(billboard_spheres) scene.add(geometry_spheres) scene.add(billboard_text) scene.add(geometry_text) scene.add(ground_top) scene.add(ground_bottom) .. GENERATED FROM PYTHON SOURCE LINES 86-87 Create and start the ShowManager. .. GENERATED FROM PYTHON SOURCE LINES 87-92 .. code-block:: Python show_m = window.ShowManager( scene=scene, size=(800, 600), title="Billboard vs Geometry Spheres" ) show_m.start() .. image-sg:: /auto_examples/04_demos/images/sphx_glr_viz_billboard_spheres_001.png :alt: viz billboard spheres :srcset: /auto_examples/04_demos/images/sphx_glr_viz_billboard_spheres_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.196 seconds) .. _sphx_glr_download_auto_examples_04_demos_viz_billboard_spheres.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: viz_billboard_spheres.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: viz_billboard_spheres.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: viz_billboard_spheres.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_