BufferNode.html 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>BufferNode - 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. <p class="inheritance" translate="no"><a href="EventDispatcher.html">EventDispatcher</a> → <a href="Node.html">Node</a> → <a href="InputNode.html">InputNode</a> → <a href="UniformNode.html">UniformNode</a> → </p>
  13. <h1 translate="no">BufferNode</h1>
  14. <section>
  15. <header>
  16. <div class="class-description"><p>A special type of uniform node which represents array-like data
  17. as uniform buffers. The access usually happens via <code>element()</code>
  18. which returns an instance of <a href="ArrayElementNode.html">ArrayElementNode</a>. For example:</p>
  19. <p>In general, it is recommended to use the more managed <a href="UniformArrayNode.html">UniformArrayNode</a>
  20. since it handles more input types and automatically cares about buffer paddings.</p></div>
  21. <h2>Code Example</h2>
  22. <div translate="no"><pre><code class="language-js">const bufferNode = buffer( array, 'mat4', count );
  23. const matrixNode = bufferNode.element( index ); // access a matrix from the buffer
  24. </code></pre></div>
  25. </header>
  26. <article>
  27. <div class="container-overview">
  28. <h2>Constructor</h2>
  29. <h3 class="name name-method" id="BufferNode" translate="no">new <a href="#BufferNode">BufferNode</a><span class="signature">( value : <span class="param-type">Array.&lt;number></span>, bufferType : <span class="param-type">string</span>, bufferCount : <span class="param-type">number</span> )</span> </h3>
  30. <div class="method">
  31. <div class="description">
  32. <p>Constructs a new buffer node.</p>
  33. </div>
  34. <table class="params">
  35. <tbody>
  36. <tr>
  37. <td class="name">
  38. <strong>value</strong>
  39. </td>
  40. <td class="description last">
  41. <p>Array-like buffer data.</p>
  42. </td>
  43. </tr>
  44. <tr>
  45. <td class="name">
  46. <strong>bufferType</strong>
  47. </td>
  48. <td class="description last">
  49. <p>The data type of the buffer.</p>
  50. </td>
  51. </tr>
  52. <tr>
  53. <td class="name">
  54. <strong>bufferCount</strong>
  55. </td>
  56. <td class="description last">
  57. <p>The count of buffer elements.</p>
  58. <p>Default is <code>0</code>.</p>
  59. </td>
  60. </tr>
  61. </tbody>
  62. </table>
  63. </div>
  64. </div>
  65. <h2 class="subsection-title">Properties</h2>
  66. <div class="member">
  67. <h3 class="name" id="bufferCount" translate="no">.<a href="#bufferCount">bufferCount</a><span class="type-signature"> : number</span> </h3>
  68. <div class="description">
  69. <p>The uniform node that holds the value of the reference node.</p>
  70. <p>Default is <code>0</code>.</p>
  71. </div>
  72. </div>
  73. <div class="member">
  74. <h3 class="name" id="bufferType" translate="no">.<a href="#bufferType">bufferType</a><span class="type-signature"> : string</span> </h3>
  75. <div class="description">
  76. <p>The data type of the buffer.</p>
  77. </div>
  78. </div>
  79. <div class="member">
  80. <h3 class="name" id="isBufferNode" translate="no">.<a href="#isBufferNode">isBufferNode</a><span class="type-signature"> : boolean</span> <span class="type-signature">(readonly) </span></h3>
  81. <div class="description">
  82. <p>This flag can be used for type testing.</p>
  83. <p>Default is <code>true</code>.</p>
  84. </div>
  85. </div>
  86. <div class="member">
  87. <h3 class="name" id="updateRanges" translate="no">.<a href="#updateRanges">updateRanges</a><span class="type-signature"> : Array.&lt;{start: number, count: number}></span> </h3>
  88. <div class="description">
  89. <p>An array of update ranges.</p>
  90. </div>
  91. </div>
  92. <h2 class="subsection-title">Methods</h2>
  93. <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>
  94. <div class="method">
  95. <div class="description">
  96. <p>Adds a range of data in the data array to be updated on the GPU.</p>
  97. </div>
  98. <table class="params">
  99. <tbody>
  100. <tr>
  101. <td class="name">
  102. <strong>start</strong>
  103. </td>
  104. <td class="description last">
  105. <p>Position at which to start update.</p>
  106. </td>
  107. </tr>
  108. <tr>
  109. <td class="name">
  110. <strong>count</strong>
  111. </td>
  112. <td class="description last">
  113. <p>The number of components to update.</p>
  114. </td>
  115. </tr>
  116. </tbody>
  117. </table>
  118. </div>
  119. <h3 class="name name-method" id="clearUpdateRanges" translate="no">.<a href="#clearUpdateRanges">clearUpdateRanges</a><span class="signature">()</span> </h3>
  120. <div class="method">
  121. <div class="description">
  122. <p>Clears the update ranges.</p>
  123. </div>
  124. </div>
  125. <h3 class="name name-method" id="getElementType" translate="no">.<a href="#getElementType">getElementType</a><span class="signature">( builder : <span class="param-type"><a href="NodeBuilder.html">NodeBuilder</a></span> )</span><span class="type-signature"> : string</span> </h3>
  126. <div class="method">
  127. <div class="description">
  128. <p>The data type of the buffer elements.</p>
  129. </div>
  130. <table class="params">
  131. <tbody>
  132. <tr>
  133. <td class="name">
  134. <strong>builder</strong>
  135. </td>
  136. <td class="description last">
  137. <p>The current node builder.</p>
  138. </td>
  139. </tr>
  140. </tbody>
  141. </table>
  142. <dl class="details">
  143. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="UniformNode.html#getElementType">UniformNode#getElementType</a></dt>
  144. </dl>
  145. <dl class="details">
  146. <dt class="tag-returns"><strong>Returns:</strong> The element type.</dt>
  147. </dl>
  148. </div>
  149. <h3 class="name name-method" id="getInputType" translate="no">.<a href="#getInputType">getInputType</a><span class="signature">( builder : <span class="param-type"><a href="NodeBuilder.html">NodeBuilder</a></span> )</span><span class="type-signature"> : string</span> </h3>
  150. <div class="method">
  151. <div class="description">
  152. <p>Overwrites the default implementation to return a fixed value <code>'buffer'</code>.</p>
  153. </div>
  154. <table class="params">
  155. <tbody>
  156. <tr>
  157. <td class="name">
  158. <strong>builder</strong>
  159. </td>
  160. <td class="description last">
  161. <p>The current node builder.</p>
  162. </td>
  163. </tr>
  164. </tbody>
  165. </table>
  166. <dl class="details">
  167. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="UniformNode.html#getInputType">UniformNode#getInputType</a></dt>
  168. </dl>
  169. <dl class="details">
  170. <dt class="tag-returns"><strong>Returns:</strong> The input type.</dt>
  171. </dl>
  172. </div>
  173. <h2 class="subsection-title">Source</h2>
  174. <p>
  175. <a href="https://github.com/mrdoob/three.js/blob/master/src/nodes/accessors/BufferNode.js" translate="no" target="_blank" rel="noopener">src/nodes/accessors/BufferNode.js</a>
  176. </p>
  177. </article>
  178. </section>
  179. <script src="../scripts/linenumber.js"></script>
  180. <script src="../scripts/page.js"></script>
  181. </body>
  182. </html>
粤ICP备19079148号