code wiki / (root) / nx_wasmvoxel.nx

nx_wasmvoxel.nx

buildroot/runtime/nx_wasmvoxel.nx

8713 B222 linesdepth 1pulls 1 transitivereach 0 importersview sourcekind orphan library
docsdependenciesstructsconstsfunctions

about

nx_wasmvoxel.nx -- a VOXEL TERRAIN in the WASM/BROWSER memory model: an 8x8 heightmap (two procedural hills, height-banded grass/rock/snow) of f32-projected voxel columns, painter-sorted far->near, integer-filled to a fixed-offset framebuffer. Same sovereign chain as the cube (nx_compile_wat -> nx_wat_compiler -> .wasm). JS owns trig + blits the fb to <canvas>; wasm owns the world + the hardware f32 math. license_tier: ORIGINAL

dependencies 1 imports · 0 importers

nx_f32_hw.nx nx_wasmvoxel.nx

imports: nx_f32_hw.nx

imported by: nobody (leaf or entry point)

structs

none

consts

6const O_MAGIC_65536: i64 = 65536
7const O_MAGIC_16777216: i64 = 16777216
9const W: i64 = 128
10const H: i64 = 128
11const HWc: i64 = 64
12const HHc: i64 = 64
13const SCALE: i64 = 9
14const N: i64 = 8
15const O_FB: i64 = 0
16const O_RY: i64 = 131072
17const O_RX: i64 = 131200
18const O_R: i64 = 131328
19const O_VTMP: i64 = 131456
20const O_OTMP: i64 = 131488
21const O_SX: i64 = 131520
22const O_SY: i64 = 131584
23const O_CIDX: i64 = 131648
24const O_CZ: i64 = 132160
25const O_CX: i64 = 132672
26const O_CZW: i64 = 133184
27const O_CH: i64 = 133696
28const O_FACES: i64 = 134208

functions

30func imin(a: i64, b: i64) -> i64 { if a < b { return a } return b }
31func imax(a: i64, b: i64) -> i64 { if a > b { return a } return b }
32func min3(a: i64, b: i64, c: i64) -> i64 { return imin(a, imin(b, c)) }
33func max3(a: i64, b: i64, c: i64) -> i64 { return imax(a, imax(b, c)) }
34func same_sign3(a: i64, b: i64, c: i64) -> i64
39func fbp() -> *i64 { return (O_FB as i64) as *i64 }
40func fratio(num: i64, den: i64) -> i64 { return f32_div(f32_of(num), f32_of(den)) }
41func fill_tri(x0: i64, y0: i64, x1: i64, y1: i64, x2: i64, y2: i64, col: i64) -> i64
63func rot_nz(R: *i64, lx: i64, ly: i64, lz: i64) -> i64
70func shade(nz: i64) -> i64
75func packc(r: i64, g: i64, b: i64, br: i64) -> i64
82func hcol(gx: i64, gz: i64) -> i64
92func face_nz(R: *i64, fidx: i64) -> i64
100func basergb(hh: i64, top: i64) -> i64
111func render(ycos: i64, ysin: i64, xcos: i64, xsin: i64) -> i64
219func fb_off() -> i64 { return O_FB }
220func ww() -> i64 { return W }
221func hh() -> i64 { return H }
222func main() -> i64 { return 0 }