@loaders.gl/3d-tiles 4.3.0-alpha.6 → 4.3.0-alpha.8

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/dist/index.cjs CHANGED
@@ -48,7 +48,7 @@ var import_loader_utils8 = require("@loaders.gl/loader-utils");
48
48
  var import_tiles2 = require("@loaders.gl/tiles");
49
49
 
50
50
  // dist/lib/utils/version.js
51
- var VERSION = true ? "4.3.0-alpha.5" : "latest";
51
+ var VERSION = true ? "4.3.0-alpha.7" : "latest";
52
52
 
53
53
  // dist/lib/constants.js
54
54
  var TILE3D_TYPE = {
@@ -1810,95 +1810,89 @@ function getChildS2VolumeBox(s2VolumeBox, index, subdivisionScheme) {
1810
1810
  return void 0;
1811
1811
  }
1812
1812
  async function parseImplicitTiles(params) {
1813
- const { implicitOptions, parentData = {
1814
- mortonIndex: 0,
1815
- x: 0,
1816
- y: 0,
1817
- z: 0
1818
- }, childIndex = 0, s2VolumeBox, loaderOptions } = params;
1819
- let { subtree, level = 0, globalData = {
1813
+ const { subtree, subtreeData = {
1820
1814
  level: 0,
1821
- mortonIndex: 0,
1822
1815
  x: 0,
1823
1816
  y: 0,
1824
1817
  z: 0
1825
- } } = params;
1818
+ }, parentData = {
1819
+ mortonIndex: 0,
1820
+ localLevel: -1,
1821
+ localX: 0,
1822
+ localY: 0,
1823
+ localZ: 0
1824
+ }, childIndex = 0, implicitOptions, loaderOptions, s2VolumeBox } = params;
1826
1825
  const { subdivisionScheme, subtreeLevels, maximumLevel, contentUrlTemplate, subtreesUriTemplate, basePath } = implicitOptions;
1827
1826
  const tile = { children: [], lodMetricValue: 0, contentUrl: "" };
1828
1827
  if (!maximumLevel) {
1829
1828
  import_log.default.once(`Missing 'maximumLevel' or 'availableLevels' property. The subtree ${contentUrlTemplate} won't be loaded...`);
1830
1829
  return tile;
1831
1830
  }
1832
- const lev = level + globalData.level;
1833
- if (lev > maximumLevel) {
1831
+ const localLevel = parentData.localLevel + 1;
1832
+ const level = subtreeData.level + localLevel;
1833
+ if (level > maximumLevel) {
1834
1834
  return tile;
1835
1835
  }
1836
1836
  const childrenPerTile = SUBDIVISION_COUNT_MAP[subdivisionScheme];
1837
1837
  const bitsPerTile = Math.log2(childrenPerTile);
1838
- const childX = childIndex & 1;
1839
- const childY = childIndex >> 1 & 1;
1840
- const childZ = childIndex >> 2 & 1;
1841
- const levelOffset = (childrenPerTile ** level - 1) / (childrenPerTile - 1);
1842
- let childTileMortonIndex = concatBits(parentData.mortonIndex, childIndex, bitsPerTile);
1843
- let tileAvailabilityIndex = levelOffset + childTileMortonIndex;
1844
- let childTileX = concatBits(parentData.x, childX, 1);
1845
- let childTileY = concatBits(parentData.y, childY, 1);
1846
- let childTileZ = concatBits(parentData.z, childZ, 1);
1847
- let isChildSubtreeAvailable = false;
1848
- if (level >= subtreeLevels) {
1849
- isChildSubtreeAvailable = getAvailabilityResult(subtree.childSubtreeAvailability, childTileMortonIndex);
1850
- }
1851
- const x = concatBits(globalData.x, childTileX, level);
1852
- const y = concatBits(globalData.y, childTileY, level);
1853
- const z = concatBits(globalData.z, childTileZ, level);
1838
+ const lastBitX = childIndex & 1;
1839
+ const lastBitY = childIndex >> 1 & 1;
1840
+ const lastBitZ = childIndex >> 2 & 1;
1841
+ const localX = concatBits(parentData.localX, lastBitX, 1);
1842
+ const localY = concatBits(parentData.localY, lastBitY, 1);
1843
+ const localZ = concatBits(parentData.localZ, lastBitZ, 1);
1844
+ const x = concatBits(subtreeData.x, localX, localLevel);
1845
+ const y = concatBits(subtreeData.y, localY, localLevel);
1846
+ const z = concatBits(subtreeData.z, localZ, localLevel);
1847
+ const mortonIndex = concatBits(parentData.mortonIndex, childIndex, bitsPerTile);
1848
+ const isChildSubtreeAvailable = localLevel === subtreeLevels && getAvailabilityResult(subtree.childSubtreeAvailability, mortonIndex);
1849
+ let nextSubtree;
1850
+ let nextSubtreeData;
1851
+ let nextParentData;
1852
+ let tileAvailabilityIndex;
1854
1853
  if (isChildSubtreeAvailable) {
1855
1854
  const subtreePath = `${basePath}/${subtreesUriTemplate}`;
1856
- const childSubtreeUrl = replaceContentUrlTemplate(subtreePath, lev, x, y, z);
1855
+ const childSubtreeUrl = replaceContentUrlTemplate(subtreePath, level, x, y, z);
1857
1856
  const childSubtree = await (0, import_core7.load)(childSubtreeUrl, Tile3DSubtreeLoader, loaderOptions);
1858
- subtree = childSubtree;
1859
- globalData = {
1860
- mortonIndex: childTileMortonIndex,
1861
- x: childTileX,
1862
- y: childTileY,
1863
- z: childTileZ,
1864
- level
1865
- };
1866
- childTileMortonIndex = 0;
1857
+ nextSubtree = childSubtree;
1867
1858
  tileAvailabilityIndex = 0;
1868
- childTileX = 0;
1869
- childTileY = 0;
1870
- childTileZ = 0;
1871
- level = 0;
1859
+ nextSubtreeData = { level, x, y, z };
1860
+ nextParentData = { mortonIndex: 0, localLevel: 0, localX: 0, localY: 0, localZ: 0 };
1861
+ } else {
1862
+ nextSubtree = subtree;
1863
+ const levelOffset = (childrenPerTile ** localLevel - 1) / (childrenPerTile - 1);
1864
+ tileAvailabilityIndex = levelOffset + mortonIndex;
1865
+ nextSubtreeData = subtreeData;
1866
+ nextParentData = { mortonIndex, localLevel, localX, localY, localZ };
1872
1867
  }
1873
- const isTileAvailable = getAvailabilityResult(subtree.tileAvailability, tileAvailabilityIndex);
1868
+ const isTileAvailable = getAvailabilityResult(nextSubtree.tileAvailability, tileAvailabilityIndex);
1874
1869
  if (!isTileAvailable) {
1875
1870
  return tile;
1876
1871
  }
1877
- const isContentAvailable = getAvailabilityResult(subtree.contentAvailability, tileAvailabilityIndex);
1872
+ const isContentAvailable = getAvailabilityResult(nextSubtree.contentAvailability, tileAvailabilityIndex);
1878
1873
  if (isContentAvailable) {
1879
- tile.contentUrl = replaceContentUrlTemplate(contentUrlTemplate, lev, x, y, z);
1874
+ tile.contentUrl = replaceContentUrlTemplate(contentUrlTemplate, level, x, y, z);
1880
1875
  }
1881
- const childTileLevel = level + 1;
1882
- const pData = { mortonIndex: childTileMortonIndex, x: childTileX, y: childTileY, z: childTileZ };
1883
1876
  for (let index = 0; index < childrenPerTile; index++) {
1884
1877
  const childS2VolumeBox = getChildS2VolumeBox(s2VolumeBox, index, subdivisionScheme);
1885
- const childTileParsed = await parseImplicitTiles({
1886
- subtree,
1878
+ const childTile = await parseImplicitTiles({
1879
+ subtree: nextSubtree,
1880
+ subtreeData: nextSubtreeData,
1881
+ parentData: nextParentData,
1882
+ childIndex: index,
1887
1883
  implicitOptions,
1888
1884
  loaderOptions,
1889
- parentData: pData,
1890
- childIndex: index,
1891
- level: childTileLevel,
1892
- globalData: { ...globalData },
1893
1885
  s2VolumeBox: childS2VolumeBox
1894
1886
  });
1895
- if (childTileParsed.contentUrl || childTileParsed.children.length) {
1896
- const globalLevel = lev + 1;
1897
- const childCoordinates = { childTileX, childTileY, childTileZ };
1898
- const formattedTile = formatTileData(childTileParsed, globalLevel, childCoordinates, implicitOptions, s2VolumeBox);
1899
- tile.children.push(formattedTile);
1887
+ if (childTile.contentUrl || childTile.children.length) {
1888
+ tile.children.push(childTile);
1900
1889
  }
1901
1890
  }
1891
+ if (tile.contentUrl || tile.children.length) {
1892
+ const coordinates = { level, x, y, z };
1893
+ const formattedTile = formatTileData(tile, coordinates, implicitOptions, s2VolumeBox);
1894
+ return formattedTile;
1895
+ }
1902
1896
  return tile;
1903
1897
  }
1904
1898
  function getAvailabilityResult(availabilityData, index) {
@@ -1919,12 +1913,12 @@ function getAvailabilityResult(availabilityData, index) {
1919
1913
  }
1920
1914
  return false;
1921
1915
  }
1922
- function formatTileData(tile, level, childCoordinates, options, s2VolumeBox) {
1916
+ function formatTileData(tile, coordinates, options, s2VolumeBox) {
1923
1917
  const { basePath, refine, getRefine: getRefine2, lodMetricType, getTileType: getTileType2, rootLodMetricValue, rootBoundingVolume } = options;
1924
1918
  const uri = tile.contentUrl && tile.contentUrl.replace(`${basePath}/`, "");
1925
- const lodMetricValue = rootLodMetricValue / 2 ** level;
1919
+ const lodMetricValue = rootLodMetricValue / 2 ** coordinates.level;
1926
1920
  const boundingVolume = (s2VolumeBox == null ? void 0 : s2VolumeBox.box) ? { box: s2VolumeBox.box } : rootBoundingVolume;
1927
- const boundingVolumeForChildTile = calculateBoundingVolumeForChildTile(level, boundingVolume, childCoordinates);
1921
+ const boundingVolumeForChildTile = calculateBoundingVolumeForChildTile(boundingVolume, coordinates, options.subdivisionScheme);
1928
1922
  return {
1929
1923
  children: tile.children,
1930
1924
  contentUrl: tile.contentUrl,
@@ -1939,20 +1933,26 @@ function formatTileData(tile, level, childCoordinates, options, s2VolumeBox) {
1939
1933
  boundingVolume: boundingVolumeForChildTile
1940
1934
  };
1941
1935
  }
1942
- function calculateBoundingVolumeForChildTile(level, rootBoundingVolume, childCoordinates) {
1936
+ function calculateBoundingVolumeForChildTile(rootBoundingVolume, coordinates, subdivisionScheme) {
1943
1937
  if (rootBoundingVolume.region) {
1944
- const { childTileX, childTileY, childTileZ } = childCoordinates;
1938
+ const { level, x, y, z } = coordinates;
1945
1939
  const [west, south, east, north, minimumHeight, maximumHeight] = rootBoundingVolume.region;
1946
1940
  const boundingVolumesCount = 2 ** level;
1947
1941
  const sizeX = (east - west) / boundingVolumesCount;
1942
+ const [childWest, childEast] = [west + sizeX * x, west + sizeX * (x + 1)];
1948
1943
  const sizeY = (north - south) / boundingVolumesCount;
1949
- const sizeZ = (maximumHeight - minimumHeight) / boundingVolumesCount;
1950
- const [childWest, childEast] = [west + sizeX * childTileX, west + sizeX * (childTileX + 1)];
1951
- const [childSouth, childNorth] = [south + sizeY * childTileY, south + sizeY * (childTileY + 1)];
1952
- const [childMinimumHeight, childMaximumHeight] = [
1953
- minimumHeight + sizeZ * childTileZ,
1954
- minimumHeight + sizeZ * (childTileZ + 1)
1955
- ];
1944
+ const [childSouth, childNorth] = [south + sizeY * y, south + sizeY * (y + 1)];
1945
+ let childMinimumHeight;
1946
+ let childMaximumHeight;
1947
+ if (subdivisionScheme === "OCTREE") {
1948
+ const sizeZ = (maximumHeight - minimumHeight) / boundingVolumesCount;
1949
+ [childMinimumHeight, childMaximumHeight] = [
1950
+ minimumHeight + sizeZ * z,
1951
+ minimumHeight + sizeZ * (z + 1)
1952
+ ];
1953
+ } else {
1954
+ [childMinimumHeight, childMaximumHeight] = [minimumHeight, maximumHeight];
1955
+ }
1956
1956
  return {
1957
1957
  region: [childWest, childSouth, childEast, childNorth, childMinimumHeight, childMaximumHeight]
1958
1958
  };
@@ -2390,7 +2390,7 @@ var parse3DTilesArchive = async (fileProvider, cb) => {
2390
2390
  };
2391
2391
 
2392
2392
  // dist/3d-tiles-archive-loader.js
2393
- var VERSION2 = true ? "4.3.0-alpha.5" : "latest";
2393
+ var VERSION2 = true ? "4.3.0-alpha.7" : "latest";
2394
2394
  var Tiles3DArchiveFileLoader = {
2395
2395
  dataType: null,
2396
2396
  batchType: null,