-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
68 lines (56 loc) · 1.76 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
module.exports = attribute;
function attribute (context) {
/**
* Attribute
* Creates an attribute.
* Represents an attribute variable in a shader program.
* @param {Object} options The options for creating the attribute.
* @param {String} [options.name] The name of the attribute.
* @param {Number} [options.type] The WebGL type of the attribute.
* @param {Number} [options.size] The size of the attributes in bytes.
* @param {Number} [options.location] The index location in the shader.
* @param {WebGLProgram} [options.program] The WebGL program.
* @api public
*/
function Attribute (options) {
options = options || {};
this.name = options.name;
this.type = options.type;
this.size = options.size;
this.location = options.location;
this.program = options.program;
};
/**
* Attribute#index
* Get/set the index of this attribute.
* @return {Number} [number] The current index of this attribute in the program.
*/
Attribute.prototype.index = function (n) {
if (n) {
return this.set_index(n);
}
return this.get_index();
};
/**
* Attribute#get_index
* Get the index of this attribute.
* @return {Number} The current index of this attribute in the program.
*/
Attribute.prototype.get_index = function () {
return this.location;
};
/**
* Attribute#set_index
* Set the index of this attribute.
* @param {v3.Program} program The program that use the attribute.
* @param {Number} n The index to set.
* @return {v3.Attribute} this for chaining.
* @api public
*/
Attribute.prototype.set_index = function (n) {
context.bindAttribLocation(this.program, n, this.name);
this.location = n;
return this;
};
return Attribute;
};