浏览代码

Add parameter to the constructor

Luis Blanco 6 年之前
父节点
当前提交
9ba4d012bb
共有 2 个文件被更改,包括 28 次插入2 次删除
  1. 26 1
      docs/api/en/core/GLBufferAttribute.html
  2. 2 1
      src/core/GLBufferAttribute.js

+ 26 - 1
docs/api/en/core/GLBufferAttribute.html

@@ -23,8 +23,27 @@
 		</p>
 		</p>
 
 
 		<h2>Constructor</h2>
 		<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>
 		<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>
 		</p>
 
 
 		<h2>Properties</h2>
 		<h2>Properties</h2>
@@ -39,6 +58,12 @@
 			The expected number of vertices in VBO.
 			The expected number of vertices in VBO.
 		</p>
 		</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>
 		<h3>[property:Integer itemSize]</h3>
 		<p>
 		<p>
 			How many values make up each item (vertex).
 			How many values make up each item (vertex).

+ 2 - 1
src/core/GLBufferAttribute.js

@@ -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 = [
 	this.sizes = [
 		[ gl.FLOAT, 4 ],
 		[ gl.FLOAT, 4 ],
@@ -35,6 +35,7 @@ function GLBufferAttribute( gl, buffer, type, itemSize, count ) {
 	this.itemSize = itemSize;
 	this.itemSize = itemSize;
 	this.elementSize = this.sizes[ type ];
 	this.elementSize = this.sizes[ type ];
 	this.count = count;
 	this.count = count;
+	this.normalized = normalized === true;
 
 
 	this.version = 0;
 	this.version = 0;