Skip to content

Commit

Permalink
Add parameter to the constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
raub committed Aug 9, 2019
1 parent 70aee41 commit 9ba4d01
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
27 changes: 26 additions & 1 deletion docs/api/en/core/GLBufferAttribute.html
Expand Up @@ -23,8 +23,27 @@ <h1>[name]</h1>
</p>

<h2>Constructor</h2>
<h3>[name]( [param:WebGLRenderingContext gl], [param:WebGLBuffer buffer], [param:GLenum type], [param:Integer itemSize], [param:Integer count] )</h3>
<h3>[name]( [param:WebGLRenderingContext gl], [param:WebGLBuffer buffer], [param:GLenum type], [param:Integer itemSize], [param:Integer count], [param:Boolean normalized] )</h3>
<p>
gl — Must be a [link:https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext].
<br />
buffer — Must be a [link:https://developer.mozilla.org/en-US/docs/Web/API/WebGLBuffer].
<br />
type — One of [link:https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants#Data_types].
<br />
itemSize — The number of values of the array that should be associated with
a particular vertex. For instance, if this
attribute is storing a 3-component vector (such as a position, normal, or color), then itemSize should be 3.
<br />
count — The expected number of vertices in VBO.
<br /><br />

normalized — (optional) Applies to integer data only. Indicates how the underlying data
in the buffer maps to the values in the GLSL code. For instance, if [page:TypedArray array] is an instance
of UInt16Array, and [page:Boolean normalized] is true, the values 0 - +65535 in the array
data will be mapped to 0.0f - +1.0f in the GLSL attribute. An Int16Array (signed) would map
from -32767 - +32767 to -1.0f - +1.0f. If [page:Boolean normalized] is false, the values
will be converted to floats unmodified, i.e. 32767 becomes 32767.0f.
</p>

<h2>Properties</h2>
Expand All @@ -39,6 +58,12 @@ <h3>[property:Integer count]</h3>
The expected number of vertices in VBO.
</p>

<h3>[property:Boolean normalized]</h3>
<p>
Indicates how the underlying data in the buffer maps to the values in the GLSL shader code.
See the constructor above for details.
</p>

<h3>[property:Integer itemSize]</h3>
<p>
How many values make up each item (vertex).
Expand Down
3 changes: 2 additions & 1 deletion src/core/GLBufferAttribute.js
Expand Up @@ -5,7 +5,7 @@ import { _Math } from '../math/Math.js';
*/


function GLBufferAttribute( gl, buffer, type, itemSize, count ) {
function GLBufferAttribute( gl, buffer, type, itemSize, count, normalized ) {

this.sizes = [
[ gl.FLOAT, 4 ],
Expand Down Expand Up @@ -35,6 +35,7 @@ function GLBufferAttribute( gl, buffer, type, itemSize, count ) {
this.itemSize = itemSize;
this.elementSize = this.sizes[ type ];
this.count = count;
this.normalized = normalized === true;

this.version = 0;

Expand Down

0 comments on commit 9ba4d01

Please sign in to comment.