Lut.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  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" rel="noopener">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">
  37. <strong>colormap</strong>
  38. </td>
  39. <td class="description last">
  40. <p>Sets a colormap from predefined list of colormaps.</p>
  41. <p>Default is <code>'rainbow'</code>.</p>
  42. </td>
  43. </tr>
  44. <tr>
  45. <td class="name">
  46. <strong>count</strong>
  47. </td>
  48. <td class="description last">
  49. <p>Sets the number of colors used to represent the data array.</p>
  50. <p>Default is <code>32</code>.</p>
  51. </td>
  52. </tr>
  53. </tbody>
  54. </table>
  55. </div>
  56. </div>
  57. <h2 class="subsection-title">Properties</h2>
  58. <div class="member">
  59. <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>
  60. <div class="description">
  61. <p>This flag can be used for type testing.</p>
  62. <p>Default is <code>true</code>.</p>
  63. </div>
  64. </div>
  65. <div class="member">
  66. <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>
  67. <div class="description">
  68. <p>The lookup table for the selected color map</p>
  69. </div>
  70. </div>
  71. <div class="member">
  72. <h3 class="name" id="map" translate="no">.<a href="#map">map</a><span class="type-signature"> : Array.&lt;Array.&lt;number>></span> </h3>
  73. <div class="description">
  74. <p>The currently selected color map.</p>
  75. </div>
  76. </div>
  77. <div class="member">
  78. <h3 class="name" id="maxV" translate="no">.<a href="#maxV">maxV</a><span class="type-signature"> : number</span> </h3>
  79. <div class="description">
  80. <p>The maximum value to be represented with the lookup table.</p>
  81. <p>Default is <code>1</code>.</p>
  82. </div>
  83. </div>
  84. <div class="member">
  85. <h3 class="name" id="minV" translate="no">.<a href="#minV">minV</a><span class="type-signature"> : number</span> </h3>
  86. <div class="description">
  87. <p>The minimum value to be represented with the lookup table.</p>
  88. <p>Default is <code>0</code>.</p>
  89. </div>
  90. </div>
  91. <div class="member">
  92. <h3 class="name" id="n" translate="no">.<a href="#n">n</a><span class="type-signature"> : number</span> </h3>
  93. <div class="description">
  94. <p>The number of colors of the current selected color map.</p>
  95. <p>Default is <code>32</code>.</p>
  96. </div>
  97. </div>
  98. <h2 class="subsection-title">Methods</h2>
  99. <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>
  100. <div class="method">
  101. <div class="description">
  102. <p>Adds a color map to this Lut instance.</p>
  103. </div>
  104. <table class="params">
  105. <tbody>
  106. <tr>
  107. <td class="name">
  108. <strong>name</strong>
  109. </td>
  110. <td class="description last">
  111. <p>The name of the color map.</p>
  112. </td>
  113. </tr>
  114. <tr>
  115. <td class="name">
  116. <strong>arrayOfColors</strong>
  117. </td>
  118. <td class="description last">
  119. <p>An array of color values. Each value is an array
  120. holding a threshold and the actual color value as a hexadecimal number.</p>
  121. </td>
  122. </tr>
  123. </tbody>
  124. </table>
  125. <dl class="details">
  126. <dt class="tag-returns"><strong>Returns:</strong> A reference to this LUT.</dt>
  127. </dl>
  128. </div>
  129. <h3 class="name name-method" id="copy" translate="no">.<a href="#copy">copy</a><span class="signature">( lut : <span class="param-type"><a href="Lut.html">Lut</a></span> )</span><span class="type-signature"> : <a href="Lut.html">Lut</a></span> </h3>
  130. <div class="method">
  131. <div class="description">
  132. <p>Copies the given lut.</p>
  133. </div>
  134. <table class="params">
  135. <tbody>
  136. <tr>
  137. <td class="name">
  138. <strong>lut</strong>
  139. </td>
  140. <td class="description last">
  141. <p>The LUT to copy.</p>
  142. </td>
  143. </tr>
  144. </tbody>
  145. </table>
  146. <dl class="details">
  147. <dt class="tag-returns"><strong>Returns:</strong> A reference to this LUT.</dt>
  148. </dl>
  149. </div>
  150. <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>
  151. <div class="method">
  152. <div class="description">
  153. <p>Creates a canvas in order to visualize the lookup table as a texture.</p>
  154. </div>
  155. <dl class="details">
  156. <dt class="tag-returns"><strong>Returns:</strong> The created canvas.</dt>
  157. </dl>
  158. </div>
  159. <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>
  160. <div class="method">
  161. <div class="description">
  162. <p>Returns an instance of Color for the given data value.</p>
  163. </div>
  164. <table class="params">
  165. <tbody>
  166. <tr>
  167. <td class="name">
  168. <strong>alpha</strong>
  169. </td>
  170. <td class="description last">
  171. <p>The value to lookup.</p>
  172. </td>
  173. </tr>
  174. </tbody>
  175. </table>
  176. <dl class="details">
  177. <dt class="tag-returns"><strong>Returns:</strong> The color from the LUT.</dt>
  178. </dl>
  179. </div>
  180. <h3 class="name name-method" id="set" translate="no">.<a href="#set">set</a><span class="signature">( value : <span class="param-type"><a href="Lut.html">Lut</a></span> )</span><span class="type-signature"> : <a href="Lut.html">Lut</a></span> </h3>
  181. <div class="method">
  182. <div class="description">
  183. <p>Sets the given LUT.</p>
  184. </div>
  185. <table class="params">
  186. <tbody>
  187. <tr>
  188. <td class="name">
  189. <strong>value</strong>
  190. </td>
  191. <td class="description last">
  192. <p>The LUT to set.</p>
  193. </td>
  194. </tr>
  195. </tbody>
  196. </table>
  197. <dl class="details">
  198. <dt class="tag-returns"><strong>Returns:</strong> A reference to this LUT.</dt>
  199. </dl>
  200. </div>
  201. <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>
  202. <div class="method">
  203. <div class="description">
  204. <p>Configure the lookup table for the given color map and number of colors.</p>
  205. </div>
  206. <table class="params">
  207. <tbody>
  208. <tr>
  209. <td class="name">
  210. <strong>colormap</strong>
  211. </td>
  212. <td class="description last">
  213. <p>The name of the color map.</p>
  214. </td>
  215. </tr>
  216. <tr>
  217. <td class="name">
  218. <strong>count</strong>
  219. </td>
  220. <td class="description last">
  221. <p>The number of colors.</p>
  222. <p>Default is <code>32</code>.</p>
  223. </td>
  224. </tr>
  225. </tbody>
  226. </table>
  227. <dl class="details">
  228. <dt class="tag-returns"><strong>Returns:</strong> A reference to this LUT.</dt>
  229. </dl>
  230. </div>
  231. <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>
  232. <div class="method">
  233. <div class="description">
  234. <p>Sets the maximum value to be represented with this LUT.</p>
  235. </div>
  236. <table class="params">
  237. <tbody>
  238. <tr>
  239. <td class="name">
  240. <strong>max</strong>
  241. </td>
  242. <td class="description last">
  243. <p>The maximum value to be represented with the lookup table.</p>
  244. </td>
  245. </tr>
  246. </tbody>
  247. </table>
  248. <dl class="details">
  249. <dt class="tag-returns"><strong>Returns:</strong> A reference to this LUT.</dt>
  250. </dl>
  251. </div>
  252. <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>
  253. <div class="method">
  254. <div class="description">
  255. <p>Sets the minimum value to be represented with this LUT.</p>
  256. </div>
  257. <table class="params">
  258. <tbody>
  259. <tr>
  260. <td class="name">
  261. <strong>min</strong>
  262. </td>
  263. <td class="description last">
  264. <p>The minimum value to be represented with the lookup table.</p>
  265. </td>
  266. </tr>
  267. </tbody>
  268. </table>
  269. <dl class="details">
  270. <dt class="tag-returns"><strong>Returns:</strong> A reference to this LUT.</dt>
  271. </dl>
  272. </div>
  273. <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>
  274. <div class="method">
  275. <div class="description">
  276. <p>Updates the given canvas with the Lut's data.</p>
  277. </div>
  278. <table class="params">
  279. <tbody>
  280. <tr>
  281. <td class="name">
  282. <strong>canvas</strong>
  283. </td>
  284. <td class="description last">
  285. <p>The canvas to update.</p>
  286. </td>
  287. </tr>
  288. </tbody>
  289. </table>
  290. <dl class="details">
  291. <dt class="tag-returns"><strong>Returns:</strong> The updated canvas.</dt>
  292. </dl>
  293. </div>
  294. <h2 class="subsection-title">Source</h2>
  295. <p>
  296. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/math/Lut.js" translate="no" target="_blank" rel="noopener">examples/jsm/math/Lut.js</a>
  297. </p>
  298. </article>
  299. </section>
  300. <script src="../scripts/linenumber.js"></script>
  301. <script src="../scripts/page.js"></script>
  302. </body>
  303. </html>
粤ICP备19079148号