.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_gallery/feature_demo/world_bounding_box.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_world_bounding_box.py: Bounding Box Coordinates ======================== Render two volumes using different world transforms. Prints the world bounding box of the scene which used to trigger an Exception. .. GENERATED FROM PYTHON SOURCE LINES 9-48 .. image-sg:: /_gallery/feature_demo/images/sphx_glr_world_bounding_box_001.webp :alt: world bounding box :srcset: /_gallery/feature_demo/images/sphx_glr_world_bounding_box_001.webp :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none World bounding box: [[ -0.5 -0.5 -0.5] [277.5 127.5 255.5]] | .. code-block:: Python import imageio.v3 as iio import numpy as np from rendercanvas.auto import RenderCanvas, loop import pygfx as gfx canvas = RenderCanvas() renderer = gfx.renderers.WgpuRenderer(canvas) scene = gfx.Scene() voldata = iio.imread("imageio:stent.npz").astype(np.float32) geometry = gfx.Geometry(grid=voldata) geometry_with_texture = gfx.Geometry(grid=gfx.Texture(data=voldata, dim=3)) material = gfx.VolumeMipMaterial(clim=(0, 2000)) vol1 = gfx.Volume(geometry, material) vol2 = gfx.Volume(geometry_with_texture, material) scene.add(vol1, vol2) vol2.local.x = 150 camera = gfx.PerspectiveCamera(70, 16 / 9) camera.show_object(scene, view_dir=(-1, -1, -1), up=(0, 0, 1)) controller = gfx.OrbitController(camera, register_events=renderer) print("World bounding box:\n", scene.get_world_bounding_box()) def animate(): renderer.render(scene, camera) canvas.request_draw() if __name__ == "__main__": canvas.request_draw(animate) loop.run() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.842 seconds) .. _sphx_glr_download__gallery_feature_demo_world_bounding_box.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: world_bounding_box.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: world_bounding_box.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: world_bounding_box.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