Public viewer

XZPattern

Published by admin ยท Updated 2026-03-20T10:51:10 UTC

Published grammar

This page uses the same scene-first presentation as the gallery viewer while also showing the source grammar text.

//------------------------------------------------
// Progen3D grammar: conditional xz-plane pattern generator
// Produces a tiled pattern across the XZ plane using conditionals
//------------------------------------------------

Start ->
    [
        T(-6 0 -6)
        R nx(10 20) R nz(10 20)
        R ix(5 nx)
        R iz(5 nz)
        PatternGrid(ix iz nx nz 1.0)
    ]

//------------------------------------------------
// PatternGrid(ix iz nx nz step)
// ix, iz  = current grid indices
// nx, nz  = grid dimensions
// step    = spacing between cells
//------------------------------------------------

PatternGrid(ix iz nx nz step) ->
    ?(iz < nz) Row(ix iz nx nz step) : End

//------------------------------------------------
// Row traversal
//------------------------------------------------

Row(ix iz nx nz step) ->
    ?(ix < nx)
        Cell(ix iz step)
        Row(ix+1 iz nx nz step)
     :
        PatternGrid(0 iz+1 nx nz step)

//------------------------------------------------
// Cell placement in XZ plane
//------------------------------------------------

Cell(ix iz step) ->
[
    T(ix*step 0 iz*step)
    ChoosePattern(ix iz)
]

//------------------------------------------------
// Conditional pattern selection
//------------------------------------------------

ChoosePattern(ix iz) ->
    ?( int((ix+iz)/2)-2==0)
        CheckerA
    :
        ?(int(ix/3)-3==0)
            StripeX
        :
            ?((int(iz/3)-3)==0)
                StripeZ
            :
                ?(( int((ix*ix)+(iz*iz))/5)-5==0)
                    Accent
                :
                    BaseTile

//------------------------------------------------
// Tile types
//------------------------------------------------

// Flat square tile
BaseTile ->
[
    S(0.9 0.08 0.9)
    I(Cube shinymetal 0)
]

// Slightly taller alternating tile
CheckerA ->
[
    T(0 0.06 0)
    S(0.9 0.16 0.9)
    I(Cube shinymetal 0)
]

// Long X-direction stripe
StripeX ->
[
    S(1.2 0.10 0.45)
    I(Cube shinymetal 0)
]

// Long Z-direction stripe
StripeZ ->
[
    S(0.45 0.10 1.2)
    I(Cube shinymetal 0)
]

// Accent pillar-like feature
Accent ->
[
    T(0 0.22 0)
    S(0.45 0.45 0.45)
    I(Cube shinymetal 0)
]

End ->

Viewer notes

Scene viewer is loaded from the embedded modular editor in read-only mode.
Orbit, zoom, grid, and axis widget remain available.
Use the gallery to jump between published grammars without leaving the live viewer workflow.