Uniform.html 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Uniform - 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">Uniform</h1>
  13. <section>
  14. <header>
  15. <div class="class-description"><p>Represents a uniform which is a global shader variable. They are passed to shader programs.</p>
  16. <p>When declaring a uniform of a <a href="ShaderMaterial.html">ShaderMaterial</a>, it is declared by value or by object.</p>
  17. <p>Since this class can only be used in context of <a href="ShaderMaterial.html">ShaderMaterial</a>, it is only supported
  18. in <a href="WebGLRenderer.html">WebGLRenderer</a>.</p></div>
  19. <h2>Code Example</h2>
  20. <div translate="no"><pre><code class="language-js">uniforms: {
  21. time: { value: 1.0 },
  22. resolution: new Uniform( new Vector2() )
  23. };
  24. </code></pre></div>
  25. </header>
  26. <article>
  27. <div class="container-overview">
  28. <h2>Constructor</h2>
  29. <h3 class="name name-method" id="Uniform" translate="no">new <a href="#Uniform">Uniform</a><span class="signature">( value : <span class="param-type"><a href="global.html#any">any</a></span> )</span> </h3>
  30. <div class="method">
  31. <div class="description">
  32. <p>Constructs a new uniform.</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>The uniform value.</p>
  42. </td>
  43. </tr>
  44. </tbody>
  45. </table>
  46. </div>
  47. </div>
  48. <h2 class="subsection-title">Properties</h2>
  49. <div class="member">
  50. <h3 class="name" id="boundary" translate="no">.<a href="#boundary">boundary</a><span class="type-signature"> : number</span> </h3>
  51. <div class="description">
  52. <p>Used to build the uniform buffer according to the STD140 layout.
  53. Derived uniforms will set this property to a data type specific
  54. value.</p>
  55. </div>
  56. </div>
  57. <div class="member">
  58. <h3 class="name" id="itemSize" translate="no">.<a href="#itemSize">itemSize</a><span class="type-signature"> : number</span> </h3>
  59. <div class="description">
  60. <p>The item size. Derived uniforms will set this property to a data
  61. type specific value.</p>
  62. </div>
  63. </div>
  64. <div class="member">
  65. <h3 class="name" id="name" translate="no">.<a href="#name">name</a><span class="type-signature"> : string</span> </h3>
  66. <div class="description">
  67. <p>The uniform's name.</p>
  68. </div>
  69. </div>
  70. <div class="member">
  71. <h3 class="name" id="offset" translate="no">.<a href="#offset">offset</a><span class="type-signature"> : number</span> </h3>
  72. <div class="description">
  73. <p>This property is set by <a href="UniformsGroup.html">UniformsGroup</a> and marks
  74. the start position in the uniform buffer.</p>
  75. </div>
  76. </div>
  77. <div class="member">
  78. <h3 class="name" id="value" translate="no">.<a href="#value">value</a><span class="type-signature"> : <a href="global.html#any">any</a></span> </h3>
  79. <div class="description">
  80. <p>The uniform value.</p>
  81. </div>
  82. </div>
  83. <div class="member">
  84. <h3 class="name" id="value" translate="no">.<a href="#value">value</a><span class="type-signature"> : <a href="global.html#any">any</a></span> </h3>
  85. <div class="description">
  86. <p>The uniform's value.</p>
  87. </div>
  88. </div>
  89. <h2 class="subsection-title">Methods</h2>
  90. <h3 class="name name-method" id="clone" translate="no">.<a href="#clone">clone</a><span class="signature">()</span><span class="type-signature"> : <a href="Uniform.html">Uniform</a></span> </h3>
  91. <div class="method">
  92. <div class="description">
  93. <p>Returns a new uniform with copied values from this instance.
  94. If the value has a <code>clone()</code> method, the value is cloned as well.</p>
  95. </div>
  96. <dl class="details">
  97. <dt class="tag-returns"><strong>Returns:</strong> A clone of this instance.</dt>
  98. </dl>
  99. </div>
  100. <h3 class="name name-method" id="getValue" translate="no">.<a href="#getValue">getValue</a><span class="signature">()</span><span class="type-signature"> : <a href="global.html#any">any</a></span> </h3>
  101. <div class="method">
  102. <div class="description">
  103. <p>Returns the uniform's value.</p>
  104. </div>
  105. <dl class="details">
  106. <dt class="tag-returns"><strong>Returns:</strong> The value.</dt>
  107. </dl>
  108. </div>
  109. <h3 class="name name-method" id="setValue" translate="no">.<a href="#setValue">setValue</a><span class="signature">( value : <span class="param-type"><a href="global.html#any">any</a></span> )</span> </h3>
  110. <div class="method">
  111. <div class="description">
  112. <p>Sets the uniform's value.</p>
  113. </div>
  114. <table class="params">
  115. <tbody>
  116. <tr>
  117. <td class="name">
  118. <strong>value</strong>
  119. </td>
  120. <td class="description last">
  121. <p>The value to set.</p>
  122. </td>
  123. </tr>
  124. </tbody>
  125. </table>
  126. </div>
  127. <h2 class="subsection-title">Source</h2>
  128. <p>
  129. <a href="https://github.com/mrdoob/three.js/blob/master/src/core/Uniform.js" translate="no" target="_blank" rel="noopener">src/core/Uniform.js</a>
  130. </p>
  131. </article>
  132. </section>
  133. <script src="../scripts/linenumber.js"></script>
  134. <script src="../scripts/page.js"></script>
  135. </body>
  136. </html>
粤ICP备19079148号