1
0

UniformArrayNode.html 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  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;<a href="global.html#any">any</a>></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">
  41. <strong>value</strong>
  42. </td>
  43. <td class="description last">
  44. <p>Array holding the buffer data.</p>
  45. </td>
  46. </tr>
  47. <tr>
  48. <td class="name">
  49. <strong>elementType</strong>
  50. </td>
  51. <td class="description last">
  52. <p>The data type of a buffer element.</p>
  53. <p>Default is <code>null</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"> : Array.&lt;<a href="global.html#any">any</a>></span> </h3>
  63. <div class="description">
  64. <p>Array holding the buffer data. Unlike <a href="BufferNode.html">BufferNode</a>, the array can
  65. hold number primitives as well as three.js objects like vectors, matrices
  66. or colors.</p>
  67. </div>
  68. </div>
  69. <div class="member">
  70. <h3 class="name" id="elementType" translate="no">.<a href="#elementType">elementType</a><span class="type-signature"> : string</span> </h3>
  71. <div class="description">
  72. <p>The data type of an array element.</p>
  73. </div>
  74. </div>
  75. <div class="member">
  76. <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>
  77. <div class="description">
  78. <p>This flag can be used for type testing.</p>
  79. <p>Default is <code>true</code>.</p>
  80. </div>
  81. </div>
  82. <div class="member">
  83. <h3 class="name" id="paddedType" translate="no">.<a href="#paddedType">paddedType</a><span class="type-signature"> : string</span> </h3>
  84. <div class="description">
  85. <p>The padded type. Uniform buffers must conform to a certain buffer layout
  86. so a separate type is computed to ensure correct buffer size.</p>
  87. </div>
  88. </div>
  89. <div class="member">
  90. <h3 class="name" id="updateType" translate="no">.<a href="#updateType">updateType</a><span class="type-signature"> : string</span> </h3>
  91. <div class="description">
  92. <p>Overwritten since uniform array nodes are updated per render.</p>
  93. <p>Default is <code>'render'</code>.</p>
  94. </div>
  95. <dl class="details">
  96. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="BufferNode.html#updateType">BufferNode#updateType</a></dt>
  97. </dl>
  98. </div>
  99. <h2 class="subsection-title">Methods</h2>
  100. <h3 class="name name-method" id="element" translate="no">.<a href="#element">element</a><span class="signature">( indexNode : <span class="param-type"><a href="IndexNode.html">IndexNode</a></span> )</span><span class="type-signature"> : <a href="UniformArrayElementNode.html">UniformArrayElementNode</a></span> </h3>
  101. <div class="method">
  102. <div class="description">
  103. <p>Overwrites the default <code>element()</code> method to provide element access
  104. based on <a href="UniformArrayNode.html">UniformArrayNode</a>.</p>
  105. </div>
  106. <table class="params">
  107. <tbody>
  108. <tr>
  109. <td class="name">
  110. <strong>indexNode</strong>
  111. </td>
  112. <td class="description last">
  113. <p>The index node.</p>
  114. </td>
  115. </tr>
  116. </tbody>
  117. </table>
  118. </div>
  119. <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>
  120. <div class="method">
  121. <div class="description">
  122. <p>The data type of the array elements.</p>
  123. </div>
  124. <table class="params">
  125. <tbody>
  126. <tr>
  127. <td class="name">
  128. <strong>builder</strong>
  129. </td>
  130. <td class="description last">
  131. <p>The current node builder.</p>
  132. </td>
  133. </tr>
  134. </tbody>
  135. </table>
  136. <dl class="details">
  137. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="BufferNode.html#getElementType">BufferNode#getElementType</a></dt>
  138. </dl>
  139. <dl class="details">
  140. <dt class="tag-returns"><strong>Returns:</strong> The element type.</dt>
  141. </dl>
  142. </div>
  143. <h3 class="name name-method" id="getNodeType" translate="no">.<a href="#getNodeType">getNodeType</a><span class="signature">( builder : <span class="param-type"><a href="NodeBuilder.html">NodeBuilder</a></span> )</span><span class="type-signature"> : string</span> </h3>
  144. <div class="method">
  145. <div class="description">
  146. <p>This method is overwritten since the node type is inferred from the
  147. <a href="UniformArrayNode.html#paddedType">UniformArrayNode#paddedType</a>.</p>
  148. </div>
  149. <table class="params">
  150. <tbody>
  151. <tr>
  152. <td class="name">
  153. <strong>builder</strong>
  154. </td>
  155. <td class="description last">
  156. <p>The current node builder.</p>
  157. </td>
  158. </tr>
  159. </tbody>
  160. </table>
  161. <dl class="details">
  162. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="BufferNode.html#getNodeType">BufferNode#getNodeType</a></dt>
  163. </dl>
  164. <dl class="details">
  165. <dt class="tag-returns"><strong>Returns:</strong> The node type.</dt>
  166. </dl>
  167. </div>
  168. <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>
  169. <div class="method">
  170. <div class="description">
  171. <p>Returns the padded type based on the element type.</p>
  172. </div>
  173. <dl class="details">
  174. <dt class="tag-returns"><strong>Returns:</strong> The padded type.</dt>
  175. </dl>
  176. </div>
  177. <h3 class="name name-method" id="setup" translate="no">.<a href="#setup">setup</a><span class="signature">( builder : <span class="param-type"><a href="NodeBuilder.html">NodeBuilder</a></span> )</span><span class="type-signature"> : null</span> </h3>
  178. <div class="method">
  179. <div class="description">
  180. <p>Implement the value buffer creation based on the array data.</p>
  181. </div>
  182. <table class="params">
  183. <tbody>
  184. <tr>
  185. <td class="name">
  186. <strong>builder</strong>
  187. </td>
  188. <td class="description last">
  189. <p>A reference to the current node builder.</p>
  190. </td>
  191. </tr>
  192. </tbody>
  193. </table>
  194. <dl class="details">
  195. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="BufferNode.html#setup">BufferNode#setup</a></dt>
  196. </dl>
  197. </div>
  198. <h3 class="name name-method" id="update" translate="no">.<a href="#update">update</a><span class="signature">( frame : <span class="param-type"><a href="NodeFrame.html">NodeFrame</a></span> )</span> </h3>
  199. <div class="method">
  200. <div class="description">
  201. <p>The update makes sure to correctly transfer the data from the (complex) objects
  202. in the array to the internal, correctly padded value buffer.</p>
  203. </div>
  204. <table class="params">
  205. <tbody>
  206. <tr>
  207. <td class="name">
  208. <strong>frame</strong>
  209. </td>
  210. <td class="description last">
  211. <p>A reference to the current node frame.</p>
  212. </td>
  213. </tr>
  214. </tbody>
  215. </table>
  216. <dl class="details">
  217. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="BufferNode.html#update">BufferNode#update</a></dt>
  218. </dl>
  219. </div>
  220. <h2 class="subsection-title">Source</h2>
  221. <p>
  222. <a href="https://github.com/mrdoob/three.js/blob/master/src/nodes/accessors/UniformArrayNode.js" translate="no" target="_blank" rel="noopener">src/nodes/accessors/UniformArrayNode.js</a>
  223. </p>
  224. </article>
  225. </section>
  226. <script src="../scripts/linenumber.js"></script>
  227. <script src="../scripts/page.js"></script>
  228. </body>
  229. </html>
粤ICP备19079148号