1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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))
}
}