-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsolid-knitting.library
116 lines (113 loc) · 3.46 KB
/
solid-knitting.library
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
//a 'cell template library' is an array of cell template definitions
// file format is json-but-with-comments
[
//generally:
//x is course direction (yarns enter/exit on +/- x sides)
//y is wale direction (within-layer loops enter/exit on +/- y sides)
//z is layer direction (between-layer loops enter on -z, exit on +z)
//what does one cell template look like?
// Block #1: Basic block.
{
"name":"knit", //base name. Full name is name + face types.
//vertices (ordered by x,y,z)
// TODO: Vertices need to be updated to reflect changed block aspect ratio:
"vertices":[
[-1,-1,-1], //0
[-1,-1, 1], //1
[-1, 1,-1], //2
[-1, 1, 1], //3
[ 1,-1,-1], //4
[ 1,-1, 1], //5
[ 1, 1,-1], //6
[ 1, 1, 1] //7
],
//faces with indices in ccw winding order starting with "first edge" (determines face connection orientation)
//faces in lexicographic order w.r.t. indices
//"first edge" is canonically the "bottom edge" or "earliest edge" for the connection
"faces":[
{ "type":"-l1", "indices":[0, 4, 5, 1], "color":"#888811" },
{ "type":"+L1", "indices":[1, 5, 7, 3], "color":"#bb0000" },
{ "type":"-y1", "indices":[2, 0, 1, 3], "color":"#884488" },
{ "type":"-L1", "indices":[4, 0, 2, 6], "color":"#aa0000" },
{ "type":"+y1", "indices":[4, 6, 7, 5], "color":"#bb88bb" },
{ "type":"+l1", "indices":[6, 2, 3, 7], "color":"#bbbb11" }
],
//yarns defined as cubic splines between faces:
"yarns":[
{
"begin":2, //beginning face index
"end":4, //ending face index
"cps":[ //control points for cubic bezier segments, 3*n+1
[-1,0,0], [0,0,0], [0,0,0], [-0.5,1,0]
]
}
//... more yarns ...
],
//eventually:
"machine":{}, //some sort of machine code info
"human":{} //some sort of human instruction info
},
// Block #2: Basic block with reversed yarn directions.
{
"name":"knit",
"vertices":[
[-1,-1,-1],
[ 1,-1,-1],
[-1, 1,-1],
[ 1, 1,-1],
[-1,-1, 1],
[ 1,-1, 1],
[-1, 1, 1],
[ 1, 1, 1]
],
"faces":[
// Same one as the first knit, but yarn directions are reversed.
{ "type":"-l1", "indices":[0, 4, 5, 1], "color":"#888811" },
{ "type":"+L1", "indices":[1, 5, 7, 3], "color":"#bb0000" },
{ "type":"+y1", "indices":[2, 0, 1, 3], "color":"#884488" }, // Yarn directions are reversed.
{ "type":"-L1", "indices":[4, 0, 2, 6], "color":"#aa0000" },
{ "type":"-y1", "indices":[4, 6, 7, 5], "color":"#bb88bb" }, // Yarn directions are reversed.
{ "type":"+l1", "indices":[6, 2, 3, 7], "color":"#bbbb11" }
],
"yarns":[
// Same as the one above ^^^
"begin":2, //beginning face index
"end":4, //ending face index
"cps":[ //control points for cubic bezier segments, 3*n+1
[-1,0,0], [0,0,0], [0,0,0], [-0.5,1,0]
]
//... more yarns ...
],
"machine":{},
"human":{}
},
// Block #3: Basic block but upside down and reflected.
{
"name":"knit",
"vertices":[
[-1,-1,-1],
[ 1,-1,-1],
[-1, 1,-1],
[ 1, 1,-1],
[-1,-1, 1],
[ 1,-1, 1],
[-1, 1, 1],
[ 1, 1, 1]
],
"faces":[
// Same one as the first knit, but reflected. i.e. upside down:
{ "type":"+l1", "indices":[0, 4, 5, 1], "color":"#888811" },
{ "type":"-L1", "indices":[1, 5, 7, 3], "color":"#bb0000" },
{ "type":"+y1", "indices":[2, 0, 1, 3], "color":"#884488" },
{ "type":"+L1", "indices":[4, 0, 2, 6], "color":"#aa0000" },
{ "type":"-y1", "indices":[4, 6, 7, 5], "color":"#bb88bb" },
{ "type":"-l1", "indices":[6, 2, 3, 7], "color":"#bbbb11" }
],
"yarns":[
// Unsure of how to represent the yarns.
],
"machine":{},
"human":{}
}
//...more blocks follow...
]