Skip to content

Commit

Permalink
Draft for shared texture handling specs
Browse files Browse the repository at this point in the history
  • Loading branch information
javagl committed Nov 25, 2024
1 parent bcdc430 commit 32dd865
Show file tree
Hide file tree
Showing 8 changed files with 159 additions and 0 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
{
"asset": {
"version": "1.1"
},
"geometricError": 4096,
"root": {
"boundingVolume": {
"box": [
3.5,
0,
0.5,
3.5,
0,
0,
0,
0,
0,
0,
0,
0.5
]
},
"geometricError": 1024,
"children": [
{
"boundingVolume": {
"box": [
0.5,
0,
0.5,
0.5,
0,
0,
0,
0,
0,
0,
0,
0.5
]
},
"geometricError": 512,
"content": {
"uri": "plane-0.glb"
}
},
{
"boundingVolume": {
"box": [
2.5,
0,
0.5,
0.5,
0,
0,
0,
0,
0,
0,
0,
0.5
]
},
"geometricError": 512,
"content": {
"uri": "plane-1.glb"
}
},
{
"boundingVolume": {
"box": [
4.5,
0,
0.5,
0.5,
0,
0,
0,
0,
0,
0,
0,
0.5
]
},
"geometricError": 512,
"content": {
"uri": "plane-2.glb"
}
},
{
"boundingVolume": {
"box": [
6.5,
0,
0.5,
0.5,
0,
0,
0,
0,
0,
0,
0,
0.5
]
},
"geometricError": 512,
"content": {
"uri": "plane-3.glb"
}
}
],
"refine": "ADD"
}
}
43 changes: 43 additions & 0 deletions packages/engine/Specs/Scene/Cesium3DTilesetSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ describe(
const tilesetOfTilesetsUrl =
"Data/Cesium3DTiles/Tilesets/TilesetOfTilesets/tileset.json";

// A tileset that refers to 4 GLB files which share two (external) textures
const tilesetUrlWithSharedTextures =
"Data/Cesium3DTiles/Tilesets/TilesetWithSharedTextures/tileset.json";

const withoutBatchTableUrl =
"Data/Cesium3DTiles/Batched/BatchedWithoutBatchTable/tileset.json";
const withBatchTableUrl =
Expand Down Expand Up @@ -963,6 +967,45 @@ describe(
);
});

it("verify memory usage statistics for shared textures", function () {
// Basic camera setup
const camera = scene.camera;
camera.position = new Cartesian3(0, -1, 0);
camera.direction = Cartesian3.clone(Cartesian3.UNIT_Y);
camera.up = Cartesian3.clone(Cartesian3.UNIT_Z);
camera.frustum.near = 0.01;
camera.frustum.far = 100.0;

// Move the camera to see no tiles
camera.position = new Cartesian3(100, -1, 100);

return Cesium3DTilesTester.loadTileset(
scene,
tilesetUrlWithSharedTextures,
).then(function (tileset) {
const statistics = tileset._statistics;

// No tiles loaded
expect(statistics.geometryByteLength).toEqual(0);
expect(statistics.texturesByteLength).toEqual(0);

// Move the camera to stare at the center of the first tile
camera.position = new Cartesian3(0.5, -13, 0.5);

return Cesium3DTilesTester.waitForTilesLoaded(scene, tileset).then(
function () {
console.log("Statistics ", JSON.stringify(statistics, null, 2));
// TODO
expect(statistics.geometryByteLength).toEqual(123);
expect(statistics.texturesByteLength).toEqual(234);

// TODO Eventually, trim
//tileset.trimLoadedTiles();
},
);
});
});

it("verify memory usage statistics for shared resources", function () {
ResourceCache.statistics.clear();
// Six tiles total:
Expand Down

0 comments on commit 32dd865

Please sign in to comment.