pptx-react-viewer 3.17.1 → 3.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (264) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/README.md +55 -31
  3. package/dist/{AiChatPanel-SINEEZBW.mjs → AiChatPanel-3M7XWTVE.mjs} +4 -4
  4. package/dist/AiChatPanel-3M7XWTVE.mjs.br +0 -0
  5. package/dist/AiChatPanel-3M7XWTVE.mjs.gz +0 -0
  6. package/dist/{AiChatPanel-GYH43XWW.js → AiChatPanel-WDVU4RIM.js} +25 -25
  7. package/dist/AiChatPanel-WDVU4RIM.js.br +0 -0
  8. package/dist/AiChatPanel-WDVU4RIM.js.gz +0 -0
  9. package/dist/{Area3DChartScene-X5SM67PZ.mjs → Area3DChartScene-CTVWVXNW.mjs} +1 -1
  10. package/dist/{Area3DChartScene-X5SM67PZ.mjs.br → Area3DChartScene-CTVWVXNW.mjs.br} +0 -0
  11. package/dist/Area3DChartScene-CTVWVXNW.mjs.gz +0 -0
  12. package/dist/{Area3DChartScene-D7GSJGPQ.js → Area3DChartScene-N5KPQFC6.js} +2 -2
  13. package/dist/Area3DChartScene-N5KPQFC6.js.br +0 -0
  14. package/dist/Area3DChartScene-N5KPQFC6.js.gz +0 -0
  15. package/dist/{Bar3DChartScene-M72WQW5Y.js → Bar3DChartScene-3QRUPVPT.js} +2 -2
  16. package/dist/Bar3DChartScene-3QRUPVPT.js.br +0 -0
  17. package/dist/Bar3DChartScene-3QRUPVPT.js.gz +0 -0
  18. package/dist/{Bar3DChartScene-HWIFFGI3.mjs → Bar3DChartScene-PXFSFZRX.mjs} +1 -1
  19. package/dist/{Bar3DChartScene-HWIFFGI3.mjs.br → Bar3DChartScene-PXFSFZRX.mjs.br} +0 -0
  20. package/dist/Bar3DChartScene-PXFSFZRX.mjs.gz +0 -0
  21. package/dist/{GLTFLoader-374ZNTXW.mjs → GLTFLoader-IWJFC4XI.mjs} +54 -16
  22. package/dist/GLTFLoader-IWJFC4XI.mjs.br +0 -0
  23. package/dist/GLTFLoader-IWJFC4XI.mjs.gz +0 -0
  24. package/dist/{GLTFLoader-Q7BHCGAW.js → GLTFLoader-KY7AYPMX.js} +178 -140
  25. package/dist/GLTFLoader-KY7AYPMX.js.br +0 -0
  26. package/dist/GLTFLoader-KY7AYPMX.js.gz +0 -0
  27. package/dist/{Line3DChartScene-YOZEEQZ3.js → Line3DChartScene-776WLKR5.js} +2 -2
  28. package/dist/Line3DChartScene-776WLKR5.js.br +0 -0
  29. package/dist/Line3DChartScene-776WLKR5.js.gz +0 -0
  30. package/dist/{Line3DChartScene-7MPZWVF3.mjs → Line3DChartScene-LLL3BU4Q.mjs} +1 -1
  31. package/dist/Line3DChartScene-LLL3BU4Q.mjs.br +0 -0
  32. package/dist/Line3DChartScene-LLL3BU4Q.mjs.gz +0 -0
  33. package/dist/{Model3DScene-5IJSNGDZ.js → Model3DScene-7TM2XSJY.js} +2 -2
  34. package/dist/Model3DScene-7TM2XSJY.js.br +0 -0
  35. package/dist/Model3DScene-7TM2XSJY.js.gz +0 -0
  36. package/dist/{Model3DScene-57LVY5QW.mjs → Model3DScene-FMQ4FDC5.mjs} +1 -1
  37. package/dist/{Model3DScene-57LVY5QW.mjs.br → Model3DScene-FMQ4FDC5.mjs.br} +0 -0
  38. package/dist/Model3DScene-FMQ4FDC5.mjs.gz +0 -0
  39. package/dist/OrbitControls-2XOMWUVE.mjs +3 -0
  40. package/dist/OrbitControls-2XOMWUVE.mjs.br +0 -0
  41. package/dist/OrbitControls-2XOMWUVE.mjs.gz +0 -0
  42. package/dist/OrbitControls-CGYUF3BY.js +12 -0
  43. package/dist/OrbitControls-CGYUF3BY.js.br +0 -0
  44. package/dist/OrbitControls-CGYUF3BY.js.gz +0 -0
  45. package/dist/{PieChart3DScene-WD5B6NP3.mjs → PieChart3DScene-2YNQ5J7A.mjs} +1 -1
  46. package/dist/{PieChart3DScene-WD5B6NP3.mjs.br → PieChart3DScene-2YNQ5J7A.mjs.br} +0 -0
  47. package/dist/PieChart3DScene-2YNQ5J7A.mjs.gz +0 -0
  48. package/dist/{PieChart3DScene-UBI6X66Q.js → PieChart3DScene-DZY4MQCG.js} +2 -2
  49. package/dist/PieChart3DScene-DZY4MQCG.js.br +0 -0
  50. package/dist/PieChart3DScene-DZY4MQCG.js.gz +0 -0
  51. package/dist/{SmartArt3DScene-ODKCGJBO.mjs → SmartArt3DScene-QZGIABOK.mjs} +2 -2
  52. package/dist/SmartArt3DScene-QZGIABOK.mjs.br +0 -0
  53. package/dist/SmartArt3DScene-QZGIABOK.mjs.gz +0 -0
  54. package/dist/{SmartArt3DScene-BK7QN3WT.js → SmartArt3DScene-T236GYUT.js} +33 -33
  55. package/dist/SmartArt3DScene-T236GYUT.js.br +0 -0
  56. package/dist/SmartArt3DScene-T236GYUT.js.gz +0 -0
  57. package/dist/{SurfaceChart3DScene-JGNPYQ32.js → SurfaceChart3DScene-G3MWPEL3.js} +2 -2
  58. package/dist/SurfaceChart3DScene-G3MWPEL3.js.br +0 -0
  59. package/dist/SurfaceChart3DScene-G3MWPEL3.js.gz +0 -0
  60. package/dist/{SurfaceChart3DScene-JZGU6BBD.mjs → SurfaceChart3DScene-XJHLH2EM.mjs} +1 -1
  61. package/dist/{SurfaceChart3DScene-JZGU6BBD.mjs.br → SurfaceChart3DScene-XJHLH2EM.mjs.br} +0 -0
  62. package/dist/SurfaceChart3DScene-XJHLH2EM.mjs.gz +0 -0
  63. package/dist/{chunk-E55VEC37.js → chunk-2QWLARCW.js} +7357 -1264
  64. package/dist/chunk-2QWLARCW.js.br +0 -0
  65. package/dist/chunk-2QWLARCW.js.gz +0 -0
  66. package/dist/{chunk-KVXB22D3.js → chunk-36O4SE4R.js} +5 -5
  67. package/dist/chunk-36O4SE4R.js.br +0 -0
  68. package/dist/chunk-36O4SE4R.js.gz +0 -0
  69. package/dist/{chunk-B4QYQLZU.js → chunk-3N6AC4HA.js} +1122 -693
  70. package/dist/chunk-3N6AC4HA.js.br +0 -0
  71. package/dist/chunk-3N6AC4HA.js.gz +0 -0
  72. package/dist/{chunk-OAKDJYYT.mjs → chunk-3R5A2E2K.mjs} +6273 -202
  73. package/dist/chunk-3R5A2E2K.mjs.br +0 -0
  74. package/dist/chunk-3R5A2E2K.mjs.gz +0 -0
  75. package/dist/{chunk-7YJBRPCT.mjs → chunk-4KKKJ5MJ.mjs} +1 -1
  76. package/dist/chunk-4KKKJ5MJ.mjs.br +0 -0
  77. package/dist/chunk-4KKKJ5MJ.mjs.gz +0 -0
  78. package/dist/{chunk-IRG7SIUX.js → chunk-6DYDAKHG.js} +2044 -7308
  79. package/dist/chunk-6DYDAKHG.js.br +0 -0
  80. package/dist/chunk-6DYDAKHG.js.gz +0 -0
  81. package/dist/{chunk-XBMKFZVP.mjs → chunk-7TAWW5QQ.mjs} +1120 -694
  82. package/dist/chunk-7TAWW5QQ.mjs.br +0 -0
  83. package/dist/chunk-7TAWW5QQ.mjs.gz +0 -0
  84. package/dist/{chunk-VYSMTC5C.mjs → chunk-7VFH2FRI.mjs} +66 -124
  85. package/dist/chunk-7VFH2FRI.mjs.br +0 -0
  86. package/dist/chunk-7VFH2FRI.mjs.gz +0 -0
  87. package/dist/{chunk-64FUV37N.js → chunk-BRJN3ZMG.js} +2 -1
  88. package/dist/chunk-BRJN3ZMG.js.br +0 -0
  89. package/dist/{chunk-64FUV37N.js.gz → chunk-BRJN3ZMG.js.gz} +0 -0
  90. package/dist/{chunk-QTGCOL5H.mjs → chunk-F552WUJN.mjs} +5668 -2129
  91. package/dist/chunk-F552WUJN.mjs.br +0 -0
  92. package/dist/chunk-F552WUJN.mjs.gz +0 -0
  93. package/dist/{chunk-6C2WYLZY.js → chunk-IXS7DALE.js} +45 -39
  94. package/dist/chunk-IXS7DALE.js.br +0 -0
  95. package/dist/chunk-IXS7DALE.js.gz +0 -0
  96. package/dist/{chunk-4SPZ5IZN.js → chunk-LBMPJYAR.js} +5726 -2132
  97. package/dist/chunk-LBMPJYAR.js.br +0 -0
  98. package/dist/chunk-LBMPJYAR.js.gz +0 -0
  99. package/dist/{chunk-LAU34UMB.mjs → chunk-MQUTXOET.mjs} +2 -1
  100. package/dist/chunk-MQUTXOET.mjs.br +0 -0
  101. package/dist/{chunk-LAU34UMB.mjs.gz → chunk-MQUTXOET.mjs.gz} +0 -0
  102. package/dist/{chunk-3CBDTD46.mjs → chunk-MV2GCDBR.mjs} +8 -2
  103. package/dist/chunk-MV2GCDBR.mjs.br +0 -0
  104. package/dist/chunk-MV2GCDBR.mjs.gz +0 -0
  105. package/dist/{chunk-IXKAIIA2.mjs → chunk-V3BOQ52U.mjs} +242 -5506
  106. package/dist/chunk-V3BOQ52U.mjs.br +0 -0
  107. package/dist/chunk-V3BOQ52U.mjs.gz +0 -0
  108. package/dist/{chunk-7FBKS7OS.js → chunk-V6S72IRP.js} +238 -296
  109. package/dist/chunk-V6S72IRP.js.br +0 -0
  110. package/dist/chunk-V6S72IRP.js.gz +0 -0
  111. package/dist/i18n/de.cjs +3765 -0
  112. package/dist/i18n/de.cjs.br +0 -0
  113. package/dist/i18n/de.cjs.gz +0 -0
  114. package/dist/i18n/de.d.cts +3 -0
  115. package/dist/i18n/de.d.mts +3 -0
  116. package/dist/i18n/de.mjs +3738 -0
  117. package/dist/i18n/de.mjs.br +0 -0
  118. package/dist/i18n/de.mjs.gz +0 -0
  119. package/dist/i18n/es.cjs +3765 -0
  120. package/dist/i18n/es.cjs.br +0 -0
  121. package/dist/i18n/es.cjs.gz +0 -0
  122. package/dist/i18n/es.d.cts +3 -0
  123. package/dist/i18n/es.d.mts +3 -0
  124. package/dist/i18n/es.mjs +3738 -0
  125. package/dist/i18n/es.mjs.br +0 -0
  126. package/dist/i18n/es.mjs.gz +0 -0
  127. package/dist/i18n/fr.cjs +3765 -0
  128. package/dist/i18n/fr.cjs.br +0 -0
  129. package/dist/i18n/fr.cjs.gz +0 -0
  130. package/dist/i18n/fr.d.cts +3 -0
  131. package/dist/i18n/fr.d.mts +3 -0
  132. package/dist/i18n/fr.mjs +3738 -0
  133. package/dist/i18n/fr.mjs.br +0 -0
  134. package/dist/i18n/fr.mjs.gz +0 -0
  135. package/dist/i18n/zh-CN.cjs +3803 -0
  136. package/dist/i18n/zh-CN.cjs.br +0 -0
  137. package/dist/i18n/zh-CN.cjs.gz +0 -0
  138. package/dist/i18n/zh-CN.d.cts +3 -0
  139. package/dist/i18n/zh-CN.d.mts +3 -0
  140. package/dist/i18n/zh-CN.mjs +3776 -0
  141. package/dist/i18n/zh-CN.mjs.br +0 -0
  142. package/dist/i18n/zh-CN.mjs.gz +0 -0
  143. package/dist/i18n.js +4 -4
  144. package/dist/i18n.js.br +0 -0
  145. package/dist/i18n.js.gz +0 -0
  146. package/dist/i18n.mjs +1 -1
  147. package/dist/i18n.mjs.br +0 -0
  148. package/dist/i18n.mjs.gz +0 -0
  149. package/dist/index.d.ts +67 -4
  150. package/dist/index.js +51 -47
  151. package/dist/index.js.br +0 -0
  152. package/dist/index.js.gz +0 -0
  153. package/dist/index.mjs +6 -6
  154. package/dist/index.mjs.br +0 -0
  155. package/dist/index.mjs.gz +0 -0
  156. package/dist/internals.d.ts +2433 -2062
  157. package/dist/internals.js +183 -79
  158. package/dist/internals.js.br +0 -0
  159. package/dist/internals.js.gz +0 -0
  160. package/dist/internals.mjs +4 -4
  161. package/dist/internals.mjs.br +0 -0
  162. package/dist/internals.mjs.gz +0 -0
  163. package/dist/pptx-viewer.css +1 -1
  164. package/dist/pptx-viewer.css.br +0 -0
  165. package/dist/pptx-viewer.css.gz +0 -0
  166. package/dist/three.module-LGUV2LI6.mjs +2 -0
  167. package/dist/three.module-LGUV2LI6.mjs.br +0 -0
  168. package/dist/three.module-LGUV2LI6.mjs.gz +0 -0
  169. package/dist/{three.module-GNNNRIMK.js → three.module-YZ4M24WM.js} +454 -442
  170. package/dist/three.module-YZ4M24WM.js.br +0 -0
  171. package/dist/three.module-YZ4M24WM.js.gz +0 -0
  172. package/dist/viewer/index.d.ts +13 -0
  173. package/dist/viewer/index.js +27 -27
  174. package/dist/viewer/index.js.br +0 -0
  175. package/dist/viewer/index.js.gz +0 -0
  176. package/dist/viewer/index.mjs +6 -6
  177. package/dist/viewer/index.mjs.br +0 -0
  178. package/dist/viewer/index.mjs.gz +0 -0
  179. package/package.json +46 -6
  180. package/dist/AiChatPanel-GYH43XWW.js.br +0 -0
  181. package/dist/AiChatPanel-GYH43XWW.js.gz +0 -0
  182. package/dist/AiChatPanel-SINEEZBW.mjs.br +0 -0
  183. package/dist/AiChatPanel-SINEEZBW.mjs.gz +0 -0
  184. package/dist/Area3DChartScene-D7GSJGPQ.js.br +0 -0
  185. package/dist/Area3DChartScene-D7GSJGPQ.js.gz +0 -0
  186. package/dist/Area3DChartScene-X5SM67PZ.mjs.gz +0 -0
  187. package/dist/Bar3DChartScene-HWIFFGI3.mjs.gz +0 -0
  188. package/dist/Bar3DChartScene-M72WQW5Y.js.br +0 -0
  189. package/dist/Bar3DChartScene-M72WQW5Y.js.gz +0 -0
  190. package/dist/GLTFLoader-374ZNTXW.mjs.br +0 -0
  191. package/dist/GLTFLoader-374ZNTXW.mjs.gz +0 -0
  192. package/dist/GLTFLoader-Q7BHCGAW.js.br +0 -0
  193. package/dist/GLTFLoader-Q7BHCGAW.js.gz +0 -0
  194. package/dist/Line3DChartScene-7MPZWVF3.mjs.br +0 -0
  195. package/dist/Line3DChartScene-7MPZWVF3.mjs.gz +0 -0
  196. package/dist/Line3DChartScene-YOZEEQZ3.js.br +0 -0
  197. package/dist/Line3DChartScene-YOZEEQZ3.js.gz +0 -0
  198. package/dist/Model3DScene-57LVY5QW.mjs.gz +0 -0
  199. package/dist/Model3DScene-5IJSNGDZ.js.br +0 -0
  200. package/dist/Model3DScene-5IJSNGDZ.js.gz +0 -0
  201. package/dist/OrbitControls-SMYCPLXO.js +0 -12
  202. package/dist/OrbitControls-SMYCPLXO.js.br +0 -3
  203. package/dist/OrbitControls-SMYCPLXO.js.gz +0 -0
  204. package/dist/OrbitControls-ZTGHPI5G.mjs +0 -3
  205. package/dist/OrbitControls-ZTGHPI5G.mjs.br +0 -0
  206. package/dist/OrbitControls-ZTGHPI5G.mjs.gz +0 -0
  207. package/dist/PieChart3DScene-UBI6X66Q.js.br +0 -0
  208. package/dist/PieChart3DScene-UBI6X66Q.js.gz +0 -0
  209. package/dist/PieChart3DScene-WD5B6NP3.mjs.gz +0 -0
  210. package/dist/PowerPointViewer-Cde_wzd0.d.ts +0 -21
  211. package/dist/PowerPointViewer-Cde_wzd0.d.ts.map +0 -1
  212. package/dist/SmartArt3DScene-BK7QN3WT.js.br +0 -0
  213. package/dist/SmartArt3DScene-BK7QN3WT.js.gz +0 -0
  214. package/dist/SmartArt3DScene-ODKCGJBO.mjs.br +0 -0
  215. package/dist/SmartArt3DScene-ODKCGJBO.mjs.gz +0 -0
  216. package/dist/SurfaceChart3DScene-JGNPYQ32.js.br +0 -0
  217. package/dist/SurfaceChart3DScene-JGNPYQ32.js.gz +0 -0
  218. package/dist/SurfaceChart3DScene-JZGU6BBD.mjs.gz +0 -0
  219. package/dist/audience-content-store-A8Km8rBo.d.ts +0 -402
  220. package/dist/audience-content-store-A8Km8rBo.d.ts.map +0 -1
  221. package/dist/chunk-3CBDTD46.mjs.br +0 -0
  222. package/dist/chunk-3CBDTD46.mjs.gz +0 -0
  223. package/dist/chunk-4SPZ5IZN.js.br +0 -0
  224. package/dist/chunk-4SPZ5IZN.js.gz +0 -0
  225. package/dist/chunk-64FUV37N.js.br +0 -0
  226. package/dist/chunk-6C2WYLZY.js.br +0 -0
  227. package/dist/chunk-6C2WYLZY.js.gz +0 -0
  228. package/dist/chunk-7FBKS7OS.js.br +0 -0
  229. package/dist/chunk-7FBKS7OS.js.gz +0 -0
  230. package/dist/chunk-7YJBRPCT.mjs.br +0 -0
  231. package/dist/chunk-7YJBRPCT.mjs.gz +0 -0
  232. package/dist/chunk-B4QYQLZU.js.br +0 -0
  233. package/dist/chunk-B4QYQLZU.js.gz +0 -0
  234. package/dist/chunk-E55VEC37.js.br +0 -0
  235. package/dist/chunk-E55VEC37.js.gz +0 -0
  236. package/dist/chunk-IRG7SIUX.js.br +0 -0
  237. package/dist/chunk-IRG7SIUX.js.gz +0 -0
  238. package/dist/chunk-IXKAIIA2.mjs.br +0 -0
  239. package/dist/chunk-IXKAIIA2.mjs.gz +0 -0
  240. package/dist/chunk-KVXB22D3.js.br +0 -0
  241. package/dist/chunk-KVXB22D3.js.gz +0 -0
  242. package/dist/chunk-LAU34UMB.mjs.br +0 -0
  243. package/dist/chunk-OAKDJYYT.mjs.br +0 -0
  244. package/dist/chunk-OAKDJYYT.mjs.gz +0 -0
  245. package/dist/chunk-QTGCOL5H.mjs.br +0 -0
  246. package/dist/chunk-QTGCOL5H.mjs.gz +0 -0
  247. package/dist/chunk-VYSMTC5C.mjs.br +0 -0
  248. package/dist/chunk-VYSMTC5C.mjs.gz +0 -0
  249. package/dist/chunk-XBMKFZVP.mjs.br +0 -0
  250. package/dist/chunk-XBMKFZVP.mjs.gz +0 -0
  251. package/dist/index-CGKutKk1.d.ts +0 -46
  252. package/dist/index-CGKutKk1.d.ts.map +0 -1
  253. package/dist/index.d.ts.map +0 -1
  254. package/dist/internals.d.ts.map +0 -1
  255. package/dist/three.module-AC7ESV4W.mjs +0 -2
  256. package/dist/three.module-AC7ESV4W.mjs.br +0 -0
  257. package/dist/three.module-AC7ESV4W.mjs.gz +0 -0
  258. package/dist/three.module-GNNNRIMK.js.br +0 -0
  259. package/dist/three.module-GNNNRIMK.js.gz +0 -0
  260. package/dist/types-BqB2ZCwS.d.ts +0 -836
  261. package/dist/types-BqB2ZCwS.d.ts.map +0 -1
  262. package/dist/useViewerBuildingBlocks-DkUGmlkP.d.ts +0 -521
  263. package/dist/useViewerBuildingBlocks-DkUGmlkP.d.ts.map +0 -1
  264. package/dist/viewer/index.d.ts.map +0 -1
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- // ../../node_modules/.bun/three@0.185.1/node_modules/three/build/three.core.js
4
- var REVISION = "185";
3
+ // ../../node_modules/.bun/three@0.186.0/node_modules/three/build/three.core.js
4
+ var REVISION = "186";
5
5
  var MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 };
6
6
  var TOUCH = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 };
7
7
  var CullFaceNone = 0;
