A small beautiful demo, laid out by David Lee - see ( discussion ).
Most of the "magic" is done using GLSL shaders on the GPU, JavaScript code with matrices is a necessary preparation for working with 3D graphics. The wave motion algorithm is based on the method described by Jerry Tessendorf in the article “Simulation of Ocean Waves” published on SIGGRAPH 2002 (the link is the source code written in C ++); on the topic you can read this . Whoever doesn’t earn the demo (“Your browser doesn’t even support the required technologies. You can still view this on YouTube”), you can try to view it along with the source code on jsfiddle , because some browsers that can display it and not less left overboard, does not skip hasWebGLSupport (). ')
PS Another couple of interestinglinks .