-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.js
54 lines (44 loc) · 1.13 KB
/
index.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
var defaults = require('./defaults')
module.exports = clear
function clear(opts) {
opts = opts || {}
var color = defaults.color(opts.color)
Object.defineProperty(clear, 'color', {
get: function() { return color },
set: function(value) {
return color = defaults.color(value)
}
})
var depth = defaults.depth(opts.depth)
Object.defineProperty(clear, 'depth', {
get: function() { return depth },
set: function(value) {
return depth = defaults.depth(value)
}
})
var stencil = defaults.stencil(opts.stencil)
Object.defineProperty(clear, 'stencil', {
get: function() { return stencil },
set: function(value) {
return stencil = defaults.stencil(value)
}
})
return clear
function clear(gl) {
var flags = 0
if (color !== false) {
gl.clearColor(color[0], color[1], color[2], color[3])
flags |= gl.COLOR_BUFFER_BIT
}
if (depth !== false) {
gl.clearDepth(depth)
flags |= gl.DEPTH_BUFFER_BIT
}
if (stencil !== false) {
gl.clearStencil(stencil)
flags |= gl.STENCIL_BUFFER_BIT
}
gl.clear(flags)
return gl
}
}