forked from gpujs/gpu.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction-builder.js
More file actions
46 lines (40 loc) · 942 Bytes
/
function-builder.js
File metadata and controls
46 lines (40 loc) · 942 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
'use strict';
const FunctionBuilderBase = require('../function-builder-base');
const WebGLFunctionNode = require('./function-node');
/**
* @class WebGLFunctionBuilder
*
* @extends FunctionBuilderBase
*
* @desc Builds webGl functions (shaders) from JavaScript function Strings
*
*/
module.exports = class WebGLFunctionBuilder extends FunctionBuilderBase {
constructor() {
super();
this.Node = WebGLFunctionNode;
}
//---------------------------------------------------------
//
// Polyfill stuff
//
//---------------------------------------------------------
// Round function used in polyfill
static round(a) {
return round(a);
}
/**
* @memberOf FunctionBuilderBase#
* @function
* @name polyfillStandardFunctions
*
* @desc Polyfill in the missing Math functions (round)
*
*/
polyfillStandardFunctions() {
this.addFunction('round', round);
}
};
function round(a) {
return Math.floor(a + 0.5);
}