From 18b28564196303129760fcc867511c0827f0e1e7 Mon Sep 17 00:00:00 2001 From: Marco Hutter Date: Sat, 15 Feb 2025 15:39:39 +0100 Subject: [PATCH 1/5] Update for async API in tools --- src/main.ts | 4 ++-- src/validation/TilesetPackageValidator.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main.ts b/src/main.ts index 9748ed60..de5afd9b 100644 --- a/src/main.ts +++ b/src/main.ts @@ -116,7 +116,7 @@ async function main() { if (argv.optionsFile) { config.options = await readOptionsFile(argv.optionsFile); } - ValidatorMain.performValidation(args, config); + await ValidatorMain.performValidation(args, config); } -main(); +void main(); diff --git a/src/validation/TilesetPackageValidator.ts b/src/validation/TilesetPackageValidator.ts index 0c1d1fc0..dc088947 100644 --- a/src/validation/TilesetPackageValidator.ts +++ b/src/validation/TilesetPackageValidator.ts @@ -150,14 +150,14 @@ export class TilesetPackageValidator implements Validator { context.addIssue(issue); return true; } - tilesetSource.open(uri); + await tilesetSource.open(uri); const result = await TilesetPackageValidator.validatePackageInternal( uri, tilesetSource, isContent, context ); - tilesetSource.close(); + await tilesetSource.close(); return result; } From b4ae5c78a330fb70c8fa3811931d37e8f8c85c5a Mon Sep 17 00:00:00 2001 From: Marco Hutter Date: Sat, 15 Feb 2025 15:40:11 +0100 Subject: [PATCH 2/5] Update for subtree URI API change --- src/validation/TilesetTraversingValidator.ts | 38 +++++++++++--------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/src/validation/TilesetTraversingValidator.ts b/src/validation/TilesetTraversingValidator.ts index d6c60caa..c8cbc3a8 100644 --- a/src/validation/TilesetTraversingValidator.ts +++ b/src/validation/TilesetTraversingValidator.ts @@ -1,5 +1,6 @@ import path from "path"; import { defined } from "3d-tiles-tools"; +import { ImplicitTilings } from "3d-tiles-tools"; import { ExplicitTraversedTile } from "3d-tiles-tools"; import { ValidationContext } from "./ValidationContext"; @@ -157,7 +158,6 @@ export class TilesetTraversingValidator { // should cause the validation to fail with which message. // Maybe some of these validation steps should be pulled // out of "validateTile", or enabled/disabled via flags. - if (traversedTile instanceof ExplicitTraversedTile) { const explicitPartIsValid = await TilesetTraversingValidator.validateExplicitTraversedTile( @@ -237,21 +237,25 @@ export class TilesetTraversingValidator { return false; } - // If the tile is the root of a subtree, then - // validate the subtree data - const subtreeUri = traversedTile.getSubtreeUri(); - if (defined(subtreeUri)) { - const subtreeRootValid = - await TilesetTraversingValidator.validateSubtreeRoot( - path, - implicitTiling, - subtreeUri, - validationState, - context - ); - if (!subtreeRootValid) { - return false; - } + // Validate the subtree data that will be expected + // for the root of the implicit tileset + const rootCoordinates = + ImplicitTilings.createRootCoordinates(implicitTiling); + const subtreeUri = ImplicitTilings.substituteTemplateUri( + implicitTiling.subdivisionScheme, + implicitTiling.subtrees.uri, + rootCoordinates + ); + const subtreeRootValid = + await TilesetTraversingValidator.validateSubtreeRoot( + path, + implicitTiling, + subtreeUri, + validationState, + context + ); + if (!subtreeRootValid) { + return false; } } @@ -355,7 +359,7 @@ export class TilesetTraversingValidator { * resolve the resulting data, and pass it to a `SubtreeValidator`. * * @param tilePath - The path for `ValidationIssue` instances - * @param implicitTiling - The `TileImpllicitTiling` + * @param implicitTiling - The `TileImplicitTiling` * @param subtreeUri - The subtree URI * @param validationState - The `ValidationState` * @param context - The `ValidationContext` From 5bd4965f2d284a1d3005762e13fe48734855f53b Mon Sep 17 00:00:00 2001 From: Marco Hutter Date: Sat, 15 Feb 2025 15:41:45 +0100 Subject: [PATCH 3/5] Fix typo in README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1686f867..47e94657 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,7 @@ npx 3d-tiles-validator --optionsFile exampleOptions.json The options represent the properties of the `ValidationOptions` class. For example, using the following `exampleOptions.json` file, then the validator will only validate the tileset JSON structure, but _no_ tile content data: ```JSON { - "validateContentData": false, + "validateContentData": false } ``` The following options will cause the validator to _include_ B3DM- and GLB files in the validation process, but ignore all other content types: From f9663e0063d7626be0963ff1fb487fcf214a2f91 Mon Sep 17 00:00:00 2001 From: Marco Hutter Date: Sat, 15 Feb 2025 15:49:09 +0100 Subject: [PATCH 4/5] Use INFO instead of WARNING for unhandled content types --- specs/extensions/MaxarContentGeojonValidationSpec.ts | 8 ++++---- src/validation/ContentDataValidators.ts | 8 ++++---- src/validation/Validators.ts | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/specs/extensions/MaxarContentGeojonValidationSpec.ts b/specs/extensions/MaxarContentGeojonValidationSpec.ts index 57ff9eb1..69d19882 100644 --- a/specs/extensions/MaxarContentGeojonValidationSpec.ts +++ b/specs/extensions/MaxarContentGeojonValidationSpec.ts @@ -5,11 +5,11 @@ describe("Tileset MAXAR_content_geojson extension validation", function () { const result = await Validators.validateTilesetFile( "specs/data/extensions/maxarContentGeojson/validTilesetWithGeojson.json" ); - // Expect one warning for skipping the GeoJSON validation + // Expect one info for skipping the GeoJSON validation // and one for the missing declaration of the // MAXAR_content_geojson usage in the extensionsUsed expect(result.length).toEqual(2); - expect(result.get(0).type).toEqual("CONTENT_VALIDATION_WARNING"); + expect(result.get(0).type).toEqual("CONTENT_VALIDATION_INFO"); expect(result.get(1).type).toEqual("EXTENSION_FOUND_BUT_NOT_USED"); }); @@ -17,8 +17,8 @@ describe("Tileset MAXAR_content_geojson extension validation", function () { const result = await Validators.validateTilesetFile( "specs/data/extensions/maxarContentGeojson/validTilesetWithMaxarContentGeojson.json" ); - // Expect one warning for skipping the GeoJSON validation + // Expect one info for skipping the GeoJSON validation expect(result.length).toEqual(1); - expect(result.get(0).type).toEqual("CONTENT_VALIDATION_WARNING"); + expect(result.get(0).type).toEqual("CONTENT_VALIDATION_INFO"); }); }); diff --git a/src/validation/ContentDataValidators.ts b/src/validation/ContentDataValidators.ts index 1330f575..f6e6bde8 100644 --- a/src/validation/ContentDataValidators.ts +++ b/src/validation/ContentDataValidators.ts @@ -82,7 +82,7 @@ export class ContentDataValidators { // Certain content types are known to be encountered, // but are not (yet) validated. These can either be - // ignored, or cause a warning. In the future, this + // ignored, or cause an info. In the future, this // should be configurable, probably even on a per-type // basis, via the command line or a config file const ignoreUnhandledContentTypes = false; @@ -90,13 +90,13 @@ export class ContentDataValidators { let vctrValidator = Validators.createEmptyValidator(); let geojsonValidator = Validators.createEmptyValidator(); if (!ignoreUnhandledContentTypes) { - geomValidator = Validators.createContentValidationWarning( + geomValidator = Validators.createContentValidationInfo( "Skipping 'geom' validation" ); - vctrValidator = Validators.createContentValidationWarning( + vctrValidator = Validators.createContentValidationInfo( "Skipping 'vctr' validation" ); - geojsonValidator = Validators.createContentValidationWarning( + geojsonValidator = Validators.createContentValidationInfo( "Skipping 'geojson' validation" ); } diff --git a/src/validation/Validators.ts b/src/validation/Validators.ts index da087c85..468c1b73 100644 --- a/src/validation/Validators.ts +++ b/src/validation/Validators.ts @@ -393,18 +393,18 @@ export class Validators { } /** - * Creates a `Validator` that only adds a `CONTENT_VALIDATION_WARNING` + * Creates a `Validator` that only adds a `CONTENT_VALIDATION_INFO` * with the given message to the given context when it is called. * * This is used for "dummy" validators that handle content data types * that are already anticipated (like VCTR or GEOM), but not validated * explicitly. * - * @param message - The message for the warning + * @param message - The message for the info * @returns The new validator * @internal */ - static createContentValidationWarning(message: string): Validator { + static createContentValidationInfo(message: string): Validator { return { async validateObject( inputPath: string, @@ -412,7 +412,7 @@ export class Validators { input: Buffer, context: ValidationContext ): Promise { - const issue = ContentValidationIssues.CONTENT_VALIDATION_WARNING( + const issue = ContentValidationIssues.CONTENT_VALIDATION_INFO( inputPath, message ); From 561f1c2c5130df4ea4203a4503241bd5dc6dd289 Mon Sep 17 00:00:00 2001 From: Marco Hutter Date: Mon, 17 Feb 2025 20:27:25 +0100 Subject: [PATCH 5/5] Update 3D Tiles Tools version to 0.5.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d5aee43c..6abd541e 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "@gltf-transform/core": "^3.2.1", "@gltf-transform/extensions": "^3.2.1", "@gltf-transform/functions": "^3.2.1", - "3d-tiles-tools": "0.4.4", + "3d-tiles-tools": "0.5.0", "cesium": "^1.97.0", "gltf-validator": "^2.0.0-dev.3.9", "minimatch": "^5.1.0",