Skip to content

Commit

Permalink
Merge pull request #161 from CesiumGS/fix-merge-implicit-tilesets
Browse files Browse the repository at this point in the history
Fix merge for multiple implicit tilesets
  • Loading branch information
lilleyse authored Nov 28, 2024
2 parents 0e8f5e0 + 2eeb812 commit 3c2b9a4
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
40 changes: 40 additions & 0 deletions specs/tools/tilesetProcessing/TilesetMergerSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,4 +220,44 @@ describe("TilesetMerger", function () {
];
expect(actualContentUris).toEqual(expectedContentUris);
});

it("merges two implicit tilesets into a valid output tileset", async function () {
// Regression test for https://github.com/CesiumGS/3d-tiles-tools/issues/157
// The input tileset is the 'dummy' implicit tileset that is used for other
// specs, and it is used TWICE - this doesn't make sense, but serves the
// purpose a spec for merging two implicit tilesets
const inputFiles = [
Paths.join(
SPECS_DATA_BASE_DIRECTORY,
"/tilesetProcessing/implicitProcessing"
),
Paths.join(
SPECS_DATA_BASE_DIRECTORY,
"/tilesetProcessing/implicitProcessing"
),
];
const outputDirectory = Paths.join(
SPECS_DATA_BASE_DIRECTORY,
"output/mergeTilesets/mergeImplicit"
);
const outputFile = Paths.join(outputDirectory, "tileset.json");

await TilesetOperations.mergeJson(inputFiles, outputFile, overwrite);

// Ensure that the output directory contains the tileset JSON
const actualRelativeFiles =
SpecHelpers.collectRelativeFileNames(outputDirectory);
expect(actualRelativeFiles.includes("tileset.json")).toBeTrue();

// Ensure that the root of the resulting tileset has two children,
// and none of them defines the 'implicitTiling' (because this is
// defined in the roots of the external tilesets)
const tilesetJsonBuffer = fs.readFileSync(outputFile);
const tileset = JSON.parse(tilesetJsonBuffer.toString());
const root = tileset.root;
const children = root.children;
expect(children.length).toBe(2);
expect(children[0].implicitTiling).toBeUndefined();
expect(children[1].implicitTiling).toBeUndefined();
});
});
4 changes: 3 additions & 1 deletion src/tools/tilesetProcessing/TilesetMerger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,8 @@ export class TilesetMerger {
// The following functions are ported from the `merge-tilesets` branch
// at https://github.com/CesiumGS/3d-tiles-tools/blob/d7e76e59022fc5e5aa4b848730ec9f8f4dea6d4e/tools/lib/mergeTilesets.js
// with slight modification of 'getChildren' for disambiguation
// and updates to compute bounding boxes instead of bounding spheres
// and updates to compute bounding boxes instead of bounding spheres,
// and a fix for https://github.com/CesiumGS/3d-tiles-tools/issues/157

private static getChildren(
tilesets: Tileset[],
Expand All @@ -360,6 +361,7 @@ export class TilesetMerger {
};
delete children[i].children;
delete children[i].transform;
delete children[i].implicitTiling;
}
return children;
}
Expand Down

0 comments on commit 3c2b9a4

Please sign in to comment.