# DebugTilesPlugin

class in `3d-tiles-renderer/three/plugins`

```js
import { DebugTilesPlugin } from '3d-tiles-renderer/three/plugins';
```

Plugin that adds visual debugging aids to a `TilesRenderer`: bounding-volume
helpers (box, sphere, region), tile color modes based on depth/error/distance/load
order, and an unlit rendering mode. Color modes are available via the static
`ColorModes` property.

Example: Showing tile bounds and coloring tiles by depth

```js
import { TilesRenderer } from '3d-tiles-renderer/three';
import { DebugTilesPlugin } from '3d-tiles-renderer/three/plugins';

// scene, camera and renderer are initialized here

const URL = 'https://raw.githubusercontent.com/NASA-AMMOS/3DTilesSampleData/master/msl-dingo-gap/0528_0260184_to_s64o256_colorize/0528_0260184_to_s64o256_colorize/0528_0260184_to_s64o256_colorize_tileset.json';
const tiles = new TilesRenderer( URL );
tiles.registerPlugin( new DebugTilesPlugin( {
	displayBoxBounds: true,
	colorMode: DebugTilesPlugin.ColorModes.DEPTH,
	unlit: true,
} ) );
tiles.setCamera( camera );
tiles.setResolutionFromRenderer( camera, renderer );
tiles.group.rotation.x = Math.PI / 2;
scene.add( tiles.group );
camera.position.set( 20, 10, 20 );

renderer.setAnimationLoop( () => {

	camera.updateMatrixWorld();
	tiles.update();
	renderer.render( scene, camera );

} );
```

## Constructor

```js
new DebugTilesPlugin( options?: Object )
```

- `options`, `Object`, optional
  - `displayBoxBounds`, `boolean`, optional, default `false`: Show OBB bounding-box helpers.
  - `displaySphereBounds`, `boolean`, optional, default `false`: Show bounding-sphere helpers.
  - `displayRegionBounds`, `boolean`, optional, default `false`: Show bounding-region helpers.
  - `displayParentBounds`, `boolean`, optional, default `false`: Also show ancestor bounding volumes for visible tiles.
  - `colorMode`, `number`, optional, default `ColorModes.NONE`: Initial tile color mode.
  - `boundsColorMode`, `number`, optional, default `ColorModes.NONE`: Color mode applied to bounding-volume helpers.
  - `maxDebugDepth`, `number`, optional, default `-1`: Maximum tree depth for depth-based coloring (`-1` = auto).
  - `maxDebugDistance`, `number`, optional, default `-1`: Maximum distance for distance-based coloring (`-1` = auto).
  - `maxDebugError`, `number`, optional, default `-1`: Maximum error for error-based coloring (`-1` = auto).
  - `customColorCallback`, `CustomColorCallback | null`, optional, default `null`: Callback invoked per-object when `colorMode` is `CUSTOM_COLOR`.
  - `unlit`, `boolean`, optional, default `false`: Replace tile materials with unlit `MeshBasicMaterial`.
  - `enabled`, `boolean`, optional, default `true`: Whether the plugin is active on init.

## Properties

### .getDebugColor: GetDebugColorCallback

default `( value, target ) => target.setRGB( value, value, value )`

Maps a normalized [0, 1] value to a `Color` for debug visualizations. Defaults to
a black-to-white gradient. Replace with a custom function to use a different color
ramp.

## Methods

### .update

```js
.update(  )
```

Applies the current plugin field values to all visible tile geometry. Call this
after modifying properties such as `colorMode`, `displayBoxBounds`, or
`displayParentBounds` when `TilesRenderer.update` is not being called every frame
so changes can be reflected.
