.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_gallery/validation/validate_normals_sides.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_normals_sides.py: Normals on front and back ========================= This example validates that normals are handled such that both the front and back faces are lit. Further it validates the appearance of the normal lines material. This shows a flattened cylinder, with normal lines sticking out both at the front and back faces. .. GENERATED FROM PYTHON SOURCE LINES 12-52 .. image-sg:: /_gallery/validation/images/sphx_glr_validate_normals_sides_001.webp :alt: validate normals sides :srcset: /_gallery/validation/images/sphx_glr_validate_normals_sides_001.webp :class: sphx-glr-single-img .. code-block:: Python from rendercanvas.auto import RenderCanvas, loop import pygfx as gfx import pylinalg as la renderer = gfx.WgpuRenderer(RenderCanvas()) scene = gfx.Scene() geo = gfx.cylinder_geometry(radial_segments=16, height_segments=3, open_ended=True) ob1 = gfx.Mesh( geo, gfx.MeshPhongMaterial(color="#f00"), ) ob2 = gfx.Mesh( geo, gfx.MeshNormalLinesMaterial(color="#0f0", line_length=0.4), ) ob3 = gfx.Mesh( geo, gfx.MeshNormalLinesMaterial(color="#00f", line_length=-0.2), ) ob1.local.position = (1, 0, 0) ob1.local.rotation = la.quat_from_axis_angle((0, 1, 0), 1) ob1.local.scale = (3, 1, 1) scene.add(ob1.add(ob2, ob3)) scene.add(gfx.DirectionalLight(), gfx.AmbientLight()) camera = gfx.PerspectiveCamera(70, 1, depth_range=(0.1, 2000)) camera.local.z = 4.5 renderer.request_draw(lambda: renderer.render(scene, camera)) if __name__ == "__main__": print(__doc__) loop.run() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.261 seconds) .. _sphx_glr_download__gallery_validation_validate_normals_sides.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: validate_normals_sides.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: validate_normals_sides.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: validate_normals_sides.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