@loaders.gl/tiles 3.1.3 → 4.0.0-alpha.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.
Files changed (122) hide show
  1. package/dist/bundle.js +2 -2
  2. package/dist/bundle.js.map +1 -0
  3. package/dist/constants.js +26 -29
  4. package/dist/constants.js.map +1 -0
  5. package/dist/dist.min.js +45 -264
  6. package/dist/index.js +10 -28
  7. package/dist/index.js.map +1 -0
  8. package/dist/tileset/helpers/3d-tiles-options.js +5 -8
  9. package/dist/tileset/helpers/3d-tiles-options.js.map +1 -0
  10. package/dist/tileset/helpers/bounding-volume.js +70 -159
  11. package/dist/tileset/helpers/bounding-volume.js.map +1 -0
  12. package/dist/tileset/helpers/frame-state.js +48 -67
  13. package/dist/tileset/helpers/frame-state.js.map +1 -0
  14. package/dist/tileset/helpers/i3s-lod.js +64 -80
  15. package/dist/tileset/helpers/i3s-lod.js.map +1 -0
  16. package/dist/tileset/helpers/tiles-3d-lod.js +100 -111
  17. package/dist/tileset/helpers/tiles-3d-lod.js.map +1 -0
  18. package/dist/tileset/helpers/transform-utils.js +56 -50
  19. package/dist/tileset/helpers/transform-utils.js.map +1 -0
  20. package/dist/tileset/helpers/zoom.js +30 -36
  21. package/dist/tileset/helpers/zoom.js.map +1 -0
  22. package/dist/tileset/tile-3d.js +533 -551
  23. package/dist/tileset/tile-3d.js.map +1 -0
  24. package/dist/tileset/tileset-3d.js +649 -576
  25. package/dist/tileset/tileset-3d.js.map +1 -0
  26. package/dist/tileset/tileset-cache.js +71 -71
  27. package/dist/tileset/tileset-cache.js.map +1 -0
  28. package/dist/tileset/traversers/i3s-tile-manager.js +40 -31
  29. package/dist/tileset/traversers/i3s-tile-manager.js.map +1 -0
  30. package/dist/tileset/traversers/i3s-tileset-traverser.js +76 -81
  31. package/dist/tileset/traversers/i3s-tileset-traverser.js.map +1 -0
  32. package/dist/tileset/traversers/tileset-3d-traverser.js +49 -51
  33. package/dist/tileset/traversers/tileset-3d-traverser.js.map +1 -0
  34. package/dist/tileset/traversers/tileset-traverser.js +276 -274
  35. package/dist/tileset/traversers/tileset-traverser.js.map +1 -0
  36. package/dist/utils/doubly-linked-list-node.js +15 -16
  37. package/dist/utils/doubly-linked-list-node.js.map +1 -0
  38. package/dist/utils/doubly-linked-list.js +75 -94
  39. package/dist/utils/doubly-linked-list.js.map +1 -0
  40. package/dist/utils/managed-array.js +109 -143
  41. package/dist/utils/managed-array.js.map +1 -0
  42. package/package.json +7 -7
  43. package/dist/es5/bundle.js +0 -7
  44. package/dist/es5/bundle.js.map +0 -1
  45. package/dist/es5/constants.js +0 -44
  46. package/dist/es5/constants.js.map +0 -1
  47. package/dist/es5/index.js +0 -104
  48. package/dist/es5/index.js.map +0 -1
  49. package/dist/es5/tileset/helpers/3d-tiles-options.js +0 -13
  50. package/dist/es5/tileset/helpers/3d-tiles-options.js.map +0 -1
  51. package/dist/es5/tileset/helpers/bounding-volume.js +0 -114
  52. package/dist/es5/tileset/helpers/bounding-volume.js.map +0 -1
  53. package/dist/es5/tileset/helpers/frame-state.js +0 -65
  54. package/dist/es5/tileset/helpers/frame-state.js.map +0 -1
  55. package/dist/es5/tileset/helpers/i3s-lod.js +0 -86
  56. package/dist/es5/tileset/helpers/i3s-lod.js.map +0 -1
  57. package/dist/es5/tileset/helpers/tiles-3d-lod.js +0 -119
  58. package/dist/es5/tileset/helpers/tiles-3d-lod.js.map +0 -1
  59. package/dist/es5/tileset/helpers/transform-utils.js +0 -65
  60. package/dist/es5/tileset/helpers/transform-utils.js.map +0 -1
  61. package/dist/es5/tileset/helpers/zoom.js +0 -43
  62. package/dist/es5/tileset/helpers/zoom.js.map +0 -1
  63. package/dist/es5/tileset/tile-3d.js +0 -605
  64. package/dist/es5/tileset/tile-3d.js.map +0 -1
  65. package/dist/es5/tileset/tileset-3d.js +0 -838
  66. package/dist/es5/tileset/tileset-3d.js.map +0 -1
  67. package/dist/es5/tileset/tileset-cache.js +0 -101
  68. package/dist/es5/tileset/tileset-cache.js.map +0 -1
  69. package/dist/es5/tileset/traversers/i3s-tile-manager.js +0 -69
  70. package/dist/es5/tileset/traversers/i3s-tile-manager.js.map +0 -1
  71. package/dist/es5/tileset/traversers/i3s-tileset-traverser.js +0 -185
  72. package/dist/es5/tileset/traversers/i3s-tileset-traverser.js.map +0 -1
  73. package/dist/es5/tileset/traversers/tileset-3d-traverser.js +0 -94
  74. package/dist/es5/tileset/traversers/tileset-3d-traverser.js.map +0 -1
  75. package/dist/es5/tileset/traversers/tileset-traverser.js +0 -377
  76. package/dist/es5/tileset/traversers/tileset-traverser.js.map +0 -1
  77. package/dist/es5/utils/doubly-linked-list-node.js +0 -25
  78. package/dist/es5/utils/doubly-linked-list-node.js.map +0 -1
  79. package/dist/es5/utils/doubly-linked-list.js +0 -104
  80. package/dist/es5/utils/doubly-linked-list.js.map +0 -1
  81. package/dist/es5/utils/managed-array.js +0 -147
  82. package/dist/es5/utils/managed-array.js.map +0 -1
  83. package/dist/esm/bundle.js +0 -5
  84. package/dist/esm/bundle.js.map +0 -1
  85. package/dist/esm/constants.js +0 -32
  86. package/dist/esm/constants.js.map +0 -1
  87. package/dist/esm/index.js +0 -10
  88. package/dist/esm/index.js.map +0 -1
  89. package/dist/esm/tileset/helpers/3d-tiles-options.js +0 -6
  90. package/dist/esm/tileset/helpers/3d-tiles-options.js.map +0 -1
  91. package/dist/esm/tileset/helpers/bounding-volume.js +0 -88
  92. package/dist/esm/tileset/helpers/bounding-volume.js.map +0 -1
  93. package/dist/esm/tileset/helpers/frame-state.js +0 -51
  94. package/dist/esm/tileset/helpers/frame-state.js.map +0 -1
  95. package/dist/esm/tileset/helpers/i3s-lod.js +0 -67
  96. package/dist/esm/tileset/helpers/i3s-lod.js.map +0 -1
  97. package/dist/esm/tileset/helpers/tiles-3d-lod.js +0 -105
  98. package/dist/esm/tileset/helpers/tiles-3d-lod.js.map +0 -1
  99. package/dist/esm/tileset/helpers/transform-utils.js +0 -58
  100. package/dist/esm/tileset/helpers/transform-utils.js.map +0 -1
  101. package/dist/esm/tileset/helpers/zoom.js +0 -36
  102. package/dist/esm/tileset/helpers/zoom.js.map +0 -1
  103. package/dist/esm/tileset/tile-3d.js +0 -537
  104. package/dist/esm/tileset/tile-3d.js.map +0 -1
  105. package/dist/esm/tileset/tileset-3d.js +0 -674
  106. package/dist/esm/tileset/tileset-3d.js.map +0 -1
  107. package/dist/esm/tileset/tileset-cache.js +0 -79
  108. package/dist/esm/tileset/tileset-cache.js.map +0 -1
  109. package/dist/esm/tileset/traversers/i3s-tile-manager.js +0 -45
  110. package/dist/esm/tileset/traversers/i3s-tile-manager.js.map +0 -1
  111. package/dist/esm/tileset/traversers/i3s-tileset-traverser.js +0 -80
  112. package/dist/esm/tileset/traversers/i3s-tileset-traverser.js.map +0 -1
  113. package/dist/esm/tileset/traversers/tileset-3d-traverser.js +0 -53
  114. package/dist/esm/tileset/traversers/tileset-3d-traverser.js.map +0 -1
  115. package/dist/esm/tileset/traversers/tileset-traverser.js +0 -296
  116. package/dist/esm/tileset/traversers/tileset-traverser.js.map +0 -1
  117. package/dist/esm/utils/doubly-linked-list-node.js +0 -16
  118. package/dist/esm/utils/doubly-linked-list-node.js.map +0 -1
  119. package/dist/esm/utils/doubly-linked-list.js +0 -81
  120. package/dist/esm/utils/doubly-linked-list.js.map +0 -1
  121. package/dist/esm/utils/managed-array.js +0 -117
  122. package/dist/esm/utils/managed-array.js.map +0 -1
