@itwin/core-frontend 3.5.0-dev.27 → 3.5.0-dev.28

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.
@@ -6,6 +6,32 @@ import { ChangesetIndex, ChangesetIndexAndId, IModelConnectionProps, OpenBriefca
6
6
  import { BriefcaseTxns } from "./BriefcaseTxns";
7
7
  import { GraphicalEditingScope } from "./GraphicalEditingScope";
8
8
  import { IModelConnection } from "./IModelConnection";
9
+ import { ProgressCallback } from "./request/Request";
10
+ /**
11
+ * Partial interface of AbortSignal.
12
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal
13
+ * @alpha
14
+ */
15
+ export interface GenericAbortSignal {
16
+ /** Add Listener for abort signal. */
17
+ addEventListener: (type: "abort", listener: (this: GenericAbortSignal, ev: any) => any) => void;
18
+ /** Remove Listener for abort signal. */
19
+ removeEventListener: (type: "abort", listener: (this: GenericAbortSignal, ev: any) => any) => void;
20
+ }
21
+ /**
22
+ * Options for pulling iModel changes.
23
+ * @public
24
+ */
25
+ export interface PullChangesOptions {
26
+ /** Function called regularly to report progress of changes download. */
27
+ progressCallback?: ProgressCallback;
28
+ /** Interval for calling progress callback (in milliseconds). */
29
+ progressInterval?: number;
30
+ /** Signal for cancelling the download.
31
+ * @alpha
32
+ */
33
+ abortSignal?: GenericAbortSignal;
34
+ }
9
35
  /** Settings that can be used to control the behavior of [[Tool]]s that modify a [[BriefcaseConnection]].
10
36
  * For example, tools that want to create new elements can consult the briefcase's editor tool settings to
11
37
  * determine into which model and category to insert the elements.
@@ -78,9 +104,10 @@ export declare class BriefcaseConnection extends IModelConnection {
78
104
  saveChanges(description?: string): Promise<void>;
79
105
  /** Pull (and potentially merge if there are local changes) up to a specified changeset from iModelHub into this briefcase
80
106
  * @param toIndex The changeset index to pull changes to. If `undefined`, pull all changes.
107
+ * @param options Options for pulling changes.
81
108
  * @see [[BriefcaseTxns.onChangesPulled]] for the event dispatched after changes are pulled.
82
109
  */
83
- pullChanges(toIndex?: ChangesetIndex): Promise<void>;
110
+ pullChanges(toIndex?: ChangesetIndex, options?: PullChangesOptions): Promise<void>;
84
111
  /** Create a changeset from local Txns and push to iModelHub. On success, clear Txn table.
85
112
  * @param description The description for the changeset
86
113
  * @returns the changesetId of the pushed changes
@@ -1 +1 @@
1
- {"version":3,"file":"BriefcaseConnection.d.ts","sourceRoot":"","sources":["../../src/BriefcaseConnection.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAU,OAAO,EAA2B,UAAU,EAAE,UAAU,EAAgB,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/H,OAAO,EACL,cAAc,EACd,mBAAmB,EAAE,qBAAqB,EAAe,kBAAkB,EAAE,qBAAqB,EACnG,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAoItD;;;;;;;GAOG;AACH,qBAAa,2BAA2B;IACtC,OAAO,CAAC,SAAS,CAAC,CAAa;IAC/B,OAAO,CAAC,MAAM,CAAC,CAAa;IAE5B,sEAAsE;IACtE,SAAgB,iBAAiB,6BAAkC,UAAU,GAAG,SAAS,KAAK,IAAI,EAAI;IAEtG,mEAAmE;IACnE,SAAgB,cAAc,0BAA+B,UAAU,GAAG,SAAS,KAAK,IAAI,EAAI;IAEhG;;;;OAIG;IACH,IAAW,QAAQ,IAAI,UAAU,GAAG,SAAS,CAE5C;IACD,IAAW,QAAQ,CAAC,QAAQ,EAAE,UAAU,GAAG,SAAS,EAMnD;IAED;;;;OAIG;IACH,IAAW,KAAK,IAAI,UAAU,GAAG,SAAS,CAEzC;IACD,IAAW,KAAK,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,EAM7C;CACF;AAED;;;GAGG;AACH,qBAAa,mBAAoB,SAAQ,gB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CAAC;IAOzJ,2DAA2D;IAC3D,IAAW,QAAQ,IAAI,OAAO,CAAoC;IAElE;;;OAGG;IACU,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAanC,OAAO,CAAC,eAAe;IAKvB,2FAA2F;IAC9E,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC;IAI/C;;OAEG;IACU,WAAW,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI7D;;;;OAIG;IACU,WAAW,CAAC,OAAO,CAAC,EAAE,cAAc,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IA4B/F;;;;OAIG;IACU,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAK3E;;OAEG;IACH,IAAW,YAAY,IAAI,qBAAqB,GAAG,SAAS,CAE3D;IAED;;;OAGG;IACU,wBAAwB,IAAI,OAAO,CAAC,OAAO,CAAC;IAIzD;;;;;OAKG;IACU,iBAAiB,IAAI,OAAO,CAAC,qBAAqB,CAAC;IAIhE;;OAEG;IACH,SAAgB,sBAAsB,4BAAiC,IAAI,MAAM,CAAC,KAAK,IAAI,EAAI;CAChG"}
@@ -238,11 +238,32 @@ class BriefcaseConnection extends IModelConnection_1.IModelConnection {
238
238
  }
239
239
  /** Pull (and potentially merge if there are local changes) up to a specified changeset from iModelHub into this briefcase
240
240
  * @param toIndex The changeset index to pull changes to. If `undefined`, pull all changes.
241
+ * @param options Options for pulling changes.
241
242
  * @see [[BriefcaseTxns.onChangesPulled]] for the event dispatched after changes are pulled.
242
243
  */
243
- async pullChanges(toIndex) {
244
+ async pullChanges(toIndex, options) {
245
+ const removeListeners = [];
246
+ if (options === null || options === void 0 ? void 0 : options.progressCallback) {
247
+ const removeProgressListener = IpcApp_1.IpcApp.addListener((0, core_common_1.getPullChangesIpcChannel)(this.iModelId), (_evt, data) => { var _a; return (_a = options === null || options === void 0 ? void 0 : options.progressCallback) === null || _a === void 0 ? void 0 : _a.call(options, data); });
248
+ removeListeners.push(removeProgressListener);
249
+ }
250
+ if (options === null || options === void 0 ? void 0 : options.abortSignal) {
251
+ const abort = () => void IpcApp_1.IpcApp.appFunctionIpc.cancelPullChangesRequest(this.key);
252
+ options === null || options === void 0 ? void 0 : options.abortSignal.addEventListener("abort", abort);
253
+ removeListeners.push(() => { var _a; return (_a = options === null || options === void 0 ? void 0 : options.abortSignal) === null || _a === void 0 ? void 0 : _a.removeEventListener("abort", abort); });
254
+ }
244
255
  this.requireTimeline();
245
- this.changeset = await IpcApp_1.IpcApp.appFunctionIpc.pullChanges(this.key, toIndex);
256
+ const ipcAppOptions = {
257
+ reportProgress: !!(options === null || options === void 0 ? void 0 : options.progressCallback),
258
+ progressInterval: options === null || options === void 0 ? void 0 : options.progressInterval,
259
+ enableCancellation: !!(options === null || options === void 0 ? void 0 : options.abortSignal),
260
+ };
261
+ try {
262
+ this.changeset = await IpcApp_1.IpcApp.appFunctionIpc.pullChanges(this.key, toIndex, ipcAppOptions);
263
+ }
264
+ finally {
265
+ removeListeners.forEach((remove) => remove());
266
+ }
246
267
  }
247
268
  /** Create a changeset from local Txns and push to iModelHub. On success, clear Txn table.
248
269
  * @param description The description for the changeset
@@ -1 +1 @@
1
- {"version":3,"file":"BriefcaseConnection.js","sourceRoot":"","sources":["../../src/BriefcaseConnection.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA+H;AAC/H,oDAG4B;AAC5B,mDAAgD;AAChD,mEAAgE;AAChE,2CAAwC;AACxC,yDAAsD;AACtD,qCAAkC;AAClC,8CAAqE;AACrE,yCAAsC;AAEtC;;;GAGG;AACH,MAAM,kBAAkB;IAOtB,YAAmB,SAA8B;QAJhC,mBAAc,GAAG,IAAI,GAAG,EAAU,CAAC;QACnC,mBAAc,GAAG,IAAI,GAAG,EAAkB,CAAC;QAC3C,cAAS,GAAmB,EAAE,CAAC;QAG9C,IAAI,CA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AW,CAAC,OAAwB;QAC/C,IAAI,CAAC,eAAe,EAAE,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,MAAM,eAAM,CAAC,cAAc,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC9E,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,WAAW,CAAC,WAAmB;QAC1C,IAAI,CAAC,eAAe,EAAE,CAAC;QACvB,OAAO,eAAM,CAAC,cAAc,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;IAClE,CAAC;IAED;;OAEG;IACH,IAAW,YAAY;QACrB,OAAO,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC;IAC1C,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,wBAAwB;QACnC,OAAO,eAAM,CAAC,cAAc,CAAC,2BAA2B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACrE,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,iBAAiB;QAC5B,OAAO,IAAI,CAAC,cAAc,CAAC,iBAAiB,EAAE,CAAC;IACjD,CAAC;CAMF;AAlID,kDAkIC","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 IModelConnection\r\n */\r\n\r\nimport { assert, BeEvent, CompressedId64Set, Guid, GuidString, Id64String, IModelStatus, OpenMode } from \"@itwin/core-bentley\";\r\nimport {\r\n ChangesetIndex,\r\n ChangesetIndexAndId, IModelConnectionProps, IModelError, OpenBriefcaseProps, StandaloneOpenOptions,\r\n} from \"@itwin/core-common\";\r\nimport { BriefcaseTxns } from \"./BriefcaseTxns\";\r\nimport { GraphicalEditingScope } from \"./GraphicalEditingScope\";\r\nimport { IModelApp } from \"./IModelApp\";\r\nimport { IModelConnection } from \"./IModelConnection\";\r\nimport { IpcApp } from \"./IpcApp\";\r\nimport { disposeTileTreesForGeometricModels } from \"./tile/internal\";\r\nimport { Viewport } from \"./Viewport\";\r\n\r\n/** Keeps track of changes to models, buffering them until synchronization points.\r\n * While a GraphicalEditingScope is open, the changes are buffered until the scope exits, at which point they are processed.\r\n * Otherwise, the buffered changes are processed after undo/redo, commit, or pull+merge changes.\r\n */\r\nclass ModelChangeMonitor {\r\n private _editingScope?: GraphicalEditingScope;\r\n private readonly _briefcase: BriefcaseConnection;\r\n private readonly _deletedModels = new Set<string>();\r\n private readonly _modelIdToGuid = new Map<string, string>();\r\n private readonly _removals: VoidFunction[] = [];\r\n\r\n public constructor(briefcase: BriefcaseConnection) {\r\n this._briefcase = briefcase;\r\n\r\n // Buffer updated geometry guids.\r\n this._removals.push(briefcase.txns.onModelGeometryChanged.addListener((changes) => {\r\n for (const change of changes) {\r\n this._deletedModels.delete(change.id);\r\n this._modelIdToGuid.set(change.id, change.guid);\r\n }\r\n }));\r\n\r\n // Buffer deletions of models.\r\n this._removals.push(briefcase.txns.onModelsChanged.addListener((changes) => {\r\n if (changes.deleted) {\r\n for (const id of CompressedId64Set.iterable(changes.deleted)) {\r\n this._modelIdToGuid.delete(id);\r\n this._deletedModels.add(id);\r\n }\r\n }\r\n }));\r\n\r\n // Outside of an editing scope, we want to update viewport contents after commit, undo/redo, or merging changes.\r\n const maybeProcess = async () => {\r\n if (this.editingScope)\r\n return;\r\n\r\n const modelIds = Array.from(this._modelIdToGuid.keys());\r\n if (modelIds.length > 0)\r\n await IModelApp.tileAdmin.purgeTileTrees(this._briefcase, modelIds);\r\n\r\n this.processBuffered();\r\n };\r\n\r\n this._removals.push(briefcase.txns.onCommitted.addListener(maybeProcess));\r\n this._removals.push(briefcase.txns.onAfterUndoRedo.addListener(maybeProcess));\r\n this._removals.push(briefcase.txns.onChangesPulled.addListener(maybeProcess));\r\n }\r\n\r\n public async close(): Promise<void> {\r\n for (const removal of this._removals)\r\n removal();\r\n\r\n this._removals.length = 0;\r\n\r\n if (this._editingScope) {\r\n await this._editingScope.exit();\r\n this._editingScope = undefined;\r\n }\r\n }\r\n\r\n public get editingScope(): GraphicalEditingScope | undefined {\r\n return this._editingScope;\r\n }\r\n\r\n public async enterEditingScope(): Promise<GraphicalEditingScope> {\r\n if (this._editingScope)\r\n throw new Error(\"Cannot create an editing scope for an iModel that already has one\");\r\n\r\n this._editingScope = await GraphicalEditingScope.enter(this._briefcase);\r\n\r\n const removeGeomListener = this._editingScope.onGeometryChanges.addListener((changes) => {\r\n const modelIds = [];\r\n for (const change of changes)\r\n modelIds.push(change.id);\r\n\r\n this.invalidateScenes(modelIds);\r\n });\r\n\r\n this._editingScope.onExited.addOnce((scope) => {\r\n assert(scope === this._editingScope);\r\n this._editingScope = undefined;\r\n removeGeomListener();\r\n this.processBuffered();\r\n });\r\n\r\n return this._editingScope;\r\n }\r\n\r\n private processBuffered(): void {\r\n const models = this._briefcase.models;\r\n for (const [id, guid] of this._modelIdToGuid) {\r\n const model = models.getLoaded(id)?.asGeometricModel;\r\n if (model)\r\n model.geometryGuid = guid;\r\n }\r\n\r\n const modelIds = new Set<string>(this._modelIdToGuid.keys());\r\n for (const deleted of this._deletedModels) {\r\n modelIds.add(deleted);\r\n models.unload(deleted);\r\n }\r\n\r\n this.invalidateScenes(modelIds);\r\n disposeTileTreesForGeometricModels(modelIds, this._briefcase);\r\n\r\n this._briefcase.onBufferedModelChanges.raiseEvent(modelIds);\r\n\r\n this._modelIdToGuid.clear();\r\n this._deletedModels.clear();\r\n }\r\n\r\n private invalidateScenes(changedModels: Iterable<Id64String>): void {\r\n for (const user of IModelApp.tileAdmin.tileUsers) {\r\n if (user instanceof Viewport && user.iModel === this._briefcase) {\r\n for (const modelId of changedModels) {\r\n if (user.view.viewsModel(modelId)) {\r\n user.invalidateScene();\r\n user.setFeatureOverrideProviderChanged();\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n}\r\n\r\n/** Settings that can be used to control the behavior of [[Tool]]s that modify a [[BriefcaseConnection]].\r\n * For example, tools that want to create new elements can consult the briefcase's editor tool settings to\r\n * determine into which model and category to insert the elements.\r\n * Specialized tools are free to ignore these settings.\r\n * @see [[BriefcaseConnection.editorToolSettings]] to query or modify the current settings for a briefcase.\r\n * @see [CreateElementTool]($editor-frontend) for an example of a tool that uses these settings.\r\n * @alpha\r\n */\r\nexport class BriefcaseEditorToolSettings {\r\n private _category?: Id64String;\r\n private _model?: Id64String;\r\n\r\n /** An event raised just after the default [[category]] is changed. */\r\n public readonly onCategoryChanged = new BeEvent<(previousCategory: Id64String | undefined) => void>();\r\n\r\n /** An event raised just after the default [[model]] is changed. */\r\n public readonly onModelChanged = new BeEvent<(previousModel: Id64String | undefined) => void>();\r\n\r\n /** The [Category]($backend) into which new elements should be inserted by default.\r\n * Specialized tools are free to ignore this setting and instead use their own logic to select an appropriate category.\r\n * @see [[onCategoryChanged]] to be notified when this property is modified.\r\n * @see [CreateElementTool.targetCategory]($editor-frontend) for an example of a tool that uses this setting.\r\n */\r\n public get category(): Id64String | undefined {\r\n return this._category;\r\n }\r\n public set category(category: Id64String | undefined) {\r\n const previousCategory = this.category;\r\n if (category !== this.category) {\r\n this._category = category;\r\n this.onCategoryChanged.raiseEvent(previousCategory);\r\n }\r\n }\r\n\r\n /** The [Model]($backend) into which new elements should be inserted by default.\r\n * Specialized tools are free to ignore this setting and instead use their own logic to select an appropriate model.\r\n * @see [[onModelChanged]] to be notified when this property is modified.\r\n * @see [CreateElementTool.targetModel]($editor-frontend) for an example of a tool that uses this setting.\r\n */\r\n public get model(): Id64String | undefined {\r\n return this._model;\r\n }\r\n public set model(model: Id64String | undefined) {\r\n const previousModel = this.model;\r\n if (model !== this.model) {\r\n this._model = model;\r\n this.onModelChanged.raiseEvent(previousModel);\r\n }\r\n }\r\n}\r\n\r\n/** A connection to an editable briefcase on the backend. This class uses [Ipc]($docs/learning/IpcInterface.md) to communicate\r\n * to the backend and may only be used by [[IpcApp]]s.\r\n * @public\r\n */\r\nexport class BriefcaseConnection extends IModelConnection {\r\n protected _isClosed?: boolean;\r\n private readonly _modelsMonitor: ModelChangeMonitor;\r\n /** Default settings that can be used to control the behavior of [[Tool]]s that modify this briefcase.\r\n * @alpha\r\n */\r\n public readonly editorToolSettings = new BriefcaseEditorToolSettings();\r\n\r\n /** Manages local changes to the briefcase via [Txns]($docs/learning/InteractiveEditing.md). */\r\n public readonly txns: BriefcaseTxns;\r\n\r\n /** @internal */\r\n public override isBriefcaseConnection(): this is BriefcaseConnection { return true; }\r\n\r\n /** The Guid that identifies the iTwin that owns this iModel. */\r\n public override get iTwinId(): GuidString { return super.iTwinId!; } // GuidString | undefined for IModelConnection, but required for BriefcaseConnection\r\n\r\n /** The Guid that identifies this iModel. */\r\n public override get iModelId(): GuidString { return super.iModelId!; } // GuidString | undefined for IModelConnection, but required for BriefcaseConnection\r\n\r\n protected constructor(props: IModelConnectionProps, openMode: OpenMode) {\r\n super(props);\r\n this._openMode = openMode;\r\n this.txns = new BriefcaseTxns(this);\r\n this._modelsMonitor = new ModelChangeMonitor(this);\r\n }\r\n\r\n /** Open a BriefcaseConnection to a [BriefcaseDb]($backend). */\r\n public static async openFile(briefcaseProps: OpenBriefcaseProps): Promise<BriefcaseConnection> {\r\n const iModelProps = await IpcApp.appFunctionIpc.openBriefcase(briefcaseProps);\r\n const connection = new this({ ...briefcaseProps, ...iModelProps }, briefcaseProps.readonly ? OpenMode.Readonly : OpenMode.ReadWrite);\r\n IModelConnection.onOpen.raiseEvent(connection);\r\n return connection;\r\n }\r\n\r\n /** Open a BriefcaseConnection to a [StandaloneDb]($backend)\r\n * @note StandaloneDbs, by definition, may not push or pull changes. Attempting to do so will throw exceptions.\r\n */\r\n public static async openStandalone(filePath: string, openMode: OpenMode = OpenMode.ReadWrite, opts?: StandaloneOpenOptions): Promise<BriefcaseConnection> {\r\n const openResponse = await IpcApp.appFunctionIpc.openStandalone(filePath, openMode, opts);\r\n const connection = new this(openResponse, openMode);\r\n IModelConnection.onOpen.raiseEvent(connection);\r\n return connection;\r\n }\r\n\r\n /** Returns `true` if [[close]] has already been called. */\r\n public get isClosed(): boolean { return this._isClosed === true; }\r\n\r\n /**\r\n * Close this BriefcaseConnection.\r\n * @note make sure to call [[saveChanges]] before calling this method. Unsaved local changes are abandoned.\r\n */\r\n public async close(): Promise<void> {\r\n if (this.isClosed)\r\n return;\r\n\r\n await this._modelsMonitor.close();\r\n\r\n this.beforeClose();\r\n this.txns.dispose();\r\n\r\n this._isClosed = true;\r\n await IpcApp.appFunctionIpc.closeIModel(this._fileKey);\r\n }\r\n\r\n private requireTimeline() {\r\n if (this.iTwinId === Guid.empty)\r\n throw new IModelError(IModelStatus.WrongIModel, \"iModel has no timeline\");\r\n }\r\n\r\n /** Query if there are any pending Txns in this briefcase that are waiting to be pushed. */\r\n public async hasPendingTxns(): Promise<boolean> { // eslint-disable-line @itwin/prefer-get\r\n return this.txns.hasPendingTxns();\r\n }\r\n\r\n /** Commit pending changes to this briefcase.\r\n * @param description Optional description of the changes.\r\n */\r\n public async saveChanges(description?: string): Promise<void> {\r\n await IpcApp.appFunctionIpc.saveChanges(this.key, description);\r\n }\r\n\r\n /** Pull (and potentially merge if there are local changes) up to a specified changeset from iModelHub into this briefcase\r\n * @param toIndex The changeset index to pull changes to. If `undefined`, pull all changes.\r\n * @see [[BriefcaseTxns.onChangesPulled]] for the event dispatched after changes are pulled.\r\n */\r\n public async pullChanges(toIndex?: ChangesetIndex): Promise<void> {\r\n this.requireTimeline();\r\n this.changeset = await IpcApp.appFunctionIpc.pullChanges(this.key, toIndex);\r\n }\r\n\r\n /** Create a changeset from local Txns and push to iModelHub. On success, clear Txn table.\r\n * @param description The description for the changeset\r\n * @returns the changesetId of the pushed changes\r\n * @see [[BriefcaseTxns.onChangesPushed]] for the event dispatched after changes are pushed.\r\n */\r\n public async pushChanges(description: string): Promise<ChangesetIndexAndId> {\r\n this.requireTimeline();\r\n return IpcApp.appFunctionIpc.pushChanges(this.key, description);\r\n }\r\n\r\n /** The current graphical editing scope, if one is in progress.\r\n * @see [[enterEditingScope]] to begin graphical editing.\r\n */\r\n public get editingScope(): GraphicalEditingScope | undefined {\r\n return this._modelsMonitor.editingScope;\r\n }\r\n\r\n /** Return whether graphical editing is supported for this briefcase. It is not supported if the briefcase is read-only, or the briefcase contains a version of\r\n * the BisCore ECSchema older than v0.1.11.\r\n * @see [[enterEditingScope]] to enable graphical editing.\r\n */\r\n public async supportsGraphicalEditing(): Promise<boolean> {\r\n return IpcApp.appFunctionIpc.isGraphicalEditingSupported(this.key);\r\n }\r\n\r\n /** Begin a new graphical editing scope.\r\n * @throws Error if an editing scope already exists or one could not be created.\r\n * @see [[GraphicalEditingScope.exit]] to exit the scope.\r\n * @see [[supportsGraphicalEditing]] to determine whether this method should be expected to succeed.\r\n * @see [[editingScope]] to obtain the current editing scope, if one is in progress.\r\n */\r\n public async enterEditingScope(): Promise<GraphicalEditingScope> {\r\n return this._modelsMonitor.enterEditingScope();\r\n }\r\n\r\n /** Strictly for tests - dispatched from ModelChangeMonitor.processBuffered.\r\n * @internal\r\n */\r\n public readonly onBufferedModelChanges = new BeEvent<(changedModelIds: Set<string>) => void>();\r\n}\r\n"]}
1
+ {"version":3,"file":"BriefcaseConnection.js","sourceRoot":"","sources":["../../src/BriefcaseConnection.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA+H;AAC/H,oDAG4B;AAC5B,mDAAgD;AAChD,mEAAgE;AAChE,2CAAwC;AACxC,yDAAsD;AACtD,qCAAkC;AAElC,8CAAqE;AACrE,yCAAsC;AA6BtC;;;GAGG;AACH,MAAM,kBAAkB;IAOtB,YAAmB,SAA8B;QAJhC,mBAAc,GAAG,IAAI,GAAG,EAAU,CAAC;QACnC,mBAAc,GAAG,IAAI,GAAG,EAAkB,CAAC;QAC3C,cAAS,GAAmB,EAAE,CAAC;QAG9C,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAE5B,iCAAiC;QAC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AAM,CAAC,cAAc,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,EAAE,aAAa,CAAC,CAAC;SAC5F;gBAAS;YACR,eAAe,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC;SAC/C;IACH,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,WAAW,CAAC,WAAmB;QAC1C,IAAI,CAAC,eAAe,EAAE,CAAC;QACvB,OAAO,eAAM,CAAC,cAAc,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;IAClE,CAAC;IAED;;OAEG;IACH,IAAW,YAAY;QACrB,OAAO,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC;IAC1C,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,wBAAwB;QACnC,OAAO,eAAM,CAAC,cAAc,CAAC,2BAA2B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACrE,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,iBAAiB;QAC5B,OAAO,IAAI,CAAC,cAAc,CAAC,iBAAiB,EAAE,CAAC;IACjD,CAAC;CAMF;AA1JD,kDA0JC","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 IModelConnection\r\n */\r\n\r\nimport { assert, BeEvent, CompressedId64Set, Guid, GuidString, Id64String, IModelStatus, OpenMode } from \"@itwin/core-bentley\";\r\nimport {\r\n ChangesetIndex, ChangesetIndexAndId, getPullChangesIpcChannel, IModelConnectionProps, IModelError,\r\n PullChangesOptions as IpcAppPullChangesOptions, OpenBriefcaseProps, StandaloneOpenOptions,\r\n} from \"@itwin/core-common\";\r\nimport { BriefcaseTxns } from \"./BriefcaseTxns\";\r\nimport { GraphicalEditingScope } from \"./GraphicalEditingScope\";\r\nimport { IModelApp } from \"./IModelApp\";\r\nimport { IModelConnection } from \"./IModelConnection\";\r\nimport { IpcApp } from \"./IpcApp\";\r\nimport { ProgressCallback } from \"./request/Request\";\r\nimport { disposeTileTreesForGeometricModels } from \"./tile/internal\";\r\nimport { Viewport } from \"./Viewport\";\r\n\r\n/**\r\n * Partial interface of AbortSignal.\r\n * @see https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal\r\n * @alpha\r\n */\r\nexport interface GenericAbortSignal {\r\n /** Add Listener for abort signal. */\r\n addEventListener: (type: \"abort\", listener: (this: GenericAbortSignal, ev: any) => any) => void;\r\n /** Remove Listener for abort signal. */\r\n removeEventListener: (type: \"abort\", listener: (this: GenericAbortSignal, ev: any) => any) => void;\r\n}\r\n\r\n/**\r\n * Options for pulling iModel changes.\r\n * @public\r\n */\r\nexport interface PullChangesOptions {\r\n /** Function called regularly to report progress of changes download. */\r\n progressCallback?: ProgressCallback;\r\n /** Interval for calling progress callback (in milliseconds). */\r\n progressInterval?: number;\r\n /** Signal for cancelling the download.\r\n * @alpha\r\n */\r\n abortSignal?: GenericAbortSignal;\r\n}\r\n\r\n/** Keeps track of changes to models, buffering them until synchronization points.\r\n * While a GraphicalEditingScope is open, the changes are buffered until the scope exits, at which point they are processed.\r\n * Otherwise, the buffered changes are processed after undo/redo, commit, or pull+merge changes.\r\n */\r\nclass ModelChangeMonitor {\r\n private _editingScope?: GraphicalEditingScope;\r\n private readonly _briefcase: BriefcaseConnection;\r\n private readonly _deletedModels = new Set<string>();\r\n private readonly _modelIdToGuid = new Map<string, string>();\r\n private readonly _removals: VoidFunction[] = [];\r\n\r\n public constructor(briefcase: BriefcaseConnection) {\r\n this._briefcase = briefcase;\r\n\r\n // Buffer updated geometry guids.\r\n this._removals.push(briefcase.txns.onModelGeometryChanged.addListener((changes) => {\r\n for (const change of changes) {\r\n this._deletedModels.delete(change.id);\r\n this._modelIdToGuid.set(change.id, change.guid);\r\n }\r\n }));\r\n\r\n // Buffer deletions of models.\r\n this._removals.push(briefcase.txns.onModelsChanged.addListener((changes) => {\r\n if (changes.deleted) {\r\n for (const id of CompressedId64Set.iterable(changes.deleted)) {\r\n this._modelIdToGuid.delete(id);\r\n this._deletedModels.add(id);\r\n }\r\n }\r\n }));\r\n\r\n // Outside of an editing scope, we want to update viewport contents after commit, undo/redo, or merging changes.\r\n const maybeProcess = async () => {\r\n if (this.editingScope)\r\n return;\r\n\r\n const modelIds = Array.from(this._modelIdToGuid.keys());\r\n if (modelIds.length > 0)\r\n await IModelApp.tileAdmin.purgeTileTrees(this._briefcase, modelIds);\r\n\r\n this.processBuffered();\r\n };\r\n\r\n this._removals.push(briefcase.txns.onCommitted.addListener(maybeProcess));\r\n this._removals.push(briefcase.txns.onAfterUndoRedo.addListener(maybeProcess));\r\n this._removals.push(briefcase.txns.onChangesPulled.addListener(maybeProcess));\r\n }\r\n\r\n public async close(): Promise<void> {\r\n for (const removal of this._removals)\r\n removal();\r\n\r\n this._removals.length = 0;\r\n\r\n if (this._editingScope) {\r\n await this._editingScope.exit();\r\n this._editingScope = undefined;\r\n }\r\n }\r\n\r\n public get editingScope(): GraphicalEditingScope | undefined {\r\n return this._editingScope;\r\n }\r\n\r\n public async enterEditingScope(): Promise<GraphicalEditingScope> {\r\n if (this._editingScope)\r\n throw new Error(\"Cannot create an editing scope for an iModel that already has one\");\r\n\r\n this._editingScope = await GraphicalEditingScope.enter(this._briefcase);\r\n\r\n const removeGeomListener = this._editingScope.onGeometryChanges.addListener((changes) => {\r\n const modelIds = [];\r\n for (const change of changes)\r\n modelIds.push(change.id);\r\n\r\n this.invalidateScenes(modelIds);\r\n });\r\n\r\n this._editingScope.onExited.addOnce((scope) => {\r\n assert(scope === this._editingScope);\r\n this._editingScope = undefined;\r\n removeGeomListener();\r\n this.processBuffered();\r\n });\r\n\r\n return this._editingScope;\r\n }\r\n\r\n private processBuffered(): void {\r\n const models = this._briefcase.models;\r\n for (const [id, guid] of this._modelIdToGuid) {\r\n const model = models.getLoaded(id)?.asGeometricModel;\r\n if (model)\r\n model.geometryGuid = guid;\r\n }\r\n\r\n const modelIds = new Set<string>(this._modelIdToGuid.keys());\r\n for (const deleted of this._deletedModels) {\r\n modelIds.add(deleted);\r\n models.unload(deleted);\r\n }\r\n\r\n this.invalidateScenes(modelIds);\r\n disposeTileTreesForGeometricModels(modelIds, this._briefcase);\r\n\r\n this._briefcase.onBufferedModelChanges.raiseEvent(modelIds);\r\n\r\n this._modelIdToGuid.clear();\r\n this._deletedModels.clear();\r\n }\r\n\r\n private invalidateScenes(changedModels: Iterable<Id64String>): void {\r\n for (const user of IModelApp.tileAdmin.tileUsers) {\r\n if (user instanceof Viewport && user.iModel === this._briefcase) {\r\n for (const modelId of changedModels) {\r\n if (user.view.viewsModel(modelId)) {\r\n user.invalidateScene();\r\n user.setFeatureOverrideProviderChanged();\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n}\r\n\r\n/** Settings that can be used to control the behavior of [[Tool]]s that modify a [[BriefcaseConnection]].\r\n * For example, tools that want to create new elements can consult the briefcase's editor tool settings to\r\n * determine into which model and category to insert the elements.\r\n * Specialized tools are free to ignore these settings.\r\n * @see [[BriefcaseConnection.editorToolSettings]] to query or modify the current settings for a briefcase.\r\n * @see [CreateElementTool]($editor-frontend) for an example of a tool that uses these settings.\r\n * @alpha\r\n */\r\nexport class BriefcaseEditorToolSettings {\r\n private _category?: Id64String;\r\n private _model?: Id64String;\r\n\r\n /** An event raised just after the default [[category]] is changed. */\r\n public readonly onCategoryChanged = new BeEvent<(previousCategory: Id64String | undefined) => void>();\r\n\r\n /** An event raised just after the default [[model]] is changed. */\r\n public readonly onModelChanged = new BeEvent<(previousModel: Id64String | undefined) => void>();\r\n\r\n /** The [Category]($backend) into which new elements should be inserted by default.\r\n * Specialized tools are free to ignore this setting and instead use their own logic to select an appropriate category.\r\n * @see [[onCategoryChanged]] to be notified when this property is modified.\r\n * @see [CreateElementTool.targetCategory]($editor-frontend) for an example of a tool that uses this setting.\r\n */\r\n public get category(): Id64String | undefined {\r\n return this._category;\r\n }\r\n public set category(category: Id64String | undefined) {\r\n const previousCategory = this.category;\r\n if (category !== this.category) {\r\n this._category = category;\r\n this.onCategoryChanged.raiseEvent(previousCategory);\r\n }\r\n }\r\n\r\n /** The [Model]($backend) into which new elements should be inserted by default.\r\n * Specialized tools are free to ignore this setting and instead use their own logic to select an appropriate model.\r\n * @see [[onModelChanged]] to be notified when this property is modified.\r\n * @see [CreateElementTool.targetModel]($editor-frontend) for an example of a tool that uses this setting.\r\n */\r\n public get model(): Id64String | undefined {\r\n return this._model;\r\n }\r\n public set model(model: Id64String | undefined) {\r\n const previousModel = this.model;\r\n if (model !== this.model) {\r\n this._model = model;\r\n this.onModelChanged.raiseEvent(previousModel);\r\n }\r\n }\r\n}\r\n\r\n/** A connection to an editable briefcase on the backend. This class uses [Ipc]($docs/learning/IpcInterface.md) to communicate\r\n * to the backend and may only be used by [[IpcApp]]s.\r\n * @public\r\n */\r\nexport class BriefcaseConnection extends IModelConnection {\r\n protected _isClosed?: boolean;\r\n private readonly _modelsMonitor: ModelChangeMonitor;\r\n /** Default settings that can be used to control the behavior of [[Tool]]s that modify this briefcase.\r\n * @alpha\r\n */\r\n public readonly editorToolSettings = new BriefcaseEditorToolSettings();\r\n\r\n /** Manages local changes to the briefcase via [Txns]($docs/learning/InteractiveEditing.md). */\r\n public readonly txns: BriefcaseTxns;\r\n\r\n /** @internal */\r\n public override isBriefcaseConnection(): this is BriefcaseConnection { return true; }\r\n\r\n /** The Guid that identifies the iTwin that owns this iModel. */\r\n public override get iTwinId(): GuidString { return super.iTwinId!; } // GuidString | undefined for IModelConnection, but required for BriefcaseConnection\r\n\r\n /** The Guid that identifies this iModel. */\r\n public override get iModelId(): GuidString { return super.iModelId!; } // GuidString | undefined for IModelConnection, but required for BriefcaseConnection\r\n\r\n protected constructor(props: IModelConnectionProps, openMode: OpenMode) {\r\n super(props);\r\n this._openMode = openMode;\r\n this.txns = new BriefcaseTxns(this);\r\n this._modelsMonitor = new ModelChangeMonitor(this);\r\n }\r\n\r\n /** Open a BriefcaseConnection to a [BriefcaseDb]($backend). */\r\n public static async openFile(briefcaseProps: OpenBriefcaseProps): Promise<BriefcaseConnection> {\r\n const iModelProps = await IpcApp.appFunctionIpc.openBriefcase(briefcaseProps);\r\n const connection = new this({ ...briefcaseProps, ...iModelProps }, briefcaseProps.readonly ? OpenMode.Readonly : OpenMode.ReadWrite);\r\n IModelConnection.onOpen.raiseEvent(connection);\r\n return connection;\r\n }\r\n\r\n /** Open a BriefcaseConnection to a [StandaloneDb]($backend)\r\n * @note StandaloneDbs, by definition, may not push or pull changes. Attempting to do so will throw exceptions.\r\n */\r\n public static async openStandalone(filePath: string, openMode: OpenMode = OpenMode.ReadWrite, opts?: StandaloneOpenOptions): Promise<BriefcaseConnection> {\r\n const openResponse = await IpcApp.appFunctionIpc.openStandalone(filePath, openMode, opts);\r\n const connection = new this(openResponse, openMode);\r\n IModelConnection.onOpen.raiseEvent(connection);\r\n return connection;\r\n }\r\n\r\n /** Returns `true` if [[close]] has already been called. */\r\n public get isClosed(): boolean { return this._isClosed === true; }\r\n\r\n /**\r\n * Close this BriefcaseConnection.\r\n * @note make sure to call [[saveChanges]] before calling this method. Unsaved local changes are abandoned.\r\n */\r\n public async close(): Promise<void> {\r\n if (this.isClosed)\r\n return;\r\n\r\n await this._modelsMonitor.close();\r\n\r\n this.beforeClose();\r\n this.txns.dispose();\r\n\r\n this._isClosed = true;\r\n await IpcApp.appFunctionIpc.closeIModel(this._fileKey);\r\n }\r\n\r\n private requireTimeline() {\r\n if (this.iTwinId === Guid.empty)\r\n throw new IModelError(IModelStatus.WrongIModel, \"iModel has no timeline\");\r\n }\r\n\r\n /** Query if there are any pending Txns in this briefcase that are waiting to be pushed. */\r\n public async hasPendingTxns(): Promise<boolean> { // eslint-disable-line @itwin/prefer-get\r\n return this.txns.hasPendingTxns();\r\n }\r\n\r\n /** Commit pending changes to this briefcase.\r\n * @param description Optional description of the changes.\r\n */\r\n public async saveChanges(description?: string): Promise<void> {\r\n await IpcApp.appFunctionIpc.saveChanges(this.key, description);\r\n }\r\n\r\n /** Pull (and potentially merge if there are local changes) up to a specified changeset from iModelHub into this briefcase\r\n * @param toIndex The changeset index to pull changes to. If `undefined`, pull all changes.\r\n * @param options Options for pulling changes.\r\n * @see [[BriefcaseTxns.onChangesPulled]] for the event dispatched after changes are pulled.\r\n */\r\n public async pullChanges(toIndex?: ChangesetIndex, options?: PullChangesOptions): Promise<void> {\r\n const removeListeners: VoidFunction[] = [];\r\n if (options?.progressCallback) {\r\n const removeProgressListener = IpcApp.addListener(\r\n getPullChangesIpcChannel(this.iModelId),\r\n (_evt: Event, data: { loaded: number, total: number }) => options?.progressCallback?.(data),\r\n );\r\n removeListeners.push(removeProgressListener);\r\n }\r\n if (options?.abortSignal) {\r\n const abort = () => void IpcApp.appFunctionIpc.cancelPullChangesRequest(this.key);\r\n options?.abortSignal.addEventListener(\"abort\", abort);\r\n removeListeners.push(() => options?.abortSignal?.removeEventListener(\"abort\", abort));\r\n }\r\n\r\n this.requireTimeline();\r\n const ipcAppOptions: IpcAppPullChangesOptions = {\r\n reportProgress: !!options?.progressCallback,\r\n progressInterval: options?.progressInterval,\r\n enableCancellation: !!options?.abortSignal,\r\n };\r\n try {\r\n this.changeset = await IpcApp.appFunctionIpc.pullChanges(this.key, toIndex, ipcAppOptions);\r\n } finally {\r\n removeListeners.forEach((remove) => remove());\r\n }\r\n }\r\n\r\n /** Create a changeset from local Txns and push to iModelHub. On success, clear Txn table.\r\n * @param description The description for the changeset\r\n * @returns the changesetId of the pushed changes\r\n * @see [[BriefcaseTxns.onChangesPushed]] for the event dispatched after changes are pushed.\r\n */\r\n public async pushChanges(description: string): Promise<ChangesetIndexAndId> {\r\n this.requireTimeline();\r\n return IpcApp.appFunctionIpc.pushChanges(this.key, description);\r\n }\r\n\r\n /** The current graphical editing scope, if one is in progress.\r\n * @see [[enterEditingScope]] to begin graphical editing.\r\n */\r\n public get editingScope(): GraphicalEditingScope | undefined {\r\n return this._modelsMonitor.editingScope;\r\n }\r\n\r\n /** Return whether graphical editing is supported for this briefcase. It is not supported if the briefcase is read-only, or the briefcase contains a version of\r\n * the BisCore ECSchema older than v0.1.11.\r\n * @see [[enterEditingScope]] to enable graphical editing.\r\n */\r\n public async supportsGraphicalEditing(): Promise<boolean> {\r\n return IpcApp.appFunctionIpc.isGraphicalEditingSupported(this.key);\r\n }\r\n\r\n /** Begin a new graphical editing scope.\r\n * @throws Error if an editing scope already exists or one could not be created.\r\n * @see [[GraphicalEditingScope.exit]] to exit the scope.\r\n * @see [[supportsGraphicalEditing]] to determine whether this method should be expected to succeed.\r\n * @see [[editingScope]] to obtain the current editing scope, if one is in progress.\r\n */\r\n public async enterEditingScope(): Promise<GraphicalEditingScope> {\r\n return this._modelsMonitor.enterEditingScope();\r\n }\r\n\r\n /** Strictly for tests - dispatched from ModelChangeMonitor.processBuffered.\r\n * @internal\r\n */\r\n public readonly onBufferedModelChanges = new BeEvent<(changedModelIds: Set<string>) => void>();\r\n}\r\n"]}
@@ -71,6 +71,12 @@ export declare class IpcApp {
71
71
  * @param channelName the channel registered by the backend handler.
72
72
  */
73
73
  static makeIpcProxy<K>(channelName: string): PickAsyncMethods<K>;
74
+ /** Create a type safe Proxy object to call an IPC function on a of registered backend handler that accepts a "methodName" argument followed by optional arguments
75
+ * @param channelName the channel registered by the backend handler.
76
+ * @param functionName the function to call on the handler.
77
+ * @internal
78
+ */
79
+ static makeIpcFunctionProxy<K>(channelName: string, functionName: string): PickAsyncMethods<K>;
74
80
  /** @deprecated use [[appFunctionIpc]] */
75
81
  static callIpcHost<T extends AsyncMethodsOf<IpcAppFunctions>>(methodName: T, ...args: Parameters<IpcAppFunctions[T]>): Promise<PromiseReturnType<IpcAppFunctions[T]>>;
76
82
  /** A Proxy to call one of the [IpcAppFunctions]($common) functions via IPC. */
@@ -1 +1 @@
1
- {"version":3,"file":"IpcApp.d.ts","sourceRoot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,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;IAIzE;;;;;;OAMG;WACW,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE;IAIlD;;;;;;;;;;OAUG;WACiB,cAAc,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;IAUzG;;OAEG;WACW,YAAY,CAAC,CAAC,EAAE,WAAW,EAAE,MAAM,GAAG,gBAAgB,CAAC,CAAC,CAAC;IASvE;;;;OAIG;WACW,oBAAoB,CAAC,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,gBAAgB,CAAC,CAAC,CAAC;IASrG,yCAAyC;WACrB,WAAW,CAAC,CAAC,SAAS,cAAc,CAAC,eAAe,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,UAAU,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IAIjI,+EAA+E;IAC/E,OAAc,cAAc,oCAAiE;IAE7F;qFACiF;WAC7D,OAAO,CAAC,GAAG,EAAE,iBAAiB,EAAE,IAAI,CAAC,EAAE,aAAa;IAMxE,gBAAgB;WACI,QAAQ;CAI7B;AAED;;;;;;;;;;;;;GAaG;AACH,8BAAsB,mBAAmB;IACvC,wFAAwF;IACxF,aAAoB,WAAW,IAAI,MAAM,CAAC;IAEnC,YAAY,IAAI,cAAc;IAUrC;;;;;OAKG;WACW,QAAQ,IAAI,cAAc;CAGzC"}
package/lib/cjs/IpcApp.js CHANGED
@@ -91,6 +91,18 @@ class IpcApp {
91
91
  },
92
92
  });
