InterleavedBuffer.html 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>InterleavedBuffer - 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">InterleavedBuffer</h1>
  13. <section>
  14. <header>
  15. <div class="class-description"><p>&quot;Interleaved&quot; means that multiple attributes, possibly of different types,
  16. (e.g., position, normal, uv, color) are packed into a single array buffer.</p>
  17. <p>An introduction into interleaved arrays can be found here: <a href="https://blog.tojicode.com/2011/05/interleaved-array-basics.html" target="_blank" rel="noopener">Interleaved array basics</a></p></div>
  18. </header>
  19. <article>
  20. <div class="container-overview">
  21. <h2>Constructor</h2>
  22. <h3 class="name name-method" id="InterleavedBuffer" translate="no">new <a href="#InterleavedBuffer">InterleavedBuffer</a><span class="signature">( array : <span class="param-type">TypedArray</span>, stride : <span class="param-type">number</span> )</span> </h3>
  23. <div class="method">
  24. <div class="description">
  25. <p>Constructs a new interleaved buffer.</p>
  26. </div>
  27. <table class="params">
  28. <tbody>
  29. <tr>
  30. <td class="name">
  31. <strong>array</strong>
  32. </td>
  33. <td class="description last">
  34. <p>A typed array with a shared buffer storing attribute data.</p>
  35. </td>
  36. </tr>
  37. <tr>
  38. <td class="name">
  39. <strong>stride</strong>
  40. </td>
  41. <td class="description last">
  42. <p>The number of typed-array elements per vertex.</p>
  43. </td>
  44. </tr>
  45. </tbody>
  46. </table>
  47. </div>
  48. </div>
  49. <h2 class="subsection-title">Properties</h2>
  50. <div class="member">
  51. <h3 class="name" id="array" translate="no">.<a href="#array">array</a><span class="type-signature"> : TypedArray</span> </h3>
  52. <div class="description">
  53. <p>A typed array with a shared buffer storing attribute data.</p>
  54. </div>
  55. </div>
  56. <div class="member">
  57. <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>
  58. <div class="description">
  59. <p>The total number of elements in the array</p>
  60. </div>
  61. </div>
  62. <div class="member">
  63. <h3 class="name" id="isInterleavedBuffer" translate="no">.<a href="#isInterleavedBuffer">isInterleavedBuffer</a><span class="type-signature"> : boolean</span> <span class="type-signature">(readonly) </span></h3>
  64. <div class="description">
  65. <p>This flag can be used for type testing.</p>
  66. <p>Default is <code>true</code>.</p>
  67. </div>
  68. </div>
  69. <div class="member">
  70. <h3 class="name" id="needsUpdate" translate="no">.<a href="#needsUpdate">needsUpdate</a><span class="type-signature"> : number</span> </h3>
  71. <div class="description">
  72. <p>Flag to indicate that this attribute has changed and should be re-sent to
  73. the GPU. Set this to <code>true</code> when you modify the value of the array.</p>
  74. <p>Default is <code>false</code>.</p>
  75. </div>
  76. </div>
  77. <div class="member">
  78. <h3 class="name" id="stride" translate="no">.<a href="#stride">stride</a><span class="type-signature"> : number</span> </h3>
  79. <div class="description">
  80. <p>The number of typed-array elements per vertex.</p>
  81. </div>
  82. </div>
  83. <div class="member">
  84. <h3 class="name" id="updateRanges" translate="no">.<a href="#updateRanges">updateRanges</a><span class="type-signature"> : Array.&lt;Object></span> </h3>
  85. <div class="description">
  86. <p>This can be used to only update some components of stored vectors (for example, just the
  87. component related to color). Use the <code>addUpdateRange()</code> function to add ranges to this array.</p>
  88. </div>
  89. </div>
  90. <div class="member">
  91. <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>
  92. <div class="description">
  93. <p>Defines the intended usage pattern of the data store for optimization purposes.</p>
  94. <p>Note: After the initial use of a buffer, its usage cannot be changed. Instead,
  95. instantiate a new one and set the desired usage before the next render.</p>
  96. <p>Default is <code>StaticDrawUsage</code>.</p>
  97. </div>
  98. </div>
  99. <div class="member">
  100. <h3 class="name" id="uuid" translate="no">.<a href="#uuid">uuid</a><span class="type-signature"> : string</span> <span class="type-signature">(readonly) </span></h3>
  101. <div class="description">
  102. <p>The UUID of the interleaved buffer.</p>
  103. </div>
  104. </div>
  105. <div class="member">
  106. <h3 class="name" id="version" translate="no">.<a href="#version">version</a><span class="type-signature"> : number</span> </h3>
  107. <div class="description">
  108. <p>A version number, incremented every time the <code>needsUpdate</code> is set to <code>true</code>.</p>
  109. </div>
  110. </div>
  111. <h2 class="subsection-title">Methods</h2>
  112. <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>
  113. <div class="method">
  114. <div class="description">
  115. <p>Adds a range of data in the data array to be updated on the GPU.</p>
  116. </div>
  117. <table class="params">
  118. <tbody>
  119. <tr>
  120. <td class="name">
  121. <strong>start</strong>
  122. </td>
  123. <td class="description last">
  124. <p>Position at which to start update.</p>
  125. </td>
  126. </tr>
  127. <tr>
  128. <td class="name">
  129. <strong>count</strong>
  130. </td>
  131. <td class="description last">
  132. <p>The number of components to update.</p>
  133. </td>
  134. </tr>
  135. </tbody>
  136. </table>
  137. </div>
  138. <h3 class="name name-method" id="clearUpdateRanges" translate="no">.<a href="#clearUpdateRanges">clearUpdateRanges</a><span class="signature">()</span> </h3>
  139. <div class="method">
  140. <div class="description">
  141. <p>Clears the update ranges.</p>
  142. </div>
  143. </div>
  144. <h3 class="name name-method" id="clone" translate="no">.<a href="#clone">clone</a><span class="signature">( data : <span class="param-type">Object</span> )</span><span class="type-signature"> : <a href="InterleavedBuffer.html">InterleavedBuffer</a></span> </h3>
  145. <div class="method">
  146. <div class="description">
  147. <p>Returns a new interleaved buffer with copied values from this instance.</p>
  148. </div>
  149. <table class="params">
  150. <tbody>
  151. <tr>
  152. <td class="name">
  153. <strong>data</strong>
  154. </td>
  155. <td class="description last">
  156. <p>An object with shared array buffers that allows to retain shared structures.</p>
  157. </td>
  158. </tr>
  159. </tbody>
  160. </table>
  161. <dl class="details">
  162. <dt class="tag-returns"><strong>Returns:</strong> A clone of this instance.</dt>
  163. </dl>
  164. </div>
  165. <h3 class="name name-method" id="copy" translate="no">.<a href="#copy">copy</a><span class="signature">( source : <span class="param-type"><a href="InterleavedBuffer.html">InterleavedBuffer</a></span> )</span><span class="type-signature"> : <a href="InterleavedBuffer.html">InterleavedBuffer</a></span> </h3>
  166. <div class="method">
  167. <div class="description">
  168. <p>Copies the values of the given interleaved buffer to this instance.</p>
  169. </div>
  170. <table class="params">
  171. <tbody>
  172. <tr>
  173. <td class="name">
  174. <strong>source</strong>
  175. </td>
  176. <td class="description last">
  177. <p>The interleaved buffer to copy.</p>
  178. </td>
  179. </tr>
  180. </tbody>
  181. </table>
  182. <dl class="details">
  183. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  184. </dl>
  185. </div>
  186. <h3 class="name name-method" id="copyAt" translate="no">.<a href="#copyAt">copyAt</a><span class="signature">( index1 : <span class="param-type">number</span>, interleavedBuffer : <span class="param-type"><a href="InterleavedBuffer.html">InterleavedBuffer</a></span>, index2 : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="InterleavedBuffer.html">InterleavedBuffer</a></span> </h3>
  187. <div class="method">
  188. <div class="description">
  189. <p>Copies a vector from the given interleaved buffer to this one. The start
  190. and destination position in the attribute buffers are represented by the
  191. given indices.</p>
  192. </div>
  193. <table class="params">
  194. <tbody>
  195. <tr>
  196. <td class="name">
  197. <strong>index1</strong>
  198. </td>
  199. <td class="description last">
  200. <p>The destination index into this interleaved buffer.</p>
  201. </td>
  202. </tr>
  203. <tr>
  204. <td class="name">
  205. <strong>interleavedBuffer</strong>
  206. </td>
  207. <td class="description last">
  208. <p>The interleaved buffer to copy from.</p>
  209. </td>
  210. </tr>
  211. <tr>
  212. <td class="name">
  213. <strong>index2</strong>
  214. </td>
  215. <td class="description last">
  216. <p>The source index into the given interleaved buffer.</p>
  217. </td>
  218. </tr>
  219. </tbody>
  220. </table>
  221. <dl class="details">
  222. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  223. </dl>
  224. </div>
  225. <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="InterleavedBuffer.html">InterleavedBuffer</a></span> </h3>
  226. <div class="method">
  227. <div class="description">
  228. <p>Sets the given callback function that is executed after the Renderer has transferred
  229. the array data to the GPU. Can be used to perform clean-up operations after
  230. the upload when data are not needed anymore on the CPU side.</p>
  231. </div>
  232. <table class="params">
  233. <tbody>
  234. <tr>
  235. <td class="name">
  236. <strong>callback</strong>
  237. </td>
  238. <td class="description last">
  239. <p>The <code>onUpload()</code> callback.</p>
  240. </td>
  241. </tr>
  242. </tbody>
  243. </table>
  244. <dl class="details">
  245. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  246. </dl>
  247. </div>
  248. <h3 class="name name-method" id="onUploadCallback" translate="no">.<a href="#onUploadCallback">onUploadCallback</a><span class="signature">()</span> </h3>
  249. <div class="method">
  250. <div class="description">
  251. <p>A callback function that is executed after the renderer has transferred the attribute array
  252. data to the GPU.</p>
  253. </div>
  254. </div>
  255. <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="InterleavedBuffer.html">InterleavedBuffer</a></span> </h3>
  256. <div class="method">
  257. <div class="description">
  258. <p>Sets the given array data in the interleaved buffer.</p>
  259. </div>
  260. <table class="params">
  261. <tbody>
  262. <tr>
  263. <td class="name">
  264. <strong>value</strong>
  265. </td>
  266. <td class="description last">
  267. <p>The array data to set.</p>
  268. </td>
  269. </tr>
  270. <tr>
  271. <td class="name">
  272. <strong>offset</strong>
  273. </td>
  274. <td class="description last">
  275. <p>The offset in this interleaved buffer's array.</p>
  276. <p>Default is <code>0</code>.</p>
  277. </td>
  278. </tr>
  279. </tbody>
  280. </table>
  281. <dl class="details">
  282. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  283. </dl>
  284. </div>
  285. <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="InterleavedBuffer.html">InterleavedBuffer</a></span> </h3>
  286. <div class="method">
  287. <div class="description">
  288. <p>Sets the usage of this interleaved buffer.</p>
  289. </div>
  290. <table class="params">
  291. <tbody>
  292. <tr>
  293. <td class="name">
  294. <strong>value</strong>
  295. </td>
  296. <td class="description last">
  297. <p>The usage to set.</p>
  298. </td>
  299. </tr>
  300. </tbody>
  301. </table>
  302. <dl class="details">
  303. <dt class="tag-returns"><strong>Returns:</strong> A reference to this interleaved buffer.</dt>
  304. </dl>
  305. </div>
  306. <h3 class="name name-method" id="toJSON" translate="no">.<a href="#toJSON">toJSON</a><span class="signature">( data : <span class="param-type">Object</span> )</span><span class="type-signature"> : Object</span> </h3>
  307. <div class="method">
  308. <div class="description">
  309. <p>Serializes the interleaved buffer into JSON.</p>
  310. </div>
  311. <table class="params">
  312. <tbody>
  313. <tr>
  314. <td class="name">
  315. <strong>data</strong>
  316. </td>
  317. <td class="description last">
  318. <p>An optional value holding meta information about the serialization.</p>
  319. </td>
  320. </tr>
  321. </tbody>
  322. </table>
  323. <dl class="details">
  324. <dt class="tag-returns"><strong>Returns:</strong> A JSON object representing the serialized interleaved buffer.</dt>
  325. </dl>
  326. </div>
  327. <h2 class="subsection-title">Source</h2>
  328. <p>
  329. <a href="https://github.com/mrdoob/three.js/blob/master/src/core/InterleavedBuffer.js" translate="no" target="_blank" rel="noopener">src/core/InterleavedBuffer.js</a>
  330. </p>
  331. </article>
  332. </section>
  333. <script src="../scripts/linenumber.js"></script>
  334. <script src="../scripts/page.js"></script>
  335. </body>
  336. </html>
粤ICP备19079148号