@itwin/frontend-tiles 4.0.0-dev.86 → 4.0.0-dev.87

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.
Files changed (37) hide show
  1. package/.rush/temp/3b6a8eb84bbdb6161beaf8db2cf6e0fdfd460983.log +10 -0
  2. package/.rush/temp/operation/build/all.log +3 -3
  3. package/.rush/temp/operation/build/state.json +1 -1
  4. package/lib/cjs/BatchedSpatialTileTreeRefs.js.map +1 -1
  5. package/lib/cjs/BatchedTile.d.ts +3 -2
  6. package/lib/cjs/BatchedTile.d.ts.map +1 -1
  7. package/lib/cjs/BatchedTile.js +23 -106
  8. package/lib/cjs/BatchedTile.js.map +1 -1
  9. package/lib/cjs/BatchedTileContentReader.js.map +1 -1
  10. package/lib/cjs/BatchedTileTree.js +3 -3
  11. package/lib/cjs/BatchedTileTree.js.map +1 -1
  12. package/lib/cjs/BatchedTileTreeReference.js.map +1 -1
  13. package/lib/cjs/BatchedTileTreeSupplier.js.map +1 -1
  14. package/lib/cjs/BatchedTilesetReader.js.map +1 -1
  15. package/lib/cjs/FrontendTiles.js.map +1 -1
  16. package/lib/cjs/LoggerCategory.js.map +1 -1
  17. package/lib/cjs/frontend-tiles.js.map +1 -1
  18. package/lib/cjs/tsconfig.tsbuildinfo +1 -1
  19. package/lib/esm/BatchedSpatialTileTreeRefs.js.map +1 -1
  20. package/lib/esm/BatchedTile.d.ts +3 -2
  21. package/lib/esm/BatchedTile.d.ts.map +1 -1
  22. package/lib/esm/BatchedTile.js +24 -107
  23. package/lib/esm/BatchedTile.js.map +1 -1
  24. package/lib/esm/BatchedTileContentReader.js.map +1 -1
  25. package/lib/esm/BatchedTileTree.js +3 -3
  26. package/lib/esm/BatchedTileTree.js.map +1 -1
  27. package/lib/esm/BatchedTileTreeReference.js.map +1 -1
  28. package/lib/esm/BatchedTileTreeSupplier.js.map +1 -1
  29. package/lib/esm/BatchedTilesetReader.js.map +1 -1
  30. package/lib/esm/FrontendTiles.js.map +1 -1
  31. package/lib/esm/LoggerCategory.js.map +1 -1
  32. package/lib/esm/frontend-tiles.js.map +1 -1
  33. package/lib/esm/tsconfig.tsbuildinfo +1 -1
  34. package/package.json +10 -10
  35. package/src/BatchedTile.ts +28 -114
  36. package/src/BatchedTileTree.ts +3 -3
  37. package/.rush/temp/package-deps_build.json +0 -23
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/frontend-tiles",
3
- "version": "4.0.0-dev.86",
3
+ "version": "4.0.0-dev.87",
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",
@@ -23,17 +23,17 @@
23
23
  "url": "http://www.bentley.com"
24
24
  },
25
25
  "peerDependencies": {
26
- "@itwin/core-bentley": "4.0.0-dev.86",
27
- "@itwin/core-common": "4.0.0-dev.86",
28
- "@itwin/core-frontend": "4.0.0-dev.86",
29
- "@itwin/core-geometry": "4.0.0-dev.86"
26
+ "@itwin/core-bentley": "4.0.0-dev.87",
27
+ "@itwin/core-common": "4.0.0-dev.87",
28
+ "@itwin/core-frontend": "4.0.0-dev.87",
29
+ "@itwin/core-geometry": "4.0.0-dev.87"
30
30
  },