93
93
  }
94
+ /** Create a type safe Proxy object to call an IPC function on a of registered backend handler that accepts a "methodName" argument followed by optional arguments
95
+ * @param channelName the channel registered by the backend handler.
96
+ * @param functionName the function to call on the handler.
97
+ * @internal
98
+ */
99
+ static makeIpcFunctionProxy(channelName, functionName) {
100
+ return new Proxy({}, {
101
+ get(_target, methodName) {
102
+ return async (...args) => IpcApp.callIpcChannel(channelName, functionName, methodName, ...args);
103
+ },
104
+ });
105
+ }
94
106
  /** @deprecated use [[appFunctionIpc]] */
95
107
  static async callIpcHost(methodName, ...args) {
96
108
  return this.callIpcChannel(core_common_1.IpcAppChannel.Functions, methodName, ...args);
@@ -1 +1 @@
1
- {"version":3,"file":"IpcApp.js","sourceRoot":"","sources":["../../src/IpcApp.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,oDAG4B;AAC5B,2CAA0D;AAU1D;;;GAGG;AACH,MAAa,MAAM;IAEjB,qEAAqE;IAE7D,MAAM,KAAK,GAAG,KAAwB,OAAO,IAAI,CAAC,IAAK,CAAC,CAAC,CAAC;IAElE,iIAAiI;IAC1H,MAAM,KAAK,OAAO,KAAc,OAAO,SAAS,KAAK,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAExE;;;;;;;OAOG;IACI,MAAM,CAAC,WAAW,CAAC,OAAe,EAAE,OAAoB;QAC7D,OAAO,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,IAAA,0BAAY,EAAC,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;IAC9D,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,cAAc,CAAC,OAAe,EAAE,QAAqB;QACjE,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,IAAA,0BAAY,EAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,CAAC;IAC3D,CAAC;IAED;;;;;;;;;OASG;IACI,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,OAAe,EAAE,GAAG,IAAW;QACxD,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAA,0BAAY,EAAC,OAAO,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC;IACzD,CAAC;IAED;;;;;;OAMG;IACI,M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AAM,mBAAoB,SAAQ,mBAAmB;IACnD,IAAW,WAAW,KAAK,OAAO,2BAAa,CAAC,SAAS,CAAC,CAAC,CAAC;IACrD,SAAS,KAAK,CAAC;CACvB","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 NativeApp\r\n */\r\n\r\nimport { AsyncMethodsOf, PickAsyncMethods, PromiseReturnType } from \"@itwin/core-bentley\";\r\nimport {\r\n BackendError, IModelError, IModelStatus, IpcAppChannel, IpcAppFunctions, IpcAppNotifications, IpcInvokeReturn, IpcListener, IpcSocketFrontend,\r\n iTwinChannel, RemoveFunction,\r\n} from \"@itwin/core-common\";\r\nimport { IModelApp, IModelAppOptions } from \"./IModelApp\";\r\n\r\n/**\r\n * Options for [[IpcApp.startup]]\r\n * @public\r\n */\r\nexport interface IpcAppOptions {\r\n iModelApp?: IModelAppOptions;\r\n}\r\n\r\n/**\r\n * The frontend of apps with a dedicated backend that can use [Ipc]($docs/learning/IpcInterface.md).\r\n * @public\r\n */\r\nexport class IpcApp {\r\n private static _ipc: IpcSocketFrontend | undefined;\r\n /** Get the implementation of the [[IpcSocketFrontend]] interface. */\r\n\r\n private static get ipc(): IpcSocketFrontend { return this._ipc!; }\r\n\r\n /** Determine whether Ipc is available for this frontend. This will only be true if [[startup]] has been called on this class. */\r\n public static get isValid(): boolean { return undefined !== this._ipc; }\r\n\r\n /**\r\n * Establish a message handler function for the supplied channel over Ipc. The handler will be called when messages are sent for\r\n * the channel via [[BackendIpc.send]].\r\n * @param channel the name of the channel\r\n * @param handler the message handler\r\n * @returns A function to remove the handler\r\n * @note Ipc is only supported if [[isValid]] is true.\r\n */\r\n public static addListener(channel: string, handler: IpcListener): RemoveFunction {\r\n return this.ipc.addListener(iTwinChannel(channel), handler);\r\n }\r\n\r\n /**\r\n * Remove a previously registered listener\r\n * @param channel The name of the channel for the listener previously registered with [[addListener]]\r\n * @param listener The function passed to [[addListener]]\r\n */\r\n public static removeListener(channel: string, listener: IpcListener) {\r\n this.ipc.removeListener(iTwinChannel(channel), listener);\r\n }\r\n\r\n /**\r\n * Send a message to the backend via `channel` and expect a result asynchronously. The handler must be established on the backend via [[BackendIpc.handle]]\r\n * @param channel The name of the channel for the method.\r\n * @see Electron [ipcRenderer.invoke](https://www.electronjs.org/docs/api/ipc-renderer) documentation for details.\r\n * Note that this interface may be implemented via Electron for desktop apps, or via\r\n * [WebSockets](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API) for mobile or web-based\r\n * Ipc connections. In either case, the Electron documentation provides the specifications for how it works.\r\n * @note `args` are serialized with the [Structured Clone Algorithm](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm), so only\r\n * primitive types and `ArrayBuffers` are allowed.\r\n */\r\n public static async invoke(channel: string, ...args: any[]): Promise<any> {\r\n return this.ipc.invoke(iTwinChannel(channel), ...args);\r\n }\r\n\r\n /**\r\n * Send a message over the socket.\r\n * @param channel The name of the channel for the message.\r\n * @param data The optional data of the message.\r\n * @note `data` is serialized with the [Structured Clone Algorithm](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm), so only\r\n * primitive types and `ArrayBuffers` are allowed.\r\n */\r\n public static send(channel: string, ...data: any[]) {\r\n return this.ipc.send(iTwinChannel(channel), ...data);\r\n }\r\n\r\n /**\r\n * Call a method on the backend through an Ipc channel.\r\n * @param channelName the channel registered by the backend handler.\r\n * @param methodName the name of a method implemented by the backend handler.\r\n * @param args arguments to `methodName`\r\n * @return a Promise with the return value from `methodName`\r\n * @note If the backend implementation throws an exception, this method will throw a [[BackendError]] exception\r\n * with the `errorNumber` and `message` from the backend.\r\n * @note Ipc is only supported if [[isValid]] is true.\r\n * @internal\r\n */\r\n public static async callIpcChannel(channelName: string, methodName: string, ...args: any[]): Promise<any> {\r\n const retVal = (await this.invoke(channelName, methodName, ...args)) as IpcInvokeReturn;\r\n if (undefined !== retVal.error) {\r\n const err = new BackendError(retVal.error.errorNumber, retVal.error.name, retVal.error.message);\r\n err.stack = retVal.error.stack;\r\n throw err;\r\n }\r\n return retVal.result;\r\n }\r\n\r\n /** Create a type safe Proxy object to make IPC calls to a registered backend interface.\r\n * @param channelName the channel registered by the backend handler.\r\n */\r\n public static makeIpcProxy<K>(channelName: string): PickAsyncMethods<K> {\r\n return new Proxy({} as PickAsyncMethods<K>, {\r\n get(_target, methodName: string) {\r\n return async (...args: any[]) =>\r\n IpcApp.callIpcChannel(channelName, methodName, ...args);\r\n },\r\n });\r\n }\r\n\r\n /** @deprecated use [[appFunctionIpc]] */\r\n public static async callIpcHost<T extends AsyncMethodsOf<IpcAppFunctions>>(methodName: T, ...args: Parameters<IpcAppFunctions[T]>) {\r\n return this.callIpcChannel(IpcAppChannel.Functions, methodName, ...args) as PromiseReturnType<IpcAppFunctions[T]>;\r\n }\r\n\r\n /** A Proxy to call one of the [IpcAppFunctions]($common) functions via IPC. */\r\n public static appFunctionIpc = IpcApp.makeIpcProxy<IpcAppFunctions>(IpcAppChannel.Functions);\r\n\r\n /** start an IpcApp.\r\n * @note this should not be called directly. It is called by NativeApp.startup */\r\n public static async startup(ipc: IpcSocketFrontend, opts?: IpcAppOptions) {\r\n this._ipc = ipc;\r\n IpcAppNotifyHandler.register(); // receives notifications from backend\r\n await IModelApp.startup(opts?.iModelApp);\r\n }\r\n\r\n /** @internal */\r\n public static async shutdown() {\r\n this._ipc = undefined;\r\n await IModelApp.shutdown();\r\n }\r\n}\r\n\r\n/**\r\n * Base class for all implementations of an Ipc notification response interface. This class is implemented on your frontend to supply\r\n * methods to receive notifications from your backend.\r\n *\r\n * Create a subclass to implement your Ipc response interface. Your class should be declared like this:\r\n * ```ts\r\n * class MyNotificationHandler extends NotificationHandler implements MyNotifications\r\n * ```\r\n * to ensure all method names and signatures are correct. Your methods cannot have a return value.\r\n *\r\n * Then, call `MyNotificationHandler.register` at startup to connect your class to your channel.\r\n * @public\r\n * @extensions\r\n */\r\nexport abstract class NotificationHandler {\r\n /** All subclasses must implement this method to specify their response channel name. */\r\n public abstract get channelName(): string;\r\n\r\n public registerImpl(): RemoveFunction {\r\n return IpcApp.addListener(this.channelName, (_evt: Event, funcName: string, ...args: any[]) => {\r\n const func = (this as any)[funcName];\r\n if (typeof func !== \"function\")\r\n throw new IModelError(IModelStatus.FunctionNotFound, `Method \"${this.constructor.name}.${funcName}\" not found on NotificationHandler registered for channel: ${this.channelName}`);\r\n\r\n func.call(this, ...args);\r\n });\r\n }\r\n\r\n /**\r\n * Register this class as the handler for notifications on its channel. This static method creates a new instance\r\n * that becomes the notification handler and is `this` when its methods are called.\r\n * @returns A function that can be called to remove the handler.\r\n * @note this method should only be called once per channel. If it is called multiple times, multiple handlers are established.\r\n */\r\n public static register(): RemoveFunction {\r\n return (new (this as any)() as NotificationHandler).registerImpl(); // create an instance of subclass. \"as any\" is necessary because base class is abstract\r\n }\r\n}\r\n\r\n/** IpcApp notifications from backend */\r\nclass IpcAppNotifyHandler extends NotificationHandler implements IpcAppNotifications {\r\n public get channelName() { return IpcAppChannel.AppNotify; }\r\n public notifyApp() { }\r\n}\r\n"]}
1
+ {"version":3,"file":"IpcApp.js","sourceRoot":"","sources":["../../src/IpcApp.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,oDAG4B;AAC5B,2CAA0D;AAU1D;;;GAGG;AACH,MAAa,MAAM;IAEjB,qEAAqE;IAE7D,MAAM,KAAK,GAAG,KAAwB,OAAO,IAAI,CAAC,IAAK,CAAC,CAAC,CAAC;IAElE,iIAAiI;IAC1H,MAAM,KAAK,OAAO,KAAc,OAAO,SAAS,KAAK,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAExE;;;;;;;OAOG;IACI,MAAM,CAAC,WAAW,CAAC,OAAe,EAAE,OAAoB;QAC7D,OAAO,IAAI,CAAC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,EAAE,CAAC;IAC7B,CAAC;;AA1HH,wBA2HC;AAhBC,+EAA+E;AACjE,qBAAc,GAAG,MAAM,CAAC,YAAY,CAAkB,2BAAa,CAAC,SAAS,CAAC,CAAC;AAiB/F;;;;;;;;;;;;;GAaG;AACH,MAAsB,mBAAmB;IAIhC,YAAY;QACjB,OAAO,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,IAAW,EAAE,QAAgB,EAAE,GAAG,IAAW,EAAE,EAAE;YAC5F,MAAM,IAAI,GAAI,IAAY,CAAC,QAAQ,CAAC,CAAC;YACrC,IAAI,OAAO,IAAI,KAAK,UAAU;gBAC5B,MAAM,IAAI,yBAAW,CAAC,0BAAY,CAAC,gBAAgB,EAAE,WAAW,IAAI,CAAC,WAAW,CAAC,IAAI,IAAI,QAAQ,8DAA8D,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;YAErL,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC;QAC3B,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,QAAQ;QACpB,OAAQ,IAAK,IAAY,EAA0B,CAAC,YAAY,EAAE,CAAC,CAAC,uFAAuF;IAC7J,CAAC;CACF;AAvBD,kDAuBC;AAED,wCAAwC;AACxC,MAAM,mBAAoB,SAAQ,mBAAmB;IACnD,IAAW,WAAW,KAAK,OAAO,2BAAa,CAAC,SAAS,CAAC,CAAC,CAAC;IACrD,SAAS,KAAK,CAAC;CACvB","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 NativeApp\r\n */\r\n\r\nimport { AsyncMethodsOf, PickAsyncMethods, PromiseReturnType } from \"@itwin/core-bentley\";\r\nimport {\r\n BackendError, IModelError, IModelStatus, IpcAppChannel, IpcAppFunctions, IpcAppNotifications, IpcInvokeReturn, IpcListener, IpcSocketFrontend,\r\n iTwinChannel, RemoveFunction,\r\n} from \"@itwin/core-common\";\r\nimport { IModelApp, IModelAppOptions } from \"./IModelApp\";\r\n\r\n/**\r\n * Options for [[IpcApp.startup]]\r\n * @public\r\n */\r\nexport interface IpcAppOptions {\r\n iModelApp?: IModelAppOptions;\r\n}\r\n\r\n/**\r\n * The frontend of apps with a dedicated backend that can use [Ipc]($docs/learning/IpcInterface.md).\r\n * @public\r\n */\r\nexport class IpcApp {\r\n private static _ipc: IpcSocketFrontend | undefined;\r\n /** Get the implementation of the [[IpcSocketFrontend]] interface. */\r\n\r\n private static get ipc(): IpcSocketFrontend { return this._ipc!; }\r\n\r\n /** Determine whether Ipc is available for this frontend. This will only be true if [[startup]] has been called on this class. */\r\n public static get isValid(): boolean { return undefined !== this._ipc; }\r\n\r\n /**\r\n * Establish a message handler function for the supplied channel over Ipc. The handler will be called when messages are sent for\r\n * the channel via [[BackendIpc.send]].\r\n * @param channel the name of the channel\r\n * @param handler the message handler\r\n * @returns A function to remove the handler\r\n * @note Ipc is only supported if [[isValid]] is true.\r\n */\r\n public static addListener(channel: string, handler: IpcListener): RemoveFunction {\r\n return this.ipc.addListener(iTwinChannel(channel), handler);\r\n }\r\n\r\n /**\r\n * Remove a previously registered listener\r\n * @param channel The name of the channel for the listener previously registered with [[addListener]]\r\n * @param listener The function passed to [[addListener]]\r\n */\r\n public static removeListener(channel: string, listener: IpcListener) {\r\n this.ipc.removeListener(iTwinChannel(channel), listener);\r\n }\r\n\r\n /**\r\n * Send a message to the backend via `channel` and expect a result asynchronously. The handler must be established on the backend via [[BackendIpc.handle]]\r\n * @param channel The name of the channel for the method.\r\n * @see Electron [ipcRenderer.invoke](https://www.electronjs.org/docs/api/ipc-renderer) documentation for details.\r\n * Note that this interface may be implemented via Electron for desktop apps, or via\r\n * [WebSockets](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API) for mobile or web-based\r\n * Ipc connections. In either case, the Electron documentation provides the specifications for how it works.\r\n * @note `args` are serialized with the [Structured Clone Algorithm](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm), so only\r\n * primitive types and `ArrayBuffers` are allowed.\r\n */\r\n public static async invoke(channel: string, ...args: any[]): Promise<any> {\r\n return this.ipc.invoke(iTwinChannel(channel), ...args);\r\n }\r\n\r\n /**\r\n * Send a message over the socket.\r\n * @param channel The name of the channel for the message.\r\n * @param data The optional data of the message.\r\n * @note `data` is serialized with the [Structured Clone Algorithm](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm), so only\r\n * primitive types and `ArrayBuffers` are allowed.\r\n */\r\n public static send(channel: string, ...data: any[]) {\r\n return this.ipc.send(iTwinChannel(channel), ...data);\r\n }\r\n\r\n /**\r\n * Call a method on the backend through an Ipc channel.\r\n * @param channelName the channel registered by the backend handler.\r\n * @param methodName the name of a method implemented by the backend handler.\r\n * @param args arguments to `methodName`\r\n * @return a Promise with the return value from `methodName`\r\n * @note If the backend implementation throws an exception, this method will throw a [[BackendError]] exception\r\n * with the `errorNumber` and `message` from the backend.\r\n * @note Ipc is only supported if [[isValid]] is true.\r\n * @internal\r\n */\r\n public static async callIpcChannel(channelName: string, methodName: string, ...args: any[]): Promise<any> {\r\n const retVal = (await this.invoke(channelName, methodName, ...args)) as IpcInvokeReturn;\r\n if (undefined !== retVal.error) {\r\n const err = new BackendError(retVal.error.errorNumber, retVal.error.name, retVal.error.message);\r\n err.stack = retVal.error.stack;\r\n throw err;\r\n }\r\n return retVal.result;\r\n }\r\n\r\n /** Create a type safe Proxy object to make IPC calls to a registered backend interface.\r\n * @param channelName the channel registered by the backend handler.\r\n */\r\n public static makeIpcProxy<K>(channelName: string): PickAsyncMethods<K> {\r\n return new Proxy({} as PickAsyncMethods<K>, {\r\n get(_target, methodName: string) {\r\n return async (...args: any[]) =>\r\n IpcApp.callIpcChannel(channelName, methodName, ...args);\r\n },\r\n });\r\n }\r\n\r\n /** Create a type safe Proxy object to call an IPC function on a of registered backend handler that accepts a \"methodName\" argument followed by optional arguments\r\n * @param channelName the channel registered by the backend handler.\r\n * @param functionName the function to call on the handler.\r\n * @internal\r\n */\r\n public static makeIpcFunctionProxy<K>(channelName: string, functionName: string): PickAsyncMethods<K> {\r\n return new Proxy({} as PickAsyncMethods<K>, {\r\n get(_target, methodName: string) {\r\n return async (...args: any[]) =>\r\n IpcApp.callIpcChannel(channelName, functionName, methodName, ...args);\r\n },\r\n });\r\n }\r\n\r\n /** @deprecated use [[appFunctionIpc]] */\r\n public static async callIpcHost<T extends AsyncMethodsOf<IpcAppFunctions>>(methodName: T, ...args: Parameters<IpcAppFunctions[T]>) {\r\n return this.callIpcChannel(IpcAppChannel.Functions, methodName, ...args) as PromiseReturnType<IpcAppFunctions[T]>;\r\n }\r\n\r\n /** A Proxy to call one of the [IpcAppFunctions]($common) functions via IPC. */\r\n public static appFunctionIpc = IpcApp.makeIpcProxy<IpcAppFunctions>(IpcAppChannel.Functions);\r\n\r\n /** start an IpcApp.\r\n * @note this should not be called directly. It is called by NativeApp.startup */\r\n public static async startup(ipc: IpcSocketFrontend, opts?: IpcAppOptions) {\r\n this._ipc = ipc;\r\n IpcAppNotifyHandler.register(); // receives notifications from backend\r\n await IModelApp.startup(opts?.iModelApp);\r\n }\r\n\r\n /** @internal */\r\n public static async shutdown() {\r\n this._ipc = undefined;\r\n await IModelApp.shutdown();\r\n }\r\n}\r\n\r\n/**\r\n * Base class for all implementations of an Ipc notification response interface. This class is implemented on your frontend to supply\r\n * methods to receive notifications from your backend.\r\n *\r\n * Create a subclass to implement your Ipc response interface. Your class should be declared like this:\r\n * ```ts\r\n * class MyNotificationHandler extends NotificationHandler implements MyNotifications\r\n * ```\r\n * to ensure all method names and signatures are correct. Your methods cannot have a return value.\r\n *\r\n * Then, call `MyNotificationHandler.register` at startup to connect your class to your channel.\r\n * @public\r\n * @extensions\r\n */\r\nexport abstract class NotificationHandler {\r\n /** All subclasses must implement this method to specify their response channel name. */\r\n public abstract get channelName(): string;\r\n\r\n public registerImpl(): RemoveFunction {\r\n return IpcApp.addListener(this.channelName, (_evt: Event, funcName: string, ...args: any[]) => {\r\n const func = (this as any)[funcName];\r\n if (typeof func !== \"function\")\r\n throw new IModelError(IModelStatus.FunctionNotFound, `Method \"${this.constructor.name}.${funcName}\" not found on NotificationHandler registered for channel: ${this.channelName}`);\r\n\r\n func.call(this, ...args);\r\n });\r\n }\r\n\r\n /**\r\n * Register this class as the handler for notifications on its channel. This static method creates a new instance\r\n * that becomes the notification handler and is `this` when its methods are called.\r\n * @returns A function that can be called to remove the handler.\r\n * @note this method should only be called once per channel. If it is called multiple times, multiple handlers are established.\r\n */\r\n public static register(): RemoveFunction {\r\n return (new (this as any)() as NotificationHandler).registerImpl(); // create an instance of subclass. \"as any\" is necessary because base class is abstract\r\n }\r\n}\r\n\r\n/** IpcApp notifications from backend */\r\nclass IpcAppNotifyHandler extends NotificationHandler implements IpcAppNotifications {\r\n public get channelName() { return IpcAppChannel.AppNotify; }\r\n public notifyApp() { }\r\n}\r\n"]}
@@ -185,7 +185,7 @@ export declare class System extends RenderSystem implements RenderSystemDebugCon
185
185
  /** Bind the specified texture to the specified unit. This *always* makes the texture *active* */
186
186
  activateTextureCubeMap(unit: TextureUnit, texture: TextureBinding): void;
187
187
  ensureSamplerBound(uniform: UniformHandle, unit: TextureUnit): void;
188
- get maxRealityImageryLayers(): 6 | 3;
188
+ get maxRealityImageryLayers(): 3 | 6;
189
189
  disposeTexture(texture: WebGLTexture): void;
190
190
  enableVertexAttribArray(id: number, instanced: boolean): void;
191
191
  updateVertexAttribArrays(): void;
@@ -259,7 +259,7 @@ class RealityTileTree extends internal_1.TileTree {
259
259
  }
260
260
  /** @internal */
261
261
  doReprojectChildren(tile) {
262
- if (!(tile instanceof internal_1.RealityTile) || !tile.region || this._gcsConverter === undefined || this._rootToEcef === undefined || undefined === this._ecefToDb)
262
+ if (!(tile instanceof internal_1.RealityTile) || this._gcsConverter === undefined || this._rootToEcef === undefined || undefined === this._ecefToDb)
263
263
  return false;
264
264
  const tileRange = this.iModelTransform.isIdentity ? tile.range : this.iModelTransform.multiplyRange(tile.range, scratchRange);
265
265
  return this.cartesianRange.intersectsRange(tileRange);
@@ -1 +1 @@
1
- {"version":3,"file":"RealityTileTree.js","sourceRoot":"","sources":["../../../src/tile/RealityTileTree.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA0D;AAC1D,wDAE8B;AAC9B,oDAAuH;AACvH,oEAAiE;AAEjE,4CAAyC;AACzC,2DAAwD;AAGxD,yCAGoB;AAEpB,gBAAgB;AAChB,MAAa,gBAAgB;IAA7B;QACS,mBAAc,GAAG,IAAI,KAAK,EAAQ,CAAC;QACnC,oBAAe,GAAG,KAAK,CAAC;QACxB,qBAAgB,GAAG,KAAK,CAAC;IAOlC,CAAC;IALQ,UAAU;QACf,IAAI,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC;QAC/B,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC;QAC7B,IAAI,CAAC,gBAAgB,GAAG,KAAK,CAAC;IAChC,CAAC;CACF;AAVD,4CAUC;AACD,gBAAgB;AAChB,MAAa,wBAAwB;IAArC;QACU,kBAAa,GAAuB,EAAE,CAAC;IAwBjD,CAAC;IAtBQ,UAAU;QACf,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,aAAa;YACpC,KAAK,CAAC,UAAU,EAAE,CAAC;IACvB,CAAC;IACM,cAAc,CAAC,KAAa;QACjC,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM,IAAI,KAAK;YACvC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,gBAAgB,EAAE,CAAC,CAAC;QAElD,OAAO,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC;IAEM,OAAO,CAAC,aAA+B;QAC5C,aAAa,CAAC,cAAc,C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AAC,CAAC;IAC/D,CAAC;IAED,gBAAgB;IACN,QAAQ,CAAC,KAAa,EAAE,KAA6B;QAC7D,IAAI,WAAW,GAAG,EAAE,CAAC;QACrB,IAAI,GAAG,GAAG,KAAK,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC;QAC9B,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAkB,CAAC;QAC3C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;YACxB,KAAK,EAAE,CAAC;YACR,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;YACzB,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;YAChC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;YAChC,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YAClC,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;SAC1D;QAED,QAAQ,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,WAAW,IAAI,GAAG,GAAG,IAAI,KAAK,IAAI,CAAC,CAAC;QACrE,sCAAsC;QACtC,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,KAAK,KAAK,SAAS,GAAG,SAAS,GAAG,YAAY,WAAW,EAAE,CAAC,CAAC;IACnF,CAAC;CACF;AArWD,0CAqWC","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, BeTimePoint } from \"@itwin/core-bentley\";\r\nimport {\r\n Matrix3d, Point3d, Range3d, Transform, Vector3d, XYZProps,\r\n} from \"@itwin/core-geometry\";\r\nimport { Cartographic, ColorDef, Frustum, FrustumPlanes, GeoCoordStatus, ViewFlagOverrides } from \"@itwin/core-common\";\r\nimport { BackgroundMapGeometry } from \"../BackgroundMapGeometry\";\r\nimport { GeoConverter } from \"../GeoServices\";\r\nimport { IModelApp } from \"../IModelApp\";\r\nimport { GraphicBranch } from \"../render/GraphicBranch\";\r\nimport { GraphicBuilder } from \"../render/GraphicBuilder\";\r\nimport { SceneContext } from \"../ViewContext\";\r\nimport {\r\n GraphicsCollectorDrawArgs, MapTile, RealityTile, RealityTileDrawArgs, RealityTileLoader, RealityTileParams, Tile, TileDrawArgs, TileGeometryCollector,\r\n TileGraphicType, TileParams, TileTree, TileTreeParams,\r\n} from \"./internal\";\r\n\r\n/** @internal */\r\nexport class TraversalDetails {\r\n public queuedChildren = new Array<Tile>();\r\n public childrenLoading = false;\r\n public childrenSelected = false;\r\n\r\n public initialize() {\r\n this.queuedChildren.length = 0;\r\n this.childrenLoading = false;\r\n this.childrenSelected = false;\r\n }\r\n}\r\n/** @internal */\r\nexport class TraversalChildrenDetails {\r\n private _childDetails: TraversalDetails[] = [];\r\n\r\n public initialize() {\r\n for (const child of this._childDetails)\r\n child.initialize();\r\n }\r\n public getChildDetail(index: number) {\r\n while (this._childDetails.length <= index)\r\n this._childDetails.push(new TraversalDetails());\r\n\r\n return this._childDetails[index];\r\n }\r\n\r\n public combine(parentDetails: TraversalDetails) {\r\n parentDetails.queuedChildren.length = 0;\r\n parentDetails.childrenLoading = false;\r\n parentDetails.childrenSelected = false;\r\n for (const child of this._childDetails) {\r\n parentDetails.childrenLoading = parentDetails.childrenLoading || child.childrenLoading;\r\n parentDetails.childrenSelected = parentDetails.childrenSelected || child.childrenSelected;\r\n for (const queuedChild of child.queuedChildren)\r\n parentDetails.queuedChildren.push(queuedChild);\r\n }\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport class TraversalSelectionContext {\r\n public preloaded = new Set<RealityTile>();\r\n public missing = new Array<RealityTile>();\r\n public get selectionCountExceeded() { return this._maxSelectionCount === undefined ? false : (this.missing.length + this.selected.length) > this._maxSelectionCount; } // Avoid selecting excessive number of tiles.\r\n constructor(public selected: Tile[], public displayedDescendants: Tile[][], public preloadDebugBuilder?: GraphicBuilder, private _maxSelectionCount?: number) { }\r\n\r\n public selectOrQueue(tile: RealityTile, args: TileDrawArgs, traversalDetails: TraversalDetails) {\r\n tile.selectSecondaryTiles(args, this);\r\n tile.markUsed(args);\r\n if (tile.isReady) {\r\n args.markReady(tile);\r\n this.selected.push(tile);\r\n tile.markDisplayed();\r\n this.displayedDescendants.push((traversalDetails.childrenSelected) ? traversalDetails.queuedChildren.slice() : []);\r\n traversalDetails.queuedChildren.length = 0;\r\n traversalDetails.childrenLoading = false;\r\n traversalDetails.childrenSelected = true;\r\n } else if (!tile.isNotFound) {\r\n traversalDetails.queuedChildren.push(tile);\r\n if (!tile.isLoaded)\r\n this.missing.push(tile);\r\n }\r\n }\r\n\r\n public preload(tile: RealityTile, args: TileDrawArgs): void {\r\n if (!this.preloaded.has(tile)) {\r\n if (this.preloadDebugBuilder)\r\n tile.addBoundingGraphic(this.preloadDebugBuilder, ColorDef.red);\r\n\r\n tile.markUsed(args);\r\n tile.selectSecondaryTiles(args, this);\r\n this.preloaded.add(tile);\r\n if (!tile.isNotFound && !tile.isLoaded)\r\n this.missing.push(tile);\r\n }\r\n }\r\n\r\n public select(tiles: RealityTile[], args: TileDrawArgs): void {\r\n for (const tile of tiles) {\r\n tile.markUsed(args);\r\n this.selected.push(tile);\r\n this.displayedDescendants.push([]);\r\n }\r\n }\r\n}\r\n\r\nconst scratchFrustum = new Frustum();\r\nconst scratchFrustumPlanes = new FrustumPlanes();\r\nconst scratchCarto = Cartographic.createZero();\r\nconst scratchPoint = Point3d.createZero(), scratchOrigin = Point3d.createZero();\r\nconst scratchRange = Range3d.createNull();\r\nconst scratchX = Vector3d.createZero(), scratchY = Vector3d.createZero(), scratchZ = Vector3d.createZero();\r\nconst scratchMatrix = Matrix3d.createZero(), scratchTransform = Transform.createZero();\r\n\r\ninterface ChildReprojection {\r\n child: RealityTile;\r\n ecefCenter: Point3d;\r\n dbPoints: Point3d[]; // Center, xEnd, yEnd, zEnd\r\n}\r\n\r\n/** @internal */\r\nexport interface RealityTileTreeParams extends TileTreeParams {\r\n readonly loader: RealityTileLoader;\r\n readonly yAxisUp?: boolean;\r\n readonly rootTile: RealityTileParams;\r\n readonly rootToEcef?: Transform;\r\n readonly gcsConverterAvailable: boolean;\r\n}\r\n\r\n/** Base class for a [[TileTree]] representing a reality model (e.g., a point cloud or photogrammetry mesh) or 3d terrain with map imagery.\r\n * The tiles within the tree are instances of [[RealityTile]]s.\r\n * @beta\r\n */\r\nexport class RealityTileTree extends TileTree {\r\n /** @internal */\r\n public traversalChildrenByDepth: TraversalChildrenDetails[] = [];\r\n /** @internal */\r\n public readonly loader: RealityTileLoader;\r\n /** @internal */\r\n public readonly yAxisUp: boolean;\r\n /** @internal */\r\n public cartesianRange: Range3d;\r\n /** @internal */\r\n public cartesianTransitionDistance: number;\r\n /** @internal */\r\n protected _gcsConverter: GeoConverter | undefined;\r\n /** @internal */\r\n protected _rootTile: RealityTile;\r\n /** @internal */\r\n protected _rootToEcef?: Transform;\r\n /** @internal */\r\n protected _ecefToDb?: Transform;\r\n\r\n /** @internal */\r\n public constructor(params: RealityTileTreeParams) {\r\n super(params);\r\n this.loader = params.loader;\r\n this.yAxisUp = true === params.yAxisUp;\r\n this._rootTile = this.createTile(params.rootTile);\r\n this.cartesianRange = BackgroundMapGeometry.getCartesianRange(this.iModel);\r\n this.cartesianTransitionDistance = this.cartesianRange.diagonal().magnitudeXY() * .25; // Transition distance from elliptical to cartesian.\r\n this._gcsConverter = params.gcsConverterAvailable ? params.iModel.geoServices.getConverter(\"WGS84\") : undefined;\r\n if (params.rootToEcef) {\r\n this._rootToEcef = params.rootToEcef;\r\n const dbToRoot = this.iModelTransform.inverse();\r\n if (dbToRoot) {\r\n const dbToEcef = this._rootToEcef.multiplyTransformTransform(dbToRoot);\r\n this._ecefToDb = dbToEcef.inverse();\r\n }\r\n }\r\n }\r\n\r\n /** @internal */\r\n public get rootTile(): RealityTile { return this._rootTile; }\r\n /** @internal */\r\n public get is3d() { return true; }\r\n /** @internal */\r\n public get maxDepth() { return this.loader.maxDepth; }\r\n /** @internal */\r\n public get minDepth() { return this.loader.minDepth; }\r\n /** @internal */\r\n public override get isContentUnbounded() { return this.loader.isContentUnbounded; }\r\n /** @internal */\r\n public get isTransparent() { return false; }\r\n\r\n /** @internal */\r\n protected _selectTiles(args: TileDrawArgs): Tile[] { return this.selectRealityTiles(args, []); }\r\n /** @internal */\r\n public get viewFlagOverrides(): ViewFlagOverrides { return this.loader.viewFlagOverrides; }\r\n /** @internal */\r\n public override get parentsAndChildrenExclusive() { return this.loader.parentsAndChildrenExclusive; }\r\n\r\n /** @internal */\r\n public createTile(props: TileParams): RealityTile { return new RealityTile(props, this); }\r\n\r\n /** Collect tiles from this tile tree based on the criteria implemented by `collector`.\r\n * @internal\r\n */\r\n public override collectTileGeometry(collector: TileGeometryCollector): void {\r\n this.rootTile.collectTileGeometry(collector);\r\n }\r\n\r\n /** @internal */\r\n public prune(): void {\r\n const olderThan = BeTimePoint.now().minus(this.expirationTime);\r\n this.rootTile.purgeContents(olderThan);\r\n }\r\n\r\n /** @internal */\r\n public draw(args: TileDrawArgs): void {\r\n const displayedTileDescendants = new Array<RealityTile[]>();\r\n const debugControl = args.context.target.debugControl;\r\n const selectBuilder = (debugControl && debugControl.displayRealityTileRanges) ? args.context.createSceneGraphicBuilder() : undefined;\r\n const preloadDebugBuilder = (debugControl && debugControl.displayRealityTilePreload) ? args.context.createSceneGraphicBuilder() : undefined;\r\n const graphicTypeBranches = new Map<TileGraphicType, GraphicBranch>();\r\n\r\n const selectedTiles = this.selectRealityTiles(args, displayedTileDescendants, preloadDebugBuilder);\r\n args.processSelectedTiles(selectedTiles);\r\n let sortIndices;\r\n\r\n if (!this.parentsAndChildrenExclusive) {\r\n sortIndices = selectedTiles.map((_x, i) => i);\r\n sortIndices.sort((a, b) => selectedTiles[a].depth - selectedTiles[b].depth);\r\n }\r\n\r\n if (! (args instanceof GraphicsCollectorDrawArgs))\r\n this.collectClassifierGraphics(args, selectedTiles);\r\n\r\n assert(selectedTiles.length === displayedTileDescendants.length);\r\n for (let i = 0; i < selectedTiles.length; i++) {\r\n const index = sortIndices ? sortIndices[i] : i;\r\n const selectedTile = selectedTiles[index];\r\n const graphics = args.getTileGraphics(selectedTile);\r\n const tileGraphicType = selectedTile.graphicType;\r\n let targetBranch;\r\n if (undefined !== tileGraphicType && tileGraphicType !== args.context.graphicType) {\r\n if (!(targetBranch = graphicTypeBranches.get(tileGraphicType))) {\r\n graphicTypeBranches.set(tileGraphicType, targetBranch = new GraphicBranch(false));\r\n targetBranch.setViewFlagOverrides(args.graphics.viewFlagOverrides);\r\n targetBranch.symbologyOverrides = args.graphics.symbologyOverrides;\r\n }\r\n }\r\n\r\n if (!targetBranch)\r\n targetBranch = args.graphics;\r\n\r\n if (undefined !== graphics) {\r\n const displayedDescendants = displayedTileDescendants[index];\r\n if (0 === displayedDescendants.length || !this.loader.parentsAndChildrenExclusive || selectedTile.allChildrenIncluded(displayedDescendants)) {\r\n targetBranch.add(graphics);\r\n if (selectBuilder)\r\n selectedTile.addBoundingGraphic(selectBuilder, ColorDef.green);\r\n } else {\r\n if (selectBuilder)\r\n selectedTile.addBoundingGraphic(selectBuilder, ColorDef.red);\r\n\r\n for (const displayedDescendant of displayedDescendants) {\r\n const clipVector = displayedDescendant.getContentClip();\r\n if (selectBuilder)\r\n displayedDescendant.addBoundingGraphic(selectBuilder, ColorDef.blue);\r\n\r\n if (undefined === clipVector) {\r\n targetBranch.add(graphics);\r\n } else {\r\n clipVector.transformInPlace(args.location);\r\n if (!this.isTransparent)\r\n for (const primitive of clipVector.clips)\r\n for (const clipPlanes of primitive.fetchClipPlanesRef()!.convexSets)\r\n for (const plane of clipPlanes.planes)\r\n plane.offsetDistance(-displayedDescendant.radius * .05); // Overlap with existing (high resolution) tile slightly to avoid cracks.\r\n\r\n const branch = new GraphicBranch(false);\r\n branch.add(graphics);\r\n const clipVolume = args.context.target.renderSystem.createClipVolume(clipVector);\r\n targetBranch.add(args.context.createGraphicBranch(branch, Transform.createIdentity(), { clipVolume }));\r\n }\r\n }\r\n }\r\n if (preloadDebugBuilder)\r\n targetBranch.add(preloadDebugBuilder.finish());\r\n\r\n if (selectBuilder)\r\n targetBranch.add(selectBuilder.finish());\r\n\r\n const rangeGraphic = selectedTile.getRangeGraphic(args.context);\r\n if (undefined !== rangeGraphic)\r\n targetBranch.add(rangeGraphic);\r\n }\r\n }\r\n\r\n args.drawGraphics();\r\n for (const graphicTypeBranch of graphicTypeBranches) {\r\n args.drawGraphicsWithType(graphicTypeBranch[0], graphicTypeBranch[1]);\r\n }\r\n }\r\n\r\n /** @internal */\r\n protected collectClassifierGraphics(args: TileDrawArgs, selectedTiles: RealityTile[]) {\r\n const classifier = args.context.planarClassifiers.get(this.modelId);\r\n if (classifier)\r\n classifier.collectGraphics(args.context, { modelId: this.modelId, tiles: selectedTiles, location: args.location, isPointCloud: this.isPointCloud });\r\n }\r\n\r\n /** @internal */\r\n public getTraversalChildren(depth: number) {\r\n while (this.traversalChildrenByDepth.length <= depth)\r\n this.traversalChildrenByDepth.push(new TraversalChildrenDetails());\r\n\r\n return this.traversalChildrenByDepth[depth];\r\n }\r\n\r\n /** @internal */\r\n public doReprojectChildren(tile: Tile): boolean {\r\n if (!(tile instanceof RealityTile) || !tile.region || this._gcsConverter === undefined || this._rootToEcef === undefined || undefined === this._ecefToDb)\r\n return false;\r\n\r\n const tileRange = this.iModelTransform.isIdentity ? tile.range : this.iModelTransform.multiplyRange(tile.range, scratchRange);\r\n\r\n return this.cartesianRange.intersectsRange(tileRange);\r\n }\r\n\r\n /** @internal */\r\n public reprojectAndResolveChildren(parent: Tile, children: Tile[], resolve: (children: Tile[] | undefined) => void): void {\r\n if (!this.doReprojectChildren(parent)) {\r\n resolve(children);\r\n return;\r\n }\r\n\r\n const ecefToDb = this._ecefToDb!; // Tested for undefined in doReprojectChildren\r\n const rootToDb = this.iModelTransform;\r\n const dbToEcef = ecefToDb.inverse()!;\r\n const reprojectChildren = new Array<ChildReprojection>();\r\n for (const child of children) {\r\n const realityChild = child as RealityTile;\r\n const childRange = realityChild.rangeCorners ? Range3d.createTransformedArray(rootToDb, realityChild.rangeCorners) : rootToDb.multiplyRange(realityChild.contentRange, scratchRange);\r\n const dbCenter = childRange.center;\r\n const ecefCenter = dbToEcef.multiplyPoint3d(dbCenter);\r\n const dbPoints = [dbCenter, dbCenter.plusXYZ(1), dbCenter.plusXYZ(0, 1), dbCenter.plusXYZ(0, 0, 1)];\r\n reprojectChildren.push({ child: realityChild, ecefCenter, dbPoints });\r\n }\r\n if (reprojectChildren.length === 0)\r\n resolve(children);\r\n else {\r\n const requestProps = new Array<XYZProps>();\r\n\r\n for (const reprojection of reprojectChildren) {\r\n for (const dbPoint of reprojection.dbPoints) {\r\n const ecefPoint = dbToEcef.multiplyPoint3d(dbPoint);\r\n const carto = Cartographic.fromEcef(ecefPoint, scratchCarto);\r\n if (carto)\r\n requestProps.push({ x: carto.longitudeDegrees, y: carto.latitudeDegrees, z: carto.height });\r\n\r\n }\r\n }\r\n\r\n if (requestProps.length !== 4 * reprojectChildren.length)\r\n resolve(children);\r\n else {\r\n this._gcsConverter!.getIModelCoordinatesFromGeoCoordinates(requestProps).then((response) => {\r\n\r\n const reprojectedCoords = response.iModelCoords;\r\n const dbToRoot = rootToDb.inverse()!;\r\n const getReprojectedPoint = (original: Point3d, reprojectedXYZ: XYZProps) => {\r\n scratchPoint.setFromJSON(reprojectedXYZ);\r\n const cartesianDistance = this.cartesianRange.distanceToPoint(scratchPoint);\r\n if (cartesianDistance < this.cartesianTransitionDistance)\r\n return scratchPoint.interpolate(cartesianDistance / this.cartesianTransitionDistance, original, scratchPoint);\r\n else\r\n return original;\r\n };\r\n\r\n let responseIndex = 0;\r\n for (const reprojection of reprojectChildren) {\r\n if (reprojectedCoords.every((coord) => coord.s === GeoCoordStatus.Success)) {\r\n const reprojectedOrigin = getReprojectedPoint(reprojection.dbPoints[0], reprojectedCoords[responseIndex++].p).clone(scratchOrigin);\r\n const xVector = Vector3d.createStartEnd(reprojectedOrigin, getReprojectedPoint(reprojection.dbPoints[1], reprojectedCoords[responseIndex++].p), scratchX);\r\n const yVector = Vector3d.createStartEnd(reprojectedOrigin, getReprojectedPoint(reprojection.dbPoints[2], reprojectedCoords[responseIndex++].p), scratchY);\r\n const zVector = Vector3d.createStartEnd(reprojectedOrigin, getReprojectedPoint(reprojection.dbPoints[3], reprojectedCoords[responseIndex++].p), scratchZ);\r\n const matrix = Matrix3d.createColumns(xVector, yVector, zVector, scratchMatrix);\r\n if (matrix !== undefined) {\r\n const dbReprojection = Transform.createMatrixPickupPutdown(matrix, reprojection.dbPoints[0], reprojectedOrigin, scratchTransform);\r\n if (dbReprojection) {\r\n const rootReprojection = dbToRoot.multiplyTransformTransform(dbReprojection).multiplyTransformTransform(rootToDb);\r\n reprojection.child.reproject(rootReprojection);\r\n }\r\n }\r\n }\r\n }\r\n\r\n resolve(children);\r\n }).catch(() => {\r\n resolve(children); // Error occured in reprojection - just resolve with unprojected corners.\r\n });\r\n }\r\n }\r\n }\r\n\r\n /** @internal */\r\n public getBaseRealityDepth(_sceneContext: SceneContext) { return -1; }\r\n\r\n /** @internal */\r\n public selectRealityTiles(args: TileDrawArgs, displayedDescendants: RealityTile[][], preloadDebugBuilder?: GraphicBuilder): RealityTile[] {\r\n this._lastSelected = BeTimePoint.now();\r\n const selected: RealityTile[] = [];\r\n const context = new TraversalSelectionContext(selected, displayedDescendants, preloadDebugBuilder, args.maxRealityTreeSelectionCount);\r\n const rootTile = this.rootTile;\r\n const debugControl = args.context.target.debugControl;\r\n const freezeTiles = debugControl && debugControl.freezeRealityTiles;\r\n\r\n rootTile.selectRealityTiles(context, args, new TraversalDetails());\r\n\r\n const baseDepth = this.getBaseRealityDepth(args.context);\r\n\r\n if (!args.context.target.renderSystem.isMobile && 0 === context.missing.length) { // We skip preloading on mobile devices.\r\n if (baseDepth > 0) // Maps may force loading of low level globe tiles.\r\n rootTile.preloadRealityTilesAtDepth(baseDepth, context, args);\r\n\r\n if (!freezeTiles)\r\n this.preloadTilesForScene(args, context, undefined);\r\n }\r\n\r\n if (!freezeTiles)\r\n for (const tile of context.missing) {\r\n const loadableTile = tile.loadableTile;\r\n\r\n loadableTile.markUsed(args);\r\n args.insertMissing(loadableTile);\r\n }\r\n\r\n if (debugControl && debugControl.logRealityTiles) {\r\n this.logTiles(\"Selected: \", selected.values());\r\n const preloaded = [];\r\n for (const tile of context.preloaded)\r\n preloaded.push(tile);\r\n\r\n this.logTiles(\"Preloaded: \", preloaded.values());\r\n this.logTiles(\"Missing: \", context.missing.values());\r\n\r\n const imageryTiles: RealityTile[] = [];\r\n for (const selectedTile of selected) {\r\n if (selectedTile instanceof MapTile) {\r\n const selectedImageryTiles = (selectedTile).imageryTiles;\r\n if (selectedImageryTiles)\r\n selectedImageryTiles.forEach((tile) => imageryTiles.push(tile));\r\n }\r\n }\r\n if (imageryTiles.length)\r\n this.logTiles(\"Imagery:\", imageryTiles.values());\r\n }\r\n\r\n IModelApp.tileAdmin.addTilesForUser(args.context.viewport, selected, args.readyTiles);\r\n return selected;\r\n }\r\n\r\n /** @internal */\r\n public preloadTilesForScene(args: TileDrawArgs, context: TraversalSelectionContext, frustumTransform?: Transform) {\r\n const preloadFrustum = args.viewingSpace.getPreloadFrustum(frustumTransform, scratchFrustum);\r\n const preloadFrustumPlanes = new FrustumPlanes(preloadFrustum);\r\n const worldToNpc = preloadFrustum.toMap4d();\r\n const preloadWorldToViewMap = args.viewingSpace.calcNpcToView().multiplyMapMap(worldToNpc!);\r\n const preloadArgs = new RealityTileDrawArgs(args, preloadWorldToViewMap, preloadFrustumPlanes);\r\n\r\n scratchFrustumPlanes.init(preloadFrustum);\r\n if (context.preloadDebugBuilder) {\r\n context.preloadDebugBuilder.setSymbology(ColorDef.blue, ColorDef.blue, 2, 0);\r\n context.preloadDebugBuilder.addFrustum(preloadFrustum);\r\n }\r\n\r\n this.rootTile.preloadTilesInFrustum(preloadArgs, context, 2);\r\n }\r\n\r\n /** @internal */\r\n protected logTiles(label: string, tiles: IterableIterator<Tile>) {\r\n let depthString = \"\";\r\n let min = 10000, max = -10000;\r\n let count = 0;\r\n const depthMap = new Map<number, number>();\r\n for (const tile of tiles) {\r\n count++;\r\n const depth = tile.depth;\r\n min = Math.min(min, tile.depth);\r\n max = Math.max(max, tile.depth);\r\n const found = depthMap.get(depth);\r\n depthMap.set(depth, found === undefined ? 1 : found + 1);\r\n }\r\n\r\n depthMap.forEach((key, value) => depthString += `${key}-${value}, `);\r\n // eslint-disable-next-line no-console\r\n console.log(`${label}: ${count} Min: ${min} Max: ${max} Depths: ${depthString}`);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"RealityTileTree.js","sourceRoot":"","sources":["../../../src/tile/RealityTileTree.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA0D;AAC1D,wDAE8B;AAC9B,oDAAuH;AACvH,oEAAiE;AAEjE,4CAAyC;AACzC,2DAAwD;AAGxD,yCAGoB;AAEpB,gBAAgB;AAChB,MAAa,gBAAgB;IAA7B;QACS,mBAAc,GAAG,IAAI,KAAK,EAAQ,CAAC;QACnC,oBAAe,GAAG,KAAK,CAAC;QACxB,qBAAgB,GAAG,KAAK,CAAC;IAOlC,CAAC;IALQ,UAAU;QACf,IAAI,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC;QAC/B,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC;QAC7B,IAAI,CAAC,gBAAgB,GAAG,KAAK,CAAC;IAChC,CAAC;CACF;AAVD,4CAUC;AACD,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KAAK,EAAE,EAAE,CAAC,WAAW,IAAI,GAAG,GAAG,IAAI,KAAK,IAAI,CAAC,CAAC;QACrE,sCAAsC;QACtC,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,KAAK,KAAK,SAAS,GAAG,SAAS,GAAG,YAAY,WAAW,EAAE,CAAC,CAAC;IACnF,CAAC;CACF;AArWD,0CAqWC","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, BeTimePoint } from \"@itwin/core-bentley\";\r\nimport {\r\n Matrix3d, Point3d, Range3d, Transform, Vector3d, XYZProps,\r\n} from \"@itwin/core-geometry\";\r\nimport { Cartographic, ColorDef, Frustum, FrustumPlanes, GeoCoordStatus, ViewFlagOverrides } from \"@itwin/core-common\";\r\nimport { BackgroundMapGeometry } from \"../BackgroundMapGeometry\";\r\nimport { GeoConverter } from \"../GeoServices\";\r\nimport { IModelApp } from \"../IModelApp\";\r\nimport { GraphicBranch } from \"../render/GraphicBranch\";\r\nimport { GraphicBuilder } from \"../render/GraphicBuilder\";\r\nimport { SceneContext } from \"../ViewContext\";\r\nimport {\r\n GraphicsCollectorDrawArgs, MapTile, RealityTile, RealityTileDrawArgs, RealityTileLoader, RealityTileParams, Tile, TileDrawArgs, TileGeometryCollector,\r\n TileGraphicType, TileParams, TileTree, TileTreeParams,\r\n} from \"./internal\";\r\n\r\n/** @internal */\r\nexport class TraversalDetails {\r\n public queuedChildren = new Array<Tile>();\r\n public childrenLoading = false;\r\n public childrenSelected = false;\r\n\r\n public initialize() {\r\n this.queuedChildren.length = 0;\r\n this.childrenLoading = false;\r\n this.childrenSelected = false;\r\n }\r\n}\r\n/** @internal */\r\nexport class TraversalChildrenDetails {\r\n private _childDetails: TraversalDetails[] = [];\r\n\r\n public initialize() {\r\n for (const child of this._childDetails)\r\n child.initialize();\r\n }\r\n public getChildDetail(index: number) {\r\n while (this._childDetails.length <= index)\r\n this._childDetails.push(new TraversalDetails());\r\n\r\n return this._childDetails[index];\r\n }\r\n\r\n public combine(parentDetails: TraversalDetails) {\r\n parentDetails.queuedChildren.length = 0;\r\n parentDetails.childrenLoading = false;\r\n parentDetails.childrenSelected = false;\r\n for (const child of this._childDetails) {\r\n parentDetails.childrenLoading = parentDetails.childrenLoading || child.childrenLoading;\r\n parentDetails.childrenSelected = parentDetails.childrenSelected || child.childrenSelected;\r\n for (const queuedChild of child.queuedChildren)\r\n parentDetails.queuedChildren.push(queuedChild);\r\n }\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport class TraversalSelectionContext {\r\n public preloaded = new Set<RealityTile>();\r\n public missing = new Array<RealityTile>();\r\n public get selectionCountExceeded() { return this._maxSelectionCount === undefined ? false : (this.missing.length + this.selected.length) > this._maxSelectionCount; } // Avoid selecting excessive number of tiles.\r\n constructor(public selected: Tile[], public displayedDescendants: Tile[][], public preloadDebugBuilder?: GraphicBuilder, private _maxSelectionCount?: number) { }\r\n\r\n public selectOrQueue(tile: RealityTile, args: TileDrawArgs, traversalDetails: TraversalDetails) {\r\n tile.selectSecondaryTiles(args, this);\r\n tile.markUsed(args);\r\n if (tile.isReady) {\r\n args.markReady(tile);\r\n this.selected.push(tile);\r\n tile.markDisplayed();\r\n this.displayedDescendants.push((traversalDetails.childrenSelected) ? traversalDetails.queuedChildren.slice() : []);\r\n traversalDetails.queuedChildren.length = 0;\r\n traversalDetails.childrenLoading = false;\r\n traversalDetails.childrenSelected = true;\r\n } else if (!tile.isNotFound) {\r\n traversalDetails.queuedChildren.push(tile);\r\n if (!tile.isLoaded)\r\n this.missing.push(tile);\r\n }\r\n }\r\n\r\n public preload(tile: RealityTile, args: TileDrawArgs): void {\r\n if (!this.preloaded.has(tile)) {\r\n if (this.preloadDebugBuilder)\r\n tile.addBoundingGraphic(this.preloadDebugBuilder, ColorDef.red);\r\n\r\n tile.markUsed(args);\r\n tile.selectSecondaryTiles(args, this);\r\n this.preloaded.add(tile);\r\n if (!tile.isNotFound && !tile.isLoaded)\r\n this.missing.push(tile);\r\n }\r\n }\r\n\r\n public select(tiles: RealityTile[], args: TileDrawArgs): void {\r\n for (const tile of tiles) {\r\n tile.markUsed(args);\r\n this.selected.push(tile);\r\n this.displayedDescendants.push([]);\r\n }\r\n }\r\n}\r\n\r\nconst scratchFrustum = new Frustum();\r\nconst scratchFrustumPlanes = new FrustumPlanes();\r\nconst scratchCarto = Cartographic.createZero();\r\nconst scratchPoint = Point3d.createZero(), scratchOrigin = Point3d.createZero();\r\nconst scratchRange = Range3d.createNull();\r\nconst scratchX = Vector3d.createZero(), scratchY = Vector3d.createZero(), scratchZ = Vector3d.createZero();\r\nconst scratchMatrix = Matrix3d.createZero(), scratchTransform = Transform.createZero();\r\n\r\ninterface ChildReprojection {\r\n child: RealityTile;\r\n ecefCenter: Point3d;\r\n dbPoints: Point3d[]; // Center, xEnd, yEnd, zEnd\r\n}\r\n\r\n/** @internal */\r\nexport interface RealityTileTreeParams extends TileTreeParams {\r\n readonly loader: RealityTileLoader;\r\n readonly yAxisUp?: boolean;\r\n readonly rootTile: RealityTileParams;\r\n readonly rootToEcef?: Transform;\r\n readonly gcsConverterAvailable: boolean;\r\n}\r\n\r\n/** Base class for a [[TileTree]] representing a reality model (e.g., a point cloud or photogrammetry mesh) or 3d terrain with map imagery.\r\n * The tiles within the tree are instances of [[RealityTile]]s.\r\n * @beta\r\n */\r\nexport class RealityTileTree extends TileTree {\r\n /** @internal */\r\n public traversalChildrenByDepth: TraversalChildrenDetails[] = [];\r\n /** @internal */\r\n public readonly loader: RealityTileLoader;\r\n /** @internal */\r\n public readonly yAxisUp: boolean;\r\n /** @internal */\r\n public cartesianRange: Range3d;\r\n /** @internal */\r\n public cartesianTransitionDistance: number;\r\n /** @internal */\r\n protected _gcsConverter: GeoConverter | undefined;\r\n /** @internal */\r\n protected _rootTile: RealityTile;\r\n /** @internal */\r\n protected _rootToEcef?: Transform;\r\n /** @internal */\r\n protected _ecefToDb?: Transform;\r\n\r\n /** @internal */\r\n public constructor(params: RealityTileTreeParams) {\r\n super(params);\r\n this.loader = params.loader;\r\n this.yAxisUp = true === params.yAxisUp;\r\n this._rootTile = this.createTile(params.rootTile);\r\n this.cartesianRange = BackgroundMapGeometry.getCartesianRange(this.iModel);\r\n this.cartesianTransitionDistance = this.cartesianRange.diagonal().magnitudeXY() * .25; // Transition distance from elliptical to cartesian.\r\n this._gcsConverter = params.gcsConverterAvailable ? params.iModel.geoServices.getConverter(\"WGS84\") : undefined;\r\n if (params.rootToEcef) {\r\n this._rootToEcef = params.rootToEcef;\r\n const dbToRoot = this.iModelTransform.inverse();\r\n if (dbToRoot) {\r\n const dbToEcef = this._rootToEcef.multiplyTransformTransform(dbToRoot);\r\n this._ecefToDb = dbToEcef.inverse();\r\n }\r\n }\r\n }\r\n\r\n /** @internal */\r\n public get rootTile(): RealityTile { return this._rootTile; }\r\n /** @internal */\r\n public get is3d() { return true; }\r\n /** @internal */\r\n public get maxDepth() { return this.loader.maxDepth; }\r\n /** @internal */\r\n public get minDepth() { return this.loader.minDepth; }\r\n /** @internal */\r\n public override get isContentUnbounded() { return this.loader.isContentUnbounded; }\r\n /** @internal */\r\n public get isTransparent() { return false; }\r\n\r\n /** @internal */\r\n protected _selectTiles(args: TileDrawArgs): Tile[] { return this.selectRealityTiles(args, []); }\r\n /** @internal */\r\n public get viewFlagOverrides(): ViewFlagOverrides { return this.loader.viewFlagOverrides; }\r\n /** @internal */\r\n public override get parentsAndChildrenExclusive() { return this.loader.parentsAndChildrenExclusive; }\r\n\r\n /** @internal */\r\n public createTile(props: TileParams): RealityTile { return new RealityTile(props, this); }\r\n\r\n /** Collect tiles from this tile tree based on the criteria implemented by `collector`.\r\n * @internal\r\n */\r\n public override collectTileGeometry(collector: TileGeometryCollector): void {\r\n this.rootTile.collectTileGeometry(collector);\r\n }\r\n\r\n /** @internal */\r\n public prune(): void {\r\n const olderThan = BeTimePoint.now().minus(this.expirationTime);\r\n this.rootTile.purgeContents(olderThan);\r\n }\r\n\r\n /** @internal */\r\n public draw(args: TileDrawArgs): void {\r\n const displayedTileDescendants = new Array<RealityTile[]>();\r\n const debugControl = args.context.target.debugControl;\r\n const selectBuilder = (debugControl && debugControl.displayRealityTileRanges) ? args.context.createSceneGraphicBuilder() : undefined;\r\n const preloadDebugBuilder = (debugControl && debugControl.displayRealityTilePreload) ? args.context.createSceneGraphicBuilder() : undefined;\r\n const graphicTypeBranches = new Map<TileGraphicType, GraphicBranch>();\r\n\r\n const selectedTiles = this.selectRealityTiles(args, displayedTileDescendants, preloadDebugBuilder);\r\n args.processSelectedTiles(selectedTiles);\r\n let sortIndices;\r\n\r\n if (!this.parentsAndChildrenExclusive) {\r\n sortIndices = selectedTiles.map((_x, i) => i);\r\n sortIndices.sort((a, b) => selectedTiles[a].depth - selectedTiles[b].depth);\r\n }\r\n\r\n if (! (args instanceof GraphicsCollectorDrawArgs))\r\n this.collectClassifierGraphics(args, selectedTiles);\r\n\r\n assert(selectedTiles.length === displayedTileDescendants.length);\r\n for (let i = 0; i < selectedTiles.length; i++) {\r\n const index = sortIndices ? sortIndices[i] : i;\r\n const selectedTile = selectedTiles[index];\r\n const graphics = args.getTileGraphics(selectedTile);\r\n const tileGraphicType = selectedTile.graphicType;\r\n let targetBranch;\r\n if (undefined !== tileGraphicType && tileGraphicType !== args.context.graphicType) {\r\n if (!(targetBranch = graphicTypeBranches.get(tileGraphicType))) {\r\n graphicTypeBranches.set(tileGraphicType, targetBranch = new GraphicBranch(false));\r\n targetBranch.setViewFlagOverrides(args.graphics.viewFlagOverrides);\r\n targetBranch.symbologyOverrides = args.graphics.symbologyOverrides;\r\n }\r\n }\r\n\r\n if (!targetBranch)\r\n targetBranch = args.graphics;\r\n\r\n if (undefined !== graphics) {\r\n const displayedDescendants = displayedTileDescendants[index];\r\n if (0 === displayedDescendants.length || !this.loader.parentsAndChildrenExclusive || selectedTile.allChildrenIncluded(displayedDescendants)) {\r\n targetBranch.add(graphics);\r\n if (selectBuilder)\r\n selectedTile.addBoundingGraphic(selectBuilder, ColorDef.green);\r\n } else {\r\n if (selectBuilder)\r\n selectedTile.addBoundingGraphic(selectBuilder, ColorDef.red);\r\n\r\n for (const displayedDescendant of displayedDescendants) {\r\n const clipVector = displayedDescendant.getContentClip();\r\n if (selectBuilder)\r\n displayedDescendant.addBoundingGraphic(selectBuilder, ColorDef.blue);\r\n\r\n if (undefined === clipVector) {\r\n targetBranch.add(graphics);\r\n } else {\r\n clipVector.transformInPlace(args.location);\r\n if (!this.isTransparent)\r\n for (const primitive of clipVector.clips)\r\n for (const clipPlanes of primitive.fetchClipPlanesRef()!.convexSets)\r\n for (const plane of clipPlanes.planes)\r\n plane.offsetDistance(-displayedDescendant.radius * .05); // Overlap with existing (high resolution) tile slightly to avoid cracks.\r\n\r\n const branch = new GraphicBranch(false);\r\n branch.add(graphics);\r\n const clipVolume = args.context.target.renderSystem.createClipVolume(clipVector);\r\n targetBranch.add(args.context.createGraphicBranch(branch, Transform.createIdentity(), { clipVolume }));\r\n }\r\n }\r\n }\r\n if (preloadDebugBuilder)\r\n targetBranch.add(preloadDebugBuilder.finish());\r\n\r\n if (selectBuilder)\r\n targetBranch.add(selectBuilder.finish());\r\n\r\n const rangeGraphic = selectedTile.getRangeGraphic(args.context);\r\n if (undefined !== rangeGraphic)\r\n targetBranch.add(rangeGraphic);\r\n }\r\n }\r\n\r\n args.drawGraphics();\r\n for (const graphicTypeBranch of graphicTypeBranches) {\r\n args.drawGraphicsWithType(graphicTypeBranch[0], graphicTypeBranch[1]);\r\n }\r\n }\r\n\r\n /** @internal */\r\n protected collectClassifierGraphics(args: TileDrawArgs, selectedTiles: RealityTile[]) {\r\n const classifier = args.context.planarClassifiers.get(this.modelId);\r\n if (classifier)\r\n classifier.collectGraphics(args.context, { modelId: this.modelId, tiles: selectedTiles, location: args.location, isPointCloud: this.isPointCloud });\r\n }\r\n\r\n /** @internal */\r\n public getTraversalChildren(depth: number) {\r\n while (this.traversalChildrenByDepth.length <= depth)\r\n this.traversalChildrenByDepth.push(new TraversalChildrenDetails());\r\n\r\n return this.traversalChildrenByDepth[depth];\r\n }\r\n\r\n /** @internal */\r\n public doReprojectChildren(tile: Tile): boolean {\r\n if (!(tile instanceof RealityTile) || this._gcsConverter === undefined || this._rootToEcef === undefined || undefined === this._ecefToDb)\r\n return false;\r\n\r\n const tileRange = this.iModelTransform.isIdentity ? tile.range : this.iModelTransform.multiplyRange(tile.range, scratchRange);\r\n\r\n return this.cartesianRange.intersectsRange(tileRange);\r\n }\r\n\r\n /** @internal */\r\n public reprojectAndResolveChildren(parent: Tile, children: Tile[], resolve: (children: Tile[] | undefined) => void): void {\r\n if (!this.doReprojectChildren(parent)) {\r\n resolve(children);\r\n return;\r\n }\r\n\r\n const ecefToDb = this._ecefToDb!; // Tested for undefined in doReprojectChildren\r\n const rootToDb = this.iModelTransform;\r\n const dbToEcef = ecefToDb.inverse()!;\r\n const reprojectChildren = new Array<ChildReprojection>();\r\n for (const child of children) {\r\n const realityChild = child as RealityTile;\r\n const childRange = realityChild.rangeCorners ? Range3d.createTransformedArray(rootToDb, realityChild.rangeCorners) : rootToDb.multiplyRange(realityChild.contentRange, scratchRange);\r\n const dbCenter = childRange.center;\r\n const ecefCenter = dbToEcef.multiplyPoint3d(dbCenter);\r\n const dbPoints = [dbCenter, dbCenter.plusXYZ(1), dbCenter.plusXYZ(0, 1), dbCenter.plusXYZ(0, 0, 1)];\r\n reprojectChildren.push({ child: realityChild, ecefCenter, dbPoints });\r\n }\r\n if (reprojectChildren.length === 0)\r\n resolve(children);\r\n else {\r\n const requestProps = new Array<XYZProps>();\r\n\r\n for (const reprojection of reprojectChildren) {\r\n for (const dbPoint of reprojection.dbPoints) {\r\n const ecefPoint = dbToEcef.multiplyPoint3d(dbPoint);\r\n const carto = Cartographic.fromEcef(ecefPoint, scratchCarto);\r\n if (carto)\r\n requestProps.push({ x: carto.longitudeDegrees, y: carto.latitudeDegrees, z: carto.height });\r\n\r\n }\r\n }\r\n\r\n if (requestProps.length !== 4 * reprojectChildren.length)\r\n resolve(children);\r\n else {\r\n this._gcsConverter!.getIModelCoordinatesFromGeoCoordinates(requestProps).then((response) => {\r\n\r\n const reprojectedCoords = response.iModelCoords;\r\n const dbToRoot = rootToDb.inverse()!;\r\n const getReprojectedPoint = (original: Point3d, reprojectedXYZ: XYZProps) => {\r\n scratchPoint.setFromJSON(reprojectedXYZ);\r\n const cartesianDistance = this.cartesianRange.distanceToPoint(scratchPoint);\r\n if (cartesianDistance < this.cartesianTransitionDistance)\r\n return scratchPoint.interpolate(cartesianDistance / this.cartesianTransitionDistance, original, scratchPoint);\r\n else\r\n return original;\r\n };\r\n\r\n let responseIndex = 0;\r\n for (const reprojection of reprojectChildren) {\r\n if (reprojectedCoords.every((coord) => coord.s === GeoCoordStatus.Success)) {\r\n const reprojectedOrigin = getReprojectedPoint(reprojection.dbPoints[0], reprojectedCoords[responseIndex++].p).clone(scratchOrigin);\r\n const xVector = Vector3d.createStartEnd(reprojectedOrigin, getReprojectedPoint(reprojection.dbPoints[1], reprojectedCoords[responseIndex++].p), scratchX);\r\n const yVector = Vector3d.createStartEnd(reprojectedOrigin, getReprojectedPoint(reprojection.dbPoints[2], reprojectedCoords[responseIndex++].p), scratchY);\r\n const zVector = Vector3d.createStartEnd(reprojectedOrigin, getReprojectedPoint(reprojection.dbPoints[3], reprojectedCoords[responseIndex++].p), scratchZ);\r\n const matrix = Matrix3d.createColumns(xVector, yVector, zVector, scratchMatrix);\r\n if (matrix !== undefined) {\r\n const dbReprojection = Transform.createMatrixPickupPutdown(matrix, reprojection.dbPoints[0], reprojectedOrigin, scratchTransform);\r\n if (dbReprojection) {\r\n const rootReprojection = dbToRoot.multiplyTransformTransform(dbReprojection).multiplyTransformTransform(rootToDb);\r\n reprojection.child.reproject(rootReprojection);\r\n }\r\n }\r\n }\r\n }\r\n\r\n resolve(children);\r\n }).catch(() => {\r\n resolve(children); // Error occured in reprojection - just resolve with unprojected corners.\r\n });\r\n }\r\n }\r\n }\r\n\r\n /** @internal */\r\n public getBaseRealityDepth(_sceneContext: SceneContext) { return -1; }\r\n\r\n /** @internal */\r\n public selectRealityTiles(args: TileDrawArgs, displayedDescendants: RealityTile[][], preloadDebugBuilder?: GraphicBuilder): RealityTile[] {\r\n this._lastSelected = BeTimePoint.now();\r\n const selected: RealityTile[] = [];\r\n const context = new TraversalSelectionContext(selected, displayedDescendants, preloadDebugBuilder, args.maxRealityTreeSelectionCount);\r\n const rootTile = this.rootTile;\r\n const debugControl = args.context.target.debugControl;\r\n const freezeTiles = debugControl && debugControl.freezeRealityTiles;\r\n\r\n rootTile.selectRealityTiles(context, args, new TraversalDetails());\r\n\r\n const baseDepth = this.getBaseRealityDepth(args.context);\r\n\r\n if (!args.context.target.renderSystem.isMobile && 0 === context.missing.length) { // We skip preloading on mobile devices.\r\n if (baseDepth > 0) // Maps may force loading of low level globe tiles.\r\n rootTile.preloadRealityTilesAtDepth(baseDepth, context, args);\r\n\r\n if (!freezeTiles)\r\n this.preloadTilesForScene(args, context, undefined);\r\n }\r\n\r\n if (!freezeTiles)\r\n for (const tile of context.missing) {\r\n const loadableTile = tile.loadableTile;\r\n\r\n loadableTile.markUsed(args);\r\n args.insertMissing(loadableTile);\r\n }\r\n\r\n if (debugControl && debugControl.logRealityTiles) {\r\n this.logTiles(\"Selected: \", selected.values());\r\n const preloaded = [];\r\n for (const tile of context.preloaded)\r\n preloaded.push(tile);\r\n\r\n this.logTiles(\"Preloaded: \", preloaded.values());\r\n this.logTiles(\"Missing: \", context.missing.values());\r\n\r\n const imageryTiles: RealityTile[] = [];\r\n for (const selectedTile of selected) {\r\n if (selectedTile instanceof MapTile) {\r\n const selectedImageryTiles = (selectedTile).imageryTiles;\r\n if (selectedImageryTiles)\r\n selectedImageryTiles.forEach((tile) => imageryTiles.push(tile));\r\n }\r\n }\r\n if (imageryTiles.length)\r\n this.logTiles(\"Imagery:\", imageryTiles.values());\r\n }\r\n\r\n IModelApp.tileAdmin.addTilesForUser(args.context.viewport, selected, args.readyTiles);\r\n return selected;\r\n }\r\n\r\n /** @internal */\r\n public preloadTilesForScene(args: TileDrawArgs, context: TraversalSelectionContext, frustumTransform?: Transform) {\r\n const preloadFrustum = args.viewingSpace.getPreloadFrustum(frustumTransform, scratchFrustum);\r\n const preloadFrustumPlanes = new FrustumPlanes(preloadFrustum);\r\n const worldToNpc = preloadFrustum.toMap4d();\r\n const preloadWorldToViewMap = args.viewingSpace.calcNpcToView().multiplyMapMap(worldToNpc!);\r\n const preloadArgs = new RealityTileDrawArgs(args, preloadWorldToViewMap, preloadFrustumPlanes);\r\n\r\n scratchFrustumPlanes.init(preloadFrustum);\r\n if (context.preloadDebugBuilder) {\r\n context.preloadDebugBuilder.setSymbology(ColorDef.blue, ColorDef.blue, 2, 0);\r\n context.preloadDebugBuilder.addFrustum(preloadFrustum);\r\n }\r\n\r\n this.rootTile.preloadTilesInFrustum(preloadArgs, context, 2);\r\n }\r\n\r\n /** @internal */\r\n protected logTiles(label: string, tiles: IterableIterator<Tile>) {\r\n let depthString = \"\";\r\n let min = 10000, max = -10000;\r\n let count = 0;\r\n const depthMap = new Map<number, number>();\r\n for (const tile of tiles) {\r\n count++;\r\n const depth = tile.depth;\r\n min = Math.min(min, tile.depth);\r\n max = Math.max(max, tile.depth);\r\n const found = depthMap.get(depth);\r\n depthMap.set(depth, found === undefined ? 1 : found + 1);\r\n }\r\n\r\n depthMap.forEach((key, value) => depthString += `${key}-${value}, `);\r\n // eslint-disable-next-line no-console\r\n console.log(`${label}: ${count} Min: ${min} Max: ${max} Depths: ${depthString}`);\r\n }\r\n}\r\n"]}
@@ -6,6 +6,32 @@ import { ChangesetIndex, ChangesetIndexAndId, IModelConnectionProps, OpenBriefca
6
6
  import { BriefcaseTxns } from "./BriefcaseTxns";
7
7
  import { GraphicalEditingScope } from "./GraphicalEditingScope";
8
8
  import { IModelConnection } from "./IModelConnection";
9
+ import { ProgressCallback } from "./request/Request";
10
+ /**
11
+ * Partial interface of AbortSignal.
12
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal
13
+ * @alpha
14
+ */
15
+ export interface GenericAbortSignal {
16
+ /** Add Listener for abort signal. */
17
+ addEventListener: (type: "abort", listener: (this: GenericAbortSignal, ev: any) => any) => void;
18
+ /** Remove Listener for abort signal. */
19
+ removeEventListener: (type: "abort", listener: (this: GenericAbortSignal, ev: any) => any) => void;
20
+ }
21
+ /**
22
+ * Options for pulling iModel changes.
23
+ * @public
24
+ */
25
+ export interface PullChangesOptions {
26
+ /** Function called regularly to report progress of changes download. */
27
+ progressCallback?: ProgressCallback;
28
+ /** Interval for calling progress callback (in milliseconds). */
29
+ progressInterval?: number;
30
+ /** Signal for cancelling the download.
31
+ * @alpha
32
+ */
33
+ abortSignal?: GenericAbortSignal;
34
+ }
9
35
  /** Settings that can be used to control the behavior of [[Tool]]s that modify a [[BriefcaseConnection]].
10
36
  * For example, tools that want to create new elements can consult the briefcase's editor tool settings to
11
37
  * determine into which model and category to insert the elements.
@@ -78,9 +104,10 @@ export declare class BriefcaseConnection extends IModelConnection {
78
104
  saveChanges(description?: string): Promise<void>;
79
105
  /** Pull (and potentially merge if there are local changes) up to a specified changeset from iModelHub into this briefcase
80
106
  * @param toIndex The changeset index to pull changes to. If `undefined`, pull all changes.
107
+ * @param options Options for pulling changes.
81
108
  * @see [[BriefcaseTxns.onChangesPulled]] for the event dispatched after changes are pulled.
82
109
  */
83
- pullChanges(toIndex?: ChangesetIndex): Promise<void>;
110
+ pullChanges(toIndex?: ChangesetIndex, options?: PullChangesOptions): Promise<void>;
84
111
  /** Create a changeset from local Txns and push to iModelHub. On success, clear Txn table.
85
112
  * @param description The description for the changeset
86
113
  * @returns the changesetId of the pushed changes
@@ -1 +1 @@
1
- {"version":3,"file":"BriefcaseConnection.d.ts","sourceRoot":"","sources":["../../src/BriefcaseConnection.ts"],"names":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I,CAAC;IAI7D;;;;OAIG;IACU,WAAW,CAAC,OAAO,CAAC,EAAE,cAAc,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IA4B/F;;;;OAIG;IACU,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAK3E;;OAEG;IACH,IAAW,YAAY,IAAI,qBAAqB,GAAG,SAAS,CAE3D;IAED;;;OAGG;IACU,wBAAwB,IAAI,OAAO,CAAC,OAAO,CAAC;IAIzD;;;;;OAKG;IACU,iBAAiB,IAAI,OAAO,CAAC,qBAAqB,CAAC;IAIhE;;OAEG;IACH,SAAgB,sBAAsB,4BAAiC,IAAI,MAAM,CAAC,KAAK,IAAI,EAAI;CAChG"}
@@ -6,7 +6,7 @@
6
6
  * @module IModelConnection
7
7
  */
8
8
  import { assert, BeEvent, CompressedId64Set, Guid, IModelStatus, OpenMode } from "@itwin/core-bentley";
9
- import { IModelError, } from "@itwin/core-common";
9
+ import { getPullChangesIpcChannel, IModelError, } from "@itwin/core-common";
10
10
  import { BriefcaseTxns } from "./BriefcaseTxns";
11
11
  import { GraphicalEditingScope } from "./GraphicalEditingScope";
12
12
  import { IModelApp } from "./IModelApp";
@@ -234,11 +234,32 @@ export class BriefcaseConnection extends IModelConnection {
234
234
  }
235
235
  /** Pull (and potentially merge if there are local changes) up to a specified changeset from iModelHub into this briefcase
236
236
  * @param toIndex The changeset index to pull changes to. If `undefined`, pull all changes.
237
+ * @param options Options for pulling changes.
237
238
  * @see [[BriefcaseTxns.onChangesPulled]] for the event dispatched after changes are pulled.
238
239
  */
239
- async pullChanges(toIndex) {
240
+ async pullChanges(toIndex, options) {
241
+ const removeListeners = [];
242
+ if (options === null || options === void 0 ? void 0 : options.progressCallback) {
243
+ const removeProgressListener = IpcApp.addListener(getPullChangesIpcChannel(this.iModelId), (_evt, data) => { var _a; return (_a = options === null || options === void 0 ? void 0 : options.progressCallback) === null || _a === void 0 ? void 0 : _a.call(options, data); });
244
+ removeListeners.push(removeProgressListener);
245
+ }
246
+ if (options === null || options === void 0 ? void 0 : options.abortSignal) {
247
+ const abort = () => void IpcApp.appFunctionIpc.cancelPullChangesRequest(this.key);
248
+ options === null || options === void 0 ? void 0 : options.abortSignal.addEventListener("abort", abort);
249
+ removeListeners.push(() => { var _a; return (_a = options === null || options === void 0 ? void 0 : options.abortSignal) === null || _a === void 0 ? void 0 : _a.removeEventListener("abort", abort); });
250
+ }
240
251
  this.requireTimeline();
241
- this.changeset = await IpcApp.appFunctionIpc.pullChanges(this.key, toIndex);
252
+ const ipcAppOptions = {
253
+ reportProgress: !!(options === null || options === void 0 ? void 0 : options.progressCallback),
254
+ progressInterval: options === null || options === void 0 ? void 0 : options.progressInterval,
255
+ enableCancellation: !!(options === null || options === void 0 ? void 0 : options.abortSignal),
256
+ };
257
+ try {
258
+ this.changeset = await IpcApp.appFunctionIpc.pullChanges(this.key, toIndex, ipcAppOptions);
259
+ }
260
+ finally {
261
+ removeListeners.forEach((remove) => remove());
262
+ }
242
263
  }
243
264
  /** Create a changeset from local Txns and push to iModelHub. On success, clear Txn table.
244
265
  * @param description The description for the changeset
@@ -1 +1 @@
1
- {"version":3,"file":"BriefcaseConnection.js","sourceRoot":"","sources":["../../src/BriefcaseConnection.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,EAAE,IAAI,EAA0B,YAAY,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/H,OAAO,EAEuC,WAAW,GACxD,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;A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AC,CAAC;IAC9E,CAAC;IAED,2FAA2F;IACpF,KAAK,CAAC,cAAc;QACzB,OAAO,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC;IACpC,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,WAAW,CAAC,WAAoB;QAC3C,MAAM,MAAM,CAAC,cAAc,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;IACjE,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,WAAW,CAAC,OAAwB;QAC/C,IAAI,CAAC,eAAe,EAAE,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC9E,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,WAAW,CAAC,WAAmB;QAC1C,IAAI,CAAC,eAAe,EAAE,CAAC;QACvB,OAAO,MAAM,CAAC,cAAc,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;IAClE,CAAC;IAED;;OAEG;IACH,IAAW,YAAY;QACrB,OAAO,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC;IAC1C,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,wBAAwB;QACnC,OAAO,MAAM,CAAC,cAAc,CAAC,2BAA2B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACrE,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,iBAAiB;QAC5B,OAAO,IAAI,CAAC,cAAc,CAAC,iBAAiB,EAAE,CAAC;IACjD,CAAC;CAMF","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 IModelConnection\r\n */\r\n\r\nimport { assert, BeEvent, CompressedId64Set, Guid, GuidString, Id64String, IModelStatus, OpenMode } from \"@itwin/core-bentley\";\r\nimport {\r\n ChangesetIndex,\r\n ChangesetIndexAndId, IModelConnectionProps, IModelError, OpenBriefcaseProps, StandaloneOpenOptions,\r\n} from \"@itwin/core-common\";\r\nimport { BriefcaseTxns } from \"./BriefcaseTxns\";\r\nimport { GraphicalEditingScope } from \"./GraphicalEditingScope\";\r\nimport { IModelApp } from \"./IModelApp\";\r\nimport { IModelConnection } from \"./IModelConnection\";\r\nimport { IpcApp } from \"./IpcApp\";\r\nimport { disposeTileTreesForGeometricModels } from \"./tile/internal\";\r\nimport { Viewport } from \"./Viewport\";\r\n\r\n/** Keeps track of changes to models, buffering them until synchronization points.\r\n * While a GraphicalEditingScope is open, the changes are buffered until the scope exits, at which point they are processed.\r\n * Otherwise, the buffered changes are processed after undo/redo, commit, or pull+merge changes.\r\n */\r\nclass ModelChangeMonitor {\r\n private _editingScope?: GraphicalEditingScope;\r\n private readonly _briefcase: BriefcaseConnection;\r\n private readonly _deletedModels = new Set<string>();\r\n private readonly _modelIdToGuid = new Map<string, string>();\r\n private readonly _removals: VoidFunction[] = [];\r\n\r\n public constructor(briefcase: BriefcaseConnection) {\r\n this._briefcase = briefcase;\r\n\r\n // Buffer updated geometry guids.\r\n this._removals.push(briefcase.txns.onModelGeometryChanged.addListener((changes) => {\r\n for (const change of changes) {\r\n this._deletedModels.delete(change.id);\r\n this._modelIdToGuid.set(change.id, change.guid);\r\n }\r\n }));\r\n\r\n // Buffer deletions of models.\r\n this._removals.push(briefcase.txns.onModelsChanged.addListener((changes) => {\r\n if (changes.deleted) {\r\n for (const id of CompressedId64Set.iterable(changes.deleted)) {\r\n this._modelIdToGuid.delete(id);\r\n this._deletedModels.add(id);\r\n }\r\n }\r\n }));\r\n\r\n // Outside of an editing scope, we want to update viewport contents after commit, undo/redo, or merging changes.\r\n const maybeProcess = async () => {\r\n if (this.editingScope)\r\n return;\r\n\r\n const modelIds = Array.from(this._modelIdToGuid.keys());\r\n if (modelIds.length > 0)\r\n await IModelApp.tileAdmin.purgeTileTrees(this._briefcase, modelIds);\r\n\r\n this.processBuffered();\r\n };\r\n\r\n this._removals.push(briefcase.txns.onCommitted.addListener(maybeProcess));\r\n this._removals.push(briefcase.txns.onAfterUndoRedo.addListener(maybeProcess));\r\n this._removals.push(briefcase.txns.onChangesPulled.addListener(maybeProcess));\r\n }\r\n\r\n public async close(): Promise<void> {\r\n for (const removal of this._removals)\r\n removal();\r\n\r\n this._removals.length = 0;\r\n\r\n if (this._editingScope) {\r\n await this._editingScope.exit();\r\n this._editingScope = undefined;\r\n }\r\n }\r\n\r\n public get editingScope(): GraphicalEditingScope | undefined {\r\n return this._editingScope;\r\n }\r\n\r\n public async enterEditingScope(): Promise<GraphicalEditingScope> {\r\n if (this._editingScope)\r\n throw new Error(\"Cannot create an editing scope for an iModel that already has one\");\r\n\r\n this._editingScope = await GraphicalEditingScope.enter(this._briefcase);\r\n\r\n const removeGeomListener = this._editingScope.onGeometryChanges.addListener((changes) => {\r\n const modelIds = [];\r\n for (const change of changes)\r\n modelIds.push(change.id);\r\n\r\n this.invalidateScenes(modelIds);\r\n });\r\n\r\n this._editingScope.onExited.addOnce((scope) => {\r\n assert(scope === this._editingScope);\r\n this._editingScope = undefined;\r\n removeGeomListener();\r\n this.processBuffered();\r\n });\r\n\r\n return this._editingScope;\r\n }\r\n\r\n private processBuffered(): void {\r\n const models = this._briefcase.models;\r\n for (const [id, guid] of this._modelIdToGuid) {\r\n const model = models.getLoaded(id)?.asGeometricModel;\r\n if (model)\r\n model.geometryGuid = guid;\r\n }\r\n\r\n const modelIds = new Set<string>(this._modelIdToGuid.keys());\r\n for (const deleted of this._deletedModels) {\r\n modelIds.add(deleted);\r\n models.unload(deleted);\r\n }\r\n\r\n this.invalidateScenes(modelIds);\r\n disposeTileTreesForGeometricModels(modelIds, this._briefcase);\r\n\r\n this._briefcase.onBufferedModelChanges.raiseEvent(modelIds);\r\n\r\n this._modelIdToGuid.clear();\r\n this._deletedModels.clear();\r\n }\r\n\r\n private invalidateScenes(changedModels: Iterable<Id64String>): void {\r\n for (const user of IModelApp.tileAdmin.tileUsers) {\r\n if (user instanceof Viewport && user.iModel === this._briefcase) {\r\n for (const modelId of changedModels) {\r\n if (user.view.viewsModel(modelId)) {\r\n user.invalidateScene();\r\n user.setFeatureOverrideProviderChanged();\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n}\r\n\r\n/** Settings that can be used to control the behavior of [[Tool]]s that modify a [[BriefcaseConnection]].\r\n * For example, tools that want to create new elements can consult the briefcase's editor tool settings to\r\n * determine into which model and category to insert the elements.\r\n * Specialized tools are free to ignore these settings.\r\n * @see [[BriefcaseConnection.editorToolSettings]] to query or modify the current settings for a briefcase.\r\n * @see [CreateElementTool]($editor-frontend) for an example of a tool that uses these settings.\r\n * @alpha\r\n */\r\nexport class BriefcaseEditorToolSettings {\r\n private _category?: Id64String;\r\n private _model?: Id64String;\r\n\r\n /** An event raised just after the default [[category]] is changed. */\r\n public readonly onCategoryChanged = new BeEvent<(previousCategory: Id64String | undefined) => void>();\r\n\r\n /** An event raised just after the default [[model]] is changed. */\r\n public readonly onModelChanged = new BeEvent<(previousModel: Id64String | undefined) => void>();\r\n\r\n /** The [Category]($backend) into which new elements should be inserted by default.\r\n * Specialized tools are free to ignore this setting and instead use their own logic to select an appropriate category.\r\n * @see [[onCategoryChanged]] to be notified when this property is modified.\r\n * @see [CreateElementTool.targetCategory]($editor-frontend) for an example of a tool that uses this setting.\r\n */\r\n public get category(): Id64String | undefined {\r\n return this._category;\r\n }\r\n public set category(category: Id64String | undefined) {\r\n const previousCategory = this.category;\r\n if (category !== this.category) {\r\n this._category = category;\r\n this.onCategoryChanged.raiseEvent(previousCategory);\r\n }\r\n }\r\n\r\n /** The [Model]($backend) into which new elements should be inserted by default.\r\n * Specialized tools are free to ignore this setting and instead use their own logic to select an appropriate model.\r\n * @see [[onModelChanged]] to be notified when this property is modified.\r\n * @see [CreateElementTool.targetModel]($editor-frontend) for an example of a tool that uses this setting.\r\n */\r\n public get model(): Id64String | undefined {\r\n return this._model;\r\n }\r\n public set model(model: Id64String | undefined) {\r\n const previousModel = this.model;\r\n if (model !== this.model) {\r\n this._model = model;\r\n this.onModelChanged.raiseEvent(previousModel);\r\n }\r\n }\r\n}\r\n\r\n/** A connection to an editable briefcase on the backend. This class uses [Ipc]($docs/learning/IpcInterface.md) to communicate\r\n * to the backend and may only be used by [[IpcApp]]s.\r\n * @public\r\n */\r\nexport class BriefcaseConnection extends IModelConnection {\r\n protected _isClosed?: boolean;\r\n private readonly _modelsMonitor: ModelChangeMonitor;\r\n /** Default settings that can be used to control the behavior of [[Tool]]s that modify this briefcase.\r\n * @alpha\r\n */\r\n public readonly editorToolSettings = new BriefcaseEditorToolSettings();\r\n\r\n /** Manages local changes to the briefcase via [Txns]($docs/learning/InteractiveEditing.md). */\r\n public readonly txns: BriefcaseTxns;\r\n\r\n /** @internal */\r\n public override isBriefcaseConnection(): this is BriefcaseConnection { return true; }\r\n\r\n /** The Guid that identifies the iTwin that owns this iModel. */\r\n public override get iTwinId(): GuidString { return super.iTwinId!; } // GuidString | undefined for IModelConnection, but required for BriefcaseConnection\r\n\r\n /** The Guid that identifies this iModel. */\r\n public override get iModelId(): GuidString { return super.iModelId!; } // GuidString | undefined for IModelConnection, but required for BriefcaseConnection\r\n\r\n protected constructor(props: IModelConnectionProps, openMode: OpenMode) {\r\n super(props);\r\n this._openMode = openMode;\r\n this.txns = new BriefcaseTxns(this);\r\n this._modelsMonitor = new ModelChangeMonitor(this);\r\n }\r\n\r\n /** Open a BriefcaseConnection to a [BriefcaseDb]($backend). */\r\n public static async openFile(briefcaseProps: OpenBriefcaseProps): Promise<BriefcaseConnection> {\r\n const iModelProps = await IpcApp.appFunctionIpc.openBriefcase(briefcaseProps);\r\n const connection = new this({ ...briefcaseProps, ...iModelProps }, briefcaseProps.readonly ? OpenMode.Readonly : OpenMode.ReadWrite);\r\n IModelConnection.onOpen.raiseEvent(connection);\r\n return connection;\r\n }\r\n\r\n /** Open a BriefcaseConnection to a [StandaloneDb]($backend)\r\n * @note StandaloneDbs, by definition, may not push or pull changes. Attempting to do so will throw exceptions.\r\n */\r\n public static async openStandalone(filePath: string, openMode: OpenMode = OpenMode.ReadWrite, opts?: StandaloneOpenOptions): Promise<BriefcaseConnection> {\r\n const openResponse = await IpcApp.appFunctionIpc.openStandalone(filePath, openMode, opts);\r\n const connection = new this(openResponse, openMode);\r\n IModelConnection.onOpen.raiseEvent(connection);\r\n return connection;\r\n }\r\n\r\n /** Returns `true` if [[close]] has already been called. */\r\n public get isClosed(): boolean { return this._isClosed === true; }\r\n\r\n /**\r\n * Close this BriefcaseConnection.\r\n * @note make sure to call [[saveChanges]] before calling this method. Unsaved local changes are abandoned.\r\n */\r\n public async close(): Promise<void> {\r\n if (this.isClosed)\r\n return;\r\n\r\n await this._modelsMonitor.close();\r\n\r\n this.beforeClose();\r\n this.txns.dispose();\r\n\r\n this._isClosed = true;\r\n await IpcApp.appFunctionIpc.closeIModel(this._fileKey);\r\n }\r\n\r\n private requireTimeline() {\r\n if (this.iTwinId === Guid.empty)\r\n throw new IModelError(IModelStatus.WrongIModel, \"iModel has no timeline\");\r\n }\r\n\r\n /** Query if there are any pending Txns in this briefcase that are waiting to be pushed. */\r\n public async hasPendingTxns(): Promise<boolean> { // eslint-disable-line @itwin/prefer-get\r\n return this.txns.hasPendingTxns();\r\n }\r\n\r\n /** Commit pending changes to this briefcase.\r\n * @param description Optional description of the changes.\r\n */\r\n public async saveChanges(description?: string): Promise<void> {\r\n await IpcApp.appFunctionIpc.saveChanges(this.key, description);\r\n }\r\n\r\n /** Pull (and potentially merge if there are local changes) up to a specified changeset from iModelHub into this briefcase\r\n * @param toIndex The changeset index to pull changes to. If `undefined`, pull all changes.\r\n * @see [[BriefcaseTxns.onChangesPulled]] for the event dispatched after changes are pulled.\r\n */\r\n public async pullChanges(toIndex?: ChangesetIndex): Promise<void> {\r\n this.requireTimeline();\r\n this.changeset = await IpcApp.appFunctionIpc.pullChanges(this.key, toIndex);\r\n }\r\n\r\n /** Create a changeset from local Txns and push to iModelHub. On success, clear Txn table.\r\n * @param description The description for the changeset\r\n * @returns the changesetId of the pushed changes\r\n * @see [[BriefcaseTxns.onChangesPushed]] for the event dispatched after changes are pushed.\r\n */\r\n public async pushChanges(description: string): Promise<ChangesetIndexAndId> {\r\n this.requireTimeline();\r\n return IpcApp.appFunctionIpc.pushChanges(this.key, description);\r\n }\r\n\r\n /** The current graphical editing scope, if one is in progress.\r\n * @see [[enterEditingScope]] to begin graphical editing.\r\n */\r\n public get editingScope(): GraphicalEditingScope | undefined {\r\n return this._modelsMonitor.editingScope;\r\n }\r\n\r\n /** Return whether graphical editing is supported for this briefcase. It is not supported if the briefcase is read-only, or the briefcase contains a version of\r\n * the BisCore ECSchema older than v0.1.11.\r\n * @see [[enterEditingScope]] to enable graphical editing.\r\n */\r\n public async supportsGraphicalEditing(): Promise<boolean> {\r\n return IpcApp.appFunctionIpc.isGraphicalEditingSupported(this.key);\r\n }\r\n\r\n /** Begin a new graphical editing scope.\r\n * @throws Error if an editing scope already exists or one could not be created.\r\n * @see [[GraphicalEditingScope.exit]] to exit the scope.\r\n * @see [[supportsGraphicalEditing]] to determine whether this method should be expected to succeed.\r\n * @see [[editingScope]] to obtain the current editing scope, if one is in progress.\r\n */\r\n public async enterEditingScope(): Promise<GraphicalEditingScope> {\r\n return this._modelsMonitor.enterEditingScope();\r\n }\r\n\r\n /** Strictly for tests - dispatched from ModelChangeMonitor.processBuffered.\r\n * @internal\r\n */\r\n public readonly onBufferedModelChanges = new BeEvent<(changedModelIds: Set<string>) => void>();\r\n}\r\n"]}
1
+ {"version":3,"file":"BriefcaseConnection.js","sourceRoot":"","sources":["../../src/BriefcaseConnection.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,EAAE,IAAI,EAA0B,YAAY,EAA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AC,IAAI,CAAC,GAAG,CAAC,CAAC;IACrE,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,iBAAiB;QAC5B,OAAO,IAAI,CAAC,cAAc,CAAC,iBAAiB,EAAE,CAAC;IACjD,CAAC;CAMF","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 IModelConnection\r\n */\r\n\r\nimport { assert, BeEvent, CompressedId64Set, Guid, GuidString, Id64String, IModelStatus, OpenMode } from \"@itwin/core-bentley\";\r\nimport {\r\n ChangesetIndex, ChangesetIndexAndId, getPullChangesIpcChannel, IModelConnectionProps, IModelError,\r\n PullChangesOptions as IpcAppPullChangesOptions, OpenBriefcaseProps, StandaloneOpenOptions,\r\n} from \"@itwin/core-common\";\r\nimport { BriefcaseTxns } from \"./BriefcaseTxns\";\r\nimport { GraphicalEditingScope } from \"./GraphicalEditingScope\";\r\nimport { IModelApp } from \"./IModelApp\";\r\nimport { IModelConnection } from \"./IModelConnection\";\r\nimport { IpcApp } from \"./IpcApp\";\r\nimport { ProgressCallback } from \"./request/Request\";\r\nimport { disposeTileTreesForGeometricModels } from \"./tile/internal\";\r\nimport { Viewport } from \"./Viewport\";\r\n\r\n/**\r\n * Partial interface of AbortSignal.\r\n * @see https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal\r\n * @alpha\r\n */\r\nexport interface GenericAbortSignal {\r\n /** Add Listener for abort signal. */\r\n addEventListener: (type: \"abort\", listener: (this: GenericAbortSignal, ev: any) => any) => void;\r\n /** Remove Listener for abort signal. */\r\n removeEventListener: (type: \"abort\", listener: (this: GenericAbortSignal, ev: any) => any) => void;\r\n}\r\n\r\n/**\r\n * Options for pulling iModel changes.\r\n * @public\r\n */\r\nexport interface PullChangesOptions {\r\n /** Function called regularly to report progress of changes download. */\r\n progressCallback?: ProgressCallback;\r\n /** Interval for calling progress callback (in milliseconds). */\r\n progressInterval?: number;\r\n /** Signal for cancelling the download.\r\n * @alpha\r\n */\r\n abortSignal?: GenericAbortSignal;\r\n}\r\n\r\n/** Keeps track of changes to models, buffering them until synchronization points.\r\n * While a GraphicalEditingScope is open, the changes are buffered until the scope exits, at which point they are processed.\r\n * Otherwise, the buffered changes are processed after undo/redo, commit, or pull+merge changes.\r\n */\r\nclass ModelChangeMonitor {\r\n private _editingScope?: GraphicalEditingScope;\r\n private readonly _briefcase: BriefcaseConnection;\r\n private readonly _deletedModels = new Set<string>();\r\n private readonly _modelIdToGuid = new Map<string, string>();\r\n private readonly _removals: VoidFunction[] = [];\r\n\r\n public constructor(briefcase: BriefcaseConnection) {\r\n this._briefcase = briefcase;\r\n\r\n // Buffer updated geometry guids.\r\n this._removals.push(briefcase.txns.onModelGeometryChanged.addListener((changes) => {\r\n for (const change of changes) {\r\n this._deletedModels.delete(change.id);\r\n this._modelIdToGuid.set(change.id, change.guid);\r\n }\r\n }));\r\n\r\n // Buffer deletions of models.\r\n this._removals.push(briefcase.txns.onModelsChanged.addListener((changes) => {\r\n if (changes.deleted) {\r\n for (const id of CompressedId64Set.iterable(changes.deleted)) {\r\n this._modelIdToGuid.delete(id);\r\n this._deletedModels.add(id);\r\n }\r\n }\r\n }));\r\n\r\n // Outside of an editing scope, we want to update viewport contents after commit, undo/redo, or merging changes.\r\n const maybeProcess = async () => {\r\n if (this.editingScope)\r\n return;\r\n\r\n const modelIds = Array.from(this._modelIdToGuid.keys());\r\n if (modelIds.length > 0)\r\n await IModelApp.tileAdmin.purgeTileTrees(this._briefcase, modelIds);\r\n\r\n this.processBuffered();\r\n };\r\n\r\n this._removals.push(briefcase.txns.onCommitted.addListener(maybeProcess));\r\n this._removals.push(briefcase.txns.onAfterUndoRedo.addListener(maybeProcess));\r\n this._removals.push(briefcase.txns.onChangesPulled.addListener(maybeProcess));\r\n }\r\n\r\n public async close(): Promise<void> {\r\n for (const removal of this._removals)\r\n removal();\r\n\r\n this._removals.length = 0;\r\n\r\n if (this._editingScope) {\r\n await this._editingScope.exit();\r\n this._editingScope = undefined;\r\n }\r\n }\r\n\r\n public get editingScope(): GraphicalEditingScope | undefined {\r\n return this._editingScope;\r\n }\r\n\r\n public async enterEditingScope(): Promise<GraphicalEditingScope> {\r\n if (this._editingScope)\r\n throw new Error(\"Cannot create an editing scope for an iModel that already has one\");\r\n\r\n this._editingScope = await GraphicalEditingScope.enter(this._briefcase);\r\n\r\n const removeGeomListener = this._editingScope.onGeometryChanges.addListener((changes) => {\r\n const modelIds = [];\r\n for (const change of changes)\r\n modelIds.push(change.id);\r\n\r\n this.invalidateScenes(modelIds);\r\n });\r\n\r\n this._editingScope.onExited.addOnce((scope) => {\r\n assert(scope === this._editingScope);\r\n this._editingScope = undefined;\r\n removeGeomListener();\r\n this.processBuffered();\r\n });\r\n\r\n return this._editingScope;\r\n }\r\n\r\n private processBuffered(): void {\r\n const models = this._briefcase.models;\r\n for (const [id, guid] of this._modelIdToGuid) {\r\n const model = models.getLoaded(id)?.asGeometricModel;\r\n if (model)\r\n model.geometryGuid = guid;\r\n }\r\n\r\n const modelIds = new Set<string>(this._modelIdToGuid.keys());\r\n for (const deleted of this._deletedModels) {\r\n modelIds.add(deleted);\r\n models.unload(deleted);\r\n }\r\n\r\n this.invalidateScenes(modelIds);\r\n disposeTileTreesForGeometricModels(modelIds, this._briefcase);\r\n\r\n this._briefcase.onBufferedModelChanges.raiseEvent(modelIds);\r\n\r\n this._modelIdToGuid.clear();\r\n this._deletedModels.clear();\r\n }\r\n\r\n private invalidateScenes(changedModels: Iterable<Id64String>): void {\r\n for (const user of IModelApp.tileAdmin.tileUsers) {\r\n if (user instanceof Viewport && user.iModel === this._briefcase) {\r\n for (const modelId of changedModels) {\r\n if (user.view.viewsModel(modelId)) {\r\n user.invalidateScene();\r\n user.setFeatureOverrideProviderChanged();\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n}\r\n\r\n/** Settings that can be used to control the behavior of [[Tool]]s that modify a [[BriefcaseConnection]].\r\n * For example, tools that want to create new elements can consult the briefcase's editor tool settings to\r\n * determine into which model and category to insert the elements.\r\n * Specialized tools are free to ignore these settings.\r\n * @see [[BriefcaseConnection.editorToolSettings]] to query or modify the current settings for a briefcase.\r\n * @see [CreateElementTool]($editor-frontend) for an example of a tool that uses these settings.\r\n * @alpha\r\n */\r\nexport class BriefcaseEditorToolSettings {\r\n private _category?: Id64String;\r\n private _model?: Id64String;\r\n\r\n /** An event raised just after the default [[category]] is changed. */\r\n public readonly onCategoryChanged = new BeEvent<(previousCategory: Id64String | undefined) => void>();\r\n\r\n /** An event raised just after the default [[model]] is changed. */\r\n public readonly onModelChanged = new BeEvent<(previousModel: Id64String | undefined) => void>();\r\n\r\n /** The [Category]($backend) into which new elements should be inserted by default.\r\n * Specialized tools are free to ignore this setting and instead use their own logic to select an appropriate category.\r\n * @see [[onCategoryChanged]] to be notified when this property is modified.\r\n * @see [CreateElementTool.targetCategory]($editor-frontend) for an example of a tool that uses this setting.\r\n */\r\n public get category(): Id64String | undefined {\r\n return this._category;\r\n }\r\n public set category(category: Id64String | undefined) {\r\n const previousCategory = this.category;\r\n if (category !== this.category) {\r\n this._category = category;\r\n this.onCategoryChanged.raiseEvent(previousCategory);\r\n }\r\n }\r\n\r\n /** The [Model]($backend) into which new elements should be inserted by default.\r\n * Specialized tools are free to ignore this setting and instead use their own logic to select an appropriate model.\r\n * @see [[onModelChanged]] to be notified when this property is modified.\r\n * @see [CreateElementTool.targetModel]($editor-frontend) for an example of a tool that uses this setting.\r\n */\r\n public get model(): Id64String | undefined {\r\n return this._model;\r\n }\r\n public set model(model: Id64String | undefined) {\r\n const previousModel = this.model;\r\n if (model !== this.model) {\r\n this._model = model;\r\n this.onModelChanged.raiseEvent(previousModel);\r\n }\r\n }\r\n}\r\n\r\n/** A connection to an editable briefcase on the backend. This class uses [Ipc]($docs/learning/IpcInterface.md) to communicate\r\n * to the backend and may only be used by [[IpcApp]]s.\r\n * @public\r\n */\r\nexport class BriefcaseConnection extends IModelConnection {\r\n protected _isClosed?: boolean;\r\n private readonly _modelsMonitor: ModelChangeMonitor;\r\n /** Default settings that can be used to control the behavior of [[Tool]]s that modify this briefcase.\r\n * @alpha\r\n */\r\n public readonly editorToolSettings = new BriefcaseEditorToolSettings();\r\n\r\n /** Manages local changes to the briefcase via [Txns]($docs/learning/InteractiveEditing.md). */\r\n public readonly txns: BriefcaseTxns;\r\n\r\n /** @internal */\r\n public override isBriefcaseConnection(): this is BriefcaseConnection { return true; }\r\n\r\n /** The Guid that identifies the iTwin that owns this iModel. */\r\n public override get iTwinId(): GuidString { return super.iTwinId!; } // GuidString | undefined for IModelConnection, but required for BriefcaseConnection\r\n\r\n /** The Guid that identifies this iModel. */\r\n public override get iModelId(): GuidString { return super.iModelId!; } // GuidString | undefined for IModelConnection, but required for BriefcaseConnection\r\n\r\n protected constructor(props: IModelConnectionProps, openMode: OpenMode) {\r\n super(props);\r\n this._openMode = openMode;\r\n this.txns = new BriefcaseTxns(this);\r\n this._modelsMonitor = new ModelChangeMonitor(this);\r\n }\r\n\r\n /** Open a BriefcaseConnection to a [BriefcaseDb]($backend). */\r\n public static async openFile(briefcaseProps: OpenBriefcaseProps): Promise<BriefcaseConnection> {\r\n const iModelProps = await IpcApp.appFunctionIpc.openBriefcase(briefcaseProps);\r\n const connection = new this({ ...briefcaseProps, ...iModelProps }, briefcaseProps.readonly ? OpenMode.Readonly : OpenMode.ReadWrite);\r\n IModelConnection.onOpen.raiseEvent(connection);\r\n return connection;\r\n }\r\n\r\n /** Open a BriefcaseConnection to a [StandaloneDb]($backend)\r\n * @note StandaloneDbs, by definition, may not push or pull changes. Attempting to do so will throw exceptions.\r\n */\r\n public static async openStandalone(filePath: string, openMode: OpenMode = OpenMode.ReadWrite, opts?: StandaloneOpenOptions): Promise<BriefcaseConnection> {\r\n const openResponse = await IpcApp.appFunctionIpc.openStandalone(filePath, openMode, opts);\r\n const connection = new this(openResponse, openMode);\r\n IModelConnection.onOpen.raiseEvent(connection);\r\n return connection;\r\n }\r\n\r\n /** Returns `true` if [[close]] has already been called. */\r\n public get isClosed(): boolean { return this._isClosed === true; }\r\n\r\n /**\r\n * Close this BriefcaseConnection.\r\n * @note make sure to call [[saveChanges]] before calling this method. Unsaved local changes are abandoned.\r\n */\r\n public async close(): Promise<void> {\r\n if (this.isClosed)\r\n return;\r\n\r\n await this._modelsMonitor.close();\r\n\r\n this.beforeClose();\r\n this.txns.dispose();\r\n\r\n this._isClosed = true;\r\n await IpcApp.appFunctionIpc.closeIModel(this._fileKey);\r\n }\r\n\r\n private requireTimeline() {\r\n if (this.iTwinId === Guid.empty)\r\n throw new IModelError(IModelStatus.WrongIModel, \"iModel has no timeline\");\r\n }\r\n\r\n /** Query if there are any pending Txns in this briefcase that are waiting to be pushed. */\r\n public async hasPendingTxns(): Promise<boolean> { // eslint-disable-line @itwin/prefer-get\r\n return this.txns.hasPendingTxns();\r\n }\r\n\r\n /** Commit pending changes to this briefcase.\r\n * @param description Optional description of the changes.\r\n */\r\n public async saveChanges(description?: string): Promise<void> {\r\n await IpcApp.appFunctionIpc.saveChanges(this.key, description);\r\n }\r\n\r\n /** Pull (and potentially merge if there are local changes) up to a specified changeset from iModelHub into this briefcase\r\n * @param toIndex The changeset index to pull changes to. If `undefined`, pull all changes.\r\n * @param options Options for pulling changes.\r\n * @see [[BriefcaseTxns.onChangesPulled]] for the event dispatched after changes are pulled.\r\n */\r\n public async pullChanges(toIndex?: ChangesetIndex, options?: PullChangesOptions): Promise<void> {\r\n const removeListeners: VoidFunction[] = [];\r\n if (options?.progressCallback) {\r\n const removeProgressListener = IpcApp.addListener(\r\n getPullChangesIpcChannel(this.iModelId),\r\n (_evt: Event, data: { loaded: number, total: number }) => options?.progressCallback?.(data),\r\n );\r\n removeListeners.push(removeProgressListener);\r\n }\r\n if (options?.abortSignal) {\r\n const abort = () => void IpcApp.appFunctionIpc.cancelPullChangesRequest(this.key);\r\n options?.abortSignal.addEventListener(\"abort\", abort);\r\n removeListeners.push(() => options?.abortSignal?.removeEventListener(\"abort\", abort));\r\n }\r\n\r\n this.requireTimeline();\r\n const ipcAppOptions: IpcAppPullChangesOptions = {\r\n reportProgress: !!options?.progressCallback,\r\n progressInterval: options?.progressInterval,\r\n enableCancellation: !!options?.abortSignal,\r\n };\r\n try {\r\n this.changeset = await IpcApp.appFunctionIpc.pullChanges(this.key, toIndex, ipcAppOptions);\r\n } finally {\r\n removeListeners.forEach((remove) => remove());\r\n }\r\n }\r\n\r\n /** Create a changeset from local Txns and push to iModelHub. On success, clear Txn table.\r\n * @param description The description for the changeset\r\n * @returns the changesetId of the pushed changes\r\n * @see [[BriefcaseTxns.onChangesPushed]] for the event dispatched after changes are pushed.\r\n */\r\n public async pushChanges(description: string): Promise<ChangesetIndexAndId> {\r\n this.requireTimeline();\r\n return IpcApp.appFunctionIpc.pushChanges(this.key, description);\r\n }\r\n\r\n /** The current graphical editing scope, if one is in progress.\r\n * @see [[enterEditingScope]] to begin graphical editing.\r\n */\r\n public get editingScope(): GraphicalEditingScope | undefined {\r\n return this._modelsMonitor.editingScope;\r\n }\r\n\r\n /** Return whether graphical editing is supported for this briefcase. It is not supported if the briefcase is read-only, or the briefcase contains a version of\r\n * the BisCore ECSchema older than v0.1.11.\r\n * @see [[enterEditingScope]] to enable graphical editing.\r\n */\r\n public async supportsGraphicalEditing(): Promise<boolean> {\r\n return IpcApp.appFunctionIpc.isGraphicalEditingSupported(this.key);\r\n }\r\n\r\n /** Begin a new graphical editing scope.\r\n * @throws Error if an editing scope already exists or one could not be created.\r\n * @see [[GraphicalEditingScope.exit]] to exit the scope.\r\n * @see [[supportsGraphicalEditing]] to determine whether this method should be expected to succeed.\r\n * @see [[editingScope]] to obtain the current editing scope, if one is in progress.\r\n */\r\n public async enterEditingScope(): Promise<GraphicalEditingScope> {\r\n return this._modelsMonitor.enterEditingScope();\r\n }\r\n\r\n /** Strictly for tests - dispatched from ModelChangeMonitor.processBuffered.\r\n * @internal\r\n */\r\n public readonly onBufferedModelChanges = new BeEvent<(changedModelIds: Set<string>) => void>();\r\n}\r\n"]}
@@ -71,6 +71,12 @@ export declare class IpcApp {
71
71
  * @param channelName the channel registered by the backend handler.
72
72
  */
73
73
  static makeIpcProxy<K>(channelName: string): PickAsyncMethods<K>;
74
+ /** Create a type safe Proxy object to call an IPC function on a of registered backend handler that accepts a "methodName" argument followed by optional arguments
75
+ * @param channelName the channel registered by the backend handler.
76
+ * @param functionName the function to call on the handler.
77
+ * @internal
78
+ */
79
+ static makeIpcFunctionProxy<K>(channelName: string, functionName: string): PickAsyncMethods<K>;
74
80
  /** @deprecated use [[appFunctionIpc]] */
75
81
  static callIpcHost<T extends AsyncMethodsOf<IpcAppFunctions>>(methodName: T, ...args: Parameters<IpcAppFunctions[T]>): Promise<PromiseReturnType<IpcAppFunctions[T]>>;
76
82
  /** A Proxy to call one of the [IpcAppFunctions]($common) functions via IPC. */
@@ -1 +1 @@
1
- {"version":3,"file":"IpcApp.d.ts","sourceRoot":"","sources":["../../src/IpcApp.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC1F,OAAO,EACmD,eAAe,EAAwC,WAAW,EAAE,iBAAiB,EAC/H,cAAc,EAC7B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAa,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE1D;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,SAAS,CAAC,EAAE,gBAAgB,CAAC;CAC9B;AAED;;;GAGG;AACH,qBAAa,MAAM;IACjB,OAAO,CAAC,MAAM,CAAC,IAAI,CAAgC;IACnD,qEAAqE;IAErE,OAAO,CAAC,MAAM,KAAK,GAAG,GAA4C;IAElE,iIAAiI;IACjI,WAAkB,OAAO,IAAI,OAAO,CAAoC;IAExE;;;;;;;OAOG;WACW,WAAW,CAAC,OA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CAAC,eAAe,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,UAAU,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IAIjI,+EAA+E;IAC/E,OAAc,cAAc,oCAAiE;IAE7F;qFACiF;WAC7D,OAAO,CAAC,GAAG,EAAE,iBAAiB,EAAE,IAAI,CAAC,EAAE,aAAa;IAMxE,gBAAgB;WACI,QAAQ;CAI7B;AAED;;;;;;;;;;;;;GAaG;AACH,8BAAsB,mBAAmB;IACvC,wFAAwF;IACxF,aAAoB,WAAW,IAAI,MAAM,CAAC;IAEnC,YAAY,IAAI,cAAc;IAUrC;;;;;OAKG;WACW,QAAQ,IAAI,cAAc;CAGzC"}
package/lib/esm/IpcApp.js CHANGED
@@ -88,6 +88,18 @@ export class IpcApp {
88
88
  },
89
89
  });
90
90
  }
