An orthographic camera for Hylograph: isometric (and any other axonometric) views of 2D layouts, drawn as keyed SVG.
An isometric view is a projection, not a layout. A 2D layout (a tree, a treemap, a grid) is put on a plane in the world, given heights, and projected by a camera with two angles, azimuth and elevation. Isometric is one setting of them (azimuth 45°, elevation ≈ 35.26°). Turning the view is changing an angle, so everything stays SVG: keyed, clickable, printable, and animatable by redrawing with HATS. No perspective, deliberately, since an orthographic view keeps lengths along an axis comparable. No WebGL.
The world uses a layout's own coordinates: x and y as the layout gave
them (y grows down the page, which on the floor is south), and z up.
Hylograph.Isometric.Camera:Point,Point3,Degrees,Camera(azimuth,elevation,scale),isometric,isometricFromaViewpoint(SouthEast | SouthWest | NorthWest | NorthEast),isometricUnit(a unit along any axis drawn so many screen units long),turnedBy,between(for animating),project :: Camera -> Point3 -> Point,depth.Hylograph.Isometric.Plane:floor(at a height, so floors stack),leftWall,rightWall,onPlane :: Plane -> Point -> Point3.Hylograph.Isometric.Outline:Outline = Polygon (Array Point) | Circle,rectangle.Hylograph.Isometric.Prism:box,cylinder;faces(every face in the world, with its outward normal) andvisibleFaces(what a camera draws: projected outlines, aFacingofUpward | Leftward | Rightward | Downward | Aroundfor flat three-tone shading, and a Lambertlightness).Hylograph.Isometric.Spike: a thin needle or bar standing on a point, always facing the camera, with an optional drop shadow.Hylograph.Isometric.Painter:paintersOrder :: Camera -> (a -> Outline) -> Array a -> Array a, back to front, for things standing on one floor, from any azimuth (a topological sort of "a horizontal line towards the camera meets this one first", not a sort by distance, which fails as soon as footprints differ in size).Hylograph.Isometric.HATS:pathData,pointsData,prismFaces(a prism's visible faces as keyed paths) andinPaintersOrder(marks joined by key in the painter's order).
Everything but the last module is pure geometry and needs no DOM. Point and
Point3 are record synonyms rather than newtypes, so that the positions
hylograph-layout produces go straight in.
camera = isometricUnit 30.0
prism = box { x0: 0.0, y0: 0.0, x1: 1.0, y1: 1.0 } { base: 0.0, height: 2.0 }
faces = visibleFaces camera prism -- top, and the sides facing +x, +y
order = paintersOrder camera prismOutline prismsspago test: the isometric axes; a full turn is the identity and a quarter
turn maps the grid onto itself; the painter's order checked against an
independent 3D statement of "in front of" (a line of sight through both
boxes' interiors) on random grids and strips, from the four viewpoints and
from azimuths and elevations in between; visible faces are exactly those
whose normals face the camera.
- the derivation city of the Sudoku demo (
purescript-hylograph-demos/baskerville-sudoku);docs/screenshots/sudoku-city-before.pngand-after.pngare the city before and after it moved onto this library; - the
isometricdemo inpurescript-hylograph-demos(flare on the floor, turned a quarter at a time).
MIT