Skip to main content

CesiumIonLoader

Extends from Tiles3DLoader, inherits all the options and share the same resolved Tileset and Tile format. Along with the support of resolving tileset metadata and authorization from Cesium ion server.

Parse 3D tile fetched from Cesium ion server.

Usage​

Load a tileset file from Cesium ion server.

import {load} from '@loaders.gl/core';
import {CesiumIonLoader} from '@loaders.gl/3d-tiles';
import {WebMercatorViewport} from '@deck.gl/core';
const tilesetUrl = 'https://assets.ion.cesium.com/69380/tileset.json';
const ION_ACCESS_TOKEN = ''; // your own ion access token

const options = {ion: {loadGLTF: true}};
// resolve the authorizations used for requesting tiles from Cesium ion server
const metadata = CesiumIonLoader.preload(tilesetUrl, {accessToken: ION_ACCESS_TOKEN});
console.log(metadata);

const tilesetJson = await load(tilesetUrl, CesiumIonLoader, {...options, ...metadata});

// If your tileset doesn't have .json extension, set options['cesium-ion'].isTileset to true
const tilesetJson = await load(tilesetUrl, CesiumIonLoader, {
...options,
...metadata,
isTileset: true
});

const viewport = new WebMercatorViewport({latitude, longitude, zoom});
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

Options​

Inherit all the options from Tiles3DLoader.

OptionTypeDefaultDescription
['cesium-ion'].isTilesetBool or autoautoWhether to load a Tileset file. If auto, will infer based on url extension.
['cesium-ion'].headersObjectnullUsed to load data from server
['cesium-ion'].tilesetObjectnullTileset object loaded by Tiles3DLoader or follow the data format specified in Tileset Object. It is required when loading i3s geometry content
['cesium-ion'].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
['cesium-ion'].decodeQuantizedPositionBooleanfalsePre-decode quantized position on CPU

For i3dm and b3dm tiles:

OptionTypeDefaultDescription
['cesium-ion'].loadGLTFBooleantrueFetch and parse any linked glTF files

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

Data formats​

The same as Tiles3DLoader.