programextensions/scene/demos/voxels-light.xtl
Voxels, 14: light. The endless world, lit: a face open to the sky is in full sunlight; under an overhang, beneath a tree's crown or down a tunnel the light fades, a step a block, as it spreads from the open air. A lamp (the hotbar's eighth block) glows: its light spreads the same way through the air around it. N turns day to night and back -- the sunlight and the sky go, the lamps stay -- by one number in scene, so nothing is worked out again. Each column's light is worked out as it is made (vx:c_olumnLight: sunlight by a scan down each column, then rounds of spreading), and again when an edit makes it again: dig a tunnel's roof open and the sun comes in. Run: just demo scene voxels-light click (or X) dig, right-click (or E) place, 1 to 8 choose the block (8 a lamp), N night or day, W A S D walk, Space jump, Shift run, F fly, drag or the arrows to look, H back to the start, q quit
The light, checked
ᵘs̲unOf : (Any a, Any b) => (a, b) -> a
ᵘs̲unOf ← { (sun, _) → sun }
L : (Int, Int)
L ← ᵛˣc̲olumnLight b
row : Int
row ← 1 + tunnel r̲eplicate cell
s : ((Float, Float, Float, Float, Float, Float), (Int, Int, Box Int, Box Int, Int, Int, Int, Int), (Int, Int, Int, Int), (Int, Int, Float, Int, Int))
s ← ᵉⁿl̲ighting ᵉⁿn̲ew w
s : ((Float, Float, Float, Float, Float, Float), (Int, Int, Box Int, Box Int, Int, Int, Int, Int), (Int, Int, Int, Int), (Int, Int, Float, Int, Int))
s ← (4 × (1 + 2 × ᵉⁿreach) × 1 + 2 × ᵉⁿreach) 'ᵉⁿs̲tream p̲ower s