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/9645088 to your computer and use it in GitHub Desktop.
Save ToJans/9645088 to your computer and use it in GitHub Desktop.
Odd error: pilar is a Mesh, and I want to change some fields, so I use the with-syntax. On the last line I get this error:
Error 1 This expression was expected to have type
unit
but here has type
Mesh C:\dev\.Net\arealities\Arealities.Models\Veranda.fs 17 11 Arealities.Models
module Arealities.Models.Veranda
let windowWall(width:decimal, height:decimal, maxWidth: decimal , beamThickness:decimal) =
let pilar = { geometry = CubeGeometry(Size(beamThickness,height, beamThickness));
position = Position(0M,0M,0M);
rotation = Rotation(0M,0M,0M);
material = ShinyStuff;
castsShadows = true;
receivesShadow = false;
}
let panelCount = (width - beamThickness)/maxWidth |> System.Math.Ceiling |> int
let spaceBetweenBeams = (width-beamThickness) / decimal(panelCount) - beamThickness
let halfWidth = width/2M
let halfHeight = height/2M
[1..panelCount] |> List.iter(fun i ->
let x = decimal(i-1)*(spaceBetweenBeams+beamThickness)-halfWidth;
{ pilar with position = Position(x, halfHeight, 0) })
let veranda(Size(x,y,z)) =
let beamSize = 1
let panelDepth = 0.5
let maxPanelWidth = 12
windowWall(1M,1M,1M,1M)
namespace Arealities.Models
type Size = Size of decimal * decimal * decimal
type Position = Position of decimal * decimal * decimal
type Rotation = Rotation of decimal * decimal * decimal
type Direction = Direction of decimal * decimal * decimal
type Intensity = float
type Color = Color of Intensity * Intensity * Intensity
type Material = Ground | Floor | ShinyStuff | Wall
type Geometry = CubeGeometry of Size
type Mesh = {
geometry : Geometry;
material : Material;
position : Position;
rotation : Rotation;
castsShadows: bool;
receivesShadow: bool
}
type Object3D = Object3D of Mesh list * Position * Rotation
type Light =
| AmbientLight of Color
| DirectionalLight of Color * Intensity * Direction
type Camera = Camera of Position * Direction
type SceneObject =
| Light
| Object3D
| Camera
type Scene = Scene of SceneObject list
@ToJans
Copy link
Author

ToJans commented Mar 19, 2014

doh; map, not iter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment