forked from gpujs/gpu.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharray4.js
More file actions
29 lines (25 loc) · 790 Bytes
/
array4.js
File metadata and controls
29 lines (25 loc) · 790 Bytes
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
const { WebGLKernelValue } = require('./index');
class WebGLKernelValueArray4 extends WebGLKernelValue {
constructor(value, settings) {
super(value, settings);
this.uploadValue = value;
}
getSource(value) {
if (this.origin === 'constants') {
return `const vec4 ${this.id} = vec4(${value[0]},${value[1]},${value[2]},${value[3]});\n`;
}
return `uniform vec4 ${this.id};\n`;
}
getStringValueHandler() {
// resetting isn't supported for Array(4)
if (this.origin === 'constants') return '';
return `const uploadValue_${this.name} = ${this.varName};\n`;
}
updateValue(value) {
if (this.origin === 'constants') return;
this.kernel.setUniform4fv(this.id, this.uploadValue = value);
}
}
module.exports = {
WebGLKernelValueArray4
};