@loaders.gl/tiles 5.0.0-alpha.1 → 5.0.0-alpha.10
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/LICENSE +14 -3
- package/README.md +26 -0
- package/dist/dist.dev.js +20271 -5055
- package/dist/dist.min.js +3 -1
- package/dist/index.cjs +7849 -2081
- package/dist/index.cjs.map +3 -4
- package/dist/index.d.ts +25 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -1
- package/dist/point-cloud/point-cloud-tile.d.ts.map +1 -1
- package/dist/point-cloud/point-cloud-tile.js +3 -0
- package/dist/point-cloud/point-cloud-tile.js.map +1 -1
- package/dist/point-cloud/point-cloud-tileset.d.ts +4 -0
- package/dist/point-cloud/point-cloud-tileset.d.ts.map +1 -1
- package/dist/point-cloud/point-cloud-tileset.js +54 -12
- package/dist/point-cloud/point-cloud-tileset.js.map +1 -1
- package/dist/point-cloud/types.d.ts +17 -0
- package/dist/point-cloud/types.d.ts.map +1 -1
- package/dist/point-cloud/types.js +3 -0
- package/dist/point-cloud/types.js.map +1 -1
- package/dist/raster-set.d.ts +48 -31
- package/dist/raster-set.d.ts.map +1 -1
- package/dist/raster-set.js +104 -24
- package/dist/raster-set.js.map +1 -1
- package/dist/spatial/format-spatial-reference.d.ts +68 -0
- package/dist/spatial/format-spatial-reference.d.ts.map +1 -0
- package/dist/spatial/format-spatial-reference.js +291 -0
- package/dist/spatial/format-spatial-reference.js.map +1 -0
- package/dist/spatial/get-spatial-coordinate-frame.d.ts +20 -0
- package/dist/spatial/get-spatial-coordinate-frame.d.ts.map +1 -0
- package/dist/spatial/get-spatial-coordinate-frame.js +139 -0
- package/dist/spatial/get-spatial-coordinate-frame.js.map +1 -0
- package/dist/spatial/i3s-elevation.d.ts +20 -0
- package/dist/spatial/i3s-elevation.d.ts.map +1 -0
- package/dist/spatial/i3s-elevation.js +90 -0
- package/dist/spatial/i3s-elevation.js.map +1 -0
- package/dist/spatial/i3s-spatial-transformer.d.ts +189 -0
- package/dist/spatial/i3s-spatial-transformer.d.ts.map +1 -0
- package/dist/spatial/i3s-spatial-transformer.js +686 -0
- package/dist/spatial/i3s-spatial-transformer.js.map +1 -0
- package/dist/spatial/normalize-crs-identifier.d.ts +15 -0
- package/dist/spatial/normalize-crs-identifier.d.ts.map +1 -0
- package/dist/spatial/normalize-crs-identifier.js +22 -0
- package/dist/spatial/normalize-crs-identifier.js.map +1 -0
- package/dist/spatial/spatial-coordinate-transformer.d.ts +52 -0
- package/dist/spatial/spatial-coordinate-transformer.d.ts.map +1 -0
- package/dist/spatial/spatial-coordinate-transformer.js +295 -0
- package/dist/spatial/spatial-coordinate-transformer.js.map +1 -0
- package/dist/spatial/spatial-resource-registry.d.ts +44 -0
- package/dist/spatial/spatial-resource-registry.d.ts.map +1 -0
- package/dist/spatial/spatial-resource-registry.js +67 -0
- package/dist/spatial/spatial-resource-registry.js.map +1 -0
- package/dist/spatial/spatial-types.d.ts +190 -0
- package/dist/spatial/spatial-types.d.ts.map +1 -0
- package/dist/spatial/spatial-types.js +192 -0
- package/dist/spatial/spatial-types.js.map +1 -0
- package/dist/spatial/tiles-3d-spatial-transformer.d.ts +32 -0
- package/dist/spatial/tiles-3d-spatial-transformer.d.ts.map +1 -0
- package/dist/spatial/tiles-3d-spatial-transformer.js +175 -0
- package/dist/spatial/tiles-3d-spatial-transformer.js.map +1 -0
- package/dist/tileset-2d/adapter.d.ts +2 -3
- package/dist/tileset-2d/adapter.d.ts.map +1 -1
- package/dist/tileset-2d/tileset-2d.d.ts +2 -3
- package/dist/tileset-2d/tileset-2d.d.ts.map +1 -1
- package/dist/tileset-2d/tileset-2d.js.map +1 -1
- package/dist/tileset-3d/common/indexed-archive-tileset-source.d.ts +3 -3
- package/dist/tileset-3d/common/indexed-archive-tileset-source.d.ts.map +1 -1
- package/dist/tileset-3d/common/indexed-archive-tileset-source.js +9 -4
- package/dist/tileset-3d/common/indexed-archive-tileset-source.js.map +1 -1
- package/dist/tileset-3d/common/tile-3d-contracts.d.ts +63 -0
- package/dist/tileset-3d/common/tile-3d-contracts.d.ts.map +1 -0
- package/dist/tileset-3d/common/tile-3d-contracts.js +51 -0
- package/dist/tileset-3d/common/tile-3d-contracts.js.map +1 -0
- package/dist/tileset-3d/common/tile-3d.d.ts +176 -5
- package/dist/tileset-3d/common/tile-3d.d.ts.map +1 -1
- package/dist/tileset-3d/common/tile-3d.js +523 -89
- package/dist/tileset-3d/common/tile-3d.js.map +1 -1
- package/dist/tileset-3d/common/tileset-3d.d.ts +192 -9
- package/dist/tileset-3d/common/tileset-3d.d.ts.map +1 -1
- package/dist/tileset-3d/common/tileset-3d.js +303 -23
- package/dist/tileset-3d/common/tileset-3d.js.map +1 -1
- package/dist/tileset-3d/common/tileset-cache.d.ts +11 -1
- package/dist/tileset-3d/common/tileset-cache.d.ts.map +1 -1
- package/dist/tileset-3d/common/tileset-cache.js +11 -3
- package/dist/tileset-3d/common/tileset-cache.js.map +1 -1
- package/dist/tileset-3d/common/tileset-content-traversal.d.ts +37 -0
- package/dist/tileset-3d/common/tileset-content-traversal.d.ts.map +1 -0
- package/dist/tileset-3d/common/tileset-content-traversal.js +80 -0
- package/dist/tileset-3d/common/tileset-content-traversal.js.map +1 -0
- package/dist/tileset-3d/common/tileset-observability.d.ts +60 -0
- package/dist/tileset-3d/common/tileset-observability.d.ts.map +1 -0
- package/dist/tileset-3d/common/tileset-observability.js +39 -0
- package/dist/tileset-3d/common/tileset-observability.js.map +1 -0
- package/dist/tileset-3d/common/tileset-source.d.ts +51 -9
- package/dist/tileset-3d/common/tileset-source.d.ts.map +1 -1
- package/dist/tileset-3d/common/tileset-source.js.map +1 -1
- package/dist/tileset-3d/common/tileset-traverser.d.ts +33 -1
- package/dist/tileset-3d/common/tileset-traverser.d.ts.map +1 -1
- package/dist/tileset-3d/common/tileset-traverser.js +59 -11
- package/dist/tileset-3d/common/tileset-traverser.js.map +1 -1
- package/dist/tileset-3d/format-3d-tiles/implicit-tiling.d.ts +182 -0
- package/dist/tileset-3d/format-3d-tiles/implicit-tiling.d.ts.map +1 -0
- package/dist/tileset-3d/format-3d-tiles/implicit-tiling.js +681 -0
- package/dist/tileset-3d/format-3d-tiles/implicit-tiling.js.map +1 -0
- package/dist/tileset-3d/format-3d-tiles/tiles-3d-source.d.ts +127 -6
- package/dist/tileset-3d/format-3d-tiles/tiles-3d-source.d.ts.map +1 -1
- package/dist/tileset-3d/format-3d-tiles/tiles-3d-source.js +485 -27
- package/dist/tileset-3d/format-3d-tiles/tiles-3d-source.js.map +1 -1
- package/dist/tileset-3d/format-3d-tiles/tileset-3d-traverser.d.ts +103 -0
- package/dist/tileset-3d/format-3d-tiles/tileset-3d-traverser.d.ts.map +1 -1
- package/dist/tileset-3d/format-3d-tiles/tileset-3d-traverser.js +278 -0
- package/dist/tileset-3d/format-3d-tiles/tileset-3d-traverser.js.map +1 -1
- package/dist/tileset-3d/format-i3s/i3s-pending-tiles-register.d.ts.map +1 -1
- package/dist/tileset-3d/format-i3s/i3s-pending-tiles-register.js +3 -0
- package/dist/tileset-3d/format-i3s/i3s-pending-tiles-register.js.map +1 -1
- package/dist/tileset-3d/format-i3s/i3s-source.d.ts +23 -6
- package/dist/tileset-3d/format-i3s/i3s-source.d.ts.map +1 -1
- package/dist/tileset-3d/format-i3s/i3s-source.js +176 -25
- package/dist/tileset-3d/format-i3s/i3s-source.js.map +1 -1
- package/dist/tileset-3d/format-i3s/i3s-tile-manager.d.ts.map +1 -1
- package/dist/tileset-3d/format-i3s/i3s-tile-manager.js +3 -0
- package/dist/tileset-3d/format-i3s/i3s-tile-manager.js.map +1 -1
- package/dist/tileset-3d/format-i3s/i3s-tileset-traverser.d.ts.map +1 -1
- package/dist/tileset-3d/format-i3s/i3s-tileset-traverser.js +4 -1
- package/dist/tileset-3d/format-i3s/i3s-tileset-traverser.js.map +1 -1
- package/dist/tileset-3d/helpers/3d-tiles-options.d.ts.map +1 -1
- package/dist/tileset-3d/helpers/3d-tiles-options.js +3 -0
- package/dist/tileset-3d/helpers/3d-tiles-options.js.map +1 -1
- package/dist/tileset-3d/helpers/bounding-volume.d.ts +7 -3
- package/dist/tileset-3d/helpers/bounding-volume.d.ts.map +1 -1
- package/dist/tileset-3d/helpers/bounding-volume.js +20 -91
- package/dist/tileset-3d/helpers/bounding-volume.js.map +1 -1
- package/dist/tileset-3d/helpers/frame-state.d.ts +67 -2
- package/dist/tileset-3d/helpers/frame-state.d.ts.map +1 -1
- package/dist/tileset-3d/helpers/frame-state.js +92 -10
- package/dist/tileset-3d/helpers/frame-state.js.map +1 -1
- package/dist/tileset-3d/helpers/i3s-lod.d.ts.map +1 -1
- package/dist/tileset-3d/helpers/i3s-lod.js +20 -8
- package/dist/tileset-3d/helpers/i3s-lod.js.map +1 -1
- package/dist/tileset-3d/helpers/s2-bounding-volume.d.ts +17 -0
- package/dist/tileset-3d/helpers/s2-bounding-volume.d.ts.map +1 -0
- package/dist/tileset-3d/helpers/s2-bounding-volume.js +20 -0
- package/dist/tileset-3d/helpers/s2-bounding-volume.js.map +1 -0
- package/dist/tileset-3d/helpers/tiles-3d-lod.d.ts +61 -9
- package/dist/tileset-3d/helpers/tiles-3d-lod.d.ts.map +1 -1
- package/dist/tileset-3d/helpers/tiles-3d-lod.js +198 -93
- package/dist/tileset-3d/helpers/tiles-3d-lod.js.map +1 -1
- package/dist/tileset-3d/helpers/tiles-3d-request-priority.d.ts +134 -0
- package/dist/tileset-3d/helpers/tiles-3d-request-priority.d.ts.map +1 -0
- package/dist/tileset-3d/helpers/tiles-3d-request-priority.js +179 -0
- package/dist/tileset-3d/helpers/tiles-3d-request-priority.js.map +1 -0
- package/dist/types.d.ts +7 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -1
- package/dist/utils/doubly-linked-list.d.ts.map +1 -1
- package/dist/utils/doubly-linked-list.js +1 -0
- package/dist/utils/doubly-linked-list.js.map +1 -1
- package/dist/utils/managed-array.d.ts.map +1 -1
- package/dist/utils/managed-array.js +1 -0
- package/dist/utils/managed-array.js.map +1 -1
- package/package.json +12 -10
- package/src/index.ts +78 -1
- package/src/point-cloud/point-cloud-tile.ts +4 -0
- package/src/point-cloud/point-cloud-tileset.ts +70 -12
- package/src/point-cloud/types.ts +21 -0
- package/src/raster-set.ts +197 -67
- package/src/spatial/format-spatial-reference.ts +385 -0
- package/src/spatial/get-spatial-coordinate-frame.ts +169 -0
- package/src/spatial/i3s-elevation.ts +96 -0
- package/src/spatial/i3s-spatial-transformer.ts +957 -0
- package/src/spatial/normalize-crs-identifier.ts +26 -0
- package/src/spatial/spatial-coordinate-transformer.ts +376 -0
- package/src/spatial/spatial-resource-registry.ts +79 -0
- package/src/spatial/spatial-types.ts +422 -0
- package/src/spatial/tiles-3d-spatial-transformer.ts +206 -0
- package/src/tileset-2d/adapter.ts +2 -3
- package/src/tileset-2d/tileset-2d.ts +2 -3
- package/src/tileset-3d/common/indexed-archive-tileset-source.ts +13 -13
- package/src/tileset-3d/common/tile-3d-contracts.ts +115 -0
- package/src/tileset-3d/common/tile-3d.ts +629 -98
- package/src/tileset-3d/common/tileset-3d.ts +459 -29
- package/src/tileset-3d/common/tileset-cache.ts +15 -7
- package/src/tileset-3d/common/tileset-content-traversal.ts +114 -0
- package/src/tileset-3d/common/tileset-observability.ts +100 -0
- package/src/tileset-3d/common/tileset-source.ts +63 -13
- package/src/tileset-3d/common/tileset-traverser.ts +71 -11
- package/src/tileset-3d/format-3d-tiles/implicit-tiling.ts +1059 -0
- package/src/tileset-3d/format-3d-tiles/tiles-3d-source.ts +674 -28
- package/src/tileset-3d/format-3d-tiles/tileset-3d-traverser.ts +316 -0
- package/src/tileset-3d/format-i3s/i3s-pending-tiles-register.ts +4 -0
- package/src/tileset-3d/format-i3s/i3s-source.ts +220 -29
- package/src/tileset-3d/format-i3s/i3s-tile-manager.ts +4 -0
- package/src/tileset-3d/format-i3s/i3s-tileset-traverser.ts +6 -1
- package/src/tileset-3d/helpers/3d-tiles-options.ts +4 -0
- package/src/tileset-3d/helpers/bounding-volume.ts +31 -114
- package/src/tileset-3d/helpers/frame-state.ts +152 -13
- package/src/tileset-3d/helpers/i3s-lod.ts +22 -8
- package/src/tileset-3d/helpers/s2-bounding-volume.ts +35 -0
- package/src/tileset-3d/helpers/tiles-3d-lod.ts +291 -112
- package/src/tileset-3d/helpers/tiles-3d-request-priority.ts +301 -0
- package/src/types.ts +11 -0
- package/src/utils/doubly-linked-list.ts +2 -0
- package/src/utils/managed-array.ts +2 -0
|
@@ -5,12 +5,65 @@
|
|
|
5
5
|
// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
|
|
6
6
|
import { Vector3, Matrix4 } from '@math.gl/core';
|
|
7
7
|
import { CullingVolume } from '@math.gl/culling';
|
|
8
|
+
import { getTile3DFeatureIdSets } from "./tile-3d-contracts.js";
|
|
8
9
|
import { LOD_METRIC_TYPE, TILE_REFINEMENT, TILE_CONTENT_STATE, TILESET_TYPE } from "../../constants.js";
|
|
9
10
|
import { createBoundingVolume, getCartographicBounds } from "../helpers/bounding-volume.js";
|
|
10
11
|
import { getTiles3DScreenSpaceError } from "../helpers/tiles-3d-lod.js";
|
|
11
12
|
import { getProjectedRadius } from "../helpers/i3s-lod.js";
|
|
12
13
|
import { TilesetTraverser } from "./tileset-traverser.js";
|
|
14
|
+
import { calculateFoveatedFactor, calculateTileRequestPriority, isFoveatedRequestDelayActive, isFoveatedRequestDeferred, isProgressiveResolutionPriority } from "../helpers/tiles-3d-request-priority.js";
|
|
13
15
|
const scratchVector = new Vector3();
|
|
16
|
+
/**
|
|
17
|
+
* Classifies render-content visibility across all content volumes owned by a tile.
|
|
18
|
+
*
|
|
19
|
+
* Content volumes form a union: one visible content entry keeps the tile renderable even when
|
|
20
|
+
* another entry is outside the frustum or clipping planes. The traversal volume is intentionally
|
|
21
|
+
* not used here except as a fallback when a tile has no content-specific volume. This separation
|
|
22
|
+
* keeps clipping render-only and prevents a tight content volume from pruning descendants.
|
|
23
|
+
*
|
|
24
|
+
* @param contentVolumes - Transformed content volumes in source order.
|
|
25
|
+
* @param fallbackVolume - Tile volume used when content does not declare its own volume.
|
|
26
|
+
* @param cullingVolume - Current view frustum.
|
|
27
|
+
* @param visibilityPlaneMask - Parent visibility mask optimization.
|
|
28
|
+
* @param clippingPlanes - Optional world-space planes applied to render content only.
|
|
29
|
+
* @returns Union visibility classification for the renderable content.
|
|
30
|
+
*/
|
|
31
|
+
export function getContentVisibility(contentVolumes, fallbackVolume, cullingVolume, visibilityPlaneMask, clippingPlanes = []) {
|
|
32
|
+
const volumes = contentVolumes.length ? contentVolumes : [fallbackVolume];
|
|
33
|
+
let visibleVolume = false;
|
|
34
|
+
let intersectingVolume = false;
|
|
35
|
+
for (const contentVolume of volumes) {
|
|
36
|
+
let visibility = 'inside';
|
|
37
|
+
if (visibilityPlaneMask !== CullingVolume.MASK_INSIDE) {
|
|
38
|
+
visibility = cullingVolume.computeVisibility(contentVolume);
|
|
39
|
+
if (visibility === 'outside') {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
let clipped = false;
|
|
44
|
+
for (const clippingPlane of clippingPlanes) {
|
|
45
|
+
if (contentVolume.intersectPlane(clippingPlane) === 'outside') {
|
|
46
|
+
clipped = true;
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (!clipped) {
|
|
51
|
+
visibleVolume = true;
|
|
52
|
+
intersectingVolume = intersectingVolume || visibility === 'intersecting';
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (!visibleVolume) {
|
|
56
|
+
return 'outside';
|
|
57
|
+
}
|
|
58
|
+
return intersectingVolume ? 'intersecting' : 'inside';
|
|
59
|
+
}
|
|
60
|
+
function isNestedTilesetPayload(payload) {
|
|
61
|
+
if (!payload || typeof payload !== 'object') {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
const record = payload;
|
|
65
|
+
return record.shape === 'tileset3d' || record.type === 'tileset3d' || Boolean(record.tileset);
|
|
66
|
+
}
|
|
14
67
|
function defined(x) {
|
|
15
68
|
return x !== undefined && x !== null;
|
|
16
69
|
}
|
|
@@ -29,6 +82,8 @@ export class Tile3D {
|
|
|
29
82
|
refine;
|
|
30
83
|
type;
|
|
31
84
|
contentUrl;
|
|
85
|
+
/** Resolved render-content URLs in source order; empty for contentless tiles. */
|
|
86
|
+
contentUrls = [];
|
|
32
87
|
/** Different refinement algorithms used by I3S and 3D tiles */
|
|
33
88
|
lodMetricType = 'geometricError';
|
|
34
89
|
/**
|
|
@@ -41,6 +96,8 @@ export class Tile3D {
|
|
|
41
96
|
* separate ensures transform updates never compound an already-scaled geometric error.
|
|
42
97
|
*/
|
|
43
98
|
_unscaledLodMetricValue = 0;
|
|
99
|
+
/** Whether the source format defines geometric error in transform-local units. */
|
|
100
|
+
_scaleGeometricError = true;
|
|
44
101
|
/** @todo math.gl is not exporting BoundingVolume base type? */
|
|
45
102
|
boundingVolume = null;
|
|
46
103
|
/**
|
|
@@ -48,10 +105,31 @@ export class Tile3D {
|
|
|
48
105
|
* not the content's metadata in the tileset JSON file.
|
|
49
106
|
*/
|
|
50
107
|
content = null;
|
|
108
|
+
/** Loaded payloads in the same order as {@link contentUrls}; `content` remains the primary payload. */
|
|
109
|
+
contents = [];
|
|
110
|
+
/** Ordered renderer-neutral descriptors for each source content entry. */
|
|
111
|
+
contentEntries = [];
|
|
112
|
+
/** Raw metadata references inherited by this tile and its content. */
|
|
113
|
+
metadataContext = {};
|
|
114
|
+
/** Feature-id declarations normalized from supported content extensions. */
|
|
115
|
+
featureIdSets = [];
|
|
116
|
+
/** Decoded 3D Tiles vector topology for the primary loaded content, when present. */
|
|
117
|
+
vectorContent = null;
|
|
118
|
+
/**
|
|
119
|
+
* Metadata entity attached to this tile in the source tileset, if present.
|
|
120
|
+
*
|
|
121
|
+
* This is the raw 3D Tiles metadata reference. The generic tiles runtime preserves it without
|
|
122
|
+
* decoding schema classes or binary property tables.
|
|
123
|
+
*/
|
|
124
|
+
metadata = null;
|
|
125
|
+
/** Raw metadata entities attached to tile contents, in content source order. */
|
|
126
|
+
contentMetadata = [];
|
|
51
127
|
contentState = TILE_CONTENT_STATE.UNLOADED;
|
|
52
128
|
gpuMemoryUsageInBytes = 0;
|
|
53
129
|
/** The tile's children - an array of Tile3D objects. */
|
|
54
130
|
children = [];
|
|
131
|
+
/** Current lifecycle state for a lazy implicit subtree rooted at this tile. */
|
|
132
|
+
childrenState = 'ready';
|
|
55
133
|
depth = 0;
|
|
56
134
|
viewportIds = [];
|
|
57
135
|
transform = new Matrix4();
|
|
@@ -70,14 +148,40 @@ export class Tile3D {
|
|
|
70
148
|
// TODO Cesium 3d tiles specific
|
|
71
149
|
_expireDate = null;
|
|
72
150
|
_expiredContent = null;
|
|
151
|
+
/** In-flight source request shared by repeated traversal frames. */
|
|
152
|
+
_childrenPromise = null;
|
|
73
153
|
_boundingBox = undefined;
|
|
74
154
|
/** updated every frame for tree traversal and rendering optimizations: */
|
|
75
155
|
_distanceToCamera = 0;
|
|
76
156
|
_screenSpaceError = 0;
|
|
157
|
+
/** SSE calculated at the reduced viewport height used to prioritize coarse coverage. */
|
|
158
|
+
_screenSpaceErrorProgressiveResolution = 0;
|
|
159
|
+
/** Whether this tile should be promoted into the progressive-resolution request pass. */
|
|
160
|
+
_priorityProgressiveResolution = false;
|
|
161
|
+
/** Angular distance from the camera view axis used to prioritize center tiles. */
|
|
162
|
+
_foveatedFactor = 0;
|
|
163
|
+
/** Whether this peripheral request is currently inside the camera-motion deferral window. */
|
|
164
|
+
priorityDeferred = false;
|
|
77
165
|
_visibilityPlaneMask;
|
|
78
166
|
_visible = undefined;
|
|
79
167
|
_contentBoundingVolume;
|
|
168
|
+
_contentBoundingVolumes = [];
|
|
169
|
+
/** Source content-volume headers retained after render content is unloaded. */
|
|
170
|
+
_contentBoundingVolumeHeaders = [];
|
|
80
171
|
_viewerRequestVolume;
|
|
172
|
+
/** Bounding volume used to cull the tile's first renderable content entry. */
|
|
173
|
+
get contentBoundingVolume() {
|
|
174
|
+
return this._contentBoundingVolume;
|
|
175
|
+
}
|
|
176
|
+
/** All transformed render-content bounding volumes, including tile-volume fallbacks. */
|
|
177
|
+
get contentBoundingVolumes() {
|
|
178
|
+
return this._contentBoundingVolumes;
|
|
179
|
+
}
|
|
180
|
+
/** Bounding volume that limits when this tile may be requested, when declared. */
|
|
181
|
+
get viewerRequestVolume() {
|
|
182
|
+
return this._viewerRequestVolume;
|
|
183
|
+
}
|
|
184
|
+
/** Accumulated tile transforms from the source JSON, excluding the tileset model matrix. */
|
|
81
185
|
_initialTransform = new Matrix4();
|
|
82
186
|
// Used by traverser, cannot be marked private
|
|
83
187
|
_priority = 0;
|
|
@@ -122,11 +226,15 @@ export class Tile3D {
|
|
|
122
226
|
this.refine = this._getRefine(header.refine);
|
|
123
227
|
this.type = header.type;
|
|
124
228
|
this.contentUrl = header.contentUrl;
|
|
229
|
+
this.contentUrls = header.contentUrls || (header.contentUrl ? [header.contentUrl] : []);
|
|
230
|
+
this._initializeMetadata(header);
|
|
231
|
+
this.childrenState = header.implicitSubtree ? 'unloaded' : 'ready';
|
|
125
232
|
this._initializeLodMetric(header);
|
|
126
233
|
this._initializeTransforms(header);
|
|
127
234
|
this._updateLodMetricScale();
|
|
128
235
|
this._initializeBoundingVolumes(header);
|
|
129
236
|
this._initializeContent(header);
|
|
237
|
+
this._initializeContentEntries(header);
|
|
130
238
|
this._initializeRenderingState(header);
|
|
131
239
|
Object.seal(this);
|
|
132
240
|
}
|
|
@@ -151,7 +259,18 @@ export class Tile3D {
|
|
|
151
259
|
}
|
|
152
260
|
/** Returns true if tile has children */
|
|
153
261
|
get hasChildren() {
|
|
154
|
-
return this.children.length > 0 ||
|
|
262
|
+
return (this.children.length > 0 ||
|
|
263
|
+
(this.header.children && this.header.children.length > 0) ||
|
|
264
|
+
Boolean(this.header.implicitSubtree && this.childrenState !== 'ready'));
|
|
265
|
+
}
|
|
266
|
+
/** Returns whether traversal may request an unresolved lazy child-header group. */
|
|
267
|
+
get hasUnloadedChildren() {
|
|
268
|
+
return Boolean(this.header.implicitSubtree &&
|
|
269
|
+
(this.childrenState === 'unloaded' || this.childrenState === 'failed'));
|
|
270
|
+
}
|
|
271
|
+
/** Returns whether a lazy child-header request is currently in flight. */
|
|
272
|
+
get childrenLoading() {
|
|
273
|
+
return this.childrenState === 'loading';
|
|
155
274
|
}
|
|
156
275
|
/**
|
|
157
276
|
* Determines if the tile's content is ready. This is automatically `true` for
|
|
@@ -203,22 +322,32 @@ export class Tile3D {
|
|
|
203
322
|
return this._screenSpaceError;
|
|
204
323
|
}
|
|
205
324
|
/**
|
|
206
|
-
* Get bounding
|
|
325
|
+
* Get the current world-space bounding volume in cartographic coordinates.
|
|
207
326
|
* @returns [min, max] each in [longitude, latitude, altitude]
|
|
208
327
|
*/
|
|
209
328
|
get boundingBox() {
|
|
210
329
|
if (!this._boundingBox) {
|
|
211
|
-
this._boundingBox = getCartographicBounds(this.header.boundingVolume, this.boundingVolume);
|
|
330
|
+
this._boundingBox = getCartographicBounds(this.header.boundingVolume, this.boundingVolume, !this.computedTransform.equals(this._initialTransform));
|
|
212
331
|
}
|
|
213
332
|
return this._boundingBox;
|
|
214
333
|
}
|
|
215
|
-
/**
|
|
216
|
-
|
|
334
|
+
/**
|
|
335
|
+
* Gets the tile's screen-space error for normal refinement or a reduced-height priority pass.
|
|
336
|
+
*
|
|
337
|
+
* I3S already supplies a screen-oriented LOD metric and intentionally ignores the optional 3D
|
|
338
|
+
* Tiles progressive-resolution height fraction.
|
|
339
|
+
*
|
|
340
|
+
* @param frameState - Current camera and viewport measurements.
|
|
341
|
+
* @param useParentLodMetric - Whether to substitute the parent LOD metric.
|
|
342
|
+
* @param viewportHeightFraction - Fraction of viewport height represented by the priority pass.
|
|
343
|
+
* @returns Screen-space LOD error for the current tileset format.
|
|
344
|
+
*/
|
|
345
|
+
getScreenSpaceError(frameState, useParentLodMetric, viewportHeightFraction = 1) {
|
|
217
346
|
switch (this.tileset.type) {
|
|
218
347
|
case TILESET_TYPE.I3S:
|
|
219
348
|
return getProjectedRadius(this, frameState);
|
|
220
349
|
case TILESET_TYPE.TILES3D:
|
|
221
|
-
return getTiles3DScreenSpaceError(this, frameState, useParentLodMetric);
|
|
350
|
+
return getTiles3DScreenSpaceError(this, frameState, useParentLodMetric, viewportHeightFraction);
|
|
222
351
|
default:
|
|
223
352
|
// eslint-disable-next-line
|
|
224
353
|
throw new Error('Unsupported tileset type');
|
|
@@ -235,16 +364,39 @@ export class Tile3D {
|
|
|
235
364
|
* Memory usage of tile on GPU
|
|
236
365
|
*/
|
|
237
366
|
_getGpuMemoryUsageInBytes() {
|
|
238
|
-
|
|
367
|
+
const contents = this.contents.length ? this.contents : [this.content];
|
|
368
|
+
return contents.reduce((total, content) => total + (content?.gpuMemoryUsageInBytes || content?.byteLength || 0), 0);
|
|
239
369
|
}
|
|
240
|
-
|
|
241
|
-
*
|
|
242
|
-
*
|
|
370
|
+
/**
|
|
371
|
+
* Returns scheduler priority for render-content requests.
|
|
372
|
+
*
|
|
373
|
+
* @returns Numeric priority, or a negative value when the queued request should be cancelled.
|
|
243
374
|
*/
|
|
244
|
-
// eslint-disable-next-line complexity
|
|
245
375
|
_getPriority() {
|
|
376
|
+
return this._calculateRequestPriority(false);
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* Returns scheduler priority for lazy child-header requests.
|
|
380
|
+
*
|
|
381
|
+
* Contentless implicit placeholders intentionally retain `UNLOADED` content state, so metadata
|
|
382
|
+
* scheduling skips only that render-content cancellation check and preserves every visibility,
|
|
383
|
+
* recency, progressive, foveated, and motion-deferral rule.
|
|
384
|
+
*
|
|
385
|
+
* @returns Numeric priority, or a negative value when the queued request should be cancelled.
|
|
386
|
+
*/
|
|
387
|
+
_getChildrenPriority() {
|
|
388
|
+
return this._calculateRequestPriority(true);
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Calculates the common scheduler priority for content or hierarchy metadata.
|
|
392
|
+
*
|
|
393
|
+
* @param allowUnloadedContent - Whether an empty placeholder may request child metadata.
|
|
394
|
+
* @returns Numeric priority, or a negative value when the queued request should be cancelled.
|
|
395
|
+
*/
|
|
396
|
+
// eslint-disable-next-line complexity
|
|
397
|
+
_calculateRequestPriority(allowUnloadedContent) {
|
|
246
398
|
const traverser = this.tileset._traverser;
|
|
247
|
-
const
|
|
399
|
+
const skipLevelOfDetail = traverser.options.skipLevelOfDetail && !traverser.disableSkipLevelOfDetail;
|
|
248
400
|
/*
|
|
249
401
|
* Tiles that are outside of the camera's frustum could be skipped if we are in 'ADD' mode
|
|
250
402
|
* or if we are using 'Skip Traversal' in 'REPLACE' mode.
|
|
@@ -260,7 +412,13 @@ export class Tile3D {
|
|
|
260
412
|
if (this.tileset._frameNumber - this._touchedFrame >= 1) {
|
|
261
413
|
return -1;
|
|
262
414
|
}
|
|
263
|
-
|
|
415
|
+
// RequestScheduler re-evaluates this callback before a queued request receives a slot. A
|
|
416
|
+
// negative priority cancels work that became deferred after it was queued; the scheduled
|
|
417
|
+
// follow-up traversal submits it again after the motion delay expires.
|
|
418
|
+
if (this.priorityDeferred) {
|
|
419
|
+
return -1;
|
|
420
|
+
}
|
|
421
|
+
if (!allowUnloadedContent && this.contentState === TILE_CONTENT_STATE.UNLOADED) {
|
|
264
422
|
return -1;
|
|
265
423
|
}
|
|
266
424
|
// Based on the priority function `getPriorityReverseScreenSpaceError` in CesiumJS. Scheduling priority is based on the parent's screen space error when possible.
|
|
@@ -270,8 +428,15 @@ export class Tile3D {
|
|
|
270
428
|
? parent._screenSpaceError
|
|
271
429
|
: this._screenSpaceError;
|
|
272
430
|
const rootScreenSpaceError = traverser.root ? traverser.root._screenSpaceError : 0.0;
|
|
273
|
-
// Map higher SSE to lower values (e.g. root tile is highest priority)
|
|
274
|
-
|
|
431
|
+
// Map higher SSE to lower values (e.g. root tile is highest priority), then combine the
|
|
432
|
+
// existing order with independent progressive and foveated priority bands.
|
|
433
|
+
const reverseScreenSpaceError = Math.max(rootScreenSpaceError - screenSpaceError, 0);
|
|
434
|
+
return calculateTileRequestPriority({
|
|
435
|
+
priorityProgressiveResolution: this._priorityProgressiveResolution,
|
|
436
|
+
foveatedFactor: this._foveatedFactor,
|
|
437
|
+
reverseScreenSpaceError,
|
|
438
|
+
rootScreenSpaceError
|
|
439
|
+
});
|
|
275
440
|
}
|
|
276
441
|
/**
|
|
277
442
|
* Requests the tile's content.
|
|
@@ -297,13 +462,7 @@ export class Tile3D {
|
|
|
297
462
|
return { loaded: false };
|
|
298
463
|
}
|
|
299
464
|
try {
|
|
300
|
-
|
|
301
|
-
if (this.tileset.options.contentLoader) {
|
|
302
|
-
await this.tileset.options.contentLoader(this);
|
|
303
|
-
}
|
|
304
|
-
this.contentState = TILE_CONTENT_STATE.READY;
|
|
305
|
-
this._onContentLoaded();
|
|
306
|
-
return loadResult;
|
|
465
|
+
return await this._loadContentFromSource();
|
|
307
466
|
}
|
|
308
467
|
catch (error) {
|
|
309
468
|
// Tile is unloaded before the content finishes loading
|
|
@@ -314,12 +473,235 @@ export class Tile3D {
|
|
|
314
473
|
requestToken.done();
|
|
315
474
|
}
|
|
316
475
|
}
|
|
476
|
+
/** Loads content for complete dataset operations without viewport-based request priority. */
|
|
477
|
+
async loadContentForTraversal() {
|
|
478
|
+
if (this.hasEmptyContent) {
|
|
479
|
+
return { loaded: false };
|
|
480
|
+
}
|
|
481
|
+
if (this.content) {
|
|
482
|
+
return { loaded: true, contents: this.contents };
|
|
483
|
+
}
|
|
484
|
+
this.contentState = TILE_CONTENT_STATE.LOADING;
|
|
485
|
+
try {
|
|
486
|
+
return await this._loadContentFromSource();
|
|
487
|
+
}
|
|
488
|
+
catch (error) {
|
|
489
|
+
this.contentState = TILE_CONTENT_STATE.FAILED;
|
|
490
|
+
throw error;
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
/** Loads source content and updates the tile's renderer-neutral payload state. */
|
|
494
|
+
async _loadContentFromSource() {
|
|
495
|
+
const loadResult = await this.tileset.source.loadTileContent(this);
|
|
496
|
+
if (loadResult.contents) {
|
|
497
|
+
this.contents = loadResult.contents;
|
|
498
|
+
this.content = this.contents[0] || null;
|
|
499
|
+
}
|
|
500
|
+
this.vectorContent =
|
|
501
|
+
this.contents.find(content => Boolean(content?.vectorContent))?.vectorContent || null;
|
|
502
|
+
if (this.tileset.options.contentLoader) {
|
|
503
|
+
await this.tileset.options.contentLoader(this);
|
|
504
|
+
}
|
|
505
|
+
this.contentState = TILE_CONTENT_STATE.READY;
|
|
506
|
+
this._onContentLoaded();
|
|
507
|
+
this._updateContentEntriesAfterLoad(loadResult);
|
|
508
|
+
return loadResult;
|
|
509
|
+
}
|
|
510
|
+
/**
|
|
511
|
+
* Requests and installs this tile's lazy child-header group through its source.
|
|
512
|
+
*
|
|
513
|
+
* The same request scheduler and SSE/foveated priority value used for render content are reused
|
|
514
|
+
* for subtree metadata. Repeated traversal frames share one promise, and scheduler cancellation
|
|
515
|
+
* restores the unloaded state so a later frame can retry.
|
|
516
|
+
*
|
|
517
|
+
* @param frameState - View state that made the subtree eligible for refinement.
|
|
518
|
+
* @returns Source load result, or an unloaded result if scheduling was cancelled.
|
|
519
|
+
*/
|
|
520
|
+
async loadChildren(frameState) {
|
|
521
|
+
if (!this.header.implicitSubtree || this.childrenState === 'ready') {
|
|
522
|
+
return { loaded: false, tileCount: 0, childSubtreeCount: 0 };
|
|
523
|
+
}
|
|
524
|
+
if (this._childrenPromise) {
|
|
525
|
+
return await this._childrenPromise;
|
|
526
|
+
}
|
|
527
|
+
if (!this.tileset.source.loadTileChildren) {
|
|
528
|
+
throw new Error('Tileset source does not support lazy tile children');
|
|
529
|
+
}
|
|
530
|
+
this.childrenState = 'loading';
|
|
531
|
+
this._childrenPromise = this._loadChildrenWithScheduler(frameState);
|
|
532
|
+
try {
|
|
533
|
+
return await this._childrenPromise;
|
|
534
|
+
}
|
|
535
|
+
finally {
|
|
536
|
+
this._childrenPromise = null;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* Runs one lazy child-header load after obtaining a scheduler token.
|
|
541
|
+
*
|
|
542
|
+
* @param frameState - View state forwarded to the source implementation.
|
|
543
|
+
* @returns Source load result.
|
|
544
|
+
*/
|
|
545
|
+
async _loadChildrenWithScheduler(frameState) {
|
|
546
|
+
const requestToken = await this.tileset._requestScheduler.scheduleRequest(`${this.id}:implicit-subtree`, this._getChildrenPriority.bind(this));
|
|
547
|
+
if (!requestToken) {
|
|
548
|
+
this.childrenState = 'unloaded';
|
|
549
|
+
return { loaded: false, tileCount: 0, childSubtreeCount: 0 };
|
|
550
|
+
}
|
|
551
|
+
try {
|
|
552
|
+
const loadResult = await this.tileset.source.loadTileChildren(this, frameState);
|
|
553
|
+
this.childrenState = loadResult.loaded ? 'ready' : 'unloaded';
|
|
554
|
+
return loadResult;
|
|
555
|
+
}
|
|
556
|
+
catch (error) {
|
|
557
|
+
this.childrenState = 'failed';
|
|
558
|
+
throw error;
|
|
559
|
+
}
|
|
560
|
+
finally {
|
|
561
|
+
requestToken.done();
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* Replaces a contentless implicit placeholder with its materialized subtree-root header.
|
|
566
|
+
*
|
|
567
|
+
* The placeholder transform is preserved when the subtree omits a root transform. An explicit
|
|
568
|
+
* subtree-root transform replaces it and is recomposed against the runtime parent. Content,
|
|
569
|
+
* metadata, bounds, and raw geometric error are reinitialized from the available header.
|
|
570
|
+
*
|
|
571
|
+
* @param materializedHeader - Available root header produced from one subtree resource.
|
|
572
|
+
*/
|
|
573
|
+
applyImplicitSubtreeHeader(materializedHeader) {
|
|
574
|
+
const existingTransform = this.header.transform;
|
|
575
|
+
const existingTransformMatrix = this.header.transformMatrix;
|
|
576
|
+
const hasMaterializedTransform = materializedHeader.transform !== undefined;
|
|
577
|
+
this.header = {
|
|
578
|
+
...this.header,
|
|
579
|
+
...materializedHeader,
|
|
580
|
+
transform: hasMaterializedTransform ? materializedHeader.transform : existingTransform,
|
|
581
|
+
transformMatrix: hasMaterializedTransform
|
|
582
|
+
? materializedHeader.transformMatrix
|
|
583
|
+
: existingTransformMatrix,
|
|
584
|
+
implicitSubtree: undefined
|
|
585
|
+
};
|
|
586
|
+
if (hasMaterializedTransform) {
|
|
587
|
+
this._initializeTransforms(this.header);
|
|
588
|
+
}
|
|
589
|
+
this.refine = this._getRefine(materializedHeader.refine);
|
|
590
|
+
this.type = materializedHeader.type;
|
|
591
|
+
this.contentUrl = materializedHeader.contentUrl;
|
|
592
|
+
this.contentUrls =
|
|
593
|
+
materializedHeader.contentUrls ||
|
|
594
|
+
(materializedHeader.contentUrl ? [materializedHeader.contentUrl] : []);
|
|
595
|
+
this._initializeMetadata(this.header);
|
|
596
|
+
this._initializeLodMetric(materializedHeader);
|
|
597
|
+
this._updateLodMetricScale();
|
|
598
|
+
this._initializeBoundingVolumes(this.header);
|
|
599
|
+
this._boundingBox = undefined;
|
|
600
|
+
// Use the merged header so inherited viewer-request-volume metadata remains available when a
|
|
601
|
+
// materialized implicit tile has no render content of its own.
|
|
602
|
+
this._initializeContent(this.header);
|
|
603
|
+
this._initializeContentEntries(this.header);
|
|
604
|
+
}
|
|
605
|
+
/** Refreshes tile and content metadata from a source or materialized tile header. */
|
|
606
|
+
_initializeMetadata(header) {
|
|
607
|
+
this.metadata = header.metadata || null;
|
|
608
|
+
const contentHeaders = Array.isArray(header.content) ? header.content : [header.content];
|
|
609
|
+
this.contentMetadata = contentHeaders
|
|
610
|
+
.filter(Boolean)
|
|
611
|
+
.map(contentHeader => contentHeader.metadata || null);
|
|
612
|
+
const firstContentHeader = contentHeaders.find(Boolean) || {};
|
|
613
|
+
const groupReference = firstContentHeader.group;
|
|
614
|
+
const group = typeof groupReference === 'number'
|
|
615
|
+
? this.tileset.groups?.[groupReference] || null
|
|
616
|
+
: groupReference || null;
|
|
617
|
+
const metadataContext = {
|
|
618
|
+
tileset: this.tileset.metadata || null,
|
|
619
|
+
group,
|
|
620
|
+
tile: this.metadata,
|
|
621
|
+
content: this.contentMetadata[0] || null,
|
|
622
|
+
subtree: header.implicitMetadata || null
|
|
623
|
+
};
|
|
624
|
+
if (this.tileset.groups) {
|
|
625
|
+
metadataContext.groups = this.tileset.groups;
|
|
626
|
+
}
|
|
627
|
+
this.metadataContext = metadataContext;
|
|
628
|
+
}
|
|
629
|
+
/** Updates payload and renderability while retaining immutable metadata descriptors. */
|
|
630
|
+
_updateContentEntriesAfterLoad(loadResult) {
|
|
631
|
+
if (loadResult.contentEntries) {
|
|
632
|
+
this.contentEntries = loadResult.contentEntries.map((entry, index) => ({
|
|
633
|
+
...entry,
|
|
634
|
+
index,
|
|
635
|
+
boundingVolume: entry.boundingVolume || this._contentBoundingVolumes[index] || this.boundingVolume,
|
|
636
|
+
payload: entry.payload ?? this.contents[index] ?? null,
|
|
637
|
+
featureIds: entry.featureIds?.length
|
|
638
|
+
? entry.featureIds
|
|
639
|
+
: getTile3DFeatureIdSets(entry.payload ?? this.contents[index]),
|
|
640
|
+
renderable: Boolean(entry.renderable !== false &&
|
|
641
|
+
(entry.payload ?? this.contents[index]) &&
|
|
642
|
+
!isNestedTilesetPayload(entry.payload ?? this.contents[index]))
|
|
643
|
+
}));
|
|
644
|
+
this.featureIdSets = this.contentEntries.flatMap(entry => entry.featureIds);
|
|
645
|
+
return;
|
|
646
|
+
}
|
|
647
|
+
this.contentEntries = this.contentEntries.map((entry, index) => ({
|
|
648
|
+
...entry,
|
|
649
|
+
payload: this.contents[index] ?? null,
|
|
650
|
+
featureIds: getTile3DFeatureIdSets(this.contents[index]),
|
|
651
|
+
renderable: Boolean(this.contents[index]) && !isNestedTilesetPayload(this.contents[index])
|
|
652
|
+
}));
|
|
653
|
+
this.featureIdSets = this.contentEntries.flatMap(entry => entry.featureIds);
|
|
654
|
+
}
|
|
655
|
+
/** Returns one ordered content descriptor, or null when the index is out of range. */
|
|
656
|
+
getContentEntry(index) {
|
|
657
|
+
return this.contentEntries[index] || null;
|
|
658
|
+
}
|
|
659
|
+
/** Returns whether an ordered content entry currently has renderable payload. */
|
|
660
|
+
isContentRenderable(index) {
|
|
661
|
+
return Boolean(this.contentEntries[index]?.renderable);
|
|
662
|
+
}
|
|
663
|
+
/** Initializes additive renderer-neutral descriptors from a normalized tile header. */
|
|
664
|
+
_initializeContentEntries(tileHeader) {
|
|
665
|
+
const headers = Array.isArray(tileHeader.content)
|
|
666
|
+
? tileHeader.content
|
|
667
|
+
: tileHeader.content
|
|
668
|
+
? [tileHeader.content]
|
|
669
|
+
: [];
|
|
670
|
+
this.contentEntries = headers.map((contentHeader, index) => {
|
|
671
|
+
const normalizedContentHeader = contentHeader || {};
|
|
672
|
+
return {
|
|
673
|
+
index,
|
|
674
|
+
uri: this.contentUrls[index] || normalizedContentHeader.uri || normalizedContentHeader.url,
|
|
675
|
+
group: normalizedContentHeader.group,
|
|
676
|
+
type: normalizedContentHeader.type,
|
|
677
|
+
payload: null,
|
|
678
|
+
metadata: normalizedContentHeader.metadata || null,
|
|
679
|
+
boundingVolume: this._contentBoundingVolumes[index] || this.boundingVolume,
|
|
680
|
+
featureIds: this._getFeatureIdSets(normalizedContentHeader),
|
|
681
|
+
renderable: false
|
|
682
|
+
};
|
|
683
|
+
});
|
|
684
|
+
}
|
|
685
|
+
/** Extracts renderer-neutral feature-id declarations without decoding property values. */
|
|
686
|
+
_getFeatureIdSets(contentHeader) {
|
|
687
|
+
return getTile3DFeatureIdSets(contentHeader);
|
|
688
|
+
}
|
|
317
689
|
// Unloads the tile's content.
|
|
318
690
|
unloadContent() {
|
|
319
|
-
|
|
320
|
-
|
|
691
|
+
for (const content of this.contents.length ? this.contents : [this.content]) {
|
|
692
|
+
if (content && content.destroy) {
|
|
693
|
+
content.destroy();
|
|
694
|
+
}
|
|
321
695
|
}
|
|
696
|
+
this.contents = [];
|
|
322
697
|
this.content = null;
|
|
698
|
+
this.vectorContent = null;
|
|
699
|
+
this.contentEntries = this.contentEntries.map(entry => ({
|
|
700
|
+
...entry,
|
|
701
|
+
payload: null,
|
|
702
|
+
renderable: false
|
|
703
|
+
}));
|
|
704
|
+
this.featureIdSets = this.contentEntries.flatMap(entry => entry.featureIds);
|
|
323
705
|
if (this.header.content && this.header.content.destroy) {
|
|
324
706
|
this.header.content.destroy();
|
|
325
707
|
}
|
|
@@ -350,12 +732,61 @@ export class Tile3D {
|
|
|
350
732
|
}
|
|
351
733
|
this._distanceToCamera = this.distanceToTile(frameState);
|
|
352
734
|
this._screenSpaceError = this.getScreenSpaceError(frameState, false);
|
|
735
|
+
this._updateRequestPriorityMetrics(frameState);
|
|
353
736
|
this._visibilityPlaneMask = this.visibility(frameState, parentVisibilityPlaneMask); // Use parent's plane mask to speed up visibility test
|
|
354
737
|
this._visible = this._visibilityPlaneMask !== CullingVolume.MASK_OUTSIDE;
|
|
355
738
|
this._inRequestVolume = this.insideViewerRequestVolume(frameState);
|
|
356
739
|
this._frameNumber = frameState.frameNumber;
|
|
357
740
|
this.viewportIds = viewportIds;
|
|
358
741
|
}
|
|
742
|
+
/**
|
|
743
|
+
* Updates progressive-resolution and foveated request metrics for a 3D Tiles traversal frame.
|
|
744
|
+
*
|
|
745
|
+
* I3S retains its format-specific screen-threshold ordering and is explicitly isolated from
|
|
746
|
+
* geometric-error scheduling. Orthographic viewports still receive progressive coverage, but
|
|
747
|
+
* angular foveation is disabled because an orthographic frustum has no perspective field of view.
|
|
748
|
+
*
|
|
749
|
+
* @param frameState - Current camera and viewport measurements.
|
|
750
|
+
*/
|
|
751
|
+
_updateRequestPriorityMetrics(frameState) {
|
|
752
|
+
if (this.tileset.type !== TILESET_TYPE.TILES3D) {
|
|
753
|
+
this._screenSpaceErrorProgressiveResolution = this._screenSpaceError;
|
|
754
|
+
this._priorityProgressiveResolution = false;
|
|
755
|
+
this._foveatedFactor = 0;
|
|
756
|
+
this.priorityDeferred = false;
|
|
757
|
+
return;
|
|
758
|
+
}
|
|
759
|
+
const options = this.tileset.options;
|
|
760
|
+
const progressiveResolutionHeightFraction = options.progressiveResolutionHeightFraction;
|
|
761
|
+
this._screenSpaceErrorProgressiveResolution = this.getScreenSpaceError(frameState, false, progressiveResolutionHeightFraction);
|
|
762
|
+
this._priorityProgressiveResolution = isProgressiveResolutionPriority(this._screenSpaceErrorProgressiveResolution, this.parent?._screenSpaceErrorProgressiveResolution, this.tileset.memoryAdjustedScreenSpaceError, progressiveResolutionHeightFraction);
|
|
763
|
+
if (!options.foveatedScreenSpaceError ||
|
|
764
|
+
frameState.viewport?.orthographic ||
|
|
765
|
+
!frameState.camera?.position ||
|
|
766
|
+
!frameState.camera?.direction) {
|
|
767
|
+
this._foveatedFactor = 0;
|
|
768
|
+
this.priorityDeferred = false;
|
|
769
|
+
return;
|
|
770
|
+
}
|
|
771
|
+
this._foveatedFactor = calculateFoveatedFactor(this.boundingVolume, frameState.camera);
|
|
772
|
+
const traverser = this.tileset._traverser;
|
|
773
|
+
const skipLevelOfDetail = traverser.options.skipLevelOfDetail && !traverser.disableSkipLevelOfDetail;
|
|
774
|
+
const deferralEligible = isFoveatedRequestDeferred({
|
|
775
|
+
refinement: this.refine,
|
|
776
|
+
skipLevelOfDetail,
|
|
777
|
+
foveatedScreenSpaceError: options.foveatedScreenSpaceError,
|
|
778
|
+
foveatedConeSize: options.foveatedConeSize,
|
|
779
|
+
minimumScreenSpaceErrorRelaxation: options.foveatedMinimumScreenSpaceErrorRelaxation,
|
|
780
|
+
interpolationCallback: options.foveatedInterpolationCallback,
|
|
781
|
+
foveatedFactor: this._foveatedFactor,
|
|
782
|
+
verticalFieldOfView: frameState.camera.verticalFieldOfView,
|
|
783
|
+
screenSpaceError: this._screenSpaceError,
|
|
784
|
+
parentScreenSpaceError: this.parent?._screenSpaceError,
|
|
785
|
+
maximumScreenSpaceError: this.tileset.memoryAdjustedScreenSpaceError,
|
|
786
|
+
priorityProgressiveResolution: this._priorityProgressiveResolution
|
|
787
|
+
});
|
|
788
|
+
this.priorityDeferred = isFoveatedRequestDelayActive(deferralEligible, frameState.camera.timeSinceMovement, options.foveatedTimeDelay);
|
|
789
|
+
}
|
|
359
790
|
// Determines whether the tile's bounding volume intersects the culling volume.
|
|
360
791
|
// @param {FrameState} frameState The frame state.
|
|
361
792
|
// @param {Number} parentVisibilityPlaneMask The parent's plane mask to speed up the visibility check.
|
|
@@ -378,46 +809,21 @@ export class Tile3D {
|
|
|
378
809
|
// return cullingVolume.computeVisibilityWithPlaneMask(boundingVolume, parentVisibilityPlaneMask);
|
|
379
810
|
return cullingVolume.computeVisibilityWithPlaneMask(boundingVolume, parentVisibilityPlaneMask);
|
|
380
811
|
}
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
// The tile's bounding volume is completely inside the culling volume so
|
|
397
|
-
// the content bounding volume must also be inside.
|
|
398
|
-
return Intersect.INSIDE;
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
// PERFORMANCE_IDEA: is it possible to burn less CPU on this test since we know the
|
|
402
|
-
// tile's (not the content's) bounding volume intersects the culling volume?
|
|
403
|
-
const cullingVolume = frameState.cullingVolume;
|
|
404
|
-
const boundingVolume = tile.contentBoundingVolume;
|
|
405
|
-
|
|
406
|
-
const tileset = this.tileset;
|
|
407
|
-
const clippingPlanes = tileset.clippingPlanes;
|
|
408
|
-
if (defined(clippingPlanes) && clippingPlanes.enabled) {
|
|
409
|
-
const intersection = clippingPlanes.computeIntersectionWithBoundingVolume(
|
|
410
|
-
boundingVolume,
|
|
411
|
-
tileset.clippingPlanesOriginMatrix
|
|
412
|
-
);
|
|
413
|
-
this._isClipped = intersection !== Intersect.INSIDE;
|
|
414
|
-
if (intersection === Intersect.OUTSIDE) {
|
|
415
|
-
return Intersect.OUTSIDE;
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
return cullingVolume.computeVisibility(boundingVolume);
|
|
420
|
-
*/
|
|
812
|
+
/**
|
|
813
|
+
* Determines whether renderable content intersects the view and configured clipping planes.
|
|
814
|
+
*
|
|
815
|
+
* Clipping planes are render-only constraints; traversal continues to use the tile volume.
|
|
816
|
+
*
|
|
817
|
+
* @param frameState Current camera, culling, and optional clipping-plane state.
|
|
818
|
+
* @returns The content visibility classification.
|
|
819
|
+
*/
|
|
820
|
+
contentVisibility(frameState, contentIndex) {
|
|
821
|
+
const contentVolumes = contentIndex === undefined
|
|
822
|
+
? this._contentBoundingVolumes
|
|
823
|
+
: this._contentBoundingVolumes[contentIndex]
|
|
824
|
+
? [this._contentBoundingVolumes[contentIndex]]
|
|
825
|
+
: [];
|
|
826
|
+
return getContentVisibility(contentVolumes, this.boundingVolume, frameState.cullingVolume, this._visibilityPlaneMask, frameState.clippingPlanes);
|
|
421
827
|
}
|
|
422
828
|
/**
|
|
423
829
|
* Computes the (potentially approximate) distance from the closest point of the tile's bounding volume to the camera.
|
|
@@ -465,6 +871,10 @@ export class Tile3D {
|
|
|
465
871
|
// INTERNAL METHODS
|
|
466
872
|
/** Initializes the tile's LOD metric from its header or its nearest available ancestor. */
|
|
467
873
|
_initializeLodMetric(header) {
|
|
874
|
+
this._scaleGeometricError =
|
|
875
|
+
typeof header._scaleGeometricError === 'boolean'
|
|
876
|
+
? header._scaleGeometricError
|
|
877
|
+
: (this.parent?._scaleGeometricError ?? true);
|
|
468
878
|
if ('lodMetricType' in header) {
|
|
469
879
|
this.lodMetricType = header.lodMetricType;
|
|
470
880
|
}
|
|
@@ -512,7 +922,7 @@ export class Tile3D {
|
|
|
512
922
|
* I3S `maxScreenThreshold` is already a screen-space metric and must not be transform-scaled.
|
|
513
923
|
*/
|
|
514
924
|
_updateLodMetricScale() {
|
|
515
|
-
if (this.lodMetricType !== LOD_METRIC_TYPE.GEOMETRIC_ERROR) {
|
|
925
|
+
if (this.lodMetricType !== LOD_METRIC_TYPE.GEOMETRIC_ERROR || !this._scaleGeometricError) {
|
|
516
926
|
this.lodMetricValue = this._unscaledLodMetricValue;
|
|
517
927
|
return;
|
|
518
928
|
}
|
|
@@ -522,18 +932,20 @@ export class Tile3D {
|
|
|
522
932
|
}
|
|
523
933
|
_initializeBoundingVolumes(tileHeader) {
|
|
524
934
|
this._contentBoundingVolume = null;
|
|
935
|
+
this._contentBoundingVolumeHeaders = [];
|
|
525
936
|
this._viewerRequestVolume = null;
|
|
526
937
|
this._updateBoundingVolume(tileHeader);
|
|
527
938
|
}
|
|
528
939
|
_initializeContent(tileHeader) {
|
|
529
940
|
// Empty tile by default
|
|
530
941
|
this.content = { _tileset: this.tileset, _tile: this };
|
|
942
|
+
this.contents = [];
|
|
531
943
|
this.hasEmptyContent = true;
|
|
532
944
|
this.contentState = TILE_CONTENT_STATE.UNLOADED;
|
|
533
945
|
// When `true`, the tile's content points to an external tileset.
|
|
534
946
|
// This is `false` until the tile's content is loaded.
|
|
535
947
|
this.hasTilesetContent = false;
|
|
536
|
-
if (tileHeader.contentUrl) {
|
|
948
|
+
if (tileHeader.contentUrl || tileHeader.contentUrls?.length) {
|
|
537
949
|
this.content = null;
|
|
538
950
|
this.hasEmptyContent = false;
|
|
539
951
|
}
|
|
@@ -546,6 +958,10 @@ export class Tile3D {
|
|
|
546
958
|
this._distanceToCamera = 0;
|
|
547
959
|
this._centerZDepth = 0;
|
|
548
960
|
this._screenSpaceError = 0;
|
|
961
|
+
this._screenSpaceErrorProgressiveResolution = 0;
|
|
962
|
+
this._priorityProgressiveResolution = false;
|
|
963
|
+
this._foveatedFactor = 0;
|
|
964
|
+
this.priorityDeferred = false;
|
|
549
965
|
this._visibilityPlaneMask = CullingVolume.MASK_INDETERMINATE;
|
|
550
966
|
this._visible = undefined;
|
|
551
967
|
this._inRequestVolume = false;
|
|
@@ -562,18 +978,28 @@ export class Tile3D {
|
|
|
562
978
|
// Inherit from parent tile if omitted.
|
|
563
979
|
return refine || (this.parent && this.parent.refine) || TILE_REFINEMENT.REPLACE;
|
|
564
980
|
}
|
|
981
|
+
/**
|
|
982
|
+
* Returns whether loaded content is an external tileset.
|
|
983
|
+
*
|
|
984
|
+
* Parsed shape is authoritative because valid external resources may be extensionless, signed,
|
|
985
|
+
* or use a misleading filename. This method is called only after source loading has populated
|
|
986
|
+
* `content`.
|
|
987
|
+
*/
|
|
565
988
|
_isTileset() {
|
|
566
|
-
return this.
|
|
989
|
+
return (this.contents.length ? this.contents : [this.content]).some(content => content?.shape === 'tileset3d');
|
|
567
990
|
}
|
|
568
991
|
_onContentLoaded() {
|
|
569
992
|
// Vector and Geometry tile rendering do not support the skip LOD optimization.
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
993
|
+
const contents = this.contents.length ? this.contents : [this.content];
|
|
994
|
+
for (const content of contents) {
|
|
995
|
+
switch (content && content.type) {
|
|
996
|
+
case 'vctr':
|
|
997
|
+
case 'geom':
|
|
998
|
+
// @ts-ignore
|
|
999
|
+
this.tileset._traverser.disableSkipLevelOfDetail = true;
|
|
1000
|
+
break;
|
|
1001
|
+
default:
|
|
1002
|
+
}
|
|
577
1003
|
}
|
|
578
1004
|
// The content may be tileset json
|
|
579
1005
|
if (this._isTileset()) {
|
|
@@ -584,24 +1010,32 @@ export class Tile3D {
|
|
|
584
1010
|
}
|
|
585
1011
|
}
|
|
586
1012
|
_updateBoundingVolume(header) {
|
|
1013
|
+
this._boundingBox = undefined;
|
|
587
1014
|
// Update the bounding volumes
|
|
588
|
-
this.boundingVolume = createBoundingVolume(header.boundingVolume, this.computedTransform, this.boundingVolume);
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
}
|
|
593
|
-
// TODO Cesium specific
|
|
594
|
-
// Non-leaf tiles may have a content bounding-volume, which is a tight-fit bounding volume
|
|
595
|
-
// around only the features in the tile. This box is useful for culling for rendering,
|
|
596
|
-
// but not for culling for traversing the tree since it does not guarantee spatial coherence, i.e.,
|
|
597
|
-
// since it only bounds features in the tile, not the entire tile, children may be
|
|
598
|
-
// outside of this box.
|
|
599
|
-
if (content.boundingVolume) {
|
|
600
|
-
this._contentBoundingVolume = createBoundingVolume(content.boundingVolume, this.computedTransform, this._contentBoundingVolume);
|
|
601
|
-
}
|
|
1015
|
+
this.boundingVolume = createBoundingVolume(header.boundingVolume, this.computedTransform, this.boundingVolume, this._initialTransform);
|
|
1016
|
+
// Viewer request volumes constrain traversal, not just render content. A contentless implicit
|
|
1017
|
+
// connector can still own an inherited request volume, so initialize it before the
|
|
1018
|
+
// content-specific early return below.
|
|
602
1019
|
if (header.viewerRequestVolume) {
|
|
603
|
-
this._viewerRequestVolume = createBoundingVolume(header.viewerRequestVolume, this.computedTransform, this._viewerRequestVolume);
|
|
1020
|
+
this._viewerRequestVolume = createBoundingVolume(header.viewerRequestVolume, this.computedTransform, this._viewerRequestVolume, this._initialTransform);
|
|
1021
|
+
}
|
|
1022
|
+
const content = header.content;
|
|
1023
|
+
if (content) {
|
|
1024
|
+
this._contentBoundingVolumeHeaders = Array.isArray(content) ? content : [content];
|
|
604
1025
|
}
|
|
1026
|
+
const contentHeaders = content
|
|
1027
|
+
? Array.isArray(content)
|
|
1028
|
+
? content
|
|
1029
|
+
: [content]
|
|
1030
|
+
: this._contentBoundingVolumeHeaders;
|
|
1031
|
+
// Preserve source order: an unbounded content entry uses the tile volume at its
|
|
1032
|
+
// corresponding index rather than being appended after bounded sibling entries.
|
|
1033
|
+
this._contentBoundingVolumes = contentHeaders.length
|
|
1034
|
+
? contentHeaders.map(headerEntry => headerEntry?.boundingVolume
|
|
1035
|
+
? createBoundingVolume(headerEntry.boundingVolume, this.computedTransform, undefined, this._initialTransform)
|
|
1036
|
+
: this.boundingVolume)
|
|
1037
|
+
: [this.boundingVolume];
|
|
1038
|
+
this._contentBoundingVolume = this._contentBoundingVolumes[0] || null;
|
|
605
1039
|
}
|
|
606
1040
|
/**
|
|
607
1041
|
* Updates the tile's computed transform, world-space geometric error, and bounding volumes.
|