@itwin/core-frontend 5.0.0-dev.92 → 5.0.0-dev.94
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/IpcApp.d.ts +2 -4
- package/lib/cjs/IpcApp.d.ts.map +1 -1
- package/lib/cjs/IpcApp.js +16 -16
- package/lib/cjs/IpcApp.js.map +1 -1
- package/lib/cjs/internal/tile/RealityTileLoader.d.ts.map +1 -1
- package/lib/cjs/internal/tile/RealityTileLoader.js +1 -1
- package/lib/cjs/internal/tile/RealityTileLoader.js.map +1 -1
- package/lib/esm/IpcApp.d.ts +2 -4
- package/lib/esm/IpcApp.d.ts.map +1 -1
- package/lib/esm/IpcApp.js +17 -17
- package/lib/esm/IpcApp.js.map +1 -1
- package/lib/esm/internal/tile/RealityTileLoader.d.ts.map +1 -1
- package/lib/esm/internal/tile/RealityTileLoader.js +1 -1
- package/lib/esm/internal/tile/RealityTileLoader.js.map +1 -1
- package/lib/public/scripts/parse-imdl-worker.js +1 -1
- package/lib/workers/webpack/parse-imdl-worker.js +1 -1
- package/package.json +16 -16
package/lib/cjs/IpcApp.d.ts
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { PickAsyncMethods } from "@itwin/core-bentley";
|
|
5
5
|
import { IpcAppFunctions, IpcListener, IpcSocketFrontend, RemoveFunction } from "@itwin/core-common";
|
|
6
|
-
import { IModelAppOptions } from "./IModelApp";
|
|
7
6
|
import { _callIpcChannel } from "./common/internal/Symbols";
|
|
7
|
+
import { IModelAppOptions } from "./IModelApp";
|
|
8
8
|
/**
|
|
9
9
|
* Options for [[IpcApp.startup]]
|
|
10
10
|
* @public
|
|
@@ -62,9 +62,7 @@ export declare class IpcApp {
|
|
|
62
62
|
* @param methodName the name of a method implemented by the backend handler.
|
|
63
63
|
* @param args arguments to `methodName`
|
|
64
64
|
* @return a Promise with the return value from `methodName`
|
|
65
|
-
* @note If the backend implementation throws an exception, this method will throw
|
|
66
|
-
* with the `errorNumber` and `message` from the backend.
|
|
67
|
-
* @note Ipc is only supported if [[isValid]] is true.
|
|
65
|
+
* @note If the backend implementation throws an exception, this method will throw an exception with its contents
|
|
68
66
|
* @internal Use [[makeIpcProxy]] for a type-safe interface.
|
|
69
67
|
*/
|
|
70
68
|
static [_callIpcChannel](channelName: string, methodName: string, ...args: any[]): Promise<any>;
|
package/lib/cjs/IpcApp.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IpcApp.d.ts","sourceRoot":"","sources":["../../src/IpcApp.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"IpcApp.d.ts","sourceRoot":"","sources":["../../src/IpcApp.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAyC,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC9F,OAAO,EACsC,eAAe,EAAwC,WAAW,EAAE,iBAAiB,EAChI,cAAc,EACf,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,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,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,cAAc;IAIhF;;;;OAIG;WACW,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW;IAInE;;;;;;;;;OASG;WACiB,MAAM,CAAC,OAAO,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;;;;;;;;OAQG;WACiB,CAAC,eAAe,CAAC,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;IAuB5G;;OAEG;WACiB,cAAc,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;IAIzG;;OAEG;WACW,YAAY,CAAC,CAAC,EAAE,WAAW,EAAE,MAAM,GAAG,gBAAgB,CAAC,CAAC,CAAC;IASvE;;;OAGG;WACW,oBAAoB,CAAC,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,gBAAgB,CAAC,CAAC,CAAC;IASrG,+EAA+E;IAC/E,OAAc,cAAc,oCAAkE;IAE9F;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
|
@@ -10,8 +10,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
10
10
|
exports.NotificationHandler = exports.IpcApp = void 0;
|
|
11
11
|
const core_bentley_1 = require("@itwin/core-bentley");
|
|
12
12
|
const core_common_1 = require("@itwin/core-common");
|
|
13
|
-
const IModelApp_1 = require("./IModelApp");
|
|
14
13
|
const Symbols_1 = require("./common/internal/Symbols");
|
|
14
|
+
const IModelApp_1 = require("./IModelApp");
|
|
15
15
|
/**
|
|
16
16
|
* The frontend of apps with a dedicated backend that can use [Ipc]($docs/learning/IpcInterface.md).
|
|
17
17
|
* @public
|
|
@@ -70,26 +70,26 @@ class IpcApp {
|
|
|
70
70
|
* @param methodName the name of a method implemented by the backend handler.
|
|
71
71
|
* @param args arguments to `methodName`
|
|
72
72
|
* @return a Promise with the return value from `methodName`
|
|
73
|
-
* @note If the backend implementation throws an exception, this method will throw
|
|
74
|
-
* with the `errorNumber` and `message` from the backend.
|
|
75
|
-
* @note Ipc is only supported if [[isValid]] is true.
|
|
73
|
+
* @note If the backend implementation throws an exception, this method will throw an exception with its contents
|
|
76
74
|
* @internal Use [[makeIpcProxy]] for a type-safe interface.
|
|
77
75
|
*/
|
|
78
76
|
static async [Symbols_1._callIpcChannel](channelName, methodName, ...args) {
|
|
79
77
|
const retVal = (await this.invoke(channelName, methodName, ...args));
|
|
80
|
-
if (
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
else if (undefined !== retVal.error) {
|
|
88
|
-
const err = new core_common_1.BackendError(retVal.error.errorNumber, retVal.error.name, retVal.error.message);
|
|
89
|
-
err.stack = retVal.error.stack;
|
|
90
|
-
throw err;
|
|
78
|
+
if (retVal.error === undefined)
|
|
79
|
+
return retVal.result; // method was successful
|
|
80
|
+
// backend threw an exception, rethrow one on frontend
|
|
81
|
+
const err = retVal.error;
|
|
82
|
+
if (!core_bentley_1.JsonUtils.isObject(err)) {
|
|
83
|
+
// Exception wasn't an object?
|
|
84
|
+
throw retVal.error; // eslint-disable-line @typescript-eslint/only-throw-error
|
|
91
85
|
}
|
|
92
|
-
|
|
86
|
+
// Note: for backwards compatibility, if the exception was from a BentleyError on the backend, throw an exception of type `BackendError`.
|
|
87
|
+
if (!core_bentley_1.BentleyError.isError(err))
|
|
88
|
+
throw Object.assign(new Error(typeof err.message === "string" ? err.message : "unknown error"), err);
|
|
89
|
+
const trimErr = { ...err };
|
|
90
|
+
delete trimErr.iTwinErrorId; // these are methods on BackendError and will cause Object.assign to fail.
|
|
91
|
+
delete trimErr.loggingMetadata;
|
|
92
|
+
throw Object.assign(new core_common_1.BackendError(err.errorNumber, err.iTwinErrorId.key, err.message, err.loggingMetadata), trimErr);
|
|
93
93
|
}
|
|
94
94
|
/** @internal
|
|
95
95
|
* @deprecated in 4.8. Use [[makeIpcProxy]] for a type-safe interface.
|
package/lib/cjs/IpcApp.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IpcApp.js","sourceRoot":"","sources":["../../src/IpcApp.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAqE;AACrE,oDAE4B;AAC5B,2CAA0D;AAC1D,uDAA4D;AAU5D;;;GAGG;AACH,MAAa,MAAM;IACT,MAAM,CAAC,IAAI,CAAgC;IACnD,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;;;;;;;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CAAC,CAAC;IAC3C,CAAC;IAED,gBAAgB;IACT,MAAM,CAAC,KAAK,CAAC,QAAQ;QAC1B,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC;QACtB,MAAM,qBAAS,CAAC,QAAQ,EAAE,CAAC;IAC7B,CAAC;;AAlIH,wBAmIC;AAED;;;;;;;;;;;;;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,2BAAY,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,4BAAc,CAAC,SAAS,CAAC,CAAC,CAAC;IACtD,SAAS,KAAK,CAAC;CACvB","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module NativeApp\n */\n\nimport { IModelStatus, PickAsyncMethods } from \"@itwin/core-bentley\";\nimport {\n BackendError, IModelError, ipcAppChannels, IpcAppFunctions, IpcAppNotifications, IpcInvokeReturn, IpcListener, IpcSocketFrontend, iTwinChannel, RemoveFunction,\n} from \"@itwin/core-common\";\nimport { IModelApp, IModelAppOptions } from \"./IModelApp\";\nimport { _callIpcChannel } from \"./common/internal/Symbols\";\n\n/**\n * Options for [[IpcApp.startup]]\n * @public\n */\nexport interface IpcAppOptions {\n iModelApp?: IModelAppOptions;\n}\n\n/**\n * The frontend of apps with a dedicated backend that can use [Ipc]($docs/learning/IpcInterface.md).\n * @public\n */\nexport class IpcApp {\n private static _ipc: IpcSocketFrontend | undefined;\n /** Get the implementation of the [[IpcSocketFrontend]] interface. */\n\n private static get ipc(): IpcSocketFrontend { return this._ipc!; }\n\n /** Determine whether Ipc is available for this frontend. This will only be true if [[startup]] has been called on this class. */\n public static get isValid(): boolean { return undefined !== this._ipc; }\n\n /**\n * Establish a message handler function for the supplied channel over Ipc. The handler will be called when messages are sent for\n * the channel via [[BackendIpc.send]].\n * @param channel the name of the channel\n * @param handler the message handler\n * @returns A function to remove the handler\n * @note Ipc is only supported if [[isValid]] is true.\n */\n public static addListener(channel: string, handler: IpcListener): RemoveFunction {\n return this.ipc.addListener(iTwinChannel(channel), handler);\n }\n\n /**\n * Remove a previously registered listener\n * @param channel The name of the channel for the listener previously registered with [[addListener]]\n * @param listener The function passed to [[addListener]]\n */\n public static removeListener(channel: string, listener: IpcListener) {\n this.ipc.removeListener(iTwinChannel(channel), listener);\n }\n\n /**\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]]\n * @param channel The name of the channel for the method.\n * @see Electron [ipcRenderer.invoke](https://www.electronjs.org/docs/api/ipc-renderer) documentation for details.\n * Note that this interface may be implemented via Electron for desktop apps, or via\n * [WebSockets](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API) for mobile or web-based\n * Ipc connections. In either case, the Electron documentation provides the specifications for how it works.\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\n * primitive types and `ArrayBuffers` are allowed.\n */\n public static async invoke(channel: string, ...args: any[]): Promise<any> {\n return this.ipc.invoke(iTwinChannel(channel), ...args);\n }\n\n /**\n * Send a message over the socket.\n * @param channel The name of the channel for the message.\n * @param data The optional data of the message.\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\n * primitive types and `ArrayBuffers` are allowed.\n */\n public static send(channel: string, ...data: any[]) {\n return this.ipc.send(iTwinChannel(channel), ...data);\n }\n\n /**\n * Call a method on the backend through an Ipc channel.\n * @param channelName the channel registered by the backend handler.\n * @param methodName the name of a method implemented by the backend handler.\n * @param args arguments to `methodName`\n * @return a Promise with the return value from `methodName`\n * @note If the backend implementation throws an exception, this method will throw a [[BackendError]] exception\n * with the `errorNumber` and `message` from the backend.\n * @note Ipc is only supported if [[isValid]] is true.\n * @internal Use [[makeIpcProxy]] for a type-safe interface.\n */\n public static async [_callIpcChannel](channelName: string, methodName: string, ...args: any[]): Promise<any> {\n const retVal = (await this.invoke(channelName, methodName, ...args)) as IpcInvokeReturn;\n\n if (undefined !== retVal.iTwinError) {\n const error = new Error();\n if (retVal.iTwinError.stack === undefined)\n delete retVal.iTwinError.stack;\n Object.assign(error, retVal.iTwinError);\n throw error;\n } else if (undefined !== retVal.error) {\n const err = new BackendError(retVal.error.errorNumber, retVal.error.name, retVal.error.message);\n err.stack = retVal.error.stack;\n throw err;\n }\n return retVal.result;\n }\n\n /** @internal\n * @deprecated in 4.8. Use [[makeIpcProxy]] for a type-safe interface.\n */\n public static async callIpcChannel(channelName: string, methodName: string, ...args: any[]): Promise<any> {\n return this[_callIpcChannel](channelName, methodName, ...args);\n }\n\n /** Create a type safe Proxy object to make IPC calls to a registered backend interface.\n * @param channelName the channel registered by the backend handler.\n */\n public static makeIpcProxy<K>(channelName: string): PickAsyncMethods<K> {\n return new Proxy({} as PickAsyncMethods<K>, {\n get(_target, methodName: string) {\n return async (...args: any[]) =>\n IpcApp[_callIpcChannel](channelName, methodName, ...args);\n },\n });\n }\n\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\n * @param channelName the channel registered by the backend handler.\n * @param functionName the function to call on the handler.\n */\n public static makeIpcFunctionProxy<K>(channelName: string, functionName: string): PickAsyncMethods<K> {\n return new Proxy({} as PickAsyncMethods<K>, {\n get(_target, methodName: string) {\n return async (...args: any[]) =>\n IpcApp[_callIpcChannel](channelName, functionName, methodName, ...args);\n },\n });\n }\n\n /** A Proxy to call one of the [IpcAppFunctions]($common) functions via IPC. */\n public static appFunctionIpc = IpcApp.makeIpcProxy<IpcAppFunctions>(ipcAppChannels.functions);\n\n /** start an IpcApp.\n * @note this should not be called directly. It is called by NativeApp.startup */\n public static async startup(ipc: IpcSocketFrontend, opts?: IpcAppOptions) {\n this._ipc = ipc;\n IpcAppNotifyHandler.register(); // receives notifications from backend\n await IModelApp.startup(opts?.iModelApp);\n }\n\n /** @internal */\n public static async shutdown() {\n this._ipc = undefined;\n await IModelApp.shutdown();\n }\n}\n\n/**\n * Base class for all implementations of an Ipc notification response interface. This class is implemented on your frontend to supply\n * methods to receive notifications from your backend.\n *\n * Create a subclass to implement your Ipc response interface. Your class should be declared like this:\n * ```ts\n * class MyNotificationHandler extends NotificationHandler implements MyNotifications\n * ```\n * to ensure all method names and signatures are correct. Your methods cannot have a return value.\n *\n * Then, call `MyNotificationHandler.register` at startup to connect your class to your channel.\n * @public\n * @extensions\n */\nexport abstract class NotificationHandler {\n /** All subclasses must implement this method to specify their response channel name. */\n public abstract get channelName(): string;\n\n public registerImpl(): RemoveFunction {\n return IpcApp.addListener(this.channelName, (_evt: Event, funcName: string, ...args: any[]) => {\n const func = (this as any)[funcName];\n if (typeof func !== \"function\")\n throw new IModelError(IModelStatus.FunctionNotFound, `Method \"${this.constructor.name}.${funcName}\" not found on NotificationHandler registered for channel: ${this.channelName}`);\n\n func.call(this, ...args);\n });\n }\n\n /**\n * Register this class as the handler for notifications on its channel. This static method creates a new instance\n * that becomes the notification handler and is `this` when its methods are called.\n * @returns A function that can be called to remove the handler.\n * @note this method should only be called once per channel. If it is called multiple times, multiple handlers are established.\n */\n public static register(): RemoveFunction {\n return (new (this as any)() as NotificationHandler).registerImpl(); // create an instance of subclass. \"as any\" is necessary because base class is abstract\n }\n}\n\n/** IpcApp notifications from backend */\nclass IpcAppNotifyHandler extends NotificationHandler implements IpcAppNotifications {\n public get channelName() { return ipcAppChannels.appNotify; }\n public notifyApp() { }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"IpcApp.js","sourceRoot":"","sources":["../../src/IpcApp.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA8F;AAC9F,oDAG4B;AAC5B,uDAA4D;AAC5D,2CAA0D;AAU1D;;;GAGG;AACH,MAAa,MAAM;IACT,MAAM,CAAC,IAAI,CAAgC;IACnD,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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AC,GAAsB,EAAE,IAAoB;QACtE,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,mBAAmB,CAAC,QAAQ,EAAE,CAAC,CAAC,sCAAsC;QACtE,MAAM,qBAAS,CAAC,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAC3C,CAAC;IAED,gBAAgB;IACT,MAAM,CAAC,KAAK,CAAC,QAAQ;QAC1B,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC;QACtB,MAAM,qBAAS,CAAC,QAAQ,EAAE,CAAC;IAC7B,CAAC;;AAtIH,wBAuIC;AAED;;;;;;;;;;;;;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,2BAAY,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,4BAAc,CAAC,SAAS,CAAC,CAAC,CAAC;IACtD,SAAS,KAAK,CAAC;CACvB","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module NativeApp\n */\n\nimport { BentleyError, IModelStatus, JsonUtils, PickAsyncMethods } from \"@itwin/core-bentley\";\nimport {\n BackendError, IModelError, ipcAppChannels, IpcAppFunctions, IpcAppNotifications, IpcInvokeReturn, IpcListener, IpcSocketFrontend, iTwinChannel,\n RemoveFunction,\n} from \"@itwin/core-common\";\nimport { _callIpcChannel } from \"./common/internal/Symbols\";\nimport { IModelApp, IModelAppOptions } from \"./IModelApp\";\n\n/**\n * Options for [[IpcApp.startup]]\n * @public\n */\nexport interface IpcAppOptions {\n iModelApp?: IModelAppOptions;\n}\n\n/**\n * The frontend of apps with a dedicated backend that can use [Ipc]($docs/learning/IpcInterface.md).\n * @public\n */\nexport class IpcApp {\n private static _ipc: IpcSocketFrontend | undefined;\n /** Get the implementation of the [[IpcSocketFrontend]] interface. */\n\n private static get ipc(): IpcSocketFrontend { return this._ipc!; }\n\n /** Determine whether Ipc is available for this frontend. This will only be true if [[startup]] has been called on this class. */\n public static get isValid(): boolean { return undefined !== this._ipc; }\n\n /**\n * Establish a message handler function for the supplied channel over Ipc. The handler will be called when messages are sent for\n * the channel via [[BackendIpc.send]].\n * @param channel the name of the channel\n * @param handler the message handler\n * @returns A function to remove the handler\n * @note Ipc is only supported if [[isValid]] is true.\n */\n public static addListener(channel: string, handler: IpcListener): RemoveFunction {\n return this.ipc.addListener(iTwinChannel(channel), handler);\n }\n\n /**\n * Remove a previously registered listener\n * @param channel The name of the channel for the listener previously registered with [[addListener]]\n * @param listener The function passed to [[addListener]]\n */\n public static removeListener(channel: string, listener: IpcListener) {\n this.ipc.removeListener(iTwinChannel(channel), listener);\n }\n\n /**\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]]\n * @param channel The name of the channel for the method.\n * @see Electron [ipcRenderer.invoke](https://www.electronjs.org/docs/api/ipc-renderer) documentation for details.\n * Note that this interface may be implemented via Electron for desktop apps, or via\n * [WebSockets](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API) for mobile or web-based\n * Ipc connections. In either case, the Electron documentation provides the specifications for how it works.\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\n * primitive types and `ArrayBuffers` are allowed.\n */\n public static async invoke(channel: string, ...args: any[]): Promise<any> {\n return this.ipc.invoke(iTwinChannel(channel), ...args);\n }\n\n /**\n * Send a message over the socket.\n * @param channel The name of the channel for the message.\n * @param data The optional data of the message.\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\n * primitive types and `ArrayBuffers` are allowed.\n */\n public static send(channel: string, ...data: any[]) {\n return this.ipc.send(iTwinChannel(channel), ...data);\n }\n\n /**\n * Call a method on the backend through an Ipc channel.\n * @param channelName the channel registered by the backend handler.\n * @param methodName the name of a method implemented by the backend handler.\n * @param args arguments to `methodName`\n * @return a Promise with the return value from `methodName`\n * @note If the backend implementation throws an exception, this method will throw an exception with its contents\n * @internal Use [[makeIpcProxy]] for a type-safe interface.\n */\n public static async [_callIpcChannel](channelName: string, methodName: string, ...args: any[]): Promise<any> {\n const retVal = (await this.invoke(channelName, methodName, ...args)) as IpcInvokeReturn;\n\n if (retVal.error === undefined)\n return retVal.result; // method was successful\n\n // backend threw an exception, rethrow one on frontend\n const err = retVal.error;\n if (!JsonUtils.isObject(err)) {\n // Exception wasn't an object?\n throw retVal.error; // eslint-disable-line @typescript-eslint/only-throw-error\n }\n\n // Note: for backwards compatibility, if the exception was from a BentleyError on the backend, throw an exception of type `BackendError`.\n if (!BentleyError.isError(err))\n throw Object.assign(new Error(typeof err.message === \"string\" ? err.message : \"unknown error\"), err);\n\n const trimErr = { ...err } as any;\n delete trimErr.iTwinErrorId // these are methods on BackendError and will cause Object.assign to fail.\n delete trimErr.loggingMetadata;\n throw Object.assign(new BackendError(err.errorNumber, err.iTwinErrorId.key, err.message, err.loggingMetadata), trimErr);\n }\n\n /** @internal\n * @deprecated in 4.8. Use [[makeIpcProxy]] for a type-safe interface.\n */\n public static async callIpcChannel(channelName: string, methodName: string, ...args: any[]): Promise<any> {\n return this[_callIpcChannel](channelName, methodName, ...args);\n }\n\n /** Create a type safe Proxy object to make IPC calls to a registered backend interface.\n * @param channelName the channel registered by the backend handler.\n */\n public static makeIpcProxy<K>(channelName: string): PickAsyncMethods<K> {\n return new Proxy({} as PickAsyncMethods<K>, {\n get(_target, methodName: string) {\n return async (...args: any[]) =>\n IpcApp[_callIpcChannel](channelName, methodName, ...args);\n },\n });\n }\n\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\n * @param channelName the channel registered by the backend handler.\n * @param functionName the function to call on the handler.\n */\n public static makeIpcFunctionProxy<K>(channelName: string, functionName: string): PickAsyncMethods<K> {\n return new Proxy({} as PickAsyncMethods<K>, {\n get(_target, methodName: string) {\n return async (...args: any[]) =>\n IpcApp[_callIpcChannel](channelName, functionName, methodName, ...args);\n },\n });\n }\n\n /** A Proxy to call one of the [IpcAppFunctions]($common) functions via IPC. */\n public static appFunctionIpc = IpcApp.makeIpcProxy<IpcAppFunctions>(ipcAppChannels.functions);\n\n /** start an IpcApp.\n * @note this should not be called directly. It is called by NativeApp.startup */\n public static async startup(ipc: IpcSocketFrontend, opts?: IpcAppOptions) {\n this._ipc = ipc;\n IpcAppNotifyHandler.register(); // receives notifications from backend\n await IModelApp.startup(opts?.iModelApp);\n }\n\n /** @internal */\n public static async shutdown() {\n this._ipc = undefined;\n await IModelApp.shutdown();\n }\n}\n\n/**\n * Base class for all implementations of an Ipc notification response interface. This class is implemented on your frontend to supply\n * methods to receive notifications from your backend.\n *\n * Create a subclass to implement your Ipc response interface. Your class should be declared like this:\n * ```ts\n * class MyNotificationHandler extends NotificationHandler implements MyNotifications\n * ```\n * to ensure all method names and signatures are correct. Your methods cannot have a return value.\n *\n * Then, call `MyNotificationHandler.register` at startup to connect your class to your channel.\n * @public\n * @extensions\n */\nexport abstract class NotificationHandler {\n /** All subclasses must implement this method to specify their response channel name. */\n public abstract get channelName(): string;\n\n public registerImpl(): RemoveFunction {\n return IpcApp.addListener(this.channelName, (_evt: Event, funcName: string, ...args: any[]) => {\n const func = (this as any)[funcName];\n if (typeof func !== \"function\")\n throw new IModelError(IModelStatus.FunctionNotFound, `Method \"${this.constructor.name}.${funcName}\" not found on NotificationHandler registered for channel: ${this.channelName}`);\n\n func.call(this, ...args);\n });\n }\n\n /**\n * Register this class as the handler for notifications on its channel. This static method creates a new instance\n * that becomes the notification handler and is `this` when its methods are called.\n * @returns A function that can be called to remove the handler.\n * @note this method should only be called once per channel. If it is called multiple times, multiple handlers are established.\n */\n public static register(): RemoveFunction {\n return (new (this as any)() as NotificationHandler).registerImpl(); // create an instance of subclass. \"as any\" is necessary because base class is abstract\n }\n}\n\n/** IpcApp notifications from backend */\nclass IpcAppNotifyHandler extends NotificationHandler implements IpcAppNotifications {\n public get channelName() { return ipcAppChannels.appNotify; }\n public notifyApp() { }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RealityTileLoader.d.ts","sourceRoot":"","sources":["../../../../src/internal/tile/RealityTileLoader.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAU,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAoB,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,SAAS,EAAmC,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAGnG,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAkB,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1D,OAAO,EACO,gBAAgB,EAAkE,eAAe,EAC7G,WAAW,EAAE,kBAAkB,EAAmB,IAAI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G,OAAO,CAAC,kBAAkB,CAAC;YAarH,sBAAsB;IAkHpC,IAAW,iBAAiB,IAAI,iBAAiB,CAAqC;WAExE,2BAA2B,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,SAAS,GAAG,MAAM;CA4ClH;AAED;;EAEE;AACF,wBAAgB,4BAA4B,CAAC,YAAY,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS,CAUtI"}
|
|
@@ -78,7 +78,7 @@ class RealityTileLoader {
|
|
|
78
78
|
const { is3d, yAxisUp, iModel, modelId } = tile.realityRoot;
|
|
79
79
|
let reader;
|
|
80
80
|
const tileData = {
|
|
81
|
-
ecefTransform: tile.tree.iModel.
|
|
81
|
+
ecefTransform: tile.tree.iModel.ecefLocation?.getTransform() ?? core_geometry_1.Transform.createIdentity(),
|
|
82
82
|
range: tile.range,
|
|
83
83
|
layerClassifiers: tile.tree.layerHandler?.layerClassifiers,
|
|
84
84
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RealityTileLoader.js","sourceRoot":"","sources":["../../../../src/internal/tile/RealityTileLoader.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AA0PH,oEAUC;AAlQD,sDAAyD;AACzD,wDAAmE;AACnE,oDAAmG;AACnG,+CAA4C;AAC5C,8DAA2D;AAE3D,6CAA0D;AAC1D,6DAA4D;AAC5D,kDAG6B;AAG7B,MAAM,wBAAwB,GAAG,IAAA,yCAA8B,EAAC,EAAE,CAAC,CAAC;AAEpE,MAAM,sBAAsB,GAAG,IAAI,uBAAO,EAAE,CAAC;AAC7C,MAAM,qBAAqB,GAAG,IAAI,uBAAO,EAAE,CAAC;AAE5C;;GAEG;AACH,MAAsB,iBAAiB;IAKV;IAJnB,oBAAoB,GAAG,KAAK,CAAC;IACrB,yBAAyB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ACH,CAAC;YAED,oDAAoD;YACpD,MAAM,aAAa,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC;YAClC,MAAM,gBAAgB,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,GAAG,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC,yBAAyB;YAErG,iFAAiF;YACjF,gIAAgI;YAChI,MAAM,sBAAsB,GAAG,GAAG,CAAC;YACnC,MAAM,QAAQ,GAAG,aAAa,GAAG,CAAC,GAAG,GAAG,sBAAsB,CAAC,GAAG,gBAAgB,GAAG,sBAAsB,CAAC;YAE5G,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;QAChD,CAAC;QAED,OAAO,WAAW,CAAC;IACrB,CAAC;CACF;AA7ND,8CA6NC;AAED;;EAEE;AACF,SAAgB,4BAA4B,CAAC,YAAwB,EAAE,OAAgB,EAAE,OAAgB;IACvG,IAAI,GAAoB,CAAC;IACzB,IAAI,OAAO,EAAE,CAAC;QACZ,IAAI,CAAC;YACH,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;QACzB,CAAC;QAAC,MAAM,CAAC;YACP,GAAG,GAAG,SAAS,CAAC;QAClB,CAAC;IACH,CAAC;IACD,OAAO,0BAAe,CAAC,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,YAAY,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;AAC3G,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Tiles\n */\n\nimport { assert, ByteStream } from \"@itwin/core-bentley\";\nimport { Point2d, Point3d, Transform } from \"@itwin/core-geometry\";\nimport { BatchType, CompositeTileHeader, TileFormat, ViewFlagOverrides } from \"@itwin/core-common\";\nimport { IModelApp } from \"../../IModelApp\";\nimport { GraphicBranch } from \"../../render/GraphicBranch\";\nimport { RenderSystem } from \"../../render/RenderSystem\";\nimport { ScreenViewport, Viewport } from \"../../Viewport\";\nimport { GltfWrapMode } from \"../../common/gltf/GltfSchema\";\nimport {\n B3dmReader, BatchedTileIdMap, createDefaultViewFlagOverrides, GltfGraphicsReader, GltfReader, GltfReaderProps, I3dmReader, ImdlReader, readPointCloudTileContent,\n RealityTile, RealityTileContent, RealityTileTree, Tile, TileContent, TileDrawArgs, TileLoadPriority, TileRequest, TileRequestChannel, TileUser,\n} from \"../../tile/internal\";\nimport { LayerTileData } from \"../render/webgl/MapLayerParams\";\n\nconst defaultViewFlagOverrides = createDefaultViewFlagOverrides({});\n\nconst scratchTileCenterWorld = new Point3d();\nconst scratchTileCenterView = new Point3d();\n\n/** Serves as a \"handler\" for a specific type of [[TileTree]]. Its primary responsibilities involve loading tile content.\n * @internal\n */\nexport abstract class RealityTileLoader {\n private _containsPointClouds = false;\n public readonly preloadRealityParentDepth: number;\n public readonly preloadRealityParentSkip: number;\n\n public constructor(private _produceGeometry?: boolean) {\n this.preloadRealityParentDepth = IModelApp.tileAdmin.contextPreloadParentDepth;\n this.preloadRealityParentSkip = IModelApp.tileAdmin.contextPreloadParentSkip;\n }\n\n public computeTilePriority(tile: Tile, viewports: Iterable<Viewport>, _users: Iterable<TileUser>): number {\n // ###TODO: Handle case where tile tree reference(s) have a transform different from tree's (background map with ground bias).\n return RealityTileLoader.computeTileLocationPriority(tile, viewports, tile.tree.iModelTransform);\n }\n\n public abstract loadChildren(tile: RealityTile): Promise<Tile[] | undefined>;\n public abstract getRequestChannel(tile: Tile): TileRequestChannel;\n public abstract requestTileContent(tile: Tile, isCanceled: () => boolean): Promise<TileRequest.Response>;\n public get wantDeduplicatedVertices(): boolean { return false; }\n public abstract get maxDepth(): number;\n public abstract get minDepth(): number;\n public abstract get priority(): TileLoadPriority;\n protected get _batchType(): BatchType { return BatchType.Primary; }\n protected get _loadEdges(): boolean { return true; }\n public getBatchIdMap(): BatchedTileIdMap | undefined { return undefined; }\n public get isContentUnbounded(): boolean { return false; }\n public get containsPointClouds(): boolean { return this._containsPointClouds; }\n public get parentsAndChildrenExclusive(): boolean { return true; }\n public forceTileLoad(_tile: Tile): boolean { return false; }\n public get maximumScreenSpaceError(): number | undefined { return undefined; }\n\n public processSelectedTiles(selected: Tile[], _args: TileDrawArgs): Tile[] { return selected; }\n\n // NB: The isCanceled arg is chiefly for tests...in usual case it just returns false if the tile is no longer in 'loading' state.\n public async loadTileContent(tile: Tile, data: TileRequest.ResponseData, system: RenderSystem, isCanceled?: () => boolean): Promise<RealityTileContent> {\n assert(data instanceof Uint8Array);\n const blob = data;\n const streamBuffer = ByteStream.fromUint8Array(blob);\n const realityTile = tile as RealityTile;\n return this._produceGeometry ? this.loadGeometryFromStream(realityTile, streamBuffer, system) : this.loadGraphicsFromStream(realityTile, streamBuffer, system, isCanceled);\n }\n\n private _getFormat(streamBuffer: ByteStream) {\n const position = streamBuffer.curPos;\n const format = streamBuffer.readUint32();\n streamBuffer.curPos = position;\n return format;\n\n }\n\n public async loadGeometryFromStream(tile: RealityTile, streamBuffer: ByteStream, system: RenderSystem): Promise<RealityTileContent> {\n const format = this._getFormat(streamBuffer);\n if (format !== TileFormat.B3dm)\n return {};\n\n const { is3d, yAxisUp, iModel, modelId } = tile.realityRoot;\n const reader = B3dmReader.create(streamBuffer, iModel, modelId, is3d, tile.contentRange, system, yAxisUp, tile.isLeaf, tile.center, tile.transformToRoot, undefined, this.getBatchIdMap());\n if (reader)\n reader.defaultWrapMode = GltfWrapMode.ClampToEdge;\n\n return { geometry: reader?.readGltfAndCreateGeometry(tile.tree.iModelTransform) };\n }\n\n private async loadGraphicsFromStream(tile: RealityTile, streamBuffer: ByteStream, system: RenderSystem, isCanceled?: () => boolean): Promise<TileContent> {\n const format = this._getFormat(streamBuffer);\n if (undefined === isCanceled)\n isCanceled = () => !tile.isLoading;\n\n const { is3d, yAxisUp, iModel, modelId } = tile.realityRoot;\n let reader: GltfReader | ImdlReader | undefined;\n const tileData: LayerTileData = {\n ecefTransform: tile.tree.iModel.getEcefTransform(),\n range: tile.range,\n layerClassifiers: tile.tree.layerHandler?.layerClassifiers,\n };\n switch (format) {\n case TileFormat.IModel:\n reader = ImdlReader.create({\n stream: streamBuffer,\n iModel,\n modelId,\n is3d,\n system,\n isCanceled,\n });\n break;\n case TileFormat.Pnts:\n this._containsPointClouds = true;\n const res = await readPointCloudTileContent(streamBuffer, iModel, modelId, is3d, tile, system);\n let graphic = res.graphic;\n const rtcCenter = res.rtcCenter;\n if (graphic && (rtcCenter || tile.transformToRoot && !tile.transformToRoot.isIdentity)) {\n const transformBranch = new GraphicBranch(true);\n transformBranch.add(graphic);\n let xform: Transform;\n if (!tile.transformToRoot && rtcCenter)\n xform = Transform.createTranslation(rtcCenter);\n else {\n if (rtcCenter)\n xform = Transform.createOriginAndMatrix(rtcCenter.plus(tile.transformToRoot!.origin), tile.transformToRoot!.matrix);\n else\n xform = tile.transformToRoot!;\n }\n graphic = system.createBranch(transformBranch, xform);\n }\n\n return { graphic };\n case TileFormat.B3dm:\n reader = B3dmReader.create(streamBuffer, iModel, modelId, is3d, tile.contentRange, system, yAxisUp, tile.isLeaf, tile.center, tile.transformToRoot, isCanceled, this.getBatchIdMap(), this.wantDeduplicatedVertices, tileData);\n if (reader) {\n // glTF spec defaults wrap mode to \"repeat\" but many reality tiles omit the wrap mode and should not repeat.\n // The render system also currently only produces mip-maps for repeating textures, and we don't want mip-maps for reality tile textures.\n assert(reader instanceof GltfReader);\n reader.defaultWrapMode = GltfWrapMode.ClampToEdge;\n }\n\n break;\n case TileFormat.I3dm:\n reader = I3dmReader.create(streamBuffer, iModel, modelId, is3d, tile.contentRange, system, yAxisUp, tile.isLeaf, isCanceled, undefined, this.wantDeduplicatedVertices, tileData);\n break;\n case TileFormat.Gltf:\n const tree = tile.tree as RealityTileTree;\n const baseUrl = tree.baseUrl;\n const props = createReaderPropsWithBaseUrl(streamBuffer, yAxisUp, baseUrl);\n if (props) {\n reader = new GltfGraphicsReader(props, {\n iModel,\n gltf: props.glTF,\n contentRange: tile.contentRange,\n transform: tile.transformToRoot,\n hasChildren: !tile.isLeaf,\n pickableOptions: { id: modelId },\n idMap: this.getBatchIdMap(),\n tileData\n });\n }\n break;\n case TileFormat.Cmpt:\n const header = new CompositeTileHeader(streamBuffer);\n if (!header.isValid)\n return {};\n\n const branch = new GraphicBranch(true);\n for (let i = 0; i < header.tileCount; i++) {\n const tilePosition = streamBuffer.curPos;\n streamBuffer.advance(8); // Skip magic and version.\n const tileBytes = streamBuffer.readUint32();\n streamBuffer.curPos = tilePosition;\n const result = await this.loadGraphicsFromStream(tile, streamBuffer, system, isCanceled);\n if (result.graphic)\n branch.add(result.graphic);\n streamBuffer.curPos = tilePosition + tileBytes;\n }\n return { graphic: branch.isEmpty ? undefined : system.createBranch(branch, Transform.createIdentity()), isLeaf: tile.isLeaf };\n\n default:\n assert(false, `unknown tile format ${format}`);\n break;\n }\n\n let content: TileContent = {};\n if (undefined !== reader) {\n try {\n content = await reader.read();\n if (content.containsPointCloud)\n this._containsPointClouds = true;\n } catch {\n // Failure to load should prevent us from trying to load children\n content.isLeaf = true;\n }\n }\n\n return content;\n }\n\n public get viewFlagOverrides(): ViewFlagOverrides { return defaultViewFlagOverrides; }\n\n public static computeTileLocationPriority(tile: Tile, viewports: Iterable<Viewport>, location: Transform): number {\n // Compute a priority value for tiles that are:\n // * Closer to the eye;\n // * Closer to the center of attention (center of the screen or zoom target).\n // This way, we can load in priority tiles that are more likely to be important.\n let center: Point3d | undefined;\n let minDistance = 1.0;\n\n const currentInputState = IModelApp.toolAdmin.currentInputState;\n const now = Date.now();\n const wheelEventRelevanceTimeout = 1000; // Wheel events older than this value will not be considered\n\n for (const viewport of viewports) {\n center = center ?? location.multiplyPoint3d(tile.center, scratchTileCenterWorld);\n const npc = viewport.worldToNpc(center, scratchTileCenterView);\n\n let focusPoint = new Point2d(0.5, 0.5);\n\n if (currentInputState.viewport === viewport && viewport instanceof ScreenViewport) {\n // Try to get a better target point from the last zoom target\n const { lastWheelEvent } = currentInputState;\n\n if (lastWheelEvent !== undefined && now - lastWheelEvent.time < wheelEventRelevanceTimeout) {\n const focusPointCandidate = Point2d.fromJSON(viewport.worldToNpc(lastWheelEvent.point));\n\n if (focusPointCandidate.x > 0 && focusPointCandidate.x < 1 && focusPointCandidate.y > 0 && focusPointCandidate.y < 1)\n focusPoint = focusPointCandidate;\n }\n }\n\n // NB: In NPC coords, 0 = far plane, 1 = near plane.\n const distanceToEye = 1.0 - npc.z;\n const distanceToCenter = Math.min(npc.distanceXY(focusPoint) / 0.707, 1.0); // Math.sqrt(0.5) = 0.707\n\n // Distance is a mix of the two previously computed values, still in range [0; 1]\n // We use this factor to determine how much the distance to the center of attention is important compared to distance to the eye\n const distanceToCenterWeight = 0.3;\n const distance = distanceToEye * (1.0 - distanceToCenterWeight) + distanceToCenter * distanceToCenterWeight;\n\n minDistance = Math.min(distance, minDistance);\n }\n\n return minDistance;\n }\n}\n\n/** Exposed strictly for testing purposes.\n* @internal\n*/\nexport function createReaderPropsWithBaseUrl(streamBuffer: ByteStream, yAxisUp: boolean, baseUrl?: string): GltfReaderProps | undefined {\n let url: URL | undefined;\n if (baseUrl) {\n try {\n url = new URL(baseUrl);\n } catch {\n url = undefined;\n }\n }\n return GltfReaderProps.create(streamBuffer.nextBytes(streamBuffer.arrayBuffer.byteLength), yAxisUp, url);\n}"]}
|
|
1
|
+
{"version":3,"file":"RealityTileLoader.js","sourceRoot":"","sources":["../../../../src/internal/tile/RealityTileLoader.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AA4PH,oEAUC;AApQD,sDAAyD;AACzD,wDAAmE;AACnE,oDAAmG;AACnG,+CAA4C;AAC5C,8DAA2D;AAE3D,6CAA0D;AAC1D,6DAA4D;AAC5D,kDAG6B;AAG7B,MAA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C,CAAC;AAC3G,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Tiles\n */\n\nimport { assert, ByteStream } from \"@itwin/core-bentley\";\nimport { Point2d, Point3d, Transform } from \"@itwin/core-geometry\";\nimport { BatchType, CompositeTileHeader, TileFormat, ViewFlagOverrides } from \"@itwin/core-common\";\nimport { IModelApp } from \"../../IModelApp\";\nimport { GraphicBranch } from \"../../render/GraphicBranch\";\nimport { RenderSystem } from \"../../render/RenderSystem\";\nimport { ScreenViewport, Viewport } from \"../../Viewport\";\nimport { GltfWrapMode } from \"../../common/gltf/GltfSchema\";\nimport {\n B3dmReader, BatchedTileIdMap, createDefaultViewFlagOverrides, GltfGraphicsReader, GltfReader, GltfReaderProps, I3dmReader, ImdlReader, readPointCloudTileContent,\n RealityTile, RealityTileContent, RealityTileTree, Tile, TileContent, TileDrawArgs, TileLoadPriority, TileRequest, TileRequestChannel, TileUser,\n} from \"../../tile/internal\";\nimport { LayerTileData } from \"../render/webgl/MapLayerParams\";\n\nconst defaultViewFlagOverrides = createDefaultViewFlagOverrides({});\n\nconst scratchTileCenterWorld = new Point3d();\nconst scratchTileCenterView = new Point3d();\n\n/** Serves as a \"handler\" for a specific type of [[TileTree]]. Its primary responsibilities involve loading tile content.\n * @internal\n */\nexport abstract class RealityTileLoader {\n private _containsPointClouds = false;\n public readonly preloadRealityParentDepth: number;\n public readonly preloadRealityParentSkip: number;\n\n public constructor(private _produceGeometry?: boolean) {\n this.preloadRealityParentDepth = IModelApp.tileAdmin.contextPreloadParentDepth;\n this.preloadRealityParentSkip = IModelApp.tileAdmin.contextPreloadParentSkip;\n }\n\n public computeTilePriority(tile: Tile, viewports: Iterable<Viewport>, _users: Iterable<TileUser>): number {\n // ###TODO: Handle case where tile tree reference(s) have a transform different from tree's (background map with ground bias).\n return RealityTileLoader.computeTileLocationPriority(tile, viewports, tile.tree.iModelTransform);\n }\n\n public abstract loadChildren(tile: RealityTile): Promise<Tile[] | undefined>;\n public abstract getRequestChannel(tile: Tile): TileRequestChannel;\n public abstract requestTileContent(tile: Tile, isCanceled: () => boolean): Promise<TileRequest.Response>;\n public get wantDeduplicatedVertices(): boolean { return false; }\n public abstract get maxDepth(): number;\n public abstract get minDepth(): number;\n public abstract get priority(): TileLoadPriority;\n protected get _batchType(): BatchType { return BatchType.Primary; }\n protected get _loadEdges(): boolean { return true; }\n public getBatchIdMap(): BatchedTileIdMap | undefined { return undefined; }\n public get isContentUnbounded(): boolean { return false; }\n public get containsPointClouds(): boolean { return this._containsPointClouds; }\n public get parentsAndChildrenExclusive(): boolean { return true; }\n public forceTileLoad(_tile: Tile): boolean { return false; }\n public get maximumScreenSpaceError(): number | undefined { return undefined; }\n\n public processSelectedTiles(selected: Tile[], _args: TileDrawArgs): Tile[] { return selected; }\n\n // NB: The isCanceled arg is chiefly for tests...in usual case it just returns false if the tile is no longer in 'loading' state.\n public async loadTileContent(tile: Tile, data: TileRequest.ResponseData, system: RenderSystem, isCanceled?: () => boolean): Promise<RealityTileContent> {\n assert(data instanceof Uint8Array);\n const blob = data;\n const streamBuffer = ByteStream.fromUint8Array(blob);\n const realityTile = tile as RealityTile;\n return this._produceGeometry ? this.loadGeometryFromStream(realityTile, streamBuffer, system) : this.loadGraphicsFromStream(realityTile, streamBuffer, system, isCanceled);\n }\n\n private _getFormat(streamBuffer: ByteStream) {\n const position = streamBuffer.curPos;\n const format = streamBuffer.readUint32();\n streamBuffer.curPos = position;\n return format;\n\n }\n\n public async loadGeometryFromStream(tile: RealityTile, streamBuffer: ByteStream, system: RenderSystem): Promise<RealityTileContent> {\n const format = this._getFormat(streamBuffer);\n if (format !== TileFormat.B3dm)\n return {};\n\n const { is3d, yAxisUp, iModel, modelId } = tile.realityRoot;\n const reader = B3dmReader.create(streamBuffer, iModel, modelId, is3d, tile.contentRange, system, yAxisUp, tile.isLeaf, tile.center, tile.transformToRoot, undefined, this.getBatchIdMap());\n if (reader)\n reader.defaultWrapMode = GltfWrapMode.ClampToEdge;\n\n return { geometry: reader?.readGltfAndCreateGeometry(tile.tree.iModelTransform) };\n }\n\n private async loadGraphicsFromStream(tile: RealityTile, streamBuffer: ByteStream, system: RenderSystem, isCanceled?: () => boolean): Promise<TileContent> {\n const format = this._getFormat(streamBuffer);\n if (undefined === isCanceled)\n isCanceled = () => !tile.isLoading;\n\n const { is3d, yAxisUp, iModel, modelId } = tile.realityRoot;\n let reader: GltfReader | ImdlReader | undefined;\n\n const tileData: LayerTileData = {\n ecefTransform: tile.tree.iModel.ecefLocation?.getTransform() ?? Transform.createIdentity(),\n range: tile.range,\n layerClassifiers: tile.tree.layerHandler?.layerClassifiers,\n };\n\n switch (format) {\n case TileFormat.IModel:\n reader = ImdlReader.create({\n stream: streamBuffer,\n iModel,\n modelId,\n is3d,\n system,\n isCanceled,\n });\n break;\n case TileFormat.Pnts:\n this._containsPointClouds = true;\n const res = await readPointCloudTileContent(streamBuffer, iModel, modelId, is3d, tile, system);\n let graphic = res.graphic;\n const rtcCenter = res.rtcCenter;\n if (graphic && (rtcCenter || tile.transformToRoot && !tile.transformToRoot.isIdentity)) {\n const transformBranch = new GraphicBranch(true);\n transformBranch.add(graphic);\n let xform: Transform;\n if (!tile.transformToRoot && rtcCenter)\n xform = Transform.createTranslation(rtcCenter);\n else {\n if (rtcCenter)\n xform = Transform.createOriginAndMatrix(rtcCenter.plus(tile.transformToRoot!.origin), tile.transformToRoot!.matrix);\n else\n xform = tile.transformToRoot!;\n }\n graphic = system.createBranch(transformBranch, xform);\n }\n\n return { graphic };\n case TileFormat.B3dm:\n reader = B3dmReader.create(streamBuffer, iModel, modelId, is3d, tile.contentRange, system, yAxisUp, tile.isLeaf, tile.center, tile.transformToRoot, isCanceled, this.getBatchIdMap(), this.wantDeduplicatedVertices, tileData);\n if (reader) {\n // glTF spec defaults wrap mode to \"repeat\" but many reality tiles omit the wrap mode and should not repeat.\n // The render system also currently only produces mip-maps for repeating textures, and we don't want mip-maps for reality tile textures.\n assert(reader instanceof GltfReader);\n reader.defaultWrapMode = GltfWrapMode.ClampToEdge;\n }\n\n break;\n case TileFormat.I3dm:\n reader = I3dmReader.create(streamBuffer, iModel, modelId, is3d, tile.contentRange, system, yAxisUp, tile.isLeaf, isCanceled, undefined, this.wantDeduplicatedVertices, tileData);\n break;\n case TileFormat.Gltf:\n const tree = tile.tree as RealityTileTree;\n const baseUrl = tree.baseUrl;\n const props = createReaderPropsWithBaseUrl(streamBuffer, yAxisUp, baseUrl);\n if (props) {\n reader = new GltfGraphicsReader(props, {\n iModel,\n gltf: props.glTF,\n contentRange: tile.contentRange,\n transform: tile.transformToRoot,\n hasChildren: !tile.isLeaf,\n pickableOptions: { id: modelId },\n idMap: this.getBatchIdMap(),\n tileData\n });\n }\n break;\n case TileFormat.Cmpt:\n const header = new CompositeTileHeader(streamBuffer);\n if (!header.isValid)\n return {};\n\n const branch = new GraphicBranch(true);\n for (let i = 0; i < header.tileCount; i++) {\n const tilePosition = streamBuffer.curPos;\n streamBuffer.advance(8); // Skip magic and version.\n const tileBytes = streamBuffer.readUint32();\n streamBuffer.curPos = tilePosition;\n const result = await this.loadGraphicsFromStream(tile, streamBuffer, system, isCanceled);\n if (result.graphic)\n branch.add(result.graphic);\n streamBuffer.curPos = tilePosition + tileBytes;\n }\n return { graphic: branch.isEmpty ? undefined : system.createBranch(branch, Transform.createIdentity()), isLeaf: tile.isLeaf };\n\n default:\n assert(false, `unknown tile format ${format}`);\n break;\n }\n\n let content: TileContent = {};\n if (undefined !== reader) {\n try {\n content = await reader.read();\n if (content.containsPointCloud)\n this._containsPointClouds = true;\n } catch {\n // Failure to load should prevent us from trying to load children\n content.isLeaf = true;\n }\n }\n\n return content;\n }\n\n public get viewFlagOverrides(): ViewFlagOverrides { return defaultViewFlagOverrides; }\n\n public static computeTileLocationPriority(tile: Tile, viewports: Iterable<Viewport>, location: Transform): number {\n // Compute a priority value for tiles that are:\n // * Closer to the eye;\n // * Closer to the center of attention (center of the screen or zoom target).\n // This way, we can load in priority tiles that are more likely to be important.\n let center: Point3d | undefined;\n let minDistance = 1.0;\n\n const currentInputState = IModelApp.toolAdmin.currentInputState;\n const now = Date.now();\n const wheelEventRelevanceTimeout = 1000; // Wheel events older than this value will not be considered\n\n for (const viewport of viewports) {\n center = center ?? location.multiplyPoint3d(tile.center, scratchTileCenterWorld);\n const npc = viewport.worldToNpc(center, scratchTileCenterView);\n\n let focusPoint = new Point2d(0.5, 0.5);\n\n if (currentInputState.viewport === viewport && viewport instanceof ScreenViewport) {\n // Try to get a better target point from the last zoom target\n const { lastWheelEvent } = currentInputState;\n\n if (lastWheelEvent !== undefined && now - lastWheelEvent.time < wheelEventRelevanceTimeout) {\n const focusPointCandidate = Point2d.fromJSON(viewport.worldToNpc(lastWheelEvent.point));\n\n if (focusPointCandidate.x > 0 && focusPointCandidate.x < 1 && focusPointCandidate.y > 0 && focusPointCandidate.y < 1)\n focusPoint = focusPointCandidate;\n }\n }\n\n // NB: In NPC coords, 0 = far plane, 1 = near plane.\n const distanceToEye = 1.0 - npc.z;\n const distanceToCenter = Math.min(npc.distanceXY(focusPoint) / 0.707, 1.0); // Math.sqrt(0.5) = 0.707\n\n // Distance is a mix of the two previously computed values, still in range [0; 1]\n // We use this factor to determine how much the distance to the center of attention is important compared to distance to the eye\n const distanceToCenterWeight = 0.3;\n const distance = distanceToEye * (1.0 - distanceToCenterWeight) + distanceToCenter * distanceToCenterWeight;\n\n minDistance = Math.min(distance, minDistance);\n }\n\n return minDistance;\n }\n}\n\n/** Exposed strictly for testing purposes.\n* @internal\n*/\nexport function createReaderPropsWithBaseUrl(streamBuffer: ByteStream, yAxisUp: boolean, baseUrl?: string): GltfReaderProps | undefined {\n let url: URL | undefined;\n if (baseUrl) {\n try {\n url = new URL(baseUrl);\n } catch {\n url = undefined;\n }\n }\n return GltfReaderProps.create(streamBuffer.nextBytes(streamBuffer.arrayBuffer.byteLength), yAxisUp, url);\n}"]}
|
package/lib/esm/IpcApp.d.ts
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { PickAsyncMethods } from "@itwin/core-bentley";
|
|
5
5
|
import { IpcAppFunctions, IpcListener, IpcSocketFrontend, RemoveFunction } from "@itwin/core-common";
|
|
6
|
-
import { IModelAppOptions } from "./IModelApp";
|
|
7
6
|
import { _callIpcChannel } from "./common/internal/Symbols";
|
|
7
|
+
import { IModelAppOptions } from "./IModelApp";
|
|
8
8
|
/**
|
|
9
9
|
* Options for [[IpcApp.startup]]
|
|
10
10
|
* @public
|
|
@@ -62,9 +62,7 @@ export declare class IpcApp {
|
|
|
62
62
|
* @param methodName the name of a method implemented by the backend handler.
|
|
63
63
|
* @param args arguments to `methodName`
|
|
64
64
|
* @return a Promise with the return value from `methodName`
|
|
65
|
-
* @note If the backend implementation throws an exception, this method will throw
|
|
66
|
-
* with the `errorNumber` and `message` from the backend.
|
|
67
|
-
* @note Ipc is only supported if [[isValid]] is true.
|
|
65
|
+
* @note If the backend implementation throws an exception, this method will throw an exception with its contents
|
|
68
66
|
* @internal Use [[makeIpcProxy]] for a type-safe interface.
|
|
69
67
|
*/
|
|
70
68
|
static [_callIpcChannel](channelName: string, methodName: string, ...args: any[]): Promise<any>;
|
package/lib/esm/IpcApp.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IpcApp.d.ts","sourceRoot":"","sources":["../../src/IpcApp.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"IpcApp.d.ts","sourceRoot":"","sources":["../../src/IpcApp.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAyC,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC9F,OAAO,EACsC,eAAe,EAAwC,WAAW,EAAE,iBAAiB,EAChI,cAAc,EACf,MAAM,oBAAoB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,EAAE,MAAM,GAAG,gBAAgB,CAAC,CAAC,CAAC;IASrG,+EAA+E;IAC/E,OAAc,cAAc,oCAAkE;IAE9F;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
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
/** @packageDocumentation
|
|
6
6
|
* @module NativeApp
|
|
7
7
|
*/
|
|
8
|
-
import { IModelStatus } from "@itwin/core-bentley";
|
|
8
|
+
import { BentleyError, IModelStatus, JsonUtils } from "@itwin/core-bentley";
|
|
9
9
|
import { BackendError, IModelError, ipcAppChannels, iTwinChannel, } from "@itwin/core-common";
|
|
10
|
-
import { IModelApp } from "./IModelApp";
|
|
11
10
|
import { _callIpcChannel } from "./common/internal/Symbols";
|
|
11
|
+
import { IModelApp } from "./IModelApp";
|
|
12
12
|
/**
|
|
13
13
|
* The frontend of apps with a dedicated backend that can use [Ipc]($docs/learning/IpcInterface.md).
|
|
14
14
|
* @public
|
|
@@ -67,26 +67,26 @@ export class IpcApp {
|
|
|
67
67
|
* @param methodName the name of a method implemented by the backend handler.
|
|
68
68
|
* @param args arguments to `methodName`
|
|
69
69
|
* @return a Promise with the return value from `methodName`
|
|
70
|
-
* @note If the backend implementation throws an exception, this method will throw
|
|
71
|
-
* with the `errorNumber` and `message` from the backend.
|
|
72
|
-
* @note Ipc is only supported if [[isValid]] is true.
|
|
70
|
+
* @note If the backend implementation throws an exception, this method will throw an exception with its contents
|
|
73
71
|
* @internal Use [[makeIpcProxy]] for a type-safe interface.
|
|
74
72
|
*/
|
|
75
73
|
static async [_callIpcChannel](channelName, methodName, ...args) {
|
|
76
74
|
const retVal = (await this.invoke(channelName, methodName, ...args));
|
|
77
|
-
if (
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
else if (undefined !== retVal.error) {
|
|
85
|
-
const err = new BackendError(retVal.error.errorNumber, retVal.error.name, retVal.error.message);
|
|
86
|
-
err.stack = retVal.error.stack;
|
|
87
|
-
throw err;
|
|
75
|
+
if (retVal.error === undefined)
|
|
76
|
+
return retVal.result; // method was successful
|
|
77
|
+
// backend threw an exception, rethrow one on frontend
|
|
78
|
+
const err = retVal.error;
|
|
79
|
+
if (!JsonUtils.isObject(err)) {
|
|
80
|
+
// Exception wasn't an object?
|
|
81
|
+
throw retVal.error; // eslint-disable-line @typescript-eslint/only-throw-error
|
|
88
82
|
}
|
|
89
|
-
|
|
83
|
+
// Note: for backwards compatibility, if the exception was from a BentleyError on the backend, throw an exception of type `BackendError`.
|
|
84
|
+
if (!BentleyError.isError(err))
|
|
85
|
+
throw Object.assign(new Error(typeof err.message === "string" ? err.message : "unknown error"), err);
|
|
86
|
+
const trimErr = { ...err };
|
|
87
|
+
delete trimErr.iTwinErrorId; // these are methods on BackendError and will cause Object.assign to fail.
|
|
88
|
+
delete trimErr.loggingMetadata;
|
|
89
|
+
throw Object.assign(new BackendError(err.errorNumber, err.iTwinErrorId.key, err.message, err.loggingMetadata), trimErr);
|
|
90
90
|
}
|
|
91
91
|
/** @internal
|
|
92
92
|
* @deprecated in 4.8. Use [[makeIpcProxy]] for a type-safe interface.
|
package/lib/esm/IpcApp.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IpcApp.js","sourceRoot":"","sources":["../../src/IpcApp.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAoB,MAAM,qBAAqB,CAAC;AACrE,OAAO,EACL,YAAY,E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W,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,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC;IACtD,SAAS,KAAK,CAAC;CACvB","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module NativeApp\n */\n\nimport { IModelStatus, PickAsyncMethods } from \"@itwin/core-bentley\";\nimport {\n BackendError, IModelError, ipcAppChannels, IpcAppFunctions, IpcAppNotifications, IpcInvokeReturn, IpcListener, IpcSocketFrontend, iTwinChannel, RemoveFunction,\n} from \"@itwin/core-common\";\nimport { IModelApp, IModelAppOptions } from \"./IModelApp\";\nimport { _callIpcChannel } from \"./common/internal/Symbols\";\n\n/**\n * Options for [[IpcApp.startup]]\n * @public\n */\nexport interface IpcAppOptions {\n iModelApp?: IModelAppOptions;\n}\n\n/**\n * The frontend of apps with a dedicated backend that can use [Ipc]($docs/learning/IpcInterface.md).\n * @public\n */\nexport class IpcApp {\n private static _ipc: IpcSocketFrontend | undefined;\n /** Get the implementation of the [[IpcSocketFrontend]] interface. */\n\n private static get ipc(): IpcSocketFrontend { return this._ipc!; }\n\n /** Determine whether Ipc is available for this frontend. This will only be true if [[startup]] has been called on this class. */\n public static get isValid(): boolean { return undefined !== this._ipc; }\n\n /**\n * Establish a message handler function for the supplied channel over Ipc. The handler will be called when messages are sent for\n * the channel via [[BackendIpc.send]].\n * @param channel the name of the channel\n * @param handler the message handler\n * @returns A function to remove the handler\n * @note Ipc is only supported if [[isValid]] is true.\n */\n public static addListener(channel: string, handler: IpcListener): RemoveFunction {\n return this.ipc.addListener(iTwinChannel(channel), handler);\n }\n\n /**\n * Remove a previously registered listener\n * @param channel The name of the channel for the listener previously registered with [[addListener]]\n * @param listener The function passed to [[addListener]]\n */\n public static removeListener(channel: string, listener: IpcListener) {\n this.ipc.removeListener(iTwinChannel(channel), listener);\n }\n\n /**\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]]\n * @param channel The name of the channel for the method.\n * @see Electron [ipcRenderer.invoke](https://www.electronjs.org/docs/api/ipc-renderer) documentation for details.\n * Note that this interface may be implemented via Electron for desktop apps, or via\n * [WebSockets](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API) for mobile or web-based\n * Ipc connections. In either case, the Electron documentation provides the specifications for how it works.\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\n * primitive types and `ArrayBuffers` are allowed.\n */\n public static async invoke(channel: string, ...args: any[]): Promise<any> {\n return this.ipc.invoke(iTwinChannel(channel), ...args);\n }\n\n /**\n * Send a message over the socket.\n * @param channel The name of the channel for the message.\n * @param data The optional data of the message.\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\n * primitive types and `ArrayBuffers` are allowed.\n */\n public static send(channel: string, ...data: any[]) {\n return this.ipc.send(iTwinChannel(channel), ...data);\n }\n\n /**\n * Call a method on the backend through an Ipc channel.\n * @param channelName the channel registered by the backend handler.\n * @param methodName the name of a method implemented by the backend handler.\n * @param args arguments to `methodName`\n * @return a Promise with the return value from `methodName`\n * @note If the backend implementation throws an exception, this method will throw a [[BackendError]] exception\n * with the `errorNumber` and `message` from the backend.\n * @note Ipc is only supported if [[isValid]] is true.\n * @internal Use [[makeIpcProxy]] for a type-safe interface.\n */\n public static async [_callIpcChannel](channelName: string, methodName: string, ...args: any[]): Promise<any> {\n const retVal = (await this.invoke(channelName, methodName, ...args)) as IpcInvokeReturn;\n\n if (undefined !== retVal.iTwinError) {\n const error = new Error();\n if (retVal.iTwinError.stack === undefined)\n delete retVal.iTwinError.stack;\n Object.assign(error, retVal.iTwinError);\n throw error;\n } else if (undefined !== retVal.error) {\n const err = new BackendError(retVal.error.errorNumber, retVal.error.name, retVal.error.message);\n err.stack = retVal.error.stack;\n throw err;\n }\n return retVal.result;\n }\n\n /** @internal\n * @deprecated in 4.8. Use [[makeIpcProxy]] for a type-safe interface.\n */\n public static async callIpcChannel(channelName: string, methodName: string, ...args: any[]): Promise<any> {\n return this[_callIpcChannel](channelName, methodName, ...args);\n }\n\n /** Create a type safe Proxy object to make IPC calls to a registered backend interface.\n * @param channelName the channel registered by the backend handler.\n */\n public static makeIpcProxy<K>(channelName: string): PickAsyncMethods<K> {\n return new Proxy({} as PickAsyncMethods<K>, {\n get(_target, methodName: string) {\n return async (...args: any[]) =>\n IpcApp[_callIpcChannel](channelName, methodName, ...args);\n },\n });\n }\n\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\n * @param channelName the channel registered by the backend handler.\n * @param functionName the function to call on the handler.\n */\n public static makeIpcFunctionProxy<K>(channelName: string, functionName: string): PickAsyncMethods<K> {\n return new Proxy({} as PickAsyncMethods<K>, {\n get(_target, methodName: string) {\n return async (...args: any[]) =>\n IpcApp[_callIpcChannel](channelName, functionName, methodName, ...args);\n },\n });\n }\n\n /** A Proxy to call one of the [IpcAppFunctions]($common) functions via IPC. */\n public static appFunctionIpc = IpcApp.makeIpcProxy<IpcAppFunctions>(ipcAppChannels.functions);\n\n /** start an IpcApp.\n * @note this should not be called directly. It is called by NativeApp.startup */\n public static async startup(ipc: IpcSocketFrontend, opts?: IpcAppOptions) {\n this._ipc = ipc;\n IpcAppNotifyHandler.register(); // receives notifications from backend\n await IModelApp.startup(opts?.iModelApp);\n }\n\n /** @internal */\n public static async shutdown() {\n this._ipc = undefined;\n await IModelApp.shutdown();\n }\n}\n\n/**\n * Base class for all implementations of an Ipc notification response interface. This class is implemented on your frontend to supply\n * methods to receive notifications from your backend.\n *\n * Create a subclass to implement your Ipc response interface. Your class should be declared like this:\n * ```ts\n * class MyNotificationHandler extends NotificationHandler implements MyNotifications\n * ```\n * to ensure all method names and signatures are correct. Your methods cannot have a return value.\n *\n * Then, call `MyNotificationHandler.register` at startup to connect your class to your channel.\n * @public\n * @extensions\n */\nexport abstract class NotificationHandler {\n /** All subclasses must implement this method to specify their response channel name. */\n public abstract get channelName(): string;\n\n public registerImpl(): RemoveFunction {\n return IpcApp.addListener(this.channelName, (_evt: Event, funcName: string, ...args: any[]) => {\n const func = (this as any)[funcName];\n if (typeof func !== \"function\")\n throw new IModelError(IModelStatus.FunctionNotFound, `Method \"${this.constructor.name}.${funcName}\" not found on NotificationHandler registered for channel: ${this.channelName}`);\n\n func.call(this, ...args);\n });\n }\n\n /**\n * Register this class as the handler for notifications on its channel. This static method creates a new instance\n * that becomes the notification handler and is `this` when its methods are called.\n * @returns A function that can be called to remove the handler.\n * @note this method should only be called once per channel. If it is called multiple times, multiple handlers are established.\n */\n public static register(): RemoveFunction {\n return (new (this as any)() as NotificationHandler).registerImpl(); // create an instance of subclass. \"as any\" is necessary because base class is abstract\n }\n}\n\n/** IpcApp notifications from backend */\nclass IpcAppNotifyHandler extends NotificationHandler implements IpcAppNotifications {\n public get channelName() { return ipcAppChannels.appNotify; }\n public notifyApp() { }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"IpcApp.js","sourceRoot":"","sources":["../../src/IpcApp.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH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AC;IAC7B,CAAC;;AAGH;;;;;;;;;;;;;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,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC;IACtD,SAAS,KAAK,CAAC;CACvB","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module NativeApp\n */\n\nimport { BentleyError, IModelStatus, JsonUtils, PickAsyncMethods } from \"@itwin/core-bentley\";\nimport {\n BackendError, IModelError, ipcAppChannels, IpcAppFunctions, IpcAppNotifications, IpcInvokeReturn, IpcListener, IpcSocketFrontend, iTwinChannel,\n RemoveFunction,\n} from \"@itwin/core-common\";\nimport { _callIpcChannel } from \"./common/internal/Symbols\";\nimport { IModelApp, IModelAppOptions } from \"./IModelApp\";\n\n/**\n * Options for [[IpcApp.startup]]\n * @public\n */\nexport interface IpcAppOptions {\n iModelApp?: IModelAppOptions;\n}\n\n/**\n * The frontend of apps with a dedicated backend that can use [Ipc]($docs/learning/IpcInterface.md).\n * @public\n */\nexport class IpcApp {\n private static _ipc: IpcSocketFrontend | undefined;\n /** Get the implementation of the [[IpcSocketFrontend]] interface. */\n\n private static get ipc(): IpcSocketFrontend { return this._ipc!; }\n\n /** Determine whether Ipc is available for this frontend. This will only be true if [[startup]] has been called on this class. */\n public static get isValid(): boolean { return undefined !== this._ipc; }\n\n /**\n * Establish a message handler function for the supplied channel over Ipc. The handler will be called when messages are sent for\n * the channel via [[BackendIpc.send]].\n * @param channel the name of the channel\n * @param handler the message handler\n * @returns A function to remove the handler\n * @note Ipc is only supported if [[isValid]] is true.\n */\n public static addListener(channel: string, handler: IpcListener): RemoveFunction {\n return this.ipc.addListener(iTwinChannel(channel), handler);\n }\n\n /**\n * Remove a previously registered listener\n * @param channel The name of the channel for the listener previously registered with [[addListener]]\n * @param listener The function passed to [[addListener]]\n */\n public static removeListener(channel: string, listener: IpcListener) {\n this.ipc.removeListener(iTwinChannel(channel), listener);\n }\n\n /**\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]]\n * @param channel The name of the channel for the method.\n * @see Electron [ipcRenderer.invoke](https://www.electronjs.org/docs/api/ipc-renderer) documentation for details.\n * Note that this interface may be implemented via Electron for desktop apps, or via\n * [WebSockets](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API) for mobile or web-based\n * Ipc connections. In either case, the Electron documentation provides the specifications for how it works.\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\n * primitive types and `ArrayBuffers` are allowed.\n */\n public static async invoke(channel: string, ...args: any[]): Promise<any> {\n return this.ipc.invoke(iTwinChannel(channel), ...args);\n }\n\n /**\n * Send a message over the socket.\n * @param channel The name of the channel for the message.\n * @param data The optional data of the message.\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\n * primitive types and `ArrayBuffers` are allowed.\n */\n public static send(channel: string, ...data: any[]) {\n return this.ipc.send(iTwinChannel(channel), ...data);\n }\n\n /**\n * Call a method on the backend through an Ipc channel.\n * @param channelName the channel registered by the backend handler.\n * @param methodName the name of a method implemented by the backend handler.\n * @param args arguments to `methodName`\n * @return a Promise with the return value from `methodName`\n * @note If the backend implementation throws an exception, this method will throw an exception with its contents\n * @internal Use [[makeIpcProxy]] for a type-safe interface.\n */\n public static async [_callIpcChannel](channelName: string, methodName: string, ...args: any[]): Promise<any> {\n const retVal = (await this.invoke(channelName, methodName, ...args)) as IpcInvokeReturn;\n\n if (retVal.error === undefined)\n return retVal.result; // method was successful\n\n // backend threw an exception, rethrow one on frontend\n const err = retVal.error;\n if (!JsonUtils.isObject(err)) {\n // Exception wasn't an object?\n throw retVal.error; // eslint-disable-line @typescript-eslint/only-throw-error\n }\n\n // Note: for backwards compatibility, if the exception was from a BentleyError on the backend, throw an exception of type `BackendError`.\n if (!BentleyError.isError(err))\n throw Object.assign(new Error(typeof err.message === \"string\" ? err.message : \"unknown error\"), err);\n\n const trimErr = { ...err } as any;\n delete trimErr.iTwinErrorId // these are methods on BackendError and will cause Object.assign to fail.\n delete trimErr.loggingMetadata;\n throw Object.assign(new BackendError(err.errorNumber, err.iTwinErrorId.key, err.message, err.loggingMetadata), trimErr);\n }\n\n /** @internal\n * @deprecated in 4.8. Use [[makeIpcProxy]] for a type-safe interface.\n */\n public static async callIpcChannel(channelName: string, methodName: string, ...args: any[]): Promise<any> {\n return this[_callIpcChannel](channelName, methodName, ...args);\n }\n\n /** Create a type safe Proxy object to make IPC calls to a registered backend interface.\n * @param channelName the channel registered by the backend handler.\n */\n public static makeIpcProxy<K>(channelName: string): PickAsyncMethods<K> {\n return new Proxy({} as PickAsyncMethods<K>, {\n get(_target, methodName: string) {\n return async (...args: any[]) =>\n IpcApp[_callIpcChannel](channelName, methodName, ...args);\n },\n });\n }\n\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\n * @param channelName the channel registered by the backend handler.\n * @param functionName the function to call on the handler.\n */\n public static makeIpcFunctionProxy<K>(channelName: string, functionName: string): PickAsyncMethods<K> {\n return new Proxy({} as PickAsyncMethods<K>, {\n get(_target, methodName: string) {\n return async (...args: any[]) =>\n IpcApp[_callIpcChannel](channelName, functionName, methodName, ...args);\n },\n });\n }\n\n /** A Proxy to call one of the [IpcAppFunctions]($common) functions via IPC. */\n public static appFunctionIpc = IpcApp.makeIpcProxy<IpcAppFunctions>(ipcAppChannels.functions);\n\n /** start an IpcApp.\n * @note this should not be called directly. It is called by NativeApp.startup */\n public static async startup(ipc: IpcSocketFrontend, opts?: IpcAppOptions) {\n this._ipc = ipc;\n IpcAppNotifyHandler.register(); // receives notifications from backend\n await IModelApp.startup(opts?.iModelApp);\n }\n\n /** @internal */\n public static async shutdown() {\n this._ipc = undefined;\n await IModelApp.shutdown();\n }\n}\n\n/**\n * Base class for all implementations of an Ipc notification response interface. This class is implemented on your frontend to supply\n * methods to receive notifications from your backend.\n *\n * Create a subclass to implement your Ipc response interface. Your class should be declared like this:\n * ```ts\n * class MyNotificationHandler extends NotificationHandler implements MyNotifications\n * ```\n * to ensure all method names and signatures are correct. Your methods cannot have a return value.\n *\n * Then, call `MyNotificationHandler.register` at startup to connect your class to your channel.\n * @public\n * @extensions\n */\nexport abstract class NotificationHandler {\n /** All subclasses must implement this method to specify their response channel name. */\n public abstract get channelName(): string;\n\n public registerImpl(): RemoveFunction {\n return IpcApp.addListener(this.channelName, (_evt: Event, funcName: string, ...args: any[]) => {\n const func = (this as any)[funcName];\n if (typeof func !== \"function\")\n throw new IModelError(IModelStatus.FunctionNotFound, `Method \"${this.constructor.name}.${funcName}\" not found on NotificationHandler registered for channel: ${this.channelName}`);\n\n func.call(this, ...args);\n });\n }\n\n /**\n * Register this class as the handler for notifications on its channel. This static method creates a new instance\n * that becomes the notification handler and is `this` when its methods are called.\n * @returns A function that can be called to remove the handler.\n * @note this method should only be called once per channel. If it is called multiple times, multiple handlers are established.\n */\n public static register(): RemoveFunction {\n return (new (this as any)() as NotificationHandler).registerImpl(); // create an instance of subclass. \"as any\" is necessary because base class is abstract\n }\n}\n\n/** IpcApp notifications from backend */\nclass IpcAppNotifyHandler extends NotificationHandler implements IpcAppNotifications {\n public get channelName() { return ipcAppChannels.appNotify; }\n public notifyApp() { }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RealityTileLoader.d.ts","sourceRoot":"","sources":["../../../../src/internal/tile/RealityTileLoader.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAU,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAoB,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,SAAS,EAAmC,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAGnG,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAkB,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1D,OAAO,EACO,gBAAgB,EAAkE,eAAe,EAC7G,WAAW,EAAE,kBAAkB,EAAmB,IAAI,EAAe,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,kBAAkB,EAAE,QAAQ,EAC/I,MAAM,qBAAqB,CAAC;AAQ7B;;GAEG;AACH,8BAAsB,iBAAiB;IAKlB,OAAO,CAAC,gBAAgB,CAAC;IAJ5C,OAAO,CAAC,oBAAoB,CAAS;IACrC,SAAgB,yBAAyB,EAAE,MAAM,CAAC;IAClD,SAAgB,wBAAwB,EAAE,MAAM,CAAC;gBAEtB,gBAAgB,CAAC,EAAE,OAAO,YAAA;IAK9C,mBAAmB,CAAC,IAAI,EAAE,IAAI,E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|
|
@@ -74,7 +74,7 @@ export class RealityTileLoader {
|
|
|
74
74
|
const { is3d, yAxisUp, iModel, modelId } = tile.realityRoot;
|
|
75
75
|
let reader;
|
|
76
76
|
const tileData = {
|
|
77
|
-
ecefTransform: tile.tree.iModel.
|
|
77
|
+
ecefTransform: tile.tree.iModel.ecefLocation?.getTransform() ?? Transform.createIdentity(),
|
|
78
78
|
range: tile.range,
|
|
79
79
|
layerClassifiers: tile.tree.layerHandler?.layerClassifiers,
|
|
80
80
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RealityTileLoader.js","sourceRoot":"","sources":["../../../../src/internal/tile/RealityTileLoader.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,UAAU,EAAqB,MAAM,oBAAoB,CAAC;AACnG,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,OAAO,EAAE,cAAc,EAAY,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EACL,UAAU,EAAoB,8BAA8B,EAAE,kBAAkB,EAAE,UAAU,EAAE,eAAe,EAAE,UAAU,EAAE,UAAU,EAAE,yBAAyB,GAEjK,MAAM,qBAAqB,CAAC;AAG7B,MAAM,wBAAwB,GAAG,8BAA8B,CAAC,EAAE,CAAC,CAAC;AAEpE,MAAM,sBAAsB,GAAG,IAAI,OAAO,EAAE,CAAC;AAC7C,MAAM,qBAAqB,GAAG,IAAI,OAAO,EAAE,CAAC;AAE5C;;GAEG;AACH,MAAM,OAAgB,iBAAiB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AC;YAED,oDAAoD;YACpD,MAAM,aAAa,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC;YAClC,MAAM,gBAAgB,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,GAAG,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC,yBAAyB;YAErG,iFAAiF;YACjF,gIAAgI;YAChI,MAAM,sBAAsB,GAAG,GAAG,CAAC;YACnC,MAAM,QAAQ,GAAG,aAAa,GAAG,CAAC,GAAG,GAAG,sBAAsB,CAAC,GAAG,gBAAgB,GAAG,sBAAsB,CAAC;YAE5G,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;QAChD,CAAC;QAED,OAAO,WAAW,CAAC;IACrB,CAAC;CACF;AAED;;EAEE;AACF,MAAM,UAAU,4BAA4B,CAAC,YAAwB,EAAE,OAAgB,EAAE,OAAgB;IACvG,IAAI,GAAoB,CAAC;IACzB,IAAI,OAAO,EAAE,CAAC;QACZ,IAAI,CAAC;YACH,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;QACzB,CAAC;QAAC,MAAM,CAAC;YACP,GAAG,GAAG,SAAS,CAAC;QAClB,CAAC;IACH,CAAC;IACD,OAAO,eAAe,CAAC,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,YAAY,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;AAC3G,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Tiles\n */\n\nimport { assert, ByteStream } from \"@itwin/core-bentley\";\nimport { Point2d, Point3d, Transform } from \"@itwin/core-geometry\";\nimport { BatchType, CompositeTileHeader, TileFormat, ViewFlagOverrides } from \"@itwin/core-common\";\nimport { IModelApp } from \"../../IModelApp\";\nimport { GraphicBranch } from \"../../render/GraphicBranch\";\nimport { RenderSystem } from \"../../render/RenderSystem\";\nimport { ScreenViewport, Viewport } from \"../../Viewport\";\nimport { GltfWrapMode } from \"../../common/gltf/GltfSchema\";\nimport {\n B3dmReader, BatchedTileIdMap, createDefaultViewFlagOverrides, GltfGraphicsReader, GltfReader, GltfReaderProps, I3dmReader, ImdlReader, readPointCloudTileContent,\n RealityTile, RealityTileContent, RealityTileTree, Tile, TileContent, TileDrawArgs, TileLoadPriority, TileRequest, TileRequestChannel, TileUser,\n} from \"../../tile/internal\";\nimport { LayerTileData } from \"../render/webgl/MapLayerParams\";\n\nconst defaultViewFlagOverrides = createDefaultViewFlagOverrides({});\n\nconst scratchTileCenterWorld = new Point3d();\nconst scratchTileCenterView = new Point3d();\n\n/** Serves as a \"handler\" for a specific type of [[TileTree]]. Its primary responsibilities involve loading tile content.\n * @internal\n */\nexport abstract class RealityTileLoader {\n private _containsPointClouds = false;\n public readonly preloadRealityParentDepth: number;\n public readonly preloadRealityParentSkip: number;\n\n public constructor(private _produceGeometry?: boolean) {\n this.preloadRealityParentDepth = IModelApp.tileAdmin.contextPreloadParentDepth;\n this.preloadRealityParentSkip = IModelApp.tileAdmin.contextPreloadParentSkip;\n }\n\n public computeTilePriority(tile: Tile, viewports: Iterable<Viewport>, _users: Iterable<TileUser>): number {\n // ###TODO: Handle case where tile tree reference(s) have a transform different from tree's (background map with ground bias).\n return RealityTileLoader.computeTileLocationPriority(tile, viewports, tile.tree.iModelTransform);\n }\n\n public abstract loadChildren(tile: RealityTile): Promise<Tile[] | undefined>;\n public abstract getRequestChannel(tile: Tile): TileRequestChannel;\n public abstract requestTileContent(tile: Tile, isCanceled: () => boolean): Promise<TileRequest.Response>;\n public get wantDeduplicatedVertices(): boolean { return false; }\n public abstract get maxDepth(): number;\n public abstract get minDepth(): number;\n public abstract get priority(): TileLoadPriority;\n protected get _batchType(): BatchType { return BatchType.Primary; }\n protected get _loadEdges(): boolean { return true; }\n public getBatchIdMap(): BatchedTileIdMap | undefined { return undefined; }\n public get isContentUnbounded(): boolean { return false; }\n public get containsPointClouds(): boolean { return this._containsPointClouds; }\n public get parentsAndChildrenExclusive(): boolean { return true; }\n public forceTileLoad(_tile: Tile): boolean { return false; }\n public get maximumScreenSpaceError(): number | undefined { return undefined; }\n\n public processSelectedTiles(selected: Tile[], _args: TileDrawArgs): Tile[] { return selected; }\n\n // NB: The isCanceled arg is chiefly for tests...in usual case it just returns false if the tile is no longer in 'loading' state.\n public async loadTileContent(tile: Tile, data: TileRequest.ResponseData, system: RenderSystem, isCanceled?: () => boolean): Promise<RealityTileContent> {\n assert(data instanceof Uint8Array);\n const blob = data;\n const streamBuffer = ByteStream.fromUint8Array(blob);\n const realityTile = tile as RealityTile;\n return this._produceGeometry ? this.loadGeometryFromStream(realityTile, streamBuffer, system) : this.loadGraphicsFromStream(realityTile, streamBuffer, system, isCanceled);\n }\n\n private _getFormat(streamBuffer: ByteStream) {\n const position = streamBuffer.curPos;\n const format = streamBuffer.readUint32();\n streamBuffer.curPos = position;\n return format;\n\n }\n\n public async loadGeometryFromStream(tile: RealityTile, streamBuffer: ByteStream, system: RenderSystem): Promise<RealityTileContent> {\n const format = this._getFormat(streamBuffer);\n if (format !== TileFormat.B3dm)\n return {};\n\n const { is3d, yAxisUp, iModel, modelId } = tile.realityRoot;\n const reader = B3dmReader.create(streamBuffer, iModel, modelId, is3d, tile.contentRange, system, yAxisUp, tile.isLeaf, tile.center, tile.transformToRoot, undefined, this.getBatchIdMap());\n if (reader)\n reader.defaultWrapMode = GltfWrapMode.ClampToEdge;\n\n return { geometry: reader?.readGltfAndCreateGeometry(tile.tree.iModelTransform) };\n }\n\n private async loadGraphicsFromStream(tile: RealityTile, streamBuffer: ByteStream, system: RenderSystem, isCanceled?: () => boolean): Promise<TileContent> {\n const format = this._getFormat(streamBuffer);\n if (undefined === isCanceled)\n isCanceled = () => !tile.isLoading;\n\n const { is3d, yAxisUp, iModel, modelId } = tile.realityRoot;\n let reader: GltfReader | ImdlReader | undefined;\n const tileData: LayerTileData = {\n ecefTransform: tile.tree.iModel.getEcefTransform(),\n range: tile.range,\n layerClassifiers: tile.tree.layerHandler?.layerClassifiers,\n };\n switch (format) {\n case TileFormat.IModel:\n reader = ImdlReader.create({\n stream: streamBuffer,\n iModel,\n modelId,\n is3d,\n system,\n isCanceled,\n });\n break;\n case TileFormat.Pnts:\n this._containsPointClouds = true;\n const res = await readPointCloudTileContent(streamBuffer, iModel, modelId, is3d, tile, system);\n let graphic = res.graphic;\n const rtcCenter = res.rtcCenter;\n if (graphic && (rtcCenter || tile.transformToRoot && !tile.transformToRoot.isIdentity)) {\n const transformBranch = new GraphicBranch(true);\n transformBranch.add(graphic);\n let xform: Transform;\n if (!tile.transformToRoot && rtcCenter)\n xform = Transform.createTranslation(rtcCenter);\n else {\n if (rtcCenter)\n xform = Transform.createOriginAndMatrix(rtcCenter.plus(tile.transformToRoot!.origin), tile.transformToRoot!.matrix);\n else\n xform = tile.transformToRoot!;\n }\n graphic = system.createBranch(transformBranch, xform);\n }\n\n return { graphic };\n case TileFormat.B3dm:\n reader = B3dmReader.create(streamBuffer, iModel, modelId, is3d, tile.contentRange, system, yAxisUp, tile.isLeaf, tile.center, tile.transformToRoot, isCanceled, this.getBatchIdMap(), this.wantDeduplicatedVertices, tileData);\n if (reader) {\n // glTF spec defaults wrap mode to \"repeat\" but many reality tiles omit the wrap mode and should not repeat.\n // The render system also currently only produces mip-maps for repeating textures, and we don't want mip-maps for reality tile textures.\n assert(reader instanceof GltfReader);\n reader.defaultWrapMode = GltfWrapMode.ClampToEdge;\n }\n\n break;\n case TileFormat.I3dm:\n reader = I3dmReader.create(streamBuffer, iModel, modelId, is3d, tile.contentRange, system, yAxisUp, tile.isLeaf, isCanceled, undefined, this.wantDeduplicatedVertices, tileData);\n break;\n case TileFormat.Gltf:\n const tree = tile.tree as RealityTileTree;\n const baseUrl = tree.baseUrl;\n const props = createReaderPropsWithBaseUrl(streamBuffer, yAxisUp, baseUrl);\n if (props) {\n reader = new GltfGraphicsReader(props, {\n iModel,\n gltf: props.glTF,\n contentRange: tile.contentRange,\n transform: tile.transformToRoot,\n hasChildren: !tile.isLeaf,\n pickableOptions: { id: modelId },\n idMap: this.getBatchIdMap(),\n tileData\n });\n }\n break;\n case TileFormat.Cmpt:\n const header = new CompositeTileHeader(streamBuffer);\n if (!header.isValid)\n return {};\n\n const branch = new GraphicBranch(true);\n for (let i = 0; i < header.tileCount; i++) {\n const tilePosition = streamBuffer.curPos;\n streamBuffer.advance(8); // Skip magic and version.\n const tileBytes = streamBuffer.readUint32();\n streamBuffer.curPos = tilePosition;\n const result = await this.loadGraphicsFromStream(tile, streamBuffer, system, isCanceled);\n if (result.graphic)\n branch.add(result.graphic);\n streamBuffer.curPos = tilePosition + tileBytes;\n }\n return { graphic: branch.isEmpty ? undefined : system.createBranch(branch, Transform.createIdentity()), isLeaf: tile.isLeaf };\n\n default:\n assert(false, `unknown tile format ${format}`);\n break;\n }\n\n let content: TileContent = {};\n if (undefined !== reader) {\n try {\n content = await reader.read();\n if (content.containsPointCloud)\n this._containsPointClouds = true;\n } catch {\n // Failure to load should prevent us from trying to load children\n content.isLeaf = true;\n }\n }\n\n return content;\n }\n\n public get viewFlagOverrides(): ViewFlagOverrides { return defaultViewFlagOverrides; }\n\n public static computeTileLocationPriority(tile: Tile, viewports: Iterable<Viewport>, location: Transform): number {\n // Compute a priority value for tiles that are:\n // * Closer to the eye;\n // * Closer to the center of attention (center of the screen or zoom target).\n // This way, we can load in priority tiles that are more likely to be important.\n let center: Point3d | undefined;\n let minDistance = 1.0;\n\n const currentInputState = IModelApp.toolAdmin.currentInputState;\n const now = Date.now();\n const wheelEventRelevanceTimeout = 1000; // Wheel events older than this value will not be considered\n\n for (const viewport of viewports) {\n center = center ?? location.multiplyPoint3d(tile.center, scratchTileCenterWorld);\n const npc = viewport.worldToNpc(center, scratchTileCenterView);\n\n let focusPoint = new Point2d(0.5, 0.5);\n\n if (currentInputState.viewport === viewport && viewport instanceof ScreenViewport) {\n // Try to get a better target point from the last zoom target\n const { lastWheelEvent } = currentInputState;\n\n if (lastWheelEvent !== undefined && now - lastWheelEvent.time < wheelEventRelevanceTimeout) {\n const focusPointCandidate = Point2d.fromJSON(viewport.worldToNpc(lastWheelEvent.point));\n\n if (focusPointCandidate.x > 0 && focusPointCandidate.x < 1 && focusPointCandidate.y > 0 && focusPointCandidate.y < 1)\n focusPoint = focusPointCandidate;\n }\n }\n\n // NB: In NPC coords, 0 = far plane, 1 = near plane.\n const distanceToEye = 1.0 - npc.z;\n const distanceToCenter = Math.min(npc.distanceXY(focusPoint) / 0.707, 1.0); // Math.sqrt(0.5) = 0.707\n\n // Distance is a mix of the two previously computed values, still in range [0; 1]\n // We use this factor to determine how much the distance to the center of attention is important compared to distance to the eye\n const distanceToCenterWeight = 0.3;\n const distance = distanceToEye * (1.0 - distanceToCenterWeight) + distanceToCenter * distanceToCenterWeight;\n\n minDistance = Math.min(distance, minDistance);\n }\n\n return minDistance;\n }\n}\n\n/** Exposed strictly for testing purposes.\n* @internal\n*/\nexport function createReaderPropsWithBaseUrl(streamBuffer: ByteStream, yAxisUp: boolean, baseUrl?: string): GltfReaderProps | undefined {\n let url: URL | undefined;\n if (baseUrl) {\n try {\n url = new URL(baseUrl);\n } catch {\n url = undefined;\n }\n }\n return GltfReaderProps.create(streamBuffer.nextBytes(streamBuffer.arrayBuffer.byteLength), yAxisUp, url);\n}"]}
|
|
1
|
+
{"version":3,"file":"RealityTileLoader.js","sourceRoot":"","sources":["../../../../src/internal/tile/RealityTileLoader.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE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gB;IACvG,IAAI,GAAoB,CAAC;IACzB,IAAI,OAAO,EAAE,CAAC;QACZ,IAAI,CAAC;YACH,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;QACzB,CAAC;QAAC,MAAM,CAAC;YACP,GAAG,GAAG,SAAS,CAAC;QAClB,CAAC;IACH,CAAC;IACD,OAAO,eAAe,CAAC,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,YAAY,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;AAC3G,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Tiles\n */\n\nimport { assert, ByteStream } from \"@itwin/core-bentley\";\nimport { Point2d, Point3d, Transform } from \"@itwin/core-geometry\";\nimport { BatchType, CompositeTileHeader, TileFormat, ViewFlagOverrides } from \"@itwin/core-common\";\nimport { IModelApp } from \"../../IModelApp\";\nimport { GraphicBranch } from \"../../render/GraphicBranch\";\nimport { RenderSystem } from \"../../render/RenderSystem\";\nimport { ScreenViewport, Viewport } from \"../../Viewport\";\nimport { GltfWrapMode } from \"../../common/gltf/GltfSchema\";\nimport {\n B3dmReader, BatchedTileIdMap, createDefaultViewFlagOverrides, GltfGraphicsReader, GltfReader, GltfReaderProps, I3dmReader, ImdlReader, readPointCloudTileContent,\n RealityTile, RealityTileContent, RealityTileTree, Tile, TileContent, TileDrawArgs, TileLoadPriority, TileRequest, TileRequestChannel, TileUser,\n} from \"../../tile/internal\";\nimport { LayerTileData } from \"../render/webgl/MapLayerParams\";\n\nconst defaultViewFlagOverrides = createDefaultViewFlagOverrides({});\n\nconst scratchTileCenterWorld = new Point3d();\nconst scratchTileCenterView = new Point3d();\n\n/** Serves as a \"handler\" for a specific type of [[TileTree]]. Its primary responsibilities involve loading tile content.\n * @internal\n */\nexport abstract class RealityTileLoader {\n private _containsPointClouds = false;\n public readonly preloadRealityParentDepth: number;\n public readonly preloadRealityParentSkip: number;\n\n public constructor(private _produceGeometry?: boolean) {\n this.preloadRealityParentDepth = IModelApp.tileAdmin.contextPreloadParentDepth;\n this.preloadRealityParentSkip = IModelApp.tileAdmin.contextPreloadParentSkip;\n }\n\n public computeTilePriority(tile: Tile, viewports: Iterable<Viewport>, _users: Iterable<TileUser>): number {\n // ###TODO: Handle case where tile tree reference(s) have a transform different from tree's (background map with ground bias).\n return RealityTileLoader.computeTileLocationPriority(tile, viewports, tile.tree.iModelTransform);\n }\n\n public abstract loadChildren(tile: RealityTile): Promise<Tile[] | undefined>;\n public abstract getRequestChannel(tile: Tile): TileRequestChannel;\n public abstract requestTileContent(tile: Tile, isCanceled: () => boolean): Promise<TileRequest.Response>;\n public get wantDeduplicatedVertices(): boolean { return false; }\n public abstract get maxDepth(): number;\n public abstract get minDepth(): number;\n public abstract get priority(): TileLoadPriority;\n protected get _batchType(): BatchType { return BatchType.Primary; }\n protected get _loadEdges(): boolean { return true; }\n public getBatchIdMap(): BatchedTileIdMap | undefined { return undefined; }\n public get isContentUnbounded(): boolean { return false; }\n public get containsPointClouds(): boolean { return this._containsPointClouds; }\n public get parentsAndChildrenExclusive(): boolean { return true; }\n public forceTileLoad(_tile: Tile): boolean { return false; }\n public get maximumScreenSpaceError(): number | undefined { return undefined; }\n\n public processSelectedTiles(selected: Tile[], _args: TileDrawArgs): Tile[] { return selected; }\n\n // NB: The isCanceled arg is chiefly for tests...in usual case it just returns false if the tile is no longer in 'loading' state.\n public async loadTileContent(tile: Tile, data: TileRequest.ResponseData, system: RenderSystem, isCanceled?: () => boolean): Promise<RealityTileContent> {\n assert(data instanceof Uint8Array);\n const blob = data;\n const streamBuffer = ByteStream.fromUint8Array(blob);\n const realityTile = tile as RealityTile;\n return this._produceGeometry ? this.loadGeometryFromStream(realityTile, streamBuffer, system) : this.loadGraphicsFromStream(realityTile, streamBuffer, system, isCanceled);\n }\n\n private _getFormat(streamBuffer: ByteStream) {\n const position = streamBuffer.curPos;\n const format = streamBuffer.readUint32();\n streamBuffer.curPos = position;\n return format;\n\n }\n\n public async loadGeometryFromStream(tile: RealityTile, streamBuffer: ByteStream, system: RenderSystem): Promise<RealityTileContent> {\n const format = this._getFormat(streamBuffer);\n if (format !== TileFormat.B3dm)\n return {};\n\n const { is3d, yAxisUp, iModel, modelId } = tile.realityRoot;\n const reader = B3dmReader.create(streamBuffer, iModel, modelId, is3d, tile.contentRange, system, yAxisUp, tile.isLeaf, tile.center, tile.transformToRoot, undefined, this.getBatchIdMap());\n if (reader)\n reader.defaultWrapMode = GltfWrapMode.ClampToEdge;\n\n return { geometry: reader?.readGltfAndCreateGeometry(tile.tree.iModelTransform) };\n }\n\n private async loadGraphicsFromStream(tile: RealityTile, streamBuffer: ByteStream, system: RenderSystem, isCanceled?: () => boolean): Promise<TileContent> {\n const format = this._getFormat(streamBuffer);\n if (undefined === isCanceled)\n isCanceled = () => !tile.isLoading;\n\n const { is3d, yAxisUp, iModel, modelId } = tile.realityRoot;\n let reader: GltfReader | ImdlReader | undefined;\n\n const tileData: LayerTileData = {\n ecefTransform: tile.tree.iModel.ecefLocation?.getTransform() ?? Transform.createIdentity(),\n range: tile.range,\n layerClassifiers: tile.tree.layerHandler?.layerClassifiers,\n };\n\n switch (format) {\n case TileFormat.IModel:\n reader = ImdlReader.create({\n stream: streamBuffer,\n iModel,\n modelId,\n is3d,\n system,\n isCanceled,\n });\n break;\n case TileFormat.Pnts:\n this._containsPointClouds = true;\n const res = await readPointCloudTileContent(streamBuffer, iModel, modelId, is3d, tile, system);\n let graphic = res.graphic;\n const rtcCenter = res.rtcCenter;\n if (graphic && (rtcCenter || tile.transformToRoot && !tile.transformToRoot.isIdentity)) {\n const transformBranch = new GraphicBranch(true);\n transformBranch.add(graphic);\n let xform: Transform;\n if (!tile.transformToRoot && rtcCenter)\n xform = Transform.createTranslation(rtcCenter);\n else {\n if (rtcCenter)\n xform = Transform.createOriginAndMatrix(rtcCenter.plus(tile.transformToRoot!.origin), tile.transformToRoot!.matrix);\n else\n xform = tile.transformToRoot!;\n }\n graphic = system.createBranch(transformBranch, xform);\n }\n\n return { graphic };\n case TileFormat.B3dm:\n reader = B3dmReader.create(streamBuffer, iModel, modelId, is3d, tile.contentRange, system, yAxisUp, tile.isLeaf, tile.center, tile.transformToRoot, isCanceled, this.getBatchIdMap(), this.wantDeduplicatedVertices, tileData);\n if (reader) {\n // glTF spec defaults wrap mode to \"repeat\" but many reality tiles omit the wrap mode and should not repeat.\n // The render system also currently only produces mip-maps for repeating textures, and we don't want mip-maps for reality tile textures.\n assert(reader instanceof GltfReader);\n reader.defaultWrapMode = GltfWrapMode.ClampToEdge;\n }\n\n break;\n case TileFormat.I3dm:\n reader = I3dmReader.create(streamBuffer, iModel, modelId, is3d, tile.contentRange, system, yAxisUp, tile.isLeaf, isCanceled, undefined, this.wantDeduplicatedVertices, tileData);\n break;\n case TileFormat.Gltf:\n const tree = tile.tree as RealityTileTree;\n const baseUrl = tree.baseUrl;\n const props = createReaderPropsWithBaseUrl(streamBuffer, yAxisUp, baseUrl);\n if (props) {\n reader = new GltfGraphicsReader(props, {\n iModel,\n gltf: props.glTF,\n contentRange: tile.contentRange,\n transform: tile.transformToRoot,\n hasChildren: !tile.isLeaf,\n pickableOptions: { id: modelId },\n idMap: this.getBatchIdMap(),\n tileData\n });\n }\n break;\n case TileFormat.Cmpt:\n const header = new CompositeTileHeader(streamBuffer);\n if (!header.isValid)\n return {};\n\n const branch = new GraphicBranch(true);\n for (let i = 0; i < header.tileCount; i++) {\n const tilePosition = streamBuffer.curPos;\n streamBuffer.advance(8); // Skip magic and version.\n const tileBytes = streamBuffer.readUint32();\n streamBuffer.curPos = tilePosition;\n const result = await this.loadGraphicsFromStream(tile, streamBuffer, system, isCanceled);\n if (result.graphic)\n branch.add(result.graphic);\n streamBuffer.curPos = tilePosition + tileBytes;\n }\n return { graphic: branch.isEmpty ? undefined : system.createBranch(branch, Transform.createIdentity()), isLeaf: tile.isLeaf };\n\n default:\n assert(false, `unknown tile format ${format}`);\n break;\n }\n\n let content: TileContent = {};\n if (undefined !== reader) {\n try {\n content = await reader.read();\n if (content.containsPointCloud)\n this._containsPointClouds = true;\n } catch {\n // Failure to load should prevent us from trying to load children\n content.isLeaf = true;\n }\n }\n\n return content;\n }\n\n public get viewFlagOverrides(): ViewFlagOverrides { return defaultViewFlagOverrides; }\n\n public static computeTileLocationPriority(tile: Tile, viewports: Iterable<Viewport>, location: Transform): number {\n // Compute a priority value for tiles that are:\n // * Closer to the eye;\n // * Closer to the center of attention (center of the screen or zoom target).\n // This way, we can load in priority tiles that are more likely to be important.\n let center: Point3d | undefined;\n let minDistance = 1.0;\n\n const currentInputState = IModelApp.toolAdmin.currentInputState;\n const now = Date.now();\n const wheelEventRelevanceTimeout = 1000; // Wheel events older than this value will not be considered\n\n for (const viewport of viewports) {\n center = center ?? location.multiplyPoint3d(tile.center, scratchTileCenterWorld);\n const npc = viewport.worldToNpc(center, scratchTileCenterView);\n\n let focusPoint = new Point2d(0.5, 0.5);\n\n if (currentInputState.viewport === viewport && viewport instanceof ScreenViewport) {\n // Try to get a better target point from the last zoom target\n const { lastWheelEvent } = currentInputState;\n\n if (lastWheelEvent !== undefined && now - lastWheelEvent.time < wheelEventRelevanceTimeout) {\n const focusPointCandidate = Point2d.fromJSON(viewport.worldToNpc(lastWheelEvent.point));\n\n if (focusPointCandidate.x > 0 && focusPointCandidate.x < 1 && focusPointCandidate.y > 0 && focusPointCandidate.y < 1)\n focusPoint = focusPointCandidate;\n }\n }\n\n // NB: In NPC coords, 0 = far plane, 1 = near plane.\n const distanceToEye = 1.0 - npc.z;\n const distanceToCenter = Math.min(npc.distanceXY(focusPoint) / 0.707, 1.0); // Math.sqrt(0.5) = 0.707\n\n // Distance is a mix of the two previously computed values, still in range [0; 1]\n // We use this factor to determine how much the distance to the center of attention is important compared to distance to the eye\n const distanceToCenterWeight = 0.3;\n const distance = distanceToEye * (1.0 - distanceToCenterWeight) + distanceToCenter * distanceToCenterWeight;\n\n minDistance = Math.min(distance, minDistance);\n }\n\n return minDistance;\n }\n}\n\n/** Exposed strictly for testing purposes.\n* @internal\n*/\nexport function createReaderPropsWithBaseUrl(streamBuffer: ByteStream, yAxisUp: boolean, baseUrl?: string): GltfReaderProps | undefined {\n let url: URL | undefined;\n if (baseUrl) {\n try {\n url = new URL(baseUrl);\n } catch {\n url = undefined;\n }\n }\n return GltfReaderProps.create(streamBuffer.nextBytes(streamBuffer.arrayBuffer.byteLength), yAxisUp, url);\n}"]}
|