BufferAttribute.html 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862
  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>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>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>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>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>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>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>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>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>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>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>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>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>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="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>
  341. <div class="method">
  342. <div class="description">
  343. <p>Returns the given component of the vector at the given index.</p>
  344. </div>
  345. <table class="params">
  346. <tbody>
  347. <tr>
  348. <td class="name">
  349. <strong>index</strong>
  350. </td>
  351. <td class="description last">
  352. <p>The index into the buffer attribute.</p>
  353. </td>
  354. </tr>
  355. <tr>
  356. <td class="name">
  357. <strong>component</strong>
  358. </td>
  359. <td class="description last">
  360. <p>The component index.</p>
  361. </td>
  362. </tr>
  363. </tbody>
  364. </table>
  365. <dl class="details">
  366. <dt class="tag-returns"><strong>Returns:</strong> The returned value.</dt>
  367. </dl>
  368. </div>
  369. <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>
  370. <div class="method">
  371. <div class="description">
  372. <p>Returns the w component of the vector at the given index.</p>
  373. </div>
  374. <table class="params">
  375. <tbody>
  376. <tr>
  377. <td class="name">
  378. <strong>index</strong>
  379. </td>
  380. <td class="description last">
  381. <p>The index into the buffer attribute.</p>
  382. </td>
  383. </tr>
  384. </tbody>
  385. </table>
  386. <dl class="details">
  387. <dt class="tag-returns"><strong>Returns:</strong> The w component.</dt>
  388. </dl>
  389. </div>
  390. <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>
  391. <div class="method">
  392. <div class="description">
  393. <p>Returns the x component of the vector at the given index.</p>
  394. </div>
  395. <table class="params">
  396. <tbody>
  397. <tr>
  398. <td class="name">
  399. <strong>index</strong>
  400. </td>
  401. <td class="description last">
  402. <p>The index into the buffer attribute.</p>
  403. </td>
  404. </tr>
  405. </tbody>
  406. </table>
  407. <dl class="details">
  408. <dt class="tag-returns"><strong>Returns:</strong> The x component.</dt>
  409. </dl>
  410. </div>
  411. <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>
  412. <div class="method">
  413. <div class="description">
  414. <p>Returns the y component of the vector at the given index.</p>
  415. </div>
  416. <table class="params">
  417. <tbody>
  418. <tr>
  419. <td class="name">
  420. <strong>index</strong>
  421. </td>
  422. <td class="description last">
  423. <p>The index into the buffer attribute.</p>
  424. </td>
  425. </tr>
  426. </tbody>
  427. </table>
  428. <dl class="details">
  429. <dt class="tag-returns"><strong>Returns:</strong> The y component.</dt>
  430. </dl>
  431. </div>
  432. <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>
  433. <div class="method">
  434. <div class="description">
  435. <p>Returns the z component of the vector at the given index.</p>
  436. </div>
  437. <table class="params">
  438. <tbody>
  439. <tr>
  440. <td class="name">
  441. <strong>index</strong>
  442. </td>
  443. <td class="description last">
  444. <p>The index into the buffer attribute.</p>
  445. </td>
  446. </tr>
  447. </tbody>
  448. </table>
  449. <dl class="details">
  450. <dt class="tag-returns"><strong>Returns:</strong> The z component.</dt>
  451. </dl>
  452. </div>
  453. <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>
  454. <div class="method">
  455. <div class="description">
  456. <p>Sets the given callback function that is executed after the Renderer has transferred
  457. the attribute array data to the GPU. Can be used to perform clean-up operations after
  458. the upload when attribute data are not needed anymore on the CPU side.</p>
  459. </div>
  460. <table class="params">
  461. <tbody>
  462. <tr>
  463. <td class="name">
  464. <strong>callback</strong>
  465. </td>
  466. <td class="description last">
  467. <p>The <code>onUpload()</code> callback.</p>
  468. </td>
  469. </tr>
  470. </tbody>
  471. </table>
  472. <dl class="details">
  473. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  474. </dl>
  475. </div>
  476. <h3 class="name name-method" id="onUploadCallback" translate="no">.<a href="#onUploadCallback">onUploadCallback</a><span class="signature">()</span> </h3>
  477. <div class="method">
  478. <div class="description">
  479. <p>A callback function that is executed after the renderer has transferred the attribute
  480. array data to the GPU.</p>
  481. </div>
  482. </div>
  483. <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>
  484. <div class="method">
  485. <div class="description">
  486. <p>Sets the given array data in the buffer attribute.</p>
  487. </div>
  488. <table class="params">
  489. <tbody>
  490. <tr>
  491. <td class="name">
  492. <strong>value</strong>
  493. </td>
  494. <td class="description last">
  495. <p>The array data to set.</p>
  496. </td>
  497. </tr>
  498. <tr>
  499. <td class="name">
  500. <strong>offset</strong>
  501. </td>
  502. <td class="description last">
  503. <p>The offset in this buffer attribute's array.</p>
  504. <p>Default is <code>0</code>.</p>
  505. </td>
  506. </tr>
  507. </tbody>
  508. </table>
  509. <dl class="details">
  510. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  511. </dl>
  512. </div>
  513. <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>
  514. <div class="method">
  515. <div class="description">
  516. <p>Sets the given value to the given component of the vector at the given index.</p>
  517. </div>
  518. <table class="params">
  519. <tbody>
  520. <tr>
  521. <td class="name">
  522. <strong>index</strong>
  523. </td>
  524. <td class="description last">
  525. <p>The index into the buffer attribute.</p>
  526. </td>
  527. </tr>
  528. <tr>
  529. <td class="name">
  530. <strong>component</strong>
  531. </td>
  532. <td class="description last">
  533. <p>The component index.</p>
  534. </td>
  535. </tr>
  536. <tr>
  537. <td class="name">
  538. <strong>value</strong>
  539. </td>
  540. <td class="description last">
  541. <p>The value to set.</p>
  542. </td>
  543. </tr>
  544. </tbody>
  545. </table>
  546. <dl class="details">
  547. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  548. </dl>
  549. </div>
  550. <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>
  551. <div class="method">
  552. <div class="description">
  553. <p>Sets the usage of this buffer attribute.</p>
  554. </div>
  555. <table class="params">
  556. <tbody>
  557. <tr>
  558. <td class="name">
  559. <strong>value</strong>
  560. </td>
  561. <td class="description last">
  562. <p>The usage to set.</p>
  563. </td>
  564. </tr>
  565. </tbody>
  566. </table>
  567. <dl class="details">
  568. <dt class="tag-returns"><strong>Returns:</strong> A reference to this buffer attribute.</dt>
  569. </dl>
  570. </div>
  571. <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>
  572. <div class="method">
  573. <div class="description">
  574. <p>Sets the w component of the vector at the given index.</p>
  575. </div>
  576. <table class="params">
  577. <tbody>
  578. <tr>
  579. <td class="name">
  580. <strong>index</strong>
  581. </td>
  582. <td class="description last">
  583. <p>The index into the buffer attribute.</p>
  584. </td>
  585. </tr>
  586. <tr>
  587. <td class="name">
  588. <strong>w</strong>
  589. </td>
  590. <td class="description last">
  591. <p>The value to set.</p>
  592. </td>
  593. </tr>
  594. </tbody>
  595. </table>
  596. <dl class="details">
  597. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  598. </dl>
  599. </div>
  600. <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>
  601. <div class="method">
  602. <div class="description">
  603. <p>Sets the x component of the vector at the given index.</p>
  604. </div>
  605. <table class="params">
  606. <tbody>
  607. <tr>
  608. <td class="name">
  609. <strong>index</strong>
  610. </td>
  611. <td class="description last">
  612. <p>The index into the buffer attribute.</p>
  613. </td>
  614. </tr>
  615. <tr>
  616. <td class="name">
  617. <strong>x</strong>
  618. </td>
  619. <td class="description last">
  620. <p>The value to set.</p>
  621. </td>
  622. </tr>
  623. </tbody>
  624. </table>
  625. <dl class="details">
  626. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  627. </dl>
  628. </div>
  629. <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>
  630. <div class="method">
  631. <div class="description">
  632. <p>Sets the x and y component of the vector at the given index.</p>
  633. </div>
  634. <table class="params">
  635. <tbody>
  636. <tr>
  637. <td class="name">
  638. <strong>index</strong>
  639. </td>
  640. <td class="description last">
  641. <p>The index into the buffer attribute.</p>
  642. </td>
  643. </tr>
  644. <tr>
  645. <td class="name">
  646. <strong>x</strong>
  647. </td>
  648. <td class="description last">
  649. <p>The value for the x component to set.</p>
  650. </td>
  651. </tr>
  652. <tr>
  653. <td class="name">
  654. <strong>y</strong>
  655. </td>
  656. <td class="description last">
  657. <p>The value for the y component to set.</p>
  658. </td>
  659. </tr>
  660. </tbody>
  661. </table>
  662. <dl class="details">
  663. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  664. </dl>
  665. </div>
  666. <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>
  667. <div class="method">
  668. <div class="description">
  669. <p>Sets the x, y and z component of the vector at the given index.</p>
  670. </div>
  671. <table class="params">
  672. <tbody>
  673. <tr>
  674. <td class="name">
  675. <strong>index</strong>
  676. </td>
  677. <td class="description last">
  678. <p>The index into the buffer attribute.</p>
  679. </td>
  680. </tr>
  681. <tr>
  682. <td class="name">
  683. <strong>x</strong>
  684. </td>
  685. <td class="description last">
  686. <p>The value for the x component to set.</p>
  687. </td>
  688. </tr>
  689. <tr>
  690. <td class="name">
  691. <strong>y</strong>
  692. </td>
  693. <td class="description last">
  694. <p>The value for the y component to set.</p>
  695. </td>
  696. </tr>
  697. <tr>
  698. <td class="name">
  699. <strong>z</strong>
  700. </td>
  701. <td class="description last">
  702. <p>The value for the z component to set.</p>
  703. </td>
  704. </tr>
  705. </tbody>
  706. </table>
  707. <dl class="details">
  708. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  709. </dl>
  710. </div>
  711. <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>
  712. <div class="method">
  713. <div class="description">
  714. <p>Sets the x, y, z and w component of the vector at the given index.</p>
  715. </div>
  716. <table class="params">
  717. <tbody>
  718. <tr>
  719. <td class="name">
  720. <strong>index</strong>
  721. </td>
  722. <td class="description last">
  723. <p>The index into the buffer attribute.</p>
  724. </td>
  725. </tr>
  726. <tr>
  727. <td class="name">
  728. <strong>x</strong>
  729. </td>
  730. <td class="description last">
  731. <p>The value for the x component to set.</p>
  732. </td>
  733. </tr>
  734. <tr>
  735. <td class="name">
  736. <strong>y</strong>
  737. </td>
  738. <td class="description last">
  739. <p>The value for the y component to set.</p>
  740. </td>
  741. </tr>
  742. <tr>
  743. <td class="name">
  744. <strong>z</strong>
  745. </td>
  746. <td class="description last">
  747. <p>The value for the z component to set.</p>
  748. </td>
  749. </tr>
  750. <tr>
  751. <td class="name">
  752. <strong>w</strong>
  753. </td>
  754. <td class="description last">
  755. <p>The value for the w component to set.</p>
  756. </td>
  757. </tr>
  758. </tbody>
  759. </table>
  760. <dl class="details">
  761. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  762. </dl>
  763. </div>
  764. <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>
  765. <div class="method">
  766. <div class="description">
  767. <p>Sets the y component of the vector at the given index.</p>
  768. </div>
  769. <table class="params">
  770. <tbody>
  771. <tr>
  772. <td class="name">
  773. <strong>index</strong>
  774. </td>
  775. <td class="description last">
  776. <p>The index into the buffer attribute.</p>
  777. </td>
  778. </tr>
  779. <tr>
  780. <td class="name">
  781. <strong>y</strong>
  782. </td>
  783. <td class="description last">
  784. <p>The value to set.</p>
  785. </td>
  786. </tr>
  787. </tbody>
  788. </table>
  789. <dl class="details">
  790. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  791. </dl>
  792. </div>
  793. <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>
  794. <div class="method">
  795. <div class="description">
  796. <p>Sets the z component of the vector at the given index.</p>
  797. </div>
  798. <table class="params">
  799. <tbody>
  800. <tr>
  801. <td class="name">
  802. <strong>index</strong>
  803. </td>
  804. <td class="description last">
  805. <p>The index into the buffer attribute.</p>
  806. </td>
  807. </tr>
  808. <tr>
  809. <td class="name">
  810. <strong>z</strong>
  811. </td>
  812. <td class="description last">
  813. <p>The value to set.</p>
  814. </td>
  815. </tr>
  816. </tbody>
  817. </table>
  818. <dl class="details">
  819. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  820. </dl>
  821. </div>
  822. <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>
  823. <div class="method">
  824. <div class="description">
  825. <p>Serializes the buffer attribute into JSON.</p>
  826. </div>
  827. <dl class="details">
  828. <dt class="tag-returns"><strong>Returns:</strong> A JSON object representing the serialized buffer attribute.</dt>
  829. </dl>
  830. </div>
  831. <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>
  832. <div class="method">
  833. <div class="description">
  834. <p>Applies the given 4x4 matrix to the given attribute. Only works with
  835. item size <code>3</code> and with direction vectors.</p>
  836. </div>
  837. <table class="params">
  838. <tbody>
  839. <tr>
  840. <td class="name">
  841. <strong>m</strong>
  842. </td>
  843. <td class="description last">
  844. <p>The matrix to apply.</p>
  845. </td>
  846. </tr>
  847. </tbody>
  848. </table>
  849. <dl class="details">
  850. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  851. </dl>
  852. </div>
  853. <h2 class="subsection-title">Source</h2>
  854. <p>
  855. <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>
  856. </p>
  857. </article>
  858. </section>
  859. <script src="../scripts/linenumber.js"></script>
  860. <script src="../scripts/page.js"></script>
  861. </body>
  862. </html>
粤ICP备19079148号