I am trying to get some properties from a model imported via Cesium Ion.
Is there any method the get the dimensions of the model from Cesium Ion?
For instance, if I use the model from Cesium Ion and I want to cut the same size in the Terrain or Buildings from OpenStreet. I was thinking that I need to use BoundingBox
How to get the position of the model imported from Cesium Ion? Something like tileset.position?
Welcome to the Cesium community!
You should use the boundingSphere.center for this case: https://cesium.com/docs/cesiumjs-ref-doc/Cesium3DTileset.html#boundingSphere.
The bounding sphere center and radius will give you a sphere that covers all the max bounds of the 3D Tileset.
Let me know if that works for you!
Thank You. I manged to use bounding.Sphere to get the center position. However I am trying to get the orientation of the tileset and I am not sure if its working. I am trying to get the dimension of the inserted tileset. To do that I am testing BoundingBox and OrientedBoundingBox.
Below I am attaching the code:
tileset_koksownia.readyPromise.then(function(tileset) {
// Set the camera to view the newly added tileset
var entity3 = viewer.entities.add({
position: tileset.boundingSphere.center,
orientation: tileset.boundingSphere.orientation,
box: {
//dimensions: new Cesium.Cartesian3(150.0, 440.0, 1.0),
dimensions: new Cesium.Cartesian3(2tileset.boundingSphere.radius, 2tileset.boundingSphere.radius, 2*tileset.boundingSphere.radius),
material: Cesium.Color.RED.withAlpha(0.4),
outline: true,
outlineColor: Cesium.Color.RED,
},
});
viewer.camera.viewBoundingSphere(tileset.boundingSphere, new Cesium.HeadingPitchRange(0, -0.5, 0));
});