-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrtree.ttslua
49 lines (43 loc) · 1.03 KB
/
rtree.ttslua
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
39
40
41
42
43
44
45
46
47
48
49
require("Lua R-tree/class")
require("Lua R-tree/bbox")
require("Lua R-tree/nodes")
require("Lua R-tree/rtree")
print("START")
lines = {}
colors = {
{0, 0.5 ,0.5},
{0.5, 0 ,0.5},
{0.5, 0.5 ,0}
}
function gatherLines(obj, level)
print(level)
if obj.children != nil then
for i, v in pairs(obj.children) do
gatherLines(v, level + 1)
end
end
if obj.bbox != nil then
table.insert(lines, {
points = {
{x = obj.bbox.minX, y=1, z=obj.bbox.maxY},
{x = obj.bbox.maxX, y=1, z=obj.bbox.maxY},
{x = obj.bbox.maxX, y=1, z=obj.bbox.minY},
{x = obj.bbox.minX, y=1, z=obj.bbox.minY},
},
loop = true,
color = colors[level],
thickness = 0.025,
rotation={0,0,0}
})
end
end
local rtree = RTree()
for i = 0, 100, 1 do
local x = math.random(-20, 10)
local y = math.random(-20, 10)
rtree:insert("bleep",BBox(x, y, x + math.random(1, 10), y+math.random(1,10)))
end
gatherLines(rtree, 0)
print("Vector lines:")
print(JSON.encode(lines))
Global.setVectorLines(lines)