Render Cesium Tilesets


If you've performed an import of a BIM, CAD, or point cloud file, you can render it through the library without having to create a Project View.

This also includes static mesh Tilesets you've uploaded from your own files.

You will need to know the tilesetId that was generated from your import.

Listing and rendering

Below is how you can list what Tilesets you've got available to render. We can find the tilesetId from here.

Typescript
Javascript
import { ENVIRONMENT, Tileset } from "bruce-models";
import { MenuItemCreator } from "bruce-cesium";
import * as Cesium from "cesium";

// Setup global defaults.
ENVIRONMENT.PARAMS = {
    ...ENVIRONMENT.PARAMS,
    accountId: "your-account-id"
};

/**
 * @Warning it is recommended to set a sessionId prior to making this request.
 * The GetList call will not include information on what Tilesets were excluded due to permissions.
 */
Tileset.GetList({}).then((data) => {
    // You can use the ".name" property and allow the user to select what they'd like to render.
    console.log("Tilesets", data.tilesets);

    // CAD. Eg: IFC, BRZ, etc.
    const cad = data.tilesets.filter(x => x.type == Tileset.EType.Cad);

    // Point clouds.
    const pointClouds = data.tilesets.filter(x => x.type == Tileset.EType.PointCloud);

    // Entities.
    // This is created from an Entity Type of arbitrary Entities, eg: vector polygons.
    const entities = data.tilesets.filter(x => x.type == Tileset.EType.EntitiesSet);

    // Static files uploaded directly by a user.
    // This is usually a mesh tileset.
    const userFiles = data.tilesets.filter(x => x.type == Tileset.EType.LegacyStatic);
}).catch((e) => {
    console.error(e);
});

// Cannot be null in real use!
// Check earlier docs for initialization of the Cesium viewer.
const viewer: Cesium.Viewer = null;

// Render using a record.
// This cannot be null in real use. Retrieve the record then plug it in.
const someSpecificRecord: Tileset.ITileset = null;
MenuItemCreator.RenderTileset({
    tileset: someSpecificRecord,
    viewer: viewer
});

// Render using an ID.
const someTilesetId: string = "some-tileset-id";
MenuItemCreator.RenderTileset({
    tilesetId: someTilesetId,
    viewer: viewer
});