I have a mesh object that has a GlobeAnchor. This correctly attaches to the Cesium Globe. I then draw some other objects onto this mesh, those objects too have a GlobeAnchor.
Shouldn’t the GlobeAnchor stay consistent (relative to the Globe)? This seems to result in Objects not being correct ‘drawn’ onto the mesh as I would expect (because I’m setting the Ecef of the GlobeAnchor).
Am I missing something? Or do you not support GlobeAnchor to be a child of a GlobeAnchor?
Apologies for the slow response. To be honest, we hadn’t considered the case of nested globe anchors and I’m not sure what the expected behavior would be. What’s the motivation to nest these globe-anchored objects – are they unable to be separate?
I don’t know how others feel but I would expect a nested GlobeAnchor would have its Unity Transform update as a standard Unity Parent-Child Transform would - so in global space the child would move with its parent.
Of course if the user had ‘DetectTrasformChanges’ enabled, the GlobeAnchor on the child would update to the new location as the parent was moving.
The motivation in our case is that we are linking 3d images to mesh objects that are placed on the globe - so moving the mesh will keep the same relatively offset to the image. These images are their own distinct entities and have their own transforms and GlobeAnchors (they also have the aiblity to “parent” to other mesh objects if the user wants).
We have worked through the limitation by updating any “child” when the “parent” moves but it would be nice if this was just handed ‘out the box’.
This stuff gets confusing fast! While the CesiumGlobeAnchor seems simple on the surface, there are a number of corner cases where inconsistent behavior creeps up if you’re not careful. We’ve settled on some behavior that is consistent and rational, but not always intuitive. It’s described in this old PR:
The best way I can describe it is that a CesiumGlobeAnchor, when you set its ECEF or longitude/latitude/height, sets the Unity position and orientation of the object its attached to based on the CesiumGeoreference and then the object is further transformed into the Unity world by the normal chain of Unity transforms. While this may seem strange, it’s necessary in order for Unity Transforms to behave the way everyone expects them to. For example, we want to be able to place the globe in the Unity world by setting its Transform, right?
But this means that two nested objects with a CesiumGlobeAnchor on each will effectively perform the CesiumGeoreference transform twice, which is surely not useful.
In theory we could detect CesiumGlobeAnchor nesting and perform special handling (i.e., don’t perform the entire CesiumGeoreference transform for the inner one). But this adds complexity and would probably reduce performance as well.
In general, I would say that objects that are anchored to the globe should be direct children of the CesiumGeoreference. If an object is instead positioned relative to some other object, nesting it makes sense, but then it should not (and, I think, need not) have a CesiumGlobeAnchor.
I guess I can imagine somewhat unusual cases where it’s useful to get or set the globe position and orientation of a GameObject, but its Unity Transform would still be relative to some other object. In those cases, you can use methods on CesiumGeoreference to perform the necessary transformations manually.