-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathTest.js
124 lines (107 loc) · 2.97 KB
/
Test.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
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
117
118
119
120
121
122
123
124
function quadraticBezier(p0, p1, p2, p3, t) {
var x =Math.pow(1-t, 3)*p0.x +
Math.pow(1-t, 2)*3*t*p1.x +
(1-t)*3*t*t*p2.x +
t*t*t*p3.x
var y =Math.pow(1-t, 3)*p0.y +
Math.pow(1-t, 2)*3*t*p1.y +
(1-t)*3*t*t*p2.y +
t*t*t*p3.y
var z =Math.pow(1-t, 3)*p0.z +
Math.pow(1-t, 2)*3*t*p1.z +
(1-t)*3*t*t*p2.z +
t*t*t*p3.z
return {x: x, y: y, z: z};
}
function generateCurve(walls, startPoint, p1, p2, endPoint) {
var amount = 64;
for (var i = 0; i < amount; i++) {
var currentPoint = quadraticBezier(
startPoint,
p1,
p2,
endPoint,
i / amount
);
var nextPoint = quadraticBezier(
startPoint,
p1,
p2,
endPoint,
(i+1) / amount
);
var startRow = currentPoint.x;
var startHeight = currentPoint.y;
var startTime = Math.min(currentPoint.z, nextPoint.z);
var width = Math.abs(nextPoint.x - currentPoint.x);
var height = Math.abs(nextPoint.y - currentPoint.y);
var duration = Math.abs(nextPoint.z - currentPoint.z);
newWall = {
_time: startTime,
_lineIndex: 0,
_type: 0,
_duration: duration,
_width: width,
_customData: {
_scale: [width, height],
_position: [startRow, startHeight]
}
};
walls.push(newWall);
}
}
function performCheck(cursor, notes, events, walls, _, global, data) {
log('Cursor = ' + cursor);
log('Notes = ' + notes.length);
log('Events = ' + events.length);
log('Walls = ' + walls.length);
while (notes.length > 5) {
notes.shift();
}
while (notes.length < 10) {
notes.push({_time: 1, _lineIndex: 1, _lineLayer: 1, _type: 1, _cutDirection: 1});
}
var i = 0;
for (x in notes) {
notes[x]._time = i++;
notes[x]._lineIndex = Math.floor(Math.random() * 4);
notes[x]._lineLayer = Math.floor(Math.random() * 3);
notes[x]._type = Math.floor(Math.random() * 2);
notes[x]._cutDirection = Math.floor(Math.random() * 9);
}
walls = [];
generateCurve(
walls,
{x: 0, y: 0, z: 0},
{x: 2, y: 0, z: 0.5},
{x: 3, y: 0, z: 1},
{x: 3, y: 2, z: 2}
);
generateCurve(
walls,
{x: 0, y: 0, z: 0},
{x: -2, y: 0, z: 0.5},
{x: -3, y: 0, z: 1},
{x: -3, y: 2, z: 2}
);
generateCurve(
walls,
{x: 0, y: 3, z: 0},
{x: 2, y: 3, z: 0.5},
{x: 3, y: 3, z: 1},
{x: 3, y: 1, z: 2}
);
generateCurve(
walls,
{x: 0, y: 3, z: 0},
{x: -2, y: 3, z: 0.5},
{x: -3, y: 3, z: 1},
{x: -3, y: 1, z: 2}
);
return {walls: walls};
}
module.exports = {
name: "Test",
params: {},
run: performCheck
};