I’m working on some performance optimizations and have noticed that in Unity’s profiler, updating the position, scale and rotation for a few dozen globe anchors can take on the order of milliseconds.

I can see that each of these lines adds a not insignificant bit of CPU time, and I’m wondering if there’s an easy way to update everything in one shot.

Am I correct to think that constructing a double4x4 with my values and setting localToGlobeFixedMatrix would do what I want? I started going down that path but realized the setter for rotationEastUpNorth calls some native code.

I’m now looking at Helpers.TranslationRotationAndScaleToMatrix as an example of how to construct the 4x4 matrix. I’ll see where that gets me.

edit: I’m thinking I’ll also need to negate the scaleEastUpNorth, convert loc to ECEF via CesiumWgs84Ellipsoid.LongitudeLatitudeHeightToEarthCenteredEarthFixed(loc), not sure about rotation, but in most if not all cases we’re using quaternion.identity for our anchors.

Taking milliseconds to update a couple of dozen globe anchors sounds like a really long time! I haven’t measured lately, but that’s definitely much longer than I would have guessed.

You can definitely save some time by setting the matrix directly. You’re right that your matrix needs to include the complete transformation from the Unity local coordinate system to the right-handed ECEF coordinate system. The native implementation can be found here:

Thanks Kevin! To be fair I did have deep profiling enabled so the numbers may have been blown out of proportion a bit. I’ll check again, but it seemed significant enough to address.