31
31
  "devDependencies": {
32
- "@itwin/build-tools": "4.0.0-dev.86",
33
- "@itwin/core-bentley": "4.0.0-dev.86",
34
- "@itwin/core-common": "4.0.0-dev.86",
35
- "@itwin/core-frontend": "4.0.0-dev.86",
36
- "@itwin/core-geometry": "4.0.0-dev.86",
32
+ "@itwin/build-tools": "4.0.0-dev.87",
33
+ "@itwin/core-bentley": "4.0.0-dev.87",
34
+ "@itwin/core-common": "4.0.0-dev.87",
35
+ "@itwin/core-frontend": "4.0.0-dev.87",
36
+ "@itwin/core-geometry": "4.0.0-dev.87",
37
37
  "@itwin/eslint-plugin": "^4.0.0-dev.33",
38
38
  "@types/node": "^18.11.5",
39
39
  "eslint": "^8.36.0",
@@ -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, SelectParent, Tile, TileBoundingBoxes, TileContent,
10
- TileDrawArgs, TileLoadStatus, TileParams, TileRequest, TileRequestChannel, TileTreeLoadStatus, TileUser, TileVisibility, Viewport,
9
+ GltfReaderProps, GraphicBuilder, ImdlReader, IModelApp, RealityTileLoader, RenderSystem, Tile, TileBoundingBoxes, TileContent,
10
+ TileDrawArgs, 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";
@@ -24,6 +24,7 @@ let channel: TileRequestChannel | undefined;
24
24
  /** @internal */
25
25
  export class BatchedTile extends Tile {
26
26
  private readonly _childrenProps?: Tileset3dSchema.Tile[];
27
+ private readonly _unskippable: boolean;
27
28
 
28
29
  public get batchedTree(): BatchedTileTree {
29
30
  return this.tree as BatchedTileTree;
@@ -31,6 +32,10 @@ export class BatchedTile extends Tile {
31
32
 
32
33
  public constructor(params: BatchedTileParams, tree: BatchedTileTree) {
33
34
  super(params, tree);
35
+
36
+ // The root tile never has content, so it doesn't count toward max levels to skip.
37
+ this._unskippable = 0 === (this.depth % getMaxLevelsToSkip());
38
+
34
39
  if (params.childrenProps?.length)
35
40
  this._childrenProps = params.childrenProps;
36
41
 
@@ -50,132 +55,40 @@ export class BatchedTile extends Tile {
50
55
  return RealityTileLoader.computeTileLocationPriority(this, viewports, this.tree.iModelTransform);
51
56
  }
52
57
 
53
- public selectTiles(selected: BatchedTile[], args: TileDrawArgs, numSkipped: number): SelectParent {
58
+ public selectTiles(selected: Set<BatchedTile>, args: TileDrawArgs, closestDisplayableAncestor: BatchedTile | undefined): void {
54
59
  const vis = this.computeVisibility(args);
55
60
  if (TileVisibility.OutsideFrustum === vis)
56
- return SelectParent.No;
57
-
58
- if (TileVisibility.Visible === vis) {
59
- // This tile is of appropriate resolution to draw. If need loading or refinement, enqueue.
60
- if (!this.isReady)
61
- args.insertMissing(this);
62
-
63
- if (this.hasGraphics) {
64
- // It can be drawn - select it
65
- args.markReady(this);
66
- selected.push(this);
67
- } else if (!this.isReady) {
68
- // It can't be drawn. Try to draw children in its place; otherwise draw the parent.
69
- // Do not load/request the children for this purpose.
70
- const initialSize = selected.length;
71
- const kids = this._batchedChildren;
72
- if (undefined === kids)
73
- return SelectParent.Yes;
74
-
75
- // Find any descendant to draw, until we exceed max initial tiles to skip.
76
- // if (this.depth < this.iModelTree.maxInitialTilesToSkip) {
77
- // for (const kid of kids) {
78
- // if (SelectParent.Yes === kid.selectTiles(selected, args, numSkipped)) {
79
- // selected.length = initialSize;
80
- // return SelectParent.Yes;
81
- // }
82
-
83
- // return SelectParent.No;
84
- // }
85
- // }
86
-
87
- // If all visible direct children can be drawn, draw them.
88
- for (const kid of kids) {
89
- if (TileVisibility.OutsideFrustum !== kid.computeVisibility(args)) {
90
- if (!kid.hasGraphics) {
91
- selected.length = initialSize;
92
- return SelectParent.Yes;
93
- } else {
94
- selected.push(kid);
95
- }
96
- }
97
- }
98
-
99
- args.markUsed(this);
100
- }
101
-
102
- // We're drawing either this tile, or its direct children.
103
- return SelectParent.No;
104
- }
105
-
106
- // This tile is too coarse to draw. Try to draw something more appropriate.
107
- // If it is not ready to draw, we may want to skip loading in favor of loading its descendants.
108
- // 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.
109
- const maximumLevelsToSkip = getMaxLevelsToSkip();
110
- let canSkipThisTile = (this._hadGraphics && !this.hasGraphics) /* || this.depth < this.iModelTree.maxInitialTilesToSkip */ ;
111
- if (canSkipThisTile) {
112
- numSkipped = 1;
113
- } else {
114
- canSkipThisTile = this.isReady || this.isParentDisplayable /* || this.depth < this.iModelTree.maxInitialTilesToSkip */ ;
115
- if (canSkipThisTile && this.isDisplayable) { // skipping an undisplayable tile doesn't count toward the maximum
116
- // Some tiles do not sub-divide - they only facet the same geometry to a higher resolution. We can skip directly to the correct resolution.
117
- const isNotReady = !this.isReady && !this.hasGraphics /* && !this.hasSizeMultiplier */ ;
118
- if (isNotReady) {
119
- if (numSkipped >= maximumLevelsToSkip)
120
- canSkipThisTile = false;
121
- else
122
- numSkipped += 1;
123
- }
124
- }
125
- }
61
+ return;
126
62
 
127
- const childrenLoadStatus = this.loadChildren(); // NB: asynchronous
128
- const children = canSkipThisTile ? this._batchedChildren : undefined;
129
- if (canSkipThisTile && TileTreeLoadStatus.Loading === childrenLoadStatus) {
130
- args.markChildrenLoading();
63
+ if (this._unskippable) {
64
+ // Prevent this tile's content from being unloaded due to memory pressure.
65
+ args.touchedTiles.add(this);
131
66
  args.markUsed(this);
132
67
  }
133
68
 
134
- if (undefined !== children) {
135
- // 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.
136
- // 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.
137
- const isUndisplayableRootTile = this.isUndisplayableRootTile;
69
+ closestDisplayableAncestor = this.hasGraphics ? this : closestDisplayableAncestor;
70
+ if (TileVisibility.TooCoarse === vis && (this.isReady || !this._unskippable)) {
138
71
  args.markUsed(this);
139
- let drawChildren = true;
140
- const initialSize = selected.length;
141
- for (const child of children) {
142
- // NB: We must continue iterating children so that they can be requested if missing.
143
- if (SelectParent.Yes === child.selectTiles(selected, args, numSkipped)) {
144
- if (child.loadStatus === TileLoadStatus.NotFound) {
145
- // At least one child we want to draw failed to load. e.g., we reached max depth of map tile tree. Draw parent instead.
146
- drawChildren = canSkipThisTile = false;
147
- } else {
148
- // 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.
149
- drawChildren = isUndisplayableRootTile;
150
- }
151
- }
152
- }
72
+ args.markReady(this);
73
+ const childrenLoadStatus = this.loadChildren();
74
+ if (TileTreeLoadStatus.Loading === childrenLoadStatus)
75
+ args.markChildrenLoading();
153
76
 
154
- if (drawChildren)
155
- return SelectParent.No;
77
+ const children = this._batchedChildren;
78
+ if (children) {
79
+ for (const child of children)
80
+ child.selectTiles(selected, args, closestDisplayableAncestor);
156
81
 
157
- // 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.
158
- if (args.parentsAndChildrenExclusive)
159
- selected.length = initialSize;
160
- }
161
-
162
- if (this.isReady) {
163
- if (this.hasGraphics) {
164
- selected.push(this);
165
- if (!canSkipThisTile) {
166
- // This tile is too coarse, but we require loading it before we can start loading higher-res children.
167
- args.markReady(this);
168
- }
82
+ return;
169
83
  }
170
-
171
- return SelectParent.No;
172
84
  }
173
85
 
174
- // This tile is not ready to be drawn. Request it *only* if we cannot skip it.
175
- if (!canSkipThisTile)
86
+ // We want to display this tile. Request its content if not already loaded.
87
+ if ((TileVisibility.Visible === vis || this._unskippable) && !this.isReady)
176
88
  args.insertMissing(this);
177
89
 
178
- return this.isParentDisplayable ? SelectParent.Yes : SelectParent.No;
90
+ if (closestDisplayableAncestor)
91
+ selected.add(closestDisplayableAncestor);
179
92
  }
180
93
 
181
94
  protected override _loadChildren(resolve: (children: Tile[] | undefined) => void, reject: (error: Error) => void): void {
@@ -225,6 +138,7 @@ export class BatchedTile extends Tile {
225
138
  iModel: this.tree.iModel,
226
139
  modelId: this.tree.modelId,
227
140
  is3d: true,
141
+ isLeaf: this.isLeaf,
228
142
  system,
229
143
  isCanceled: shouldAbort,
230
144
  options: {
@@ -51,9 +51,9 @@ export class BatchedTileTree extends TileTree {
51
51
 
52
52
  // eslint-disable-next-line @typescript-eslint/naming-convention
53
53
  public override _selectTiles(args: TileDrawArgs): Tile[] {
54
- const selected: BatchedTile[] = [];
55
- this.rootTile.selectTiles(selected, args, 0);
56
- return selected;
54
+ const selected = new Set<BatchedTile>();
55
+ this.rootTile.selectTiles(selected, args, undefined);
56
+ return Array.from(selected);
57
57
  }
58
58
 
59
59
  public override draw(args: TileDrawArgs): void {
@@ -1,23 +0,0 @@
1
- {
2
- "files": {
3
- "extensions/frontend-tiles/CHANGELOG.json": "a5b896a6c2f099210f946fe4b348923fb743ed24",
4
- "extensions/frontend-tiles/CHANGELOG.md": "2cb56e72bf39b6dd290d7f01227776bff12edeb6",
5
- "extensions/frontend-tiles/LICENSE.md": "77dfb5043040cc16a3611930daba56d86ef54334",
6
- "extensions/frontend-tiles/README.md": "4ea38e83e862cdfa6fab08adc92eb62bcb2fe238",
7
- "extensions/frontend-tiles/config/rush-project.json": "075dba097aa1ba473c368c262559aa10306afe68",
8
- "extensions/frontend-tiles/package.json": "3e8cee05376d32a66e290198e22d8ca9576685db",
9
- "extensions/frontend-tiles/src/BatchedSpatialTileTreeRefs.ts": "1bd92ba0d816eada104e1eb9ec1c198eb69d6842",
10
- "extensions/frontend-tiles/src/BatchedTile.ts": "5a65ba092f420eb9cd5ff2ee9ae2f80bb5b42945",
11
- "extensions/frontend-tiles/src/BatchedTileContentReader.ts": "7a1392a3e55882eedd68f0fb098db9009f190a3e",
12
- "extensions/frontend-tiles/src/BatchedTileTree.ts": "bc27ba7b54de36cfe58ce3ecd62c7795569d3509",
13
- "extensions/frontend-tiles/src/BatchedTileTreeReference.ts": "38e908b8193aef773fb6782142482378041ab923",
14
- "extensions/frontend-tiles/src/BatchedTileTreeSupplier.ts": "916587d978864b4f9595b560ee1bac3033a123f5",
15
- "extensions/frontend-tiles/src/BatchedTilesetReader.ts": "0cc90a58fc8f4cafab8c2bbdac6dc1186337b4f0",
16
- "extensions/frontend-tiles/src/FrontendTiles.ts": "576ca9d6b519e7c75187507f9243fa2b802787d8",
17
- "extensions/frontend-tiles/src/LoggerCategory.ts": "458e67157ea150f6bff37674320dfc8cf5886049",
18
- "extensions/frontend-tiles/src/frontend-tiles.ts": "2778da0ad9afc43273e7105641ef1213edc47a83",
19
- "extensions/frontend-tiles/tsconfig.json": "67be9deac4eea3b76c3e1a66b0e9004ed0f6255e",
20
- "extensions/frontend-tiles/.rush/temp/shrinkwrap-deps.json": "eb7572b17cd720bcebef5ea41c61d3fada733328"
21
- },
22
- "arguments": "npm run -s build:cjs && npm run -s build:esm "
23
- }