Hi there,
we are currently running into an issue with the zoomTo function for tilesets. By default, the zoom seems to be based on the bounding volume of a tileset. Creating tileset with Agisoft Metashape, however, leads to bounding volumes significantly larger than the actual content volume.
Is there any way of using the zoomTo function to zoom to the actual content of a tileset rather than the extent of the largest bounding volume of the tileset?
In short, we would like to zoom to the blue box instead of the white one seen in the screenshot.
Thanks a lot in advance!
Hi there,
It’d be possible to zoom to the bounding sphere of the relevant tile.
You would iterate through the tree of tiles starting at the tileset root tile. Then, once you’ve identified the relevant tile, use tile.contentBoundingVolume.boundingSphere
to get the tighter fitting bounding sphere.
That bounding sphere can be used as input to Camera.flyToBoundingSphere
.
Hope that helps!
Thanks a lot for your reply! Actually, this approach seems to work quite well.
Cheers
Hi, I am stuck with same problem. Can you share your approach ?
How to identify the correct tileset to zoom ?
Thanks
Hi Saurabh,
we managed to solve the issue using the following code:
const viewer = new Cesium.Viewer(“cesiumContainer”, {
terrain: Cesium.Terrain.fromWorldTerrain(),
});
try {
const tileset = await Cesium.Cesium3DTileset.fromIonAssetId(YOURASSETID);
viewer.scene.primitives.add(tileset);
await viewer.scene.primitives.add(tileset).readyPromise;
const rootTile = tileset.root;
const boundingSphere = rootTile.contentBoundingVolume.boundingSphere;
const offset = new Cesium.HeadingPitchRange(
0,
-0.5,
boundingSphere.radius * 1.5
);
viewer.camera.flyToBoundingSphere(boundingSphere, {
duration: 3.0,
offset: offset
});
} catch (error) {
console.log(Error loading tileset: ${error}
);
}
Best regards and good luck,
Johannes