BufferAttribute.html 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>BufferAttribute - Three.js Docs</title>
  6. <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
  7. <script src="../scripts/highlight.min.js"></script>
  8. <link type="text/css" rel="stylesheet" href="../styles/highlight-three.css">
  9. <link type="text/css" rel="stylesheet" href="../styles/page.css">
  10. </head>
  11. <body>
  12. <h1 translate="no">BufferAttribute</h1>
  13. <section>
  14. <header>
  15. <div class="class-description"><p>This class stores data for an attribute (such as vertex positions, face
  16. indices, normals, colors, UVs, and any custom attributes ) associated with
  17. a geometry, which allows for more efficient passing of data to the GPU.</p>
  18. <p>When working with vector-like data, the <code>fromBufferAttribute( attribute, index )</code>
  19. helper methods on vector and color class might be helpful. E.g. <a href="Vector3.html#fromBufferAttribute">Vector3#fromBufferAttribute</a>.</p></div>
  20. </header>
  21. <article>
  22. <div class="container-overview">
  23. <h2>Constructor</h2>
  24. <h3 class="name name-method" id="BufferAttribute" translate="no">new <a href="#BufferAttribute">BufferAttribute</a><span class="signature">( array : <span class="param-type">TypedArray</span>, itemSize : <span class="param-type">number</span>, normalized : <span class="param-type">boolean</span> )</span> </h3>
  25. <div class="method">
  26. <div class="description">
  27. <p>Constructs a new buffer attribute.</p>
  28. </div>
  29. <table class="params">
  30. <tbody>
  31. <tr>
  32. <td class="name"><code>array</code></td>
  33. <td class="description last"><p>The array holding the attribute data.</p></td>
  34. </tr>
  35. <tr>
  36. <td class="name"><code>itemSize</code></td>
  37. <td class="description last"><p>The item size.</p></td>
  38. </tr>
  39. <tr>
  40. <td class="name"><code>normalized</code></td>
  41. <td class="description last"><p>Whether the data are normalized or not.<br/>Default is <code>false</code>.</p></td>
  42. </tr>
  43. </tbody>
  44. </table>
  45. </div>
  46. </div>
  47. <h2 class="subsection-title">Properties</h2>
  48. <div class="member">
  49. <h3 class="name" id="array" translate="no">.<a href="#array">array</a><span class="type-signature"> : TypedArray</span> </h3>
  50. <div class="description">
  51. <p>The array holding the attribute data. It should have <code>itemSize * numVertices</code>
  52. elements, where <code>numVertices</code> is the number of vertices in the associated geometry.</p>
  53. </div>
  54. </div>
  55. <div class="member">
  56. <h3 class="name" id="count" translate="no">.<a href="#count">count</a><span class="type-signature"> : number</span> <span class="type-signature">(readonly) </span></h3>
  57. <div class="description">
  58. <p>Represents the number of items this buffer attribute stores. It is internally computed
  59. by dividing the <code>array</code> length by the <code>itemSize</code>.</p>
  60. </div>
  61. </div>
  62. <div class="member">
  63. <h3 class="name" id="gpuType" translate="no">.<a href="#gpuType">gpuType</a><span class="type-signature"> : <a href="global.html#FloatType">FloatType</a> | <a href="global.html#IntType">IntType</a></span> </h3>
  64. <div class="description">
  65. <p>Configures the bound GPU type for use in shaders.</p>
  66. <p>Note: this only has an effect for integer arrays and is not configurable for float arrays.
  67. For lower precision float types, use <code>Float16BufferAttribute</code>.<br/>Default is <code>FloatType</code>.</p>
  68. </div>
  69. </div>
  70. <div class="member">
  71. <h3 class="name" id="id" translate="no">.<a href="#id">id</a><span class="type-signature"> : number</span> <span class="type-signature">(readonly) </span></h3>
  72. <div class="description">
  73. <p>The ID of the buffer attribute.</p>
  74. </div>
  75. </div>
  76. <div class="member">
  77. <h3 class="name" id="isBufferAttribute" translate="no">.<a href="#isBufferAttribute">isBufferAttribute</a><span class="type-signature"> : boolean</span> <span class="type-signature">(readonly) </span></h3>
  78. <div class="description">
  79. <p>This flag can be used for type testing.<br/>Default is <code>true</code>.</p>
  80. </div>
  81. </div>
  82. <div class="member">
  83. <h3 class="name" id="itemSize" translate="no">.<a href="#itemSize">itemSize</a><span class="type-signature"> : number</span> </h3>
  84. <div class="description">
  85. <p>The number of values of the array that should be associated with a particular vertex.
  86. For instance, if this attribute is storing a 3-component vector (such as a position,
  87. normal, or color), then the value should be <code>3</code>.</p>
  88. </div>
  89. </div>
  90. <div class="member">
  91. <h3 class="name" id="name" translate="no">.<a href="#name">name</a><span class="type-signature"> : string</span> </h3>
  92. <div class="description">
  93. <p>The name of the buffer attribute.</p>
  94. </div>
  95. </div>
  96. <div class="member">
  97. <h3 class="name" id="needsUpdate" translate="no">.<a href="#needsUpdate">needsUpdate</a><span class="type-signature"> : number</span> </h3>
  98. <div class="description">
  99. <p>Flag to indicate that this attribute has changed and should be re-sent to
  100. the GPU. Set this to <code>true</code> when you modify the value of the array.<br/>Default is <code>false</code>.</p>
  101. </div>
  102. </div>
  103. <div class="member">
  104. <h3 class="name" id="normalized" translate="no">.<a href="#normalized">normalized</a><span class="type-signature"> : boolean</span> </h3>
  105. <div class="description">
  106. <p>Applies to integer data only. Indicates how the underlying data in the buffer maps to
  107. the values in the GLSL code. For instance, if <code>array</code> is an instance of <code>UInt16Array</code>,
  108. and <code>normalized</code> is <code>true</code>, the values <code>0 - +65535</code> in the array data will be mapped to
  109. <code>0.0f - +1.0f</code> in the GLSL attribute. If <code>normalized</code> is <code>false</code>, the values will be converted
  110. to floats unmodified, i.e. <code>65535</code> becomes <code>65535.0f</code>.</p>
  111. </div>
  112. </div>
  113. <div class="member">
  114. <h3 class="name" id="updateRanges" translate="no">.<a href="#updateRanges">updateRanges</a><span class="type-signature"> : Array.&lt;Object></span> </h3>
  115. <div class="description">
  116. <p>This can be used to only update some components of stored vectors (for example, just the
  117. component related to color). Use the <code>addUpdateRange()</code> function to add ranges to this array.</p>
  118. </div>
  119. </div>
  120. <div class="member">
  121. <h3 class="name" id="usage" translate="no">.<a href="#usage">usage</a><span class="type-signature"> : <a href="global.html#StaticDrawUsage">StaticDrawUsage</a> | <a href="global.html#DynamicDrawUsage">DynamicDrawUsage</a> | <a href="global.html#StreamDrawUsage">StreamDrawUsage</a> | <a href="global.html#StaticReadUsage">StaticReadUsage</a> | <a href="global.html#DynamicReadUsage">DynamicReadUsage</a> | <a href="global.html#StreamReadUsage">StreamReadUsage</a> | <a href="global.html#StaticCopyUsage">StaticCopyUsage</a> | <a href="global.html#DynamicCopyUsage">DynamicCopyUsage</a> | <a href="global.html#StreamCopyUsage">StreamCopyUsage</a></span> </h3>
  122. <div class="description">
  123. <p>Defines the intended usage pattern of the data store for optimization purposes.</p>
  124. <p>Note: After the initial use of a buffer, its usage cannot be changed. Instead,
  125. instantiate a new one and set the desired usage before the next render.<br/>Default is <code>StaticDrawUsage</code>.</p>
  126. </div>
  127. </div>
  128. <div class="member">
  129. <h3 class="name" id="version" translate="no">.<a href="#version">version</a><span class="type-signature"> : number</span> </h3>
  130. <div class="description">
  131. <p>A version number, incremented every time the <code>needsUpdate</code> is set to <code>true</code>.</p>
  132. </div>
  133. </div>
  134. <h2 class="subsection-title">Methods</h2>
  135. <h3 class="name name-method" id="addUpdateRange" translate="no">.<a href="#addUpdateRange">addUpdateRange</a><span class="signature">( start : <span class="param-type">number</span>, count : <span class="param-type">number</span> )</span> </h3>
  136. <div class="method">
  137. <div class="description">
  138. <p>Adds a range of data in the data array to be updated on the GPU.</p>
  139. </div>
  140. <table class="params">
  141. <tbody>
  142. <tr>
  143. <td class="name"><code>start</code></td>
  144. <td class="description last"><p>Position at which to start update.</p></td>
  145. </tr>
  146. <tr>
  147. <td class="name"><code>count</code></td>
  148. <td class="description last"><p>The number of components to update.</p></td>
  149. </tr>
  150. </tbody>
  151. </table>
  152. </div>
  153. <h3 class="name name-method" id="applyMatrix3" translate="no">.<a href="#applyMatrix3">applyMatrix3</a><span class="signature">( m : <span class="param-type">Matrix3</span> )</span><span class="type-signature"> : <a href="BufferAttribute.html">BufferAttribute</a></span> </h3>
  154. <div class="method">
  155. <div class="description">
  156. <p>Applies the given 3x3 matrix to the given attribute. Works with
  157. item size <code>2</code> and <code>3</code>.</p>
  158. </div>
  159. <table class="params">
  160. <tbody>
  161. <tr>
  162. <td class="name"><code>m</code></td>
  163. <td class="description last"><p>The matrix to apply.</p></td>
  164. </tr>
  165. </tbody>
  166. </table>
  167. <dl class="details">
  168. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  169. </dl>
  170. </div>
  171. <h3 class="name name-method" id="applyMatrix4" translate="no">.<a href="#applyMatrix4">applyMatrix4</a><span class="signature">( m : <span class="param-type">Matrix4</span> )</span><span class="type-signature"> : <a href="BufferAttribute.html">BufferAttribute</a></span> </h3>
  172. <div class="method">
  173. <div class="description">
  174. <p>Applies the given 4x4 matrix to the given attribute. Only works with
  175. item size <code>3</code>.</p>
  176. </div>
  177. <table class="params">
  178. <tbody>
  179. <tr>
  180. <td class="name"><code>m</code></td>
  181. <td class="description last"><p>The matrix to apply.</p></td>
  182. </tr>
  183. </tbody>
  184. </table>
  185. <dl class="details">
  186. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  187. </dl>
  188. </div>
  189. <h3 class="name name-method" id="applyNormalMatrix" translate="no">.<a href="#applyNormalMatrix">applyNormalMatrix</a><span class="signature">( m : <span class="param-type">Matrix3</span> )</span><span class="type-signature"> : <a href="BufferAttribute.html">BufferAttribute</a></span> </h3>
  190. <div class="method">
  191. <div class="description">
  192. <p>Applies the given 3x3 normal matrix to the given attribute. Only works with
  193. item size <code>3</code>.</p>
  194. </div>
  195. <table class="params">
  196. <tbody>
  197. <tr>
  198. <td class="name"><code>m</code></td>
  199. <td class="description last"><p>The normal matrix to apply.</p></td>
  200. </tr>
  201. </tbody>
  202. </table>
  203. <dl class="details">
  204. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  205. </dl>
  206. </div>
  207. <h3 class="name name-method" id="clearUpdateRanges" translate="no">.<a href="#clearUpdateRanges">clearUpdateRanges</a><span class="signature">()</span> </h3>
  208. <div class="method">
  209. <div class="description">
  210. <p>Clears the update ranges.</p>
  211. </div>
  212. </div>
  213. <h3 class="name name-method" id="clone" translate="no">.<a href="#clone">clone</a><span class="signature">()</span><span class="type-signature"> : <a href="BufferAttribute.html">BufferAttribute</a></span> </h3>
  214. <div class="method">
  215. <div class="description">
  216. <p>Returns a new buffer attribute with copied values from this instance.</p>
  217. </div>
  218. <dl class="details">
  219. <dt class="tag-returns"><strong>Returns:</strong> A clone of this instance.</dt>
  220. </dl>
  221. </div>
  222. <h3 class="name name-method" id="copy" translate="no">.<a href="#copy">copy</a><span class="signature">( source : <span class="param-type">BufferAttribute</span> )</span><span class="type-signature"> : <a href="BufferAttribute.html">BufferAttribute</a></span> </h3>
  223. <div class="method">
  224. <div class="description">
  225. <p>Copies the values of the given buffer attribute to this instance.</p>
  226. </div>
  227. <table class="params">
  228. <tbody>
  229. <tr>
  230. <td class="name"><code>source</code></td>
  231. <td class="description last"><p>The buffer attribute to copy.</p></td>
  232. </tr>
  233. </tbody>
  234. </table>
  235. <dl class="details">
  236. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  237. </dl>
  238. </div>
  239. <h3 class="name name-method" id="copyArray" translate="no">.<a href="#copyArray">copyArray</a><span class="signature">( array : <span class="param-type">TypedArray | Array</span> )</span><span class="type-signature"> : <a href="BufferAttribute.html">BufferAttribute</a></span> </h3>
  240. <div class="method">
  241. <div class="description">
  242. <p>Copies the given array data into this buffer attribute.</p>
  243. </div>
  244. <table class="params">
  245. <tbody>
  246. <tr>
  247. <td class="name"><code>array</code></td>
  248. <td class="description last"><p>The array to copy.</p></td>
  249. </tr>
  250. </tbody>
  251. </table>
  252. <dl class="details">
  253. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  254. </dl>
  255. </div>
  256. <h3 class="name name-method" id="copyAt" translate="no">.<a href="#copyAt">copyAt</a><span class="signature">( index1 : <span class="param-type">number</span>, attribute : <span class="param-type">BufferAttribute</span>, index2 : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="BufferAttribute.html">BufferAttribute</a></span> </h3>
  257. <div class="method">
  258. <div class="description">
  259. <p>Copies a vector from the given buffer attribute to this one. The start
  260. and destination position in the attribute buffers are represented by the
  261. given indices.</p>
  262. </div>
  263. <table class="params">
  264. <tbody>
  265. <tr>
  266. <td class="name"><code>index1</code></td>
  267. <td class="description last"><p>The destination index into this buffer attribute.</p></td>
  268. </tr>
  269. <tr>
  270. <td class="name"><code>attribute</code></td>
  271. <td class="description last"><p>The buffer attribute to copy from.</p></td>
  272. </tr>
  273. <tr>
  274. <td class="name"><code>index2</code></td>
  275. <td class="description last"><p>The source index into the given buffer attribute.</p></td>
  276. </tr>
  277. </tbody>
  278. </table>
  279. <dl class="details">
  280. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  281. </dl>
  282. </div>
  283. <h3 class="name name-method" id="getComponent" translate="no">.<a href="#getComponent">getComponent</a><span class="signature">( index : <span class="param-type">number</span>, component : <span class="param-type">number</span> )</span><span class="type-signature"> : number</span> </h3>
  284. <div class="method">
  285. <div class="description">
  286. <p>Returns the given component of the vector at the given index.</p>
  287. </div>
  288. <table class="params">
  289. <tbody>
  290. <tr>
  291. <td class="name"><code>index</code></td>
  292. <td class="description last"><p>The index into the buffer attribute.</p></td>
  293. </tr>
  294. <tr>
  295. <td class="name"><code>component</code></td>
  296. <td class="description last"><p>The component index.</p></td>
  297. </tr>
  298. </tbody>
  299. </table>
  300. <dl class="details">
  301. <dt class="tag-returns"><strong>Returns:</strong> The returned value.</dt>
  302. </dl>
  303. </div>
  304. <h3 class="name name-method" id="getW" translate="no">.<a href="#getW">getW</a><span class="signature">( index : <span class="param-type">number</span> )</span><span class="type-signature"> : number</span> </h3>
  305. <div class="method">
  306. <div class="description">
  307. <p>Returns the w component of the vector at the given index.</p>
  308. </div>
  309. <table class="params">
  310. <tbody>
  311. <tr>
  312. <td class="name"><code>index</code></td>
  313. <td class="description last"><p>The index into the buffer attribute.</p></td>
  314. </tr>
  315. </tbody>
  316. </table>
  317. <dl class="details">
  318. <dt class="tag-returns"><strong>Returns:</strong> The w component.</dt>
  319. </dl>
  320. </div>
  321. <h3 class="name name-method" id="getX" translate="no">.<a href="#getX">getX</a><span class="signature">( index : <span class="param-type">number</span> )</span><span class="type-signature"> : number</span> </h3>
  322. <div class="method">
  323. <div class="description">
  324. <p>Returns the x component of the vector at the given index.</p>
  325. </div>
  326. <table class="params">
  327. <tbody>
  328. <tr>
  329. <td class="name"><code>index</code></td>
  330. <td class="description last"><p>The index into the buffer attribute.</p></td>
  331. </tr>
  332. </tbody>
  333. </table>
  334. <dl class="details">
  335. <dt class="tag-returns"><strong>Returns:</strong> The x component.</dt>
  336. </dl>
  337. </div>
  338. <h3 class="name name-method" id="getY" translate="no">.<a href="#getY">getY</a><span class="signature">( index : <span class="param-type">number</span> )</span><span class="type-signature"> : number</span> </h3>
  339. <div class="method">
  340. <div class="description">
  341. <p>Returns the y component of the vector at the given index.</p>
  342. </div>
  343. <table class="params">
  344. <tbody>
  345. <tr>
  346. <td class="name"><code>index</code></td>
  347. <td class="description last"><p>The index into the buffer attribute.</p></td>
  348. </tr>
  349. </tbody>
  350. </table>
  351. <dl class="details">
  352. <dt class="tag-returns"><strong>Returns:</strong> The y component.</dt>
  353. </dl>
  354. </div>
  355. <h3 class="name name-method" id="getZ" translate="no">.<a href="#getZ">getZ</a><span class="signature">( index : <span class="param-type">number</span> )</span><span class="type-signature"> : number</span> </h3>
  356. <div class="method">
  357. <div class="description">
  358. <p>Returns the z component of the vector at the given index.</p>
  359. </div>
  360. <table class="params">
  361. <tbody>
  362. <tr>
  363. <td class="name"><code>index</code></td>
  364. <td class="description last"><p>The index into the buffer attribute.</p></td>
  365. </tr>
  366. </tbody>
  367. </table>
  368. <dl class="details">
  369. <dt class="tag-returns"><strong>Returns:</strong> The z component.</dt>
  370. </dl>
  371. </div>
  372. <h3 class="name name-method" id="onUpload" translate="no">.<a href="#onUpload">onUpload</a><span class="signature">( callback : <span class="param-type">function</span> )</span><span class="type-signature"> : <a href="BufferAttribute.html">BufferAttribute</a></span> </h3>
  373. <div class="method">
  374. <div class="description">
  375. <p>Sets the given callback function that is executed after the Renderer has transferred
  376. the attribute array data to the GPU. Can be used to perform clean-up operations after
  377. the upload when attribute data are not needed anymore on the CPU side.</p>
  378. </div>
  379. <table class="params">
  380. <tbody>
  381. <tr>
  382. <td class="name"><code>callback</code></td>
  383. <td class="description last"><p>The <code>onUpload()</code> callback.</p></td>
  384. </tr>
  385. </tbody>
  386. </table>
  387. <dl class="details">
  388. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  389. </dl>
  390. </div>
  391. <h3 class="name name-method" id="onUploadCallback" translate="no">.<a href="#onUploadCallback">onUploadCallback</a><span class="signature">()</span> </h3>
  392. <div class="method">
  393. <div class="description">
  394. <p>A callback function that is executed after the renderer has transferred the attribute
  395. array data to the GPU.</p>
  396. </div>
  397. </div>
  398. <h3 class="name name-method" id="set" translate="no">.<a href="#set">set</a><span class="signature">( value : <span class="param-type">TypedArray | Array</span>, offset : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="BufferAttribute.html">BufferAttribute</a></span> </h3>
  399. <div class="method">
  400. <div class="description">
  401. <p>Sets the given array data in the buffer attribute.</p>
  402. </div>
  403. <table class="params">
  404. <tbody>
  405. <tr>
  406. <td class="name"><code>value</code></td>
  407. <td class="description last"><p>The array data to set.</p></td>
  408. </tr>
  409. <tr>
  410. <td class="name"><code>offset</code></td>
  411. <td class="description last"><p>The offset in this buffer attribute's array.<br/>Default is <code>0</code>.</p></td>
  412. </tr>
  413. </tbody>
  414. </table>
  415. <dl class="details">
  416. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  417. </dl>
  418. </div>
  419. <h3 class="name name-method" id="setComponent" translate="no">.<a href="#setComponent">setComponent</a><span class="signature">( index : <span class="param-type">number</span>, component : <span class="param-type">number</span>, value : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="BufferAttribute.html">BufferAttribute</a></span> </h3>
  420. <div class="method">
  421. <div class="description">
  422. <p>Sets the given value to the given component of the vector at the given index.</p>
  423. </div>
  424. <table class="params">
  425. <tbody>
  426. <tr>
  427. <td class="name"><code>index</code></td>
  428. <td class="description last"><p>The index into the buffer attribute.</p></td>
  429. </tr>
  430. <tr>
  431. <td class="name"><code>component</code></td>
  432. <td class="description last"><p>The component index.</p></td>
  433. </tr>
  434. <tr>
  435. <td class="name"><code>value</code></td>
  436. <td class="description last"><p>The value to set.</p></td>
  437. </tr>
  438. </tbody>
  439. </table>
  440. <dl class="details">
  441. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  442. </dl>
  443. </div>
  444. <h3 class="name name-method" id="setUsage" translate="no">.<a href="#setUsage">setUsage</a><span class="signature">( value : <span class="param-type">StaticDrawUsage | DynamicDrawUsage | StreamDrawUsage | StaticReadUsage | DynamicReadUsage | StreamReadUsage | StaticCopyUsage | DynamicCopyUsage | StreamCopyUsage</span> )</span><span class="type-signature"> : <a href="BufferAttribute.html">BufferAttribute</a></span> </h3>
  445. <div class="method">
  446. <div class="description">
  447. <p>Sets the usage of this buffer attribute.</p>
  448. </div>
  449. <table class="params">
  450. <tbody>
  451. <tr>
  452. <td class="name"><code>value</code></td>
  453. <td class="description last"><p>The usage to set.</p></td>
  454. </tr>
  455. </tbody>
  456. </table>
  457. <dl class="details">
  458. <dt class="tag-returns"><strong>Returns:</strong> A reference to this buffer attribute.</dt>
  459. </dl>
  460. </div>
  461. <h3 class="name name-method" id="setW" translate="no">.<a href="#setW">setW</a><span class="signature">( index : <span class="param-type">number</span>, w : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="BufferAttribute.html">BufferAttribute</a></span> </h3>
  462. <div class="method">
  463. <div class="description">
  464. <p>Sets the w component of the vector at the given index.</p>
  465. </div>
  466. <table class="params">
  467. <tbody>
  468. <tr>
  469. <td class="name"><code>index</code></td>
  470. <td class="description last"><p>The index into the buffer attribute.</p></td>
  471. </tr>
  472. <tr>
  473. <td class="name"><code>w</code></td>
  474. <td class="description last"><p>The value to set.</p></td>
  475. </tr>
  476. </tbody>
  477. </table>
  478. <dl class="details">
  479. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  480. </dl>
  481. </div>
  482. <h3 class="name name-method" id="setX" translate="no">.<a href="#setX">setX</a><span class="signature">( index : <span class="param-type">number</span>, x : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="BufferAttribute.html">BufferAttribute</a></span> </h3>
  483. <div class="method">
  484. <div class="description">
  485. <p>Sets the x component of the vector at the given index.</p>
  486. </div>
  487. <table class="params">
  488. <tbody>
  489. <tr>
  490. <td class="name"><code>index</code></td>
  491. <td class="description last"><p>The index into the buffer attribute.</p></td>
  492. </tr>
  493. <tr>
  494. <td class="name"><code>x</code></td>
  495. <td class="description last"><p>The value to set.</p></td>
  496. </tr>
  497. </tbody>
  498. </table>
  499. <dl class="details">
  500. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  501. </dl>
  502. </div>
  503. <h3 class="name name-method" id="setXY" translate="no">.<a href="#setXY">setXY</a><span class="signature">( index : <span class="param-type">number</span>, x : <span class="param-type">number</span>, y : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="BufferAttribute.html">BufferAttribute</a></span> </h3>
  504. <div class="method">
  505. <div class="description">
  506. <p>Sets the x and y component of the vector at the given index.</p>
  507. </div>
  508. <table class="params">
  509. <tbody>
  510. <tr>
  511. <td class="name"><code>index</code></td>
  512. <td class="description last"><p>The index into the buffer attribute.</p></td>
  513. </tr>
  514. <tr>
  515. <td class="name"><code>x</code></td>
  516. <td class="description last"><p>The value for the x component to set.</p></td>
  517. </tr>
  518. <tr>
  519. <td class="name"><code>y</code></td>
  520. <td class="description last"><p>The value for the y component to set.</p></td>
  521. </tr>
  522. </tbody>
  523. </table>
  524. <dl class="details">
  525. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  526. </dl>
  527. </div>
  528. <h3 class="name name-method" id="setXYZ" translate="no">.<a href="#setXYZ">setXYZ</a><span class="signature">( index : <span class="param-type">number</span>, x : <span class="param-type">number</span>, y : <span class="param-type">number</span>, z : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="BufferAttribute.html">BufferAttribute</a></span> </h3>
  529. <div class="method">
  530. <div class="description">
  531. <p>Sets the x, y and z component of the vector at the given index.</p>
  532. </div>
  533. <table class="params">
  534. <tbody>
  535. <tr>
  536. <td class="name"><code>index</code></td>
  537. <td class="description last"><p>The index into the buffer attribute.</p></td>
  538. </tr>
  539. <tr>
  540. <td class="name"><code>x</code></td>
  541. <td class="description last"><p>The value for the x component to set.</p></td>
  542. </tr>
  543. <tr>
  544. <td class="name"><code>y</code></td>
  545. <td class="description last"><p>The value for the y component to set.</p></td>
  546. </tr>
  547. <tr>
  548. <td class="name"><code>z</code></td>
  549. <td class="description last"><p>The value for the z component to set.</p></td>
  550. </tr>
  551. </tbody>
  552. </table>
  553. <dl class="details">
  554. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  555. </dl>
  556. </div>
  557. <h3 class="name name-method" id="setXYZW" translate="no">.<a href="#setXYZW">setXYZW</a><span class="signature">( index : <span class="param-type">number</span>, x : <span class="param-type">number</span>, y : <span class="param-type">number</span>, z : <span class="param-type">number</span>, w : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="BufferAttribute.html">BufferAttribute</a></span> </h3>
  558. <div class="method">
  559. <div class="description">
  560. <p>Sets the x, y, z and w component of the vector at the given index.</p>
  561. </div>
  562. <table class="params">
  563. <tbody>
  564. <tr>
  565. <td class="name"><code>index</code></td>
  566. <td class="description last"><p>The index into the buffer attribute.</p></td>
  567. </tr>
  568. <tr>
  569. <td class="name"><code>x</code></td>
  570. <td class="description last"><p>The value for the x component to set.</p></td>
  571. </tr>
  572. <tr>
  573. <td class="name"><code>y</code></td>
  574. <td class="description last"><p>The value for the y component to set.</p></td>
  575. </tr>
  576. <tr>
  577. <td class="name"><code>z</code></td>
  578. <td class="description last"><p>The value for the z component to set.</p></td>
  579. </tr>
  580. <tr>
  581. <td class="name"><code>w</code></td>
  582. <td class="description last"><p>The value for the w component to set.</p></td>
  583. </tr>
  584. </tbody>
  585. </table>
  586. <dl class="details">
  587. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  588. </dl>
  589. </div>
  590. <h3 class="name name-method" id="setY" translate="no">.<a href="#setY">setY</a><span class="signature">( index : <span class="param-type">number</span>, y : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="BufferAttribute.html">BufferAttribute</a></span> </h3>
  591. <div class="method">
  592. <div class="description">
  593. <p>Sets the y component of the vector at the given index.</p>
  594. </div>
  595. <table class="params">
  596. <tbody>
  597. <tr>
  598. <td class="name"><code>index</code></td>
  599. <td class="description last"><p>The index into the buffer attribute.</p></td>
  600. </tr>
  601. <tr>
  602. <td class="name"><code>y</code></td>
  603. <td class="description last"><p>The value to set.</p></td>
  604. </tr>
  605. </tbody>
  606. </table>
  607. <dl class="details">
  608. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  609. </dl>
  610. </div>
  611. <h3 class="name name-method" id="setZ" translate="no">.<a href="#setZ">setZ</a><span class="signature">( index : <span class="param-type">number</span>, z : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="BufferAttribute.html">BufferAttribute</a></span> </h3>
  612. <div class="method">
  613. <div class="description">
  614. <p>Sets the z component of the vector at the given index.</p>
  615. </div>
  616. <table class="params">
  617. <tbody>
  618. <tr>
  619. <td class="name"><code>index</code></td>
  620. <td class="description last"><p>The index into the buffer attribute.</p></td>
  621. </tr>
  622. <tr>
  623. <td class="name"><code>z</code></td>
  624. <td class="description last"><p>The value to set.</p></td>
  625. </tr>
  626. </tbody>
  627. </table>
  628. <dl class="details">
  629. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  630. </dl>
  631. </div>
  632. <h3 class="name name-method" id="toJSON" translate="no">.<a href="#toJSON">toJSON</a><span class="signature">()</span><span class="type-signature"> : Object</span> </h3>
  633. <div class="method">
  634. <div class="description">
  635. <p>Serializes the buffer attribute into JSON.</p>
  636. </div>
  637. <dl class="details">
  638. <dt class="tag-returns"><strong>Returns:</strong> A JSON object representing the serialized buffer attribute.</dt>
  639. </dl>
  640. </div>
  641. <h3 class="name name-method" id="transformDirection" translate="no">.<a href="#transformDirection">transformDirection</a><span class="signature">( m : <span class="param-type">Matrix4</span> )</span><span class="type-signature"> : <a href="BufferAttribute.html">BufferAttribute</a></span> </h3>
  642. <div class="method">
  643. <div class="description">
  644. <p>Applies the given 4x4 matrix to the given attribute. Only works with
  645. item size <code>3</code> and with direction vectors.</p>
  646. </div>
  647. <table class="params">
  648. <tbody>
  649. <tr>
  650. <td class="name"><code>m</code></td>
  651. <td class="description last"><p>The matrix to apply.</p></td>
  652. </tr>
  653. </tbody>
  654. </table>
  655. <dl class="details">
  656. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  657. </dl>
  658. </div>
  659. <h2 class="subsection-title">Source</h2>
  660. <p>
  661. <a href="https://github.com/mrdoob/three.js/blob/master/src/core/BufferAttribute.js" target="_blank" rel="noopener" translate="no">src/core/BufferAttribute.js</a>
  662. </p>
  663. </article>
  664. </section>
  665. <script src="../scripts/linenumber.js"></script>
  666. <script src="../scripts/page.js"></script>
  667. </body>
  668. </html>
粤ICP备19079148号