I am working on the project where I have to type an address, and Geocoding service gives me its lat/lon. As I don’t have height parameter, I am requesting the position in Cesium with the height=0.
Now - when the tiles are settled, I need to somehow determine what is minimal Y value for all the tiles in the tileset, and to re-position CesiumGeoreference object to fit on the plane acting as the table.
Passing through the tiles and getting their CesiumGlobeAnchor and MeshRenderer components is not a question - I did that already, and I have an access to all these components. I am just in doubt how to obtain this “elevation” value, so I can shift CesiumGeoreference by that amount, in order to make it look like it is sitting on the table.
I was trying to do that with the help of meshRenderer.bounds, as well as with globeAnchor.longitudeLatitudeHeight.z, but no one of them didn’t give me satisfying results.
Any suggestion appreciated.
Perhaps you can get the MeshRenderer.bounds
property of every tile. Union them all together to the overall bounding volume of the rendered part of the globe (union of two axis-aligned bounding boxes is just the minimum of the minimums and the maximum of the maximums). Then access the center
property of the union Bounds instance (or perhaps the center of the bottom?). That will be in Unity world coordinates, so Y is the vertical direction. Be aware that the result will be affected by the Georeference’s current transform, so you’ll have to account for that.
When you say it will be affected by the Georeference transform - what do you exactly mean? Because I think that is the main thing which is causing the problems.
So far, I was trying to iterate through all the active tile renderers, and get their bounds, but when I tried to render the bounding box with gizmos, I was getting much larger boxes.
I also tried to make overall bounds by calling bounds.Encapsulate(otherTileBounds), but still - much larger box was the result.
Hi @NebojsaBrindic,
Kevin is referring to the transform of the CesiumGeoreference’s game object. The georeference and all of the Cesium game objects under it are also affected by its transform. So if you have Cesium World Terrain under the georeference, and the georeference’s transform is (0, 100, 0), then the globe and all other Cesium objects will be transformed 100 units up. Basically, if the georeference’s transform is different from the default values, you’ll have to account for them in your calculations.
Can you share how you’re trying to combine the bounding boxes (the exact code), and what output you’re seeing with the gizmos?
Hey @NebojsaBrindic, were you able to solve your problem? I was curious about the same thing too. And do you mind sharing what geocoding service do you use?