In the image, the ECS hierarchy is on the left. The
GeoReference
is the at the root. The ECS subscene is a child of the GeoReference
and has a GlobeAnchor
component on it (but I’m not sure this is needed in this case).
I’ve selected one of the particles to see what it’s position is at runtime. As you can see in the inspector, the position is some really big numbers in all three axes. This should be the “local” position of the particle, but to be honest, I’ve just started using ECS and I’m not sure if entity positions take the position of the ECS (parent) subscene into consideration.
My basic approach to placing the particles in the scene (using the GeoToLocalPosition
function described above):
- Read the lon/lat/depth values of the particle that frame
- Convert the lon/lat/depth values from lon/lat/depth to ECEF
- Convert the ECEF values to Unity coordinates
Obviously, if I can go straight from lon/lat/depth values to Unity local space, that would be ideal, but I’m not a math genius and I can’t quite figure out how to do that (without a week for research on the math). I was hoping there is some magic Cesium functions to do that, but I also can’t find the API documentation for the CesiumUnity package so I have to read the source code to figure it out, but most of it is behind prebuilt binaries (and this is probably in the cesium-native repo, but this is where the search starts getting complex for a newbie like me).
I can’t just use the GlobeAnchors on the ECS entities in the scene. You can’t just use a standard components on entities like you can on GameObjects in Unity. I can read data (like a transform matrix) from the the components and translate that to the ECS world and do the math there (which is what I’m trying), but the numbers just don’t come out to what I expect them to.
Sorry for the long post, but I’m really struggling with this and my project lead is getting impatient