Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tools to 0.5.0 #332

Merged
merged 5 commits into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 4 additions & 4 deletions specs/extensions/MaxarContentGeojonValidationSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ 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");
});

it("detects issues in validTilesetWithMaxarContentGeojson", async 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");
});
});
4 changes: 2 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
8 changes: 4 additions & 4 deletions src/validation/ContentDataValidators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,21 +82,21 @@ 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;
let geomValidator = Validators.createEmptyValidator();
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"
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/validation/TilesetPackageValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,14 @@ export class TilesetPackageValidator implements Validator<string> {
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;
}

Expand Down
38 changes: 21 additions & 17 deletions src/validation/TilesetTraversingValidator.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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`
Expand Down
8 changes: 4 additions & 4 deletions src/validation/Validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -393,26 +393,26 @@ 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<Buffer> {
static createContentValidationInfo(message: string): Validator<Buffer> {
return {
async validateObject(
inputPath: string,
//eslint-disable-next-line @typescript-eslint/no-unused-vars
input: Buffer,
context: ValidationContext
): Promise<boolean> {
const issue = ContentValidationIssues.CONTENT_VALIDATION_WARNING(
const issue = ContentValidationIssues.CONTENT_VALIDATION_INFO(
inputPath,
message
);
Expand Down