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

Fix merge for multiple implicit tilesets #161

Merged
merged 1 commit into from
Nov 28, 2024
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
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