Skip to content

Commit

Permalink
Properly define issue limit. Minor comment cleanups.
Browse files Browse the repository at this point in the history
  • Loading branch information
javagl committed Nov 9, 2023
1 parent 70a85b9 commit 4cda006
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 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,7 +105,7 @@ export class GltfValidator implements Validator<Buffer> {
try {
gltfResult = await validator.validateBytes(inputWithoutPadding, {
uri: uri,
maxIssues: 1000,
maxIssues: GltfValidator.MAX_ISSUES,
externalResourceFunction: (gltfUri: string) => {
const resolvedDataPromise = resourceResolver.resolveData(gltfUri);
return resolvedDataPromise.then((resolvedData: any) => {
Expand Down Expand Up @@ -169,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 4cda006

Please sign in to comment.