Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DATAVIZ-2220: Fix multiple subtree tilesets #5

Merged
merged 6 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 21 additions & 16 deletions modules/3d-tiles/src/lib/parsers/helpers/parse-3d-implicit-tiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
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;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙏

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
};

/**
Expand Down Expand Up @@ -103,17 +103,20 @@
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,
Expand Down Expand Up @@ -163,9 +166,9 @@
);
}

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}`;
Expand All @@ -174,11 +177,13 @@

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;
Expand Down Expand Up @@ -375,7 +380,7 @@
return rootBoundingVolume;
}

throw new Error(`Unsupported bounding volume type ${rootBoundingVolume}`);

Check warning on line 383 in modules/3d-tiles/src/lib/parsers/helpers/parse-3d-implicit-tiles.ts

View workflow job for this annotation

GitHub Actions / test (16)

'rootBoundingVolume' will evaluate to '[object Object]' when stringified

Check warning on line 383 in modules/3d-tiles/src/lib/parsers/helpers/parse-3d-implicit-tiles.ts

View workflow job for this annotation

GitHub Actions / test (18)

'rootBoundingVolume' will evaluate to '[object Object]' when stringified

Check warning on line 383 in modules/3d-tiles/src/lib/parsers/helpers/parse-3d-implicit-tiles.ts

View workflow job for this annotation

GitHub Actions / test (20)

'rootBoundingVolume' will evaluate to '[object Object]' when stringified
}

/**
Expand Down
6 changes: 6 additions & 0 deletions modules/3d-tiles/src/lib/parsers/parse-3d-tile-header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Empty file.
Binary file not shown.
Empty file.
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Empty file.
Binary file not shown.
Binary file not shown.
Empty file.
Empty file.
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified modules/3d-tiles/test/data/SparseOctree/subtrees/0/0/0/0.subtree
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
43 changes: 17 additions & 26 deletions modules/3d-tiles/test/data/SparseOctree/tileset.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
}
}
32 changes: 24 additions & 8 deletions modules/3d-tiles/test/tile-3d-subtree-loader.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
100 changes: 65 additions & 35 deletions modules/3d-tiles/test/tiles-3d-loader.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -131,52 +139,74 @@ 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);
const tileset = await parse(response, Tiles3DLoader);

// 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();
});
Expand Down
Loading