Well, this is what sampleHeight() and sampleHeightMostDetailed() is all about, where you pass in an array of positions you want to sample the height of, and then you get that array back (in a Promise for the latter).
There’s been some talk in the past (both here and on various Git issues) the idea of having API access (or flagging to retain certain data; lots of data gets loaded and then freed up as it hits the 3D rendering engine) to height data, but it’s a tricky one as you’re trying to have the scene render fast and use as little memory as possible. I know some of that data is in the rendering engine, but unaccessible, and I don’t actually know if code can be written to access it any faster than the current way (unless the height data is made available on load, for example through an event we can subscribe to?) That way we could pull out the data we need for a given area [without needing to store the data for the whole scene]).
But they are still somewhat time-consuming still. It might be worth your time, depending on how large the area is, to look at the source data instead of the rendered scene. For example, if you need to know the precise heights across a large area, I would consider creating a service that runs on a server where you pass in an array of positions, and you’ll get back that array that has been filled from the original data (in the DEM), as on the server-side you can index these and pull out the info far quicker than sampling with a ray intersection on the UI.
Hope any of that’s helpful.