JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://nextspace-limited.github.io/nextspace-web-bundle/dist/nextspace.js?v1"></script>
<div id="VIEWER"></div>
CSS
html, body {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
}
#VIEWER {
width: 100%;
height: 100%;
}
JavaScript
BModels.ENVIRONMENT.Reset({
// Replace with your account ID.
accountId: "examples",
// Replace with UAT when used for real work.
env: BModels.Api.EEnv.DEV,
sessionId: "anonymous"
});
const init = async () => {
// Proxy Cesium Ion requests through the Nextspace API.
// This allows for access to Cesium Ion resources without exposing your token, or the default token.
const api = BModels.ENVIRONMENT.Api().GetBruceApi({});
await api.Loading;
Cesium.Ion.defaultServer = api.GetBaseUrl() + "proxy/cesium-ion/";
Cesium.Ion.defaultAccessToken = "proxy";
const viewer = new Cesium.Viewer("VIEWER", {
// Excluding the default imagery and terrain providers.
// This is to avoid consuming Cesium Ion or Bing Maps quota before custom tiles load.
imageryProvider: false,
baseLayerPicker: false,
terrainProvider: null
});
await BEngine.TileRenderEngine.Map.Navigator.Render({
tiles: [
// We'll underlay preset imageries since the example is only a small piece of land.
{
tilesetId: BModels.ProjectViewTile.EDefaultImagery.MapboxSatellite,
alpha: 0.3
},
{
tilesetId: BModels.ProjectViewTile.EDefaultImagery.Grid
},
{
// On file import it will generate a tileset for optimized delivery of the graphics.
// This is an import TIF file example.
tilesetId: "6af69a5e-afe4-4344-a16c-a9baeca6ff72"
}
],
viewer: viewer
});
await BEngine.TileRenderEngine.Terrain.Navigator.Render({
tile: {
tilesetId: BModels.ProjectViewTile.EDefaultTerrain.FlatTerrain
},
viewer: viewer
});
BEngine.ViewerUtils.InitViewer({
viewer: viewer,
// Call if you're seeing default Cesium widgets!
...