BufferAttribute.html 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868
  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">
  33. <strong translate="no">array</strong>
  34. </td>
  35. <td class="description last">
  36. <p>The array holding the attribute data.</p>
  37. </td>
  38. </tr>
  39. <tr>
  40. <td class="name">
  41. <strong translate="no">itemSize</strong>
  42. </td>
  43. <td class="description last">
  44. <p>The item size.</p>
  45. </td>
  46. </tr>
  47. <tr>
  48. <td class="name">
  49. <strong translate="no">normalized</strong>
  50. </td>
  51. <td class="description last">
  52. <p>Whether the data are normalized or not.</p>
  53. <p>Default is <code>false</code>.</p>
  54. </td>
  55. </tr>
  56. </tbody>
  57. </table>
  58. </div>
  59. </div>
  60. <h2 class="subsection-title">Properties</h2>
  61. <div class="member">
  62. <h3 class="name" id="array" translate="no">.<a href="#array">array</a><span class="type-signature"> : TypedArray</span> </h3>
  63. <div class="description">
  64. <p>The array holding the attribute data. It should have <code>itemSize * numVertices</code>
  65. elements, where <code>numVertices</code> is the number of vertices in the associated geometry.</p>
  66. </div>
  67. </div>
  68. <div class="member">
  69. <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>
  70. <div class="description">
  71. <p>Represents the number of items this buffer attribute stores. It is internally computed
  72. by dividing the <code>array</code> length by the <code>itemSize</code>.</p>
  73. </div>
  74. </div>
  75. <div class="member">
  76. <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>
  77. <div class="description">
  78. <p>Configures the bound GPU type for use in shaders.</p>
  79. <p>Note: this only has an effect for integer arrays and is not configurable for float arrays.
  80. For lower precision float types, use <code>Float16BufferAttribute</code>.</p>
  81. <p>Default is <code>FloatType</code>.</p>
  82. </div>
  83. </div>
  84. <div class="member">
  85. <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>
  86. <div class="description">
  87. <p>The ID of the buffer attribute.</p>
  88. </div>
  89. </div>
  90. <div class="member">
  91. <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>
  92. <div class="description">
  93. <p>This flag can be used for type testing.</p>
  94. <p>Default is <code>true</code>.</p>
  95. </div>
  96. </div>
  97. <div class="member">
  98. <h3 class="name" id="itemSize" translate="no">.<a href="#itemSize">itemSize</a><span class="type-signature"> : number</span> </h3>
  99. <div class="description">
  100. <p>The number of values of the array that should be associated with a particular vertex.
  101. For instance, if this attribute is storing a 3-component vector (such as a position,
  102. normal, or color), then the value should be <code>3</code>.</p>
  103. </div>
  104. </div>
  105. <div class="member">
  106. <h3 class="name" id="name" translate="no">.<a href="#name">name</a><span class="type-signature"> : string</span> </h3>
  107. <div class="description">
  108. <p>The name of the buffer attribute.</p>
  109. </div>
  110. </div>
  111. <div class="member">
  112. <h3 class="name" id="needsUpdate" translate="no">.<a href="#needsUpdate">needsUpdate</a><span class="type-signature"> : number</span> </h3>
  113. <div class="description">
  114. <p>Flag to indicate that this attribute has changed and should be re-sent to
  115. the GPU. Set this to <code>true</code> when you modify the value of the array.</p>
  116. <p>Default is <code>false</code>.</p>
  117. </div>
  118. </div>
  119. <div class="member">
  120. <h3 class="name" id="normalized" translate="no">.<a href="#normalized">normalized</a><span class="type-signature"> : boolean</span> </h3>
  121. <div class="description">
  122. <p>Applies to integer data only. Indicates how the underlying data in the buffer maps to
  123. the values in the GLSL code. For instance, if <code>array</code> is an instance of <code>UInt16Array</code>,
  124. and <code>normalized</code> is <code>true</code>, the values <code>0 - +65535</code> in the array data will be mapped to
  125. <code>0.0f - +1.0f</code> in the GLSL attribute. If <code>normalized</code> is <code>false</code>, the values will be converted
  126. to floats unmodified, i.e. <code>65535</code> becomes <code>65535.0f</code>.</p>
  127. </div>
  128. </div>
  129. <div class="member">
  130. <h3 class="name" id="updateRanges" translate="no">.<a href="#updateRanges">updateRanges</a><span class="type-signature"> : Array.&lt;Object></span> </h3>
  131. <div class="description">
  132. <p>This can be used to only update some components of stored vectors (for example, just the
  133. component related to color). Use the <code>addUpdateRange()</code> function to add ranges to this array.</p>
  134. </div>
  135. </div>
  136. <div class="member">
  137. <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>
  138. <div class="description">
  139. <p>Defines the intended usage pattern of the data store for optimization purposes.</p>
  140. <p>Note: After the initial use of a buffer, its usage cannot be changed. Instead,
  141. instantiate a new one and set the desired usage before the next render.</p>
  142. <p>Default is <code>StaticDrawUsage</code>.</p>
  143. </div>
  144. </div>
  145. <div class="member">
  146. <h3 class="name" id="version" translate="no">.<a href="#version">version</a><span class="type-signature"> : number</span> </h3>
  147. <div class="description">
  148. <p>A version number, incremented every time the <code>needsUpdate</code> is set to <code>true</code>.</p>
  149. </div>
  150. </div>
  151. <h2 class="subsection-title">Methods</h2>
  152. <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>
  153. <div class="method">
  154. <div class="description">
  155. <p>Adds a range of data in the data array to be updated on the GPU.</p>
  156. </div>
  157. <table class="params">
  158. <tbody>
  159. <tr>
  160. <td class="name">
  161. <strong translate="no">start</strong>
  162. </td>
  163. <td class="description last">
  164. <p>Position at which to start update.</p>
  165. </td>
  166. </tr>
  167. <tr>
  168. <td class="name">
  169. <strong translate="no">count</strong>
  170. </td>
  171. <td class="description last">
  172. <p>The number of components to update.</p>
  173. </td>
  174. </tr>
  175. </tbody>
  176. </table>
  177. </div>
  178. <h3 class="name name-method" id="applyMatrix3" translate="no">.<a href="#applyMatrix3">applyMatrix3</a><span class="signature">( m : <span class="param-type"><a href="Matrix3.html">Matrix3</a></span> )</span><span class="type-signature"> : <a href="BufferAttribute.html">BufferAttribute</a></span> </h3>
  179. <div class="method">
  180. <div class="description">
  181. <p>Applies the given 3x3 matrix to the given attribute. Works with
  182. item size <code>2</code> and <code>3</code>.</p>
  183. </div>
  184. <table class="params">
  185. <tbody>
  186. <tr>
  187. <td class="name">
  188. <strong translate="no">m</strong>
  189. </td>
  190. <td class="description last">
  191. <p>The matrix to apply.</p>
  192. </td>
  193. </tr>
  194. </tbody>
  195. </table>
  196. <dl class="details">
  197. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  198. </dl>
  199. </div>
  200. <h3 class="name name-method" id="applyMatrix4" translate="no">.<a href="#applyMatrix4">applyMatrix4</a><span class="signature">( m : <span class="param-type"><a href="Matrix4.html">Matrix4</a></span> )</span><span class="type-signature"> : <a href="BufferAttribute.html">BufferAttribute</a></span> </h3>
  201. <div class="method">
  202. <div class="description">
  203. <p>Applies the given 4x4 matrix to the given attribute. Only works with
  204. item size <code>3</code>.</p>
  205. </div>
  206. <table class="params">
  207. <tbody>
  208. <tr>
  209. <td class="name">
  210. <strong translate="no">m</strong>
  211. </td>
  212. <td class="description last">
  213. <p>The matrix to apply.</p>
  214. </td>
  215. </tr>
  216. </tbody>
  217. </table>
  218. <dl class="details">
  219. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  220. </dl>
  221. </div>
  222. <h3 class="name name-method" id="applyNormalMatrix" translate="no">.<a href="#applyNormalMatrix">applyNormalMatrix</a><span class="signature">( m : <span class="param-type"><a href="Matrix3.html">Matrix3</a></span> )</span><span class="type-signature"> : <a href="BufferAttribute.html">BufferAttribute</a></span> </h3>
  223. <div class="method">
  224. <div class="description">
  225. <p>Applies the given 3x3 normal matrix to the given attribute. Only works with
  226. item size <code>3</code>.</p>
  227. </div>
  228. <table class="params">
  229. <tbody>
  230. <tr>
  231. <td class="name">
  232. <strong translate="no">m</strong>
  233. </td>
  234. <td class="description last">
  235. <p>The normal matrix to apply.</p>
  236. </td>
  237. </tr>
  238. </tbody>
  239. </table>
  240. <dl class="details">
  241. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  242. </dl>
  243. </div>
  244. <h3 class="name name-method" id="clearUpdateRanges" translate="no">.<a href="#clearUpdateRanges">clearUpdateRanges</a><span class="signature">()</span> </h3>
  245. <div class="method">
  246. <div class="description">
  247. <p>Clears the update ranges.</p>
  248. </div>
  249. </div>
  250. <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>
  251. <div class="method">
  252. <div class="description">
  253. <p>Returns a new buffer attribute with copied values from this instance.</p>
  254. </div>
  255. <dl class="details">
  256. <dt class="tag-returns"><strong>Returns:</strong> A clone of this instance.</dt>
  257. </dl>
  258. </div>
  259. <h3 class="name name-method" id="copy" translate="no">.<a href="#copy">copy</a><span class="signature">( source : <span class="param-type"><a href="BufferAttribute.html">BufferAttribute</a></span> )</span><span class="type-signature"> : <a href="BufferAttribute.html">BufferAttribute</a></span> </h3>
  260. <div class="method">
  261. <div class="description">
  262. <p>Copies the values of the given buffer attribute to this instance.</p>
  263. </div>
  264. <table class="params">
  265. <tbody>
  266. <tr>
  267. <td class="name">
  268. <strong translate="no">source</strong>
  269. </td>
  270. <td class="description last">
  271. <p>The buffer attribute to copy.</p>
  272. </td>
  273. </tr>
  274. </tbody>
  275. </table>
  276. <dl class="details">
  277. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  278. </dl>
  279. </div>
  280. <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>
  281. <div class="method">
  282. <div class="description">
  283. <p>Copies the given array data into this buffer attribute.</p>
  284. </div>
  285. <table class="params">
  286. <tbody>
  287. <tr>
  288. <td class="name">
  289. <strong translate="no">array</strong>
  290. </td>
  291. <td class="description last">
  292. <p>The array to copy.</p>
  293. </td>
  294. </tr>
  295. </tbody>
  296. </table>
  297. <dl class="details">
  298. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  299. </dl>
  300. </div>
  301. <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"><a href="BufferAttribute.html">BufferAttribute</a></span>, index2 : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="BufferAttribute.html">BufferAttribute</a></span> </h3>
  302. <div class="method">
  303. <div class="description">
  304. <p>Copies a vector from the given buffer attribute to this one. The start
  305. and destination position in the attribute buffers are represented by the
  306. given indices.</p>
  307. </div>
  308. <table class="params">
  309. <tbody>
  310. <tr>
  311. <td class="name">
  312. <strong translate="no">index1</strong>
  313. </td>
  314. <td class="description last">
  315. <p>The destination index into this buffer attribute.</p>
  316. </td>
  317. </tr>
  318. <tr>
  319. <td class="name">
  320. <strong translate="no">attribute</strong>
  321. </td>
  322. <td class="description last">
  323. <p>The buffer attribute to copy from.</p>
  324. </td>
  325. </tr>
  326. <tr>
  327. <td class="name">
  328. <strong translate="no">index2</strong>
  329. </td>
  330. <td class="description last">
  331. <p>The source index into the given buffer attribute.</p>
  332. </td>
  333. </tr>
  334. </tbody>
  335. </table>
  336. <dl class="details">
  337. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  338. </dl>
  339. </div>
  340. <h3 class="name name-method" id="dispose" translate="no">.<a href="#dispose">dispose</a><span class="signature">()</span> </h3>
  341. <div class="method">
  342. <div class="description">
  343. <p>Disposes of the buffer attribute. Available only in <a href="WebGPURenderer.html">WebGPURenderer</a>.</p>
  344. </div>
  345. </div>
  346. <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>
  347. <div class="method">
  348. <div class="description">
  349. <p>Returns the given component of the vector at the given index.</p>
  350. </div>
  351. <table class="params">
  352. <tbody>
  353. <tr>
  354. <td class="name">
  355. <strong translate="no">index</strong>
  356. </td>
  357. <td class="description last">
  358. <p>The index into the buffer attribute.</p>
  359. </td>
  360. </tr>
  361. <tr>
  362. <td class="name">
  363. <strong translate="no">component</strong>
  364. </td>
  365. <td class="description last">
  366. <p>The component index.</p>
  367. </td>
  368. </tr>
  369. </tbody>
  370. </table>
  371. <dl class="details">
  372. <dt class="tag-returns"><strong>Returns:</strong> The returned value.</dt>
  373. </dl>
  374. </div>
  375. <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>
  376. <div class="method">
  377. <div class="description">
  378. <p>Returns the w component of the vector at the given index.</p>
  379. </div>
  380. <table class="params">
  381. <tbody>
  382. <tr>
  383. <td class="name">
  384. <strong translate="no">index</strong>
  385. </td>
  386. <td class="description last">
  387. <p>The index into the buffer attribute.</p>
  388. </td>
  389. </tr>
  390. </tbody>
  391. </table>
  392. <dl class="details">
  393. <dt class="tag-returns"><strong>Returns:</strong> The w component.</dt>
  394. </dl>
  395. </div>
  396. <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>
  397. <div class="method">
  398. <div class="description">
  399. <p>Returns the x component of the vector at the given index.</p>
  400. </div>
  401. <table class="params">
  402. <tbody>
  403. <tr>
  404. <td class="name">
  405. <strong translate="no">index</strong>
  406. </td>
  407. <td class="description last">
  408. <p>The index into the buffer attribute.</p>
  409. </td>
  410. </tr>
  411. </tbody>
  412. </table>
  413. <dl class="details">
  414. <dt class="tag-returns"><strong>Returns:</strong> The x component.</dt>
  415. </dl>
  416. </div>
  417. <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>
  418. <div class="method">
  419. <div class="description">
  420. <p>Returns the y component of the vector at the given index.</p>
  421. </div>
  422. <table class="params">
  423. <tbody>
  424. <tr>
  425. <td class="name">
  426. <strong translate="no">index</strong>
  427. </td>
  428. <td class="description last">
  429. <p>The index into the buffer attribute.</p>
  430. </td>
  431. </tr>
  432. </tbody>
  433. </table>
  434. <dl class="details">
  435. <dt class="tag-returns"><strong>Returns:</strong> The y component.</dt>
  436. </dl>
  437. </div>
  438. <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>
  439. <div class="method">
  440. <div class="description">
  441. <p>Returns the z component of the vector at the given index.</p>
  442. </div>
  443. <table class="params">
  444. <tbody>
  445. <tr>
  446. <td class="name">
  447. <strong translate="no">index</strong>
  448. </td>
  449. <td class="description last">
  450. <p>The index into the buffer attribute.</p>
  451. </td>
  452. </tr>
  453. </tbody>
  454. </table>
  455. <dl class="details">
  456. <dt class="tag-returns"><strong>Returns:</strong> The z component.</dt>
  457. </dl>
  458. </div>
  459. <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>
  460. <div class="method">
  461. <div class="description">
  462. <p>Sets the given callback function that is executed after the Renderer has transferred
  463. the attribute array data to the GPU. Can be used to perform clean-up operations after
  464. the upload when attribute data are not needed anymore on the CPU side.</p>
  465. </div>
  466. <table class="params">
  467. <tbody>
  468. <tr>
  469. <td class="name">
  470. <strong translate="no">callback</strong>
  471. </td>
  472. <td class="description last">
  473. <p>The <code>onUpload()</code> callback.</p>
  474. </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="onUploadCallback" translate="no">.<a href="#onUploadCallback">onUploadCallback</a><span class="signature">()</span> </h3>
  483. <div class="method">
  484. <div class="description">
  485. <p>A callback function that is executed after the renderer has transferred the attribute
  486. array data to the GPU.</p>
  487. </div>
  488. </div>
  489. <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>
  490. <div class="method">
  491. <div class="description">
  492. <p>Sets the given array data in the buffer attribute.</p>
  493. </div>
  494. <table class="params">
  495. <tbody>
  496. <tr>
  497. <td class="name">
  498. <strong translate="no">value</strong>
  499. </td>
  500. <td class="description last">
  501. <p>The array data to set.</p>
  502. </td>
  503. </tr>
  504. <tr>
  505. <td class="name">
  506. <strong translate="no">offset</strong>
  507. </td>
  508. <td class="description last">
  509. <p>The offset in this buffer attribute's array.</p>
  510. <p>Default is <code>0</code>.</p>
  511. </td>
  512. </tr>
  513. </tbody>
  514. </table>
  515. <dl class="details">
  516. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  517. </dl>
  518. </div>
  519. <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>
  520. <div class="method">
  521. <div class="description">
  522. <p>Sets the given value to the given component of the vector at the given index.</p>
  523. </div>
  524. <table class="params">
  525. <tbody>
  526. <tr>
  527. <td class="name">
  528. <strong translate="no">index</strong>
  529. </td>
  530. <td class="description last">
  531. <p>The index into the buffer attribute.</p>
  532. </td>
  533. </tr>
  534. <tr>
  535. <td class="name">
  536. <strong translate="no">component</strong>
  537. </td>
  538. <td class="description last">
  539. <p>The component index.</p>
  540. </td>
  541. </tr>
  542. <tr>
  543. <td class="name">
  544. <strong translate="no">value</strong>
  545. </td>
  546. <td class="description last">
  547. <p>The value to set.</p>
  548. </td>
  549. </tr>
  550. </tbody>
  551. </table>
  552. <dl class="details">
  553. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  554. </dl>
  555. </div>
  556. <h3 class="name name-method" id="setUsage" translate="no">.<a href="#setUsage">setUsage</a><span class="signature">( value : <span class="param-type"><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> )</span><span class="type-signature"> : <a href="BufferAttribute.html">BufferAttribute</a></span> </h3>
  557. <div class="method">
  558. <div class="description">
  559. <p>Sets the usage of this buffer attribute.</p>
  560. </div>
  561. <table class="params">
  562. <tbody>
  563. <tr>
  564. <td class="name">
  565. <strong translate="no">value</strong>
  566. </td>
  567. <td class="description last">
  568. <p>The usage to set.</p>
  569. </td>
  570. </tr>
  571. </tbody>
  572. </table>
  573. <dl class="details">
  574. <dt class="tag-returns"><strong>Returns:</strong> A reference to this buffer attribute.</dt>
  575. </dl>
  576. </div>
  577. <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>
  578. <div class="method">
  579. <div class="description">
  580. <p>Sets the w component of the vector at the given index.</p>
  581. </div>
  582. <table class="params">
  583. <tbody>
  584. <tr>
  585. <td class="name">
  586. <strong translate="no">index</strong>
  587. </td>
  588. <td class="description last">
  589. <p>The index into the buffer attribute.</p>
  590. </td>
  591. </tr>
  592. <tr>
  593. <td class="name">
  594. <strong translate="no">w</strong>
  595. </td>
  596. <td class="description last">
  597. <p>The value to set.</p>
  598. </td>
  599. </tr>
  600. </tbody>
  601. </table>
  602. <dl class="details">
  603. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  604. </dl>
  605. </div>
  606. <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>
  607. <div class="method">
  608. <div class="description">
  609. <p>Sets the x component of the vector at the given index.</p>
  610. </div>
  611. <table class="params">
  612. <tbody>
  613. <tr>
  614. <td class="name">
  615. <strong translate="no">index</strong>
  616. </td>
  617. <td class="description last">
  618. <p>The index into the buffer attribute.</p>
  619. </td>
  620. </tr>
  621. <tr>
  622. <td class="name">
  623. <strong translate="no">x</strong>
  624. </td>
  625. <td class="description last">
  626. <p>The value to set.</p>
  627. </td>
  628. </tr>
  629. </tbody>
  630. </table>
  631. <dl class="details">
  632. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  633. </dl>
  634. </div>
  635. <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>
  636. <div class="method">
  637. <div class="description">
  638. <p>Sets the x and y component of the vector at the given index.</p>
  639. </div>
  640. <table class="params">
  641. <tbody>
  642. <tr>
  643. <td class="name">
  644. <strong translate="no">index</strong>
  645. </td>
  646. <td class="description last">
  647. <p>The index into the buffer attribute.</p>
  648. </td>
  649. </tr>
  650. <tr>
  651. <td class="name">
  652. <strong translate="no">x</strong>
  653. </td>
  654. <td class="description last">
  655. <p>The value for the x component to set.</p>
  656. </td>
  657. </tr>
  658. <tr>
  659. <td class="name">
  660. <strong translate="no">y</strong>
  661. </td>
  662. <td class="description last">
  663. <p>The value for the y component to set.</p>
  664. </td>
  665. </tr>
  666. </tbody>
  667. </table>
  668. <dl class="details">
  669. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  670. </dl>
  671. </div>
  672. <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>
  673. <div class="method">
  674. <div class="description">
  675. <p>Sets the x, y and z component of the vector at the given index.</p>
  676. </div>
  677. <table class="params">
  678. <tbody>
  679. <tr>
  680. <td class="name">
  681. <strong translate="no">index</strong>
  682. </td>
  683. <td class="description last">
  684. <p>The index into the buffer attribute.</p>
  685. </td>
  686. </tr>
  687. <tr>
  688. <td class="name">
  689. <strong translate="no">x</strong>
  690. </td>
  691. <td class="description last">
  692. <p>The value for the x component to set.</p>
  693. </td>
  694. </tr>
  695. <tr>
  696. <td class="name">
  697. <strong translate="no">y</strong>
  698. </td>
  699. <td class="description last">
  700. <p>The value for the y component to set.</p>
  701. </td>
  702. </tr>
  703. <tr>
  704. <td class="name">
  705. <strong translate="no">z</strong>
  706. </td>
  707. <td class="description last">
  708. <p>The value for the z component to set.</p>
  709. </td>
  710. </tr>
  711. </tbody>
  712. </table>
  713. <dl class="details">
  714. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  715. </dl>
  716. </div>
  717. <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>
  718. <div class="method">
  719. <div class="description">
  720. <p>Sets the x, y, z and w component of the vector at the given index.</p>
  721. </div>
  722. <table class="params">
  723. <tbody>
  724. <tr>
  725. <td class="name">
  726. <strong translate="no">index</strong>
  727. </td>
  728. <td class="description last">
  729. <p>The index into the buffer attribute.</p>
  730. </td>
  731. </tr>
  732. <tr>
  733. <td class="name">
  734. <strong translate="no">x</strong>
  735. </td>
  736. <td class="description last">
  737. <p>The value for the x component to set.</p>
  738. </td>
  739. </tr>
  740. <tr>
  741. <td class="name">
  742. <strong translate="no">y</strong>
  743. </td>
  744. <td class="description last">
  745. <p>The value for the y component to set.</p>
  746. </td>
  747. </tr>
  748. <tr>
  749. <td class="name">
  750. <strong translate="no">z</strong>
  751. </td>
  752. <td class="description last">
  753. <p>The value for the z component to set.</p>
  754. </td>
  755. </tr>
  756. <tr>
  757. <td class="name">
  758. <strong translate="no">w</strong>
  759. </td>
  760. <td class="description last">
  761. <p>The value for the w component to set.</p>
  762. </td>
  763. </tr>
  764. </tbody>
  765. </table>
  766. <dl class="details">
  767. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  768. </dl>
  769. </div>
  770. <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>
  771. <div class="method">
  772. <div class="description">
  773. <p>Sets the y component of the vector at the given index.</p>
  774. </div>
  775. <table class="params">
  776. <tbody>
  777. <tr>
  778. <td class="name">
  779. <strong translate="no">index</strong>
  780. </td>
  781. <td class="description last">
  782. <p>The index into the buffer attribute.</p>
  783. </td>
  784. </tr>
  785. <tr>
  786. <td class="name">
  787. <strong translate="no">y</strong>
  788. </td>
  789. <td class="description last">
  790. <p>The value to set.</p>
  791. </td>
  792. </tr>
  793. </tbody>
  794. </table>
  795. <dl class="details">
  796. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  797. </dl>
  798. </div>
  799. <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>
  800. <div class="method">
  801. <div class="description">
  802. <p>Sets the z component of the vector at the given index.</p>
  803. </div>
  804. <table class="params">
  805. <tbody>
  806. <tr>
  807. <td class="name">
  808. <strong translate="no">index</strong>
  809. </td>
  810. <td class="description last">
  811. <p>The index into the buffer attribute.</p>
  812. </td>
  813. </tr>
  814. <tr>
  815. <td class="name">
  816. <strong translate="no">z</strong>
  817. </td>
  818. <td class="description last">
  819. <p>The value to set.</p>
  820. </td>
  821. </tr>
  822. </tbody>
  823. </table>
  824. <dl class="details">
  825. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  826. </dl>
  827. </div>
  828. <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>
  829. <div class="method">
  830. <div class="description">
  831. <p>Serializes the buffer attribute into JSON.</p>
  832. </div>
  833. <dl class="details">
  834. <dt class="tag-returns"><strong>Returns:</strong> A JSON object representing the serialized buffer attribute.</dt>
  835. </dl>
  836. </div>
  837. <h3 class="name name-method" id="transformDirection" translate="no">.<a href="#transformDirection">transformDirection</a><span class="signature">( m : <span class="param-type"><a href="Matrix4.html">Matrix4</a></span> )</span><span class="type-signature"> : <a href="BufferAttribute.html">BufferAttribute</a></span> </h3>
  838. <div class="method">
  839. <div class="description">
  840. <p>Applies the given 4x4 matrix to the given attribute. Only works with
  841. item size <code>3</code> and with direction vectors.</p>
  842. </div>
  843. <table class="params">
  844. <tbody>
  845. <tr>
  846. <td class="name">
  847. <strong translate="no">m</strong>
  848. </td>
  849. <td class="description last">
  850. <p>The matrix to apply.</p>
  851. </td>
  852. </tr>
  853. </tbody>
  854. </table>
  855. <dl class="details">
  856. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  857. </dl>
  858. </div>
  859. <h2 class="subsection-title">Source</h2>
  860. <p>
  861. <a href="https://github.com/mrdoob/three.js/blob/master/src/core/BufferAttribute.js" translate="no" target="_blank" rel="noopener">src/core/BufferAttribute.js</a>
  862. </p>
  863. </article>
  864. </section>
  865. <script src="../scripts/linenumber.js"></script>
  866. <script src="../scripts/page.js"></script>
  867. </body>
  868. </html>
粤ICP备19079148号