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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/// Controls how recoverable VRM semantic violations are handled.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum ValidationMode {
/// Reject every supported VRM specification violation.
#[default]
Strict,
/// Keep loading when a violation cannot make the resulting asset unsafe.
Permissive,
}
/// Options shared by file and in-memory loading.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub struct LoadOptions {
/// Controls whether recoverable conformance violations are rejected or reported.
pub validation: ValidationMode,
}
/// Feature support exposed by this crate version.
///
/// Applications can use this value to decide whether to reject a model,
/// offer a fallback, or route it through another implementation.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Capabilities {
/// Supports VRM 1.0 assets.
pub vrm_1_0: bool,
/// Supports legacy VRM 0.x assets.
pub vrm_0_x: bool,
/// Supports `VRMC_materials_mtoon`.
pub mtoon: bool,
/// Supports `VRMC_node_constraint`.
pub node_constraints: bool,
/// Supports `VRMC_springBone`.
pub spring_bones: bool,
/// Supports standalone `VRMC_vrm_animation` assets.
pub vrma_loading: bool,
/// Supports the archived `VRMC_materials_hdr_emissiveMultiplier` extension.
pub hdr_emissive_multiplier: bool,
/// Supports `VRMC_springBone_extended_collider`.
pub extended_spring_colliders: bool,
/// Supports `KHR_materials_unlit` on VRM materials.
pub unlit_materials: bool,
/// Supports `KHR_materials_emissive_strength` on VRM materials.
pub emissive_strength: bool,
/// Supports per-texture `KHR_texture_transform` UV selection and transforms.
pub texture_transform: bool,
}
impl Capabilities {
/// Returns the feature set implemented by this crate version.
pub const fn current() -> Self {
Self {
vrm_1_0: true,
vrm_0_x: false,
mtoon: true,
node_constraints: true,
spring_bones: true,
vrma_loading: true,
hdr_emissive_multiplier: true,
extended_spring_colliders: true,
unlit_materials: true,
emissive_strength: true,
texture_transform: true,
}
}
}
/// Severity assigned to a loader diagnostic.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum DiagnosticSeverity {
/// A recoverable issue that did not prevent loading.
Warning,
/// An issue severe enough to invalidate the requested operation.
Error,
}
/// A machine-readable problem reported while loading an avatar.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Diagnostic {
/// Severity assigned to the issue.
pub severity: DiagnosticSeverity,
/// Stable machine-readable identifier for the diagnostic kind.
pub code: &'static str,
/// JSON-style path to the value that produced the diagnostic.
pub path: String,
/// Human-readable explanation of the issue.
pub message: String,
}
impl Diagnostic {
pub(crate) fn warning(
code: &'static str,
path: impl Into<String>,
message: impl Into<String>,
) -> Self {
Self {
severity: DiagnosticSeverity::Warning,
code,
path: path.into(),
message: message.into(),
}
}
}