-
Notifications
You must be signed in to change notification settings - Fork 347
/
Copy pathparse_zpos.js
48 lines (44 loc) · 1.32 KB
/
parse_zpos.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
39
40
41
42
43
44
45
46
47
48
const testFolder = 'sheet_definitions';
const fs = require('fs');
var csvEntries = [];
const possibleBodies = ["male", "female", "muscular", "pregnant","child"];
fs.readdirSync(testFolder).forEach(file => {
if (!file.includes('.json')) {
return
}
const json = file;
const definition = JSON.parse(fs.readFileSync(`sheet_definitions/${file}`));
for (jdx =1; jdx < 10; jdx++) {
const layerDefinition = definition[`layer_${jdx}`];
if (layerDefinition !== undefined) {
const layer = `layer_${jdx}`;
const zPos = layerDefinition.zPos;
var images = "";
var bodyIndex = 0;
var firstImage = true;
for (item in possibleBodies) {
const body = possibleBodies[bodyIndex];
const imageRef = layerDefinition[`${body}`];
if (imageRef !== undefined) {
if (!firstImage) {
images += " "
}
images += imageRef;
firstImage = false;
}
bodyIndex+=1;
}
csvEntries.push(`${json},${layer},${zPos},${images}`)
} else {
return
}
}
});
const csvToWrite = "json,layer,zPos,images\n" + csvEntries.sort().join("\n");
fs.writeFile('scripts/zPositioning/z_positions.csv', csvToWrite, function(err) {
if (err) {
return console.log(err);
} else {
console.log('Updated z_positions.csv!');
}
});