@loaders.gl/tiles-3d 5.0.0-beta.10 → 5.0.0-beta.11

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 (154) hide show
  1. package/dist/3d-tiles/3d-tiles-archive-loader.js +1 -1
  2. package/dist/3d-tiles/dist.dev.js +169 -581
  3. package/dist/3d-tiles/dist.min.js +16 -16
  4. package/dist/3d-tiles/index.cjs +115 -390
  5. package/dist/3d-tiles/index.cjs.map +3 -3
  6. package/dist/3d-tiles/lib/classes/helpers/tile-3d-accessor-utils.d.ts +1 -2
  7. package/dist/3d-tiles/lib/classes/helpers/tile-3d-accessor-utils.d.ts.map +1 -1
  8. package/dist/3d-tiles/lib/classes/helpers/tile-3d-accessor-utils.js +3 -4
  9. package/dist/3d-tiles/lib/classes/helpers/tile-3d-accessor-utils.js.map +1 -1
  10. package/dist/3d-tiles/lib/classes/helpers/tile-component-types.d.ts +4 -0
  11. package/dist/3d-tiles/lib/classes/helpers/tile-component-types.d.ts.map +1 -0
  12. package/dist/3d-tiles/lib/classes/helpers/tile-component-types.js +36 -0
  13. package/dist/3d-tiles/lib/classes/helpers/tile-component-types.js.map +1 -0
  14. package/dist/3d-tiles/lib/classes/tile-3d-batch-table-hierarchy.d.ts.map +1 -1
  15. package/dist/3d-tiles/lib/classes/tile-3d-batch-table-hierarchy.js +3 -4
  16. package/dist/3d-tiles/lib/classes/tile-3d-batch-table-hierarchy.js.map +1 -1
  17. package/dist/3d-tiles/lib/classes/tile-3d-batch-table.d.ts +1 -1
  18. package/dist/3d-tiles/lib/classes/tile-3d-feature-table.d.ts +9 -5
  19. package/dist/3d-tiles/lib/classes/tile-3d-feature-table.d.ts.map +1 -1
  20. package/dist/3d-tiles/lib/classes/tile-3d-feature-table.js +15 -12
  21. package/dist/3d-tiles/lib/classes/tile-3d-feature-table.js.map +1 -1
  22. package/dist/3d-tiles/lib/parsers/helpers/normalize-3d-tile-colors.d.ts +0 -1
  23. package/dist/3d-tiles/lib/parsers/helpers/normalize-3d-tile-colors.d.ts.map +1 -1
  24. package/dist/3d-tiles/lib/parsers/helpers/normalize-3d-tile-colors.js +2 -4
  25. package/dist/3d-tiles/lib/parsers/helpers/normalize-3d-tile-colors.js.map +1 -1
  26. package/dist/3d-tiles/lib/parsers/helpers/normalize-3d-tile-normals.d.ts +1 -2
  27. package/dist/3d-tiles/lib/parsers/helpers/normalize-3d-tile-normals.d.ts.map +1 -1
  28. package/dist/3d-tiles/lib/parsers/helpers/normalize-3d-tile-normals.js +7 -7
  29. package/dist/3d-tiles/lib/parsers/helpers/normalize-3d-tile-normals.js.map +1 -1
  30. package/dist/3d-tiles/lib/parsers/helpers/normalize-3d-tile-positions.d.ts.map +1 -1
  31. package/dist/3d-tiles/lib/parsers/helpers/normalize-3d-tile-positions.js +0 -2
  32. package/dist/3d-tiles/lib/parsers/helpers/normalize-3d-tile-positions.js.map +1 -1
  33. package/dist/3d-tiles/lib/parsers/parse-3d-tile-batched-model.d.ts.map +1 -1
  34. package/dist/3d-tiles/lib/parsers/parse-3d-tile-batched-model.js +1 -2
  35. package/dist/3d-tiles/lib/parsers/parse-3d-tile-batched-model.js.map +1 -1
  36. package/dist/3d-tiles/lib/parsers/parse-3d-tile-instanced-model.js +13 -13
  37. package/dist/3d-tiles/lib/parsers/parse-3d-tile-instanced-model.js.map +1 -1
  38. package/dist/3d-tiles/lib/parsers/parse-3d-tile-point-cloud.d.ts.map +1 -1
  39. package/dist/3d-tiles/lib/parsers/parse-3d-tile-point-cloud.js +22 -23
  40. package/dist/3d-tiles/lib/parsers/parse-3d-tile-point-cloud.js.map +1 -1
  41. package/dist/3d-tiles/lib/utils/version.js +1 -1
  42. package/dist/3d-tiles/types.d.ts +7 -3
  43. package/dist/3d-tiles/types.d.ts.map +1 -1
  44. package/dist/3d-tiles-archive-writer.cjs +1 -1
  45. package/dist/copc/copc-loader.d.ts.map +1 -1
  46. package/dist/copc/copc-loader.js +10 -7
  47. package/dist/copc/copc-loader.js.map +1 -1
  48. package/dist/copc/copc-writer.d.ts +5 -4
  49. package/dist/copc/copc-writer.d.ts.map +1 -1
  50. package/dist/copc/copc-writer.js +1 -1
  51. package/dist/copc/copc-writer.js.map +1 -1
  52. package/dist/copc/index.cjs +809 -124
  53. package/dist/copc/index.cjs.map +3 -3
  54. package/dist/dist.dev.js +45 -77
  55. package/dist/dist.min.js +10 -10
  56. package/dist/i3s/arcgis-webscene-loader.js +1 -1
  57. package/dist/i3s/dist.dev.js +11915 -12119
  58. package/dist/i3s/dist.min.js +25 -25
  59. package/dist/i3s/i3s-attribute-loader.js +1 -1
  60. package/dist/i3s/i3s-building-scene-layer-loader.js +1 -1
  61. package/dist/i3s/i3s-content-loader.js +1 -1
  62. package/dist/i3s/i3s-lepcc-loader-types.js +1 -1
  63. package/dist/i3s/i3s-loader.js +1 -1
  64. package/dist/i3s/i3s-mesh-attributes.d.ts +2 -2
  65. package/dist/i3s/i3s-mesh-attributes.d.ts.map +1 -1
  66. package/dist/i3s/i3s-mesh-attributes.js +6 -11
  67. package/dist/i3s/i3s-mesh-attributes.js.map +1 -1
  68. package/dist/i3s/i3s-mesh-writer.js +2 -3
  69. package/dist/i3s/i3s-mesh-writer.js.map +1 -1
  70. package/dist/i3s/i3s-node-page-loader.js +1 -1
  71. package/dist/i3s/i3s-slpk-loader.js +1 -1
  72. package/dist/i3s/i3s-slpk-writer.js +1 -1
  73. package/dist/i3s/index.cjs +314 -442
  74. package/dist/i3s/index.cjs.map +3 -3
  75. package/dist/i3s/lib/parsers/constants.d.ts +0 -3
  76. package/dist/i3s/lib/parsers/constants.d.ts.map +1 -1
  77. package/dist/i3s/lib/parsers/constants.js +0 -8
  78. package/dist/i3s/lib/parsers/constants.js.map +1 -1
  79. package/dist/i3s/lib/parsers/parse-i3s-tile-content.d.ts.map +1 -1
  80. package/dist/i3s/lib/parsers/parse-i3s-tile-content.js +1 -2
  81. package/dist/i3s/lib/parsers/parse-i3s-tile-content.js.map +1 -1
  82. package/dist/i3s/types.d.ts +0 -1
  83. package/dist/i3s/types.d.ts.map +1 -1
  84. package/dist/i3s-content-worker-node.js +11 -11
  85. package/dist/i3s-content-worker-node.js.map +4 -4
  86. package/dist/i3s-content-worker.js +485 -879
  87. package/dist/i3s-lepcc-worker-node.js +2 -2
  88. package/dist/i3s-lepcc-worker.js +2 -2
  89. package/dist/i3s-mesh-writer.cjs +87 -206
  90. package/dist/i3s-mesh-writer.cjs.map +3 -3
  91. package/dist/i3s-slpk-writer.cjs +1 -1
  92. package/dist/index.cjs +44 -41
  93. package/dist/index.cjs.map +1 -1
  94. package/dist/point-cloud-tile-loader-types.js +1 -1
  95. package/dist/point-cloud-tile-loader.cjs +17 -28
  96. package/dist/point-cloud-tile-loader.cjs.map +1 -1
  97. package/dist/point-cloud-tile-source.cjs +16 -27
  98. package/dist/point-cloud-tile-source.cjs.map +1 -1
  99. package/dist/point-cloud-tile-source.js +2 -2
  100. package/dist/point-cloud-tile-source.js.map +1 -1
  101. package/dist/potree/dist.dev.js +985 -139
  102. package/dist/potree/dist.min.js +28 -28
  103. package/dist/potree/index.cjs +813 -140
  104. package/dist/potree/index.cjs.map +3 -3
  105. package/dist/potree/lib/potree-node-source.d.ts.map +1 -1
  106. package/dist/potree/lib/potree-node-source.js +2 -14
  107. package/dist/potree/lib/potree-node-source.js.map +1 -1
  108. package/dist/potree/parsers/parse-potree-bin.js +3 -3
  109. package/dist/potree/parsers/parse-potree-bin.js.map +1 -1
  110. package/dist/potree/potree-bin-loader.js +1 -1
  111. package/dist/potree/potree-hierarchy-chunk-loader.js +1 -1
  112. package/dist/potree/potree-loader-types.js +1 -1
  113. package/dist/potree/potree-writer.d.ts +3 -3
  114. package/dist/potree/potree-writer.d.ts.map +1 -1
  115. package/dist/potree/potree-writer.js +2 -2
  116. package/dist/potree/potree-writer.js.map +1 -1
  117. package/dist/potree/potree2-source.d.ts +1 -1
  118. package/dist/potree/potree2-source.d.ts.map +1 -1
  119. package/dist/potree/potree2-source.js +6 -3
  120. package/dist/potree/potree2-source.js.map +1 -1
  121. package/dist/potree-loader.cjs +817 -153
  122. package/dist/potree-loader.cjs.map +3 -3
  123. package/dist/tileset-3d/helpers/frame-state.d.ts +2 -1
  124. package/dist/tileset-3d/helpers/frame-state.d.ts.map +1 -1
  125. package/dist/tileset-3d/helpers/frame-state.js +41 -15
  126. package/dist/tileset-3d/helpers/frame-state.js.map +1 -1
  127. package/dist/types.d.ts +15 -0
  128. package/dist/types.d.ts.map +1 -1
  129. package/package.json +13 -13
  130. package/src/3d-tiles/lib/classes/helpers/tile-3d-accessor-utils.ts +3 -4
  131. package/src/3d-tiles/lib/classes/helpers/tile-component-types.ts +39 -0
  132. package/src/3d-tiles/lib/classes/tile-3d-batch-table-hierarchy.ts +3 -4
  133. package/src/3d-tiles/lib/classes/tile-3d-feature-table.ts +38 -14
  134. package/src/3d-tiles/lib/parsers/helpers/normalize-3d-tile-colors.ts +2 -5
  135. package/src/3d-tiles/lib/parsers/helpers/normalize-3d-tile-normals.ts +10 -10
  136. package/src/3d-tiles/lib/parsers/helpers/normalize-3d-tile-positions.ts +0 -2
  137. package/src/3d-tiles/lib/parsers/parse-3d-tile-batched-model.ts +1 -2
  138. package/src/3d-tiles/lib/parsers/parse-3d-tile-instanced-model.ts +19 -19
  139. package/src/3d-tiles/lib/parsers/parse-3d-tile-point-cloud.ts +22 -23
  140. package/src/3d-tiles/types.ts +4 -3
  141. package/src/copc/copc-loader.ts +8 -8
  142. package/src/copc/copc-writer.ts +6 -5
  143. package/src/i3s/i3s-mesh-attributes.ts +9 -17
  144. package/src/i3s/i3s-mesh-writer.ts +4 -3
  145. package/src/i3s/lib/parsers/constants.ts +0 -9
  146. package/src/i3s/lib/parsers/parse-i3s-tile-content.ts +1 -2
  147. package/src/i3s/types.ts +0 -1
  148. package/src/point-cloud-tile-source.ts +2 -2
  149. package/src/potree/lib/potree-node-source.ts +2 -15
  150. package/src/potree/parsers/parse-potree-bin.ts +3 -3
  151. package/src/potree/potree-writer.ts +6 -11
  152. package/src/potree/potree2-source.ts +6 -3
  153. package/src/tileset-3d/helpers/frame-state.ts +43 -15
  154. package/src/types.ts +15 -0