@@ -1,555 +1,537 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- // This file is derived from the Cesium code base under Apache 2 license
7
- // See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
8
- const core_1 = require("@math.gl/core");
9
- const culling_1 = require("@math.gl/culling");
10
- const core_2 = require("@loaders.gl/core");
11
- const constants_1 = require("../constants");
12
- const bounding_volume_1 = require("./helpers/bounding-volume");
13
- const tiles_3d_lod_1 = require("./helpers/tiles-3d-lod");
14
- const i3s_lod_1 = require("./helpers/i3s-lod");
15
- const _3d_tiles_options_1 = require("./helpers/3d-tiles-options");
16
- const tileset_traverser_1 = __importDefault(require("./traversers/tileset-traverser"));
17
- const scratchVector = new core_1.Vector3();
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ import { Vector3, Matrix4 } from '@math.gl/core';
3
+ import { CullingVolume } from '@math.gl/culling';
4
+ import { load } from '@loaders.gl/core';
5
+ import { TILE_REFINEMENT, TILE_CONTENT_STATE, TILESET_TYPE } from '../constants';
6
+ import { createBoundingVolume } from './helpers/bounding-volume';
7
+ import { getTiles3DScreenSpaceError } from './helpers/tiles-3d-lod';
8
+ import { getProjectedRadius } from './helpers/i3s-lod';
9
+ import { get3dTilesOptions } from './helpers/3d-tiles-options';
10
+ import TilesetTraverser from './traversers/tileset-traverser';
11
+ const scratchVector = new Vector3();
12
+
18
13
  function defined(x) {
19
- return x !== undefined && x !== null;
14
+ return x !== undefined && x !== null;
20
15
  }
