.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_gallery/other/load_open3d_mesh.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_other_load_open3d_mesh.py: Load Open3D Mesh ================ Demonstrates loading mesh models from open3d. .. GENERATED FROM PYTHON SOURCE LINES 9-16 .. warning:: An external model is needed to run this example. To run this example, you need a model from the source repo's example folder. If you are running this example from a local copy of the code (dev install) no further actions are needed. Otherwise, you may have to replace the path below to point to the location of the model. .. GENERATED FROM PYTHON SOURCE LINES 16-36 .. code-block:: Python import os from pathlib import Path from importlib.util import find_spec if not find_spec("open3d"): raise ImportError( "The `open3d` library is required for this example: pip install open3d" ) import open3d.visualization from open3d.cpu.pybind.visualization.rendering import TriangleMeshModel try: # modify this line if your model is located elsewhere model_dir = Path(__file__).parents[1] / "data" except NameError: # compatibility with sphinx-gallery model_dir = Path(os.getcwd()).parent / "data" .. GENERATED FROM PYTHON SOURCE LINES 37-38 Once the path is set correctly, you can use the model as follows: .. GENERATED FROM PYTHON SOURCE LINES 38-80 .. code-block:: Python from open3d import io import pygfx as gfx # load helmet model with open3d helmet: TriangleMeshModel = io.read_triangle_model( str(model_dir / "DamagedHelmet/glTF/DamagedHelmet.gltf") ) # extract helmet infos helmet_mesh_info: TriangleMeshModel.MeshInfo = helmet.meshes[0] helmet_mesh: open3d.geometry.TriangleMesh = helmet_mesh_info.mesh helmet_material: open3d.visualization.Material = helmet.materials[ helmet_mesh_info.material_idx ] material = gfx.materials.material_from_open3d(helmet_material) # create scene scene = gfx.Scene() scene.add(gfx.AmbientLight(), gfx.DirectionalLight()) # construct helmet mesh object mesh = gfx.Mesh( gfx.geometries.geometry_from_open3d(helmet_mesh), material, ) # or use alternative helper method for simplified TriangleMeshModel loading mesh2 = gfx.Group() for m in gfx.utils.load.meshes_from_open3d(helmet): mesh2.add(m) mesh2.world.position = (2, 0, 0) scene.add(mesh) scene.add(mesh2) if __name__ == "__main__": disp = gfx.Display() disp.show(scene, up=(0, 1, 0)) .. _sphx_glr_download__gallery_other_load_open3d_mesh.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: load_open3d_mesh.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: load_open3d_mesh.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: load_open3d_mesh.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