forked from gpujs/gpu.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfloat.js
More file actions
30 lines (27 loc) · 796 Bytes
/
float.js
File metadata and controls
30 lines (27 loc) · 796 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
30
const { utils } = require('../../../utils');
const { WebGLKernelValue } = require('./index');
class WebGLKernelValueFloat extends WebGLKernelValue {
constructor(value, settings) {
super(value, settings);
this.uploadValue = value;
}
getStringValueHandler() {
return `const uploadValue_${this.name} = ${this.varName};\n`;
}
getSource(value) {
if (this.origin === 'constants') {
if (Number.isInteger(value)) {
return `const float ${this.id} = ${value}.0;\n`;
}
return `const float ${this.id} = ${value};\n`;
}
return `uniform float ${this.id};\n`;
}
updateValue(value) {
if (this.origin === 'constants') return;
this.kernel.setUniform1f(this.id, this.uploadValue = value);
}
}
module.exports = {
WebGLKernelValueFloat
};