Google Earth and Cesium examples


To help developers move from Google Earth to Cesium, we ported 30 Google Earth examples and demos to Cesium:

This includes the most popular Google Earth demo, the Monster Milktruck:

Try it. It’s fun to catch air off the cliffs in the Grand Canyon.

We also added a second tutorial for Google Earth developers, which is available here:

Please help spread the word.


Thanks for the links. Do all or most of those 30 examples have editable sandcastle counterparts? I noticed it only showed non-editable relevant code on those links.

The Monster Milktruck example is definitely fun! It seems to be sampling terrain height every frame and obtaining results quickly. I don’t see any promise/whens, just globe.getHeight. It also seems to be getting surface normal information used to orient the truck and determine travel and bounce direction.

Apparently it’s approximating the normal using a function called estimateGroundNormal by sampling altitude 1 unit away in the 4 cardinal directions. Clever idea. The graph is mis-labeled though, should be 0=east,1=west,2=north,3=south.


This will definitely be of great use for folks making the transition

for the examples of pin dragging, hittest, drawing ect… it may be useful to turn on terrain or have a second example with terrain to show the use of getPickRay, similar to the ‘Retrieving Ground Altitude Data’ example

var ray =,

cartesian = scene.globe.pick(ray,scene);

This is great, nice work guys!

Some feedback on the “Ground Altitude Data” example. The method this example uses for querying terrain heights is kind of ok when you’re zoomed in, but it returns total nonsense when you’re zoomed out. To see what I mean, zoom out until the entire globe is visible and then hover the cursor in the Pacific ocean off the coast of California. Cesium reports heights like -40k kilometers.

This is because low detail triangles cut deeply through the Earth. You can improve this somewhat by interpolating heights instead of positions. Figure out what triangle you’re in, get the heights at each of the three vertices of the triangle, find your barycentric coordinates within the triangle, interpolate the height at those barycentric coordinates. This gives better results, but still not amazing.

In National Map we go a step further and report a height +/- error bounds while moving the mouse, and then do an accurate height sample when the mouse stops moving.

Code for both techniques is here if it helps:

Note that I had to add a pickTriangle method to Cesium’s Globe. pickTriangle is identical to pick except that it also returns the vertices of the triangle that the pick hit instead of just the Cartesian location. Code for that is in the “nm” Cesium branch.


The pickTriangle function sounds great. It would then be easy to obtain the triangle’s normal by crossing 2 of its edges.

I did notice this line in the Monster Milktruck demo

“// TODO: would be nice to have globe.getGroundNormal() in the API.”

Monster Milktruck’s sampling heights on 4 nearby locations to determine the normal isn’t particularly efficient. Having access to the 3 vertices of the triangle would be much better.

One difference I’ve noticed is that ge.ALTITUDE_ABSOLUTE in GE is MSL and the altitude in Cesium is WGS84 (the difference is called undulation). When transitioning code from GE to Cesium one needs to account for this difference.

Matt, while you’re definitely correct, I wanted to add that support for various altitude modes is on the near term roadmap so this won’t be a problem for long.

@Hyper: “Do all or most of those 30 examples have editable sandcastle counterparts? I noticed it only showed non-editable relevant code on those links.”

No, but you should be able to copy and paste into Sandcastle with little trouble. You can also view source to see the complete example.

@Matt, thanks. We’ll mention it in the tutorial.