Three.js implementation of a 3D Tiles renderer. Extends TilesRendererBase with
camera management, three.js scene integration, and GPU-accelerated tile loading.
Add tiles.group to your scene and call tiles.update() each frame.
Every object in a loaded tile's scene is stamped with a userData.tile back-reference to
its owning tile, so a raycast hit, click target, or debug inspector can resolve the tile
directly from any intersected object without walking the hierarchy or consulting the renderer.
import { TilesRenderer } from '3d-tiles-renderer/three';
// 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.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
autoDisableRendererCulling: boolean = true
If true, all tile meshes automatically have frustumCulled set to false since the
tiles renderer performs its own frustum culling. If displayActiveTiles is true or
multiple cameras are being used, consider setting this to false.
accelerateRaycast: boolean = true
Whether to use the bounding-volume hierarchy to accelerate raycasting. When disabled, all active tile geometry is tested directly. Useful for tilesets with inaccurate bounding volumes (e.g. Google Photorealistic Tiles) where traversal may miss geometry between bounding volumes.
The container Group for the 3D tiles. Add this to the three.js scene. The group
also exposes a matrixWorldInverse field for transforming objects into the local
tileset frame.
The ellipsoid definition used for the tileset. May be overridden by the
3DTILES_ellipsoid extension. Specified in the local frame of TilesRenderer.group.
surface: Object = this.ellipsoid
The surface definition used to map between cartographic values and the tile geometry
in the local frame of TilesRenderer.group. Defaults to the ellipsoid and may be
reassigned by plugins that flatten or reproject the tile geometry.
Array of cameras registered with this renderer.
manager: LoadingManager = new LoadingManager()
The LoadingManager used when loading tile geometry.
Methods
getBoundingBox(
// Target box to write into.
target: Box3
): booleanReturns the axis-aligned bounding box of the root tile in the group's local space.
getOrientedBoundingBox(
// Target box to write into (in local OBB space).
targetBox: Box3,
// Transform from OBB local space to group local space.
targetMatrix: Matrix4
): booleanReturns the oriented bounding box and transform of the root tile.
getBoundingSphere(
// Target sphere to write into.
target: Sphere
): booleanReturns the bounding sphere of the root tile in the group's local space.
forEachLoadedModel(
// Called with `( scene: Object3D, tile: object )` for each loaded tile.
callback: function
): voidIterates over all currently loaded tile scenes.
raycast(
raycaster: Raycaster,
// Array to push intersection results into.
intersects: Array
): voidPerforms a raycast against all loaded tile scenes. Compatible with Three.js raycasting.
Supports raycaster.firstHitOnly for early termination.
hasCamera( camera: Camera ): booleanReturns whether the given camera is registered with this renderer.
setCamera( camera: Camera ): booleanRegisters a camera with the renderer so it is used for tile selection and screen-space error
calculation. Use setResolution or setResolutionFromRenderer to provide the camera's resolution.
setResolution(
// A previously registered camera.
camera: Camera,
// Render width in pixels, or a Vector2 containing width and height.
xOrVec: number | Vector2,
// Render height in pixels when `xOrVec` is a number.
y?: number
): booleanSets the render resolution for a registered camera, used for screen-space error calculation.
getResolution(
// A previously registered camera.
camera: Camera,
// Vector2 to write the result into.
target: Vector2
): Vector2 | nullReturns the render resolution previously set for a registered camera.
setResolutionFromRenderer(
// A previously registered camera.
camera: Camera,
renderer: WebGLRenderer
): booleanSets the render resolution for a camera by reading the current size from a WebGLRenderer.
deleteCamera( camera: Camera ): booleanUnregisters a camera from the renderer.
Inherited
From TilesRendererBase
- Properties
- Methods