UniformArrayNode.html 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>UniformArrayNode - 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> → <a href="BufferNode.html">BufferNode</a> → </p>
  13. <h1 translate="no">UniformArrayNode</h1>
  14. <section>
  15. <header>
  16. <div class="class-description"><p>Similar to <a href="BufferNode.html">BufferNode</a> this module represents array-like data as
  17. uniform buffers. Unlike <a href="BufferNode.html">BufferNode</a>, it can handle more common
  18. data types in the array (e.g <code>three.js</code> primitives) and automatically
  19. manage buffer padding. It should be the first choice when working with
  20. uniforms buffers.</p></div>
  21. <h2>Code Example</h2>
  22. <div translate="no"><pre><code class="language-js">const tintColors = uniformArray( [
  23. new Color( 1, 0, 0 ),
  24. new Color( 0, 1, 0 ),
  25. new Color( 0, 0, 1 )
  26. ], 'color' );
  27. const redColor = tintColors.element( 0 );</code></pre></div>
  28. </header>
  29. <article>
  30. <div class="container-overview">
  31. <h2>Constructor</h2>
  32. <h3 class="name name-method" id="UniformArrayNode" translate="no">new <a href="#UniformArrayNode">UniformArrayNode</a><span class="signature">( value : <span class="param-type">Array.&lt;any></span>, elementType : <span class="param-type">string</span> )</span> </h3>
  33. <div class="method">
  34. <div class="description">
  35. <p>Constructs a new uniform array node.</p>
  36. </div>
  37. <table class="params">
  38. <tbody>
  39. <tr>
  40. <td class="name"><code>value</code></td>
  41. <td class="description last"><p>Array holding the buffer data.</p></td>
  42. </tr>
  43. <tr>
  44. <td class="name"><code>elementType</code></td>
  45. <td class="description last"><p>The data type of a buffer element.<br/>Default is <code>null</code>.</p></td>
  46. </tr>
  47. </tbody>
  48. </table>
  49. </div>
  50. </div>
  51. <h2 class="subsection-title">Properties</h2>
  52. <div class="member">
  53. <h3 class="name" id="array" translate="no">.<a href="#array">array</a><span class="type-signature"> : Array.&lt;<a href="global.html#any">any</a>></span> </h3>
  54. <div class="description">
  55. <p>Array holding the buffer data. Unlike <a href="BufferNode.html">BufferNode</a>, the array can
  56. hold number primitives as well as three.js objects like vectors, matrices
  57. or colors.</p>
  58. </div>
  59. </div>
  60. <div class="member">
  61. <h3 class="name" id="elementType" translate="no">.<a href="#elementType">elementType</a><span class="type-signature"> : string</span> </h3>
  62. <div class="description">
  63. <p>The data type of an array element.</p>
  64. </div>
  65. </div>
  66. <div class="member">
  67. <h3 class="name" id="isArrayBufferNode" translate="no">.<a href="#isArrayBufferNode">isArrayBufferNode</a><span class="type-signature"> : boolean</span> <span class="type-signature">(readonly) </span></h3>
  68. <div class="description">
  69. <p>This flag can be used for type testing.<br/>Default is <code>true</code>.</p>
  70. </div>
  71. </div>
  72. <div class="member">
  73. <h3 class="name" id="paddedType" translate="no">.<a href="#paddedType">paddedType</a><span class="type-signature"> : string</span> </h3>
  74. <div class="description">
  75. <p>The padded type. Uniform buffers must conform to a certain buffer layout
  76. so a separate type is computed to ensure correct buffer size.</p>
  77. </div>
  78. </div>
  79. <div class="member">
  80. <h3 class="name" id="updateType" translate="no">.<a href="#updateType">updateType</a><span class="type-signature"> : string</span> </h3>
  81. <div class="description">
  82. <p>Overwritten since uniform array nodes are updated per render.<br/>Default is <code>'render'</code>.</p>
  83. </div>
  84. <dl class="details">
  85. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="BufferNode.html#updateType">BufferNode#updateType</a></dt>
  86. </dl>
  87. </div>
  88. <h2 class="subsection-title">Methods</h2>
  89. <h3 class="name name-method" id="element" translate="no">.<a href="#element">element</a><span class="signature">( indexNode : <span class="param-type">IndexNode</span> )</span><span class="type-signature"> : <a href="UniformArrayElementNode.html">UniformArrayElementNode</a></span> </h3>
  90. <div class="method">
  91. <div class="description">
  92. <p>Overwrites the default <code>element()</code> method to provide element access
  93. based on <a href="UniformArrayNode.html">UniformArrayNode</a>.</p>
  94. </div>
  95. <table class="params">
  96. <tbody>
  97. <tr>
  98. <td class="name"><code>indexNode</code></td>
  99. <td class="description last"><p>The index node.</p></td>
  100. </tr>
  101. </tbody>
  102. </table>
  103. <dl class="details">
  104. <dt class="tag-returns"><strong>Returns:</strong> </dt>
  105. </dl>
  106. </div>
  107. <h3 class="name name-method" id="getElementType" translate="no">.<a href="#getElementType">getElementType</a><span class="signature">( builder : <span class="param-type">NodeBuilder</span> )</span><span class="type-signature"> : string</span> </h3>
  108. <div class="method">
  109. <div class="description">
  110. <p>The data type of the array elements.</p>
  111. </div>
  112. <table class="params">
  113. <tbody>
  114. <tr>
  115. <td class="name"><code>builder</code></td>
  116. <td class="description last"><p>The current node builder.</p></td>
  117. </tr>
  118. </tbody>
  119. </table>
  120. <dl class="details">
  121. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="BufferNode.html#getElementType">BufferNode#getElementType</a></dt>
  122. </dl>
  123. <dl class="details">
  124. <dt class="tag-returns"><strong>Returns:</strong> The element type.</dt>
  125. </dl>
  126. </div>
  127. <h3 class="name name-method" id="getNodeType" translate="no">.<a href="#getNodeType">getNodeType</a><span class="signature">( builder : <span class="param-type">NodeBuilder</span> )</span><span class="type-signature"> : string</span> </h3>
  128. <div class="method">
  129. <div class="description">
  130. <p>This method is overwritten since the node type is inferred from the
  131. <a href="UniformArrayNode.html#paddedType">UniformArrayNode#paddedType</a>.</p>
  132. </div>
  133. <table class="params">
  134. <tbody>
  135. <tr>
  136. <td class="name"><code>builder</code></td>
  137. <td class="description last"><p>The current node builder.</p></td>
  138. </tr>
  139. </tbody>
  140. </table>
  141. <dl class="details">
  142. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="BufferNode.html#getNodeType">BufferNode#getNodeType</a></dt>
  143. </dl>
  144. <dl class="details">
  145. <dt class="tag-returns"><strong>Returns:</strong> The node type.</dt>
  146. </dl>
  147. </div>
  148. <h3 class="name name-method" id="getPaddedType" translate="no">.<a href="#getPaddedType">getPaddedType</a><span class="signature">()</span><span class="type-signature"> : string</span> </h3>
  149. <div class="method">
  150. <div class="description">
  151. <p>Returns the padded type based on the element type.</p>
  152. </div>
  153. <dl class="details">
  154. <dt class="tag-returns"><strong>Returns:</strong> The padded type.</dt>
  155. </dl>
  156. </div>
  157. <h3 class="name name-method" id="setup" translate="no">.<a href="#setup">setup</a><span class="signature">( builder : <span class="param-type">NodeBuilder</span> )</span><span class="type-signature"> : null</span> </h3>
  158. <div class="method">
  159. <div class="description">
  160. <p>Implement the value buffer creation based on the array data.</p>
  161. </div>
  162. <table class="params">
  163. <tbody>
  164. <tr>
  165. <td class="name"><code>builder</code></td>
  166. <td class="description last"><p>A reference to the current node builder.</p></td>
  167. </tr>
  168. </tbody>
  169. </table>
  170. <dl class="details">
  171. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="BufferNode.html#setup">BufferNode#setup</a></dt>
  172. </dl>
  173. <dl class="details">
  174. <dt class="tag-returns"><strong>Returns:</strong> </dt>
  175. </dl>
  176. </div>
  177. <h3 class="name name-method" id="update" translate="no">.<a href="#update">update</a><span class="signature">( frame : <span class="param-type">NodeFrame</span> )</span> </h3>
  178. <div class="method">
  179. <div class="description">
  180. <p>The update makes sure to correctly transfer the data from the (complex) objects
  181. in the array to the internal, correctly padded value buffer.</p>
  182. </div>
  183. <table class="params">
  184. <tbody>
  185. <tr>
  186. <td class="name"><code>frame</code></td>
  187. <td class="description last"><p>A reference to the current node frame.</p></td>
  188. </tr>
  189. </tbody>
  190. </table>
  191. <dl class="details">
  192. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="BufferNode.html#update">BufferNode#update</a></dt>
  193. </dl>
  194. </div>
  195. <h2 class="subsection-title">Source</h2>
  196. <p>
  197. <a href="https://github.com/mrdoob/three.js/blob/master/src/nodes/accessors/UniformArrayNode.js" target="_blank" rel="noopener" translate="no">src/nodes/accessors/UniformArrayNode.js</a>
  198. </p>
  199. </article>
  200. </section>
  201. <script src="../scripts/linenumber.js"></script>
  202. <script src="../scripts/page.js"></script>
  203. </body>
  204. </html>
粤ICP备19079148号