@itwin/core-frontend 3.1.0-dev.7 → 3.1.0-dev.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/BriefcaseConnection.d.ts.map +1 -1
- package/lib/cjs/BriefcaseConnection.js +6 -5
- package/lib/cjs/BriefcaseConnection.js.map +1 -1
- package/lib/cjs/DrawingViewState.js +3 -3
- package/lib/cjs/DrawingViewState.js.map +1 -1
- package/lib/cjs/SheetViewState.js +3 -3
- package/lib/cjs/SheetViewState.js.map +1 -1
- package/lib/cjs/Viewport.d.ts +6 -3
- package/lib/cjs/Viewport.d.ts.map +1 -1
- package/lib/cjs/Viewport.js +16 -9
- package/lib/cjs/Viewport.js.map +1 -1
- package/lib/cjs/tile/DynamicIModelTile.d.ts.map +1 -1
- package/lib/cjs/tile/DynamicIModelTile.js +1 -1
- package/lib/cjs/tile/DynamicIModelTile.js.map +1 -1
- package/lib/cjs/tile/LRUTileList.d.ts +29 -29
- package/lib/cjs/tile/LRUTileList.d.ts.map +1 -1
- package/lib/cjs/tile/LRUTileList.js +50 -50
- package/lib/cjs/tile/LRUTileList.js.map +1 -1
- package/lib/cjs/tile/OrbitGtTileTree.js +1 -1
- package/lib/cjs/tile/OrbitGtTileTree.js.map +1 -1
- package/lib/cjs/tile/RealityModelTileTree.d.ts.map +1 -1
- package/lib/cjs/tile/RealityModelTileTree.js +1 -1
- package/lib/cjs/tile/RealityModelTileTree.js.map +1 -1
- package/lib/cjs/tile/RealityTile.d.ts +2 -2
- package/lib/cjs/tile/RealityTile.d.ts.map +1 -1
- package/lib/cjs/tile/RealityTile.js +2 -2
- package/lib/cjs/tile/RealityTile.js.map +1 -1
- package/lib/cjs/tile/RealityTileLoader.d.ts +2 -2
- package/lib/cjs/tile/RealityTileLoader.d.ts.map +1 -1
- package/lib/cjs/tile/RealityTileLoader.js +1 -1
- package/lib/cjs/tile/RealityTileLoader.js.map +1 -1
- package/lib/cjs/tile/RealityTileTree.js +1 -1
- package/lib/cjs/tile/RealityTileTree.js.map +1 -1
- package/lib/cjs/tile/Tile.d.ts +5 -4
- package/lib/cjs/tile/Tile.d.ts.map +1 -1
- package/lib/cjs/tile/Tile.js +3 -2
- package/lib/cjs/tile/Tile.js.map +1 -1
- package/lib/cjs/tile/TileAdmin.d.ts +43 -45
- package/lib/cjs/tile/TileAdmin.d.ts.map +1 -1
- package/lib/cjs/tile/TileAdmin.js +104 -99
- package/lib/cjs/tile/TileAdmin.js.map +1 -1
- package/lib/cjs/tile/TileRequest.d.ts +12 -9
- package/lib/cjs/tile/TileRequest.d.ts.map +1 -1
- package/lib/cjs/tile/TileRequest.js +19 -11
- package/lib/cjs/tile/TileRequest.js.map +1 -1
- package/lib/cjs/tile/TileRequestChannel.js +3 -3
- package/lib/cjs/tile/TileRequestChannel.js.map +1 -1
- package/lib/cjs/tile/TileTree.js +1 -1
- package/lib/cjs/tile/TileTree.js.map +1 -1
- package/lib/cjs/tile/TileTreeReference.d.ts +1 -1
- package/lib/cjs/tile/TileTreeReference.js +1 -1
- package/lib/cjs/tile/TileTreeReference.js.map +1 -1
- package/lib/cjs/tile/TileUsageMarker.d.ts +9 -9
- package/lib/cjs/tile/TileUsageMarker.d.ts.map +1 -1
- package/lib/cjs/tile/TileUsageMarker.js +9 -9
- package/lib/cjs/tile/TileUsageMarker.js.map +1 -1
- package/lib/cjs/tile/TileUser.d.ts +33 -0
- package/lib/cjs/tile/TileUser.d.ts.map +1 -0
- package/lib/cjs/tile/TileUser.js +28 -0
- package/lib/cjs/tile/TileUser.js.map +1 -0
- package/lib/cjs/tile/TileUserSet.d.ts +28 -0
- package/lib/cjs/tile/TileUserSet.d.ts.map +1 -0
- package/lib/cjs/tile/TileUserSet.js +123 -0
- package/lib/cjs/tile/TileUserSet.js.map +1 -0
- package/lib/cjs/tile/internal.d.ts +2 -0
- package/lib/cjs/tile/internal.d.ts.map +1 -1
- package/lib/cjs/tile/internal.js +2 -0
- package/lib/cjs/tile/internal.js.map +1 -1
- package/lib/cjs/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.d.ts +1 -2
- package/lib/cjs/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.d.ts.map +1 -1
- package/lib/cjs/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.js +1 -1
- package/lib/cjs/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.js.map +1 -1
- package/lib/cjs/tile/map/ImageryProviders/AzureMapsLayerImageryProvider.d.ts +1 -2
- package/lib/cjs/tile/map/ImageryProviders/AzureMapsLayerImageryProvider.d.ts.map +1 -1
- package/lib/cjs/tile/map/ImageryProviders/AzureMapsLayerImageryProvider.js +1 -1
- package/lib/cjs/tile/map/ImageryProviders/AzureMapsLayerImageryProvider.js.map +1 -1
- package/lib/cjs/tile/map/ImageryProviders/BingImageryProvider.js +1 -1
- package/lib/cjs/tile/map/ImageryProviders/BingImageryProvider.js.map +1 -1
- package/lib/cjs/tile/map/ImageryProviders/MapBoxLayerImageryProvider.d.ts +1 -2
- package/lib/cjs/tile/map/ImageryProviders/MapBoxLayerImageryProvider.d.ts.map +1 -1
- package/lib/cjs/tile/map/ImageryProviders/MapBoxLayerImageryProvider.js +1 -1
- package/lib/cjs/tile/map/ImageryProviders/MapBoxLayerImageryProvider.js.map +1 -1
- package/lib/cjs/tile/map/ImageryTileTree.d.ts +2 -2
- package/lib/cjs/tile/map/ImageryTileTree.d.ts.map +1 -1
- package/lib/cjs/tile/map/ImageryTileTree.js +1 -1
- package/lib/cjs/tile/map/ImageryTileTree.js.map +1 -1
- package/lib/cjs/tile/map/MapTileTree.d.ts +3 -3
- package/lib/cjs/tile/map/MapTileTree.js +4 -4
- package/lib/cjs/tile/map/MapTileTree.js.map +1 -1
- package/lib/esm/BriefcaseConnection.d.ts.map +1 -1
- package/lib/esm/BriefcaseConnection.js +6 -5
- package/lib/esm/BriefcaseConnection.js.map +1 -1
- package/lib/esm/DrawingViewState.js +3 -3
- package/lib/esm/DrawingViewState.js.map +1 -1
- package/lib/esm/SheetViewState.js +3 -3
- package/lib/esm/SheetViewState.js.map +1 -1
- package/lib/esm/Viewport.d.ts +6 -3
- package/lib/esm/Viewport.d.ts.map +1 -1
- package/lib/esm/Viewport.js +17 -10
- package/lib/esm/Viewport.js.map +1 -1
- package/lib/esm/tile/DynamicIModelTile.d.ts.map +1 -1
- package/lib/esm/tile/DynamicIModelTile.js +1 -1
- package/lib/esm/tile/DynamicIModelTile.js.map +1 -1
- package/lib/esm/tile/LRUTileList.d.ts +29 -29
- package/lib/esm/tile/LRUTileList.d.ts.map +1 -1
- package/lib/esm/tile/LRUTileList.js +47 -47
- package/lib/esm/tile/LRUTileList.js.map +1 -1
- package/lib/esm/tile/OrbitGtTileTree.js +1 -1
- package/lib/esm/tile/OrbitGtTileTree.js.map +1 -1
- package/lib/esm/tile/RealityModelTileTree.d.ts.map +1 -1
- package/lib/esm/tile/RealityModelTileTree.js +1 -1
- package/lib/esm/tile/RealityModelTileTree.js.map +1 -1
- package/lib/esm/tile/RealityTile.d.ts +2 -2
- package/lib/esm/tile/RealityTile.d.ts.map +1 -1
- package/lib/esm/tile/RealityTile.js +2 -2
- package/lib/esm/tile/RealityTile.js.map +1 -1
- package/lib/esm/tile/RealityTileLoader.d.ts +2 -2
- package/lib/esm/tile/RealityTileLoader.d.ts.map +1 -1
- package/lib/esm/tile/RealityTileLoader.js +1 -1
- package/lib/esm/tile/RealityTileLoader.js.map +1 -1
- package/lib/esm/tile/RealityTileTree.js +1 -1
- package/lib/esm/tile/RealityTileTree.js.map +1 -1
- package/lib/esm/tile/Tile.d.ts +5 -4
- package/lib/esm/tile/Tile.d.ts.map +1 -1
- package/lib/esm/tile/Tile.js +3 -2
- package/lib/esm/tile/Tile.js.map +1 -1
- package/lib/esm/tile/TileAdmin.d.ts +43 -45
- package/lib/esm/tile/TileAdmin.d.ts.map +1 -1
- package/lib/esm/tile/TileAdmin.js +105 -100
- package/lib/esm/tile/TileAdmin.js.map +1 -1
- package/lib/esm/tile/TileRequest.d.ts +12 -9
- package/lib/esm/tile/TileRequest.d.ts.map +1 -1
- package/lib/esm/tile/TileRequest.js +19 -11
- package/lib/esm/tile/TileRequest.js.map +1 -1
- package/lib/esm/tile/TileRequestChannel.js +3 -3
- package/lib/esm/tile/TileRequestChannel.js.map +1 -1
- package/lib/esm/tile/TileTree.js +1 -1
- package/lib/esm/tile/TileTree.js.map +1 -1
- package/lib/esm/tile/TileTreeReference.d.ts +1 -1
- package/lib/esm/tile/TileTreeReference.js +1 -1
- package/lib/esm/tile/TileTreeReference.js.map +1 -1
- package/lib/esm/tile/TileUsageMarker.d.ts +9 -9
- package/lib/esm/tile/TileUsageMarker.d.ts.map +1 -1
- package/lib/esm/tile/TileUsageMarker.js +9 -9
- package/lib/esm/tile/TileUsageMarker.js.map +1 -1
- package/lib/esm/tile/TileUser.d.ts +33 -0
- package/lib/esm/tile/TileUser.d.ts.map +1 -0
- package/lib/esm/tile/TileUser.js +25 -0
- package/lib/esm/tile/TileUser.js.map +1 -0
- package/lib/esm/tile/TileUserSet.d.ts +28 -0
- package/lib/esm/tile/TileUserSet.d.ts.map +1 -0
- package/lib/esm/tile/TileUserSet.js +118 -0
- package/lib/esm/tile/TileUserSet.js.map +1 -0
- package/lib/esm/tile/internal.d.ts +2 -0
- package/lib/esm/tile/internal.d.ts.map +1 -1
- package/lib/esm/tile/internal.js +2 -0
- package/lib/esm/tile/internal.js.map +1 -1
- package/lib/esm/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.d.ts +1 -2
- package/lib/esm/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.d.ts.map +1 -1
- package/lib/esm/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.js +1 -1
- package/lib/esm/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.js.map +1 -1
- package/lib/esm/tile/map/ImageryProviders/AzureMapsLayerImageryProvider.d.ts +1 -2
- package/lib/esm/tile/map/ImageryProviders/AzureMapsLayerImageryProvider.d.ts.map +1 -1
- package/lib/esm/tile/map/ImageryProviders/AzureMapsLayerImageryProvider.js +1 -1
- package/lib/esm/tile/map/ImageryProviders/AzureMapsLayerImageryProvider.js.map +1 -1
- package/lib/esm/tile/map/ImageryProviders/BingImageryProvider.js +1 -1
- package/lib/esm/tile/map/ImageryProviders/BingImageryProvider.js.map +1 -1
- package/lib/esm/tile/map/ImageryProviders/MapBoxLayerImageryProvider.d.ts +1 -2
- package/lib/esm/tile/map/ImageryProviders/MapBoxLayerImageryProvider.d.ts.map +1 -1
- package/lib/esm/tile/map/ImageryProviders/MapBoxLayerImageryProvider.js +1 -1
- package/lib/esm/tile/map/ImageryProviders/MapBoxLayerImageryProvider.js.map +1 -1
- package/lib/esm/tile/map/ImageryTileTree.d.ts +2 -2
- package/lib/esm/tile/map/ImageryTileTree.d.ts.map +1 -1
- package/lib/esm/tile/map/ImageryTileTree.js +1 -1
- package/lib/esm/tile/map/ImageryTileTree.js.map +1 -1
- package/lib/esm/tile/map/MapTileTree.d.ts +3 -3
- package/lib/esm/tile/map/MapTileTree.js +4 -4
- package/lib/esm/tile/map/MapTileTree.js.map +1 -1
- package/package.json +20 -20
- package/lib/cjs/ViewportSet.d.ts +0 -28
- package/lib/cjs/ViewportSet.d.ts.map +0 -1
- package/lib/cjs/ViewportSet.js +0 -126
- package/lib/cjs/ViewportSet.js.map +0 -1
- package/lib/esm/ViewportSet.d.ts +0 -28
- package/lib/esm/ViewportSet.d.ts.map +0 -1
- package/lib/esm/ViewportSet.js +0 -121
- package/lib/esm/ViewportSet.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TileRequest.js","sourceRoot":"","sources":["../../../src/tile/TileRequest.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,wBAAwB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACrF,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;A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hB;AACH,CAAC,EA7BgB,WAAW,KAAX,WAAW,QA6B3B","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Tiles\r\n */\r\n\r\nimport { assert, base64StringToUint8Array, IModelStatus } from \"@itwin/core-bentley\";\r\nimport { ImageSource } from \"@itwin/core-common\";\r\nimport { IModelApp } from \"../IModelApp\";\r\nimport { Viewport } from \"../Viewport\";\r\nimport { ReadonlyViewportSet } from \"../ViewportSet\";\r\nimport { Tile, TileContent, TileRequestChannel, TileTree } from \"./internal\";\r\n\r\n/** Represents a pending or active request to load the contents of a [[Tile]]. The request coordinates with the [[Tile.requestContent]] to obtain the raw content and\r\n * [[Tile.readContent]] to convert the result into a [[RenderGraphic]]. TileRequests are created internally as needed; it is never necessary or useful for external code to create them.\r\n * @public\r\n */\r\nexport class TileRequest {\r\n /** The requested tile. While the request is pending or active, `tile.request` points back to this TileRequest. */\r\n public readonly tile: Tile;\r\n /** The channel via which the request will be executed. */\r\n public readonly channel: TileRequestChannel;\r\n /** The set of [[Viewport]]s that are awaiting the result of this request. When this becomes empty, the request is canceled because no viewport cares about it. */\r\n public viewports: ReadonlyViewportSet;\r\n private _state: TileRequest.State;\r\n /** Determines the order in which pending requests are pulled off the queue to become active. A tile with a lower priority value takes precedence over one with a higher value. */\r\n public priority = 0;\r\n\r\n /** Constructor */\r\n public constructor(tile: Tile, vp: Viewport) {\r\n this._state = TileRequest.State.Queued;\r\n this.tile = tile;\r\n this.channel = tile.channel;\r\n this.viewports = IModelApp.tileAdmin.getViewportSetForRequest(vp);\r\n }\r\n\r\n /** The request's current state. */\r\n public get state(): TileRequest.State { return this._state; }\r\n\r\n /** True if the request has been enqueued but not yet dispatched. */\r\n public get isQueued() { return TileRequest.State.Queued === this._state; }\r\n\r\n /** True if the request has been canceled. */\r\n public get isCanceled(): boolean {\r\n // If iModel was closed, cancel immediately\r\n if (this.tile.iModel.tiles.isDisposed)\r\n return true;\r\n\r\n // After we've received the raw tile data, always finish processing it - otherwise tile may end up in limbo (and producing tile content should be faster than re-requesting raw data).\r\n if (TileRequest.State.Loading === this._state)\r\n return false;\r\n\r\n // If no viewport cares about this tile any more, we're canceled.\r\n return this.viewports.isEmpty;\r\n }\r\n\r\n /** The tile tree to which the requested [[Tile]] belongs. */\r\n public get tree(): TileTree { return this.tile.tree; }\r\n\r\n /** Indicate that the specified viewport is awaiting the result of this request.\r\n * @internal\r\n */\r\n public addViewport(vp: Viewport): void {\r\n this.viewports = IModelApp.tileAdmin.getViewportSetForRequest(vp, this.viewports);\r\n }\r\n\r\n /** Transition the request from \"queued\" to \"active\", kicking off a series of asynchronous operations usually beginning with an http request, and -\r\n * if the request is not subsequently canceled - resulting in either a successfully-loaded Tile, or a failed (\"not found\") Tile.\r\n * @internal\r\n */\r\n public async dispatch(onHttpResponse: () => void): Promise<void> {\r\n if (this.isCanceled)\r\n return;\r\n\r\n assert(this._state === TileRequest.State.Queued);\r\n this._state = TileRequest.State.Dispatched;\r\n let response;\r\n let gotResponse = false;\r\n try {\r\n response = await this.channel.requestContent(this.tile, () => this.isCanceled);\r\n gotResponse = true;\r\n\r\n // Set this now, so our `isCanceled` check can see it.\r\n this._state = TileRequest.State.Loading;\r\n } catch (err: any) {\r\n if (err.errorNumber && err.errorNumber === IModelStatus.ServerTimeout) {\r\n // Invalidate scene - if tile is re-selected, it will be re-requested.\r\n this.notifyAndClear();\r\n this._state = TileRequest.State.Failed;\r\n this.channel.recordTimeout();\r\n } else {\r\n // Unknown error - not retryable\r\n this.setFailed();\r\n }\r\n }\r\n\r\n // Notify caller that we have finished http activity.\r\n onHttpResponse();\r\n\r\n if (!gotResponse || this.isCanceled)\r\n return;\r\n\r\n if (undefined === response && this.channel.onNoContent(this)) {\r\n // Invalidate scene - if tile is re-selected, it will be re-requested - presumably via a different channel.\r\n this.notifyAndClear();\r\n this._state = TileRequest.State.Failed;\r\n return;\r\n }\r\n\r\n return this.handleResponse(response);\r\n }\r\n\r\n /** Cancels this request. This leaves the associated Tile's state untouched.\r\n * @internal\r\n */\r\n public cancel(): void {\r\n this.notifyAndClear();\r\n if (TileRequest.State.Dispatched === this._state)\r\n this.channel.onActiveRequestCanceled(this);\r\n\r\n this._state = TileRequest.State.Failed;\r\n }\r\n\r\n /** Invalidates the scene of each [[Viewport]] interested in this request - typically because the request succeeded, failed, or was canceled. */\r\n private notify(): void {\r\n this.viewports.forEach((vp) => vp.invalidateScene());\r\n }\r\n\r\n /** Invalidates the scene of each [[Viewport]] interested in this request and clears the set of interested viewports. */\r\n private notifyAndClear(): void {\r\n this.notify();\r\n this.viewports = IModelApp.tileAdmin.emptyViewportSet;\r\n this.tile.request = undefined;\r\n }\r\n\r\n private setFailed() {\r\n this.notifyAndClear();\r\n this._state = TileRequest.State.Failed;\r\n this.tile.setNotFound();\r\n this.channel.recordFailure();\r\n }\r\n\r\n /** Invoked when the raw tile content becomes available, to convert it into a tile graphic. */\r\n private async handleResponse(response: TileRequest.Response): Promise<void> {\r\n let content: TileContent | undefined;\r\n let data: TileRequest.ResponseData | undefined;\r\n if (undefined !== response) {\r\n if (typeof response === \"string\")\r\n data = base64StringToUint8Array(response);\r\n else if (response instanceof Uint8Array || response instanceof ImageSource)\r\n data = response;\r\n else if (response instanceof ArrayBuffer)\r\n data = new Uint8Array(response);\r\n else if (typeof response === \"object\" && undefined !== response.content)\r\n content = response.content;\r\n }\r\n\r\n if (!content && !data) {\r\n this.setFailed();\r\n return;\r\n }\r\n\r\n try {\r\n if (!content) {\r\n assert(undefined !== data);\r\n content = await this.tile.readContent(data, IModelApp.renderSystem, () => this.isCanceled);\r\n if (this.isCanceled)\r\n return;\r\n }\r\n\r\n this._state = TileRequest.State.Completed;\r\n this.tile.setContent(content);\r\n this.notifyAndClear();\r\n this.channel.recordCompletion(this.tile, content);\r\n } catch (_err) {\r\n this.setFailed();\r\n }\r\n }\r\n}\r\n\r\n/** @public */\r\nexport namespace TileRequest { // eslint-disable-line no-redeclare\r\n /** The type of a raw response to a request for tile content. Processed upon receipt into a [[TileRequest.Response]] type.\r\n * [[Tile.requestContent]] produces a response of this type; it is then converted to a [[Tile.ResponseData]] from which [[Tile.readContent]]\r\n * can produce a [[RenderGraphic]].\r\n * @public\r\n */\r\n export type Response = Uint8Array | ArrayBuffer | string | ImageSource | { content: TileContent } | undefined;\r\n\r\n /** The input to [[Tile.readContent]], to be converted into a [[RenderGraphic]].\r\n * @public\r\n */\r\n export type ResponseData = Uint8Array | ImageSource;\r\n\r\n /** The states through which a [[TileRequest]] proceeds. During the first 3 states, the [[Tile]]'s `request` member is defined,\r\n * and its [[Tile.LoadStatus]] is computed based on the state of its request.\r\n *@ public\r\n */\r\n export enum State {\r\n /** Initial state. Request is pending but not yet dispatched. */\r\n Queued,\r\n /** Follows `Queued` when request begins to be actively processed. */\r\n Dispatched,\r\n /** Follows `Dispatched` when the response to the request is being converted into tile graphics. */\r\n Loading,\r\n /** Follows `Loading` when tile graphic has successfully been produced. */\r\n Completed,\r\n /** Follows any state in which an error prevents progression, or during which the request was canceled. */\r\n Failed,\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"TileRequest.js","sourceRoot":"","sources":["../../../src/tile/TileRequest.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,wBAAwB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACrF,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAwE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE5G;;;GAGG;AACH,MAAM,OAAO,WAAW;IAatB,kBAAkB;IAClB,YAAmB,IAAU,EAAE,IAAc;QAJ7C,kLAAkL;QAC3K,aAAQ,GAAG,C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AAL,iBAAK,QAWhB;AACH,CAAC,EA7BgB,WAAW,KAAX,WAAW,QA6B3B","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Tiles\r\n */\r\n\r\nimport { assert, base64StringToUint8Array, IModelStatus } from \"@itwin/core-bentley\";\r\nimport { ImageSource } from \"@itwin/core-common\";\r\nimport { IModelApp } from \"../IModelApp\";\r\nimport { Viewport } from \"../Viewport\";\r\nimport { ReadonlyTileUserSet, Tile, TileContent, TileRequestChannel, TileTree, TileUser } from \"./internal\";\r\n\r\n/** Represents a pending or active request to load the contents of a [[Tile]]. The request coordinates with the [[Tile.requestContent]] to obtain the raw content and\r\n * [[Tile.readContent]] to convert the result into a [[RenderGraphic]]. TileRequests are created internally as needed; it is never necessary or useful for external code to create them.\r\n * @public\r\n */\r\nexport class TileRequest {\r\n /** The requested tile. While the request is pending or active, `tile.request` points back to this TileRequest. */\r\n public readonly tile: Tile;\r\n /** The channel via which the request will be executed. */\r\n public readonly channel: TileRequestChannel;\r\n /** The set of [[TileUser]]s that are awaiting the result of this request. When this becomes empty, the request is canceled because no user cares about it.\r\n * @internal\r\n */\r\n public users: ReadonlyTileUserSet;\r\n private _state: TileRequest.State;\r\n /** Determines the order in which pending requests are pulled off the queue to become active. A tile with a lower priority value takes precedence over one with a higher value. */\r\n public priority = 0;\r\n\r\n /** Constructor */\r\n public constructor(tile: Tile, user: TileUser) {\r\n this._state = TileRequest.State.Queued;\r\n this.tile = tile;\r\n this.channel = tile.channel;\r\n this.users = IModelApp.tileAdmin.getTileUserSetForRequest(user);\r\n }\r\n\r\n /** The set of [[Viewport]]s that are awaiting the result of this request. When this becomes empty, the request is canceled because no user cares about it. */\r\n public get viewports(): Iterable<Viewport> {\r\n return TileUser.viewportsFromUsers(this.users);\r\n }\r\n\r\n /** The request's current state. */\r\n public get state(): TileRequest.State { return this._state; }\r\n\r\n /** True if the request has been enqueued but not yet dispatched. */\r\n public get isQueued() { return TileRequest.State.Queued === this._state; }\r\n\r\n /** True if the request has been canceled. */\r\n public get isCanceled(): boolean {\r\n // If iModel was closed, cancel immediately\r\n if (this.tile.iModel.tiles.isDisposed)\r\n return true;\r\n\r\n // After we've received the raw tile data, always finish processing it - otherwise tile may end up in limbo (and producing tile content should be faster than re-requesting raw data).\r\n if (TileRequest.State.Loading === this._state)\r\n return false;\r\n\r\n // If no user cares about this tile any more, we're canceled.\r\n return this.users.isEmpty;\r\n }\r\n\r\n /** The tile tree to which the requested [[Tile]] belongs. */\r\n public get tree(): TileTree { return this.tile.tree; }\r\n\r\n /** Indicate that the specified user is awaiting the result of this request.\r\n * @internal\r\n */\r\n public addUser(user: TileUser): void {\r\n this.users = IModelApp.tileAdmin.getTileUserSetForRequest(user, this.users);\r\n }\r\n\r\n /** Transition the request from \"queued\" to \"active\", kicking off a series of asynchronous operations usually beginning with an http request, and -\r\n * if the request is not subsequently canceled - resulting in either a successfully-loaded Tile, or a failed (\"not found\") Tile.\r\n * @internal\r\n */\r\n public async dispatch(onHttpResponse: () => void): Promise<void> {\r\n if (this.isCanceled)\r\n return;\r\n\r\n assert(this._state === TileRequest.State.Queued);\r\n this._state = TileRequest.State.Dispatched;\r\n let response;\r\n let gotResponse = false;\r\n try {\r\n response = await this.channel.requestContent(this.tile, () => this.isCanceled);\r\n gotResponse = true;\r\n\r\n // Set this now, so our `isCanceled` check can see it.\r\n this._state = TileRequest.State.Loading;\r\n } catch (err: any) {\r\n if (err.errorNumber && err.errorNumber === IModelStatus.ServerTimeout) {\r\n // Invalidate scene - if tile is re-selected, it will be re-requested.\r\n this.notifyAndClear();\r\n this._state = TileRequest.State.Failed;\r\n this.channel.recordTimeout();\r\n } else {\r\n // Unknown error - not retryable\r\n this.setFailed();\r\n }\r\n }\r\n\r\n // Notify caller that we have finished http activity.\r\n onHttpResponse();\r\n\r\n if (!gotResponse || this.isCanceled)\r\n return;\r\n\r\n if (undefined === response && this.channel.onNoContent(this)) {\r\n // Invalidate scene - if tile is re-selected, it will be re-requested - presumably via a different channel.\r\n this.notifyAndClear();\r\n this._state = TileRequest.State.Failed;\r\n return;\r\n }\r\n\r\n return this.handleResponse(response);\r\n }\r\n\r\n /** Cancels this request. This leaves the associated Tile's state untouched.\r\n * @internal\r\n */\r\n public cancel(): void {\r\n this.notifyAndClear();\r\n if (TileRequest.State.Dispatched === this._state)\r\n this.channel.onActiveRequestCanceled(this);\r\n\r\n this._state = TileRequest.State.Failed;\r\n }\r\n\r\n /** Invalidates the scene of each [[TileUser]] interested in this request - typically because the request succeeded, failed, or was canceled. */\r\n private notify(): void {\r\n this.users.forEach((user) => {\r\n if (user.onRequestStateChanged)\r\n user.onRequestStateChanged(this);\r\n });\r\n }\r\n\r\n /** Invalidates the scene of each [[TileUser]] interested in this request and clears the set of interested users. */\r\n private notifyAndClear(): void {\r\n this.notify();\r\n this.users = IModelApp.tileAdmin.emptyTileUserSet;\r\n this.tile.request = undefined;\r\n }\r\n\r\n private setFailed() {\r\n this.notifyAndClear();\r\n this._state = TileRequest.State.Failed;\r\n this.tile.setNotFound();\r\n this.channel.recordFailure();\r\n }\r\n\r\n /** Invoked when the raw tile content becomes available, to convert it into a tile graphic. */\r\n private async handleResponse(response: TileRequest.Response): Promise<void> {\r\n let content: TileContent | undefined;\r\n let data: TileRequest.ResponseData | undefined;\r\n if (undefined !== response) {\r\n if (typeof response === \"string\")\r\n data = base64StringToUint8Array(response);\r\n else if (response instanceof Uint8Array || response instanceof ImageSource)\r\n data = response;\r\n else if (response instanceof ArrayBuffer)\r\n data = new Uint8Array(response);\r\n else if (typeof response === \"object\" && undefined !== response.content)\r\n content = response.content;\r\n }\r\n\r\n if (!content && !data) {\r\n this.setFailed();\r\n return;\r\n }\r\n\r\n try {\r\n if (!content) {\r\n assert(undefined !== data);\r\n content = await this.tile.readContent(data, IModelApp.renderSystem, () => this.isCanceled);\r\n if (this.isCanceled)\r\n return;\r\n }\r\n\r\n this._state = TileRequest.State.Completed;\r\n this.tile.setContent(content);\r\n this.notifyAndClear();\r\n this.channel.recordCompletion(this.tile, content);\r\n } catch (_err) {\r\n this.setFailed();\r\n }\r\n }\r\n}\r\n\r\n/** @public */\r\nexport namespace TileRequest { // eslint-disable-line no-redeclare\r\n /** The type of a raw response to a request for tile content. Processed upon receipt into a [[TileRequest.Response]] type.\r\n * [[Tile.requestContent]] produces a response of this type; it is then converted to a [[Tile.ResponseData]] from which [[Tile.readContent]]\r\n * can produce a [[RenderGraphic]].\r\n * @public\r\n */\r\n export type Response = Uint8Array | ArrayBuffer | string | ImageSource | { content: TileContent } | undefined;\r\n\r\n /** The input to [[Tile.readContent]], to be converted into a [[RenderGraphic]].\r\n * @public\r\n */\r\n export type ResponseData = Uint8Array | ImageSource;\r\n\r\n /** The states through which a [[TileRequest]] proceeds. During the first 3 states, the [[Tile]]'s `request` member is defined,\r\n * and its [[Tile.LoadStatus]] is computed based on the state of its request.\r\n *@ public\r\n */\r\n export enum State {\r\n /** Initial state. Request is pending but not yet dispatched. */\r\n Queued,\r\n /** Follows `Queued` when request begins to be actively processed. */\r\n Dispatched,\r\n /** Follows `Dispatched` when the response to the request is being converted into tile graphics. */\r\n Loading,\r\n /** Follows `Loading` when tile graphic has successfully been produced. */\r\n Completed,\r\n /** Follows any state in which an error prevents progression, or during which the request was canceled. */\r\n Failed,\r\n }\r\n}\r\n"]}
|
|
@@ -163,18 +163,18 @@ export class TileRequestChannel {
|
|
|
163
163
|
this._statistics.numCanceled = 0;
|
|
164
164
|
// Recompute priority of each request.
|
|
165
165
|
for (const pending of this._pending)
|
|
166
|
-
pending.priority = pending.tile.computeLoadPriority(pending.viewports);
|
|
166
|
+
pending.priority = pending.tile.computeLoadPriority(pending.viewports, pending.users);
|
|
167
167
|
// Sort pending requests by priority.
|
|
168
168
|
this._pending.sort();
|
|
169
169
|
// Cancel any previously pending requests that are no longer needed.
|
|
170
170
|
for (const queued of this._previouslyPending)
|
|
171
|
-
if (queued.
|
|
171
|
+
if (queued.users.isEmpty)
|
|
172
172
|
this.cancel(queued);
|
|
173
173
|
this._previouslyPending.clear();
|
|
174
174
|
// Cancel any active requests that are no longer needed.
|
|
175
175
|
// NB: Do NOT remove them from the active set until their http activity has completed.
|
|
176
176
|
for (const active of this._active)
|
|
177
|
-
if (active.
|
|
177
|
+
if (active.users.isEmpty)
|
|
178
178
|
this.cancel(active);
|
|
179
179
|
// Batch-cancel running requests.
|
|
180
180
|
this.processCancellations();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TileRequestChannel.js","sourceRoot":"","sources":["../../../src/tile/TileRequestChannel.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAI5D,MAAM,gBAAiB,SAAQ,aAA0B;IACvD;QACE,KAAK,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;YACjB,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,GAAG,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC;YACrE,OAAO,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC;QACzD,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,OAAO,4BAA4B;IAAzC;QACE,uEAAuE;QAChE,uBAAkB,GAAG,CAAC,CAAC;QAC9B,8EAA8E;QACvE,sBAAiB,GAAG,CAAC,CAAC;QAC7B,qEAAqE;QAC9D,gBAAW,GAAG,CAAC,CAAC;QACvB,kEAAkE;QAC3D,2BAAsB,GAAG,CAAC,CAAC;QAClC,+DAA+D;QACxD,wBAAmB,GAAG,CAAC,CAAC;QAC/B,kE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AAM,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,UAAU,CAAC,CAAC;QACxD,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Tiles\r\n */\r\n\r\nimport { assert, PriorityQueue } from \"@itwin/core-bentley\";\r\nimport { IModelConnection } from \"../IModelConnection\";\r\nimport { Tile, TileContent, TileRequest } from \"./internal\";\r\n\r\nclass TileRequestQueue extends PriorityQueue<TileRequest> {\r\n public constructor() {\r\n super((lhs, rhs) => {\r\n const diff = lhs.tile.tree.loadPriority - rhs.tile.tree.loadPriority;\r\n return 0 !== diff ? diff : lhs.priority - rhs.priority;\r\n });\r\n }\r\n}\r\n\r\n/** Statistics regarding the current and cumulative state of one or more [[TileRequestChannel]]s. Useful for monitoring performance and diagnosing problems.\r\n * @see [[TileRequestChannel.statistics]] for a specific channel's statistics.\r\n * @see [[TileRequestChannels.statistics]] for statistics from all channels.\r\n * @see [[TileAdmin.statistics]] for additional statistics.\r\n * @public\r\n */\r\nexport class TileRequestChannelStatistics {\r\n /** The number of queued requests that have not yet been dispatched. */\r\n public numPendingRequests = 0;\r\n /** The number of requests that have been dispatched but not yet completed. */\r\n public numActiveRequests = 0;\r\n /** The number of requests canceled during the most recent update. */\r\n public numCanceled = 0;\r\n /** The total number of completed requests during this session. */\r\n public totalCompletedRequests = 0;\r\n /** The total number of failed requests during this session. */\r\n public totalFailedRequests = 0;\r\n /** The total number of timed-out requests during this session. */\r\n public totalTimedOutRequests = 0;\r\n /** The total number of completed requests during this session which produced an empty tile.\r\n * These tiles also contribute to [[totalCompletedRequests]], but not to [[totalUndisplayableTiles]].\r\n */\r\n public totalEmptyTiles = 0;\r\n /** The total number of completed requests during this session that produced an undisplayable tile.\r\n * These tiles also contribute to [[totalCompletedRequests]], but not to [[totalEmptyTiles]].\r\n */\r\n public totalUndisplayableTiles = 0;\r\n /** 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. */\r\n public totalCacheMisses = 0;\r\n /** The total number of tiles for which content requests were dispatched. */\r\n public totalDispatchedRequests = 0;\r\n /** The total number of tiles for which content requests were dispatched and then canceled on the backend before completion. */\r\n public totalAbortedRequests = 0;\r\n\r\n /** @internal */\r\n public addTo(stats: TileRequestChannelStatistics): void {\r\n for (const propName in this) { // eslint-disable-line guard-for-in\r\n const key = propName as keyof TileRequestChannelStatistics;\r\n const val = this[key];\r\n if (typeof val === \"number\") {\r\n // This type guard ought to suffice but doesn't.\r\n assert(typeof stats[key] === \"number\");\r\n (stats[key] as number) += val;\r\n }\r\n }\r\n }\r\n}\r\n\r\n/** A channel over which requests for tile content can be made. The channel may request content over HTTP, calls to the backend via IPC or RPC, or any other method like generating the content\r\n * on the frontend. The channel consists of a queue of pending requests and a set of \"active\" requests (dispatched and awaiting a response). Incoming requests are placed onto the queue. Requests are popped of the queue in order of priority and dispatched, until the maximum number of simultaneously-active requests is reached.\r\n * The maximum number of active requests depends on the transport mechanism. For HTTP 1.1, browsers impose a limit of 6 simultaneous connections to a given domain, so ideally each unique domain will use its own unique channel with a limit of 6 active requests. Even for requests satisfied entirely by the frontend, imposing a limit is important for throttling the amount of work done at one time, especially because as the user navigates the view, tiles that were previously requested may no longer be of interest and we shouldn't waste resources producing their content.\r\n * A channel must be registered with [[TileRequestChannels]] and must have a unique name among all registered channels.\r\n * @see [[TileRequestChannels.getForHttp]] to obtain (and register if not already registered) an HTTP-based channel.\r\n * @see [[TileAdmin.channels]] for the channels configured for use with the iTwin.js display system.\r\n * @see [[Tile.channel]] to specify the channel to be used to request a given tile's content.\r\n * @public\r\n */\r\nexport class TileRequestChannel {\r\n /** The channel's name. It must be unique among all registered [[TileRequestChannels]]. */\r\n public readonly name: string;\r\n private _concurrency: number;\r\n /** Protected strictly for tests. @internal */\r\n protected readonly _active = new Set<TileRequest>();\r\n private _pending = new TileRequestQueue();\r\n private _previouslyPending = new TileRequestQueue();\r\n protected _statistics = new TileRequestChannelStatistics();\r\n /** Callback invoked by recordCompletion. See IModelTileMetadataCacheChannel.\r\n * @internal\r\n */\r\n public contentCallback?: (tile: Tile, content: TileContent) => void;\r\n\r\n /** Create a new channel.\r\n * @param name The unique name of the channel.\r\n * @param concurrency The maximum number of requests that can be dispatched and awaiting a response at any given time. Requests beyond this maximum are enqueued for deferred dispatch.\r\n * @see [[TileRequestChannels.getForHttp]] to create an HTTP-based channel.\r\n */\r\n public constructor(name: string, concurrency: number) {\r\n this.name = name;\r\n this._concurrency = concurrency;\r\n }\r\n\r\n /** The maximum number of active requests. This is generally only modified for debugging purposes.\r\n * @note When reducing `concurrency`, the number of active requests ([[numActive]]) will only decrease to the new value after a sufficient number of dispatched requests are resolved.\r\n */\r\n public get concurrency(): number {\r\n return this._concurrency;\r\n }\r\n public set concurrency(max: number) {\r\n this._concurrency = max;\r\n }\r\n\r\n /** The number of requests that have been dispatched and are awaiting a response. */\r\n public get numActive(): number {\r\n return this._active.size;\r\n }\r\n\r\n /** The number of requests that have been enqueued for later dispatch. */\r\n public get numPending(): number {\r\n return this._pending.length;\r\n }\r\n\r\n /** The total number of requests in this channel, whether dispatched or enqueued. */\r\n public get size(): number {\r\n return this.numActive + this.numPending;\r\n }\r\n\r\n /** Statistics intended primarily for debugging. */\r\n public get statistics(): Readonly<TileRequestChannelStatistics> {\r\n this._statistics.numPendingRequests = this.numPending;\r\n this._statistics.numActiveRequests = this.numActive;\r\n return this._statistics;\r\n }\r\n\r\n /** Reset all of this channel's [[statistics]] to zero. */\r\n public resetStatistics(): void {\r\n this._statistics = new TileRequestChannelStatistics();\r\n }\r\n\r\n /** Invoked by [[TileRequest]] when a request times out.\r\n * @internal\r\n */\r\n public recordTimeout(): void {\r\n ++this._statistics.totalTimedOutRequests;\r\n }\r\n\r\n /** Invoked by [[TileRequest]] when a request fails to produce a response.\r\n * @internal\r\n */\r\n public recordFailure(): void {\r\n ++this._statistics.totalFailedRequests;\r\n }\r\n\r\n /** Invoked by [[TileRequest]] after a request completes.\r\n * @internal\r\n */\r\n public recordCompletion(tile: Tile, content: TileContent): void {\r\n ++this._statistics.totalCompletedRequests;\r\n if (tile.isEmpty)\r\n ++this._statistics.totalEmptyTiles;\r\n else if (!tile.isDisplayable)\r\n ++this._statistics.totalUndisplayableTiles;\r\n\r\n if (this.contentCallback)\r\n this.contentCallback(tile, content);\r\n }\r\n\r\n /** Invoked by [[TileRequestChannels.swapPending]] when [[TileAdmin]] is about to start enqueuing new requests.\r\n * @internal\r\n */\r\n public swapPending(): void {\r\n const previouslyPending = this._pending;\r\n this._pending = this._previouslyPending;\r\n this._previouslyPending = previouslyPending;\r\n }\r\n\r\n /** Invoked by [[TileAdmin.processRequests]] to enqueue a request. Ordering is ignored - the queue will be re-sorted later.\r\n * @internal\r\n */\r\n public append(request: TileRequest): void {\r\n assert(request.channel === this);\r\n this._pending.append(request);\r\n }\r\n\r\n /** Invoked by [[TileRequestChannels.process]] to process the active and pending requests.\r\n * @internal\r\n */\r\n public process(): void {\r\n this._statistics.numCanceled = 0;\r\n\r\n // Recompute priority of each request.\r\n for (const pending of this._pending)\r\n pending.priority = pending.tile.computeLoadPriority(pending.viewports);\r\n\r\n // Sort pending requests by priority.\r\n this._pending.sort();\r\n\r\n // Cancel any previously pending requests that are no longer needed.\r\n for (const queued of this._previouslyPending)\r\n if (queued.viewports.isEmpty)\r\n this.cancel(queued);\r\n\r\n this._previouslyPending.clear();\r\n\r\n // Cancel any active requests that are no longer needed.\r\n // NB: Do NOT remove them from the active set until their http activity has completed.\r\n for (const active of this._active)\r\n if (active.viewports.isEmpty)\r\n this.cancel(active);\r\n\r\n // Batch-cancel running requests.\r\n this.processCancellations();\r\n\r\n // Dispatch requests from the queue up to our maximum.\r\n while (this._active.size < this._concurrency) {\r\n const request = this._pending.pop();\r\n if (!request)\r\n break;\r\n\r\n this.dispatch(request);\r\n }\r\n }\r\n\r\n /** Cancel all active and queued requests and clear the active set and queue.\r\n * @internal\r\n */\r\n public cancelAndClearAll(): void {\r\n for (const active of this._active)\r\n active.cancel();\r\n\r\n for (const queued of this._pending)\r\n queued.cancel();\r\n\r\n this._active.clear();\r\n this._pending.clear();\r\n }\r\n\r\n /** Invoked when [[Tile.requestContent]] returns `undefined`. Return true if the request can be retried, e.g., via different channel.\r\n * If so, the tile will remain marked as \"not loaded\" and, if re-selected for display, a new [[TileRequest]] will be enqueued for it.\r\n * Otherwise, the tile will be marked as \"failed to load\" and no further requests will be made for its content.\r\n * The default implementation always returns `false`.\r\n */\r\n public onNoContent(_request: TileRequest): boolean {\r\n return false;\r\n }\r\n\r\n /** Invoked when a request that was previously dispatched is canceled before a response is received.\r\n * Some channels accumulate such requests for later cancellation in [[processCancellations]].\r\n */\r\n public onActiveRequestCanceled(_request: TileRequest): void { }\r\n\r\n /** Invoked to do any additional work to cancel tiles accumulated by [[onActiveRequestCanceled]]. For example, a channel that requests tile content\r\n * over IPC may signal to the tile generation process that it should cease generating content for those tiles.\r\n */\r\n public processCancellations(): void { }\r\n\r\n /** Invoked when an iModel is closed, to clean up any state associated with that iModel. */\r\n public onIModelClosed(_iModel: IModelConnection): void { }\r\n\r\n /** Request content for the specified tile. The default implementation simply forwards to [[Tile.requestContent]]. */\r\n public async requestContent(tile: Tile, isCanceled: () => boolean): Promise<TileRequest.Response> {\r\n return tile.requestContent(isCanceled);\r\n }\r\n\r\n /** Protected only for tests - do not override.\r\n * @internal\r\n */\r\n protected dispatch(request: TileRequest): void {\r\n ++this._statistics.totalDispatchedRequests;\r\n this._active.add(request);\r\n request.dispatch(() => {\r\n this.dropActiveRequest(request);\r\n }).catch((_) => {\r\n //\r\n });\r\n }\r\n\r\n /** Protected only for tests - do not override.\r\n * @internal\r\n */\r\n protected cancel(request: TileRequest): void {\r\n request.cancel();\r\n ++this._statistics.numCanceled;\r\n }\r\n\r\n /** Protected only for tests - do not override.\r\n * @internal\r\n */\r\n protected dropActiveRequest(request: TileRequest): void {\r\n assert(this._active.has(request) || request.isCanceled);\r\n this._active.delete(request);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"TileRequestChannel.js","sourceRoot":"","sources":["../../../src/tile/TileRequestChannel.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAI5D,MAAM,gBAAiB,SAAQ,aAA0B;IACvD;QACE,KAAK,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;YACjB,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,GAAG,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC;YACrE,OAAO,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC;QACzD,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,OAAO,4BAA4B;IAAzC;QACE,uEAAuE;QAChE,uBAAkB,GAAG,CAAC,CAAC;QAC9B,8EAA8E;QACvE,sBAAiB,GAAG,CAAC,CAAC;QAC7B,qEAAqE;QAC9D,gBAAW,GAAG,CAAC,CAAC;QACvB,kEAAkE;QAC3D,2BAAsB,GAAG,CAAC,CAAC;QAClC,+DAA+D;QACxD,wBAAmB,GAAG,CAAC,CAAC;QAC/B,kEAAkE;QAC3D,0BAAqB,GAAG,CAAC,CAAC;QACjC;;WAEG;QACI,oBAAe,GAAG,CAAC,CAAC;QAC3B;;WAEG;QACI,4BAAuB,GAAG,CAAC,CAAC;QACnC,+JAA+J;QACxJ,qBAAgB,GAAG,CAAC,CAAC;QAC5B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CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Tiles\r\n */\r\n\r\nimport { assert, PriorityQueue } from \"@itwin/core-bentley\";\r\nimport { IModelConnection } from \"../IModelConnection\";\r\nimport { Tile, TileContent, TileRequest } from \"./internal\";\r\n\r\nclass TileRequestQueue extends PriorityQueue<TileRequest> {\r\n public constructor() {\r\n super((lhs, rhs) => {\r\n const diff = lhs.tile.tree.loadPriority - rhs.tile.tree.loadPriority;\r\n return 0 !== diff ? diff : lhs.priority - rhs.priority;\r\n });\r\n }\r\n}\r\n\r\n/** Statistics regarding the current and cumulative state of one or more [[TileRequestChannel]]s. Useful for monitoring performance and diagnosing problems.\r\n * @see [[TileRequestChannel.statistics]] for a specific channel's statistics.\r\n * @see [[TileRequestChannels.statistics]] for statistics from all channels.\r\n * @see [[TileAdmin.statistics]] for additional statistics.\r\n * @public\r\n */\r\nexport class TileRequestChannelStatistics {\r\n /** The number of queued requests that have not yet been dispatched. */\r\n public numPendingRequests = 0;\r\n /** The number of requests that have been dispatched but not yet completed. */\r\n public numActiveRequests = 0;\r\n /** The number of requests canceled during the most recent update. */\r\n public numCanceled = 0;\r\n /** The total number of completed requests during this session. */\r\n public totalCompletedRequests = 0;\r\n /** The total number of failed requests during this session. */\r\n public totalFailedRequests = 0;\r\n /** The total number of timed-out requests during this session. */\r\n public totalTimedOutRequests = 0;\r\n /** The total number of completed requests during this session which produced an empty tile.\r\n * These tiles also contribute to [[totalCompletedRequests]], but not to [[totalUndisplayableTiles]].\r\n */\r\n public totalEmptyTiles = 0;\r\n /** The total number of completed requests during this session that produced an undisplayable tile.\r\n * These tiles also contribute to [[totalCompletedRequests]], but not to [[totalEmptyTiles]].\r\n */\r\n public totalUndisplayableTiles = 0;\r\n /** 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. */\r\n public totalCacheMisses = 0;\r\n /** The total number of tiles for which content requests were dispatched. */\r\n public totalDispatchedRequests = 0;\r\n /** The total number of tiles for which content requests were dispatched and then canceled on the backend before completion. */\r\n public totalAbortedRequests = 0;\r\n\r\n /** @internal */\r\n public addTo(stats: TileRequestChannelStatistics): void {\r\n for (const propName in this) { // eslint-disable-line guard-for-in\r\n const key = propName as keyof TileRequestChannelStatistics;\r\n const val = this[key];\r\n if (typeof val === \"number\") {\r\n // This type guard ought to suffice but doesn't.\r\n assert(typeof stats[key] === \"number\");\r\n (stats[key] as number) += val;\r\n }\r\n }\r\n }\r\n}\r\n\r\n/** A channel over which requests for tile content can be made. The channel may request content over HTTP, calls to the backend via IPC or RPC, or any other method like generating the content\r\n * on the frontend. The channel consists of a queue of pending requests and a set of \"active\" requests (dispatched and awaiting a response). Incoming requests are placed onto the queue. Requests are popped of the queue in order of priority and dispatched, until the maximum number of simultaneously-active requests is reached.\r\n * The maximum number of active requests depends on the transport mechanism. For HTTP 1.1, browsers impose a limit of 6 simultaneous connections to a given domain, so ideally each unique domain will use its own unique channel with a limit of 6 active requests. Even for requests satisfied entirely by the frontend, imposing a limit is important for throttling the amount of work done at one time, especially because as the user navigates the view, tiles that were previously requested may no longer be of interest and we shouldn't waste resources producing their content.\r\n * A channel must be registered with [[TileRequestChannels]] and must have a unique name among all registered channels.\r\n * @see [[TileRequestChannels.getForHttp]] to obtain (and register if not already registered) an HTTP-based channel.\r\n * @see [[TileAdmin.channels]] for the channels configured for use with the iTwin.js display system.\r\n * @see [[Tile.channel]] to specify the channel to be used to request a given tile's content.\r\n * @public\r\n */\r\nexport class TileRequestChannel {\r\n /** The channel's name. It must be unique among all registered [[TileRequestChannels]]. */\r\n public readonly name: string;\r\n private _concurrency: number;\r\n /** Protected strictly for tests. @internal */\r\n protected readonly _active = new Set<TileRequest>();\r\n private _pending = new TileRequestQueue();\r\n private _previouslyPending = new TileRequestQueue();\r\n protected _statistics = new TileRequestChannelStatistics();\r\n /** Callback invoked by recordCompletion. See IModelTileMetadataCacheChannel.\r\n * @internal\r\n */\r\n public contentCallback?: (tile: Tile, content: TileContent) => void;\r\n\r\n /** Create a new channel.\r\n * @param name The unique name of the channel.\r\n * @param concurrency The maximum number of requests that can be dispatched and awaiting a response at any given time. Requests beyond this maximum are enqueued for deferred dispatch.\r\n * @see [[TileRequestChannels.getForHttp]] to create an HTTP-based channel.\r\n */\r\n public constructor(name: string, concurrency: number) {\r\n this.name = name;\r\n this._concurrency = concurrency;\r\n }\r\n\r\n /** The maximum number of active requests. This is generally only modified for debugging purposes.\r\n * @note When reducing `concurrency`, the number of active requests ([[numActive]]) will only decrease to the new value after a sufficient number of dispatched requests are resolved.\r\n */\r\n public get concurrency(): number {\r\n return this._concurrency;\r\n }\r\n public set concurrency(max: number) {\r\n this._concurrency = max;\r\n }\r\n\r\n /** The number of requests that have been dispatched and are awaiting a response. */\r\n public get numActive(): number {\r\n return this._active.size;\r\n }\r\n\r\n /** The number of requests that have been enqueued for later dispatch. */\r\n public get numPending(): number {\r\n return this._pending.length;\r\n }\r\n\r\n /** The total number of requests in this channel, whether dispatched or enqueued. */\r\n public get size(): number {\r\n return this.numActive + this.numPending;\r\n }\r\n\r\n /** Statistics intended primarily for debugging. */\r\n public get statistics(): Readonly<TileRequestChannelStatistics> {\r\n this._statistics.numPendingRequests = this.numPending;\r\n this._statistics.numActiveRequests = this.numActive;\r\n return this._statistics;\r\n }\r\n\r\n /** Reset all of this channel's [[statistics]] to zero. */\r\n public resetStatistics(): void {\r\n this._statistics = new TileRequestChannelStatistics();\r\n }\r\n\r\n /** Invoked by [[TileRequest]] when a request times out.\r\n * @internal\r\n */\r\n public recordTimeout(): void {\r\n ++this._statistics.totalTimedOutRequests;\r\n }\r\n\r\n /** Invoked by [[TileRequest]] when a request fails to produce a response.\r\n * @internal\r\n */\r\n public recordFailure(): void {\r\n ++this._statistics.totalFailedRequests;\r\n }\r\n\r\n /** Invoked by [[TileRequest]] after a request completes.\r\n * @internal\r\n */\r\n public recordCompletion(tile: Tile, content: TileContent): void {\r\n ++this._statistics.totalCompletedRequests;\r\n if (tile.isEmpty)\r\n ++this._statistics.totalEmptyTiles;\r\n else if (!tile.isDisplayable)\r\n ++this._statistics.totalUndisplayableTiles;\r\n\r\n if (this.contentCallback)\r\n this.contentCallback(tile, content);\r\n }\r\n\r\n /** Invoked by [[TileRequestChannels.swapPending]] when [[TileAdmin]] is about to start enqueuing new requests.\r\n * @internal\r\n */\r\n public swapPending(): void {\r\n const previouslyPending = this._pending;\r\n this._pending = this._previouslyPending;\r\n this._previouslyPending = previouslyPending;\r\n }\r\n\r\n /** Invoked by [[TileAdmin.processRequests]] to enqueue a request. Ordering is ignored - the queue will be re-sorted later.\r\n * @internal\r\n */\r\n public append(request: TileRequest): void {\r\n assert(request.channel === this);\r\n this._pending.append(request);\r\n }\r\n\r\n /** Invoked by [[TileRequestChannels.process]] to process the active and pending requests.\r\n * @internal\r\n */\r\n public process(): void {\r\n this._statistics.numCanceled = 0;\r\n\r\n // Recompute priority of each request.\r\n for (const pending of this._pending)\r\n pending.priority = pending.tile.computeLoadPriority(pending.viewports, pending.users);\r\n\r\n // Sort pending requests by priority.\r\n this._pending.sort();\r\n\r\n // Cancel any previously pending requests that are no longer needed.\r\n for (const queued of this._previouslyPending)\r\n if (queued.users.isEmpty)\r\n this.cancel(queued);\r\n\r\n this._previouslyPending.clear();\r\n\r\n // Cancel any active requests that are no longer needed.\r\n // NB: Do NOT remove them from the active set until their http activity has completed.\r\n for (const active of this._active)\r\n if (active.users.isEmpty)\r\n this.cancel(active);\r\n\r\n // Batch-cancel running requests.\r\n this.processCancellations();\r\n\r\n // Dispatch requests from the queue up to our maximum.\r\n while (this._active.size < this._concurrency) {\r\n const request = this._pending.pop();\r\n if (!request)\r\n break;\r\n\r\n this.dispatch(request);\r\n }\r\n }\r\n\r\n /** Cancel all active and queued requests and clear the active set and queue.\r\n * @internal\r\n */\r\n public cancelAndClearAll(): void {\r\n for (const active of this._active)\r\n active.cancel();\r\n\r\n for (const queued of this._pending)\r\n queued.cancel();\r\n\r\n this._active.clear();\r\n this._pending.clear();\r\n }\r\n\r\n /** Invoked when [[Tile.requestContent]] returns `undefined`. Return true if the request can be retried, e.g., via different channel.\r\n * If so, the tile will remain marked as \"not loaded\" and, if re-selected for display, a new [[TileRequest]] will be enqueued for it.\r\n * Otherwise, the tile will be marked as \"failed to load\" and no further requests will be made for its content.\r\n * The default implementation always returns `false`.\r\n */\r\n public onNoContent(_request: TileRequest): boolean {\r\n return false;\r\n }\r\n\r\n /** Invoked when a request that was previously dispatched is canceled before a response is received.\r\n * Some channels accumulate such requests for later cancellation in [[processCancellations]].\r\n */\r\n public onActiveRequestCanceled(_request: TileRequest): void { }\r\n\r\n /** Invoked to do any additional work to cancel tiles accumulated by [[onActiveRequestCanceled]]. For example, a channel that requests tile content\r\n * over IPC may signal to the tile generation process that it should cease generating content for those tiles.\r\n */\r\n public processCancellations(): void { }\r\n\r\n /** Invoked when an iModel is closed, to clean up any state associated with that iModel. */\r\n public onIModelClosed(_iModel: IModelConnection): void { }\r\n\r\n /** Request content for the specified tile. The default implementation simply forwards to [[Tile.requestContent]]. */\r\n public async requestContent(tile: Tile, isCanceled: () => boolean): Promise<TileRequest.Response> {\r\n return tile.requestContent(isCanceled);\r\n }\r\n\r\n /** Protected only for tests - do not override.\r\n * @internal\r\n */\r\n protected dispatch(request: TileRequest): void {\r\n ++this._statistics.totalDispatchedRequests;\r\n this._active.add(request);\r\n request.dispatch(() => {\r\n this.dropActiveRequest(request);\r\n }).catch((_) => {\r\n //\r\n });\r\n }\r\n\r\n /** Protected only for tests - do not override.\r\n * @internal\r\n */\r\n protected cancel(request: TileRequest): void {\r\n request.cancel();\r\n ++this._statistics.numCanceled;\r\n }\r\n\r\n /** Protected only for tests - do not override.\r\n * @internal\r\n */\r\n protected dropActiveRequest(request: TileRequest): void {\r\n assert(this._active.has(request) || request.isCanceled);\r\n this._active.delete(request);\r\n }\r\n}\r\n"]}
|
package/lib/esm/tile/TileTree.js
CHANGED
|
@@ -82,7 +82,7 @@ export class TileTree {
|
|
|
82
82
|
selectTiles(args) {
|
|
83
83
|
this._lastSelected = BeTimePoint.now();
|
|
84
84
|
const tiles = this._selectTiles(args);
|
|
85
|
-
IModelApp.tileAdmin.
|
|
85
|
+
IModelApp.tileAdmin.addTilesForUser(args.context.viewport, tiles, args.readyTiles);
|
|
86
86
|
args.processSelectedTiles(tiles);
|
|
87
87
|
return tiles;
|
|
88
88
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TileTree.js","sourceRoot":"","sources":["../../../src/tile/TileTree.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAc,WAAW,EAAE,OAAO,EAAc,MAAM,qBAAqB,CAAC;AAGnF,OAAO,EAAE,oCAAoC,EAAE,MAAM,0BAA0B,CAAC;AAChF,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAMzC;;;GAGG;AACH,MAAM,CAAN,IAAY,kBASX;AATD,WAAY,kBAAkB;IAC5B,0DAA0D;IAC1D,qEAAS,CAAA;IACT,uDAAuD;IACvD,iEAAO,CAAA;IACP,kDAAkD;IAClD,+DAAM,CAAA;IACN,+CAA+C;IAC/C,mEAAQ,CAAA;AACV,CAAC,EATW,kBAAkB,KAAlB,kBAAkB,QAS7B;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAgB,QAAQ;IAgE5B,kBAAkB;IAClB,YAAsB,MAAsB;;QAhEpC,gBAAW,GAAG,KAAK,CAAC;QAC5B,gBAAgB;QACN,kBAAa,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;QA+D1C,IAAI,CAAC,aAAa,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;QACvC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,eAAe,GAAG,MAAM,CA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AC,CAAC;QACjD,IAAI,MAAM,EAAE;YACV,IAAI,CAAC,eAAe,CAAC,eAAe,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YACrD,MAAM,QAAQ,GAAG,MAAM,oCAAoC,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;YACjF,QAAQ,GAAG,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,OAAO,EAAE,CAAC;SAChC;QACD,IAAI,CAAC,QAAQ;YACX,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,YAAY,EAAE,CAAC;QAErD,OAAO,QAAQ,CAAC,0BAA0B,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IACnE,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Tiles\r\n */\r\n\r\nimport { BeDuration, BeTimePoint, dispose, Id64String } from \"@itwin/core-bentley\";\r\nimport { Matrix4d, Range3d, Transform } from \"@itwin/core-geometry\";\r\nimport { ElementAlignedBox3d, FrustumPlanes, ViewFlagOverrides } from \"@itwin/core-common\";\r\nimport { calculateEcefToDbTransformAtLocation } from \"../BackgroundMapGeometry\";\r\nimport { IModelApp } from \"../IModelApp\";\r\nimport { IModelConnection } from \"../IModelConnection\";\r\nimport { RenderClipVolume } from \"../render/RenderClipVolume\";\r\nimport { RenderMemory } from \"../render/RenderMemory\";\r\nimport { Tile, TileDrawArgs, TileLoadPriority, TileTreeParams } from \"./internal\";\r\n\r\n/** Describes the current state of a [[TileTree]]. TileTrees are loaded asynchronously and may be unloaded after a period of disuse.\r\n * @see [[TileTreeOwner]].\r\n * @public\r\n */\r\nexport enum TileTreeLoadStatus {\r\n /** No attempt to load the tile tree has yet been made. */\r\n NotLoaded,\r\n /** The tile tree is in the process of being loaded. */\r\n Loading,\r\n /** The tile tree has been successfully loaded. */\r\n Loaded,\r\n /** An attempt to load the tile tree failed. */\r\n NotFound,\r\n}\r\n\r\n/** A hierarchical level-of-detail tree of [3d Tiles](https://github.com/CesiumGS/3d-tiles) to be rendered in a [[Viewport]].\r\n * Tile trees originate from a variety of sources:\r\n * - Each [[GeometricModelState]] can supply its graphics as a tile tree;\r\n * - A [[DisplayStyleState]]'s map settings or reality models;\r\n * - [ViewAttachment]($backend)s in a [[SheetModelState]];\r\n * - [[TiledGraphicsProvider]]s associated with a viewport.\r\n *\r\n * The same TileTree can be displayed in any number of viewports using multiple [[TileTreeReference]]s.\r\n * A TileTree's lifetime is managed by a [[TileTreeOwner]].\r\n *\r\n * @note Some methods carry a warning that they should **not** be overridden by subclasses; typically a protected method exists that can be\r\n * overridden instead to customize the behavior. For example, [[selectTiles]] should not be overridden; instead, override the[[_selectTiles]] method\r\n * that it calls.\r\n * @public\r\n */\r\nexport abstract class TileTree {\r\n private _isDisposed = false;\r\n /** @internal */\r\n protected _lastSelected = BeTimePoint.now();\r\n /** @internal */\r\n protected _clipVolume?: RenderClipVolume;\r\n public readonly iModel: IModelConnection;\r\n /** Transform from this tile tree's coordinate space to the iModel's coordinate space. */\r\n public readonly iModelTransform: Transform;\r\n /** Uniquely identifies this tree among all other tile trees associated with the iModel. */\r\n public readonly id: string;\r\n /** A 64-bit identifier for this tile tree, unique within the context of its [[IModelConnection]].\r\n * For a tile tree associated with a [[GeometricModelState]], this is the Id of the model. Other types of tile trees\r\n * typically use a transient Id obtained from [[IModelConnection.transientIds]].\r\n */\r\n public readonly modelId: Id64String;\r\n /** The length of time after which tiles belonging to this tree are considered elegible for disposal if they are no longer in use. */\r\n public readonly expirationTime: BeDuration;\r\n /** @internal */\r\n public get loadPriority(): TileLoadPriority { return this._loadPriority; }\r\n private readonly _loadPriority: TileLoadPriority;\r\n /** Optional tight bounding box around the entire contents of all of this tree's tiles. */\r\n public readonly contentRange?: ElementAlignedBox3d;\r\n\r\n /** The lowest-resolution tile in this tree. */\r\n public abstract get rootTile(): Tile;\r\n /** True if this tile tree contains 3d graphics. */\r\n public abstract get is3d(): boolean;\r\n /** Returns the maximum depth of this tree, if any. */\r\n public abstract get maxDepth(): number | undefined;\r\n\r\n /** The overrides that should be applied to the view's [ViewFlags]($common) when this tile tree is drawn. Can be overridden by individual [[TileTreeReference]]s. */\r\n public abstract get viewFlagOverrides(): ViewFlagOverrides;\r\n\r\n /** True if this tile tree has no bounds - e.g., a tile tree representing a globe is unbounded. */\r\n public get isContentUnbounded(): boolean {\r\n return false;\r\n }\r\n\r\n /** Implement this method to select tiles of appropriate resolution. */\r\n protected abstract _selectTiles(args: TileDrawArgs): Tile[];\r\n\r\n /** Produce graphics of appropriate resolution to be drawn in a [[Viewport]]. */\r\n public abstract draw(args: TileDrawArgs): void;\r\n\r\n /** Discard tiles and/or tile contents, presumably based on a least-recently-used and/or least-likely-to-be-needed criterion. */\r\n public abstract prune(): void;\r\n\r\n /** True if this tile tree contains 2d graphics. */\r\n public get is2d(): boolean { return !this.is3d; }\r\n /** @internal */\r\n public get isPointCloud(): boolean { return false; }\r\n /** @internal */\r\n public get clipVolume(): RenderClipVolume | undefined { return this._clipVolume; }\r\n\r\n /** The volume of space occupied by this tile tree. */\r\n public get range(): ElementAlignedBox3d { return this.rootTile.range; }\r\n /** The most recent time at which tiles [[selectTiles]] was called. */\r\n public get lastSelectedTime(): BeTimePoint { return this._lastSelected; }\r\n /** True if a tile and its child tiles should not be drawn simultaneously.\r\n * Default: true.\r\n */\r\n public get parentsAndChildrenExclusive(): boolean { return true; }\r\n\r\n /** Constructor */\r\n protected constructor(params: TileTreeParams) {\r\n this._lastSelected = BeTimePoint.now();\r\n this.iModel = params.iModel;\r\n this.iModelTransform = params.location;\r\n this._clipVolume = params.clipVolume;\r\n this.modelId = params.modelId;\r\n this.id = params.id;\r\n this.contentRange = params.contentRange;\r\n\r\n const admin = IModelApp.tileAdmin;\r\n this._loadPriority = params.priority;\r\n this.expirationTime = params.expirationTime ?? admin.tileExpirationTime;\r\n }\r\n\r\n /** Selects tiles of appropriate resolution for some purpose like drawing to the screen, producing a shadow map, etc.\r\n * @note Do **not** override this method. Implement [[_selectTiles]].\r\n */\r\n public selectTiles(args: TileDrawArgs): Tile[] {\r\n this._lastSelected = BeTimePoint.now();\r\n const tiles = this._selectTiles(args);\r\n IModelApp.tileAdmin.addTilesForViewport(args.context.viewport, tiles, args.readyTiles);\r\n args.processSelectedTiles(tiles);\r\n return tiles;\r\n }\r\n\r\n /** True if [[dispose]] has been called on this tile tree. */\r\n public get isDisposed(): boolean { return this._isDisposed; }\r\n\r\n /** Dispose of this tree and any resources owned by it. This is typically invoked by a [[TileTreeOwner]]. */\r\n public dispose(): void {\r\n if (this.isDisposed)\r\n return;\r\n\r\n this._isDisposed = true;\r\n dispose(this.rootTile);\r\n }\r\n\r\n /** @internal */\r\n public collectStatistics(stats: RenderMemory.Statistics): void {\r\n this.rootTile.collectStatistics(stats);\r\n }\r\n\r\n /** Returns the number of [[Tile]]s currently in memory belonging to this tree, primarily for debugging. */\r\n public countTiles(): number {\r\n return 1 + this.rootTile.countDescendants();\r\n }\r\n\r\n /** @internal */\r\n public accumulateTransformedRange(range: Range3d, matrix: Matrix4d, location: Transform, frustumPlanes?: FrustumPlanes): void {\r\n this.rootTile.extendRangeForContent(range, matrix, location, frustumPlanes);\r\n }\r\n\r\n /**\r\n * Return the transform from the tile tree's coordinate space to [ECEF](https://en.wikipedia.org/wiki/ECEF) (Earth Centered Earth Fixed) coordinates.\r\n * If a geographic coordinate system is present then this transform will be calculated at the tile tree center.\r\n * @beta\r\n */\r\n public async getEcefTransform(): Promise<Transform | undefined> {\r\n if (!this.iModel.ecefLocation)\r\n return undefined;\r\n\r\n let dbToEcef: Transform | undefined;\r\n const range = this.contentRange ? this.contentRange : this.range;\r\n const center = range.localXYZToWorld(.5, .5, .5);\r\n if (center) {\r\n this.iModelTransform.multiplyPoint3d(center, center);\r\n const ecefToDb = await calculateEcefToDbTransformAtLocation(center, this.iModel);\r\n dbToEcef = ecefToDb?.inverse();\r\n }\r\n if (!dbToEcef)\r\n dbToEcef = this.iModel.ecefLocation.getTransform();\r\n\r\n return dbToEcef.multiplyTransformTransform(this.iModelTransform);\r\n }\r\n}\r\n\r\n"]}
|
|
1
|
+
{"version":3,"file":"TileTree.js","sourceRoot":"","sources":["../../../src/tile/TileTree.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAc,WAAW,EAAE,OAAO,EAAc,MAAM,qBAAqB,CAAC;AAGnF,OAAO,EAAE,oCAAoC,EAAE,MAAM,0BAA0B,CAAC;AAChF,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAMzC;;;GAGG;AACH,MAAM,CAAN,IAAY,kBASX;AATD,WAAY,kBAAkB;IAC5B,0DAA0D;IAC1D,qEAAS,CAAA;IACT,uDAAuD;IACvD,iEAAO,CAAA;IACP,kDAAkD;IAClD,+DAAM,CAAA;IACN,+CAA+C;IAC/C,mEAAQ,CAAA;AACV,CAAC,EATW,kBAAkB,KAAlB,kBAAkB,QAS7B;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAgB,QAAQ;IAgE5B,kBAAkB;IAClB,YAAsB,MAAsB;;QAhEpC,gBAAW,GAAG,KAAK,CAAC;QAC5B,gBAAgB;QACN,kBAAa,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;QA+D1C,IAAI,CAAC,aAAa,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;QACvC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC,QAAQ,CAAC;QACvC,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,UAAU,CAAC;QACrC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;QAC9B,IAAI,CAAC,EAAE,GAAG,MAAM,CAAC,EAAE,CAA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CAAC,CAAC;YACjF,QAAQ,GAAG,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,OAAO,EAAE,CAAC;SAChC;QACD,IAAI,CAAC,QAAQ;YACX,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,YAAY,EAAE,CAAC;QAErD,OAAO,QAAQ,CAAC,0BAA0B,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IACnE,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Tiles\r\n */\r\n\r\nimport { BeDuration, BeTimePoint, dispose, Id64String } from \"@itwin/core-bentley\";\r\nimport { Matrix4d, Range3d, Transform } from \"@itwin/core-geometry\";\r\nimport { ElementAlignedBox3d, FrustumPlanes, ViewFlagOverrides } from \"@itwin/core-common\";\r\nimport { calculateEcefToDbTransformAtLocation } from \"../BackgroundMapGeometry\";\r\nimport { IModelApp } from \"../IModelApp\";\r\nimport { IModelConnection } from \"../IModelConnection\";\r\nimport { RenderClipVolume } from \"../render/RenderClipVolume\";\r\nimport { RenderMemory } from \"../render/RenderMemory\";\r\nimport { Tile, TileDrawArgs, TileLoadPriority, TileTreeParams } from \"./internal\";\r\n\r\n/** Describes the current state of a [[TileTree]]. TileTrees are loaded asynchronously and may be unloaded after a period of disuse.\r\n * @see [[TileTreeOwner]].\r\n * @public\r\n */\r\nexport enum TileTreeLoadStatus {\r\n /** No attempt to load the tile tree has yet been made. */\r\n NotLoaded,\r\n /** The tile tree is in the process of being loaded. */\r\n Loading,\r\n /** The tile tree has been successfully loaded. */\r\n Loaded,\r\n /** An attempt to load the tile tree failed. */\r\n NotFound,\r\n}\r\n\r\n/** A hierarchical level-of-detail tree of [3d Tiles](https://github.com/CesiumGS/3d-tiles) to be rendered in a [[Viewport]].\r\n * Tile trees originate from a variety of sources:\r\n * - Each [[GeometricModelState]] can supply its graphics as a tile tree;\r\n * - A [[DisplayStyleState]]'s map settings or reality models;\r\n * - [ViewAttachment]($backend)s in a [[SheetModelState]];\r\n * - [[TiledGraphicsProvider]]s associated with a viewport.\r\n *\r\n * The same TileTree can be displayed in any number of viewports using multiple [[TileTreeReference]]s.\r\n * A TileTree's lifetime is managed by a [[TileTreeOwner]].\r\n *\r\n * @note Some methods carry a warning that they should **not** be overridden by subclasses; typically a protected method exists that can be\r\n * overridden instead to customize the behavior. For example, [[selectTiles]] should not be overridden; instead, override the[[_selectTiles]] method\r\n * that it calls.\r\n * @public\r\n */\r\nexport abstract class TileTree {\r\n private _isDisposed = false;\r\n /** @internal */\r\n protected _lastSelected = BeTimePoint.now();\r\n /** @internal */\r\n protected _clipVolume?: RenderClipVolume;\r\n public readonly iModel: IModelConnection;\r\n /** Transform from this tile tree's coordinate space to the iModel's coordinate space. */\r\n public readonly iModelTransform: Transform;\r\n /** Uniquely identifies this tree among all other tile trees associated with the iModel. */\r\n public readonly id: string;\r\n /** A 64-bit identifier for this tile tree, unique within the context of its [[IModelConnection]].\r\n * For a tile tree associated with a [[GeometricModelState]], this is the Id of the model. Other types of tile trees\r\n * typically use a transient Id obtained from [[IModelConnection.transientIds]].\r\n */\r\n public readonly modelId: Id64String;\r\n /** The length of time after which tiles belonging to this tree are considered elegible for disposal if they are no longer in use. */\r\n public readonly expirationTime: BeDuration;\r\n /** @internal */\r\n public get loadPriority(): TileLoadPriority { return this._loadPriority; }\r\n private readonly _loadPriority: TileLoadPriority;\r\n /** Optional tight bounding box around the entire contents of all of this tree's tiles. */\r\n public readonly contentRange?: ElementAlignedBox3d;\r\n\r\n /** The lowest-resolution tile in this tree. */\r\n public abstract get rootTile(): Tile;\r\n /** True if this tile tree contains 3d graphics. */\r\n public abstract get is3d(): boolean;\r\n /** Returns the maximum depth of this tree, if any. */\r\n public abstract get maxDepth(): number | undefined;\r\n\r\n /** The overrides that should be applied to the view's [ViewFlags]($common) when this tile tree is drawn. Can be overridden by individual [[TileTreeReference]]s. */\r\n public abstract get viewFlagOverrides(): ViewFlagOverrides;\r\n\r\n /** True if this tile tree has no bounds - e.g., a tile tree representing a globe is unbounded. */\r\n public get isContentUnbounded(): boolean {\r\n return false;\r\n }\r\n\r\n /** Implement this method to select tiles of appropriate resolution. */\r\n protected abstract _selectTiles(args: TileDrawArgs): Tile[];\r\n\r\n /** Produce graphics of appropriate resolution to be drawn in a [[Viewport]]. */\r\n public abstract draw(args: TileDrawArgs): void;\r\n\r\n /** Discard tiles and/or tile contents, presumably based on a least-recently-used and/or least-likely-to-be-needed criterion. */\r\n public abstract prune(): void;\r\n\r\n /** True if this tile tree contains 2d graphics. */\r\n public get is2d(): boolean { return !this.is3d; }\r\n /** @internal */\r\n public get isPointCloud(): boolean { return false; }\r\n /** @internal */\r\n public get clipVolume(): RenderClipVolume | undefined { return this._clipVolume; }\r\n\r\n /** The volume of space occupied by this tile tree. */\r\n public get range(): ElementAlignedBox3d { return this.rootTile.range; }\r\n /** The most recent time at which tiles [[selectTiles]] was called. */\r\n public get lastSelectedTime(): BeTimePoint { return this._lastSelected; }\r\n /** True if a tile and its child tiles should not be drawn simultaneously.\r\n * Default: true.\r\n */\r\n public get parentsAndChildrenExclusive(): boolean { return true; }\r\n\r\n /** Constructor */\r\n protected constructor(params: TileTreeParams) {\r\n this._lastSelected = BeTimePoint.now();\r\n this.iModel = params.iModel;\r\n this.iModelTransform = params.location;\r\n this._clipVolume = params.clipVolume;\r\n this.modelId = params.modelId;\r\n this.id = params.id;\r\n this.contentRange = params.contentRange;\r\n\r\n const admin = IModelApp.tileAdmin;\r\n this._loadPriority = params.priority;\r\n this.expirationTime = params.expirationTime ?? admin.tileExpirationTime;\r\n }\r\n\r\n /** Selects tiles of appropriate resolution for some purpose like drawing to the screen, producing a shadow map, etc.\r\n * @note Do **not** override this method. Implement [[_selectTiles]].\r\n */\r\n public selectTiles(args: TileDrawArgs): Tile[] {\r\n this._lastSelected = BeTimePoint.now();\r\n const tiles = this._selectTiles(args);\r\n IModelApp.tileAdmin.addTilesForUser(args.context.viewport, tiles, args.readyTiles);\r\n args.processSelectedTiles(tiles);\r\n return tiles;\r\n }\r\n\r\n /** True if [[dispose]] has been called on this tile tree. */\r\n public get isDisposed(): boolean { return this._isDisposed; }\r\n\r\n /** Dispose of this tree and any resources owned by it. This is typically invoked by a [[TileTreeOwner]]. */\r\n public dispose(): void {\r\n if (this.isDisposed)\r\n return;\r\n\r\n this._isDisposed = true;\r\n dispose(this.rootTile);\r\n }\r\n\r\n /** @internal */\r\n public collectStatistics(stats: RenderMemory.Statistics): void {\r\n this.rootTile.collectStatistics(stats);\r\n }\r\n\r\n /** Returns the number of [[Tile]]s currently in memory belonging to this tree, primarily for debugging. */\r\n public countTiles(): number {\r\n return 1 + this.rootTile.countDescendants();\r\n }\r\n\r\n /** @internal */\r\n public accumulateTransformedRange(range: Range3d, matrix: Matrix4d, location: Transform, frustumPlanes?: FrustumPlanes): void {\r\n this.rootTile.extendRangeForContent(range, matrix, location, frustumPlanes);\r\n }\r\n\r\n /**\r\n * Return the transform from the tile tree's coordinate space to [ECEF](https://en.wikipedia.org/wiki/ECEF) (Earth Centered Earth Fixed) coordinates.\r\n * If a geographic coordinate system is present then this transform will be calculated at the tile tree center.\r\n * @beta\r\n */\r\n public async getEcefTransform(): Promise<Transform | undefined> {\r\n if (!this.iModel.ecefLocation)\r\n return undefined;\r\n\r\n let dbToEcef: Transform | undefined;\r\n const range = this.contentRange ? this.contentRange : this.range;\r\n const center = range.localXYZToWorld(.5, .5, .5);\r\n if (center) {\r\n this.iModelTransform.multiplyPoint3d(center, center);\r\n const ecefToDb = await calculateEcefToDbTransformAtLocation(center, this.iModel);\r\n dbToEcef = ecefToDb?.inverse();\r\n }\r\n if (!dbToEcef)\r\n dbToEcef = this.iModel.ecefLocation.getTransform();\r\n\r\n return dbToEcef.multiplyTransformTransform(this.iModelTransform);\r\n }\r\n}\r\n\r\n"]}
|
|
@@ -22,7 +22,7 @@ export declare enum TileGraphicType {
|
|
|
22
22
|
Overlay = 2
|
|
23
23
|
}
|
|
24
24
|
/** A reference to a [[TileTree]] suitable for drawing within a [[Viewport]]. The reference does not *own* its tile tree - it merely refers to it by
|
|
25
|
-
* way of the tree [[TileTreeOwner]].
|
|
25
|
+
* way of the tree's [[TileTreeOwner]].
|
|
26
26
|
* The specific [[TileTree]] referenced by this object may change based on the current state of the Viewport in which it is drawn - for example,
|
|
27
27
|
* as a result of changing the RenderMode, or animation settings, or classification settings, etc.
|
|
28
28
|
* A reference to a TileTree is typically associated with a [[ViewState]], a [[DisplayStyleState]], or a [[Viewport]].
|
|
@@ -22,7 +22,7 @@ export var TileGraphicType;
|
|
|
22
22
|
TileGraphicType[TileGraphicType["Overlay"] = 2] = "Overlay";
|
|
23
23
|
})(TileGraphicType || (TileGraphicType = {}));
|
|
24
24
|
/** A reference to a [[TileTree]] suitable for drawing within a [[Viewport]]. The reference does not *own* its tile tree - it merely refers to it by
|
|
25
|
-
* way of the tree [[TileTreeOwner]].
|
|
25
|
+
* way of the tree's [[TileTreeOwner]].
|
|
26
26
|
* The specific [[TileTree]] referenced by this object may change based on the current state of the Viewport in which it is drawn - for example,
|
|
27
27
|
* as a result of changing the RenderMode, or animation settings, or classification settings, etc.
|
|
28
28
|
* A reference to a TileTree is typically associated with a [[ViewState]], a [[DisplayStyleState]], or a [[Viewport]].
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TileTreeReference.js","sourceRoot":"","sources":["../../../src/tile/TileTreeReference.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAqB,OAAO,EAAa,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EAA6E,sBAAsB,EAAqB,MAAM,oBAAoB,CAAC;AAO1J,OAAO,EAAwB,YAAY,EAAY,kBAAkB,EAAiB,M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aAA6B;QAC/F,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC;QACrC,IAAI,SAAS,KAAK,IAAI;YACpB,OAAO;QAET,MAAM,QAAQ,GAAG,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,CAAC,0BAA0B,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAC;IAC1E,CAAC;IAED,gBAAgB;IACT,gBAAgB,CAAC,eAAwB,IAAU,CAAC;IAE3D,6GAA6G;IAC7G,IAAW,YAAY;QACrB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,iKAAiK;IACjK,IAAW,QAAQ,KAAc,OAAO,KAAK,CAAC,CAAC,CAAC;IAEhD;;;OAGG;IACH,IAAW,sBAAsB,KAAa,OAAO,sBAAsB,CAAC,WAAW,CAAC,CAAC,CAAC;IAE1F,iGAAiG;IAC1F,YAAY,CAAC,MAAwB,EAAE,GAAmB,IAAU,CAAC;CAC7E","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Tiles\r\n */\r\n\r\nimport { BeTimePoint } from \"@itwin/core-bentley\";\r\nimport { Matrix4d, Range1d, Range3d, Transform } from \"@itwin/core-geometry\";\r\nimport { ElementAlignedBox3d, FeatureAppearanceProvider, FrustumPlanes, HiddenLine, PlanarClipMaskPriority, ViewFlagOverrides } from \"@itwin/core-common\";\r\nimport { HitDetail } from \"../HitDetail\";\r\nimport { FeatureSymbology } from \"../render/FeatureSymbology\";\r\nimport { RenderClipVolume } from \"../render/RenderClipVolume\";\r\nimport { RenderMemory } from \"../render/RenderMemory\";\r\nimport { DecorateContext, SceneContext } from \"../ViewContext\";\r\nimport { ScreenViewport } from \"../Viewport\";\r\nimport { DisclosedTileTreeSet, TileDrawArgs, TileTree, TileTreeLoadStatus, TileTreeOwner } from \"./internal\";\r\n\r\n/** Describes the type of graphics produced by a [[TileTreeReference]].\r\n * @public\r\n */\r\nexport enum TileGraphicType {\r\n /** Rendered behind all other geometry without depth. */\r\n BackgroundMap = 0,\r\n /** Rendered with normal scene graphics. */\r\n Scene = 1,\r\n /** Rendered in front of all other geometry. */\r\n Overlay = 2,\r\n}\r\n\r\n/** A reference to a [[TileTree]] suitable for drawing within a [[Viewport]]. The reference does not *own* its tile tree - it merely refers to it by\r\n * way of the tree [[TileTreeOwner]].\r\n * The specific [[TileTree]] referenced by this object may change based on the current state of the Viewport in which it is drawn - for example,\r\n * as a result of changing the RenderMode, or animation settings, or classification settings, etc.\r\n * A reference to a TileTree is typically associated with a [[ViewState]], a [[DisplayStyleState]], or a [[Viewport]].\r\n * Multiple TileTreeReferences can refer to the same TileTree with different parameters and logic - for example, the same background map tiles can be displayed in two viewports with\r\n * differing levels of transparency.\r\n * @see [[TiledGraphicsProvider]] to supply custom [[TileTreeReference]]s to be drawn within a [[Viewport]].\r\n * @public\r\n */\r\nexport abstract class TileTreeReference /* implements RenderMemory.Consumer */ {\r\n /** The owner of the currently-referenced [[TileTree]]. Do not store a direct reference to it, because it may change or become disposed at any time. */\r\n public abstract get treeOwner(): TileTreeOwner;\r\n\r\n /** Disclose *all* TileTrees use by this reference. This may include things like map tiles used for draping on terrain.\r\n * Override this and call super if you have such auxiliary trees.\r\n * @note Any tree *NOT* disclosed becomes a candidate for *purging* (being unloaded from memory along with all of its tiles and graphics).\r\n */\r\n public discloseTileTrees(trees: DisclosedTileTreeSet): void {\r\n const tree = this.treeOwner.tileTree;\r\n if (undefined !== tree)\r\n trees.add(tree);\r\n }\r\n\r\n /** Adds this reference's graphics to the scene. By default this invokes [[draw]]. */\r\n public addToScene(context: SceneContext): void {\r\n const args = this.createDrawArgs(context);\r\n if (undefined !== args)\r\n this.draw(args);\r\n }\r\n\r\n /** Adds this reference's graphics to the scene. By default this invokes [[TileTree.draw]] on the referenced TileTree, if it is loaded. */\r\n public draw(args: TileDrawArgs): void {\r\n args.tree.draw(args);\r\n }\r\n\r\n /** Optionally return a tooltip describing the hit. */\r\n public async getToolTip(_hit: HitDetail): Promise<HTMLElement | string | undefined> { return undefined; }\r\n\r\n /** Optionally add any decorations specific to this reference. For example, map tile trees may add a logo image and/or copyright attributions.\r\n * @note This is currently only invoked for background maps and TiledGraphicsProviders - others have no decorations, but if they did implement this it would not be called.\r\n */\r\n public decorate(_context: DecorateContext): void { }\r\n\r\n /** Unions this reference's range with the supplied range to help compute a volume in world space for fitting a viewport to its contents.\r\n * Override this function if a reference's range should not be included in the fit range, or a range different from its tile tree's range should be used.\r\n */\r\n public unionFitRange(union: Range3d): void {\r\n const contentRange = this.computeWorldContentRange();\r\n if (!contentRange.isNull)\r\n union.extendRange(contentRange);\r\n }\r\n\r\n /** @internal */\r\n public collectStatistics(stats: RenderMemory.Statistics): void {\r\n const tree = this.treeOwner.tileTree;\r\n if (undefined !== tree)\r\n tree.collectStatistics(stats);\r\n }\r\n\r\n /** Return true if the tile tree is fully loaded and ready to draw.\r\n * The default implementation returns true if the tile tree loading process completed (whether it resulted in success or failure).\r\n * @note Do *not* override this property - override [[_isLoadingComplete]] instead..\r\n * @public\r\n */\r\n public get isLoadingComplete(): boolean {\r\n switch (this.treeOwner.loadStatus) {\r\n case TileTreeLoadStatus.NotLoaded:\r\n case TileTreeLoadStatus.Loading:\r\n return false;\r\n case TileTreeLoadStatus.NotFound:\r\n return true; // we tried, and failed, to load.\r\n case TileTreeLoadStatus.Loaded:\r\n return this._isLoadingComplete;\r\n }\r\n }\r\n\r\n /** Override if additional asynchronous loading is required after the tile tree is successfully loaded, to indicate when that loading has completed.\r\n * @public\r\n */\r\n protected get _isLoadingComplete(): boolean {\r\n return true;\r\n }\r\n\r\n /** Create context for drawing the tile tree, if it is ready for drawing.\r\n * TileTreeReferences can override individual portions of the context, e.g. apply their own transform.\r\n * Returns undefined if, e.g., the tile tree is not yet loaded.\r\n */\r\n public createDrawArgs(context: SceneContext): TileDrawArgs | undefined {\r\n const tree = this.treeOwner.load();\r\n if (undefined === tree)\r\n return undefined;\r\n\r\n return new TileDrawArgs({\r\n context,\r\n tree,\r\n now: BeTimePoint.now(),\r\n location: this.computeTransform(tree),\r\n viewFlagOverrides: this.getViewFlagOverrides(tree),\r\n clipVolume: this.getClipVolume(tree),\r\n parentsAndChildrenExclusive: tree.parentsAndChildrenExclusive,\r\n symbologyOverrides: this.getSymbologyOverrides(tree),\r\n appearanceProvider: this.getAppearanceProvider(tree),\r\n hiddenLineSettings: this.getHiddenLineSettings(tree),\r\n animationTransformNodeId: this.getAnimationTransformNodeId(tree),\r\n });\r\n }\r\n\r\n /** @internal */\r\n protected getAnimationTransformNodeId(_tree: TileTree): number | undefined {\r\n return undefined;\r\n }\r\n\r\n /** Supply transform from this tile tree reference's location to iModel coordinate space.\r\n * @returns undefined if the TileTree is not yet loaded.\r\n */\r\n public getLocation(): Transform | undefined {\r\n const tree = this.treeOwner.load();\r\n return undefined !== tree ? this.computeTransform(tree) : undefined;\r\n }\r\n\r\n /** Compute a transform from this tile tree reference's coordinate space to the [[IModelConnection]]'s coordinate space. */\r\n protected computeTransform(tree: TileTree): Transform {\r\n return tree.iModelTransform.clone();\r\n }\r\n\r\n /** Compute the range of this tile tree's contents in world coordinates.\r\n * @returns The content range in world coodinates, or a null range if the tile tree is not loaded or has a null content range.\r\n */\r\n public computeWorldContentRange(): ElementAlignedBox3d {\r\n const range = new Range3d();\r\n const tree = this.treeOwner.tileTree;\r\n if (undefined !== tree && !tree.rootTile.contentRange.isNull)\r\n this.computeTransform(tree).multiplyRange(tree.rootTile.contentRange, range);\r\n\r\n return range;\r\n }\r\n\r\n /** Return the clip volume applied to this reference's tile tree, if any. */\r\n protected getClipVolume(tree: TileTree): RenderClipVolume | undefined {\r\n return tree.clipVolume;\r\n }\r\n\r\n /** Supply overrides that should be applied to the [[ViewState]]'s [ViewFlags]($common) when drawing this tile tree reference. */\r\n protected getViewFlagOverrides(tree: TileTree): ViewFlagOverrides {\r\n return tree.viewFlagOverrides;\r\n }\r\n\r\n /** Return overrides that *replace* any defined for the view. */\r\n protected getSymbologyOverrides(_tree: TileTree): FeatureSymbology.Overrides | undefined {\r\n return undefined;\r\n }\r\n\r\n /** Return a provider that can supplement the view's symbology overrides. */\r\n protected getAppearanceProvider(_tree: TileTree): FeatureAppearanceProvider | undefined {\r\n return undefined;\r\n }\r\n\r\n /** Return hidden line settings to replace those defined for the view. */\r\n protected getHiddenLineSettings(_tree: TileTree): HiddenLine.Settings | undefined {\r\n return undefined;\r\n }\r\n\r\n /* Extend range to include transformed range of this tile tree.\r\n * @internal\r\n */\r\n public accumulateTransformedRange(range: Range3d, matrix: Matrix4d, frustumPlanes?: FrustumPlanes) {\r\n const tree = this.treeOwner.tileTree;\r\n if (undefined === tree)\r\n return;\r\n\r\n const location = this.computeTransform(tree);\r\n tree.accumulateTransformedRange(range, matrix, location, frustumPlanes);\r\n }\r\n\r\n /** @internal */\r\n public getTerrainHeight(_terrainHeights: Range1d): void { }\r\n\r\n /** Return whether the geometry exposed by this tile tree reference should cast shadows on other geometry. */\r\n public get castsShadows(): boolean {\r\n return true;\r\n }\r\n\r\n /** Return whether this reference has global coverage. Mapping data is global and some non-primary models such as the OSM building layer have global coverage */\r\n public get isGlobal(): boolean { return false; }\r\n\r\n /** Return the clip mask priority for this model - models will be clipped by any other viewed model with a higher proirity.\r\n * BIM models have highest prioirty and are never clipped.\r\n * @alpha\r\n */\r\n public get planarclipMaskPriority(): number { return PlanarClipMaskPriority.DesignModel; }\r\n\r\n /** Add attribution logo cards for the tile tree source logo cards to the viewport's logo div. */\r\n public addLogoCards(_cards: HTMLTableElement, _vp: ScreenViewport): void { }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"TileTreeReference.js","sourceRoot":"","sources":["../../../src/tile/TileTreeReference.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAE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AA4E;IAClE,qBAAqB,CAAC,KAAe;QAC7C,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,yEAAyE;IAC/D,qBAAqB,CAAC,KAAe;QAC7C,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;OAEG;IACI,0BAA0B,CAAC,KAAc,EAAE,MAAgB,EAAE,aAA6B;QAC/F,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC;QACrC,IAAI,SAAS,KAAK,IAAI;YACpB,OAAO;QAET,MAAM,QAAQ,GAAG,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,CAAC,0BAA0B,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAC;IAC1E,CAAC;IAED,gBAAgB;IACT,gBAAgB,CAAC,eAAwB,IAAU,CAAC;IAE3D,6GAA6G;IAC7G,IAAW,YAAY;QACrB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,iKAAiK;IACjK,IAAW,QAAQ,KAAc,OAAO,KAAK,CAAC,CAAC,CAAC;IAEhD;;;OAGG;IACH,IAAW,sBAAsB,KAAa,OAAO,sBAAsB,CAAC,WAAW,CAAC,CAAC,CAAC;IAE1F,iGAAiG;IAC1F,YAAY,CAAC,MAAwB,EAAE,GAAmB,IAAU,CAAC;CAC7E","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Tiles\r\n */\r\n\r\nimport { BeTimePoint } from \"@itwin/core-bentley\";\r\nimport { Matrix4d, Range1d, Range3d, Transform } from \"@itwin/core-geometry\";\r\nimport { ElementAlignedBox3d, FeatureAppearanceProvider, FrustumPlanes, HiddenLine, PlanarClipMaskPriority, ViewFlagOverrides } from \"@itwin/core-common\";\r\nimport { HitDetail } from \"../HitDetail\";\r\nimport { FeatureSymbology } from \"../render/FeatureSymbology\";\r\nimport { RenderClipVolume } from \"../render/RenderClipVolume\";\r\nimport { RenderMemory } from \"../render/RenderMemory\";\r\nimport { DecorateContext, SceneContext } from \"../ViewContext\";\r\nimport { ScreenViewport } from \"../Viewport\";\r\nimport { DisclosedTileTreeSet, TileDrawArgs, TileTree, TileTreeLoadStatus, TileTreeOwner } from \"./internal\";\r\n\r\n/** Describes the type of graphics produced by a [[TileTreeReference]].\r\n * @public\r\n */\r\nexport enum TileGraphicType {\r\n /** Rendered behind all other geometry without depth. */\r\n BackgroundMap = 0,\r\n /** Rendered with normal scene graphics. */\r\n Scene = 1,\r\n /** Rendered in front of all other geometry. */\r\n Overlay = 2,\r\n}\r\n\r\n/** A reference to a [[TileTree]] suitable for drawing within a [[Viewport]]. The reference does not *own* its tile tree - it merely refers to it by\r\n * way of the tree's [[TileTreeOwner]].\r\n * The specific [[TileTree]] referenced by this object may change based on the current state of the Viewport in which it is drawn - for example,\r\n * as a result of changing the RenderMode, or animation settings, or classification settings, etc.\r\n * A reference to a TileTree is typically associated with a [[ViewState]], a [[DisplayStyleState]], or a [[Viewport]].\r\n * Multiple TileTreeReferences can refer to the same TileTree with different parameters and logic - for example, the same background map tiles can be displayed in two viewports with\r\n * differing levels of transparency.\r\n * @see [[TiledGraphicsProvider]] to supply custom [[TileTreeReference]]s to be drawn within a [[Viewport]].\r\n * @public\r\n */\r\nexport abstract class TileTreeReference /* implements RenderMemory.Consumer */ {\r\n /** The owner of the currently-referenced [[TileTree]]. Do not store a direct reference to it, because it may change or become disposed at any time. */\r\n public abstract get treeOwner(): TileTreeOwner;\r\n\r\n /** Disclose *all* TileTrees use by this reference. This may include things like map tiles used for draping on terrain.\r\n * Override this and call super if you have such auxiliary trees.\r\n * @note Any tree *NOT* disclosed becomes a candidate for *purging* (being unloaded from memory along with all of its tiles and graphics).\r\n */\r\n public discloseTileTrees(trees: DisclosedTileTreeSet): void {\r\n const tree = this.treeOwner.tileTree;\r\n if (undefined !== tree)\r\n trees.add(tree);\r\n }\r\n\r\n /** Adds this reference's graphics to the scene. By default this invokes [[draw]]. */\r\n public addToScene(context: SceneContext): void {\r\n const args = this.createDrawArgs(context);\r\n if (undefined !== args)\r\n this.draw(args);\r\n }\r\n\r\n /** Adds this reference's graphics to the scene. By default this invokes [[TileTree.draw]] on the referenced TileTree, if it is loaded. */\r\n public draw(args: TileDrawArgs): void {\r\n args.tree.draw(args);\r\n }\r\n\r\n /** Optionally return a tooltip describing the hit. */\r\n public async getToolTip(_hit: HitDetail): Promise<HTMLElement | string | undefined> { return undefined; }\r\n\r\n /** Optionally add any decorations specific to this reference. For example, map tile trees may add a logo image and/or copyright attributions.\r\n * @note This is currently only invoked for background maps and TiledGraphicsProviders - others have no decorations, but if they did implement this it would not be called.\r\n */\r\n public decorate(_context: DecorateContext): void { }\r\n\r\n /** Unions this reference's range with the supplied range to help compute a volume in world space for fitting a viewport to its contents.\r\n * Override this function if a reference's range should not be included in the fit range, or a range different from its tile tree's range should be used.\r\n */\r\n public unionFitRange(union: Range3d): void {\r\n const contentRange = this.computeWorldContentRange();\r\n if (!contentRange.isNull)\r\n union.extendRange(contentRange);\r\n }\r\n\r\n /** @internal */\r\n public collectStatistics(stats: RenderMemory.Statistics): void {\r\n const tree = this.treeOwner.tileTree;\r\n if (undefined !== tree)\r\n tree.collectStatistics(stats);\r\n }\r\n\r\n /** Return true if the tile tree is fully loaded and ready to draw.\r\n * The default implementation returns true if the tile tree loading process completed (whether it resulted in success or failure).\r\n * @note Do *not* override this property - override [[_isLoadingComplete]] instead..\r\n * @public\r\n */\r\n public get isLoadingComplete(): boolean {\r\n switch (this.treeOwner.loadStatus) {\r\n case TileTreeLoadStatus.NotLoaded:\r\n case TileTreeLoadStatus.Loading:\r\n return false;\r\n case TileTreeLoadStatus.NotFound:\r\n return true; // we tried, and failed, to load.\r\n case TileTreeLoadStatus.Loaded:\r\n return this._isLoadingComplete;\r\n }\r\n }\r\n\r\n /** Override if additional asynchronous loading is required after the tile tree is successfully loaded, to indicate when that loading has completed.\r\n * @public\r\n */\r\n protected get _isLoadingComplete(): boolean {\r\n return true;\r\n }\r\n\r\n /** Create context for drawing the tile tree, if it is ready for drawing.\r\n * TileTreeReferences can override individual portions of the context, e.g. apply their own transform.\r\n * Returns undefined if, e.g., the tile tree is not yet loaded.\r\n */\r\n public createDrawArgs(context: SceneContext): TileDrawArgs | undefined {\r\n const tree = this.treeOwner.load();\r\n if (undefined === tree)\r\n return undefined;\r\n\r\n return new TileDrawArgs({\r\n context,\r\n tree,\r\n now: BeTimePoint.now(),\r\n location: this.computeTransform(tree),\r\n viewFlagOverrides: this.getViewFlagOverrides(tree),\r\n clipVolume: this.getClipVolume(tree),\r\n parentsAndChildrenExclusive: tree.parentsAndChildrenExclusive,\r\n symbologyOverrides: this.getSymbologyOverrides(tree),\r\n appearanceProvider: this.getAppearanceProvider(tree),\r\n hiddenLineSettings: this.getHiddenLineSettings(tree),\r\n animationTransformNodeId: this.getAnimationTransformNodeId(tree),\r\n });\r\n }\r\n\r\n /** @internal */\r\n protected getAnimationTransformNodeId(_tree: TileTree): number | undefined {\r\n return undefined;\r\n }\r\n\r\n /** Supply transform from this tile tree reference's location to iModel coordinate space.\r\n * @returns undefined if the TileTree is not yet loaded.\r\n */\r\n public getLocation(): Transform | undefined {\r\n const tree = this.treeOwner.load();\r\n return undefined !== tree ? this.computeTransform(tree) : undefined;\r\n }\r\n\r\n /** Compute a transform from this tile tree reference's coordinate space to the [[IModelConnection]]'s coordinate space. */\r\n protected computeTransform(tree: TileTree): Transform {\r\n return tree.iModelTransform.clone();\r\n }\r\n\r\n /** Compute the range of this tile tree's contents in world coordinates.\r\n * @returns The content range in world coodinates, or a null range if the tile tree is not loaded or has a null content range.\r\n */\r\n public computeWorldContentRange(): ElementAlignedBox3d {\r\n const range = new Range3d();\r\n const tree = this.treeOwner.tileTree;\r\n if (undefined !== tree && !tree.rootTile.contentRange.isNull)\r\n this.computeTransform(tree).multiplyRange(tree.rootTile.contentRange, range);\r\n\r\n return range;\r\n }\r\n\r\n /** Return the clip volume applied to this reference's tile tree, if any. */\r\n protected getClipVolume(tree: TileTree): RenderClipVolume | undefined {\r\n return tree.clipVolume;\r\n }\r\n\r\n /** Supply overrides that should be applied to the [[ViewState]]'s [ViewFlags]($common) when drawing this tile tree reference. */\r\n protected getViewFlagOverrides(tree: TileTree): ViewFlagOverrides {\r\n return tree.viewFlagOverrides;\r\n }\r\n\r\n /** Return overrides that *replace* any defined for the view. */\r\n protected getSymbologyOverrides(_tree: TileTree): FeatureSymbology.Overrides | undefined {\r\n return undefined;\r\n }\r\n\r\n /** Return a provider that can supplement the view's symbology overrides. */\r\n protected getAppearanceProvider(_tree: TileTree): FeatureAppearanceProvider | undefined {\r\n return undefined;\r\n }\r\n\r\n /** Return hidden line settings to replace those defined for the view. */\r\n protected getHiddenLineSettings(_tree: TileTree): HiddenLine.Settings | undefined {\r\n return undefined;\r\n }\r\n\r\n /* Extend range to include transformed range of this tile tree.\r\n * @internal\r\n */\r\n public accumulateTransformedRange(range: Range3d, matrix: Matrix4d, frustumPlanes?: FrustumPlanes) {\r\n const tree = this.treeOwner.tileTree;\r\n if (undefined === tree)\r\n return;\r\n\r\n const location = this.computeTransform(tree);\r\n tree.accumulateTransformedRange(range, matrix, location, frustumPlanes);\r\n }\r\n\r\n /** @internal */\r\n public getTerrainHeight(_terrainHeights: Range1d): void { }\r\n\r\n /** Return whether the geometry exposed by this tile tree reference should cast shadows on other geometry. */\r\n public get castsShadows(): boolean {\r\n return true;\r\n }\r\n\r\n /** Return whether this reference has global coverage. Mapping data is global and some non-primary models such as the OSM building layer have global coverage */\r\n public get isGlobal(): boolean { return false; }\r\n\r\n /** Return the clip mask priority for this model - models will be clipped by any other viewed model with a higher proirity.\r\n * BIM models have highest prioirty and are never clipped.\r\n * @alpha\r\n */\r\n public get planarclipMaskPriority(): number { return PlanarClipMaskPriority.DesignModel; }\r\n\r\n /** Add attribution logo cards for the tile tree source logo cards to the viewport's logo div. */\r\n public addLogoCards(_cards: HTMLTableElement, _vp: ScreenViewport): void { }\r\n}\r\n"]}
|
|
@@ -2,22 +2,22 @@
|
|
|
2
2
|
* @module Tiles
|
|
3
3
|
*/
|
|
4
4
|
import { BeTimePoint } from "@itwin/core-bentley";
|
|
5
|
-
import {
|
|
6
|
-
/** A marker associated with a [[Tile]] to track usage of that tile by any number of
|
|
5
|
+
import { TileUser } from "./internal";
|
|
6
|
+
/** A marker associated with a [[Tile]] to track usage of that tile by any number of [[TileUser]]s.
|
|
7
7
|
* The marker tracks:
|
|
8
|
-
* - the set of [[
|
|
9
|
-
* - the most recent time at which any
|
|
10
|
-
* The marker is used to allow tiles to be discarded after they become disused by any
|
|
8
|
+
* - the set of [[TileUser]]s by which the tile is in use for some purpose (displayed, preloaded, requested, selected for shadow map, etc); and
|
|
9
|
+
* - the most recent time at which any tile user declared its use of the tile.
|
|
10
|
+
* The marker is used to allow tiles to be discarded after they become disused by any tile user, via [[Tile.prune]].
|
|
11
11
|
* @see [[Tile.usageMarker]].
|
|
12
12
|
* @public
|
|
13
13
|
*/
|
|
14
14
|
export declare class TileUsageMarker {
|
|
15
15
|
private _timePoint;
|
|
16
|
-
/** Constructs a usage marker with its timepoint set to the current time and its set of
|
|
16
|
+
/** Constructs a usage marker with its timepoint set to the current time and its set of [[TileUser]]s empty. */
|
|
17
17
|
constructor();
|
|
18
|
-
/** Returns true if this tile is currently in use by no
|
|
18
|
+
/** Returns true if this tile is currently in use by no [[TileUser]]s and its timestamp pre-dates `expirationTime`. */
|
|
19
19
|
isExpired(expirationTime: BeTimePoint): boolean;
|
|
20
|
-
/** Updates the timestamp to the specified time and marks the tile as being in use by the specified
|
|
21
|
-
mark(
|
|
20
|
+
/** Updates the timestamp to the specified time and marks the tile as being in use by the specified [[TileUser]]. */
|
|
21
|
+
mark(user: TileUser, time: BeTimePoint): void;
|
|
22
22
|
}
|
|
23
23
|
//# sourceMappingURL=TileUsageMarker.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TileUsageMarker.d.ts","sourceRoot":"","sources":["../../../src/tile/TileUsageMarker.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,OAAO,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"TileUsageMarker.d.ts","sourceRoot":"","sources":["../../../src/tile/TileUsageMarker.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC;;;;;;;GAOG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,UAAU,CAAqB;IAEvC,+GAA+G;;IAI/G,sHAAsH;IAC/G,SAAS,CAAC,cAAc,EAAE,WAAW,GAAG,OAAO;IAItD,oHAAoH;IAC7G,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,GAAG,IAAI;CAIrD"}
|
|
@@ -7,27 +7,27 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { BeTimePoint } from "@itwin/core-bentley";
|
|
9
9
|
import { IModelApp } from "../IModelApp";
|
|
10
|
-
/** A marker associated with a [[Tile]] to track usage of that tile by any number of
|
|
10
|
+
/** A marker associated with a [[Tile]] to track usage of that tile by any number of [[TileUser]]s.
|
|
11
11
|
* The marker tracks:
|
|
12
|
-
* - the set of [[
|
|
13
|
-
* - the most recent time at which any
|
|
14
|
-
* The marker is used to allow tiles to be discarded after they become disused by any
|
|
12
|
+
* - the set of [[TileUser]]s by which the tile is in use for some purpose (displayed, preloaded, requested, selected for shadow map, etc); and
|
|
13
|
+
* - the most recent time at which any tile user declared its use of the tile.
|
|
14
|
+
* The marker is used to allow tiles to be discarded after they become disused by any tile user, via [[Tile.prune]].
|
|
15
15
|
* @see [[Tile.usageMarker]].
|
|
16
16
|
* @public
|
|
17
17
|
*/
|
|
18
18
|
export class TileUsageMarker {
|
|
19
|
-
/** Constructs a usage marker with its timepoint set to the current time and its set of
|
|
19
|
+
/** Constructs a usage marker with its timepoint set to the current time and its set of [[TileUser]]s empty. */
|
|
20
20
|
constructor() {
|
|
21
21
|
this._timePoint = BeTimePoint.now();
|
|
22
22
|
}
|
|
23
|
-
/** Returns true if this tile is currently in use by no
|
|
23
|
+
/** Returns true if this tile is currently in use by no [[TileUser]]s and its timestamp pre-dates `expirationTime`. */
|
|
24
24
|
isExpired(expirationTime) {
|
|
25
25
|
return this._timePoint.before(expirationTime) && !IModelApp.tileAdmin.isTileInUse(this);
|
|
26
26
|
}
|
|
27
|
-
/** Updates the timestamp to the specified time and marks the tile as being in use by the specified
|
|
28
|
-
mark(
|
|
27
|
+
/** Updates the timestamp to the specified time and marks the tile as being in use by the specified [[TileUser]]. */
|
|
28
|
+
mark(user, time) {
|
|
29
29
|
this._timePoint = time;
|
|
30
|
-
IModelApp.tileAdmin.
|
|
30
|
+
IModelApp.tileAdmin.markTileUsed(this, user);
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
//# sourceMappingURL=TileUsageMarker.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TileUsageMarker.js","sourceRoot":"","sources":["../../../src/tile/TileUsageMarker.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGzC;;;;;;;GAOG;AACH,MAAM,OAAO,eAAe;IAG1B
|
|
1
|
+
{"version":3,"file":"TileUsageMarker.js","sourceRoot":"","sources":["../../../src/tile/TileUsageMarker.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGzC;;;;;;;GAOG;AACH,MAAM,OAAO,eAAe;IAG1B,+GAA+G;IAC/G;QAHQ,eAAU,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;IAIvC,CAAC;IAED,sHAAsH;IAC/G,SAAS,CAAC,cAA2B;QAC1C,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAC1F,CAAC;IAED,oHAAoH;IAC7G,IAAI,CAAC,IAAc,EAAE,IAAiB;QAC3C,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACvB,SAAS,CAAC,SAAS,CAAC,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC/C,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Tiles\r\n */\r\n\r\nimport { BeTimePoint } from \"@itwin/core-bentley\";\r\nimport { IModelApp } from \"../IModelApp\";\r\nimport { TileUser } from \"./internal\";\r\n\r\n/** A marker associated with a [[Tile]] to track usage of that tile by any number of [[TileUser]]s.\r\n * The marker tracks:\r\n * - the set of [[TileUser]]s by which the tile is in use for some purpose (displayed, preloaded, requested, selected for shadow map, etc); and\r\n * - the most recent time at which any tile user declared its use of the tile.\r\n * The marker is used to allow tiles to be discarded after they become disused by any tile user, via [[Tile.prune]].\r\n * @see [[Tile.usageMarker]].\r\n * @public\r\n */\r\nexport class TileUsageMarker {\r\n private _timePoint = BeTimePoint.now();\r\n\r\n /** Constructs a usage marker with its timepoint set to the current time and its set of [[TileUser]]s empty. */\r\n public constructor() {\r\n }\r\n\r\n /** Returns true if this tile is currently in use by no [[TileUser]]s and its timestamp pre-dates `expirationTime`. */\r\n public isExpired(expirationTime: BeTimePoint): boolean {\r\n return this._timePoint.before(expirationTime) && !IModelApp.tileAdmin.isTileInUse(this);\r\n }\r\n\r\n /** Updates the timestamp to the specified time and marks the tile as being in use by the specified [[TileUser]]. */\r\n public mark(user: TileUser, time: BeTimePoint): void {\r\n this._timePoint = time;\r\n IModelApp.tileAdmin.markTileUsed(this, user);\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module Tiles
|
|
3
|
+
*/
|
|
4
|
+
import { IModelConnection } from "../IModelConnection";
|
|
5
|
+
import { Viewport } from "../Viewport";
|
|
6
|
+
import { DisclosedTileTreeSet, TileRequest } from "./internal";
|
|
7
|
+
/** Represents some object that makes use of [[Tile]]s in some way - e.g., by requesting and/or displaying their contents, querying their geometry, etc.
|
|
8
|
+
* Each [[Tile]] keeps track of its users via its [[TileUsageMarker]]. A tile with no users is eligible to be discarded view [[Tile.prune]].
|
|
9
|
+
* Every [[Viewport]] is a tile user. It is occasionally useful to have a tile user that is **not** a viewport.
|
|
10
|
+
* Every TileUser is identified by an integer Id that is unique among all extant TileUsers. This Id **must** be obtained via [[TileUser.generateId]].
|
|
11
|
+
* Every TileUser must be registered with [[IModelApp.tileAdmin]] before use via [[TileAdmin.registerUser]] and unregistered via [[TileAdmin.forgetUser]] after
|
|
12
|
+
* it ceases using tiles.
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
export interface TileUser {
|
|
16
|
+
/** A unique integer identifying this user amongst all extant users. This Id **must** be obtained via [[TIleUser.generateId]]. */
|
|
17
|
+
readonly tileUserId: number;
|
|
18
|
+
/** The iModel with which the user is associated. */
|
|
19
|
+
readonly iModel: IModelConnection;
|
|
20
|
+
/** Disclose all tile trees currently in use by this user. Any tile tree not disclosed by any user becomes eligible for garbage collection. */
|
|
21
|
+
readonly discloseTileTrees: (trees: DisclosedTileTreeSet) => void;
|
|
22
|
+
/** An optional function invoked when a [[TileRequest]] associated with a [[Tile]] in use by this user changes state - e.g., when the request completes, fails, or
|
|
23
|
+
* is cancelled. For example, a [[Viewport]] responds to such events by invalidating its scene.
|
|
24
|
+
*/
|
|
25
|
+
readonly onRequestStateChanged?: (req: TileRequest) => void;
|
|
26
|
+
}
|
|
27
|
+
/** @public */
|
|
28
|
+
export declare namespace TileUser {
|
|
29
|
+
function generateId(): number;
|
|
30
|
+
/** Iterate the subset of `users` that are [[Viewport]]s. */
|
|
31
|
+
function viewportsFromUsers(users: Iterable<TileUser>): Iterable<Viewport>;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=TileUser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TileUser.d.ts","sourceRoot":"","sources":["../../../src/tile/TileUser.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE/D;;;;;;;GAOG;AACH,MAAM,WAAW,QAAQ;IACvB,iIAAiI;IACjI,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,oDAAoD;IACpD,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAClC,8IAA8I;IAC9I,QAAQ,CAAC,iBAAiB,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,IAAI,CAAC;IAClE;;OAEG;IACH,QAAQ,CAAC,qBAAqB,CAAC,EAAE,CAAC,GAAG,EAAE,WAAW,KAAK,IAAI,CAAC;CAC7D;AAID,cAAc;AACd,yBAAiB,QAAQ,CAAC;IACxB,SAAgB,UAAU,IAAI,MAAM,CAEnC;IAED,4DAA4D;IAC5D,SAAkB,kBAAkB,CAAC,KAAK,EAAE,QAAQ,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAIlF;CACF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
/** @packageDocumentation
|
|
6
|
+
* @module Tiles
|
|
7
|
+
*/
|
|
8
|
+
import { Viewport } from "../Viewport";
|
|
9
|
+
let nextUserId = 1;
|
|
10
|
+
/** @public */
|
|
11
|
+
export var TileUser;
|
|
12
|
+
(function (TileUser) {
|
|
13
|
+
function generateId() {
|
|
14
|
+
return nextUserId++;
|
|
15
|
+
}
|
|
16
|
+
TileUser.generateId = generateId;
|
|
17
|
+
/** Iterate the subset of `users` that are [[Viewport]]s. */
|
|
18
|
+
function* viewportsFromUsers(users) {
|
|
19
|
+
for (const user of users)
|
|
20
|
+
if (user instanceof Viewport)
|
|
21
|
+
yield user;
|
|
22
|
+
}
|
|
23
|
+
TileUser.viewportsFromUsers = viewportsFromUsers;
|
|
24
|
+
})(TileUser || (TileUser = {}));
|
|
25
|
+
//# sourceMappingURL=TileUser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TileUser.js","sourceRoot":"","sources":["../../../src/tile/TileUser.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAwBvC,IAAI,UAAU,GAAG,CAAC,CAAC;AAEnB,cAAc;AACd,MAAM,KAAW,QAAQ,CAWxB;AAXD,WAAiB,QAAQ;IACvB,SAAgB,UAAU;QACxB,OAAO,UAAU,EAAE,CAAC;IACtB,CAAC;IAFe,mBAAU,aAEzB,CAAA;IAED,4DAA4D;IAC5D,QAAgB,CAAC,CAAC,kBAAkB,CAAC,KAAyB;QAC5D,KAAK,MAAM,IAAI,IAAI,KAAK;YACtB,IAAI,IAAI,YAAY,QAAQ;gBAC1B,MAAM,IAAI,CAAC;IACjB,CAAC;IAJiB,2BAAkB,qBAInC,CAAA;AACH,CAAC,EAXgB,QAAQ,KAAR,QAAQ,QAWxB","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Tiles\r\n */\r\n\r\nimport { IModelConnection } from \"../IModelConnection\";\r\nimport { Viewport } from \"../Viewport\";\r\nimport { DisclosedTileTreeSet, TileRequest } from \"./internal\";\r\n\r\n/** Represents some object that makes use of [[Tile]]s in some way - e.g., by requesting and/or displaying their contents, querying their geometry, etc.\r\n * Each [[Tile]] keeps track of its users via its [[TileUsageMarker]]. A tile with no users is eligible to be discarded view [[Tile.prune]].\r\n * Every [[Viewport]] is a tile user. It is occasionally useful to have a tile user that is **not** a viewport.\r\n * Every TileUser is identified by an integer Id that is unique among all extant TileUsers. This Id **must** be obtained via [[TileUser.generateId]].\r\n * Every TileUser must be registered with [[IModelApp.tileAdmin]] before use via [[TileAdmin.registerUser]] and unregistered via [[TileAdmin.forgetUser]] after\r\n * it ceases using tiles.\r\n * @public\r\n */\r\nexport interface TileUser {\r\n /** A unique integer identifying this user amongst all extant users. This Id **must** be obtained via [[TIleUser.generateId]]. */\r\n readonly tileUserId: number;\r\n /** The iModel with which the user is associated. */\r\n readonly iModel: IModelConnection;\r\n /** Disclose all tile trees currently in use by this user. Any tile tree not disclosed by any user becomes eligible for garbage collection. */\r\n readonly discloseTileTrees: (trees: DisclosedTileTreeSet) => void;\r\n /** An optional function invoked when a [[TileRequest]] associated with a [[Tile]] in use by this user changes state - e.g., when the request completes, fails, or\r\n * is cancelled. For example, a [[Viewport]] responds to such events by invalidating its scene.\r\n */\r\n readonly onRequestStateChanged?: (req: TileRequest) => void;\r\n}\r\n\r\nlet nextUserId = 1;\r\n\r\n/** @public */\r\nexport namespace TileUser {\r\n export function generateId(): number {\r\n return nextUserId++;\r\n }\r\n\r\n /** Iterate the subset of `users` that are [[Viewport]]s. */\r\n export function * viewportsFromUsers(users: Iterable<TileUser>): Iterable<Viewport> {\r\n for (const user of users)\r\n if (user instanceof Viewport)\r\n yield user;\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module Utils
|
|
3
|
+
*/
|
|
4
|
+
import { ReadonlySortedArray } from "@itwin/core-bentley";
|
|
5
|
+
import { TileUser } from "./internal";
|
|
6
|
+
/** An immutable set of [[TileUser]]s wherein uniqueness is determined by each TileUser's unique integer identifier.
|
|
7
|
+
* @see [[UniqueTileUserSets]].
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export declare class ReadonlyTileUserSet extends ReadonlySortedArray<TileUser> {
|
|
11
|
+
constructor(user?: TileUser);
|
|
12
|
+
}
|
|
13
|
+
/** Maintains a set of [[TileUserSets]] designed to minimize duplication.
|
|
14
|
+
* For example, the tile request scheduler needs to associate with each [[TileRequest]] the set of [[TileUser]]s awaiting the request's response.
|
|
15
|
+
* Using UniqueTileUserSets ensures all tiles requested by the same user use the same TileUserSet object.
|
|
16
|
+
* Additionally, whenever a user is unregistered there is no need to track down every associated tile request - the user can just be removed from the TileUserSets managed by this object.
|
|
17
|
+
* The TileUserSets managed by this object should be treated as immutable - "adding" a user to an existing set should be done using [[getTileUserSet]].
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
export declare class UniqueTileUserSets {
|
|
21
|
+
private readonly _sets;
|
|
22
|
+
getTileUserSet(user: TileUser, users?: ReadonlyTileUserSet): ReadonlyTileUserSet;
|
|
23
|
+
clearAll(): void;
|
|
24
|
+
clear(): void;
|
|
25
|
+
remove(user: TileUser): void;
|
|
26
|
+
static get emptySet(): ReadonlyTileUserSet;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=TileUserSet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TileUserSet.d.ts","sourceRoot":"","sources":["../../../src/tile/TileUserSet.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,mBAAmB,EAAe,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC;;;GAGG;AACH,qBAAa,mBAAoB,SAAQ,mBAAmB,CAAC,QAAQ,CAAC;gBACjD,IAAI,CAAC,EAAE,QAAQ;CAKnC;AAwFD;;;;;;GAMG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAwB;IAEvC,cAAc,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,CAAC,EAAE,mBAAmB,GAAG,mBAAmB;IAIhF,QAAQ,IAAI,IAAI;IAIhB,KAAK,IAAI,IAAI;IAIb,MAAM,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI;IAInC,WAAkB,QAAQ,IAAI,mBAAmB,CAEhD;CACF"}
|