use crate::{Document, Material};
pub struct Variant<'a> {
#[allow(dead_code)]
document: &'a Document,
#[allow(dead_code)]
index: usize,
json: &'a json::extensions::scene::khr_materials_variants::Variant,
}
impl<'a> Variant<'a> {
pub(crate) fn new(
document: &'a Document,
index: usize,
json: &'a json::extensions::scene::khr_materials_variants::Variant,
) -> Self {
Self {
document,
index,
json,
}
}
pub fn name(&self) -> &'a str {
&self.json.name
}
}
pub struct Mapping<'a> {
document: &'a Document,
json: &'a json::extensions::mesh::Mapping,
}
impl<'a> Mapping<'a> {
pub(crate) fn new(document: &'a Document, json: &'a json::extensions::mesh::Mapping) -> Self {
Self { document, json }
}
pub fn variants(&self) -> &'a [u32] {
&self.json.variants
}
pub fn material(&self) -> Material<'a> {
self.document
.materials()
.nth(self.json.material as usize)
.unwrap_or_else(|| Material::default(self.document))
}
}