Tuesday, September 17, 2019

Coding Projects

So, what I want to create is a star sector map drawing page, which I have, not perfect but it's a first pass. Then I want to have star systems and an animation displaying the orbiting planets, in 2D to keep it simple. Finally, I want to generate a simple low-poly world map, again in 2D, either a rectilinear longitude and latitude map or an XY side view of a 3D globe without the fancy rendering tricks I can learn to do...

The world map is best generated XYZ, a cube-sphere for what I ultimately have in mind, but a long/lat rectangle mapped to a UV sphere is something I have done many times before. I don't have a noise function in plain vanilla javascript but I can do midpoint displacement (diamond square) by long and lat for a nice height map of the long/lat points, divide the long/lat quads into triangles and average the vertices to find a height for each triangle, placing it above or below sea level.

Drawing landmass... this is just a polygon drawn around an origin from a random starting angle to a random stopping angle. The rectangle is 520 by 260 pixels because the blog text block seems to be that wide and this looks okay. The star sector was 500 pixels square, a 20 light year cube with about 30 stars.

Canvas

No comments:

Post a Comment