File: BufferAttribute.html

package info (click to toggle)
three.js 111%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 15,184 kB
  • sloc: javascript: 133,174; makefile: 24; sh: 1
file content (190 lines) | stat: -rw-r--r-- 8,864 bytes parent folder | download | duplicates (2)
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
<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8" />
		<base href="../../../" />
		<script src="list.js"></script>
		<script src="page.js"></script>
		<link type="text/css" rel="stylesheet" href="page.css" />
	</head>
	<body>
		<h1>[name]</h1>

		<p class="desc">
			这个类用于存储与[page:BufferGeometry]相关联的 attribute(例如顶点位置向量,面片索引,法向量,颜色值,UV坐标以及任何自定义 attribute )。
			利用 BufferAttribute,可以更高效的向GPU传递数据。详情和例子见该页。<br /><br />

			在 BufferAttribute 中,数据被存储为任意长度的矢量(通过[page:BufferAttribute.itemSize itemSize]进行定义),下列函数如无特别说明,
			函数参数中的index会自动乘以矢量长度进行计算。
		</p>

		<h2>构造函数</h2>
		<h3>[name]( [param:TypedArray array], [param:Integer itemSize], [param:Boolean normalized] )</h3>
		<p>
			[page:TypedArray array] -- 必须是 [link:https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/TypedArray TypedArray].
			类型,用于实例化缓存。<br />
			该队列应该包含:
	 	<code>itemSize * numVertices</code>
			个元素,numVertices 是 [page:BufferGeometry BufferGeometry]中的顶点数目<br /><br />


		[page:Integer itemSize] --
			队列中与顶点相关的数据值的大小。举例,如果 attribute 存储的是三元组(例如顶点空间坐标、法向量或颜色值)则itemSize的值应该是3。
		<br /><br />

			[page:Boolean normalized] -- (可选) 指明缓存中的数据如何与GLSL代码中的数据对应。例如,如果[page:TypedArray array]是
			UInt16Array类型,且[page:Boolean normalized]的值是 true,则队列中的值将会从 0 - +65535 映射为 GLSL 中的 0.0f - +1.0f。
			如果[page:TypedArray array]是 Int16Array (有符号),则值将会从 -32767 - +32767 映射为 -1.0f - +1.0f。若 [page:Boolean normalized]
			的值为 false,则数据映射不会归一化,而会直接映射为 float 值,例如,32767 将会映射为 32767.0f.
		</p>

		<h2>属性</h2>

		<h3>[property:TypedArray array]</h3>
		<p>
			在 [page:TypedArray array] 中保存着缓存中的数据。
		</p>

		<h3>[property:Integer count]</h3>
		<p>
			保存 [page:BufferAttribute.array array] 除以 [page:BufferAttribute.itemSize itemSize] 之后的大小。<br /><br />

			若缓存存储三元组(例如顶点位置、法向量、颜色值),则该值应等于队列中三元组的个数。
		</p>

		<h3>[property:Boolean isBufferAttribute]</h3>
		<p>
			指示当前类或派生类是 BufferAttributes. 默认值为 *true*.<br /><br />

			开发者不应当改变该值,该值用于内部实现优化。
		</p>

		<h3>[property:Integer itemSize]</h3>
		<p>保存在 [page:BufferAttribute.array array] 中矢量的长度。</p>

		<h3>[property:String name]</h3>
		<p>
			该 attribute 实例的别名,默认值为空字符串。
		</p>

		<h3>[property:Boolean needsUpdate]</h3>
		<p>
			该标志位指明当前 attribute 已经被修改过,且需要再次送入 GPU 处理。当开发者改变了该队列的值,则标志位需要设置为 true。<br /><br />
			将标志位设为 true 同样会增加 [page:BufferAttribute.version version] 的值。
		</p>

		<h3>[property:Boolean normalized]</h3>
		<p>
			指明缓存中数据在转化为GLSL着色器代码中数据时是否需要被归一化。详见构造函数中的说明。
		</p>

		<h3>[property:Function onUploadCallback]</h3>
		<p>
			attribute 数据传输到GPU后的回调函数。
		</p>

		<h3>[property:Object updateRange]</h3>
		<p>对象包含如下成员:<br />
			[page:Integer offset]: 默认值为 *0*。 指明更新的起始位置。<br />
			[page:Integer count]: 默认值为 *-1*,表示不指定更新范围。<br /><br />

			该值只可以被用于更新某些矢量数据(例如,颜色相关数据)。
		</p>

		<h3>[property:Usage usage]</h3>
		<p>
			Defines the intended usage pattern of the data store for optimization purposes. Corresponds to the *usage* parameter of
			[link:https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/bufferData WebGLRenderingContext.bufferData]().
			Default is *THREE.StaticDrawUsage*.
		</p>

		<h3>[property:Integer version]</h3>
		<p>版本号,当 [page:BufferAttribute.needsUpdate needsUpdate] 被设置为 true 时,该值会自增。</p>


		<h2>方法</h2>

		<h3>[method:BufferAttribute clone]() </h3>
		<p>返回该 BufferAttribute 的拷贝。</p>

		<h3>[method:BufferAttribute copyArray]( array ) </h3>
		<p>将参数中所给定的普通队列或 TypedArray 拷贝到 [page:BufferAttribute.array array] 中。<br /><br />
			拷贝 TypedArray 相关注意事项详见 [link:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set TypedArray.set]。
		</p>

		<h3>[method:null copyAt] ( [param:Integer index1], [param:BufferAttribute bufferAttribute], [param:Integer index2] ) </h3>
		<p>将一个矢量从 bufferAttribute[index2] 拷贝到 [page:BufferAttribute.array array][index1] 中。</p>

		<h3>[method:BufferAttribute copyColorsArray]( [param:Array colors] ) </h3>
		<p>将一个存储 RGB 颜色值的队列拷贝到 [page:BufferAttribute.array array] 中。</p>

		<h3>[method:BufferAttribute copyVector2sArray]( [param:Array vectors] ) </h3>
		<p>将一个存储 [page:Vector2] 的队列拷贝到 [page:BufferAttribute.array array] 中。</p>

		<h3>[method:BufferAttribute copyVector3sArray]( [param:Array vectors] ) </h3>
		<p>将一个存储 [page:Vector3] 的队列拷贝到 [page:BufferAttribute.array array] 中。</p>

		<h3>[method:BufferAttribute copyVector4sArray]( [param:Array vectors] ) </h3>
		<p>将一个存储 [page:Vector4] 的队列拷贝到 [page:BufferAttribute.array array] 中。</p>

		<h3>[method:Number getX]( [param:Integer index] ) </h3>
		<p>获取给定索引的矢量的第一维元素 (即 X 值)。</p>

		<h3>[method:Number getY]( [param:Integer index] ) </h3>
		<p>获取给定索引的矢量的第二维元素 (即 Y 值)。</p>

		<h3>[method:Number getZ]( [param:Integer index] ) </h3>
		<p>获取给定索引的矢量的第三维元素 (即 Z 值)。</p>

		<h3>[method:Number getW]( [param:Integer index] ) </h3>
		<p>获取给定索引的矢量的第四维元素 (即 W 值)。</p>

		<h3>[method:null onUpload]( [param:Function callback] ) </h3>
		<p>见 onUploadCallback 属性。<br /><br />
			在 [example:webgl_buffergeometry WebGL / Buffergeometry] 中,该方在缓存数据传递给 GPU 后,用于释放内存。
		</p>

		<h3>[method:BufferAttribute set] ( [param:Array value], [param:Integer offset] ) </h3>
		<p>
		value -- 被拷贝的 [page:Array] 或 [page:TypedArray] 类型的数据。 <br />
		offset -- (可选) [page:BufferAttribute.array array] 中开始拷贝的位置索引。<br /><br />

		对 [page:BufferAttribute.array array],调用	[link:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set TypedArray.set]( [page:Array value], [page:Integer offset] )
		方法。<br /><br />

		特别的, 对将 [page:Array value] 转为  [page:TypedArray] 的要求详见上述链接。
		</p>

		<h3>[method:BufferAttribute setUsage] ( [param:Usage value] ) </h3>
		<p>Set [page:BufferAttribute.usage usage] to value.</p>

		<h3>[method:BufferAttribute setX]( [param:Integer index], [param:Float x] ) </h3>
		<p>设置给定索引的矢量的第一维数据(设置 X 值)。</p>

		<h3>[method:BufferAttribute setY]( [param:Integer index], [param:Float y] ) </h3>
		<p>设置给定索引的矢量的第二维数据(设置 Y 值)。</p>

		<h3>[method:BufferAttribute setZ]( [param:Integer index], [param:Float z] ) </h3>
		<p>设置给定索引的矢量的第三维数据(设置 Z 值)。</p>

		<h3>[method:BufferAttribute setW]( [param:Integer index], [param:Float w] ) </h3>
		<p>设置给定索引的矢量的第四维数据(设置 W 值)。</p>

		<h3>[method:BufferAttribute setXY]( [param:Integer index], [param:Float x], [param:Float y] ) </h3>
		<p>设置给定索引的矢量的第一、二维数据(设置 X 和 Y 值)。</p>

		<h3>[method:BufferAttribute setXYZ]( [param:Integer index], [param:Float x], [param:Float y], [param:Float z] ) </h3>
		<p>设置给定索引的矢量的第一、二、三维数据(设置 X、Y 和 Z 值)。</p>

		<h3>[method:BufferAttribute setXYZW]( [param:Integer index], [param:Float x], [param:Float y], [param:Float z], [param:Float w] ) </h3>
		<p>设置给定索引的矢量的第一、二、三、四维数据(设置 X、Y、Z 和 W 值)。</p>



		<h2>源代码</h2>

		<p>
			[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
		</p>
	</body>
</html>