@@ -227,6 +227,11 @@ var InterpolationSamplingMode = {
227
227
  var Compatibility = {
228
228
  TEXTURE_COMPARE: "depthTextureCompare"
229
229
  };
230
+ var RenderObjectRefreshType = {
231
+ NONE: 0,
232
+ SHARED: 1,
233
+ FULL: 2
234
+ };
230
235
  function arrayNeedsUint32(array) {
231
236
  for (let i = array.length - 1; i >= 0; --i) {
232
237
  if (array[i] >= 65535) return true;
@@ -484,7 +489,7 @@ function radToDeg(radians) {
484
489
  return radians * RAD2DEG;
485
490
  }
486
491
  function isPowerOfTwo(value) {
487
- return (value & value - 1) === 0 && value !== 0;
492
+ return value > 0 && Number.isInteger(value) && 2 ** Math.round(Math.log2(value)) === value;
488
493
  }
489
494
  function ceilPowerOfTwo(value) {
490
495
  return Math.pow(2, Math.ceil(Math.log(value) / Math.LN2));
@@ -535,6 +540,7 @@ function denormalize(value, array) {
535
540
  case Uint16Array:
536
541
  return value / 65535;
537
542
  case Uint8Array:
543
+ case Uint8ClampedArray:
538
544
  return value / 255;
539
545
  case Int32Array:
540
546
  return Math.max(value / 2147483647, -1);
@@ -555,6 +561,7 @@ function normalize(value, array) {
555
561
  case Uint16Array:
556
562
  return Math.round(value * 65535);
557
563
  case Uint8Array:
564
+ case Uint8ClampedArray:
558
565
  return Math.round(value * 255);
559
566
  case Int32Array:
560
567
  return Math.round(value * 2147483647);
@@ -2392,8 +2399,8 @@ var Vector3 = class _Vector3 {
2392
2399
  return this.applyMatrix4(camera.projectionMatrixInverse).applyMatrix4(camera.matrixWorld);
2393
2400
  }
2394
2401
  /**
2395
- * Transforms the direction of this vector by a matrix (the upper left 3 x 3
2396
- * subset of the given 4x4 matrix and then normalizes the result.
2402
+ * Transforms this vector by the upper left 3x3 sub-matrix of the given 4x4 matrix,
2403
+ * and normalizes the result.
2397
2404
  *
2398
2405
  * @param {Matrix4} m - The matrix.
2399
2406
  * @return {Vector3} A reference to this vector.
@@ -3645,14 +3652,14 @@ var ImageUtils = class {
3645
3652
  }
3646
3653
  };
3647
3654
  var _sourceId = 0;
3648
- var Source = class {
3655
+ var TextureSource = class {
3649
3656
  /**
3650
- * Constructs a new video texture.
3657
+ * Constructs a new texture source.
3651
3658
  *
3652
3659
  * @param {any} [data=null] - The data definition of a texture.
3653
3660
  */
3654
3661
  constructor(data = null) {
3655
- this.isSource = true;
3662
+ this.isTextureSource = true;
3656
3663
  Object.defineProperty(this, "id", { value: _sourceId++ });
3657
3664
  this.uuid = generateUUID();
3658
3665
  this.data = data;
@@ -3746,6 +3753,19 @@ function serializeImage(image) {
3746
3753
  }
3747
3754
  }
3748
3755
  }
3756
+ var Source = class extends TextureSource {
3757
+ /**
3758
+ * Constructs a new texture source.
3759
+ *
3760
+ * @param {any} [data=null] - The data definition of a texture.
3761
+ * @deprecated since r186. Use {@link TextureSource} instead.
3762
+ */
3763
+ constructor(data = null) {
3764
+ warnOnce('Source: "Source" has been renamed to "TextureSource". Please update your code to use "THREE.TextureSource" instead.');
3765
+ super(data);
3766
+ this.isSource = true;
3767
+ }
3768
+ };
3749
3769
  var _textureId = 0;
3750
3770
  var _tempVec3 = /* @__PURE__ */ new Vector3();
3751
3771
  var Texture = class _Texture extends EventDispatcher {
@@ -3769,7 +3789,7 @@ var Texture = class _Texture extends EventDispatcher {
3769
3789
  Object.defineProperty(this, "id", { value: _textureId++ });
3770
3790
  this.uuid = generateUUID();
3771
3791
  this.name = "";
3772
- this.source = new Source(image);
3792
+ this.source = new TextureSource(image);
3773
3793
  this.mipmaps = [];
3774
3794
  this.mapping = mapping;
3775
3795
  this.channel = 0;
@@ -4812,8 +4832,12 @@ var RenderTarget = class extends EventDispatcher {
4812
4832
  * @property {string} [colorSpace=NoColorSpace] - The texture's color space.
4813
4833
  * @property {boolean} [depthBuffer=true] - Whether to allocate a depth buffer or not.
4814
4834
  * @property {boolean} [stencilBuffer=false] - Whether to allocate a stencil buffer or not.
4815
- * @property {boolean} [resolveDepthBuffer=true] - Whether to resolve the depth buffer or not.
4816
- * @property {boolean} [resolveStencilBuffer=true] - Whether to resolve the stencil buffer or not.
4835
+ * @property {boolean} [resolveColorBuffer=true] - Whether to resolve the color buffer or not. Only relevant for multisampled render targets.
4836
+ * @property {boolean} [resolveDepthBuffer=true] - Whether to resolve the depth buffer or not. Only relevant for multisampled render targets.
4837
+ * @property {boolean} [resolveStencilBuffer=true] - Whether to resolve the stencil buffer or not. Only relevant for multisampled render targets.
4838
+ * @property {boolean} [storeMultisampledColorBuffer=true] - Whether to store the multisampled color buffer or not. Setting to `false` saves memory bandwidth when the multisampled data are not needed after a render pass.
4839
+ * @property {boolean} [storeMultisampledDepthBuffer=true] - Whether to store the multisampled depth buffer or not. Setting to `false` saves memory bandwidth when the multisampled data are not needed after a render pass.
4840
+ * @property {boolean} [storeMultisampledStencilBuffer=true] - Whether to store the multisampled stencil buffer or not. Setting to `false` saves memory bandwidth when the multisampled data are not needed after a render pass.
4817
4841
  * @property {?Texture} [depthTexture=null] - Reference to a depth texture.
4818
4842
  * @property {number} [samples=0] - The MSAA samples count.
4819
4843
  * @property {number} [count=1] - Defines the number of color attachments . Must be at least `1`.
@@ -4836,8 +4860,12 @@ var RenderTarget = class extends EventDispatcher {
4836
4860
  minFilter: LinearFilter,
4837
4861
  depthBuffer: true,
4838
4862
  stencilBuffer: false,
4863
+ resolveColorBuffer: true,
4839
4864
  resolveDepthBuffer: true,
4840
4865
  resolveStencilBuffer: true,
4866
+ storeMultisampledColorBuffer: true,
4867
+ storeMultisampledDepthBuffer: true,
4868
+ storeMultisampledStencilBuffer: true,
4841
4869
  depthTexture: null,
4842
4870
  samples: 0,
4843
4871
  count: 1,
@@ -4864,8 +4892,12 @@ var RenderTarget = class extends EventDispatcher {
4864
4892
  this._setTextureOptions(options);
4865
4893
  this.depthBuffer = options.depthBuffer;
4866
4894
  this.stencilBuffer = options.stencilBuffer;
4895
+ this.resolveColorBuffer = options.resolveColorBuffer;
4867
4896
  this.resolveDepthBuffer = options.resolveDepthBuffer;
4868
4897
  this.resolveStencilBuffer = options.resolveStencilBuffer;
4898
+ this.storeMultisampledColorBuffer = options.storeMultisampledColorBuffer;
4899
+ this.storeMultisampledDepthBuffer = options.storeMultisampledDepthBuffer;
4900
+ this.storeMultisampledStencilBuffer = options.storeMultisampledStencilBuffer;
4869
4901
  this._depthTexture = null;
4870
4902
  this.depthTexture = options.depthTexture;
4871
4903
  this.samples = options.samples;
@@ -4909,8 +4941,8 @@ var RenderTarget = class extends EventDispatcher {
4909
4941
  this.textures[0] = value;
4910
4942
  }
4911
4943
  set depthTexture(current) {
4912
- if (this._depthTexture !== null) this._depthTexture.renderTarget = null;
4913
- if (current !== null) current.renderTarget = this;
4944
+ if (this._depthTexture !== null && this._depthTexture.renderTarget === this) this._depthTexture.renderTarget = null;
4945
+ if (current !== null && current.renderTarget === null) current.renderTarget = this;
4914
4946
  this._depthTexture = current;
4915
4947
  }
4916
4948
  /**
@@ -4978,13 +5010,25 @@ var RenderTarget = class extends EventDispatcher {
4978
5010
  this.textures[i].isRenderTargetTexture = true;
4979
5011
  this.textures[i].renderTarget = this;
4980
5012
  const image = Object.assign({}, source.textures[i].image);
4981
- this.textures[i].source = new Source(image);
5013
+ this.textures[i].source = new TextureSource(image);
4982
5014
  }
4983
5015
  this.depthBuffer = source.depthBuffer;
4984
5016
  this.stencilBuffer = source.stencilBuffer;
5017
+ this.resolveColorBuffer = source.resolveColorBuffer;
4985
5018
  this.resolveDepthBuffer = source.resolveDepthBuffer;
4986
5019
  this.resolveStencilBuffer = source.resolveStencilBuffer;
4987
- if (source.depthTexture !== null) this.depthTexture = source.depthTexture.clone();
5020
+ this.storeMultisampledColorBuffer = source.storeMultisampledColorBuffer;
5021
+ this.storeMultisampledDepthBuffer = source.storeMultisampledDepthBuffer;
5022
+ this.storeMultisampledStencilBuffer = source.storeMultisampledStencilBuffer;
5023
+ if (source.depthTexture !== null) {
5024
+ if (source.depthTexture.renderTarget === source) {
5025
+ const depthTexture = source.depthTexture.clone();
5026
+ depthTexture.renderTarget = null;
5027
+ this.depthTexture = depthTexture;
5028
+ } else {
5029
+ this.depthTexture = source.depthTexture;
5030
+ }
5031
+ }
4988
5032
  this.samples = source.samples;
4989
5033
  this.multiview = source.multiview;
4990
5034
  this.useArrayDepthTexture = source.useArrayDepthTexture;
@@ -5034,6 +5078,17 @@ var DataArrayTexture = class extends Texture {
5034
5078
  this.unpackAlignment = 1;
5035
5079
  this.layerUpdates = /* @__PURE__ */ new Set();
5036
5080
  }
5081
+ /**
5082
+ * Copies the values of the given texture to this instance.
5083
+ *
5084
+ * @param {DataArrayTexture} source - The texture to copy.
5085
+ * @return {DataArrayTexture} A reference to this instance.
5086
+ */
5087
+ copy(source) {
5088
+ super.copy(source);
5089
+ this.wrapR = source.wrapR;
5090
+ return this;
5091
+ }
5037
5092
  /**
5038
5093
  * Describes that a specific layer of the texture needs to be updated.
5039
5094
  * Normally when {@link Texture#needsUpdate} is set to `true`, the
@@ -5091,6 +5146,17 @@ var Data3DTexture = class extends Texture {
5091
5146
  this.flipY = false;
5092
5147
  this.unpackAlignment = 1;
5093
5148
  }
5149
+ /**
5150
+ * Copies the values of the given texture to this instance.
5151
+ *
5152
+ * @param {Data3DTexture} source - The texture to copy.
5153
+ * @return {Data3DTexture} A reference to this instance.
5154
+ */
5155
+ copy(source) {
5156
+ super.copy(source);
5157
+ this.wrapR = source.wrapR;
5158
+ return this;
5159
+ }
5094
5160
  };
5095
5161
  var WebGL3DRenderTarget = class extends WebGLRenderTarget {
5096
5162
  /**
@@ -5305,7 +5371,7 @@ var Matrix4 = class _Matrix4 {
5305
5371
  return this;
5306
5372
  }
5307
5373
  /**
5308
- * Extracts the basis of this matrix into the three axis vectors provided.
5374
+ * Extracts the basis vectors of this matrix into the three vectors provided.
5309
5375
  *
5310
5376
  * @param {Vector3} xAxis - The basis's x axis.
5311
5377
  * @param {Vector3} yAxis - The basis's y axis.
@@ -5616,8 +5682,6 @@ var Matrix4 = class _Matrix4 {
5616
5682
  /**
5617
5683
  * Computes and returns the determinant of this matrix.
5618
5684
  *
5619
- * Based on the method outlined [here](http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.html).
5620
- *
5621
5685
  * @return {number} The determinant.
5622
5686
  */
5623
5687
  determinant() {
@@ -5733,7 +5797,7 @@ var Matrix4 = class _Matrix4 {
5733
5797
  return this;
5734
5798
  }
5735
5799
  /**
5736
- * Multiplies the columns of this matrix by the given vector.
5800
+ * Scales each of the first three columns of this matrix by the corresponding component of the given vector.
5737
5801
  *
5738
5802
  * @param {Vector3} v - The scale vector.
5739
5803
  * @return {Matrix4} A reference to this matrix.
@@ -5908,9 +5972,6 @@ var Matrix4 = class _Matrix4 {
5908
5972
  * Sets this matrix as a rotational transformation around the given axis by
5909
5973
  * the given angle.
5910
5974
  *
5911
- * This is a somewhat controversial but mathematically sound alternative to
5912
- * rotating via Quaternions. See the discussion [here](https://www.gamedev.net/articles/programming/math-and-physics/do-we-really-need-quaternions-r1199).
5913
- *
5914
5975
  * @param {Vector3} axis - The normalized rotation axis.
5915
5976
  * @param {number} angle - The rotation in radians.
5916
5977
  * @return {Matrix4} A reference to this matrix.
@@ -7198,6 +7259,17 @@ var Object3D = class _Object3D extends EventDispatcher {
7198
7259
  */
7199
7260
  raycast() {
7200
7261
  }
7262
+ /**
7263
+ * Abstract method to test whether this 3D object intersects the given frustum.
7264
+ * Renderable 3D objects such as {@link Mesh}, {@link Line} or {@link Points}
7265
+ * implement this method in order to use frustum culling.
7266
+ *
7267
+ * @abstract
7268
+ * @param {Frustum|FrustumArray} frustum - The frustum to test.
7269
+ * @return {boolean|undefined} Whether this 3D object intersects the given frustum or not.
7270
+ */
7271
+ intersectsFrustum() {
7272
+ }
7201
7273
  /**
7202
7274
  * Executes the callback on this 3D object and all descendants.
7203
7275
  *
@@ -7352,19 +7424,19 @@ var Object3D = class _Object3D extends EventDispatcher {
7352
7424
  const object = {};
7353
7425
  object.uuid = this.uuid;
7354
7426
  object.type = this.type;
7355
- if (this.name !== "") object.name = this.name;
7356
- if (this.castShadow === true) object.castShadow = true;
7357
- if (this.receiveShadow === true) object.receiveShadow = true;
7358
- if (this.visible === false) object.visible = false;
7359
- if (this.frustumCulled === false) object.frustumCulled = false;
7360
- if (this.renderOrder !== 0) object.renderOrder = this.renderOrder;
7361
- if (this.static !== false) object.static = this.static;
7427
+ object.name = this.name;
7428
+ object.castShadow = this.castShadow;
7429
+ object.receiveShadow = this.receiveShadow;
7430
+ object.visible = this.visible;
7431
+ object.frustumCulled = this.frustumCulled;
7432
+ object.renderOrder = this.renderOrder;
7433
+ object.static = this.static;
7434
+ object.matrixAutoUpdate = this.matrixAutoUpdate;
7362
7435
  if (Object.keys(this.userData).length > 0) object.userData = this.userData;
7363
7436
  object.layers = this.layers.mask;
7364
7437
  object.matrix = this.matrix.toArray();
7365
7438
  object.up = this.up.toArray();
7366
7439
  if (this.pivot !== null) object.pivot = this.pivot.toArray();
7367
- if (this.matrixAutoUpdate === false) object.matrixAutoUpdate = false;
7368
7440
  if (this.morphTargetDictionary !== void 0) object.morphTargetDictionary = Object.assign({}, this.morphTargetDictionary);
7369
7441
  if (this.morphTargetInfluences !== void 0) object.morphTargetInfluences = this.morphTargetInfluences.slice();
7370
7442
  if (this.isInstancedMesh) {
@@ -7546,6 +7618,18 @@ var Object3D = class _Object3D extends EventDispatcher {
7546
7618
  }
7547
7619
  return this;
7548
7620
  }
7621
+ /**
7622
+ * Frees the GPU-related resources allocated by this instance. Call this
7623
+ * method whenever this instance is no longer used in your app.
7624
+ *
7625
+ * Geometries, materials and textures are potentially shared with other
7626
+ * 3D objects and must be disposed of separately.
7627
+ *
7628
+ * @fires Object3D#dispose
7629
+ */
7630
+ dispose() {
7631
+ this.dispatchEvent({ type: "dispose" });
7632
+ }
7549
7633
  };
7550
7634
  Object3D.DEFAULT_UP = /* @__PURE__ */ new Vector3(0, 1, 0);
7551
7635
  Object3D.DEFAULT_MATRIX_AUTO_UPDATE = true;
@@ -8673,10 +8757,10 @@ var Scene = class extends Object3D {
8673
8757
  toJSON(meta) {
8674
8758
  const data = super.toJSON(meta);
8675
8759
  if (this.fog !== null) data.object.fog = this.fog.toJSON();
8676
- if (this.backgroundBlurriness > 0) data.object.backgroundBlurriness = this.backgroundBlurriness;
8677
- if (this.backgroundIntensity !== 1) data.object.backgroundIntensity = this.backgroundIntensity;
8760
+ data.object.backgroundBlurriness = this.backgroundBlurriness;
8761
+ data.object.backgroundIntensity = this.backgroundIntensity;
8678
8762
  data.object.backgroundRotation = this.backgroundRotation.toArray();
8679
- if (this.environmentIntensity !== 1) data.object.environmentIntensity = this.environmentIntensity;
8763
+ data.object.environmentIntensity = this.environmentIntensity;
8680
8764
  data.object.environmentRotation = this.environmentRotation.toArray();
8681
8765
  return data;
8682
8766
  }
@@ -10117,8 +10201,9 @@ var BufferAttribute = class extends EventDispatcher {
10117
10201
  array: Array.from(this.array),
10118
10202
  normalized: this.normalized
10119
10203
  };
10120
- if (this.name !== "") data.name = this.name;
10121
- if (this.usage !== StaticDrawUsage) data.usage = this.usage;
10204
+ data.name = this.name;
10205
+ data.usage = this.usage;
10206
+ data.gpuType = this.gpuType;
10122
10207
  return data;
10123
10208
  }
10124
10209
  /**
@@ -11239,7 +11324,7 @@ var BufferGeometry = class _BufferGeometry extends EventDispatcher {
11239
11324
  };
11240
11325
  data.uuid = this.uuid;
11241
11326
  data.type = this.parameters !== void 0 && this._transformed === true ? "BufferGeometry" : this.type;
11242
- if (this.name !== "") data.name = this.name;
11327
+ data.name = this.name;
11243
11328
  if (Object.keys(this.userData).length > 0) data.userData = this.userData;
11244
11329
  if (this.parameters !== void 0 && this._transformed !== true) {
11245
11330
  const parameters = this.parameters;
@@ -11510,12 +11595,14 @@ var InterleavedBuffer = class {
11510
11595
  if (data.arrayBuffers[this.array.buffer._uuid] === void 0) {
11511
11596
  data.arrayBuffers[this.array.buffer._uuid] = Array.from(new Uint32Array(this.array.buffer));
11512
11597
  }
11513
- return {
11598
+ const json = {
11514
11599
  uuid: this.uuid,
11515
11600
  buffer: this.array.buffer._uuid,
11516
11601
  type: this.array.constructor.name,
11517
11602
  stride: this.stride
11518
11603
  };
11604
+ json.usage = this.usage;
11605
+ return json;
11519
11606
  }
11520
11607
  };
11521
11608
  var _vector$8 = /* @__PURE__ */ new Vector3();
@@ -11859,6 +11946,270 @@ var InterleavedBufferAttribute = class _InterleavedBufferAttribute {
11859
11946
  }
11860
11947
  }
11861
11948
  };
11949
+ var _vector1 = /* @__PURE__ */ new Vector3();
11950
+ var _vector2 = /* @__PURE__ */ new Vector3();
11951
+ var _normalMatrix = /* @__PURE__ */ new Matrix3();
11952
+ var Plane = class {
11953
+ /**
11954
+ * Constructs a new plane.
11955
+ *
11956
+ * @param {Vector3} [normal=(1,0,0)] - A unit length vector defining the normal of the plane.
11957
+ * @param {number} [constant=0] - The signed distance from the origin to the plane.
11958
+ */
11959
+ constructor(normal = new Vector3(1, 0, 0), constant = 0) {
11960
+ this.isPlane = true;
11961
+ this.normal = normal;
11962
+ this.constant = constant;
11963
+ }
11964
+ /**
11965
+ * Sets the plane components by copying the given values.
11966
+ *
11967
+ * @param {Vector3} normal - The normal.
11968
+ * @param {number} constant - The constant.
11969
+ * @return {Plane} A reference to this plane.
11970
+ */
11971
+ set(normal, constant) {
11972
+ this.normal.copy(normal);
11973
+ this.constant = constant;
11974
+ return this;
11975
+ }
11976
+ /**
11977
+ * Sets the plane components by defining `x`, `y`, `z` as the
11978
+ * plane normal and `w` as the constant.
11979
+ *
11980
+ * @param {number} x - The value for the normal's x component.
11981
+ * @param {number} y - The value for the normal's y component.
11982
+ * @param {number} z - The value for the normal's z component.
11983
+ * @param {number} w - The constant value.
11984
+ * @return {Plane} A reference to this plane.
11985
+ */
11986
+ setComponents(x, y, z, w) {
11987
+ this.normal.set(x, y, z);
11988
+ this.constant = w;
11989
+ return this;
11990
+ }
11991
+ /**
11992
+ * Sets the plane from the given normal and coplanar point (that is a point
11993
+ * that lies onto the plane).
11994
+ *
11995
+ * @param {Vector3} normal - The normal.
11996
+ * @param {Vector3} point - A coplanar point.
11997
+ * @return {Plane} A reference to this plane.
11998
+ */
11999
+ setFromNormalAndCoplanarPoint(normal, point) {
12000
+ this.normal.copy(normal);
12001
+ this.constant = -point.dot(this.normal);
12002
+ return this;
12003
+ }
12004
+ /**
12005
+ * Sets the plane from three coplanar points. The winding order is
12006
+ * assumed to be counter-clockwise, and determines the direction of
12007
+ * the plane normal.
12008
+ *
12009
+ * @param {Vector3} a - The first coplanar point.
12010
+ * @param {Vector3} b - The second coplanar point.
12011
+ * @param {Vector3} c - The third coplanar point.
12012
+ * @return {Plane} A reference to this plane.
12013
+ */
12014
+ setFromCoplanarPoints(a, b, c) {
12015
+ const normal = _vector1.subVectors(c, b).cross(_vector2.subVectors(a, b)).normalize();
12016
+ this.setFromNormalAndCoplanarPoint(normal, a);
12017
+ return this;
12018
+ }
12019
+ /**
12020
+ * Copies the values of the given plane to this instance.
12021
+ *
12022
+ * @param {Plane} plane - The plane to copy.
12023
+ * @return {Plane} A reference to this plane.
12024
+ */
12025
+ copy(plane) {
12026
+ this.normal.copy(plane.normal);
12027
+ this.constant = plane.constant;
12028
+ return this;
12029
+ }
12030
+ /**
12031
+ * Normalizes the plane normal and adjusts the constant accordingly.
12032
+ *
12033
+ * @return {Plane} A reference to this plane.
12034
+ */
12035
+ normalize() {
12036
+ const inverseNormalLength = 1 / this.normal.length();
12037
+ this.normal.multiplyScalar(inverseNormalLength);
12038
+ this.constant *= inverseNormalLength;
12039
+ return this;
12040
+ }
12041
+ /**
12042
+ * Negates both the plane normal and the constant.
12043
+ *
12044
+ * @return {Plane} A reference to this plane.
12045
+ */
12046
+ negate() {
12047
+ this.constant *= -1;
12048
+ this.normal.negate();
12049
+ return this;
12050
+ }
12051
+ /**
12052
+ * Returns the signed distance from the given point to this plane.
12053
+ *
12054
+ * @param {Vector3} point - The point to compute the distance for.
12055
+ * @return {number} The signed distance.
12056
+ */
12057
+ distanceToPoint(point) {
12058
+ return this.normal.dot(point) + this.constant;
12059
+ }
12060
+ /**
12061
+ * Returns the signed distance from the given sphere to this plane.
12062
+ *
12063
+ * @param {Sphere} sphere - The sphere to compute the distance for.
12064
+ * @return {number} The signed distance.
12065
+ */
12066
+ distanceToSphere(sphere) {
12067
+ return this.distanceToPoint(sphere.center) - sphere.radius;
12068
+ }
12069
+ /**
12070
+ * Projects a the given point onto the plane.
12071
+ *
12072
+ * @param {Vector3} point - The point to project.
12073
+ * @param {Vector3} target - The target vector that is used to store the method's result.
12074
+ * @return {Vector3} The projected point on the plane.
12075
+ */
12076
+ projectPoint(point, target) {
12077
+ return target.copy(point).addScaledVector(this.normal, -this.distanceToPoint(point));
12078
+ }
12079
+ /**
12080
+ * Returns the intersection point of the passed line and the plane. Returns
12081
+ * `null` if the line does not intersect. Returns the line's starting point if
12082
+ * the line is coplanar with the plane.
12083
+ *
12084
+ * @param {Line3} line - The line to compute the intersection for.
12085
+ * @param {Vector3} target - The target vector that is used to store the method's result.
12086
+ * @param {boolean} [clampToLine=true] - Whether to clamp the intersection to the line segment.
12087
+ * @return {?Vector3} The intersection point. Returns `null` if no intersection is detected.
12088
+ */
12089
+ intersectLine(line, target, clampToLine = true) {
12090
+ const direction = line.delta(_vector1);
12091
+ const denominator = this.normal.dot(direction);
12092
+ if (denominator === 0) {
12093
+ if (this.distanceToPoint(line.start) === 0) {
12094
+ return target.copy(line.start);
12095
+ }
12096
+ return null;
12097
+ }
12098
+ const t = -(line.start.dot(this.normal) + this.constant) / denominator;
12099
+ if (clampToLine === true && (t < 0 || t > 1)) {
12100
+ return null;
12101
+ }
12102
+ return target.copy(line.start).addScaledVector(direction, t);
12103
+ }
12104
+ /**
12105
+ * Returns `true` if the given line segment intersects with (passes through) the plane.
12106
+ *
12107
+ * @param {Line3} line - The line to test.
12108
+ * @return {boolean} Whether the given line segment intersects with the plane or not.
12109
+ */
12110
+ intersectsLine(line) {
12111
+ const startSign = this.distanceToPoint(line.start);
12112
+ const endSign = this.distanceToPoint(line.end);
12113
+ return startSign < 0 && endSign > 0 || endSign < 0 && startSign > 0;
12114
+ }
12115
+ /**
12116
+ * Returns `true` if the given bounding box intersects with the plane.
12117
+ *
12118
+ * @param {Box3} box - The bounding box to test.
12119
+ * @return {boolean} Whether the given bounding box intersects with the plane or not.
12120
+ */
12121
+ intersectsBox(box) {
12122
+ return box.intersectsPlane(this);
12123
+ }
12124
+ /**
12125
+ * Returns `true` if the given bounding sphere intersects with the plane.
12126
+ *
12127
+ * @param {Sphere} sphere - The bounding sphere to test.
12128
+ * @return {boolean} Whether the given bounding sphere intersects with the plane or not.
12129
+ */
12130
+ intersectsSphere(sphere) {
12131
+ return sphere.intersectsPlane(this);
12132
+ }
12133
+ /**
12134
+ * Returns a coplanar vector to the plane, by calculating the
12135
+ * projection of the normal at the origin onto the plane.
12136
+ *
12137
+ * @param {Vector3} target - The target vector that is used to store the method's result.
12138
+ * @return {Vector3} The coplanar point.
12139
+ */
12140
+ coplanarPoint(target) {
12141
+ return target.copy(this.normal).multiplyScalar(-this.constant);
12142
+ }
12143
+ /**
12144
+ * Apply a 4x4 matrix to the plane. The matrix must be an affine, homogeneous transform.
12145
+ *
12146
+ * The optional normal matrix can be pre-computed like so:
12147
+ * ```js
12148
+ * const optionalNormalMatrix = new THREE.Matrix3().getNormalMatrix( matrix );
12149
+ * ```
12150
+ *
12151
+ * @param {Matrix4} matrix - The transformation matrix.
12152
+ * @param {Matrix4} [optionalNormalMatrix] - A pre-computed normal matrix.
12153
+ * @return {Plane} A reference to this plane.
12154
+ */
12155
+ applyMatrix4(matrix, optionalNormalMatrix) {
12156
+ const normalMatrix = optionalNormalMatrix || _normalMatrix.getNormalMatrix(matrix);
12157
+ const referencePoint = this.coplanarPoint(_vector1).applyMatrix4(matrix);
12158
+ const normal = this.normal.applyMatrix3(normalMatrix).normalize();
12159
+ this.constant = -referencePoint.dot(normal);
12160
+ return this;
12161
+ }
12162
+ /**
12163
+ * Translates the plane by the distance defined by the given offset vector.
12164
+ * Note that this only affects the plane constant and will not affect the normal vector.
12165
+ *
12166
+ * @param {Vector3} offset - The offset vector.
12167
+ * @return {Plane} A reference to this plane.
12168
+ */
12169
+ translate(offset) {
12170
+ this.constant -= offset.dot(this.normal);
12171
+ return this;
12172
+ }
12173
+ /**
12174
+ * Returns `true` if this plane is equal with the given one.
12175
+ *
12176
+ * @param {Plane} plane - The plane to test for equality.
12177
+ * @return {boolean} Whether this plane is equal with the given one.
12178
+ */
12179
+ equals(plane) {
12180
+ return plane.normal.equals(this.normal) && plane.constant === this.constant;
12181
+ }
12182
+ /**
12183
+ * Returns a new plane with copied values from this instance.
12184
+ *
12185
+ * @return {Plane} A clone of this instance.
12186
+ */
12187
+ clone() {
12188
+ return new this.constructor().copy(this);
12189
+ }
12190
+ /**
12191
+ * Returns a serialized structure of the plane.
12192
+ *
12193
+ * @return {Object} Serialized structure with fields representing the object state.
12194
+ */
12195
+ toJSON() {
12196
+ return {
12197
+ normal: this.normal.toArray(),
12198
+ constant: this.constant
12199
+ };
12200
+ }
12201
+ /**
12202
+ * Sets the plane properties from the given JSON.
12203
+ *
12204
+ * @param {Object} json - The serialized json to set the plane from.
12205
+ * @return {Plane} A reference to this plane.
12206
+ */
12207
+ fromJSON(json) {
12208
+ this.normal.fromArray(json.normal);
12209
+ this.constant = json.constant;
12210
+ return this;
12211
+ }
12212
+ };
11862
12213
  var _materialId = 0;
11863
12214
  var Material = class extends EventDispatcher {
11864
12215
  /**
@@ -12026,7 +12377,47 @@ var Material = class extends EventDispatcher {
12026
12377
  };
12027
12378
  data.uuid = this.uuid;
12028
12379
  data.type = this.type;
12029
- if (this.name !== "") data.name = this.name;
12380
+ data.blending = this.blending;
12381
+ data.side = this.side;
12382
+ data.shadowSide = this.shadowSide;
12383
+ data.vertexColors = this.vertexColors;
12384
+ data.opacity = this.opacity;
12385
+ data.transparent = this.transparent;
12386
+ data.blendSrc = this.blendSrc;
12387
+ data.blendDst = this.blendDst;
12388
+ data.blendEquation = this.blendEquation;
12389
+ data.blendSrcAlpha = this.blendSrcAlpha;
12390
+ data.blendDstAlpha = this.blendDstAlpha;
12391
+ data.blendEquationAlpha = this.blendEquationAlpha;
12392
+ data.blendColor = this.blendColor.getHex();
12393
+ data.blendAlpha = this.blendAlpha;
12394
+ data.depthFunc = this.depthFunc;
12395
+ data.depthTest = this.depthTest;
12396
+ data.depthWrite = this.depthWrite;
12397
+ data.colorWrite = this.colorWrite;
12398
+ data.clipIntersection = this.clipIntersection;
12399
+ data.clipShadows = this.clipShadows;
12400
+ data.stencilWriteMask = this.stencilWriteMask;
12401
+ data.stencilFunc = this.stencilFunc;
12402
+ data.stencilRef = this.stencilRef;
12403
+ data.stencilFuncMask = this.stencilFuncMask;
12404
+ data.stencilFail = this.stencilFail;
12405
+ data.stencilZFail = this.stencilZFail;
12406
+ data.stencilZPass = this.stencilZPass;
12407
+ data.stencilWrite = this.stencilWrite;
12408
+ data.polygonOffset = this.polygonOffset;
12409
+ data.polygonOffsetFactor = this.polygonOffsetFactor;
12410
+ data.polygonOffsetUnits = this.polygonOffsetUnits;
12411
+ data.dithering = this.dithering;
12412
+ data.alphaTest = this.alphaTest;
12413
+ data.alphaHash = this.alphaHash;
12414
+ data.alphaToCoverage = this.alphaToCoverage;
12415
+ data.premultipliedAlpha = this.premultipliedAlpha;
12416
+ data.forceSinglePass = this.forceSinglePass;
12417
+ data.allowOverride = this.allowOverride;
12418
+ data.visible = this.visible;
12419
+ data.toneMapped = this.toneMapped;
12420
+ data.name = this.name;
12030
12421
  if (this.color && this.color.isColor) data.color = this.color.getHex();
12031
12422
  if (this.roughness !== void 0) data.roughness = this.roughness;
12032
12423
  if (this.metalness !== void 0) data.metalness = this.metalness;
@@ -12034,7 +12425,7 @@ var Material = class extends EventDispatcher {
12034
12425
  if (this.sheenColor && this.sheenColor.isColor) data.sheenColor = this.sheenColor.getHex();
12035
12426
  if (this.sheenRoughness !== void 0) data.sheenRoughness = this.sheenRoughness;
12036
12427
  if (this.emissive && this.emissive.isColor) data.emissive = this.emissive.getHex();
12037
- if (this.emissiveIntensity !== void 0 && this.emissiveIntensity !== 1) data.emissiveIntensity = this.emissiveIntensity;
12428
+ if (this.emissiveIntensity !== void 0) data.emissiveIntensity = this.emissiveIntensity;
12038
12429
  if (this.specular && this.specular.isColor) data.specular = this.specular.getHex();
12039
12430
  if (this.specularIntensity !== void 0) data.specularIntensity = this.specularIntensity;
12040
12431
  if (this.specularColor && this.specularColor.isColor) data.specularColor = this.specularColor.getHex();
@@ -12058,6 +12449,7 @@ var Material = class extends EventDispatcher {
12058
12449
  data.sheenRoughnessMap = this.sheenRoughnessMap.toJSON(meta).uuid;
12059
12450
  }
12060
12451
  if (this.dispersion !== void 0) data.dispersion = this.dispersion;
12452
+ if (this.retroreflectivity !== void 0) data.retroreflectivity = this.retroreflectivity;
12061
12453
  if (this.iridescence !== void 0) data.iridescence = this.iridescence;
12062
12454
  if (this.iridescenceIOR !== void 0) data.iridescenceIOR = this.iridescenceIOR;
12063
12455
  if (this.iridescenceThicknessRange !== void 0) data.iridescenceThicknessRange = this.iridescenceThicknessRange;
@@ -12118,59 +12510,27 @@ var Material = class extends EventDispatcher {
12118
12510
  if (this.transmissionMap && this.transmissionMap.isTexture) data.transmissionMap = this.transmissionMap.toJSON(meta).uuid;
12119
12511
  if (this.thickness !== void 0) data.thickness = this.thickness;
12120
12512
  if (this.thicknessMap && this.thicknessMap.isTexture) data.thicknessMap = this.thicknessMap.toJSON(meta).uuid;
12121
- if (this.attenuationDistance !== void 0 && this.attenuationDistance !== Infinity) data.attenuationDistance = this.attenuationDistance;
12513
+ if (this.attenuationDistance !== void 0) data.attenuationDistance = this.attenuationDistance;
12122
12514
  if (this.attenuationColor !== void 0) data.attenuationColor = this.attenuationColor.getHex();
12123
12515
  if (this.size !== void 0) data.size = this.size;
12124
- if (this.shadowSide !== null) data.shadowSide = this.shadowSide;
12125
12516
  if (this.sizeAttenuation !== void 0) data.sizeAttenuation = this.sizeAttenuation;
12126
- if (this.blending !== NormalBlending) data.blending = this.blending;
12127
- if (this.side !== FrontSide) data.side = this.side;
12128
- if (this.vertexColors === true) data.vertexColors = true;
12129
- if (this.opacity < 1) data.opacity = this.opacity;
12130
- if (this.transparent === true) data.transparent = true;
12131
- if (this.blendSrc !== SrcAlphaFactor) data.blendSrc = this.blendSrc;
12132
- if (this.blendDst !== OneMinusSrcAlphaFactor) data.blendDst = this.blendDst;
12133
- if (this.blendEquation !== AddEquation) data.blendEquation = this.blendEquation;
12134
- if (this.blendSrcAlpha !== null) data.blendSrcAlpha = this.blendSrcAlpha;
12135
- if (this.blendDstAlpha !== null) data.blendDstAlpha = this.blendDstAlpha;
12136
- if (this.blendEquationAlpha !== null) data.blendEquationAlpha = this.blendEquationAlpha;
12137
- if (this.blendColor && this.blendColor.isColor) data.blendColor = this.blendColor.getHex();
12138
- if (this.blendAlpha !== 0) data.blendAlpha = this.blendAlpha;
12139
- if (this.depthFunc !== LessEqualDepth) data.depthFunc = this.depthFunc;
12140
- if (this.depthTest === false) data.depthTest = this.depthTest;
12141
- if (this.depthWrite === false) data.depthWrite = this.depthWrite;
12142
- if (this.colorWrite === false) data.colorWrite = this.colorWrite;
12143
- if (this.stencilWriteMask !== 255) data.stencilWriteMask = this.stencilWriteMask;
12144
- if (this.stencilFunc !== AlwaysStencilFunc) data.stencilFunc = this.stencilFunc;
12145
- if (this.stencilRef !== 0) data.stencilRef = this.stencilRef;
12146
- if (this.stencilFuncMask !== 255) data.stencilFuncMask = this.stencilFuncMask;
12147
- if (this.stencilFail !== KeepStencilOp) data.stencilFail = this.stencilFail;
12148
- if (this.stencilZFail !== KeepStencilOp) data.stencilZFail = this.stencilZFail;
12149
- if (this.stencilZPass !== KeepStencilOp) data.stencilZPass = this.stencilZPass;
12150
- if (this.stencilWrite === true) data.stencilWrite = this.stencilWrite;
12151
- if (this.rotation !== void 0 && this.rotation !== 0) data.rotation = this.rotation;
12152
- if (this.polygonOffset === true) data.polygonOffset = true;
12153
- if (this.polygonOffsetFactor !== 0) data.polygonOffsetFactor = this.polygonOffsetFactor;
12154
- if (this.polygonOffsetUnits !== 0) data.polygonOffsetUnits = this.polygonOffsetUnits;
12155
- if (this.linewidth !== void 0 && this.linewidth !== 1) data.linewidth = this.linewidth;
12517
+ if (Array.isArray(this.clippingPlanes) && this.clippingPlanes.length > 0) {
12518
+ data.clippingPlanes = this.clippingPlanes.map((plane) => plane.toJSON());
12519
+ }
12520
+ if (this.rotation !== void 0) data.rotation = this.rotation;
12521
+ if (this.depthPacking !== void 0) data.depthPacking = this.depthPacking;
12522
+ if (this.linewidth !== void 0) data.linewidth = this.linewidth;
12523
+ if (this.linecap !== void 0) data.linecap = this.linecap;
12524
+ if (this.linejoin !== void 0) data.linejoin = this.linejoin;
12156
12525
  if (this.dashSize !== void 0) data.dashSize = this.dashSize;
12157
12526
  if (this.gapSize !== void 0) data.gapSize = this.gapSize;
12158
12527
  if (this.scale !== void 0) data.scale = this.scale;
12159
- if (this.dithering === true) data.dithering = true;
12160
- if (this.alphaTest > 0) data.alphaTest = this.alphaTest;
12161
- if (this.alphaHash === true) data.alphaHash = true;
12162
- if (this.alphaToCoverage === true) data.alphaToCoverage = true;
12163
- if (this.premultipliedAlpha === true) data.premultipliedAlpha = true;
12164
- if (this.forceSinglePass === true) data.forceSinglePass = true;
12165
- if (this.allowOverride === false) data.allowOverride = false;
12166
- if (this.wireframe === true) data.wireframe = true;
12167
- if (this.wireframeLinewidth > 1) data.wireframeLinewidth = this.wireframeLinewidth;
12168
- if (this.wireframeLinecap !== "round") data.wireframeLinecap = this.wireframeLinecap;
12169
- if (this.wireframeLinejoin !== "round") data.wireframeLinejoin = this.wireframeLinejoin;
12170
- if (this.flatShading === true) data.flatShading = true;
12171
- if (this.visible === false) data.visible = false;
12172
- if (this.toneMapped === false) data.toneMapped = false;
12173
- if (this.fog === false) data.fog = false;
12528
+ if (this.wireframe !== void 0) data.wireframe = this.wireframe;
12529
+ if (this.wireframeLinewidth !== void 0) data.wireframeLinewidth = this.wireframeLinewidth;
12530
+ if (this.wireframeLinecap !== void 0) data.wireframeLinecap = this.wireframeLinecap;
12531
+ if (this.wireframeLinejoin !== void 0) data.wireframeLinejoin = this.wireframeLinejoin;
12532
+ if (this.flatShading !== void 0) data.flatShading = this.flatShading;
12533
+ if (this.fog !== void 0) data.fog = this.fog;
12174
12534
  if (Object.keys(this.userData).length > 0) data.userData = this.userData;
12175
12535
  function extractFromCache(cache) {
12176
12536
  const values = [];
@@ -12213,6 +12573,7 @@ var Material = class extends EventDispatcher {
12213
12573
  if (json.clearcoat !== void 0) this.clearcoat = json.clearcoat;
12214
12574
  if (json.clearcoatRoughness !== void 0) this.clearcoatRoughness = json.clearcoatRoughness;
12215
12575
  if (json.dispersion !== void 0) this.dispersion = json.dispersion;
12576
+ if (json.retroreflectivity !== void 0) this.retroreflectivity = json.retroreflectivity;
12216
12577
  if (json.iridescence !== void 0) this.iridescence = json.iridescence;
12217
12578
  if (json.iridescenceIOR !== void 0) this.iridescenceIOR = json.iridescenceIOR;
12218
12579
  if (json.iridescenceThicknessRange !== void 0) this.iridescenceThicknessRange = json.iridescenceThicknessRange;
@@ -12236,6 +12597,10 @@ var Material = class extends EventDispatcher {
12236
12597
  if (json.depthTest !== void 0) this.depthTest = json.depthTest;
12237
12598
  if (json.depthWrite !== void 0) this.depthWrite = json.depthWrite;
12238
12599
  if (json.colorWrite !== void 0) this.colorWrite = json.colorWrite;
12600
+ if (json.clippingPlanes !== void 0) this.clippingPlanes = json.clippingPlanes.map((plane) => new Plane().fromJSON(plane));
12601
+ if (json.clipIntersection !== void 0) this.clipIntersection = json.clipIntersection;
12602
+ if (json.clipShadows !== void 0) this.clipShadows = json.clipShadows;
12603
+ if (json.depthPacking !== void 0) this.depthPacking = json.depthPacking;
12239
12604
  if (json.blendSrc !== void 0) this.blendSrc = json.blendSrc;
12240
12605
  if (json.blendDst !== void 0) this.blendDst = json.blendDst;
12241
12606
  if (json.blendEquation !== void 0) this.blendEquation = json.blendEquation;
@@ -12258,6 +12623,8 @@ var Material = class extends EventDispatcher {
12258
12623
  if (json.wireframeLinejoin !== void 0) this.wireframeLinejoin = json.wireframeLinejoin;
12259
12624
  if (json.rotation !== void 0) this.rotation = json.rotation;
12260
12625
  if (json.linewidth !== void 0) this.linewidth = json.linewidth;
12626
+ if (json.linecap !== void 0) this.linecap = json.linecap;
12627
+ if (json.linejoin !== void 0) this.linejoin = json.linejoin;
12261
12628
  if (json.dashSize !== void 0) this.dashSize = json.dashSize;
12262
12629
  if (json.gapSize !== void 0) this.gapSize = json.gapSize;
12263
12630
  if (json.scale !== void 0) this.scale = json.scale;
@@ -12510,6 +12877,15 @@ var Sprite = class extends Object3D {
12510
12877
  this.center = new Vector2(0.5, 0.5);
12511
12878
  this.count = 1;
12512
12879
  }
12880
+ /**
12881
+ * Returns `true` if this sprite intersects the given frustum.
12882
+ *
12883
+ * @param {Frustum|FrustumArray} frustum - The frustum to test.
12884
+ * @return {boolean} Whether this sprite intersects the given frustum or not.
12885
+ */
12886
+ intersectsFrustum(frustum) {
12887
+ return frustum.intersectsSprite(this);
12888
+ }
12513
12889
  /**
12514
12890
  * Computes intersection points between a casted ray and this sprite.
12515
12891
  *
@@ -12734,7 +13110,7 @@ var LOD = class extends Object3D {
12734
13110
  }
12735
13111
  toJSON(meta) {
12736
13112
  const data = super.toJSON(meta);
12737
- if (this.autoUpdate === false) data.object.autoUpdate = false;
13113
+ data.object.autoUpdate = this.autoUpdate;
12738
13114
  data.object.levels = [];
12739
13115
  const levels = this.levels;
12740
13116
  for (let i = 0, l = levels.length; i < l; i++) {
@@ -12752,9 +13128,6 @@ var _vector$7 = /* @__PURE__ */ new Vector3();
12752
13128
  var _segCenter = /* @__PURE__ */ new Vector3();
12753
13129
  var _segDir = /* @__PURE__ */ new Vector3();
12754
13130
  var _diff = /* @__PURE__ */ new Vector3();
12755
- var _edge1 = /* @__PURE__ */ new Vector3();
12756
- var _edge2 = /* @__PURE__ */ new Vector3();
12757
- var _normal$1 = /* @__PURE__ */ new Vector3();
12758
13131
  var Ray = class {
12759
13132
  /**
12760
13133
  * Constructs a new ray.
@@ -12935,6 +13308,7 @@ var Ray = class {
12935
13308
  * @return {?Vector3} The intersection point.
12936
13309
  */
12937
13310
  intersectSphere(sphere, target) {
13311
+ if (sphere.radius < 0) return null;
12938
13312
  _vector$7.subVectors(sphere.center, this.origin);
12939
13313
  const tca = _vector$7.dot(this.direction);
12940
13314
  const d2 = _vector$7.dot(_vector$7) - tca * tca;
@@ -13070,37 +13444,108 @@ var Ray = class {
13070
13444
  * @return {?Vector3} The intersection point.
13071
13445
  */
13072
13446
  intersectTriangle(a, b, c, backfaceCulling, target) {
13073
- _edge1.subVectors(b, a);
13074
- _edge2.subVectors(c, a);
13075
- _normal$1.crossVectors(_edge1, _edge2);
13076
- let DdN = this.direction.dot(_normal$1);
13077
- let sign2;
13078
- if (DdN > 0) {
13079
- if (backfaceCulling) return null;
13080
- sign2 = 1;
13081
- } else if (DdN < 0) {
13082
- sign2 = -1;
13083
- DdN = -DdN;
13447
+ const origin = this.origin;
13448
+ const direction = this.direction;
13449
+ const dx = direction.x;
13450
+ const dy = direction.y;
13451
+ const dz = direction.z;
13452
+ const aox = a.x - origin.x, aoy = a.y - origin.y, aoz = a.z - origin.z;
13453
+ const box = b.x - origin.x, boy = b.y - origin.y, boz = b.z - origin.z;
13454
+ const cox = c.x - origin.x, coy = c.y - origin.y, coz = c.z - origin.z;
13455
+ const adx = Math.abs(dx), ady = Math.abs(dy), adz = Math.abs(dz);
13456
+ let dkx, dky, dkz;
13457
+ let akx, aky, akz, bkx, bky, bkz, ckx, cky, ckz;
13458
+ if (adx >= ady && adx >= adz) {
13459
+ dkz = dx;
13460
+ akz = aox;
13461
+ bkz = box;
13462
+ ckz = cox;
13463
+ if (dx >= 0) {
13464
+ dkx = dy;
13465
+ dky = dz;
13466
+ akx = aoy;
13467
+ aky = aoz;
13468
+ bkx = boy;
13469
+ bky = boz;
13470
+ ckx = coy;
13471
+ cky = coz;
13472
+ } else {
13473
+ dkx = dz;
13474
+ dky = dy;
13475
+ akx = aoz;
13476
+ aky = aoy;
13477
+ bkx = boz;
13478
+ bky = boy;
13479
+ ckx = coz;
13480
+ cky = coy;
13481
+ }
13482
+ } else if (ady >= adz) {
13483
+ dkz = dy;
13484
+ akz = aoy;
13485
+ bkz = boy;
13486
+ ckz = coy;
13487
+ if (dy >= 0) {
13488
+ dkx = dz;
13489
+ dky = dx;
13490
+ akx = aoz;
13491
+ aky = aox;
13492
+ bkx = boz;
13493
+ bky = box;
13494
+ ckx = coz;
13495
+ cky = cox;
13496
+ } else {
13497
+ dkx = dx;
13498
+ dky = dz;
13499
+ akx = aox;
13500
+ aky = aoz;
13501
+ bkx = box;
13502
+ bky = boz;
13503
+ ckx = cox;
13504
+ cky = coz;
13505
+ }
13084
13506
  } else {
13085
- return null;
13086
- }
13087
- _diff.subVectors(this.origin, a);
13088
- const DdQxE2 = sign2 * this.direction.dot(_edge2.crossVectors(_diff, _edge2));
13089
- if (DdQxE2 < 0) {
13090
- return null;
13091
- }
13092
- const DdE1xQ = sign2 * this.direction.dot(_edge1.cross(_diff));
13093
- if (DdE1xQ < 0) {
13094
- return null;
13095
- }
13096
- if (DdQxE2 + DdE1xQ > DdN) {
13097
- return null;
13098
- }
13099
- const QdN = -sign2 * _diff.dot(_normal$1);
13100
- if (QdN < 0) {
13101
- return null;
13507
+ dkz = dz;
13508
+ akz = aoz;
13509
+ bkz = boz;
13510
+ ckz = coz;
13511
+ if (dz >= 0) {
13512
+ dkx = dx;
13513
+ dky = dy;
13514
+ akx = aox;
13515
+ aky = aoy;
13516
+ bkx = box;
13517
+ bky = boy;
13518
+ ckx = cox;
13519
+ cky = coy;
13520
+ } else {
13521
+ dkx = dy;
13522
+ dky = dx;
13523
+ akx = aoy;
13524
+ aky = aox;
13525
+ bkx = boy;
13526
+ bky = box;
13527
+ ckx = coy;
13528
+ cky = cox;
13529
+ }
13530
+ }
13531
+ if (dkz === 0) return null;
13532
+ const sx = dkx / dkz, sy = dky / dkz, sz = 1 / dkz;
13533
+ const ax = akx - sx * akz, ay = aky - sy * akz;
13534
+ const bx = bkx - sx * bkz, by = bky - sy * bkz;
13535
+ const cx = ckx - sx * ckz, cy = cky - sy * ckz;
13536
+ const u = cx * by - cy * bx;
13537
+ const v = ax * cy - ay * cx;
13538
+ const w = bx * ay - by * ax;
13539
+ if (backfaceCulling) {
13540
+ if (u < 0 || v < 0 || w < 0) return null;
13541
+ } else {
13542
+ if ((u < 0 || v < 0 || w < 0) && (u > 0 || v > 0 || w > 0)) return null;
13102
13543
  }
13103
- return this.at(QdN / DdN, target);
13544
+ const det = u + v + w;
13545
+ if (det === 0) return null;
13546
+ const tScaled = sz * (u * akz + v * bkz + w * ckz);
13547
+ if (det > 0 ? tScaled < 0 : tScaled > 0) return null;
13548
+ return this.at(tScaled / det, target);
13104
13549
  }
13105
13550
  /**
13106
13551
  * Transforms this ray with the given 4x4 transformation matrix.
@@ -13282,6 +13727,15 @@ var Mesh = class extends Object3D {
13282
13727
  }
13283
13728
  return target;
13284
13729
  }
13730
+ /**
13731
+ * Returns `true` if this mesh intersects the given frustum.
13732
+ *
13733
+ * @param {Frustum|FrustumArray} frustum - The frustum to test.
13734
+ * @return {boolean} Whether this mesh intersects the given frustum or not.
13735
+ */
13736
+ intersectsFrustum(frustum) {
13737
+ return frustum.intersectsObject(this);
13738
+ }
13285
13739
  /**
13286
13740
  * Computes intersection points between a casted ray and this line.
13287
13741
  *
@@ -14077,255 +14531,13 @@ var InstancedMesh = class extends Mesh {
14077
14531
  * method whenever this instance is no longer used in your app.
14078
14532
  */
14079
14533
  dispose() {
14080
- this.dispatchEvent({ type: "dispose" });
14534
+ super.dispose();
14081
14535
  if (this.morphTexture !== null) {
14082
14536
  this.morphTexture.dispose();
14083
14537
  this.morphTexture = null;
14084
14538
  }
14085
14539
  }
14086
14540
  };
14087
- var _vector1 = /* @__PURE__ */ new Vector3();
14088
- var _vector2 = /* @__PURE__ */ new Vector3();
14089
- var _normalMatrix = /* @__PURE__ */ new Matrix3();
14090
- var Plane = class {
14091
- /**
14092
- * Constructs a new plane.
14093
- *
14094
- * @param {Vector3} [normal=(1,0,0)] - A unit length vector defining the normal of the plane.
14095
- * @param {number} [constant=0] - The signed distance from the origin to the plane.
14096
- */
14097
- constructor(normal = new Vector3(1, 0, 0), constant = 0) {
14098
- this.isPlane = true;
14099
- this.normal = normal;
14100
- this.constant = constant;
14101
- }
14102
- /**
14103
- * Sets the plane components by copying the given values.
14104
- *
14105
- * @param {Vector3} normal - The normal.
14106
- * @param {number} constant - The constant.
14107
- * @return {Plane} A reference to this plane.
14108
- */
14109
- set(normal, constant) {
14110
- this.normal.copy(normal);
14111
- this.constant = constant;
14112
- return this;
14113
- }
14114
- /**
14115
- * Sets the plane components by defining `x`, `y`, `z` as the
14116
- * plane normal and `w` as the constant.
14117
- *
14118
- * @param {number} x - The value for the normal's x component.
14119
- * @param {number} y - The value for the normal's y component.
14120
- * @param {number} z - The value for the normal's z component.
14121
- * @param {number} w - The constant value.
14122
- * @return {Plane} A reference to this plane.
14123
- */
14124
- setComponents(x, y, z, w) {
14125
- this.normal.set(x, y, z);
14126
- this.constant = w;
14127
- return this;
14128
- }
14129
- /**
14130
- * Sets the plane from the given normal and coplanar point (that is a point
14131
- * that lies onto the plane).
14132
- *
14133
- * @param {Vector3} normal - The normal.
14134
- * @param {Vector3} point - A coplanar point.
14135
- * @return {Plane} A reference to this plane.
14136
- */
14137
- setFromNormalAndCoplanarPoint(normal, point) {
14138
- this.normal.copy(normal);
14139
- this.constant = -point.dot(this.normal);
14140
- return this;
14141
- }
14142
- /**
14143
- * Sets the plane from three coplanar points. The winding order is
14144
- * assumed to be counter-clockwise, and determines the direction of
14145
- * the plane normal.
14146
- *
14147
- * @param {Vector3} a - The first coplanar point.
14148
- * @param {Vector3} b - The second coplanar point.
14149
- * @param {Vector3} c - The third coplanar point.
14150
- * @return {Plane} A reference to this plane.
14151
- */
14152
- setFromCoplanarPoints(a, b, c) {
14153
- const normal = _vector1.subVectors(c, b).cross(_vector2.subVectors(a, b)).normalize();
14154
- this.setFromNormalAndCoplanarPoint(normal, a);
14155
- return this;
14156
- }
14157
- /**
14158
- * Copies the values of the given plane to this instance.
14159
- *
14160
- * @param {Plane} plane - The plane to copy.
14161
- * @return {Plane} A reference to this plane.
14162
- */
14163
- copy(plane) {
14164
- this.normal.copy(plane.normal);
14165
- this.constant = plane.constant;
14166
- return this;
14167
- }
14168
- /**
14169
- * Normalizes the plane normal and adjusts the constant accordingly.
14170
- *
14171
- * @return {Plane} A reference to this plane.
14172
- */
14173
- normalize() {
14174
- const inverseNormalLength = 1 / this.normal.length();
14175
- this.normal.multiplyScalar(inverseNormalLength);
14176
- this.constant *= inverseNormalLength;
14177
- return this;
14178
- }
14179
- /**
14180
- * Negates both the plane normal and the constant.
14181
- *
14182
- * @return {Plane} A reference to this plane.
14183
- */
14184
- negate() {
14185
- this.constant *= -1;
14186
- this.normal.negate();
14187
- return this;
14188
- }
14189
- /**
14190
- * Returns the signed distance from the given point to this plane.
14191
- *
14192
- * @param {Vector3} point - The point to compute the distance for.
14193
- * @return {number} The signed distance.
14194
- */
14195
- distanceToPoint(point) {
14196
- return this.normal.dot(point) + this.constant;
14197
- }
14198
- /**
14199
- * Returns the signed distance from the given sphere to this plane.
14200
- *
14201
- * @param {Sphere} sphere - The sphere to compute the distance for.
14202
- * @return {number} The signed distance.
14203
- */
14204
- distanceToSphere(sphere) {
14205
- return this.distanceToPoint(sphere.center) - sphere.radius;
14206
- }
14207
- /**
14208
- * Projects a the given point onto the plane.
14209
- *
14210
- * @param {Vector3} point - The point to project.
14211
- * @param {Vector3} target - The target vector that is used to store the method's result.
14212
- * @return {Vector3} The projected point on the plane.
14213
- */
14214
- projectPoint(point, target) {
14215
- return target.copy(point).addScaledVector(this.normal, -this.distanceToPoint(point));
14216
- }
14217
- /**
14218
- * Returns the intersection point of the passed line and the plane. Returns
14219
- * `null` if the line does not intersect. Returns the line's starting point if
14220
- * the line is coplanar with the plane.
14221
- *
14222
- * @param {Line3} line - The line to compute the intersection for.
14223
- * @param {Vector3} target - The target vector that is used to store the method's result.
14224
- * @param {boolean} [clampToLine=true] - Whether to clamp the intersection to the line segment.
14225
- * @return {?Vector3} The intersection point. Returns `null` if no intersection is detected.
14226
- */
14227
- intersectLine(line, target, clampToLine = true) {
14228
- const direction = line.delta(_vector1);
14229
- const denominator = this.normal.dot(direction);
14230
- if (denominator === 0) {
14231
- if (this.distanceToPoint(line.start) === 0) {
14232
- return target.copy(line.start);
14233
- }
14234
- return null;
14235
- }
14236
- const t = -(line.start.dot(this.normal) + this.constant) / denominator;
14237
- if (clampToLine === true && (t < 0 || t > 1)) {
14238
- return null;
14239
- }
14240
- return target.copy(line.start).addScaledVector(direction, t);
14241
- }
14242
- /**
14243
- * Returns `true` if the given line segment intersects with (passes through) the plane.
14244
- *
14245
- * @param {Line3} line - The line to test.
14246
- * @return {boolean} Whether the given line segment intersects with the plane or not.
14247
- */
14248
- intersectsLine(line) {
14249
- const startSign = this.distanceToPoint(line.start);
14250
- const endSign = this.distanceToPoint(line.end);
14251
- return startSign < 0 && endSign > 0 || endSign < 0 && startSign > 0;
14252
- }
14253
- /**
14254
- * Returns `true` if the given bounding box intersects with the plane.
14255
- *
14256
- * @param {Box3} box - The bounding box to test.
14257
- * @return {boolean} Whether the given bounding box intersects with the plane or not.
14258
- */
14259
- intersectsBox(box) {
14260
- return box.intersectsPlane(this);
14261
- }
14262
- /**
14263
- * Returns `true` if the given bounding sphere intersects with the plane.
14264
- *
14265
- * @param {Sphere} sphere - The bounding sphere to test.
14266
- * @return {boolean} Whether the given bounding sphere intersects with the plane or not.
14267
- */
14268
- intersectsSphere(sphere) {
14269
- return sphere.intersectsPlane(this);
14270
- }
14271
- /**
14272
- * Returns a coplanar vector to the plane, by calculating the
14273
- * projection of the normal at the origin onto the plane.
14274
- *
14275
- * @param {Vector3} target - The target vector that is used to store the method's result.
14276
- * @return {Vector3} The coplanar point.
14277
- */
14278
- coplanarPoint(target) {
14279
- return target.copy(this.normal).multiplyScalar(-this.constant);
14280
- }
14281
- /**
14282
- * Apply a 4x4 matrix to the plane. The matrix must be an affine, homogeneous transform.
14283
- *
14284
- * The optional normal matrix can be pre-computed like so:
14285
- * ```js
14286
- * const optionalNormalMatrix = new THREE.Matrix3().getNormalMatrix( matrix );
14287
- * ```
14288
- *
14289
- * @param {Matrix4} matrix - The transformation matrix.
14290
- * @param {Matrix4} [optionalNormalMatrix] - A pre-computed normal matrix.
14291
- * @return {Plane} A reference to this plane.
14292
- */
14293
- applyMatrix4(matrix, optionalNormalMatrix) {
14294
- const normalMatrix = optionalNormalMatrix || _normalMatrix.getNormalMatrix(matrix);
14295
- const referencePoint = this.coplanarPoint(_vector1).applyMatrix4(matrix);
14296
- const normal = this.normal.applyMatrix3(normalMatrix).normalize();
14297
- this.constant = -referencePoint.dot(normal);
14298
- return this;
14299
- }
14300
- /**
14301
- * Translates the plane by the distance defined by the given offset vector.
14302
- * Note that this only affects the plane constant and will not affect the normal vector.
14303
- *
14304
- * @param {Vector3} offset - The offset vector.
14305
- * @return {Plane} A reference to this plane.
14306
- */
14307
- translate(offset) {
14308
- this.constant -= offset.dot(this.normal);
14309
- return this;
14310
- }
14311
- /**
14312
- * Returns `true` if this plane is equal with the given one.
14313
- *
14314
- * @param {Plane} plane - The plane to test for equality.
14315
- * @return {boolean} Whether this plane is equal with the given one.
14316
- */
14317
- equals(plane) {
14318
- return plane.normal.equals(this.normal) && plane.constant === this.constant;
14319
- }
14320
- /**
14321
- * Returns a new plane with copied values from this instance.
14322
- *
14323
- * @return {Plane} A clone of this instance.
14324
- */
14325
- clone() {
14326
- return new this.constructor().copy(this);
14327
- }
14328
- };
14329
14541
  var _sphere$3 = /* @__PURE__ */ new Sphere();
14330
14542
  var _defaultSpriteCenter = /* @__PURE__ */ new Vector2(0.5, 0.5);
14331
14543
  var _vector$6 = /* @__PURE__ */ new Vector3();
@@ -14446,6 +14658,10 @@ var Frustum = class {
14446
14658
  /**
14447
14659
  * Returns `true` if the given bounding sphere is intersecting this frustum.
14448
14660
  *
14661
+ * This is a fast, conservative test that favors performance over precision. It can
14662
+ * report false positives for spheres that lie outside the frustum but are not separated
14663
+ * by a single frustum plane. It never reports false negatives, so it is safe for culling.
14664
+ *
14449
14665
  * @param {Sphere} sphere - The bounding sphere to test.
14450
14666
  * @return {boolean} Whether the bounding sphere is intersecting this frustum or not.
14451
14667
  */
@@ -14464,6 +14680,11 @@ var Frustum = class {
14464
14680
  /**
14465
14681
  * Returns `true` if the given bounding box is intersecting this frustum.
14466
14682
  *
14683
+ * This is a fast, conservative test that favors performance over precision. It can
14684
+ * report false positives for large boxes that lie outside the frustum but are not
14685
+ * separated by a single frustum plane. It never reports false negatives, so it is
14686
+ * safe for culling.
14687
+ *
14467
14688
  * @param {Box3} box - The bounding box to test.
14468
14689
  * @return {boolean} Whether the bounding box is intersecting this frustum or not.
14469
14690
  */
@@ -14611,7 +14832,7 @@ var FrustumArray = class _FrustumArray {
14611
14832
  /**
14612
14833
  * Copies the values of the given frustum array to this instance.
14613
14834
  *
14614
- * @param {FrustumArray} frustumArray - The frustum array to copy.
14835
+ * @param {FrustumArray} source - The frustum array to copy.
14615
14836
  * @return {FrustumArray} A reference to this frustum array.
14616
14837
  */
14617
14838
  copy(source) {
@@ -14742,6 +14963,7 @@ var BatchedMesh = class extends Mesh {
14742
14963
  this._multiDrawCounts = new Int32Array(maxInstanceCount);
14743
14964
  this._multiDrawStarts = new Int32Array(maxInstanceCount);
14744
14965
  this._multiDrawCount = 0;
14966
+ this._multiDrawBytesPerElement = 1;
14745
14967
  this._matricesTexture = null;
14746
14968
  this._indirectTexture = null;
14747
14969
  this._colorsTexture = null;
@@ -15333,6 +15555,7 @@ var BatchedMesh = class extends Mesh {
15333
15555
  this.validateInstanceId(instanceId);
15334
15556
  this.validateGeometryId(geometryId);
15335
15557
  this._instanceInfo[instanceId].geometryIndex = geometryId;
15558
+ this._visibilityChanged = true;
15336
15559
  return this;
15337
15560
  }
15338
15561
  /**
@@ -15509,6 +15732,7 @@ var BatchedMesh = class extends Mesh {
15509
15732
  this._geometryInitialized = source._geometryInitialized;
15510
15733
  this._multiDrawCounts = source._multiDrawCounts.slice();
15511
15734
  this._multiDrawStarts = source._multiDrawStarts.slice();
15735
+ this._multiDrawBytesPerElement = source._multiDrawBytesPerElement;
15512
15736
  this._indirectTexture = source._indirectTexture.clone();
15513
15737
  this._indirectTexture.image.data = this._indirectTexture.image.data.slice();
15514
15738
  this._matricesTexture = source._matricesTexture.clone();
@@ -15524,6 +15748,7 @@ var BatchedMesh = class extends Mesh {
15524
15748
  * method whenever this instance is no longer used in your app.
15525
15749
  */
15526
15750
  dispose() {
15751
+ super.dispose();
15527
15752
  this.geometry.dispose();
15528
15753
  this._matricesTexture.dispose();
15529
15754
  this._matricesTexture = null;
@@ -15623,6 +15848,7 @@ var BatchedMesh = class extends Mesh {
15623
15848
  }
15624
15849
  indirectTexture.needsUpdate = true;
15625
15850
  this._multiDrawCount = multiDrawCount;
15851
+ this._multiDrawBytesPerElement = bytesPerElement;
15626
15852
  this._visibilityChanged = false;
15627
15853
  }
15628
15854
  onBeforeShadow(renderer, object, camera, shadowCamera, geometry, depthMaterial) {
@@ -15716,6 +15942,15 @@ var Line = class extends Object3D {
15716
15942
  }
15717
15943
  return this;
15718
15944
  }
15945
+ /**
15946
+ * Returns `true` if this line intersects the given frustum.
15947
+ *
15948
+ * @param {Frustum|FrustumArray} frustum - The frustum to test.
15949
+ * @return {boolean} Whether this line intersects the given frustum or not.
15950
+ */
15951
+ intersectsFrustum(frustum) {
15952
+ return frustum.intersectsObject(this);
15953
+ }
15719
15954
  /**
15720
15955
  * Computes intersection points between a casted ray and this line.
15721
15956
  *
@@ -15924,6 +16159,15 @@ var Points = class extends Object3D {
15924
16159
  this.geometry = source.geometry;
15925
16160
  return this;
15926
16161
  }
16162
+ /**
16163
+ * Returns `true` if this point cloud intersects the given frustum.
16164
+ *
16165
+ * @param {Frustum|FrustumArray} frustum - The frustum to test.
16166
+ * @return {boolean} Whether this point cloud intersects the given frustum or not.
16167
+ */
16168
+ intersectsFrustum(frustum) {
16169
+ return frustum.intersectsObject(this);
16170
+ }
15927
16171
  /**
15928
16172
  * Computes intersection points between a casted ray and this point cloud.
15929
16173
  *
@@ -16157,6 +16401,17 @@ var CompressedArrayTexture = class extends CompressedTexture {
16157
16401
  this.wrapR = ClampToEdgeWrapping;
16158
16402
  this.layerUpdates = /* @__PURE__ */ new Set();
16159
16403
  }
16404
+ /**
16405
+ * Copies the values of the given texture to this instance.
16406
+ *
16407
+ * @param {CompressedArrayTexture} source - The texture to copy.
16408
+ * @return {CompressedArrayTexture} A reference to this instance.
16409
+ */
16410
+ copy(source) {
16411
+ super.copy(source);
16412
+ this.wrapR = source.wrapR;
16413
+ return this;
16414
+ }
16160
16415
  /**
16161
16416
  * Describes that a specific layer of the texture needs to be updated.
16162
16417
  * Normally when {@link Texture#needsUpdate} is set to `true`, the
@@ -16307,13 +16562,13 @@ var DepthTexture = class extends Texture {
16307
16562
  }
16308
16563
  copy(source) {
16309
16564
  super.copy(source);
16310
- this.source = new Source(Object.assign({}, source.image));
16565
+ this.source = new TextureSource(Object.assign({}, source.image));
16311
16566
  this.compareFunction = source.compareFunction;
16312
16567
  return this;
16313
16568
  }
16314
16569
  toJSON(meta) {
16315
16570
  const data = super.toJSON(meta);
16316
- if (this.compareFunction !== null) data.compareFunction = this.compareFunction;
16571
+ data.compareFunction = this.compareFunction;
16317
16572
  return data;
16318
16573
  }
16319
16574
  };
@@ -20490,7 +20745,7 @@ var TorusGeometry = class _TorusGeometry extends BufferGeometry {
20490
20745
  * @return {TorusGeometry} A new instance.
20491
20746
  */
20492
20747
  static fromJSON(data) {
20493
- return new _TorusGeometry(data.radius, data.tube, data.radialSegments, data.tubularSegments, data.arc);
20748
+ return new _TorusGeometry(data.radius, data.tube, data.radialSegments, data.tubularSegments, data.arc, data.thetaStart, data.thetaLength);
20494
20749
  }
20495
20750
  };
20496
20751
  var TorusKnotGeometry = class _TorusKnotGeometry extends BufferGeometry {
@@ -21227,6 +21482,7 @@ var MeshPhysicalMaterial = class extends MeshStandardMaterial {
21227
21482
  this._clearcoat = 0;
21228
21483
  this._dispersion = 0;
21229
21484
  this._iridescence = 0;
21485
+ this._retroreflectivity = 0;
21230
21486
  this._sheen = 0;
21231
21487
  this._transmission = 0;
21232
21488
  this.setValues(parameters);
@@ -21296,6 +21552,24 @@ var MeshPhysicalMaterial = class extends MeshStandardMaterial {
21296
21552
  }
21297
21553
  this._dispersion = value;
21298
21554
  }
21555
+ /**
21556
+ * The strength of retroreflection, from `0.0` to `1.0`. A value of `1.0`
21557
+ * evaluates the material's microfacet reflection with the view direction
21558
+ * reflected about the surface normal, redirecting the specular lobe back
21559
+ * toward the light source.
21560
+ *
21561
+ * @type {number}
21562
+ * @default 0
21563
+ */
21564
+ get retroreflectivity() {
21565
+ return this._retroreflectivity;
21566
+ }
21567
+ set retroreflectivity(value) {
21568
+ if (this._retroreflectivity > 0 !== value > 0) {
21569
+ this.version++;
21570
+ }
21571
+ this._retroreflectivity = value;
21572
+ }
21299
21573
  /**
21300
21574
  * The intensity of the sheen layer, from `0.0` to `1.0`.
21301
21575
  *
@@ -21354,6 +21628,7 @@ var MeshPhysicalMaterial = class extends MeshStandardMaterial {
21354
21628
  this.iridescenceIOR = source.iridescenceIOR;
21355
21629
  this.iridescenceThicknessRange = [...source.iridescenceThicknessRange];
21356
21630
  this.iridescenceThicknessMap = source.iridescenceThicknessMap;
21631
+ this.retroreflectivity = source.retroreflectivity;
21357
21632
  this.sheen = source.sheen;
21358
21633
  this.sheenColor.copy(source.sheenColor);
21359
21634
  this.sheenColorMap = source.sheenColorMap;
@@ -21812,6 +22087,9 @@ function convertArray(array, type) {
21812
22087
  }
21813
22088
  return Array.prototype.slice.call(array);
21814
22089
  }
22090
+ function hasTangents(settings) {
22091
+ return settings !== void 0 && settings.inTangents !== void 0 && settings.outTangents !== void 0;
22092
+ }
21815
22093
  function getKeyframeOrder(times) {
21816
22094
  function compareTime(i, j) {
21817
22095
  return times[i] - times[j];
@@ -21993,6 +22271,16 @@ var AnimationUtils = class {
21993
22271
  static isTypedArray(object) {
21994
22272
  return isTypedArray(object);
21995
22273
  }
22274
+ /**
22275
+ * Returns `true` if the given keyframe track settings hold Bezier tangent data.
22276
+ *
22277
+ * @static
22278
+ * @param {?Object} settings - The settings of a keyframe track.
22279
+ * @return {boolean} Whether both tangent arrays are defined or not.
22280
+ */
22281
+ static hasTangents(settings) {
22282
+ return hasTangents(settings);
22283
+ }
21996
22284
  /**
21997
22285
  * Returns an array by which times and values can be sorted.
21998
22286
  *
@@ -22332,27 +22620,31 @@ var BezierInterpolant = class extends Interpolant {
22332
22620
  const inTangentOffset = i1 * tangentStride + i * 2;
22333
22621
  const c1x = inTangents[inTangentOffset];
22334
22622
  const c1y = inTangents[inTangentOffset + 1];
22335
- let s = (t - t0) / (t1 - t0);
22336
- let s2, s3, oneMinusS, oneMinusS2, oneMinusS3;
22337
- for (let iter = 0; iter < 8; iter++) {
22338
- s2 = s * s;
22339
- s3 = s2 * s;
22340
- oneMinusS = 1 - s;
22341
- oneMinusS2 = oneMinusS * oneMinusS;
22342
- oneMinusS3 = oneMinusS2 * oneMinusS;
22343
- const bx = oneMinusS3 * t0 + 3 * oneMinusS2 * s * c0x + 3 * oneMinusS * s2 * c1x + s3 * t1;
22344
- const error2 = bx - t;
22345
- if (Math.abs(error2) < 1e-10) break;
22346
- const dbx = 3 * oneMinusS2 * (c0x - t0) + 6 * oneMinusS * s * (c1x - c0x) + 3 * s2 * (t1 - c1x);
22347
- if (Math.abs(dbx) < 1e-10) break;
22348
- s = s - error2 / dbx;
22349
- s = Math.max(0, Math.min(1, s));
22350
- }
22351
- result[i] = oneMinusS3 * v0 + 3 * oneMinusS2 * s * c0y + 3 * oneMinusS * s2 * c1y + s3 * v1;
22623
+ const s = solveBezierParameter(t, t0, c0x, c1x, t1);
22624
+ result[i] = cubicBezier(s, v0, c0y, c1y, v1);
22352
22625
  }
22353
22626
  return result;
22354
22627
  }
22355
22628
  };
22629
+ function cubicBezier(s, p0, p1, p2, p3) {
22630
+ const k = 1 - s;
22631
+ return k * k * k * p0 + 3 * k * k * s * p1 + 3 * k * s * s * p2 + s * s * s * p3;
22632
+ }
22633
+ function cubicBezierSlope(s, p0, p1, p2, p3) {
22634
+ const k = 1 - s;
22635
+ return 3 * k * k * (p1 - p0) + 6 * k * s * (p2 - p1) + 3 * s * s * (p3 - p2);
22636
+ }
22637
+ function solveBezierParameter(x, x0, x1, x2, x3) {
22638
+ let s = (x - x0) / (x3 - x0);
22639
+ for (let i = 0; i < 8; i++) {
22640
+ const error2 = cubicBezier(s, x0, x1, x2, x3) - x;
22641
+ if (Math.abs(error2) < 1e-10) break;
22642
+ const slope = cubicBezierSlope(s, x0, x1, x2, x3);
22643
+ if (Math.abs(slope) < 1e-10) break;
22644
+ s = Math.max(0, Math.min(1, s - error2 / slope));
22645
+ }
22646
+ return s;
22647
+ }
22356
22648
  var KeyframeTrack = class {
22357
22649
  /**
22358
22650
  * Constructs a new keyframe track.
@@ -22392,6 +22684,12 @@ var KeyframeTrack = class {
22392
22684
  if (interpolation !== track.DefaultInterpolation) {
22393
22685
  json.interpolation = interpolation;
22394
22686
  }
22687
+ if (hasTangents(track.settings)) {
22688
+ json.settings = {
22689
+ inTangents: convertArray(track.settings.inTangents, Array),
22690
+ outTangents: convertArray(track.settings.outTangents, Array)
22691
+ };
22692
+ }
22395
22693
  }
22396
22694
  json.type = track.ValueTypeName;
22397
22695
  return json;
@@ -22535,6 +22833,10 @@ var KeyframeTrack = class {
22535
22833
  for (let i = 0, n = times.length; i !== n; ++i) {
22536
22834
  times[i] *= timeScale;
22537
22835
  }
22836
+ if (hasTangents(this.settings)) {
22837
+ scaleTangentTimes(this.settings.inTangents, timeScale);
22838
+ scaleTangentTimes(this.settings.outTangents, timeScale);
22839
+ }
22538
22840
  }
22539
22841
  return this;
22540
22842
  }
@@ -22681,9 +22983,20 @@ var KeyframeTrack = class {
22681
22983
  const TypedKeyframeTrack = this.constructor;
22682
22984
  const track = new TypedKeyframeTrack(this.name, times, values);
22683
22985
  track.createInterpolant = this.createInterpolant;
22986
+ if (hasTangents(this.settings)) {
22987
+ track.settings = {
22988
+ inTangents: this.settings.inTangents.slice(),
22989
+ outTangents: this.settings.outTangents.slice()
22990
+ };
22991
+ }
22684
22992
  return track;
22685
22993
  }
22686
22994
  };
22995
+ function scaleTangentTimes(tangents, timeScale) {
22996
+ for (let i = 0, n = tangents.length; i !== n; i += 2) {
22997
+ tangents[i] *= timeScale;
22998
+ }
22999
+ }
22687
23000
  KeyframeTrack.prototype.ValueTypeName = "";
22688
23001
  KeyframeTrack.prototype.TimeBufferType = Float32Array;
22689
23002
  KeyframeTrack.prototype.ValueBufferType = Float32Array;
@@ -23091,11 +23404,19 @@ function parseKeyframeTrack(json) {
23091
23404
  json.times = times;
23092
23405
  json.values = values;
23093
23406
  }
23407
+ let track;
23094
23408
  if (trackType.parse !== void 0) {
23095
- return trackType.parse(json);
23409
+ track = trackType.parse(json);
23096
23410
  } else {
23097
- return new trackType(json.name, json.times, json.values, json.interpolation);
23411
+ track = new trackType(json.name, json.times, json.values, json.interpolation);
23412
+ }
23413
+ if (hasTangents(json.settings)) {
23414
+ track.settings = {
23415
+ inTangents: convertArray(json.settings.inTangents, Float32Array),
23416
+ outTangents: convertArray(json.settings.outTangents, Float32Array)
23417
+ };
23098
23418
  }
23419
+ return track;
23099
23420
  }
23100
23421
  var Cache = {
23101
23422
  /**
@@ -23985,13 +24306,6 @@ var Light = class extends Object3D {
23985
24306
  this.color = new Color(color);
23986
24307
  this.intensity = intensity;
23987
24308
  }
23988
- /**
23989
- * Frees the GPU-related resources allocated by this instance. Call this
23990
- * method whenever this instance is no longer used in your app.
23991
- */
23992
- dispose() {
23993
- this.dispatchEvent({ type: "dispose" });
23994
- }
23995
24309
  copy(source, recursive) {
23996
24310
  super.copy(source, recursive);
23997
24311
  this.color.copy(source.color);
@@ -24072,6 +24386,15 @@ var LightShadow = class {
24072
24386
  getViewportCount() {
24073
24387
  return this._viewportCount;
24074
24388
  }
24389
+ /**
24390
+ * Used internally by the renderer to get the camera that renders the given viewport.
24391
+ *
24392
+ * @param {number} [viewportIndex=0] - The viewport index.
24393
+ * @return {Camera} The shadow camera.
24394
+ */
24395
+ getCamera() {
24396
+ return this.camera;
24397
+ }
24075
24398
  /**
24076
24399
  * Gets the shadow cameras frustum. Used internally by the renderer to cull objects.
24077
24400
  *
@@ -24087,24 +24410,40 @@ var LightShadow = class {
24087
24410
  */
24088
24411
  updateMatrices(light) {
24089
24412
  const shadowCamera = this.camera;
24090
- const shadowMatrix = this.matrix;
24091
24413
  _lightPositionWorld.setFromMatrixPosition(light.matrixWorld);
24092
24414
  shadowCamera.position.copy(_lightPositionWorld);
24093
24415
  _lookTarget.setFromMatrixPosition(light.target.matrixWorld);
24094
24416
  shadowCamera.lookAt(_lookTarget);
24095
24417
  shadowCamera.updateMatrixWorld();
24418
+ this._updateMatrix(shadowCamera, this.matrix, this._frustum);
24419
+ }
24420
+ /**
24421
+ * Updates a shadow projection matrix and its corresponding frustum.
24422
+ *
24423
+ * @private
24424
+ * @param {Camera} shadowCamera - The shadow camera.
24425
+ * @param {Matrix4} shadowMatrix - The target shadow matrix.
24426
+ * @param {Frustum} frustum - The target frustum.
24427
+ * @param {Vector4} [viewport] - The viewport within the shadow atlas.
24428
+ */
24429
+ _updateMatrix(shadowCamera, shadowMatrix, frustum, viewport) {
24096
24430
  _projScreenMatrix.multiplyMatrices(shadowCamera.projectionMatrix, shadowCamera.matrixWorldInverse);
24097
- this._frustum.setFromProjectionMatrix(_projScreenMatrix, shadowCamera.coordinateSystem, shadowCamera.reversedDepth);
24431
+ frustum.setFromProjectionMatrix(_projScreenMatrix, shadowCamera.coordinateSystem, shadowCamera.reversedDepth);
24432
+ const frameExtents = this._frameExtents;
24433
+ const scaleX = viewport ? viewport.z / frameExtents.x : 1;
24434
+ const scaleY = viewport ? viewport.w / frameExtents.y : 1;
24435
+ const offsetX = viewport ? viewport.x / frameExtents.x : 0;
24436
+ const offsetY = viewport ? viewport.y / frameExtents.y : 0;
24098
24437
  if (shadowCamera.coordinateSystem === WebGPUCoordinateSystem || shadowCamera.reversedDepth) {
24099
24438
  shadowMatrix.set(
24100
- 0.5,
24439
+ 0.5 * scaleX,
24101
24440
  0,
24102
24441
  0,
24103
- 0.5,
24442
+ 0.5 * scaleX + offsetX,
24104
24443
  0,
24105
- 0.5,
24444
+ 0.5 * scaleY,
24106
24445
  0,
24107
- 0.5,
24446
+ 0.5 * scaleY + offsetY,
24108
24447
  0,
24109
24448
  0,
24110
24449
  1,
@@ -24117,14 +24456,14 @@ var LightShadow = class {
24117
24456
  );
24118
24457
  } else {
24119
24458
  shadowMatrix.set(
24120
- 0.5,
24459
+ 0.5 * scaleX,
24121
24460
  0,
24122
24461
  0,
24123
- 0.5,
24462
+ 0.5 * scaleX + offsetX,
24124
24463
  0,
24125
- 0.5,
24464
+ 0.5 * scaleY,
24126
24465
  0,
24127
- 0.5,
24466
+ 0.5 * scaleY + offsetY,
24128
24467
  0,
24129
24468
  0,
24130
24469
  0.5,
@@ -24201,11 +24540,12 @@ var LightShadow = class {
24201
24540
  */
24202
24541
  toJSON() {
24203
24542
  const object = {};
24204
- if (this.intensity !== 1) object.intensity = this.intensity;
24205
- if (this.bias !== 0) object.bias = this.bias;
24206
- if (this.normalBias !== 0) object.normalBias = this.normalBias;
24207
- if (this.radius !== 1) object.radius = this.radius;
24208
- if (this.mapSize.x !== 512 || this.mapSize.y !== 512) object.mapSize = this.mapSize.toArray();
24543
+ object.intensity = this.intensity;
24544
+ object.bias = this.bias;
24545
+ object.normalBias = this.normalBias;
24546
+ object.radius = this.radius;
24547
+ object.blurSamples = this.blurSamples;
24548
+ object.mapSize = this.mapSize.toArray();
24209
24549
  object.camera = this.camera.toJSON(false).object;
24210
24550
  delete object.camera.matrix;
24211
24551
  return object;
@@ -24532,8 +24872,21 @@ var SpotLightShadow = class extends LightShadow {
24532
24872
  copy(source) {
24533
24873
  super.copy(source);
24534
24874
  this.focus = source.focus;
24875
+ this.aspect = source.aspect;
24535
24876
  return this;
24536
24877
  }
24878
+ /**
24879
+ * Serializes the light shadow into JSON.
24880
+ *
24881
+ * @return {Object} A JSON object representing the serialized light shadow.
24882
+ * @see {@link ObjectLoader#parse}
24883
+ */
24884
+ toJSON() {
24885
+ const object = super.toJSON();
24886
+ object.focus = this.focus;
24887
+ object.aspect = this.aspect;
24888
+ return object;
24889
+ }
24537
24890
  };
24538
24891
  var SpotLight = class extends Light {
24539
24892
  /**
@@ -25327,6 +25680,7 @@ var BufferGeometryLoader = class extends Loader {
25327
25680
  const array = getTypedArray(interleavedBuffer.type, buffer);
25328
25681
  const ib = new InterleavedBuffer(array, interleavedBuffer.stride);
25329
25682
  ib.uuid = interleavedBuffer.uuid;
25683
+ if (interleavedBuffer.usage !== void 0) ib.setUsage(interleavedBuffer.usage);
25330
25684
  interleavedBufferMap[uuid] = ib;
25331
25685
  return ib;
25332
25686
  }
@@ -25358,6 +25712,7 @@ var BufferGeometryLoader = class extends Loader {
25358
25712
  }
25359
25713
  if (attribute.name !== void 0) bufferAttribute.name = attribute.name;
25360
25714
  if (attribute.usage !== void 0) bufferAttribute.setUsage(attribute.usage);
25715
+ if (attribute.gpuType !== void 0) bufferAttribute.gpuType = attribute.gpuType;
25361
25716
  geometry.setAttribute(key, bufferAttribute);
25362
25717
  }
25363
25718
  const morphAttributes = json.data.morphAttributes;
@@ -25376,6 +25731,8 @@ var BufferGeometryLoader = class extends Loader {
25376
25731
  bufferAttribute = new BufferAttribute(typedArray, attribute.itemSize, attribute.normalized);
25377
25732
  }
25378
25733
  if (attribute.name !== void 0) bufferAttribute.name = attribute.name;
25734
+ if (attribute.usage !== void 0) bufferAttribute.setUsage(attribute.usage);
25735
+ if (attribute.gpuType !== void 0) bufferAttribute.gpuType = attribute.gpuType;
25379
25736
  array.push(bufferAttribute);
25380
25737
  }
25381
25738
  geometry.morphAttributes[key] = array;
@@ -25669,10 +26026,10 @@ var ObjectLoader = class extends Loader {
25669
26026
  }
25670
26027
  }
25671
26028
  }
25672
- images[image.uuid] = new Source(imageArray);
26029
+ images[image.uuid] = new TextureSource(imageArray);
25673
26030
  } else {
25674
26031
  const deserializedImage = deserializeImage(image.url);
25675
- images[image.uuid] = new Source(deserializedImage);
26032
+ images[image.uuid] = new TextureSource(deserializedImage);
25676
26033
  }
25677
26034
  }
25678
26035
  }
@@ -25718,10 +26075,10 @@ var ObjectLoader = class extends Loader {
25718
26075
  }
25719
26076
  }
25720
26077
  }
25721
- images[image.uuid] = new Source(imageArray);
26078
+ images[image.uuid] = new TextureSource(imageArray);
25722
26079
  } else {
25723
26080
  const deserializedImage = await deserializeImage(image.url);
25724
- images[image.uuid] = new Source(deserializedImage);
26081
+ images[image.uuid] = new TextureSource(deserializedImage);
25725
26082
  }
25726
26083
  }
25727
26084
  }
@@ -26008,6 +26365,9 @@ var ObjectLoader = class extends Loader {
26008
26365
  if (data.shadow.bias !== void 0) object.shadow.bias = data.shadow.bias;
26009
26366
  if (data.shadow.normalBias !== void 0) object.shadow.normalBias = data.shadow.normalBias;
26010
26367
  if (data.shadow.radius !== void 0) object.shadow.radius = data.shadow.radius;
26368
+ if (data.shadow.blurSamples !== void 0) object.shadow.blurSamples = data.shadow.blurSamples;
26369
+ if (data.shadow.focus !== void 0) object.shadow.focus = data.shadow.focus;
26370
+ if (data.shadow.aspect !== void 0) object.shadow.aspect = data.shadow.aspect;
26011
26371
  if (data.shadow.mapSize !== void 0) object.shadow.mapSize.fromArray(data.shadow.mapSize);
26012
26372
  if (data.shadow.camera !== void 0) object.shadow.camera = this.parseObject(data.shadow.camera);
26013
26373
  }
@@ -26166,11 +26526,12 @@ var ImageBitmapLoader = class extends Loader {
26166
26526
  const promise = fetch(url, fetchOptions).then(function(res) {
26167
26527
  return res.blob();
26168
26528
  }).then(function(blob) {
26169
- return createImageBitmap(blob, Object.assign(scope.options, { colorSpaceConversion: "none" }));
26529
+ return createImageBitmap(blob, Object.assign({}, scope.options, { colorSpaceConversion: "none" }));
26170
26530
  }).then(function(imageBitmap) {
26171
26531
  Cache.add(`image-bitmap:${url}`, imageBitmap);
26172
26532
  if (onLoad) onLoad(imageBitmap);
26173
26533
  scope.manager.itemEnd(url);
26534
+ return imageBitmap;
26174
26535
  }).catch(function(e) {
26175
26536
  if (onError) onError(e);
26176
26537
  _errorMap.set(promise, e);
@@ -28010,9 +28371,13 @@ var AnimationObjectGroup = class {
28010
28371
  delete indicesByUUID[uuid];
28011
28372
  if (index < nCachedObjects) {
28012
28373
  const firstActiveIndex = --nCachedObjects, lastCachedObject = objects[firstActiveIndex], lastIndex = --nObjects, lastObject = objects[lastIndex];
28013
- indicesByUUID[lastCachedObject.uuid] = index;
28374
+ if (index !== firstActiveIndex) {
28375
+ indicesByUUID[lastCachedObject.uuid] = index;
28376
+ }
28014
28377
  objects[index] = lastCachedObject;
28015
- indicesByUUID[lastObject.uuid] = firstActiveIndex;
28378
+ if (firstActiveIndex !== lastIndex) {
28379
+ indicesByUUID[lastObject.uuid] = firstActiveIndex;
28380
+ }
28016
28381
  objects[firstActiveIndex] = lastObject;
28017
28382
  objects.pop();
28018
28383
  for (let j = 0, m = nBindings; j !== m; ++j) {
@@ -28023,7 +28388,7 @@ var AnimationObjectGroup = class {
28023
28388
  }
28024
28389
  } else {
28025
28390
  const lastIndex = --nObjects, lastObject = objects[lastIndex];
28026
- if (lastIndex > 0) {
28391
+ if (index !== lastIndex) {
28027
28392
  indicesByUUID[lastObject.uuid] = index;
28028
28393
  }
28029
28394
  objects[index] = lastObject;
@@ -28059,7 +28424,7 @@ var AnimationObjectGroup = class {
28059
28424
  unsubscribe_(path) {
28060
28425
  const indicesByPath = this._bindingsIndicesByPath, index = indicesByPath[path];
28061
28426
  if (index !== void 0) {
28062
- const paths = this._paths, parsedPaths = this._parsedPaths, bindings = this._bindings, lastBindingsIndex = bindings.length - 1, lastBindings = bindings[lastBindingsIndex], lastBindingsPath = path[lastBindingsIndex];
28427
+ const paths = this._paths, parsedPaths = this._parsedPaths, bindings = this._bindings, lastBindingsIndex = bindings.length - 1, lastBindings = bindings[lastBindingsIndex], lastBindingsPath = paths[lastBindingsIndex];
28063
28428
  indicesByPath[lastBindingsPath] = index;
28064
28429
  bindings[index] = lastBindings;
28065
28430
  bindings.pop();
@@ -29024,9 +29389,13 @@ var RenderTarget3D = class extends RenderTarget {
29024
29389
  super(width, height, options);
29025
29390
  this.isRenderTarget3D = true;
29026
29391
  this.depth = depth;
29027
- this.texture = new Data3DTexture(null, width, height, depth);
29392
+ for (let i = 0; i < this.textures.length; i++) {
29393
+ const texture = new Data3DTexture(null, width, height, depth);
29394
+ texture.isRenderTargetTexture = true;
29395
+ texture.renderTarget = this;
29396
+ this.textures[i] = texture;
29397
+ }
29028
29398
  this._setTextureOptions(options);
29029
- this.texture.isRenderTargetTexture = true;
29030
29399
  }
29031
29400
  };
29032
29401
  var Uniform = class _Uniform {
@@ -29339,6 +29708,10 @@ var Raycaster = class {
29339
29708
  * be detected. To raycast against both faces of an object, you'll want to set {@link Material#side}
29340
29709
  * to `THREE.DoubleSide`.
29341
29710
  *
29711
+ * Note that a ray hitting a triangle mesh exactly along an edge shared by two faces may be
29712
+ * reported by both faces, resulting in two coincident intersections (identical point and
29713
+ * distance) in the returned array.
29714
+ *
29342
29715
  * @param {Object3D} object - The 3D object to check for intersection with the ray.
29343
29716
  * @param {boolean} [recursive=true] - If set to `true`, it also checks all descendants.
29344
29717
  * Otherwise it only checks intersection with the object.
@@ -30211,6 +30584,7 @@ var SpotLightHelper = class extends Object3D {
30211
30584
  * method whenever this instance is no longer used in your app.
30212
30585
  */
30213
30586
  dispose() {
30587
+ super.dispose();
30214
30588
  this.cone.geometry.dispose();
30215
30589
  this.cone.material.dispose();
30216
30590
  }
@@ -30320,6 +30694,7 @@ var SkeletonHelper = class extends LineSegments {
30320
30694
  * method whenever this instance is no longer used in your app.
30321
30695
  */
30322
30696
  dispose() {
30697
+ super.dispose();
30323
30698
  this.geometry.dispose();
30324
30699
  this.material.dispose();
30325
30700
  }
@@ -30359,6 +30734,7 @@ var PointLightHelper = class extends Mesh {
30359
30734
  * method whenever this instance is no longer used in your app.
30360
30735
  */
30361
30736
  dispose() {
30737
+ super.dispose();
30362
30738
  this.geometry.dispose();
30363
30739
  this.material.dispose();
30364
30740
  }
@@ -30410,6 +30786,7 @@ var HemisphereLightHelper = class extends Object3D {
30410
30786
  * method whenever this instance is no longer used in your app.
30411
30787
  */
30412
30788
  dispose() {
30789
+ super.dispose();
30413
30790
  this.children[0].geometry.dispose();
30414
30791
  this.children[0].material.dispose();
30415
30792
  }
@@ -30477,6 +30854,7 @@ var GridHelper = class extends LineSegments {
30477
30854
  * method whenever this instance is no longer used in your app.
30478
30855
  */
30479
30856
  dispose() {
30857
+ super.dispose();
30480
30858
  this.geometry.dispose();
30481
30859
  this.material.dispose();
30482
30860
  }
@@ -30537,6 +30915,7 @@ var PolarGridHelper = class extends LineSegments {
30537
30915
  * method whenever this instance is no longer used in your app.
30538
30916
  */
30539
30917
  dispose() {
30918
+ super.dispose();
30540
30919
  this.geometry.dispose();
30541
30920
  this.material.dispose();
30542
30921
  }
@@ -30593,6 +30972,7 @@ var DirectionalLightHelper = class extends Object3D {
30593
30972
  * method whenever this instance is no longer used in your app.
30594
30973
  */
30595
30974
  dispose() {
30975
+ super.dispose();
30596
30976
  this.lightPlane.geometry.dispose();
30597
30977
  this.lightPlane.material.dispose();
30598
30978
  this.targetLine.geometry.dispose();
@@ -30806,6 +31186,7 @@ var CameraHelper = class extends LineSegments {
30806
31186
  * method whenever this instance is no longer used in your app.
30807
31187
  */
30808
31188
  dispose() {
31189
+ super.dispose();
30809
31190
  this.geometry.dispose();
30810
31191
  this.material.dispose();
30811
31192
  }
@@ -30901,6 +31282,7 @@ var BoxHelper = class extends LineSegments {
30901
31282
  * method whenever this instance is no longer used in your app.
30902
31283
  */
30903
31284
  dispose() {
31285
+ super.dispose();
30904
31286
  this.geometry.dispose();
30905
31287
  this.material.dispose();
30906
31288
  }
@@ -30936,6 +31318,7 @@ var Box3Helper = class extends LineSegments {
30936
31318
  * method whenever this instance is no longer used in your app.
30937
31319
  */
30938
31320
  dispose() {
31321
+ super.dispose();
30939
31322
  this.geometry.dispose();
30940
31323
  this.material.dispose();
30941
31324
  }
@@ -30976,6 +31359,7 @@ var PlaneHelper = class extends Line {
30976
31359
  * light being visualized.
30977
31360
  */
30978
31361
  dispose() {
31362
+ super.dispose();
30979
31363
  this.geometry.dispose();
30980
31364
  this.material.dispose();
30981
31365
  this.children[0].geometry.dispose();
@@ -31065,6 +31449,7 @@ var ArrowHelper = class extends Object3D {
31065
31449
  * method whenever this instance is no longer used in your app.
31066
31450
  */
31067
31451
  dispose() {
31452
+ super.dispose();
31068
31453
  this.line.geometry.dispose();
31069
31454
  this.line.material.dispose();
31070
31455
  this.cone.geometry.dispose();
@@ -31153,6 +31538,7 @@ var AxesHelper = class extends LineSegments {
31153
31538
  * method whenever this instance is no longer used in your app.
31154
31539
  */
31155
31540
  dispose() {
31541
+ super.dispose();
31156
31542
  this.geometry.dispose();
31157
31543
  this.material.dispose();
31158
31544
  }
@@ -31363,10 +31749,6 @@ var Controls = class extends EventDispatcher {
31363
31749
  * @param {HTMLElement} element - The DOM element to connect to.
31364
31750
  */
31365
31751
  connect(element) {
31366
- if (element === void 0) {
31367
- warn("Controls: connect() now requires an element.");
31368
- return;
31369
- }
31370
31752
  if (this.domElement !== null) this.disconnect();
31371
31753
  this.domElement = element;
31372
31754
  }
@@ -31599,15 +31981,15 @@ if (typeof window !== "undefined") {
31599
31981
  }
31600
31982
  }
31601
31983
 
31602
- // ../../node_modules/.bun/three@0.185.1/node_modules/three/build/three.module.js
31984
+ // ../../node_modules/.bun/three@0.186.0/node_modules/three/build/three.module.js
31603
31985
  function WebGLAnimation() {
31604
31986
  let context = null;
31605
31987
  let isAnimating = false;
31606
31988
  let animationLoop = null;
31607
31989
  let requestId = null;
31608
31990
  function onAnimationFrame(time, frame) {
31609
- animationLoop(time, frame);
31610
31991
  requestId = context.requestAnimationFrame(onAnimationFrame);
31992
+ animationLoop(time, frame);
31611
31993
  }
31612
31994
  return {
31613
31995
  start: function() {
@@ -31798,16 +32180,16 @@ var gradientmap_pars_fragment = "#ifdef USE_GRADIENTMAP\n uniform sampler2D grad
31798
32180
  var lightmap_pars_fragment = "#ifdef USE_LIGHTMAP\n uniform sampler2D lightMap;\n uniform float lightMapIntensity;\n#endif";
31799
32181
  var lights_lambert_fragment = "LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;";
31800
32182
  var lights_lambert_pars_fragment = "varying vec3 vViewPosition;\nstruct LambertMaterial {\n vec3 diffuseColor;\n float specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n float dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct RE_Direct_Lambert\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert";
31801
- var lights_pars_begin = "uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n uniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n float x = normal.x, y = normal.y, z = normal.z;\n vec3 result = shCoefficients[ 0 ] * 0.886227;\n result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n return result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );\n vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n return irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n vec3 irradiance = ambientLightColor;\n return irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n if ( cutoffDistance > 0.0 ) {\n distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n }\n return distanceFalloff;\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n return smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n struct DirectionalLight {\n vec3 direction;\n vec3 color;\n };\n uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n light.color = directionalLight.color;\n light.direction = directionalLight.direction;\n light.visible = true;\n }\n#endif\n#if NUM_POINT_LIGHTS > 0\n struct PointLight {\n vec3 position;\n vec3 color;\n float distance;\n float decay;\n };\n uniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n vec3 lVector = pointLight.position - geometryPosition;\n light.direction = normalize( lVector );\n float lightDistance = length( lVector );\n light.color = pointLight.color;\n light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n light.visible = ( light.color != vec3( 0.0 ) );\n }\n#endif\n#if NUM_SPOT_LIGHTS > 0\n struct SpotLight {\n vec3 position;\n vec3 direction;\n vec3 color;\n float distance;\n float decay;\n float coneCos;\n float penumbraCos;\n };\n uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n vec3 lVector = spotLight.position - geometryPosition;\n light.direction = normalize( lVector );\n float angleCos = dot( light.direction, spotLight.direction );\n float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n if ( spotAttenuation > 0.0 ) {\n float lightDistance = length( lVector );\n light.color = spotLight.color * spotAttenuation;\n light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n light.visible = ( light.color != vec3( 0.0 ) );\n } else {\n light.color = vec3( 0.0 );\n light.visible = false;\n }\n }\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n struct RectAreaLight {\n vec3 color;\n vec3 position;\n vec3 halfWidth;\n vec3 halfHeight;\n };\n uniform sampler2D ltc_1; uniform sampler2D ltc_2;\n uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n struct HemisphereLight {\n vec3 direction;\n vec3 skyColor;\n vec3 groundColor;\n };\n uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n float dotNL = dot( normal, hemiLight.direction );\n float hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n return irradiance;\n }\n#endif\n#include <lightprobes_pars_fragment>";
31802
- var envmap_physical_pars_fragment = "#ifdef USE_ENVMAP\n vec3 getIBLIrradiance( const in vec3 normal ) {\n #ifdef ENVMAP_TYPE_CUBE_UV\n vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );\n vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );\n return PI * envMapColor.rgb * envMapIntensity;\n #else\n return vec3( 0.0 );\n #endif\n }\n vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n #ifdef ENVMAP_TYPE_CUBE_UV\n vec3 reflectVec = reflect( - viewDir, normal );\n reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );\n reflectVec = transformDirectionByInverseViewMatrix( reflectVec, viewMatrix );\n vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );\n return envMapColor.rgb * envMapIntensity;\n #else\n return vec3( 0.0 );\n #endif\n }\n #ifdef USE_ANISOTROPY\n vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n #ifdef ENVMAP_TYPE_CUBE_UV\n vec3 bentNormal = cross( bitangent, viewDir );\n bentNormal = normalize( cross( bentNormal, bitangent ) );\n bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n return getIBLRadiance( viewDir, bentNormal, roughness );\n #else\n return vec3( 0.0 );\n #endif\n }\n #endif\n#endif";
32183
+ var lights_pars_begin = "uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n uniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n float x = normal.x, y = normal.y, z = normal.z;\n vec3 result = shCoefficients[ 0 ] * 0.886227;\n result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n return result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );\n vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n return irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n vec3 irradiance = ambientLightColor;\n return irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n if ( cutoffDistance > 0.0 ) {\n distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n }\n return distanceFalloff;\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n return smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_SUN_LIGHTS > 0\n struct SunLight {\n vec3 direction;\n vec3 color;\n };\n uniform SunLight sunLights[ NUM_SUN_LIGHTS ];\n void getSunLightInfo( const in SunLight sunLight, out IncidentLight light ) {\n light.color = sunLight.color;\n light.direction = sunLight.direction;\n light.visible = true;\n }\n#endif\n#if NUM_DIR_LIGHTS > 0\n struct DirectionalLight {\n vec3 direction;\n vec3 color;\n };\n uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n light.color = directionalLight.color;\n light.direction = directionalLight.direction;\n light.visible = true;\n }\n#endif\n#if NUM_POINT_LIGHTS > 0\n struct PointLight {\n vec3 position;\n vec3 color;\n float distance;\n float decay;\n };\n uniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n vec3 lVector = pointLight.position - geometryPosition;\n light.direction = normalize( lVector );\n float lightDistance = length( lVector );\n light.color = pointLight.color;\n light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n light.visible = ( light.color != vec3( 0.0 ) );\n }\n#endif\n#if NUM_SPOT_LIGHTS > 0\n struct SpotLight {\n vec3 position;\n vec3 direction;\n vec3 color;\n float distance;\n float decay;\n float coneCos;\n float penumbraCos;\n };\n uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n vec3 lVector = spotLight.position - geometryPosition;\n light.direction = normalize( lVector );\n float angleCos = dot( light.direction, spotLight.direction );\n float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n if ( spotAttenuation > 0.0 ) {\n float lightDistance = length( lVector );\n light.color = spotLight.color * spotAttenuation;\n light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n light.visible = ( light.color != vec3( 0.0 ) );\n } else {\n light.color = vec3( 0.0 );\n light.visible = false;\n }\n }\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n struct RectAreaLight {\n vec3 color;\n vec3 position;\n vec3 halfWidth;\n vec3 halfHeight;\n };\n uniform sampler2D ltc_1; uniform sampler2D ltc_2;\n uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n struct HemisphereLight {\n vec3 direction;\n vec3 skyColor;\n vec3 groundColor;\n };\n uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n float dotNL = dot( normal, hemiLight.direction );\n float hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n return irradiance;\n }\n#endif\n#include <lightprobes_pars_fragment>";
32184
+ var envmap_physical_pars_fragment = "#ifdef USE_ENVMAP\n vec3 getIBLIrradiance( const in vec3 normal ) {\n #ifdef ENVMAP_TYPE_CUBE_UV\n vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );\n vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );\n return PI * envMapColor.rgb * envMapIntensity;\n #else\n return vec3( 0.0 );\n #endif\n }\n vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n #ifdef ENVMAP_TYPE_CUBE_UV\n vec3 reflectVec = reflect( - viewDir, normal );\n reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );\n reflectVec = transformDirectionByInverseViewMatrix( reflectVec, viewMatrix );\n vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );\n return envMapColor.rgb * envMapIntensity;\n #else\n return vec3( 0.0 );\n #endif\n }\n #ifdef USE_RETROREFLECTION\n vec3 getIBLRetroRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n #ifdef ENVMAP_TYPE_CUBE_UV\n vec3 retroVec = normalize( mix( viewDir, normal, pow4( roughness ) ) );\n retroVec = transformDirectionByInverseViewMatrix( retroVec, viewMatrix );\n vec4 envMapColor = textureCubeUV( envMap, envMapRotation * retroVec, roughness );\n return envMapColor.rgb * envMapIntensity;\n #else\n return vec3( 0.0 );\n #endif\n }\n #endif\n #ifdef USE_ANISOTROPY\n vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n #ifdef ENVMAP_TYPE_CUBE_UV\n vec3 bentNormal = cross( bitangent, viewDir );\n bentNormal = normalize( cross( bentNormal, bitangent ) );\n bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n return getIBLRadiance( viewDir, bentNormal, roughness );\n #else\n return vec3( 0.0 );\n #endif\n }\n #ifdef USE_RETROREFLECTION\n vec3 getIBLAnisotropyRetroRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n #ifdef ENVMAP_TYPE_CUBE_UV\n vec3 bentNormal = cross( bitangent, viewDir );\n bentNormal = normalize( cross( bentNormal, bitangent ) );\n bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n return getIBLRetroRadiance( viewDir, bentNormal, roughness );\n #else\n return vec3( 0.0 );\n #endif\n }\n #endif\n #endif\n#endif";
31803
32185
  var lights_toon_fragment = "ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;";
31804
32186
  var lights_toon_pars_fragment = "varying vec3 vViewPosition;\nstruct ToonMaterial {\n vec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct RE_Direct_Toon\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon";
31805
32187
  var lights_phong_fragment = "BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;";
31806
32188
  var lights_phong_pars_fragment = "varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n vec3 diffuseColor;\n vec3 specularColor;\n float specularShininess;\n float specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n float dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct RE_Direct_BlinnPhong\n#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong";
31807
- var lights_physical_fragment = "PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.metalness = metalnessFactor;\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n material.ior = ior;\n #ifdef USE_SPECULAR\n float specularIntensityFactor = specularIntensity;\n vec3 specularColorFactor = specularColor;\n #ifdef USE_SPECULAR_COLORMAP\n specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n #endif\n #ifdef USE_SPECULAR_INTENSITYMAP\n specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n #endif\n material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n #else\n float specularIntensityFactor = 1.0;\n vec3 specularColorFactor = vec3( 1.0 );\n material.specularF90 = 1.0;\n #endif\n material.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor;\n material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );\n#else\n material.specularColor = vec3( 0.04 );\n material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );\n material.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n material.clearcoat = clearcoat;\n material.clearcoatRoughness = clearcoatRoughness;\n material.clearcoatF0 = vec3( 0.04 );\n material.clearcoatF90 = 1.0;\n #ifdef USE_CLEARCOATMAP\n material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n #endif\n #ifdef USE_CLEARCOAT_ROUGHNESSMAP\n material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n #endif\n material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n material.clearcoatRoughness += geometryRoughness;\n material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_DISPERSION\n material.dispersion = dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n material.iridescence = iridescence;\n material.iridescenceIOR = iridescenceIOR;\n #ifdef USE_IRIDESCENCEMAP\n material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n #endif\n #ifdef USE_IRIDESCENCE_THICKNESSMAP\n material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n #else\n material.iridescenceThickness = iridescenceThicknessMaximum;\n #endif\n#endif\n#ifdef USE_SHEEN\n material.sheenColor = sheenColor;\n #ifdef USE_SHEEN_COLORMAP\n material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n #endif\n material.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 );\n #ifdef USE_SHEEN_ROUGHNESSMAP\n material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n #endif\n#endif\n#ifdef USE_ANISOTROPY\n #ifdef USE_ANISOTROPYMAP\n mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n #else\n vec2 anisotropyV = anisotropyVector;\n #endif\n material.anisotropy = length( anisotropyV );\n if( material.anisotropy == 0.0 ) {\n anisotropyV = vec2( 1.0, 0.0 );\n } else {\n anisotropyV /= material.anisotropy;\n material.anisotropy = saturate( material.anisotropy );\n }\n material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;\n material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;\n#endif";
31808
- var lights_physical_pars_fragment = "uniform sampler2D dfgLUT;\nstruct PhysicalMaterial {\n vec3 diffuseColor;\n vec3 diffuseContribution;\n vec3 specularColor;\n vec3 specularColorBlended;\n float roughness;\n float metalness;\n float specularF90;\n float dispersion;\n #ifdef USE_CLEARCOAT\n float clearcoat;\n float clearcoatRoughness;\n vec3 clearcoatF0;\n float clearcoatF90;\n #endif\n #ifdef USE_IRIDESCENCE\n float iridescence;\n float iridescenceIOR;\n float iridescenceThickness;\n vec3 iridescenceFresnel;\n vec3 iridescenceF0;\n vec3 iridescenceFresnelDielectric;\n vec3 iridescenceFresnelMetallic;\n #endif\n #ifdef USE_SHEEN\n vec3 sheenColor;\n float sheenRoughness;\n #endif\n #ifdef IOR\n float ior;\n #endif\n #ifdef USE_TRANSMISSION\n float transmission;\n float transmissionAlpha;\n float thickness;\n float attenuationDistance;\n vec3 attenuationColor;\n #endif\n #ifdef USE_ANISOTROPY\n float anisotropy;\n float alphaT;\n vec3 anisotropyT;\n vec3 anisotropyB;\n #endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n float a2 = pow2( alpha );\n float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n return 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n float a2 = pow2( alpha );\n float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n return RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n return 0.5 / max( gv + gl, EPSILON );\n }\n float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n float a2 = alphaT * alphaB;\n highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n highp float v2 = dot( v, v );\n float w2 = a2 / v2;\n return RECIPROCAL_PI * a2 * pow2 ( w2 );\n }\n#endif\n#ifdef USE_CLEARCOAT\n vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n vec3 f0 = material.clearcoatF0;\n float f90 = material.clearcoatF90;\n float roughness = material.clearcoatRoughness;\n float alpha = pow2( roughness );\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float dotVH = saturate( dot( viewDir, halfDir ) );\n vec3 F = F_Schlick( f0, f90, dotVH );\n float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n float D = D_GGX( alpha, dotNH );\n return F * ( V * D );\n }\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n vec3 f0 = material.specularColorBlended;\n float f90 = material.specularF90;\n float roughness = material.roughness;\n float alpha = pow2( roughness );\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float dotVH = saturate( dot( viewDir, halfDir ) );\n vec3 F = F_Schlick( f0, f90, dotVH );\n #ifdef USE_IRIDESCENCE\n F = mix( F, material.iridescenceFresnel, material.iridescence );\n #endif\n #ifdef USE_ANISOTROPY\n float dotTL = dot( material.anisotropyT, lightDir );\n float dotTV = dot( material.anisotropyT, viewDir );\n float dotTH = dot( material.anisotropyT, halfDir );\n float dotBL = dot( material.anisotropyB, lightDir );\n float dotBV = dot( material.anisotropyB, viewDir );\n float dotBH = dot( material.anisotropyB, halfDir );\n float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n #else\n float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n float D = D_GGX( alpha, dotNH );\n #endif\n return F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n const float LUT_SIZE = 64.0;\n const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n const float LUT_BIAS = 0.5 / LUT_SIZE;\n float dotNV = saturate( dot( N, V ) );\n vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n uv = uv * LUT_SCALE + LUT_BIAS;\n return uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n float l = length( f );\n return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n float x = dot( v1, v2 );\n float y = abs( x );\n float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n float b = 3.4175940 + ( 4.1616724 + y ) * y;\n float v = a / b;\n float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n return cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n vec3 lightNormal = cross( v1, v2 );\n if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n vec3 T1, T2;\n T1 = normalize( V - N * dot( V, N ) );\n T2 = - cross( N, T1 );\n mat3 mat = mInv * transpose( mat3( T1, T2, N ) );\n vec3 coords[ 4 ];\n coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n coords[ 0 ] = normalize( coords[ 0 ] );\n coords[ 1 ] = normalize( coords[ 1 ] );\n coords[ 2 ] = normalize( coords[ 2 ] );\n coords[ 3 ] = normalize( coords[ 3 ] );\n vec3 vectorFormFactor = vec3( 0.0 );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n float result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n return vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n float alpha = pow2( roughness );\n float invAlpha = 1.0 / alpha;\n float cos2h = dotNH * dotNH;\n float sin2h = max( 1.0 - cos2h, 0.0078125 );\n return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float D = D_Charlie( sheenRoughness, dotNH );\n float V = V_Neubelt( dotNV, dotNL );\n return sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n float dotNV = saturate( dot( normal, viewDir ) );\n float r2 = roughness * roughness;\n float rInv = 1.0 / ( roughness + 0.1 );\n float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv;\n float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv;\n float DG = exp( a * dotNV + b );\n return saturate( DG );\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n float dotNV = saturate( dot( normal, viewDir ) );\n vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n return specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n float dotNV = saturate( dot( normal, viewDir ) );\n vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n #ifdef USE_IRIDESCENCE\n vec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n #else\n vec3 Fr = specularColor;\n #endif\n vec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n float Ess = fab.x + fab.y;\n float Ems = 1.0 - Ess;\n vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n singleScatter += FssEss;\n multiScatter += Fms * Ems;\n}\nvec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n vec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg;\n vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg;\n vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y;\n vec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y;\n float Ess_V = dfgV.x + dfgV.y;\n float Ess_L = dfgL.x + dfgL.y;\n float Ems_V = 1.0 - Ess_V;\n float Ems_L = 1.0 - Ess_L;\n vec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619;\n vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON );\n float compensationFactor = Ems_V * Ems_L;\n vec3 multiScatter = Fms * compensationFactor;\n return singleScatter + multiScatter;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n vec3 normal = geometryNormal;\n vec3 viewDir = geometryViewDir;\n vec3 position = geometryPosition;\n vec3 lightPos = rectAreaLight.position;\n vec3 halfWidth = rectAreaLight.halfWidth;\n vec3 halfHeight = rectAreaLight.halfHeight;\n vec3 lightColor = rectAreaLight.color;\n float roughness = material.roughness;\n vec3 rectCoords[ 4 ];\n rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n vec2 uv = LTC_Uv( normal, viewDir, roughness );\n vec4 t1 = texture2D( ltc_1, uv );\n vec4 t2 = texture2D( ltc_2, uv );\n mat3 mInv = mat3(\n vec3( t1.x, 0, t1.y ),\n vec3( 0, 1, 0 ),\n vec3( t1.z, 0, t1.w )\n );\n vec3 fresnel = ( material.specularColorBlended * t2.x + ( material.specularF90 - material.specularColorBlended ) * t2.y );\n reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n #ifdef USE_CLEARCOAT\n vec3 Ncc = geometryClearcoatNormal;\n vec2 uvClearcoat = LTC_Uv( Ncc, viewDir, material.clearcoatRoughness );\n vec4 t1Clearcoat = texture2D( ltc_1, uvClearcoat );\n vec4 t2Clearcoat = texture2D( ltc_2, uvClearcoat );\n mat3 mInvClearcoat = mat3(\n vec3( t1Clearcoat.x, 0, t1Clearcoat.y ),\n vec3( 0, 1, 0 ),\n vec3( t1Clearcoat.z, 0, t1Clearcoat.w )\n );\n vec3 fresnelClearcoat = material.clearcoatF0 * t2Clearcoat.x + ( material.clearcoatF90 - material.clearcoatF0 ) * t2Clearcoat.y;\n clearcoatSpecularDirect += lightColor * fresnelClearcoat * LTC_Evaluate( Ncc, viewDir, position, mInvClearcoat, rectCoords );\n #endif\n }\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n float dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n #ifdef USE_CLEARCOAT\n float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n vec3 ccIrradiance = dotNLcc * directLight.color;\n clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n #endif\n #ifdef USE_SHEEN\n \n sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n \n float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness );\n \n float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL );\n \n irradiance *= sheenEnergyComp;\n \n #endif\n reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution );\n #ifdef USE_SHEEN\n float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n diffuse *= sheenEnergyComp;\n #endif\n reflectedLight.indirectDiffuse += diffuse;\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n #ifdef USE_CLEARCOAT\n clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n #endif\n #ifdef USE_SHEEN\n sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI;\n #endif\n vec3 singleScatteringDielectric = vec3( 0.0 );\n vec3 multiScatteringDielectric = vec3( 0.0 );\n vec3 singleScatteringMetallic = vec3( 0.0 );\n vec3 multiScatteringMetallic = vec3( 0.0 );\n #ifdef USE_IRIDESCENCE\n computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n #else\n computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n #endif\n vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness );\n vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness );\n vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric;\n vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric );\n vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n vec3 indirectSpecular = radiance * singleScattering;\n indirectSpecular += multiScattering * cosineWeightedIrradiance;\n vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance;\n #ifdef USE_SHEEN\n float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n indirectSpecular *= sheenEnergyComp;\n indirectDiffuse *= sheenEnergyComp;\n #endif\n reflectedLight.indirectSpecular += indirectSpecular;\n reflectedLight.indirectDiffuse += indirectDiffuse;\n}\n#define RE_Direct RE_Direct_Physical\n#define RE_Direct_RectArea RE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular RE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}";
31809
- var lights_fragment_begin = "\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n geometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n float dotNVi = saturate( dot( normal, geometryViewDir ) );\n if ( material.iridescenceThickness == 0.0 ) {\n material.iridescence = 0.0;\n } else {\n material.iridescence = saturate( material.iridescence );\n }\n if ( material.iridescence > 0.0 ) {\n material.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor );\n material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness );\n material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n }\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n PointLight pointLight;\n #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n PointLightShadow pointLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n pointLight = pointLights[ i ];\n getPointLightInfo( pointLight, geometryPosition, directLight );\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\n pointLightShadow = pointLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n SpotLight spotLight;\n vec4 spotColor;\n vec3 spotLightCoord;\n bool inSpotLightMap;\n #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n SpotLightShadow spotLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n spotLight = spotLights[ i ];\n getSpotLightInfo( spotLight, geometryPosition, directLight );\n #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n #else\n #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n #endif\n #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n #endif\n #undef SPOT_LIGHT_MAP_INDEX\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n spotLightShadow = spotLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n DirectionalLight directionalLight;\n #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n directionalLight = directionalLights[ i ];\n getDirectionalLightInfo( directionalLight, directLight );\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n directionalLightShadow = directionalLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n RectAreaLight rectAreaLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n rectAreaLight = rectAreaLights[ i ];\n RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n vec3 iblIrradiance = vec3( 0.0 );\n vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n #if defined( USE_LIGHT_PROBES )\n irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n #endif\n #if ( NUM_HEMI_LIGHTS > 0 )\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n }\n #pragma unroll_loop_end\n #endif\n #ifdef USE_LIGHT_PROBES_GRID\n vec3 probeWorldPos = ( ( vec4( geometryPosition, 1.0 ) - viewMatrix[ 3 ] ) * viewMatrix ).xyz;\n vec3 probeWorldNormal = transformNormalByInverseViewMatrix( geometryNormal, viewMatrix );\n irradiance += getLightProbeGridIrradiance( probeWorldPos, probeWorldNormal );\n #endif\n#endif\n#if defined( RE_IndirectSpecular )\n vec3 radiance = vec3( 0.0 );\n vec3 clearcoatRadiance = vec3( 0.0 );\n#endif";
31810
- var lights_fragment_maps = "#if defined( RE_IndirectDiffuse )\n #ifdef USE_LIGHTMAP\n vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n irradiance += lightMapIrradiance;\n #endif\n #if defined( USE_ENVMAP ) && defined( ENVMAP_TYPE_CUBE_UV )\n #if defined( STANDARD ) || defined( LAMBERT ) || defined( PHONG )\n iblIrradiance += getIBLIrradiance( geometryNormal );\n #endif\n #endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n #ifdef USE_ANISOTROPY\n radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n #else\n radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n #endif\n #ifdef USE_CLEARCOAT\n clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n #endif\n#endif";
32189
+ var lights_physical_fragment = "PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.metalness = metalnessFactor;\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n material.ior = ior;\n #ifdef USE_SPECULAR\n float specularIntensityFactor = specularIntensity;\n vec3 specularColorFactor = specularColor;\n #ifdef USE_SPECULAR_COLORMAP\n specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n #endif\n #ifdef USE_SPECULAR_INTENSITYMAP\n specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n #endif\n material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n #else\n float specularIntensityFactor = 1.0;\n vec3 specularColorFactor = vec3( 1.0 );\n material.specularF90 = 1.0;\n #endif\n material.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor;\n material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );\n#else\n material.specularColor = vec3( 0.04 );\n material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );\n material.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n material.clearcoat = clearcoat;\n material.clearcoatRoughness = clearcoatRoughness;\n material.clearcoatF0 = vec3( 0.04 );\n material.clearcoatF90 = 1.0;\n #ifdef USE_CLEARCOATMAP\n material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n #endif\n #ifdef USE_CLEARCOAT_ROUGHNESSMAP\n material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n #endif\n material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n material.clearcoatRoughness += geometryRoughness;\n material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_DISPERSION\n material.dispersion = dispersion;\n#endif\n#ifdef USE_RETROREFLECTION\n material.retroreflectivity = retroreflectivity;\n#endif\n#ifdef USE_IRIDESCENCE\n material.iridescence = iridescence;\n material.iridescenceIOR = iridescenceIOR;\n #ifdef USE_IRIDESCENCEMAP\n material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n #endif\n #ifdef USE_IRIDESCENCE_THICKNESSMAP\n material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n #else\n material.iridescenceThickness = iridescenceThicknessMaximum;\n #endif\n#endif\n#ifdef USE_SHEEN\n material.sheenColor = sheenColor;\n #ifdef USE_SHEEN_COLORMAP\n material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n #endif\n material.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 );\n #ifdef USE_SHEEN_ROUGHNESSMAP\n material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n #endif\n#endif\n#ifdef USE_ANISOTROPY\n #ifdef USE_ANISOTROPYMAP\n mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n #else\n vec2 anisotropyV = anisotropyVector;\n #endif\n material.anisotropy = length( anisotropyV );\n if( material.anisotropy == 0.0 ) {\n anisotropyV = vec2( 1.0, 0.0 );\n } else {\n anisotropyV /= material.anisotropy;\n material.anisotropy = saturate( material.anisotropy );\n }\n material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;\n material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;\n#endif";
32190
+ var lights_physical_pars_fragment = "uniform sampler2D dfgLUT;\nstruct PhysicalMaterial {\n vec3 diffuseColor;\n vec3 diffuseContribution;\n vec3 specularColor;\n vec3 specularColorBlended;\n float roughness;\n float metalness;\n float specularF90;\n float dispersion;\n vec2 dfg;\n vec3 multiScatteringCompensation;\n #ifdef USE_RETROREFLECTION\n float retroreflectivity;\n #endif\n #ifdef USE_CLEARCOAT\n float clearcoat;\n float clearcoatRoughness;\n vec3 clearcoatF0;\n float clearcoatF90;\n #endif\n #ifdef USE_IRIDESCENCE\n float iridescence;\n float iridescenceIOR;\n float iridescenceThickness;\n vec3 iridescenceFresnel;\n vec3 iridescenceF0Dielectric;\n vec3 iridescenceF0Metallic;\n #endif\n #ifdef USE_SHEEN\n vec3 sheenColor;\n float sheenRoughness;\n #endif\n #ifdef IOR\n float ior;\n #endif\n #ifdef USE_TRANSMISSION\n float transmission;\n float transmissionAlpha;\n float thickness;\n float attenuationDistance;\n vec3 attenuationColor;\n #endif\n #ifdef USE_ANISOTROPY\n float anisotropy;\n float alphaT;\n vec3 anisotropyT;\n vec3 anisotropyB;\n #endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n float a2 = pow2( alpha );\n float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n return 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n float a2 = pow2( alpha );\n float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n return RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n return 0.5 / max( gv + gl, EPSILON );\n }\n float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n float a2 = alphaT * alphaB;\n highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n highp float v2 = dot( v, v );\n float w2 = a2 / v2;\n return RECIPROCAL_PI * a2 * pow2 ( w2 );\n }\n#endif\n#ifdef USE_CLEARCOAT\n vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n vec3 f0 = material.clearcoatF0;\n float f90 = material.clearcoatF90;\n float roughness = material.clearcoatRoughness;\n float alpha = pow2( roughness );\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float dotVH = saturate( dot( viewDir, halfDir ) );\n vec3 F = F_Schlick( f0, f90, dotVH );\n float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n float D = D_GGX( alpha, dotNH );\n return F * ( V * D );\n }\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n vec3 f0 = material.specularColorBlended;\n float f90 = material.specularF90;\n float roughness = material.roughness;\n float alpha = pow2( roughness );\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float dotVH = saturate( dot( viewDir, halfDir ) );\n vec3 F = F_Schlick( f0, f90, dotVH );\n #ifdef USE_IRIDESCENCE\n F = mix( F, material.iridescenceFresnel, material.iridescence );\n #endif\n #ifdef USE_ANISOTROPY\n float dotTL = dot( material.anisotropyT, lightDir );\n float dotTV = dot( material.anisotropyT, viewDir );\n float dotTH = dot( material.anisotropyT, halfDir );\n float dotBL = dot( material.anisotropyB, lightDir );\n float dotBV = dot( material.anisotropyB, viewDir );\n float dotBH = dot( material.anisotropyB, halfDir );\n float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n #else\n float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n float D = D_GGX( alpha, dotNH );\n #endif\n return F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n const float LUT_SIZE = 64.0;\n const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n const float LUT_BIAS = 0.5 / LUT_SIZE;\n float dotNV = saturate( dot( N, V ) );\n vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n uv = uv * LUT_SCALE + LUT_BIAS;\n return uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n float l = length( f );\n return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n float x = dot( v1, v2 );\n float y = abs( x );\n float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n float b = 3.4175940 + ( 4.1616724 + y ) * y;\n float v = a / b;\n float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n return cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n vec3 lightNormal = cross( v1, v2 );\n if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n vec3 T1, T2;\n T1 = normalize( V - N * dot( V, N ) );\n T2 = - cross( N, T1 );\n mat3 mat = mInv * transpose( mat3( T1, T2, N ) );\n vec3 coords[ 4 ];\n coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n coords[ 0 ] = normalize( coords[ 0 ] );\n coords[ 1 ] = normalize( coords[ 1 ] );\n coords[ 2 ] = normalize( coords[ 2 ] );\n coords[ 3 ] = normalize( coords[ 3 ] );\n vec3 vectorFormFactor = vec3( 0.0 );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n float result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n return vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n float alpha = pow2( roughness );\n float invAlpha = 1.0 / alpha;\n float cos2h = dotNH * dotNH;\n float sin2h = max( 1.0 - cos2h, 0.0078125 );\n return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float D = D_Charlie( sheenRoughness, dotNH );\n float V = V_Neubelt( dotNV, dotNL );\n return sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n float dotNV = saturate( dot( normal, viewDir ) );\n float r2 = roughness * roughness;\n float rInv = 1.0 / ( roughness + 0.1 );\n float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv;\n float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv;\n float DG = exp( a * dotNV + b );\n return saturate( DG );\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n float dotNV = saturate( dot( normal, viewDir ) );\n vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n return specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec2 fab, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec2 fab, const in vec3 specularColor, const in float specularF90, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n #ifdef USE_IRIDESCENCE\n vec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n #else\n vec3 Fr = specularColor;\n #endif\n vec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n float Ess = fab.x + fab.y;\n float Ems = 1.0 - Ess;\n vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n singleScatter += FssEss;\n multiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n vec3 normal = geometryNormal;\n vec3 viewDir = geometryViewDir;\n vec3 position = geometryPosition;\n vec3 lightPos = rectAreaLight.position;\n vec3 halfWidth = rectAreaLight.halfWidth;\n vec3 halfHeight = rectAreaLight.halfHeight;\n vec3 lightColor = rectAreaLight.color;\n float roughness = material.roughness;\n vec3 rectCoords[ 4 ];\n rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n vec2 uv = LTC_Uv( normal, viewDir, roughness );\n vec4 t1 = texture2D( ltc_1, uv );\n vec4 t2 = texture2D( ltc_2, uv );\n mat3 mInv = mat3(\n vec3( t1.x, 0, t1.y ),\n vec3( 0, 1, 0 ),\n vec3( t1.z, 0, t1.w )\n );\n vec3 fresnel = ( material.specularColorBlended * t2.x + ( material.specularF90 - material.specularColorBlended ) * t2.y );\n reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n #ifdef USE_CLEARCOAT\n vec3 Ncc = geometryClearcoatNormal;\n vec2 uvClearcoat = LTC_Uv( Ncc, viewDir, material.clearcoatRoughness );\n vec4 t1Clearcoat = texture2D( ltc_1, uvClearcoat );\n vec4 t2Clearcoat = texture2D( ltc_2, uvClearcoat );\n mat3 mInvClearcoat = mat3(\n vec3( t1Clearcoat.x, 0, t1Clearcoat.y ),\n vec3( 0, 1, 0 ),\n vec3( t1Clearcoat.z, 0, t1Clearcoat.w )\n );\n vec3 fresnelClearcoat = material.clearcoatF0 * t2Clearcoat.x + ( material.clearcoatF90 - material.clearcoatF0 ) * t2Clearcoat.y;\n clearcoatSpecularDirect += lightColor * fresnelClearcoat * LTC_Evaluate( Ncc, viewDir, position, mInvClearcoat, rectCoords );\n #endif\n }\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n float dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n #ifdef USE_CLEARCOAT\n float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n vec3 ccIrradiance = dotNLcc * directLight.color;\n clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n #endif\n #ifdef USE_SHEEN\n \n sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n \n float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness );\n \n float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL );\n \n irradiance *= sheenEnergyComp;\n \n #endif\n vec3 specularBRDF = BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );\n #ifdef USE_RETROREFLECTION\n vec3 retroViewDir = reflect( - geometryViewDir, geometryNormal );\n vec3 retroSpecularBRDF = BRDF_GGX( directLight.direction, retroViewDir, geometryNormal, material );\n specularBRDF = mix( specularBRDF, retroSpecularBRDF, saturate( material.retroreflectivity ) );\n #endif\n reflectedLight.directSpecular += irradiance * specularBRDF * material.multiScatteringCompensation;\n vec3 halfDir = normalize( directLight.direction + geometryViewDir );\n float dotVH = saturate( dot( geometryViewDir, halfDir ) );\n vec3 F = F_Schlick( material.specularColor, material.specularF90, dotVH );\n #ifdef USE_RETROREFLECTION\n vec3 retroHalfDir = normalize( directLight.direction + retroViewDir );\n float dotRetroVH = saturate( dot( retroViewDir, retroHalfDir ) );\n vec3 retroF = F_Schlick( material.specularColor, material.specularF90, dotRetroVH );\n F = mix( F, retroF, saturate( material.retroreflectivity ) );\n #endif\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution ) * ( 1.0 - F );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n vec3 singleScattering = vec3( 0.0 );\n vec3 multiScattering = vec3( 0.0 );\n #ifdef USE_IRIDESCENCE\n computeMultiscatteringIridescence( material.dfg, material.specularColor, material.specularF90, material.iridescence, material.iridescenceF0Dielectric, singleScattering, multiScattering );\n #else\n computeMultiscattering( material.dfg, material.specularColor, material.specularF90, singleScattering, multiScattering );\n #endif\n vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution ) * ( 1.0 - singleScattering - multiScattering );\n #ifdef USE_SHEEN\n float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n sheenSpecularIndirect += irradiance * material.sheenColor * sheenAlbedo * RECIPROCAL_PI;\n float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n diffuse *= sheenEnergyComp;\n #endif\n reflectedLight.indirectDiffuse += diffuse;\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n #ifdef USE_CLEARCOAT\n clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n #endif\n #ifdef USE_SHEEN\n sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI;\n #endif\n vec3 singleScatteringDielectric = vec3( 0.0 );\n vec3 multiScatteringDielectric = vec3( 0.0 );\n vec3 singleScatteringMetallic = vec3( 0.0 );\n vec3 multiScatteringMetallic = vec3( 0.0 );\n #ifdef USE_IRIDESCENCE\n computeMultiscatteringIridescence( material.dfg, material.specularColor, material.specularF90, material.iridescence, material.iridescenceF0Dielectric, singleScatteringDielectric, multiScatteringDielectric );\n computeMultiscatteringIridescence( material.dfg, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceF0Metallic, singleScatteringMetallic, multiScatteringMetallic );\n #else\n computeMultiscattering( material.dfg, material.specularColor, material.specularF90, singleScatteringDielectric, multiScatteringDielectric );\n computeMultiscattering( material.dfg, material.diffuseColor, material.specularF90, singleScatteringMetallic, multiScatteringMetallic );\n #endif\n vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness );\n vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness );\n vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric;\n vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric );\n vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n vec3 indirectSpecular = radiance * singleScattering;\n indirectSpecular += multiScattering * cosineWeightedIrradiance;\n vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance;\n #ifdef USE_SHEEN\n float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n indirectSpecular *= sheenEnergyComp;\n indirectDiffuse *= sheenEnergyComp;\n #endif\n reflectedLight.indirectSpecular += indirectSpecular;\n reflectedLight.indirectDiffuse += indirectDiffuse;\n}\n#define RE_Direct RE_Direct_Physical\n#define RE_Direct_RectArea RE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular RE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}";
32191
+ var lights_fragment_begin = "\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n geometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n float dotNVi = saturate( dot( normal, geometryViewDir ) );\n if ( material.iridescenceThickness == 0.0 ) {\n material.iridescence = 0.0;\n } else {\n material.iridescence = saturate( material.iridescence );\n }\n if ( material.iridescence > 0.0 ) {\n vec3 iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n vec3 iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor );\n material.iridescenceFresnel = mix( iridescenceFresnelDielectric, iridescenceFresnelMetallic, material.metalness );\n material.iridescenceF0Dielectric = Schlick_to_F0( iridescenceFresnelDielectric, 1.0, dotNVi );\n material.iridescenceF0Metallic = Schlick_to_F0( iridescenceFresnelMetallic, 1.0, dotNVi );\n }\n#endif\n#ifdef STANDARD\n float dotNVms = saturate( dot( geometryNormal, geometryViewDir ) );\n material.dfg = texture2D( dfgLUT, vec2( material.roughness, dotNVms ) ).rg;\n #if ( NUM_SUN_LIGHTS > 0 || NUM_DIR_LIGHTS > 0 || NUM_POINT_LIGHTS > 0 || NUM_SPOT_LIGHTS > 0 )\n float EssMs = material.dfg.x + material.dfg.y;\n material.multiScatteringCompensation = 1.0 + material.specularColorBlended * ( 1.0 / EssMs - 1.0 );\n #endif\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n PointLight pointLight;\n #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n PointLightShadow pointLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n pointLight = pointLights[ i ];\n getPointLightInfo( pointLight, geometryPosition, directLight );\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\n pointLightShadow = pointLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n SpotLight spotLight;\n vec4 spotColor;\n vec3 spotLightCoord;\n bool inSpotLightMap;\n #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n SpotLightShadow spotLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n spotLight = spotLights[ i ];\n getSpotLightInfo( spotLight, geometryPosition, directLight );\n #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n #else\n #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n #endif\n #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n #endif\n #undef SPOT_LIGHT_MAP_INDEX\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n spotLightShadow = spotLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_SUN_LIGHTS > 0 ) && defined( RE_Direct )\n SunLight sunLight;\n #if defined( USE_SHADOWMAP ) && NUM_SUN_LIGHT_SHADOWS > 0\n SunLightShadow sunLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SUN_LIGHTS; i ++ ) {\n sunLight = sunLights[ i ];\n getSunLightInfo( sunLight, directLight );\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SUN_LIGHT_SHADOWS )\n sunLightShadow = sunLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getSunShadow( sunShadowMap[ i ], sunLightShadow, UNROLLED_LOOP_INDEX ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n DirectionalLight directionalLight;\n #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n directionalLight = directionalLights[ i ];\n getDirectionalLightInfo( directionalLight, directLight );\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n directionalLightShadow = directionalLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n RectAreaLight rectAreaLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n rectAreaLight = rectAreaLights[ i ];\n RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n vec3 iblIrradiance = vec3( 0.0 );\n vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n #if defined( USE_LIGHT_PROBES )\n irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n #endif\n #if ( NUM_HEMI_LIGHTS > 0 )\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n }\n #pragma unroll_loop_end\n #endif\n #ifdef USE_LIGHT_PROBES_GRID\n vec3 probeWorldPos = ( ( vec4( geometryPosition, 1.0 ) - viewMatrix[ 3 ] ) * viewMatrix ).xyz;\n vec3 probeWorldNormal = transformNormalByInverseViewMatrix( geometryNormal, viewMatrix );\n irradiance += getLightProbeGridIrradiance( probeWorldPos, probeWorldNormal );\n #endif\n#endif\n#if defined( RE_IndirectSpecular )\n vec3 radiance = vec3( 0.0 );\n vec3 clearcoatRadiance = vec3( 0.0 );\n#endif";
32192
+ var lights_fragment_maps = "#if defined( RE_IndirectDiffuse )\n #ifdef USE_LIGHTMAP\n vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n irradiance += lightMapIrradiance;\n #endif\n #if defined( USE_ENVMAP ) && defined( ENVMAP_TYPE_CUBE_UV )\n #if defined( STANDARD ) || defined( LAMBERT ) || defined( PHONG )\n iblIrradiance += getIBLIrradiance( geometryNormal );\n #endif\n #endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n #ifdef USE_ANISOTROPY\n vec3 iblRadiance = getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n #else\n vec3 iblRadiance = getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n #endif\n #ifdef USE_RETROREFLECTION\n #ifdef USE_ANISOTROPY\n vec3 retroIBLRadiance = getIBLAnisotropyRetroRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n #else\n vec3 retroIBLRadiance = getIBLRetroRadiance( geometryViewDir, geometryNormal, material.roughness );\n #endif\n iblRadiance = mix( iblRadiance, retroIBLRadiance, saturate( material.retroreflectivity ) );\n #endif\n radiance += iblRadiance;\n #ifdef USE_CLEARCOAT\n clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n #endif\n#endif";
31811
32193
  var lights_fragment_end = "#if defined( RE_IndirectDiffuse )\n #if defined( LAMBERT ) || defined( PHONG )\n irradiance += iblIrradiance;\n #endif\n RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif";
31812
32194
  var lightprobes_pars_fragment = "#ifdef USE_LIGHT_PROBES_GRID\nuniform highp sampler3D probesSH;\nuniform vec3 probesMin;\nuniform vec3 probesMax;\nuniform vec3 probesResolution;\nvec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {\n vec3 res = probesResolution;\n vec3 gridRange = probesMax - probesMin;\n vec3 resMinusOne = res - 1.0;\n vec3 probeSpacing = gridRange / resMinusOne;\n vec3 samplePos = worldPos + worldNormal * probeSpacing * 0.5;\n vec3 uvw = clamp( ( samplePos - probesMin ) / gridRange, 0.0, 1.0 );\n uvw = uvw * resMinusOne / res + 0.5 / res;\n float nz = res.z;\n float paddedSlices = nz + 2.0;\n float atlasDepth = 7.0 * paddedSlices;\n float uvZBase = uvw.z * nz + 1.0;\n vec4 s0 = texture( probesSH, vec3( uvw.xy, ( uvZBase ) / atlasDepth ) );\n vec4 s1 = texture( probesSH, vec3( uvw.xy, ( uvZBase + paddedSlices ) / atlasDepth ) );\n vec4 s2 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 2.0 * paddedSlices ) / atlasDepth ) );\n vec4 s3 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 3.0 * paddedSlices ) / atlasDepth ) );\n vec4 s4 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 4.0 * paddedSlices ) / atlasDepth ) );\n vec4 s5 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 5.0 * paddedSlices ) / atlasDepth ) );\n vec4 s6 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 6.0 * paddedSlices ) / atlasDepth ) );\n vec3 c0 = s0.xyz;\n vec3 c1 = vec3( s0.w, s1.xy );\n vec3 c2 = vec3( s1.zw, s2.x );\n vec3 c3 = s2.yzw;\n vec3 c4 = s3.xyz;\n vec3 c5 = vec3( s3.w, s4.xy );\n vec3 c6 = vec3( s4.zw, s5.x );\n vec3 c7 = s5.yzw;\n vec3 c8 = s6.xyz;\n float x = worldNormal.x, y = worldNormal.y, z = worldNormal.z;\n vec3 result = c0 * 0.886227;\n result += c1 * 2.0 * 0.511664 * y;\n result += c2 * 2.0 * 0.511664 * z;\n result += c3 * 2.0 * 0.511664 * x;\n result += c4 * 2.0 * 0.429043 * x * y;\n result += c5 * 2.0 * 0.429043 * y * z;\n result += c6 * ( 0.743125 * z * z - 0.247708 );\n result += c7 * 2.0 * 0.429043 * x * z;\n result += c8 * 0.429043 * ( x * x - y * y );\n return max( result, vec3( 0.0 ) );\n}\n#endif";
31813
32195
  var logdepthbuf_fragment = "#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif";
@@ -31843,10 +32225,10 @@ var dithering_fragment = "#ifdef DITHERING\n gl_FragColor.rgb = dithering( gl_Fr
31843
32225
  var dithering_pars_fragment = "#ifdef DITHERING\n vec3 dithering( vec3 color ) {\n float grid_position = rand( gl_FragCoord.xy );\n vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n return color + dither_shift_RGB;\n }\n#endif";
31844
32226
  var roughnessmap_fragment = "float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n roughnessFactor *= texelRoughness.g;\n#endif";
31845
32227
  var roughnessmap_pars_fragment = "#ifdef USE_ROUGHNESSMAP\n uniform sampler2D roughnessMap;\n#endif";
31846
- var shadowmap_pars_fragment = "#if NUM_SPOT_LIGHT_COORDS > 0\n varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n #if defined( SHADOWMAP_TYPE_PCF )\n uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n #else\n uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n #endif\n varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n struct DirectionalLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n #if defined( SHADOWMAP_TYPE_PCF )\n uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n #else\n uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n #endif\n struct SpotLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n #if defined( SHADOWMAP_TYPE_PCF )\n uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n #elif defined( SHADOWMAP_TYPE_BASIC )\n uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n #endif\n varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n struct PointLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n float shadowCameraNear;\n float shadowCameraFar;\n };\n uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n #endif\n #if defined( SHADOWMAP_TYPE_PCF )\n float interleavedGradientNoise( vec2 position ) {\n return fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) );\n }\n vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) {\n const float goldenAngle = 2.399963229728653;\n float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) );\n float theta = float( sampleIndex ) * goldenAngle + phi;\n return vec2( cos( theta ), sin( theta ) ) * r;\n }\n #endif\n #if defined( SHADOWMAP_TYPE_PCF )\n float getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n float shadow = 1.0;\n shadowCoord.xyz /= shadowCoord.w;\n shadowCoord.z += shadowBias;\n bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n bool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n if ( frustumTest ) {\n vec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n float radius = shadowRadius * texelSize.x;\n float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2;\n shadow = (\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) +\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) +\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) +\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) +\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) )\n ) * 0.2;\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #elif defined( SHADOWMAP_TYPE_VSM )\n float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n float shadow = 1.0;\n shadowCoord.xyz /= shadowCoord.w;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n shadowCoord.z -= shadowBias;\n #else\n shadowCoord.z += shadowBias;\n #endif\n bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n bool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n if ( frustumTest ) {\n vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg;\n float mean = distribution.x;\n float variance = distribution.y * distribution.y;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n float hard_shadow = step( mean, shadowCoord.z );\n #else\n float hard_shadow = step( shadowCoord.z, mean );\n #endif\n \n if ( hard_shadow == 1.0 ) {\n shadow = 1.0;\n } else {\n variance = max( variance, 0.0000001 );\n float d = shadowCoord.z - mean;\n float p_max = variance / ( variance + d * d );\n p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 );\n shadow = max( hard_shadow, p_max );\n }\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #else\n float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n float shadow = 1.0;\n shadowCoord.xyz /= shadowCoord.w;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n shadowCoord.z -= shadowBias;\n #else\n shadowCoord.z += shadowBias;\n #endif\n bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n bool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n if ( frustumTest ) {\n float depth = texture2D( shadowMap, shadowCoord.xy ).r;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n shadow = step( depth, shadowCoord.z );\n #else\n shadow = step( shadowCoord.z, depth );\n #endif\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n #if defined( SHADOWMAP_TYPE_PCF )\n float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n float shadow = 1.0;\n vec3 lightToPosition = shadowCoord.xyz;\n vec3 bd3D = normalize( lightToPosition );\n vec3 absVec = abs( lightToPosition );\n float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {\n #ifdef USE_REVERSED_DEPTH_BUFFER\n float dp = ( shadowCameraNear * ( shadowCameraFar - viewSpaceZ ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n dp -= shadowBias;\n #else\n float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n dp += shadowBias;\n #endif\n float texelSize = shadowRadius / shadowMapSize.x;\n vec3 absDir = abs( bd3D );\n vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 );\n tangent = normalize( cross( bd3D, tangent ) );\n vec3 bitangent = cross( bd3D, tangent );\n float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2;\n vec2 sample0 = vogelDiskSample( 0, 5, phi );\n vec2 sample1 = vogelDiskSample( 1, 5, phi );\n vec2 sample2 = vogelDiskSample( 2, 5, phi );\n vec2 sample3 = vogelDiskSample( 3, 5, phi );\n vec2 sample4 = vogelDiskSample( 4, 5, phi );\n shadow = (\n texture( shadowMap, vec4( bd3D + ( tangent * sample0.x + bitangent * sample0.y ) * texelSize, dp ) ) +\n texture( shadowMap, vec4( bd3D + ( tangent * sample1.x + bitangent * sample1.y ) * texelSize, dp ) ) +\n texture( shadowMap, vec4( bd3D + ( tangent * sample2.x + bitangent * sample2.y ) * texelSize, dp ) ) +\n texture( shadowMap, vec4( bd3D + ( tangent * sample3.x + bitangent * sample3.y ) * texelSize, dp ) ) +\n texture( shadowMap, vec4( bd3D + ( tangent * sample4.x + bitangent * sample4.y ) * texelSize, dp ) )\n ) * 0.2;\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #elif defined( SHADOWMAP_TYPE_BASIC )\n float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n float shadow = 1.0;\n vec3 lightToPosition = shadowCoord.xyz;\n vec3 absVec = abs( lightToPosition );\n float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {\n float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n dp += shadowBias;\n vec3 bd3D = normalize( lightToPosition );\n float depth = textureCube( shadowMap, bd3D ).r;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n depth = 1.0 - depth;\n #endif\n shadow = step( dp, depth );\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #endif\n #endif\n#endif";
31847
- var shadowmap_pars_vertex = "#if NUM_SPOT_LIGHT_COORDS > 0\n uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n struct DirectionalLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n struct SpotLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n struct PointLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n float shadowCameraNear;\n float shadowCameraFar;\n };\n uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n #endif\n#endif";
31848
- var shadowmap_vertex = "#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n #ifdef HAS_NORMAL\n vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix );\n #else\n vec3 shadowWorldNormal = vec3( 0.0 );\n #endif\n vec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n #if NUM_DIR_LIGHT_SHADOWS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n #endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n shadowWorldPosition = worldPosition;\n #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n #endif\n vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n#endif";
31849
- var shadowmask_pars_fragment = "float getShadowMask() {\n float shadow = 1.0;\n #ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n directionalLight = directionalLightShadows[ i ];\n shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n SpotLightShadow spotLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n spotLight = spotLightShadows[ i ];\n shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\n PointLightShadow pointLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n pointLight = pointLightShadows[ i ];\n shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n }\n #pragma unroll_loop_end\n #endif\n #endif\n return shadow;\n}";
32228
+ var shadowmap_pars_fragment = "#if NUM_SPOT_LIGHT_COORDS > 0\n varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n #if NUM_SUN_LIGHT_SHADOWS > 0\n #define SUN_LIGHT_CASCADES 2\n #if defined( SHADOWMAP_TYPE_PCF )\n uniform sampler2DShadow sunShadowMap[ NUM_SUN_LIGHT_SHADOWS ];\n #else\n uniform sampler2D sunShadowMap[ NUM_SUN_LIGHT_SHADOWS ];\n #endif\n uniform mat4 sunShadowMatrix[ NUM_SUN_LIGHT_SHADOWS * SUN_LIGHT_CASCADES ];\n uniform vec4 sunShadowCascade[ NUM_SUN_LIGHT_SHADOWS * SUN_LIGHT_CASCADES ];\n varying vec4 vSunShadowWorldPosition;\n varying vec3 vSunShadowWorldNormal;\n struct SunLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform SunLightShadow sunLightShadows[ NUM_SUN_LIGHT_SHADOWS ];\n #endif\n #if NUM_DIR_LIGHT_SHADOWS > 0\n #if defined( SHADOWMAP_TYPE_PCF )\n uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n #else\n uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n #endif\n varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n struct DirectionalLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n #if defined( SHADOWMAP_TYPE_PCF )\n uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n #else\n uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n #endif\n struct SpotLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n #if defined( SHADOWMAP_TYPE_PCF )\n uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n #elif defined( SHADOWMAP_TYPE_BASIC )\n uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n #endif\n varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n struct PointLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n float shadowCameraNear;\n float shadowCameraFar;\n };\n uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n #endif\n #if defined( SHADOWMAP_TYPE_PCF )\n float interleavedGradientNoise( vec2 position ) {\n return fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) );\n }\n vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) {\n const float goldenAngle = 2.399963229728653;\n float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) );\n float theta = float( sampleIndex ) * goldenAngle + phi;\n return vec2( cos( theta ), sin( theta ) ) * r;\n }\n #endif\n #if defined( SHADOWMAP_TYPE_PCF )\n float getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n float shadow = 1.0;\n shadowCoord.xyz /= shadowCoord.w;\n shadowCoord.z += shadowBias;\n bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n bool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n if ( frustumTest ) {\n vec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n float radius = shadowRadius * texelSize.x;\n float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2;\n shadow = (\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) +\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) +\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) +\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) +\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) )\n ) * 0.2;\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #elif defined( SHADOWMAP_TYPE_VSM )\n float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n float shadow = 1.0;\n shadowCoord.xyz /= shadowCoord.w;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n shadowCoord.z -= shadowBias;\n #else\n shadowCoord.z += shadowBias;\n #endif\n bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n bool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n if ( frustumTest ) {\n vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg;\n float mean = distribution.x;\n float variance = distribution.y * distribution.y;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n float hard_shadow = step( mean, shadowCoord.z );\n #else\n float hard_shadow = step( shadowCoord.z, mean );\n #endif\n \n if ( hard_shadow == 1.0 ) {\n shadow = 1.0;\n } else {\n variance = max( variance, 0.0000001 );\n float d = shadowCoord.z - mean;\n float p_max = variance / ( variance + d * d );\n p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 );\n shadow = max( hard_shadow, p_max );\n }\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #else\n float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n float shadow = 1.0;\n shadowCoord.xyz /= shadowCoord.w;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n shadowCoord.z -= shadowBias;\n #else\n shadowCoord.z += shadowBias;\n #endif\n bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n bool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n if ( frustumTest ) {\n float depth = texture2D( shadowMap, shadowCoord.xy ).r;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n shadow = step( depth, shadowCoord.z );\n #else\n shadow = step( shadowCoord.z, depth );\n #endif\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #endif\n #if NUM_SUN_LIGHT_SHADOWS > 0\n float getSunShadow(\n #if defined( SHADOWMAP_TYPE_PCF )\n sampler2DShadow shadowMap,\n #else\n sampler2D shadowMap,\n #endif\n SunLightShadow sunLightShadow,\n int shadowIndex\n ) {\n vec4 shadowWorldPosition = vec4( vSunShadowWorldPosition.xyz + vSunShadowWorldNormal * sunLightShadow.shadowNormalBias, 1.0 );\n float viewDepth = vSunShadowWorldPosition.w;\n int cascadeOffset = shadowIndex * SUN_LIGHT_CASCADES;\n float shadow = 1.0;\n for ( int i = SUN_LIGHT_CASCADES - 1; i >= 0; i -- ) {\n vec4 cascade = sunShadowCascade[ cascadeOffset + i ];\n if ( viewDepth >= cascade.x && viewDepth < cascade.y ) {\n float cascadeShadow = getShadow(\n shadowMap,\n sunLightShadow.shadowMapSize,\n sunLightShadow.shadowIntensity,\n sunLightShadow.shadowBias,\n sunLightShadow.shadowRadius,\n sunShadowMatrix[ cascadeOffset + i ] * shadowWorldPosition\n );\n shadow = mix( cascadeShadow, shadow, smoothstep( cascade.z, cascade.y, viewDepth ) );\n }\n }\n return shadow;\n }\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n #if defined( SHADOWMAP_TYPE_PCF )\n float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n float shadow = 1.0;\n vec3 lightToPosition = shadowCoord.xyz;\n vec3 bd3D = normalize( lightToPosition );\n vec3 absVec = abs( lightToPosition );\n float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {\n #ifdef USE_REVERSED_DEPTH_BUFFER\n float dp = ( shadowCameraNear * ( shadowCameraFar - viewSpaceZ ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n dp -= shadowBias;\n #else\n float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n dp += shadowBias;\n #endif\n float texelSize = shadowRadius / shadowMapSize.x;\n vec3 absDir = abs( bd3D );\n vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 );\n tangent = normalize( cross( bd3D, tangent ) );\n vec3 bitangent = cross( bd3D, tangent );\n float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2;\n vec2 sample0 = vogelDiskSample( 0, 5, phi );\n vec2 sample1 = vogelDiskSample( 1, 5, phi );\n vec2 sample2 = vogelDiskSample( 2, 5, phi );\n vec2 sample3 = vogelDiskSample( 3, 5, phi );\n vec2 sample4 = vogelDiskSample( 4, 5, phi );\n shadow = (\n texture( shadowMap, vec4( bd3D + ( tangent * sample0.x + bitangent * sample0.y ) * texelSize, dp ) ) +\n texture( shadowMap, vec4( bd3D + ( tangent * sample1.x + bitangent * sample1.y ) * texelSize, dp ) ) +\n texture( shadowMap, vec4( bd3D + ( tangent * sample2.x + bitangent * sample2.y ) * texelSize, dp ) ) +\n texture( shadowMap, vec4( bd3D + ( tangent * sample3.x + bitangent * sample3.y ) * texelSize, dp ) ) +\n texture( shadowMap, vec4( bd3D + ( tangent * sample4.x + bitangent * sample4.y ) * texelSize, dp ) )\n ) * 0.2;\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #elif defined( SHADOWMAP_TYPE_BASIC )\n float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n float shadow = 1.0;\n vec3 lightToPosition = shadowCoord.xyz;\n vec3 absVec = abs( lightToPosition );\n float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {\n float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n dp += shadowBias;\n vec3 bd3D = normalize( lightToPosition );\n float depth = textureCube( shadowMap, bd3D ).r;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n depth = 1.0 - depth;\n #endif\n shadow = step( dp, depth );\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #endif\n #endif\n#endif";
32229
+ var shadowmap_pars_vertex = "#if NUM_SPOT_LIGHT_COORDS > 0\n uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n #if NUM_SUN_LIGHT_SHADOWS > 0\n varying vec4 vSunShadowWorldPosition;\n varying vec3 vSunShadowWorldNormal;\n #endif\n #if NUM_DIR_LIGHT_SHADOWS > 0\n uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n struct DirectionalLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n struct SpotLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n struct PointLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n float shadowCameraNear;\n float shadowCameraFar;\n };\n uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n #endif\n#endif";
32230
+ var shadowmap_vertex = "#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SUN_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n #ifdef HAS_NORMAL\n vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix );\n #else\n vec3 shadowWorldNormal = vec3( 0.0 );\n #endif\n vec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n #if NUM_SUN_LIGHT_SHADOWS > 0\n vSunShadowWorldPosition = vec4( worldPosition.xyz, - mvPosition.z );\n vSunShadowWorldNormal = shadowWorldNormal;\n #endif\n #if NUM_DIR_LIGHT_SHADOWS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n #endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n shadowWorldPosition = worldPosition;\n #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n #endif\n vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n#endif";
32231
+ var shadowmask_pars_fragment = "float getShadowMask() {\n float shadow = 1.0;\n #ifdef USE_SHADOWMAP\n #if NUM_SUN_LIGHT_SHADOWS > 0\n SunLightShadow sunLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SUN_LIGHT_SHADOWS; i ++ ) {\n sunLight = sunLightShadows[ i ];\n shadow *= receiveShadow ? getSunShadow( sunShadowMap[ i ], sunLight, UNROLLED_LOOP_INDEX ) : 1.0;\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n directionalLight = directionalLightShadows[ i ];\n shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n SpotLightShadow spotLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n spotLight = spotLightShadows[ i ];\n shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\n PointLightShadow pointLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n pointLight = pointLightShadows[ i ];\n shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n }\n #pragma unroll_loop_end\n #endif\n #endif\n return shadow;\n}";
31850
32232
  var skinbase_vertex = "#ifdef USE_SKINNING\n mat4 boneMatX = getBoneMatrix( skinIndex.x );\n mat4 boneMatY = getBoneMatrix( skinIndex.y );\n mat4 boneMatZ = getBoneMatrix( skinIndex.z );\n mat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif";
31851
32233
  var skinning_pars_vertex = "#ifdef USE_SKINNING\n uniform mat4 bindMatrix;\n uniform mat4 bindMatrixInverse;\n uniform highp sampler2D boneTexture;\n mat4 getBoneMatrix( const in float i ) {\n int size = textureSize( boneTexture, 0 ).x;\n int j = int( i ) * 4;\n int x = j % size;\n int y = j / size;\n vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );\n vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );\n vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );\n vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );\n return mat4( v1, v2, v3, v4 );\n }\n#endif";
31852
32234
  var skinning_vertex = "#ifdef USE_SKINNING\n vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n vec4 skinned = vec4( 0.0 );\n skinned += boneMatX * skinVertex * skinWeight.x;\n skinned += boneMatY * skinVertex * skinWeight.y;\n skinned += boneMatZ * skinVertex * skinWeight.z;\n skinned += boneMatW * skinVertex * skinWeight.w;\n transformed = ( bindMatrixInverse * skinned ).xyz;\n#endif";
@@ -31886,7 +32268,7 @@ var fragment$7 = "#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHAD
31886
32268
  var vertex$6 = "#define PHONG\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n #include <color_vertex>\n #include <morphcolor_vertex>\n #include <batching_vertex>\n #include <beginnormal_vertex>\n #include <morphinstance_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n #include <normal_vertex>\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <displacementmap_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n vViewPosition = - mvPosition.xyz;\n #include <worldpos_vertex>\n #include <envmap_vertex>\n #include <shadowmap_vertex>\n #include <fog_vertex>\n}";
31887
32269
  var fragment$6 = "#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <clipping_planes_fragment>\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <color_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n #include <specularmap_fragment>\n #include <normal_fragment_begin>\n #include <normal_fragment_maps>\n #include <emissivemap_fragment>\n #include <lights_phong_fragment>\n #include <lights_fragment_begin>\n #include <lights_fragment_maps>\n #include <lights_fragment_end>\n #include <aomap_fragment>\n vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n #include <envmap_fragment>\n #include <opaque_fragment>\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n #include <dithering_fragment>\n}";
31888
32270
  var vertex$5 = "#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n varying vec3 vWorldPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n #include <color_vertex>\n #include <morphinstance_vertex>\n #include <morphcolor_vertex>\n #include <batching_vertex>\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n #include <normal_vertex>\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <displacementmap_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n vViewPosition = - mvPosition.xyz;\n #include <worldpos_vertex>\n #include <shadowmap_vertex>\n #include <fog_vertex>\n#ifdef USE_TRANSMISSION\n vWorldPosition = worldPosition.xyz;\n#endif\n}";
31889
- var fragment$5 = "#define STANDARD\n#ifdef PHYSICAL\n #define IOR\n #define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n uniform float ior;\n#endif\n#ifdef USE_SPECULAR\n uniform float specularIntensity;\n uniform vec3 specularColor;\n #ifdef USE_SPECULAR_COLORMAP\n uniform sampler2D specularColorMap;\n #endif\n #ifdef USE_SPECULAR_INTENSITYMAP\n uniform sampler2D specularIntensityMap;\n #endif\n#endif\n#ifdef USE_CLEARCOAT\n uniform float clearcoat;\n uniform float clearcoatRoughness;\n#endif\n#ifdef USE_DISPERSION\n uniform float dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n uniform float iridescence;\n uniform float iridescenceIOR;\n uniform float iridescenceThicknessMinimum;\n uniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n uniform vec3 sheenColor;\n uniform float sheenRoughness;\n #ifdef USE_SHEEN_COLORMAP\n uniform sampler2D sheenColorMap;\n #endif\n #ifdef USE_SHEEN_ROUGHNESSMAP\n uniform sampler2D sheenRoughnessMap;\n #endif\n#endif\n#ifdef USE_ANISOTROPY\n uniform vec2 anisotropyVector;\n #ifdef USE_ANISOTROPYMAP\n uniform sampler2D anisotropyMap;\n #endif\n#endif\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <iridescence_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <iridescence_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <clipping_planes_fragment>\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <color_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n #include <roughnessmap_fragment>\n #include <metalnessmap_fragment>\n #include <normal_fragment_begin>\n #include <normal_fragment_maps>\n #include <clearcoat_normal_fragment_begin>\n #include <clearcoat_normal_fragment_maps>\n #include <emissivemap_fragment>\n #include <lights_physical_fragment>\n #include <lights_fragment_begin>\n #include <lights_fragment_maps>\n #include <lights_fragment_end>\n #include <aomap_fragment>\n vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n #include <transmission_fragment>\n vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n #ifdef USE_SHEEN\n \n outgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect;\n \n #endif\n #ifdef USE_CLEARCOAT\n float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;\n #endif\n #include <opaque_fragment>\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n #include <dithering_fragment>\n}";
32271
+ var fragment$5 = "#define STANDARD\n#ifdef PHYSICAL\n #define IOR\n #define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n uniform float ior;\n#endif\n#ifdef USE_SPECULAR\n uniform float specularIntensity;\n uniform vec3 specularColor;\n #ifdef USE_SPECULAR_COLORMAP\n uniform sampler2D specularColorMap;\n #endif\n #ifdef USE_SPECULAR_INTENSITYMAP\n uniform sampler2D specularIntensityMap;\n #endif\n#endif\n#ifdef USE_CLEARCOAT\n uniform float clearcoat;\n uniform float clearcoatRoughness;\n#endif\n#ifdef USE_DISPERSION\n uniform float dispersion;\n#endif\n#ifdef USE_RETROREFLECTION\n uniform float retroreflectivity;\n#endif\n#ifdef USE_IRIDESCENCE\n uniform float iridescence;\n uniform float iridescenceIOR;\n uniform float iridescenceThicknessMinimum;\n uniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n uniform vec3 sheenColor;\n uniform float sheenRoughness;\n #ifdef USE_SHEEN_COLORMAP\n uniform sampler2D sheenColorMap;\n #endif\n #ifdef USE_SHEEN_ROUGHNESSMAP\n uniform sampler2D sheenRoughnessMap;\n #endif\n#endif\n#ifdef USE_ANISOTROPY\n uniform vec2 anisotropyVector;\n #ifdef USE_ANISOTROPYMAP\n uniform sampler2D anisotropyMap;\n #endif\n#endif\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <iridescence_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <iridescence_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <clipping_planes_fragment>\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <color_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n #include <roughnessmap_fragment>\n #include <metalnessmap_fragment>\n #include <normal_fragment_begin>\n #include <normal_fragment_maps>\n #include <clearcoat_normal_fragment_begin>\n #include <clearcoat_normal_fragment_maps>\n #include <emissivemap_fragment>\n #include <lights_physical_fragment>\n #include <lights_fragment_begin>\n #include <lights_fragment_maps>\n #include <lights_fragment_end>\n #include <aomap_fragment>\n vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n #include <transmission_fragment>\n vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n #ifdef USE_SHEEN\n \n outgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect;\n \n #endif\n #ifdef USE_CLEARCOAT\n float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;\n #endif\n #include <opaque_fragment>\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n #include <dithering_fragment>\n}";
31890
32272
  var vertex$4 = "#define TOON\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n #include <color_vertex>\n #include <morphinstance_vertex>\n #include <morphcolor_vertex>\n #include <batching_vertex>\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n #include <normal_vertex>\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <displacementmap_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n vViewPosition = - mvPosition.xyz;\n #include <worldpos_vertex>\n #include <shadowmap_vertex>\n #include <fog_vertex>\n}";
31891
32273
  var fragment$4 = "#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <clipping_planes_fragment>\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <color_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n #include <normal_fragment_begin>\n #include <normal_fragment_maps>\n #include <emissivemap_fragment>\n #include <lights_toon_fragment>\n #include <lights_fragment_begin>\n #include <lights_fragment_maps>\n #include <lights_fragment_end>\n #include <aomap_fragment>\n vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n #include <opaque_fragment>\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n #include <dithering_fragment>\n}";
31892
32274
  var vertex$3 = "uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n#ifdef USE_POINTS_UV\n varying vec2 vUv;\n uniform mat3 uvTransform;\n#endif\nvoid main() {\n #ifdef USE_POINTS_UV\n vUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n #endif\n #include <color_vertex>\n #include <morphinstance_vertex>\n #include <morphcolor_vertex>\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <project_vertex>\n gl_PointSize = size;\n #ifdef USE_SIZEATTENUATION\n bool isPerspective = isPerspectiveMatrix( projectionMatrix );\n if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n #endif\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n #include <worldpos_vertex>\n #include <fog_vertex>\n}";
@@ -32115,6 +32497,19 @@ var UniformsLib = {
32115
32497
  lights: {
32116
32498
  ambientLightColor: { value: [] },
32117
32499
  lightProbe: { value: [] },
32500
+ sunLights: { value: [], properties: {
32501
+ direction: {},
32502
+ color: {}
32503
+ } },
32504
+ sunLightShadows: { value: [], properties: {
32505
+ shadowIntensity: 1,
32506
+ shadowBias: {},
32507
+ shadowNormalBias: {},
32508
+ shadowRadius: {},
32509
+ shadowMapSize: {}
32510
+ } },
32511
+ sunShadowMatrix: { value: [] },
32512
+ sunShadowCascade: { value: [] },
32118
32513
  directionalLights: { value: [], properties: {
32119
32514
  direction: {},
32120
32515
  color: {}
@@ -32442,6 +32837,7 @@ ShaderLib.physical = {
32442
32837
  clearcoatRoughnessMap: { value: null },
32443
32838
  clearcoatRoughnessMapTransform: { value: /* @__PURE__ */ new Matrix3() },
32444
32839
  dispersion: { value: 0 },
32840
+ retroreflectivity: { value: 0 },
32445
32841
  iridescence: { value: 0 },
32446
32842
  iridescenceMap: { value: null },
32447
32843
  iridescenceMapTransform: { value: /* @__PURE__ */ new Matrix3() },
@@ -33060,8 +33456,7 @@ function WebGLCapabilities(gl, extensions, parameters, utils) {
33060
33456
  }
33061
33457
  function textureTypeReadable(textureType) {
33062
33458
  const halfFloatSupportedByExt = textureType === HalfFloatType && (extensions.has("EXT_color_buffer_half_float") || extensions.has("EXT_color_buffer_float"));
33063
- if (textureType !== UnsignedByteType && utils.convert(textureType) !== gl.getParameter(gl.IMPLEMENTATION_COLOR_READ_TYPE) && // Edge and Chrome Mac < 52 (#9513)
33064
- textureType !== FloatType && !halfFloatSupportedByExt) {
33459
+ if (textureType !== UnsignedByteType && textureType !== FloatType && !halfFloatSupportedByExt && utils.convert(textureType) !== gl.getParameter(gl.IMPLEMENTATION_COLOR_READ_TYPE)) {
33065
33460
  return false;
33066
33461
  }
33067
33462
  return true;
@@ -33204,8 +33599,8 @@ function WebGLClipping(properties) {
33204
33599
  }
33205
33600
  }
33206
33601
  var LOD_MIN = 4;
33207
- var EXTRA_LOD_SIGMA = [0.125, 0.215, 0.35, 0.446, 0.526, 0.582];
33208
- var MAX_SAMPLES = 20;
33602
+ var EXTRA_LODS = 6;
33603
+ var BLUR_SAMPLES = 20;
33209
33604
  var GGX_SAMPLES = 256;
33210
33605
  var _flatCamera = /* @__PURE__ */ new OrthographicCamera();
33211
33606
  var _clearColor = /* @__PURE__ */ new Color();
@@ -33214,6 +33609,7 @@ var _oldActiveCubeFace = 0;
33214
33609
  var _oldActiveMipmapLevel = 0;
33215
33610
  var _oldXrEnabled = false;
33216
33611
  var _origin = /* @__PURE__ */ new Vector3();
33612
+ var _direction = /* @__PURE__ */ new Vector3();
33217
33613
  var PMREMGenerator = class {
33218
33614
  /**
33219
33615
  * Constructs a new PMREM generator.
@@ -33226,7 +33622,6 @@ var PMREMGenerator = class {
33226
33622
  this._lodMax = 0;
33227
33623
  this._cubeSize = 0;
33228
33624
  this._sizeLods = [];
33229
- this._sigmas = [];
33230
33625
  this._lodMeshes = [];
33231
33626
  this._backgroundBox = null;
33232
33627
  this._cubemapMaterial = null;
@@ -33385,7 +33780,7 @@ var PMREMGenerator = class {
33385
33780
  }
33386
33781
  this._pingPongRenderTarget = _createRenderTarget(width, height, params);
33387
33782
  const { _lodMax } = this;
33388
- ({ lodMeshes: this._lodMeshes, sizeLods: this._sizeLods, sigmas: this._sigmas } = _createPlanes(_lodMax));
33783
+ ({ lodMeshes: this._lodMeshes, sizeLods: this._sizeLods } = _createPlanes(_lodMax));
33389
33784
  this._blurMaterial = _getBlurShader(_lodMax, width, height);
33390
33785
  this._ggxMaterial = _getGGXShader(_lodMax, width, height);
33391
33786
  }
@@ -33519,7 +33914,7 @@ var PMREMGenerator = class {
33519
33914
  const targetRoughness = lodOut / (this._lodMeshes.length - 1);
33520
33915
  const sourceRoughness = lodIn / (this._lodMeshes.length - 1);
33521
33916
  const incrementalRoughness = Math.sqrt(targetRoughness * targetRoughness - sourceRoughness * sourceRoughness);
33522
- const blurStrength = 0 + targetRoughness * 1.25;
33917
+ const blurStrength = targetRoughness * 1.25;
33523
33918
  const adjustedRoughness = incrementalRoughness * blurStrength;
33524
33919
  const { _lodMax } = this;
33525
33920
  const outputSize = this._sizeLods[lodOut];
@@ -33539,11 +33934,9 @@ var PMREMGenerator = class {
33539
33934
  renderer.render(ggxMesh, _flatCamera);
33540
33935
  }
33541
33936
  /**
33542
- * This is a two-pass Gaussian blur for a cubemap. Normally this is done
33543
- * vertically and horizontally, but this breaks down on a cube. Here we apply
33544
- * the blur latitudinally (around the poles), and then longitudinally (towards
33545
- * the poles) to approximate the orthogonally-separable blur. It is least
33546
- * accurate at the poles, but still does a decent job.
33937
+ * This is a two-pass Gaussian blur for a cubemap. Each pass importance-samples
33938
+ * the Gaussian along a spiral kernel (Golden Angle), which distributes samples
33939
+ * isotropically on the sphere (no pole artifacts).
33547
33940
  *
33548
33941
  * Used for initial scene blur in fromScene() method when sigma > 0.
33549
33942
  *
@@ -33552,75 +33945,24 @@ var PMREMGenerator = class {
33552
33945
  * @param {number} lodIn
33553
33946
  * @param {number} lodOut
33554
33947
  * @param {number} sigma
33555
- * @param {Vector3} [poleAxis]
33556
33948
  */
33557
- _blur(cubeUVRenderTarget, lodIn, lodOut, sigma, poleAxis) {
33949
+ _blur(cubeUVRenderTarget, lodIn, lodOut, sigma) {
33558
33950
  const pingPongRenderTarget = this._pingPongRenderTarget;
33559
- this._halfBlur(
33560
- cubeUVRenderTarget,
33561
- pingPongRenderTarget,
33562
- lodIn,
33563
- lodOut,
33564
- sigma,
33565
- "latitudinal",
33566
- poleAxis
33567
- );
33568
- this._halfBlur(
33569
- pingPongRenderTarget,
33570
- cubeUVRenderTarget,
33571
- lodOut,
33572
- lodOut,
33573
- sigma,
33574
- "longitudinal",
33575
- poleAxis
33576
- );
33951
+ const blurSigma = Math.min(sigma, Math.PI) / Math.SQRT2;
33952
+ this._blurPass(cubeUVRenderTarget, pingPongRenderTarget, lodIn, lodOut, blurSigma);
33953
+ this._blurPass(pingPongRenderTarget, cubeUVRenderTarget, lodOut, lodOut, blurSigma);
33577
33954
  }
33578
- _halfBlur(targetIn, targetOut, lodIn, lodOut, sigmaRadians, direction, poleAxis) {
33955
+ _blurPass(targetIn, targetOut, lodIn, lodOut, sigmaRadians) {
33579
33956
  const renderer = this._renderer;
33580
33957
  const blurMaterial = this._blurMaterial;
33581
- if (direction !== "latitudinal" && direction !== "longitudinal") {
33582
- error(
33583
- "blur direction must be either latitudinal or longitudinal!"
33584
- );
33585
- }
33586
- const STANDARD_DEVIATIONS = 3;
33587
33958
  const blurMesh = this._lodMeshes[lodOut];
33588
33959
  blurMesh.material = blurMaterial;
33589
33960
  const blurUniforms = blurMaterial.uniforms;
33590
- const pixels = this._sizeLods[lodIn] - 1;
33591
- const radiansPerPixel = isFinite(sigmaRadians) ? Math.PI / (2 * pixels) : 2 * Math.PI / (2 * MAX_SAMPLES - 1);
33592
- const sigmaPixels = sigmaRadians / radiansPerPixel;
33593
- const samples = isFinite(sigmaRadians) ? 1 + Math.floor(STANDARD_DEVIATIONS * sigmaPixels) : MAX_SAMPLES;
33594
- if (samples > MAX_SAMPLES) {
33595
- warn(`sigmaRadians, ${sigmaRadians}, is too large and will clip, as it requested ${samples} samples when the maximum is set to ${MAX_SAMPLES}`);
33596
- }
33597
- const weights = [];
33598
- let sum = 0;
33599
- for (let i = 0; i < MAX_SAMPLES; ++i) {
33600
- const x2 = i / sigmaPixels;
33601
- const weight = Math.exp(-x2 * x2 / 2);
33602
- weights.push(weight);
33603
- if (i === 0) {
33604
- sum += weight;
33605
- } else if (i < samples) {
33606
- sum += 2 * weight;
33607
- }
33608
- }
33609
- for (let i = 0; i < weights.length; i++) {
33610
- weights[i] = weights[i] / sum;
33611
- }
33612
33961
  blurUniforms["envMap"].value = targetIn.texture;
33613
- blurUniforms["samples"].value = samples;
33614
- blurUniforms["weights"].value = weights;
33615
- blurUniforms["latitudinal"].value = direction === "latitudinal";
33616
- if (poleAxis) {
33617
- blurUniforms["poleAxis"].value = poleAxis;
33618
- }
33619
- const { _lodMax } = this;
33620
- blurUniforms["dTheta"].value = radiansPerPixel;
33621
- blurUniforms["mipInt"].value = _lodMax - lodIn;
33962
+ blurUniforms["sigma"].value = sigmaRadians;
33963
+ blurUniforms["mipInt"].value = this._lodMax - lodIn;
33622
33964
  const outputSize = this._sizeLods[lodOut];
33623
- const x = 3 * outputSize * (lodOut > _lodMax - LOD_MIN ? lodOut - _lodMax + LOD_MIN : 0);
33965
+ const x = 3 * outputSize * (lodOut > this._lodMax - LOD_MIN ? lodOut - this._lodMax + LOD_MIN : 0);
33624
33966
  const y = 4 * (this._cubeSize - outputSize);
33625
33967
  _setViewport(targetOut, x, y, 3 * outputSize, 2 * outputSize);
33626
33968
  renderer.setRenderTarget(targetOut);
@@ -33629,20 +33971,12 @@ var PMREMGenerator = class {
33629
33971
  };
33630
33972
  function _createPlanes(lodMax) {
33631
33973
  const sizeLods = [];
33632
- const sigmas = [];
33633
33974
  const lodMeshes = [];
33634
33975
  let lod = lodMax;
33635
- const totalLods = lodMax - LOD_MIN + 1 + EXTRA_LOD_SIGMA.length;
33976
+ const totalLods = lodMax - LOD_MIN + 1 + EXTRA_LODS;
33636
33977
  for (let i = 0; i < totalLods; i++) {
33637
33978
  const sizeLod = Math.pow(2, lod);
33638
33979
  sizeLods.push(sizeLod);
33639
- let sigma = 1 / sizeLod;
33640
- if (i > lodMax - LOD_MIN) {
33641
- sigma = EXTRA_LOD_SIGMA[i - lodMax + LOD_MIN - 1];
33642
- } else if (i === 0) {
33643
- sigma = 0;
33644
- }
33645
- sigmas.push(sigma);
33646
33980
  const texelSize = 1 / (sizeLod - 2);
33647
33981
  const min = -texelSize;
33648
33982
  const max = 1 + texelSize;
@@ -33650,11 +33984,8 @@ function _createPlanes(lodMax) {
33650
33984
  const cubeFaces = 6;
33651
33985
  const vertices = 6;
33652
33986
  const positionSize = 3;
33653
- const uvSize = 2;
33654
- const faceIndexSize = 1;
33655
33987
  const position = new Float32Array(positionSize * vertices * cubeFaces);
33656
- const uv = new Float32Array(uvSize * vertices * cubeFaces);
33657
- const faceIndex = new Float32Array(faceIndexSize * vertices * cubeFaces);
33988
+ const outputDirection = new Float32Array(positionSize * vertices * cubeFaces);
33658
33989
  for (let face = 0; face < cubeFaces; face++) {
33659
33990
  const x = face % 3 * 2 / 3 - 1;
33660
33991
  const y = face > 2 ? 0 : -1;
@@ -33679,20 +34010,34 @@ function _createPlanes(lodMax) {
33679
34010
  0
33680
34011
  ];
33681
34012
  position.set(coordinates, positionSize * vertices * face);
33682
- uv.set(uv1, uvSize * vertices * face);
33683
- const fill2 = [face, face, face, face, face, face];
33684
- faceIndex.set(fill2, faceIndexSize * vertices * face);
34013
+ for (let vertex2 = 0; vertex2 < vertices; vertex2++) {
34014
+ const u = uv1[vertex2 * 2] * 2 - 1;
34015
+ const v = uv1[vertex2 * 2 + 1] * 2 - 1;
34016
+ if (face === 0) {
34017
+ _direction.set(1, v, u);
34018
+ } else if (face === 1) {
34019
+ _direction.set(-u, 1, -v);
34020
+ } else if (face === 2) {
34021
+ _direction.set(-u, v, 1);
34022
+ } else if (face === 3) {
34023
+ _direction.set(-1, v, -u);
34024
+ } else if (face === 4) {
34025
+ _direction.set(-u, -1, v);
34026
+ } else {
34027
+ _direction.set(u, v, -1);
34028
+ }
34029
+ _direction.toArray(outputDirection, (face * vertices + vertex2) * positionSize);
34030
+ }
33685
34031
  }
33686
34032
  const planes = new BufferGeometry();
33687
34033
  planes.setAttribute("position", new BufferAttribute(position, positionSize));
33688
- planes.setAttribute("uv", new BufferAttribute(uv, uvSize));
33689
- planes.setAttribute("faceIndex", new BufferAttribute(faceIndex, faceIndexSize));
34034
+ planes.setAttribute("outputDirection", new BufferAttribute(outputDirection, positionSize));
33690
34035
  lodMeshes.push(new Mesh(planes, null));
33691
34036
  if (lod > LOD_MIN) {
33692
34037
  lod--;
33693
34038
  }
33694
34039
  }
33695
- return { lodMeshes, sizeLods, sigmas };
34040
+ return { lodMeshes, sizeLods };
33696
34041
  }
33697
34042
  function _createRenderTarget(width, height, params) {
33698
34043
  const cubeUVRenderTarget = new WebGLRenderTarget(width, height, params);
@@ -33835,87 +34180,81 @@ function _getGGXShader(lodMax, width, height) {
33835
34180
  return shaderMaterial;
33836
34181
  }
33837
34182
  function _getBlurShader(lodMax, width, height) {
33838
- const weights = new Float32Array(MAX_SAMPLES);
33839
- const poleAxis = new Vector3(0, 1, 0);
33840
34183
  const shaderMaterial = new ShaderMaterial({
33841
34184
  name: "SphericalGaussianBlur",
33842
34185
  defines: {
33843
- "n": MAX_SAMPLES,
34186
+ "SAMPLES": BLUR_SAMPLES,
33844
34187
  "CUBEUV_TEXEL_WIDTH": 1 / width,
33845
34188
  "CUBEUV_TEXEL_HEIGHT": 1 / height,
33846
34189
  "CUBEUV_MAX_MIP": `${lodMax}.0`
33847
34190
  },
33848
34191
  uniforms: {
33849
34192
  "envMap": { value: null },
33850
- "samples": { value: 1 },
33851
- "weights": { value: weights },
33852
- "latitudinal": { value: false },
33853
- "dTheta": { value: 0 },
33854
- "mipInt": { value: 0 },
33855
- "poleAxis": { value: poleAxis }
34193
+ "sigma": { value: 0 },
34194
+ "mipInt": { value: 0 }
33856
34195
  },
33857
34196
  vertexShader: _getCommonVertexShader(),
33858
34197
  fragmentShader: (
33859
34198
  /* glsl */
33860
34199
  `
33861
34200
 
33862
- precision mediump float;
33863
- precision mediump int;
34201
+ precision highp float;
34202
+ precision highp int;
33864
34203
 
33865
34204
  varying vec3 vOutputDirection;
33866
34205
 
33867
34206
  uniform sampler2D envMap;
33868
- uniform int samples;
33869
- uniform float weights[ n ];
33870
- uniform bool latitudinal;
33871
- uniform float dTheta;
34207
+ uniform float sigma;
33872
34208
  uniform float mipInt;
33873
- uniform vec3 poleAxis;
33874
34209
 
33875
34210
  #define ENVMAP_TYPE_CUBE_UV
33876
34211
  #include <cube_uv_reflection_fragment>
33877
34212
 
33878
- vec3 getSample( float theta, vec3 axis ) {
33879
-
33880
- float cosTheta = cos( theta );
33881
- // Rodrigues' axis-angle rotation
33882
- vec3 sampleDirection = vOutputDirection * cosTheta
33883
- + cross( axis, vOutputDirection ) * sin( theta )
33884
- + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
33885
-
33886
- return bilinearCubeUV( envMap, sampleDirection, mipInt );
33887
-
33888
- }
34213
+ #define PI 3.14159265359
34214
+ #define GOLDEN_ANGLE 2.39996322973
33889
34215
 
33890
34216
  void main() {
33891
34217
 
33892
- vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
33893
-
33894
- if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
34218
+ if ( sigma == 0.0 ) {
33895
34219
 
33896
- axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
34220
+ gl_FragColor = vec4( bilinearCubeUV( envMap, vOutputDirection, mipInt ), 1.0 );
34221
+ return;
33897
34222
 
33898
34223
  }
33899
34224
 
33900
- axis = normalize( axis );
34225
+ vec3 outputDirection = normalize( vOutputDirection );
34226
+
34227
+ vec3 up = abs( outputDirection.z ) < 0.999 ? vec3( 0.0, 0.0, 1.0 ) : vec3( 1.0, 0.0, 0.0 );
34228
+ vec3 tangent = normalize( cross( up, outputDirection ) );
34229
+ vec3 bitangent = cross( outputDirection, tangent );
33901
34230
 
33902
- gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
33903
- gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
34231
+ // Truncate the kernel at three standard deviations or at the antipode.
34232
+ float thetaMax = min( 3.0 * sigma, PI );
34233
+ float truncation = 1.0 - exp( - 0.5 * thetaMax * thetaMax / ( sigma * sigma ) );
33904
34234
 
33905
- for ( int i = 1; i < n; i++ ) {
34235
+ vec3 accumColor = vec3( 0.0 );
34236
+ float accumWeight = 0.0;
33906
34237
 
33907
- if ( i >= samples ) {
34238
+ for ( int i = 0; i < SAMPLES; i ++ ) {
33908
34239
 
33909
- break;
34240
+ // Stratified inverse-CDF sampling of the Gaussian, placed on a golden-angle spiral.
34241
+ float stratum = ( float( i ) + 0.5 ) / float( SAMPLES );
34242
+ float theta = sigma * sqrt( - 2.0 * log( 1.0 - stratum * truncation ) );
34243
+ float phi = float( i ) * GOLDEN_ANGLE;
33910
34244
 
33911
- }
34245
+ vec3 offset = cos( phi ) * tangent + sin( phi ) * bitangent;
34246
+ vec3 sampleDirection = cos( theta ) * outputDirection + sin( theta ) * offset;
33912
34247
 
33913
- float theta = dTheta * float( i );
33914
- gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
33915
- gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
34248
+ // Correct the planar sample density to solid angle.
34249
+ float weight = sin( theta ) / theta;
34250
+
34251
+ accumColor += weight * bilinearCubeUV( envMap, sampleDirection, mipInt );
34252
+ accumWeight += weight;
33916
34253
 
33917
34254
  }
33918
34255
 
34256
+ gl_FragColor = vec4( accumColor / accumWeight, 1.0 );
34257
+
33919
34258
  }
33920
34259
  `
33921
34260
  ),
@@ -34001,53 +34340,13 @@ function _getCommonVertexShader() {
34001
34340
  precision mediump float;
34002
34341
  precision mediump int;
34003
34342
 
34004
- attribute float faceIndex;
34343
+ attribute vec3 outputDirection;
34005
34344
 
34006
34345
  varying vec3 vOutputDirection;
34007
34346
 
34008
- // RH coordinate system; PMREM face-indexing convention
34009
- vec3 getDirection( vec2 uv, float face ) {
34010
-
34011
- uv = 2.0 * uv - 1.0;
34012
-
34013
- vec3 direction = vec3( uv, 1.0 );
34014
-
34015
- if ( face == 0.0 ) {
34016
-
34017
- direction = direction.zyx; // ( 1, v, u ) pos x
34018
-
34019
- } else if ( face == 1.0 ) {
34020
-
34021
- direction = direction.xzy;
34022
- direction.xz *= -1.0; // ( -u, 1, -v ) pos y
34023
-
34024
- } else if ( face == 2.0 ) {
34025
-
34026
- direction.x *= -1.0; // ( -u, v, 1 ) pos z
34027
-
34028
- } else if ( face == 3.0 ) {
34029
-
34030
- direction = direction.zyx;
34031
- direction.xz *= -1.0; // ( -1, v, -u ) neg x
34032
-
34033
- } else if ( face == 4.0 ) {
34034
-
34035
- direction = direction.xzy;
34036
- direction.xy *= -1.0; // ( -u, -1, v ) neg y
34037
-
34038
- } else if ( face == 5.0 ) {
34039
-
34040
- direction.z *= -1.0; // ( u, v, -1 ) neg z
34041
-
34042
- }
34043
-
34044
- return direction;
34045
-
34046
- }
34047
-
34048
34347
  void main() {
34049
34348
 
34050
- vOutputDirection = getDirection( uv, faceIndex );
34349
+ vOutputDirection = outputDirection;
34051
34350
  gl_Position = vec4( position, 1.0 );
34052
34351
 
34053
34352
  }
@@ -34638,18 +34937,18 @@ var toneMappingMap = {
34638
34937
  [CustomToneMapping]: "CUSTOM_TONE_MAPPING"
34639
34938
  };
34640
34939
  function WebGLOutput(type, width, height, antialias, depth, stencil) {
34641
- const targetA = new WebGLRenderTarget(width, height, {
34940
+ const targetScene = new WebGLRenderTarget(width, height, {
34642
34941
  type,
34643
34942
  depthBuffer: depth,
34644
34943
  stencilBuffer: stencil,
34645
34944
  samples: antialias ? 4 : 0,
34646
- depthTexture: depth ? new DepthTexture(width, height) : void 0
34647
- });
34648
- const targetB = new WebGLRenderTarget(width, height, {
34649
- type: HalfFloatType,
34650
- depthBuffer: false,
34651
- stencilBuffer: false
34945
+ storeMultisampledDepthBuffer: false,
34946
+ storeMultisampledStencilBuffer: false,
34947
+ resolveDepthBuffer: false,
34948
+ resolveStencilBuffer: false
34652
34949
  });
34950
+ let targetA = null;
34951
+ let targetB = null;
34653
34952
  const geometry = new BufferGeometry();
34654
34953
  geometry.setAttribute("position", new Float32BufferAttribute([-1, 3, 0, -1, -1, 0, 3, -1, 0], 3));
34655
34954
  geometry.setAttribute("uv", new Float32BufferAttribute([0, 2, 0, 0, 2, 0], 2));
@@ -34724,8 +35023,9 @@ function WebGLOutput(type, width, height, antialias, depth, stencil) {
34724
35023
  let _effects = [];
34725
35024
  let _hasRenderPass = false;
34726
35025
  this.setSize = function(width2, height2) {
34727
- targetA.setSize(width2, height2);
34728
- targetB.setSize(width2, height2);
35026
+ targetScene.setSize(width2, height2);
35027
+ if (targetA !== null) targetA.setSize(width2, height2);
35028
+ if (targetB !== null) targetB.setSize(width2, height2);
34729
35029
  for (let i = 0; i < _effects.length; i++) {
34730
35030
  const effect = _effects[i];
34731
35031
  if (effect.setSize) effect.setSize(width2, height2);
@@ -34734,8 +35034,12 @@ function WebGLOutput(type, width, height, antialias, depth, stencil) {
34734
35034
  this.setEffects = function(effects) {
34735
35035
  _effects = effects;
34736
35036
  _hasRenderPass = _effects.length > 0 && _effects[0].isRenderPass === true;
34737
- const width2 = targetA.width;
34738
- const height2 = targetA.height;
35037
+ const width2 = targetScene.width;
35038
+ const height2 = targetScene.height;
35039
+ if (_effects.length > 0 && targetA === null) {
35040
+ targetA = new WebGLRenderTarget(width2, height2, { type: HalfFloatType, depthBuffer: false, stencilBuffer: false });
35041
+ targetB = new WebGLRenderTarget(width2, height2, { type: HalfFloatType, depthBuffer: false, stencilBuffer: false });
35042
+ }
34739
35043
  for (let i = 0; i < _effects.length; i++) {
34740
35044
  const effect = _effects[i];
34741
35045
  if (effect.setSize) effect.setSize(width2, height2);
@@ -34748,12 +35052,12 @@ function WebGLOutput(type, width, height, antialias, depth, stencil) {
34748
35052
  if (renderTarget !== null) {
34749
35053
  const width2 = renderTarget.width;
34750
35054
  const height2 = renderTarget.height;
34751
- if (targetA.width !== width2 || targetA.height !== height2) {
35055
+ if (targetScene.width !== width2 || targetScene.height !== height2) {
34752
35056
  this.setSize(width2, height2);
34753
35057
  }
34754
35058
  }
34755
35059
  if (_hasRenderPass === false) {
34756
- renderer.setRenderTarget(targetA);
35060
+ renderer.setRenderTarget(targetScene);
34757
35061
  }
34758
35062
  _savedToneMapping = renderer.toneMapping;
34759
35063
  renderer.toneMapping = NoToneMapping;
@@ -34765,16 +35069,15 @@ function WebGLOutput(type, width, height, antialias, depth, stencil) {
34765
35069
  this.end = function(renderer, deltaTime) {
34766
35070
  renderer.toneMapping = _savedToneMapping;
34767
35071
  _isCompositing = true;
34768
- let readBuffer = targetA;
34769
- let writeBuffer = targetB;
35072
+ let readBuffer = targetScene;
35073
+ let writeBuffer = targetA;
34770
35074
  for (let i = 0; i < _effects.length; i++) {
34771
35075
  const effect = _effects[i];
34772
35076
  if (effect.enabled === false) continue;
34773
35077
  effect.render(renderer, writeBuffer, readBuffer, deltaTime);
34774
35078
  if (effect.needsSwap !== false) {
34775
- const temp = readBuffer;
34776
35079
  readBuffer = writeBuffer;
34777
- writeBuffer = temp;
35080
+ writeBuffer = writeBuffer === targetA ? targetB : targetA;
34778
35081
  }
34779
35082
  }
34780
35083
  if (_outputColorSpace !== renderer.outputColorSpace || _outputToneMapping !== renderer.toneMapping) {
@@ -34796,9 +35099,9 @@ function WebGLOutput(type, width, height, antialias, depth, stencil) {
34796
35099
  return _isCompositing;
34797
35100
  };
34798
35101
  this.dispose = function() {
34799
- if (targetA.depthTexture) targetA.depthTexture.dispose();
34800
- targetA.dispose();
34801
- targetB.dispose();
35102
+ targetScene.dispose();
35103
+ if (targetA !== null) targetA.dispose();
35104
+ if (targetB !== null) targetB.dispose();
34802
35105
  geometry.dispose();
34803
35106
  material.dispose();
34804
35107
  };
@@ -35604,7 +35907,7 @@ function filterEmptyLine(string) {
35604
35907
  }
35605
35908
  function replaceLightNums(string, parameters) {
35606
35909
  const numSpotLightCoords = parameters.numSpotLightShadows + parameters.numSpotLightMaps - parameters.numSpotLightShadowsWithMaps;
35607
- return string.replace(/NUM_DIR_LIGHTS/g, parameters.numDirLights).replace(/NUM_SPOT_LIGHTS/g, parameters.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g, parameters.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g, numSpotLightCoords).replace(/NUM_RECT_AREA_LIGHTS/g, parameters.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g, parameters.numPointLights).replace(/NUM_HEMI_LIGHTS/g, parameters.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g, parameters.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g, parameters.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g, parameters.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g, parameters.numPointLightShadows);
35910
+ return string.replace(/NUM_SUN_LIGHTS/g, parameters.numSunLights).replace(/NUM_DIR_LIGHTS/g, parameters.numDirLights).replace(/NUM_SPOT_LIGHTS/g, parameters.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g, parameters.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g, numSpotLightCoords).replace(/NUM_RECT_AREA_LIGHTS/g, parameters.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g, parameters.numPointLights).replace(/NUM_HEMI_LIGHTS/g, parameters.numHemiLights).replace(/NUM_SUN_LIGHT_SHADOWS/g, parameters.numSunLightShadows).replace(/NUM_DIR_LIGHT_SHADOWS/g, parameters.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g, parameters.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g, parameters.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g, parameters.numPointLightShadows);
35608
35911
  }
35609
35912
  function replaceClippingPlaneNums(string, parameters) {
35610
35913
  return string.replace(/NUM_CLIPPING_PLANES/g, parameters.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g, parameters.numClippingPlanes - parameters.numClipIntersection);
@@ -35904,6 +36207,7 @@ function WebGLProgram(renderer, cacheKey, parameters, bindingStates) {
35904
36207
  parameters.clearcoatRoughnessMap ? "#define USE_CLEARCOAT_ROUGHNESSMAP" : "",
35905
36208
  parameters.clearcoatNormalMap ? "#define USE_CLEARCOAT_NORMALMAP" : "",
35906
36209
  parameters.dispersion ? "#define USE_DISPERSION" : "",
36210
+ parameters.retroreflection ? "#define USE_RETROREFLECTION" : "",
35907
36211
  parameters.iridescence ? "#define USE_IRIDESCENCE" : "",
35908
36212
  parameters.iridescenceMap ? "#define USE_IRIDESCENCEMAP" : "",
35909
36213
  parameters.iridescenceThicknessMap ? "#define USE_IRIDESCENCE_THICKNESSMAP" : "",
@@ -36233,6 +36537,7 @@ function WebGLPrograms(renderer, environments, extensions, capabilities, binding
36233
36537
  const HAS_ANISOTROPY = material.anisotropy > 0;
36234
36538
  const HAS_CLEARCOAT = material.clearcoat > 0;
36235
36539
  const HAS_DISPERSION = material.dispersion > 0;
36540
+ const HAS_RETROREFLECTION = material.retroreflectivity > 0;
36236
36541
  const HAS_IRIDESCENCE = material.iridescence > 0;
36237
36542
  const HAS_SHEEN = material.sheen > 0;
36238
36543
  const HAS_TRANSMISSION = material.transmission > 0;
@@ -36302,6 +36607,7 @@ function WebGLPrograms(renderer, environments, extensions, capabilities, binding
36302
36607
  clearcoatNormalMap: HAS_CLEARCOAT_NORMALMAP,
36303
36608
  clearcoatRoughnessMap: HAS_CLEARCOAT_ROUGHNESSMAP,
36304
36609
  dispersion: HAS_DISPERSION,
36610
+ retroreflection: HAS_RETROREFLECTION,
36305
36611
  iridescence: HAS_IRIDESCENCE,
36306
36612
  iridescenceMap: HAS_IRIDESCENCEMAP,
36307
36613
  iridescenceThicknessMap: HAS_IRIDESCENCE_THICKNESSMAP,
@@ -36364,12 +36670,14 @@ function WebGLPrograms(renderer, environments, extensions, capabilities, binding
36364
36670
  morphColors: geometry.morphAttributes.color !== void 0,
36365
36671
  morphTargetsCount,
36366
36672
  morphTextureStride,
36673
+ numSunLights: lights.sun.length,
36367
36674
  numDirLights: lights.directional.length,
36368
36675
  numPointLights: lights.point.length,
36369
36676
  numSpotLights: lights.spot.length,
36370
36677
  numSpotLightMaps: lights.spotLightMap.length,
36371
36678
  numRectAreaLights: lights.rectArea.length,
36372
36679
  numHemiLights: lights.hemi.length,
36680
+ numSunLightShadows: lights.sunShadowMap.length,
36373
36681
  numDirLightShadows: lights.directionalShadowMap.length,
36374
36682
  numPointLightShadows: lights.pointShadowMap.length,
36375
36683
  numSpotLightShadows: lights.spotShadowMap.length,
@@ -36456,12 +36764,14 @@ function WebGLPrograms(renderer, environments, extensions, capabilities, binding
36456
36764
  array.push(parameters.sizeAttenuation);
36457
36765
  array.push(parameters.morphTargetsCount);
36458
36766
  array.push(parameters.morphAttributeCount);
36767
+ array.push(parameters.numSunLights);
36459
36768
  array.push(parameters.numDirLights);
36460
36769
  array.push(parameters.numPointLights);
36461
36770
  array.push(parameters.numSpotLights);
36462
36771
  array.push(parameters.numSpotLightMaps);
36463
36772
  array.push(parameters.numHemiLights);
36464
36773
  array.push(parameters.numRectAreaLights);
36774
+ array.push(parameters.numSunLightShadows);
36465
36775
  array.push(parameters.numDirLightShadows);
36466
36776
  array.push(parameters.numPointLightShadows);
36467
36777
  array.push(parameters.numSpotLightShadows);
@@ -36515,6 +36825,8 @@ function WebGLPrograms(renderer, environments, extensions, capabilities, binding
36515
36825
  _programLayers.enable(18);
36516
36826
  if (parameters.dispersion)
36517
36827
  _programLayers.enable(19);
36828
+ if (parameters.retroreflection)
36829
+ _programLayers.enable(24);
36518
36830
  if (parameters.batchingColor)
36519
36831
  _programLayers.enable(20);
36520
36832
  if (parameters.gradientMap)
@@ -36727,7 +37039,8 @@ function WebGLRenderList() {
36727
37039
  renderItemsIndex++;
36728
37040
  return renderItem;
36729
37041
  }
36730
- function push(object, geometry, material, groupOrder, z, group) {
37042
+ function push(object, geometry, material, groupOrder, z, group, camera) {
37043
+ if (camera.reversedDepth === true) z = -z;
36731
37044
  const renderItem = getNextRenderItem(object, geometry, material, groupOrder, z, group);
36732
37045
  if (material.transmission > 0) {
36733
37046
  transmissive.push(renderItem);
@@ -36747,15 +37060,10 @@ function WebGLRenderList() {
36747
37060
  opaque.unshift(renderItem);
36748
37061
  }
36749
37062
  }
36750
- function sort(customOpaqueSort, customTransparentSort, reversedDepth) {
37063
+ function sort(customOpaqueSort, customTransparentSort) {
36751
37064
  if (opaque.length > 1) opaque.sort(customOpaqueSort || painterSortStable);
36752
37065
  if (transmissive.length > 1) transmissive.sort(customTransparentSort || reversePainterSortStable);
36753
37066
  if (transparent.length > 1) transparent.sort(customTransparentSort || reversePainterSortStable);
36754
- if (reversedDepth) {
36755
- opaque.reverse();
36756
- transmissive.reverse();
36757
- transparent.reverse();
36758
- }
36759
37067
  }
36760
37068
  function finish() {
36761
37069
  for (let i = renderItemsIndex, il = renderItems.length; i < il; i++) {
@@ -36814,6 +37122,7 @@ function UniformsCache() {
36814
37122
  }
36815
37123
  let uniforms;
36816
37124
  switch (light.type) {
37125
+ case "SunLight":
36817
37126
  case "DirectionalLight":
36818
37127
  uniforms = {
36819
37128
  direction: new Vector3(),
@@ -36869,6 +37178,7 @@ function ShadowUniformsCache() {
36869
37178
  }
36870
37179
  let uniforms;
36871
37180
  switch (light.type) {
37181
+ case "SunLight":
36872
37182
  case "DirectionalLight":
36873
37183
  uniforms = {
36874
37184
  shadowIntensity: 1,
@@ -36914,11 +37224,13 @@ function WebGLLights(extensions) {
36914
37224
  const state = {
36915
37225
  version: 0,
36916
37226
  hash: {
37227
+ sunLength: -1,
36917
37228
  directionalLength: -1,
36918
37229
  pointLength: -1,
36919
37230
  spotLength: -1,
36920
37231
  rectAreaLength: -1,
36921
37232
  hemiLength: -1,
37233
+ numSunShadows: -1,
36922
37234
  numDirectionalShadows: -1,
36923
37235
  numPointShadows: -1,
36924
37236
  numSpotShadows: -1,
@@ -36927,6 +37239,11 @@ function WebGLLights(extensions) {
36927
37239
  },
36928
37240
  ambient: [0, 0, 0],
36929
37241
  probe: [],
37242
+ sun: [],
37243
+ sunShadow: [],
37244
+ sunShadowMap: [],
37245
+ sunShadowMatrix: [],
37246
+ sunShadowCascade: [],
36930
37247
  directional: [],
36931
37248
  directionalShadow: [],
36932
37249
  directionalShadowMap: [],
@@ -36954,6 +37271,9 @@ function WebGLLights(extensions) {
36954
37271
  function setup(lights) {
36955
37272
  let r = 0, g = 0, b = 0;
36956
37273
  for (let i = 0; i < 9; i++) state.probe[i].set(0, 0, 0);
37274
+ let sunLength = 0;
37275
+ let numSunShadows = 0;
37276
+ let numSunShadowCascades = 0;
36957
37277
  let directionalLength = 0;
36958
37278
  let pointLength = 0;
36959
37279
  let spotLength = 0;
@@ -36988,6 +37308,29 @@ function WebGLLights(extensions) {
36988
37308
  state.probe[j].addScaledVector(light.sh.coefficients[j], intensity);
36989
37309
  }
36990
37310
  numLightProbes++;
37311
+ } else if (light.isSunLight) {
37312
+ const uniforms = cache.get(light);
37313
+ uniforms.color.copy(light.color).multiplyScalar(light.intensity);
37314
+ if (light.castShadow) {
37315
+ const shadow = light.shadow;
37316
+ const shadowUniforms = shadowCache.get(light);
37317
+ shadowUniforms.shadowIntensity = shadow.intensity;
37318
+ shadowUniforms.shadowBias = shadow.bias;
37319
+ shadowUniforms.shadowNormalBias = shadow.normalBias;
37320
+ shadowUniforms.shadowRadius = shadow.radius;
37321
+ shadowUniforms.shadowMapSize.copy(shadow.mapSize).multiply(shadow.getFrameExtents());
37322
+ state.sunShadow[numSunShadows] = shadowUniforms;
37323
+ state.sunShadowMap[numSunShadows] = shadowMap;
37324
+ const cascadeCount = shadow.getViewportCount();
37325
+ for (let j = 0; j < cascadeCount; j++) {
37326
+ state.sunShadowMatrix[numSunShadowCascades + j] = shadow.getMatrix(j);
37327
+ state.sunShadowCascade[numSunShadowCascades + j] = shadow._cascadeData[j];
37328
+ }
37329
+ numSunShadowCascades += cascadeCount;
37330
+ numSunShadows++;
37331
+ }
37332
+ state.sun[sunLength] = uniforms;
37333
+ sunLength++;
36991
37334
  } else if (light.isDirectionalLight) {
36992
37335
  const uniforms = cache.get(light);
36993
37336
  uniforms.color.copy(light.color).multiplyScalar(light.intensity);
@@ -37085,29 +37428,36 @@ function WebGLLights(extensions) {
37085
37428
  state.ambient[1] = g;
37086
37429
  state.ambient[2] = b;
37087
37430
  const hash = state.hash;
37088
- if (hash.directionalLength !== directionalLength || hash.pointLength !== pointLength || hash.spotLength !== spotLength || hash.rectAreaLength !== rectAreaLength || hash.hemiLength !== hemiLength || hash.numDirectionalShadows !== numDirectionalShadows || hash.numPointShadows !== numPointShadows || hash.numSpotShadows !== numSpotShadows || hash.numSpotMaps !== numSpotMaps || hash.numLightProbes !== numLightProbes) {
37431
+ if (hash.sunLength !== sunLength || hash.directionalLength !== directionalLength || hash.pointLength !== pointLength || hash.spotLength !== spotLength || hash.rectAreaLength !== rectAreaLength || hash.hemiLength !== hemiLength || hash.numSunShadows !== numSunShadows || hash.numDirectionalShadows !== numDirectionalShadows || hash.numPointShadows !== numPointShadows || hash.numSpotShadows !== numSpotShadows || hash.numSpotMaps !== numSpotMaps || hash.numLightProbes !== numLightProbes) {
37432
+ state.sun.length = sunLength;
37089
37433
  state.directional.length = directionalLength;
37090
37434
  state.spot.length = spotLength;
37091
37435
  state.rectArea.length = rectAreaLength;
37092
37436
  state.point.length = pointLength;
37093
37437
  state.hemi.length = hemiLength;
37438
+ state.sunShadow.length = numSunShadows;
37439
+ state.sunShadowMap.length = numSunShadows;
37440
+ state.sunShadowMatrix.length = numSunShadowCascades;
37441
+ state.sunShadowCascade.length = numSunShadowCascades;
37094
37442
  state.directionalShadow.length = numDirectionalShadows;
37095
37443
  state.directionalShadowMap.length = numDirectionalShadows;
37444
+ state.directionalShadowMatrix.length = numDirectionalShadows;
37096
37445
  state.pointShadow.length = numPointShadows;
37097
37446
  state.pointShadowMap.length = numPointShadows;
37447
+ state.pointShadowMatrix.length = numPointShadows;
37098
37448
  state.spotShadow.length = numSpotShadows;
37099
37449
  state.spotShadowMap.length = numSpotShadows;
37100
- state.directionalShadowMatrix.length = numDirectionalShadows;
37101
- state.pointShadowMatrix.length = numPointShadows;
37102
37450
  state.spotLightMatrix.length = numSpotShadows + numSpotMaps - numSpotShadowsWithMaps;
37103
37451
  state.spotLightMap.length = numSpotMaps;
37104
37452
  state.numSpotLightShadowsWithMaps = numSpotShadowsWithMaps;
37105
37453
  state.numLightProbes = numLightProbes;
37454
+ hash.sunLength = sunLength;
37106
37455
  hash.directionalLength = directionalLength;
37107
37456
  hash.pointLength = pointLength;
37108
37457
  hash.spotLength = spotLength;
37109
37458
  hash.rectAreaLength = rectAreaLength;
37110
37459
  hash.hemiLength = hemiLength;
37460
+ hash.numSunShadows = numSunShadows;
37111
37461
  hash.numDirectionalShadows = numDirectionalShadows;
37112
37462
  hash.numPointShadows = numPointShadows;
37113
37463
  hash.numSpotShadows = numSpotShadows;
@@ -37117,6 +37467,7 @@ function WebGLLights(extensions) {
37117
37467
  }
37118
37468
  }
37119
37469
  function setupView(lights, camera) {
37470
+ let sunLength = 0;
37120
37471
  let directionalLength = 0;
37121
37472
  let pointLength = 0;
37122
37473
  let spotLength = 0;
@@ -37125,7 +37476,12 @@ function WebGLLights(extensions) {
37125
37476
  const viewMatrix = camera.matrixWorldInverse;
37126
37477
  for (let i = 0, l = lights.length; i < l; i++) {
37127
37478
  const light = lights[i];
37128
- if (light.isDirectionalLight) {
37479
+ if (light.isSunLight) {
37480
+ const uniforms = state.sun[sunLength];
37481
+ uniforms.direction.setFromMatrixPosition(light.matrixWorld);
37482
+ uniforms.direction.transformDirection(viewMatrix);
37483
+ sunLength++;
37484
+ } else if (light.isDirectionalLight) {
37129
37485
  const uniforms = state.directional[directionalLength];
37130
37486
  uniforms.direction.setFromMatrixPosition(light.matrixWorld);
37131
37487
  vector3.setFromMatrixPosition(light.target.matrixWorld);
@@ -37303,7 +37659,7 @@ function WebGLShadowMap(renderer, objects, capabilities) {
37303
37659
  if (scope.autoUpdate === false && scope.needsUpdate === false) return;
37304
37660
  if (lights.length === 0) return;
37305
37661
  if (this.type === PCFSoftShadowMap) {
37306
- warn("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead.");
37662
+ warn("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead.");
37307
37663
  this.type = PCFShadowMap;
37308
37664
  }
37309
37665
  const currentRenderTarget = renderer.getRenderTarget();
@@ -37405,25 +37761,13 @@ function WebGLShadowMap(renderer, objects, capabilities) {
37405
37761
  }
37406
37762
  shadow.camera.updateProjectionMatrix();
37407
37763
  }
37408
- const faceCount = shadow.map.isWebGLCubeRenderTarget ? 6 : 1;
37764
+ if (shadow.map.isWebGLCubeRenderTarget !== true && (shadow.map.width !== _shadowMapSize.x || shadow.map.height !== _shadowMapSize.y)) {
37765
+ shadow.map.setSize(_shadowMapSize.x, _shadowMapSize.y);
37766
+ }
37767
+ const faceCount = shadow.map.isWebGLCubeRenderTarget ? 6 : shadow.getViewportCount();
37768
+ if (light.isPointLight !== true) shadow.updateMatrices(light, camera);
37409
37769
  for (let face = 0; face < faceCount; face++) {
37410
- if (shadow.map.isWebGLCubeRenderTarget) {
37411
- renderer.setRenderTarget(shadow.map, face);
37412
- renderer.clear();
37413
- } else {
37414
- if (face === 0) {
37415
- renderer.setRenderTarget(shadow.map);
37416
- renderer.clear();
37417
- }
37418
- const viewport = shadow.getViewport(face);
37419
- _viewport.set(
37420
- _viewportSize.x * viewport.x,
37421
- _viewportSize.y * viewport.y,
37422
- _viewportSize.x * viewport.z,
37423
- _viewportSize.y * viewport.w
37424
- );
37425
- _state.viewport(_viewport);
37426
- }
37770
+ const shadowCamera = shadow.getCamera(face);
37427
37771
  if (light.isPointLight) {
37428
37772
  const camera2 = shadow.camera;
37429
37773
  const shadowMatrix = shadow.matrix;
@@ -37442,11 +37786,26 @@ function WebGLShadowMap(renderer, objects, capabilities) {
37442
37786
  shadowMatrix.makeTranslation(-_lightPositionWorld2.x, -_lightPositionWorld2.y, -_lightPositionWorld2.z);
37443
37787
  _projScreenMatrix2.multiplyMatrices(camera2.projectionMatrix, camera2.matrixWorldInverse);
37444
37788
  shadow._frustum.setFromProjectionMatrix(_projScreenMatrix2, camera2.coordinateSystem, camera2.reversedDepth);
37789
+ }
37790
+ if (shadow.map.isWebGLCubeRenderTarget) {
37791
+ renderer.setRenderTarget(shadow.map, face);
37792
+ renderer.clear();
37445
37793
  } else {
37446
- shadow.updateMatrices(light);
37794
+ if (face === 0) {
37795
+ renderer.setRenderTarget(shadow.map);
37796
+ renderer.clear();
37797
+ }
37798
+ const viewport = shadow.getViewport(face);
37799
+ _viewport.set(
37800
+ _viewportSize.x * viewport.x,
37801
+ _viewportSize.y * viewport.y,
37802
+ _viewportSize.x * viewport.z,
37803
+ _viewportSize.y * viewport.w
37804
+ );
37805
+ _state.viewport(_viewport);
37447
37806
  }
37448
- _frustum2 = shadow.getFrustum();
37449
- renderObject(scene, camera, shadow.camera, light, this.type);
37807
+ _frustum2 = shadow.getFrustum(face);
37808
+ renderObject(scene, camera, shadowCamera, light, this.type);
37450
37809
  }
37451
37810
  if (shadow.isPointLightShadow !== true && this.type === VSMShadowMap) {
37452
37811
  VSMPass(shadow, camera);
@@ -37470,15 +37829,17 @@ function WebGLShadowMap(renderer, objects, capabilities) {
37470
37829
  format: RGFormat,
37471
37830
  type: HalfFloatType
37472
37831
  });
37832
+ } else if (shadow.mapPass.width !== shadow.map.width || shadow.mapPass.height !== shadow.map.height) {
37833
+ shadow.mapPass.setSize(shadow.map.width, shadow.map.height);
37473
37834
  }
37474
37835
  shadowMaterialVertical.uniforms.shadow_pass.value = shadow.map.depthTexture;
37475
- shadowMaterialVertical.uniforms.resolution.value = shadow.mapSize;
37836
+ shadowMaterialVertical.uniforms.resolution.value.set(shadow.map.width, shadow.map.height);
37476
37837
  shadowMaterialVertical.uniforms.radius.value = shadow.radius;
37477
37838
  renderer.setRenderTarget(shadow.mapPass);
37478
37839
  renderer.clear();
37479
37840
  renderer.renderBufferDirect(camera, null, geometry, shadowMaterialVertical, fullScreenMesh, null);
37480
37841
  shadowMaterialHorizontal.uniforms.shadow_pass.value = shadow.mapPass.texture;
37481
- shadowMaterialHorizontal.uniforms.resolution.value = shadow.mapSize;
37842
+ shadowMaterialHorizontal.uniforms.resolution.value.set(shadow.map.width, shadow.map.height);
37482
37843
  shadowMaterialHorizontal.uniforms.radius.value = shadow.radius;
37483
37844
  renderer.setRenderTarget(shadow.map);
37484
37845
  renderer.clear();
@@ -37535,7 +37896,7 @@ function WebGLShadowMap(renderer, objects, capabilities) {
37535
37896
  if (object.visible === false) return;
37536
37897
  const visible = object.layers.test(camera.layers);
37537
37898
  if (visible && (object.isMesh || object.isLine || object.isPoints)) {
37538
- if ((object.castShadow || object.receiveShadow && type === VSMShadowMap) && (!object.frustumCulled || _frustum2.intersectsObject(object))) {
37899
+ if ((object.castShadow || object.receiveShadow && type === VSMShadowMap) && (!object.frustumCulled || object.intersectsFrustum(_frustum2))) {
37539
37900
  object.modelViewMatrix.multiplyMatrices(shadowCamera.matrixWorldInverse, object.matrixWorld);
37540
37901
  const geometry = objects.update(object);
37541
37902
  const material = object.material;
@@ -38624,7 +38985,7 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
38624
38985
  function allocateTextureUnit() {
38625
38986
  const textureUnit = textureUnits;
38626
38987
  if (textureUnit >= capabilities.maxTextures) {
38627
- warn("WebGLTextures: Trying to use " + textureUnit + " texture units while this GPU supports only " + capabilities.maxTextures);
38988
+ warn("WebGLTextures: Trying to use " + (textureUnit + 1) + " texture units while this GPU supports only " + capabilities.maxTextures);
38628
38989
  }
38629
38990
  textureUnits += 1;
38630
38991
  return textureUnit;
@@ -38914,7 +39275,6 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
38914
39275
  );
38915
39276
  state.compressedTexSubImage3D(_gl.TEXTURE_2D_ARRAY, i, 0, 0, layerIndex, mipmap.width, mipmap.height, 1, glFormat, layerData);
38916
39277
  }
38917
- texture.clearLayerUpdates();
38918
39278
  } else {
38919
39279
  state.compressedTexSubImage3D(_gl.TEXTURE_2D_ARRAY, i, 0, 0, 0, mipmap.width, mipmap.height, image.depth, glFormat, mipmap.data);
38920
39280
  }
@@ -38935,6 +39295,7 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
38935
39295
  }
38936
39296
  }
38937
39297
  }
39298
+ if (texture.layerUpdates.size > 0) texture.clearLayerUpdates();
38938
39299
  } else {
38939
39300
  if (useTexStorage && allocateMemory) {
38940
39301
  state.texStorage2D(_gl.TEXTURE_2D, levels, glInternalFormat, mipmaps[0].width, mipmaps[0].height);
@@ -39571,7 +39932,7 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
39571
39932
  invalidationArrayRead.length = 0;
39572
39933
  invalidationArrayDraw.length = 0;
39573
39934
  invalidationArrayRead.push(_gl.COLOR_ATTACHMENT0 + i);
39574
- if (renderTarget.depthBuffer && renderTarget.resolveDepthBuffer === false) {
39935
+ if (renderTarget.depthBuffer && renderTarget.storeMultisampledDepthBuffer === false) {
39575
39936
  invalidationArrayRead.push(depthStyle);
39576
39937
  invalidationArrayDraw.push(depthStyle);
39577
39938
  _gl.invalidateFramebuffer(_gl.DRAW_FRAMEBUFFER, invalidationArrayDraw);
@@ -39592,7 +39953,7 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
39592
39953
  }
39593
39954
  state.bindFramebuffer(_gl.DRAW_FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer);
39594
39955
  } else {
39595
- if (renderTarget.depthBuffer && renderTarget.resolveDepthBuffer === false && supportsInvalidateFramebuffer) {
39956
+ if (renderTarget.depthBuffer && renderTarget.storeMultisampledDepthBuffer === false && supportsInvalidateFramebuffer) {
39596
39957
  const depthStyle = renderTarget.stencilBuffer ? _gl.DEPTH_STENCIL_ATTACHMENT : _gl.DEPTH_ATTACHMENT;
39597
39958
  _gl.invalidateFramebuffer(_gl.DRAW_FRAMEBUFFER, [depthStyle]);
39598
39959
  }
@@ -39904,6 +40265,7 @@ var WebXRManager = class extends EventDispatcher {
39904
40265
  const controllerInputSources = [];
39905
40266
  const currentSize = new Vector2();
39906
40267
  let currentPixelRatio = null;
40268
+ let currentCameraSettings = null;
39907
40269
  const cameraL = new PerspectiveCamera();
39908
40270
  cameraL.viewport = new Vector4();
39909
40271
  const cameraR = new PerspectiveCamera();
@@ -39981,6 +40343,13 @@ var WebXRManager = class extends EventDispatcher {
39981
40343
  scope.isPresenting = false;
39982
40344
  renderer.setPixelRatio(currentPixelRatio);
39983
40345
  renderer.setSize(currentSize.width, currentSize.height, false);
40346
+ if (currentCameraSettings !== null) {
40347
+ const camera = currentCameraSettings.camera;
40348
+ camera.fov = currentCameraSettings.fov;
40349
+ camera.zoom = currentCameraSettings.zoom;
40350
+ camera.updateProjectionMatrix();
40351
+ currentCameraSettings = null;
40352
+ }
39984
40353
  scope.dispatchEvent({ type: "sessionend" });
39985
40354
  }
39986
40355
  this.setFramebufferScaleFactor = function(value) {
@@ -40055,7 +40424,9 @@ var WebXRManager = class extends EventDispatcher {
40055
40424
  colorSpace: renderer.outputColorSpace,
40056
40425
  stencilBuffer: attributes.stencil,
40057
40426
  resolveDepthBuffer: glBaseLayer.ignoreDepthValues === false,
40058
- resolveStencilBuffer: glBaseLayer.ignoreDepthValues === false
40427
+ resolveStencilBuffer: glBaseLayer.ignoreDepthValues === false,
40428
+ storeMultisampledDepthBuffer: glBaseLayer.ignoreDepthValues === false,
40429
+ storeMultisampledStencilBuffer: glBaseLayer.ignoreDepthValues === false
40059
40430
  }
40060
40431
  );
40061
40432
  } else {
@@ -40088,7 +40459,9 @@ var WebXRManager = class extends EventDispatcher {
40088
40459
  colorSpace: renderer.outputColorSpace,
40089
40460
  samples: attributes.antialias ? 4 : 0,
40090
40461
  resolveDepthBuffer: glProjLayer.ignoreDepthValues === false,
40091
- resolveStencilBuffer: glProjLayer.ignoreDepthValues === false
40462
+ resolveStencilBuffer: glProjLayer.ignoreDepthValues === false,
40463
+ storeMultisampledDepthBuffer: glProjLayer.ignoreDepthValues === false,
40464
+ storeMultisampledStencilBuffer: glProjLayer.ignoreDepthValues === false
40092
40465
  }
40093
40466
  );
40094
40467
  }
@@ -40219,6 +40592,9 @@ var WebXRManager = class extends EventDispatcher {
40219
40592
  } else {
40220
40593
  cameraXR.projectionMatrix.copy(cameraL.projectionMatrix);
40221
40594
  }
40595
+ if (currentCameraSettings === null && camera.isPerspectiveCamera) {
40596
+ currentCameraSettings = { camera, fov: camera.fov, zoom: camera.zoom };
40597
+ }
40222
40598
  updateUserCamera(camera, cameraXR, parent);
40223
40599
  };
40224
40600
  function updateUserCamera(camera, cameraXR2, parent) {
@@ -40616,6 +40992,9 @@ function WebGLMaterials(renderer, properties) {
40616
40992
  if (material.dispersion > 0) {
40617
40993
  uniforms.dispersion.value = material.dispersion;
40618
40994
  }
40995
+ if (material.retroreflectivity > 0) {
40996
+ uniforms.retroreflectivity.value = material.retroreflectivity;
40997
+ }
40619
40998
  if (material.iridescence > 0) {
40620
40999
  uniforms.iridescence.value = material.iridescence;
40621
41000
  uniforms.iridescenceIOR.value = material.iridescenceIOR;
@@ -41493,6 +41872,14 @@ var WebGLRenderer = class {
41493
41872
  * @type {boolean}
41494
41873
  */
41495
41874
  checkShaderErrors: true,
41875
+ /**
41876
+ * Diagnostics configuration for the shader generation. Only relevant for TSL.
41877
+ * @type {Object}
41878
+ * @property {boolean} keywords - Whether declaration names that collide with reserved keywords of the shading language should be renamed or not.
41879
+ */
41880
+ diagnostics: {
41881
+ keywords: false
41882
+ },
41496
41883
  /**
41497
41884
  * Callback for custom error reporting.
41498
41885
  * @type {?Function}
@@ -41549,6 +41936,11 @@ var WebGLRenderer = class {
41549
41936
  function getContext(contextName, contextAttributes) {
41550
41937
  return canvas.getContext(contextName, contextAttributes);
41551
41938
  }
41939
+ let extensions, capabilities, state, info;
41940
+ let properties, textures, environments, attributes, geometries, objects;
41941
+ let programCache, materials, renderLists, renderStates, clipping, shadowMap;
41942
+ let background, morphtargets, bufferRenderer, indexedBufferRenderer;
41943
+ let utils, bindingStates, uniformsGroups;
41552
41944
  try {
41553
41945
  const contextAttributes = {
41554
41946
  alpha: true,
@@ -41575,15 +41967,14 @@ var WebGLRenderer = class {
41575
41967
  }
41576
41968
  }
41577
41969
  }
41970
+ initGLContext();
41578
41971
  } catch (e) {
41972
+ canvas.removeEventListener("webglcontextlost", onContextLost, false);
41973
+ canvas.removeEventListener("webglcontextrestored", onContextRestore, false);
41974
+ canvas.removeEventListener("webglcontextcreationerror", onContextCreationError, false);
41579
41975
  error("WebGLRenderer: " + e.message);
41580
41976
  throw e;
41581
41977
  }
41582
- let extensions, capabilities, state, info;
41583
- let properties, textures, environments, attributes, geometries, objects;
41584
- let programCache, materials, renderLists, renderStates, clipping, shadowMap;
41585
- let background, morphtargets, bufferRenderer, indexedBufferRenderer;
41586
- let utils, bindingStates, uniformsGroups;
41587
41978
  function initGLContext() {
41588
41979
  extensions = new WebGLExtensions(_gl);
41589
41980
  extensions.init();
@@ -41624,7 +42015,6 @@ var WebGLRenderer = class {
41624
42015
  _this.state = state;
41625
42016
  _this.info = info;
41626
42017
  }
41627
- initGLContext();
41628
42018
  if (_outputBufferType !== UnsignedByteType) {
41629
42019
  output = new WebGLOutput(_outputBufferType, canvas.width, canvas.height, antialias, depth, stencil);
41630
42020
  }
@@ -41951,7 +42341,9 @@ var WebGLRenderer = class {
41951
42341
  renderer.render(drawStart, drawCount);
41952
42342
  }
41953
42343
  };
41954
- function prepareMaterial(material, scene, object) {
42344
+ function prepareMaterial(material, scene, camera, object) {
42345
+ if (_nodesHandler !== null && material.isNodeMaterial) _nodesHandler.setObject(object, material);
42346
+ if (_clippingEnabled === true) clipping.setState(material, camera, false);
41955
42347
  if (material.transparent === true && material.side === DoubleSide && material.forceSinglePass === false) {
41956
42348
  material.side = BackSide;
41957
42349
  material.needsUpdate = true;
@@ -41966,6 +42358,7 @@ var WebGLRenderer = class {
41966
42358
  }
41967
42359
  this.compile = function(scene, camera, targetScene = null) {
41968
42360
  if (targetScene === null) targetScene = scene;
42361
+ if (_nodesHandler !== null) _nodesHandler.renderStart(scene, camera, targetScene);
41969
42362
  currentRenderState = renderStates.get(targetScene);
41970
42363
  currentRenderState.init(camera);
41971
42364
  renderStateStack.push(currentRenderState);
@@ -41988,6 +42381,11 @@ var WebGLRenderer = class {
41988
42381
  });
41989
42382
  }
41990
42383
  currentRenderState.setupLights();
42384
+ if (_nodesHandler !== null) _nodesHandler.updateLights(currentRenderState.state.lightsArray);
42385
+ _localClippingEnabled = this.localClippingEnabled;
42386
+ _clippingEnabled = clipping.init(this.clippingPlanes, _localClippingEnabled);
42387
+ if (_clippingEnabled === true) clipping.setGlobalState(this.clippingPlanes, camera);
42388
+ if (_nodesHandler !== null) shadowMap.render(currentRenderState.state.shadowsArray, targetScene, camera);
41991
42389
  const materials2 = /* @__PURE__ */ new Set();
41992
42390
  scene.traverse(function(object) {
41993
42391
  if (!(object.isMesh || object.isPoints || object.isLine || object.isSprite)) {
@@ -41998,16 +42396,17 @@ var WebGLRenderer = class {
41998
42396
  if (Array.isArray(material)) {
41999
42397
  for (let i = 0; i < material.length; i++) {
42000
42398
  const material2 = material[i];
42001
- prepareMaterial(material2, targetScene, object);
42399
+ prepareMaterial(material2, targetScene, camera, object);
42002
42400
  materials2.add(material2);
42003
42401
  }
42004
42402
  } else {
42005
- prepareMaterial(material, targetScene, object);
42403
+ prepareMaterial(material, targetScene, camera, object);
42006
42404
  materials2.add(material);
42007
42405
  }
42008
42406
  }
42009
42407
  });
42010
42408
  currentRenderState = renderStateStack.pop();
42409
+ if (_nodesHandler !== null) _nodesHandler.renderEnd();
42011
42410
  return materials2;
42012
42411
  };
42013
42412
  this.compileAsync = function(scene, camera, targetScene = null) {
@@ -42017,7 +42416,7 @@ var WebGLRenderer = class {
42017
42416
  materials2.forEach(function(material) {
42018
42417
  const materialProperties = properties.get(material);
42019
42418
  const program = materialProperties.currentProgram;
42020
- if (program.isReady()) {
42419
+ if (program === void 0 || program.isReady()) {
42021
42420
  materials2.delete(material);
42022
42421
  }
42023
42422
  });
@@ -42091,8 +42490,9 @@ var WebGLRenderer = class {
42091
42490
  }
42092
42491
  projectObject(scene, camera, 0, _this.sortObjects);
42093
42492
  currentRenderList.finish();
42493
+ if (_nodesHandler !== null) _nodesHandler.updateLights(currentRenderState.state.lightsArray);
42094
42494
  if (_this.sortObjects === true) {
42095
- currentRenderList.sort(_opaqueSort, _transparentSort, camera.reversedDepth);
42495
+ currentRenderList.sort(_opaqueSort, _transparentSort);
42096
42496
  }
42097
42497
  _renderBackground = xr.enabled === false || xr.isPresenting === false || xr.hasDepthSensing() === false;
42098
42498
  if (_renderBackground) {
@@ -42173,18 +42573,18 @@ var WebGLRenderer = class {
42173
42573
  currentRenderState.pushShadow(object);
42174
42574
  }
42175
42575
  } else if (object.isSprite) {
42176
- if (!object.frustumCulled || _frustum2.intersectsSprite(object)) {
42576
+ if (!object.frustumCulled || object.intersectsFrustum(_frustum2)) {
42177
42577
  if (sortObjects) {
42178
42578
  _vector42.setFromMatrixPosition(object.matrixWorld).applyMatrix4(_projScreenMatrix3);
42179
42579
  }
42180
42580
  const geometry = objects.update(object);
42181
42581
  const material = object.material;
42182
42582
  if (material.visible) {
42183
- currentRenderList.push(object, geometry, material, groupOrder, _vector42.z, null);
42583
+ currentRenderList.push(object, geometry, material, groupOrder, _vector42.z, null, camera);
42184
42584
  }
42185
42585
  }
42186
42586
  } else if (object.isMesh || object.isLine || object.isPoints) {
42187
- if (!object.frustumCulled || _frustum2.intersectsObject(object)) {
42587
+ if (!object.frustumCulled || object.intersectsFrustum(_frustum2)) {
42188
42588
  const geometry = objects.update(object);
42189
42589
  const material = object.material;
42190
42590
  if (sortObjects) {
@@ -42203,11 +42603,11 @@ var WebGLRenderer = class {
42203
42603
  const group = groups[i];
42204
42604
  const groupMaterial = material[group.materialIndex];
42205
42605
  if (groupMaterial && groupMaterial.visible) {
42206
- currentRenderList.push(object, geometry, groupMaterial, groupOrder, _vector42.z, group);
42606
+ currentRenderList.push(object, geometry, groupMaterial, groupOrder, _vector42.z, group, camera);
42207
42607
  }
42208
42608
  }
42209
42609
  } else if (material.visible) {
42210
- currentRenderList.push(object, geometry, material, groupOrder, _vector42.z, null);
42610
+ currentRenderList.push(object, geometry, material, groupOrder, _vector42.z, null, camera);
42211
42611
  }
42212
42612
  }
42213
42613
  }
@@ -42246,6 +42646,8 @@ var WebGLRenderer = class {
42246
42646
  stencilBuffer: stencil,
42247
42647
  resolveDepthBuffer: false,
42248
42648
  resolveStencilBuffer: false,
42649
+ storeMultisampledDepthBuffer: false,
42650
+ storeMultisampledStencilBuffer: false,
42249
42651
  colorSpace: ColorManagement.workingColorSpace
42250
42652
  });
42251
42653
  }
@@ -42310,6 +42712,7 @@ var WebGLRenderer = class {
42310
42712
  }
42311
42713
  }
42312
42714
  function renderObject(object, scene, camera, geometry, material, group) {
42715
+ if (_nodesHandler !== null && material.isNodeMaterial) _nodesHandler.setObject(object, material);
42313
42716
  object.onBeforeRender(_this, scene, camera, geometry, material, group);
42314
42717
  object.modelViewMatrix.multiplyMatrices(camera.matrixWorldInverse, object.matrixWorld);
42315
42718
  object.normalMatrix.getNormalMatrix(object.modelViewMatrix);
@@ -42372,6 +42775,8 @@ var WebGLRenderer = class {
42372
42775
  if (materialProperties.needsLights) {
42373
42776
  uniforms.ambientLightColor.value = lights.state.ambient;
42374
42777
  uniforms.lightProbe.value = lights.state.probe;
42778
+ uniforms.sunLights.value = lights.state.sun;
42779
+ uniforms.sunLightShadows.value = lights.state.sunShadow;
42375
42780
  uniforms.directionalLights.value = lights.state.directional;
42376
42781
  uniforms.directionalLightShadows.value = lights.state.directionalShadow;
42377
42782
  uniforms.spotLights.value = lights.state.spot;
@@ -42382,6 +42787,8 @@ var WebGLRenderer = class {
42382
42787
  uniforms.pointLights.value = lights.state.point;
42383
42788
  uniforms.pointLightShadows.value = lights.state.pointShadow;
42384
42789
  uniforms.hemisphereLights.value = lights.state.hemi;
42790
+ uniforms.sunShadowMatrix.value = lights.state.sunShadowMatrix;
42791
+ uniforms.sunShadowCascade.value = lights.state.sunShadowCascade;
42385
42792
  uniforms.directionalShadowMatrix.value = lights.state.directionalShadowMatrix;
42386
42793
  uniforms.spotLightMatrix.value = lights.state.spotLightMatrix;
42387
42794
  uniforms.spotLightMap.value = lights.state.spotLightMap;
@@ -42469,9 +42876,9 @@ var WebGLRenderer = class {
42469
42876
  needsProgramChange = true;
42470
42877
  } else if (!object.isBatchedMesh && materialProperties.batching === true) {
42471
42878
  needsProgramChange = true;
42472
- } else if (object.isBatchedMesh && materialProperties.batchingColor === true && object.colorTexture === null) {
42879
+ } else if (object.isBatchedMesh && materialProperties.batchingColor === true && object._colorsTexture === null) {
42473
42880
  needsProgramChange = true;
42474
- } else if (object.isBatchedMesh && materialProperties.batchingColor === false && object.colorTexture !== null) {
42881
+ } else if (object.isBatchedMesh && materialProperties.batchingColor === false && object._colorsTexture !== null) {
42475
42882
  needsProgramChange = true;
42476
42883
  } else if (object.isInstancedMesh && materialProperties.instancing === false) {
42477
42884
  needsProgramChange = true;
@@ -42572,6 +42979,9 @@ var WebGLRenderer = class {
42572
42979
  }
42573
42980
  }
42574
42981
  if (materialProperties.needsLights) {
42982
+ if (lights.state.sunShadowMap.length > 0) {
42983
+ p_uniforms.setValue(_gl, "sunShadowMap", lights.state.sunShadowMap, textures);
42984
+ }
42575
42985
  if (lights.state.directionalShadowMap.length > 0) {
42576
42986
  p_uniforms.setValue(_gl, "directionalShadowMap", lights.state.directionalShadowMap, textures);
42577
42987
  }
@@ -42656,6 +43066,8 @@ var WebGLRenderer = class {
42656
43066
  function markUniformsLightsNeedsUpdate(uniforms, value) {
42657
43067
  uniforms.ambientLightColor.needsUpdate = value;
42658
43068
  uniforms.lightProbe.needsUpdate = value;
43069
+ uniforms.sunLights.needsUpdate = value;
43070
+ uniforms.sunLightShadows.needsUpdate = value;
42659
43071
  uniforms.directionalLights.needsUpdate = value;
42660
43072
  uniforms.directionalLightShadows.needsUpdate = value;
42661
43073
  uniforms.pointLights.needsUpdate = value;
@@ -42778,6 +43190,16 @@ var WebGLRenderer = class {
42778
43190
  }
42779
43191
  _currentMaterialId = -1;
42780
43192
  };
43193
+ function getReadableState(texture) {
43194
+ const textureProperties = properties.get(texture);
43195
+ if (textureProperties.__readFormat !== texture.format || textureProperties.__readType !== texture.type) {
43196
+ textureProperties.__readFormat = texture.format;
43197
+ textureProperties.__readType = texture.type;
43198
+ textureProperties.__formatReadable = capabilities.textureFormatReadable(texture.format);
43199
+ textureProperties.__typeReadable = capabilities.textureTypeReadable(texture.type);
43200
+ }
43201
+ return textureProperties;
43202
+ }
42781
43203
  this.readRenderTargetPixels = function(renderTarget, x, y, width, height, buffer, activeCubeFaceIndex, textureIndex = 0) {
42782
43204
  if (!(renderTarget && renderTarget.isWebGLRenderTarget)) {
42783
43205
  error("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");
@@ -42794,11 +43216,12 @@ var WebGLRenderer = class {
42794
43216
  const textureFormat = texture.format;
42795
43217
  const textureType = texture.type;
42796
43218
  if (renderTarget.textures.length > 1) _gl.readBuffer(_gl.COLOR_ATTACHMENT0 + textureIndex);
42797
- if (!capabilities.textureFormatReadable(textureFormat)) {
43219
+ const readableState = getReadableState(texture);
43220
+ if (readableState.__formatReadable === false) {
42798
43221
  error("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");
42799
43222
  return;
42800
43223
  }
42801
- if (!capabilities.textureTypeReadable(textureType)) {
43224
+ if (readableState.__typeReadable === false) {
42802
43225
  error("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");
42803
43226
  return;
42804
43227
  }
@@ -42826,16 +43249,18 @@ var WebGLRenderer = class {
42826
43249
  const textureFormat = texture.format;
42827
43250
  const textureType = texture.type;
42828
43251
  if (renderTarget.textures.length > 1) _gl.readBuffer(_gl.COLOR_ATTACHMENT0 + textureIndex);
42829
- if (!capabilities.textureFormatReadable(textureFormat)) {
43252
+ const readableState = getReadableState(texture);
43253
+ if (readableState.__formatReadable === false) {
42830
43254
  throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");
42831
43255
  }
42832
- if (!capabilities.textureTypeReadable(textureType)) {
43256
+ if (readableState.__typeReadable === false) {
42833
43257
  throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");
42834
43258
  }
42835
43259
  const glBuffer = _gl.createBuffer();
42836
43260
  _gl.bindBuffer(_gl.PIXEL_PACK_BUFFER, glBuffer);
42837
43261
  _gl.bufferData(_gl.PIXEL_PACK_BUFFER, buffer.byteLength, _gl.STREAM_READ);
42838
43262
  _gl.readPixels(x, y, width, height, utils.convert(textureFormat), utils.convert(textureType), 0);
43263
+ _gl.bindBuffer(_gl.PIXEL_PACK_BUFFER, null);
42839
43264
  const currFramebuffer = _currentRenderTarget !== null ? properties.get(_currentRenderTarget).__webglFramebuffer : null;
42840
43265
  state.bindFramebuffer(_gl.FRAMEBUFFER, currFramebuffer);
42841
43266
  const sync = _gl.fenceSync(_gl.SYNC_GPU_COMMANDS_COMPLETE, 0);
@@ -42843,6 +43268,7 @@ var WebGLRenderer = class {
42843
43268
  await probeAsync(_gl, sync, 4);
42844
43269
  _gl.bindBuffer(_gl.PIXEL_PACK_BUFFER, glBuffer);
42845
43270
  _gl.getBufferSubData(_gl.PIXEL_PACK_BUFFER, 0, buffer);
43271
+ _gl.bindBuffer(_gl.PIXEL_PACK_BUFFER, null);
42846
43272
  _gl.deleteBuffer(glBuffer);
42847
43273
  _gl.deleteSync(sync);
42848
43274
  return buffer;
@@ -43243,6 +43669,7 @@ exports.LessEqualStencilFunc = LessEqualStencilFunc;
43243
43669
  exports.LessStencilFunc = LessStencilFunc;
43244
43670
  exports.Light = Light;
43245
43671
  exports.LightProbe = LightProbe;
43672
+ exports.LightShadow = LightShadow;
43246
43673
  exports.Line = Line;
43247
43674
  exports.Line3 = Line3;
43248
43675
  exports.LineBasicMaterial = LineBasicMaterial;
@@ -43395,6 +43822,7 @@ exports.RectAreaLight = RectAreaLight;
43395
43822
  exports.RedFormat = RedFormat;
43396
43823
  exports.RedIntegerFormat = RedIntegerFormat;
43397
43824
  exports.ReinhardToneMapping = ReinhardToneMapping;
43825
+ exports.RenderObjectRefreshType = RenderObjectRefreshType;
43398
43826
  exports.RenderTarget = RenderTarget;
43399
43827
  exports.RenderTarget3D = RenderTarget3D;
43400
43828
  exports.RepeatWrapping = RepeatWrapping;
@@ -43448,6 +43876,7 @@ exports.TangentSpaceNormalMap = TangentSpaceNormalMap;
43448
43876
  exports.TetrahedronGeometry = TetrahedronGeometry;
43449
43877
  exports.Texture = Texture;
43450
43878
  exports.TextureLoader = TextureLoader;
43879
+ exports.TextureSource = TextureSource;
43451
43880
  exports.TextureUtils = TextureUtils;
43452
43881
  exports.Timer = Timer;
43453
43882
  exports.TimestampQuery = TimestampQuery;