Skip to main content

Tiles3DLoader

From-v2.1

Parses a 3D tiles tileset.

LoaderCharacteristic
File Extensions.b3dm,.i3dm, .pnts, .cmpt
File TypeBinary (with linked assets)
File Format3D Tiles
Data FormatData Formats (see below)
Decoder TypeAsynchronous
Worker Thread SupportNo
Streaming SupportNo *
SubloadersDracoLoader (.pnts), GLTFLoader (.b3dm, .i3dm), ImageLoader (..jpg, .png), TextureLoader (.ktx)

* Streaming is not supported for individual tiles, however tilesets are streamed by loading only the tiles needed for the specified viewports.

Usage​

As a tileset contains multiple file formats, Tiles3DLoader is needed to be explicitly specified when using load function.

Load a tileset file.

import {load} from '@loaders.gl/core';
import {Tiles3DLoader} from '@loaders.gl/3d-tiles';
const tilesetUrl = 'https://assets.ion.cesium.com/43978/tileset.json';
const tilesetJson = await load(tilesetUrl, Tiles3DLoader);

To decompress tiles containing Draco compressed glTF models or Draco compressed point clouds:

import {load, registerLoaders} from '@loaders.gl/core';
import {Tiles3DLoader} from '@loaders.gl/3d-tiles';
const tileUrl = 'https://assets.ion.cesium.com/43978/1.pnts';
const tile = await load(tileUrl, Tiles3DLoader, {decompress: true});

Load a tileset and dynamically load/unload tiles based on viewport with helper class Tileset3D (@loaders.gl/tiles)

import {load} from '@loaders.gl/core';
import {Tileset3D} from '@loaders.gl/tiles';
import {Tiles3DLoader} from '@loaders.gl/3d-tiles';
import {WebMercatorViewport} from '@deck.gl/core';

const tilesetUrl = 'https://assets.cesium.ion.com/43978/tileset.json';
const tilesetJson = await load(tilesetUrl, Tiles3DLoader);

// if your tileset file doesn't have the .json extension, set `3d-tiles.isTileset` to true
const tilesetJson = await load(tilesetUrl, Tiles3DLoader, {'3d-tiles': {isTileset: true}});

const tileset3d = new Tileset3D(tilesetJson, {
throttleRequests: false,
onTileLoad: tile => console.log(tile)
});

const viewport = new WebMercatorViewport({
width: 600,
height: 400,
latitude: 40.7067584,
longitude: -74.0115413,
zoom: 17
});
tileset3d.selectTiles(viewport);

// visible tiles
const visibleTiles = tileset3d.tiles.filter(tile => tile.selected);
// Note that visibleTiles will likely not immediately include all tiles
// tiles will keep loading and file `onTileLoad` callbacks

// To fully load all tiles in a given view, repeatedly select tiles until the tileset is loaded
while (!tileset3d.isLoaded()) {
await tileset3d.selectTiles(viewport);
}

Options​

OptionTypeDefaultDescription
3d-tiles.isTilesetBool or autoautoWhether to load a Tileset file. If auto, will infer based on url extension.
3d-tiles.headersObjectnullUsed to load data from server
3d-tiles.tilesetObjectnullTileset object loaded by Tiles3DLoader or follow the data format specified in Tileset Object. It is required when loading i3s geometry content
3d-tiles.tileObjectnullTile object loaded by Tiles3DLoader or follow the data format Tile Object. It is required when loading i3s geometry content

Point cloud tie options

OptionTypeDefaultDescription
3d-tiles.decodeQuantizedPositionsBooleanfalsePre-decode quantized position on CPU

For i3dm and b3dm tiles:

OptionTypeDefaultDescription
3d-tiles.loadGLTFBooleantrueFetch and parse any linked glTF files

If options['3d-tiles'].loadGLTF is true, GLTF loading can be controlled by providing GLTFLoader options via the options.gltf sub options.

Notes about Tile Types​

b3dm, i3dm​

The Batched 3D Model and Instanced 3D model tile types contain an embedded glTF file. This can be parsed into a hierarchical scene graph description that can be used to instantiate an actual sceneg raph in most WebGL libraries.

Can load both binary .glb files and JSON .gltf files.

glTF content extension​

3DTILES_content_gltf extension is supported. This extension allows a tileset to use glTF 2.0 assets directly as tile content. Both glTF JSON and GLB binary formats are supported.

Data Format​

Loaded data conforms to the 3D Tiles loader category specification with the following exceptions.

Tileset Object​

FieldTypeContents
typeStringValue is TILES3D. Indicates the returned object is a Cesium 3D Tiles tileset.
lodMetricTypeStringRoot's Level of Detail (LoD) metric type, which is used to decide if a tile is sufficient for current viewport. Used for deciding if this tile is sufficient given current viewport. Cesium use geometricError.
lodMetricValueNumberRoot's level of detail (LoD) metric value.

Tile Object​

The following fields are guaranteed. Additionally, the loaded tile object will contain all the data fetched from the provided url.

FieldTypeContents
idStringIdentifier of the tile, unique in a tileset
refineStringRefinement type of the tile, ADD or REPLACE
typeStringType of the tile, one of pointcloud (.pnts), scenegraph (.i3dm, .b3dm, .glb, .gltf)
boundingVolumeObjectA bounding volume in Cartesian coordinates that encloses a tile or its content. Exactly one box, region, or sphere property is required. (Reference)
lodMetricTypeStringLevel of Detail (LoD) metric type, which is used to decide if a tile is sufficient for current viewport. Used for deciding if this tile is sufficient given current viewport. Cesium use geometricError.
lodMetricValueStringLevel of Detail (LoD) metric value.
childrenArrayAn array of objects that define child tiles. Each child tile content is fully enclosed by its parent tile's bounding volume and, generally, has more details than parent. for leaf tiles, the length of this array is zero, and children may not be defined.
transformMatrixNumber[16]A matrix that transforms from the tile's local coordinate system to the parent tile's coordinate systemβ€”or the tileset's coordinate system in the case of the root tile

Tile Content​

After content is loaded, the following fields are guaranteed. But different tiles may have different extra content fields.

FieldTypeContents
cartesianOriginNumber[3]"Center" of tile geometry in WGS84 fixed frame coordinates
cartographicOriginNumber[3]"Origin" in lng/lat (center of tile's bounding volume)
modelMatrixNumber[16]Transforms tile geometry positions to fixed frame coordinates
attributesObjectEach attribute follows luma.gl accessor properties
featureIdsUint32ArrayAn array of feature ids which specify which feature each vertex belongs to. Can be used for picking functionality.

attributes contains following fields

FieldTypeContents
attributes.positionsObject{value, type, size, normalized}
attributes.normalsObject{value, type, size, normalized}
attributes.colorsObject{value, type, size, normalized}

PointCloud Fields

FieldTypeContents
pointCountNumberNumber of points
colorNumber[3] or Number[4]Color of the tile when there are not attributes.colors

Scenegraph Fields

FieldTypeContents
gltfObjectcheck GLTFLoader for detailed spec