2 people like it.

Fun3D Castle

3D castle sample from the Fun3D project, now written using WebGL and running in a web browser...

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
14: 
15: 
16: 
17: 
18: 
19: 
20: 
21: 
22: 
23: 
24: 
25: 
26: 
27: 
28: 
let tower x y = 
  ( Fun.cone 
    |> Fun.color 0xff0000 
    |> Fun.scale (1.2, 1.2, 1.2) ) $ 
  ( Fun.cylinder 
    |> Fun.color 0xffff00
    |> Fun.scale (1.0, 3.0, 1.0) 
    |> Fun.move (0.0, -2.0, 0.0) )
  |> Fun.move (x, 2.0, y)

let wall rotation = 
  [ 0 .. 20 ] 
  |> List.map (fun i ->
      let scale = 
        if i%2=0 then 1.0 else 0.8
      let offs = (1.0-scale)/2.0
      Fun.cube 
      |> Fun.scale (1.0, scale, 1.0) 
      |> Fun.move (float i, -offs, 0.0)  )
  |> List.reduce ($)
  |> Fun.scale (0.25, 2.0, 0.5)
  |> Fun.move (-2.5, -0.5, -3.0)
  |> Fun.rotate (0.0, rotation, 0.0)

tower -3.0 -3.0 $ tower -3.0 3.0 $
tower 3.0 3.0 $ tower 3.0 -3.0 $
wall 0.0 $ wall 90.0 $ 
wall 180.0 $ wall 270.0 
val tower : x:'a -> y:'b -> 'c

Full name: Script.tower
val x : 'a
val y : 'a
val wall : rotation:'a -> 'b

Full name: Script.wall
val rotation : 'a
Multiple items
module List

from Microsoft.FSharp.Collections

--------------------
type List<'T> =
  | ( [] )
  | ( :: ) of Head: 'T * Tail: 'T list
  interface IEnumerable
  interface IEnumerable<'T>
  member Head : 'T
  member IsEmpty : bool
  member Item : index:int -> 'T with get
  member Length : int
  member Tail : 'T list
  static member Cons : head:'T * tail:'T list -> 'T list
  static member Empty : 'T list

Full name: Microsoft.FSharp.Collections.List<_>
val map : mapping:('T -> 'U) -> list:'T list -> 'U list

Full name: Microsoft.FSharp.Collections.List.map
val i : int
val scale : float
val offs : float
Multiple items
val float : value:'T -> float (requires member op_Explicit)

Full name: Microsoft.FSharp.Core.Operators.float

--------------------
type float = System.Double

Full name: Microsoft.FSharp.Core.float

--------------------
type float<'Measure> = float

Full name: Microsoft.FSharp.Core.float<_>
val reduce : reduction:('T -> 'T -> 'T) -> list:'T list -> 'T

Full name: Microsoft.FSharp.Collections.List.reduce

More information

Link:http://fssnip.net/qI
Posted:9 years ago
Author:Tomas Petricek
Tags: fun3d