SphericalHarmonics3.html 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>SphericalHarmonics3 - 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">SphericalHarmonics3</h1>
  13. <section>
  14. <header>
  15. <div class="class-description"><p>Represents a third-order spherical harmonics (SH). Light probes use this class
  16. to encode lighting information.</p>
  17. <ul>
  18. <li>Primary reference: <a href="https://graphics.stanford.edu/papers/envmap/envmap.pdf" target="_blank" rel="noopener">https://graphics.stanford.edu/papers/envmap/envmap.pdf</a></li>
  19. <li>Secondary reference: <a href="https://www.ppsloan.org/publications/StupidSH36.pdf" target="_blank" rel="noopener">https://www.ppsloan.org/publications/StupidSH36.pdf</a></li>
  20. </ul></div>
  21. </header>
  22. <article>
  23. <div class="container-overview">
  24. <h2>Constructor</h2>
  25. <h3 class="name name-method" id="SphericalHarmonics3" translate="no">new <a href="#SphericalHarmonics3">SphericalHarmonics3</a><span class="signature">()</span> </h3>
  26. <div class="method">
  27. <div class="description">
  28. <p>Constructs a new spherical harmonics.</p>
  29. </div>
  30. </div>
  31. </div>
  32. <h2 class="subsection-title">Properties</h2>
  33. <div class="member">
  34. <h3 class="name" id="coefficients" translate="no">.<a href="#coefficients">coefficients</a><span class="type-signature"> : Array.&lt;<a href="Vector3.html">Vector3</a>></span> </h3>
  35. <div class="description">
  36. <p>An array holding the (9) SH coefficients.</p>
  37. </div>
  38. </div>
  39. <div class="member">
  40. <h3 class="name" id="isSphericalHarmonics3" translate="no">.<a href="#isSphericalHarmonics3">isSphericalHarmonics3</a><span class="type-signature"> : boolean</span> <span class="type-signature">(readonly) </span></h3>
  41. <div class="description">
  42. <p>This flag can be used for type testing.</p>
  43. <p>Default is <code>true</code>.</p>
  44. </div>
  45. </div>
  46. <h2 class="subsection-title">Methods</h2>
  47. <h3 class="name name-method" id="add" translate="no">.<a href="#add">add</a><span class="signature">( sh : <span class="param-type"><a href="SphericalHarmonics3.html">SphericalHarmonics3</a></span> )</span><span class="type-signature"> : <a href="SphericalHarmonics3.html">SphericalHarmonics3</a></span> </h3>
  48. <div class="method">
  49. <div class="description">
  50. <p>Adds the given SH to this instance.</p>
  51. </div>
  52. <table class="params">
  53. <tbody>
  54. <tr>
  55. <td class="name">
  56. <strong>sh</strong>
  57. </td>
  58. <td class="description last">
  59. <p>The SH to add.</p>
  60. </td>
  61. </tr>
  62. </tbody>
  63. </table>
  64. <dl class="details">
  65. <dt class="tag-returns"><strong>Returns:</strong> A reference to this spherical harmonics.</dt>
  66. </dl>
  67. </div>
  68. <h3 class="name name-method" id="addScaledSH" translate="no">.<a href="#addScaledSH">addScaledSH</a><span class="signature">( sh : <span class="param-type"><a href="SphericalHarmonics3.html">SphericalHarmonics3</a></span>, s : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="SphericalHarmonics3.html">SphericalHarmonics3</a></span> </h3>
  69. <div class="method">
  70. <div class="description">
  71. <p>A convenience method for performing <a href="SphericalHarmonics3.html#add">SphericalHarmonics3#add</a> and
  72. <a href="SphericalHarmonics3.html#scale">SphericalHarmonics3#scale</a> at once.</p>
  73. </div>
  74. <table class="params">
  75. <tbody>
  76. <tr>
  77. <td class="name">
  78. <strong>sh</strong>
  79. </td>
  80. <td class="description last">
  81. <p>The SH to add.</p>
  82. </td>
  83. </tr>
  84. <tr>
  85. <td class="name">
  86. <strong>s</strong>
  87. </td>
  88. <td class="description last">
  89. <p>The scale factor.</p>
  90. </td>
  91. </tr>
  92. </tbody>
  93. </table>
  94. <dl class="details">
  95. <dt class="tag-returns"><strong>Returns:</strong> A reference to this spherical harmonics.</dt>
  96. </dl>
  97. </div>
  98. <h3 class="name name-method" id="clone" translate="no">.<a href="#clone">clone</a><span class="signature">()</span><span class="type-signature"> : <a href="SphericalHarmonics3.html">SphericalHarmonics3</a></span> </h3>
  99. <div class="method">
  100. <div class="description">
  101. <p>Returns a new spherical harmonics with copied values from this instance.</p>
  102. </div>
  103. <dl class="details">
  104. <dt class="tag-returns"><strong>Returns:</strong> A clone of this instance.</dt>
  105. </dl>
  106. </div>
  107. <h3 class="name name-method" id="copy" translate="no">.<a href="#copy">copy</a><span class="signature">( sh : <span class="param-type"><a href="SphericalHarmonics3.html">SphericalHarmonics3</a></span> )</span><span class="type-signature"> : <a href="SphericalHarmonics3.html">SphericalHarmonics3</a></span> </h3>
  108. <div class="method">
  109. <div class="description">
  110. <p>Copies the values of the given spherical harmonics to this instance.</p>
  111. </div>
  112. <table class="params">
  113. <tbody>
  114. <tr>
  115. <td class="name">
  116. <strong>sh</strong>
  117. </td>
  118. <td class="description last">
  119. <p>The spherical harmonics to copy.</p>
  120. </td>
  121. </tr>
  122. </tbody>
  123. </table>
  124. <dl class="details">
  125. <dt class="tag-returns"><strong>Returns:</strong> A reference to this spherical harmonics.</dt>
  126. </dl>
  127. </div>
  128. <h3 class="name name-method" id="equals" translate="no">.<a href="#equals">equals</a><span class="signature">( sh : <span class="param-type"><a href="SphericalHarmonics3.html">SphericalHarmonics3</a></span> )</span><span class="type-signature"> : boolean</span> </h3>
  129. <div class="method">
  130. <div class="description">
  131. <p>Returns <code>true</code> if this spherical harmonics is equal with the given one.</p>
  132. </div>
  133. <table class="params">
  134. <tbody>
  135. <tr>
  136. <td class="name">
  137. <strong>sh</strong>
  138. </td>
  139. <td class="description last">
  140. <p>The spherical harmonics to test for equality.</p>
  141. </td>
  142. </tr>
  143. </tbody>
  144. </table>
  145. <dl class="details">
  146. <dt class="tag-returns"><strong>Returns:</strong> Whether this spherical harmonics is equal with the given one.</dt>
  147. </dl>
  148. </div>
  149. <h3 class="name name-method" id="fromArray" translate="no">.<a href="#fromArray">fromArray</a><span class="signature">( array : <span class="param-type">Array.&lt;number></span>, offset : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="SphericalHarmonics3.html">SphericalHarmonics3</a></span> </h3>
  150. <div class="method">
  151. <div class="description">
  152. <p>Sets the SH coefficients of this instance from the given array.</p>
  153. </div>
  154. <table class="params">
  155. <tbody>
  156. <tr>
  157. <td class="name">
  158. <strong>array</strong>
  159. </td>
  160. <td class="description last">
  161. <p>An array holding the SH coefficients.</p>
  162. </td>
  163. </tr>
  164. <tr>
  165. <td class="name">
  166. <strong>offset</strong>
  167. </td>
  168. <td class="description last">
  169. <p>The array offset where to start copying.</p>
  170. <p>Default is <code>0</code>.</p>
  171. </td>
  172. </tr>
  173. </tbody>
  174. </table>
  175. <dl class="details">
  176. <dt class="tag-returns"><strong>Returns:</strong> A clone of this instance.</dt>
  177. </dl>
  178. </div>
  179. <h3 class="name name-method" id="getAt" translate="no">.<a href="#getAt">getAt</a><span class="signature">( normal : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, target : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  180. <div class="method">
  181. <div class="description">
  182. <p>Returns the radiance in the direction of the given normal.</p>
  183. </div>
  184. <table class="params">
  185. <tbody>
  186. <tr>
  187. <td class="name">
  188. <strong>normal</strong>
  189. </td>
  190. <td class="description last">
  191. <p>The normal vector (assumed to be unit length)</p>
  192. </td>
  193. </tr>
  194. <tr>
  195. <td class="name">
  196. <strong>target</strong>
  197. </td>
  198. <td class="description last">
  199. <p>The target vector that is used to store the method's result.</p>
  200. </td>
  201. </tr>
  202. </tbody>
  203. </table>
  204. <dl class="details">
  205. <dt class="tag-returns"><strong>Returns:</strong> The radiance.</dt>
  206. </dl>
  207. </div>
  208. <h3 class="name name-method" id="getIrradianceAt" translate="no">.<a href="#getIrradianceAt">getIrradianceAt</a><span class="signature">( normal : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, target : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  209. <div class="method">
  210. <div class="description">
  211. <p>Returns the irradiance (radiance convolved with cosine lobe) in the
  212. direction of the given normal.</p>
  213. </div>
  214. <table class="params">
  215. <tbody>
  216. <tr>
  217. <td class="name">
  218. <strong>normal</strong>
  219. </td>
  220. <td class="description last">
  221. <p>The normal vector (assumed to be unit length)</p>
  222. </td>
  223. </tr>
  224. <tr>
  225. <td class="name">
  226. <strong>target</strong>
  227. </td>
  228. <td class="description last">
  229. <p>The target vector that is used to store the method's result.</p>
  230. </td>
  231. </tr>
  232. </tbody>
  233. </table>
  234. <dl class="details">
  235. <dt class="tag-returns"><strong>Returns:</strong> The irradiance.</dt>
  236. </dl>
  237. </div>
  238. <h3 class="name name-method" id="lerp" translate="no">.<a href="#lerp">lerp</a><span class="signature">( sh : <span class="param-type"><a href="SphericalHarmonics3.html">SphericalHarmonics3</a></span>, alpha : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="SphericalHarmonics3.html">SphericalHarmonics3</a></span> </h3>
  239. <div class="method">
  240. <div class="description">
  241. <p>Linear interpolates between the given SH and this instance by the given
  242. alpha factor.</p>
  243. </div>
  244. <table class="params">
  245. <tbody>
  246. <tr>
  247. <td class="name">
  248. <strong>sh</strong>
  249. </td>
  250. <td class="description last">
  251. <p>The SH to interpolate with.</p>
  252. </td>
  253. </tr>
  254. <tr>
  255. <td class="name">
  256. <strong>alpha</strong>
  257. </td>
  258. <td class="description last">
  259. <p>The alpha factor.</p>
  260. </td>
  261. </tr>
  262. </tbody>
  263. </table>
  264. <dl class="details">
  265. <dt class="tag-returns"><strong>Returns:</strong> A reference to this spherical harmonics.</dt>
  266. </dl>
  267. </div>
  268. <h3 class="name name-method" id="scale" translate="no">.<a href="#scale">scale</a><span class="signature">( s : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="SphericalHarmonics3.html">SphericalHarmonics3</a></span> </h3>
  269. <div class="method">
  270. <div class="description">
  271. <p>Scales this SH by the given scale factor.</p>
  272. </div>
  273. <table class="params">
  274. <tbody>
  275. <tr>
  276. <td class="name">
  277. <strong>s</strong>
  278. </td>
  279. <td class="description last">
  280. <p>The scale factor.</p>
  281. </td>
  282. </tr>
  283. </tbody>
  284. </table>
  285. <dl class="details">
  286. <dt class="tag-returns"><strong>Returns:</strong> A reference to this spherical harmonics.</dt>
  287. </dl>
  288. </div>
  289. <h3 class="name name-method" id="set" translate="no">.<a href="#set">set</a><span class="signature">( coefficients : <span class="param-type">Array.&lt;<a href="Vector3.html">Vector3</a>></span> )</span><span class="type-signature"> : <a href="SphericalHarmonics3.html">SphericalHarmonics3</a></span> </h3>
  290. <div class="method">
  291. <div class="description">
  292. <p>Sets the given SH coefficients to this instance by copying
  293. the values.</p>
  294. </div>
  295. <table class="params">
  296. <tbody>
  297. <tr>
  298. <td class="name">
  299. <strong>coefficients</strong>
  300. </td>
  301. <td class="description last">
  302. <p>The SH coefficients.</p>
  303. </td>
  304. </tr>
  305. </tbody>
  306. </table>
  307. <dl class="details">
  308. <dt class="tag-returns"><strong>Returns:</strong> A reference to this spherical harmonics.</dt>
  309. </dl>
  310. </div>
  311. <h3 class="name name-method" id="toArray" translate="no">.<a href="#toArray">toArray</a><span class="signature">( array : <span class="param-type">Array.&lt;number></span>, offset : <span class="param-type">number</span> )</span><span class="type-signature"> : Array.&lt;number></span> </h3>
  312. <div class="method">
  313. <div class="description">
  314. <p>Returns an array with the SH coefficients, or copies them into the provided
  315. array. The coefficients are represented as numbers.</p>
  316. </div>
  317. <table class="params">
  318. <tbody>
  319. <tr>
  320. <td class="name">
  321. <strong>array</strong>
  322. </td>
  323. <td class="description last">
  324. <p>The target array.</p>
  325. <p>Default is <code>[]</code>.</p>
  326. </td>
  327. </tr>
  328. <tr>
  329. <td class="name">
  330. <strong>offset</strong>
  331. </td>
  332. <td class="description last">
  333. <p>The array offset where to start copying.</p>
  334. <p>Default is <code>0</code>.</p>
  335. </td>
  336. </tr>
  337. </tbody>
  338. </table>
  339. <dl class="details">
  340. <dt class="tag-returns"><strong>Returns:</strong> An array with flat SH coefficients.</dt>
  341. </dl>
  342. </div>
  343. <h3 class="name name-method" id="zero" translate="no">.<a href="#zero">zero</a><span class="signature">()</span><span class="type-signature"> : <a href="SphericalHarmonics3.html">SphericalHarmonics3</a></span> </h3>
  344. <div class="method">
  345. <div class="description">
  346. <p>Sets all SH coefficients to <code>0</code>.</p>
  347. </div>
  348. <dl class="details">
  349. <dt class="tag-returns"><strong>Returns:</strong> A reference to this spherical harmonics.</dt>
  350. </dl>
  351. </div>
  352. <h2 class="subsection-title">Static Methods</h2>
  353. <h3 class="name name-method" id=".getBasisAt" translate="no">.<a href="#.getBasisAt">getBasisAt</a><span class="signature">( normal : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, shBasis : <span class="param-type">Array.&lt;number></span> )</span> </h3>
  354. <div class="method">
  355. <div class="description">
  356. <p>Computes the SH basis for the given normal vector.</p>
  357. </div>
  358. <table class="params">
  359. <tbody>
  360. <tr>
  361. <td class="name">
  362. <strong>normal</strong>
  363. </td>
  364. <td class="description last">
  365. <p>The normal.</p>
  366. </td>
  367. </tr>
  368. <tr>
  369. <td class="name">
  370. <strong>shBasis</strong>
  371. </td>
  372. <td class="description last">
  373. <p>The target array holding the SH basis.</p>
  374. </td>
  375. </tr>
  376. </tbody>
  377. </table>
  378. </div>
  379. <h2 class="subsection-title">Source</h2>
  380. <p>
  381. <a href="https://github.com/mrdoob/three.js/blob/master/src/math/SphericalHarmonics3.js" translate="no" target="_blank" rel="noopener">src/math/SphericalHarmonics3.js</a>
  382. </p>
  383. </article>
  384. </section>
  385. <script src="../scripts/linenumber.js"></script>
  386. <script src="../scripts/page.js"></script>
  387. </body>
  388. </html>
粤ICP备19079148号