3D Tiles Validator Implementation Notes
October 24, 2023 ยท View on GitHub
Parts of the current implementation may still change. This page is only a short description of the overall structure.
Directory structure:
./src: The entry point for the command line interface is inmain.ts./src/validation: The core classes for the 3D Tiles validation./src/issues: Classes defining the categories of detected issues./src/tileFormats: Classes for the validation of tile contents./src/archives: Functions that are specific for the validation of 3TZ archives/packages./specs: Jasmine specs./specs/data: Test data
Overview
The classes in the ./src/validation directory are the core classes for the 3D Tiles validation.
The entry point for the tileset validation is the TilesetValidator class. This class is not publicly visible, but it is the main class that is used in the public Validators.validateTilesetFile method. The validation process, as it is implemented in the TilesetValidator, is:
- It receives a tileset JSON string and parses it into a
Tilesetobject from thestructurepackage of the3d-tiles-tools - It traverses the
Tilesetstructure, and performs the validation- For each object type, there is a validator, like
AssetValidator,ContentValidator,TileValidator,BoundingVolumeValidatoretc. For now, these are mainly classes with single static functions, but they might be refined for some objects.
- For each object type, there is a validator, like
Each validation function receives a ValidationContext as the last parameter.
The ValidationContext class:
- Contains a
ValidationOptionsobject that contains configuration options for the validation process (e.g. flags that determine whether tile content should be validated) - Maintains a
ResourceResolverthat reads aBufferfrom a given URI (resolved in the respective context - the tileset, external tileset, or glTF) - Collects the
ValidationIssueinstances (errors and warnings) that are found during the traversal
The ValidationIssue class and its types:
- The
ValidationIssueitself is a plain data structure with basic info about the issue (message, path, severity...) - Instances of this class are created with methods in the
issues*classes, roughly categorized here:IoValidationIssues.ts: Fundamental IO errors, likeJSON_PARSE_ERRORJsonValidationIssues.ts: Violations of the JSON schema, likePROPERTY_MISSINGorARRAY_LENGTH_MISMATCHStructureValidationIssues.ts: General, inconsistent structures, likeIDENTIFIER_NOT_FOUNDSemanticValidationIssues.ts: Inconsistent property values, likeTILE_GEOMETRIC_ERRORS_INCONSISTENTMetadataValidationIssues.ts: Invalid metadata schema and valuesBinaryValidationIssues.ts: Invalid data layouts of binary tile content dataContentValidationIssues.ts: Issues that are found in tile content or external tilesets
- For validation issues that refer to the tile content, each
ValidationIssuecan have an array ofcauses. This can be filled, for example, with the information from the glTF validator that caused the validation to fail
Future Work
Certain functionalities are currently offered via the command line, but only intended for internal use:
Validate a single metadata schema file:
npx ts-node src/main.ts --metadataSchemaFile specs/data/schemas/validSchema.json
Validate a single subtree file:
Note: For the actual validation of standalone subtree files, there has to be a mechanism for passing in the information about the expected structure of the subtree (namely, the information from the implicitTiling object). This example only refers to the files in the specs directory, which all assume the same subtree structure for now.
npx ts-node src/main.ts --subtreeFile specs/data/subtrees/binarySubtreeValid.subtree
Batch runs for the spec files
The specs/data directory contains sample files that cause different validation issues. These files can be processed with
npx ts-node src/main.ts --tilesetSpecs
npx ts-node src/main.ts --metadataSchemaSpecs
npx ts-node src/main.ts --subtreeSpecs
API Definition
The API definition is tracked with https://api-extractor.com
After running npm install, the API documentation can be created with npm run docs. The API documentation will be written into the build/docs directory. The surface API information will be written into etc/3d-tiles-validator.api.md. This file captures the public API, and changes in the public API will cause a warning to be printed
Warning: You have changed the public API signature for this project. Updating etc/3d-tiles-validator.api.md
This API definition file is tracked with Git, so changes in this file should be reviewed carefully.
Release Process
-
Prepare the actual release:
- Update
CHANGES.md - Update the version number in
package.json
- Update
-
Generate the tarball for the release:
npm run packageThis will run the required scripts from the
package.json:- Clean the build output folder
- Prepare the package:
- Perform linting
- Check formatting
- Build (compile TypeScript to JavaScript)
- Run the unit tests
- Generate the documentation
- Update the third-party information
- Package the build output folder into a TAR file
-
Verify the contents of the resulting TAR file. If there are unwanted files, add these files to
.npmignoreand re-generate the tarball -
Create a git tag for the version and push it:
git tag -a v1.2.3 -m "Release of version 1.2.3"git push origin v1.2.3 -
Publish the package:
npm publish
Build Scripts
The build scripts that are used for the release process are documented with about:<step> in the package.json file. Each of these comments indicates the goal and preconditions for running the respective step. The structure of these scripts is often organized hierarchically:
docsbuilddocs-generatedocs-prepare-directorydocs-extract-api,docs-generate-markdown,
The intention is to make sure that each "top-level" (single-word) script can be executed without any preconditions (athough this pattern may not be applied for all steps). Intermediate steps can be executed manually or as part of other steps when it is ensured that the respective preconditions are met.
The following devDependencies are only used for the implementation of the build process:
mkdirp- To generate theetcoutput directory for the API definition file (if it does not exist yet)del-cli- To delete the contents of thebuildoutput foldercopyfiles- To copy thebin/mainfile to the build folder (seebin/README.mdfor details)