Luce packages
LuceLuce BaseLuciaOS

dymokomi/luce-geocore

Source of release 0.7.7

0.7.7 / src / verbs / create_sweeps.lucb

## Torus (twisting its rings by a number of their points over the way
## round) and Helix (a spring: a wire along a helix, its ends capped).

let torus_parms: ParmSpec[9] = [
    ParmSpec("Radius", ParmKind.number, 1.0, 0.001, 100000.0, 1, "", "From the center to the middle of the tube (the major radius).", 10.0),
    ParmSpec("Tube radius", ParmKind.number, 0.3, 0.001, 100000.0, 1, "", "The tube's own radius (the minor radius), below the radius.", 2.0),
    ParmSpec("Segments", ParmKind.integer, 24.0, 3.0, 4096.0, 1, "", "Rings round the torus (major segments)."),
    ParmSpec("Sides", ParmKind.integer, 12.0, 3.0, 4096.0, 1, "", "Points round each ring (minor segments)."),
    ParmSpec("Twist", ParmKind.integer, 0.0, 0.0, 4095.0, 1, "", "Points each ring turns by over the whole way round (below Sides)."),
    position_parm, up_parm, turn_parm, piece_parm]

let torus_place: PlaceSpec = PlaceSpec("radius", 0, rise = 1, rise_mode = "radius", position = 5, up = 6)

func torus_verb() -> Verb:
    return Verb("Torus", "Primitives", "A ring: a tube swept round a circle, resting on its base", Domain.face, false, torus_parms, true, cook_torus, section = "Create", family = "Primitives", icon = "torus", inputs = 0, wheel = 2, gesture = "create", place = torus_place)

func cook_torus(input: const VerbInput*, output: VerbOutput*) -> !:
    let p = input.parms
    try add_piece(input, output, try torus_mesh(p.at(0), p.at(1), try count_of(p.at(2), 3.0, 4096.0), try count_of(p.at(3), 3.0, 4096.0), try count_of(p.at(4), 0.0, 4095.0)), "torus", 5)

let helix_parms: ParmSpec[11] = [
    ParmSpec("Radius", ParmKind.number, 1.0, 0.001, 100000.0, 1, "", "From the axis to the wire's middle.", 10.0),
    ParmSpec("Wire", ParmKind.number, 0.1, 0.001, 100000.0, 1, "", "The wire's radius.", 1.0),
    ParmSpec("Turns", ParmKind.number, 4.0, 0.01, 1000.0, 1, "", "Times the wire goes round.", 20.0),
    ParmSpec("Height", ParmKind.number, 2.0, 0.0, 100000.0, 1, "", "How far it rises from the first turn's start to the last's end (0: a flat spiral of turns on one another).", 10.0),
    ParmSpec("Steps", ParmKind.integer, 24.0, 3.0, 2048.0, 1, "", "Rings of the wire in each turn."),
    ParmSpec("Sides", ParmKind.integer, 8.0, 3.0, 4096.0, 1, "", "Points round the wire."),
    ParmSpec("Caps", ParmKind.toggle, 1.0, 0.0, 1.0, 1, "", "Close the wire's two ends."),
    position_parm, up_parm, turn_parm, piece_parm]

let helix_place: PlaceSpec = PlaceSpec("radius", 0, rise = 3, position = 7, up = 8)

func helix_verb() -> Verb:
    return Verb("Helix", "Primitives", "A spring: a wire swept along a helix", Domain.face, false, helix_parms, true, cook_helix, section = "Create", family = "Primitives", icon = "curve-spiral", inputs = 0, wheel = 4, gesture = "create", place = helix_place)

func cook_helix(input: const VerbInput*, output: VerbOutput*) -> !:
    let p = input.parms
    try add_piece(input, output, try helix_mesh(p.at(0), p.at(1), p.at(2), p.at(3), try count_of(p.at(4), 3.0, 2048.0), try count_of(p.at(5), 3.0, 4096.0), p.at(6) != 0.0), "helix", 7)