Skip to content

Commit

Permalink
Merge pull request #291 from CesiumGS/limit-gltf-issues
Browse files Browse the repository at this point in the history
Limit number of glTF validation issues
  • Loading branch information
lilleyse committed Nov 9, 2023
2 parents d8e350b + 3c9a737 commit 5656f67
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@

Version ?.?.? - yyyy-mm-dd

- The maximum number of issues that are reported for a single glTF asset is now limited (via [#291](https://github.com/CesiumGS/3d-tiles-validator/pull/291)).

Version 0.5.0 - 2023-10-24

- Added validation of glTF extensions via [#280](https://github.com/CesiumGS/3d-tiles-validator/pull/280) and [#284](https://github.com/CesiumGS/3d-tiles-validator/pull/284). In addition to the basic validation of glTF tile content that is performed with the glTF validator, the 3D Tiles Validator now checks the validity of certain glTF extensions:
Expand Down
14 changes: 12 additions & 2 deletions src/tileFormats/GltfValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ const validator = require("gltf-validator");
* @internal
*/
export class GltfValidator implements Validator<Buffer> {
/**
* The maximum number of issues that should be reported by
* the glTF validator. For large glTF assets that contain
* "completely invalid" data, a large number of issues
* can cause out-of-memory errors.
* See https://github.com/CesiumGS/3d-tiles-validator/issues/290
*/
private static readonly MAX_ISSUES = 1000;

/**
* Creates a `ValidationIssue` object for the given 'message' object
* that appears in the output of the glTF validator.
Expand Down Expand Up @@ -96,6 +105,7 @@ export class GltfValidator implements Validator<Buffer> {
try {
gltfResult = await validator.validateBytes(inputWithoutPadding, {
uri: uri,
maxIssues: GltfValidator.MAX_ISSUES,
externalResourceFunction: (gltfUri: string) => {
const resolvedDataPromise = resourceResolver.resolveData(gltfUri);
return resolvedDataPromise.then((resolvedData: any) => {
Expand Down Expand Up @@ -168,15 +178,15 @@ export class GltfValidator implements Validator<Buffer> {
);

for (const gltfMessage of gltfResult.issues.messages) {
//console.log(gltfMessage);
const cause =
GltfValidator.createValidationIssueFromGltfMessage(gltfMessage);
issue.addCause(cause);
}
context.addIssue(issue);
}

// XXX TODO Find a sensible place to hook in glTF extension validators
// When the glTF itself is considered to be valid, then perform
// the validation of the Cesium glTF metadata extensions
const extensionsValid =
await GltfExtensionValidators.validateGltfExtensions(uri, input, context);
if (!extensionsValid) {
Expand Down

0 comments on commit 5656f67

Please sign in to comment.