Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

3d-tiles-validator

CesiumGS1.3kApache-2.00.6.0TypeScript support: included

Tools for validating 3D Tiles tilesets.

3D Tiles

readme

3D Tiles Validator

A validator for 3D Tiles.

A note about the repository structure

This repository originally contained multiple projects. Now, these projects are maintained in separate repositories:

Overview

The 3D Tiles validator can be used to validate 3D Tiles tilesets and their associated tile content data. It supports version 1.0 and version 1.1 of the 3D Tiles specification. The validator can be used as a command line tool, or as a library.

Note: Some of the implementation and interfaces may still change. This refers to the source code as well as details of the command line interface and report format.

Implemented Features

  • Validation of the JSON structure of the tileset.json file
  • Validation of the 3D Tiles Tile Formats
    • The supported tile formats are: Batched 3D Model (b3dm), Instanced 3D Model (i3dm), Point Cloud (pnts), Composite (cmpt)
    • glTF tile content is validated with the glTF Validator
  • Validation of implicit tilesets
  • Validation of 3D Tiles Metadata
    • This includes the validation of the JSON structure of the metadata, as well as the structure and ranges of metadata values, both for the JSON based representation and for the binary metadata that is stored in property tables
  • A basic validation of the 3DTILES_bounding_volume_S2 extension
  • Validation of tilesets that are contained in 3D Tiles package files (3TZ and 3DTILES files)

Installation

In order to install the validator locally into a directory, run

npm install 3d-tiles-validator

(If you want to work directly with a clone of the Git repository, see Developer Setup)

Command Line Usage

Validate a single tileset file

npx 3d-tiles-validator --tilesetFile specs/data/Samples/SparseImplicitQuadtree/tileset.json

The input file can either be a tileset JSON file, or one of the known tileset package files. The known package file formats are 3TZ (a package format based on ZIP), and 3DTILES (a package format based on SQLite). The type of the input is determined from the file extension, which may be .3tz or .3dtiles (case-insensitively). For example, to validate a 3TZ file:

npx 3d-tiles-validator --tilesetFile ./specs/data/tilesets/packages/validTilesetPackage.3tz

Validate a set of tileset files

npx 3d-tiles-validator --tilesetsDirectory specs/data/Samples/

This will validate all tileset files in the given directory and all its subdirectories. The tileset files are identified by matching the file name against the glob pattern **/*tileset*.json. The pattern can be configured with the tilesetGlobPattern parameter. For example, in order to treat all .json files as tileset files:

npx 3d-tiles-validator --tilesetsDirectory specs/data/Samples/ --tilesetGlobPattern **/*.json

Validate a tile content file

npx 3d-tiles-validator --tileContentFile specs/data/gltfExtensions/FeatureIdAttributeAndPropertyTableFeatureIdNotInRange.gltf

The input file can be any of the content types that are supported by the validator. This includes B3DM, I3DM, PNTS, CMPT, and glTF/GLB files. The type of the file will be determined, and if it is not a known type, then a validation warning will be created.

Report Files

By default, validation reports are printed to the console.

When validating a single file, then the reportFile argument can be used to specify the output file for the validation report. For example:

npx 3d-tiles-validator --tilesetFile specs/data/Samples/TilesetWithFullMetadata/tileset.json --reportFile MY_REPORT.json

Alternatively, or when validating multiple files, the writeReports argument can be used to write report files into the same directory as the input files. The name of the report file will be derived from the input file name.

npx 3d-tiles-validator --tilesetsDirectory specs/data/Samples/ --writeReports

Option Files

Options for the validation process can be specified in a file that is given via the --optionsFile argument:

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:

{
  "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:

{
  "includeContentTypes": [ "CONTENT_TYPE_B3DM", "CONTENT_TYPE_GLB" ]
}

The following options will cause the validator to exclude tileset files (i.e. external tilesets) during the validation:

{
  "excludeContentTypes": [ "CONTENT_TYPE_TILESET" ]
}

The options can also be part of a configuration file, as described in the next section.

Configuration Files

The command line arguments for a validator run can be summarized in a configuration file that is given with the --configFile argument. For example, when running the validator with

npx 3d-tiles-validator --configFile exampleConfig.json

using the following exampleConfig.json file

{
  "tilesetsDirectory": "specs/data/tilesets",
  "tilesetGlobPattern": "**/*.json"
}

then the validator will validate all files in the given directory that match the given glob pattern.

The configuration can also contain an options object. This object summarizes the validation options, as described in the Option Files section. For example:

{
  "tilesetsDirectory": "specs/data/tilesets",
  "tilesetGlobPattern": "**/*.json",
  "options": {
    "includeContentTypes": [ "CONTENT_TYPE_B3DM", "CONTENT_TYPE_GLB" ]
  }
}

This will cause the validator to validate all JSON files in the specified directory, but only consider B3DM- and GLB tile content data during the validation.

Custom Metadata Semantics

The 3D Metadata Specification allows for the definition of custom semantics for metadata properties. The built-in semantics are described in the 3D Metadata Semantic Reference. For other semantics, the validator will by default generate a METADATA_SEMANTIC_UNKNOWN issue.

To avoid these warnings, clients can define their own semantics in a metadata schema file, so that they are taken into account during the validation process. Some details of this process might still change (see 3d-tiles/issues/643 for a discussion). But the current state of the support of metadata semantics validation in the 3D Tiles Validator is described here.

Metadata Semantics Schema

A 'semantics schema' is a 3D Metadata Schema file that describes the semantics that may appear in another metadata schema. In a semantics schema, the property names are just the names of the semantics. For example, when a client wants to define a semantic for a class like ExampleClass, and this semantic has the name EXAMPLE_SEMANTIC, then this structure can be represented in a semantics schema file as follows:

exampleSemanticsSchema.json:

{
  "id": "Example-Semantics-0.0.0",
  "description": "A metadata schema where each class property has a name that represents one possible semantic of a metadata property, and that is used for validating semantics, by passing it in as one of the 'semanticSchemaFileNames' of the validation options",
  "classes": {
    "ExampleClassSemantics": {
      "description": "A class where each property is a semantic for a property of the 'ExampleClass'",
      "properties": {
        "EXAMPLE_SEMANTIC": {
          "name": "The 'EXAMPLE_SEMANTIC' structure",
          "description": "The structure that a property must have so that it can have the 'EXAMPLE_SEMANTIC'",
          "type": "SCALAR",
          "componentType": "FLOAT32"
        }
      }
    }
  }
}

Note:

This schema file contains elaborate names and descriptions. These are optional on a technical level. An equivalent schema file is

{
  "id": "Example-Semantics-0.0.0",
  "classes": {
    "ExampleClassSemantics": {
      "properties": {
        "EXAMPLE_SEMANTIC": {
          "type": "SCALAR",
          "componentType": "FLOAT32"
        }
      }
    }
  }
}

But adding names and descriptions is strongly recommended for documentation purposes.

Metadata Semantics Schema Registration

In order to include a 'semantics schema' in the validation process, the name of the schema file can be passed to the validator, as part of the validation options:

exampleOptions.json:

{
  "semanticSchemaFileNames": ["exampleSemanticsSchema.json"]
}

This options file can then be passed to the validator:

npx 3d-tiles-validator --optionsFile exampleOptions.json -t ./data/exampleTileset.json

The validator will then validate the semantics that are defined in the tileset JSON against the structure that was defined in the semantics schema.

Developer Setup

When the validator is not installed as a package from NPM, but supposed to be used directly in a cloned repository, then the command line usage is as follows:

  • Clone the repository into the current directory:
    git clone https://github.com/CesiumGS/3d-tiles-validator
  • Change into the directory of the cloned repository:
    cd 3d-tiles-validator
  • Install the validator and all its dependencies:
    npm install

After this, ts-node can be used to directly execute the validator, using the same command line options as described above - for example, to validate a single tileset file:

npx ts-node src/main.ts --tilesetFile specs/data/Samples/SparseImplicitQuadtree/tileset.json

Library Usage

The basic usage of the validator as a library is shown here:

const { Validators } = require("3d-tiles-validator");

const resultPromise = Validators.validateTilesetFile("example.json");
resultPromise.then((result) => {
  console.log(result.serialize());
});

The Validators.validateTilesetFile receives a file name, and returns a promise to the ValidationResult, which can then be printed to the console. The second (optional) parameter is a ValidationOptions object that summarizes the options for the validation process (also see Option Files).

Validaton Result Filtering

Clients can perform basic filtering operations on a ValidationResult, in order to remove validation issues that are below a certain severity level, or warnings that are anticipated in a certain application context.

For example, a given validation result can be filtered to

  • include validation issues that have the severity ERROR
  • exclude validation issues that have the type EXTENSION_NOT_SUPPORTED

An example of applying such a filter to a given validation result is shown here:

const { Validators, ValidationIssueFilters, ValidationIssueSeverity } = require("3d-tiles-validator");

const resultPromise = Validators.validateTilesetFile("example.json");
resultPromise.then((result) => {
  const filteredResult = result
    .filter(ValidationIssueFilters.byIncludedSeverities(ValidationIssueSeverity.ERROR))
    .filter(ValidationIssueFilters.byExcludedTypes("EXTENSION_NOT_SUPPORTED"));
  console.log(filteredResult.serialize());
});

Note: The type strings that are used for describing and categorizing the validation issues are not part of the core API. These strings might change between minor- or patch releases. But changes will be pointed out in the change log.

Implementation Notes

See IMPLEMENTATION.md for implementation notes.

changelog

Version 0.6.0 - 2025-02-24

  • Fixed a bug where a BOUNDING_VOLUMES_INCONSISTENT error was reported when a tile defined a transform #328
  • Allow users to provide schema files for validating custom metadata semantics #329
  • Do not emit warnings when encountering MAXAR_content_geojson, VRICON_class, or VRICON_grid extensions #330
  • Fixes for 3TZ validation #331
    • Fixed a bug where a 3TZ file could not be referred to with a relative path
    • Handled the case where completely invalid 3TZ files caused an INTERNAL_ERROR
  • Updated 3d-tiles-tools version to 0.5.0
    • Minor updates for the new async API that was introduced via 3d-tiles-tools/pull/167
    • Includes a bugfix from `3d-tiles-tools/pull/173 where 3TZ files that contained certain local ZIP file headers caused an internal error in the validator
  • Changed the severity of issues that have been generated for content types that are known but not validated (like VCTR, GEOM, and GEOJSON) from WARNING to INFO #332

Version 0.5.1 - 2024-12-05

  • The maximum number of issues that are reported for a single glTF asset is now limited (#291).
  • When the number of bytes that are required for a certain property texture property did not match the number of channels, then the validator reported this as an ERROR, with the type TEXTURE_CHANNELS_OUT_OF_RANGE. This could cause errors to be reported for the case of 16-bit channels in textures, where these numbers do not have to match. Now, these cases are only reported as a WARNING, of the type TEXTURE_CHANNELS_SIZE_MISMATCH (#293).
  • The refine property for tiles is optional in general, but required for the root tile. The validator did not check this. Now, it reports a TILE_REFINE_MISSING_IN_ROOT error when the refine property is missing in a root tile (#303).
  • When encountering an invalid alignment in the binary data of legacy tile content files, the validator stopped the validation of these files, and only reported a BINARY_INVALID_ALIGNMENT error. Now, it will try to process the data despite the invalid alignment, and perform further validation steps, for example, of the binary glTF data (#304).
  • Fixed a bug where the validator erroneously reported validation error when external tilesets did not use extensions that had been declared in the extensionsUsed of the containing tileset (#305).
  • Added a convenience function to the ValidationResult class, to easily deserialize and post-process validation reports (#307).
  • Fixed a bug where the default value for texCoord properties of property texture was not handled properly (#309).
  • Added the option to define a severity threshold for content validation issues. Setting the contentValidationIssueSeverity in the validation config file will omit all content validation issues that are below this severity threshold (#310).
  • Fixed a bug where the validator reported an error for binary .subtree files that did not contain any buffers (#313).
  • Added support for the validation of the NGA_gpm_local glTF extension (#316).
  • Added support for the validation of the NGA_gpm 3D Tiles extension (#319).
  • Fixed a bug where the validator erroneously reported a BOUNDING_VOLUMES_INCONSISTENT error when a tile with a transform contained a content with a boundingVolume (#322).
  • Updated the underlying 3d-tiles-tools dependency to include a fix for a bug where the validator reported an INTERNAL_ERROR when trying to validate a tileset that contains glTF that use the EXT_meshopt_compression extension (#323).
  • Fixed a bug where the semantics that are referred to as 'General Semantics' in the 3D Metadata Semantic Reference had been reported to be unknown with a METADATA_SEMANTIC_UNKNOWN message (#325).

Version 0.5.0 - 2023-10-24

  • Added validation of glTF extensions via #280 and #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:
    • For EXT_mesh_features, it will check the validity of feature ID attributes and feature ID textures
    • For EXT_instance_features, it will check the validity of the feature ID attributes that refer to the EXT_mesh_gpu_instancing extension
    • For EXT_structural_metadata, it will check the validity of the metadata schema definition, property tables, property attributes, and property textures
  • Added a command line functionality for validating single tile content files (glTF/GLB, B3DM, I3DM, PNTS, and CMPT), via #285
  • When an I3DM refers to an external glTF asset with a URI, then the URI has to be padded with 0x20 (space) bytes if necessary to satisfy the alignment requirements. The validator only accepted 0x00 (zero) bytes as padding bytes. Now the validator properly handles trailing spaces, and reports the presence of zero-bytes with a validation warning (#276)
  • Changed the severity level of validation issues:
    • The case that the geometricError of a tile was larger than the geometricError of its parent was reported as an ERROR. The specification does not explicitly disallow this, so it is now only treated as a WARNING (#286)
    • An empty children array in a tile was treated as an ERROR, but is now treated as a WARNING, via #288

Version 0.4.1 - 2023-05-02

  • Moved most of the internal implementation into the 3d-tiles-tools, and replaced it with a dependency to 3d-tiles-tools
  • Detect cycles in external tilesets (#269)
  • Handle 3D Tiles packages that contain entries that are individually compressed with GZIP

Version 0.4.0 - 2023-01-31

  • Padding bytes in B3DM that had only be inserted to align its length to 8 bytes had not been handled properly, and caused unwanted validation warnings. This case is now handled by restricting the glTF validation to the GLB without padding bytes (#256)
  • When a tileset referred to glTF (JSON) data that could not be resolved, then this was ignored. Now, it creates an error saying that the data could not be resolved. The treatment of non-resolvable data might be configured with validation options in the future (see https://github.com/CesiumGS/3d-tiles-validator/issues/224)
  • When the glTF validator generated messages with the "hint" severity, these had not been shown in the tileset validation report. Now, they show up as issues with the INFO severity level.
  • The tile.transform matrices had been checked to be invertible. Now they are checked to be affine (#262).
  • Fixed a bug where the validation of PNTS caused wrong validation issues for the batch table length for batched point clouds.
  • Added experimental support for validating tileset package files. The --tilesetFile that is given at the command line can now also be a 3TZ or 3DTILES file.
  • When input JSON files contained a Unicode BOM (Byte Order Mark), the validator reported a JSON_PARSE_ERROR without information about the reason for the parsing error. Now it reports an IO_ERROR with a helpful error message.

Version 0.3.0 - 2022-12-20

  • Updated the packaging so that the validator can more easily be executed as a command line tool after installing
  • Updated the scripts in package.json to simplify the packaging process

Version 0.2.0 - 2022-12-13

  • Add support for validation options that allow to include/exclude certain content types for the validation. These options can either be given via the --optionsFile command line argument, or passed as an optional parameter to Validators.validateTilesetFile.
  • Fixed a bug where the content data was not validated when the validator was used as a library (#248)
  • Fixed a bug that caused validation errors for statistics.class properties
  • When a tileset input file did not exist, the validator generated a JSON_PARSE_ERROR. Now it generates an IO_ERROR (including the file path) instead.
  • Dependency updates:
    • Updated better-sqlite3 from 7.5.3 to 8.0.1 (for compatibility with Node 19 - see #245)
    • Removed jasmine-node
    • Removed tsconfig/node16
    • Reduced engines.node version from >=16.0.0 to >=14.0.0

Version 0.1.0 - 2022-11-29

  • Initial release