21
- /**
22
- * A Tile3DHeader represents a tile as Tileset3D. When a tile is first created, its content is not loaded;
23
- * the content is loaded on-demand when needed based on the view.
24
- * Do not construct this directly, instead access tiles through {@link Tileset3D#tileVisible}.
25
- */
26
- class TileHeader {
27
- /**
28
- * @constructs
29
- * Create a TileHeader instance
30
- * @param tileset - Tileset3D instance
31
- * @param header - tile header - JSON loaded from a dataset
32
- * @param parentHeader - parent TileHeader instance
33
- * @param extendedId - optional ID to separate copies of a tile for different viewports.
34
- * const extendedId = `${tile.id}-${frameState.viewport.id}`;
35
- */
36
- // eslint-disable-next-line max-statements
37
- constructor(tileset, header, parentHeader, extendedId = '') {
38
- // PUBLIC MEMBERS
39
- // original tile data
40
- this.header = header;
41
- // The tileset containing this tile.
42
- this.tileset = tileset;
43
- this.id = extendedId || header.id;
44
- this.url = header.url;
45
- // This tile's parent or `undefined` if this tile is the root.
46
- // @ts-ignore
47
- this.parent = parentHeader;
48
- this.refine = this._getRefine(header.refine);
49
- this.type = header.type;
50
- this.contentUrl = header.contentUrl;
51
- // The error, in meters, introduced if this tile is rendered and its children are not.
52
- this.lodMetricType = 'geometricError';
53
- this.lodMetricValue = 0;
54
- // Specifies the type of refine that is used when traversing this tile for rendering.
55
- this.boundingVolume = null;
56
- // The tile's content. This represents the actual tile's payload,
57
- // not the content's metadata in the tileset JSON file.
58
- this.content = null;
59
- this.contentState = constants_1.TILE_CONTENT_STATE.UNLOADED;
60
- this.gpuMemoryUsageInBytes = 0;
61
- // The tile's children - an array of Tile3D objects.
62
- this.children = [];
63
- this.hasEmptyContent = false;
64
- this.hasTilesetContent = false;
65
- this.depth = 0;
66
- this.viewportIds = [];
67
- // Container to store application specific data
68
- this.userData = {};
69
- this.extensions = null;
70
- // PRIVATE MEMBERS
71
- this._priority = 0;
72
- this._touchedFrame = 0;
73
- this._visitedFrame = 0;
74
- this._selectedFrame = 0;
75
- this._requestedFrame = 0;
76
- this._screenSpaceError = 0;
77
- this._cacheNode = null;
78
- this._frameNumber = null;
79
- this._cacheNode = null;
80
- this.traverser = new tileset_traverser_1.default({});
81
- this._shouldRefine = false;
82
- this._distanceToCamera = 0;
83
- this._centerZDepth = 0;
84
- this._visible = undefined;
85
- this._inRequestVolume = false;
86
- this._stackLength = 0;
87
- this._selectionDepth = 0;
88
- this._initialTransform = new core_1.Matrix4();
89
- this.transform = new core_1.Matrix4();
90
- this._initializeLodMetric(header);
91
- this._initializeTransforms(header);
92
- this._initializeBoundingVolumes(header);
93
- this._initializeContent(header);
94
- this._initializeRenderingState(header);
95
- // TODO i3s specific, needs to remove
96
- this._lodJudge = null;
97
- // TODO Cesium 3d tiles specific
98
- this._expireDate = null;
99
- this._expiredContent = null;
100
- Object.seal(this);
101
- }
102
- destroy() {
103
- this.header = null;
104
- }
105
- isDestroyed() {
106
- return this.header === null;
107
- }
108
- get selected() {
109
- return this._selectedFrame === this.tileset._frameNumber;
110
- }
111
- get isVisible() {
112
- return this._visible;
113
- }
114
- get isVisibleAndInRequestVolume() {
115
- return this._visible && this._inRequestVolume;
116
- }
117
- /** Returns true if tile is not an empty tile and not an external tileset */
118
- get hasRenderContent() {
119
- return !this.hasEmptyContent && !this.hasTilesetContent;
120
- }
121
- /** Returns true if tile has children */
122
- get hasChildren() {
123
- return this.children.length > 0 || (this.header.children && this.header.children.length > 0);
124
- }
125
- /**
126
- * Determines if the tile's content is ready. This is automatically `true` for
127
- * tiles with empty content.
128
- */
129
- get contentReady() {
130
- return this.contentState === constants_1.TILE_CONTENT_STATE.READY || this.hasEmptyContent;
131
- }
132
- /**
133
- * Determines if the tile has available content to render. `true` if the tile's
134
- * content is ready or if it has expired content this renders while new content loads; otherwise,
135
- */
136
- get contentAvailable() {
137
- return Boolean((this.contentReady && this.hasRenderContent) || (this._expiredContent && !this.contentFailed));
138
- }
139
- /** Returns true if tile has renderable content but it's unloaded */
140
- get hasUnloadedContent() {
141
- return this.hasRenderContent && this.contentUnloaded;
142
- }
143
- /**
144
- * Determines if the tile's content has not be requested. `true` if tile's
145
- * content has not be requested; otherwise, `false`.
146
- */
147
- get contentUnloaded() {
148
- return this.contentState === constants_1.TILE_CONTENT_STATE.UNLOADED;
149
- }
150
- /**
151
- * Determines if the tile's content is expired. `true` if tile's
152
- * content is expired; otherwise, `false`.
153
- */
154
- get contentExpired() {
155
- return this.contentState === constants_1.TILE_CONTENT_STATE.EXPIRED;
156
- }
157
- // Determines if the tile's content failed to load. `true` if the tile's
158
- // content failed to load; otherwise, `false`.
159
- get contentFailed() {
160
- return this.contentState === constants_1.TILE_CONTENT_STATE.FAILED;
161
- }
162
- /** Get the tile's screen space error. */
163
- getScreenSpaceError(frameState, useParentLodMetric) {
164
- switch (this.tileset.type) {
165
- case constants_1.TILESET_TYPE.I3S:
166
- return (0, i3s_lod_1.getProjectedRadius)(this, frameState);
167
- case constants_1.TILESET_TYPE.TILES3D:
168
- return (0, tiles_3d_lod_1.getTiles3DScreenSpaceError)(this, frameState, useParentLodMetric);
169
- default:
170
- // eslint-disable-next-line
171
- throw new Error('Unsupported tileset type');
172
- }
173
- }
174
- /*
175
- * If skipLevelOfDetail is off try to load child tiles as soon as possible so that their parent can refine sooner.
176
- * Tiles are prioritized by screen space error.
177
- */
178
- // eslint-disable-next-line complexity
179
- _getPriority() {
180
- const traverser = this.tileset._traverser;
181
- const { skipLevelOfDetail } = traverser.options;
182
- /*
183
- * Tiles that are outside of the camera's frustum could be skipped if we are in 'ADD' mode
184
- * or if we are using 'Skip Traversal' in 'REPLACE' mode.
185
- * Otherewise, all 'touched' child tiles have to be loaded and displayed,
186
- * this may include tiles that are outide of the camera frustum (so that we can hide the parent tile).
187
- */
188
- const maySkipTile = this.refine === constants_1.TILE_REFINEMENT.ADD || skipLevelOfDetail;
189
- // Check if any reason to abort
190
- if (maySkipTile && !this.isVisible && this._visible !== undefined) {
191
- return -1;
192
- }
193
- // Condition used in `cancelOutOfViewRequests` function in CesiumJS/Cesium3DTileset.js
194
- if (this.tileset._frameNumber - this._touchedFrame >= 1) {
195
- return -1;
16
+
17
+ export default class TileHeader {
18
+ constructor(tileset, header, parentHeader, extendedId = '') {
19
+ _defineProperty(this, "tileset", void 0);
20
+
21
+ _defineProperty(this, "header", void 0);
22
+
23
+ _defineProperty(this, "id", void 0);
24
+
25
+ _defineProperty(this, "url", void 0);
26
+
27
+ _defineProperty(this, "parent", void 0);
28
+
29
+ _defineProperty(this, "refine", void 0);
30
+
31
+ _defineProperty(this, "type", void 0);
32
+
33
+ _defineProperty(this, "contentUrl", void 0);
34
+
35
+ _defineProperty(this, "lodMetricType", void 0);
36
+
37
+ _defineProperty(this, "lodMetricValue", void 0);
38
+
39
+ _defineProperty(this, "boundingVolume", void 0);
40
+
41
+ _defineProperty(this, "content", void 0);
42
+
43
+ _defineProperty(this, "contentState", void 0);
44
+
45
+ _defineProperty(this, "gpuMemoryUsageInBytes", void 0);
46
+
47
+ _defineProperty(this, "children", void 0);
48
+
49
+ _defineProperty(this, "depth", void 0);
50
+
51
+ _defineProperty(this, "viewportIds", void 0);
52
+
53
+ _defineProperty(this, "transform", void 0);
54
+
55
+ _defineProperty(this, "extensions", void 0);
56
+
57
+ _defineProperty(this, "userData", void 0);
58
+
59
+ _defineProperty(this, "computedTransform", void 0);
60
+
61
+ _defineProperty(this, "hasEmptyContent", void 0);
62
+
63
+ _defineProperty(this, "hasTilesetContent", void 0);
64
+
65
+ _defineProperty(this, "traverser", void 0);
66
+
67
+ _defineProperty(this, "_cacheNode", void 0);
68
+
69
+ _defineProperty(this, "_frameNumber", void 0);
70
+
71
+ _defineProperty(this, "_lodJudge", void 0);
72
+
73
+ _defineProperty(this, "_expireDate", void 0);
74
+
75
+ _defineProperty(this, "_expiredContent", void 0);
76
+
77
+ _defineProperty(this, "_shouldRefine", void 0);
78
+
79
+ _defineProperty(this, "_distanceToCamera", void 0);
80
+
81
+ _defineProperty(this, "_centerZDepth", void 0);
82
+
83
+ _defineProperty(this, "_screenSpaceError", void 0);
84
+
85
+ _defineProperty(this, "_visibilityPlaneMask", void 0);
86
+
87
+ _defineProperty(this, "_visible", void 0);
88
+
89
+ _defineProperty(this, "_inRequestVolume", void 0);
90
+
91
+ _defineProperty(this, "_stackLength", void 0);
92
+
93
+ _defineProperty(this, "_selectionDepth", void 0);
94
+
95
+ _defineProperty(this, "_touchedFrame", void 0);
96
+
97
+ _defineProperty(this, "_visitedFrame", void 0);
98
+
99
+ _defineProperty(this, "_selectedFrame", void 0);
100
+
101
+ _defineProperty(this, "_requestedFrame", void 0);
102
+
103
+ _defineProperty(this, "_priority", void 0);
104
+
105
+ _defineProperty(this, "_contentBoundingVolume", void 0);
106
+
107
+ _defineProperty(this, "_viewerRequestVolume", void 0);
108
+
109
+ _defineProperty(this, "_initialTransform", void 0);
110
+
111
+ this.header = header;
112
+ this.tileset = tileset;
113
+ this.id = extendedId || header.id;
114
+ this.url = header.url;
115
+ this.parent = parentHeader;
116
+ this.refine = this._getRefine(header.refine);
117
+ this.type = header.type;
118
+ this.contentUrl = header.contentUrl;
119
+ this.lodMetricType = 'geometricError';
120
+ this.lodMetricValue = 0;
121
+ this.boundingVolume = null;
122
+ this.content = null;
123
+ this.contentState = TILE_CONTENT_STATE.UNLOADED;
124
+ this.gpuMemoryUsageInBytes = 0;
125
+ this.children = [];
126
+ this.hasEmptyContent = false;
127
+ this.hasTilesetContent = false;
128
+ this.depth = 0;
129
+ this.viewportIds = [];
130
+ this.userData = {};
131
+ this.extensions = null;
132
+ this._priority = 0;
133
+ this._touchedFrame = 0;
134
+ this._visitedFrame = 0;
135
+ this._selectedFrame = 0;
136
+ this._requestedFrame = 0;
137
+ this._screenSpaceError = 0;
138
+ this._cacheNode = null;
139
+ this._frameNumber = null;
140
+ this._cacheNode = null;
141
+ this.traverser = new TilesetTraverser({});
142
+ this._shouldRefine = false;
143
+ this._distanceToCamera = 0;
144
+ this._centerZDepth = 0;
145
+ this._visible = undefined;
146
+ this._inRequestVolume = false;
147
+ this._stackLength = 0;
148
+ this._selectionDepth = 0;
149
+ this._initialTransform = new Matrix4();
150
+ this.transform = new Matrix4();
151
+
152
+ this._initializeLodMetric(header);
153
+
154
+ this._initializeTransforms(header);
155
+
156
+ this._initializeBoundingVolumes(header);
157
+
158
+ this._initializeContent(header);
159
+
160
+ this._initializeRenderingState(header);
161
+
162
+ this._lodJudge = null;
163
+ this._expireDate = null;
164
+ this._expiredContent = null;
165
+ Object.seal(this);
166
+ }
167
+
168
+ destroy() {
169
+ this.header = null;
170
+ }
171
+
172
+ isDestroyed() {
173
+ return this.header === null;
174
+ }
175
+
176
+ get selected() {
177
+ return this._selectedFrame === this.tileset._frameNumber;
178
+ }
179
+
180
+ get isVisible() {
181
+ return this._visible;
182
+ }
183
+
184
+ get isVisibleAndInRequestVolume() {
185
+ return this._visible && this._inRequestVolume;
186
+ }
187
+
188
+ get hasRenderContent() {
189
+ return !this.hasEmptyContent && !this.hasTilesetContent;
190
+ }
191
+
192
+ get hasChildren() {
193
+ return this.children.length > 0 || this.header.children && this.header.children.length > 0;
194
+ }
195
+
196
+ get contentReady() {
197
+ return this.contentState === TILE_CONTENT_STATE.READY || this.hasEmptyContent;
198
+ }
199
+
200
+ get contentAvailable() {
201
+ return Boolean(this.contentReady && this.hasRenderContent || this._expiredContent && !this.contentFailed);
202
+ }
203
+
204
+ get hasUnloadedContent() {
205
+ return this.hasRenderContent && this.contentUnloaded;
206
+ }
207
+
208
+ get contentUnloaded() {
209
+ return this.contentState === TILE_CONTENT_STATE.UNLOADED;
210
+ }
211
+
212
+ get contentExpired() {
213
+ return this.contentState === TILE_CONTENT_STATE.EXPIRED;
214
+ }
215
+
216
+ get contentFailed() {
217
+ return this.contentState === TILE_CONTENT_STATE.FAILED;
218
+ }
219
+
220
+ getScreenSpaceError(frameState, useParentLodMetric) {
221
+ switch (this.tileset.type) {
222
+ case TILESET_TYPE.I3S:
223
+ return getProjectedRadius(this, frameState);
224
+
225
+ case TILESET_TYPE.TILES3D:
226
+ return getTiles3DScreenSpaceError(this, frameState, useParentLodMetric);
227
+
228
+ default:
229
+ throw new Error('Unsupported tileset type');
230
+ }
231
+ }
232
+
233
+ _getPriority() {
234
+ const traverser = this.tileset._traverser;
235
+ const {
236
+ skipLevelOfDetail
237
+ } = traverser.options;
238
+ const maySkipTile = this.refine === TILE_REFINEMENT.ADD || skipLevelOfDetail;
239
+
240
+ if (maySkipTile && !this.isVisible && this._visible !== undefined) {
241
+ return -1;
242
+ }
243
+
244
+ if (this.tileset._frameNumber - this._touchedFrame >= 1) {
245
+ return -1;
246
+ }
247
+
248
+ if (this.contentState === TILE_CONTENT_STATE.UNLOADED) {
249
+ return -1;
250
+ }
251
+
252
+ const parent = this.parent;
253
+ const useParentScreenSpaceError = parent && (!maySkipTile || this._screenSpaceError === 0.0 || parent.hasTilesetContent);
254
+ const screenSpaceError = useParentScreenSpaceError ? parent._screenSpaceError : this._screenSpaceError;
255
+ const rootScreenSpaceError = traverser.root ? traverser.root._screenSpaceError : 0.0;
256
+ return Math.max(rootScreenSpaceError - screenSpaceError, 0);
257
+ }
258
+
259
+ async loadContent() {
260
+ if (this.hasEmptyContent) {
261
+ return false;
262
+ }
263
+
264
+ if (this.content) {
265
+ return true;
266
+ }
267
+
268
+ const expired = this.contentExpired;
269
+
270
+ if (expired) {
271
+ this._expireDate = null;
272
+ }
273
+
274
+ this.contentState = TILE_CONTENT_STATE.LOADING;
275
+ const requestToken = await this.tileset._requestScheduler.scheduleRequest(this.id, this._getPriority.bind(this));
276
+
277
+ if (!requestToken) {
278
+ this.contentState = TILE_CONTENT_STATE.UNLOADED;
279
+ return false;
280
+ }
281
+
282
+ try {
283
+ const contentUrl = this.tileset.getTileUrl(this.contentUrl);
284
+ const loader = this.tileset.loader;
285
+ const options = { ...this.tileset.loadOptions,
286
+ [loader.id]: { ...this.tileset.loadOptions[loader.id],
287
+ isTileset: this.type === 'json',
288
+ ...this._getLoaderSpecificOptions(loader.id)
196
289
  }
197
- if (this.contentState === constants_1.TILE_CONTENT_STATE.UNLOADED) {
198
- return -1;
199
- }
200
- // Based on the priority function `getPriorityReverseScreenSpaceError` in CesiumJS. Scheduling priority is based on the parent's screen space error when possible.
201
- const parent = this.parent;
202
- const useParentScreenSpaceError = parent && (!maySkipTile || this._screenSpaceError === 0.0 || parent.hasTilesetContent);
203
- const screenSpaceError = useParentScreenSpaceError
204
- ? parent._screenSpaceError
205
- : this._screenSpaceError;
206
- const rootScreenSpaceError = traverser.root ? traverser.root._screenSpaceError : 0.0;
207
- // Map higher SSE to lower values (e.g. root tile is highest priority)
208
- return Math.max(rootScreenSpaceError - screenSpaceError, 0);
209
- }
210
- /**
211
- * Requests the tile's content.
212
- * The request may not be made if the Request Scheduler can't prioritize it.
213
- */
214
- // eslint-disable-next-line max-statements, complexity
215
- async loadContent() {
216
- if (this.hasEmptyContent) {
217
- return false;
218
- }
219
- if (this.content) {
220
- return true;
221
- }
222
- const expired = this.contentExpired;
223
- if (expired) {
224
- this._expireDate = null;
225
- }
226
- this.contentState = constants_1.TILE_CONTENT_STATE.LOADING;
227
- const requestToken = await this.tileset._requestScheduler.scheduleRequest(this.id, this._getPriority.bind(this));
228
- if (!requestToken) {
229
- // cancelled
230
- this.contentState = constants_1.TILE_CONTENT_STATE.UNLOADED;
231
- return false;
232
- }
233
- try {
234
- const contentUrl = this.tileset.getTileUrl(this.contentUrl);
235
- // The content can be a binary tile ot a JSON tileset
236
- const loader = this.tileset.loader;
237
- const options = {
238
- ...this.tileset.loadOptions,
239
- [loader.id]: {
240
- ...this.tileset.loadOptions[loader.id],
241
- isTileset: this.type === 'json',
242
- ...this._getLoaderSpecificOptions(loader.id)
243
- }
244
- };
245
- this.content = await (0, core_2.load)(contentUrl, loader, options);
246
- if (this.tileset.options.contentLoader) {
247
- await this.tileset.options.contentLoader(this);
248
- }
249
- if (this._isTileset()) {
250
- // Add tile headers for the nested tilset's subtree
251
- // Async update of the tree should be fine since there would never be edits to the same node
252
- // TODO - we need to capture the child tileset's URL
253
- this.tileset._initializeTileHeaders(this.content, this);
254
- }
255
- this.contentState = constants_1.TILE_CONTENT_STATE.READY;
256
- this._onContentLoaded();
257
- return true;
258
- }
259
- catch (error) {
260
- // Tile is unloaded before the content finishes loading
261
- this.contentState = constants_1.TILE_CONTENT_STATE.FAILED;
262
- throw error;
263
- }
264
- finally {
265
- requestToken.done();
266
- }
267
- }
268
- // Unloads the tile's content.
269
- unloadContent() {
270
- if (this.content && this.content.destroy) {
271
- this.content.destroy();
272
- }
273
- this.content = null;
274
- if (this.header.content && this.header.content.destroy) {
275
- this.header.content.destroy();
276
- }
277
- this.header.content = null;
278
- this.contentState = constants_1.TILE_CONTENT_STATE.UNLOADED;
279
- return true;
280
- }
281
- /**
282
- * Update the tile's visibility
283
- * @param {Object} frameState - frame state for tile culling
284
- * @param {string[]} viewportIds - a list of viewport ids that show this tile
285
- * @return {void}
286
- */
287
- updateVisibility(frameState, viewportIds) {
288
- if (this._frameNumber === frameState.frameNumber) {
289
- // Return early if visibility has already been checked during the traversal.
290
- // The visibility may have already been checked if the cullWithChildrenBounds optimization is used.
291
- return;
292
- }
293
- const parent = this.parent;
294
- const parentVisibilityPlaneMask = parent
295
- ? parent._visibilityPlaneMask
296
- : culling_1.CullingVolume.MASK_INDETERMINATE;
297
- if (this.tileset._traverser.options.updateTransforms) {
298
- const parentTransform = parent ? parent.computedTransform : this.tileset.modelMatrix;
299
- this._updateTransform(parentTransform);
300
- }
301
- this._distanceToCamera = this.distanceToTile(frameState);
302
- this._screenSpaceError = this.getScreenSpaceError(frameState, false);
303
- this._visibilityPlaneMask = this.visibility(frameState, parentVisibilityPlaneMask); // Use parent's plane mask to speed up visibility test
304
- this._visible = this._visibilityPlaneMask !== culling_1.CullingVolume.MASK_OUTSIDE;
305
- this._inRequestVolume = this.insideViewerRequestVolume(frameState);
306
- this._frameNumber = frameState.frameNumber;
307
- this.viewportIds = viewportIds;
308
- }
309
- // Determines whether the tile's bounding volume intersects the culling volume.
310
- // @param {FrameState} frameState The frame state.
311
- // @param {Number} parentVisibilityPlaneMask The parent's plane mask to speed up the visibility check.
312
- // @returns {Number} A plane mask as described above in {@link CullingVolume#computeVisibilityWithPlaneMask}.
313
- visibility(frameState, parentVisibilityPlaneMask) {
314
- const { cullingVolume } = frameState;
315
- const { boundingVolume } = this;
316
- // TODO Cesium specific - restore clippingPlanes
317
- // const {clippingPlanes, clippingPlanesOriginMatrix} = tileset;
318
- // if (clippingPlanes && clippingPlanes.enabled) {
319
- // const intersection = clippingPlanes.computeIntersectionWithBoundingVolume(
320
- // boundingVolume,
321
- // clippingPlanesOriginMatrix
322
- // );
323
- // this._isClipped = intersection !== Intersect.INSIDE;
324
- // if (intersection === Intersect.OUTSIDE) {
325
- // return CullingVolume.MASK_OUTSIDE;
326
- // }
327
- // }
328
- // return cullingVolume.computeVisibilityWithPlaneMask(boundingVolume, parentVisibilityPlaneMask);
329
- return cullingVolume.computeVisibilityWithPlaneMask(boundingVolume, parentVisibilityPlaneMask);
330
- }
331
- // Assuming the tile's bounding volume intersects the culling volume, determines
332
- // whether the tile's content's bounding volume intersects the culling volume.
333
- // @param {FrameState} frameState The frame state.
334
- // @returns {Intersect} The result of the intersection: the tile's content is completely outside, completely inside, or intersecting the culling volume.
335
- contentVisibility() {
336
- return true;
337
- // TODO restore
338
- /*
339
- // Assumes the tile's bounding volume intersects the culling volume already, so
340
- // just return Intersect.INSIDE if there is no content bounding volume.
341
- if (!defined(this.contentBoundingVolume)) {
342
- return Intersect.INSIDE;
343
- }
344
-
345
- if (this._visibilityPlaneMask === CullingVolume.MASK_INSIDE) {
346
- // The tile's bounding volume is completely inside the culling volume so
347
- // the content bounding volume must also be inside.
348
- return Intersect.INSIDE;
349
- }
350
-
351
- // PERFORMANCE_IDEA: is it possible to burn less CPU on this test since we know the
352
- // tile's (not the content's) bounding volume intersects the culling volume?
353
- const cullingVolume = frameState.cullingVolume;
354
- const boundingVolume = tile.contentBoundingVolume;
355
-
356
- const tileset = this.tileset;
357
- const clippingPlanes = tileset.clippingPlanes;
358
- if (defined(clippingPlanes) && clippingPlanes.enabled) {
359
- const intersection = clippingPlanes.computeIntersectionWithBoundingVolume(
360
- boundingVolume,
361
- tileset.clippingPlanesOriginMatrix
362
- );
363
- this._isClipped = intersection !== Intersect.INSIDE;
364
- if (intersection === Intersect.OUTSIDE) {
365
- return Intersect.OUTSIDE;
366
- }
367
- }
368
-
369
- return cullingVolume.computeVisibility(boundingVolume);
370
- */
371
- }
372
- /**
373
- * Computes the (potentially approximate) distance from the closest point of the tile's bounding volume to the camera.
374
- * @param frameState The frame state.
375
- * @returns {Number} The distance, in meters, or zero if the camera is inside the bounding volume.
376
- */
377
- distanceToTile(frameState) {
378
- const boundingVolume = this.boundingVolume;
379
- return Math.sqrt(Math.max(boundingVolume.distanceSquaredTo(frameState.camera.position), 0));
380
- }
381
- /**
382
- * Computes the tile's camera-space z-depth.
383
- * @param frameState The frame state.
384
- * @returns The distance, in meters.
385
- */
386
- cameraSpaceZDepth({ camera }) {
387
- const boundingVolume = this.boundingVolume; // Gets the underlying OrientedBoundingBox or BoundingSphere
388
- scratchVector.subVectors(boundingVolume.center, camera.position);
389
- return camera.direction.dot(scratchVector);
390
- }
391
- /**
392
- * Checks if the camera is inside the viewer request volume.
393
- * @param {FrameState} frameState The frame state.
394
- * @returns {Boolean} Whether the camera is inside the volume.
395
- */
396
- insideViewerRequestVolume(frameState) {
397
- const viewerRequestVolume = this._viewerRequestVolume;
398
- return (!viewerRequestVolume || viewerRequestVolume.distanceSquaredTo(frameState.camera.position) <= 0);
399
- }
400
- // TODO Cesium specific
401
- // Update whether the tile has expired.
402
- updateExpiration() {
403
- if (defined(this._expireDate) && this.contentReady && !this.hasEmptyContent) {
404
- const now = Date.now();
405
- // @ts-ignore Date.lessThan - replace with ms compare?
406
- if (Date.lessThan(this._expireDate, now)) {
407
- this.contentState = constants_1.TILE_CONTENT_STATE.EXPIRED;
408
- this._expiredContent = this.content;
409
- }
410
- }
411
- }
412
- get extras() {
413
- return this.header.extras;
414
- }
415
- // INTERNAL METHODS
416
- _initializeLodMetric(header) {
417
- if ('lodMetricType' in header) {
418
- this.lodMetricType = header.lodMetricType;
419
- }
420
- else {
421
- this.lodMetricType = (this.parent && this.parent.lodMetricType) || this.tileset.lodMetricType;
422
- // eslint-disable-next-line
423
- console.warn(`3D Tile: Required prop lodMetricType is undefined. Using parent lodMetricType`);
424
- }
425
- // This is used to compute screen space error, i.e., the error measured in pixels.
426
- if ('lodMetricValue' in header) {
427
- this.lodMetricValue = header.lodMetricValue;
428
- }
429
- else {
430
- this.lodMetricValue =
431
- (this.parent && this.parent.lodMetricValue) || this.tileset.lodMetricValue;
432
- // eslint-disable-next-line
433
- console.warn('3D Tile: Required prop lodMetricValue is undefined. Using parent lodMetricValue');
434
- }
435
- }
436
- _initializeTransforms(tileHeader) {
437
- // The local transform of this tile.
438
- this.transform = tileHeader.transform ? new core_1.Matrix4(tileHeader.transform) : new core_1.Matrix4();
439
- const parent = this.parent;
440
- const tileset = this.tileset;
441
- const parentTransform = parent && parent.computedTransform
442
- ? parent.computedTransform.clone()
443
- : tileset.modelMatrix.clone();
444
- this.computedTransform = new core_1.Matrix4(parentTransform).multiplyRight(this.transform);
445
- const parentInitialTransform = parent && parent._initialTransform ? parent._initialTransform.clone() : new core_1.Matrix4();
446
- this._initialTransform = new core_1.Matrix4(parentInitialTransform).multiplyRight(this.transform);
447
- }
448
- _initializeBoundingVolumes(tileHeader) {
449
- this._contentBoundingVolume = null;
450
- this._viewerRequestVolume = null;
451
- this._updateBoundingVolume(tileHeader);
452
- }
453
- _initializeContent(tileHeader) {
454
- // Empty tile by default
455
- this.content = { _tileset: this.tileset, _tile: this };
456
- this.hasEmptyContent = true;
457
- this.contentState = constants_1.TILE_CONTENT_STATE.UNLOADED;
458
- // When `true`, the tile's content points to an external tileset.
459
- // This is `false` until the tile's content is loaded.
460
- this.hasTilesetContent = false;
461
- if (tileHeader.contentUrl) {
462
- this.content = null;
463
- this.hasEmptyContent = false;
464
- }
465
- }
466
- // TODO - remove anything not related to basic visibility detection
467
- _initializeRenderingState(header) {
468
- this.depth = header.level || (this.parent ? this.parent.depth + 1 : 0);
469
- this._shouldRefine = false;
470
- // Members this are updated every frame for tree traversal and rendering optimizations:
471
- this._distanceToCamera = 0;
472
- this._centerZDepth = 0;
473
- this._screenSpaceError = 0;
474
- this._visibilityPlaneMask = culling_1.CullingVolume.MASK_INDETERMINATE;
475
- this._visible = undefined;
476
- this._inRequestVolume = false;
477
- this._stackLength = 0;
478
- this._selectionDepth = 0;
479
- this._frameNumber = 0;
480
- this._touchedFrame = 0;
481
- this._visitedFrame = 0;
482
- this._selectedFrame = 0;
483
- this._requestedFrame = 0;
484
- this._priority = 0.0;
485
- }
486
- _getRefine(refine) {
487
- // Inherit from parent tile if omitted.
488
- return refine || (this.parent && this.parent.refine) || constants_1.TILE_REFINEMENT.REPLACE;
489
- }
490
- _isTileset() {
491
- return this.contentUrl.indexOf('.json') !== -1;
492
- }
493
- _onContentLoaded() {
494
- // Vector and Geometry tile rendering do not support the skip LOD optimization.
495
- switch (this.content && this.content.type) {
496
- case 'vctr':
497
- case 'geom':
498
- // @ts-ignore
499
- this.tileset._traverser.disableSkipLevelOfDetail = true;
500
- break;
501
- default:
502
- }
503
- // The content may be tileset json
504
- if (this._isTileset()) {
505
- this.hasTilesetContent = true;
506
- }
507
- }
508
- _updateBoundingVolume(header) {
509
- // Update the bounding volumes
510
- this.boundingVolume = (0, bounding_volume_1.createBoundingVolume)(header.boundingVolume, this.computedTransform, this.boundingVolume);
511
- const content = header.content;
512
- if (!content) {
513
- return;
514
- }
515
- // TODO Cesium specific
516
- // Non-leaf tiles may have a content bounding-volume, which is a tight-fit bounding volume
517
- // around only the features in the tile. This box is useful for culling for rendering,
518
- // but not for culling for traversing the tree since it does not guarantee spatial coherence, i.e.,
519
- // since it only bounds features in the tile, not the entire tile, children may be
520
- // outside of this box.
521
- if (content.boundingVolume) {
522
- this._contentBoundingVolume = (0, bounding_volume_1.createBoundingVolume)(content.boundingVolume, this.computedTransform, this._contentBoundingVolume);
523
- }
524
- if (header.viewerRequestVolume) {
525
- this._viewerRequestVolume = (0, bounding_volume_1.createBoundingVolume)(header.viewerRequestVolume, this.computedTransform, this._viewerRequestVolume);
526
- }
527
- }
528
- // Update the tile's transform. The transform is applied to the tile's bounding volumes.
529
- _updateTransform(parentTransform = new core_1.Matrix4()) {
530
- const computedTransform = parentTransform.clone().multiplyRight(this.transform);
531
- const didTransformChange = !computedTransform.equals(this.computedTransform);
532
- if (!didTransformChange) {
533
- return;
534
- }
535
- this.computedTransform = computedTransform;
536
- this._updateBoundingVolume(this.header);
537
- }
538
- // Get options which are applicable only for the particular loader
539
- _getLoaderSpecificOptions(loaderId) {
540
- switch (loaderId) {
541
- case 'i3s':
542
- return {
543
- ...this.tileset.options.i3s,
544
- tile: this.header,
545
- tileset: this.tileset.tileset,
546
- isTileHeader: false
547
- };
548
- case '3d-tiles':
549
- case 'cesium-ion':
550
- default:
551
- return (0, _3d_tiles_options_1.get3dTilesOptions)(this.tileset.tileset);
552
- }
553
- }
290
+ };
291
+ this.content = await load(contentUrl, loader, options);
292
+
293
+ if (this.tileset.options.contentLoader) {
294
+ await this.tileset.options.contentLoader(this);
295
+ }
296
+
297
+ if (this._isTileset()) {
298
+ this.tileset._initializeTileHeaders(this.content, this);
299
+ }
300
+
301
+ this.contentState = TILE_CONTENT_STATE.READY;
302
+
303
+ this._onContentLoaded();
304
+
305
+ return true;
306
+ } catch (error) {
307
+ this.contentState = TILE_CONTENT_STATE.FAILED;
308
+ throw error;
309
+ } finally {
310
+ requestToken.done();
311
+ }
312
+ }
313
+
314
+ unloadContent() {
315
+ if (this.content && this.content.destroy) {
316
+ this.content.destroy();
317
+ }
318
+
319
+ this.content = null;
320
+
321
+ if (this.header.content && this.header.content.destroy) {
322
+ this.header.content.destroy();
323
+ }
324
+
325
+ this.header.content = null;
326
+ this.contentState = TILE_CONTENT_STATE.UNLOADED;
327
+ return true;
328
+ }
329
+
330
+ updateVisibility(frameState, viewportIds) {
331
+ if (this._frameNumber === frameState.frameNumber) {
332
+ return;
333
+ }
334
+
335
+ const parent = this.parent;
336
+ const parentVisibilityPlaneMask = parent ? parent._visibilityPlaneMask : CullingVolume.MASK_INDETERMINATE;
337
+
338
+ if (this.tileset._traverser.options.updateTransforms) {
339
+ const parentTransform = parent ? parent.computedTransform : this.tileset.modelMatrix;
340
+
341
+ this._updateTransform(parentTransform);
342
+ }
343
+
344
+ this._distanceToCamera = this.distanceToTile(frameState);
345
+ this._screenSpaceError = this.getScreenSpaceError(frameState, false);
346
+ this._visibilityPlaneMask = this.visibility(frameState, parentVisibilityPlaneMask);
347
+ this._visible = this._visibilityPlaneMask !== CullingVolume.MASK_OUTSIDE;
348
+ this._inRequestVolume = this.insideViewerRequestVolume(frameState);
349
+ this._frameNumber = frameState.frameNumber;
350
+ this.viewportIds = viewportIds;
351
+ }
352
+
353
+ visibility(frameState, parentVisibilityPlaneMask) {
354
+ const {
355
+ cullingVolume
356
+ } = frameState;
357
+ const {
358
+ boundingVolume
359
+ } = this;
360
+ return cullingVolume.computeVisibilityWithPlaneMask(boundingVolume, parentVisibilityPlaneMask);
361
+ }
362
+
363
+ contentVisibility() {
364
+ return true;
365
+ }
366
+
367
+ distanceToTile(frameState) {
368
+ const boundingVolume = this.boundingVolume;
369
+ return Math.sqrt(Math.max(boundingVolume.distanceSquaredTo(frameState.camera.position), 0));
370
+ }
371
+
372
+ cameraSpaceZDepth({
373
+ camera
374
+ }) {
375
+ const boundingVolume = this.boundingVolume;
376
+ scratchVector.subVectors(boundingVolume.center, camera.position);
377
+ return camera.direction.dot(scratchVector);
378
+ }
379
+
380
+ insideViewerRequestVolume(frameState) {
381
+ const viewerRequestVolume = this._viewerRequestVolume;
382
+ return !viewerRequestVolume || viewerRequestVolume.distanceSquaredTo(frameState.camera.position) <= 0;
383
+ }
384
+
385
+ updateExpiration() {
386
+ if (defined(this._expireDate) && this.contentReady && !this.hasEmptyContent) {
387
+ const now = Date.now();
388
+
389
+ if (Date.lessThan(this._expireDate, now)) {
390
+ this.contentState = TILE_CONTENT_STATE.EXPIRED;
391
+ this._expiredContent = this.content;
392
+ }
393
+ }
394
+ }
395
+
396
+ get extras() {
397
+ return this.header.extras;
398
+ }
399
+
400
+ _initializeLodMetric(header) {
401
+ if ('lodMetricType' in header) {
402
+ this.lodMetricType = header.lodMetricType;
403
+ } else {
404
+ this.lodMetricType = this.parent && this.parent.lodMetricType || this.tileset.lodMetricType;
405
+ console.warn("3D Tile: Required prop lodMetricType is undefined. Using parent lodMetricType");
406
+ }
407
+
408
+ if ('lodMetricValue' in header) {
409
+ this.lodMetricValue = header.lodMetricValue;
410
+ } else {
411
+ this.lodMetricValue = this.parent && this.parent.lodMetricValue || this.tileset.lodMetricValue;
412
+ console.warn('3D Tile: Required prop lodMetricValue is undefined. Using parent lodMetricValue');
413
+ }
414
+ }
415
+
416
+ _initializeTransforms(tileHeader) {
417
+ this.transform = tileHeader.transform ? new Matrix4(tileHeader.transform) : new Matrix4();
418
+ const parent = this.parent;
419
+ const tileset = this.tileset;
420
+ const parentTransform = parent && parent.computedTransform ? parent.computedTransform.clone() : tileset.modelMatrix.clone();
421
+ this.computedTransform = new Matrix4(parentTransform).multiplyRight(this.transform);
422
+ const parentInitialTransform = parent && parent._initialTransform ? parent._initialTransform.clone() : new Matrix4();
423
+ this._initialTransform = new Matrix4(parentInitialTransform).multiplyRight(this.transform);
424
+ }
425
+
426
+ _initializeBoundingVolumes(tileHeader) {
427
+ this._contentBoundingVolume = null;
428
+ this._viewerRequestVolume = null;
429
+
430
+ this._updateBoundingVolume(tileHeader);
431
+ }
432
+
433
+ _initializeContent(tileHeader) {
434
+ this.content = {
435
+ _tileset: this.tileset,
436
+ _tile: this
437
+ };
438
+ this.hasEmptyContent = true;
439
+ this.contentState = TILE_CONTENT_STATE.UNLOADED;
440
+ this.hasTilesetContent = false;
441
+
442
+ if (tileHeader.contentUrl) {
443
+ this.content = null;
444
+ this.hasEmptyContent = false;
445
+ }
446
+ }
447
+
448
+ _initializeRenderingState(header) {
449
+ this.depth = header.level || (this.parent ? this.parent.depth + 1 : 0);
450
+ this._shouldRefine = false;
451
+ this._distanceToCamera = 0;
452
+ this._centerZDepth = 0;
453
+ this._screenSpaceError = 0;
454
+ this._visibilityPlaneMask = CullingVolume.MASK_INDETERMINATE;
455
+ this._visible = undefined;
456
+ this._inRequestVolume = false;
457
+ this._stackLength = 0;
458
+ this._selectionDepth = 0;
459
+ this._frameNumber = 0;
460
+ this._touchedFrame = 0;
461
+ this._visitedFrame = 0;
462
+ this._selectedFrame = 0;
463
+ this._requestedFrame = 0;
464
+ this._priority = 0.0;
465
+ }
466
+
467
+ _getRefine(refine) {
468
+ return refine || this.parent && this.parent.refine || TILE_REFINEMENT.REPLACE;
469
+ }
470
+
471
+ _isTileset() {
472
+ return this.contentUrl.indexOf('.json') !== -1;
473
+ }
474
+
475
+ _onContentLoaded() {
476
+ switch (this.content && this.content.type) {
477
+ case 'vctr':
478
+ case 'geom':
479
+ this.tileset._traverser.disableSkipLevelOfDetail = true;
480
+ break;
481
+
482
+ default:
483
+ }
484
+
485
+ if (this._isTileset()) {
486
+ this.hasTilesetContent = true;
487
+ }
488
+ }
489
+
490
+ _updateBoundingVolume(header) {
491
+ this.boundingVolume = createBoundingVolume(header.boundingVolume, this.computedTransform, this.boundingVolume);
492
+ const content = header.content;
493
+
494
+ if (!content) {
495
+ return;
496
+ }
497
+
498
+ if (content.boundingVolume) {
499
+ this._contentBoundingVolume = createBoundingVolume(content.boundingVolume, this.computedTransform, this._contentBoundingVolume);
500
+ }
501
+
502
+ if (header.viewerRequestVolume) {
503
+ this._viewerRequestVolume = createBoundingVolume(header.viewerRequestVolume, this.computedTransform, this._viewerRequestVolume);
504
+ }
505
+ }
506
+
507
+ _updateTransform(parentTransform = new Matrix4()) {
508
+ const computedTransform = parentTransform.clone().multiplyRight(this.transform);
509
+ const didTransformChange = !computedTransform.equals(this.computedTransform);
510
+
511
+ if (!didTransformChange) {
512
+ return;
513
+ }
514
+
515
+ this.computedTransform = computedTransform;
516
+
517
+ this._updateBoundingVolume(this.header);
518
+ }
519
+
520
+ _getLoaderSpecificOptions(loaderId) {
521
+ switch (loaderId) {
522
+ case 'i3s':
523
+ return { ...this.tileset.options.i3s,
524
+ tile: this.header,
525
+ tileset: this.tileset.tileset,
526
+ isTileHeader: false
527
+ };
528
+
529
+ case '3d-tiles':
530
+ case 'cesium-ion':
531
+ default:
532
+ return get3dTilesOptions(this.tileset.tileset);
533
+ }
534
+ }
535
+
554
536
  }
555
- exports.default = TileHeader;
537
+ //# sourceMappingURL=tile-3d.js.map