Lut.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Lut - 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">Lut</h1>
  13. <section>
  14. <header>
  15. <div class="class-description"><p>Represents a lookup table for colormaps. It is used to determine the color
  16. values from a range of data values.</p></div>
  17. <h2>Code Example</h2>
  18. <div translate="no"><pre><code class="language-js">const lut = new Lut( 'rainbow', 512 );
  19. const color = lut.getColor( 0.5 );
  20. </code></pre></div>
  21. </header>
  22. <article>
  23. <h2 class="subsection-title">Import</h2>
  24. <p><span translate="no">Lut</span> is an addon, and must be imported explicitly, see <a href="https://threejs.org/manual/#en/installation" target="_blank">Installation#Addons</a>.</p>
  25. <pre><code class="language-js">import { Lut } from 'three/addons/math/Lut.js';</code></pre>
  26. <div class="container-overview">
  27. <h2>Constructor</h2>
  28. <h3 class="name name-method" id="Lut" translate="no">new <a href="#Lut">Lut</a><span class="signature">( colormap : <span class="param-type">'rainbow' | 'cooltowarm' | 'blackbody' | 'grayscale'</span>, count : <span class="param-type">number</span> )</span> </h3>
  29. <div class="method">
  30. <div class="description">
  31. <p>Constructs a new Lut.</p>
  32. </div>
  33. <table class="params">
  34. <tbody>
  35. <tr>
  36. <td class="name"><code>colormap</code></td>
  37. <td class="description last"><p>Sets a colormap from predefined list of colormaps.<br/>Default is <code>'rainbow'</code>.</p></td>
  38. </tr>
  39. <tr>
  40. <td class="name"><code>count</code></td>
  41. <td class="description last"><p>Sets the number of colors used to represent the data array.<br/>Default is <code>32</code>.</p></td>
  42. </tr>
  43. </tbody>
  44. </table>
  45. </div>
  46. </div>
  47. <h2 class="subsection-title">Properties</h2>
  48. <div class="member">
  49. <h3 class="name" id="isLut" translate="no">.<a href="#isLut">isLut</a><span class="type-signature"> : boolean</span> <span class="type-signature">(readonly) </span></h3>
  50. <div class="description">
  51. <p>This flag can be used for type testing.<br/>Default is <code>true</code>.</p>
  52. </div>
  53. </div>
  54. <div class="member">
  55. <h3 class="name" id="lut" translate="no">.<a href="#lut">lut</a><span class="type-signature"> : Array.&lt;<a href="Color.html">Color</a>></span> </h3>
  56. <div class="description">
  57. <p>The lookup table for the selected color map</p>
  58. </div>
  59. </div>
  60. <div class="member">
  61. <h3 class="name" id="map" translate="no">.<a href="#map">map</a><span class="type-signature"> : Array.&lt;Array.&lt;number>></span> </h3>
  62. <div class="description">
  63. <p>The currently selected color map.</p>
  64. </div>
  65. </div>
  66. <div class="member">
  67. <h3 class="name" id="maxV" translate="no">.<a href="#maxV">maxV</a><span class="type-signature"> : number</span> </h3>
  68. <div class="description">
  69. <p>The maximum value to be represented with the lookup table.<br/>Default is <code>1</code>.</p>
  70. </div>
  71. </div>
  72. <div class="member">
  73. <h3 class="name" id="minV" translate="no">.<a href="#minV">minV</a><span class="type-signature"> : number</span> </h3>
  74. <div class="description">
  75. <p>The minimum value to be represented with the lookup table.<br/>Default is <code>0</code>.</p>
  76. </div>
  77. </div>
  78. <div class="member">
  79. <h3 class="name" id="n" translate="no">.<a href="#n">n</a><span class="type-signature"> : number</span> </h3>
  80. <div class="description">
  81. <p>The number of colors of the current selected color map.<br/>Default is <code>32</code>.</p>
  82. </div>
  83. </div>
  84. <h2 class="subsection-title">Methods</h2>
  85. <h3 class="name name-method" id="addColorMap" translate="no">.<a href="#addColorMap">addColorMap</a><span class="signature">( name : <span class="param-type">string</span>, arrayOfColors : <span class="param-type">Array.&lt;Array.&lt;number>></span> )</span><span class="type-signature"> : <a href="Lut.html">Lut</a></span> </h3>
  86. <div class="method">
  87. <div class="description">
  88. <p>Adds a color map to this Lut instance.</p>
  89. </div>
  90. <table class="params">
  91. <tbody>
  92. <tr>
  93. <td class="name"><code>name</code></td>
  94. <td class="description last"><p>The name of the color map.</p></td>
  95. </tr>
  96. <tr>
  97. <td class="name"><code>arrayOfColors</code></td>
  98. <td class="description last"><p>An array of color values. Each value is an array
  99. holding a threshold and the actual color value as a hexadecimal number.</p></td>
  100. </tr>
  101. </tbody>
  102. </table>
  103. <dl class="details">
  104. <dt class="tag-returns"><strong>Returns:</strong> A reference to this LUT.</dt>
  105. </dl>
  106. </div>
  107. <h3 class="name name-method" id="copy" translate="no">.<a href="#copy">copy</a><span class="signature">( lut : <span class="param-type">Lut</span> )</span><span class="type-signature"> : <a href="Lut.html">Lut</a></span> </h3>
  108. <div class="method">
  109. <div class="description">
  110. <p>Copies the given lut.</p>
  111. </div>
  112. <table class="params">
  113. <tbody>
  114. <tr>
  115. <td class="name"><code>lut</code></td>
  116. <td class="description last"><p>The LUT to copy.</p></td>
  117. </tr>
  118. </tbody>
  119. </table>
  120. <dl class="details">
  121. <dt class="tag-returns"><strong>Returns:</strong> A reference to this LUT.</dt>
  122. </dl>
  123. </div>
  124. <h3 class="name name-method" id="createCanvas" translate="no">.<a href="#createCanvas">createCanvas</a><span class="signature">()</span><span class="type-signature"> : HTMLCanvasElement</span> </h3>
  125. <div class="method">
  126. <div class="description">
  127. <p>Creates a canvas in order to visualize the lookup table as a texture.</p>
  128. </div>
  129. <dl class="details">
  130. <dt class="tag-returns"><strong>Returns:</strong> The created canvas.</dt>
  131. </dl>
  132. </div>
  133. <h3 class="name name-method" id="getColor" translate="no">.<a href="#getColor">getColor</a><span class="signature">( alpha : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Color.html">Color</a></span> </h3>
  134. <div class="method">
  135. <div class="description">
  136. <p>Returns an instance of Color for the given data value.</p>
  137. </div>
  138. <table class="params">
  139. <tbody>
  140. <tr>
  141. <td class="name"><code>alpha</code></td>
  142. <td class="description last"><p>The value to lookup.</p></td>
  143. </tr>
  144. </tbody>
  145. </table>
  146. <dl class="details">
  147. <dt class="tag-returns"><strong>Returns:</strong> The color from the LUT.</dt>
  148. </dl>
  149. </div>
  150. <h3 class="name name-method" id="set" translate="no">.<a href="#set">set</a><span class="signature">( value : <span class="param-type">Lut</span> )</span><span class="type-signature"> : <a href="Lut.html">Lut</a></span> </h3>
  151. <div class="method">
  152. <div class="description">
  153. <p>Sets the given LUT.</p>
  154. </div>
  155. <table class="params">
  156. <tbody>
  157. <tr>
  158. <td class="name"><code>value</code></td>
  159. <td class="description last"><p>The LUT to set.</p></td>
  160. </tr>
  161. </tbody>
  162. </table>
  163. <dl class="details">
  164. <dt class="tag-returns"><strong>Returns:</strong> A reference to this LUT.</dt>
  165. </dl>
  166. </div>
  167. <h3 class="name name-method" id="setColorMap" translate="no">.<a href="#setColorMap">setColorMap</a><span class="signature">( colormap : <span class="param-type">string</span>, count : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Lut.html">Lut</a></span> </h3>
  168. <div class="method">
  169. <div class="description">
  170. <p>Configure the lookup table for the given color map and number of colors.</p>
  171. </div>
  172. <table class="params">
  173. <tbody>
  174. <tr>
  175. <td class="name"><code>colormap</code></td>
  176. <td class="description last"><p>The name of the color map.</p></td>
  177. </tr>
  178. <tr>
  179. <td class="name"><code>count</code></td>
  180. <td class="description last"><p>The number of colors.<br/>Default is <code>32</code>.</p></td>
  181. </tr>
  182. </tbody>
  183. </table>
  184. <dl class="details">
  185. <dt class="tag-returns"><strong>Returns:</strong> A reference to this LUT.</dt>
  186. </dl>
  187. </div>
  188. <h3 class="name name-method" id="setMax" translate="no">.<a href="#setMax">setMax</a><span class="signature">( max : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Lut.html">Lut</a></span> </h3>
  189. <div class="method">
  190. <div class="description">
  191. <p>Sets the maximum value to be represented with this LUT.</p>
  192. </div>
  193. <table class="params">
  194. <tbody>
  195. <tr>
  196. <td class="name"><code>max</code></td>
  197. <td class="description last"><p>The maximum value to be represented with the lookup table.</p></td>
  198. </tr>
  199. </tbody>
  200. </table>
  201. <dl class="details">
  202. <dt class="tag-returns"><strong>Returns:</strong> A reference to this LUT.</dt>
  203. </dl>
  204. </div>
  205. <h3 class="name name-method" id="setMin" translate="no">.<a href="#setMin">setMin</a><span class="signature">( min : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Lut.html">Lut</a></span> </h3>
  206. <div class="method">
  207. <div class="description">
  208. <p>Sets the minimum value to be represented with this LUT.</p>
  209. </div>
  210. <table class="params">
  211. <tbody>
  212. <tr>
  213. <td class="name"><code>min</code></td>
  214. <td class="description last"><p>The minimum value to be represented with the lookup table.</p></td>
  215. </tr>
  216. </tbody>
  217. </table>
  218. <dl class="details">
  219. <dt class="tag-returns"><strong>Returns:</strong> A reference to this LUT.</dt>
  220. </dl>
  221. </div>
  222. <h3 class="name name-method" id="updateCanvas" translate="no">.<a href="#updateCanvas">updateCanvas</a><span class="signature">( canvas : <span class="param-type">HTMLCanvasElement</span> )</span><span class="type-signature"> : HTMLCanvasElement</span> </h3>
  223. <div class="method">
  224. <div class="description">
  225. <p>Updates the given canvas with the Lut's data.</p>
  226. </div>
  227. <table class="params">
  228. <tbody>
  229. <tr>
  230. <td class="name"><code>canvas</code></td>
  231. <td class="description last"><p>The canvas to update.</p></td>
  232. </tr>
  233. </tbody>
  234. </table>
  235. <dl class="details">
  236. <dt class="tag-returns"><strong>Returns:</strong> The updated canvas.</dt>
  237. </dl>
  238. </div>
  239. <h2 class="subsection-title">Source</h2>
  240. <p>
  241. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/math/Lut.js" target="_blank" rel="noopener" translate="no">examples/jsm/math/Lut.js</a>
  242. </p>
  243. </article>
  244. </section>
  245. <script src="../scripts/linenumber.js"></script>
  246. <script src="../scripts/page.js"></script>
  247. </body>
  248. </html>
粤ICP备19079148号