WIP
This commit is contained in:
parent
9d5259767c
commit
25fcefcb50
68 changed files with 2982 additions and 307 deletions
|
|
@ -1,4 +1,9 @@
|
|||
class Sphere extends Visual {
|
||||
constructor() {
|
||||
super();
|
||||
this.name = "Sphere";
|
||||
}
|
||||
|
||||
draw() {
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,10 @@
|
|||
//animate Water the way like the Audio is Coming... 256FFT-Size max!
|
||||
class Water extends Visual {
|
||||
constructor() {
|
||||
super();
|
||||
this.name = "Water";
|
||||
}
|
||||
|
||||
draw() {
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
// 3D Audio-Waves -> maybe also 2D?
|
||||
class Wave extends Visual {
|
||||
constructor() {
|
||||
super();
|
||||
this.name = "3D Wave";
|
||||
}
|
||||
|
||||
updateData() {
|
||||
//only for debug! remove pls
|
||||
if (window.stopUpdate) {
|
||||
return;
|
||||
}
|
||||
let data = audioHandler.getFloatArray();
|
||||
let add = 2 / data.length,
|
||||
x = -1;
|
||||
|
|
@ -36,6 +37,7 @@ class Wave extends Visual {
|
|||
gl.enableVertexAttribArray(position);
|
||||
gl.vertexAttribPointer(position, 3, gl.FLOAT, true, 0, 0);
|
||||
gl.drawArrays(vConf.get("waveForm", gl.TRIANGLES), 0, this.data.length / 3);
|
||||
this.afterDraw();
|
||||
}
|
||||
|
||||
rotate(program) {
|
||||
|
|
@ -46,27 +48,36 @@ class Wave extends Visual {
|
|||
0, 0, 1, 0,
|
||||
0, 0, 0, 1
|
||||
]
|
||||
matrix = TDUtils.multiply(matrix, TDUtils.xRotation(vConf.get("xRotate", 0)));
|
||||
matrix = TDUtils.multiply(matrix, TDUtils.yRotation(vConf.get("yRotate", 0)));
|
||||
matrix = TDUtils.multiply(matrix, TDUtils.zRotation(vConf.get("zRotate", 0)));
|
||||
matrix = TDUtils.multiply(matrix, TDUtils.xRotation(vConf.get("rotation-x", 10)));
|
||||
matrix = TDUtils.multiply(matrix, TDUtils.yRotation(vConf.get("rotation-y", 50)));
|
||||
matrix = TDUtils.multiply(matrix, TDUtils.zRotation(vConf.get("rotation-z", -30)));
|
||||
let rotate = gl.getUniformLocation(program, "u_matrix");
|
||||
gl.uniformMatrix4fv(rotate, false, matrix);
|
||||
}
|
||||
|
||||
setup() {
|
||||
audioHandler.fftSize(16384)
|
||||
this.data = new Float32Array(16384 * 9);
|
||||
vConf.get("zRotate", TDUtils.degToRad(-30));
|
||||
vConf.get("yRotate", TDUtils.degToRad(50));
|
||||
vConf.get("xRotate", TDUtils.degToRad(10));
|
||||
this.updateFFT(vConf.get('fftSize', 4096));
|
||||
vConf.get("rotation-z", -30);
|
||||
vConf.get("rotation-y", 50);
|
||||
vConf.get("rotation-x", 10);
|
||||
}
|
||||
|
||||
updateFFT(fftSize) {
|
||||
audioHandler.fftSize(fftSize);
|
||||
this.data = new Float32Array(fftSize * 9);
|
||||
}
|
||||
|
||||
prepare(program) {
|
||||
this.position = gl.getAttribLocation(program, "a_position");
|
||||
this.color = gl.getUniformLocation(program, "u_color");
|
||||
let lightPos = gl.getUniformLocation(program, "u_lightPos"),
|
||||
matrix = gl.getUniformLocation(program, "u_matrix");
|
||||
let lightPos = gl.getUniformLocation(program, "u_lightPos");
|
||||
gl.uniform3fv(lightPos, vConf.get("light", [0, 5, -56]));
|
||||
//gl.uniformMatrix4fv(matrix, false, TDUtils.getMatrix(90, c.width / c.height, 1, 2000, 200, 200));
|
||||
}
|
||||
|
||||
afterDraw() {
|
||||
TDUtils.updateRotate('rotation-x', 10);
|
||||
TDUtils.updateRotate('rotation-y', 50);
|
||||
TDUtils.updateRotate('rotation-z', -30);
|
||||
vConf.save();
|
||||
}
|
||||
}
|
||||
73
raw/javascript/visuals/wave2d.js
Normal file
73
raw/javascript/visuals/wave2d.js
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
class Wave2D extends Visual {
|
||||
constructor() {
|
||||
super();
|
||||
this.name = "2D Wave";
|
||||
}
|
||||
|
||||
updateData() {
|
||||
let data = audioHandler.getFloatArray();
|
||||
let add = 2 / data.length,
|
||||
x = -1;
|
||||
let outerLoop = 0;
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
//first
|
||||
this.data[outerLoop] = x;
|
||||
this.data[outerLoop + 1] = data[i];
|
||||
this.data[outerLoop + 2] = data[i];
|
||||
outerLoop += 3;
|
||||
x += add;
|
||||
}
|
||||
}
|
||||
|
||||
draw(program) {
|
||||
this.prepare(program);
|
||||
let position = this.position,
|
||||
positionBuffer = gl.createBuffer();
|
||||
this.rotate(program);
|
||||
gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer);
|
||||
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(this.data), gl.DYNAMIC_DRAW);
|
||||
let vao = gl.createVertexArray();
|
||||
gl.bindVertexArray(vao);
|
||||
gl.enableVertexAttribArray(position);
|
||||
gl.vertexAttribPointer(position, 3, gl.FLOAT, true, 0, 0);
|
||||
gl.drawArrays(vConf.get("waveForm", gl.LINE_STRIP), 0, this.data.length / 3);
|
||||
this.afterDraw();
|
||||
}
|
||||
|
||||
rotate(program) {
|
||||
let matrix = [
|
||||
1, 0, 0, 0,
|
||||
0, 0.6, 0, 0,
|
||||
0, 0, 1, 0,
|
||||
0, 0, 0, 1
|
||||
]
|
||||
matrix = TDUtils.multiply(matrix, TDUtils.xRotation(vConf.get("rotation-x", 0)));
|
||||
matrix = TDUtils.multiply(matrix, TDUtils.yRotation(vConf.get("rotation-y", 0)));
|
||||
matrix = TDUtils.multiply(matrix, TDUtils.zRotation(vConf.get("rotation-z", 0)));
|
||||
let rotate = gl.getUniformLocation(program, "u_matrix");
|
||||
gl.uniformMatrix4fv(rotate, false, matrix);
|
||||
}
|
||||
|
||||
setup() {
|
||||
this.updateFFT(vConf.get('fftSize', 16384));
|
||||
}
|
||||
|
||||
updateFFT(fftSize) {
|
||||
audioHandler.fftSize(fftSize);
|
||||
this.data = new Float32Array(fftSize * 3);
|
||||
}
|
||||
|
||||
prepare(program) {
|
||||
this.position = gl.getAttribLocation(program, "a_position");
|
||||
this.color = gl.getUniformLocation(program, "u_color");
|
||||
let lightPos = gl.getUniformLocation(program, "u_lightPos");
|
||||
gl.uniform3fv(lightPos, vConf.get("light", [0, 5, -56]));
|
||||
}
|
||||
|
||||
afterDraw() {
|
||||
TDUtils.updateRotate('rotation-x', 0);
|
||||
TDUtils.updateRotate('rotation-y', 0);
|
||||
TDUtils.updateRotate('rotation-z', 0);
|
||||
vConf.save();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue