@itwin/frontend-tiles 4.4.0-dev.9 → 4.5.0-dev.2
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 +6 -1
- package/lib/cjs/BatchedModelGroups.d.ts +45 -0
- package/lib/cjs/BatchedModelGroups.d.ts.map +1 -0
- package/lib/cjs/BatchedModelGroups.js +110 -0
- package/lib/cjs/BatchedModelGroups.js.map +1 -0
- package/lib/cjs/BatchedModels.d.ts +2 -3
- package/lib/cjs/BatchedModels.d.ts.map +1 -1
- package/lib/cjs/BatchedModels.js +5 -26
- package/lib/cjs/BatchedModels.js.map +1 -1
- package/lib/cjs/BatchedSpatialTileTreeRefs.d.ts.map +1 -1
- package/lib/cjs/BatchedSpatialTileTreeRefs.js +55 -47
- package/lib/cjs/BatchedSpatialTileTreeRefs.js.map +1 -1
- package/lib/cjs/BatchedTile.d.ts.map +1 -1
- package/lib/cjs/BatchedTile.js +3 -0
- package/lib/cjs/BatchedTile.js.map +1 -1
- package/lib/cjs/BatchedTileContentReader.js.map +1 -1
- package/lib/cjs/BatchedTileTree.d.ts +5 -3
- package/lib/cjs/BatchedTileTree.d.ts.map +1 -1
- package/lib/cjs/BatchedTileTree.js +1 -0
- package/lib/cjs/BatchedTileTree.js.map +1 -1
- package/lib/cjs/BatchedTileTreeReference.d.ts +25 -27
- package/lib/cjs/BatchedTileTreeReference.d.ts.map +1 -1
- package/lib/cjs/BatchedTileTreeReference.js +64 -44
- package/lib/cjs/BatchedTileTreeReference.js.map +1 -1
- package/lib/cjs/BatchedTileTreeSupplier.d.ts +5 -0
- package/lib/cjs/BatchedTileTreeSupplier.d.ts.map +1 -1
- package/lib/cjs/BatchedTileTreeSupplier.js +4 -2
- package/lib/cjs/BatchedTileTreeSupplier.js.map +1 -1
- package/lib/cjs/BatchedTilesetReader.d.ts +29 -12
- package/lib/cjs/BatchedTilesetReader.d.ts.map +1 -1
- package/lib/cjs/BatchedTilesetReader.js +19 -8
- package/lib/cjs/BatchedTilesetReader.js.map +1 -1
- package/lib/cjs/FrontendTiles.js.map +1 -1
- package/lib/cjs/LoggerCategory.js.map +1 -1
- package/lib/cjs/ModelGroup.d.ts +48 -0
- package/lib/cjs/ModelGroup.d.ts.map +1 -0
- package/lib/cjs/ModelGroup.js +89 -0
- package/lib/cjs/ModelGroup.js.map +1 -0
- package/lib/cjs/ModelGroupDisplayTransforms.d.ts +22 -0
- package/lib/cjs/ModelGroupDisplayTransforms.d.ts.map +1 -0
- package/lib/cjs/ModelGroupDisplayTransforms.js +62 -0
- package/lib/cjs/ModelGroupDisplayTransforms.js.map +1 -0
- package/lib/cjs/frontend-tiles.js.map +1 -1
- package/lib/esm/BatchedModelGroups.d.ts +45 -0
- package/lib/esm/BatchedModelGroups.d.ts.map +1 -0
- package/lib/esm/BatchedModelGroups.js +106 -0
- package/lib/esm/BatchedModelGroups.js.map +1 -0
- package/lib/esm/BatchedModels.d.ts +2 -3
- package/lib/esm/BatchedModels.d.ts.map +1 -1
- package/lib/esm/BatchedModels.js +5 -26
- package/lib/esm/BatchedModels.js.map +1 -1
- package/lib/esm/BatchedSpatialTileTreeRefs.d.ts.map +1 -1
- package/lib/esm/BatchedSpatialTileTreeRefs.js +58 -50
- package/lib/esm/BatchedSpatialTileTreeRefs.js.map +1 -1
- package/lib/esm/BatchedTile.d.ts.map +1 -1
- package/lib/esm/BatchedTile.js +3 -0
- package/lib/esm/BatchedTile.js.map +1 -1
- package/lib/esm/BatchedTileContentReader.js.map +1 -1
- package/lib/esm/BatchedTileTree.d.ts +5 -3
- package/lib/esm/BatchedTileTree.d.ts.map +1 -1
- package/lib/esm/BatchedTileTree.js +1 -0
- package/lib/esm/BatchedTileTree.js.map +1 -1
- package/lib/esm/BatchedTileTreeReference.d.ts +25 -27
- package/lib/esm/BatchedTileTreeReference.d.ts.map +1 -1
- package/lib/esm/BatchedTileTreeReference.js +63 -41
- package/lib/esm/BatchedTileTreeReference.js.map +1 -1
- package/lib/esm/BatchedTileTreeSupplier.d.ts +5 -0
- package/lib/esm/BatchedTileTreeSupplier.d.ts.map +1 -1
- package/lib/esm/BatchedTileTreeSupplier.js +5 -3
- package/lib/esm/BatchedTileTreeSupplier.js.map +1 -1
- package/lib/esm/BatchedTilesetReader.d.ts +29 -12
- package/lib/esm/BatchedTilesetReader.d.ts.map +1 -1
- package/lib/esm/BatchedTilesetReader.js +19 -8
- package/lib/esm/BatchedTilesetReader.js.map +1 -1
- package/lib/esm/FrontendTiles.js.map +1 -1
- package/lib/esm/LoggerCategory.js.map +1 -1
- package/lib/esm/ModelGroup.d.ts +48 -0
- package/lib/esm/ModelGroup.d.ts.map +1 -0
- package/lib/esm/ModelGroup.js +85 -0
- package/lib/esm/ModelGroup.js.map +1 -0
- package/lib/esm/ModelGroupDisplayTransforms.d.ts +22 -0
- package/lib/esm/ModelGroupDisplayTransforms.d.ts.map +1 -0
- package/lib/esm/ModelGroupDisplayTransforms.js +58 -0
- package/lib/esm/ModelGroupDisplayTransforms.js.map +1 -0
- package/lib/esm/frontend-tiles.js.map +1 -1
- package/package.json +13 -14
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*--------------------------------------------------------------------------------------------*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.BatchedTilesetReader = exports.BatchedTilesetSpec = void 0;
|
|
8
|
+
const core_bentley_1 = require("@itwin/core-bentley");
|
|
8
9
|
const core_geometry_1 = require("@itwin/core-geometry");
|
|
9
10
|
const core_frontend_1 = require("@itwin/core-frontend");
|
|
10
11
|
function isBatchedTileset(json) {
|
|
@@ -13,6 +14,10 @@ function isBatchedTileset(json) {
|
|
|
13
14
|
const props = json;
|
|
14
15
|
if (!props.root || !props.asset)
|
|
15
16
|
return false;
|
|
17
|
+
// The extension is required.
|
|
18
|
+
const models = props.extensions?.BENTLEY_BatchedTileSet?.models;
|
|
19
|
+
if (!models || typeof models !== "object")
|
|
20
|
+
return false;
|
|
16
21
|
// ###TODO spec requires geometricError to be present on tileset and all tiles; exporter is omitting from tileset.
|
|
17
22
|
if (undefined === props.geometricError)
|
|
18
23
|
props.geometricError = props.root.geometricError;
|
|
@@ -24,7 +29,13 @@ var BatchedTilesetSpec;
|
|
|
24
29
|
function create(baseUrl, json) {
|
|
25
30
|
if (!isBatchedTileset(json))
|
|
26
31
|
throw new Error("Invalid tileset JSON");
|
|
27
|
-
|
|
32
|
+
const models = new Map();
|
|
33
|
+
for (const [modelId, value] of Object.entries(json.extensions.BENTLEY_BatchedTileSet.models)) {
|
|
34
|
+
if (core_bentley_1.Id64.isValidId64(modelId) && value) {
|
|
35
|
+
models.set(modelId, { extents: core_geometry_1.Range3d.fromJSON(value.extents), viewFlags: value.viewFlags ? { ...value.viewFlags } : undefined });
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return { baseUrl, props: json, models };
|
|
28
39
|
}
|
|
29
40
|
BatchedTilesetSpec.create = create;
|
|
30
41
|
})(BatchedTilesetSpec = exports.BatchedTilesetSpec || (exports.BatchedTilesetSpec = {}));
|
|
@@ -56,11 +67,12 @@ function transformFromJSON(json) {
|
|
|
56
67
|
}
|
|
57
68
|
/** @internal */
|
|
58
69
|
class BatchedTilesetReader {
|
|
59
|
-
constructor(spec, iModel) {
|
|
70
|
+
constructor(spec, iModel, modelGroups) {
|
|
60
71
|
this._iModel = iModel;
|
|
61
|
-
this.
|
|
62
|
-
this.
|
|
72
|
+
this._spec = spec;
|
|
73
|
+
this._modelGroups = modelGroups;
|
|
63
74
|
}
|
|
75
|
+
get baseUrl() { return this._spec.baseUrl; }
|
|
64
76
|
readTileParams(json, parent) {
|
|
65
77
|
const content = json.content;
|
|
66
78
|
const geometricError = json.geometricError;
|
|
@@ -93,10 +105,8 @@ class BatchedTilesetReader {
|
|
|
93
105
|
};
|
|
94
106
|
}
|
|
95
107
|
async readTileTreeParams() {
|
|
96
|
-
const root = this.
|
|
108
|
+
const root = this._spec.props.root;
|
|
97
109
|
const location = root.transform ? transformFromJSON(root.transform) : core_geometry_1.Transform.createIdentity();
|
|
98
|
-
const extension = this._tileset.extensions?.BENTLEY_BatchedTileSet;
|
|
99
|
-
const includedModels = extension ? new Set(extension.includedModels) : undefined;
|
|
100
110
|
return {
|
|
101
111
|
id: "spatial-models",
|
|
102
112
|
modelId: this._iModel.transientIds.getNext(),
|
|
@@ -105,7 +115,8 @@ class BatchedTilesetReader {
|
|
|
105
115
|
priority: core_frontend_1.TileLoadPriority.Primary,
|
|
106
116
|
rootTile: this.readTileParams(root),
|
|
107
117
|
reader: this,
|
|
108
|
-
|
|
118
|
+
models: this._spec.models,
|
|
119
|
+
modelGroups: this._modelGroups,
|
|
109
120
|
};
|
|
110
121
|
}
|
|
111
122
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BatchedTilesetReader.js","sourceRoot":"","sources":["../../src/BatchedTilesetReader.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAG/F,wDAE8B;AAE9B,wDAAiG;AAajG,SAAS,gBAAgB,CAAC,IAAa;IACrC,IAAI,OAAO,IAAI,KAAK,QAAQ;QAC1B,OAAO,KAAK,CAAC;IAEf,MAAM,KAAK,GAAG,IAAsB,CAAC;IAErC,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK;QAC7B,OAAO,KAAK,CAAC;IAEf,kHAAkH;IAClH,IAAI,SAAS,KAAK,KAAK,CAAC,cAAc;QACpC,KAAK,CAAC,cAAc,GAAG,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC;IAEnD,OAAO,IAAI,CAAC;AACd,CAAC;AAQD,gBAAgB;AAChB,IAAiB,kBAAkB,CAOlC;AAPD,WAAiB,kBAAkB;IACjC,SAAgB,MAAM,CAAC,OAAY,EAAE,IAAa;QAChD,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC;YACzB,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;QAE1C,OAAO,EAAE,OAA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AAS,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE;YAC7B,KAAK;YACL,YAAY,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC,uBAAuB,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,SAAS;YACnG,MAAM;YACN,WAAW,EAAE,gBAAgB,GAAG,qCAAqB,CAAC,iCAAiC,CAAC,KAAK,EAAE,cAAc,CAAC;YAC9G,aAAa,EAAE,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ;YACjD,eAAe;SAChB,CAAC;IACJ,CAAC;IAEM,KAAK,CAAC,kBAAkB;QAC7B,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;QAChC,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,iBAAiB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,yBAAS,CAAC,cAAc,EAAE,CAAC;QACjG,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,sBAAsB,CAAC;QACnE,MAAM,cAAc,GAAG,SAAS,CAAC,CAAC,CAAC,IAAI,GAAG,CAAa,SAAS,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAE7F,OAAO;YACL,EAAE,EAAE,gBAAgB;YACpB,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,EAAE;YAC5C,MAAM,EAAE,IAAI,CAAC,OAAO;YACpB,QAAQ;YACR,QAAQ,EAAE,gCAAgB,CAAC,OAAO;YAClC,QAAQ,EAAE,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC;YACnC,MAAM,EAAE,IAAI;YACZ,cAAc;SACf,CAAC;IACJ,CAAC;CACF;AA9DD,oDA8DC","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\r\nimport { Id64String } from \"@itwin/core-bentley\";\r\nimport {\r\n Matrix3d, Point3d, Range3d, Transform, Vector3d,\r\n} from \"@itwin/core-geometry\";\r\nimport { Tileset3dSchema as schema } from \"@itwin/core-common\";\r\nimport { IModelConnection, RealityModelTileUtils, TileLoadPriority } from \"@itwin/core-frontend\";\r\nimport { BatchedTileTreeParams } from \"./BatchedTileTree\";\r\nimport { BatchedTile, BatchedTileParams } from \"./BatchedTile\";\r\n\r\n/** @internal */\r\nexport interface BatchedTilesetProps extends schema.Tileset {\r\n extensions?: {\r\n BENTLEY_BatchedTileSet?: { // eslint-disable-line @typescript-eslint/naming-convention\r\n includedModels: Id64String[];\r\n };\r\n };\r\n}\r\n\r\nfunction isBatchedTileset(json: unknown): json is BatchedTilesetProps {\r\n if (typeof json !== \"object\")\r\n return false;\r\n\r\n const props = json as schema.Tileset;\r\n\r\n if (!props.root || !props.asset)\r\n return false;\r\n\r\n // ###TODO spec requires geometricError to be present on tileset and all tiles; exporter is omitting from tileset.\r\n if (undefined === props.geometricError)\r\n props.geometricError = props.root.geometricError;\r\n\r\n return true;\r\n}\r\n\r\n/** @internal */\r\nexport interface BatchedTilesetSpec {\r\n baseUrl: URL;\r\n props: BatchedTilesetProps;\r\n}\r\n\r\n/** @internal */\r\nexport namespace BatchedTilesetSpec {\r\n export function create(baseUrl: URL, json: unknown) {\r\n if (!isBatchedTileset(json))\r\n throw new Error(\"Invalid tileset JSON\");\r\n\r\n return { baseUrl, props: json };\r\n }\r\n}\r\n\r\nfunction rangeFromBoundingVolume(vol: schema.BoundingVolume): Range3d {\r\n if (vol.box) {\r\n const center = new Point3d(vol.box[0], vol.box[1], vol.box[2]);\r\n const ux = new Vector3d(vol.box[3], vol.box[4], vol.box[5]);\r\n const uy = new Vector3d(vol.box[6], vol.box[7], vol.box[8]);\r\n const uz = new Vector3d(vol.box[9], vol.box[10], vol.box[11]);\r\n\r\n const range = Range3d.createNull();\r\n for (let i = -1; i <= 1; i += 2)\r\n for (let j = -1; j <= 1; j += 2)\r\n for (let k = -1; k <= 1; k += 2)\r\n range.extendPoint(center.plus3Scaled(ux, i, uy, j, uz, k));\r\n\r\n return range;\r\n } else if (vol.sphere) {\r\n const center = new Point3d(vol.sphere[0], vol.sphere[1], vol.sphere[2]);\r\n const radius = vol.sphere[3];\r\n return Range3d.createXYZXYZ(center.x - radius, center.y - radius, center.z - radius, center.x + radius, center.y + radius, center.z + radius);\r\n }\r\n\r\n // We won't get region bounding volumes in our tiles.\r\n throw new Error(\"region bounding volume unimplemented\");\r\n}\r\n\r\nfunction transformFromJSON(json: schema.Transform): Transform {\r\n const translation = new Point3d(json[12], json[13], json[14]);\r\n const matrix = Matrix3d.createRowValues(\r\n json[0], json[4], json[8],\r\n json[1], json[5], json[9],\r\n json[2], json[6], json[10],\r\n );\r\n\r\n return Transform.createOriginAndMatrix(translation, matrix);\r\n}\r\n\r\n/** @internal */\r\nexport class BatchedTilesetReader {\r\n private readonly _iModel: IModelConnection;\r\n private readonly _tileset: schema.Tileset;\r\n public readonly baseUrl: URL;\r\n\r\n public constructor(spec: BatchedTilesetSpec, iModel: IModelConnection) {\r\n this._iModel = iModel;\r\n this._tileset = spec.props;\r\n this.baseUrl = spec.baseUrl;\r\n }\r\n\r\n public readTileParams(json: schema.Tile, parent?: BatchedTile): BatchedTileParams {\r\n const content = json.content;\r\n const geometricError = json.geometricError;\r\n const range = rangeFromBoundingVolume(json.boundingVolume);\r\n const isLeaf = undefined === json.children || json.children.length === 0;\r\n\r\n let transformToRoot;\r\n if (undefined !== parent) {\r\n const localToParent = json.transform ? transformFromJSON(json.transform) : undefined;\r\n const parentToRoot = parent.transformToRoot;\r\n if (localToParent) {\r\n if (parentToRoot)\r\n localToParent.multiplyTransformTransform(parentToRoot, localToParent);\r\n\r\n transformToRoot = localToParent;\r\n } else {\r\n transformToRoot = parentToRoot;\r\n }\r\n }\r\n\r\n // ###TODO evaluate this. The geometric errors in the tiles seem far too small.\r\n const maximumSizeScale = 8;\r\n return {\r\n parent,\r\n contentId: content?.uri ?? \"\",\r\n range,\r\n contentRange: content?.boundingVolume ? rangeFromBoundingVolume(content.boundingVolume) : undefined,\r\n isLeaf,\r\n maximumSize: maximumSizeScale * RealityModelTileUtils.maximumSizeFromGeometricTolerance(range, geometricError),\r\n childrenProps: isLeaf ? undefined : json.children,\r\n transformToRoot,\r\n };\r\n }\r\n\r\n public async readTileTreeParams(): Promise<BatchedTileTreeParams> {\r\n const root = this._tileset.root;\r\n const location = root.transform ? transformFromJSON(root.transform) : Transform.createIdentity();\r\n const extension = this._tileset.extensions?.BENTLEY_BatchedTileSet;\r\n const includedModels = extension ? new Set<Id64String>(extension.includedModels) : undefined;\r\n\r\n return {\r\n id: \"spatial-models\",\r\n modelId: this._iModel.transientIds.getNext(),\r\n iModel: this._iModel,\r\n location,\r\n priority: TileLoadPriority.Primary,\r\n rootTile: this.readTileParams(root),\r\n reader: this,\r\n includedModels,\r\n };\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"BatchedTilesetReader.js","sourceRoot":"","sources":["../../src/BatchedTilesetReader.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,sDAAgE;AAChE,wDAE8B;AAE9B,wDAAiG;AAgCjG,SAAS,gBAAgB,CAAC,IAAa;IACrC,IAAI,OAAO,IAAI,KAAK,QAAQ;QAC1B,OAAO,KAAK,CAAC;IAEf,MAAM,KAAK,GAAG,IAAsB,CAAC;IAErC,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK;QAC7B,OAAO,KAAK,CAAC;IAEf,6BAA6B;IAC7B,MAAM,MAAM,GAAG,KAAK,CAAC,UAAU,EAAE,sBAAsB,EAAE,MAAM,CAAC;IAChE,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ;QACvC,OAAO,KAAK,CAAC;IAEf,kHAAkH;IA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E,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ;YACjD,eAAe;SAChB,CAAC;IACJ,CAAC;IAEM,KAAK,CAAC,kBAAkB;QAC7B,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC;QACnC,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,iBAAiB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,yBAAS,CAAC,cAAc,EAAE,CAAC;QAEjG,OAAO;YACL,EAAE,EAAE,gBAAgB;YACpB,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,EAAE;YAC5C,MAAM,EAAE,IAAI,CAAC,OAAO;YACpB,QAAQ;YACR,QAAQ,EAAE,gCAAgB,CAAC,OAAO;YAClC,QAAQ,EAAE,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC;YACnC,MAAM,EAAE,IAAI;YACZ,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM;YACzB,WAAW,EAAE,IAAI,CAAC,YAAY;SAC/B,CAAC;IACJ,CAAC;CACF;AA/DD,oDA+DC","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\nimport { Id64, Id64Set, Id64String } from \"@itwin/core-bentley\";\nimport {\n Matrix3d, Point3d, Range3d, Range3dProps, Transform, Vector3d,\n} from \"@itwin/core-geometry\";\nimport { Tileset3dSchema as schema, ViewFlagOverrides } from \"@itwin/core-common\";\nimport { IModelConnection, RealityModelTileUtils, TileLoadPriority } from \"@itwin/core-frontend\";\nimport { BatchedTileTreeParams } from \"./BatchedTileTree\";\nimport { BatchedTile, BatchedTileParams } from \"./BatchedTile\";\n\n/** @internal */\nexport interface ModelMetadataProps {\n /** The spatial volume occupied by this model's geometry. */\n extents: Range3dProps;\n /** Overrides to be applied to the view's [ViewFlags]($common) when rendering this model, if any. */\n viewFlags?: ViewFlagOverrides;\n}\n\n/** @internal */\nexport interface ModelMetadata {\n /** The spatial volume occupied by this model's geometry. */\n extents: Range3d;\n /** Overrides to be applied to the view's [ViewFlags]($common) when rendering this model, if any. */\n viewFlags?: ViewFlagOverrides;\n}\n\n/** @internal */\nexport interface BatchedTilesetProps extends schema.Tileset {\n extensions: {\n BENTLEY_BatchedTileSet: { // eslint-disable-line @typescript-eslint/naming-convention\n /** Contains an entry for every model that was processed during publishing of the tileset. */\n models: {\n [modelId: Id64String]: ModelMetadataProps | undefined;\n };\n };\n };\n}\n\nfunction isBatchedTileset(json: unknown): json is BatchedTilesetProps {\n if (typeof json !== \"object\")\n return false;\n\n const props = json as schema.Tileset;\n\n if (!props.root || !props.asset)\n return false;\n\n // The extension is required.\n const models = props.extensions?.BENTLEY_BatchedTileSet?.models;\n if (!models || typeof models !== \"object\")\n return false;\n\n // ###TODO spec requires geometricError to be present on tileset and all tiles; exporter is omitting from tileset.\n if (undefined === props.geometricError)\n props.geometricError = props.root.geometricError;\n\n return true;\n}\n\n/** @internal */\nexport interface BatchedTilesetSpec {\n baseUrl: URL;\n props: BatchedTilesetProps;\n models: Map<Id64String, ModelMetadata>;\n}\n\n/** @internal */\nexport namespace BatchedTilesetSpec {\n export function create(baseUrl: URL, json: unknown): BatchedTilesetSpec {\n if (!isBatchedTileset(json))\n throw new Error(\"Invalid tileset JSON\");\n\n const models = new Map<Id64String, ModelMetadata>();\n for (const [modelId, value] of Object.entries(json.extensions.BENTLEY_BatchedTileSet.models)) {\n if (Id64.isValidId64(modelId) && value) {\n models.set(modelId, { extents: Range3d.fromJSON(value.extents), viewFlags: value.viewFlags ? { ...value.viewFlags } : undefined });\n }\n }\n\n return { baseUrl, props: json, models };\n }\n}\n\nfunction rangeFromBoundingVolume(vol: schema.BoundingVolume): Range3d {\n if (vol.box) {\n const center = new Point3d(vol.box[0], vol.box[1], vol.box[2]);\n const ux = new Vector3d(vol.box[3], vol.box[4], vol.box[5]);\n const uy = new Vector3d(vol.box[6], vol.box[7], vol.box[8]);\n const uz = new Vector3d(vol.box[9], vol.box[10], vol.box[11]);\n\n const range = Range3d.createNull();\n for (let i = -1; i <= 1; i += 2)\n for (let j = -1; j <= 1; j += 2)\n for (let k = -1; k <= 1; k += 2)\n range.extendPoint(center.plus3Scaled(ux, i, uy, j, uz, k));\n\n return range;\n } else if (vol.sphere) {\n const center = new Point3d(vol.sphere[0], vol.sphere[1], vol.sphere[2]);\n const radius = vol.sphere[3];\n return Range3d.createXYZXYZ(center.x - radius, center.y - radius, center.z - radius, center.x + radius, center.y + radius, center.z + radius);\n }\n\n // We won't get region bounding volumes in our tiles.\n throw new Error(\"region bounding volume unimplemented\");\n}\n\nfunction transformFromJSON(json: schema.Transform): Transform {\n const translation = new Point3d(json[12], json[13], json[14]);\n const matrix = Matrix3d.createRowValues(\n json[0], json[4], json[8],\n json[1], json[5], json[9],\n json[2], json[6], json[10],\n );\n\n return Transform.createOriginAndMatrix(translation, matrix);\n}\n\n/** @internal */\nexport class BatchedTilesetReader {\n private readonly _iModel: IModelConnection;\n private readonly _spec: BatchedTilesetSpec;\n private readonly _modelGroups: Id64Set[] | undefined;\n\n public constructor(spec: BatchedTilesetSpec, iModel: IModelConnection, modelGroups: Id64Set[] | undefined) {\n this._iModel = iModel;\n this._spec = spec;\n this._modelGroups = modelGroups;\n }\n\n public get baseUrl(): URL { return this._spec.baseUrl; }\n\n public readTileParams(json: schema.Tile, parent?: BatchedTile): BatchedTileParams {\n const content = json.content;\n const geometricError = json.geometricError;\n const range = rangeFromBoundingVolume(json.boundingVolume);\n const isLeaf = undefined === json.children || json.children.length === 0;\n\n let transformToRoot;\n if (undefined !== parent) {\n const localToParent = json.transform ? transformFromJSON(json.transform) : undefined;\n const parentToRoot = parent.transformToRoot;\n if (localToParent) {\n if (parentToRoot)\n localToParent.multiplyTransformTransform(parentToRoot, localToParent);\n\n transformToRoot = localToParent;\n } else {\n transformToRoot = parentToRoot;\n }\n }\n\n // ###TODO evaluate this. The geometric errors in the tiles seem far too small.\n const maximumSizeScale = 8;\n return {\n parent,\n contentId: content?.uri ?? \"\",\n range,\n contentRange: content?.boundingVolume ? rangeFromBoundingVolume(content.boundingVolume) : undefined,\n isLeaf,\n maximumSize: maximumSizeScale * RealityModelTileUtils.maximumSizeFromGeometricTolerance(range, geometricError),\n childrenProps: isLeaf ? undefined : json.children,\n transformToRoot,\n };\n }\n\n public async readTileTreeParams(): Promise<BatchedTileTreeParams> {\n const root = this._spec.props.root;\n const location = root.transform ? transformFromJSON(root.transform) : Transform.createIdentity();\n\n return {\n id: \"spatial-models\",\n modelId: this._iModel.transientIds.getNext(),\n iModel: this._iModel,\n location,\n priority: TileLoadPriority.Primary,\n rootTile: this.readTileParams(root),\n reader: this,\n models: this._spec.models,\n modelGroups: this._modelGroups,\n };\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FrontendTiles.js","sourceRoot":"","sources":["../../src/FrontendTiles.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,sDAA0D;AAC1D,wDAAgH;AAChH,qDAAkD;AAClD,6EAAsF;AAUtF,SAAS,+BAA+B,CAAC,IAAoE;IAC3G,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,IAAI,EAAE,CAAC;IACpC,IAAI,GAAG,GAAG,WAAW,MAAM,yCAAyC,IAAI,CAAC,QAAQ,qBAAqB,CAAC;IACvG,IAAI,IAAI,CAAC,WAAW;QAClB,GAAG,GAAG,GAAG,GAAG,gBAAgB,IAAI,CAAC,WAAW,EAAE,CAAC;IAEjD,OAAO,GAAG,CAAC;AACb,CAAC;AAwDD;;;;GAIG;AACI,KAAK,SAAU,CAAC,CAAC,gBAAgB,CAAC,IAA0B;IACjE,MAAM,OAAO,GAAG;QACd,mEAAmE;QACnE,aAAa,EAAE,IAAI,CAAC,WAAW,I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I,SAAS,KAAK,OAAO,CAAC,eAAe,IAAI,OAAO,CAAC,eAAe,IAAI,CAAC;QACvE,4BAAoB,CAAC,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;IAEjE,IAAI,OAAO,CAAC,WAAW;QACrB,4BAAoB,CAAC,WAAW,GAAG,IAAI,CAAC;IAE1C,MAAM,UAAU,GAAG,OAAO,CAAC,4BAA4B,IAAI,CACzD,KAAK,EAAE,MAAwB,EAAE,EAAE,CAAC,0BAA0B,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,yBAAS,CAAC,cAAc,EAAE,EAAE,CAAC,CAC1H,CAAC;IAEF,yCAAyB,CAAC,MAAM,GAAG,CAAC,IAAsB,EAAE,EAAE,CAAC,IAAA,mEAAsC,EAAC,IAAI,EAAE,UAAU,CAAC,CAAC;AAC1H,CAAC;AAZD,0DAYC","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\r\nimport { AccessToken, Logger } from \"@itwin/core-bentley\";\r\nimport { IModelApp, IModelConnection, SpatialTileTreeReferences, SpatialViewState } from \"@itwin/core-frontend\";\r\nimport { loggerCategory } from \"./LoggerCategory\";\r\nimport { createBatchedSpatialTileTreeReferences } from \"./BatchedSpatialTileTreeRefs\";\r\n\r\n/** A function that can provide the base URL where a tileset representing all of the spatial models in a given iModel are stored.\r\n * The tileset is expected to reside at \"baseUrl/tileset.json\" and to have been produced by the [mesh export service](https://developer.bentley.com/apis/mesh-export/).\r\n * If no such tileset exists for the given iModel, return `undefined`.\r\n * @see [[FrontendTilesOptions.computeSpatialTilesetBaseUrl]].\r\n * @beta\r\n */\r\nexport type ComputeSpatialTilesetBaseUrl = (iModel: IModelConnection) => Promise<URL | undefined>;\r\n\r\nfunction createMeshExportServiceQueryUrl(args: { iModelId: string, urlPrefix?: string, changesetId?: string }): string {\r\n const prefix = args.urlPrefix ?? \"\";\r\n let url = `https://${prefix}api.bentley.com/mesh-export/?iModelId=${args.iModelId}&$orderBy=date:desc`;\r\n if (args.changesetId)\r\n url = `${url}&changesetId=${args.changesetId}`;\r\n\r\n return url;\r\n}\r\n\r\n/** Represents the result of a [mesh export](https://developer.bentley.com/apis/mesh-export/operations/get-export/#export).\r\n * @see [[queryCompletedMeshExports]].\r\n * @beta\r\n */\r\nexport interface MeshExport {\r\n id: string;\r\n displayName: string;\r\n status: string;\r\n request: {\r\n iModelId: string;\r\n changesetId: string;\r\n exportType: string;\r\n geometryOptions: any;\r\n viewDefinitionFilter: any;\r\n };\r\n\r\n /* eslint-disable-next-line @typescript-eslint/naming-convention */\r\n _links: {\r\n mesh: {\r\n href: string;\r\n };\r\n };\r\n}\r\n\r\n/** Exposed strictly for tests.\r\n * @internal\r\n */\r\nexport interface MeshExports {\r\n exports: MeshExport[];\r\n\r\n /* eslint-disable-next-line @typescript-eslint/naming-convention */\r\n _links: {\r\n next?: {\r\n href: string;\r\n };\r\n };\r\n}\r\n\r\n/** Arguments supplied to [[queryMeshExports]].\r\n * @beta\r\n */\r\nexport interface QueryMeshExportsArgs {\r\n /** The token used to access the mesh export service. */\r\n accessToken: AccessToken;\r\n /** The Id of the iModel for which to query exports. */\r\n iModelId: string;\r\n /** If defined, constrains the query to exports produced from the specified changeset. */\r\n changesetId?: string;\r\n /** Chiefly used in testing environments. */\r\n urlPrefix?: string;\r\n /** If true, exports whose status is not \"Complete\" (indicating the export successfully finished) will be included in the results. */\r\n includeIncomplete?: boolean;\r\n}\r\n\r\n/** Query the [mesh export service](https://developer.bentley.com/apis/mesh-export/operations/get-exports/) for exports of type \"IMODEL\" matching\r\n * the specified criteria.\r\n * The exports are sorted from most-recently- to least-recently-produced.\r\n * @beta\r\n */\r\nexport async function * queryMeshExports(args: QueryMeshExportsArgs): AsyncIterableIterator<MeshExport> {\r\n const headers = {\r\n /* eslint-disable-next-line @typescript-eslint/naming-convention */\r\n Authorization: args.accessToken ?? await IModelApp.getAccessToken(),\r\n /* eslint-disable-next-line @typescript-eslint/naming-convention */\r\n Accept: \"application/vnd.bentley.itwin-platform.v1+json\",\r\n /* eslint-disable-next-line @typescript-eslint/naming-convention */\r\n Prefer: \"return=representation\",\r\n };\r\n\r\n let url: string | undefined = createMeshExportServiceQueryUrl(args);\r\n while (url) {\r\n let result;\r\n try {\r\n const response = await fetch(url, { headers });\r\n result = await response.json() as MeshExports;\r\n } catch (err) {\r\n Logger.logException(loggerCategory, err);\r\n Logger.logError(loggerCategory, `Failed loading exports for iModel ${args.iModelId}`);\r\n break;\r\n }\r\n\r\n const foundExports = result.exports.filter((x) => x.request.exportType === \"IMODEL\" && (args.includeIncomplete || x.status === \"Complete\"));\r\n for (const foundExport of foundExports)\r\n yield foundExport;\r\n\r\n url = result._links.next?.href;\r\n }\r\n}\r\n\r\n/** Arguments supplied to [[obtainMeshExportTilesetUrl]].\r\n * @beta\r\n */\r\nexport interface ObtainMeshExportTilesetUrlArgs {\r\n /** The iModel for which to obtain a tileset URl. */\r\n iModel: IModelConnection;\r\n /** The token used to access the mesh export service. */\r\n accessToken: AccessToken;\r\n /** Chiefly used in testing environments. */\r\n urlPrefix?: string;\r\n /** If true, only exports produced for `iModel`'s specific changeset will be considered; otherwise, if no exports are found for the changeset,\r\n * the most recent export for any changeset will be used.\r\n */\r\n requireExactChangeset?: boolean;\r\n}\r\n\r\n/** Obtains a URL pointing to a tileset appropriate for visualizing a specific iModel.\r\n * [[queryCompletedMeshExports]] is used to obtain a list of available exports. By default, the list is sorted from most to least recently-exported.\r\n * The first export matching the iModel's changeset is selected; or, if no such export exists, the first export in the list is selected.\r\n * @returns A URL from which the tileset can be loaded, or `undefined` if no appropriate URL could be obtained.\r\n * @beta\r\n */\r\nexport async function obtainMeshExportTilesetUrl(args: ObtainMeshExportTilesetUrlArgs): Promise<URL | undefined> {\r\n if (!args.iModel.iModelId) {\r\n Logger.logInfo(loggerCategory, \"Cannot obtain exports for an iModel with no iModelId\");\r\n return undefined;\r\n }\r\n\r\n const queryArgs: QueryMeshExportsArgs = {\r\n accessToken: args.accessToken,\r\n iModelId: args.iModel.iModelId,\r\n changesetId: args.iModel.changeset.id,\r\n urlPrefix: args.urlPrefix,\r\n };\r\n\r\n let selectedExport;\r\n for await (const exp of queryMeshExports(queryArgs)) {\r\n selectedExport = exp;\r\n break;\r\n }\r\n\r\n if (!selectedExport && !args.requireExactChangeset) {\r\n queryArgs.changesetId = undefined;\r\n for await (const exp of queryMeshExports(queryArgs)) {\r\n selectedExport = exp;\r\n Logger.logInfo(loggerCategory, `No exports for iModel ${args.iModel.iModelId} for changeset ${args.iModel.changeset.id}; falling back to most recent`);\r\n break;\r\n }\r\n }\r\n\r\n if (!selectedExport) {\r\n Logger.logInfo(loggerCategory, `No exports available for iModel ${args.iModel.iModelId}`);\r\n return undefined;\r\n }\r\n\r\n const url = new URL(selectedExport._links.mesh.href);\r\n url.pathname = `${url.pathname}/tileset.json`;\r\n return url;\r\n}\r\n\r\n/** Options supplied to [[initializeFrontendTiles]].\r\n * @beta\r\n */\r\nexport interface FrontendTilesOptions {\r\n /** Provide the base URL for the pre-published tileset for a given iModel.\r\n * If omitted, [[obtainMeshExportTilesetUrl]] will be invoked with default arguments, using the access token provided by [[IModelApp]].\r\n */\r\n computeSpatialTilesetBaseUrl?: ComputeSpatialTilesetBaseUrl;\r\n /** The maximum number of levels in the tile tree to skip loading if they do not provide the desired level of detail for the current view.\r\n * Default: 4.\r\n * Reducing this value will load more intermediate tiles, which causes more gradual refinement: low-resolution tiles will display quickly, followed more gradually by\r\n * successively higher-resolution ones.\r\n * Increasing the value jumps more directly to tiles of the exact level of detail desired, which may load more, smaller tiles up-front, leaving some areas of the view\r\n * vacant for longer; and when zooming out some newly-exposed areas of the view may remain vacant for longer because no lower-resolution tiles are initially available to\r\n * fill them. However, tiles close to the viewer (and therefore likely of most interest to them) will refine to an appropriate level of detail more quickly.\r\n */\r\n maxLevelsToSkip?: number;\r\n /** Specifies whether to permit the user to enable visible edges or wireframe mode for batched tiles.\r\n * The currently-deployed mesh export service does not produce edges, so this currently defaults to `false` to avoid user confusion.\r\n * Set it to `true` if you are loading tiles created with a version of the exporter that does produce edges.\r\n * ###TODO delete this option once we deploy an edge-producing version of the exporter to production.\r\n * @internal\r\n */\r\n enableEdges?: boolean;\r\n}\r\n\r\n/** Global configuration initialized by [[initializeFrontendTiles]].\r\n * @internal\r\n */\r\nexport const frontendTilesOptions = {\r\n maxLevelsToSkip: 4,\r\n enableEdges: false,\r\n};\r\n\r\n/** Initialize the frontend-tiles package to obtain tiles for spatial views.\r\n * @beta\r\n */\r\nexport function initializeFrontendTiles(options: FrontendTilesOptions): void {\r\n if (undefined !== options.maxLevelsToSkip && options.maxLevelsToSkip >= 0)\r\n frontendTilesOptions.maxLevelsToSkip = options.maxLevelsToSkip;\r\n\r\n if (options.enableEdges)\r\n frontendTilesOptions.enableEdges = true;\r\n\r\n const computeUrl = options.computeSpatialTilesetBaseUrl ?? (\r\n async (iModel: IModelConnection) => obtainMeshExportTilesetUrl({ iModel, accessToken: await IModelApp.getAccessToken() })\r\n );\r\n\r\n SpatialTileTreeReferences.create = (view: SpatialViewState) => createBatchedSpatialTileTreeReferences(view, computeUrl);\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"FrontendTiles.js","sourceRoot":"","sources":["../../src/FrontendTiles.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,sDAA0D;AAC1D,wDAAgH;AAChH,qDAAkD;AAClD,6EAAsF;AAUtF,SAAS,+BAA+B,CAAC,IAAoE;IAC3G,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,IAAI,EAAE,CAAC;IACpC,IAAI,GAAG,GAAG,WAAW,MAAM,yCAAyC,IAAI,CAAC,QAAQ,qBAAqB,CAAC;IACvG,IAAI,IAAI,CAAC,WAAW;QAClB,GAAG,GAAG,GAAG,GAAG,gBAAgB,IAAI,CAAC,WAAW,EAAE,CAAC;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,CAAC;AApCD,gEAoCC;AA4BD;;GAEG;AACU,QAAA,oBAAoB,GAAG;IAClC,eAAe,EAAE,CAAC;IAClB,WAAW,EAAE,KAAK;CACnB,CAAC;AAEF;;GAEG;AACH,SAAgB,uBAAuB,CAAC,OAA6B;IACnE,IAAI,SAAS,KAAK,OAAO,CAAC,eAAe,IAAI,OAAO,CAAC,eAAe,IAAI,CAAC;QACvE,4BAAoB,CAAC,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;IAEjE,IAAI,OAAO,CAAC,WAAW;QACrB,4BAAoB,CAAC,WAAW,GAAG,IAAI,CAAC;IAE1C,MAAM,UAAU,GAAG,OAAO,CAAC,4BAA4B,IAAI,CACzD,KAAK,EAAE,MAAwB,EAAE,EAAE,CAAC,0BAA0B,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,yBAAS,CAAC,cAAc,EAAE,EAAE,CAAC,CAC1H,CAAC;IAEF,yCAAyB,CAAC,MAAM,GAAG,CAAC,IAAsB,EAAE,EAAE,CAAC,IAAA,mEAAsC,EAAC,IAAI,EAAE,UAAU,CAAC,CAAC;AAC1H,CAAC;AAZD,0DAYC","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\nimport { AccessToken, Logger } from \"@itwin/core-bentley\";\nimport { IModelApp, IModelConnection, SpatialTileTreeReferences, SpatialViewState } from \"@itwin/core-frontend\";\nimport { loggerCategory } from \"./LoggerCategory\";\nimport { createBatchedSpatialTileTreeReferences } from \"./BatchedSpatialTileTreeRefs\";\n\n/** A function that can provide the base URL where a tileset representing all of the spatial models in a given iModel are stored.\n * The tileset is expected to reside at \"baseUrl/tileset.json\" and to have been produced by the [mesh export service](https://developer.bentley.com/apis/mesh-export/).\n * If no such tileset exists for the given iModel, return `undefined`.\n * @see [[FrontendTilesOptions.computeSpatialTilesetBaseUrl]].\n * @beta\n */\nexport type ComputeSpatialTilesetBaseUrl = (iModel: IModelConnection) => Promise<URL | undefined>;\n\nfunction createMeshExportServiceQueryUrl(args: { iModelId: string, urlPrefix?: string, changesetId?: string }): string {\n const prefix = args.urlPrefix ?? \"\";\n let url = `https://${prefix}api.bentley.com/mesh-export/?iModelId=${args.iModelId}&$orderBy=date:desc`;\n if (args.changesetId)\n url = `${url}&changesetId=${args.changesetId}`;\n\n return url;\n}\n\n/** Represents the result of a [mesh export](https://developer.bentley.com/apis/mesh-export/operations/get-export/#export).\n * @see [[queryCompletedMeshExports]].\n * @beta\n */\nexport interface MeshExport {\n id: string;\n displayName: string;\n status: string;\n request: {\n iModelId: string;\n changesetId: string;\n exportType: string;\n geometryOptions: any;\n viewDefinitionFilter: any;\n };\n\n /* eslint-disable-next-line @typescript-eslint/naming-convention */\n _links: {\n mesh: {\n href: string;\n };\n };\n}\n\n/** Exposed strictly for tests.\n * @internal\n */\nexport interface MeshExports {\n exports: MeshExport[];\n\n /* eslint-disable-next-line @typescript-eslint/naming-convention */\n _links: {\n next?: {\n href: string;\n };\n };\n}\n\n/** Arguments supplied to [[queryMeshExports]].\n * @beta\n */\nexport interface QueryMeshExportsArgs {\n /** The token used to access the mesh export service. */\n accessToken: AccessToken;\n /** The Id of the iModel for which to query exports. */\n iModelId: string;\n /** If defined, constrains the query to exports produced from the specified changeset. */\n changesetId?: string;\n /** Chiefly used in testing environments. */\n urlPrefix?: string;\n /** If true, exports whose status is not \"Complete\" (indicating the export successfully finished) will be included in the results. */\n includeIncomplete?: boolean;\n}\n\n/** Query the [mesh export service](https://developer.bentley.com/apis/mesh-export/operations/get-exports/) for exports of type \"IMODEL\" matching\n * the specified criteria.\n * The exports are sorted from most-recently- to least-recently-produced.\n * @beta\n */\nexport async function * queryMeshExports(args: QueryMeshExportsArgs): AsyncIterableIterator<MeshExport> {\n const headers = {\n /* eslint-disable-next-line @typescript-eslint/naming-convention */\n Authorization: args.accessToken ?? await IModelApp.getAccessToken(),\n /* eslint-disable-next-line @typescript-eslint/naming-convention */\n Accept: \"application/vnd.bentley.itwin-platform.v1+json\",\n /* eslint-disable-next-line @typescript-eslint/naming-convention */\n Prefer: \"return=representation\",\n };\n\n let url: string | undefined = createMeshExportServiceQueryUrl(args);\n while (url) {\n let result;\n try {\n const response = await fetch(url, { headers });\n result = await response.json() as MeshExports;\n } catch (err) {\n Logger.logException(loggerCategory, err);\n Logger.logError(loggerCategory, `Failed loading exports for iModel ${args.iModelId}`);\n break;\n }\n\n const foundExports = result.exports.filter((x) => x.request.exportType === \"IMODEL\" && (args.includeIncomplete || x.status === \"Complete\"));\n for (const foundExport of foundExports)\n yield foundExport;\n\n url = result._links.next?.href;\n }\n}\n\n/** Arguments supplied to [[obtainMeshExportTilesetUrl]].\n * @beta\n */\nexport interface ObtainMeshExportTilesetUrlArgs {\n /** The iModel for which to obtain a tileset URl. */\n iModel: IModelConnection;\n /** The token used to access the mesh export service. */\n accessToken: AccessToken;\n /** Chiefly used in testing environments. */\n urlPrefix?: string;\n /** If true, only exports produced for `iModel`'s specific changeset will be considered; otherwise, if no exports are found for the changeset,\n * the most recent export for any changeset will be used.\n */\n requireExactChangeset?: boolean;\n}\n\n/** Obtains a URL pointing to a tileset appropriate for visualizing a specific iModel.\n * [[queryCompletedMeshExports]] is used to obtain a list of available exports. By default, the list is sorted from most to least recently-exported.\n * The first export matching the iModel's changeset is selected; or, if no such export exists, the first export in the list is selected.\n * @returns A URL from which the tileset can be loaded, or `undefined` if no appropriate URL could be obtained.\n * @beta\n */\nexport async function obtainMeshExportTilesetUrl(args: ObtainMeshExportTilesetUrlArgs): Promise<URL | undefined> {\n if (!args.iModel.iModelId) {\n Logger.logInfo(loggerCategory, \"Cannot obtain exports for an iModel with no iModelId\");\n return undefined;\n }\n\n const queryArgs: QueryMeshExportsArgs = {\n accessToken: args.accessToken,\n iModelId: args.iModel.iModelId,\n changesetId: args.iModel.changeset.id,\n urlPrefix: args.urlPrefix,\n };\n\n let selectedExport;\n for await (const exp of queryMeshExports(queryArgs)) {\n selectedExport = exp;\n break;\n }\n\n if (!selectedExport && !args.requireExactChangeset) {\n queryArgs.changesetId = undefined;\n for await (const exp of queryMeshExports(queryArgs)) {\n selectedExport = exp;\n Logger.logInfo(loggerCategory, `No exports for iModel ${args.iModel.iModelId} for changeset ${args.iModel.changeset.id}; falling back to most recent`);\n break;\n }\n }\n\n if (!selectedExport) {\n Logger.logInfo(loggerCategory, `No exports available for iModel ${args.iModel.iModelId}`);\n return undefined;\n }\n\n const url = new URL(selectedExport._links.mesh.href);\n url.pathname = `${url.pathname}/tileset.json`;\n return url;\n}\n\n/** Options supplied to [[initializeFrontendTiles]].\n * @beta\n */\nexport interface FrontendTilesOptions {\n /** Provide the base URL for the pre-published tileset for a given iModel.\n * If omitted, [[obtainMeshExportTilesetUrl]] will be invoked with default arguments, using the access token provided by [[IModelApp]].\n */\n computeSpatialTilesetBaseUrl?: ComputeSpatialTilesetBaseUrl;\n /** The maximum number of levels in the tile tree to skip loading if they do not provide the desired level of detail for the current view.\n * Default: 4.\n * Reducing this value will load more intermediate tiles, which causes more gradual refinement: low-resolution tiles will display quickly, followed more gradually by\n * successively higher-resolution ones.\n * Increasing the value jumps more directly to tiles of the exact level of detail desired, which may load more, smaller tiles up-front, leaving some areas of the view\n * vacant for longer; and when zooming out some newly-exposed areas of the view may remain vacant for longer because no lower-resolution tiles are initially available to\n * fill them. However, tiles close to the viewer (and therefore likely of most interest to them) will refine to an appropriate level of detail more quickly.\n */\n maxLevelsToSkip?: number;\n /** Specifies whether to permit the user to enable visible edges or wireframe mode for batched tiles.\n * The currently-deployed mesh export service does not produce edges, so this currently defaults to `false` to avoid user confusion.\n * Set it to `true` if you are loading tiles created with a version of the exporter that does produce edges.\n * ###TODO delete this option once we deploy an edge-producing version of the exporter to production.\n * @internal\n */\n enableEdges?: boolean;\n}\n\n/** Global configuration initialized by [[initializeFrontendTiles]].\n * @internal\n */\nexport const frontendTilesOptions = {\n maxLevelsToSkip: 4,\n enableEdges: false,\n};\n\n/** Initialize the frontend-tiles package to obtain tiles for spatial views.\n * @beta\n */\nexport function initializeFrontendTiles(options: FrontendTilesOptions): void {\n if (undefined !== options.maxLevelsToSkip && options.maxLevelsToSkip >= 0)\n frontendTilesOptions.maxLevelsToSkip = options.maxLevelsToSkip;\n\n if (options.enableEdges)\n frontendTilesOptions.enableEdges = true;\n\n const computeUrl = options.computeSpatialTilesetBaseUrl ?? (\n async (iModel: IModelConnection) => obtainMeshExportTilesetUrl({ iModel, accessToken: await IModelApp.getAccessToken() })\n );\n\n SpatialTileTreeReferences.create = (view: SpatialViewState) => createBatchedSpatialTileTreeReferences(view, computeUrl);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LoggerCategory.js","sourceRoot":"","sources":["../../src/LoggerCategory.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,gBAAgB;AACH,QAAA,cAAc,GAAG,gBAAgB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\
|
|
1
|
+
{"version":3,"file":"LoggerCategory.js","sourceRoot":"","sources":["../../src/LoggerCategory.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,gBAAgB;AACH,QAAA,cAAc,GAAG,gBAAgB,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\n/** @internal */\nexport const loggerCategory = \"frontend-tiles\";\n\n"]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Id64Set, Id64String } from "@itwin/core-bentley";
|
|
2
|
+
import { PlanProjectionSettings, RenderSchedule, ViewFlagOverrides } from "@itwin/core-common";
|
|
3
|
+
import { ModelDisplayTransform, RenderClipVolume } from "@itwin/core-frontend";
|
|
4
|
+
import { ModelGroupDisplayTransforms } from "./ModelGroupDisplayTransforms";
|
|
5
|
+
/** Plan projection settings relevant to a [[ModelGroupInfo]].
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export interface PlanProjectionInfo {
|
|
9
|
+
/** Z elevation, from [PlanProjectionSettings.elevation]($common) if specified, else the default elevation of the model (computed from model extents). */
|
|
10
|
+
elevation: number;
|
|
11
|
+
/** Transparency in [0..1] with 0 being fully opaque. */
|
|
12
|
+
transparency: number;
|
|
13
|
+
/** If true, the graphics are drawn as overlays with no depth test. */
|
|
14
|
+
overlay: boolean;
|
|
15
|
+
}
|
|
16
|
+
/** Display settings to be applied to a group of models.
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
export interface ModelGroupInfo {
|
|
20
|
+
displayTransform?: ModelDisplayTransform;
|
|
21
|
+
clip?: RenderClipVolume;
|
|
22
|
+
planProjection?: PlanProjectionInfo;
|
|
23
|
+
timeline?: RenderSchedule.ModelTimeline;
|
|
24
|
+
viewFlags: ViewFlagOverrides;
|
|
25
|
+
}
|
|
26
|
+
/** Represents a group of models and the display settings to be applied to them.
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
29
|
+
export interface ModelGroup extends ModelGroupInfo {
|
|
30
|
+
/** The set of models belonging to this group. */
|
|
31
|
+
modelIds: Id64Set;
|
|
32
|
+
}
|
|
33
|
+
/** Context supplied to [[groupModels]].
|
|
34
|
+
* @internal
|
|
35
|
+
*/
|
|
36
|
+
export interface ModelGroupingContext {
|
|
37
|
+
modelGroupDisplayTransforms: ModelGroupDisplayTransforms;
|
|
38
|
+
getModelClip(modelId: Id64String): RenderClipVolume | undefined;
|
|
39
|
+
getPlanProjectionSettings(modelId: Id64String): PlanProjectionSettings | undefined;
|
|
40
|
+
getModelTimeline(modelId: Id64String): RenderSchedule.ModelTimeline | undefined;
|
|
41
|
+
getDefaultElevation(modelId: Id64String): number;
|
|
42
|
+
getViewFlagOverrides(modelId: Id64String): ViewFlagOverrides | undefined;
|
|
43
|
+
}
|
|
44
|
+
/** Group the supplied `modelIds` such that all models that are to be drawn with equivalent display settings are grouped together.
|
|
45
|
+
* @internal
|
|
46
|
+
*/
|
|
47
|
+
export declare function groupModels(context: ModelGroupingContext, modelIds: Id64Set): ModelGroup[];
|
|
48
|
+
//# sourceMappingURL=ModelGroup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModelGroup.d.ts","sourceRoot":"","sources":["../../src/ModelGroup.ts"],"names":[],"mappings":"AAKA,OAAO,EAAU,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC/F,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAE5E;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,yJAAyJ;IACzJ,SAAS,EAAE,MAAM,CAAC;IAClB,wDAAwD;IACxD,YAAY,EAAE,MAAM,CAAC;IACrB,sEAAsE;IACtE,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,gBAAgB,CAAC,EAAE,qBAAqB,CAAC;IACzC,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACxB,cAAc,CAAC,EAAE,kBAAkB,CAAC;IACpC,QAAQ,CAAC,EAAE,cAAc,CAAC,aAAa,CAAC;IACxC,SAAS,EAAE,iBAAiB,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,UAAW,SAAQ,cAAc;IAChD,iDAAiD;IACjD,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,2BAA2B,EAAE,2BAA2B,CAAC;IACzD,YAAY,CAAC,OAAO,EAAE,UAAU,GAAG,gBAAgB,GAAG,SAAS,CAAC;IAChE,yBAAyB,CAAC,OAAO,EAAE,UAAU,GAAG,sBAAsB,GAAG,SAAS,CAAC;IACnF,gBAAgB,CAAC,OAAO,EAAE,UAAU,GAAG,cAAc,CAAC,aAAa,GAAG,SAAS,CAAC;IAChF,mBAAmB,CAAC,OAAO,EAAE,UAAU,GAAG,MAAM,CAAC;IACjD,oBAAoB,CAAC,OAAO,EAAE,UAAU,GAAG,iBAAiB,GAAG,SAAS,CAAC;CAC1E;AAgFD;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,oBAAoB,EAAE,QAAQ,EAAE,OAAO,GAAG,UAAU,EAAE,CAa1F"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.groupModels = void 0;
|
|
8
|
+
const core_bentley_1 = require("@itwin/core-bentley");
|
|
9
|
+
function createPlanProjectionInfo(modelId, context) {
|
|
10
|
+
const settings = context.getPlanProjectionSettings(modelId);
|
|
11
|
+
if (!settings)
|
|
12
|
+
return undefined;
|
|
13
|
+
return {
|
|
14
|
+
elevation: settings.elevation ?? context.getDefaultElevation(modelId),
|
|
15
|
+
transparency: settings.transparency ?? 0,
|
|
16
|
+
overlay: settings.overlay,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function equalPlanProjections(a, b) {
|
|
20
|
+
return a.elevation === b.elevation && a.overlay === b.overlay && a.transparency === b.transparency;
|
|
21
|
+
}
|
|
22
|
+
function createModelGroupInfo(context, modelId) {
|
|
23
|
+
const planProjection = createPlanProjectionInfo(modelId, context);
|
|
24
|
+
const viewFlags = { ...context.getViewFlagOverrides(modelId) };
|
|
25
|
+
if (planProjection) {
|
|
26
|
+
// Always enable improved z-fighting mitigation for plan projections (they're planar models).
|
|
27
|
+
viewFlags.forceSurfaceDiscard = true;
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
displayTransform: context.modelGroupDisplayTransforms.getDisplayTransform(modelId),
|
|
31
|
+
clip: context.getModelClip(modelId),
|
|
32
|
+
planProjection,
|
|
33
|
+
viewFlags,
|
|
34
|
+
timeline: context.getModelTimeline(modelId),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function equalViewFlags(a, b) {
|
|
38
|
+
const lhs = Object.keys(a);
|
|
39
|
+
const rhs = Object.keys(b);
|
|
40
|
+
if (lhs.length !== rhs.length) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
for (const propName of lhs) {
|
|
44
|
+
const key = propName;
|
|
45
|
+
if (a[key] !== b[key])
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
function equalModelGroupInfo(a, b) {
|
|
51
|
+
// If a model has a timeline it cannot be grouped
|
|
52
|
+
if (a.timeline !== b.timeline)
|
|
53
|
+
return false;
|
|
54
|
+
// Display transforms are obtained from ModelGroupDisplayTransforms - they are guaranteed to be the same object if they are equivalent.
|
|
55
|
+
if (a.displayTransform !== b.displayTransform)
|
|
56
|
+
return false;
|
|
57
|
+
if (a.clip || b.clip) {
|
|
58
|
+
// Note: ClipVector lacks an `isAlmostEqual` method.
|
|
59
|
+
// For two models belonging to the same clip group, we should have the same exact object.
|
|
60
|
+
// But we won't currently detect two different objects that represent effectively identical clips.
|
|
61
|
+
if (!a.clip || !b.clip || a.clip.clipVector !== b.clip.clipVector)
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
if (a.planProjection || b.planProjection) {
|
|
65
|
+
if (!a.planProjection || !b.planProjection || !equalPlanProjections(a.planProjection, b.planProjection)) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (!equalViewFlags(a.viewFlags, b.viewFlags))
|
|
70
|
+
return false;
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
/** Group the supplied `modelIds` such that all models that are to be drawn with equivalent display settings are grouped together.
|
|
74
|
+
* @internal
|
|
75
|
+
*/
|
|
76
|
+
function groupModels(context, modelIds) {
|
|
77
|
+
const groups = [];
|
|
78
|
+
for (const modelId of modelIds) {
|
|
79
|
+
const info = createModelGroupInfo(context, modelId);
|
|
80
|
+
let group = groups.find((x) => equalModelGroupInfo(x, info));
|
|
81
|
+
if (!group)
|
|
82
|
+
groups.push(group = { ...info, modelIds: new Set() });
|
|
83
|
+
(0, core_bentley_1.assert)(!group.modelIds.has(modelId));
|
|
84
|
+
group.modelIds.add(modelId);
|
|
85
|
+
}
|
|
86
|
+
return groups;
|
|
87
|
+
}
|
|
88
|
+
exports.groupModels = groupModels;
|
|
89
|
+
//# sourceMappingURL=ModelGroup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModelGroup.js","sourceRoot":"","sources":["../../src/ModelGroup.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,sDAAkE;AAgDlE,SAAS,wBAAwB,CAAC,OAAmB,EAAE,OAA6B;IAClF,MAAM,QAAQ,GAAG,OAAO,CAAC,yBAAyB,CAAC,OAAO,CAAC,CAAC;IAC5D,IAAI,CAAC,QAAQ;QACX,OAAO,SAAS,CAAC;IAEnB,OAAO;QACL,SAAS,EAAE,QAAQ,CAAC,SAAS,IAAI,OAAO,CAAC,mBAAmB,CAAC,OAAO,CAAC;QACrE,YAAY,EAAE,QAAQ,CAAC,YAAY,IAAI,CAAC;QACxC,OAAO,EAAE,QAAQ,CAAC,OAAO;KAC1B,CAAC;AACJ,CAAC;AAED,SAAS,oBAAoB,CAAC,CAAqB,EAAE,CAAqB;IACxE,OAAO,CAAC,CAAC,SAAS,KAAK,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,OAAO,IAAI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EAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;QACrC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;KAC7B;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAbD,kCAaC","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\nimport { assert, Id64Set, Id64String } from \"@itwin/core-bentley\";\nimport { PlanProjectionSettings, RenderSchedule, ViewFlagOverrides } from \"@itwin/core-common\";\nimport { ModelDisplayTransform, RenderClipVolume } from \"@itwin/core-frontend\";\nimport { ModelGroupDisplayTransforms } from \"./ModelGroupDisplayTransforms\";\n\n/** Plan projection settings relevant to a [[ModelGroupInfo]].\n * @internal\n */\nexport interface PlanProjectionInfo {\n /** Z elevation, from [PlanProjectionSettings.elevation]($common) if specified, else the default elevation of the model (computed from model extents). */\n elevation: number;\n /** Transparency in [0..1] with 0 being fully opaque. */\n transparency: number;\n /** If true, the graphics are drawn as overlays with no depth test. */\n overlay: boolean;\n}\n\n/** Display settings to be applied to a group of models.\n * @internal\n */\nexport interface ModelGroupInfo {\n displayTransform?: ModelDisplayTransform;\n clip?: RenderClipVolume;\n planProjection?: PlanProjectionInfo;\n timeline?: RenderSchedule.ModelTimeline;\n viewFlags: ViewFlagOverrides;\n}\n\n/** Represents a group of models and the display settings to be applied to them.\n * @internal\n */\nexport interface ModelGroup extends ModelGroupInfo {\n /** The set of models belonging to this group. */\n modelIds: Id64Set;\n}\n\n/** Context supplied to [[groupModels]].\n * @internal\n */\nexport interface ModelGroupingContext {\n modelGroupDisplayTransforms: ModelGroupDisplayTransforms;\n getModelClip(modelId: Id64String): RenderClipVolume | undefined;\n getPlanProjectionSettings(modelId: Id64String): PlanProjectionSettings | undefined;\n getModelTimeline(modelId: Id64String): RenderSchedule.ModelTimeline | undefined;\n getDefaultElevation(modelId: Id64String): number;\n getViewFlagOverrides(modelId: Id64String): ViewFlagOverrides | undefined;\n}\n\nfunction createPlanProjectionInfo(modelId: Id64String, context: ModelGroupingContext): PlanProjectionInfo | undefined {\n const settings = context.getPlanProjectionSettings(modelId);\n if (!settings)\n return undefined;\n\n return {\n elevation: settings.elevation ?? context.getDefaultElevation(modelId),\n transparency: settings.transparency ?? 0,\n overlay: settings.overlay,\n };\n}\n\nfunction equalPlanProjections(a: PlanProjectionInfo, b: PlanProjectionInfo): boolean {\n return a.elevation === b.elevation && a.overlay === b.overlay && a.transparency === b.transparency;\n}\n\nfunction createModelGroupInfo(context: ModelGroupingContext, modelId: Id64String): ModelGroupInfo {\n const planProjection = createPlanProjectionInfo(modelId, context);\n const viewFlags = { ...context.getViewFlagOverrides(modelId) };\n if (planProjection) {\n // Always enable improved z-fighting mitigation for plan projections (they're planar models).\n viewFlags.forceSurfaceDiscard = true;\n }\n\n return {\n displayTransform: context.modelGroupDisplayTransforms.getDisplayTransform(modelId),\n clip: context.getModelClip(modelId),\n planProjection,\n viewFlags,\n timeline: context.getModelTimeline(modelId),\n };\n}\n\nfunction equalViewFlags(a: ViewFlagOverrides, b: ViewFlagOverrides): boolean {\n const lhs = Object.keys(a);\n const rhs = Object.keys(b);\n if (lhs.length !== rhs.length) {\n return false;\n }\n\n for (const propName of lhs) {\n const key = propName as keyof ViewFlagOverrides;\n if (a[key] !== b[key])\n return false;\n }\n\n return true;\n}\n\nfunction equalModelGroupInfo(a: ModelGroupInfo, b: ModelGroupInfo): boolean {\n // If a model has a timeline it cannot be grouped\n if (a.timeline !== b.timeline)\n return false;\n\n // Display transforms are obtained from ModelGroupDisplayTransforms - they are guaranteed to be the same object if they are equivalent.\n if (a.displayTransform !== b.displayTransform)\n return false;\n\n if (a.clip || b.clip) {\n // Note: ClipVector lacks an `isAlmostEqual` method.\n // For two models belonging to the same clip group, we should have the same exact object.\n // But we won't currently detect two different objects that represent effectively identical clips.\n if (!a.clip || !b.clip || a.clip.clipVector !== b.clip.clipVector)\n return false;\n }\n\n if (a.planProjection || b.planProjection) {\n if (!a.planProjection || !b.planProjection || !equalPlanProjections(a.planProjection, b.planProjection)) {\n return false;\n }\n }\n\n if (!equalViewFlags(a.viewFlags, b.viewFlags))\n return false;\n\n return true;\n}\n\n/** Group the supplied `modelIds` such that all models that are to be drawn with equivalent display settings are grouped together.\n * @internal\n */\nexport function groupModels(context: ModelGroupingContext, modelIds: Id64Set): ModelGroup[] {\n const groups: ModelGroup[] = [];\n for (const modelId of modelIds) {\n const info = createModelGroupInfo(context, modelId);\n let group = groups.find((x) => equalModelGroupInfo(x, info));\n if (!group)\n groups.push(group = { ...info, modelIds: new Set<string>() });\n\n assert(!group.modelIds.has(modelId));\n group.modelIds.add(modelId);\n }\n\n return groups;\n}\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Id64Set, Id64String } from "@itwin/core-bentley";
|
|
2
|
+
import { ModelDisplayTransform, ModelDisplayTransformProvider } from "@itwin/core-frontend";
|
|
3
|
+
/** Manages the display transforms to be applied to all of the models in a BatchedTileTree, enabling all models that share an equivalent transform
|
|
4
|
+
* to be drawn together.
|
|
5
|
+
* Call `update` whenever the transforms may have changed (e.g., after the viewport's scene is invalidated).
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export declare class ModelGroupDisplayTransforms {
|
|
9
|
+
private _state;
|
|
10
|
+
private readonly _modelIds;
|
|
11
|
+
/** Create a new set of groups for the specified `modelIds`. If `provider` is supplied, the grouping will be applied to those models immediately. */
|
|
12
|
+
constructor(modelIds: Id64Set, provider?: ModelDisplayTransformProvider);
|
|
13
|
+
/** A string uniquely identifying the current grouping. */
|
|
14
|
+
get guid(): string;
|
|
15
|
+
/** Get the display transform for the specified model.
|
|
16
|
+
* @note This method is guaranteed to return the same object for all models in the same group, at least between calls to `update`.
|
|
17
|
+
*/
|
|
18
|
+
getDisplayTransform(modelId: Id64String): ModelDisplayTransform | undefined;
|
|
19
|
+
update(provider: ModelDisplayTransformProvider | undefined): boolean;
|
|
20
|
+
private computeState;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=ModelGroupDisplayTransforms.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModelGroupDisplayTransforms.d.ts","sourceRoot":"","sources":["../../src/ModelGroupDisplayTransforms.ts"],"names":[],"mappings":"AAKA,OAAO,EAAqB,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,6BAA6B,EAAE,MAAM,sBAAsB,CAAC;AAqB5F;;;;GAIG;AACH,qBAAa,2BAA2B;IACtC,OAAO,CAAC,MAAM,CAAgD;IAC9D,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAU;IAEpC,oJAAoJ;gBACjI,QAAQ,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,6BAA6B;IAM9E,0DAA0D;IAC1D,IAAW,IAAI,IAAI,MAAM,CAA6B;IAEtD;;OAEG;IACI,mBAAmB,CAAC,OAAO,EAAE,UAAU,GAAG,qBAAqB,GAAG,SAAS;IAM3E,MAAM,CAAC,QAAQ,EAAE,6BAA6B,GAAG,SAAS,GAAG,OAAO;IAM3E,OAAO,CAAC,YAAY;CAsBrB"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.ModelGroupDisplayTransforms = void 0;
|
|
8
|
+
const core_bentley_1 = require("@itwin/core-bentley");
|
|
9
|
+
function equalDisplayTransforms(a, b) {
|
|
10
|
+
return !!a.premultiply === !!b.premultiply && a.transform.isAlmostEqual(b.transform);
|
|
11
|
+
}
|
|
12
|
+
/** Optimization for the common case in which no display transforms are to be applied. */
|
|
13
|
+
const emptyState = { transforms: [], guid: "" };
|
|
14
|
+
/** Manages the display transforms to be applied to all of the models in a BatchedTileTree, enabling all models that share an equivalent transform
|
|
15
|
+
* to be drawn together.
|
|
16
|
+
* Call `update` whenever the transforms may have changed (e.g., after the viewport's scene is invalidated).
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
class ModelGroupDisplayTransforms {
|
|
20
|
+
/** Create a new set of groups for the specified `modelIds`. If `provider` is supplied, the grouping will be applied to those models immediately. */
|
|
21
|
+
constructor(modelIds, provider) {
|
|
22
|
+
this._state = emptyState;
|
|
23
|
+
this._modelIds = modelIds;
|
|
24
|
+
if (provider)
|
|
25
|
+
this.update(provider);
|
|
26
|
+
}
|
|
27
|
+
/** A string uniquely identifying the current grouping. */
|
|
28
|
+
get guid() { return this._state.guid; }
|
|
29
|
+
/** Get the display transform for the specified model.
|
|
30
|
+
* @note This method is guaranteed to return the same object for all models in the same group, at least between calls to `update`.
|
|
31
|
+
*/
|
|
32
|
+
getDisplayTransform(modelId) {
|
|
33
|
+
return this._state.transforms.find((x) => x.modelIds.has(modelId))?.transform;
|
|
34
|
+
}
|
|
35
|
+
// Update the display transforms and the model groupings based on the transforms supplied by `provider`.
|
|
36
|
+
// Return `true` if the groupings changed as a result.
|
|
37
|
+
update(provider) {
|
|
38
|
+
const prevState = this._state;
|
|
39
|
+
this._state = this.computeState(provider);
|
|
40
|
+
return this._state.guid !== prevState.guid;
|
|
41
|
+
}
|
|
42
|
+
computeState(provider) {
|
|
43
|
+
if (!provider)
|
|
44
|
+
return emptyState;
|
|
45
|
+
const transforms = [];
|
|
46
|
+
for (const modelId of this._modelIds) {
|
|
47
|
+
const transform = provider.getModelDisplayTransform(modelId);
|
|
48
|
+
if (transform) {
|
|
49
|
+
let entry = transforms.find((x) => equalDisplayTransforms(transform, x.transform));
|
|
50
|
+
if (!entry)
|
|
51
|
+
transforms.push(entry = { transform, modelIds: new Set() });
|
|
52
|
+
entry.modelIds.add(modelId);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (transforms.length === 0)
|
|
56
|
+
return emptyState;
|
|
57
|
+
const guid = transforms.map((x) => core_bentley_1.CompressedId64Set.compressSet(x.modelIds)).sort().join("_");
|
|
58
|
+
return { transforms, guid };
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.ModelGroupDisplayTransforms = ModelGroupDisplayTransforms;
|
|
62
|
+
//# sourceMappingURL=ModelGroupDisplayTransforms.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModelGroupDisplayTransforms.js","sourceRoot":"","sources":["../../src/ModelGroupDisplayTransforms.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,sDAA6E;AAG7E,SAAS,sBAAsB,CAAC,CAAwB,EAAE,CAAwB;IAChF,OAAO,CAAC,CAAC,CAAC,CAAC,WAAW,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,IAAI,CAAC,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;AACvF,CAAC;AAcD,yFAAyF;AACzF,MAAM,UAAU,GAAqC,EAAE,UAAU,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;AAElF;;;;GAIG;AACH,MAAa,2BAA2B;IAItC,oJAAoJ;IACpJ,YAAmB,QAAiB,EAAE,QAAwC;QAJtE,WAAM,GAAqC,UAAU,CAAC;QAK5D,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,QAAQ;YACV,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC1B,CAAC;IAED,0DAA0D;IAC1D,IAAW,IAAI,KAAa,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;IAEtD;;OAEG;IACI,mBAAmB,CAAC,OAAm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,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC/F,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;IAC9B,CAAC;CACF;AAnDD,kEAmDC","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\nimport { CompressedId64Set, Id64Set, Id64String } from \"@itwin/core-bentley\";\nimport { ModelDisplayTransform, ModelDisplayTransformProvider } from \"@itwin/core-frontend\";\n\nfunction equalDisplayTransforms(a: ModelDisplayTransform, b: ModelDisplayTransform): boolean {\n return !!a.premultiply === !!b.premultiply && a.transform.isAlmostEqual(b.transform);\n}\n\n/** A display transform to be applied to a set of models. */\ninterface ModelGroupDisplayTransform {\n modelIds: Id64Set;\n transform: ModelDisplayTransform;\n}\n\n/** A collection of model Ids grouped according to the unique transforms to be applied to each group. */\ninterface ModelGroupDisplayTransformsState {\n readonly transforms: ReadonlyArray<ModelGroupDisplayTransform>;\n readonly guid: string;\n}\n\n/** Optimization for the common case in which no display transforms are to be applied. */\nconst emptyState: ModelGroupDisplayTransformsState = { transforms: [], guid: \"\" };\n\n/** Manages the display transforms to be applied to all of the models in a BatchedTileTree, enabling all models that share an equivalent transform\n * to be drawn together.\n * Call `update` whenever the transforms may have changed (e.g., after the viewport's scene is invalidated).\n * @internal\n */\nexport class ModelGroupDisplayTransforms {\n private _state: ModelGroupDisplayTransformsState = emptyState;\n private readonly _modelIds: Id64Set;\n\n /** Create a new set of groups for the specified `modelIds`. If `provider` is supplied, the grouping will be applied to those models immediately. */\n public constructor(modelIds: Id64Set, provider?: ModelDisplayTransformProvider) {\n this._modelIds = modelIds;\n if (provider)\n this.update(provider);\n }\n\n /** A string uniquely identifying the current grouping. */\n public get guid(): string { return this._state.guid; }\n\n /** Get the display transform for the specified model.\n * @note This method is guaranteed to return the same object for all models in the same group, at least between calls to `update`.\n */\n public getDisplayTransform(modelId: Id64String): ModelDisplayTransform | undefined {\n return this._state.transforms.find((x) => x.modelIds.has(modelId))?.transform;\n }\n\n // Update the display transforms and the model groupings based on the transforms supplied by `provider`.\n // Return `true` if the groupings changed as a result.\n public update(provider: ModelDisplayTransformProvider | undefined): boolean {\n const prevState = this._state;\n this._state = this.computeState(provider);\n return this._state.guid !== prevState.guid;\n }\n\n private computeState(provider: ModelDisplayTransformProvider | undefined): ModelGroupDisplayTransformsState {\n if (!provider)\n return emptyState;\n\n const transforms: ModelGroupDisplayTransform[] = [];\n for (const modelId of this._modelIds) {\n const transform = provider.getModelDisplayTransform(modelId);\n if (transform) {\n let entry = transforms.find((x) => equalDisplayTransforms(transform, x.transform));\n if (!entry)\n transforms.push(entry = { transform, modelIds: new Set() });\n\n entry.modelIds.add(modelId);\n }\n }\n\n if (transforms.length === 0)\n return emptyState;\n\n const guid = transforms.map((x) => CompressedId64Set.compressSet(x.modelIds)).sort().join(\"_\");\n return { transforms, guid };\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frontend-tiles.js","sourceRoot":"","sources":["../../src/frontend-tiles.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;;;;;;;;;;;;;;AAE/F,kDAAgC","sourcesContent":["/*---------------------------------------------------------------------------------------------\
|
|
1
|
+
{"version":3,"file":"frontend-tiles.js","sourceRoot":"","sources":["../../src/frontend-tiles.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;;;;;;;;;;;;;;AAE/F,kDAAgC","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\nexport * from \"./FrontendTiles\";\n"]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ModelGroupDisplayTransforms } from "./ModelGroupDisplayTransforms";
|
|
2
|
+
import { ModelGroup, ModelGroupingContext } from "./ModelGroup";
|
|
3
|
+
import { RenderClipVolume, SpatialViewState } from "@itwin/core-frontend";
|
|
4
|
+
import { Id64Set, Id64String } from "@itwin/core-bentley";
|
|
5
|
+
import { PlanProjectionSettings, RenderSchedule, ViewFlagOverrides } from "@itwin/core-common";
|
|
6
|
+
import { ModelMetadata } from "./BatchedTilesetReader";
|
|
7
|
+
/** Groups the set of spatial models included in a [[BatchedSpatialTileTreeReferences]] based on their display settings.
|
|
8
|
+
* This ensures that models are displayed correctly, while using batching to reduce the number of draw calls to a minimum.
|
|
9
|
+
* The groupings are re-evaluated only when there's a possibility that they may have changed (e.g., if the view's plan projection settings or model clip groups were modified).
|
|
10
|
+
* Unfortunately, there is currently no way to know when the transforms supplied by a [ModelDisplayTransformProvider]($frontend) may have changed, so
|
|
11
|
+
* display transforms are re-evaluated every time the Viewport's scene is invalidated. This may (but usually won't) affect the groupings.
|
|
12
|
+
* The BatchedSpatialTileTreeReferences object allocates new [[BatchedTileTreeReferences]] whenever the groupings change.
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
export declare class BatchedModelGroups implements ModelGroupingContext {
|
|
16
|
+
private readonly _view;
|
|
17
|
+
private readonly _includedModelIds;
|
|
18
|
+
private readonly _metadata;
|
|
19
|
+
private _script?;
|
|
20
|
+
private _transformsValid;
|
|
21
|
+
private _groupsValid;
|
|
22
|
+
private _scriptValid;
|
|
23
|
+
/** A stringified representation of the current groupings, of the format:
|
|
24
|
+
* group1_group2_group3_..._groupN
|
|
25
|
+
* where each group is a [CompressedId64Set]($bentley).
|
|
26
|
+
* @see [[BatchedTileTreeId.modelGroups]].
|
|
27
|
+
*/
|
|
28
|
+
guid: string;
|
|
29
|
+
groups: ModelGroup[];
|
|
30
|
+
modelGroupDisplayTransforms: ModelGroupDisplayTransforms;
|
|
31
|
+
constructor(view: SpatialViewState, script: RenderSchedule.Script | undefined, includedModelIds: Id64Set, metadata: Map<Id64String, ModelMetadata>);
|
|
32
|
+
setScript(script: RenderSchedule.Script | undefined): void;
|
|
33
|
+
invalidateTransforms(): void;
|
|
34
|
+
private listenForDisplayStyleEvents;
|
|
35
|
+
getModelClip(modelId: Id64String): RenderClipVolume | undefined;
|
|
36
|
+
getPlanProjectionSettings(modelId: Id64String): PlanProjectionSettings | undefined;
|
|
37
|
+
getModelTimeline(modelId: Id64String): RenderSchedule.ModelTimeline | undefined;
|
|
38
|
+
getViewFlagOverrides(modelId: Id64String): ViewFlagOverrides | undefined;
|
|
39
|
+
getDefaultElevation(modelId: Id64String): number;
|
|
40
|
+
/** Re-evaluate transforms and groupings if they may be out of date.
|
|
41
|
+
* @returns true if the groupings changed as a result.
|
|
42
|
+
*/
|
|
43
|
+
update(): boolean;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=BatchedModelGroups.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BatchedModelGroups.d.ts","sourceRoot":"","sources":["../../src/BatchedModelGroups.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAe,UAAU,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAA6B,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACrF,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC/F,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD;;;;;;;GAOG;AACH,qBAAa,kBAAmB,YAAW,oBAAoB;IAC7D,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAmB;IACzC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAU;IAC5C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAiC;IAC3D,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