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.
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 );
} );On this page
Properties
getDebugColor: ( val: number, target: Color ) => void = ( 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
new DebugTilesPlugin(
options?: {
// Show OBB bounding-box helpers.
displayBoxBounds: boolean = false,
// Show bounding-sphere helpers.
displaySphereBounds: boolean = false,
// Show bounding-region helpers.
displayRegionBounds: boolean = false,
// Also show ancestor bounding volumes for visible tiles.
displayParentBounds: boolean = false,
// Initial tile color mode.
colorMode: number = ColorModes.NONE,
// Color mode applied to bounding-volume helpers.
boundsColorMode: number = ColorModes.NONE,
// Maximum tree depth for depth-based coloring (`-1` = auto).
maxDebugDepth: number = -1,
// Maximum distance for distance-based coloring (`-1` = auto).
maxDebugDistance: number = -1,
// Maximum error for error-based coloring (`-1` = auto).
maxDebugError: number = -1,
// Callback invoked per-object when `colorMode` is `CUSTOM_COLOR`.
customColorCallback: ( tile: Object, child: Object3D ) => void | null = null,
// Replace tile materials with unlit `MeshBasicMaterial`.
unlit: boolean = false,
// Whether the plugin is active on init.
enabled: boolean = true
}
)update(): voidApplies 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.