# tileset **Repository Path**: cesiumjs/tileset ## Basic Information - **Project Name**: tileset - **Description**: No description available - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-09-10 - **Last Updated**: 2025-09-10 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # tileset A TypeScript library for working with 3D Tiles tileset.json files. This library provides functionality to parse, validate, and manipulate 3D Tiles datasets. ## Installation npm install tileset ## Usage ### Parsing a tileset.json import { Tileset } from 'tileset'; import * as fs from 'fs'; // Read the tileset.json file const jsonContent = fs.readFileSync('path/to/tileset.json', 'utf8'); // Parse the JSON content into a Tileset instance const tileset = Tileset.parse(jsonContent, { validate: true }); // Validate the tileset (if not already validated during parsing) const validationResult = tileset.validate(); if (!validationResult.valid) { console.error('Invalid tileset:', validationResult.errors); } ### Creating a new tileset import { Tileset } from 'tileset'; // Create a basic tileset structure const tilesetData = { asset: { version: '1.1' }, geometricError: 1000.0, root: { boundingVolume: { region: [116.3, 39.9, 116.4, 40.0, 0, 500] }, geometricError: 500.0, children: [ // Add child tiles here ] } }; // Create a Tileset instance from the data const tileset = Tileset.fromObject(tilesetData, { validate: true }); ### Traversing tiles // Traverse all tiles tileset.traverse((tile, depth) => { console.log(`Depth ${depth}: Tile with geometric error ${tile.geometricError}`); }); // Get all tiles in an array const allTiles = tileset.getAllTiles(); console.log(`Total tiles: ${allTiles.length}`); // Find specific tiles const highDetailTiles = tileset.findAllTiles(tile => tile.geometricError < 100); console.log(`High detail tiles: ${highDetailTiles.length}`); ### Exporting the tileset // Convert to JSON string const jsonOutput = tileset.toJSON(2); // 2 spaces indentation fs.writeFileSync('output/tileset.json', jsonOutput, 'utf8'); // Get the raw object const tilesetObject = tileset.toObject(); ## API Documentation ### Tileset Class - `static parse(json: string, options?: ParseOptions): Tileset` - Parses a JSON string into a Tileset instance - `static fromObject(data: Tileset, options?: ParseOptions): Tileset` - Creates a Tileset instance from an object - `validate(): ValidationResult` - Validates the tileset structure - `toJSON(space?: number): string` - Converts the tileset to a JSON string - `toObject(): Tileset` - Returns a deep copy of the tileset data - `getRootTile(): Tile` - Returns the root tile - `getAllTiles(): Tile[]` - Returns all tiles in an array - `traverse(callback: (tile: Tile, depth: number) => void)` - Traverses all tiles recursively - `findTile(predicate: (tile: Tile) => boolean): Tile | undefined` - Finds the first tile matching the predicate - `findAllTiles(predicate: (tile: Tile) => boolean): Tile[]` - Finds all tiles matching the predicate - `getTileCount(): number` - Returns the total number of tiles - `getVersion(): string` - Returns the 3D Tiles version - `getProperties(): Record | undefined` - Returns custom properties - `setProperties(properties: Record): void` - Sets custom properties - `getExtensionsUsed(): string[] | undefined` - Returns used extensions - `addExtension(extension: string): void` - Adds an extension to the used extensions list - `computeOverallBoundingVolume(): BoundingVolume` - Computes the overall bounding volume ## License MIT