mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-01-29 20:08:21 +01:00
refactor
This commit is contained in:
parent
8b90e319b3
commit
d6f7219eb6
@ -6,4 +6,4 @@ function _footprints3(cmds, t, leng, i = 0) =
|
||||
nxt = turtle3d(cmds[i][0], t, cmds[i][1]),
|
||||
pts = _footprints3(cmds, nxt, leng, i + 1)
|
||||
)
|
||||
cmds[i][0] != "forward" && cmds[i][0] != "yu_move" && cmds[i][0] != "zu_move" ? pts : [turtle3d("pt", nxt), each pts];
|
||||
cmds[i][0] != "forward" ? pts : [turtle3d("pt", nxt), each pts];
|
||||
|
@ -20,14 +20,14 @@ function _next_t1(t1, t2, code, stack) =
|
||||
|
||||
function _next_t2(t, code, angle, leng) =
|
||||
is_undef(code) || code == "[" || code == "]" ? t :
|
||||
code == "F" || code == "f" ? turtle3d("xu_move", t, leng) :
|
||||
code == "+" ? turtle3d("zu_turn", t, angle) :
|
||||
code == "-" ? turtle3d("zu_turn", t, -angle) :
|
||||
code == "|" ? turtle3d("zu_turn", t, 180) :
|
||||
code == "&" ? turtle3d("yu_turn", t, angle) :
|
||||
code == "^" ? turtle3d("yu_turn", t, -angle) :
|
||||
code == "\\" ? turtle3d("xu_turn", t, -angle) :
|
||||
code == "/" ? turtle3d("xu_turn", t, angle) : t;
|
||||
code == "F" || code == "f" ? turtle3d("forward", t, leng) :
|
||||
code == "+" ? turtle3d("turn", t, angle) :
|
||||
code == "-" ? turtle3d("turn", t, -angle) :
|
||||
code == "|" ? turtle3d("turn", t, 180) :
|
||||
code == "&" ? turtle3d("pitch", t, -angle) :
|
||||
code == "^" ? turtle3d("pitch", t, angle) :
|
||||
code == "\\" ? turtle3d("roll", t, angle) :
|
||||
code == "/" ? turtle3d("roll", t, -angle) : t;
|
||||
|
||||
// It doesn't use recursion to avoid recursion error.
|
||||
function _lines(t, codes, angle, leng) =
|
||||
|
@ -101,23 +101,27 @@ function _t3d_set(t, point, unit_vectors) =
|
||||
assert(false, "no target to set");
|
||||
|
||||
function _t3d_cmd(t, cmd, point, unit_vectors, leng, angle) =
|
||||
cmd == "xforward" ? _t3d_xu_forward(t, leng) :
|
||||
cmd == "yforward" ? _t3d_yu_forward(t, leng) :
|
||||
cmd == "zforward" ? _t3d_zu_forward(t, leng) :
|
||||
cmd == "forward" || cmd == "xforward" ? _t3d_xu_forward(t, leng) :
|
||||
cmd == "roll" ? _t3d_xu_turn(t, -angle) :
|
||||
cmd == "pitch" ? _t3d_yu_turn(t, -angle) :
|
||||
cmd == "turn" || cmd == "zturn" ? _t3d_zu_turn(t, angle) :
|
||||
cmd == "xturn" ? _t3d_xu_turn(t, angle) :
|
||||
cmd == "yturn" ? _t3d_yu_turn(t, angle) :
|
||||
cmd == "zturn" ? _t3d_zu_turn(t, angle) :
|
||||
cmd == "yforward" ? _t3d_yu_forward(t, leng) :
|
||||
cmd == "zforward" ? _t3d_zu_forward(t, leng) :
|
||||
_t3d_get(t, cmd);
|
||||
|
||||
function _t3d_cmdline(cmd, t, arg) =
|
||||
is_undef(arg) ? _t3d_get(t, cmd) :
|
||||
cmd == "xforward" ? _t3d_xu_forward(t, arg) :
|
||||
cmd == "yforward" ? _t3d_yu_forward(t, arg) :
|
||||
cmd == "zforward" ? _t3d_zu_forward(t, arg) :
|
||||
cmd == "forward" || cmd == "xforward" ? _t3d_xu_forward(t, arg) :
|
||||
cmd == "roll" ? _t3d_xu_turn(t, -arg) :
|
||||
cmd == "pitch" ? _t3d_yu_turn(t, -arg) :
|
||||
cmd == "turn" || cmd == "zturn" ? _t3d_zu_turn(t, arg) :
|
||||
cmd == "point" ? _t3d_set_point(t, point) :
|
||||
cmd == "xturn" ? _t3d_xu_turn(t, arg) :
|
||||
cmd == "yturn" ? _t3d_yu_turn(t, arg) :
|
||||
cmd == "zturn" ? _t3d_zu_turn(t, arg) :
|
||||
cmd == "point" ? _t3d_set_point(t, point) :
|
||||
cmd == "yforward" ? _t3d_yu_forward(t, arg) :
|
||||
cmd == "zforward" ? _t3d_zu_forward(t, arg) :
|
||||
cmd == "unit_vectors" ? _t3d_set_unit_vectors(t, unit_vectors) :
|
||||
assert(false, "unknown command");
|
||||
|
||||
|
@ -90,16 +90,16 @@ function _turtle3d_create_cmd(arg1, arg2) =
|
||||
!is_undef(arg1) && !is_undef(arg2) ? _turtle3d_create(arg1, arg2) : undef;
|
||||
|
||||
function _turtle3d_chain_move(cmd, arg1, arg2) =
|
||||
cmd == "xu_move" || cmd == "forward" ? _turtle3d_xu_move(arg1, arg2) :
|
||||
cmd == "forward" || cmd == "xu_move" ? _turtle3d_xu_move(arg1, arg2) :
|
||||
cmd == "yu_move" ? _turtle3d_yu_move(arg1, arg2) :
|
||||
cmd == "zu_move" ? _turtle3d_zu_move(arg1, arg2) : _turtle3d_chain_turn(cmd, arg1, arg2);
|
||||
|
||||
function _turtle3d_chain_turn(cmd, arg1, arg2) =
|
||||
cmd == "xu_turn" ? _turtle3d_xu_turn(arg1, arg2) :
|
||||
cmd == "roll" ? _turtle3d_xu_turn(arg1, -arg2) :
|
||||
cmd == "yu_turn" ? _turtle3d_yu_turn(arg1, arg2) :
|
||||
cmd == "pitch" ? _turtle3d_yu_turn(arg1, -arg2) :
|
||||
cmd == "zu_turn" || cmd == "turn" ? _turtle3d_zu_turn(arg1, arg2) : _turtle3d_chain_one_arg(cmd, arg1);
|
||||
cmd == "turn" || cmd == "zu_turn" ? _turtle3d_zu_turn(arg1, arg2) :
|
||||
cmd == "xu_turn" ? _turtle3d_xu_turn(arg1, arg2) :
|
||||
cmd == "yu_turn" ? _turtle3d_yu_turn(arg1, arg2) : _turtle3d_chain_one_arg(cmd, arg1);
|
||||
|
||||
function _turtle3d_chain_one_arg(cmd, arg) =
|
||||
cmd == "pt" ? _turtle3d_pt(arg) :
|
||||
|
Loading…
x
Reference in New Issue
Block a user