How To Create Webgl Earth With Geodata Showing Locations By Tooltip
Date 15.1.2013 //
// Add to
The first idea was to run this code thru CanvasRender, sadly CanvasRender does not support THREE.Texture, so, impossible to show Tooltips.
I had to switch to WebGL. It took a while to finish this puzzle code, I spent lot of time till I figured out that THREE.Texture is not displayed in Firefox :))
So, what this demo does is:
1. Creates a 3D Globe Sphere with texture.
2. Add Geodata on Sphere surface.
3. Using INTERSECTED intersects the objects on surface and shows the Tooltip ( works only in WebGL ).
Demo link webGL( try Chrome for WebGL!):
Demo link Canvas:
When I start to code on this demo I had in mind the Flash 3D Version available on GeocodEarth Website ( http://www.geocodearth.com/
), before was ( http://www.twittearth.com/
), where xml data is readed from Twitter/Flickr and than displayed by location Latitude and Longitude of a Point. Of course this demo can be improved, an xml/json File can be readed with jQuery and then, all data can be attached to different Geo Data Points on Sphere surface.
There is also a hope to have Tooltips in CanvasRender mode, well, not in Canvas drawed but as distinct div layers or modalwindow. Using jQuery(document).mousemove(e) the demo can get mouse position as e.pageX, e.pageY values for Top and Left and then, on INTERSECT.object event is easy to place a layer exactly over the Geo Data Point Dot/Marker using absolute position as style attribute for Tooltip layer. CanvasRender output is not so good as WebGLRenderer but the advantage for Canvas is that every browser support it.
References for Demo:
1. For creating a Globe Sphere, a good reference is Canvas Geometry Earth Demo from mrdoob website:
Another good example of canvas Globe:
2. For converting data point to a coordinate on the sphere, adding Geodata on Sphere, I use the function latLongToVector3() from smartjava.org:
3. Tooltip idea came from stemkoski demo: