diff --git a/modules/3d-tiles/src/lib/parsers/helpers/parse-3d-implicit-tiles.ts b/modules/3d-tiles/src/lib/parsers/helpers/parse-3d-implicit-tiles.ts index 0223ab8633..3e70acbe22 100644 --- a/modules/3d-tiles/src/lib/parsers/helpers/parse-3d-implicit-tiles.ts +++ b/modules/3d-tiles/src/lib/parsers/helpers/parse-3d-implicit-tiles.ts @@ -10,12 +10,12 @@ import Long from 'long'; import {Tiles3DLoaderOptions} from '../../../tiles-3d-loader'; import {ImplicitOptions} from '../parse-3d-tile-header'; -const QUADTREE_DEVISION_COUNT = 4; -const OCTREE_DEVISION_COUNT = 8; +const QUADTREE_DIVISION_COUNT = 4; +const OCTREE_DIVISION_COUNT = 8; const SUBDIVISION_COUNT_MAP = { - QUADTREE: QUADTREE_DEVISION_COUNT, - OCTREE: OCTREE_DEVISION_COUNT + QUADTREE: QUADTREE_DIVISION_COUNT, + OCTREE: OCTREE_DIVISION_COUNT }; /** @@ -103,17 +103,20 @@ export async function parseImplicitTiles(params: { z: 0 }, childIndex = 0, + s2VolumeBox, + loaderOptions + } = params; + let { + subtree, + level = 0, globalData = { level: 0, mortonIndex: 0, x: 0, y: 0, z: 0 - }, - s2VolumeBox, - loaderOptions + } } = params; - let {subtree, level = 0} = params; const { subdivisionScheme, subtreeLevels, @@ -163,9 +166,9 @@ export async function parseImplicitTiles(params: { ); } - const x = concatBits(globalData.x, childTileX, level * bitsPerTile); - const y = concatBits(globalData.y, childTileY, level * bitsPerTile); - const z = concatBits(globalData.z, childTileZ, level * bitsPerTile); + const x = concatBits(globalData.x, childTileX, level); + const y = concatBits(globalData.y, childTileY, level); + const z = concatBits(globalData.z, childTileZ, level); if (isChildSubtreeAvailable) { const subtreePath = `${basePath}/${subtreesUriTemplate}`; @@ -174,11 +177,13 @@ export async function parseImplicitTiles(params: { subtree = childSubtree; - globalData.mortonIndex = childTileMortonIndex; - globalData.x = childTileX; - globalData.y = childTileY; - globalData.z = childTileZ; - globalData.level = level; + globalData = { + mortonIndex: childTileMortonIndex, + x: childTileX, + y: childTileY, + z: childTileZ, + level + }; childTileMortonIndex = 0; tileAvailabilityIndex = 0; diff --git a/modules/3d-tiles/src/lib/parsers/parse-3d-tile-header.ts b/modules/3d-tiles/src/lib/parsers/parse-3d-tile-header.ts index c0b5cac9a6..29ded359ec 100644 --- a/modules/3d-tiles/src/lib/parsers/parse-3d-tile-header.ts +++ b/modules/3d-tiles/src/lib/parsers/parse-3d-tile-header.ts @@ -80,6 +80,12 @@ function getRefine(refine?: string): TILE_REFINEMENT | string | undefined { } function resolveUri(uri: string = '', basePath: string): string { + if (uri === '') { + // if there's no URI we don't want to make a request to just the basePath + // and the URI may not exist if we're dealing with a sparse implicit tileset + return ''; + } + // url scheme per RFC3986 const urlSchemeRegex = /^[a-z][0-9a-z+.-]*:/i; diff --git a/modules/3d-tiles/test/data/SparseOctree/content/0/0/0/0.pnts b/modules/3d-tiles/test/data/SparseOctree/content/0/0/0/0.pnts deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/modules/3d-tiles/test/data/SparseOctree/content/1/0/0/0.glb b/modules/3d-tiles/test/data/SparseOctree/content/1/0/0/0.glb new file mode 100644 index 0000000000..ee1e2ff2e3 Binary files /dev/null and b/modules/3d-tiles/test/data/SparseOctree/content/1/0/0/0.glb differ diff --git a/modules/3d-tiles/test/data/SparseOctree/content/1/0/0/0.pnts b/modules/3d-tiles/test/data/SparseOctree/content/1/0/0/0.pnts deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/modules/3d-tiles/test/data/SparseOctree/content/2/1/0/0.pnts b/modules/3d-tiles/test/data/SparseOctree/content/2/1/0/0.pnts deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/modules/3d-tiles/test/data/SparseOctree/content/2/2/0/0.glb b/modules/3d-tiles/test/data/SparseOctree/content/2/2/0/0.glb new file mode 100644 index 0000000000..09f1b20a85 Binary files /dev/null and b/modules/3d-tiles/test/data/SparseOctree/content/2/2/0/0.glb differ diff --git a/modules/3d-tiles/test/data/SparseOctree/content/2/3/1/1.glb b/modules/3d-tiles/test/data/SparseOctree/content/2/3/1/1.glb new file mode 100644 index 0000000000..1086a9ee09 Binary files /dev/null and b/modules/3d-tiles/test/data/SparseOctree/content/2/3/1/1.glb differ diff --git a/modules/3d-tiles/test/data/SparseOctree/content/3/0/4/0.glb b/modules/3d-tiles/test/data/SparseOctree/content/3/0/4/0.glb new file mode 100644 index 0000000000..c4e901ca91 Binary files /dev/null and b/modules/3d-tiles/test/data/SparseOctree/content/3/0/4/0.glb differ diff --git a/modules/3d-tiles/test/data/SparseOctree/content/3/1/5/1.glb b/modules/3d-tiles/test/data/SparseOctree/content/3/1/5/1.glb new file mode 100644 index 0000000000..0cb82c9389 Binary files /dev/null and b/modules/3d-tiles/test/data/SparseOctree/content/3/1/5/1.glb differ diff --git a/modules/3d-tiles/test/data/SparseOctree/content/3/2/6/2.glb b/modules/3d-tiles/test/data/SparseOctree/content/3/2/6/2.glb new file mode 100644 index 0000000000..ff8a7d7bac Binary files /dev/null and b/modules/3d-tiles/test/data/SparseOctree/content/3/2/6/2.glb differ diff --git a/modules/3d-tiles/test/data/SparseOctree/content/3/3/0/1.pnts b/modules/3d-tiles/test/data/SparseOctree/content/3/3/0/1.pnts deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/modules/3d-tiles/test/data/SparseOctree/content/3/3/7/3.glb b/modules/3d-tiles/test/data/SparseOctree/content/3/3/7/3.glb new file mode 100644 index 0000000000..78efa77e5d Binary files /dev/null and b/modules/3d-tiles/test/data/SparseOctree/content/3/3/7/3.glb differ diff --git a/modules/3d-tiles/test/data/SparseOctree/content/4/10/10/2.glb b/modules/3d-tiles/test/data/SparseOctree/content/4/10/10/2.glb new file mode 100644 index 0000000000..dbc269115b Binary files /dev/null and b/modules/3d-tiles/test/data/SparseOctree/content/4/10/10/2.glb differ diff --git a/modules/3d-tiles/test/data/SparseOctree/content/4/11/11/3.glb b/modules/3d-tiles/test/data/SparseOctree/content/4/11/11/3.glb new file mode 100644 index 0000000000..8eb0cc6b67 Binary files /dev/null and b/modules/3d-tiles/test/data/SparseOctree/content/4/11/11/3.glb differ diff --git a/modules/3d-tiles/test/data/SparseOctree/content/4/12/12/4.glb b/modules/3d-tiles/test/data/SparseOctree/content/4/12/12/4.glb new file mode 100644 index 0000000000..a90258f8f6 Binary files /dev/null and b/modules/3d-tiles/test/data/SparseOctree/content/4/12/12/4.glb differ diff --git a/modules/3d-tiles/test/data/SparseOctree/content/4/13/13/5.glb b/modules/3d-tiles/test/data/SparseOctree/content/4/13/13/5.glb new file mode 100644 index 0000000000..c99001d131 Binary files /dev/null and b/modules/3d-tiles/test/data/SparseOctree/content/4/13/13/5.glb differ diff --git a/modules/3d-tiles/test/data/SparseOctree/content/4/14/14/6.glb b/modules/3d-tiles/test/data/SparseOctree/content/4/14/14/6.glb new file mode 100644 index 0000000000..1315dc0ceb Binary files /dev/null and b/modules/3d-tiles/test/data/SparseOctree/content/4/14/14/6.glb differ diff --git a/modules/3d-tiles/test/data/SparseOctree/content/4/15/15/7.glb b/modules/3d-tiles/test/data/SparseOctree/content/4/15/15/7.glb new file mode 100644 index 0000000000..14b93e1b72 Binary files /dev/null and b/modules/3d-tiles/test/data/SparseOctree/content/4/15/15/7.glb differ diff --git a/modules/3d-tiles/test/data/SparseOctree/content/4/6/1/2.pnts b/modules/3d-tiles/test/data/SparseOctree/content/4/6/1/2.pnts deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/modules/3d-tiles/test/data/SparseOctree/content/4/8/8/0.glb b/modules/3d-tiles/test/data/SparseOctree/content/4/8/8/0.glb new file mode 100644 index 0000000000..2f8653a878 Binary files /dev/null and b/modules/3d-tiles/test/data/SparseOctree/content/4/8/8/0.glb differ diff --git a/modules/3d-tiles/test/data/SparseOctree/content/4/9/9/1.glb b/modules/3d-tiles/test/data/SparseOctree/content/4/9/9/1.glb new file mode 100644 index 0000000000..4701680539 Binary files /dev/null and b/modules/3d-tiles/test/data/SparseOctree/content/4/9/9/1.glb differ diff --git a/modules/3d-tiles/test/data/SparseOctree/content/5/12/2/6.pnts b/modules/3d-tiles/test/data/SparseOctree/content/5/12/2/6.pnts deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/modules/3d-tiles/test/data/SparseOctree/content/5/12/3/5.pnts b/modules/3d-tiles/test/data/SparseOctree/content/5/12/3/5.pnts deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/modules/3d-tiles/test/data/SparseOctree/content/5/12/3/6.pnts b/modules/3d-tiles/test/data/SparseOctree/content/5/12/3/6.pnts deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/modules/3d-tiles/test/data/SparseOctree/content/5/16/16/16.glb b/modules/3d-tiles/test/data/SparseOctree/content/5/16/16/16.glb new file mode 100644 index 0000000000..446c61f77e Binary files /dev/null and b/modules/3d-tiles/test/data/SparseOctree/content/5/16/16/16.glb differ diff --git a/modules/3d-tiles/test/data/SparseOctree/content/5/17/17/17.glb b/modules/3d-tiles/test/data/SparseOctree/content/5/17/17/17.glb new file mode 100644 index 0000000000..e0965d6138 Binary files /dev/null and b/modules/3d-tiles/test/data/SparseOctree/content/5/17/17/17.glb differ diff --git a/modules/3d-tiles/test/data/SparseOctree/content/5/18/18/18.glb b/modules/3d-tiles/test/data/SparseOctree/content/5/18/18/18.glb new file mode 100644 index 0000000000..2aeb34a76c Binary files /dev/null and b/modules/3d-tiles/test/data/SparseOctree/content/5/18/18/18.glb differ diff --git a/modules/3d-tiles/test/data/SparseOctree/content/5/19/19/19.glb b/modules/3d-tiles/test/data/SparseOctree/content/5/19/19/19.glb new file mode 100644 index 0000000000..5ebc17b6e4 Binary files /dev/null and b/modules/3d-tiles/test/data/SparseOctree/content/5/19/19/19.glb differ diff --git a/modules/3d-tiles/test/data/SparseOctree/content/5/20/20/20.glb b/modules/3d-tiles/test/data/SparseOctree/content/5/20/20/20.glb new file mode 100644 index 0000000000..a80bcf8e5f Binary files /dev/null and b/modules/3d-tiles/test/data/SparseOctree/content/5/20/20/20.glb differ diff --git a/modules/3d-tiles/test/data/SparseOctree/content/5/21/21/21.glb b/modules/3d-tiles/test/data/SparseOctree/content/5/21/21/21.glb new file mode 100644 index 0000000000..e10c4884fd Binary files /dev/null and b/modules/3d-tiles/test/data/SparseOctree/content/5/21/21/21.glb differ diff --git a/modules/3d-tiles/test/data/SparseOctree/content/5/22/22/22.glb b/modules/3d-tiles/test/data/SparseOctree/content/5/22/22/22.glb new file mode 100644 index 0000000000..390fd99a04 Binary files /dev/null and b/modules/3d-tiles/test/data/SparseOctree/content/5/22/22/22.glb differ diff --git a/modules/3d-tiles/test/data/SparseOctree/content/5/23/23/23.glb b/modules/3d-tiles/test/data/SparseOctree/content/5/23/23/23.glb new file mode 100644 index 0000000000..20c94f8d42 Binary files /dev/null and b/modules/3d-tiles/test/data/SparseOctree/content/5/23/23/23.glb differ diff --git a/modules/3d-tiles/test/data/SparseOctree/content/5/24/24/24.glb b/modules/3d-tiles/test/data/SparseOctree/content/5/24/24/24.glb new file mode 100644 index 0000000000..f38188b8b6 Binary files /dev/null and b/modules/3d-tiles/test/data/SparseOctree/content/5/24/24/24.glb differ diff --git a/modules/3d-tiles/test/data/SparseOctree/content/5/25/25/25.glb b/modules/3d-tiles/test/data/SparseOctree/content/5/25/25/25.glb new file mode 100644 index 0000000000..f9c8388f29 Binary files /dev/null and b/modules/3d-tiles/test/data/SparseOctree/content/5/25/25/25.glb differ diff --git a/modules/3d-tiles/test/data/SparseOctree/content/5/26/26/26.glb b/modules/3d-tiles/test/data/SparseOctree/content/5/26/26/26.glb new file mode 100644 index 0000000000..480bc1ee24 Binary files /dev/null and b/modules/3d-tiles/test/data/SparseOctree/content/5/26/26/26.glb differ diff --git a/modules/3d-tiles/test/data/SparseOctree/content/5/27/27/27.glb b/modules/3d-tiles/test/data/SparseOctree/content/5/27/27/27.glb new file mode 100644 index 0000000000..39e0705c7f Binary files /dev/null and b/modules/3d-tiles/test/data/SparseOctree/content/5/27/27/27.glb differ diff --git a/modules/3d-tiles/test/data/SparseOctree/content/5/28/28/28.glb b/modules/3d-tiles/test/data/SparseOctree/content/5/28/28/28.glb new file mode 100644 index 0000000000..4614b522e6 Binary files /dev/null and b/modules/3d-tiles/test/data/SparseOctree/content/5/28/28/28.glb differ diff --git a/modules/3d-tiles/test/data/SparseOctree/content/5/29/29/29.glb b/modules/3d-tiles/test/data/SparseOctree/content/5/29/29/29.glb new file mode 100644 index 0000000000..ea12922414 Binary files /dev/null and b/modules/3d-tiles/test/data/SparseOctree/content/5/29/29/29.glb differ diff --git a/modules/3d-tiles/test/data/SparseOctree/content/5/30/30/30.glb b/modules/3d-tiles/test/data/SparseOctree/content/5/30/30/30.glb new file mode 100644 index 0000000000..86e77434e3 Binary files /dev/null and b/modules/3d-tiles/test/data/SparseOctree/content/5/30/30/30.glb differ diff --git a/modules/3d-tiles/test/data/SparseOctree/content/5/31/31/31.glb b/modules/3d-tiles/test/data/SparseOctree/content/5/31/31/31.glb new file mode 100644 index 0000000000..621a04d94a Binary files /dev/null and b/modules/3d-tiles/test/data/SparseOctree/content/5/31/31/31.glb differ diff --git a/modules/3d-tiles/test/data/SparseOctree/subtrees/0/0/0/0.subtree b/modules/3d-tiles/test/data/SparseOctree/subtrees/0/0/0/0.subtree index be4a5d7ea1..c368d4a80d 100644 Binary files a/modules/3d-tiles/test/data/SparseOctree/subtrees/0/0/0/0.subtree and b/modules/3d-tiles/test/data/SparseOctree/subtrees/0/0/0/0.subtree differ diff --git a/modules/3d-tiles/test/data/SparseOctree/subtrees/2/1/0/0.subtree b/modules/3d-tiles/test/data/SparseOctree/subtrees/2/1/0/0.subtree deleted file mode 100644 index c08fdfb3cb..0000000000 Binary files a/modules/3d-tiles/test/data/SparseOctree/subtrees/2/1/0/0.subtree and /dev/null differ diff --git a/modules/3d-tiles/test/data/SparseOctree/subtrees/3/0/4/0.subtree b/modules/3d-tiles/test/data/SparseOctree/subtrees/3/0/4/0.subtree new file mode 100644 index 0000000000..d9db927847 Binary files /dev/null and b/modules/3d-tiles/test/data/SparseOctree/subtrees/3/0/4/0.subtree differ diff --git a/modules/3d-tiles/test/data/SparseOctree/subtrees/3/1/5/1.subtree b/modules/3d-tiles/test/data/SparseOctree/subtrees/3/1/5/1.subtree new file mode 100644 index 0000000000..d9db927847 Binary files /dev/null and b/modules/3d-tiles/test/data/SparseOctree/subtrees/3/1/5/1.subtree differ diff --git a/modules/3d-tiles/test/data/SparseOctree/subtrees/3/2/6/2.subtree b/modules/3d-tiles/test/data/SparseOctree/subtrees/3/2/6/2.subtree new file mode 100644 index 0000000000..d9db927847 Binary files /dev/null and b/modules/3d-tiles/test/data/SparseOctree/subtrees/3/2/6/2.subtree differ diff --git a/modules/3d-tiles/test/data/SparseOctree/subtrees/3/3/7/3.subtree b/modules/3d-tiles/test/data/SparseOctree/subtrees/3/3/7/3.subtree new file mode 100644 index 0000000000..d9db927847 Binary files /dev/null and b/modules/3d-tiles/test/data/SparseOctree/subtrees/3/3/7/3.subtree differ diff --git a/modules/3d-tiles/test/data/SparseOctree/subtrees/3/4/4/0.subtree b/modules/3d-tiles/test/data/SparseOctree/subtrees/3/4/4/0.subtree new file mode 100644 index 0000000000..ba8ad540e9 Binary files /dev/null and b/modules/3d-tiles/test/data/SparseOctree/subtrees/3/4/4/0.subtree differ diff --git a/modules/3d-tiles/test/data/SparseOctree/subtrees/3/4/4/4.subtree b/modules/3d-tiles/test/data/SparseOctree/subtrees/3/4/4/4.subtree new file mode 100644 index 0000000000..a37e8e1c1e Binary files /dev/null and b/modules/3d-tiles/test/data/SparseOctree/subtrees/3/4/4/4.subtree differ diff --git a/modules/3d-tiles/test/data/SparseOctree/subtrees/3/5/5/1.subtree b/modules/3d-tiles/test/data/SparseOctree/subtrees/3/5/5/1.subtree new file mode 100644 index 0000000000..ba8ad540e9 Binary files /dev/null and b/modules/3d-tiles/test/data/SparseOctree/subtrees/3/5/5/1.subtree differ diff --git a/modules/3d-tiles/test/data/SparseOctree/subtrees/3/5/5/5.subtree b/modules/3d-tiles/test/data/SparseOctree/subtrees/3/5/5/5.subtree new file mode 100644 index 0000000000..a37e8e1c1e Binary files /dev/null and b/modules/3d-tiles/test/data/SparseOctree/subtrees/3/5/5/5.subtree differ diff --git a/modules/3d-tiles/test/data/SparseOctree/subtrees/3/6/6/2.subtree b/modules/3d-tiles/test/data/SparseOctree/subtrees/3/6/6/2.subtree new file mode 100644 index 0000000000..ba8ad540e9 Binary files /dev/null and b/modules/3d-tiles/test/data/SparseOctree/subtrees/3/6/6/2.subtree differ diff --git a/modules/3d-tiles/test/data/SparseOctree/subtrees/3/6/6/6.subtree b/modules/3d-tiles/test/data/SparseOctree/subtrees/3/6/6/6.subtree new file mode 100644 index 0000000000..a37e8e1c1e Binary files /dev/null and b/modules/3d-tiles/test/data/SparseOctree/subtrees/3/6/6/6.subtree differ diff --git a/modules/3d-tiles/test/data/SparseOctree/subtrees/3/7/7/3.subtree b/modules/3d-tiles/test/data/SparseOctree/subtrees/3/7/7/3.subtree new file mode 100644 index 0000000000..ba8ad540e9 Binary files /dev/null and b/modules/3d-tiles/test/data/SparseOctree/subtrees/3/7/7/3.subtree differ diff --git a/modules/3d-tiles/test/data/SparseOctree/subtrees/3/7/7/7.subtree b/modules/3d-tiles/test/data/SparseOctree/subtrees/3/7/7/7.subtree new file mode 100644 index 0000000000..a37e8e1c1e Binary files /dev/null and b/modules/3d-tiles/test/data/SparseOctree/subtrees/3/7/7/7.subtree differ diff --git a/modules/3d-tiles/test/data/SparseOctree/subtrees/4/6/1/2.subtree b/modules/3d-tiles/test/data/SparseOctree/subtrees/4/6/1/2.subtree deleted file mode 100644 index 033d64a730..0000000000 Binary files a/modules/3d-tiles/test/data/SparseOctree/subtrees/4/6/1/2.subtree and /dev/null differ diff --git a/modules/3d-tiles/test/data/SparseOctree/tileset.json b/modules/3d-tiles/test/data/SparseOctree/tileset.json index 2f3c8ecc98..fb73e3ba75 100644 --- a/modules/3d-tiles/test/data/SparseOctree/tileset.json +++ b/modules/3d-tiles/test/data/SparseOctree/tileset.json @@ -1,33 +1,24 @@ - { - "asset": { - "version": "1.0" + "asset" : { + "version" : "1.1" }, - "geometricError": 10000, - "extensionsUsed": [ - "3DTILES_implicit_tiling" - ], - "extensionsRequired": [ - "3DTILES_implicit_tiling" - ], - "root": { - "boundingVolume": { - "region": [-1.318, 0.697, -1.319, 0.698, 0, 20] + "geometricError" : 1024.0, + "root" : { + "boundingVolume" : { + "box" : [ 0.5, 0.5, 0.5, 0.5, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.5 ] }, - "refine": "ADD", - "geometricError": 5000, - "content": { - "uri": "content/{level}/{x}/{y}/{z}.pnts" + "geometricError" : 32.0, + "refine" : "ADD", + "content" : { + "uri" : "content/{level}/{x}/{y}/{z}.glb" }, - "extensions": { - "3DTILES_implicit_tiling": { - "subdivisionScheme": "OCTREE", - "subtreeLevels": 2, - "maximumLevel": 5, - "subtrees": { - "uri": "subtrees/{level}/{x}/{y}/{z}.subtree" - } + "implicitTiling" : { + "subdivisionScheme" : "OCTREE", + "subtreeLevels" : 3, + "availableLevels" : 6, + "subtrees" : { + "uri" : "subtrees/{level}/{x}/{y}/{z}.subtree" } } } -} +} \ No newline at end of file diff --git a/modules/3d-tiles/test/tile-3d-subtree-loader.spec.ts b/modules/3d-tiles/test/tile-3d-subtree-loader.spec.ts index ed665c8837..d0db3c48a1 100644 --- a/modules/3d-tiles/test/tile-3d-subtree-loader.spec.ts +++ b/modules/3d-tiles/test/tile-3d-subtree-loader.spec.ts @@ -48,17 +48,33 @@ test('Tile3DSubtreeLoader#Should load quadtree subtree with expicitBitstream', a test('Tile3DSubtreeLoader#Should load octree subtree with expicitBitstream', async (t) => { const EXPECTED = { - buffers: [{byteLength: 9}], + buffers: [{byteLength: 96}], bufferViews: [ - {buffer: 0, byteOffset: 0, byteLength: 1}, - {buffer: 0, byteOffset: 1, byteLength: 8} + {buffer: 0, byteOffset: 0, byteLength: 10}, + {buffer: 0, byteOffset: 16, byteLength: 10}, + {buffer: 0, byteOffset: 32, byteLength: 64} ], - tileAvailability: {bufferView: 0, explicitBitstream: new Uint8Array([3])}, - childSubtreeAvailability: { - bufferView: 1, - explicitBitstream: new Uint8Array([2, 0, 0, 0, 0, 0, 0, 0]) + tileAvailability: { + bitstream: 0, + availableCount: 14, + explicitBitstream: new Uint8Array([31, 1, 2, 3, 3, 1, 0, 0, 2, 1]) }, - contentAvailability: {bufferView: 0, explicitBitstream: new Uint8Array([3])} + contentAvailability: [ + { + bitstream: 1, + availableCount: 3, + explicitBitstream: new Uint8Array([2, 0, 2, 1, 0, 0, 0, 0, 0, 0]) + } + ], + childSubtreeAvailability: { + bitstream: 2, + availableCount: 12, + explicitBitstream: new Uint8Array([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 129, 0, 0, 0, 0, 0, 0, 129, 129, 0, 0, 0, 0, + 0, 0, 129, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 129, 0, + 0, 0, 0, 0, 0, 129 + ]) + } }; const availabilitySubtree = await load( diff --git a/modules/3d-tiles/test/tiles-3d-loader.spec.ts b/modules/3d-tiles/test/tiles-3d-loader.spec.ts index af152676a2..b7684bf3ef 100644 --- a/modules/3d-tiles/test/tiles-3d-loader.spec.ts +++ b/modules/3d-tiles/test/tiles-3d-loader.spec.ts @@ -22,6 +22,14 @@ const IMPLICIT_FULL_AVAILABLE_QUADTREE_TILESET_URL = '@loaders.gl/3d-tiles/test/data/FullQuadtree/tileset.json'; const IMPLICIT_QUADTREE_TILESET_URL = '@loaders.gl/3d-tiles/test/data/BasicExample/tileset.json'; +function checkRegionBoundingBox(t, tile) { + if (tile.children.length) { + return tile.children.forEach((childTile) => checkRegionBoundingBox(t, childTile)); + } + + return t.ok(tile.boundingVolume.box) && t.equal(tile.boundingVolume.box.length, 12); +} + function checkRegionBoundingVolumes(t, tile) { if (tile.children.length) { return tile.children.forEach((childTile) => checkRegionBoundingVolumes(t, childTile)); @@ -131,13 +139,11 @@ test('Tiles3DLoader#Tile GLTF content extension', async (t) => { // eslint-disable-next-line max-statements test('Tiles3DLoader#Implicit Octree Tileset with bitstream availability and subtrees', async (t) => { - const ROOT_EXTENSION_EXPECTED = { - '3DTILES_implicit_tiling': { - subdivisionScheme: 'OCTREE', - subtreeLevels: 2, - maximumLevel: 5, - subtrees: {uri: 'subtrees/{level}/{x}/{y}/{z}.subtree'} - } + const IMPLICIT_TILING_EXPECTED = { + subdivisionScheme: 'OCTREE', + subtreeLevels: 3, + availableLevels: 6, + subtrees: {uri: 'subtrees/{level}/{x}/{y}/{z}.subtree'} }; const response = await fetchFile(IMPLICIT_OCTREE_TILESET_URL); @@ -145,38 +151,62 @@ test('Tiles3DLoader#Implicit Octree Tileset with bitstream availability and subt // root t.ok(tileset); - t.equal(tileset.extensionsRequired[0], '3DTILES_implicit_tiling'); - t.equal(tileset.extensionsUsed[0], '3DTILES_implicit_tiling'); t.ok(tileset.root); - t.equal(tileset.root.content.uri, 'content/0/0/0/0.pnts'); - t.equal(tileset.root.lodMetricValue, 5000); - t.equal(tileset.root.type, 'pointcloud'); + t.deepEqual(tileset.root.implicitTiling, IMPLICIT_TILING_EXPECTED); + t.equal(tileset.root.implicitTiling.subdivisionScheme, 'OCTREE'); + t.equal(tileset.root.implicitTiling.subtreeLevels, 3); + t.equal(tileset.root.implicitTiling.availableLevels, 6); + + t.equal(tileset.root.content.uri, 'content/{level}/{x}/{y}/{z}.glb'); + t.equal(tileset.root.lodMetricValue, 32); + t.equal(tileset.root.type, 'empty'); t.equal(tileset.root.refine, 1); - t.equal(tileset.root.children.length, 1); - t.deepEqual(tileset.root.extensions, ROOT_EXTENSION_EXPECTED); + t.equal(tileset.root.children.length, 5); - // children level 1 - t.equal(tileset.root.children[0].content.uri, 'content/1/0/0/0.pnts'); - t.equal(tileset.root.children[0].lodMetricValue, 2500); - t.equal(tileset.root.children[0].refine, 1); - t.equal(tileset.root.children[0].type, 'pointcloud'); - t.equal(tileset.root.children[0].children.length, 1); - - // children level 2 - t.equal(tileset.root.children[0].children[0].content.uri, 'content/2/1/0/0.pnts'); - t.equal(tileset.root.children[0].children[0].lodMetricValue, 1250); - t.equal(tileset.root.children[0].children[0].refine, 1); - t.equal(tileset.root.children[0].children[0].type, 'pointcloud'); - t.equal(tileset.root.children[0].children[0].children.length, 1); - - // children level 3 - t.equal(tileset.root.children[0].children[0].children[0].content.uri, 'content/3/8/0/1.pnts'); - t.equal(tileset.root.children[0].children[0].children[0].lodMetricValue, 625); - t.equal(tileset.root.children[0].children[0].children[0].refine, 1); - t.equal(tileset.root.children[0].children[0].children[0].type, 'pointcloud'); - t.equal(tileset.root.children[0].children[0].children[0].children.length, 0); + // first children tree + t.equal(tileset.root.children[0].type, 'scenegraph'); + t.equal(tileset.root.children[0].content.uri, 'content/1/0/0/0.glb'); + t.equal(tileset.root.children[0].children.length, 0); - checkRegionBoundingVolumes(t, tileset.root); + // second children tree + t.equal(tileset.root.children[1].content.uri, ''); + t.equal(tileset.root.children[1].children[0].content.uri, 'content/2/2/0/0.glb'); + t.equal(tileset.root.children[1].children[1].content.uri, 'content/2/3/1/1.glb'); + + // third children tree + t.equal(tileset.root.children[2].content.uri, ''); + t.equal(tileset.root.children[2].children[0].content.uri, ''); + t.equal(tileset.root.children[2].children[0].children[0].content.uri, 'content/3/0/4/0.glb'); + t.equal(tileset.root.children[2].children[0].children[1].content.uri, 'content/3/1/5/1.glb'); + + // fourth children tree + t.equal(tileset.root.children[3].content.uri, ''); + t.equal(tileset.root.children[3].children[0].content.uri, ''); + t.equal(tileset.root.children[3].children[0].children[0].content.uri, ''); + t.equal( + tileset.root.children[3].children[0].children[0].children[0].content.uri, + 'content/4/8/8/0.glb' + ); + t.equal( + tileset.root.children[3].children[0].children[0].children[1].content.uri, + 'content/4/9/9/1.glb' + ); + + // fifth children tree + t.equal(tileset.root.children[4].content.uri, ''); + t.equal(tileset.root.children[4].children[0].content.uri, ''); + t.equal(tileset.root.children[4].children[0].children[0].content.uri, ''); + t.equal(tileset.root.children[4].children[0].children[0].children[0].content.uri, ''); + t.equal( + tileset.root.children[4].children[0].children[0].children[0].children[0].content.uri, + 'content/5/16/16/16.glb' + ); + t.equal( + tileset.root.children[4].children[0].children[0].children[0].children[1].content.uri, + 'content/5/17/17/17.glb' + ); + + checkRegionBoundingBox(t, tileset.root); t.end(); });