package/dist/dist.dev.js CHANGED
@@ -5327,7 +5327,7 @@ var __exports__ = (() => {
5327
5327
  }
5328
5328
  return IDENTITY_MATRIX3;
5329
5329
  }
5330
- var INDICES, IDENTITY_MATRIX, Matrix3, ZERO_MATRIX3, IDENTITY_MATRIX3;
5330
+ var IDENTITY_MATRIX, Matrix3, ZERO_MATRIX3, IDENTITY_MATRIX3;
5331
5331
  var init_matrix3 = __esm({
5332
5332
  "../../node_modules/@math.gl/core/dist/classes/matrix3.js"() {
5333
5333
  init_matrix();
@@ -5336,17 +5336,6 @@ var __exports__ = (() => {
5336
5336
  init_mat3();
5337
5337
  init_vec2();
5338
5338
  init_vec3();
5339
- (function(INDICES3) {
5340
- INDICES3[INDICES3["COL0ROW0"] = 0] = "COL0ROW0";
5341
- INDICES3[INDICES3["COL0ROW1"] = 1] = "COL0ROW1";
5342
- INDICES3[INDICES3["COL0ROW2"] = 2] = "COL0ROW2";
5343
- INDICES3[INDICES3["COL1ROW0"] = 3] = "COL1ROW0";
5344
- INDICES3[INDICES3["COL1ROW1"] = 4] = "COL1ROW1";
5345
- INDICES3[INDICES3["COL1ROW2"] = 5] = "COL1ROW2";
5346
- INDICES3[INDICES3["COL2ROW0"] = 6] = "COL2ROW0";
5347
- INDICES3[INDICES3["COL2ROW1"] = 7] = "COL2ROW1";
5348
- INDICES3[INDICES3["COL2ROW2"] = 8] = "COL2ROW2";
5349
- })(INDICES || (INDICES = {}));
5350
5339
  IDENTITY_MATRIX = Object.freeze([1, 0, 0, 0, 1, 0, 0, 0, 1]);
5351
5340
  Matrix3 = class extends Matrix {
5352
5341
  static get IDENTITY() {
@@ -5361,9 +5350,6 @@ var __exports__ = (() => {
5361
5350
  get RANK() {
5362
5351
  return 3;
5363
5352
  }
5364
- get INDICES() {
5365
- return INDICES;
5366
- }
5367
5353
  constructor(array2) {
5368
5354
  super(-0, -0, -0, -0, -0, -0, -0, -0, -0);
5369
5355
  if (arguments.length === 1 && Array.isArray(array2)) {
@@ -6297,7 +6283,7 @@ var __exports__ = (() => {
6297
6283
  result[15] = 0;
6298
6284
  return result;
6299
6285
  }
6300
- var INDICES2, DEFAULT_FOVY, DEFAULT_ASPECT, DEFAULT_NEAR, DEFAULT_FAR, IDENTITY_MATRIX2, Matrix4, ZERO2, IDENTITY;
6286
+ var DEFAULT_FOVY, DEFAULT_ASPECT, DEFAULT_NEAR, DEFAULT_FAR, IDENTITY_MATRIX2, Matrix4, ZERO2, IDENTITY;
6301
6287
  var init_matrix4 = __esm({
6302
6288
  "../../node_modules/@math.gl/core/dist/classes/matrix4.js"() {
6303
6289
  init_matrix();
@@ -6308,24 +6294,6 @@ var __exports__ = (() => {
6308
6294
  init_vec2();
6309
6295
  init_vec3();
6310
6296
  init_vec4();
6311
- (function(INDICES3) {
6312
- INDICES3[INDICES3["COL0ROW0"] = 0] = "COL0ROW0";
6313
- INDICES3[INDICES3["COL0ROW1"] = 1] = "COL0ROW1";
6314
- INDICES3[INDICES3["COL0ROW2"] = 2] = "COL0ROW2";
6315
- INDICES3[INDICES3["COL0ROW3"] = 3] = "COL0ROW3";
6316
- INDICES3[INDICES3["COL1ROW0"] = 4] = "COL1ROW0";
6317
- INDICES3[INDICES3["COL1ROW1"] = 5] = "COL1ROW1";
6318
- INDICES3[INDICES3["COL1ROW2"] = 6] = "COL1ROW2";
6319
- INDICES3[INDICES3["COL1ROW3"] = 7] = "COL1ROW3";
6320
- INDICES3[INDICES3["COL2ROW0"] = 8] = "COL2ROW0";
6321
- INDICES3[INDICES3["COL2ROW1"] = 9] = "COL2ROW1";
6322
- INDICES3[INDICES3["COL2ROW2"] = 10] = "COL2ROW2";
6323
- INDICES3[INDICES3["COL2ROW3"] = 11] = "COL2ROW3";
6324
- INDICES3[INDICES3["COL3ROW0"] = 12] = "COL3ROW0";
6325
- INDICES3[INDICES3["COL3ROW1"] = 13] = "COL3ROW1";
6326
- INDICES3[INDICES3["COL3ROW2"] = 14] = "COL3ROW2";
6327
- INDICES3[INDICES3["COL3ROW3"] = 15] = "COL3ROW3";
6328
- })(INDICES2 || (INDICES2 = {}));
6329
6297
  DEFAULT_FOVY = 45 * Math.PI / 180;
6330
6298
  DEFAULT_ASPECT = 1;
6331
6299
  DEFAULT_NEAR = 0.1;
@@ -6344,9 +6312,6 @@ var __exports__ = (() => {
6344
6312
  get RANK() {
6345
6313
  return 4;
6346
6314
  }
6347
- get INDICES() {
6348
- return INDICES2;
6349
- }
6350
6315
  constructor(array2) {
6351
6316
  super(-0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0);
6352
6317
  if (arguments.length === 1 && Array.isArray(array2)) {
@@ -27947,7 +27912,7 @@ return true;`);
27947
27912
  });
27948
27913
 
27949
27914
  // ../core/src/lib/loader-utils/native-arrow.ts
27950
- function isNativeArrowTable(value2) {
27915
+ function isArrowTable2(value2) {
27951
27916
  return Boolean(
27952
27917
  value2 && typeof value2 === "object" && "schema" in value2 && "batches" in value2 && Array.isArray(value2.batches) && "numRows" in value2 && typeof value2.numRows === "number" && "getChildAt" in value2 && typeof value2.getChildAt === "function"
27953
27918
  );
@@ -28151,7 +28116,7 @@ return true;`);
28151
28116
  });
28152
28117
 
28153
28118
  // ../core/src/schema-utils/lib/mesh/convert-mesh-to-table.ts
28154
- function convertMeshToArrowTableWrapper(mesh, batchSize) {
28119
+ function convertMeshToArrowTable(mesh) {
28155
28120
  return makeMeshArrowTable(mesh.attributes, {
28156
28121
  schema: mesh.schema,
28157
28122
  topology: mesh.topology,
@@ -28172,22 +28137,14 @@ return true;`);
28172
28137
  fields.push(
28173
28138
  getAttributeArrowField(options.schema, attributeName, column, attribute.componentType)
28174
28139
  );
28175
- if (attributeName === "POSITION" && options.indices?.value?.length) {
28140
+ if (attributeName === attributeNames[0] && options.indices?.value?.length) {
28176
28141
  const indicesField = indexedMeshArrowSchema.fields.find((field) => field.name === "indices");
28177
28142
  columns.indices = getIndicesVector(options.indices.value, column.length, indicesField.type);
28178
28143
  fields.push(indicesField);
28179
28144
  }
28180
28145
  }
28181
28146
  const arrowSchema = new Schema2(fields, getMeshArrowMetadata(options));
28182
- const table = columns[attributeNames[0]]?.length === 0 ? new Table(arrowSchema) : new Table(arrowSchema, columns);
28183
- const schema = serializeArrowSchema(table.schema);
28184
- return {
28185
- shape: "arrow-table",
28186
- schema,
28187
- data: table,
28188
- topology: options.topology || "point-list",
28189
- indices: options.indices
28190
- };
28147
+ return columns[attributeNames[0]]?.length === 0 ? new Table(arrowSchema) : new Table(arrowSchema, columns);
28191
28148
  }
28192
28149
  function getAttributeArrowVector(value2, size, componentType) {
28193
28150
  if (componentType === "float16") {
@@ -28312,18 +28269,10 @@ return true;`);
28312
28269
 
28313
28270
  // ../core/src/schema-utils/lib/mesh/convert-table-to-mesh.ts
28314
28271
  function convertTableToMesh(table) {
28315
- if (isNativeArrowTable(table)) return convertArrowTableToMesh(table);
28316
- switch (table.shape) {
28317
- // case 'columnar-table':
28318
- // return convertColumnarTableToMesh(table);
28319
- case "arrow-table":
28320
- return convertArrowTableToMesh(table);
28321
- default:
28322
- throw new Error(table.shape);
28323
- }
28272
+ if (isArrowTable2(table)) return convertArrowTableToMesh(table);
28273
+ throw new Error(table.shape);
28324
28274
  }
28325
- function convertArrowTableToMesh(table) {
28326
- const arrowTable = isNativeArrowTable(table) ? table : table.data;
28275
+ function convertArrowTableToMesh(arrowTable) {
28327
28276
  const schema = serializeArrowSchema(arrowTable.schema);
28328
28277
  const localBounds = arrowTable.batches.length === 1 ? arrowTable.batches[0].metadata.get("boundingBox") : void 0;
28329
28278
  if (localBounds) schema.metadata = { ...schema.metadata, boundingBox: localBounds };
@@ -28427,13 +28376,18 @@ return true;`);
28427
28376
  if (!(attributeData.type instanceof FixedSizeList2)) {
28428
28377
  return attributeData.toArray();
28429
28378
  }
28430
- const values = attributeData.data[0].children[0].values;
28379
+ if (attributeData.length === 0) {
28380
+ const EmptyStorage = attributeData.type.valueType.ArrayType;
28381
+ return new EmptyStorage(0);
28382
+ }
28383
+ const values = attributeData.data.find((chunk) => chunk.length > 0).children[0].values;
28431
28384
  const TypedArrayConstructor = values.constructor;
28432
28385
  const typedArray = new TypedArrayConstructor(attributeData.length * size);
28433
28386
  let targetOffset = 0;
28434
28387
  for (const data of attributeData.data) {
28435
- const child2 = data.children[0];
28436
28388
  const sourceLength = data.length * size;
28389
+ if (sourceLength === 0) continue;
28390
+ const child2 = data.children[0];
28437
28391
  const sourceOffset = child2.offset || data.offset * size;
28438
28392
  const sourceStart = sourceOffset + sourceLength <= child2.values.length ? sourceOffset : 0;
28439
28393
  const source = child2.values.subarray(sourceStart, sourceStart + sourceLength);
@@ -28668,7 +28622,7 @@ return true;`);
28668
28622
  async initialize(input) {
28669
28623
  this.signal.throwIfAborted();
28670
28624
  if (!("attributes" in input)) {
28671
- const table = "shape" in input ? input.data : input;
28625
+ const table = input;
28672
28626
  const buffers2 = /* @__PURE__ */ new Set();
28673
28627
  let arrowBytes = 0;
28674
28628
  const checkData = (data) => {
@@ -28911,7 +28865,7 @@ return true;`);
28911
28865
  const mesh = await this.tiler.getTileMesh(tile.id);
28912
28866
  if (!mesh.header.vertexCount) return null;
28913
28867
  return {
28914
- data: convertMeshToArrowTableWrapper(mesh),
28868
+ data: convertMeshToArrowTable(mesh),
28915
28869
  pointCount: mesh.header.vertexCount,
28916
28870
  cartographicOrigin: [0, 0, 0],
28917
28871
  coordinateSystem: "cartesian",
@@ -29333,18 +29287,7 @@ return true;`);
29333
29287
  enuToFixedTransform.transformAsVector(new Vector3(cameraUp).scale(metersPerUnit))
29334
29288
  ).normalize();
29335
29289
  commonSpacePlanesToWGS84(viewport);
29336
- const ViewportClass = viewport.constructor;
29337
- const { longitude, latitude, width, bearing, zoom, position } = viewport;
29338
- const topDownViewport = new ViewportClass({
29339
- longitude,
29340
- latitude,
29341
- height,
29342
- width,
29343
- bearing,
29344
- zoom,
29345
- position,
29346
- pitch: 0
29347
- });
29290
+ const topDownViewport = getTopDownViewport(viewport);
29348
29291
  const verticalFieldOfView = Number.isFinite(viewport.fovy) && Number(viewport.fovy) > 0 && Number(viewport.fovy) < 180 ? Number(viewport.fovy) * Math.PI / 180 : Math.PI / 3;
29349
29292
  return {
29350
29293
  camera: {
@@ -29391,7 +29334,7 @@ return true;`);
29391
29334
  return [tiles, []];
29392
29335
  }
29393
29336
  const tuples = [];
29394
- const { longitude: viewportLongitude, latitude: viewportLatitude } = frameState.viewport;
29337
+ const [viewportLongitude, viewportLatitude] = getViewportLongitudeLatitude(frameState.viewport);
29395
29338
  for (const [index, tile] of tiles.entries()) {
29396
29339
  const [longitude, latitude] = tile.header.mbs;
29397
29340
  const deltaLon = Math.abs(viewportLongitude - longitude);
@@ -29410,6 +29353,31 @@ return true;`);
29410
29353
  }
29411
29354
  return [selectedTiles, unselectedTiles];
29412
29355
  }
29356
+ function getTopDownViewport(viewport) {
29357
+ if (viewport.getTopDownViewport) {
29358
+ return viewport.getTopDownViewport();
29359
+ }
29360
+ const ViewportClass = viewport.constructor;
29361
+ const { longitude, latitude, height, width, bearing, zoom, position } = viewport;
29362
+ return new ViewportClass({
29363
+ longitude,
29364
+ latitude,
29365
+ height,
29366
+ width,
29367
+ bearing,
29368
+ zoom,
29369
+ position,
29370
+ pitch: 0
29371
+ });
29372
+ }
29373
+ function getViewportLongitudeLatitude(viewport) {
29374
+ const { longitude, latitude } = viewport;
29375
+ if (Number.isFinite(longitude) && Number.isFinite(latitude)) {
29376
+ return [longitude, latitude];
29377
+ }
29378
+ const [centerLongitude, centerLatitude] = viewport.unprojectPosition(viewport.center);
29379
+ return [centerLongitude, centerLatitude];
29380
+ }
29413
29381
  function commonSpacePlanesToWGS84(viewport) {
29414
29382
  const frustumPlanes = viewport.getFrustumPlanes();
29415
29383
  const nearCenterCommon = closestPointOnPlane(frustumPlanes.near, viewport.cameraPosition);