Initialize Nextspace viewer with Cesium and a bookmark

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

// Replace with your Account ID and Project View.
const ACCOUNT_ID = "examples";
const PROJECT_VIEW_ID = "2b6a86c4-6f76-4a84-9536-c8abb0234225";
const BOOKMARK_ID = "be00cbaa-d3be-448b-8e81-9ef11a6e7525";
// Nextspace examples don't use production, swap to true for your data.
const IS_PRODUCTION = false;
// If your Project View is not public, then this will be required for it to load.
const SESSION_ID = "anonymous";

BModels.ENVIRONMENT.Reset({
    accountId: ACCOUNT_ID,
    sessionId: SESSION_ID,
    env: IS_PRODUCTION ? BModels.Api.EEnv.PROD : BModels.Api.EEnv.DEV
});

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", {
        // Disabling any default imagery/terrain from coming in since we're rendering a bookmark right afterwards that will dictate these things.
        imageryProvider: false,
        baseLayerPicker: false,
        terrainProvider: null,
    });

    BEngine.ViewerUtils.InitViewer({
        viewer: viewer,
        // Call if you're seeing default Cesium widgets!
        destroyWidgets: false,
        // This will generate default Nextspace widgets.
        nextspaceWidgets: true
    });

    await BEngine.ViewRenderEngine.Render({
        bookmarkId: BOOKMARK_ID,
        viewId: PROJECT_VIEW_ID,
        skipTransition: true,
        viewer: viewer
    });
};

init();