CesiumJS : Zoom on tileset BoundingVolume Rectangle?

Good evening,

I work on windows 10 with Cesium 1.72.
NodeJS and Cesium work well.
I succeed in adding a tileset format3D tiles (Meshs + associated texture).
However, I would like to define a zoom on my tileset extents.
Currently, the display, the viewer remains global and the camera don’t move toward my area of interest.

My wish is that once the tileset is ready to be displayed, the camera will move and position itself above the tileset. The little script works fine with my cesium3D tiles version 0.0 file. But does not work for the moment with my cesium 3D tiles 1.0 version.
I don’t know where the error could come from. I don’t have an error message in the console. My tileset is loading fine but
the camera does not move over my tileset. When running the code, the camera does not move and remains in a global “globe” grip and no zoom is performed. I am therefore obliged to go manually to the area of ​​interest.

Below is an excerpt from the tileset.json file:

> {"asset":{"version":"1.0"},
> "geometricError":10000,
> "properties":{"Height":{"maximum":197.2902062288683,"minimum":158.81894164623267},
> "Latitude":{"maximum":0.86549605155357123,"minimum":0.86536928860221218},
> "Longitude":{"maximum":0.069327552218852465,"minimum":0.069115786360719259}},
> "root":{"boundingVolume":{"sphere":[4133254.630298804,286568.64019880601,4833172.8602689737,596.59912274524095]},
> "children":[{"boundingVolume":{"sphere":[4133289.5021612602,286493.75629316899,4833147.6480717165,514.11988103071815]}

Below, my little javascript script :

> // Cesium viewer set up
> var viewer = new Cesium.Viewer("cesiumContainer", {
>   
> });
> 
> // tilset setup
> var tileset = new Cesium.Cesium3DTileset({
>   url: 'http://localhost:8080/riaom/tileset.json'
> });
> 
> // Add the tileset to the 3D scene
> viewer.scene.primitives.add(tileset);
> 
> // Zoom on Tileset
> tileset.readyPromise.then(function (tileset) {
>   viewer.scene.camera.setView({
>     // Final position has to take into account the whole tileset
>     destination: tileset.root.boundingVolume.rectangle,
>   });
> });

Thanks a lot for your usefull help

Checkout this function. Zooming to the tileset is as easy as:
viewer.zoomTo(tileset);

Thanks for your reply.
But the function viewer.zoomTo(tileset);
seems to set a default position with camera 's rotation.


My goal would be to set a “true aerial view” , a camera position without rotation value and taking into consideration the whole tileset extents. Taking into consideration the value defined in the tilest json file for the root boundingVolume Rectangle :

Moreover, in addition to the function viewer.zoomTo(tileset);
Do you know others ways to define cameras positions (for instance with defining rotation, position, scale parameters? Or thanks to rectangle drawing ? Or coordinates seting ? Or other way?

Thanks a lots.

get the extents of the bounding volume, create a rectangle from the extents, use this as the destination arg for camera.flyTo/setView?

Thanks for your reply. Indeed, as i writed within my first message i tried to use the boundingVolume for the zoom destination. But up to now, my attemp does not work. I don’t know why. I have no error message in the console but the viewer stays at the world level. I will do new tests thanks to your resource link. Thanks again.