forked from cacciatc/scriptcraft-lsystems
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fun.js
39 lines (33 loc) · 991 Bytes
/
fun.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
load(__folder + "lsystem.js");
Drone.extend('fun', function(blockID,size,generations)
{
var dr = new Drone();
size = size == null ? 50 : size;
blockID = blockID == null ? 1 : blockID;
generations = generations == null ? 3 : generations;
var d;
var ls = new Lsystem({
F: function() {
dr.fwd(d).box(blockID);
},
"+": function() {
dr.turn(3).box(blockID);
},
"-": function() {
dr.turn(1).box(blockID);
},
},
[ {id: "F"},{id: "-"},{id: "F"},{id: "-"},{id: "F"},{id: "-"},{id: "F"} ],
[
{ p: [ {id: "F"} ],
s: function() { return [{id:"F"},{id:"F"},{id:"-"},{id:"F"},{id:"-"},
{id:"-"},{id:"F"},{id:"-"},{id:"F"}];} }
]
);
ls.beforeRender = function () {
d = d0 * (1 / Math.pow(3, ls.generation));
};
ls.generateN(generations);
ls.render();
return this;
});