@itwin/core-common 4.1.0-dev.7 → 4.1.0-dev.71
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/CHANGELOG.md +83 -1
- package/lib/cjs/BriefcaseTypes.d.ts +13 -1
- package/lib/cjs/BriefcaseTypes.d.ts.map +1 -1
- package/lib/cjs/BriefcaseTypes.js.map +1 -1
- package/lib/cjs/ChangedElements.d.ts +2 -0
- package/lib/cjs/ChangedElements.d.ts.map +1 -1
- package/lib/cjs/ChangedElements.js +2 -0
- package/lib/cjs/ChangedElements.js.map +1 -1
- package/lib/cjs/ConcurrentQuery.d.ts +26 -2
- package/lib/cjs/ConcurrentQuery.d.ts.map +1 -1
- package/lib/cjs/ConcurrentQuery.js +29 -3
- package/lib/cjs/ConcurrentQuery.js.map +1 -1
- package/lib/cjs/DisplayStyleSettings.d.ts +1 -15
- package/lib/cjs/DisplayStyleSettings.d.ts.map +1 -1
- package/lib/cjs/DisplayStyleSettings.js +1 -15
- package/lib/cjs/DisplayStyleSettings.js.map +1 -1
- package/lib/cjs/ECSqlReader.d.ts +164 -7
- package/lib/cjs/ECSqlReader.d.ts.map +1 -1
- package/lib/cjs/ECSqlReader.js +124 -12
- package/lib/cjs/ECSqlReader.js.map +1 -1
- package/lib/cjs/ElementProps.d.ts +2 -2
- package/lib/cjs/ElementProps.js.map +1 -1
- package/lib/cjs/EntityProps.js +2 -2
- package/lib/cjs/EntityProps.js.map +1 -1
- package/lib/cjs/FeatureIndex.d.ts +50 -4
- package/lib/cjs/FeatureIndex.d.ts.map +1 -1
- package/lib/cjs/FeatureIndex.js +44 -4
- package/lib/cjs/FeatureIndex.js.map +1 -1
- package/lib/cjs/FeatureTable.d.ts +44 -20
- package/lib/cjs/FeatureTable.d.ts.map +1 -1
- package/lib/cjs/FeatureTable.js +17 -2
- package/lib/cjs/FeatureTable.js.map +1 -1
- package/lib/cjs/IModel.d.ts +1 -1
- package/lib/cjs/IModel.d.ts.map +1 -1
- package/lib/cjs/IModel.js +1 -1
- package/lib/cjs/IModel.js.map +1 -1
- package/lib/cjs/IpcAppProps.d.ts +6 -6
- package/lib/cjs/IpcAppProps.d.ts.map +1 -1
- package/lib/cjs/IpcAppProps.js +8 -9
- package/lib/cjs/IpcAppProps.js.map +1 -1
- package/lib/cjs/NativeAppProps.d.ts +4 -3
- package/lib/cjs/NativeAppProps.d.ts.map +1 -1
- package/lib/cjs/NativeAppProps.js +5 -4
- package/lib/cjs/NativeAppProps.js.map +1 -1
- package/lib/cjs/QPoint.d.ts +3 -3
- package/lib/cjs/QPoint.js +3 -3
- package/lib/cjs/QPoint.js.map +1 -1
- package/lib/cjs/Render.d.ts +27 -35
- package/lib/cjs/Render.d.ts.map +1 -1
- package/lib/cjs/Render.js +4 -67
- package/lib/cjs/Render.js.map +1 -1
- package/lib/cjs/RpcInterface.d.ts +1 -1
- package/lib/cjs/RpcInterface.d.ts.map +1 -1
- package/lib/cjs/RpcInterface.js +26 -25
- package/lib/cjs/RpcInterface.js.map +1 -1
- package/lib/cjs/SkyBox.d.ts +3 -3
- package/lib/cjs/SkyBox.d.ts.map +1 -1
- package/lib/cjs/SkyBox.js +3 -3
- package/lib/cjs/SkyBox.js.map +1 -1
- package/lib/cjs/ViewFlags.d.ts +4 -4
- package/lib/cjs/ViewFlags.d.ts.map +1 -1
- package/lib/cjs/ViewFlags.js +4 -4
- package/lib/cjs/ViewFlags.js.map +1 -1
- package/lib/cjs/ViewProps.d.ts +429 -5
- package/lib/cjs/ViewProps.d.ts.map +1 -1
- package/lib/cjs/ViewProps.js +16 -0
- package/lib/cjs/ViewProps.js.map +1 -1
- package/lib/cjs/geometry/AreaPattern.js +2 -2
- package/lib/cjs/geometry/AreaPattern.js.map +1 -1
- package/lib/cjs/geometry/ElementGeometry.d.ts +6 -6
- package/lib/cjs/geometry/ElementGeometry.js +1 -1
- package/lib/cjs/geometry/ElementGeometry.js.map +1 -1
- package/lib/cjs/ipc/IpcSession.d.ts +4 -0
- package/lib/cjs/ipc/IpcSession.d.ts.map +1 -1
- package/lib/cjs/ipc/IpcSession.js +6 -6
- package/lib/cjs/ipc/IpcSession.js.map +1 -1
- package/lib/cjs/rpc/IModelReadRpcInterface.d.ts +4 -2
- package/lib/cjs/rpc/IModelReadRpcInterface.d.ts.map +1 -1
- package/lib/cjs/rpc/IModelReadRpcInterface.js +6 -4
- package/lib/cjs/rpc/IModelReadRpcInterface.js.map +1 -1
- package/lib/cjs/rpc/core/RpcInvocation.d.ts +2 -0
- package/lib/cjs/rpc/core/RpcInvocation.d.ts.map +1 -1
- package/lib/cjs/rpc/core/RpcInvocation.js +1 -0
- package/lib/cjs/rpc/core/RpcInvocation.js.map +1 -1
- package/lib/cjs/rpc/core/RpcMarshaling.js +2 -2
- package/lib/cjs/rpc/core/RpcMarshaling.js.map +1 -1
- package/lib/cjs/rpc/web/WebAppRpcProtocol.js +1 -1
- package/lib/cjs/rpc/web/WebAppRpcProtocol.js.map +1 -1
- package/lib/cjs/tile/GltfTileIO.d.ts.map +1 -1
- package/lib/cjs/tile/GltfTileIO.js +2 -0
- package/lib/cjs/tile/GltfTileIO.js.map +1 -1
- package/lib/cjs/tile/IModelTileIO.d.ts +2 -2
- package/lib/cjs/tile/IModelTileIO.js +2 -2
- package/lib/cjs/tile/IModelTileIO.js.map +1 -1
- package/lib/cjs/tile/TileMetadata.d.ts +14 -13
- package/lib/cjs/tile/TileMetadata.d.ts.map +1 -1
- package/lib/cjs/tile/TileMetadata.js +56 -44
- package/lib/cjs/tile/TileMetadata.js.map +1 -1
- package/lib/esm/BriefcaseTypes.d.ts +13 -1
- package/lib/esm/BriefcaseTypes.d.ts.map +1 -1
- package/lib/esm/BriefcaseTypes.js.map +1 -1
- package/lib/esm/ChangedElements.d.ts +2 -0
- package/lib/esm/ChangedElements.d.ts.map +1 -1
- package/lib/esm/ChangedElements.js +2 -0
- package/lib/esm/ChangedElements.js.map +1 -1
- package/lib/esm/ConcurrentQuery.d.ts +26 -2
- package/lib/esm/ConcurrentQuery.d.ts.map +1 -1
- package/lib/esm/ConcurrentQuery.js +29 -3
- package/lib/esm/ConcurrentQuery.js.map +1 -1
- package/lib/esm/DisplayStyleSettings.d.ts +1 -15
- package/lib/esm/DisplayStyleSettings.d.ts.map +1 -1
- package/lib/esm/DisplayStyleSettings.js +1 -15
- package/lib/esm/DisplayStyleSettings.js.map +1 -1
- package/lib/esm/ECSqlReader.d.ts +164 -7
- package/lib/esm/ECSqlReader.d.ts.map +1 -1
- package/lib/esm/ECSqlReader.js +124 -12
- package/lib/esm/ECSqlReader.js.map +1 -1
- package/lib/esm/ElementProps.d.ts +2 -2
- package/lib/esm/ElementProps.js.map +1 -1
- package/lib/esm/EntityProps.js +2 -2
- package/lib/esm/EntityProps.js.map +1 -1
- package/lib/esm/FeatureIndex.d.ts +50 -4
- package/lib/esm/FeatureIndex.d.ts.map +1 -1
- package/lib/esm/FeatureIndex.js +44 -4
- package/lib/esm/FeatureIndex.js.map +1 -1
- package/lib/esm/FeatureTable.d.ts +44 -20
- package/lib/esm/FeatureTable.d.ts.map +1 -1
- package/lib/esm/FeatureTable.js +17 -2
- package/lib/esm/FeatureTable.js.map +1 -1
- package/lib/esm/IModel.d.ts +1 -1
- package/lib/esm/IModel.d.ts.map +1 -1
- package/lib/esm/IModel.js +1 -1
- package/lib/esm/IModel.js.map +1 -1
- package/lib/esm/IpcAppProps.d.ts +6 -6
- package/lib/esm/IpcAppProps.d.ts.map +1 -1
- package/lib/esm/IpcAppProps.js +7 -8
- package/lib/esm/IpcAppProps.js.map +1 -1
- package/lib/esm/NativeAppProps.d.ts +4 -3
- package/lib/esm/NativeAppProps.d.ts.map +1 -1
- package/lib/esm/NativeAppProps.js +4 -3
- package/lib/esm/NativeAppProps.js.map +1 -1
- package/lib/esm/QPoint.d.ts +3 -3
- package/lib/esm/QPoint.js +3 -3
- package/lib/esm/QPoint.js.map +1 -1
- package/lib/esm/Render.d.ts +27 -35
- package/lib/esm/Render.d.ts.map +1 -1
- package/lib/esm/Render.js +3 -64
- package/lib/esm/Render.js.map +1 -1
- package/lib/esm/RpcInterface.d.ts +1 -1
- package/lib/esm/RpcInterface.d.ts.map +1 -1
- package/lib/esm/RpcInterface.js +26 -25
- package/lib/esm/RpcInterface.js.map +1 -1
- package/lib/esm/SkyBox.d.ts +3 -3
- package/lib/esm/SkyBox.d.ts.map +1 -1
- package/lib/esm/SkyBox.js +3 -3
- package/lib/esm/SkyBox.js.map +1 -1
- package/lib/esm/ViewFlags.d.ts +4 -4
- package/lib/esm/ViewFlags.d.ts.map +1 -1
- package/lib/esm/ViewFlags.js +4 -4
- package/lib/esm/ViewFlags.js.map +1 -1
- package/lib/esm/ViewProps.d.ts +429 -5
- package/lib/esm/ViewProps.d.ts.map +1 -1
- package/lib/esm/ViewProps.js +15 -1
- package/lib/esm/ViewProps.js.map +1 -1
- package/lib/esm/geometry/AreaPattern.js +2 -2
- package/lib/esm/geometry/AreaPattern.js.map +1 -1
- package/lib/esm/geometry/ElementGeometry.d.ts +6 -6
- package/lib/esm/geometry/ElementGeometry.js +1 -1
- package/lib/esm/geometry/ElementGeometry.js.map +1 -1
- package/lib/esm/ipc/IpcSession.d.ts +4 -0
- package/lib/esm/ipc/IpcSession.d.ts.map +1 -1
- package/lib/esm/ipc/IpcSession.js +5 -5
- package/lib/esm/ipc/IpcSession.js.map +1 -1
- package/lib/esm/rpc/IModelReadRpcInterface.d.ts +4 -2
- package/lib/esm/rpc/IModelReadRpcInterface.d.ts.map +1 -1
- package/lib/esm/rpc/IModelReadRpcInterface.js +6 -4
- package/lib/esm/rpc/IModelReadRpcInterface.js.map +1 -1
- package/lib/esm/rpc/core/RpcInvocation.d.ts +2 -0
- package/lib/esm/rpc/core/RpcInvocation.d.ts.map +1 -1
- package/lib/esm/rpc/core/RpcInvocation.js +1 -0
- package/lib/esm/rpc/core/RpcInvocation.js.map +1 -1
- package/lib/esm/rpc/core/RpcMarshaling.js +2 -2
- package/lib/esm/rpc/core/RpcMarshaling.js.map +1 -1
- package/lib/esm/rpc/web/WebAppRpcProtocol.js +1 -1
- package/lib/esm/rpc/web/WebAppRpcProtocol.js.map +1 -1
- package/lib/esm/tile/GltfTileIO.d.ts.map +1 -1
- package/lib/esm/tile/GltfTileIO.js +2 -0
- package/lib/esm/tile/GltfTileIO.js.map +1 -1
- package/lib/esm/tile/IModelTileIO.d.ts +2 -2
- package/lib/esm/tile/IModelTileIO.js +2 -2
- package/lib/esm/tile/IModelTileIO.js.map +1 -1
- package/lib/esm/tile/TileMetadata.d.ts +14 -13
- package/lib/esm/tile/TileMetadata.d.ts.map +1 -1
- package/lib/esm/tile/TileMetadata.js +57 -45
- package/lib/esm/tile/TileMetadata.js.map +1 -1
- package/package.json +11 -29
package/lib/cjs/Render.js
CHANGED
|
@@ -7,80 +7,17 @@
|
|
|
7
7
|
* @module Rendering
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.PolylineEdgeArgs = exports.SilhouetteEdgeArgs = exports.EdgeArgs = exports.MeshEdges = exports.MeshEdge = exports.MeshPolylineList = exports.MeshPolyline = exports.
|
|
11
|
-
const core_bentley_1 = require("@itwin/core-bentley");
|
|
10
|
+
exports.PolylineEdgeArgs = exports.SilhouetteEdgeArgs = exports.EdgeArgs = exports.MeshEdges = exports.MeshEdge = exports.MeshPolylineList = exports.MeshPolyline = exports.PolylineTypeFlags = void 0;
|
|
12
11
|
// cSpell:ignore vals
|
|
13
|
-
/**
|
|
12
|
+
/** Describes the semantics of a [PolylineArgs]($frontend).
|
|
13
|
+
* @alpha
|
|
14
|
+
*/
|
|
14
15
|
var PolylineTypeFlags;
|
|
15
16
|
(function (PolylineTypeFlags) {
|
|
16
17
|
PolylineTypeFlags[PolylineTypeFlags["Normal"] = 0] = "Normal";
|
|
17
18
|
PolylineTypeFlags[PolylineTypeFlags["Edge"] = 1] = "Edge";
|
|
18
19
|
PolylineTypeFlags[PolylineTypeFlags["Outline"] = 2] = "Outline";
|
|
19
20
|
})(PolylineTypeFlags = exports.PolylineTypeFlags || (exports.PolylineTypeFlags = {}));
|
|
20
|
-
/** Flags describing a polyline. A polyline may represent a continuous line string, or a set of discrete points.
|
|
21
|
-
* @internal
|
|
22
|
-
*/
|
|
23
|
-
class PolylineFlags {
|
|
24
|
-
constructor(is2d = false, isPlanar = false, isDisjoint = false, type = PolylineTypeFlags.Normal) {
|
|
25
|
-
this.isDisjoint = isDisjoint;
|
|
26
|
-
this.isPlanar = isPlanar;
|
|
27
|
-
this.is2d = is2d;
|
|
28
|
-
this.type = type;
|
|
29
|
-
}
|
|
30
|
-
clone() { return new PolylineFlags(this.is2d, this.isPlanar, this.isDisjoint, this.type); }
|
|
31
|
-
/** Create a PolylineFlags from a serialized numeric representation. */
|
|
32
|
-
static unpack(value) {
|
|
33
|
-
const isDisjoint = 0 !== (value & 1);
|
|
34
|
-
const isPlanar = 0 !== (value & 2);
|
|
35
|
-
const is2d = 0 !== (value & 4);
|
|
36
|
-
const type = (value >> 3);
|
|
37
|
-
(0, core_bentley_1.assert)(type === PolylineTypeFlags.Normal || type === PolylineTypeFlags.Edge || type === PolylineTypeFlags.Outline);
|
|
38
|
-
return new PolylineFlags(is2d, isPlanar, isDisjoint, type);
|
|
39
|
-
}
|
|
40
|
-
initDefaults() {
|
|
41
|
-
this.isDisjoint = this.isPlanar = this.is2d = false;
|
|
42
|
-
this.type = PolylineTypeFlags.Normal;
|
|
43
|
-
}
|
|
44
|
-
get isOutlineEdge() { return PolylineTypeFlags.Outline === this.type; }
|
|
45
|
-
get isNormalEdge() { return PolylineTypeFlags.Edge === this.type; }
|
|
46
|
-
get isAnyEdge() { return PolylineTypeFlags.Normal !== this.type; }
|
|
47
|
-
setIsNormalEdge() { this.type = PolylineTypeFlags.Edge; }
|
|
48
|
-
setIsOutlineEdge() { this.type = PolylineTypeFlags.Outline; }
|
|
49
|
-
/** Convert these flags to a numeric representation for serialization. */
|
|
50
|
-
pack() {
|
|
51
|
-
let val = 0;
|
|
52
|
-
if (this.isDisjoint)
|
|
53
|
-
val += 1;
|
|
54
|
-
if (this.isPlanar)
|
|
55
|
-
val += 1 << 1;
|
|
56
|
-
if (this.is2d)
|
|
57
|
-
val += 1 << 2;
|
|
58
|
-
val += this.type << 3;
|
|
59
|
-
return val;
|
|
60
|
-
}
|
|
61
|
-
equals(other) {
|
|
62
|
-
return this.type === other.type && this.is2d === other.is2d && this.isPlanar === other.isPlanar && this.isDisjoint === other.isDisjoint;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
exports.PolylineFlags = PolylineFlags;
|
|
66
|
-
/** @internal */
|
|
67
|
-
class PolylineData {
|
|
68
|
-
constructor(vertIndices = [], numIndices = 0) {
|
|
69
|
-
this.vertIndices = vertIndices;
|
|
70
|
-
this.numIndices = numIndices;
|
|
71
|
-
}
|
|
72
|
-
get isValid() { return 0 < this.numIndices; }
|
|
73
|
-
reset() {
|
|
74
|
-
this.numIndices = 0;
|
|
75
|
-
this.vertIndices = [];
|
|
76
|
-
}
|
|
77
|
-
init(polyline) {
|
|
78
|
-
this.numIndices = polyline.indices.length;
|
|
79
|
-
this.vertIndices = 0 < this.numIndices ? polyline.indices : [];
|
|
80
|
-
return this.isValid;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
exports.PolylineData = PolylineData;
|
|
84
21
|
/** @internal */
|
|
85
22
|
class MeshPolyline {
|
|
86
23
|
constructor(indices = []) {
|
package/lib/cjs/Render.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Render.js","sourceRoot":"","sources":["../../src/Render.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA6C;AAG7C,qBAAqB;AAErB,gBAAgB;AAChB,IAAY,iBAIX;AAJD,WAAY,iBAAiB;IAC3B,6DAAU,CAAA;IACV,yDAAa,CAAA;IACb,+DAAgB,CAAA;AAClB,CAAC,EAJW,iBAAiB,GAAjB,yBAAiB,K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C,CAAC,CAAC,CAAC,CAAC;IAClF,IAAW,OAAO,KAAK,OAAO,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC;IAC3C,KAAK,KAAK,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC,CAAC,CAAC;CAC3C;AAbD,4CAaC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Rendering\r\n */\r\n\r\nimport { assert } from \"@itwin/core-bentley\";\r\nimport { OctEncodedNormalPair } from \"./OctEncodedNormal\";\r\n\r\n// cSpell:ignore vals\r\n\r\n/** @internal */\r\nexport enum PolylineTypeFlags {\r\n Normal = 0, // Just an ordinary polyline\r\n Edge = 1 << 0, // A polyline used to define the edges of a planar region.\r\n Outline = 1 << 1, // Like Edge, but the edges are only displayed in wireframe mode when surface fill is undisplayed.\r\n}\r\n\r\n/** Flags describing a polyline. A polyline may represent a continuous line string, or a set of discrete points.\r\n * @internal\r\n */\r\nexport class PolylineFlags {\r\n public isDisjoint: boolean;\r\n public isPlanar: boolean;\r\n public is2d: boolean;\r\n public type: PolylineTypeFlags;\r\n\r\n public constructor(is2d = false, isPlanar = false, isDisjoint = false, type = PolylineTypeFlags.Normal) {\r\n this.isDisjoint = isDisjoint;\r\n this.isPlanar = isPlanar;\r\n this.is2d = is2d;\r\n this.type = type;\r\n }\r\n\r\n public clone(): PolylineFlags { return new PolylineFlags(this.is2d, this.isPlanar, this.isDisjoint, this.type); }\r\n\r\n /** Create a PolylineFlags from a serialized numeric representation. */\r\n public static unpack(value: number): PolylineFlags {\r\n const isDisjoint = 0 !== (value & 1);\r\n const isPlanar = 0 !== (value & 2);\r\n const is2d = 0 !== (value & 4);\r\n const type: PolylineTypeFlags = (value >> 3);\r\n assert(type === PolylineTypeFlags.Normal || type === PolylineTypeFlags.Edge || type === PolylineTypeFlags.Outline);\r\n\r\n return new PolylineFlags(is2d, isPlanar, isDisjoint, type);\r\n }\r\n\r\n public initDefaults() {\r\n this.isDisjoint = this.isPlanar = this.is2d = false;\r\n this.type = PolylineTypeFlags.Normal;\r\n }\r\n\r\n public get isOutlineEdge(): boolean { return PolylineTypeFlags.Outline === this.type; }\r\n public get isNormalEdge(): boolean { return PolylineTypeFlags.Edge === this.type; }\r\n public get isAnyEdge(): boolean { return PolylineTypeFlags.Normal !== this.type; }\r\n public setIsNormalEdge(): void { this.type = PolylineTypeFlags.Edge; }\r\n public setIsOutlineEdge(): void { this.type = PolylineTypeFlags.Outline; }\r\n\r\n /** Convert these flags to a numeric representation for serialization. */\r\n public pack(): number {\r\n let val: number = 0;\r\n if (this.isDisjoint)\r\n val += 1;\r\n if (this.isPlanar)\r\n val += 1 << 1;\r\n if (this.is2d)\r\n val += 1 << 2;\r\n val += (this.type as number) << 3;\r\n return val;\r\n }\r\n\r\n public equals(other: PolylineFlags) {\r\n return this.type === other.type && this.is2d === other.is2d && this.isPlanar === other.isPlanar && this.isDisjoint === other.isDisjoint;\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport class PolylineData {\r\n public vertIndices: number[];\r\n public numIndices: number;\r\n public constructor(vertIndices: number[] = [], numIndices = 0) {\r\n this.vertIndices = vertIndices;\r\n this.numIndices = numIndices;\r\n }\r\n public get isValid(): boolean { return 0 < this.numIndices; }\r\n public reset(): void {\r\n this.numIndices = 0;\r\n this.vertIndices = [];\r\n }\r\n\r\n public init(polyline: MeshPolyline) {\r\n this.numIndices = polyline.indices.length;\r\n this.vertIndices = 0 < this.numIndices ? polyline.indices : [];\r\n return this.isValid;\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport class MeshPolyline {\r\n public readonly indices: number[];\r\n public constructor(indices: number[] = []) {\r\n this.indices = indices.slice();\r\n }\r\n public addIndex(index: number) {\r\n const { indices } = this;\r\n if (indices.length === 0 || indices[indices.length - 1] !== index)\r\n indices.push(index);\r\n }\r\n public clear() { this.indices.length = 0; }\r\n}\r\n\r\n/** @internal */\r\nexport class MeshPolylineList extends Array<MeshPolyline> {\r\n constructor(...args: MeshPolyline[]) {\r\n super(...args);\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport class MeshEdge {\r\n public indices = [0, 0];\r\n\r\n public constructor(index0?: number, index1?: number) {\r\n if (undefined === index0 || undefined === index1)\r\n return;\r\n if (index0 < index1) {\r\n this.indices[0] = index0;\r\n this.indices[1] = index1;\r\n } else {\r\n this.indices[0] = index1;\r\n this.indices[1] = index0;\r\n }\r\n }\r\n\r\n public compareTo(other: MeshEdge): number {\r\n let diff = this.indices[0] - other.indices[0];\r\n if (0 === diff)\r\n diff = this.indices[1] - other.indices[1];\r\n\r\n return diff;\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport class MeshEdges {\r\n public visible: MeshEdge[] = [];\r\n public silhouette: MeshEdge[] = [];\r\n public polylines: MeshPolylineList = new MeshPolylineList();\r\n public silhouetteNormals: OctEncodedNormalPair[] = [];\r\n public constructor() { }\r\n}\r\n\r\n/** @internal */\r\nexport class EdgeArgs {\r\n public edges?: MeshEdge[];\r\n\r\n public init(meshEdges?: MeshEdges): boolean {\r\n this.clear();\r\n if (undefined !== meshEdges && 0 < meshEdges.visible.length)\r\n this.edges = meshEdges.visible;\r\n\r\n return this.isValid;\r\n }\r\n\r\n public clear(): void { this.edges = undefined; }\r\n public get isValid(): boolean { return 0 < this.numEdges; }\r\n public get numEdges() { return undefined !== this.edges ? this.edges.length : 0; }\r\n}\r\n\r\n/** @internal */\r\nexport class SilhouetteEdgeArgs extends EdgeArgs {\r\n public normals?: OctEncodedNormalPair[];\r\n\r\n public override init(meshEdges?: MeshEdges) {\r\n this.clear();\r\n if (undefined !== meshEdges && 0 < meshEdges.silhouette.length) {\r\n this.edges = meshEdges.silhouette;\r\n this.normals = meshEdges.silhouetteNormals;\r\n }\r\n\r\n return this.isValid;\r\n }\r\n\r\n public override clear() {\r\n this.normals = undefined;\r\n super.clear();\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport class PolylineEdgeArgs {\r\n public lines?: PolylineData[];\r\n\r\n public constructor(lines?: PolylineData[]) { this.init(lines); }\r\n\r\n public init(lines?: PolylineData[]): boolean {\r\n this.lines = undefined !== lines && 0 < lines.length ? lines : undefined;\r\n return this.isValid;\r\n }\r\n\r\n public get numLines() { return undefined !== this.lines ? this.lines.length : 0; }\r\n public get isValid() { return this.numLines > 0; }\r\n public clear() { this.lines = undefined; }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"Render.js","sourceRoot":"","sources":["../../src/Render.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAIH,qBAAqB;AAErB;;GAEG;AACH,IAAY,iBAIX;AAJD,WAAY,iBAAiB;IAC3B,6DAAU,CAAA;IACV,yDAAa,CAAA;IACb,+DAAgB,CAAA;AAClB,CAAC,EAJW,iBAAiB,GAAjB,yBAAiB,KAAjB,yBAAiB,QAI5B;AAyBD,gBAAgB;AAChB,MAAa,YAAY;IAGvB,YAAmB,UAA2B,EAAE;QAC9C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;IACjC,CAAC;IAEM,QAAQ,CAAC,KAAa;QAC3B,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;QACzB,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,KAAK;YAC/D,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACxB,CAAC;IAEM,KAAK,KAAK,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;CAC5C;AAdD,oCAcC;AAED,gBAAgB;AAChB,MAAa,gBAAiB,SAAQ,KAAmB;IACvD,YAAY,GAAG,IAAoB;QACjC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;IACjB,CAAC;C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AQ,KAAK,OAAO,SAAS,KAAK,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAClF,IAAW,OAAO,KAAK,OAAO,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC;IAC3C,KAAK,KAAK,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC,CAAC,CAAC;CAC3C;AAbD,4CAaC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Rendering\r\n */\r\n\r\nimport { OctEncodedNormalPair } from \"./OctEncodedNormal\";\r\n\r\n// cSpell:ignore vals\r\n\r\n/** Describes the semantics of a [PolylineArgs]($frontend).\r\n * @alpha\r\n */\r\nexport enum PolylineTypeFlags {\r\n Normal = 0, // Just an ordinary polyline\r\n Edge = 1 << 0, // A polyline used to define the edges of a planar region.\r\n Outline = 1 << 1, // Like Edge, but the edges are only displayed in wireframe mode when surface fill is undisplayed.\r\n}\r\n\r\n/** Flags describing a [PolylineArgs]($frontend).\r\n * @public\r\n */\r\nexport interface PolylineFlags {\r\n /** If `true`, the polylines are to be drawn as individual disconnected point strings instead of as connected line strings. */\r\n isDisjoint?: boolean;\r\n /** If `true`, the polylines' positions are all coplanar. */\r\n isPlanar?: boolean;\r\n /** If `true`, the polylines' positions all have the same z coordinate. */\r\n is2d?: boolean;\r\n /** Default: Normal.\r\n * @alpha\r\n */\r\n type?: PolylineTypeFlags;\r\n}\r\n\r\n/** Describes the vertex indices of a single line within a [PolylineArgs]($frontend).\r\n * The indices represent either a line string as a connected series of points, or a point string as a set of disconnected points, depending\r\n * on the [[PolylineFlags.isDisjoint]] value of [PolylineArgs.flags]($frontend).\r\n * @public\r\n */\r\nexport type PolylineIndices = number[];\r\n\r\n/** @internal */\r\nexport class MeshPolyline {\r\n public readonly indices: PolylineIndices;\r\n\r\n public constructor(indices: PolylineIndices = []) {\r\n this.indices = indices.slice();\r\n }\r\n\r\n public addIndex(index: number) {\r\n const { indices } = this;\r\n if (indices.length === 0 || indices[indices.length - 1] !== index)\r\n indices.push(index);\r\n }\r\n\r\n public clear() { this.indices.length = 0; }\r\n}\r\n\r\n/** @internal */\r\nexport class MeshPolylineList extends Array<MeshPolyline> {\r\n constructor(...args: MeshPolyline[]) {\r\n super(...args);\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport class MeshEdge {\r\n public indices = [0, 0];\r\n\r\n public constructor(index0?: number, index1?: number) {\r\n if (undefined === index0 || undefined === index1)\r\n return;\r\n if (index0 < index1) {\r\n this.indices[0] = index0;\r\n this.indices[1] = index1;\r\n } else {\r\n this.indices[0] = index1;\r\n this.indices[1] = index0;\r\n }\r\n }\r\n\r\n public compareTo(other: MeshEdge): number {\r\n let diff = this.indices[0] - other.indices[0];\r\n if (0 === diff)\r\n diff = this.indices[1] - other.indices[1];\r\n\r\n return diff;\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport class MeshEdges {\r\n public visible: MeshEdge[] = [];\r\n public silhouette: MeshEdge[] = [];\r\n public polylines: MeshPolylineList = new MeshPolylineList();\r\n public silhouetteNormals: OctEncodedNormalPair[] = [];\r\n public constructor() { }\r\n}\r\n\r\n/** @internal */\r\nexport class EdgeArgs {\r\n public edges?: MeshEdge[];\r\n\r\n public init(meshEdges?: MeshEdges): boolean {\r\n this.clear();\r\n if (undefined !== meshEdges && 0 < meshEdges.visible.length)\r\n this.edges = meshEdges.visible;\r\n\r\n return this.isValid;\r\n }\r\n\r\n public clear(): void { this.edges = undefined; }\r\n public get isValid(): boolean { return 0 < this.numEdges; }\r\n public get numEdges() { return undefined !== this.edges ? this.edges.length : 0; }\r\n}\r\n\r\n/** @internal */\r\nexport class SilhouetteEdgeArgs extends EdgeArgs {\r\n public normals?: OctEncodedNormalPair[];\r\n\r\n public override init(meshEdges?: MeshEdges) {\r\n this.clear();\r\n if (undefined !== meshEdges && 0 < meshEdges.silhouette.length) {\r\n this.edges = meshEdges.silhouette;\r\n this.normals = meshEdges.silhouetteNormals;\r\n }\r\n\r\n return this.isValid;\r\n }\r\n\r\n public override clear() {\r\n this.normals = undefined;\r\n super.clear();\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport class PolylineEdgeArgs {\r\n public lines?: PolylineIndices[];\r\n\r\n public constructor(lines?: PolylineIndices[]) { this.init(lines); }\r\n\r\n public init(lines?: PolylineIndices[]): boolean {\r\n this.lines = undefined !== lines && 0 < lines.length ? lines : undefined;\r\n return this.isValid;\r\n }\r\n\r\n public get numLines() { return undefined !== this.lines ? this.lines.length : 0; }\r\n public get isValid() { return this.numLines > 0; }\r\n public clear() { this.lines = undefined; }\r\n}\r\n"]}
|
|
@@ -33,7 +33,7 @@ export declare abstract class RpcInterface {
|
|
|
33
33
|
readonly configuration: RpcConfiguration;
|
|
34
34
|
/** @internal */
|
|
35
35
|
readonly routing: RpcRoutingToken;
|
|
36
|
-
/** @
|
|
36
|
+
/** @beta */
|
|
37
37
|
constructor(routing?: RpcRoutingToken);
|
|
38
38
|
/** Obtains the implementation result for an RPC operation. */
|
|
39
39
|
forward<T = any>(parameters: IArguments): Promise<T>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RpcInterface.d.ts","sourceRoot":"","sources":["../../src/RpcInterface.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,OAAO,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AAGzF,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAW7D;;;;GAIG;AACH,MAAM,WAAW,sBAAsB,CAAC,CAAC,SAAS,YAAY,GAAG,YAAY;IAAI,SAAS,EAAE,CAAC,CAAC;IAAC,aAAa,EAAE,MAAM,CAAC;IAAC,gBAAgB,EAAE,MAAM,CAA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CHANGED
|
@@ -22,41 +22,42 @@ const core_bentley_1 = require("@itwin/core-bentley");
|
|
|
22
22
|
*/
|
|
23
23
|
class RpcInterface {
|
|
24
24
|
static findDiff(backend, frontend) {
|
|
25
|
-
return backend.major !== frontend.major ? "major" :
|
|
25
|
+
return backend.major !== frontend.major ? "major" :
|
|
26
|
+
backend.minor !== frontend.minor ? "minor" :
|
|
27
|
+
backend.patch !== frontend.patch ? "patch" :
|
|
28
|
+
backend.prerelease !== frontend.prerelease ? "prerelease" :
|
|
29
|
+
"same";
|
|
26
30
|
}
|
|
27
31
|
static parseVer(version) {
|
|
28
|
-
//
|
|
29
|
-
const
|
|
30
|
-
// Split the major.minor.path into
|
|
31
|
-
const prefix =
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
return { major: Number(prefix[0]), minor: Number(prefix[1]), patch: Number(prefix[2]), prerelease: split[1] };
|
|
37
|
-
}
|
|
32
|
+
// separate the version from the prerelease tag
|
|
33
|
+
const parts = version.split(/[:-]/);
|
|
34
|
+
// Split the major.minor.path into separate components
|
|
35
|
+
const prefix = parts[0].split(".");
|
|
36
|
+
const ver = { major: Number(prefix[0]), minor: Number(prefix[1]), patch: Number(prefix[2]) };
|
|
37
|
+
if (parts.length > 1)
|
|
38
|
+
ver.prerelease = parts[1];
|
|
39
|
+
return ver;
|
|
38
40
|
}
|
|
39
41
|
/** Determines whether the backend version of an RPC interface is compatible (according to semantic versioning) with the frontend version of the interface. */
|
|
40
42
|
static isVersionCompatible(backend, frontend) {
|
|
43
|
+
if (backend === frontend)
|
|
44
|
+
return true; // most common case, versions are identical
|
|
41
45
|
const backendSemver = this.parseVer(backend);
|
|
42
46
|
const frontendSemver = this.parseVer(frontend);
|
|
47
|
+
// if either has a prerelease tag, they are not compatible unless version strings are identical
|
|
48
|
+
if (backendSemver.prerelease || frontendSemver.prerelease)
|
|
49
|
+
return false;
|
|
43
50
|
const difference = this.findDiff(backendSemver, frontendSemver);
|
|
44
51
|
// If the major versions are different, the versions are not compatible
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
// If the strings match exactly, major and minor match but patch differs, versions are compatible
|
|
55
|
-
// If minor versions differ, compatible as long as backend patch versionn is greater
|
|
56
|
-
return difference === "same" || difference === "patch" || (difference === "minor" && frontendSemver.minor < backendSemver.minor);
|
|
57
|
-
}
|
|
52
|
+
if (difference === "major")
|
|
53
|
+
return false;
|
|
54
|
+
// special case for major version 0. If patch difference, backend patch must be greater than frontend patch
|
|
55
|
+
if (backendSemver.major === 0)
|
|
56
|
+
return (difference === "patch" && frontendSemver.patch < backendSemver.patch);
|
|
57
|
+
// patch difference is fine. If minor versions differ, compatible as long as backend minor version is greater
|
|
58
|
+
return difference === "patch" || (difference === "minor" && frontendSemver.minor < backendSemver.minor);
|
|
58
59
|
}
|
|
59
|
-
/** @
|
|
60
|
+
/** @beta */
|
|
60
61
|
constructor(routing = RpcRoutingToken_1.RpcRoutingToken.default) {
|
|
61
62
|
this.routing = routing;
|
|
62
63
|
this.configuration = RpcConfiguration_1.RpcConfiguration.supply(this);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RpcInterface.js","sourceRoot":"","sources":["../../src/RpcInterface.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,kEAAyF;AACzF,wDAAyD;AACzD,sDAAkE;AAClE,gEAA6D;AAC7D,iDAAqE;AAGrE,+CAA2E;AAC3E,0DAA4E;AAC5E,sDAAiD;AAyBjD;;;GAGG;AACH,MAAsB,YAAY;IAExB,MAAM,CAAC,QAAQ,CAAC,OAAmB,EAAE,QAAoB;QAC/D,OAAO,OAAO,CAAC,KAAK,KAAK,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,KAAK,QAA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e;IAC5B,MAAM,IAAI,4BAAc,EAAE,CAAC;AAC7B,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module RpcInterface\r\n */\r\nimport { RpcConfiguration, RpcConfigurationSupplier } from \"./rpc/core/RpcConfiguration\";\r\nimport { CURRENT_REQUEST } from \"./rpc/core/RpcRegistry\";\r\nimport { aggregateLoad, RpcRequest } from \"./rpc/core/RpcRequest\";\r\nimport { RpcRoutingToken } from \"./rpc/core/RpcRoutingToken\";\r\nimport { InterceptedRpcRequest, IpcSession } from \"./ipc/IpcSession\";\r\nimport { RpcSerializedValue } from \"./rpc/core/RpcMarshaling\";\r\nimport { RpcManagedStatus } from \"./rpc/core/RpcProtocol\";\r\nimport { BentleyStatus, IModelError, NoContentError } from \"./IModelError\";\r\nimport { RpcRequestEvent, RpcRequestStatus } from \"./rpc/core/RpcConstants\";\r\nimport { BeDuration } from \"@itwin/core-bentley\";\r\nimport { RpcNotFoundResponse } from \"./rpc/core/RpcControl\";\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\n/**\r\n * Specifies the required static properties of an RpcInterface class.\r\n * These properties are used to identify RPC requests and responses.\r\n * @beta\r\n */\r\nexport interface RpcInterfaceDefinition<T extends RpcInterface = RpcInterface> { prototype: T, interfaceName: string, interfaceVersion: string }\r\n\r\n/**\r\n * A class that implements the operations of an RPC interface.\r\n * @beta\r\n */\r\nexport type RpcInterfaceImplementation<T extends RpcInterface = RpcInterface> = new () => T;\r\n\r\ninterface SemverType {\r\n major: number;\r\n minor: number;\r\n patch: number;\r\n prerelease?: string;\r\n}\r\n\r\n/** An RPC interface is a set of operations exposed by a service that a client can call, using configurable protocols,\r\n * in a platform-independent way. TheRpcInterface class is the base class for RPC interface definitions and implementations.\r\n * @public\r\n */\r\nexport abstract class RpcInterface {\r\n\r\n private static findDiff(backend: SemverType, frontend: SemverType) {\r\n return backend.major !== frontend.major ? \"major\" : backend.minor !== frontend.minor ? \"minor\" : backend.patch !== frontend.patch ? \"patch\" : backend.prerelease !== frontend.prerelease ? \"prerelease\" : \"same\";\r\n }\r\n\r\n private static parseVer(version: string): SemverType {\r\n // Split the version string into major.minor.path and prerelease tag\r\n const split = version.split(/[:-]/);\r\n // Split the major.minor.path into seperate components\r\n const prefix = split[0].split(\".\");\r\n if (split.length === 1) {\r\n return { major: Number(prefix[0]), minor: Number(prefix[1]), patch: Number(prefix[2]) };\r\n } else {\r\n return { major: Number(prefix[0]), minor: Number(prefix[1]), patch: Number(prefix[2]), prerelease: split[1] };\r\n }\r\n }\r\n\r\n /** Determines whether the backend version of an RPC interface is compatible (according to semantic versioning) with the frontend version of the interface. */\r\n public static isVersionCompatible(backend: string, frontend: string): boolean {\r\n const backendSemver = this.parseVer(backend);\r\n const frontendSemver = this.parseVer(frontend);\r\n const difference = this.findDiff(backendSemver, frontendSemver);\r\n\r\n // If the major versions are different, the versions are not compatible\r\n // In the case of prerelease tags, they are compatible if the whole version string matches, otherwise it fails\r\n if ((backendSemver.prerelease !== undefined || frontendSemver.prerelease !== undefined) || difference === \"major\") {\r\n return difference === \"same\";\r\n } else if (backendSemver.major === 0 || frontendSemver.major === 0) {\r\n // If the major and minor versions match and major versions are 0, compatible as long as backend patch version is greater\r\n return difference === \"same\" || (difference === \"patch\" && frontendSemver.patch < backendSemver.patch);\r\n } else {\r\n // If the strings match exactly, major and minor match but patch differs, versions are compatible\r\n // If minor versions differ, compatible as long as backend patch versionn is greater\r\n return difference === \"same\" || difference === \"patch\" || (difference === \"minor\" && frontendSemver.minor < backendSemver.minor);\r\n }\r\n }\r\n\r\n /** The configuration for the RPC interface.\r\n * @internal\r\n */\r\n public readonly configuration: RpcConfiguration;\r\n\r\n /** @internal */\r\n public readonly routing: RpcRoutingToken;\r\n\r\n /** @internal */\r\n public constructor(routing: RpcRoutingToken = RpcRoutingToken.default) {\r\n this.routing = routing;\r\n this.configuration = RpcConfiguration.supply(this);\r\n }\r\n\r\n /** Obtains the implementation result for an RPC operation. */\r\n public async forward<T = any>(parameters: IArguments): Promise<T> {\r\n const parametersCompat = (arguments.length === 1 && typeof (parameters) === \"object\") ? parameters : arguments;\r\n const parametersArray = Array.isArray(parametersCompat) ? parametersCompat : Array.prototype.slice.call(parametersCompat);\r\n const operationName = parametersArray.pop();\r\n\r\n const session = IpcSession.active;\r\n if (session) {\r\n return intercept(session, this, operationName, parametersArray);\r\n } else {\r\n const request = new (this.configuration.protocol.requestType as any)(this, operationName, parametersArray) as RpcRequest;\r\n request.submit(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n (this as any)[CURRENT_REQUEST] = request;\r\n return request.response;\r\n }\r\n }\r\n\r\n /** @internal */\r\n public configurationSupplier: RpcConfigurationSupplier | undefined;\r\n}\r\n\r\nRpcInterface.prototype.configurationSupplier = undefined;\r\n\r\nclass InterceptedRequest extends RpcRequest {\r\n protected override async load(): Promise<RpcSerializedValue> { throw new Error(); }\r\n protected override async send(): Promise<number> { throw new Error(); }\r\n protected override setHeader(_name: string, _value: string): void { throw new Error(); }\r\n}\r\n\r\nasync function intercept(session: IpcSession, client: RpcInterface, operation: string, parameters: any[]) {\r\n const request = new InterceptedRequest(client, operation, []);\r\n (client as any)[CURRENT_REQUEST] = request;\r\n\r\n const context = await client.configuration.protocol.serialize(request);\r\n request.parameters = parameters;\r\n\r\n const info: InterceptedRpcRequest = {\r\n definition: {\r\n interfaceName: context.operation.interfaceDefinition,\r\n interfaceVersion: context.operation.interfaceVersion,\r\n },\r\n operation,\r\n parameters,\r\n context: {\r\n applicationId: context.applicationId,\r\n applicationVersion: context.applicationVersion,\r\n id: context.id,\r\n sessionId: context.sessionId,\r\n protocolVersion: (context.protocolVersion || 0).toString(),\r\n },\r\n };\r\n\r\n const dispatch = async () => {\r\n aggregateLoad.lastRequest = new Date().getTime();\r\n\r\n const response = await session.handleRpc(info);\r\n\r\n aggregateLoad.lastResponse = new Date().getTime();\r\n\r\n if (typeof (response) === \"object\" && response.hasOwnProperty(\"iTwinRpcCoreResponse\") && response.hasOwnProperty(\"managedStatus\")) {\r\n const status: RpcManagedStatus = response;\r\n\r\n if (status.managedStatus === \"pending\") {\r\n return handlePending(request, status, dispatch);\r\n } else if (status.managedStatus === \"notFound\") {\r\n return handleNotFound(request, status, dispatch);\r\n } else if (status.managedStatus === \"noContent\") {\r\n return handleNoContent();\r\n }\r\n } else {\r\n return response;\r\n }\r\n };\r\n\r\n return dispatch();\r\n}\r\n\r\nasync function handlePending(request: InterceptedRequest, status: RpcManagedStatus, dispatch: () => Promise<any>) {\r\n request._status = RpcRequestStatus.Pending;\r\n request._extendedStatus = (status.responseValue as { message: string }).message;\r\n RpcRequest.events.raiseEvent(RpcRequestEvent.PendingUpdateReceived, request);\r\n\r\n const delay = request.operation.policy.retryInterval(request.client.configuration);\r\n\r\n await BeDuration.wait(delay);\r\n return dispatch();\r\n}\r\n\r\nasync function handleNotFound(request: InterceptedRequest, status: RpcManagedStatus, dispatch: () => Promise<any>) {\r\n return new Promise((resolve, reject) => {\r\n let resubmitted = false;\r\n\r\n RpcRequest.notFoundHandlers.raiseEvent(request, status.responseValue as RpcNotFoundResponse, async () => {\r\n if (resubmitted) {\r\n throw new IModelError(BentleyStatus.ERROR, `Already resubmitted using this handler.`);\r\n }\r\n\r\n resubmitted = true;\r\n\r\n try {\r\n const response = await dispatch();\r\n resolve(response);\r\n } catch (err) {\r\n reject(err);\r\n }\r\n }, reject);\r\n });\r\n}\r\n\r\nasync function handleNoContent() {\r\n throw new NoContentError();\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"RpcInterface.js","sourceRoot":"","sources":["../../src/RpcInterface.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,kEAAyF;AACzF,wDAAyD;AACzD,sDAAkE;AAClE,gEAA6D;AAC7D,iDAAqE;AAGrE,+C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AAU,eAAe;IAC5B,MAAM,IAAI,4BAAc,EAAE,CAAC;AAC7B,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module RpcInterface\r\n */\r\nimport { RpcConfiguration, RpcConfigurationSupplier } from \"./rpc/core/RpcConfiguration\";\r\nimport { CURRENT_REQUEST } from \"./rpc/core/RpcRegistry\";\r\nimport { aggregateLoad, RpcRequest } from \"./rpc/core/RpcRequest\";\r\nimport { RpcRoutingToken } from \"./rpc/core/RpcRoutingToken\";\r\nimport { InterceptedRpcRequest, IpcSession } from \"./ipc/IpcSession\";\r\nimport { RpcSerializedValue } from \"./rpc/core/RpcMarshaling\";\r\nimport { RpcManagedStatus } from \"./rpc/core/RpcProtocol\";\r\nimport { BentleyStatus, IModelError, NoContentError } from \"./IModelError\";\r\nimport { RpcRequestEvent, RpcRequestStatus } from \"./rpc/core/RpcConstants\";\r\nimport { BeDuration } from \"@itwin/core-bentley\";\r\nimport { RpcNotFoundResponse } from \"./rpc/core/RpcControl\";\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\n/**\r\n * Specifies the required static properties of an RpcInterface class.\r\n * These properties are used to identify RPC requests and responses.\r\n * @beta\r\n */\r\nexport interface RpcInterfaceDefinition<T extends RpcInterface = RpcInterface> { prototype: T, interfaceName: string, interfaceVersion: string }\r\n\r\n/**\r\n * A class that implements the operations of an RPC interface.\r\n * @beta\r\n */\r\nexport type RpcInterfaceImplementation<T extends RpcInterface = RpcInterface> = new () => T;\r\n\r\ninterface SemverType {\r\n major: number;\r\n minor: number;\r\n patch: number;\r\n prerelease?: string;\r\n}\r\n\r\n/** An RPC interface is a set of operations exposed by a service that a client can call, using configurable protocols,\r\n * in a platform-independent way. TheRpcInterface class is the base class for RPC interface definitions and implementations.\r\n * @public\r\n */\r\nexport abstract class RpcInterface {\r\n\r\n private static findDiff(backend: SemverType, frontend: SemverType) {\r\n return backend.major !== frontend.major ? \"major\" :\r\n backend.minor !== frontend.minor ? \"minor\" :\r\n backend.patch !== frontend.patch ? \"patch\" :\r\n backend.prerelease !== frontend.prerelease ? \"prerelease\" :\r\n \"same\";\r\n }\r\n\r\n private static parseVer(version: string): SemverType {\r\n // separate the version from the prerelease tag\r\n const parts = version.split(/[:-]/);\r\n // Split the major.minor.path into separate components\r\n const prefix = parts[0].split(\".\");\r\n\r\n const ver: SemverType = { major: Number(prefix[0]), minor: Number(prefix[1]), patch: Number(prefix[2]) };\r\n if (parts.length > 1)\r\n ver.prerelease = parts[1];\r\n return ver;\r\n }\r\n\r\n /** Determines whether the backend version of an RPC interface is compatible (according to semantic versioning) with the frontend version of the interface. */\r\n public static isVersionCompatible(backend: string, frontend: string): boolean {\r\n if (backend === frontend)\r\n return true; // most common case, versions are identical\r\n\r\n const backendSemver = this.parseVer(backend);\r\n const frontendSemver = this.parseVer(frontend);\r\n\r\n // if either has a prerelease tag, they are not compatible unless version strings are identical\r\n if (backendSemver.prerelease || frontendSemver.prerelease)\r\n return false;\r\n\r\n const difference = this.findDiff(backendSemver, frontendSemver);\r\n // If the major versions are different, the versions are not compatible\r\n if (difference === \"major\")\r\n return false;\r\n\r\n // special case for major version 0. If patch difference, backend patch must be greater than frontend patch\r\n if (backendSemver.major === 0)\r\n return (difference === \"patch\" && frontendSemver.patch < backendSemver.patch);\r\n\r\n // patch difference is fine. If minor versions differ, compatible as long as backend minor version is greater\r\n return difference === \"patch\" || (difference === \"minor\" && frontendSemver.minor < backendSemver.minor);\r\n }\r\n\r\n /** The configuration for the RPC interface.\r\n * @internal\r\n */\r\n public readonly configuration: RpcConfiguration;\r\n\r\n /** @internal */\r\n public readonly routing: RpcRoutingToken;\r\n\r\n /** @beta */\r\n public constructor(routing: RpcRoutingToken = RpcRoutingToken.default) {\r\n this.routing = routing;\r\n this.configuration = RpcConfiguration.supply(this);\r\n }\r\n\r\n /** Obtains the implementation result for an RPC operation. */\r\n public async forward<T = any>(parameters: IArguments): Promise<T> {\r\n const parametersCompat = (arguments.length === 1 && typeof (parameters) === \"object\") ? parameters : arguments;\r\n const parametersArray = Array.isArray(parametersCompat) ? parametersCompat : Array.prototype.slice.call(parametersCompat);\r\n const operationName = parametersArray.pop();\r\n\r\n const session = IpcSession.active;\r\n if (session) {\r\n return intercept(session, this, operationName, parametersArray);\r\n } else {\r\n const request = new (this.configuration.protocol.requestType as any)(this, operationName, parametersArray) as RpcRequest;\r\n request.submit(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n (this as any)[CURRENT_REQUEST] = request;\r\n return request.response;\r\n }\r\n }\r\n\r\n /** @internal */\r\n public configurationSupplier: RpcConfigurationSupplier | undefined;\r\n}\r\n\r\nRpcInterface.prototype.configurationSupplier = undefined;\r\n\r\nclass InterceptedRequest extends RpcRequest {\r\n protected override async load(): Promise<RpcSerializedValue> { throw new Error(); }\r\n protected override async send(): Promise<number> { throw new Error(); }\r\n protected override setHeader(_name: string, _value: string): void { throw new Error(); }\r\n}\r\n\r\nasync function intercept(session: IpcSession, client: RpcInterface, operation: string, parameters: any[]) {\r\n const request = new InterceptedRequest(client, operation, []);\r\n (client as any)[CURRENT_REQUEST] = request;\r\n\r\n const context = await client.configuration.protocol.serialize(request);\r\n request.parameters = parameters;\r\n\r\n const info: InterceptedRpcRequest = {\r\n definition: {\r\n interfaceName: context.operation.interfaceDefinition,\r\n interfaceVersion: context.operation.interfaceVersion,\r\n },\r\n operation,\r\n parameters,\r\n context: {\r\n applicationId: context.applicationId,\r\n applicationVersion: context.applicationVersion,\r\n id: context.id,\r\n sessionId: context.sessionId,\r\n protocolVersion: (context.protocolVersion || 0).toString(),\r\n },\r\n };\r\n\r\n const dispatch = async () => {\r\n aggregateLoad.lastRequest = new Date().getTime();\r\n\r\n const response = await session.handleRpc(info);\r\n\r\n aggregateLoad.lastResponse = new Date().getTime();\r\n\r\n if (typeof (response) === \"object\" && response.hasOwnProperty(\"iTwinRpcCoreResponse\") && response.hasOwnProperty(\"managedStatus\")) {\r\n const status: RpcManagedStatus = response;\r\n\r\n if (status.managedStatus === \"pending\") {\r\n return handlePending(request, status, dispatch);\r\n } else if (status.managedStatus === \"notFound\") {\r\n return handleNotFound(request, status, dispatch);\r\n } else if (status.managedStatus === \"noContent\") {\r\n return handleNoContent();\r\n }\r\n } else {\r\n return response;\r\n }\r\n };\r\n\r\n return dispatch();\r\n}\r\n\r\nasync function handlePending(request: InterceptedRequest, status: RpcManagedStatus, dispatch: () => Promise<any>) {\r\n request._status = RpcRequestStatus.Pending;\r\n request._extendedStatus = (status.responseValue as { message: string }).message;\r\n RpcRequest.events.raiseEvent(RpcRequestEvent.PendingUpdateReceived, request);\r\n\r\n const delay = request.operation.policy.retryInterval(request.client.configuration);\r\n\r\n await BeDuration.wait(delay);\r\n return dispatch();\r\n}\r\n\r\nasync function handleNotFound(request: InterceptedRequest, status: RpcManagedStatus, dispatch: () => Promise<any>) {\r\n return new Promise((resolve, reject) => {\r\n let resubmitted = false;\r\n\r\n RpcRequest.notFoundHandlers.raiseEvent(request, status.responseValue as RpcNotFoundResponse, async () => {\r\n if (resubmitted) {\r\n throw new IModelError(BentleyStatus.ERROR, `Already resubmitted using this handler.`);\r\n }\r\n\r\n resubmitted = true;\r\n\r\n try {\r\n const response = await dispatch();\r\n resolve(response);\r\n } catch (err) {\r\n reject(err);\r\n }\r\n }, reject);\r\n });\r\n}\r\n\r\nasync function handleNoContent() {\r\n throw new NoContentError();\r\n}\r\n"]}
|
package/lib/cjs/SkyBox.d.ts
CHANGED
|
@@ -193,7 +193,7 @@ export declare class SkySphere extends SkyBox {
|
|
|
193
193
|
* @param gradient Optionally overrides the default gradient settings used if the image cannot be obtained.
|
|
194
194
|
*/
|
|
195
195
|
constructor(image: TextureImageSpec, gradient?: SkyGradient);
|
|
196
|
-
/**
|
|
196
|
+
/** See [[SkyBox.toJSON]]. */
|
|
197
197
|
toJSON(display?: boolean): SkyBoxProps;
|
|
198
198
|
/** @internal */
|
|
199
199
|
get textureIds(): Iterable<Id64String>;
|
|
@@ -207,10 +207,10 @@ export declare class SkyCube extends SkyBox {
|
|
|
207
207
|
readonly images: SkyCubeProps;
|
|
208
208
|
/** Create a new sky cube using the specified images.
|
|
209
209
|
* @param images The images to map to each face of the cube.
|
|
210
|
-
* @param Optionally overrides the default gradient settings used if the images cannot be obtained.
|
|
210
|
+
* @param gradient Optionally overrides the default gradient settings used if the images cannot be obtained.
|
|
211
211
|
*/
|
|
212
212
|
constructor(images: SkyCubeProps, gradient?: SkyGradient);
|
|
213
|
-
/**
|
|
213
|
+
/** See [[SkyBox.toJSON]]. */
|
|
214
214
|
toJSON(display?: boolean): SkyBoxProps;
|
|
215
215
|
/** @internal */
|
|
216
216
|
get textureIds(): Iterable<Id64String>;
|
package/lib/cjs/SkyBox.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SkyBox.d.ts","sourceRoot":"","sources":["../../src/SkyBox.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAQ,UAAU,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD;;;;GAIG;AACH,oBAAY,eAAe;IACzB,kEAAkE;IAClE,IAAI,IAAI;IACR;;OAEG;IACH,SAAS,IAAI;IACb,kCAAkC;IAClC,WAAW,IAAI;IACf;;OAEG;IACH,IAAI,IAAI;CACT;AAED;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,gBAAgB,CAAC;IACxB,IAAI,EAAE,gBAAgB,CAAC;IACvB,GAAG,EAAE,gBAAgB,CAAC;IACtB,MAAM,EAAE,gBAAgB,CAAC;IACzB,KAAK,EAAE,gBAAgB,CAAC;IACxB,IAA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|
163
163
|
super(gradient ?? SkyGradient.defaults);
|
|
164
164
|
this.image = image;
|
|
165
165
|
}
|
|
166
|
-
/**
|
|
166
|
+
/** See [[SkyBox.toJSON]]. */
|
|
167
167
|
toJSON(display) {
|
|
168
168
|
const props = super.toJSON(display);
|
|
169
169
|
props.image = {
|
|
@@ -185,13 +185,13 @@ exports.SkySphere = SkySphere;
|
|
|
185
185
|
class SkyCube extends SkyBox {
|
|
186
186
|
/** Create a new sky cube using the specified images.
|
|
187
187
|
* @param images The images to map to each face of the cube.
|
|
188
|
-
* @param Optionally overrides the default gradient settings used if the images cannot be obtained.
|
|
188
|
+
* @param gradient Optionally overrides the default gradient settings used if the images cannot be obtained.
|
|
189
189
|
*/
|
|
190
190
|
constructor(images, gradient) {
|
|
191
191
|
super(gradient ?? SkyGradient.defaults);
|
|
192
192
|
this.images = { ...images };
|
|
193
193
|
}
|
|
194
|
-
/**
|
|
194
|
+
/** See [[SkyBox.toJSON]]. */
|
|
195
195
|
toJSON(display) {
|
|
196
196
|
const props = super.toJSON(display);
|
|
197
197
|
props.image = {
|
package/lib/cjs/SkyBox.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SkyBox.js","sourceRoot":"","sources":["../../src/SkyBox.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAgF;AAChF,yCAAqD;AAGrD;;;;GAIG;AACH,IAAY,eAaX;AAbD,WAAY,eAAe;IACzB,kEAAkE;IAClE,qDAAQ,CAAA;IACR;;OAEG;IACH,+DAAa,CAAA;IACb,kCAAkC;IAClC,mEAAe,CAAA;IACf;;OAEG;IACH,qDAAQ,CAAA;AACV,CAAC,EAbW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAa1B;AA4GD,MAAM,kBAAkB,GAAG,mBAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AACxD,MAAM,kBAAkB,GAAG,mBAAQ,C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AC;QAEF,OAAO,KAAK,CAAC;IACf,CAAC;IAED,gBAAgB;IAChB,IAAoB,UAAU;QAC5B,OAAO,mBAAI,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC1D,CAAC;CACF;AA5BD,8BA4BC;AAED;;;GAGG;AACH,MAAa,OAAQ,SAAQ,MAAM;IAIjC;;;OAGG;IACH,YAAmB,MAAoB,EAAE,QAAsB;QAC7D,KAAK,CAAC,QAAQ,IAAI,WAAW,CAAC,QAAQ,CAAC,CAAC;QACxC,IAAI,CAAC,MAAM,GAAG,EAAE,GAAG,MAAM,EAAE,CAAC;IAC9B,CAAC;IAED,yBAAyB;IACT,MAAM,CAAC,OAAiB;QACtC,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACpC,KAAK,CAAC,KAAK,GAAG;YACZ,IAAI,EAAE,eAAe,CAAC,IAAI;YAC1B,QAAQ,EAAE,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE;SAC7B,CAAC;QAEF,OAAO,KAAK,CAAC;IACf,CAAC;IAED,gBAAgB;IAChB,IAAoB,UAAU;QAC5B,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC;QACzB,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,mBAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;IAClH,CAAC;CACF;AA7BD,0BA6BC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module DisplayStyles\r\n */\r\n\r\nimport { Id64, Id64String, NonFunctionPropertiesOf } from \"@itwin/core-bentley\";\r\nimport { ColorDef, ColorDefProps } from \"./ColorDef\";\r\nimport { TextureImageSpec } from \"./RenderTexture\";\r\n\r\n/** Supported types of [[SkyBox]] images.\r\n * @see [[SkyBoxImageProps]].\r\n * @public\r\n * @extensions\r\n */\r\nexport enum SkyBoxImageType {\r\n /** No image, indicating a [[SkyGradient]] should be displayed. */\r\n None = 0,\r\n /** A single image mapped to the surface of a sphere.\r\n * @see [[SkySphere]].\r\n */\r\n Spherical = 1,\r\n /** @internal not yet supported */\r\n Cylindrical = 2,\r\n /** Six images mapped to the faces of a cube.\r\n * @see [[SkyCube]].\r\n */\r\n Cube = 3,\r\n}\r\n\r\n/** JSON representation of the six images used by a [[SkyCube]].\r\n * Each property specifies the image for a face of the cube as either an image URL, or the Id of a [Texture]($backend) element.\r\n * Each image must be square and have the same dimensions as all the other images.\r\n * @public\r\n * @extensions\r\n */\r\nexport interface SkyCubeProps {\r\n front: TextureImageSpec;\r\n back: TextureImageSpec;\r\n top: TextureImageSpec;\r\n bottom: TextureImageSpec;\r\n right: TextureImageSpec;\r\n left: TextureImageSpec;\r\n}\r\n\r\n/** JSON representation of the image used for a [[SkySphere]].\r\n * @see [[SkyBoxProps.image]].\r\n * @public\r\n */\r\nexport interface SkySphereImageProps {\r\n type: SkyBoxImageType.Spherical;\r\n texture: TextureImageSpec;\r\n /** @internal */\r\n textures?: never;\r\n}\r\n\r\n/** JSON representation of the images used for a [[SkyCube]].\r\n * @see [[SkyBoxProps.image]].\r\n * @public\r\n */\r\nexport interface SkyCubeImageProps {\r\n type: SkyBoxImageType.Cube;\r\n textures: SkyCubeProps;\r\n /** @internal */\r\n texture?: never;\r\n}\r\n\r\n/** JSON representation of the image(s) to be mapped to the surfaces of a [[SkyBox]].\r\n * @see [[SkyBoxProps.image]].\r\n * @public\r\n * @extensions\r\n */\r\nexport type SkyBoxImageProps = SkySphereImageProps | SkyCubeImageProps | { type?: SkyBoxImageType, texture?: never, textures?: never };\r\n\r\n/** JSON representation of a [[SkyBox]] that can be drawn as the background of a [ViewState3d]($frontend).\r\n * An object of this type can describe one of several types of sky box:\r\n * - A cube with a texture image mapped to each face; or\r\n * - A sphere with a single texture image mapped to its surface; or\r\n * - A sphere with a two- or four-color vertical [[Gradient]] mapped to its surface.\r\n *\r\n * Whether cuboid or spherical, the skybox is drawn as if the viewer and the contents of the view are contained within its interior.\r\n *\r\n * For a two-color gradient, the gradient transitions smoothly from the nadir color at the bottom of the sphere to the zenith color at the top of the sphere.\r\n * The sky and ground colors are unused, as are the sky and ground exponents.\r\n *\r\n * For a four-color gradient, a \"horizon\" is produced on the equator of the sphere, where the ground color and sky color meet. The lower half of the sphere transitions\r\n * smoothly from the ground color at the equator to the nadir color at the bottom, and the upper half transitions from the sky color at the equator to the zenith color at\r\n * the top of the sphere.\r\n *\r\n * The color and exponent properties are unused if one or more texture images are supplied.\r\n *\r\n * The skybox is ignored entirely when an atmosphere is displayed.\r\n *\r\n * @see [[DisplayStyle3dSettings.environment]] to define the skybox for a display style.\r\n * @public\r\n * @extensions\r\n */\r\nexport interface SkyBoxProps {\r\n /** Whether or not the skybox should be displayed.\r\n * Default: false.\r\n */\r\n display?: boolean;\r\n /** For a [[SkyGradient]], if true, a 2-color gradient skybox is used instead of a 4-color.\r\n * Default: false.\r\n */\r\n twoColor?: boolean;\r\n /** The color of the sky at the horizon. Unused unless this is a four-color [[SkyGradient]].\r\n * Default: (143, 205, 255).\r\n */\r\n skyColor?: ColorDefProps;\r\n /** The color of the ground at the horizon. Unused unless this is a four-color [[SkyGradient]].\r\n * Default: (120, 143, 125).\r\n */\r\n groundColor?: ColorDefProps;\r\n /** The color of the top of the sphere.\r\n * Default: (54, 117, 255).\r\n */\r\n zenithColor?: ColorDefProps;\r\n /** The color of the bottom of the sphere.\r\n * Default: (40, 15, 0).\r\n */\r\n nadirColor?: ColorDefProps;\r\n /** For a 4-color [[SkyGradient]], controls speed of change from sky color to zenith color; otherwise unused.\r\n * Default: 4.0.\r\n */\r\n skyExponent?: number;\r\n /** For a 4-color [[SkyGradient]], controls speed of change from ground color to nadir color; otherwise unused.\r\n * Default: 4.0.\r\n */\r\n groundExponent?: number;\r\n /** The image(s), if any, to be mapped to the surfaces of the sphere or cube. If undefined, the skybox will be displayed as a gradient instead.\r\n * Default: undefined.\r\n */\r\n image?: SkyBoxImageProps;\r\n}\r\n\r\nconst defaultGroundColor = ColorDef.from(143, 205, 125);\r\nconst defaultZenithColor = ColorDef.from(54, 117, 255);\r\nconst defaultNadirColor = ColorDef.from(40, 125, 0);\r\nconst defaultSkyColor = ColorDef.from(142, 205, 255);\r\nconst defaultExponent = 4.0;\r\n\r\nfunction colorDefFromJson(props?: ColorDefProps): ColorDef | undefined {\r\n return undefined !== props ? ColorDef.fromJSON(props) : undefined;\r\n}\r\n\r\n/** A type containing all of the properties and none of the methods of [[SkyGradient]] with `readonly` modifiers removed.\r\n * @see [[SkyGradient.create]] and [[SkyGradient.clone]].\r\n * @public\r\n */\r\nexport type SkyGradientProperties = NonFunctionPropertiesOf<SkyGradient>;\r\n\r\n/** Describes how to map a two- or four-color [[Gradient]] to the interior of a sphere to produce a [[SkyBox]].\r\n * @see [[SkyBox.gradient]].\r\n * @public\r\n */\r\nexport class SkyGradient {\r\n public readonly twoColor: boolean;\r\n public readonly skyColor: ColorDef;\r\n public readonly groundColor: ColorDef;\r\n public readonly zenithColor: ColorDef;\r\n public readonly nadirColor: ColorDef;\r\n public readonly skyExponent: number;\r\n public readonly groundExponent: number;\r\n\r\n private constructor(args: Partial<SkyGradientProperties>) {\r\n this.twoColor = args.twoColor ?? false;\r\n this.skyColor = args.skyColor ?? defaultSkyColor;\r\n this.groundColor = args.groundColor ?? defaultGroundColor;\r\n this.nadirColor = args.nadirColor ?? defaultNadirColor;\r\n this.zenithColor = args.zenithColor ?? defaultZenithColor;\r\n this.skyExponent = args.skyExponent ?? defaultExponent;\r\n this.groundExponent = args.groundExponent ?? defaultExponent;\r\n }\r\n\r\n /** Default settings for a four-color gradient. */\r\n public static readonly defaults = new SkyGradient({});\r\n\r\n /** Create a new gradient. Any properties not specified by `props` are initialized to their default values. */\r\n public static create(props?: Partial<SkyGradientProperties>): SkyGradient {\r\n return props ? new this(props) : this.defaults;\r\n }\r\n\r\n /** Create from JSON representation. */\r\n public static fromJSON(props?: SkyBoxProps): SkyGradient {\r\n if (!props)\r\n return this.defaults;\r\n\r\n return new this({\r\n twoColor: props.twoColor,\r\n skyExponent: props.skyExponent,\r\n groundExponent: props.groundExponent,\r\n skyColor: colorDefFromJson(props.skyColor),\r\n groundColor: colorDefFromJson(props.groundColor),\r\n nadirColor: colorDefFromJson(props.nadirColor),\r\n zenithColor: colorDefFromJson(props.zenithColor),\r\n });\r\n }\r\n\r\n /** Create ea copy of this gradient, identical except for any properties explicitly specified by `changedProps`.\r\n * Any properties of `changedProps` explicitly set to `undefined` will be reset to their default values.\r\n */\r\n public clone(changedProps: SkyGradientProperties): SkyGradient {\r\n return new SkyGradient({ ...this, ...changedProps });\r\n }\r\n\r\n /** Convert to JSON representation. */\r\n public toJSON(): SkyBoxProps {\r\n const props: SkyBoxProps = {\r\n skyColor: this.skyColor.toJSON(),\r\n groundColor: this.groundColor.toJSON(),\r\n nadirColor: this.nadirColor.toJSON(),\r\n zenithColor: this.zenithColor.toJSON(),\r\n };\r\n\r\n if (this.groundExponent !== defaultExponent)\r\n props.groundExponent = this.groundExponent;\r\n\r\n if (this.skyExponent !== defaultExponent)\r\n props.skyExponent = this.skyExponent;\r\n\r\n if (this.twoColor)\r\n props.twoColor = this.twoColor;\r\n\r\n return props;\r\n }\r\n\r\n /** Returns true if this gradient is equivalent to the supplied gradient. */\r\n public equals(other: SkyGradient): boolean {\r\n if (this === other)\r\n return true;\r\n\r\n return this.twoColor === other.twoColor && this.skyColor.equals(other.skyColor) && this.groundColor.equals(other.groundColor) &&\r\n this.zenithColor.equals(other.zenithColor) && this.nadirColor.equals(other.nadirColor);\r\n }\r\n}\r\n\r\n/** Describes how to draw a representation of a sky, as part of an [[Environment]].\r\n * @see [[SkyBoxProps]].\r\n * @public\r\n */\r\nexport class SkyBox {\r\n /** The gradient settings, used if no cube or sphere images are supplied, or if the images cannot be loaded. */\r\n public readonly gradient: SkyGradient;\r\n\r\n protected constructor(gradient: SkyGradient) {\r\n this.gradient = gradient;\r\n }\r\n\r\n /** Default settings for a four-color gradient. */\r\n public static readonly defaults = new SkyBox(SkyGradient.defaults);\r\n\r\n /** Create a skybox that displays the specified gradient, or the default gradient if none is supplied. */\r\n public static createGradient(gradient?: SkyGradient): SkyBox {\r\n return gradient ? new this(gradient) : this.defaults;\r\n }\r\n\r\n /** Create from JSON representation. */\r\n public static fromJSON(props?: SkyBoxProps): SkyBox {\r\n const gradient = SkyGradient.fromJSON(props);\r\n\r\n if (props?.image) {\r\n switch (props.image.type) {\r\n case SkyBoxImageType.Spherical:\r\n if (undefined !== props.image.texture)\r\n return new SkySphere(props.image.texture, gradient);\r\n\r\n break;\r\n case SkyBoxImageType.Cube: {\r\n const tx = props.image.textures;\r\n if (tx && undefined !== tx.top && undefined !== tx.bottom && undefined !== tx.right && undefined !== tx.left && undefined !== tx.front && undefined !== tx.back)\r\n return new SkyCube(tx, gradient);\r\n\r\n break;\r\n }\r\n }\r\n }\r\n\r\n return this.createGradient(gradient);\r\n }\r\n\r\n /** Convert to JSON representation.\r\n * @param display If defined, the value to use for [[SkyBoxProps.display]]; otherwise, that property will be left undefined.\r\n */\r\n public toJSON(display?: boolean): SkyBoxProps {\r\n const props = this.gradient.toJSON();\r\n if (undefined !== display)\r\n props.display = display;\r\n\r\n return props;\r\n }\r\n\r\n /** @internal */\r\n public get textureIds(): Iterable<Id64String> {\r\n return [];\r\n }\r\n}\r\n\r\n/** Describes how to draw a representation of a sky by mapping a single image to the interior of a sphere.\r\n * @public\r\n */\r\nexport class SkySphere extends SkyBox {\r\n /** The image to map to the interior of the sphere. */\r\n public readonly image: TextureImageSpec;\r\n\r\n /** Create a new sky sphere using the specified image.\r\n * @param image The image to map to the interior of the sphere.\r\n * @param gradient Optionally overrides the default gradient settings used if the image cannot be obtained.\r\n */\r\n public constructor(image: TextureImageSpec, gradient?: SkyGradient) {\r\n super(gradient ?? SkyGradient.defaults);\r\n this.image = image;\r\n }\r\n\r\n /** @internal override */\r\n public override toJSON(display?: boolean): SkyBoxProps {\r\n const props = super.toJSON(display);\r\n props.image = {\r\n type: SkyBoxImageType.Spherical,\r\n texture: this.image,\r\n };\r\n\r\n return props;\r\n }\r\n\r\n /** @internal */\r\n public override get textureIds(): Iterable<Id64String> {\r\n return Id64.isValidId64(this.image) ? [this.image] : [];\r\n }\r\n}\r\n\r\n/** Describes how to draw a representation of a sky by mapping images to the interior faces of a cube.\r\n * The images are required to be *square*, and each image must have the same dimensions as the other images.\r\n * @public\r\n */\r\nexport class SkyCube extends SkyBox {\r\n /** The images to map to each face of the cube. */\r\n public readonly images: SkyCubeProps;\r\n\r\n /** Create a new sky cube using the specified images.\r\n * @param images The images to map to each face of the cube.\r\n * @param Optionally overrides the default gradient settings used if the images cannot be obtained.\r\n */\r\n public constructor(images: SkyCubeProps, gradient?: SkyGradient) {\r\n super(gradient ?? SkyGradient.defaults);\r\n this.images = { ...images };\r\n }\r\n\r\n /** @internal override */\r\n public override toJSON(display?: boolean): SkyBoxProps {\r\n const props = super.toJSON(display);\r\n props.image = {\r\n type: SkyBoxImageType.Cube,\r\n textures: { ...this.images },\r\n };\r\n\r\n return props;\r\n }\r\n\r\n /** @internal */\r\n public override get textureIds(): Iterable<Id64String> {\r\n const imgs = this.images;\r\n return [imgs.front, imgs.back, imgs.top, imgs.bottom, imgs.left, imgs.right].filter((x) => Id64.isValidId64(x));\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"SkyBox.js","sourceRoot":"","sources":["../../src/SkyBox.ts"],"names":[],"mappings":";AAAA;;;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AAI,CAAC,MAAM,CAAC;QACzB,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,mBAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;IAClH,CAAC;CACF;AA7BD,0BA6BC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module DisplayStyles\r\n */\r\n\r\nimport { Id64, Id64String, NonFunctionPropertiesOf } from \"@itwin/core-bentley\";\r\nimport { ColorDef, ColorDefProps } from \"./ColorDef\";\r\nimport { TextureImageSpec } from \"./RenderTexture\";\r\n\r\n/** Supported types of [[SkyBox]] images.\r\n * @see [[SkyBoxImageProps]].\r\n * @public\r\n * @extensions\r\n */\r\nexport enum SkyBoxImageType {\r\n /** No image, indicating a [[SkyGradient]] should be displayed. */\r\n None = 0,\r\n /** A single image mapped to the surface of a sphere.\r\n * @see [[SkySphere]].\r\n */\r\n Spherical = 1,\r\n /** @internal not yet supported */\r\n Cylindrical = 2,\r\n /** Six images mapped to the faces of a cube.\r\n * @see [[SkyCube]].\r\n */\r\n Cube = 3,\r\n}\r\n\r\n/** JSON representation of the six images used by a [[SkyCube]].\r\n * Each property specifies the image for a face of the cube as either an image URL, or the Id of a [Texture]($backend) element.\r\n * Each image must be square and have the same dimensions as all the other images.\r\n * @public\r\n * @extensions\r\n */\r\nexport interface SkyCubeProps {\r\n front: TextureImageSpec;\r\n back: TextureImageSpec;\r\n top: TextureImageSpec;\r\n bottom: TextureImageSpec;\r\n right: TextureImageSpec;\r\n left: TextureImageSpec;\r\n}\r\n\r\n/** JSON representation of the image used for a [[SkySphere]].\r\n * @see [[SkyBoxProps.image]].\r\n * @public\r\n */\r\nexport interface SkySphereImageProps {\r\n type: SkyBoxImageType.Spherical;\r\n texture: TextureImageSpec;\r\n /** @internal */\r\n textures?: never;\r\n}\r\n\r\n/** JSON representation of the images used for a [[SkyCube]].\r\n * @see [[SkyBoxProps.image]].\r\n * @public\r\n */\r\nexport interface SkyCubeImageProps {\r\n type: SkyBoxImageType.Cube;\r\n textures: SkyCubeProps;\r\n /** @internal */\r\n texture?: never;\r\n}\r\n\r\n/** JSON representation of the image(s) to be mapped to the surfaces of a [[SkyBox]].\r\n * @see [[SkyBoxProps.image]].\r\n * @public\r\n * @extensions\r\n */\r\nexport type SkyBoxImageProps = SkySphereImageProps | SkyCubeImageProps | { type?: SkyBoxImageType, texture?: never, textures?: never };\r\n\r\n/** JSON representation of a [[SkyBox]] that can be drawn as the background of a [ViewState3d]($frontend).\r\n * An object of this type can describe one of several types of sky box:\r\n * - A cube with a texture image mapped to each face; or\r\n * - A sphere with a single texture image mapped to its surface; or\r\n * - A sphere with a two- or four-color vertical [[Gradient]] mapped to its surface.\r\n *\r\n * Whether cuboid or spherical, the skybox is drawn as if the viewer and the contents of the view are contained within its interior.\r\n *\r\n * For a two-color gradient, the gradient transitions smoothly from the nadir color at the bottom of the sphere to the zenith color at the top of the sphere.\r\n * The sky and ground colors are unused, as are the sky and ground exponents.\r\n *\r\n * For a four-color gradient, a \"horizon\" is produced on the equator of the sphere, where the ground color and sky color meet. The lower half of the sphere transitions\r\n * smoothly from the ground color at the equator to the nadir color at the bottom, and the upper half transitions from the sky color at the equator to the zenith color at\r\n * the top of the sphere.\r\n *\r\n * The color and exponent properties are unused if one or more texture images are supplied.\r\n *\r\n * The skybox is ignored entirely when an atmosphere is displayed.\r\n *\r\n * @see [[DisplayStyle3dSettings.environment]] to define the skybox for a display style.\r\n * @public\r\n * @extensions\r\n */\r\nexport interface SkyBoxProps {\r\n /** Whether or not the skybox should be displayed.\r\n * Default: false.\r\n */\r\n display?: boolean;\r\n /** For a [[SkyGradient]], if true, a 2-color gradient skybox is used instead of a 4-color.\r\n * Default: false.\r\n */\r\n twoColor?: boolean;\r\n /** The color of the sky at the horizon. Unused unless this is a four-color [[SkyGradient]].\r\n * Default: (143, 205, 255).\r\n */\r\n skyColor?: ColorDefProps;\r\n /** The color of the ground at the horizon. Unused unless this is a four-color [[SkyGradient]].\r\n * Default: (120, 143, 125).\r\n */\r\n groundColor?: ColorDefProps;\r\n /** The color of the top of the sphere.\r\n * Default: (54, 117, 255).\r\n */\r\n zenithColor?: ColorDefProps;\r\n /** The color of the bottom of the sphere.\r\n * Default: (40, 15, 0).\r\n */\r\n nadirColor?: ColorDefProps;\r\n /** For a 4-color [[SkyGradient]], controls speed of change from sky color to zenith color; otherwise unused.\r\n * Default: 4.0.\r\n */\r\n skyExponent?: number;\r\n /** For a 4-color [[SkyGradient]], controls speed of change from ground color to nadir color; otherwise unused.\r\n * Default: 4.0.\r\n */\r\n groundExponent?: number;\r\n /** The image(s), if any, to be mapped to the surfaces of the sphere or cube. If undefined, the skybox will be displayed as a gradient instead.\r\n * Default: undefined.\r\n */\r\n image?: SkyBoxImageProps;\r\n}\r\n\r\nconst defaultGroundColor = ColorDef.from(143, 205, 125);\r\nconst defaultZenithColor = ColorDef.from(54, 117, 255);\r\nconst defaultNadirColor = ColorDef.from(40, 125, 0);\r\nconst defaultSkyColor = ColorDef.from(142, 205, 255);\r\nconst defaultExponent = 4.0;\r\n\r\nfunction colorDefFromJson(props?: ColorDefProps): ColorDef | undefined {\r\n return undefined !== props ? ColorDef.fromJSON(props) : undefined;\r\n}\r\n\r\n/** A type containing all of the properties and none of the methods of [[SkyGradient]] with `readonly` modifiers removed.\r\n * @see [[SkyGradient.create]] and [[SkyGradient.clone]].\r\n * @public\r\n */\r\nexport type SkyGradientProperties = NonFunctionPropertiesOf<SkyGradient>;\r\n\r\n/** Describes how to map a two- or four-color [[Gradient]] to the interior of a sphere to produce a [[SkyBox]].\r\n * @see [[SkyBox.gradient]].\r\n * @public\r\n */\r\nexport class SkyGradient {\r\n public readonly twoColor: boolean;\r\n public readonly skyColor: ColorDef;\r\n public readonly groundColor: ColorDef;\r\n public readonly zenithColor: ColorDef;\r\n public readonly nadirColor: ColorDef;\r\n public readonly skyExponent: number;\r\n public readonly groundExponent: number;\r\n\r\n private constructor(args: Partial<SkyGradientProperties>) {\r\n this.twoColor = args.twoColor ?? false;\r\n this.skyColor = args.skyColor ?? defaultSkyColor;\r\n this.groundColor = args.groundColor ?? defaultGroundColor;\r\n this.nadirColor = args.nadirColor ?? defaultNadirColor;\r\n this.zenithColor = args.zenithColor ?? defaultZenithColor;\r\n this.skyExponent = args.skyExponent ?? defaultExponent;\r\n this.groundExponent = args.groundExponent ?? defaultExponent;\r\n }\r\n\r\n /** Default settings for a four-color gradient. */\r\n public static readonly defaults = new SkyGradient({});\r\n\r\n /** Create a new gradient. Any properties not specified by `props` are initialized to their default values. */\r\n public static create(props?: Partial<SkyGradientProperties>): SkyGradient {\r\n return props ? new this(props) : this.defaults;\r\n }\r\n\r\n /** Create from JSON representation. */\r\n public static fromJSON(props?: SkyBoxProps): SkyGradient {\r\n if (!props)\r\n return this.defaults;\r\n\r\n return new this({\r\n twoColor: props.twoColor,\r\n skyExponent: props.skyExponent,\r\n groundExponent: props.groundExponent,\r\n skyColor: colorDefFromJson(props.skyColor),\r\n groundColor: colorDefFromJson(props.groundColor),\r\n nadirColor: colorDefFromJson(props.nadirColor),\r\n zenithColor: colorDefFromJson(props.zenithColor),\r\n });\r\n }\r\n\r\n /** Create ea copy of this gradient, identical except for any properties explicitly specified by `changedProps`.\r\n * Any properties of `changedProps` explicitly set to `undefined` will be reset to their default values.\r\n */\r\n public clone(changedProps: SkyGradientProperties): SkyGradient {\r\n return new SkyGradient({ ...this, ...changedProps });\r\n }\r\n\r\n /** Convert to JSON representation. */\r\n public toJSON(): SkyBoxProps {\r\n const props: SkyBoxProps = {\r\n skyColor: this.skyColor.toJSON(),\r\n groundColor: this.groundColor.toJSON(),\r\n nadirColor: this.nadirColor.toJSON(),\r\n zenithColor: this.zenithColor.toJSON(),\r\n };\r\n\r\n if (this.groundExponent !== defaultExponent)\r\n props.groundExponent = this.groundExponent;\r\n\r\n if (this.skyExponent !== defaultExponent)\r\n props.skyExponent = this.skyExponent;\r\n\r\n if (this.twoColor)\r\n props.twoColor = this.twoColor;\r\n\r\n return props;\r\n }\r\n\r\n /** Returns true if this gradient is equivalent to the supplied gradient. */\r\n public equals(other: SkyGradient): boolean {\r\n if (this === other)\r\n return true;\r\n\r\n return this.twoColor === other.twoColor && this.skyColor.equals(other.skyColor) && this.groundColor.equals(other.groundColor) &&\r\n this.zenithColor.equals(other.zenithColor) && this.nadirColor.equals(other.nadirColor);\r\n }\r\n}\r\n\r\n/** Describes how to draw a representation of a sky, as part of an [[Environment]].\r\n * @see [[SkyBoxProps]].\r\n * @public\r\n */\r\nexport class SkyBox {\r\n /** The gradient settings, used if no cube or sphere images are supplied, or if the images cannot be loaded. */\r\n public readonly gradient: SkyGradient;\r\n\r\n protected constructor(gradient: SkyGradient) {\r\n this.gradient = gradient;\r\n }\r\n\r\n /** Default settings for a four-color gradient. */\r\n public static readonly defaults = new SkyBox(SkyGradient.defaults);\r\n\r\n /** Create a skybox that displays the specified gradient, or the default gradient if none is supplied. */\r\n public static createGradient(gradient?: SkyGradient): SkyBox {\r\n return gradient ? new this(gradient) : this.defaults;\r\n }\r\n\r\n /** Create from JSON representation. */\r\n public static fromJSON(props?: SkyBoxProps): SkyBox {\r\n const gradient = SkyGradient.fromJSON(props);\r\n\r\n if (props?.image) {\r\n switch (props.image.type) {\r\n case SkyBoxImageType.Spherical:\r\n if (undefined !== props.image.texture)\r\n return new SkySphere(props.image.texture, gradient);\r\n\r\n break;\r\n case SkyBoxImageType.Cube: {\r\n const tx = props.image.textures;\r\n if (tx && undefined !== tx.top && undefined !== tx.bottom && undefined !== tx.right && undefined !== tx.left && undefined !== tx.front && undefined !== tx.back)\r\n return new SkyCube(tx, gradient);\r\n\r\n break;\r\n }\r\n }\r\n }\r\n\r\n return this.createGradient(gradient);\r\n }\r\n\r\n /** Convert to JSON representation.\r\n * @param display If defined, the value to use for [[SkyBoxProps.display]]; otherwise, that property will be left undefined.\r\n */\r\n public toJSON(display?: boolean): SkyBoxProps {\r\n const props = this.gradient.toJSON();\r\n if (undefined !== display)\r\n props.display = display;\r\n\r\n return props;\r\n }\r\n\r\n /** @internal */\r\n public get textureIds(): Iterable<Id64String> {\r\n return [];\r\n }\r\n}\r\n\r\n/** Describes how to draw a representation of a sky by mapping a single image to the interior of a sphere.\r\n * @public\r\n */\r\nexport class SkySphere extends SkyBox {\r\n /** The image to map to the interior of the sphere. */\r\n public readonly image: TextureImageSpec;\r\n\r\n /** Create a new sky sphere using the specified image.\r\n * @param image The image to map to the interior of the sphere.\r\n * @param gradient Optionally overrides the default gradient settings used if the image cannot be obtained.\r\n */\r\n public constructor(image: TextureImageSpec, gradient?: SkyGradient) {\r\n super(gradient ?? SkyGradient.defaults);\r\n this.image = image;\r\n }\r\n\r\n /** See [[SkyBox.toJSON]]. */\r\n public override toJSON(display?: boolean): SkyBoxProps {\r\n const props = super.toJSON(display);\r\n props.image = {\r\n type: SkyBoxImageType.Spherical,\r\n texture: this.image,\r\n };\r\n\r\n return props;\r\n }\r\n\r\n /** @internal */\r\n public override get textureIds(): Iterable<Id64String> {\r\n return Id64.isValidId64(this.image) ? [this.image] : [];\r\n }\r\n}\r\n\r\n/** Describes how to draw a representation of a sky by mapping images to the interior faces of a cube.\r\n * The images are required to be *square*, and each image must have the same dimensions as the other images.\r\n * @public\r\n */\r\nexport class SkyCube extends SkyBox {\r\n /** The images to map to each face of the cube. */\r\n public readonly images: SkyCubeProps;\r\n\r\n /** Create a new sky cube using the specified images.\r\n * @param images The images to map to each face of the cube.\r\n * @param gradient Optionally overrides the default gradient settings used if the images cannot be obtained.\r\n */\r\n public constructor(images: SkyCubeProps, gradient?: SkyGradient) {\r\n super(gradient ?? SkyGradient.defaults);\r\n this.images = { ...images };\r\n }\r\n\r\n /** See [[SkyBox.toJSON]]. */\r\n public override toJSON(display?: boolean): SkyBoxProps {\r\n const props = super.toJSON(display);\r\n props.image = {\r\n type: SkyBoxImageType.Cube,\r\n textures: { ...this.images },\r\n };\r\n\r\n return props;\r\n }\r\n\r\n /** @internal */\r\n public override get textureIds(): Iterable<Id64String> {\r\n const imgs = this.images;\r\n return [imgs.front, imgs.back, imgs.top, imgs.bottom, imgs.left, imgs.right].filter((x) => Id64.isValidId64(x));\r\n }\r\n}\r\n"]}
|
package/lib/cjs/ViewFlags.d.ts
CHANGED
|
@@ -249,11 +249,11 @@ export declare class ViewFlags {
|
|
|
249
249
|
hiddenEdgesVisible(): boolean;
|
|
250
250
|
/** Returns true if the edges of surfaces should be displayed, based on [[RenderMode]] and the [[visibleEdges]] flag. */
|
|
251
251
|
edgesRequired(): boolean;
|
|
252
|
-
/** Convert to JSON representation.
|
|
253
|
-
|
|
254
|
-
/** Like [[toJSON]], but no properties are omitted.
|
|
255
|
-
* @internal
|
|
252
|
+
/** Convert to JSON representation.
|
|
253
|
+
* Properties are omitted if they match the default values.
|
|
256
254
|
*/
|
|
255
|
+
toJSON(): ViewFlagProps;
|
|
256
|
+
/** Like [[toJSON]], but no properties are omitted. */
|
|
257
257
|
toFullyDefinedJSON(): Required<ViewFlagProps>;
|
|
258
258
|
/** A ViewFlags object with all properties initialized to their default values. */
|
|
259
259
|
static readonly defaults: ViewFlags;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ViewFlags.d.ts","sourceRoot":"","sources":["../../src/ViewFlags.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,EAAa,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAElF;;;;GAIG;AACH,oBAAY,UAAU;IACpB;;;;OAIG;IACH,SAAS,IAAI;IACb;;;;OAIG;IACH,WAAW,IAAI;IACf;;;;;OAKG;I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;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC"}
|
package/lib/cjs/ViewFlags.js
CHANGED
|
@@ -194,7 +194,9 @@ class ViewFlags {
|
|
|
194
194
|
edgesRequired() {
|
|
195
195
|
return edgesRequired(this.renderMode, this.visibleEdges);
|
|
196
196
|
}
|
|
197
|
-
/** Convert to JSON representation.
|
|
197
|
+
/** Convert to JSON representation.
|
|
198
|
+
* Properties are omitted if they match the default values.
|
|
199
|
+
*/
|
|
198
200
|
toJSON() {
|
|
199
201
|
const out = {};
|
|
200
202
|
if (!this.constructions)
|
|
@@ -246,9 +248,7 @@ class ViewFlags {
|
|
|
246
248
|
out.renderMode = this.renderMode;
|
|
247
249
|
return out;
|
|
248
250
|
}
|
|
249
|
-
/** Like [[toJSON]], but no properties are omitted.
|
|
250
|
-
* @internal
|
|
251
|
-
*/
|
|
251
|
+
/** Like [[toJSON]], but no properties are omitted. */
|
|
252
252
|
toFullyDefinedJSON() {
|
|
253
253
|
return {
|
|
254
254
|
renderMode: this.renderMode,
|