Module

Hylograph.Isometric.Prism

Package
purescript-hylograph-isometric
Repository
afcondon/purescript-hylograph-isometric

Prisms: an outline extruded upwards, and the faces of it a camera sees.

A box is a rectangle extruded, a cylinder a circle. Faces come in two forms: faces gives every face of a polygon prism in the world, wound anticlockwise about its outward normal; visibleFaces gives what a camera draws of any prism, projected, with a flat shading for each.

#Prism Source

newtype Prism

An outline on the floor at height base, extruded height upwards.

Constructors

Instances

#FaceKind Source

data FaceKind

Which face: the top, the bottom, the side standing on edge n of the outline (edge n runs from corner n to corner n + 1, the corners wound anticlockwise about +z), or a cylinder's curved side.

Constructors

Instances

#Facing Source

data Facing

Which way a drawn face looks, on the screen: the usual three tones of an isometric drawing (a top and the sides turned left and right), plus the underside and a cylinder's round side.

Constructors

Instances

#Face Source

type Face = { corners :: Array Point3, kind :: FaceKind, normal :: Point3 }

A face in the world: its corners, wound anticlockwise seen from outside, and its outward unit normal.

#DrawnFace Source

type DrawnFace = { facing :: Facing, kind :: FaceKind, lightness :: Number, normal :: Point3, outline :: Array Point }

A face as drawn: its outline on the screen, which way it looks, and a flat lightness in [0, 1] (see lightness).

#box Source

box :: Rectangle -> { base :: Number, height :: Number } -> Prism

#cylinder Source

cylinder :: { centre :: Point, radius :: Number } -> { base :: Number, height :: Number } -> Prism

#prismOutline Source

#faces Source

faces :: Prism -> Array Face

Every face of a polygon prism: the bottom, the sides, the top. A cylinder's curved side has no single normal, so for a cylinder this gives only the top and the bottom.

#visibleFaces Source

visibleFaces :: Camera -> Prism -> Array DrawnFace

What the camera sees of a prism: the faces turned towards it, projected. A prism is convex, so its visible faces never overlap one another; they come sides first and top last, so the top's outline is drawn over the edges it shares with them.

A flat face is kept when its projected outline winds the way a face seen from outside does, which is the same as its normal facing the camera. A cylinder's curved side is drawn as one face: the half of it towards the camera.

#faceKey Source

faceKey :: FaceKind -> String

A key for a face, stable while the camera turns.

#lightness Source

lightness :: Camera -> Point3 -> Number

A flat (Lambertian) lightness in [0, 1] for a face with this outward normal, lit from above, over the viewer's left shoulder. The light turns with the camera, so a turned scene keeps its tones: tops lightest, faces turned left next, faces turned right darkest.