@itwin/frontend-tiles 3.7.3 → 3.7.5
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/.rush/temp/8767d8e57eacc648f9e35b3b97ca2ba97f018069.log +10 -0
- package/.rush/temp/operation/build_ci/state.json +1 -1
- package/CHANGELOG.json +18 -0
- package/CHANGELOG.md +13 -1
- package/lib/cjs/BatchedTile.d.ts +3 -2
- package/lib/cjs/BatchedTile.d.ts.map +1 -1
- package/lib/cjs/BatchedTile.js +23 -106
- package/lib/cjs/BatchedTile.js.map +1 -1
- package/lib/cjs/BatchedTileTree.js +3 -3
- package/lib/cjs/BatchedTileTree.js.map +1 -1
- package/lib/cjs/tsconfig.tsbuildinfo +1 -1
- package/lib/esm/BatchedTile.d.ts +3 -2
- package/lib/esm/BatchedTile.d.ts.map +1 -1
- package/lib/esm/BatchedTile.js +24 -107
- package/lib/esm/BatchedTile.js.map +1 -1
- package/lib/esm/BatchedTileTree.js +3 -3
- package/lib/esm/BatchedTileTree.js.map +1 -1
- package/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/package.json +11 -11
- package/src/BatchedTile.ts +28 -114
- package/src/BatchedTileTree.ts +3 -3
- package/.rush/temp/eded9a4b6d9857cb78afd6aaf9c145be5cb5d964.log +0 -10
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Start time: Thu May 04 2023 15:48:22 GMT-0400 (Eastern Daylight Time)
|
|
2
|
+
Invoking "C:\WINDOWS\system32\tar.exe -x -m -f D:\vsts_a\4\s\common\temp\build-cache\8767d8e57eacc648f9e35b3b97ca2ba97f018069"
|
|
3
|
+
|
|
4
|
+
======= BEGIN PROCESS INPUT ======
|
|
5
|
+
|
|
6
|
+
======== END PROCESS INPUT =======
|
|
7
|
+
======= BEGIN PROCESS OUTPUT =======
|
|
8
|
+
======== END PROCESS OUTPUT ========
|
|
9
|
+
|
|
10
|
+
Exited with code "0"
|
package/CHANGELOG.json
CHANGED
|
@@ -1,6 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/frontend-tiles",
|
|
3
3
|
"entries": [
|
|
4
|
+
{
|
|
5
|
+
"version": "3.7.5",
|
|
6
|
+
"tag": "@itwin/frontend-tiles_v3.7.5",
|
|
7
|
+
"date": "Thu, 04 May 2023 19:43:18 GMT",
|
|
8
|
+
"comments": {}
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"version": "3.7.4",
|
|
12
|
+
"tag": "@itwin/frontend-tiles_v3.7.4",
|
|
13
|
+
"date": "Tue, 25 Apr 2023 17:50:35 GMT",
|
|
14
|
+
"comments": {
|
|
15
|
+
"none": [
|
|
16
|
+
{
|
|
17
|
+
"comment": "Improve tile content disposal under memory pressure."
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
}
|
|
21
|
+
},
|
|
4
22
|
{
|
|
5
23
|
"version": "3.7.3",
|
|
6
24
|
"tag": "@itwin/frontend-tiles_v3.7.3",
|
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
# Change Log - @itwin/frontend-tiles
|
|
2
2
|
|
|
3
|
-
This log was last generated on Thu,
|
|
3
|
+
This log was last generated on Thu, 04 May 2023 19:43:18 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 3.7.5
|
|
6
|
+
Thu, 04 May 2023 19:43:18 GMT
|
|
7
|
+
|
|
8
|
+
_Version update only_
|
|
9
|
+
|
|
10
|
+
## 3.7.4
|
|
11
|
+
Tue, 25 Apr 2023 17:50:35 GMT
|
|
12
|
+
|
|
13
|
+
### Updates
|
|
14
|
+
|
|
15
|
+
- Improve tile content disposal under memory pressure.
|
|
4
16
|
|
|
5
17
|
## 3.7.3
|
|
6
18
|
Thu, 20 Apr 2023 13:19:29 GMT
|
package/lib/cjs/BatchedTile.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BeTimePoint } from "@itwin/core-bentley";
|
|
2
2
|
import { Tileset3dSchema } from "@itwin/core-common";
|
|
3
|
-
import { GraphicBuilder, RenderSystem,
|
|
3
|
+
import { GraphicBuilder, RenderSystem, Tile, TileBoundingBoxes, TileContent, TileDrawArgs, TileParams, TileRequest, TileRequestChannel, TileUser, Viewport } from "@itwin/core-frontend";
|
|
4
4
|
import { BatchedTileTree } from "./BatchedTileTree";
|
|
5
5
|
/** @internal */
|
|
6
6
|
export interface BatchedTileParams extends TileParams {
|
|
@@ -9,11 +9,12 @@ export interface BatchedTileParams extends TileParams {
|
|
|
9
9
|
/** @internal */
|
|
10
10
|
export declare class BatchedTile extends Tile {
|
|
11
11
|
private readonly _childrenProps?;
|
|
12
|
+
private readonly _unskippable;
|
|
12
13
|
get batchedTree(): BatchedTileTree;
|
|
13
14
|
constructor(params: BatchedTileParams, tree: BatchedTileTree);
|
|
14
15
|
private get _batchedChildren();
|
|
15
16
|
computeLoadPriority(viewports: Iterable<Viewport>, _users: Iterable<TileUser>): number;
|
|
16
|
-
selectTiles(selected: BatchedTile
|
|
17
|
+
selectTiles(selected: Set<BatchedTile>, args: TileDrawArgs, closestDisplayableAncestor: BatchedTile | undefined): void;
|
|
17
18
|
protected _loadChildren(resolve: (children: Tile[] | undefined) => void, reject: (error: Error) => void): void;
|
|
18
19
|
get channel(): TileRequestChannel;
|
|
19
20
|
requestContent(_isCanceled: () => boolean): Promise<TileRequest.Response>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BatchedTile.d.ts","sourceRoot":"","sources":["../../src/BatchedTile.ts"],"names":[],"mappings":"AAKA,OAAO,EAAU,WAAW,EAAsB,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAAY,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EACY,cAAc,EAA4C,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"BatchedTile.d.ts","sourceRoot":"","sources":["../../src/BatchedTile.ts"],"names":[],"mappings":"AAKA,OAAO,EAAU,WAAW,EAAsB,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WAAW,CAAC,IAAI,EAAE,WAAW,CAAC,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,WAAW,CAAC,EAAE,MAAM,OAAO,GAAG,OAAO,CAAC,WAAW,CAAC;cAwCvH,eAAe,CAAC,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,iBAAiB,GAAG,IAAI;IAsBnF,KAAK,CAAC,SAAS,EAAE,WAAW,GAAG,IAAI;CAY3C"}
|
package/lib/cjs/BatchedTile.js
CHANGED
|
@@ -17,6 +17,8 @@ class BatchedTile extends core_frontend_1.Tile {
|
|
|
17
17
|
constructor(params, tree) {
|
|
18
18
|
var _a;
|
|
19
19
|
super(params, tree);
|
|
20
|
+
// The root tile never has content, so it doesn't count toward max levels to skip.
|
|
21
|
+
this._unskippable = 0 === (this.depth % (0, FrontendTiles_1.getMaxLevelsToSkip)());
|
|
20
22
|
if ((_a = params.childrenProps) === null || _a === void 0 ? void 0 : _a.length)
|
|
21
23
|
this._childrenProps = params.childrenProps;
|
|
22
24
|
if (!this.contentId) {
|
|
@@ -35,120 +37,34 @@ class BatchedTile extends core_frontend_1.Tile {
|
|
|
35
37
|
// Prioritize tiles closer to camera and center of attention (zoom point or screen center).
|
|
36
38
|
return core_frontend_1.RealityTileLoader.computeTileLocationPriority(this, viewports, this.tree.iModelTransform);
|
|
37
39
|
}
|
|
38
|
-
selectTiles(selected, args,
|
|
40
|
+
selectTiles(selected, args, closestDisplayableAncestor) {
|
|
39
41
|
const vis = this.computeVisibility(args);
|
|
40
42
|
if (core_frontend_1.TileVisibility.OutsideFrustum === vis)
|
|
41
|
-
return
|
|
42
|
-
if (
|
|
43
|
-
//
|
|
44
|
-
|
|
45
|
-
args.insertMissing(this);
|
|
46
|
-
if (this.hasGraphics) {
|
|
47
|
-
// It can be drawn - select it
|
|
48
|
-
args.markReady(this);
|
|
49
|
-
selected.push(this);
|
|
50
|
-
}
|
|
51
|
-
else if (!this.isReady) {
|
|
52
|
-
// It can't be drawn. Try to draw children in its place; otherwise draw the parent.
|
|
53
|
-
// Do not load/request the children for this purpose.
|
|
54
|
-
const initialSize = selected.length;
|
|
55
|
-
const kids = this._batchedChildren;
|
|
56
|
-
if (undefined === kids)
|
|
57
|
-
return core_frontend_1.SelectParent.Yes;
|
|
58
|
-
// Find any descendant to draw, until we exceed max initial tiles to skip.
|
|
59
|
-
// if (this.depth < this.iModelTree.maxInitialTilesToSkip) {
|
|
60
|
-
// for (const kid of kids) {
|
|
61
|
-
// if (SelectParent.Yes === kid.selectTiles(selected, args, numSkipped)) {
|
|
62
|
-
// selected.length = initialSize;
|
|
63
|
-
// return SelectParent.Yes;
|
|
64
|
-
// }
|
|
65
|
-
// return SelectParent.No;
|
|
66
|
-
// }
|
|
67
|
-
// }
|
|
68
|
-
// If all visible direct children can be drawn, draw them.
|
|
69
|
-
for (const kid of kids) {
|
|
70
|
-
if (core_frontend_1.TileVisibility.OutsideFrustum !== kid.computeVisibility(args)) {
|
|
71
|
-
if (!kid.hasGraphics) {
|
|
72
|
-
selected.length = initialSize;
|
|
73
|
-
return core_frontend_1.SelectParent.Yes;
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
selected.push(kid);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
args.markUsed(this);
|
|
81
|
-
}
|
|
82
|
-
// We're drawing either this tile, or its direct children.
|
|
83
|
-
return core_frontend_1.SelectParent.No;
|
|
84
|
-
}
|
|
85
|
-
// This tile is too coarse to draw. Try to draw something more appropriate.
|
|
86
|
-
// If it is not ready to draw, we may want to skip loading in favor of loading its descendants.
|
|
87
|
-
// If we previously loaded and later unloaded content for this tile to free memory, don't force it to reload its content - proceed to children.
|
|
88
|
-
const maximumLevelsToSkip = (0, FrontendTiles_1.getMaxLevelsToSkip)();
|
|
89
|
-
let canSkipThisTile = (this._hadGraphics && !this.hasGraphics) /* || this.depth < this.iModelTree.maxInitialTilesToSkip */;
|
|
90
|
-
if (canSkipThisTile) {
|
|
91
|
-
numSkipped = 1;
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
canSkipThisTile = this.isReady || this.isParentDisplayable /* || this.depth < this.iModelTree.maxInitialTilesToSkip */;
|
|
95
|
-
if (canSkipThisTile && this.isDisplayable) { // skipping an undisplayable tile doesn't count toward the maximum
|
|
96
|
-
// Some tiles do not sub-divide - they only facet the same geometry to a higher resolution. We can skip directly to the correct resolution.
|
|
97
|
-
const isNotReady = !this.isReady && !this.hasGraphics /* && !this.hasSizeMultiplier */;
|
|
98
|
-
if (isNotReady) {
|
|
99
|
-
if (numSkipped >= maximumLevelsToSkip)
|
|
100
|
-
canSkipThisTile = false;
|
|
101
|
-
else
|
|
102
|
-
numSkipped += 1;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
const childrenLoadStatus = this.loadChildren(); // NB: asynchronous
|
|
107
|
-
const children = canSkipThisTile ? this._batchedChildren : undefined;
|
|
108
|
-
if (canSkipThisTile && core_frontend_1.TileTreeLoadStatus.Loading === childrenLoadStatus) {
|
|
109
|
-
args.markChildrenLoading();
|
|
43
|
+
return;
|
|
44
|
+
if (this._unskippable) {
|
|
45
|
+
// Prevent this tile's content from being unloaded due to memory pressure.
|
|
46
|
+
args.touchedTiles.add(this);
|
|
110
47
|
args.markUsed(this);
|
|
111
48
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
// Otherwise, if we want to draw children in our place, we should wait for *all* of them to load, or else we would show missing chunks where not-yet-loaded children belong.
|
|
115
|
-
const isUndisplayableRootTile = this.isUndisplayableRootTile;
|
|
49
|
+
closestDisplayableAncestor = this.hasGraphics ? this : closestDisplayableAncestor;
|
|
50
|
+
if (core_frontend_1.TileVisibility.TooCoarse === vis && (this.isReady || !this._unskippable)) {
|
|
116
51
|
args.markUsed(this);
|
|
117
|
-
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
else {
|
|
127
|
-
// At least one child we want to draw is not yet loaded. Wait for it to load before drawing it and its siblings, unless we have nothing to draw in their place.
|
|
128
|
-
drawChildren = isUndisplayableRootTile;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
if (drawChildren)
|
|
133
|
-
return core_frontend_1.SelectParent.No;
|
|
134
|
-
// Some types of tiles (like maps) allow the ready children to be drawn on top of the parent while other children are not yet loaded.
|
|
135
|
-
if (args.parentsAndChildrenExclusive)
|
|
136
|
-
selected.length = initialSize;
|
|
137
|
-
}
|
|
138
|
-
if (this.isReady) {
|
|
139
|
-
if (this.hasGraphics) {
|
|
140
|
-
selected.push(this);
|
|
141
|
-
if (!canSkipThisTile) {
|
|
142
|
-
// This tile is too coarse, but we require loading it before we can start loading higher-res children.
|
|
143
|
-
args.markReady(this);
|
|
144
|
-
}
|
|
52
|
+
args.markReady(this);
|
|
53
|
+
const childrenLoadStatus = this.loadChildren();
|
|
54
|
+
if (core_frontend_1.TileTreeLoadStatus.Loading === childrenLoadStatus)
|
|
55
|
+
args.markChildrenLoading();
|
|
56
|
+
const children = this._batchedChildren;
|
|
57
|
+
if (children) {
|
|
58
|
+
for (const child of children)
|
|
59
|
+
child.selectTiles(selected, args, closestDisplayableAncestor);
|
|
60
|
+
return;
|
|
145
61
|
}
|
|
146
|
-
return core_frontend_1.SelectParent.No;
|
|
147
62
|
}
|
|
148
|
-
//
|
|
149
|
-
if (!
|
|
63
|
+
// We want to display this tile. Request its content if not already loaded.
|
|
64
|
+
if ((core_frontend_1.TileVisibility.Visible === vis || this._unskippable) && !this.isReady)
|
|
150
65
|
args.insertMissing(this);
|
|
151
|
-
|
|
66
|
+
if (closestDisplayableAncestor)
|
|
67
|
+
selected.add(closestDisplayableAncestor);
|
|
152
68
|
}
|
|
153
69
|
_loadChildren(resolve, reject) {
|
|
154
70
|
let children;
|
|
@@ -192,6 +108,7 @@ class BatchedTile extends core_frontend_1.Tile {
|
|
|
192
108
|
iModel: this.tree.iModel,
|
|
193
109
|
modelId: this.tree.modelId,
|
|
194
110
|
is3d: true,
|
|
111
|
+
isLeaf: this.isLeaf,
|
|
195
112
|
system,
|
|
196
113
|
isCanceled: shouldAbort,
|
|
197
114
|
options: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BatchedTile.js","sourceRoot":"","sources":["../../src/BatchedTile.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,sDAA8E;AAC9E,oDAA+D;AAC/D,wDAG8B;AAC9B,qDAAkD;AAElD,yEAAsE;AACtE,mDAAqD;AAOrD,IAAI,OAAuC,CAAC;AAE5C,gBAAgB;AAChB,MAAa,WAAY,SAAQ,oBAAI;IAOnC,YAAmB,MAAyB,EAAE,IAAqB;;QACjE,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QACpB,IAAI,MAAA,MAAM,CAAC,aAAa,0CAAE,MAAM;YAC9B,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,aAAa,CAAC;QAE7C,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YACnB,IAAI,CAAC,UAAU,EAAE,CAAC;YAClB,uBAAuB;YACvB,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC;SACvB;IACH,CAAC;IAdD,IAAW,WAAW;QACpB,OAAO,IAAI,CAAC,IAAuB,CAAC;IACtC,CAAC;IAcD,IAAY,gBAAgB;QAC1B,OAAO,IAAI,CAAC,QAAqC,CAAC;IACpD,CAAC;IAEe,mBAAmB,CAAC,SAA6B,EAAE,MAA0B;QAC3F,2FAA2F;QAC3F,OAAO,iCAAiB,CAAC,2BAA2B,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IACnG,CAAC;IAEM,WAAW,CAAC,QAAuB,EAAE,IAAkB,EAAE,UAAkB;QAChF,MAAM,GAAG,GAAG,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;QACzC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AC,CAAC;YACrC,OAAO;SACR;QAED,OAAO,CAAC,YAAY,CAAC,sBAAQ,CAAC,KAAK,EAAE,sBAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QACxD,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAEhC,IAAI,CAAC,YAAY,EAAE,CAAC;QACpB,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC/B,IAAI,CAAC,QAAQ;YACX,OAAO;QAET,OAAO,CAAC,YAAY,CAAC,sBAAQ,CAAC,IAAI,EAAE,sBAAQ,CAAC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;QAC7E,KAAK,MAAM,KAAK,IAAI,QAAQ,EAAE;YAC5B,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;YAC1B,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;YAC3B,OAAO,CAAC,WAAW,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;SAClC;IACH,CAAC;IAEM,KAAK,CAAC,SAAsB;QACjC,MAAM,QAAQ,GAAG,IAAI,CAAC,gBAAgB,CAAC;QACvC,IAAI,CAAC,QAAQ;YACX,OAAO;QAET,IAAI,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE;YACzC,IAAI,CAAC,eAAe,EAAE,CAAC;SACxB;aAAM;YACL,KAAK,MAAM,KAAK,IAAI,QAAQ;gBAC1B,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;SAC1B;IACH,CAAC;CACF;AA1QD,kCA0QC","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, BeTimePoint, ByteStream, Logger } from \"@itwin/core-bentley\";\nimport { ColorDef, Tileset3dSchema } from \"@itwin/core-common\";\nimport {\n GltfReaderProps, GraphicBuilder, ImdlReader, IModelApp, RealityTileLoader, RenderSystem, SelectParent, Tile, TileBoundingBoxes, TileContent,\n TileDrawArgs, TileLoadStatus, TileParams, TileRequest, TileRequestChannel, TileTreeLoadStatus, TileUser, TileVisibility, Viewport,\n} from \"@itwin/core-frontend\";\nimport { loggerCategory } from \"./LoggerCategory\";\nimport { BatchedTileTree } from \"./BatchedTileTree\";\nimport { BatchedTileContentReader } from \"./BatchedTileContentReader\";\nimport { getMaxLevelsToSkip } from \"./FrontendTiles\";\n\n/** @internal */\nexport interface BatchedTileParams extends TileParams {\n childrenProps: Tileset3dSchema.Tile[] | undefined;\n}\n\nlet channel: TileRequestChannel | undefined;\n\n/** @internal */\nexport class BatchedTile extends Tile {\n private readonly _childrenProps?: Tileset3dSchema.Tile[];\n\n public get batchedTree(): BatchedTileTree {\n return this.tree as BatchedTileTree;\n }\n\n public constructor(params: BatchedTileParams, tree: BatchedTileTree) {\n super(params, tree);\n if (params.childrenProps?.length)\n this._childrenProps = params.childrenProps;\n\n if (!this.contentId) {\n this.setIsReady();\n // mark \"undisplayable\"\n this._maximumSize = 0;\n }\n }\n\n private get _batchedChildren(): BatchedTile[] | undefined {\n return this.children as BatchedTile[] | undefined;\n }\n\n public override computeLoadPriority(viewports: Iterable<Viewport>, _users: Iterable<TileUser>): number {\n // Prioritize tiles closer to camera and center of attention (zoom point or screen center).\n return RealityTileLoader.computeTileLocationPriority(this, viewports, this.tree.iModelTransform);\n }\n\n public selectTiles(selected: BatchedTile[], args: TileDrawArgs, numSkipped: number): SelectParent {\n const vis = this.computeVisibility(args);\n if (TileVisibility.OutsideFrustum === vis)\n return SelectParent.No;\n\n if (TileVisibility.Visible === vis) {\n // This tile is of appropriate resolution to draw. If need loading or refinement, enqueue.\n if (!this.isReady)\n args.insertMissing(this);\n\n if (this.hasGraphics) {\n // It can be drawn - select it\n args.markReady(this);\n selected.push(this);\n } else if (!this.isReady) {\n // It can't be drawn. Try to draw children in its place; otherwise draw the parent.\n // Do not load/request the children for this purpose.\n const initialSize = selected.length;\n const kids = this._batchedChildren;\n if (undefined === kids)\n return SelectParent.Yes;\n\n // Find any descendant to draw, until we exceed max initial tiles to skip.\n // if (this.depth < this.iModelTree.maxInitialTilesToSkip) {\n // for (const kid of kids) {\n // if (SelectParent.Yes === kid.selectTiles(selected, args, numSkipped)) {\n // selected.length = initialSize;\n // return SelectParent.Yes;\n // }\n\n // return SelectParent.No;\n // }\n // }\n\n // If all visible direct children can be drawn, draw them.\n for (const kid of kids) {\n if (TileVisibility.OutsideFrustum !== kid.computeVisibility(args)) {\n if (!kid.hasGraphics) {\n selected.length = initialSize;\n return SelectParent.Yes;\n } else {\n selected.push(kid);\n }\n }\n }\n\n args.markUsed(this);\n }\n\n // We're drawing either this tile, or its direct children.\n return SelectParent.No;\n }\n\n // This tile is too coarse to draw. Try to draw something more appropriate.\n // If it is not ready to draw, we may want to skip loading in favor of loading its descendants.\n // If we previously loaded and later unloaded content for this tile to free memory, don't force it to reload its content - proceed to children.\n const maximumLevelsToSkip = getMaxLevelsToSkip();\n let canSkipThisTile = (this._hadGraphics && !this.hasGraphics) /* || this.depth < this.iModelTree.maxInitialTilesToSkip */ ;\n if (canSkipThisTile) {\n numSkipped = 1;\n } else {\n canSkipThisTile = this.isReady || this.isParentDisplayable /* || this.depth < this.iModelTree.maxInitialTilesToSkip */ ;\n if (canSkipThisTile && this.isDisplayable) { // skipping an undisplayable tile doesn't count toward the maximum\n // Some tiles do not sub-divide - they only facet the same geometry to a higher resolution. We can skip directly to the correct resolution.\n const isNotReady = !this.isReady && !this.hasGraphics /* && !this.hasSizeMultiplier */ ;\n if (isNotReady) {\n if (numSkipped >= maximumLevelsToSkip)\n canSkipThisTile = false;\n else\n numSkipped += 1;\n }\n }\n }\n\n const childrenLoadStatus = this.loadChildren(); // NB: asynchronous\n const children = canSkipThisTile ? this._batchedChildren : undefined;\n if (canSkipThisTile && TileTreeLoadStatus.Loading === childrenLoadStatus) {\n args.markChildrenLoading();\n args.markUsed(this);\n }\n\n if (undefined !== children) {\n // If we are the root tile and we are not displayable, then we want to draw *any* currently available children in our place, or else we would draw nothing.\n // Otherwise, if we want to draw children in our place, we should wait for *all* of them to load, or else we would show missing chunks where not-yet-loaded children belong.\n const isUndisplayableRootTile = this.isUndisplayableRootTile;\n args.markUsed(this);\n let drawChildren = true;\n const initialSize = selected.length;\n for (const child of children) {\n // NB: We must continue iterating children so that they can be requested if missing.\n if (SelectParent.Yes === child.selectTiles(selected, args, numSkipped)) {\n if (child.loadStatus === TileLoadStatus.NotFound) {\n // At least one child we want to draw failed to load. e.g., we reached max depth of map tile tree. Draw parent instead.\n drawChildren = canSkipThisTile = false;\n } else {\n // At least one child we want to draw is not yet loaded. Wait for it to load before drawing it and its siblings, unless we have nothing to draw in their place.\n drawChildren = isUndisplayableRootTile;\n }\n }\n }\n\n if (drawChildren)\n return SelectParent.No;\n\n // Some types of tiles (like maps) allow the ready children to be drawn on top of the parent while other children are not yet loaded.\n if (args.parentsAndChildrenExclusive)\n selected.length = initialSize;\n }\n\n if (this.isReady) {\n if (this.hasGraphics) {\n selected.push(this);\n if (!canSkipThisTile) {\n // This tile is too coarse, but we require loading it before we can start loading higher-res children.\n args.markReady(this);\n }\n }\n\n return SelectParent.No;\n }\n\n // This tile is not ready to be drawn. Request it *only* if we cannot skip it.\n if (!canSkipThisTile)\n args.insertMissing(this);\n\n return this.isParentDisplayable ? SelectParent.Yes : SelectParent.No;\n }\n\n protected override _loadChildren(resolve: (children: Tile[] | undefined) => void, reject: (error: Error) => void): void {\n let children: BatchedTile[] | undefined;\n if (this._childrenProps) {\n try {\n for (const childProps of this._childrenProps) {\n const params = this.batchedTree.reader.readTileParams(childProps, this);\n const child = new BatchedTile(params, this.batchedTree);\n children = children ?? [];\n children.push(child);\n }\n } catch (err) {\n Logger.logException(loggerCategory, err);\n children = undefined;\n if (err instanceof Error)\n reject(err);\n }\n }\n\n resolve(children);\n }\n\n public override get channel(): TileRequestChannel {\n if (!channel) {\n channel = new TileRequestChannel(\"itwinjs-batched-models\", 20);\n IModelApp.tileAdmin.channels.add(channel);\n }\n\n return channel;\n }\n\n public override async requestContent(_isCanceled: () => boolean): Promise<TileRequest.Response> {\n const url = new URL(this.contentId, this.batchedTree.reader.baseUrl);\n url.search = this.batchedTree.reader.baseUrl.search;\n const response = await fetch(url.toString());\n return response.arrayBuffer();\n }\n\n public override async readContent(data: TileRequest.ResponseData, system: RenderSystem, shouldAbort?: () => boolean): Promise<TileContent> {\n assert(data instanceof Uint8Array);\n if (!(data instanceof Uint8Array))\n return { };\n\n let reader: ImdlReader | BatchedTileContentReader | undefined = ImdlReader.create({\n stream: ByteStream.fromUint8Array(data),\n iModel: this.tree.iModel,\n modelId: this.tree.modelId,\n is3d: true,\n system,\n isCanceled: shouldAbort,\n options: {\n tileId: this.contentId,\n },\n });\n\n if (!reader) {\n const gltfProps = GltfReaderProps.create(data, false, this.batchedTree.reader.baseUrl);\n if (gltfProps) {\n reader = new BatchedTileContentReader({\n props: gltfProps,\n iModel: this.tree.iModel,\n system,\n shouldAbort,\n vertexTableRequired: true,\n modelId: this.tree.modelId,\n isLeaf: this.isLeaf,\n range: this.range,\n });\n }\n }\n\n if (!reader)\n return { };\n\n return reader.read();\n }\n\n protected override addRangeGraphic(builder: GraphicBuilder, type: TileBoundingBoxes): void {\n if (TileBoundingBoxes.ChildVolumes !== type) {\n super.addRangeGraphic(builder, type);\n return;\n }\n\n builder.setSymbology(ColorDef.green, ColorDef.green, 2);\n builder.addRangeBox(this.range);\n\n this.loadChildren();\n const children = this.children;\n if (!children)\n return;\n\n builder.setSymbology(ColorDef.blue, ColorDef.blue.withTransparency(0xdf), 1);\n for (const child of children) {\n const range = child.range;\n builder.addRangeBox(range);\n builder.addRangeBox(range, true);\n }\n }\n\n public prune(olderThan: BeTimePoint): void {\n const children = this._batchedChildren;\n if (!children)\n return;\n\n if (this.usageMarker.isExpired(olderThan)) {\n this.disposeChildren();\n } else {\n for (const child of children)\n child.prune(olderThan);\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"BatchedTile.js","sourceRoot":"","sources":["../../src/BatchedTile.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,sDAA8E;AAC9E,oDAA+D;AAC/D,wDAG8B;AAC9B,qDAAkD;AAElD,yEAAsE;AACtE,mDAAqD;AAOrD,IAAI,OAAuC,CAAC;AAE5C,gBAAgB;AAChB,MAAa,WAAY,SAAQ,oBAAI;IAQnC,YAAmB,MAAyB,EAAE,IAAqB;;QACjE,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAEpB,kFAAkF;QAClF,IAAI,CAAC,YAAY,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,GAAG,IAAA,kCAAkB,GAAE,CAAC,CAAC;QAE9D,IAAI,MAAA,MAAM,CAAC,aAAa,0CAAE,MAAM;YAC9B,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,aAAa,CAAC;QAE7C,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YACnB,IAAI,CAAC,UAAU,EAAE,CAAC;YAClB,uBAAuB;YACvB,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC;SACvB;IACH,CAAC;IAlBD,IAAW,WAAW;QACpB,OAAO,IAAI,CAAC,IAAuB,CAAC;IACtC,CAAC;IAkBD,IAAY,gBAAgB;QAC1B,OAAO,IAAI,CAAC,QAAqC,CAAC;IACpD,CAAC;IAEe,mBAAmB,CAAC,SAA6B,EAAE,MAA0B;QAC3F,2FAA2F;QAC3F,OAAO,iCAAiB,CAAC,2BAA2B,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IACnG,CAAC;IAEM,WAAW,CAAC,QAA0B,EAAE,IAAkB,EAAE,0BAAmD;QACpH,MAAM,GAAG,GAAG,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;QACzC,IAAI,8BAAc,C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,IAAuB;QACjF,IAAI,iCAAiB,CAAC,YAAY,KAAK,IAAI,EAAE;YAC3C,KAAK,CAAC,eAAe,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;YACrC,OAAO;SACR;QAED,OAAO,CAAC,YAAY,CAAC,sBAAQ,CAAC,KAAK,EAAE,sBAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QACxD,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAEhC,IAAI,CAAC,YAAY,EAAE,CAAC;QACpB,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC/B,IAAI,CAAC,QAAQ;YACX,OAAO;QAET,OAAO,CAAC,YAAY,CAAC,sBAAQ,CAAC,IAAI,EAAE,sBAAQ,CAAC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;QAC7E,KAAK,MAAM,KAAK,IAAI,QAAQ,EAAE;YAC5B,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;YAC1B,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;YAC3B,OAAO,CAAC,WAAW,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;SAClC;IACH,CAAC;IAEM,KAAK,CAAC,SAAsB;QACjC,MAAM,QAAQ,GAAG,IAAI,CAAC,gBAAgB,CAAC;QACvC,IAAI,CAAC,QAAQ;YACX,OAAO;QAET,IAAI,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE;YACzC,IAAI,CAAC,eAAe,EAAE,CAAC;SACxB;aAAM;YACL,KAAK,MAAM,KAAK,IAAI,QAAQ;gBAC1B,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;SAC1B;IACH,CAAC;CACF;AApLD,kCAoLC","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, BeTimePoint, ByteStream, Logger } from \"@itwin/core-bentley\";\nimport { ColorDef, Tileset3dSchema } from \"@itwin/core-common\";\nimport {\n GltfReaderProps, GraphicBuilder, ImdlReader, IModelApp, RealityTileLoader, RenderSystem, Tile, TileBoundingBoxes, TileContent,\n TileDrawArgs, TileParams, TileRequest, TileRequestChannel, TileTreeLoadStatus, TileUser, TileVisibility, Viewport,\n} from \"@itwin/core-frontend\";\nimport { loggerCategory } from \"./LoggerCategory\";\nimport { BatchedTileTree } from \"./BatchedTileTree\";\nimport { BatchedTileContentReader } from \"./BatchedTileContentReader\";\nimport { getMaxLevelsToSkip } from \"./FrontendTiles\";\n\n/** @internal */\nexport interface BatchedTileParams extends TileParams {\n childrenProps: Tileset3dSchema.Tile[] | undefined;\n}\n\nlet channel: TileRequestChannel | undefined;\n\n/** @internal */\nexport class BatchedTile extends Tile {\n private readonly _childrenProps?: Tileset3dSchema.Tile[];\n private readonly _unskippable: boolean;\n\n public get batchedTree(): BatchedTileTree {\n return this.tree as BatchedTileTree;\n }\n\n public constructor(params: BatchedTileParams, tree: BatchedTileTree) {\n super(params, tree);\n\n // The root tile never has content, so it doesn't count toward max levels to skip.\n this._unskippable = 0 === (this.depth % getMaxLevelsToSkip());\n\n if (params.childrenProps?.length)\n this._childrenProps = params.childrenProps;\n\n if (!this.contentId) {\n this.setIsReady();\n // mark \"undisplayable\"\n this._maximumSize = 0;\n }\n }\n\n private get _batchedChildren(): BatchedTile[] | undefined {\n return this.children as BatchedTile[] | undefined;\n }\n\n public override computeLoadPriority(viewports: Iterable<Viewport>, _users: Iterable<TileUser>): number {\n // Prioritize tiles closer to camera and center of attention (zoom point or screen center).\n return RealityTileLoader.computeTileLocationPriority(this, viewports, this.tree.iModelTransform);\n }\n\n public selectTiles(selected: Set<BatchedTile>, args: TileDrawArgs, closestDisplayableAncestor: BatchedTile | undefined): void {\n const vis = this.computeVisibility(args);\n if (TileVisibility.OutsideFrustum === vis)\n return;\n\n if (this._unskippable) {\n // Prevent this tile's content from being unloaded due to memory pressure.\n args.touchedTiles.add(this);\n args.markUsed(this);\n }\n\n closestDisplayableAncestor = this.hasGraphics ? this : closestDisplayableAncestor;\n if (TileVisibility.TooCoarse === vis && (this.isReady || !this._unskippable)) {\n args.markUsed(this);\n args.markReady(this);\n const childrenLoadStatus = this.loadChildren();\n if (TileTreeLoadStatus.Loading === childrenLoadStatus)\n args.markChildrenLoading();\n\n const children = this._batchedChildren;\n if (children) {\n for (const child of children)\n child.selectTiles(selected, args, closestDisplayableAncestor);\n\n return;\n }\n }\n\n // We want to display this tile. Request its content if not already loaded.\n if ((TileVisibility.Visible === vis || this._unskippable) && !this.isReady)\n args.insertMissing(this);\n\n if (closestDisplayableAncestor)\n selected.add(closestDisplayableAncestor);\n }\n\n protected override _loadChildren(resolve: (children: Tile[] | undefined) => void, reject: (error: Error) => void): void {\n let children: BatchedTile[] | undefined;\n if (this._childrenProps) {\n try {\n for (const childProps of this._childrenProps) {\n const params = this.batchedTree.reader.readTileParams(childProps, this);\n const child = new BatchedTile(params, this.batchedTree);\n children = children ?? [];\n children.push(child);\n }\n } catch (err) {\n Logger.logException(loggerCategory, err);\n children = undefined;\n if (err instanceof Error)\n reject(err);\n }\n }\n\n resolve(children);\n }\n\n public override get channel(): TileRequestChannel {\n if (!channel) {\n channel = new TileRequestChannel(\"itwinjs-batched-models\", 20);\n IModelApp.tileAdmin.channels.add(channel);\n }\n\n return channel;\n }\n\n public override async requestContent(_isCanceled: () => boolean): Promise<TileRequest.Response> {\n const url = new URL(this.contentId, this.batchedTree.reader.baseUrl);\n url.search = this.batchedTree.reader.baseUrl.search;\n const response = await fetch(url.toString());\n return response.arrayBuffer();\n }\n\n public override async readContent(data: TileRequest.ResponseData, system: RenderSystem, shouldAbort?: () => boolean): Promise<TileContent> {\n assert(data instanceof Uint8Array);\n if (!(data instanceof Uint8Array))\n return { };\n\n let reader: ImdlReader | BatchedTileContentReader | undefined = ImdlReader.create({\n stream: ByteStream.fromUint8Array(data),\n iModel: this.tree.iModel,\n modelId: this.tree.modelId,\n is3d: true,\n isLeaf: this.isLeaf,\n system,\n isCanceled: shouldAbort,\n options: {\n tileId: this.contentId,\n },\n });\n\n if (!reader) {\n const gltfProps = GltfReaderProps.create(data, false, this.batchedTree.reader.baseUrl);\n if (gltfProps) {\n reader = new BatchedTileContentReader({\n props: gltfProps,\n iModel: this.tree.iModel,\n system,\n shouldAbort,\n vertexTableRequired: true,\n modelId: this.tree.modelId,\n isLeaf: this.isLeaf,\n range: this.range,\n });\n }\n }\n\n if (!reader)\n return { };\n\n return reader.read();\n }\n\n protected override addRangeGraphic(builder: GraphicBuilder, type: TileBoundingBoxes): void {\n if (TileBoundingBoxes.ChildVolumes !== type) {\n super.addRangeGraphic(builder, type);\n return;\n }\n\n builder.setSymbology(ColorDef.green, ColorDef.green, 2);\n builder.addRangeBox(this.range);\n\n this.loadChildren();\n const children = this.children;\n if (!children)\n return;\n\n builder.setSymbology(ColorDef.blue, ColorDef.blue.withTransparency(0xdf), 1);\n for (const child of children) {\n const range = child.range;\n builder.addRangeBox(range);\n builder.addRangeBox(range, true);\n }\n }\n\n public prune(olderThan: BeTimePoint): void {\n const children = this._batchedChildren;\n if (!children)\n return;\n\n if (this.usageMarker.isExpired(olderThan)) {\n this.disposeChildren();\n } else {\n for (const child of children)\n child.prune(olderThan);\n }\n }\n}\n"]}
|
|
@@ -34,9 +34,9 @@ class BatchedTileTree extends core_frontend_1.TileTree {
|
|
|
34
34
|
}
|
|
35
35
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
36
36
|
_selectTiles(args) {
|
|
37
|
-
const selected =
|
|
38
|
-
this.rootTile.selectTiles(selected, args,
|
|
39
|
-
return selected;
|
|
37
|
+
const selected = new Set();
|
|
38
|
+
this.rootTile.selectTiles(selected, args, undefined);
|
|
39
|
+
return Array.from(selected);
|
|
40
40
|
}
|
|
41
41
|
draw(args) {
|
|
42
42
|
const tiles = this.selectTiles(args);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BatchedTileTree.js","sourceRoot":"","sources":["../../src/BatchedTileTree.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,sDAAkD;AAClD,oDAAmE;AACnE,wDAE8B;AAC9B,+CAA+D;AAS/D,MAAM,iBAAiB,GAAsB;IAC3C,UAAU,EAAE,wBAAU,CAAC,WAAW;IAClC,YAAY,EAAE,KAAK;CACpB,CAAC;AAEF,gBAAgB;AAChB,MAAa,eAAgB,SAAQ,wBAAQ;IAI3C,YAAmB,MAA6B;QAC9C,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,SAAS,GAAG,IAAI,yBAAW,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QACxD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;IAC9B,CAAC;IAED,IAAoB,QAAQ;QAC1B,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED,IAAoB,IAAI;QACtB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAoB,QAAQ;QAC1B,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,IAAoB,iBAAiB;QACnC,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IAED,gEAAgE;IAChD,YAAY,CAAC,IAAkB;QAC7C,MAAM,QAAQ,
|
|
1
|
+
{"version":3,"file":"BatchedTileTree.js","sourceRoot":"","sources":["../../src/BatchedTileTree.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,sDAAkD;AAClD,oDAAmE;AACnE,wDAE8B;AAC9B,+CAA+D;AAS/D,MAAM,iBAAiB,GAAsB;IAC3C,UAAU,EAAE,wBAAU,CAAC,WAAW;IAClC,YAAY,EAAE,KAAK;CACpB,CAAC;AAEF,gBAAgB;AAChB,MAAa,eAAgB,SAAQ,wBAAQ;IAI3C,YAAmB,MAA6B;QAC9C,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,SAAS,GAAG,IAAI,yBAAW,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QACxD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;IAC9B,CAAC;IAED,IAAoB,QAAQ;QAC1B,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED,IAAoB,IAAI;QACtB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAoB,QAAQ;QAC1B,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,IAAoB,iBAAiB;QACnC,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IAED,gEAAgE;IAChD,YAAY,CAAC,IAAkB;QAC7C,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAe,CAAC;QACxC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,QAAQ,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;QACrD,OAAO,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC9B,CAAC;IAEe,IAAI,CAAC,IAAkB;QACrC,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACrC,KAAK,MAAM,IAAI,IAAI,KAAK;YACtB,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QAE1B,IAAI,CAAC,YAAY,EAAE,CAAC;IACtB,CAAC;IAEe,KAAK;QACnB,MAAM,SAAS,GAAG,0BAAW,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC/D,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IACjC,CAAC;CACF;AA7CD,0CA6CC","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 { BeTimePoint } from \"@itwin/core-bentley\";\nimport { RenderMode, ViewFlagOverrides } from \"@itwin/core-common\";\nimport {\n Tile, TileDrawArgs, TileTree, TileTreeParams,\n} from \"@itwin/core-frontend\";\nimport { BatchedTile, BatchedTileParams } from \"./BatchedTile\";\nimport { BatchedTilesetReader } from \"./BatchedTilesetReader\";\n\n/** @internal */\nexport interface BatchedTileTreeParams extends TileTreeParams {\n rootTile: BatchedTileParams;\n reader: BatchedTilesetReader;\n}\n\nconst viewFlagOverrides: ViewFlagOverrides = {\n renderMode: RenderMode.SmoothShade,\n visibleEdges: false,\n};\n\n/** @internal */\nexport class BatchedTileTree extends TileTree {\n private readonly _rootTile: BatchedTile;\n public readonly reader: BatchedTilesetReader;\n\n public constructor(params: BatchedTileTreeParams) {\n super(params);\n this._rootTile = new BatchedTile(params.rootTile, this);\n this.reader = params.reader;\n }\n\n public override get rootTile(): BatchedTile {\n return this._rootTile;\n }\n\n public override get is3d(): boolean {\n return true;\n }\n\n public override get maxDepth(): number | undefined {\n return undefined;\n }\n\n public override get viewFlagOverrides(): ViewFlagOverrides {\n return viewFlagOverrides;\n }\n\n // eslint-disable-next-line @typescript-eslint/naming-convention\n public override _selectTiles(args: TileDrawArgs): Tile[] {\n const selected = new Set<BatchedTile>();\n this.rootTile.selectTiles(selected, args, undefined);\n return Array.from(selected);\n }\n\n public override draw(args: TileDrawArgs): void {\n const tiles = this.selectTiles(args);\n for (const tile of tiles)\n tile.drawGraphics(args);\n\n args.drawGraphics();\n }\n\n public override prune(): void {\n const olderThan = BeTimePoint.now().minus(this.expirationTime);\n this.rootTile.prune(olderThan);\n }\n}\n"]}
|