Module three_d_asset::io

source ·
Expand description

Contains functionality to load any type of asset runtime as well as parsers for common 3D assets. Also includes functionality to save data which is limited to native.

A typical use-case is to load and deserialize assets:

use three_d_asset::io::*;
use three_d_asset::{Texture2D, Model};

let mut assets = load(&["test_data/test.png", "test_data/cube.obj"]).unwrap();
let texture: Texture2D = assets.deserialize("test.png").unwrap();
let model: Model = assets.deserialize("cube.obj").unwrap();

Or serialize and save assets:

use three_d_asset::io::*;
use three_d_asset::{Texture2D, TextureData};

let texture = Texture2D {
    data: TextureData::RgbaU8(vec![
        [0, 0, 0, 255],
        [255, 0, 0, 255],
        [0, 255, 0, 255],
        [0, 0, 255, 255],
    ]),
    width: 2,
    height: 2,
    ..Default::default()
};
let assets = texture.serialize("test_data/test.png").unwrap();
save(&assets).unwrap();

Structs

Contains raw assets which are usually generated by either the load/load_async functions or the Serialize::serialize function. Can also be constructed manually using the RawAssets::new and RawAssets::insert.

Traits

Implemented for assets that can be deserialized after being loaded (see also load and RawAssets::deserialize).
Implemented for assets that can be serialized before being saved (see also save).

Functions

Loads all of the resources in the given paths and returns the RawAssets resources.
Loads and deserialize a single file. If the file depends on other files, those files are also loaded.
Async loads and deserialize a single file. If the file depends on other files, those files are also loaded.
Async loads all of the resources in the given paths and returns the RawAssets resources.
Save the assets as files.
Save and serialize a single file.