Skip to content

Commit

Permalink
Added validation issues in case file does not contain VRM extensions …
Browse files Browse the repository at this point in the history
…at all
  • Loading branch information
mrxz committed Nov 7, 2024
1 parent add5d45 commit fcd5a0f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/src/base/gltf.dart
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,15 @@ class Gltf extends GltfProperty {

context.initExtensions(extensionsUsed, extensionsRequired);

// Verify that the file IS a VRM file.
if (!extensionsUsed.contains('VRMC_vrm')) {
if (extensionsUsed.contains('VRM')) {
context.addIssue(SemanticError.vrm0Extension, name: EXTENSIONS_USED);
} else {
context.addIssue(SemanticError.vrm1MissingVrmExtension, name: EXTENSIONS_USED);
}
}

// Helper function for converting JSON array to List of proper glTF objects
SafeList<T> toSafeList<T>(String name, FromMapFunction<T> fromMap) {
if (!map.containsKey(name)) {
Expand Down
12 changes: 12 additions & 0 deletions lib/src/errors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,18 @@ class SemanticError extends IssueType {
Severity.Information);

// VRM specific semantic errors
static final SemanticError vrm0Extension = SemanticError._(
'VRM0_VRM_EXTENSION',
(args) =>
'VRM 0.0 extensions are not validated',
Severity.Warning);

static final SemanticError vrm1MissingVrmExtension = SemanticError._(
'VRM1_NO_VRM_EXTENSION',
(args) =>
'The VRMC_vrm extension is missing; this file is NOT a .vrm file.',
Severity.Error);

static final SemanticError vrm1TextureTransformRotation = SemanticError._(
'VRM1_TEXTURE_TRANSFORM_ROTATION',
(args) =>
Expand Down

0 comments on commit fcd5a0f

Please sign in to comment.