Function rend3_gltf::load_gltf
source · [−]pub async fn load_gltf<F, Fut, E>(
renderer: &Renderer,
data: &[u8],
settings: &GltfLoadSettings,
io_func: F
) -> Result<(LoadedGltfScene, GltfSceneInstance), GltfLoadError<E>> where
F: FnMut(SsoString) -> Fut,
Fut: Future<Output = Result<Vec<u8>, E>>,
E: Error + 'static,
Expand description
Load a given gltf into the renderer’s world.
Allows the user to specify how URIs are resolved into their underlying data. Supports most gltfs and glbs.
Must keep the LoadedGltfScene
alive for the scene to remain.
See load_gltf_data
and instance_loaded_scene
if you need more
fine-grained control about how and when the scene data is instanced.
let path = Path::new("some/path/scene.gltf"); // or glb
let gltf_data = std::fs::read(&path).unwrap();
let parent_directory = path.parent().unwrap();
let _loaded = pollster::block_on(rend3_gltf::load_gltf(
&renderer,
&gltf_data,
&rend3_gltf::GltfLoadSettings::default(),
|p| rend3_gltf::filesystem_io_func(&parent_directory, p)
));