Skip to content

Commit

Permalink
Additional test for tileset JSON creation
Browse files Browse the repository at this point in the history
  • Loading branch information
javagl committed Nov 5, 2023
1 parent 1b9c004 commit a4cdad7
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 3 deletions.
10 changes: 7 additions & 3 deletions specs/data/createTilesetJson/CreateTilesetJsonTestSandcastle.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const viewer = new Cesium.Viewer("cesiumContainer", {
globe: false
//globe: false
});

let currentTileset;
Expand All @@ -22,16 +22,19 @@ async function recreateTileset() {
debugShowBoundingVolume: true,
})
);

if (currentTilesetName.startsWith("plane")) {
const transform = Cesium.Transforms.eastNorthUpToFixedFrame(
Cesium.Cartesian3.fromDegrees(-75.152408, 39.946975, 0)
Cesium.Cartesian3.fromDegrees(-75.15232,39.94705, 0)
);
const scale = 1.0;
const modelMatrix = Cesium.Matrix4.multiplyByUniformScale(
transform,
scale,
new Cesium.Matrix4()
);
//currentTileset.modelMatrix = modelMatrix;
currentTileset.modelMatrix = modelMatrix;
}

if (doZoom) {
const offset = new Cesium.HeadingPitchRange(
Expand Down Expand Up @@ -68,6 +71,7 @@ function createOptions() {
createOption("instancedOrientation.json"),
createOption("pointCloudQuantized.json"),
createOption("pointCloudRGB.json"),
createOption("plane-ds-p-n-32x32.json"),
];
return options;
}
Expand Down
1 change: 1 addition & 0 deletions specs/data/createTilesetJson/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Data for testing the `createTilesetJson` command.

The tile content files in the `input` directory are copies of the corresponding files in the CesiumJS specs,
at https://github.com/CesiumGS/cesium/tree/08f28d46a5201ff49c211bc2bcbc6f254b275391/Specs/Data/Cesium3DTiles
(except for `plane-ds-p-n-32x32.glb`, which is simple "diamond-square" plane in the xy-plane)

The `TilesetJsonCreatorSpec.ts` tests are processing these inputs:

Expand Down
Binary file not shown.
24 changes: 24 additions & 0 deletions specs/tilesetProcessing/TilesetJsonCreatorSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,28 @@ describe("TilesetJsonCreator", function () {
.toString();
expect(outputJsonString).toEqual(goldenJsonString);
});

it("creates correct tileset JSON for plane-ds-p-n-32x32", async function () {
const tilesetFileName = "plane-ds-p-n-32x32.json";
const contentUri = "plane-ds-p-n-32x32.glb";
const tileset = await TilesetJsonCreator.createTilesetFromContents(
sourceDir,
[contentUri]
);
const outputJsonString = JSON.stringify(tileset, null, 2);
Paths.ensureDirectoryExists(targetDir);
fs.writeFileSync(
Paths.resolve(targetDir, tilesetFileName),
outputJsonString
);
fs.copyFileSync(
Paths.resolve(sourceDir, contentUri),
Paths.resolve(targetDir, contentUri)
);
const goldenJsonString = fs
.readFileSync(Paths.resolve(goldenDir, tilesetFileName))
.toString();
expect(outputJsonString).toEqual(goldenJsonString);
});

});

0 comments on commit a4cdad7

Please sign in to comment.