.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_gallery/feature_demo/sheen_chair.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_sheen_chair.py: Sheen Chair =========== This example demonstrates the sheen effect in a glTF model. .. GENERATED FROM PYTHON SOURCE LINES 7-64 .. image-sg:: /_gallery/feature_demo/images/sphx_glr_sheen_chair_001.webp :alt: sheen chair :srcset: /_gallery/feature_demo/images/sphx_glr_sheen_chair_001.webp :class: sphx-glr-single-img .. code-block:: Python import imageio.v3 as iio from rendercanvas.auto import RenderCanvas, loop import pygfx as gfx # Init canvas = RenderCanvas(size=(1280, 720), title="Sheen Chair") renderer = gfx.renderers.WgpuRenderer(canvas) scene = gfx.Scene() directional_light = gfx.DirectionalLight(intensity=2.5) directional_light.local.position = (0.5, 0, 0.866) scene.add(directional_light) # Read cube image and turn it into a 3D image (a 4d array) env_img = iio.imread("imageio:meadow_cube.jpg") cube_size = env_img.shape[1] env_img.shape = 6, cube_size, cube_size, env_img.shape[-1] # Create environment map env_tex = gfx.Texture( env_img, dim=2, size=(cube_size, cube_size, 6), generate_mipmaps=True ) gltf_path = "https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Assets/main/Models/SheenChair/glTF-Binary/SheenChair.glb" gltf = gfx.load_gltf(gltf_path, quiet=True) # gfx.print_scene_graph(gltf.scene) # Uncomment to see the tree structure scene.add(gltf.scene) def add_env_map(obj): if isinstance(obj, gfx.Mesh) and isinstance(obj.material, gfx.MeshStandardMaterial): obj.material.env_map = env_tex obj.material.env_map_intensity = 0.5 gltf.scene.traverse(add_env_map) scene.add(gfx.AmbientLight(intensity=0.1)) # Create camera and controller camera = gfx.PerspectiveCamera(45, 640 / 480) camera.show_object(gltf.scene, view_dir=(1.8, -0.6, -2.7)) controller = gfx.OrbitController(camera, register_events=renderer) def animate(): renderer.render(scene, camera) canvas.request_draw() if __name__ == "__main__": renderer.request_draw(animate) loop.run() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 2.319 seconds) .. _sphx_glr_download__gallery_feature_demo_sheen_chair.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: sheen_chair.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: sheen_chair.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: sheen_chair.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