programextensions/scene/demos/voxels-faces.xtl
Voxels, 2: which faces to draw. A face shows where a solid block's neighbor is not solid: six rotations of the solid mask, each compared with the mask itself (the idiom of Life), give every exposed face of the chunk at once; the faces become a list, one row each: x y z direction block. Checked on shapes with known answers, then the chunk's faces drawn as outlines in a 3D window, turning. Run: just demo scene voxels-faces (drag to turn it; q or close: quit)
inside : Int
inside ← 16 16 16 r̲eshape (ᵛˣxs > 0) × (ᵛˣxs < 15) × (ᵛˣys > 0) × (ᵛˣys < 15) × (ᵛˣzs > 0) × ᵛˣzs < 15
k : Int
k ← w ˢᶜc̲amera! 0.7 0.5 3.4 0.35
ᵘp̲ut : Int -> Int
each kind of block as one object, in its color
ᵘp̲ut ← { t → sel ← (5 s̲elect₂ f) = t 0 = '+ r̲/ sel ? t + 1 head ← (f̲loat w c̲at t) c̲at (t + 1) s̲elect ᵛˣcolors x ← head ˢᶜs̲egments! ᵛˣe̲dges sel r̲eplicate f t + 1 }
Used in: put