@itwin/core-frontend
Version:
iTwin.js frontend components
37 lines • 2.12 kB
JavaScript
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
* @module Tiles
*/
import { getCesiumTerrainProvider } from "../internal";
/** A registry of [[TerrainProvider]]s identified by their unique names. The registry can be accessed via [[IModelApp.terrainProviderRegistry]].
* It always includes the built-in provider named "CesiumWorldTerrain", which obtains terrain meshes from [Cesium ION](https://cesium.com/platform/cesium-ion/content/cesium-world-terrain/). That provider requires a valid [[TileAdmin.Props.cesiumIonKey]] to be supplied to [[IModelApp.startup]].
* Any number of additional providers can be [[register]]ed.
*
* When terrain is enabled for a [[Viewport]], the display system will attempt to look up the [[TerrainProvider]] corresponding to the [TerrainSettings.providerName]($common) specified by the [[Viewport]]'s [DisplayStyleSettings]($common). If a provider by that name is registered, it will be used to obtain terrain meshes; otherwise, the display system will produce flat terrain meshes.
* @public
*/
export class TerrainProviderRegistry {
_providers = new Map();
/** @internal */
constructor() {
this.register("CesiumWorldTerrain", {
createTerrainMeshProvider: async (options) => getCesiumTerrainProvider(options),
});
}
/** Register a new [[TerrainProvider]].
* @param name The name of the provider. It must be unique among all providers.
* @param provider The provider to register.
* @see [[find]] to later retrieve the provider by name.
*/
register(name, provider) {
this._providers.set(name, provider);
}
/** Look up a [[register]]ed [[TerrainProvider]] by its name. */
find(name) {
return this._providers.get(name);
}
}
//# sourceMappingURL=TerrainProvider.js.map