.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_gallery/validation/validate_volume_ray_cam_sign.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_validation_validate_volume_ray_cam_sign.py: Volume Axis-Aligned, Rotated Camera ===================================== Render a MIP volume with the camera oriented such that the view matrix has zeros on its diagonal. You should see: * A 3x3 grid of voxels with a smooth gradient from dark (bottom-left) to bright (top-right). .. GENERATED FROM PYTHON SOURCE LINES 11-51 .. image-sg:: /_gallery/validation/images/sphx_glr_validate_volume_ray_cam_sign_001.webp :alt: validate volume ray cam sign :srcset: /_gallery/validation/images/sphx_glr_validate_volume_ray_cam_sign_001.webp :class: sphx-glr-single-img .. code-block:: Python import numpy as np from rendercanvas.auto import RenderCanvas, loop import pygfx as gfx canvas = RenderCanvas() renderer = gfx.renderers.WgpuRenderer(canvas) data = np.arange(27, dtype=np.uint16).reshape(3, 3, 3) scene = gfx.Scene() vol = gfx.Volume( gfx.Geometry(grid=gfx.Texture(data, dim=3)), gfx.VolumeMipMaterial( clim=(float(data.min()), float(data.max())), interpolation="nearest" ), ) scene.add(vol) camera = gfx.PerspectiveCamera(fov=70, depth_range=(1, 1_000_000)) camera.world.matrix = np.array( [ [0, 0, 1, 10], [1, 0, 0, 1], [0, 1, 0, 1], [0, 0, 0, 1], ], dtype=float, ) def animate(): renderer.render(scene, camera) canvas.request_draw(animate) if __name__ == "__main__": loop.run() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.347 seconds) .. _sphx_glr_download__gallery_validation_validate_volume_ray_cam_sign.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: validate_volume_ray_cam_sign.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: validate_volume_ray_cam_sign.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: validate_volume_ray_cam_sign.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_