@itwin/core-frontend
Version:
iTwin.js frontend components
734 lines • 43 kB
TypeScript
/** @packageDocumentation
* @module Tiles
*/
import { BeDuration, BeEvent, Id64Array, Id64String } from "@itwin/core-bentley";
import { EdgeOptions, ElementGraphicsRequestProps, IModelTileTreeProps, RenderSchedule, TileVersionInfo } from "@itwin/core-common";
import { IModelConnection } from "../IModelConnection";
import { Viewport } from "../Viewport";
import { IModelTileTree, ReadonlyTileUserSet, Tile, TileContentDecodingStatistics, TileRequestChannels, TileTreeOwner, TileUsageMarker, TileUser } from "./internal";
import type { FrontendStorage } from "@itwin/object-storage-core/lib/frontend";
/** Details about any tiles not handled by [[TileAdmin]]. At this time, that means OrbitGT point cloud tiles.
* Used for bookkeeping by SelectedAndReadyTiles
* @internal
*/
export interface ExternalTileStatistics {
requested: number;
selected: number;
ready: number;
}
/** Describes two sets of tiles associated with a viewport's current scene.
* @internal
*/
export interface SelectedAndReadyTiles {
/** The tiles actually selected for the viewport's scene. This includes tiles drawn to the screen; it may also include tiles selected for the shadow map.
* These represent the "best available" tiles for the current view - some may have been selected as placeholders while more appropriate tiles are loaded.
*/
readonly selected: Set<Tile>;
/** The tiles that are considered appropriate for the current view and that are ready to draw. Some may not have actually been selected for drawing in the
* current view, e.g., because sibling tiles are not yet ready to draw.
*/
readonly ready: Set<Tile>;
/** Details about any tiles not handled by [[TileAdmin]]. At this time, that means OrbitGT point cloud tiles and tiles for view attachments. */
readonly external: ExternalTileStatistics;
}
/** Describes a strategy for imposing limits upon the amount of GPU memory consumed by [[Tile]] content.
*
* For a given view, a set of tiles is required to display its contents. As the user navigates the view by panning, rotating, zooming, etc, that set of tiles changes.
* Previously-displayed tiles can remain in memory for a short while so that if they are subsequently required for display again they will be immediately available.
* Keeping too many tiles in memory can consume excessive amounts of GPU memory; in extreme cases, more GPU memory can be consumed than is available, resulting in loss of
* the WebGL context, which causes all rendering to stop.
*
* Over-consumption of GPU memory can be prevented by imposing a limit on the maximum amount that can be in use at any one time. When the limit is exceeded, the contents
* of [[Tile]]s that are not currently being displayed by any [[Viewport]] are discarded, freeing up memory, until the limit is satisfied or all
* undisplayed tiles' contents have been discarded. The least-recently-displayed tiles' contents are discarded first, under the assumption that they are the least likely to
* be displayed again in the near future. Contents of tiles that are currently being displayed by at least one viewport will not be discarded.
*
* WebGL provides no direct access to the GPU, so the amount of memory actually being consumed can only be estimated based on the amount of memory
* requested from it; the actual amount will invariably be larger - sometimes much larger.
*
* The number of bytes corresponding to the various limits is estimated at run-time based on whether the client is running on a mobile device or not - tighter limits
* are imposed on mobile devices due to their tighter resource constraints.
*
* In addition to the memory limits, tile contents are naturally discarded after a certain length of time during which they have been displayed by no viewports based on
* [[TileAdmin.Props.tileExpirationTime]].
*
* The options are:
* - "none" - no limits are imposed. Tile contents are discarded solely based on [[TileAdmin.Props.tileExpirationTime]].
* - "aggressive" - a small limit resulting in tile contents being more aggressively discarded.
* - "default" - a moderate limit that strives to balance limiting memory consumption while keeping tiles likely to be displayed again in memory.
* - "relaxed" - a larger limit that may be appropriate for devices equipped with ample GPU memory.
* - number - an explicit limit, in number of bytes. Because of the vagaries of actual GPU memory consumption under WebGL, this should be a conservative estimate - no more than perhaps 1/4 of the total GPU memory available, depending on the device.
* @see [[TileAdmin.Props.gpuMemoryLimits]] to configure the limit at startup.
* @see [[TileAdmin.gpuMemoryLimit]] to adjust the limit after startup.
* @see [[TileAdmin.totalTileContentBytes]] for the current amount of GPU memory being used for tile contents.
* @public
* @extensions
*/
export type GpuMemoryLimit = "none" | "default" | "aggressive" | "relaxed" | number;
/** Defines separate [[GpuMemoryLimit]]s for mobile and desktop clients.
* @see [[TileAdmin.Props.gpuMemoryLimits]] to configure the limit at startup.
* @see [[GpuMemoryLimit]] for a description of how the available limits and how they are imposed.
* @public
* @extensions
*/
export interface GpuMemoryLimits {
/** Limits applied to clients running on mobile devices. Defaults to "default" if undefined. */
mobile?: GpuMemoryLimit;
/** Limits applied to clients running on non-mobile devices. Defaults to 6,000 MB if undefined. */
nonMobile?: GpuMemoryLimit;
}
/** Manages [[Tile]]s and [[TileTree]]s on behalf of [[IModelApp]]. Its responsibilities include scheduling requests for tile content via a priority queue;
* keeping track of and imposing limits upon the amount of GPU memory consumed by tiles; and notifying listeners of tile-related events.
* @see [[IModelApp.tileAdmin]] to access the instance of the TileAdmin.
* @see [[TileAdmin.Props]] to configure the TileAdmin at startup.
* @public
* @extensions
*/
export declare class TileAdmin {
private _versionInfo?;
readonly channels: TileRequestChannels;
private readonly _users;
private readonly _requestsPerUser;
private readonly _tileUsagePerUser;
private readonly _selectedAndReady;
private readonly _tileUserSetsForRequests;
private readonly _maxActiveTileTreePropsRequests;
private _defaultTileSizeModifier;
private readonly _retryInterval;
private readonly _enableInstancing;
/** @internal */
readonly edgeOptions: EdgeOptions;
/** @internal */
readonly enableImprovedElision: boolean;
/** @internal */
readonly enableFrontendScheduleScripts: boolean;
/** @internal */
readonly decodeImdlInWorker: boolean;
/** @internal */
readonly ignoreAreaPatterns: boolean;
/** @internal */
readonly enableExternalTextures: boolean;
/** @internal */
readonly disableMagnification: boolean;
/** @internal */
readonly percentGPUMemDisablePreload: number;
/** @internal */
readonly alwaysRequestEdges: boolean;
/** @internal */
readonly alwaysSubdivideIncompleteTiles: boolean;
/** @internal */
readonly minimumSpatialTolerance: number;
/** @internal */
readonly maximumMajorTileFormatVersion: number;
/** @internal */
readonly useProjectExtents: boolean;
/** @internal */
readonly expandProjectExtents: boolean;
/** @internal */
readonly optimizeBRepProcessing: boolean;
/** @internal */
readonly disablePolyfaceDecimation: boolean;
/** @internal */
readonly useLargerTiles: boolean;
/** @internal */
readonly maximumLevelsToSkip: number;
/** @internal */
readonly mobileRealityTileMinToleranceRatio: number;
/** @internal */
readonly tileTreeExpirationTime: BeDuration;
/** @internal */
readonly tileExpirationTime: BeDuration;
/** @internal */
readonly contextPreloadParentDepth: number;
/** @internal */
readonly contextPreloadParentSkip: number;
/** @beta */
readonly cesiumIonKey?: string;
private readonly _removeIModelConnectionOnCloseListener;
private _totalElided;
private _rpcInitialized;
private _nextPruneTime;
private _nextPurgeTime;
private _tileTreePropsRequests;
private _cleanup?;
private readonly _lruList;
private _maxTotalTileContentBytes?;
private _gpuMemoryLimit;
private readonly _isMobile;
private readonly _cloudStorage?;
/** Create a TileAdmin suitable for passing to [[IModelApp.startup]] via [[IModelAppOptions.tileAdmin]] to customize aspects of
* its behavior.
* @param props Options for customizing the behavior of the TileAdmin.
* @returns the TileAdmin
*/
static create(props?: TileAdmin.Props): Promise<TileAdmin>;
/** @internal */
get emptyTileUserSet(): ReadonlyTileUserSet;
/** Returns basic statistics about the TileAdmin's current state. */
get statistics(): TileAdmin.Statistics;
/** Resets the cumulative (per-session) statistics like totalCompletedRequests, totalEmptyTiles, etc. */
resetStatistics(): void;
/** Exposed as public strictly for tests.
* @internal
*/
constructor(isMobile: boolean, rpcConcurrency: number | undefined, options?: TileAdmin.Props);
private _tileStorage?;
private getTileStorage;
/** @internal */
get enableInstancing(): boolean;
/** Given a numeric combined major+minor tile format version (typically obtained from a request to the backend to query the maximum tile format version it supports),
* return the maximum *major* format version to be used to request tile content from the backend.
* @see [[TileAdmin.Props.maximumMajorTileFormatVersion]]
* @see [[CurrentImdlVersion]]
*/
getMaximumMajorTileFormatVersion(formatVersion?: number): number;
/** A default multiplier applied to the size in pixels of a [[Tile]] during tile selection for any [[Viewport]].
* Individual Viewports can override this multiplier if desired.
* A value greater than 1.0 causes lower-resolution tiles to be selected; a value < 1.0 selects higher-resolution tiles.
* This can allow an application to sacrifice quality for performance or vice-versa.
* This property is initialized from the value supplied by the [[TileAdmin.Props.defaultTileSizeModifier]] used to initialize the TileAdmin at startup.
* Changing it after startup will change it for all Viewports that do not explicitly override it with their own multiplier.
* This value must be greater than zero.
*/
get defaultTileSizeModifier(): number;
set defaultTileSizeModifier(modifier: number);
/** The total number of bytes of GPU memory allocated to [[Tile]] contents.
* @see [[gpuMemoryLimit]] to impose limits on how high this can grow.
*/
get totalTileContentBytes(): number;
/** The maximum number of bytes of GPU memory that can be allocated to the contents of [[Tile]]s. When this limit is exceeded, the contents of the least-recently-drawn
* tiles are discarded until the total is below this limit or all undisplayed tiles' contents have been discarded.
* @see [[totalTileContentBytes]] for the current GPU memory usage.
* @see [[gpuMemoryLimit]] to adjust this maximum.
*/
get maxTotalTileContentBytes(): number | undefined;
/** The strategy for limiting the amount of GPU memory allocated to [[Tile]] graphics.
* @see [[TileAdmin.Props.gpuMemoryLimits]] to configure this at startup.
* @see [[maxTotalTileContentBytes]] for the limit as a maximum number of bytes.
*/
get gpuMemoryLimit(): GpuMemoryLimit;
set gpuMemoryLimit(limit: GpuMemoryLimit);
/** Returns whether or not preloading for context (reality and map tiles) is currently allowed.
* It is not allowed on mobile devices or if [[TileAdmin.Props.percentGPUMemDisablePreload]] is 0.
* Otherwise it is always allowed if [[GpuMemoryLimit]] is "none".
* Otherwise it is only allowed if current GPU memory utilization is less than [[TileAdmin.Props.percentGPUMemDisablePreload]] of GpuMemoryLimit.
* @internal
*/
get isPreloadingAllowed(): boolean;
/** Invoked from the [[ToolAdmin]] event loop to process any pending or active requests for tiles.
* @internal
*/
process(): void;
/** Iterate over the tiles that have content loaded but are not in use by any [[TileUser]].
* @alpha
*/
get unselectedLoadedTiles(): Iterable<Tile>;
/** Iterate over the tiles that have content loaded and are in use by any [[TileUser]].
* @alpha
*/
get selectedLoadedTiles(): Iterable<Tile>;
/** Returns the number of pending and active requests associated with the specified viewport. */
getNumRequestsForViewport(vp: Viewport): number;
/** Returns the number of pending and active requests associated with the specified user. */
getNumRequestsForUser(user: TileUser): number;
/** Returns the current set of Tiles requested by the specified TileUser.
* Do not modify the set or the Tiles.
* @internal
*/
getRequestsForUser(user: TileUser): Set<Tile> | undefined;
/** Specifies the set of tiles currently requested for use by a TileUser. This set replaces any previously specified for the same user.
* The requests are not actually processed until the next call to [[TileAdmin.process].
* This is typically invoked when a viewport recreates its scene, e.g. in response to camera movement.
* @internal
*/
requestTiles(user: TileUser, tiles: Set<Tile>): void;
/** Returns two sets of tiles associated with the specified user - typically, a viewport's current scene.
* Do not modify the returned sets.
* @internal
*/
getTilesForUser(user: TileUser): SelectedAndReadyTiles | undefined;
/** Adds the specified tiles to the sets of selected and ready tiles for the specified TileUser.
* The TileAdmin takes ownership of the `ready` set - do not modify it after passing it in.
* @internal
*/
addTilesForUser(user: TileUser, selected: Tile[], ready: Set<Tile>, touched: Set<Tile>): void;
/** Disclose statistics about tiles that are handled externally from TileAdmin. At this time, that means OrbitGT point cloud tiles.
* These statistics are included in the return value of [[getTilesForUser]].
* @internal
*/
addExternalTilesForUser(user: TileUser, statistics: ExternalTileStatistics): void;
/** Clears the sets of tiles associated with a TileUser. */
clearTilesForUser(user: TileUser): void;
/** Indicates that the TileAdmin should cease tracking the specified TileUser, e.g. because it is about to be destroyed.
* Any requests which are of interest only to the specified user will be canceled.
*/
forgetUser(user: TileUser): void;
/** Indicates that the TileAdmin should track tile requests for the specified TileUser.
* This is invoked by the Viewport constructor and should be invoked manually for any non-Viewport TileUser.
* [[forgetUser]] must be later invoked to unregister the user.
*/
registerUser(user: TileUser): void;
/** Iterable over all TileUsers registered with TileAdmin. This may include [[OffScreenViewport]]s.
* @alpha
*/
get tileUsers(): Iterable<TileUser>;
/** @internal */
invalidateAllScenes(): void;
/** @internal */
onShutDown(): void;
/** Returns the union of the input set and the input TileUser, to be associated with a [[TileRequest]].
* @internal
*/
getTileUserSetForRequest(user: TileUser, users?: ReadonlyTileUserSet): ReadonlyTileUserSet;
/** Marks the Tile as "in use" by the specified TileUser, where the tile defines what "in use" means.
* A tile will not be discarded while it is in use by any TileUser.
* @see [[TileTree.prune]]
* @internal
*/
markTileUsed(marker: TileUsageMarker, user: TileUser): void;
/** Returns true if the Tile is currently in use by any TileUser.
* @see [[markTileUsed]].
* @internal
*/
isTileInUse(marker: TileUsageMarker): boolean;
/** Indicates that the TileAdmin should reset usage tracking for the specified TileUser, e.g. because the user is a Viewport about
* to recreate its scene. Any tiles currently marked as "in use" by this user no longer will be.
* @internal
*/
clearUsageForUser(user: TileUser): void;
/** @internal */
requestTileTreeProps(iModel: IModelConnection, treeId: string): Promise<IModelTileTreeProps>;
/** Temporary workaround for authoring applications. Usage:
* ```ts
* async function handleModelChanged(modelId: Id64String, iModel: IModelConnection): Promise<void> {
* await iModel.tiles.purgeTileTrees([modelId]);
* IModelApp.viewManager.refreshForModifiedModels(modelId);
* }
* ```
* @internal
*/
purgeTileTrees(iModel: IModelConnection, modelIds: Id64Array | undefined): Promise<void>;
/** @internal */
requestCachedTileContent(tile: {
iModelTree: IModelTileTree;
contentId: string;
}): Promise<Uint8Array | undefined>;
/** @internal */
generateTileContent(tile: {
iModelTree: IModelTileTree;
contentId: string;
request?: {
isCanceled: boolean;
};
}): Promise<Uint8Array>;
/** @internal */
getTileRequestProps(tile: {
iModelTree: IModelTileTree;
contentId: string;
}): {
tokenProps: import("@itwin/core-common").IModelRpcProps;
treeId: string;
contentId: string;
guid: string;
};
/** Request graphics for a single element or geometry stream.
* @see [[readElementGraphics]] to convert the result into a [[RenderGraphic]] for display.
* @public
*/
requestElementGraphics(iModel: IModelConnection, requestProps: ElementGraphicsRequestProps): Promise<Uint8Array | undefined>;
/** Obtain information about the version/format of the tiles supplied by the backend. */
queryVersionInfo(): Promise<Readonly<TileVersionInfo>>;
/** @internal */
onTilesElided(numElided: number): void;
/** Invoked when a Tile marks itself as "ready" - i.e., its content is loaded (or determined not to exist, or not to be needed).
* If the tile has content, it is added to the LRU list of tiles with content.
* The `onTileLoad` event will also be raised.
* @internal
*/
onTileContentLoaded(tile: Tile): void;
/** Invoked when a Tile's content is disposed of. It will be removed from the LRU list of tiles with content.
* @internal
*/
onTileContentDisposed(tile: Tile): void;
/** @internal */
terminateTileTreePropsRequest(request: TileTreePropsRequest): void;
/** Event raised when a request to load a tile's content completes. */
readonly onTileLoad: BeEvent<(tile: Tile) => void>;
/** Event raised when a request to load a tile tree completes. */
readonly onTileTreeLoad: BeEvent<(tileTree: TileTreeOwner) => void>;
/** Event raised when a request to load a tile's child tiles completes. */
readonly onTileChildrenLoad: BeEvent<(parentTile: Tile) => void>;
/** Subscribe to [[onTileLoad]], [[onTileTreeLoad]], and [[onTileChildrenLoad]]. */
addLoadListener(callback: (imodel: IModelConnection) => void): () => void;
/** Determine what information about the schedule script is needed to produce tiles.
* If no script, or the script doesn't require batching, then no information is needed - normal tiles can be used.
* If possible and enabled, normal tiles can be requested and then processed on the frontend based on the ModelTimeline.
* Otherwise, special tiles must be requested based on the script's sourceId (RenderTimeline or DisplayStyle element).
* @internal
*/
getScriptInfoForTreeId(modelId: Id64String, script: RenderSchedule.ScriptReference | undefined): {
timeline?: RenderSchedule.ModelTimeline;
animationId?: Id64String;
} | undefined;
private dispatchTileTreePropsRequests;
private processQueue;
/** Exported strictly for tests. @internal */
freeMemory(): void;
private pruneAndPurge;
private processRequests;
private onUserIModelClosed;
private onIModelClosed;
private initializeRpc;
}
/** @public */
export declare namespace TileAdmin {
/** Statistics regarding the current and cumulative state of the [[TileAdmin]]. Useful for monitoring performance and diagnosing problems.
* @public
*/
interface Statistics {
/** The number of requests in the queue which have not yet been dispatched. */
numPendingRequests: number;
/** The number of requests which have been dispatched but not yet completed. */
numActiveRequests: number;
/** The number of requests canceled during the most recent update. */
numCanceled: number;
/** The total number of completed requests during this session. */
totalCompletedRequests: number;
/** The total number of failed requests during this session. */
totalFailedRequests: number;
/** The total number of timed-out requests during this session. */
totalTimedOutRequests: number;
/** The total number of completed requests during this session which produced an empty tile. These tiles also contribute to totalCompletedRequests, but not to totalUndisplayableTiles. */
totalEmptyTiles: number;
/** The total number of completed requests during this session which produced an undisplayable tile. These tiles also contribute to totalCompletedRequests, but not to totalEmptyTiles. */
totalUndisplayableTiles: number;
/** The total number of tiles whose contents were not requested during this session because their volumes were determined to be empty. */
totalElidedTiles: number;
/** The total number of tiles whose contents were not found in cloud storage cache and therefore resulted in a backend request to generate the tile content. */
totalCacheMisses: number;
/** The total number of tiles for which content requests were dispatched. */
totalDispatchedRequests: number;
/** The total number of tiles for which content requests were dispatched and then canceled on the backend before completion. */
totalAbortedRequests: number;
/** The number of in-flight IModelTileTreeProps requests. */
numActiveTileTreePropsRequests: number;
/** The number of pending IModelTileTreeProps requests. */
numPendingTileTreePropsRequests: number;
/** See [[TileContentDecodingStatistics]].
* @beta
*/
decoding: TileContentDecodingStatistics;
}
/** Describes the configuration of the [[TileAdmin]].
* @see [[TileAdmin.create]] to specify the configuration at [[IModelApp.startup]] time.
* @note Many of these settings serve as "feature gates" introduced alongside new, potentially experimental features.
* Over time, as a feature is tested and proven, their relevance wanes, and the feature becomes enabled by default.
* Such properties should be flagged as `beta` and removed or rendered non-operational once the feature itself is considered
* stable.
* @public
*/
interface Props {
/**
* The client side storage implementation of @itwin/object-storage-core to use for retrieving tiles from tile cache.
*
* Defaults to AzureFrontendStorage
* @beta
*/
tileStorage?: FrontendStorage;
/** The maximum number of simultaneously active requests for IModelTileTreeProps. Requests are fulfilled in FIFO order.
*
* Default value: 10
* @alpha
*/
maxActiveTileTreePropsRequests?: number;
/** A default multiplier applied to the size in pixels of a [[Tile]] during tile selection for any [[Viewport]].
* Individual Viewports can override this multiplier if desired.
* A value greater than 1.0 causes lower-resolution tiles to be selected; a value < 1.0 selects higher-resolution tiles.
* This value must be greater than zero.
* This can allow an application to sacrifice quality for performance or vice-versa.
*
* Default value: 1.0
*/
defaultTileSizeModifier?: number;
/** If true, tiles may represent repeated geometry as sets of instances. This can reduce tile size and tile generation time, and improve performance.
*
* Default value: true
*/
enableInstancing?: boolean;
/** If true - and WebGL 2 is supported by the [[RenderSystem]] - when tiles containing edges are requested, request that they produce
* indexed edges to reduce tile size and GPU memory consumption.
*
* Default value: true
*/
enableIndexedEdges?: boolean;
/** If true then if a [Polyface]($geometry) lacks edge visibility information, the display system will display the edges of all of its faces.
* Otherwise, the display system will attempt to infer the visibility of each interior edge based on the angle between the two adjacent faces.
* Edge inference can produce less visually useful results.
*
* Default value: true
* @beta
*/
generateAllPolyfaceEdges?: boolean;
/** If true, during tile generation the backend will perform tighter intersection tests to more accurately identify empty sub-volumes.
* This can reduce the number of tiles requested and the number of tile requests that return no content.
*
* Default value: true
*/
enableImprovedElision?: boolean;
/** If true, during tile generation the backend will omit geometry for area patterns. This can help reduce the amount of memory consumed by the backend and the amount
* of geometry sent to the frontend.
*
* Default value: false
* @public
*/
ignoreAreaPatterns?: boolean;
/** If true, during tile generation the backend will not embed all texture image data in the tile content. If texture image data is considered large enough by the backend, it will not be embedded in the tile content and the frontend will request that element texture data separately from the backend. This can help reduce the amount of memory consumed by the frontend and the amount of data sent to the frontend. Also, if this is enabled, requested textures that exceed the maximum texture size supported by the client will be downsampled.
*
* Default value: true
*/
enableExternalTextures?: boolean;
/** The interval in milliseconds at which a request for tile content will be retried until a response is received.
*
* Default value: 1000 (1 second)
* @public
*/
retryInterval?: number;
/** If defined, specifies the maximum MAJOR tile format version to request. For example, if CurrentImdlVersion.Major = 3, and maximumMajorTileFormatVersion = 2,
* requests for tile content will obtain tile content in some version 2.x of the format, never of some version 3.x.
* Note that the actual maximum major version is also dependent on the backend which fulfills the requests - if the backend only knows how to produce tiles of format version 1.5, for example,
* requests for tiles in format version 2.1 will still return content in format version 1.5.
* This can be used to feature-gate newer tile formats on a per-user basis.
*
* Default value: undefined
* @internal
*/
maximumMajorTileFormatVersion?: number;
/** When computing the range of a spatial tile tree we can use either the range of the model, or the project extents. If the model range is small relative to the
* project extents, the "low-resolution" tiles will be much higher-resolution than is appropriate when the view is fit to the project extents. This can cause poor
* framerate due to too much tiny geometry. Setting this option to `true` will use the project extents for the tile tree range; `false` will use the model range.
*
* Default value: true
*
* @internal
*/
useProjectExtents?: boolean;
/** @internal See TreeFlags.ExpandProjectExtents. Default: true. */
expandProjectExtents?: boolean;
/** When producing facets from BRep entities, use an optimized pipeline to improve performance.
* Default value: true
* @internal
*/
optimizeBRepProcessing?: boolean;
/** Produce tiles that are larger in screen pixels to reduce the number of tiles requested and drawn by the scene.
* Default value: true
* @public
*/
useLargerTiles?: boolean;
/** Specifies that metadata about each [[IModelTile]] loaded during the session should be cached until the corresponding [[IModelConnection]] is closed; and
* that the graphics for cached tiles should never be reloaded when the tile is re-requested after having been discarded. This fulfills a niche scenario in
* which the application does not care about displaying the graphics, only about ensuring the tile content is generated and uploaded to blob storage.
* @internal
*/
cacheTileMetadata?: boolean;
/** The minimum number of seconds to keep a Tile in memory after it has become unused.
* Each tile has an expiration timer. Each time tiles are selected for drawing in a view, if we decide to draw a tile we reset its expiration timer.
* Otherwise, if its expiration timer has exceeded this minimum, we discard it along with all of its children. This allows us to free up memory for other tiles.
* If we later want to draw the same tile, we must re-request it (typically from some cache).
* Setting this value too small will cause excessive tile requests. Setting it too high will cause excessive memory consumption.
*
* Default value: 20 seconds.
* Minimum value: 5 seconds.
* Maximum value: 60 seconds.
*/
tileExpirationTime?: number;
/** The minimum number of seconds to keep a TileTree in memory after it has become disused.
* Each time a TileTree is drawn, we record the current time as its most-recently-used time.
* Periodically we traverse all TileTrees in the system. Any which have not been used within this specified number of seconds will be discarded, freeing up memory.
*
* @note This is separate from [[tileExpirationTime]], which is applied to individual Tiles each time the TileTree *is* drawn.
*
* Default value: 300 seconds (5 minutes).
* Minimum value: 10 seconds.
* Maximum value: 3600 seconds (1 hour).
*
* @public
*/
tileTreeExpirationTime?: number;
/** Defines optional limits on the total amount of GPU memory allocated to [[Tile]] contents.
* If an instance of [[GpuMemoryLimits]], defines separate limits for mobile and non-mobile devices; otherwise, defines the limit for whatever
* type of device the client is running on.
*
* Default value: `{ "mobile": "default" }`.
*
* @see [[GpuMemoryLimit]] for a description of the available limits and how they are imposed.
*/
gpuMemoryLimits?: GpuMemoryLimit | GpuMemoryLimits;
/** Nominally the error on screen size of a reality tile. The minimum value of 1.0 will apply a direct 1:1 scale.
* A ratio higher than 1.0 will result in lower quality display as the reality tile refinement becomes more coarse.
*
* @note This value only has an effect on mobile devices. On non-mobile devices, this ratio will always internally be 1.0 and any setting here will be ignored.
*
* Default value: 3.0
* Minimum value: 1.0
*
* @public
*/
mobileRealityTileMinToleranceRatio?: number;
/** Used strictly for tests to circumvent the minimum expiration times.
* This allows tests to reduce the expiration times below their stated minimums so that tests execute more quickly.
* @internal
*/
ignoreMinimumExpirationTimes?: boolean;
/** When producing child tiles for a given tile, two refinement strategies are considered:
* - Subdivision: typical oct- or quad-tree subdivision into 8 or 4 smaller child tiles; and
* - Magnification: production of a single child tile of the same size as the parent but with twice the level of detail
* The magnification strategy can in some cases produce extremely large, detailed tiles, because the heuristic which decides which strategy to use considers that if
* a tile contains fewer than some "small" number of elements, it is not worth subdividing, and instead chooses magnification - but element sizes vary **wildly**.
*
* If this option is defined and true, the magnification strategy will never be chosen.
*
* Default value: false
* @alpha
*/
disableMagnification?: boolean;
/** The Percentage of GPU memory utilization at which to disable preloading for context (reality and map tiles).
* While GPU memory usage is at or above this percentage of the limit, preloading will be disabled.
* A setting of 0 will disable preloading altogether.
* If GpuMemoryLimit is "none", then a setting of anything above 0 is ignored.
* Mobile devices do not allow preloading and will ignore this setting.
*
* Default value: 80
* Minimum value 0.
* Maximum value 80.
* @alpha
*/
percentGPUMemDisablePreload?: number;
/** Preloading parents for context (reality and map tiles) will improve the user experience by making it more likely that tiles in nearly the required resolution will be
* already loaded as the view is manipulated. This value controls the depth above the the selected tile depth that will be preloaded. The default
* value (2) with default contextPreloadParentDepth of one will load only grandparents and great grandparents. This generally preloads around 20% more tiles than are required.
* Default value: 2.
* Minimum value 0.
* Maximum value 8.
* @alpha
*/
contextPreloadParentDepth?: number;
/** Preloading parents for context (reality and map tiles) will improve the user experience by making it more likely that tiles in nearly the required resolution will be
* already loaded as the view is manipulated. This value controls the number of parents that are skipped before parents are preloaded. The default value of 1 will skip
* immediate parents and significantly reduce the number of preloaded tiles without significant reducing the value of preloading.
* Default value: 1;
* Minimum value: 0.
* Maximum value: 5.
* @alpha
*/
contextPreloadParentSkip?: number;
/** For iModel tile trees, the maximum number of levels of the tree to skip loading when selecting tiles.
* When selecting tiles, if a given tile is too coarse to display and its graphics have not yet been loaded, we can skip loading its graphics and instead try to select one or more of its children
* - *until* we have skipped the specified maximum number of levels of the tree, at which point we will load the coarse tile's graphics before evaluating its children for selection.
* Increasing this value can reduce the amount of time before all tiles are ready when opening a zoomed-in view, but can also increase the number of tiles requested.
* Default value: 1
* Minimum value: 0
* @alpha
*/
maximumLevelsToSkip?: number;
/** If true, when requesting tile content, edges will always be requested, even if they are not required for the view.
* This can improve user experience in cases in which the user or application is expected to frequently switch between views of the same models with
* different edge settings, because otherwise, toggling edge display may require loading completely new tiles.
* However, edges require additional memory and bandwidth that may be wasted if they are never displayed.
* Default value: false
* @public
*/
alwaysRequestEdges?: boolean;
/** If true, when choosing whether to sub-divide or magnify a tile for refinement, the tile will always be sub-divided if any geometry was omitted from it.
* Default value: false
* @internal
*/
alwaysSubdivideIncompleteTiles?: boolean;
/** If defined and greater than zero, specifies the minimum chord tolerance in meters of a tile. A tile with chord tolerance less than this minimum will not be refined.
* Applies only to spatial models, which model real-world assets on real-world scales.
* A reasonable value is on the order of millimeters.
* Default value: 0.001 (1 millimeter).
* @public
*/
minimumSpatialTolerance?: number;
/** An API key that can be used to access content from [Cesium ION](https://cesium.com/platform/cesium-ion/) like terrain meshes and OpenStreetMap Buildings meshes.
* If a valid key is not supplied, such content can neither be obtained nor displayed.
* @public
*/
cesiumIonKey?: string;
/** If true, when applying a schedule script to a view, ordinary tiles will be requested and then reprocessed on the frontend to align with the script's
* animation nodes. This permits the use of schedule scripts not stored in the iModel and improves utilization of the tile cache for animated views.
* If false, the schedule script must be stored in the iModel and special tiles must be requested from the backend to align with the script's animation nodes.
* Default value: false.
* @public
*/
enableFrontendScheduleScripts?: boolean;
/** If true, contents of tiles in iMdl format will be decoded in a web worker to avoid blocking the main (UI) thread.
* Default value: true
* @alpha This was primarily introduced because the electron version of certa does not serve local assets, so the tests can't locate the worker script.
*/
decodeImdlInWorker?: boolean;
/** If true, disable polyface decimation during tile generation.
* When the tiler encounters a [Polyface]($geometry) in an element's geometry stream, it may attempt to reduce the number of vertices
* to match the tile's level of detail ("LOD"). This can deform the mesh, though the deformation is generally not noticeable at the tile's LOD.
* If `disablePolyfaceDecimation` is `true`, the tiler will never attempt to decimate polyfaces.
* Default value: false.
* @beta
*/
disablePolyfaceDecimation?: boolean;
}
/** The number of bytes of GPU memory associated with the various [[GpuMemoryLimit]]s for non-mobile devices.
* @see [[TileAdmin.Props.gpuMemoryLimits]] to specify the limit at startup.
* @see [[TileAdmin.gpuMemoryLimit]] to adjust the actual limit after startup.
* @see [[TileAdmin.mobileMemoryLimits]] for mobile devices.
*/
const nonMobileGpuMemoryLimits: {
default: number;
aggressive: number;
relaxed: number;
};
/** @internal exported for tests */
const nonMobileUndefinedGpuMemoryLimit: number;
/** The number of bytes of GPU memory associated with the various [[GpuMemoryLimit]]s for mobile devices.
* @see [[TileAdmin.Props.gpuMemoryLimits]] to specify the limit at startup.
* @see [[TileAdmin.gpuMemoryLimit]] to adjust the actual limit after startup.
* @see [[TileAdmin.nonMobileMemoryLimits]] for non-mobile devices.
*/
const mobileGpuMemoryLimits: {
default: number;
aggressive: number;
relaxed: number;
};
}
/** Some views contain thousands of models. When we open such a view, the first thing we do is request the IModelTileTreeProps for each model. This involves a http request per model,
* which can exceed the maximum number of simultaneous requests permitted by the browser.
* Similar to how we throttle requests for tile *content*, we throttle requests for IModelTileTreeProps based on `TileAdmin.Props.maxActiveTileTreePropsRequests`, heretofore referred to as `N`.
* TileAdmin maintains a FIFO queue of requests for IModelTileTreeProps. The first N of those requests have been dispatched; the remainder are waiting for their turn.
* When `TileAdmin.requestTileTreeProps` is called, it appends a new request to the queue, and if the queue length < N, dispatches it immediately.
* When a request completes, throws an error, or is canceled, it is removed from the queue, and any not-yet-dispatched requests are dispatched (not exceeding N total in flight).
* When an IModelConnection is closed, any requests associated with that iModel are canceled.
* NOTE: This request queue currently does not interact at all with the tile content request queue.
* NOTE: We rely on TreeOwner to not request the same IModelTileTreeProps multiple times - we do not check the queue for presence of a requested tree before enqeueing it.
*/
declare class TileTreePropsRequest {
readonly iModel: IModelConnection;
private readonly _treeId;
private readonly _resolve;
private readonly _reject;
private _isDispatched;
constructor(iModel: IModelConnection, _treeId: string, _resolve: (props: IModelTileTreeProps) => void, _reject: (error: Error) => void);
get isDispatched(): boolean;
dispatch(): void;
/** The IModelConnection was closed, or IModelApp was shut down. Don't call terminate(), because we don't want to dispatch pending requests as a result.
* Just reject if not yet dispatched.
*/
abandon(): void;
private terminate;
}
/** @internal */
export type RequestTileTreePropsFunc = (iModel: IModelConnection, treeId: string) => Promise<IModelTileTreeProps>;
/** Strictly for tests - overrides the call to IModelTileRpcInterface.requestTileTreeProps with a custom function, or clears the override.
* @internal
*/
export declare function overrideRequestTileTreeProps(func: RequestTileTreePropsFunc | undefined): void;
export {};
//# sourceMappingURL=TileAdmin.d.ts.map