You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[DOCS] Document APIs related to vertex attributes (playcanvas#1898)
* move the type for parameter "description" (in VertexFormat constructor) into a separate interface VertexAttributeDescription
* add interface VertexAttributeElement (which extends VertexAttributeDescription) with additional vertex buffer layout data.
* use new interface VertexAttributeElement in property VertexFormat#elements
* fix all referances to old VertexAttributeElement properties
* document VertexIteratorAccessor and methods
* fix type for property VertexIterator#element
* Revert "fix all referances to old VertexAttributeElement properties"
This reverts commit 40029b2.
* Partial revert "use new interface VertexAttributeElement in property VertexFormat#elements"
* Copy documentation from VertexAttributeDescription to VertexAttributeElement (but using different property names)
* remove unecessary dot
* add param to interface constructors
* revert description param in VertexFormat ctor and remove VertexAttributeDescription
* simplify VertexAttributeElement by removing ctor params
* change jsdoc for VertexAttributeElement from interface to class
* construct VertexAttributeElement instances in VertexFormat
* Revert "construct VertexAttributeElement instances in VertexFormat"
This reverts commit cac35e7.
* remove VertexAttributeElement and document VertexFormat#elements and VertexIteratorAccessor ctor (param vertexElement) individually
* document vertexFormat parameter in VertexIteratorAccessor constructor
* document VertexIteratorAccessor#setFromArray
* document VertexIteratorAccessor#getToArray
Co-authored-by: Will Eastcott <will@playcanvas.com>
Copy file name to clipboardExpand all lines: src/graphics/vertex-format.js
+39Lines changed: 39 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -57,6 +57,45 @@ Object.assign(pc, function () {
57
57
* number of vertices. (example: PPPPNNNNCCCC), where arrays of individual attributes will be stored one right after the other (subject to alignment requirements).
58
58
* Note that in this case, the format depends on the number of vertices, and needs to change when the number of vertices changes.
59
59
* When not specified, vertex format will be interleaved. (example: PNCPNCPNCPNC)
60
+
* @property {object[]} elements The vertex attribute elements.
61
+
* @property {string} elements[].name The meaning of the vertex element. This is used to link
62
+
* the vertex data to a shader input. Can be:
63
+
*
64
+
* * {@link pc.SEMANTIC_POSITION}
65
+
* * {@link pc.SEMANTIC_NORMAL}
66
+
* * {@link pc.SEMANTIC_TANGENT}
67
+
* * {@link pc.SEMANTIC_BLENDWEIGHT}
68
+
* * {@link pc.SEMANTIC_BLENDINDICES}
69
+
* * {@link pc.SEMANTIC_COLOR}
70
+
* * {@link pc.SEMANTIC_TEXCOORD0}
71
+
* * {@link pc.SEMANTIC_TEXCOORD1}
72
+
* * {@link pc.SEMANTIC_TEXCOORD2}
73
+
* * {@link pc.SEMANTIC_TEXCOORD3}
74
+
* * {@link pc.SEMANTIC_TEXCOORD4}
75
+
* * {@link pc.SEMANTIC_TEXCOORD5}
76
+
* * {@link pc.SEMANTIC_TEXCOORD6}
77
+
* * {@link pc.SEMANTIC_TEXCOORD7}
78
+
*
79
+
* If vertex data has a meaning other that one of those listed above, use the user-defined
80
+
* semantics: pc.SEMANTIC_ATTR0 to pc.SEMANTIC_ATTR15.
81
+
* @property {number} elements[].numComponents The number of components of the vertex attribute.
82
+
* Can be 1, 2, 3 or 4.
83
+
* @property {number} elements[].dataType The data type of the attribute. Can be:
84
+
*
85
+
* * {@link pc.TYPE_INT8}
86
+
* * {@link pc.TYPE_UINT8}
87
+
* * {@link pc.TYPE_INT16}
88
+
* * {@link pc.TYPE_UINT16}
89
+
* * {@link pc.TYPE_INT32}
90
+
* * {@link pc.TYPE_UINT32}
91
+
* * {@link pc.TYPE_FLOAT32}
92
+
* @property {boolean} elements[].normalize If true, vertex attribute data will be mapped from a
93
+
* 0 to 255 range down to 0 to 1 when fed to a shader. If false, vertex attribute data is left
94
+
* unchanged. If this property is unspecified, false is assumed.
95
+
* @property {number} elements[].offset The number of initial bytes at the start of a vertex that are not relevant to this attribute.
96
+
* @property {number} elements[].stride The number of total bytes that are between the start of one vertex, and the start of the next.
97
+
* @property {pc.ScopeId} elements[].scopeId The shader input variable corresponding to the attribute.
98
+
* @property {number} elements[].size The size of the attribute in bytes.
60
99
* @example
61
100
* // Specify 3-component positions (x, y, z)
62
101
* var vertexFormat = new pc.VertexFormat(graphicsDevice, [
// Will be replaced with specialized implementation based on number of components
137
+
};
138
+
72
139
functionVertexIteratorAccessor_set1(a){
73
140
this.array[this.index]=a;
74
141
}
@@ -91,6 +158,18 @@ Object.assign(pc, function () {
91
158
this.array[this.index+3]=d;
92
159
}
93
160
161
+
/**
162
+
* @function
163
+
* @name pc.VertexIteratorAccessor#setFromArray
164
+
* @description Write attribute components from an input array.
165
+
* @param {number} index - The starting index at which to write data into the buffer. Will be used instead of the iterator's current index.
166
+
* @param {number[]|Int8Array|Uint8Array|Uint8ClampedArray|Int16Array|Uint16Array|Int32Array|Uint32Array|Float32Array} inputArray - The input array to read data from.
167
+
* @param {number} inputIndex - The input index at which to read from the input array.
@@ -113,6 +192,18 @@ Object.assign(pc, function () {
113
192
this.array[index+3]=inputArray[inputIndex+3];
114
193
}
115
194
195
+
/**
196
+
* @function
197
+
* @name pc.VertexIteratorAccessor#getToArray
198
+
* @description Read attribute components to an output array.
199
+
* @param {number} offset - The component offset at which to read data from the buffer. Will be used instead of the iterator's current index.
200
+
* @param {number[]|Int8Array|Uint8Array|Uint8ClampedArray|Int16Array|Uint16Array|Int32Array|Uint32Array|Float32Array} outputArray - The output array to write data into.
201
+
* @param {number} outputIndex - The output index at which to write into the output array.
0 commit comments