1

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 area. 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,
>   });
> });
0

tileset.root.boundingVolume.rectangle would be "undefined" in your tileset.

use the following code.

tileset.readyPromise.then(function (tileset) {
   console.log(tileset.root.boundingVolume.rectangle)
    
   console.log(tileset.root.boundingSphere)
  
   viewer.camera.flyToBoundingSphere(tileset.root.boundingSphere);
 });

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.