91
+ /** Create a type safe Proxy object to call an IPC function on a of registered backend handler that accepts a "methodName" argument followed by optional arguments
92
+ * @param channelName the channel registered by the backend handler.
93
+ * @param functionName the function to call on the handler.
94
+ * @internal
95
+ */
96
+ static makeIpcFunctionProxy(channelName, functionName) {
97
+ return new Proxy({}, {
98
+ get(_target, methodName) {
99
+ return async (...args) => IpcApp.callIpcChannel(channelName, functionName, methodName, ...args);
100
+ },
101
+ });
102
+ }
91
103
  /** @deprecated use [[appFunctionIpc]] */
92
104
  static async callIpcHost(methodName, ...args) {
93
105
  return this.callIpcChannel(IpcAppChannel.Functions, methodName, ...args);
@@ -1 +1 @@
1
- {"version":3,"file":"IpcApp.js","sourceRoot":"","sources":["../../src/IpcApp.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAGH,OAAO,EACL,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EACtD,YAAY,GACb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAoB,MAAM,aAAa,CAAC;AAU1D;;;GAGG;AACH,MAAM,OAAO,MAAM;IAEjB,qEAAqE;IAE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S,CAAC,CAAC;AAiB/F;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAgB,mBAAmB;IAIhC,YAAY;QACjB,OAAO,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,IAAW,EAAE,QAAgB,EAAE,GAAG,IAAW,EAAE,EAAE;YAC5F,MAAM,IAAI,GAAI,IAAY,CAAC,QAAQ,CAAC,CAAC;YACrC,IAAI,OAAO,IAAI,KAAK,UAAU;gBAC5B,MAAM,IAAI,WAAW,CAAC,YAAY,CAAC,gBAAgB,EAAE,WAAW,IAAI,CAAC,WAAW,CAAC,IAAI,IAAI,QAAQ,8DAA8D,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;YAErL,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC;QAC3B,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,QAAQ;QACpB,OAAQ,IAAK,IAAY,EAA0B,CAAC,YAAY,EAAE,CAAC,CAAC,uFAAuF;IAC7J,CAAC;CACF;AAED,wCAAwC;AACxC,MAAM,mBAAoB,SAAQ,mBAAmB;IACnD,IAAW,WAAW,KAAK,OAAO,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC;IACrD,SAAS,KAAK,CAAC;CACvB","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 NativeApp\r\n */\r\n\r\nimport { AsyncMethodsOf, PickAsyncMethods, PromiseReturnType } from \"@itwin/core-bentley\";\r\nimport {\r\n BackendError, IModelError, IModelStatus, IpcAppChannel, IpcAppFunctions, IpcAppNotifications, IpcInvokeReturn, IpcListener, IpcSocketFrontend,\r\n iTwinChannel, RemoveFunction,\r\n} from \"@itwin/core-common\";\r\nimport { IModelApp, IModelAppOptions } from \"./IModelApp\";\r\n\r\n/**\r\n * Options for [[IpcApp.startup]]\r\n * @public\r\n */\r\nexport interface IpcAppOptions {\r\n iModelApp?: IModelAppOptions;\r\n}\r\n\r\n/**\r\n * The frontend of apps with a dedicated backend that can use [Ipc]($docs/learning/IpcInterface.md).\r\n * @public\r\n */\r\nexport class IpcApp {\r\n private static _ipc: IpcSocketFrontend | undefined;\r\n /** Get the implementation of the [[IpcSocketFrontend]] interface. */\r\n\r\n private static get ipc(): IpcSocketFrontend { return this._ipc!; }\r\n\r\n /** Determine whether Ipc is available for this frontend. This will only be true if [[startup]] has been called on this class. */\r\n public static get isValid(): boolean { return undefined !== this._ipc; }\r\n\r\n /**\r\n * Establish a message handler function for the supplied channel over Ipc. The handler will be called when messages are sent for\r\n * the channel via [[BackendIpc.send]].\r\n * @param channel the name of the channel\r\n * @param handler the message handler\r\n * @returns A function to remove the handler\r\n * @note Ipc is only supported if [[isValid]] is true.\r\n */\r\n public static addListener(channel: string, handler: IpcListener): RemoveFunction {\r\n return this.ipc.addListener(iTwinChannel(channel), handler);\r\n }\r\n\r\n /**\r\n * Remove a previously registered listener\r\n * @param channel The name of the channel for the listener previously registered with [[addListener]]\r\n * @param listener The function passed to [[addListener]]\r\n */\r\n public static removeListener(channel: string, listener: IpcListener) {\r\n this.ipc.removeListener(iTwinChannel(channel), listener);\r\n }\r\n\r\n /**\r\n * Send a message to the backend via `channel` and expect a result asynchronously. The handler must be established on the backend via [[BackendIpc.handle]]\r\n * @param channel The name of the channel for the method.\r\n * @see Electron [ipcRenderer.invoke](https://www.electronjs.org/docs/api/ipc-renderer) documentation for details.\r\n * Note that this interface may be implemented via Electron for desktop apps, or via\r\n * [WebSockets](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API) for mobile or web-based\r\n * Ipc connections. In either case, the Electron documentation provides the specifications for how it works.\r\n * @note `args` are serialized with the [Structured Clone Algorithm](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm), so only\r\n * primitive types and `ArrayBuffers` are allowed.\r\n */\r\n public static async invoke(channel: string, ...args: any[]): Promise<any> {\r\n return this.ipc.invoke(iTwinChannel(channel), ...args);\r\n }\r\n\r\n /**\r\n * Send a message over the socket.\r\n * @param channel The name of the channel for the message.\r\n * @param data The optional data of the message.\r\n * @note `data` is serialized with the [Structured Clone Algorithm](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm), so only\r\n * primitive types and `ArrayBuffers` are allowed.\r\n */\r\n public static send(channel: string, ...data: any[]) {\r\n return this.ipc.send(iTwinChannel(channel), ...data);\r\n }\r\n\r\n /**\r\n * Call a method on the backend through an Ipc channel.\r\n * @param channelName the channel registered by the backend handler.\r\n * @param methodName the name of a method implemented by the backend handler.\r\n * @param args arguments to `methodName`\r\n * @return a Promise with the return value from `methodName`\r\n * @note If the backend implementation throws an exception, this method will throw a [[BackendError]] exception\r\n * with the `errorNumber` and `message` from the backend.\r\n * @note Ipc is only supported if [[isValid]] is true.\r\n * @internal\r\n */\r\n public static async callIpcChannel(channelName: string, methodName: string, ...args: any[]): Promise<any> {\r\n const retVal = (await this.invoke(channelName, methodName, ...args)) as IpcInvokeReturn;\r\n if (undefined !== retVal.error) {\r\n const err = new BackendError(retVal.error.errorNumber, retVal.error.name, retVal.error.message);\r\n err.stack = retVal.error.stack;\r\n throw err;\r\n }\r\n return retVal.result;\r\n }\r\n\r\n /** Create a type safe Proxy object to make IPC calls to a registered backend interface.\r\n * @param channelName the channel registered by the backend handler.\r\n */\r\n public static makeIpcProxy<K>(channelName: string): PickAsyncMethods<K> {\r\n return new Proxy({} as PickAsyncMethods<K>, {\r\n get(_target, methodName: string) {\r\n return async (...args: any[]) =>\r\n IpcApp.callIpcChannel(channelName, methodName, ...args);\r\n },\r\n });\r\n }\r\n\r\n /** @deprecated use [[appFunctionIpc]] */\r\n public static async callIpcHost<T extends AsyncMethodsOf<IpcAppFunctions>>(methodName: T, ...args: Parameters<IpcAppFunctions[T]>) {\r\n return this.callIpcChannel(IpcAppChannel.Functions, methodName, ...args) as PromiseReturnType<IpcAppFunctions[T]>;\r\n }\r\n\r\n /** A Proxy to call one of the [IpcAppFunctions]($common) functions via IPC. */\r\n public static appFunctionIpc = IpcApp.makeIpcProxy<IpcAppFunctions>(IpcAppChannel.Functions);\r\n\r\n /** start an IpcApp.\r\n * @note this should not be called directly. It is called by NativeApp.startup */\r\n public static async startup(ipc: IpcSocketFrontend, opts?: IpcAppOptions) {\r\n this._ipc = ipc;\r\n IpcAppNotifyHandler.register(); // receives notifications from backend\r\n await IModelApp.startup(opts?.iModelApp);\r\n }\r\n\r\n /** @internal */\r\n public static async shutdown() {\r\n this._ipc = undefined;\r\n await IModelApp.shutdown();\r\n }\r\n}\r\n\r\n/**\r\n * Base class for all implementations of an Ipc notification response interface. This class is implemented on your frontend to supply\r\n * methods to receive notifications from your backend.\r\n *\r\n * Create a subclass to implement your Ipc response interface. Your class should be declared like this:\r\n * ```ts\r\n * class MyNotificationHandler extends NotificationHandler implements MyNotifications\r\n * ```\r\n * to ensure all method names and signatures are correct. Your methods cannot have a return value.\r\n *\r\n * Then, call `MyNotificationHandler.register` at startup to connect your class to your channel.\r\n * @public\r\n * @extensions\r\n */\r\nexport abstract class NotificationHandler {\r\n /** All subclasses must implement this method to specify their response channel name. */\r\n public abstract get channelName(): string;\r\n\r\n public registerImpl(): RemoveFunction {\r\n return IpcApp.addListener(this.channelName, (_evt: Event, funcName: string, ...args: any[]) => {\r\n const func = (this as any)[funcName];\r\n if (typeof func !== \"function\")\r\n throw new IModelError(IModelStatus.FunctionNotFound, `Method \"${this.constructor.name}.${funcName}\" not found on NotificationHandler registered for channel: ${this.channelName}`);\r\n\r\n func.call(this, ...args);\r\n });\r\n }\r\n\r\n /**\r\n * Register this class as the handler for notifications on its channel. This static method creates a new instance\r\n * that becomes the notification handler and is `this` when its methods are called.\r\n * @returns A function that can be called to remove the handler.\r\n * @note this method should only be called once per channel. If it is called multiple times, multiple handlers are established.\r\n */\r\n public static register(): RemoveFunction {\r\n return (new (this as any)() as NotificationHandler).registerImpl(); // create an instance of subclass. \"as any\" is necessary because base class is abstract\r\n }\r\n}\r\n\r\n/** IpcApp notifications from backend */\r\nclass IpcAppNotifyHandler extends NotificationHandler implements IpcAppNotifications {\r\n public get channelName() { return IpcAppChannel.AppNotify; }\r\n public notifyApp() { }\r\n}\r\n"]}
1
+ {"version":3,"file":"IpcApp.js","sourceRoot":"","sources":["../../src/IpcApp.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAGH,OAAO,EACL,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EACtD,YAAY,GACb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAoB,MAAM,aAAa,CAAC;AAU1D;;;GAGG;AACH,MAAM,OAAO,MAAM;IAEjB,qEAAqE;IAE7D,MAAM,KAAK,GAAG,KAAwB,OAAO,IAAI,CAAC,IAAK,CAAC,CAAC,CAAC;IAElE,iIAAiI;IAC1H,MAAM,KAAK,OAAO,KAAc,OAAO,SAAS,KAAK,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAExE;;;;;;;OAOG;IACI,MAAM,CAAC,WAAW,CAAC,OAAe,EAAE,OAAoB;QAC7D,OAAO,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;IAC9D,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,cAAc,CAAC,OAAe,EAAE,QAAqB;QACjE,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,CAAC;IAC3D,CAAC;IAED;;;;;;;;;OASG;IACI,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,OAAe,EAAE,GAAG,IAAW;QACxD,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,G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E,WAAW,IAAI,CAAC,WAAW,CAAC,IAAI,IAAI,QAAQ,8DAA8D,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;YAErL,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC;QAC3B,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,QAAQ;QACpB,OAAQ,IAAK,IAAY,EAA0B,CAAC,YAAY,EAAE,CAAC,CAAC,uFAAuF;IAC7J,CAAC;CACF;AAED,wCAAwC;AACxC,MAAM,mBAAoB,SAAQ,mBAAmB;IACnD,IAAW,WAAW,KAAK,OAAO,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC;IACrD,SAAS,KAAK,CAAC;CACvB","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 NativeApp\r\n */\r\n\r\nimport { AsyncMethodsOf, PickAsyncMethods, PromiseReturnType } from \"@itwin/core-bentley\";\r\nimport {\r\n BackendError, IModelError, IModelStatus, IpcAppChannel, IpcAppFunctions, IpcAppNotifications, IpcInvokeReturn, IpcListener, IpcSocketFrontend,\r\n iTwinChannel, RemoveFunction,\r\n} from \"@itwin/core-common\";\r\nimport { IModelApp, IModelAppOptions } from \"./IModelApp\";\r\n\r\n/**\r\n * Options for [[IpcApp.startup]]\r\n * @public\r\n */\r\nexport interface IpcAppOptions {\r\n iModelApp?: IModelAppOptions;\r\n}\r\n\r\n/**\r\n * The frontend of apps with a dedicated backend that can use [Ipc]($docs/learning/IpcInterface.md).\r\n * @public\r\n */\r\nexport class IpcApp {\r\n private static _ipc: IpcSocketFrontend | undefined;\r\n /** Get the implementation of the [[IpcSocketFrontend]] interface. */\r\n\r\n private static get ipc(): IpcSocketFrontend { return this._ipc!; }\r\n\r\n /** Determine whether Ipc is available for this frontend. This will only be true if [[startup]] has been called on this class. */\r\n public static get isValid(): boolean { return undefined !== this._ipc; }\r\n\r\n /**\r\n * Establish a message handler function for the supplied channel over Ipc. The handler will be called when messages are sent for\r\n * the channel via [[BackendIpc.send]].\r\n * @param channel the name of the channel\r\n * @param handler the message handler\r\n * @returns A function to remove the handler\r\n * @note Ipc is only supported if [[isValid]] is true.\r\n */\r\n public static addListener(channel: string, handler: IpcListener): RemoveFunction {\r\n return this.ipc.addListener(iTwinChannel(channel), handler);\r\n }\r\n\r\n /**\r\n * Remove a previously registered listener\r\n * @param channel The name of the channel for the listener previously registered with [[addListener]]\r\n * @param listener The function passed to [[addListener]]\r\n */\r\n public static removeListener(channel: string, listener: IpcListener) {\r\n this.ipc.removeListener(iTwinChannel(channel), listener);\r\n }\r\n\r\n /**\r\n * Send a message to the backend via `channel` and expect a result asynchronously. The handler must be established on the backend via [[BackendIpc.handle]]\r\n * @param channel The name of the channel for the method.\r\n * @see Electron [ipcRenderer.invoke](https://www.electronjs.org/docs/api/ipc-renderer) documentation for details.\r\n * Note that this interface may be implemented via Electron for desktop apps, or via\r\n * [WebSockets](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API) for mobile or web-based\r\n * Ipc connections. In either case, the Electron documentation provides the specifications for how it works.\r\n * @note `args` are serialized with the [Structured Clone Algorithm](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm), so only\r\n * primitive types and `ArrayBuffers` are allowed.\r\n */\r\n public static async invoke(channel: string, ...args: any[]): Promise<any> {\r\n return this.ipc.invoke(iTwinChannel(channel), ...args);\r\n }\r\n\r\n /**\r\n * Send a message over the socket.\r\n * @param channel The name of the channel for the message.\r\n * @param data The optional data of the message.\r\n * @note `data` is serialized with the [Structured Clone Algorithm](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm), so only\r\n * primitive types and `ArrayBuffers` are allowed.\r\n */\r\n public static send(channel: string, ...data: any[]) {\r\n return this.ipc.send(iTwinChannel(channel), ...data);\r\n }\r\n\r\n /**\r\n * Call a method on the backend through an Ipc channel.\r\n * @param channelName the channel registered by the backend handler.\r\n * @param methodName the name of a method implemented by the backend handler.\r\n * @param args arguments to `methodName`\r\n * @return a Promise with the return value from `methodName`\r\n * @note If the backend implementation throws an exception, this method will throw a [[BackendError]] exception\r\n * with the `errorNumber` and `message` from the backend.\r\n * @note Ipc is only supported if [[isValid]] is true.\r\n * @internal\r\n */\r\n public static async callIpcChannel(channelName: string, methodName: string, ...args: any[]): Promise<any> {\r\n const retVal = (await this.invoke(channelName, methodName, ...args)) as IpcInvokeReturn;\r\n if (undefined !== retVal.error) {\r\n const err = new BackendError(retVal.error.errorNumber, retVal.error.name, retVal.error.message);\r\n err.stack = retVal.error.stack;\r\n throw err;\r\n }\r\n return retVal.result;\r\n }\r\n\r\n /** Create a type safe Proxy object to make IPC calls to a registered backend interface.\r\n * @param channelName the channel registered by the backend handler.\r\n */\r\n public static makeIpcProxy<K>(channelName: string): PickAsyncMethods<K> {\r\n return new Proxy({} as PickAsyncMethods<K>, {\r\n get(_target, methodName: string) {\r\n return async (...args: any[]) =>\r\n IpcApp.callIpcChannel(channelName, methodName, ...args);\r\n },\r\n });\r\n }\r\n\r\n /** Create a type safe Proxy object to call an IPC function on a of registered backend handler that accepts a \"methodName\" argument followed by optional arguments\r\n * @param channelName the channel registered by the backend handler.\r\n * @param functionName the function to call on the handler.\r\n * @internal\r\n */\r\n public static makeIpcFunctionProxy<K>(channelName: string, functionName: string): PickAsyncMethods<K> {\r\n return new Proxy({} as PickAsyncMethods<K>, {\r\n get(_target, methodName: string) {\r\n return async (...args: any[]) =>\r\n IpcApp.callIpcChannel(channelName, functionName, methodName, ...args);\r\n },\r\n });\r\n }\r\n\r\n /** @deprecated use [[appFunctionIpc]] */\r\n public static async callIpcHost<T extends AsyncMethodsOf<IpcAppFunctions>>(methodName: T, ...args: Parameters<IpcAppFunctions[T]>) {\r\n return this.callIpcChannel(IpcAppChannel.Functions, methodName, ...args) as PromiseReturnType<IpcAppFunctions[T]>;\r\n }\r\n\r\n /** A Proxy to call one of the [IpcAppFunctions]($common) functions via IPC. */\r\n public static appFunctionIpc = IpcApp.makeIpcProxy<IpcAppFunctions>(IpcAppChannel.Functions);\r\n\r\n /** start an IpcApp.\r\n * @note this should not be called directly. It is called by NativeApp.startup */\r\n public static async startup(ipc: IpcSocketFrontend, opts?: IpcAppOptions) {\r\n this._ipc = ipc;\r\n IpcAppNotifyHandler.register(); // receives notifications from backend\r\n await IModelApp.startup(opts?.iModelApp);\r\n }\r\n\r\n /** @internal */\r\n public static async shutdown() {\r\n this._ipc = undefined;\r\n await IModelApp.shutdown();\r\n }\r\n}\r\n\r\n/**\r\n * Base class for all implementations of an Ipc notification response interface. This class is implemented on your frontend to supply\r\n * methods to receive notifications from your backend.\r\n *\r\n * Create a subclass to implement your Ipc response interface. Your class should be declared like this:\r\n * ```ts\r\n * class MyNotificationHandler extends NotificationHandler implements MyNotifications\r\n * ```\r\n * to ensure all method names and signatures are correct. Your methods cannot have a return value.\r\n *\r\n * Then, call `MyNotificationHandler.register` at startup to connect your class to your channel.\r\n * @public\r\n * @extensions\r\n */\r\nexport abstract class NotificationHandler {\r\n /** All subclasses must implement this method to specify their response channel name. */\r\n public abstract get channelName(): string;\r\n\r\n public registerImpl(): RemoveFunction {\r\n return IpcApp.addListener(this.channelName, (_evt: Event, funcName: string, ...args: any[]) => {\r\n const func = (this as any)[funcName];\r\n if (typeof func !== \"function\")\r\n throw new IModelError(IModelStatus.FunctionNotFound, `Method \"${this.constructor.name}.${funcName}\" not found on NotificationHandler registered for channel: ${this.channelName}`);\r\n\r\n func.call(this, ...args);\r\n });\r\n }\r\n\r\n /**\r\n * Register this class as the handler for notifications on its channel. This static method creates a new instance\r\n * that becomes the notification handler and is `this` when its methods are called.\r\n * @returns A function that can be called to remove the handler.\r\n * @note this method should only be called once per channel. If it is called multiple times, multiple handlers are established.\r\n */\r\n public static register(): RemoveFunction {\r\n return (new (this as any)() as NotificationHandler).registerImpl(); // create an instance of subclass. \"as any\" is necessary because base class is abstract\r\n }\r\n}\r\n\r\n/** IpcApp notifications from backend */\r\nclass IpcAppNotifyHandler extends NotificationHandler implements IpcAppNotifications {\r\n public get channelName() { return IpcAppChannel.AppNotify; }\r\n public notifyApp() { }\r\n}\r\n"]}
@@ -185,7 +185,7 @@ export declare class System extends RenderSystem implements RenderSystemDebugCon
185
185
  /** Bind the specified texture to the specified unit. This *always* makes the texture *active* */
186
186
  activateTextureCubeMap(unit: TextureUnit, texture: TextureBinding): void;
187
187
  ensureSamplerBound(uniform: UniformHandle, unit: TextureUnit): void;
188
- get maxRealityImageryLayers(): 6 | 3;
188
+ get maxRealityImageryLayers(): 3 | 6;
189
189
  disposeTexture(texture: WebGLTexture): void;
190
190
  enableVertexAttribArray(id: number, instanced: boolean): void;
191
191
  updateVertexAttribArrays(): void;
@@ -253,7 +253,7 @@ export class RealityTileTree extends TileTree {
253
253
  }
254
254
  /** @internal */
255
255
  doReprojectChildren(tile) {
256
- if (!(tile instanceof RealityTile) || !tile.region || this._gcsConverter === undefined || this._rootToEcef === undefined || undefined === this._ecefToDb)
256
+ if (!(tile instanceof RealityTile) || this._gcsConverter === undefined || this._rootToEcef === undefined || undefined === this._ecefToDb)
257
257
  return false;
258
258
  const tileRange = this.iModelTransform.isIdentity ? tile.range : this.iModelTransform.multiplyRange(tile.range, scratchRange);
259
259
  return this.cartesianRange.intersectsRange(tileRange);
@@ -1 +1 @@
1
- {"version":3,"file":"RealityTileTree.js","sourceRoot":"","sources":["../../../src/tile/RealityTileTree.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EACL,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,GAChD,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,YAAY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G,CAAC,KAAK,CAAC;QAC9B,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAkB,CAAC;QAC3C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;YACxB,KAAK,EAAE,CAAC;YACR,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;YACzB,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;YAChC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;YAChC,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YAClC,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;SAC1D;QAED,QAAQ,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,WAAW,IAAI,GAAG,GAAG,IAAI,KAAK,IAAI,CAAC,CAAC;QACrE,sCAAsC;QACtC,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,KAAK,KAAK,SAAS,GAAG,SAAS,GAAG,YAAY,WAAW,EAAE,CAAC,CAAC;IACnF,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, BeTimePoint } from \"@itwin/core-bentley\";\r\nimport {\r\n Matrix3d, Point3d, Range3d, Transform, Vector3d, XYZProps,\r\n} from \"@itwin/core-geometry\";\r\nimport { Cartographic, ColorDef, Frustum, FrustumPlanes, GeoCoordStatus, ViewFlagOverrides } from \"@itwin/core-common\";\r\nimport { BackgroundMapGeometry } from \"../BackgroundMapGeometry\";\r\nimport { GeoConverter } from \"../GeoServices\";\r\nimport { IModelApp } from \"../IModelApp\";\r\nimport { GraphicBranch } from \"../render/GraphicBranch\";\r\nimport { GraphicBuilder } from \"../render/GraphicBuilder\";\r\nimport { SceneContext } from \"../ViewContext\";\r\nimport {\r\n GraphicsCollectorDrawArgs, MapTile, RealityTile, RealityTileDrawArgs, RealityTileLoader, RealityTileParams, Tile, TileDrawArgs, TileGeometryCollector,\r\n TileGraphicType, TileParams, TileTree, TileTreeParams,\r\n} from \"./internal\";\r\n\r\n/** @internal */\r\nexport class TraversalDetails {\r\n public queuedChildren = new Array<Tile>();\r\n public childrenLoading = false;\r\n public childrenSelected = false;\r\n\r\n public initialize() {\r\n this.queuedChildren.length = 0;\r\n this.childrenLoading = false;\r\n this.childrenSelected = false;\r\n }\r\n}\r\n/** @internal */\r\nexport class TraversalChildrenDetails {\r\n private _childDetails: TraversalDetails[] = [];\r\n\r\n public initialize() {\r\n for (const child of this._childDetails)\r\n child.initialize();\r\n }\r\n public getChildDetail(index: number) {\r\n while (this._childDetails.length <= index)\r\n this._childDetails.push(new TraversalDetails());\r\n\r\n return this._childDetails[index];\r\n }\r\n\r\n public combine(parentDetails: TraversalDetails) {\r\n parentDetails.queuedChildren.length = 0;\r\n parentDetails.childrenLoading = false;\r\n parentDetails.childrenSelected = false;\r\n for (const child of this._childDetails) {\r\n parentDetails.childrenLoading = parentDetails.childrenLoading || child.childrenLoading;\r\n parentDetails.childrenSelected = parentDetails.childrenSelected || child.childrenSelected;\r\n for (const queuedChild of child.queuedChildren)\r\n parentDetails.queuedChildren.push(queuedChild);\r\n }\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport class TraversalSelectionContext {\r\n public preloaded = new Set<RealityTile>();\r\n public missing = new Array<RealityTile>();\r\n public get selectionCountExceeded() { return this._maxSelectionCount === undefined ? false : (this.missing.length + this.selected.length) > this._maxSelectionCount; } // Avoid selecting excessive number of tiles.\r\n constructor(public selected: Tile[], public displayedDescendants: Tile[][], public preloadDebugBuilder?: GraphicBuilder, private _maxSelectionCount?: number) { }\r\n\r\n public selectOrQueue(tile: RealityTile, args: TileDrawArgs, traversalDetails: TraversalDetails) {\r\n tile.selectSecondaryTiles(args, this);\r\n tile.markUsed(args);\r\n if (tile.isReady) {\r\n args.markReady(tile);\r\n this.selected.push(tile);\r\n tile.markDisplayed();\r\n this.displayedDescendants.push((traversalDetails.childrenSelected) ? traversalDetails.queuedChildren.slice() : []);\r\n traversalDetails.queuedChildren.length = 0;\r\n traversalDetails.childrenLoading = false;\r\n traversalDetails.childrenSelected = true;\r\n } else if (!tile.isNotFound) {\r\n traversalDetails.queuedChildren.push(tile);\r\n if (!tile.isLoaded)\r\n this.missing.push(tile);\r\n }\r\n }\r\n\r\n public preload(tile: RealityTile, args: TileDrawArgs): void {\r\n if (!this.preloaded.has(tile)) {\r\n if (this.preloadDebugBuilder)\r\n tile.addBoundingGraphic(this.preloadDebugBuilder, ColorDef.red);\r\n\r\n tile.markUsed(args);\r\n tile.selectSecondaryTiles(args, this);\r\n this.preloaded.add(tile);\r\n if (!tile.isNotFound && !tile.isLoaded)\r\n this.missing.push(tile);\r\n }\r\n }\r\n\r\n public select(tiles: RealityTile[], args: TileDrawArgs): void {\r\n for (const tile of tiles) {\r\n tile.markUsed(args);\r\n this.selected.push(tile);\r\n this.displayedDescendants.push([]);\r\n }\r\n }\r\n}\r\n\r\nconst scratchFrustum = new Frustum();\r\nconst scratchFrustumPlanes = new FrustumPlanes();\r\nconst scratchCarto = Cartographic.createZero();\r\nconst scratchPoint = Point3d.createZero(), scratchOrigin = Point3d.createZero();\r\nconst scratchRange = Range3d.createNull();\r\nconst scratchX = Vector3d.createZero(), scratchY = Vector3d.createZero(), scratchZ = Vector3d.createZero();\r\nconst scratchMatrix = Matrix3d.createZero(), scratchTransform = Transform.createZero();\r\n\r\ninterface ChildReprojection {\r\n child: RealityTile;\r\n ecefCenter: Point3d;\r\n dbPoints: Point3d[]; // Center, xEnd, yEnd, zEnd\r\n}\r\n\r\n/** @internal */\r\nexport interface RealityTileTreeParams extends TileTreeParams {\r\n readonly loader: RealityTileLoader;\r\n readonly yAxisUp?: boolean;\r\n readonly rootTile: RealityTileParams;\r\n readonly rootToEcef?: Transform;\r\n readonly gcsConverterAvailable: boolean;\r\n}\r\n\r\n/** Base class for a [[TileTree]] representing a reality model (e.g., a point cloud or photogrammetry mesh) or 3d terrain with map imagery.\r\n * The tiles within the tree are instances of [[RealityTile]]s.\r\n * @beta\r\n */\r\nexport class RealityTileTree extends TileTree {\r\n /** @internal */\r\n public traversalChildrenByDepth: TraversalChildrenDetails[] = [];\r\n /** @internal */\r\n public readonly loader: RealityTileLoader;\r\n /** @internal */\r\n public readonly yAxisUp: boolean;\r\n /** @internal */\r\n public cartesianRange: Range3d;\r\n /** @internal */\r\n public cartesianTransitionDistance: number;\r\n /** @internal */\r\n protected _gcsConverter: GeoConverter | undefined;\r\n /** @internal */\r\n protected _rootTile: RealityTile;\r\n /** @internal */\r\n protected _rootToEcef?: Transform;\r\n /** @internal */\r\n protected _ecefToDb?: Transform;\r\n\r\n /** @internal */\r\n public constructor(params: RealityTileTreeParams) {\r\n super(params);\r\n this.loader = params.loader;\r\n this.yAxisUp = true === params.yAxisUp;\r\n this._rootTile = this.createTile(params.rootTile);\r\n this.cartesianRange = BackgroundMapGeometry.getCartesianRange(this.iModel);\r\n this.cartesianTransitionDistance = this.cartesianRange.diagonal().magnitudeXY() * .25; // Transition distance from elliptical to cartesian.\r\n this._gcsConverter = params.gcsConverterAvailable ? params.iModel.geoServices.getConverter(\"WGS84\") : undefined;\r\n if (params.rootToEcef) {\r\n this._rootToEcef = params.rootToEcef;\r\n const dbToRoot = this.iModelTransform.inverse();\r\n if (dbToRoot) {\r\n const dbToEcef = this._rootToEcef.multiplyTransformTransform(dbToRoot);\r\n this._ecefToDb = dbToEcef.inverse();\r\n }\r\n }\r\n }\r\n\r\n /** @internal */\r\n public get rootTile(): RealityTile { return this._rootTile; }\r\n /** @internal */\r\n public get is3d() { return true; }\r\n /** @internal */\r\n public get maxDepth() { return this.loader.maxDepth; }\r\n /** @internal */\r\n public get minDepth() { return this.loader.minDepth; }\r\n /** @internal */\r\n public override get isContentUnbounded() { return this.loader.isContentUnbounded; }\r\n /** @internal */\r\n public get isTransparent() { return false; }\r\n\r\n /** @internal */\r\n protected _selectTiles(args: TileDrawArgs): Tile[] { return this.selectRealityTiles(args, []); }\r\n /** @internal */\r\n public get viewFlagOverrides(): ViewFlagOverrides { return this.loader.viewFlagOverrides; }\r\n /** @internal */\r\n public override get parentsAndChildrenExclusive() { return this.loader.parentsAndChildrenExclusive; }\r\n\r\n /** @internal */\r\n public createTile(props: TileParams): RealityTile { return new RealityTile(props, this); }\r\n\r\n /** Collect tiles from this tile tree based on the criteria implemented by `collector`.\r\n * @internal\r\n */\r\n public override collectTileGeometry(collector: TileGeometryCollector): void {\r\n this.rootTile.collectTileGeometry(collector);\r\n }\r\n\r\n /** @internal */\r\n public prune(): void {\r\n const olderThan = BeTimePoint.now().minus(this.expirationTime);\r\n this.rootTile.purgeContents(olderThan);\r\n }\r\n\r\n /** @internal */\r\n public draw(args: TileDrawArgs): void {\r\n const displayedTileDescendants = new Array<RealityTile[]>();\r\n const debugControl = args.context.target.debugControl;\r\n const selectBuilder = (debugControl && debugControl.displayRealityTileRanges) ? args.context.createSceneGraphicBuilder() : undefined;\r\n const preloadDebugBuilder = (debugControl && debugControl.displayRealityTilePreload) ? args.context.createSceneGraphicBuilder() : undefined;\r\n const graphicTypeBranches = new Map<TileGraphicType, GraphicBranch>();\r\n\r\n const selectedTiles = this.selectRealityTiles(args, displayedTileDescendants, preloadDebugBuilder);\r\n args.processSelectedTiles(selectedTiles);\r\n let sortIndices;\r\n\r\n if (!this.parentsAndChildrenExclusive) {\r\n sortIndices = selectedTiles.map((_x, i) => i);\r\n sortIndices.sort((a, b) => selectedTiles[a].depth - selectedTiles[b].depth);\r\n }\r\n\r\n if (! (args instanceof GraphicsCollectorDrawArgs))\r\n this.collectClassifierGraphics(args, selectedTiles);\r\n\r\n assert(selectedTiles.length === displayedTileDescendants.length);\r\n for (let i = 0; i < selectedTiles.length; i++) {\r\n const index = sortIndices ? sortIndices[i] : i;\r\n const selectedTile = selectedTiles[index];\r\n const graphics = args.getTileGraphics(selectedTile);\r\n const tileGraphicType = selectedTile.graphicType;\r\n let targetBranch;\r\n if (undefined !== tileGraphicType && tileGraphicType !== args.context.graphicType) {\r\n if (!(targetBranch = graphicTypeBranches.get(tileGraphicType))) {\r\n graphicTypeBranches.set(tileGraphicType, targetBranch = new GraphicBranch(false));\r\n targetBranch.setViewFlagOverrides(args.graphics.viewFlagOverrides);\r\n targetBranch.symbologyOverrides = args.graphics.symbologyOverrides;\r\n }\r\n }\r\n\r\n if (!targetBranch)\r\n targetBranch = args.graphics;\r\n\r\n if (undefined !== graphics) {\r\n const displayedDescendants = displayedTileDescendants[index];\r\n if (0 === displayedDescendants.length || !this.loader.parentsAndChildrenExclusive || selectedTile.allChildrenIncluded(displayedDescendants)) {\r\n targetBranch.add(graphics);\r\n if (selectBuilder)\r\n selectedTile.addBoundingGraphic(selectBuilder, ColorDef.green);\r\n } else {\r\n if (selectBuilder)\r\n selectedTile.addBoundingGraphic(selectBuilder, ColorDef.red);\r\n\r\n for (const displayedDescendant of displayedDescendants) {\r\n const clipVector = displayedDescendant.getContentClip();\r\n if (selectBuilder)\r\n displayedDescendant.addBoundingGraphic(selectBuilder, ColorDef.blue);\r\n\r\n if (undefined === clipVector) {\r\n targetBranch.add(graphics);\r\n } else {\r\n clipVector.transformInPlace(args.location);\r\n if (!this.isTransparent)\r\n for (const primitive of clipVector.clips)\r\n for (const clipPlanes of primitive.fetchClipPlanesRef()!.convexSets)\r\n for (const plane of clipPlanes.planes)\r\n plane.offsetDistance(-displayedDescendant.radius * .05); // Overlap with existing (high resolution) tile slightly to avoid cracks.\r\n\r\n const branch = new GraphicBranch(false);\r\n branch.add(graphics);\r\n const clipVolume = args.context.target.renderSystem.createClipVolume(clipVector);\r\n targetBranch.add(args.context.createGraphicBranch(branch, Transform.createIdentity(), { clipVolume }));\r\n }\r\n }\r\n }\r\n if (preloadDebugBuilder)\r\n targetBranch.add(preloadDebugBuilder.finish());\r\n\r\n if (selectBuilder)\r\n targetBranch.add(selectBuilder.finish());\r\n\r\n const rangeGraphic = selectedTile.getRangeGraphic(args.context);\r\n if (undefined !== rangeGraphic)\r\n targetBranch.add(rangeGraphic);\r\n }\r\n }\r\n\r\n args.drawGraphics();\r\n for (const graphicTypeBranch of graphicTypeBranches) {\r\n args.drawGraphicsWithType(graphicTypeBranch[0], graphicTypeBranch[1]);\r\n }\r\n }\r\n\r\n /** @internal */\r\n protected collectClassifierGraphics(args: TileDrawArgs, selectedTiles: RealityTile[]) {\r\n const classifier = args.context.planarClassifiers.get(this.modelId);\r\n if (classifier)\r\n classifier.collectGraphics(args.context, { modelId: this.modelId, tiles: selectedTiles, location: args.location, isPointCloud: this.isPointCloud });\r\n }\r\n\r\n /** @internal */\r\n public getTraversalChildren(depth: number) {\r\n while (this.traversalChildrenByDepth.length <= depth)\r\n this.traversalChildrenByDepth.push(new TraversalChildrenDetails());\r\n\r\n return this.traversalChildrenByDepth[depth];\r\n }\r\n\r\n /** @internal */\r\n public doReprojectChildren(tile: Tile): boolean {\r\n if (!(tile instanceof RealityTile) || !tile.region || this._gcsConverter === undefined || this._rootToEcef === undefined || undefined === this._ecefToDb)\r\n return false;\r\n\r\n const tileRange = this.iModelTransform.isIdentity ? tile.range : this.iModelTransform.multiplyRange(tile.range, scratchRange);\r\n\r\n return this.cartesianRange.intersectsRange(tileRange);\r\n }\r\n\r\n /** @internal */\r\n public reprojectAndResolveChildren(parent: Tile, children: Tile[], resolve: (children: Tile[] | undefined) => void): void {\r\n if (!this.doReprojectChildren(parent)) {\r\n resolve(children);\r\n return;\r\n }\r\n\r\n const ecefToDb = this._ecefToDb!; // Tested for undefined in doReprojectChildren\r\n const rootToDb = this.iModelTransform;\r\n const dbToEcef = ecefToDb.inverse()!;\r\n const reprojectChildren = new Array<ChildReprojection>();\r\n for (const child of children) {\r\n const realityChild = child as RealityTile;\r\n const childRange = realityChild.rangeCorners ? Range3d.createTransformedArray(rootToDb, realityChild.rangeCorners) : rootToDb.multiplyRange(realityChild.contentRange, scratchRange);\r\n const dbCenter = childRange.center;\r\n const ecefCenter = dbToEcef.multiplyPoint3d(dbCenter);\r\n const dbPoints = [dbCenter, dbCenter.plusXYZ(1), dbCenter.plusXYZ(0, 1), dbCenter.plusXYZ(0, 0, 1)];\r\n reprojectChildren.push({ child: realityChild, ecefCenter, dbPoints });\r\n }\r\n if (reprojectChildren.length === 0)\r\n resolve(children);\r\n else {\r\n const requestProps = new Array<XYZProps>();\r\n\r\n for (const reprojection of reprojectChildren) {\r\n for (const dbPoint of reprojection.dbPoints) {\r\n const ecefPoint = dbToEcef.multiplyPoint3d(dbPoint);\r\n const carto = Cartographic.fromEcef(ecefPoint, scratchCarto);\r\n if (carto)\r\n requestProps.push({ x: carto.longitudeDegrees, y: carto.latitudeDegrees, z: carto.height });\r\n\r\n }\r\n }\r\n\r\n if (requestProps.length !== 4 * reprojectChildren.length)\r\n resolve(children);\r\n else {\r\n this._gcsConverter!.getIModelCoordinatesFromGeoCoordinates(requestProps).then((response) => {\r\n\r\n const reprojectedCoords = response.iModelCoords;\r\n const dbToRoot = rootToDb.inverse()!;\r\n const getReprojectedPoint = (original: Point3d, reprojectedXYZ: XYZProps) => {\r\n scratchPoint.setFromJSON(reprojectedXYZ);\r\n const cartesianDistance = this.cartesianRange.distanceToPoint(scratchPoint);\r\n if (cartesianDistance < this.cartesianTransitionDistance)\r\n return scratchPoint.interpolate(cartesianDistance / this.cartesianTransitionDistance, original, scratchPoint);\r\n else\r\n return original;\r\n };\r\n\r\n let responseIndex = 0;\r\n for (const reprojection of reprojectChildren) {\r\n if (reprojectedCoords.every((coord) => coord.s === GeoCoordStatus.Success)) {\r\n const reprojectedOrigin = getReprojectedPoint(reprojection.dbPoints[0], reprojectedCoords[responseIndex++].p).clone(scratchOrigin);\r\n const xVector = Vector3d.createStartEnd(reprojectedOrigin, getReprojectedPoint(reprojection.dbPoints[1], reprojectedCoords[responseIndex++].p), scratchX);\r\n const yVector = Vector3d.createStartEnd(reprojectedOrigin, getReprojectedPoint(reprojection.dbPoints[2], reprojectedCoords[responseIndex++].p), scratchY);\r\n const zVector = Vector3d.createStartEnd(reprojectedOrigin, getReprojectedPoint(reprojection.dbPoints[3], reprojectedCoords[responseIndex++].p), scratchZ);\r\n const matrix = Matrix3d.createColumns(xVector, yVector, zVector, scratchMatrix);\r\n if (matrix !== undefined) {\r\n const dbReprojection = Transform.createMatrixPickupPutdown(matrix, reprojection.dbPoints[0], reprojectedOrigin, scratchTransform);\r\n if (dbReprojection) {\r\n const rootReprojection = dbToRoot.multiplyTransformTransform(dbReprojection).multiplyTransformTransform(rootToDb);\r\n reprojection.child.reproject(rootReprojection);\r\n }\r\n }\r\n }\r\n }\r\n\r\n resolve(children);\r\n }).catch(() => {\r\n resolve(children); // Error occured in reprojection - just resolve with unprojected corners.\r\n });\r\n }\r\n }\r\n }\r\n\r\n /** @internal */\r\n public getBaseRealityDepth(_sceneContext: SceneContext) { return -1; }\r\n\r\n /** @internal */\r\n public selectRealityTiles(args: TileDrawArgs, displayedDescendants: RealityTile[][], preloadDebugBuilder?: GraphicBuilder): RealityTile[] {\r\n this._lastSelected = BeTimePoint.now();\r\n const selected: RealityTile[] = [];\r\n const context = new TraversalSelectionContext(selected, displayedDescendants, preloadDebugBuilder, args.maxRealityTreeSelectionCount);\r\n const rootTile = this.rootTile;\r\n const debugControl = args.context.target.debugControl;\r\n const freezeTiles = debugControl && debugControl.freezeRealityTiles;\r\n\r\n rootTile.selectRealityTiles(context, args, new TraversalDetails());\r\n\r\n const baseDepth = this.getBaseRealityDepth(args.context);\r\n\r\n if (!args.context.target.renderSystem.isMobile && 0 === context.missing.length) { // We skip preloading on mobile devices.\r\n if (baseDepth > 0) // Maps may force loading of low level globe tiles.\r\n rootTile.preloadRealityTilesAtDepth(baseDepth, context, args);\r\n\r\n if (!freezeTiles)\r\n this.preloadTilesForScene(args, context, undefined);\r\n }\r\n\r\n if (!freezeTiles)\r\n for (const tile of context.missing) {\r\n const loadableTile = tile.loadableTile;\r\n\r\n loadableTile.markUsed(args);\r\n args.insertMissing(loadableTile);\r\n }\r\n\r\n if (debugControl && debugControl.logRealityTiles) {\r\n this.logTiles(\"Selected: \", selected.values());\r\n const preloaded = [];\r\n for (const tile of context.preloaded)\r\n preloaded.push(tile);\r\n\r\n this.logTiles(\"Preloaded: \", preloaded.values());\r\n this.logTiles(\"Missing: \", context.missing.values());\r\n\r\n const imageryTiles: RealityTile[] = [];\r\n for (const selectedTile of selected) {\r\n if (selectedTile instanceof MapTile) {\r\n const selectedImageryTiles = (selectedTile).imageryTiles;\r\n if (selectedImageryTiles)\r\n selectedImageryTiles.forEach((tile) => imageryTiles.push(tile));\r\n }\r\n }\r\n if (imageryTiles.length)\r\n this.logTiles(\"Imagery:\", imageryTiles.values());\r\n }\r\n\r\n IModelApp.tileAdmin.addTilesForUser(args.context.viewport, selected, args.readyTiles);\r\n return selected;\r\n }\r\n\r\n /** @internal */\r\n public preloadTilesForScene(args: TileDrawArgs, context: TraversalSelectionContext, frustumTransform?: Transform) {\r\n const preloadFrustum = args.viewingSpace.getPreloadFrustum(frustumTransform, scratchFrustum);\r\n const preloadFrustumPlanes = new FrustumPlanes(preloadFrustum);\r\n const worldToNpc = preloadFrustum.toMap4d();\r\n const preloadWorldToViewMap = args.viewingSpace.calcNpcToView().multiplyMapMap(worldToNpc!);\r\n const preloadArgs = new RealityTileDrawArgs(args, preloadWorldToViewMap, preloadFrustumPlanes);\r\n\r\n scratchFrustumPlanes.init(preloadFrustum);\r\n if (context.preloadDebugBuilder) {\r\n context.preloadDebugBuilder.setSymbology(ColorDef.blue, ColorDef.blue, 2, 0);\r\n context.preloadDebugBuilder.addFrustum(preloadFrustum);\r\n }\r\n\r\n this.rootTile.preloadTilesInFrustum(preloadArgs, context, 2);\r\n }\r\n\r\n /** @internal */\r\n protected logTiles(label: string, tiles: IterableIterator<Tile>) {\r\n let depthString = \"\";\r\n let min = 10000, max = -10000;\r\n let count = 0;\r\n const depthMap = new Map<number, number>();\r\n for (const tile of tiles) {\r\n count++;\r\n const depth = tile.depth;\r\n min = Math.min(min, tile.depth);\r\n max = Math.max(max, tile.depth);\r\n const found = depthMap.get(depth);\r\n depthMap.set(depth, found === undefined ? 1 : found + 1);\r\n }\r\n\r\n depthMap.forEach((key, value) => depthString += `${key}-${value}, `);\r\n // eslint-disable-next-line no-console\r\n console.log(`${label}: ${count} Min: ${min} Max: ${max} Depths: ${depthString}`);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"RealityTileTree.js","sourceRoot":"","sources":["../../../src/tile/RealityTileTree.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EACL,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,GAChD,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAE,aAAa,EAAE,cAAc,EAAqB,MAAM,oBAAoB,CAAC;AACvH,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAGxD,OAAO,EACL,yBAAyB,EAAE,OAAO,EAAE,WAAW,EAAE,mBAAmB,EACvC,QAAQ,GACtC,MAAM,YAAY,CAAC;AAEpB,gBAAgB;AAChB,MAAM,OAAO,gBAAgB;IAA7B;QACS,mBAAc,GAAG,IAAI,KAAK,EAAQ,CAAC;QACnC,oBAAe,GAAG,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GAAG,CAAC,KAAK,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;SAC1D;QAED,QAAQ,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,WAAW,IAAI,GAAG,GAAG,IAAI,KAAK,IAAI,CAAC,CAAC;QACrE,sCAAsC;QACtC,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,KAAK,KAAK,SAAS,GAAG,SAAS,GAAG,YAAY,WAAW,EAAE,CAAC,CAAC;IACnF,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, BeTimePoint } from \"@itwin/core-bentley\";\r\nimport {\r\n Matrix3d, Point3d, Range3d, Transform, Vector3d, XYZProps,\r\n} from \"@itwin/core-geometry\";\r\nimport { Cartographic, ColorDef, Frustum, FrustumPlanes, GeoCoordStatus, ViewFlagOverrides } from \"@itwin/core-common\";\r\nimport { BackgroundMapGeometry } from \"../BackgroundMapGeometry\";\r\nimport { GeoConverter } from \"../GeoServices\";\r\nimport { IModelApp } from \"../IModelApp\";\r\nimport { GraphicBranch } from \"../render/GraphicBranch\";\r\nimport { GraphicBuilder } from \"../render/GraphicBuilder\";\r\nimport { SceneContext } from \"../ViewContext\";\r\nimport {\r\n GraphicsCollectorDrawArgs, MapTile, RealityTile, RealityTileDrawArgs, RealityTileLoader, RealityTileParams, Tile, TileDrawArgs, TileGeometryCollector,\r\n TileGraphicType, TileParams, TileTree, TileTreeParams,\r\n} from \"./internal\";\r\n\r\n/** @internal */\r\nexport class TraversalDetails {\r\n public queuedChildren = new Array<Tile>();\r\n public childrenLoading = false;\r\n public childrenSelected = false;\r\n\r\n public initialize() {\r\n this.queuedChildren.length = 0;\r\n this.childrenLoading = false;\r\n this.childrenSelected = false;\r\n }\r\n}\r\n/** @internal */\r\nexport class TraversalChildrenDetails {\r\n private _childDetails: TraversalDetails[] = [];\r\n\r\n public initialize() {\r\n for (const child of this._childDetails)\r\n child.initialize();\r\n }\r\n public getChildDetail(index: number) {\r\n while (this._childDetails.length <= index)\r\n this._childDetails.push(new TraversalDetails());\r\n\r\n return this._childDetails[index];\r\n }\r\n\r\n public combine(parentDetails: TraversalDetails) {\r\n parentDetails.queuedChildren.length = 0;\r\n parentDetails.childrenLoading = false;\r\n parentDetails.childrenSelected = false;\r\n for (const child of this._childDetails) {\r\n parentDetails.childrenLoading = parentDetails.childrenLoading || child.childrenLoading;\r\n parentDetails.childrenSelected = parentDetails.childrenSelected || child.childrenSelected;\r\n for (const queuedChild of child.queuedChildren)\r\n parentDetails.queuedChildren.push(queuedChild);\r\n }\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport class TraversalSelectionContext {\r\n public preloaded = new Set<RealityTile>();\r\n public missing = new Array<RealityTile>();\r\n public get selectionCountExceeded() { return this._maxSelectionCount === undefined ? false : (this.missing.length + this.selected.length) > this._maxSelectionCount; } // Avoid selecting excessive number of tiles.\r\n constructor(public selected: Tile[], public displayedDescendants: Tile[][], public preloadDebugBuilder?: GraphicBuilder, private _maxSelectionCount?: number) { }\r\n\r\n public selectOrQueue(tile: RealityTile, args: TileDrawArgs, traversalDetails: TraversalDetails) {\r\n tile.selectSecondaryTiles(args, this);\r\n tile.markUsed(args);\r\n if (tile.isReady) {\r\n args.markReady(tile);\r\n this.selected.push(tile);\r\n tile.markDisplayed();\r\n this.displayedDescendants.push((traversalDetails.childrenSelected) ? traversalDetails.queuedChildren.slice() : []);\r\n traversalDetails.queuedChildren.length = 0;\r\n traversalDetails.childrenLoading = false;\r\n traversalDetails.childrenSelected = true;\r\n } else if (!tile.isNotFound) {\r\n traversalDetails.queuedChildren.push(tile);\r\n if (!tile.isLoaded)\r\n this.missing.push(tile);\r\n }\r\n }\r\n\r\n public preload(tile: RealityTile, args: TileDrawArgs): void {\r\n if (!this.preloaded.has(tile)) {\r\n if (this.preloadDebugBuilder)\r\n tile.addBoundingGraphic(this.preloadDebugBuilder, ColorDef.red);\r\n\r\n tile.markUsed(args);\r\n tile.selectSecondaryTiles(args, this);\r\n this.preloaded.add(tile);\r\n if (!tile.isNotFound && !tile.isLoaded)\r\n this.missing.push(tile);\r\n }\r\n }\r\n\r\n public select(tiles: RealityTile[], args: TileDrawArgs): void {\r\n for (const tile of tiles) {\r\n tile.markUsed(args);\r\n this.selected.push(tile);\r\n this.displayedDescendants.push([]);\r\n }\r\n }\r\n}\r\n\r\nconst scratchFrustum = new Frustum();\r\nconst scratchFrustumPlanes = new FrustumPlanes();\r\nconst scratchCarto = Cartographic.createZero();\r\nconst scratchPoint = Point3d.createZero(), scratchOrigin = Point3d.createZero();\r\nconst scratchRange = Range3d.createNull();\r\nconst scratchX = Vector3d.createZero(), scratchY = Vector3d.createZero(), scratchZ = Vector3d.createZero();\r\nconst scratchMatrix = Matrix3d.createZero(), scratchTransform = Transform.createZero();\r\n\r\ninterface ChildReprojection {\r\n child: RealityTile;\r\n ecefCenter: Point3d;\r\n dbPoints: Point3d[]; // Center, xEnd, yEnd, zEnd\r\n}\r\n\r\n/** @internal */\r\nexport interface RealityTileTreeParams extends TileTreeParams {\r\n readonly loader: RealityTileLoader;\r\n readonly yAxisUp?: boolean;\r\n readonly rootTile: RealityTileParams;\r\n readonly rootToEcef?: Transform;\r\n readonly gcsConverterAvailable: boolean;\r\n}\r\n\r\n/** Base class for a [[TileTree]] representing a reality model (e.g., a point cloud or photogrammetry mesh) or 3d terrain with map imagery.\r\n * The tiles within the tree are instances of [[RealityTile]]s.\r\n * @beta\r\n */\r\nexport class RealityTileTree extends TileTree {\r\n /** @internal */\r\n public traversalChildrenByDepth: TraversalChildrenDetails[] = [];\r\n /** @internal */\r\n public readonly loader: RealityTileLoader;\r\n /** @internal */\r\n public readonly yAxisUp: boolean;\r\n /** @internal */\r\n public cartesianRange: Range3d;\r\n /** @internal */\r\n public cartesianTransitionDistance: number;\r\n /** @internal */\r\n protected _gcsConverter: GeoConverter | undefined;\r\n /** @internal */\r\n protected _rootTile: RealityTile;\r\n /** @internal */\r\n protected _rootToEcef?: Transform;\r\n /** @internal */\r\n protected _ecefToDb?: Transform;\r\n\r\n /** @internal */\r\n public constructor(params: RealityTileTreeParams) {\r\n super(params);\r\n this.loader = params.loader;\r\n this.yAxisUp = true === params.yAxisUp;\r\n this._rootTile = this.createTile(params.rootTile);\r\n this.cartesianRange = BackgroundMapGeometry.getCartesianRange(this.iModel);\r\n this.cartesianTransitionDistance = this.cartesianRange.diagonal().magnitudeXY() * .25; // Transition distance from elliptical to cartesian.\r\n this._gcsConverter = params.gcsConverterAvailable ? params.iModel.geoServices.getConverter(\"WGS84\") : undefined;\r\n if (params.rootToEcef) {\r\n this._rootToEcef = params.rootToEcef;\r\n const dbToRoot = this.iModelTransform.inverse();\r\n if (dbToRoot) {\r\n const dbToEcef = this._rootToEcef.multiplyTransformTransform(dbToRoot);\r\n this._ecefToDb = dbToEcef.inverse();\r\n }\r\n }\r\n }\r\n\r\n /** @internal */\r\n public get rootTile(): RealityTile { return this._rootTile; }\r\n /** @internal */\r\n public get is3d() { return true; }\r\n /** @internal */\r\n public get maxDepth() { return this.loader.maxDepth; }\r\n /** @internal */\r\n public get minDepth() { return this.loader.minDepth; }\r\n /** @internal */\r\n public override get isContentUnbounded() { return this.loader.isContentUnbounded; }\r\n /** @internal */\r\n public get isTransparent() { return false; }\r\n\r\n /** @internal */\r\n protected _selectTiles(args: TileDrawArgs): Tile[] { return this.selectRealityTiles(args, []); }\r\n /** @internal */\r\n public get viewFlagOverrides(): ViewFlagOverrides { return this.loader.viewFlagOverrides; }\r\n /** @internal */\r\n public override get parentsAndChildrenExclusive() { return this.loader.parentsAndChildrenExclusive; }\r\n\r\n /** @internal */\r\n public createTile(props: TileParams): RealityTile { return new RealityTile(props, this); }\r\n\r\n /** Collect tiles from this tile tree based on the criteria implemented by `collector`.\r\n * @internal\r\n */\r\n public override collectTileGeometry(collector: TileGeometryCollector): void {\r\n this.rootTile.collectTileGeometry(collector);\r\n }\r\n\r\n /** @internal */\r\n public prune(): void {\r\n const olderThan = BeTimePoint.now().minus(this.expirationTime);\r\n this.rootTile.purgeContents(olderThan);\r\n }\r\n\r\n /** @internal */\r\n public draw(args: TileDrawArgs): void {\r\n const displayedTileDescendants = new Array<RealityTile[]>();\r\n const debugControl = args.context.target.debugControl;\r\n const selectBuilder = (debugControl && debugControl.displayRealityTileRanges) ? args.context.createSceneGraphicBuilder() : undefined;\r\n const preloadDebugBuilder = (debugControl && debugControl.displayRealityTilePreload) ? args.context.createSceneGraphicBuilder() : undefined;\r\n const graphicTypeBranches = new Map<TileGraphicType, GraphicBranch>();\r\n\r\n const selectedTiles = this.selectRealityTiles(args, displayedTileDescendants, preloadDebugBuilder);\r\n args.processSelectedTiles(selectedTiles);\r\n let sortIndices;\r\n\r\n if (!this.parentsAndChildrenExclusive) {\r\n sortIndices = selectedTiles.map((_x, i) => i);\r\n sortIndices.sort((a, b) => selectedTiles[a].depth - selectedTiles[b].depth);\r\n }\r\n\r\n if (! (args instanceof GraphicsCollectorDrawArgs))\r\n this.collectClassifierGraphics(args, selectedTiles);\r\n\r\n assert(selectedTiles.length === displayedTileDescendants.length);\r\n for (let i = 0; i < selectedTiles.length; i++) {\r\n const index = sortIndices ? sortIndices[i] : i;\r\n const selectedTile = selectedTiles[index];\r\n const graphics = args.getTileGraphics(selectedTile);\r\n const tileGraphicType = selectedTile.graphicType;\r\n let targetBranch;\r\n if (undefined !== tileGraphicType && tileGraphicType !== args.context.graphicType) {\r\n if (!(targetBranch = graphicTypeBranches.get(tileGraphicType))) {\r\n graphicTypeBranches.set(tileGraphicType, targetBranch = new GraphicBranch(false));\r\n targetBranch.setViewFlagOverrides(args.graphics.viewFlagOverrides);\r\n targetBranch.symbologyOverrides = args.graphics.symbologyOverrides;\r\n }\r\n }\r\n\r\n if (!targetBranch)\r\n targetBranch = args.graphics;\r\n\r\n if (undefined !== graphics) {\r\n const displayedDescendants = displayedTileDescendants[index];\r\n if (0 === displayedDescendants.length || !this.loader.parentsAndChildrenExclusive || selectedTile.allChildrenIncluded(displayedDescendants)) {\r\n targetBranch.add(graphics);\r\n if (selectBuilder)\r\n selectedTile.addBoundingGraphic(selectBuilder, ColorDef.green);\r\n } else {\r\n if (selectBuilder)\r\n selectedTile.addBoundingGraphic(selectBuilder, ColorDef.red);\r\n\r\n for (const displayedDescendant of displayedDescendants) {\r\n const clipVector = displayedDescendant.getContentClip();\r\n if (selectBuilder)\r\n displayedDescendant.addBoundingGraphic(selectBuilder, ColorDef.blue);\r\n\r\n if (undefined === clipVector) {\r\n targetBranch.add(graphics);\r\n } else {\r\n clipVector.transformInPlace(args.location);\r\n if (!this.isTransparent)\r\n for (const primitive of clipVector.clips)\r\n for (const clipPlanes of primitive.fetchClipPlanesRef()!.convexSets)\r\n for (const plane of clipPlanes.planes)\r\n plane.offsetDistance(-displayedDescendant.radius * .05); // Overlap with existing (high resolution) tile slightly to avoid cracks.\r\n\r\n const branch = new GraphicBranch(false);\r\n branch.add(graphics);\r\n const clipVolume = args.context.target.renderSystem.createClipVolume(clipVector);\r\n targetBranch.add(args.context.createGraphicBranch(branch, Transform.createIdentity(), { clipVolume }));\r\n }\r\n }\r\n }\r\n if (preloadDebugBuilder)\r\n targetBranch.add(preloadDebugBuilder.finish());\r\n\r\n if (selectBuilder)\r\n targetBranch.add(selectBuilder.finish());\r\n\r\n const rangeGraphic = selectedTile.getRangeGraphic(args.context);\r\n if (undefined !== rangeGraphic)\r\n targetBranch.add(rangeGraphic);\r\n }\r\n }\r\n\r\n args.drawGraphics();\r\n for (const graphicTypeBranch of graphicTypeBranches) {\r\n args.drawGraphicsWithType(graphicTypeBranch[0], graphicTypeBranch[1]);\r\n }\r\n }\r\n\r\n /** @internal */\r\n protected collectClassifierGraphics(args: TileDrawArgs, selectedTiles: RealityTile[]) {\r\n const classifier = args.context.planarClassifiers.get(this.modelId);\r\n if (classifier)\r\n classifier.collectGraphics(args.context, { modelId: this.modelId, tiles: selectedTiles, location: args.location, isPointCloud: this.isPointCloud });\r\n }\r\n\r\n /** @internal */\r\n public getTraversalChildren(depth: number) {\r\n while (this.traversalChildrenByDepth.length <= depth)\r\n this.traversalChildrenByDepth.push(new TraversalChildrenDetails());\r\n\r\n return this.traversalChildrenByDepth[depth];\r\n }\r\n\r\n /** @internal */\r\n public doReprojectChildren(tile: Tile): boolean {\r\n if (!(tile instanceof RealityTile) || this._gcsConverter === undefined || this._rootToEcef === undefined || undefined === this._ecefToDb)\r\n return false;\r\n\r\n const tileRange = this.iModelTransform.isIdentity ? tile.range : this.iModelTransform.multiplyRange(tile.range, scratchRange);\r\n\r\n return this.cartesianRange.intersectsRange(tileRange);\r\n }\r\n\r\n /** @internal */\r\n public reprojectAndResolveChildren(parent: Tile, children: Tile[], resolve: (children: Tile[] | undefined) => void): void {\r\n if (!this.doReprojectChildren(parent)) {\r\n resolve(children);\r\n return;\r\n }\r\n\r\n const ecefToDb = this._ecefToDb!; // Tested for undefined in doReprojectChildren\r\n const rootToDb = this.iModelTransform;\r\n const dbToEcef = ecefToDb.inverse()!;\r\n const reprojectChildren = new Array<ChildReprojection>();\r\n for (const child of children) {\r\n const realityChild = child as RealityTile;\r\n const childRange = realityChild.rangeCorners ? Range3d.createTransformedArray(rootToDb, realityChild.rangeCorners) : rootToDb.multiplyRange(realityChild.contentRange, scratchRange);\r\n const dbCenter = childRange.center;\r\n const ecefCenter = dbToEcef.multiplyPoint3d(dbCenter);\r\n const dbPoints = [dbCenter, dbCenter.plusXYZ(1), dbCenter.plusXYZ(0, 1), dbCenter.plusXYZ(0, 0, 1)];\r\n reprojectChildren.push({ child: realityChild, ecefCenter, dbPoints });\r\n }\r\n if (reprojectChildren.length === 0)\r\n resolve(children);\r\n else {\r\n const requestProps = new Array<XYZProps>();\r\n\r\n for (const reprojection of reprojectChildren) {\r\n for (const dbPoint of reprojection.dbPoints) {\r\n const ecefPoint = dbToEcef.multiplyPoint3d(dbPoint);\r\n const carto = Cartographic.fromEcef(ecefPoint, scratchCarto);\r\n if (carto)\r\n requestProps.push({ x: carto.longitudeDegrees, y: carto.latitudeDegrees, z: carto.height });\r\n\r\n }\r\n }\r\n\r\n if (requestProps.length !== 4 * reprojectChildren.length)\r\n resolve(children);\r\n else {\r\n this._gcsConverter!.getIModelCoordinatesFromGeoCoordinates(requestProps).then((response) => {\r\n\r\n const reprojectedCoords = response.iModelCoords;\r\n const dbToRoot = rootToDb.inverse()!;\r\n const getReprojectedPoint = (original: Point3d, reprojectedXYZ: XYZProps) => {\r\n scratchPoint.setFromJSON(reprojectedXYZ);\r\n const cartesianDistance = this.cartesianRange.distanceToPoint(scratchPoint);\r\n if (cartesianDistance < this.cartesianTransitionDistance)\r\n return scratchPoint.interpolate(cartesianDistance / this.cartesianTransitionDistance, original, scratchPoint);\r\n else\r\n return original;\r\n };\r\n\r\n let responseIndex = 0;\r\n for (const reprojection of reprojectChildren) {\r\n if (reprojectedCoords.every((coord) => coord.s === GeoCoordStatus.Success)) {\r\n const reprojectedOrigin = getReprojectedPoint(reprojection.dbPoints[0], reprojectedCoords[responseIndex++].p).clone(scratchOrigin);\r\n const xVector = Vector3d.createStartEnd(reprojectedOrigin, getReprojectedPoint(reprojection.dbPoints[1], reprojectedCoords[responseIndex++].p), scratchX);\r\n const yVector = Vector3d.createStartEnd(reprojectedOrigin, getReprojectedPoint(reprojection.dbPoints[2], reprojectedCoords[responseIndex++].p), scratchY);\r\n const zVector = Vector3d.createStartEnd(reprojectedOrigin, getReprojectedPoint(reprojection.dbPoints[3], reprojectedCoords[responseIndex++].p), scratchZ);\r\n const matrix = Matrix3d.createColumns(xVector, yVector, zVector, scratchMatrix);\r\n if (matrix !== undefined) {\r\n const dbReprojection = Transform.createMatrixPickupPutdown(matrix, reprojection.dbPoints[0], reprojectedOrigin, scratchTransform);\r\n if (dbReprojection) {\r\n const rootReprojection = dbToRoot.multiplyTransformTransform(dbReprojection).multiplyTransformTransform(rootToDb);\r\n reprojection.child.reproject(rootReprojection);\r\n }\r\n }\r\n }\r\n }\r\n\r\n resolve(children);\r\n }).catch(() => {\r\n resolve(children); // Error occured in reprojection - just resolve with unprojected corners.\r\n });\r\n }\r\n }\r\n }\r\n\r\n /** @internal */\r\n public getBaseRealityDepth(_sceneContext: SceneContext) { return -1; }\r\n\r\n /** @internal */\r\n public selectRealityTiles(args: TileDrawArgs, displayedDescendants: RealityTile[][], preloadDebugBuilder?: GraphicBuilder): RealityTile[] {\r\n this._lastSelected = BeTimePoint.now();\r\n const selected: RealityTile[] = [];\r\n const context = new TraversalSelectionContext(selected, displayedDescendants, preloadDebugBuilder, args.maxRealityTreeSelectionCount);\r\n const rootTile = this.rootTile;\r\n const debugControl = args.context.target.debugControl;\r\n const freezeTiles = debugControl && debugControl.freezeRealityTiles;\r\n\r\n rootTile.selectRealityTiles(context, args, new TraversalDetails());\r\n\r\n const baseDepth = this.getBaseRealityDepth(args.context);\r\n\r\n if (!args.context.target.renderSystem.isMobile && 0 === context.missing.length) { // We skip preloading on mobile devices.\r\n if (baseDepth > 0) // Maps may force loading of low level globe tiles.\r\n rootTile.preloadRealityTilesAtDepth(baseDepth, context, args);\r\n\r\n if (!freezeTiles)\r\n this.preloadTilesForScene(args, context, undefined);\r\n }\r\n\r\n if (!freezeTiles)\r\n for (const tile of context.missing) {\r\n const loadableTile = tile.loadableTile;\r\n\r\n loadableTile.markUsed(args);\r\n args.insertMissing(loadableTile);\r\n }\r\n\r\n if (debugControl && debugControl.logRealityTiles) {\r\n this.logTiles(\"Selected: \", selected.values());\r\n const preloaded = [];\r\n for (const tile of context.preloaded)\r\n preloaded.push(tile);\r\n\r\n this.logTiles(\"Preloaded: \", preloaded.values());\r\n this.logTiles(\"Missing: \", context.missing.values());\r\n\r\n const imageryTiles: RealityTile[] = [];\r\n for (const selectedTile of selected) {\r\n if (selectedTile instanceof MapTile) {\r\n const selectedImageryTiles = (selectedTile).imageryTiles;\r\n if (selectedImageryTiles)\r\n selectedImageryTiles.forEach((tile) => imageryTiles.push(tile));\r\n }\r\n }\r\n if (imageryTiles.length)\r\n this.logTiles(\"Imagery:\", imageryTiles.values());\r\n }\r\n\r\n IModelApp.tileAdmin.addTilesForUser(args.context.viewport, selected, args.readyTiles);\r\n return selected;\r\n }\r\n\r\n /** @internal */\r\n public preloadTilesForScene(args: TileDrawArgs, context: TraversalSelectionContext, frustumTransform?: Transform) {\r\n const preloadFrustum = args.viewingSpace.getPreloadFrustum(frustumTransform, scratchFrustum);\r\n const preloadFrustumPlanes = new FrustumPlanes(preloadFrustum);\r\n const worldToNpc = preloadFrustum.toMap4d();\r\n const preloadWorldToViewMap = args.viewingSpace.calcNpcToView().multiplyMapMap(worldToNpc!);\r\n const preloadArgs = new RealityTileDrawArgs(args, preloadWorldToViewMap, preloadFrustumPlanes);\r\n\r\n scratchFrustumPlanes.init(preloadFrustum);\r\n if (context.preloadDebugBuilder) {\r\n context.preloadDebugBuilder.setSymbology(ColorDef.blue, ColorDef.blue, 2, 0);\r\n context.preloadDebugBuilder.addFrustum(preloadFrustum);\r\n }\r\n\r\n this.rootTile.preloadTilesInFrustum(preloadArgs, context, 2);\r\n }\r\n\r\n /** @internal */\r\n protected logTiles(label: string, tiles: IterableIterator<Tile>) {\r\n let depthString = \"\";\r\n let min = 10000, max = -10000;\r\n let count = 0;\r\n const depthMap = new Map<number, number>();\r\n for (const tile of tiles) {\r\n count++;\r\n const depth = tile.depth;\r\n min = Math.min(min, tile.depth);\r\n max = Math.max(max, tile.depth);\r\n const found = depthMap.get(depth);\r\n depthMap.set(depth, found === undefined ? 1 : found + 1);\r\n }\r\n\r\n depthMap.forEach((key, value) => depthString += `${key}-${value}, `);\r\n // eslint-disable-next-line no-console\r\n console.log(`${label}: ${count} Min: ${min} Max: ${max} Depths: ${depthString}`);\r\n }\r\n}\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/core-frontend",
3
- "version": "3.5.0-dev.27",
3
+ "version": "3.5.0-dev.28",
4
4
  "description": "iTwin.js frontend components",
5
5
  "main": "lib/cjs/core-frontend.js",
6
6
  "module": "lib/esm/core-frontend.js",
@@ -22,29 +22,29 @@
22
22
  "url": "http://www.bentley.com"
23
23
  },
24
24
  "peerDependencies": {
25
- "@itwin/appui-abstract": "^3.5.0-dev.27",
26
- "@itwin/core-bentley": "^3.5.0-dev.27",
27
- "@itwin/core-common": "^3.5.0-dev.27",
28
- "@itwin/core-geometry": "^3.5.0-dev.27",
29
- "@itwin/core-orbitgt": "^3.5.0-dev.27",
30
- "@itwin/core-quantity": "^3.5.0-dev.27",
31
- "@itwin/webgl-compatibility": "^3.5.0-dev.27"
25
+ "@itwin/appui-abstract": "^3.5.0-dev.28",
26
+ "@itwin/core-bentley": "^3.5.0-dev.28",
27
+ "@itwin/core-common": "^3.5.0-dev.28",
28
+ "@itwin/core-geometry": "^3.5.0-dev.28",
29
+ "@itwin/core-orbitgt": "^3.5.0-dev.28",
30
+ "@itwin/core-quantity": "^3.5.0-dev.28",
31
+ "@itwin/webgl-compatibility": "^3.5.0-dev.28"
32
32
  },
33
33
  "//devDependencies": [
34
34
  "NOTE: All peerDependencies should also be listed as devDependencies since peerDependencies are not considered by npm install",
35
35
  "NOTE: All tools used by scripts in this package must be listed as devDependencies"
36
36
  ],
37
37
  "devDependencies": {
38
- "@itwin/appui-abstract": "3.5.0-dev.27",
39
- "@itwin/build-tools": "3.5.0-dev.27",
40
- "@itwin/core-bentley": "3.5.0-dev.27",
41
- "@itwin/core-common": "3.5.0-dev.27",
42
- "@itwin/core-geometry": "3.5.0-dev.27",
43
- "@itwin/core-orbitgt": "3.5.0-dev.27",
44
- "@itwin/core-quantity": "3.5.0-dev.27",
45
- "@itwin/certa": "3.5.0-dev.27",
46
- "@itwin/eslint-plugin": "3.5.0-dev.27",
47
- "@itwin/webgl-compatibility": "3.5.0-dev.27",
38
+ "@itwin/appui-abstract": "3.5.0-dev.28",
39
+ "@itwin/build-tools": "3.5.0-dev.28",
40
+ "@itwin/core-bentley": "3.5.0-dev.28",
41
+ "@itwin/core-common": "3.5.0-dev.28",
42
+ "@itwin/core-geometry": "3.5.0-dev.28",
43
+ "@itwin/core-orbitgt": "3.5.0-dev.28",
44
+ "@itwin/core-quantity": "3.5.0-dev.28",
45
+ "@itwin/certa": "3.5.0-dev.28",
46
+ "@itwin/eslint-plugin": "3.5.0-dev.28",
47
+ "@itwin/webgl-compatibility": "3.5.0-dev.28",
48
48
  "@types/chai": "4.3.1",
49
49
  "@types/chai-as-promised": "^7",
50
50
  "@types/deep-assign": "^0.1.0",
@@ -76,8 +76,8 @@
76
76
  "@itwin/object-storage-azure": "~1.4.0",
77
77
  "@itwin/cloud-agnostic-core": "~1.4.0",
78
78
  "@itwin/object-storage-core": "~1.4.0",
79
- "@itwin/core-i18n": "3.5.0-dev.27",
80
- "@itwin/core-telemetry": "3.5.0-dev.27",
79
+ "@itwin/core-i18n": "3.5.0-dev.28",
80
+ "@itwin/core-telemetry": "3.5.0-dev.28",
81
81
  "@loaders.gl/core": "^3.1.6",
82
82
  "@loaders.gl/draco": "^3.1.6",
83
83
  "deep-assign": "^2.0.0",