-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathH3DU.BufferAccessor.html
executable file
·326 lines (248 loc) · 15.5 KB
/
H3DU.BufferAccessor.html
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
<!DOCTYPE html><html xmlns:dc="http://purl.org/dc/terms/"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width"><link rel=stylesheet type="text/css" href="/style.css">
<script type="text/x-mathjax-config"> MathJax.Hub.Config({"HTML-CSS": { availableFonts: ["STIX","TeX"], linebreaks: { automatic:true }, preferredFont: "TeX" },
tex2jax: { displayMath: [ ["$$","$$"], ["\\[", "\\]"] ], inlineMath: [ ["$", "$"], ["\\\\(","\\\\)"] ], processEscapes: true } });
</script><script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS_HTML-full"></script></head><body> <div class="header">
<nav><p><a href="#navigation">Menu</a> - <a href="#top">Top</a> - <a href="/">Home</a></nav></div>
<div class="mainarea" id="top">
<h1 id="h3dubufferaccessor">H3DU.BufferAccessor</h1>
<p><a href="index.html">Back to documentation index.</a></p>
<p><a name="H3DU.BufferAccessor"></a>
### new H3DU.BufferAccessor(buffer, countPerValue, [offset], [stride])</p>
<p>A <b>vertex attribute object</b>.</p>
<h4 id="parameters">Parameters</h4>
<ul>
<li><code>buffer</code> (Type: Float32Array)<br />A buffer to store vertex attribute data; see BufferAccessor#buffer.</li>
<li><code>countPerValue</code> (Type: number)<br />Number of elements per value; see BufferAccessor#countPerValue. Throws an error if 0 or less.</li>
<li><code>offset</code> (Type: number) (optional)<br />Offset to the first value; see BufferAccessor#offset. If null, undefined, or omitted, the default is 0. Throws an error if less than 0.</li>
<li><code>stride</code> (Type: number) (optional)<br />Number of elements from the start of one value to the start of the next; see BufferAccessor#stride. If null, undefined, or omitted, has the same value as “countPerValue”. Throws an error if 0 or less.</li>
</ul>
<h3 id="members">Members</h3>
<ul>
<li><a href="#H3DU.BufferAccessor_buffer">buffer</a><br />A <i>buffer</i> of arbitrary size.</li>
<li><a href="#H3DU.BufferAccessor_countPerValue">countPerValue</a><br />A count of the number of elements each value has.</li>
<li><a href="#H3DU.BufferAccessor_offset">offset</a><br />An offset, which identifies the index, starting from 0, of the first value
of the attribute within the buffer.</li>
<li><a href="#H3DU.BufferAccessor_stride">stride</a><br />A stride, which gives the number of elements from the start of one
value to the start of the next.</li>
</ul>
<h3 id="methods">Methods</h3>
<ul>
<li><a href="#H3DU.BufferAccessor_copy">copy</a><br />Copies the values of this accessor into a new vertex attribute object.</li>
<li><a href="#H3DU.BufferAccessor_count">count</a><br />Gets the number of values defined for this accessor.</li>
<li><a href="#H3DU.BufferAccessor_get">get</a><br />Gets the first element of the attribute value with the specified vertex index.</li>
<li><a href="#H3DU.BufferAccessor_getVec">getVec</a><br />Gets the elements of a vertex attribute value.</li>
<li><a href="#H3DU.BufferAccessor.makeBlank">makeBlank</a><br />Generates a vertex attribute buffer, with each value set to all zeros.</li>
<li><a href="#H3DU.BufferAccessor.makeIndices">makeIndices</a><br />Generates an array of increasing vertex indices.</li>
<li><a href="#H3DU.BufferAccessor.merge">merge</a><br />Merges two vertex attributes, whose vertices can be indexed differently, into one
combined vertex attribute.</li>
<li><a href="#H3DU.BufferAccessor_set">set</a><br />Sets the first element of the attribute value with the specified vertex index.</li>
<li><a href="#H3DU.BufferAccessor_setVec">setVec</a><br />Sets the elements of a vertex attribute value.</li>
</ul>
<p><a name="H3DU.BufferAccessor_buffer"></a>
### H3DU.BufferAccessor#buffer</p>
<p>A <i>buffer</i> of arbitrary size. This buffer
is made up of <i>values</i>, one for each vertex, and each value
takes up one or more <i>elements</i> in the buffer, which are numbers such
as x-coordinates or red components, depending on the attribute’s semantic.
Each value has the same number of elements. An example of a <i>value</i>
is (10, 20, 5), which can take up three consecutive <i>elements</i>
in a <code>Float32Array</code> buffer such as the one given in this
property.</p>
<p>Type: Float32Array</p>
<p><a name="H3DU.BufferAccessor_countPerValue"></a>
### H3DU.BufferAccessor#countPerValue</p>
<p>A count of the number of elements each value has. For example, 3-dimensional
positions will have 3 elements, one for each coordinate.</p>
<p>Type: number</p>
<p><a name="H3DU.BufferAccessor_offset"></a>
### H3DU.BufferAccessor#offset</p>
<p>An offset, which identifies the index, starting from 0, of the first value
of the attribute within the buffer. The offset counts the number of
elements in the buffer to the first value. For example, if this property is 6,
then the first element of the first value in the buffer is found at
<code>acc.buffer[acc.offset]</code> (assuming the buffer is
more than 6 elements long).</p>
<p>Type: number</p>
<p><a name="H3DU.BufferAccessor_stride"></a>
### H3DU.BufferAccessor#stride</p>
<p>A stride, which gives the number of elements from the start of one
value to the start of the next. A “packed” buffer will have a stride
equal to the count per value.</p>
<p>Type: number</p>
<p><a name="H3DU.BufferAccessor_copy"></a>
### H3DU.BufferAccessor#copy()</p>
<p>Copies the values of this accessor into a new vertex attribute object.</p>
<h4 id="return-value">Return Value</h4>
<p>A copy of the vertex attribute object. (Type: BufferAccessor)</p>
<p><a name="H3DU.BufferAccessor_count"></a>
### H3DU.BufferAccessor#count()</p>
<p>Gets the number of values defined for this accessor.</p>
<h4 id="return-value-1">Return Value</h4>
<p>The number of values defined in this accessor’s buffer. (Type: number)</p>
<p><a name="H3DU.BufferAccessor_get"></a>
### H3DU.BufferAccessor#get(index)</p>
<p>Gets the first element of the attribute value with the specified vertex index.</p>
<p>Note that currently, this method does no bounds checking beyond the
checking naturally done when accessing the attribute’s buffer.</p>
<h4 id="parameters-1">Parameters</h4>
<ul>
<li><code>index</code> (Type: number)<br />A numeric index, starting from 0, that identifies a value stored in the attribute’s buffer. For example, 0 identifies the first value, 1 identifies the second, and so on.</li>
</ul>
<h4 id="return-value-2">Return Value</h4>
<p>The first element of the specified attribute value. (Type: number)</p>
<p><a name="H3DU.BufferAccessor_getVec"></a>
### H3DU.BufferAccessor#getVec(index, vec)</p>
<p>Gets the elements of a vertex attribute value.</p>
<p>Note that currently, this method does no bounds checking beyond the
checking naturally done when accessing the attribute’s buffer.</p>
<h4 id="parameters-2">Parameters</h4>
<ul>
<li><code>index</code> (Type: number)<br />A numeric index, starting from 0, that identifies a value stored in the attribute’s buffer. For example, 0 identifies the first value, 1 identifies the second, and so on.</li>
<li><code>vec</code> (Type: Array.<number>)<br />An array whose elements will be set to those of the value at the specified index. The number of elements copied to this array is the attribute’s count per value (see BufferAccessor#countPerValue).</li>
</ul>
<h4 id="return-value-3">Return Value</h4>
<p>The parameter “vec”. (Type: Array.<number>)</p>
<p><a name="H3DU.BufferAccessor.makeBlank"></a>
### (static) H3DU.BufferAccessor.makeBlank(count, countPerValue)</p>
<p>Generates a vertex attribute buffer, with each value set to all zeros.</p>
<h4 id="parameters-3">Parameters</h4>
<ul>
<li><code>count</code> (Type: number)<br />The number of values the buffer will hold. For example, (10, 20, 5) is a 3-element value.</li>
<li><code>countPerValue</code> (Type: number)<br />The number of elements each value will take in the buffer.</li>
</ul>
<h4 id="return-value-4">Return Value</h4>
<p>A blank vertex attribute buffer. (Type: BufferAccessor)</p>
<p><a name="H3DU.BufferAccessor.makeIndices"></a>
### (static) H3DU.BufferAccessor.makeIndices(numIndices)</p>
<p>Generates an array of increasing vertex indices.</p>
<h4 id="parameters-4">Parameters</h4>
<ul>
<li><code>numIndices</code> (Type: number)<br />The number of vertex indices to generate. The array will range from 0 to the number of vertex indices minus 1.</li>
</ul>
<h4 id="return-value-5">Return Value</h4>
<table>
<tbody>
<tr>
<td>An array of vertex indices. (Type: Uint16Array</td>
<td>Uint32Array)</td>
</tr>
</tbody>
</table>
<p><a name="H3DU.BufferAccessor.merge"></a>
### (static) H3DU.BufferAccessor.merge(attr1, indices1, attr2, indices2)</p>
<p>Merges two vertex attributes, whose vertices can be indexed differently, into one
combined vertex attribute.</p>
<h4 id="parameters-5">Parameters</h4>
<ul>
<li><code>attr1</code> (Type: BufferAccessor)<br />A vertex buffer accessor for the first vertex attribute. Can be null, in which case it is assumed that the attribute contains as many values as the length of “indices1” and all the values are zeros.</li>
<li>
<table>
<tbody>
<tr>
<td><code>indices1</code> (Type: Array.<number></td>
<td>Uint16Array</td>
<td>Uint8Array</td>
<td>Uint32Array)<br />An array of vertex indices associated with the first vertex attribute.</td>
</tr>
</tbody>
</table>
</li>
<li><code>attr2</code> (Type: BufferAccessor)<br />A vertex buffer accessor for the second vertex attribute. Can be null, in which case it is assumed that the attribute contains as many values as the length of “indices2” and all the values are zeros.</li>
<li>
<table>
<tbody>
<tr>
<td><code>indices2</code> (Type: Array.<number></td>
<td>Uint16Array</td>
<td>Uint8Array</td>
<td>Uint32Array)<br />An array of vertex indices associated with the second vertex attribute.</td>
</tr>
</tbody>
</table>
</li>
</ul>
<h4 id="return-value-6">Return Value</h4>
<p>The merged attribute, where the vertices from the first vertex
attribute come before those from the second. The merged attribute will have as many
values as the sum of the lengths of “indices1” and “indices2”. (Type: BufferAccessor)</p>
<p><a name="H3DU.BufferAccessor_set"></a>
### H3DU.BufferAccessor#set(index, value)</p>
<p>Sets the first element of the attribute value with the specified vertex index.</p>
<p>Note that currently, this method does no bounds checking beyond the
checking naturally done when writing to the attribute’s buffer.</p>
<h4 id="parameters-6">Parameters</h4>
<ul>
<li><code>index</code> (Type: number)<br />A numeric index, starting from 0, that identifies a value stored in the attribute’s buffer. For example, 0 identifies the first value, 1 identifies the second, and so on.</li>
<li><code>value</code> (Type: number)<br />The number to set the first element to.</li>
</ul>
<h4 id="return-value-7">Return Value</h4>
<p>This object. (Type: BufferAccessor)</p>
<p><a name="H3DU.BufferAccessor_setVec"></a>
### H3DU.BufferAccessor#setVec(index, vec)</p>
<p>Sets the elements of a vertex attribute value.</p>
<p>Note that currently, this method does no bounds checking beyond the
checking naturally done when writing to the attribute’s buffer, except
where noted otherwise.</p>
<h4 id="parameters-7">Parameters</h4>
<ul>
<li><code>index</code> (Type: number)<br />A numeric index, starting from 0, that identifies a value stored in the attribute’s buffer. For example, 0 identifies the first value, 1 identifies the second, and so on.</li>
<li><code>vec</code> (Type: Array.<number>)<br />An array containing the elements to copy to the value at the specified index. The number of elements copied is this array’s length or the attribute’s count per value (see BufferAccessor#countPerValue), whichever is less.</li>
</ul>
<h4 id="return-value-8">Return Value</h4>
<p>This object. (Type: BufferAccessor)</p>
<p><a href="index.html">Back to documentation index.</a></p>
</div><nav id="navigation"><ul>
<li><a href="/">Back to start site.</a>
<li><a href="https://github.com/peteroupc/peteroupc.github.io">This site's repository (source code)</a>
<li><a href="https://github.com/peteroupc/peteroupc.github.io/issues">Post an issue or comment</a></ul>
<div class="noprint">
<p>
<a href="//twitter.com/intent/tweet">Share via Twitter</a>, <a href="//www.facebook.com/sharer/sharer.php" id="sharer">Share via Facebook</a>
</p>
</div>
<h3 id="navigation">Navigation</h3>
<ul>
<li><a href="BSplineCurve.html">BSplineCurve</a></li>
<li><a href="BSplineSurface.html">BSplineSurface</a></li>
<li><a href="BufferAccessor.html">BufferAccessor</a></li>
<li><a href="Curve.html">Curve</a></li>
<li><a href="CurveBuilder.html">CurveBuilder</a></li>
<li><a href="GraphicsPath.html">GraphicsPath</a></li>
<li><a href="H3DU.html">H3DU</a></li>
<li><a href="MathUtil.html">MathUtil</a></li>
<li><a href="MeshBuffer.html">MeshBuffer</a></li>
<li><a href="Meshes.html">Meshes</a></li>
<li><a href="PiecewiseCurve.html">PiecewiseCurve</a></li>
<li><a href="Semantic.html">Semantic</a></li>
<li><a href="ShapeGroup.html">ShapeGroup</a></li>
<li><a href="Surface.html">Surface</a></li>
<li><a href="SurfaceBuilder.html">SurfaceBuilder</a></li>
<li><a href="Transform.html">Transform</a></li>
<li><a href="extras_camera.html">module:extras/camera</a></li>
<li><a href="extras_camera.Camera.html">module:extras/camera.Camera</a></li>
<li><a href="extras_camera.InputTracker.html">module:extras/camera.InputTracker</a></li>
<li><a href="extras_createwasher.html">module:extras/createwasher</a></li>
<li><a href="extras_curvetube.html">module:extras/curvetube</a></li>
<li><a href="extras_curvetube.CurveTube.html">module:extras/curvetube.CurveTube</a></li>
<li><a href="extras_derivedcurves.html">module:extras/derivedcurves</a></li>
<li><a href="extras_evaluators.html">module:extras/evaluators</a></li>
<li><a href="extras_evaluators.Roulette.html">module:extras/evaluators.Roulette</a></li>
<li><a href="extras_evaluators.SurfaceOfRevolution.html">module:extras/evaluators.SurfaceOfRevolution</a></li>
<li><a href="extras_fourierknot.html">module:extras/fourierknot</a></li>
<li><a href="extras_gradients.html">module:extras/gradients</a></li>
<li><a href="extras_marbleshader2.html">module:extras/marbleshader2</a></li>
<li><a href="extras_matrixstack.html">module:extras/matrixstack</a></li>
<li><a href="extras_matrixstack.MatrixStack.html">module:extras/matrixstack.MatrixStack</a></li>
<li><a href="extras_moresurfaces.html">module:extras/moresurfaces</a></li>
<li><a href="extras_moresurfaces.KleinBottle.html">module:extras/moresurfaces.KleinBottle</a></li>
<li><a href="extras_moresurfaces.MoebiusStrip.html">module:extras/moresurfaces.MoebiusStrip</a></li>
<li><a href="extras_pathutil.html">module:extras/pathutil</a></li>
<li><a href="extras_randompolygon.html">module:extras/randompolygon</a></li>
<li><a href="extras_starpolygon.html">module:extras/starpolygon</a></li>
<li><a href="extras_superellipsoid.html">module:extras/superellipsoid</a></li>
<li><a href="extras_superellipsoid.Supershape.html">module:extras/superellipsoid.Supershape</a></li>
<li><a href="extras_superellipsoid.Supertoroid.html">module:extras/superellipsoid.Supertoroid</a></li>
<li><a href="extras_torusknot.html">module:extras/torusknot</a></li>
<li><a href="extras_torusknot.TorusKnot.html">module:extras/torusknot.TorusKnot</a></li>
</ul>
</nav></body></html>