Skip to content

Instantly share code, notes, and snippets.

@ToJans
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ToJans/9659764 to your computer and use it in GitHub Desktop.
Save ToJans/9659764 to your computer and use it in GitHub Desktop.
I am probably overdoing it regarding types ATM
namespace Arealities.Models
type [<Measure>] mm; // milimeter
type [<Measure>] degrees; // degrees
type [<Measure>] intensity; // unit = 1
type Vector3D<'a> = {x: 'a; y: 'a; z: 'a}
type Placement = Placement of position: decimal<mm> Vector3D *
rotation: decimal<degrees> Vector3D
type Color = { r: float<intensity>; g: float<intensity>; b: float<intensity>}
type Material = Ground | Floor | ShinyStuff | Wall
type Geometry = CubeGeometry of size: decimal<mm> Vector3D
type Mesh = {
geometry: Geometry
material: Material
placement: Placement
castsShadows: bool
receivesShadow: bool
}
type Object3D = {meshes: Mesh list; placement: Placement}
type Light =
| AmbientLight of Color
| DirectionalLight of color:Color * intensity: float<intensity> * direction: decimal<mm> Vector3D
type Camera = Camera of position: decimal<mm> Vector3D * lookAt: decimal<mm> Vector3D
type SceneObject =
| Light
| Object3D
| Camera
type Scene = Scene of SceneObject list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment