Skip to content

glTF file format

Romain Milbert edited this page Nov 10, 2024 · 1 revision

glTF & GLB files are handled using fastgltf.


Meshes from all available formats can be loaded with Raz::MeshFormat::load(). glTF and GLB meshes specifically can be imported using Raz::GltfFormat::load(), which returns both a Mesh and a MeshRenderer.

#include <RaZ/Data/GltfFormat.hpp>

auto [mesh, meshRenderer] = Raz::GltfFormat::load("path/to/mesh.gltf"); // Or Raz::MeshFormat::load(...)

// Adding the Mesh component is purely optional, unless you want to manipulate its data
// If you want to render the mesh, the MeshRenderer is however needed
entity.addComponent<Raz::Mesh>(std::move(mesh));
entity.addComponent<Raz::MeshRenderer>(std::move(meshRenderer));
Clone this wiki locally