@itwin/frontend-tiles 4.0.0-dev.52 → 4.0.0-dev.55
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/operation/build_ci/state.json +1 -1
- package/.rush/temp/package-deps_build_ci.json +4 -4
- package/.rush/temp/shrinkwrap-deps.json +45 -52
- package/lib/cjs/BatchedSpatialTileTreeRefs.d.ts +3 -3
- package/lib/cjs/BatchedSpatialTileTreeRefs.js +34 -34
- package/lib/cjs/BatchedTile.d.ts +23 -23
- package/lib/cjs/BatchedTile.d.ts.map +1 -1
- package/lib/cjs/BatchedTile.js +249 -155
- package/lib/cjs/BatchedTile.js.map +1 -1
- package/lib/cjs/BatchedTileContentReader.d.ts +22 -22
- package/lib/cjs/BatchedTileContentReader.js +74 -74
- package/lib/cjs/BatchedTileTree.d.ts +22 -22
- package/lib/cjs/BatchedTileTree.js +52 -52
- package/lib/cjs/BatchedTileTree.js.map +1 -1
- package/lib/cjs/BatchedTileTreeReference.d.ts +17 -17
- package/lib/cjs/BatchedTileTreeReference.js +49 -49
- package/lib/cjs/BatchedTileTreeSupplier.d.ts +5 -5
- package/lib/cjs/BatchedTileTreeSupplier.d.ts.map +1 -1
- package/lib/cjs/BatchedTileTreeSupplier.js +38 -38
- package/lib/cjs/BatchedTilesetReader.d.ts +13 -13
- package/lib/cjs/BatchedTilesetReader.js +87 -87
- package/lib/cjs/FrontendTiles.d.ts +14 -14
- package/lib/cjs/FrontendTiles.js +16 -16
- package/lib/cjs/LoggerCategory.d.ts +2 -2
- package/lib/cjs/LoggerCategory.js +9 -9
- package/lib/cjs/frontend-tiles.d.ts +1 -1
- package/lib/cjs/frontend-tiles.js +21 -17
- package/lib/cjs/frontend-tiles.js.map +1 -1
- package/lib/cjs/tsconfig.tsbuildinfo +1 -1
- package/lib/esm/BatchedSpatialTileTreeRefs.d.ts +3 -3
- package/lib/esm/BatchedSpatialTileTreeRefs.js +30 -30
- package/lib/esm/BatchedTile.d.ts +23 -23
- package/lib/esm/BatchedTile.d.ts.map +1 -1
- package/lib/esm/BatchedTile.js +245 -151
- package/lib/esm/BatchedTile.js.map +1 -1
- package/lib/esm/BatchedTileContentReader.d.ts +22 -22
- package/lib/esm/BatchedTileContentReader.js +70 -70
- package/lib/esm/BatchedTileTree.d.ts +22 -22
- package/lib/esm/BatchedTileTree.js +48 -48
- package/lib/esm/BatchedTileTree.js.map +1 -1
- package/lib/esm/BatchedTileTreeReference.d.ts +17 -17
- package/lib/esm/BatchedTileTreeReference.js +45 -45
- package/lib/esm/BatchedTileTreeSupplier.d.ts +5 -5
- package/lib/esm/BatchedTileTreeSupplier.d.ts.map +1 -1
- package/lib/esm/BatchedTileTreeSupplier.js +34 -34
- package/lib/esm/BatchedTilesetReader.d.ts +13 -13
- package/lib/esm/BatchedTilesetReader.js +83 -83
- package/lib/esm/FrontendTiles.d.ts +14 -14
- package/lib/esm/FrontendTiles.js +12 -12
- package/lib/esm/LoggerCategory.d.ts +2 -2
- package/lib/esm/LoggerCategory.js +6 -6
- package/lib/esm/frontend-tiles.d.ts +1 -1
- package/lib/esm/frontend-tiles.js +5 -5
- package/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/package.json +12 -12
- package/src/BatchedTile.ts +131 -27
- package/src/BatchedTileTree.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/frontend-tiles",
|
|
3
|
-
"version": "4.0.0-dev.
|
|
3
|
+
"version": "4.0.0-dev.55",
|
|
4
4
|
"description": "Experimental alternative technique for visualizing the contents of iModels",
|
|
5
5
|
"main": "lib/cjs/frontend-tiles.js",
|
|
6
6
|
"module": "lib/esm/frontend-tiles.js",
|
|
@@ -22,22 +22,22 @@
|
|
|
22
22
|
"url": "http://www.bentley.com"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"@itwin/core-bentley": "4.0.0-dev.
|
|
26
|
-
"@itwin/core-common": "4.0.0-dev.
|
|
27
|
-
"@itwin/core-frontend": "4.0.0-dev.
|
|
28
|
-
"@itwin/core-geometry": "4.0.0-dev.
|
|
25
|
+
"@itwin/core-bentley": "4.0.0-dev.55",
|
|
26
|
+
"@itwin/core-common": "4.0.0-dev.55",
|
|
27
|
+
"@itwin/core-frontend": "4.0.0-dev.55",
|
|
28
|
+
"@itwin/core-geometry": "4.0.0-dev.55"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@itwin/build-tools": "4.0.0-dev.
|
|
32
|
-
"@itwin/core-bentley": "4.0.0-dev.
|
|
33
|
-
"@itwin/core-common": "4.0.0-dev.
|
|
34
|
-
"@itwin/core-frontend": "4.0.0-dev.
|
|
35
|
-
"@itwin/core-geometry": "4.0.0-dev.
|
|
36
|
-
"@itwin/eslint-plugin": "
|
|
31
|
+
"@itwin/build-tools": "4.0.0-dev.55",
|
|
32
|
+
"@itwin/core-bentley": "4.0.0-dev.55",
|
|
33
|
+
"@itwin/core-common": "4.0.0-dev.55",
|
|
34
|
+
"@itwin/core-frontend": "4.0.0-dev.55",
|
|
35
|
+
"@itwin/core-geometry": "4.0.0-dev.55",
|
|
36
|
+
"@itwin/eslint-plugin": "^4.0.0-dev.32",
|
|
37
37
|
"@types/node": "^18.11.5",
|
|
38
38
|
"eslint": "^7.11.0",
|
|
39
39
|
"rimraf": "^3.0.2",
|
|
40
|
-
"typescript": "~
|
|
40
|
+
"typescript": "~5.0.2"
|
|
41
41
|
},
|
|
42
42
|
"eslintConfig": {
|
|
43
43
|
"plugins": [
|
package/src/BatchedTile.ts
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
import { assert, BeTimePoint, ByteStream, Logger } from "@itwin/core-bentley";
|
|
7
7
|
import { ColorDef, Tileset3dSchema } from "@itwin/core-common";
|
|
8
8
|
import {
|
|
9
|
-
GltfReaderProps, GraphicBuilder, ImdlReader, IModelApp, RealityTileLoader, RenderSystem, Tile, TileBoundingBoxes, TileContent,
|
|
10
|
-
TileRequestChannel, TileTreeLoadStatus, TileUser, TileVisibility, Viewport,
|
|
9
|
+
GltfReaderProps, GraphicBuilder, ImdlReader, IModelApp, RealityTileLoader, RenderSystem, SelectParent, Tile, TileBoundingBoxes, TileContent,
|
|
10
|
+
TileDrawArgs, TileLoadStatus, TileParams, TileRequest, TileRequestChannel, TileTreeLoadStatus, TileUser, TileVisibility, Viewport,
|
|
11
11
|
} from "@itwin/core-frontend";
|
|
12
12
|
import { loggerCategory } from "./LoggerCategory";
|
|
13
13
|
import { BatchedTileTree } from "./BatchedTileTree";
|
|
@@ -18,6 +18,8 @@ export interface BatchedTileParams extends TileParams {
|
|
|
18
18
|
childrenProps: Tileset3dSchema.Tile[] | undefined;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
let channel: TileRequestChannel | undefined;
|
|
22
|
+
|
|
21
23
|
/** @internal */
|
|
22
24
|
export class BatchedTile extends Tile {
|
|
23
25
|
private readonly _childrenProps?: Tileset3dSchema.Tile[];
|
|
@@ -31,8 +33,11 @@ export class BatchedTile extends Tile {
|
|
|
31
33
|
if (params.childrenProps?.length)
|
|
32
34
|
this._childrenProps = params.childrenProps;
|
|
33
35
|
|
|
34
|
-
if (!this.contentId)
|
|
36
|
+
if (!this.contentId) {
|
|
35
37
|
this.setIsReady();
|
|
38
|
+
// mark "undisplayable"
|
|
39
|
+
this._maximumSize = 0;
|
|
40
|
+
}
|
|
36
41
|
}
|
|
37
42
|
|
|
38
43
|
private get _batchedChildren(): BatchedTile[] | undefined {
|
|
@@ -44,38 +49,132 @@ export class BatchedTile extends Tile {
|
|
|
44
49
|
return RealityTileLoader.computeTileLocationPriority(this, viewports, this.tree.iModelTransform);
|
|
45
50
|
}
|
|
46
51
|
|
|
47
|
-
public selectTiles(selected: BatchedTile[], args: TileDrawArgs):
|
|
52
|
+
public selectTiles(selected: BatchedTile[], args: TileDrawArgs, numSkipped: number): SelectParent {
|
|
48
53
|
const vis = this.computeVisibility(args);
|
|
49
54
|
if (TileVisibility.OutsideFrustum === vis)
|
|
50
|
-
return;
|
|
55
|
+
return SelectParent.No;
|
|
51
56
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
if (TileVisibility.Visible === vis) {
|
|
58
|
+
// This tile is of appropriate resolution to draw. If need loading or refinement, enqueue.
|
|
59
|
+
if (!this.isReady)
|
|
60
|
+
args.insertMissing(this);
|
|
61
|
+
|
|
62
|
+
if (this.hasGraphics) {
|
|
63
|
+
// It can be drawn - select it
|
|
64
|
+
args.markReady(this);
|
|
65
|
+
selected.push(this);
|
|
66
|
+
} else if (!this.isReady) {
|
|
67
|
+
// It can't be drawn. Try to draw children in its place; otherwise draw the parent.
|
|
68
|
+
// Do not load/request the children for this purpose.
|
|
69
|
+
const initialSize = selected.length;
|
|
70
|
+
const kids = this._batchedChildren;
|
|
71
|
+
if (undefined === kids)
|
|
72
|
+
return SelectParent.Yes;
|
|
73
|
+
|
|
74
|
+
// Find any descendant to draw, until we exceed max initial tiles to skip.
|
|
75
|
+
// if (this.depth < this.iModelTree.maxInitialTilesToSkip) {
|
|
76
|
+
// for (const kid of kids) {
|
|
77
|
+
// if (SelectParent.Yes === kid.selectTiles(selected, args, numSkipped)) {
|
|
78
|
+
// selected.length = initialSize;
|
|
79
|
+
// return SelectParent.Yes;
|
|
80
|
+
// }
|
|
81
|
+
|
|
82
|
+
// return SelectParent.No;
|
|
83
|
+
// }
|
|
84
|
+
// }
|
|
85
|
+
|
|
86
|
+
// If all visible direct children can be drawn, draw them.
|
|
87
|
+
for (const kid of kids) {
|
|
88
|
+
if (TileVisibility.OutsideFrustum !== kid.computeVisibility(args)) {
|
|
89
|
+
if (!kid.hasGraphics) {
|
|
90
|
+
selected.length = initialSize;
|
|
91
|
+
return SelectParent.Yes;
|
|
92
|
+
} else {
|
|
93
|
+
selected.push(kid);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
args.markUsed(this);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// We're drawing either this tile, or its direct children.
|
|
102
|
+
return SelectParent.No;
|
|
60
103
|
}
|
|
61
104
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
105
|
+
// This tile is too coarse to draw. Try to draw something more appropriate.
|
|
106
|
+
// If it is not ready to draw, we may want to skip loading in favor of loading its descendants.
|
|
107
|
+
// 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.
|
|
108
|
+
const maximumLevelsToSkip = IModelApp.tileAdmin.maximumLevelsToSkip;
|
|
109
|
+
let canSkipThisTile = (this._hadGraphics && !this.hasGraphics) /* || this.depth < this.iModelTree.maxInitialTilesToSkip */ ;
|
|
110
|
+
if (canSkipThisTile) {
|
|
111
|
+
numSkipped = 1;
|
|
112
|
+
} else {
|
|
113
|
+
canSkipThisTile = this.isReady || this.isParentDisplayable /* || this.depth < this.iModelTree.maxInitialTilesToSkip */ ;
|
|
114
|
+
if (canSkipThisTile && this.isDisplayable) { // skipping an undisplayable tile doesn't count toward the maximum
|
|
115
|
+
// Some tiles do not sub-divide - they only facet the same geometry to a higher resolution. We can skip directly to the correct resolution.
|
|
116
|
+
const isNotReady = !this.isReady && !this.hasGraphics /* && !this.hasSizeMultiplier */ ;
|
|
117
|
+
if (isNotReady) {
|
|
118
|
+
if (numSkipped >= maximumLevelsToSkip)
|
|
119
|
+
canSkipThisTile = false;
|
|
120
|
+
else
|
|
121
|
+
numSkipped += 1;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const childrenLoadStatus = this.loadChildren(); // NB: asynchronous
|
|
127
|
+
const children = canSkipThisTile ? this._batchedChildren : undefined;
|
|
128
|
+
if (canSkipThisTile && TileTreeLoadStatus.Loading === childrenLoadStatus) {
|
|
129
|
+
args.markChildrenLoading();
|
|
130
|
+
args.markUsed(this);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (undefined !== children) {
|
|
134
|
+
// 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.
|
|
135
|
+
// 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.
|
|
136
|
+
const isUndisplayableRootTile = this.isUndisplayableRootTile;
|
|
137
|
+
args.markUsed(this);
|
|
138
|
+
let drawChildren = true;
|
|
139
|
+
const initialSize = selected.length;
|
|
140
|
+
for (const child of children) {
|
|
141
|
+
// NB: We must continue iterating children so that they can be requested if missing.
|
|
142
|
+
if (SelectParent.Yes === child.selectTiles(selected, args, numSkipped)) {
|
|
143
|
+
if (child.loadStatus === TileLoadStatus.NotFound) {
|
|
144
|
+
// At least one child we want to draw failed to load. e.g., we reached max depth of map tile tree. Draw parent instead.
|
|
145
|
+
drawChildren = canSkipThisTile = false;
|
|
146
|
+
} else {
|
|
147
|
+
// 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.
|
|
148
|
+
drawChildren = isUndisplayableRootTile;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (drawChildren)
|
|
154
|
+
return SelectParent.No;
|
|
155
|
+
|
|
156
|
+
// 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.
|
|
157
|
+
if (args.parentsAndChildrenExclusive)
|
|
158
|
+
selected.length = initialSize;
|
|
66
159
|
}
|
|
67
160
|
|
|
68
|
-
args.markUsed(this);
|
|
69
161
|
if (this.isReady) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
162
|
+
if (this.hasGraphics) {
|
|
163
|
+
selected.push(this);
|
|
164
|
+
if (!canSkipThisTile) {
|
|
165
|
+
// This tile is too coarse, but we require loading it before we can start loading higher-res children.
|
|
166
|
+
args.markReady(this);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
return SelectParent.No;
|
|
78
171
|
}
|
|
172
|
+
|
|
173
|
+
// This tile is not ready to be drawn. Request it *only* if we cannot skip it.
|
|
174
|
+
if (!canSkipThisTile)
|
|
175
|
+
args.insertMissing(this);
|
|
176
|
+
|
|
177
|
+
return this.isParentDisplayable ? SelectParent.Yes : SelectParent.No;
|
|
79
178
|
}
|
|
80
179
|
|
|
81
180
|
protected override _loadChildren(resolve: (children: Tile[] | undefined) => void, reject: (error: Error) => void): void {
|
|
@@ -100,7 +199,12 @@ export class BatchedTile extends Tile {
|
|
|
100
199
|
}
|
|
101
200
|
|
|
102
201
|
public override get channel(): TileRequestChannel {
|
|
103
|
-
|
|
202
|
+
if (!channel) {
|
|
203
|
+
channel = new TileRequestChannel("itwinjs-batched-models", 20);
|
|
204
|
+
IModelApp.tileAdmin.channels.add(channel);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
return channel;
|
|
104
208
|
}
|
|
105
209
|
|
|
106
210
|
public override async requestContent(_isCanceled: () => boolean): Promise<TileRequest.Response> {
|
package/src/BatchedTileTree.ts
CHANGED
|
@@ -52,7 +52,7 @@ export class BatchedTileTree extends TileTree {
|
|
|
52
52
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
53
53
|
public override _selectTiles(args: TileDrawArgs): Tile[] {
|
|
54
54
|
const selected: BatchedTile[] = [];
|
|
55
|
-
this.rootTile.selectTiles(selected, args);
|
|
55
|
+
this.rootTile.selectTiles(selected, args, 0);
|
|
56
56
|
return selected;
|
|
57
57
|
}
|
|
58
58
|
|