@splinetool/runtime 2.0.9 → 2.0.10

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 (280) hide show
  1. package/build/hana-ui.js +73 -43
  2. package/build/hana-ui.js.br +0 -0
  3. package/build/hana-ui.js.gz +0 -0
  4. package/build/hana-ui.wasm +0 -0
  5. package/build/hana-ui.wasm.br +0 -0
  6. package/build/hana-ui.wasm.gz +0 -0
  7. package/build/{runtime-chunk-ZTHLLGVX.js → runtime-chunk-4LKRNVPP.js} +1 -1
  8. package/build/{runtime-chunk-ZTHLLGVX.js.br → runtime-chunk-4LKRNVPP.js.br} +0 -0
  9. package/build/runtime-chunk-4LKRNVPP.js.gz +0 -0
  10. package/build/{runtime-chunk-3D6ELLRB.js → runtime-chunk-7FDJ7IIR.js} +1 -1
  11. package/build/runtime-chunk-7FDJ7IIR.js.br +0 -0
  12. package/build/runtime-chunk-7FDJ7IIR.js.gz +0 -0
  13. package/build/{runtime-chunk-5RKK7JBF.js → runtime-chunk-BLFFIB2B.js} +1 -1
  14. package/build/runtime-chunk-BLFFIB2B.js.br +0 -0
  15. package/build/runtime-chunk-BLFFIB2B.js.gz +0 -0
  16. package/build/{runtime-chunk-U7JVP2TI.js → runtime-chunk-CDR3AZNB.js} +1 -1
  17. package/build/runtime-chunk-CDR3AZNB.js.br +0 -0
  18. package/build/runtime-chunk-CDR3AZNB.js.gz +0 -0
  19. package/build/{runtime-chunk-CUH4PXNR.js → runtime-chunk-CDYE22J6.js} +1 -1
  20. package/build/runtime-chunk-CDYE22J6.js.br +0 -0
  21. package/build/runtime-chunk-CDYE22J6.js.gz +0 -0
  22. package/build/runtime-chunk-DZIH7EMN.js +1 -0
  23. package/build/runtime-chunk-DZIH7EMN.js.br +0 -0
  24. package/build/runtime-chunk-DZIH7EMN.js.gz +0 -0
  25. package/build/{runtime-chunk-SOL2NZB4.js → runtime-chunk-FN2C54JM.js} +1 -1
  26. package/build/runtime-chunk-FN2C54JM.js.br +0 -0
  27. package/build/runtime-chunk-FN2C54JM.js.gz +0 -0
  28. package/build/runtime-chunk-I6B5A36U.js +1 -0
  29. package/build/runtime-chunk-I6B5A36U.js.br +0 -0
  30. package/build/runtime-chunk-I6B5A36U.js.gz +0 -0
  31. package/build/{runtime-chunk-KRQKRJPD.js → runtime-chunk-JSRKKIOS.js} +1 -1
  32. package/build/runtime-chunk-JSRKKIOS.js.br +0 -0
  33. package/build/runtime-chunk-JSRKKIOS.js.gz +0 -0
  34. package/build/{runtime-chunk-LVFNCYIC.js → runtime-chunk-KKDM5MC5.js} +1 -1
  35. package/build/runtime-chunk-KKDM5MC5.js.br +0 -0
  36. package/build/runtime-chunk-KKDM5MC5.js.gz +0 -0
  37. package/build/{runtime-chunk-YNTJMLA5.js → runtime-chunk-L2C7JGYG.js} +1 -1
  38. package/build/runtime-chunk-L2C7JGYG.js.br +0 -0
  39. package/build/runtime-chunk-L2C7JGYG.js.gz +0 -0
  40. package/build/{runtime-chunk-RYIFGI7L.js → runtime-chunk-LQL2PJVX.js} +1 -1
  41. package/build/runtime-chunk-LQL2PJVX.js.br +0 -0
  42. package/build/runtime-chunk-LQL2PJVX.js.gz +0 -0
  43. package/build/{runtime-chunk-YANJNJO2.js → runtime-chunk-M4BPCY7K.js} +1 -1
  44. package/build/runtime-chunk-M4BPCY7K.js.br +0 -0
  45. package/build/runtime-chunk-M4BPCY7K.js.gz +0 -0
  46. package/build/{runtime-chunk-R3V4RB3X.js → runtime-chunk-MOZWC42D.js} +1 -1
  47. package/build/runtime-chunk-MOZWC42D.js.br +0 -0
  48. package/build/runtime-chunk-MOZWC42D.js.gz +0 -0
  49. package/build/{runtime-chunk-EPFYNTQQ.js → runtime-chunk-MVJAFW5H.js} +1 -1
  50. package/build/runtime-chunk-MVJAFW5H.js.br +1 -0
  51. package/build/runtime-chunk-MVJAFW5H.js.gz +0 -0
  52. package/build/{runtime-chunk-CXBK7LPG.js → runtime-chunk-QSJVWNNM.js} +1 -1
  53. package/build/runtime-chunk-QSJVWNNM.js.br +0 -0
  54. package/build/runtime-chunk-QSJVWNNM.js.gz +0 -0
  55. package/build/{runtime-chunk-VJPN4EM6.js → runtime-chunk-RTRWO43P.js} +1 -1
  56. package/build/runtime-chunk-RTRWO43P.js.br +0 -0
  57. package/build/runtime-chunk-RTRWO43P.js.gz +0 -0
  58. package/build/{runtime-chunk-UFFTT5MI.js → runtime-chunk-RX3SW5K2.js} +1 -1
  59. package/build/runtime-chunk-RX3SW5K2.js.br +0 -0
  60. package/build/runtime-chunk-RX3SW5K2.js.gz +0 -0
  61. package/build/{runtime-chunk-4FRVTTCF.js → runtime-chunk-UHCXLQHA.js} +1 -1
  62. package/build/runtime-chunk-UHCXLQHA.js.br +0 -0
  63. package/build/runtime-chunk-UHCXLQHA.js.gz +0 -0
  64. package/build/{runtime-chunk-FJZAL2GU.js → runtime-chunk-VNO2DW74.js} +1 -1
  65. package/build/runtime-chunk-VNO2DW74.js.br +0 -0
  66. package/build/runtime-chunk-VNO2DW74.js.gz +0 -0
  67. package/build/{runtime-chunk-WFTAZCXD.js → runtime-chunk-WQ2NXI3U.js} +1 -1
  68. package/build/runtime-chunk-WQ2NXI3U.js.br +0 -0
  69. package/build/runtime-chunk-WQ2NXI3U.js.gz +0 -0
  70. package/build/{runtime-chunk-KJLTN6RE.js → runtime-chunk-YO3XFDZF.js} +1 -1
  71. package/build/runtime-chunk-YO3XFDZF.js.br +0 -0
  72. package/build/runtime-chunk-YO3XFDZF.js.gz +0 -0
  73. package/build/{runtime-chunk-44F5FA4N.js → runtime-chunk-YS7K3AW3.js} +1 -1
  74. package/build/runtime-chunk-YS7K3AW3.js.br +0 -0
  75. package/build/runtime-chunk-YS7K3AW3.js.gz +0 -0
  76. package/build/{runtime-chunk-33KX2TOT.js → runtime-chunk-ZASM3KKC.js} +1 -1
  77. package/build/runtime-chunk-ZASM3KKC.js.br +0 -0
  78. package/build/runtime-chunk-ZASM3KKC.js.gz +0 -0
  79. package/build/{runtime-chunk-ROGQC3YL.js → runtime-chunk-ZLOMOV3N.js} +1 -1
  80. package/build/runtime-chunk-ZLOMOV3N.js.br +0 -0
  81. package/build/runtime-chunk-ZLOMOV3N.js.gz +0 -0
  82. package/build/{runtime-chunk-5MDYMRYM.js → runtime-chunk-ZM7N5SZG.js} +1 -1
  83. package/build/runtime-chunk-ZM7N5SZG.js.br +0 -0
  84. package/build/runtime-chunk-ZM7N5SZG.js.gz +0 -0
  85. package/build/{runtime-classicRuntime-7YZ7NLMG.js → runtime-classicRuntime-A3DEJ3YH.js} +1 -1
  86. package/build/runtime-classicRuntime-A3DEJ3YH.js.br +0 -0
  87. package/build/runtime-classicRuntime-A3DEJ3YH.js.gz +0 -0
  88. package/build/{runtime-cloners-H554LSFU.js → runtime-cloners-UFF7A36S.js} +1 -1
  89. package/build/runtime-cloners-UFF7A36S.js.br +1 -0
  90. package/build/runtime-cloners-UFF7A36S.js.gz +0 -0
  91. package/build/{runtime-components-ZCELGDQ5.js → runtime-components-EESAIEPO.js} +1 -1
  92. package/build/runtime-components-EESAIEPO.js.br +0 -0
  93. package/build/runtime-components-EESAIEPO.js.gz +0 -0
  94. package/build/{runtime-createDestroy-FK2ZKK66.js → runtime-createDestroy-WBIIVRMC.js} +1 -1
  95. package/build/runtime-createDestroy-WBIIVRMC.js.br +0 -0
  96. package/build/runtime-createDestroy-WBIIVRMC.js.gz +0 -0
  97. package/build/{runtime-dragDrop-E4OSDFGY.js → runtime-dragDrop-D45J5GQ5.js} +1 -1
  98. package/build/runtime-dragDrop-D45J5GQ5.js.br +0 -0
  99. package/build/runtime-dragDrop-D45J5GQ5.js.gz +0 -0
  100. package/build/{runtime-gameControls-A3BST7FA.js → runtime-gameControls-GNLQ3FT6.js} +1 -1
  101. package/build/runtime-gameControls-GNLQ3FT6.js.br +0 -0
  102. package/build/runtime-gameControls-GNLQ3FT6.js.gz +0 -0
  103. package/build/{runtime-hair-W5WKY4OE.js → runtime-hair-55OFZZFY.js} +1 -1
  104. package/build/runtime-hair-55OFZZFY.js.br +1 -0
  105. package/build/runtime-hair-55OFZZFY.js.gz +0 -0
  106. package/build/{runtime-mergeStaticGeometries-5FS3LGQQ.js → runtime-mergeStaticGeometries-NLUOSGZB.js} +1 -1
  107. package/build/runtime-mergeStaticGeometries-NLUOSGZB.js.br +0 -0
  108. package/build/runtime-mergeStaticGeometries-NLUOSGZB.js.gz +0 -0
  109. package/build/{runtime-miscActions-F72HQZ5I.js → runtime-miscActions-5YY5ARQT.js} +1 -1
  110. package/build/runtime-miscActions-5YY5ARQT.js.br +0 -0
  111. package/build/runtime-miscActions-5YY5ARQT.js.gz +0 -0
  112. package/build/{runtime-mouseHover-44D2CVLI.js → runtime-mouseHover-MTTJI6DT.js} +1 -1
  113. package/build/runtime-mouseHover-MTTJI6DT.js.br +0 -0
  114. package/build/runtime-mouseHover-MTTJI6DT.js.gz +0 -0
  115. package/build/{runtime-particles-5BBDNO44.js → runtime-particles-VZVZJ35I.js} +1 -1
  116. package/build/runtime-particles-VZVZJ35I.js.br +0 -0
  117. package/build/runtime-particles-VZVZJ35I.js.gz +0 -0
  118. package/build/{runtime-paths-YF5SB3I3.js → runtime-paths-4UDUBYZN.js} +1 -1
  119. package/build/runtime-paths-4UDUBYZN.js.br +0 -0
  120. package/build/runtime-paths-4UDUBYZN.js.gz +0 -0
  121. package/build/{runtime-resize-ZORLCUGS.js → runtime-resize-QYCZUOPF.js} +1 -1
  122. package/build/runtime-resize-QYCZUOPF.js.br +0 -0
  123. package/build/runtime-resize-QYCZUOPF.js.gz +0 -0
  124. package/build/{runtime-sceneTransition-EEJJDLOW.js → runtime-sceneTransition-FC5TQNCH.js} +1 -1
  125. package/build/runtime-sceneTransition-FC5TQNCH.js.br +0 -0
  126. package/build/runtime-sceneTransition-FC5TQNCH.js.gz +0 -0
  127. package/build/{runtime-scroll-HSHQUB6P.js → runtime-scroll-VKMCDMAZ.js} +1 -1
  128. package/build/runtime-scroll-VKMCDMAZ.js.br +0 -0
  129. package/build/runtime-scroll-VKMCDMAZ.js.gz +0 -0
  130. package/build/runtime-shapeBlends-3QLNRN2O.js +1 -0
  131. package/build/runtime-shapeBlends-3QLNRN2O.js.br +4 -0
  132. package/build/runtime-shapeBlends-3QLNRN2O.js.gz +0 -0
  133. package/build/{runtime-text-UGIMBR6B.js → runtime-text-IYCY3PFB.js} +1 -1
  134. package/build/runtime-text-IYCY3PFB.js.br +0 -0
  135. package/build/runtime-text-IYCY3PFB.js.gz +0 -0
  136. package/build/{runtime-textInputs-HE2LSUKB.js → runtime-textInputs-LFDWIRLC.js} +1 -1
  137. package/build/runtime-textInputs-LFDWIRLC.js.br +0 -0
  138. package/build/runtime-textInputs-LFDWIRLC.js.gz +0 -0
  139. package/build/runtime-timeline-WNUPRRKW.js +1 -0
  140. package/build/runtime-timeline-WNUPRRKW.js.br +0 -0
  141. package/build/runtime-timeline-WNUPRRKW.js.gz +0 -0
  142. package/build/{runtime-tracking-WYI7223D.js → runtime-tracking-HMTCBZ7J.js} +1 -1
  143. package/build/runtime-tracking-HMTCBZ7J.js.br +0 -0
  144. package/build/runtime-tracking-HMTCBZ7J.js.gz +0 -0
  145. package/build/{runtime-transitions-ISGRYHHG.js → runtime-transitions-NPD3CNKU.js} +1 -1
  146. package/build/runtime-transitions-NPD3CNKU.js.br +0 -0
  147. package/build/runtime-transitions-NPD3CNKU.js.gz +0 -0
  148. package/build/{runtime-ui2d-K7CMSG7Q.js → runtime-ui2d-NZTQW5UJ.js} +1 -1
  149. package/build/runtime-ui2d-NZTQW5UJ.js.br +0 -0
  150. package/build/runtime-ui2d-NZTQW5UJ.js.gz +0 -0
  151. package/build/{runtime-vectorShapes-TE66F2C6.js → runtime-vectorShapes-26IDV3ZL.js} +1 -1
  152. package/build/runtime-vectorShapes-26IDV3ZL.js.br +0 -0
  153. package/build/runtime-vectorShapes-26IDV3ZL.js.gz +0 -0
  154. package/build/{runtime-webgpu-JHHLEDVG.js → runtime-webgpu-CDBERG7X.js} +1 -1
  155. package/build/runtime-webgpu-CDBERG7X.js.br +0 -0
  156. package/build/runtime-webgpu-CDBERG7X.js.gz +0 -0
  157. package/build/runtime.cjs +5 -5
  158. package/build/runtime.js +1 -1
  159. package/build/runtime.js.br +0 -0
  160. package/build/runtime.js.gz +0 -0
  161. package/build/runtime.standalone.js +1 -1
  162. package/build/runtime.standalone.js.br +0 -0
  163. package/build/runtime.standalone.js.gz +0 -0
  164. package/build/runtime.standalone.webgl.js +1 -1
  165. package/build/runtime.standalone.webgl.js.br +0 -0
  166. package/build/runtime.standalone.webgl.js.gz +0 -0
  167. package/build/runtime.standalone.webgpu.js +1 -1
  168. package/build/runtime.standalone.webgpu.js.br +0 -0
  169. package/build/runtime.standalone.webgpu.js.gz +0 -0
  170. package/build/runtime.standalone.webgpu.micro.js +1 -1
  171. package/build/runtime.standalone.webgpu.micro.js.br +0 -0
  172. package/build/runtime.standalone.webgpu.micro.js.gz +0 -0
  173. package/build/runtime.standalone.webgpu.min.js +1 -1
  174. package/build/runtime.standalone.webgpu.min.js.br +0 -0
  175. package/build/runtime.standalone.webgpu.min.js.gz +0 -0
  176. package/build/snippets/hana-82e9eb82a79dead4/js-imports.js +204 -77
  177. package/package.json +1 -1
  178. package/build/runtime-chunk-2SOMTXZZ.js +0 -1
  179. package/build/runtime-chunk-2SOMTXZZ.js.br +0 -0
  180. package/build/runtime-chunk-2SOMTXZZ.js.gz +0 -0
  181. package/build/runtime-chunk-33KX2TOT.js.br +0 -0
  182. package/build/runtime-chunk-33KX2TOT.js.gz +0 -0
  183. package/build/runtime-chunk-3D6ELLRB.js.br +0 -0
  184. package/build/runtime-chunk-3D6ELLRB.js.gz +0 -0
  185. package/build/runtime-chunk-44F5FA4N.js.br +0 -0
  186. package/build/runtime-chunk-44F5FA4N.js.gz +0 -0
  187. package/build/runtime-chunk-4FRVTTCF.js.br +0 -0
  188. package/build/runtime-chunk-4FRVTTCF.js.gz +0 -0
  189. package/build/runtime-chunk-5MDYMRYM.js.br +0 -0
  190. package/build/runtime-chunk-5MDYMRYM.js.gz +0 -0
  191. package/build/runtime-chunk-5RKK7JBF.js.br +0 -0
  192. package/build/runtime-chunk-5RKK7JBF.js.gz +0 -0
  193. package/build/runtime-chunk-CUH4PXNR.js.br +0 -0
  194. package/build/runtime-chunk-CUH4PXNR.js.gz +0 -0
  195. package/build/runtime-chunk-CXBK7LPG.js.br +0 -0
  196. package/build/runtime-chunk-CXBK7LPG.js.gz +0 -0
  197. package/build/runtime-chunk-EPFYNTQQ.js.br +0 -0
  198. package/build/runtime-chunk-EPFYNTQQ.js.gz +0 -0
  199. package/build/runtime-chunk-FJZAL2GU.js.br +0 -0
  200. package/build/runtime-chunk-FJZAL2GU.js.gz +0 -0
  201. package/build/runtime-chunk-HRGNIGSC.js +0 -1
  202. package/build/runtime-chunk-HRGNIGSC.js.br +0 -0
  203. package/build/runtime-chunk-HRGNIGSC.js.gz +0 -0
  204. package/build/runtime-chunk-KJLTN6RE.js.br +0 -0
  205. package/build/runtime-chunk-KJLTN6RE.js.gz +0 -0
  206. package/build/runtime-chunk-KRQKRJPD.js.br +0 -0
  207. package/build/runtime-chunk-KRQKRJPD.js.gz +0 -0
  208. package/build/runtime-chunk-LVFNCYIC.js.br +0 -0
  209. package/build/runtime-chunk-LVFNCYIC.js.gz +0 -0
  210. package/build/runtime-chunk-R3V4RB3X.js.br +0 -0
  211. package/build/runtime-chunk-R3V4RB3X.js.gz +0 -0
  212. package/build/runtime-chunk-ROGQC3YL.js.br +0 -0
  213. package/build/runtime-chunk-ROGQC3YL.js.gz +0 -0
  214. package/build/runtime-chunk-RYIFGI7L.js.br +0 -0
  215. package/build/runtime-chunk-RYIFGI7L.js.gz +0 -0
  216. package/build/runtime-chunk-SOL2NZB4.js.br +0 -0
  217. package/build/runtime-chunk-SOL2NZB4.js.gz +0 -0
  218. package/build/runtime-chunk-U7JVP2TI.js.br +0 -0
  219. package/build/runtime-chunk-U7JVP2TI.js.gz +0 -0
  220. package/build/runtime-chunk-UFFTT5MI.js.br +0 -0
  221. package/build/runtime-chunk-UFFTT5MI.js.gz +0 -0
  222. package/build/runtime-chunk-VJPN4EM6.js.br +0 -0
  223. package/build/runtime-chunk-VJPN4EM6.js.gz +0 -0
  224. package/build/runtime-chunk-WFTAZCXD.js.br +0 -0
  225. package/build/runtime-chunk-WFTAZCXD.js.gz +0 -0
  226. package/build/runtime-chunk-YANJNJO2.js.br +0 -0
  227. package/build/runtime-chunk-YANJNJO2.js.gz +0 -0
  228. package/build/runtime-chunk-YNTJMLA5.js.br +0 -0
  229. package/build/runtime-chunk-YNTJMLA5.js.gz +0 -0
  230. package/build/runtime-chunk-ZTHLLGVX.js.gz +0 -0
  231. package/build/runtime-classicRuntime-7YZ7NLMG.js.br +0 -0
  232. package/build/runtime-classicRuntime-7YZ7NLMG.js.gz +0 -0
  233. package/build/runtime-cloners-H554LSFU.js.br +0 -0
  234. package/build/runtime-cloners-H554LSFU.js.gz +0 -0
  235. package/build/runtime-components-ZCELGDQ5.js.br +0 -0
  236. package/build/runtime-components-ZCELGDQ5.js.gz +0 -0
  237. package/build/runtime-createDestroy-FK2ZKK66.js.br +0 -0
  238. package/build/runtime-createDestroy-FK2ZKK66.js.gz +0 -0
  239. package/build/runtime-dragDrop-E4OSDFGY.js.br +0 -0
  240. package/build/runtime-dragDrop-E4OSDFGY.js.gz +0 -0
  241. package/build/runtime-gameControls-A3BST7FA.js.br +0 -0
  242. package/build/runtime-gameControls-A3BST7FA.js.gz +0 -0
  243. package/build/runtime-hair-W5WKY4OE.js.br +0 -2
  244. package/build/runtime-hair-W5WKY4OE.js.gz +0 -0
  245. package/build/runtime-mergeStaticGeometries-5FS3LGQQ.js.br +0 -0
  246. package/build/runtime-mergeStaticGeometries-5FS3LGQQ.js.gz +0 -0
  247. package/build/runtime-miscActions-F72HQZ5I.js.br +0 -0
  248. package/build/runtime-miscActions-F72HQZ5I.js.gz +0 -0
  249. package/build/runtime-mouseHover-44D2CVLI.js.br +0 -0
  250. package/build/runtime-mouseHover-44D2CVLI.js.gz +0 -0
  251. package/build/runtime-particles-5BBDNO44.js.br +0 -0
  252. package/build/runtime-particles-5BBDNO44.js.gz +0 -0
  253. package/build/runtime-paths-YF5SB3I3.js.br +0 -0
  254. package/build/runtime-paths-YF5SB3I3.js.gz +0 -0
  255. package/build/runtime-resize-ZORLCUGS.js.br +0 -0
  256. package/build/runtime-resize-ZORLCUGS.js.gz +0 -0
  257. package/build/runtime-sceneTransition-EEJJDLOW.js.br +0 -0
  258. package/build/runtime-sceneTransition-EEJJDLOW.js.gz +0 -0
  259. package/build/runtime-scroll-HSHQUB6P.js.br +0 -0
  260. package/build/runtime-scroll-HSHQUB6P.js.gz +0 -0
  261. package/build/runtime-shapeBlends-5ND6NZVA.js +0 -1
  262. package/build/runtime-shapeBlends-5ND6NZVA.js.br +0 -3
  263. package/build/runtime-shapeBlends-5ND6NZVA.js.gz +0 -0
  264. package/build/runtime-text-UGIMBR6B.js.br +0 -0
  265. package/build/runtime-text-UGIMBR6B.js.gz +0 -0
  266. package/build/runtime-textInputs-HE2LSUKB.js.br +0 -0
  267. package/build/runtime-textInputs-HE2LSUKB.js.gz +0 -0
  268. package/build/runtime-timeline-ZY2DQMB7.js +0 -1
  269. package/build/runtime-timeline-ZY2DQMB7.js.br +0 -0
  270. package/build/runtime-timeline-ZY2DQMB7.js.gz +0 -0
  271. package/build/runtime-tracking-WYI7223D.js.br +0 -0
  272. package/build/runtime-tracking-WYI7223D.js.gz +0 -0
  273. package/build/runtime-transitions-ISGRYHHG.js.br +0 -0
  274. package/build/runtime-transitions-ISGRYHHG.js.gz +0 -0
  275. package/build/runtime-ui2d-K7CMSG7Q.js.br +0 -0
  276. package/build/runtime-ui2d-K7CMSG7Q.js.gz +0 -0
  277. package/build/runtime-vectorShapes-TE66F2C6.js.br +0 -0
  278. package/build/runtime-vectorShapes-TE66F2C6.js.gz +0 -0
  279. package/build/runtime-webgpu-JHHLEDVG.js.br +0 -0
  280. package/build/runtime-webgpu-JHHLEDVG.js.gz +0 -0
@@ -1 +1 @@
1
- import{a as e,b as t,d as n}from"./runtime-chunk-SOL2NZB4.js";import{b as i}from"./runtime-chunk-CVUJ3GMH.js";import{c as a}from"./runtime-chunk-GFTBNL2W.js";import{e as r,f as o}from"./runtime-chunk-LVFNCYIC.js";import"./runtime-chunk-5MDYMRYM.js";import"./runtime-chunk-4FRVTTCF.js";import"./runtime-chunk-CUH4PXNR.js";import"./runtime-chunk-VJPN4EM6.js";import"./runtime-chunk-33KX2TOT.js";import"./runtime-chunk-TU4KDRKR.js";import"./runtime-chunk-WFTAZCXD.js";import{c as s}from"./runtime-chunk-FQNSP44B.js";import{a as l}from"./runtime-chunk-44F5FA4N.js";import"./runtime-chunk-EPFYNTQQ.js";import"./runtime-chunk-KRQKRJPD.js";import"./runtime-chunk-YANJNJO2.js";import"./runtime-chunk-CXBK7LPG.js";import"./runtime-chunk-FJZAL2GU.js";import{M as c,P as d,S as u,U as f,V as p,W as h,X as m,Y as v,Z as g,_,d as x,e as S,h as T,i as b,m as w}from"./runtime-chunk-3D6ELLRB.js";import"./runtime-chunk-4YV3EXSU.js";import"./runtime-chunk-NSD7DU3P.js";import{v as E}from"./runtime-chunk-R3V4RB3X.js";import"./runtime-chunk-2PT2WH66.js";import"./runtime-chunk-4KZXQGUQ.js";import"./runtime-chunk-U4QOT2PX.js";import"./runtime-chunk-TZCHGFVF.js";import{W as M,ea as y,fa as C,qa as R,sa as A,ta as P,x as D}from"./runtime-chunk-VPEJ5BFD.js";import{a as L,b as U,c as N,d as I,e as O,f as F,g as z,h as B,i as V,j as H,k as G,l as k,m as W,n as X}from"./runtime-chunk-OFPUAZKY.js";import{b as j,c as $,f as q}from"./runtime-chunk-EOV2DL2V.js";import"./runtime-chunk-Y3BMDVJ7.js";import{$ as Y,$a as K,$c as Z,$d as J,A as Q,Aa as ee,Ac as te,Ad as ne,Ae as ie,B as ae,Ba as re,Bc as oe,C as se,Ca as le,Cc as ce,Cd as de,D as ue,Da as fe,Dc as pe,Dd as he,E as me,Ea as ve,Ed as ge,F as _e,Fa as xe,Fb as Se,Fc as Te,G as be,Ga as we,Gb as Ee,Gc as Me,H as ye,Ha as Ce,Hb as Re,Hc as Ae,I as Pe,Ia as De,Ib as Le,Ic as Ue,J as Ne,Ja as Ie,Jb as Oe,Jc as Fe,Je as ze,K as Be,Ka as Ve,Kb as He,L as Ge,La as ke,Lb as We,Lc as Xe,Le as je,M as $e,Ma as qe,Mc as Ye,N as Ke,Na as Ze,Nc as Je,O as Qe,Oa as et,Oc as tt,P as nt,Pa as it,Q as at,Qc as rt,R as ot,Ra as st,S as lt,Sa as ct,T as dt,Ta as ut,Tc as ft,U as pt,Ua as ht,V as mt,Va as vt,Vc as gt,Vd as _t,W as xt,Wa as St,X as Tt,Xa as bt,Y as wt,Ya as Et,Ye as Mt,Z as yt,Za as Ct,Zc as Rt,Zd as At,_ as Pt,_a as Dt,_c as Lt,_d as Ut,a as Nt,aa as It,ab as Ot,ae as Ft,ba as zt,bb as Bt,bd as Vt,be as Ht,c as Gt,ca as kt,cb as Wt,ce as Xt,d as jt,da as $t,db as qt,dc as Yt,dd as Kt,de as Zt,e as Jt,eb as Qt,ec as en,f as tn,fa as nn,fb as an,fc as rn,g as on,ga as sn,gb as ln,gc as cn,h as dn,ha as un,hb as fn,hc as pn,i as hn,ia as mn,ib as vn,ic as gn,j as _n,ja as xn,jb as Sn,jc as Tn,k as bn,ka as wn,kb as En,kc as Mn,ke as yn,l as Cn,la as Rn,lb as An,ld as Pn,le as Dn,m as Ln,ma as Un,mb as Nn,n as In,na as On,nb as Fn,nc as zn,nd as Bn,o as Vn,oa as Hn,ob as Gn,oc as kn,p as Wn,pa as Xn,pb as jn,q as $n,qa as qn,qb as Yn,r as Kn,ra as Zn,rb as Jn,rd as Qn,sa as ei,sb as ti,sd as ni,t as ii,tb as ai,tc as ri,u as oi,ua as si,ub as li,uc as ci,v as di,va as ui,vb as fi,vc as pi,w as hi,wa as mi,wb as vi,wc as gi,x as _i,xa as xi,xb as Si,xc as Ti,y as bi,ya as wi,yb as Ei,yc as Mi,z as yi,za as Ci,zb as Ri,zc as Ai}from"./runtime-chunk-VGN7YHB7.js";import"./runtime-chunk-ML3Z74BL.js";var Pi=class{constructor(e){if(this.hashProperties=void 0,this.isNode=!0,this.shortcuts={},null===Pi.uuidContext)throw new Error("plz startContext");Pi.uuidContext===Pi.globalContext?this.uuid="_gid"+Pi.uuidContext.nodeContextUuid++:this.uuid="_uid"+Pi.uuidContext.nodeContextUuid++,this.type=e,this.name=""}static startContext(e){null===this.uuidContext||this.uuidContext===Pi.globalContext?this.uuidContext=e:console.error("Can't start context twice")}static endContext(e){this.uuidContext!==e&&console.error("Can't end context twice"),this.uuidContext=null}analyze(e,t){t=t??{},e.analyzing=!0,this.build(e.addFlow(t.slot,t.cache,t.context),"v4"),e.clearVertexNodeCode(),e.clearFragmentNodeCode(),e.removeFlow(),e.analyzing=!1}analyzeAndFlow(e,t,n){return n=n??{},this.analyze(e,n),this.flow(e,t,n)}flow(e,t,n){n=n??{},e.addFlow(n.slot,n.cache,n.context);let i={result:this.build(e,t),code:e.clearNodeCode(),extra:e.context.extra};return e.removeFlow(),i}build(e,t,n){t=t??this.getType(e,t);let i=e.getNodeData(n??this);return e.analyzing&&this.appendDepsNode(e,i,t),-1===e.nodes.indexOf(this)&&e.nodes.push(this),void 0!==this.updateFrame&&-1===e.updaters.indexOf(this)&&e.updaters.push(this),this.generate(e,t,n)}updateFrame(e){}generateReadonly(e,t,n,i,a,r){return""}generate(e,t,n,i,a){return""}parse(e,t,n,i){}appendDepsNode(e,t,n){t.deps=(t.deps||0)+1;let i=e.getTypeLength(n);(i>(t.outputMax||0)||this.getType(e,n))&&(t.outputMax=i,t.output=n)}setName(e){this.name=e}getName(){return this.name}getType(e,t){return"sampler2D"===t||"samplerCube"===t?t:this.type}},Di=Pi;Di.globalContext={nodeContextUuid:0},Di.uuidContext=Pi.globalContext;var Li=3e3,Ui=3001,Ni=class{constructor(e){e=e??{},this.name=e.name,this.type=e.type,this.node=e.node,this.size=e.size,this.needsUpdate=e.needsUpdate}get value(){return this.node.value}set value(e){this.node.value=e}},Ii=new class{constructor(){this.nodes={},this.keywords={}}add(e){this.nodes[e.name]=e}addKeyword(e,t,n){n=void 0===n||n,this.keywords[e]={callback:t,cache:n}}remove(e){delete this.nodes[e.name]}removeKeyword(e){delete this.keywords[e]}get(e){return this.nodes[e]}getKeyword(e,t){return this.keywords[e].callback(t)}getKeywordData(e){return this.keywords[e]}contains(e){return void 0!==this.nodes[e]}containsKeyword(e){return void 0!==this.keywords[e]}},Oi=class extends Di{constructor(e,t){super(e),this.scope="",t=t??{},this.shared=void 0===t.shared||t.shared,this.unique=void 0!==t.unique&&t.unique}build(e,t,n,i){if(t=t??this.getType(e),this.getShared(e,t)){let a=this.getUnique(e,t);a&&void 0===this.uuid&&(this.uuid=ce.generateUUID()),n=e.getUUID(n??this.getUUID(),!a);let r=e.getNodeData(n),o=r.output||this.getType(e);if(e.analyzing)return(r.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,r,t),this.generate(e,t,n)):super.build(e,t,n);if(a)return r.name=r.name||super.build(e,t,n),r.name;if(!this.getLabel()&&(!this.getShared(e,o)||e.context.ignoreCache||1===r.deps))return super.build(e,t,n);n=this.getUUID(!1);let s=this.getTemp(e,n);if(s)return e.format(s,o,t);{s=super.generate(e,t,n,r.output,i);let a=this.generate(e,o,n);return e.addNodeCode(s+" = "+a+";"),e.format(s,o,t)}}return super.build(e,t,n)}getShared(e,t){return"sampler2D"!==t&&"samplerCube"!==t&&this.shared}getUnique(e,t){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let t=this.uuid;return"string"==typeof this.scope&&(t=this.scope+"-"+t),t}getTemp(e,t){t=t||this.uuid;let n=e.getVars()[t];return n?n.name:void 0}generate(e,t,n,i,a){return this.getShared(e,t)||console.error("TempNode is not shared"),n=n??this.uuid,e.getTempVar(n,i??this.getType(e),a,this.getLabel()).name}},Fi=class extends Oi{constructor(e,t){(t=t??{}).shared=void 0!==t.shared&&t.shared,super(e,t),this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,t,n,i,a,r){n=e.getUUID(n??this.getUUID()),i=i??this.getType(e);let o=e.getNodeData(n);return this.getReadonly()&&void 0!==this.generateReadonly?this.generateReadonly(e,t,n,i,a,r):e.isShader("vertex")?(o.vertex||(o.vertex=e.createVertexUniform(i,this,a,r,this.getLabel())),e.format(o.vertex.name,i,t)):(o.fragment||(o.fragment=e.createFragmentUniform(i,this,a,r,this.getLabel())),e.format(o.fragment.name,i,t))}},zi=class extends Fi{constructor(e=0,t){super("v2"),this.nodeType="Vector2",this.value=e instanceof pe?e:new pe(e,t)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,t,n,i,a,r){return e.format("vec2("+this.value.x+", "+this.value.y+")",i,t)}},Bi=class extends Fi{constructor(e=0,t,n){super("v3"),this.nodeType="Vector3",this.value=e instanceof Te?e:new Te(e,t,n)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,t,n,i,a,r){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",i,t)}},Vi=class extends Fi{constructor(e){super("v4"),this.nodeType="Vector4",this.value=e instanceof T?e:new T(e.r,e.g,e.b,e.a)}generateReadonly(e,t,n,i,a,r){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",i,t)}},Hi=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,Gi=/[a-z_0-9]+/gi,ki=class extends Oi{constructor(e,t,n,i,a){super(a),this.src="",this.nodeType="Function",this.useKeywords=!0,this.includes=[],this.extensions={},this.keywords={},this.isMethod=void 0===a,this.isInterface=!1,this.parse(e,t,n,i)}getShared(e,t){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}}getIncludeByName(e){if(this.includes){let t=this.includes.length;for(;t--;)if(this.includes[t].name===e)return this.includes[t]}}generate(e,t,n,i,a){let r,o=0,s=this.src;if(this.includes)for(let t=0;t<this.includes.length;t++)e.include(this.includes[t],this);for(let t in this.extensions)e.extensions[t]=!0;let l=[];for(;r=Gi.exec(this.src);)l.push(r);for(let t=0;t<l.length;t++){let n=l[t],i=n[0],a=!this.isMethod||!this.getInputByName(i),r=i;if(this.keywords[i]||this.useKeywords&&a&&Ii.containsKeyword(i)){let t=this.keywords[i];if(!t){let n=Ii.getKeywordData(i);n.cache&&(t=e.keywords[i]),t=t||Ii.getKeyword(i,e),n.cache&&(e.keywords[i]=t)}r=t.build(e)}i!==r&&"."!==s[n.index+o-1]&&(s=s.substring(0,n.index+o)+r+s.substring(n.index+i.length+o),o+=r.length-i.length),void 0===this.getIncludeByName(r)&&Ii.contains(r)&&e.include(Ii.get(r))}return"source"===t?s:this.isMethod?(this.isInterface||e.include(this,void 0,s),this.name):e.format("( "+s+" )",this.getType(e),t)}parse(e,t,n,i){if(this.src=e||"",this.includes=t??[],this.extensions=n??{},this.keywords=i??{},this.isMethod){let e=Hi.exec(this.src);if(this.inputs=[],e&&4==e.length){this.type=e[1],this.name=e[2];let t=e[3].match(Gi);if(t){let e=0;for(;e<t.length;){let n,i=t[e++];"in"===i||"out"===i||"inout"===i?n=t[e++]:(n=i,i="");let a=t[e++];this.inputs.push({name:a,type:n,qualifier:i})}}this.isInterface=-1===this.src.indexOf("{")}else this.type="",this.name=""}}},Wi=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?=?\s?(.*?)(;|$)/i,Xi=class extends Oi{constructor(e="",t){super(),this.src="",this.useDefine=!1,this.nodeType="Const",this.parse(e||Xi.PI,void 0,void 0,void 0,t)}getType(e){return e.getTypeByFormat(this.type)}parse(e,t,n,i,a){this.src=e||"";let r,o,s="",l=Wi.exec(e);this.useDefine=a??"#"===this.src.charAt(0),l&&l.length>1?(o=l[1],r=l[2],s=l[3]):(r=this.src,o="f"),this.name=r,this.type=o,this.value=s}build(e,t){if("source"===t){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),t)}generate(e,t,n,i,a){return e.format(this.name,this.getType(e),t)}},ji=Xi;ji.PI="PI",ji.PI2="PI2",ji.RECIPROCAL_PI="RECIPROCAL_PI",ji.RECIPROCAL_PI2="RECIPROCAL_PI2",ji.LOG2="LOG2",ji.EPSILON="EPSILON";var $i=new RegExp("^structs*([a-z_0-9]+)s*{s*((.|\n)*?)}","gim"),qi=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),Yi=class extends Oi{constructor(e=""){super(),this.inputs=[],this.src="",this.nodeType="Struct",this.parse(e)}getType(e){return e.getTypeByFormat(this.name)}getInputByName(e){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}generate(e,t,n,i,a){return"source"===t?this.src+";":e.format("( "+this.src+" )",this.getType(e),t)}parse(e=""){this.src=e,this.inputs=[];let t=$i.exec(e);if(t){let e,n=t[2];for(;e=qi.exec(n);)this.inputs.push({type:e[1],name:e[2]});this.name=t[1]}else this.name="";this.type=this.name}},Ki=class extends Oi{constructor(e){super("v2",{shared:!1}),this.nodeType="UV",this.index=e??0}generate(e,t){e.requires.uv[this.index]=!0;let n=this.index>0?this.index+1:"",i=e.isShader("vertex")?"uv"+n:"vUv"+n;return e.format(i,this.getType(e),t)}};Ii.addKeyword("uv",function(){return new Ki}),Ii.addKeyword("uv2",function(){return new Ki(1)});var Zi=class extends Oi{constructor(e,t){super("v4"),this.nodeType="ColorSpace",this.input=e,this.method=t??Zi.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case Li:return["Linear"];case Ui:return["sRGB"];default:return[]}}generate(e,t){let n=this.input.build(e,"v4"),i=this.getType(e),a=Zi.Nodes[this.method],r=e.include(a);if(r===Zi.LINEAR_TO_LINEAR)return e.format(n,i,t);if(2===a.inputs?.length){let a=this.factor.build(e,"f");return e.format(r+"( "+n+", "+a+" )",i,t)}return e.format(r+"( "+n+" )",i,t)}fromEncoding(e){let t=Zi.getEncodingComponents(e);this.method="LinearTo"+t[0],this.factor=t[1]}fromDecoding(e){let t=Zi.getEncodingComponents(e);this.method=t[0]+"ToLinear",this.factor=t[1]}},Ji=Zi;Ji.Nodes={LinearToLinear:new ki(["vec4 LinearToLinear( in vec4 value ) {","\treturn value;","}"].join("\n")),sRGBToLinear:new ki(["vec4 sRGBToLinear( in vec4 value ) {","\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );","}"].join("\n")),LinearTosRGB:new ki(["vec4 LinearTosRGB( in vec4 value ) {","\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );","}"].join("\n"))},Ji.LINEAR_TO_LINEAR="LinearToLinear",Ji.SRGB_TO_LINEAR="sRGBToLinear",Ji.LINEAR_TO_SRGB="LinearTosRGB";var Qi=class extends ki{constructor(e="",t,n,i,a){super(e,a,i,n,t),this.nodeType="Expression"}},ea=class extends Fi{constructor(e=new Ue,t,n,i){super("v4",{shared:!0}),this.nodeType="Texture",this.value=e,this.uv=t??new Ki,this.bias=n,this.project=void 0!==i&&i}getTexture(e,t){return super.generate(e,t,this.value.uuid,"t")}generate(e,t){if("sampler2D"===t)return this.getTexture(e,t);let n,i,a=this.getTexture(e,t),r=this.uv.build(e,this.project?"v4":"v2"),o=this.bias?this.bias.build(e,"f"):void 0;void 0===o&&e.context.bias&&(o=e.context.bias.setTexture(this).build(e,"f")),n=this.project?"texture2DProj":o?"tex2DBias":"tex2D",i=o?n+"( "+a+", "+r+", "+o+" )":n+"( "+a+", "+r+" )";let s={include:e.isShader("vertex"),ignoreCache:!0},l=this.getType(e);return e.addContext(s),this.colorSpace=this.colorSpace??new Ji(new Qi("",l)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(i),i=this.colorSpace.build(e,l),e.removeContext(),e.format(i,l,t)}},ta=class extends Fi{constructor(e){super("f"),this.nodeType="Float",this.value=e??0}generateReadonly(e,t,n,i,a,r){return e.format(this.value+(this.value%1?"":".0"),i,t)}},na=class extends Oi{constructor(e,t){super(),this.inputs=[],this.nodeType="FunctionCall",this.value=e,this.inputs=t??[]}getFunction(){return this.value}getType(e){return this.value.getType(e)}generate(e,t,n,i,a){i=this.getType(e);let r=this.value,o=r.build(e,t)+"( ",s=[];if(r.inputs){for(let t=0;t<r.inputs.length;t++){let n=r.inputs[t],i=this.inputs[t]||this.inputs[n.name];s.push(i.build(e,e.getTypeByFormat(n.type)))}o+=s.join(", ")+" )"}return e.format(o,i,t)}},ia=class extends Oi{constructor(e,t,n=ia.ADD){super(),this.nodeType="Operator",this.type=e.type,this.a=e,this.b=t,this.op=n}getType(e){let t=this.a.getType(e),n=this.b.getType(e);return e.isTypeMatrix(t)?"v4":e.getTypeLength(n)>e.getTypeLength(t)?n:t}generate(e,t){let n=this.getType(e);this.type=n;let i=this.a.build(e,n),a=this.b.build(e,n);return e.format("( "+i+" "+this.op+" "+a+" )",n,t)}},aa=ia;aa.ADD="+",aa.SUB="-",aa.MUL="*",aa.DIV="/";var ra=class extends Oi{constructor(e,t=ra.ABS,n,i){super(),this.nodeType="Math",this.a=e,"string"!=typeof t?this.b=t:i=t,"string"!=typeof n?this.c=n:i=n,this.method=i,this.hashProperties=["method"]}getNumInputs(e){switch(this.method){case ra.MIX:case ra.CLAMP:case ra.REFRACT:case ra.SMOOTHSTEP:case ra.FACEFORWARD:return 3;case ra.MIN:case ra.MAX:case ra.MOD:case ra.STEP:case ra.REFLECT:case ra.DISTANCE:case ra.DOT:case ra.CROSS:case ra.POW:return 2;default:return 1}}getInputType(e){let t=e.getTypeLength(this.a.getType(e)),n=this.b?e.getTypeLength(this.b.getType(e)):0,i=this.c?e.getTypeLength(this.c.getType(e)):0;return t>n&&t>i?this.a.getType(e):n>i?this.b.getType(e):this.c.getType(e)}getType(e){switch(this.method){case ra.LENGTH:case ra.DISTANCE:case ra.DOT:return"f";case ra.CROSS:return"v3"}return this.getInputType(e)}generate(e,t){let n,i,a,r=this.a?e.getTypeLength(this.a.getType(e)):0,o=this.b?e.getTypeLength(this.b.getType(e)):0,s=this.c?e.getTypeLength(this.c.getType(e)):0,l=this.getInputType(e),c=this.getType(e);switch(this.type=c,this.method){case ra.NEGATE:return e.format("( -"+this.a.build(e,l)+" )",l,t);case ra.INVERT:return e.format("( 1.0 - "+this.a.build(e,l)+" )",l,t);case ra.CROSS:n=this.a.build(e,"v3"),i=this.b.build(e,"v3");break;case ra.STEP:n=this.a.build(e,1===r?"f":l),i=this.b.build(e,l);break;case ra.MIN:case ra.MAX:case ra.MOD:n=this.a.build(e,l),i=this.b.build(e,1===o?"f":l);break;case ra.REFRACT:n=this.a.build(e,l),i=this.b.build(e,l),a=this.c.build(e,"f");break;case ra.MIX:n=this.a.build(e,l),i=this.b.build(e,l),a=this.c.build(e,1===s?"f":l);break;default:n=this.a.build(e,l),this.b&&(i=this.b.build(e,l)),this.c&&(a=this.c.build(e,l))}let d=[];d.push(n),i&&d.push(i),a&&d.push(a);let u=this.getNumInputs(e);if(d.length!==u)throw Error(`Arguments not match used in "${this.method}". Require ${u}, currently ${d.length}.`);return e.format(this.method+"( "+d.join(", ")+" )",c,t)}},oa=ra;oa.RAD="radians",oa.DEG="degrees",oa.EXP="exp",oa.EXP2="exp2",oa.LOG="log",oa.LOG2="log2",oa.SQRT="sqrt",oa.INV_SQRT="inversesqrt",oa.FLOOR="floor",oa.CEIL="ceil",oa.NORMALIZE="normalize",oa.FRACT="fract",oa.SATURATE="saturate",oa.SIN="sin",oa.COS="cos",oa.TAN="tan",oa.ASIN="asin",oa.ACOS="acos",oa.ARCTAN="atan",oa.ABS="abs",oa.SIGN="sign",oa.LENGTH="length",oa.NEGATE="negate",oa.INVERT="invert",oa.MIN="min",oa.MAX="max",oa.MOD="mod",oa.STEP="step",oa.REFLECT="reflect",oa.DISTANCE="distance",oa.DOT="dot",oa.CROSS="cross",oa.POW="pow",oa.MIX="mix",oa.CLAMP="clamp",oa.REFRACT="refract",oa.SMOOTHSTEP="smoothstep",oa.FACEFORWARD="faceforward";var sa=class extends Oi{constructor(e,t,n){super("v4"),this.nodeType="TextureCubeUV",this.value=e,this.uv=t,this.bias=n}bilinearCubeUV(e,t,n,i){let a=new na(sa.Nodes.bilinearCubeUV,[t,n,i]);this.colorSpaceTL=this.colorSpaceTL??new Ji(new Qi("","v4")),this.colorSpaceTL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTL.input.parse(a.build(e)+".tl"),this.colorSpaceTR=this.colorSpaceTR??new Ji(new Qi("","v4")),this.colorSpaceTR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTR.input.parse(a.build(e)+".tr"),this.colorSpaceBL=this.colorSpaceBL??new Ji(new Qi("","v4")),this.colorSpaceBL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBL.input.parse(a.build(e)+".bl"),this.colorSpaceBR=this.colorSpaceBR??new Ji(new Qi("","v4")),this.colorSpaceBR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBR.input.parse(a.build(e)+".br");let r={include:e.isShader("vertex"),ignoreCache:!0};e.addContext(r),this.colorSpaceTLExp=new Qi(this.colorSpaceTL.build(e,"v4"),"v4"),this.colorSpaceTRExp=new Qi(this.colorSpaceTR.build(e,"v4"),"v4"),this.colorSpaceBLExp=new Qi(this.colorSpaceBL.build(e,"v4"),"v4"),this.colorSpaceBRExp=new Qi(this.colorSpaceBR.build(e,"v4"),"v4"),e.removeContext();let o=new Qi("mix( mix( cubeUV_TL, cubeUV_TR, cubeUV.f.x ), mix( cubeUV_BL, cubeUV_BR, cubeUV.f.x ), cubeUV.f.y )","v4");return o.keywords.cubeUV_TL=this.colorSpaceTLExp,o.keywords.cubeUV_TR=this.colorSpaceTRExp,o.keywords.cubeUV_BL=this.colorSpaceBLExp,o.keywords.cubeUV_BR=this.colorSpaceBRExp,o.keywords.cubeUV=a,o}generate(e,t){if(e.isShader("fragment")){let n=this.uv,i=this.bias||e.context.roughness,a=new na(sa.Nodes.roughnessToMip,[i]),r=new oa(a,sa.Nodes.m0,sa.Nodes.cubeUV_maxMipLevel,oa.CLAMP),o=new oa(r,oa.FLOOR),s=new oa(r,oa.FRACT),l=this.bilinearCubeUV(e,this.value,n,o),c=this.bilinearCubeUV(e,this.value,n,new aa(o,new ta(1).setReadonly(!0),aa.ADD)),d=new oa(l,c,s,oa.MIX);return e.format(d.build(e),"v4",t)}return console.warn("TextureCubeUVNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),t)}},la=sa;la.Nodes=function(){let e=new Yi("struct TextureCubeUVData {\n\t\t\tvec4 tl;\n\t\t\tvec4 tr;\n\t\t\tvec4 br;\n\t\t\tvec4 bl;\n\t\t\tvec2 f;\n\t\t}"),t=new ji("float cubeUV_maxMipLevel 8.0",!0),n=new ji("float cubeUV_minMipLevel 4.0",!0),i=new ji("float cubeUV_maxTileSize 256.0",!0),a=new ji("float cubeUV_minTileSize 16.0",!0),r=new ki("float getFace(vec3 direction) {\n\t\t\t\tvec3 absDirection = abs(direction);\n\t\t\t\tfloat face = -1.0;\n\t\t\t\tif (absDirection.x > absDirection.z) {\n\t\t\t\t\tif (absDirection.x > absDirection.y)\n\t\t\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\t\t\telse\n\t\t\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t\t\t} else {\n\t\t\t\t\tif (absDirection.z > absDirection.y)\n\t\t\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\t\t\telse\n\t\t\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t\t\t}\n\t\t\t\treturn face;\n\t\t}");r.useKeywords=!1;let o=new ki("vec2 getUV(vec3 direction, float face) {\n\t\t\t\tvec2 uv;\n\t\t\t\tif (face == 0.0) {\n\t\t\t\t\tuv = vec2(direction.z, direction.y) / abs(direction.x); \n\t\t\t\t} else if (face == 1.0) {\n\t\t\t\t\tuv = vec2(-direction.x, -direction.z) / abs(direction.y); \n\t\t\t\t} else if (face == 2.0) {\n\t\t\t\t\tuv = vec2(-direction.x, direction.y) / abs(direction.z); \n\t\t\t\t} else if (face == 3.0) {\n\t\t\t\t\tuv = vec2(-direction.z, direction.y) / abs(direction.x); \n\t\t\t\t} else if (face == 4.0) {\n\t\t\t\t\tuv = vec2(-direction.x, direction.z) / abs(direction.y); \n\t\t\t\t} else {\n\t\t\t\t\tuv = vec2(direction.x, direction.y) / abs(direction.z); \n\t\t\t\t}\n\t\t\t\treturn 0.5 * (uv + 1.0);\n\t\t}");o.useKeywords=!1;let s=new ki("TextureCubeUVData bilinearCubeUV(sampler2D envMap, vec3 direction, float mipInt) {\n\t\t\tfloat face = getFace(direction);\n\t\t\tfloat filterInt = max(cubeUV_minMipLevel - mipInt, 0.0);\n\t\t\tmipInt = max(mipInt, cubeUV_minMipLevel);\n\t\t\tfloat faceSize = exp2(mipInt);\n\t\t\tfloat texelSize = 1.0 / (3.0 * cubeUV_maxTileSize);\n\t\t\tvec2 uv = getUV(direction, face) * (faceSize - 1.0);\n\t\t\tvec2 f = fract(uv);\n\t\t\tuv += 0.5 - f;\n\t\t\tif (face > 2.0) {\n\t\t\t\tuv.y += faceSize;\n\t\t\t\tface -= 3.0;\n\t\t\t}\n\t\t\tuv.x += face * faceSize;\n\t\t\tif(mipInt < cubeUV_maxMipLevel){\n\t\t\t\tuv.y += 2.0 * cubeUV_maxTileSize;\n\t\t\t}\n\t\t\tuv.y += filterInt * 2.0 * cubeUV_minTileSize;\n\t\t\tuv.x += 3.0 * max(0.0, cubeUV_maxTileSize - 2.0 * faceSize);\n\t\t\tuv *= texelSize;\n\t\t\tvec4 tl = texture2D(envMap, uv);\n\t\t\tuv.x += texelSize;\n\t\t\tvec4 tr = texture2D(envMap, uv);\n\t\t\tuv.y += texelSize;\n\t\t\tvec4 br = texture2D(envMap, uv);\n\t\t\tuv.x -= texelSize;\n\t\t\tvec4 bl = texture2D(envMap, uv);\n\t\t\treturn TextureCubeUVData( tl, tr, br, bl, f );\n\t\t}",[e,r,o,t,n,i,a]);s.useKeywords=!1;let l=new ji("float r0 1.0",!0),c=new ji("float v0 0.339",!0),d=new ji("float m0 -2.0",!0),u=new ji("float r1 0.8",!0),f=new ji("float v1 0.276",!0),p=new ji("float m1 -1.0",!0),h=new ji("float r4 0.4",!0),m=new ji("float v4 0.046",!0),v=new ji("float m4 2.0",!0),g=new ji("float r5 0.305",!0),_=new ji("float v5 0.016",!0),x=new ji("float m5 3.0",!0),S=new ji("float r6 0.21",!0),T=new ji("float v6 0.0038",!0),b=new ji("float m6 4.0",!0);return{bilinearCubeUV:s,roughnessToMip:new ki("float roughnessToMip(float roughness) {\n\t\t\tfloat mip = 0.0;\n\t\t\tif (roughness >= r1) {\n\t\t\t\tmip = (r0 - roughness) * (m1 - m0) / (r0 - r1) + m0;\n\t\t\t} else if (roughness >= r4) {\n\t\t\t\tmip = (r1 - roughness) * (m4 - m1) / (r1 - r4) + m1;\n\t\t\t} else if (roughness >= r5) {\n\t\t\t\tmip = (r4 - roughness) * (m5 - m4) / (r4 - r5) + m4;\n\t\t\t} else if (roughness >= r6) {\n\t\t\t\tmip = (r5 - roughness) * (m6 - m5) / (r5 - r6) + m5;\n\t\t\t} else {\n\t\t\t\tmip = -2.0 * log2(1.16 * roughness);// 1.16 = 1.79^0.25\n\t\t\t}\n\t\t\treturn mip;\n\t\t}",[l,c,d,u,f,p,h,m,v,g,_,x,S,T,b]),m0:d,cubeUV_maxMipLevel:t}}();var ca=class extends Oi{constructor(e){super("v3"),this.nodeType="Normal",this.scope=e??ca.VIEW}getShared(){return this.scope===ca.WORLD}build(e,t,n,i){let a=e.context[this.scope+"Normal"];return a?a.build(e,t,n,i):super.build(e,t,n)}generate(e,t,n,i,a){let r;switch(this.scope){case ca.VIEW:r=e.isShader("vertex")?"transformedNormal":"geometryNormal";break;case ca.LOCAL:e.isShader("vertex")?r="objectNormal":(e.requires.normal=!0,r="vObjectNormal");break;case ca.WORLD:e.isShader("vertex")?r="inverseTransformDirection( transformedNormal, viewMatrix ).xyz":(e.requires.worldNormal=!0,r="vWNormal")}return e.format(r,this.getType(e),t)}},da=ca;da.LOCAL="local",da.WORLD="world",da.VIEW="view",da.NORMAL="normal",Ii.addKeyword("viewNormal",function(){return new da(da.VIEW)}),Ii.addKeyword("localNormal",function(){return new da(da.NORMAL)}),Ii.addKeyword("worldNormal",function(){return new da(da.WORLD)});var ua=class extends Oi{constructor(e){super("v3"),this.nodeType="Position",this.scope=e??ua.LOCAL}getType(){return this.scope===ua.PROJECTION?"v4":this.type}getShader(){switch(this.scope){case ua.LOCAL:case ua.WORLD:return!1}return!0}generate(e,t,n,i,a){let r;switch(this.scope){case ua.LOCAL:e.isShader("vertex")?r="transformed":(e.requires.position=!0,r="vPosition");break;case ua.WORLD:if(e.isShader("vertex"))return"( modelMatrix * vec4( transformed, 1.0 ) ).xyz";e.requires.worldPosition=!0,r="vWPosition";break;case ua.VIEW:r=e.isShader("vertex")?"-mvPosition.xyz":"vViewPosition";break;case ua.PROJECTION:r=e.isShader("vertex")?"( projectionMatrix * modelViewMatrix * vec4( position, 1.0 ) )":"vec4( 0.0 )"}return e.format(r,this.getType(),t)}},fa=ua;fa.LOCAL="local",fa.WORLD="world",fa.VIEW="view",fa.PROJECTION="projection",Ii.addKeyword("position",function(){return new fa}),Ii.addKeyword("worldPosition",function(){return new fa(fa.WORLD)}),Ii.addKeyword("viewPosition",function(){return new fa(fa.VIEW)});var pa=class extends Oi{constructor(e){super("v3"),this.nodeType="Reflect",this.scope=e??pa.CUBE}getUnique(e){return!e.context.viewNormal}getType(){return this.scope===pa.SPHERE?"v2":this.type}generate(e,t){let n=this.getUnique(e);if(e.isShader("fragment")){let i;switch(this.scope){case pa.VECTOR:{let t=new da(da.VIEW),a=e.context.roughness,r=t.build(e,"v3"),o=new fa(fa.VIEW).build(e,"v3"),s=a?a.build(e,"f"):void 0,l=`reflect( -normalize( ${o} ), ${r} )`;s&&(l=`normalize( mix( ${l}, ${r}, ${s} * ${s} ) )`);let c=`inverseTransformDirection( ${l}, viewMatrix )`;n?(e.addNodeCode(`vec3 reflectVec = ${c};`),i="reflectVec"):i=c;break}case pa.CUBE:{let t=new pa(pa.VECTOR).build(e,"v3"),a="vec3( -"+t+".x, "+t+".yz )";n?(e.addNodeCode(`vec3 reflectCubeVec = ${a};`),i="reflectCubeVec"):i=a;break}case pa.SPHERE:{let t="normalize( ( viewMatrix * vec4( "+new pa(pa.VECTOR).build(e,"v3")+", 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) ).xy * 0.5 + 0.5";n?(e.addNodeCode(`vec2 reflectSphereVec = ${t};`),i="reflectSphereVec"):i=t;break}}return e.format(i,this.getType(),t)}return console.warn("ReflectNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.type,t)}},ha=pa;ha.CUBE="cube",ha.SPHERE="sphere",ha.VECTOR="vector";var ma=class extends Oi{constructor(e=new ea,t,n){super("v4"),this.nodeType="TextureCube",this.value=e,this.radianceNode=new la(this.value,t??new ha(ha.VECTOR),n),this.irradianceNode=new la(this.value,new da(da.WORLD),new ta(1).setReadonly(!0))}generate(e,t){return e.isShader("fragment")?(e.require("irradiance"),e.context.bias&&e.context.bias.setTexture(this.value),("irradiance"===e.slot?this.irradianceNode:this.radianceNode).build(e,t)):(console.warn("TextureCubeNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),t))}},va=class extends Fi{constructor(e=new ne,t,n){super("v4",{shared:!0}),this.nodeType="CubeTexture",this.value=e,this.uv=t??new ha,this.bias=n}getTexture(e,t){return super.generate(e,t,this.value.uuid,"tc")}generate(e,t){if("samplerCube"===t)return this.getTexture(e,t);let n,i=this.getTexture(e,t),a=this.uv?.build(e,"v3"),r=this.bias?this.bias.build(e,"f"):void 0;void 0===r&&e.context.bias&&(r=e.context.bias.setTexture(this).build(e,"f")),n=r?"texCubeBias( "+i+", "+a+", "+r+" )":"texCube( "+i+", "+a+" )";let o={include:e.isShader("vertex"),ignoreCache:!0},s=this.getType(e);return e.addContext(o),this.colorSpace=this.colorSpace??new Ji(new Qi("",s)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(n),n=this.colorSpace.build(e,s),e.removeContext(),e.format(n,s,t)}},ga=["x","y","z","w"],_a=["float","vec2","vec3","vec4"],xa={float:"f",vec2:"v2",vec3:"v3",vec4:"v4",mat4:"v4",int:"i",bool:"b","float[]":"f[]","vec4[]":"v4[]"},Sa={t:"sampler2D",tc:"samplerCube",b:"bool",i:"int",f:"float",c:"vec3",v2:"vec2",v3:"vec3",v4:"vec4",m3:"mat3",m4:"mat4","f[]":"float[]","v4[]":"vec4[]"},Ta=class{constructor(){this.includes={consts:{},functions:{},structs:{}},this.cache="",this.slot="",this.shader="",this.context={},this.needsJitter=!0,this.getIncludesCode=function(){function e(e,t){return e.deps.length-t.deps.length}return function(t,n){let i=this.getIncludes(t,n);if(!i)return"";let a="";i=i.sort(e);for(let e=0;e<i.length;e++)i[e].src&&(a+=i[e].src+"\n");return a}}(),this.slots=[],this.caches=[],this.contexts=[],this.keywords={},this.nodeData={},this.fragmentVariables={},this.fragmentParsVariables={},this.vertexParsVariables={},this.requires={uv:[],color:[],transparent:!1,irradiance:!1,position:!1,worldPosition:!1,normal:!1,worldNormal:!1,vWorldViewDir:!1,modelMatrix:!1,viewMatrix:!1,projectionMatrix:!1},this.includes={consts:[],functions:[],structs:[]},this.attributes={},this.prefixCode=["#ifdef TEXTURE_LOD_EXT","\t#define texCube(a, b) textureCube(a, b)","\t#define texCubeBias(a, b, c) textureCubeLodEXT(a, b, c)","\t#define tex2D(a, b) texture2D(a, b)","\t#define tex2DBias(a, b, c) texture2DLodEXT(a, b, c)","#else","\t#define texCube(a, b) textureCube(a, b)","\t#define texCubeBias(a, b, c) textureCube(a, b, c)","\t#define tex2D(a, b) texture2D(a, b)","\t#define tex2DBias(a, b, c) texture2D(a, b, c)","#endif","\n\t\t\t\n\t\t\t#define SPE_BLENDING_NORMAL 0\n\t\t\t#define SPE_BLENDING_MULTIPLY 1\n\t\t\t#define SPE_BLENDING_SCREEN 2\n\t\t\t#define SPE_BLENDING_OVERLAY 3\n\n\t\t\tvec3 spe_normalBlend( vec3 a, vec3 b, float alpha ) {\n\t\t\t\treturn mix( a, b, alpha );\n\t\t\t}\n\n\t\t\tvec3 spe_multiplyBlend( vec3 a, vec3 b, float alpha ) {\n\t\t\t\treturn mix( a, a * b, alpha );\n\t\t\t}\n\n\t\t\tvec3 spe_screenBlend( vec3 a, vec3 b, float alpha ) {\n\t\t\t\tvec3 tmp = 1.0 - ( 1.0 - a ) * ( 1.0 - b );\n\t\t\t\treturn mix( a, tmp, alpha );\n\t\t\t}\n\n\t\t\tvec3 spe_overlayBlend( vec3 a, vec3 b, float alpha ) {\n\t\t\t\tvec3 tmp = mix( 1. - 2. * (1. - a) * (1. - b), 2. * a * b, step( a, vec3(.5) ) );\n\t\t\t\treturn clamp( mix( a, tmp, alpha ), 0.0, 1.0 );\n\t\t\t}\n\n\t\t\tvec3 spe_blend( vec3 a, vec3 b, float alpha, int mode ) {\n\t\t\t\tif ( mode == SPE_BLENDING_NORMAL ) return spe_normalBlend( a, b, alpha );\n\t\t\t\telse if ( mode == SPE_BLENDING_MULTIPLY ) return spe_multiplyBlend( a, b, alpha );\n\t\t\t\telse if ( mode == SPE_BLENDING_SCREEN ) return spe_screenBlend( a, b, alpha );\n\t\t\t\telse if ( mode == SPE_BLENDING_OVERLAY ) return spe_overlayBlend( a, b, alpha );\n\t\t\t\treturn vec3( 1.0 );\n\t\t\t}\n\t\t\t","#include <packing>","#include <common>"].join("\n"),this.parsCode={vertex:["float neighbor_offset = 0.0001;",""].join("\n"),fragment:["float accumAlpha = 0.0;","void accumulateAlpha(float alpha) {\n\t\t\t\t\taccumAlpha += (1.0 - accumAlpha) * alpha;\n\t\t\t\t}",""].join("\n")},this.code={vertex:"",fragment:""},this.nodeCode={vertex:"",fragment:""},this.resultCode={vertex:"",fragment:""},this.finalCode={vertex:"",fragment:""},this.inputs={uniforms:{list:[],vertex:[],fragment:[]},arrayUniforms:{list:[],vertex:[],fragment:[]},vars:{varying:[],vertex:[],fragment:[]}},this.defines={},this.uniforms={},this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.updaters=[],this.nodes=[],this.analyzing=!1}build(e,t){this.addVertexParsCode("\nuniform int frameIndex;\nuniform vec2 resolution;\nuniform mat4 previousModelViewMatrix;\nuniform mat4 previousProjectionMatrix;\n\nvarying vec4 vCurrentPosition;\nvarying vec4 vPreviousPosition;\n"),this.addFragmentParsCode("\nlayout(location = 1) out vec4 gVelocity;\n\nuniform int frameIndex;\nuniform vec2 resolution;\n\nvarying vec4 vCurrentPosition;\nvarying vec4 vPreviousPosition;\n\nconst vec2 haltonSequence[16] = vec2[16](\nvec2( 0.000000,-0.333334),\nvec2(-0.500000, 0.333334),\nvec2( 0.500000,-0.777778),\nvec2(-0.750000,-0.111112),\nvec2( 0.250000, 0.555556),\nvec2(-0.250000,-0.555556),\nvec2( 0.750000, 0.111112),\nvec2(-0.875000, 0.777778),\nvec2(0.125000, -0.925926),\nvec2(-0.375000, -0.259260),\nvec2(0.625000, 0.407408),\nvec2(-0.625000, -0.703704),\nvec2(0.375000, -0.037038),\nvec2(-0.125000, 0.629630),\nvec2(0.875000, -0.481482),\nvec2(-0.937500, 0.185186));\n\nvec2 vogelDiskSample(int sampleIndex, int sampleCount, float angle) {\n const float goldenAngle = 2.399963f; \n float r = sqrt(float(sampleIndex) + 0.5f) / sqrt(float(sampleCount));\n float theta = float(sampleIndex) * goldenAngle + angle;\n float sine = sin(theta);\n float cosine = cos(theta);\n return vec2(cosine, sine) * r;\n}\n\n\nfloat getNoiseInterleavedGradient(vec2 screenPos) {\n vec3 magic = vec3(0.06711056f, 0.00583715f, 52.9829189f);\n return fract(magic.z * fract(dot(screenPos, magic.xy)));\n}\n\n"),this.buildShader("vertex",e),this.buildShader("fragment",t);for(let e=0;e<this.requires.uv.length;e++)if(this.requires.uv[e]){let t=e>0?e+1:"";this.addVaryCode("varying vec2 vUv"+t+";"),e>0&&this.addVertexParsCode("attribute vec2 uv"+t+";"),this.addVertexFinalCode("vUv"+t+" = uv"+t+";")}return this.requires.color[0]&&(this.addVaryCode("varying vec4 vColor;"),this.addVertexFinalCode("\n\t\t\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\t\t\tvColor = color;\n\t\t\t\t#elif defined( USE_COLOR )\n\t\t\t\t\tvColor = vec4( color, 1.0 );\n\t\t\t\t#else\n\t\t\t\t\tvColor = vec4( 1.0 );\n\t\t\t\t#endif\n\t\t\t")),this.requires.color[1]&&(this.addVaryCode("varying vec4 vColor2;"),this.addVertexParsCode("attribute vec4 color2;"),this.addVertexFinalCode("vColor2 = color2;")),this.requires.position&&(this.addVaryCode("varying vec3 vPosition;"),this.addVertexFinalCode("vPosition = transformed;")),this.requires.worldPosition,this.requires.normal&&(this.addVaryCode("varying vec3 vObjectNormal;"),this.addVertexFinalCode("\n\t\t\t\t#ifndef SHAPEBLEND \n\t\t\t\t\tvObjectNormal = normal;\n\t\t\t\t#else\n\t\t\t\t\tvObjectNormal = objectNormal;\n\t\t\t\t#endif\n\t\t\t")),this.requires.modelMatrix&&this.addFragmentParsCode("uniform mat4 modelMatrix;"),this.requires.viewMatrix&&this.addFragmentParsCode("uniform mat4 viewMatrix;"),this.requires.projectionMatrix&&this.addFragmentParsCode("uniform mat4 projectionMatrix;"),this.requires.worldNormal&&(this.addVaryCode("varying vec3 vWNormal;"),this.addVertexFinalCode("vWNormal = inverseTransformDirection( transformedNormal, viewMatrix ).xyz;")),this.requires.vWorldViewDir&&(this.addVaryCode("varying vec3 vWorldViewDir;"),this.addVertexFinalCode("vWorldViewDir = isPerspectiveMatrix( projectionMatrix ) ? ( (modelMatrix * vec4(position, 1.0)).xyz - cameraPosition ) : vec3( -viewMatrix[0][2], -viewMatrix[1][2], -viewMatrix[2][2] );")),this.needsJitter&&(this.addVertexFinalCode("\n\nconst vec2 haltonSequence[16] = vec2[16](\nvec2( 0.000000,-0.333334),\nvec2(-0.500000, 0.333334),\nvec2( 0.500000,-0.777778),\nvec2(-0.750000,-0.111112),\nvec2( 0.250000, 0.555556),\nvec2(-0.250000,-0.555556),\nvec2( 0.750000, 0.111112),\nvec2(-0.875000, 0.777778),\nvec2(0.125000, -0.925926),\nvec2(-0.375000, -0.259260),\nvec2(0.625000, 0.407408),\nvec2(-0.625000, -0.703704),\nvec2(0.375000, -0.037038),\nvec2(-0.125000, 0.629630),\nvec2(0.875000, -0.481482),\nvec2(-0.937500, 0.185186));\n\n\nvec2 offset = haltonSequence[frameIndex];\noffset.x /= resolution.x;\noffset.y /= resolution.y;\n\nvec4 currentPosition = gl_Position;\nvec4 currentPositionJittered = currentPosition + (vec4(offset.x, offset.y, 0.0, 0.0) * currentPosition.w);\n\n\n\nvCurrentPosition = currentPosition;\nvec4 previousLocalPosition = vec4(transformed, 1.0);\n#ifdef USE_INSTANCING\n\n\n\npreviousLocalPosition = instanceMatrix * previousLocalPosition;\n#endif\nvPreviousPosition = previousProjectionMatrix * previousModelViewMatrix * previousLocalPosition;\n#ifdef OUTLINE_COMPENSATION\nvPreviousPosition.xy += OUTLINE_COMPENSATION;\n#endif\ngl_Position = currentPositionJittered;\n\n"),this.addFragmentFinalCode("\nvec2 oldPos = vPreviousPosition.xy;\n oldPos /= vPreviousPosition.w;\n oldPos.xy = (oldPos.xy+1.)/2.0;\n\nvec2 newPos = vCurrentPosition.xy;\n newPos /= vCurrentPosition.w;\n newPos.xy = (newPos.xy+1.)/2.0;\n\nvec2 velocity = (newPos - oldPos);\n\n\nif (gl_FragColor.a <= 0.0) discard;\n\ngVelocity = vec4(velocity, 0.0, 1.0);\n")),this}buildShader(e,t){this.resultCode[e]=t.build(this.setShader(e),"v4")}setMaterial(e,t){return this.defines={},this}addFlow(e,t,n){return this.addSlot(e).addCache(t).addContext(n)}removeFlow(){return this.removeSlot().removeCache().removeContext()}addCache(e){return this.cache=e??"",this.caches.push(this.cache),this}removeCache(){return this.caches.pop(),this.cache=this.caches[this.caches.length-1]||"",this}addContext(e){return this.context=Object.assign({},this.context,e),this.context.extra=this.context.extra||{},this.contexts.push(this.context),this}removeContext(){return this.contexts.pop(),this.context=this.contexts[this.contexts.length-1]||{},this}addSlot(e){return this.slot=e||"",this.slots.push(this.slot),this}removeSlot(){return this.slots.pop(),this.slot=this.slots[this.slots.length-1]||"",this}addFragmentVariable(e,t){void 0===this.fragmentVariables[e]&&(this.addFragmentCode(`${t} ${e};`),this.fragmentVariables[e]="")}addFragmentParsVariable(e,t){void 0===this.fragmentParsVariables[e]&&(this.addFragmentParsCode(`${t} ${e};`),this.fragmentParsVariables[e]="")}addVertexParsVariable(e,t){void 0===this.vertexParsVariables[e]&&(this.addVertexParsCode(`${t} ${e};`),this.vertexParsVariables[e]="")}addVertexCode(e){this.addCode(e,"vertex")}addFragmentCode(e){this.addCode(e,"fragment")}addCode(e,t){this.code[t??this.shader]+=e+"\n"}addVertexNodeCode(e){this.addNodeCode(e,"vertex")}addFragmentNodeCode(e){this.addNodeCode(e,"fragment")}addNodeCode(e,t){this.nodeCode[t??this.shader]+=e+"\n"}clearNodeCode(e){e=e??this.shader;let t=this.nodeCode[e];return this.nodeCode[e]="",t}clearVertexNodeCode(){return this.clearNodeCode("vertex")}clearFragmentNodeCode(){return this.clearNodeCode("fragment")}addVertexFinalCode(e){this.addFinalCode(e,"vertex")}addFragmentFinalCode(e){this.addFinalCode(e,"fragment")}addFinalCode(e,t){this.finalCode[t??this.shader]+=e+"\n"}addVertexParsCode(e){this.addParsCode(e,"vertex")}addFragmentParsCode(e){this.addParsCode(e,"fragment")}addParsCode(e,t){this.parsCode[t??this.shader]+=e+"\n"}addVaryCode(e){this.addVertexParsCode(e),this.addFragmentParsCode(e)}isCache(e){return-1!==this.caches.indexOf(e)}isSlot(e){return-1!==this.slots.indexOf(e)}define(e,t){this.defines[e]=void 0===t?1:t}require(e){this.requires[e]=!0}isDefined(e){return void 0!==this.defines[e]}getVar(e,t,n,i="varying",a="V",r=""){let o=this.getVars(i),s=o[e];if(!s){let i=o.length;s={name:n||"node"+a+i+(r?"_"+r:""),type:t},o.push(s),o[e]=s}return s}getTempVar(e,t,n,i){return this.getVar(e,t,n,this.shader,"T",i)}getAttribute(e,t){if(!this.attributes[e]){let n=this.getVar(e,t);this.addVertexParsCode("attribute "+t+" "+e+";"),this.addVertexFinalCode(n.name+" = "+e+";"),this.attributes[e]={varying:n,name:e,type:t}}return this.attributes[e]}getCode(e){return[this.prefixCode,this.parsCode[e],this.getVarListCode(this.getVars("varying"),"varying"),this.getVarListCode(this.inputs.uniforms[e],"uniform"),this.getVarListCode(this.inputs.arrayUniforms[e],"uniform"),this.getIncludesCode("consts",e),this.getIncludesCode("structs",e),this.getIncludesCode("functions",e),"void main() {",this.getVarListCode(this.getVars(e)),this.code[e],this.resultCode[e],this.finalCode[e],"}"].join("\n")}getVarListCode(e,t){t=t??"";let n="";for(let i=0,a=e.length;i<a;++i){let a=e[i],r=a.type,o=a.name,s=a.size,l=this.getFormatByType(r);if(void 0===l)throw new Error("Node pars "+l+" not found.");l.includes("[]")?n+=t+" "+l.substring(0,l.length-2)+" "+o+`[${s}];\n`:n+=t+" "+l+" "+o+";\n"}return n}getVars(e){return this.inputs.vars[e??this.shader]}getNodeData(e){let t=e instanceof Di?e.uuid:e;return this.nodeData[t]=this.nodeData[t]||{}}createUniform(e,t,n,i,a,r){if(t.includes("[]")){let o=this.inputs.arrayUniforms,s=o.list.length,l=new Ni({type:t,size:n.size,name:i||"nodeUA"+s+(r?"_"+r:""),node:n,needsUpdate:a});return o.list.push(l),o[e].push(l),o[e][l.name]=l,this.uniforms[l.name]=l,l}{let o=this.inputs.uniforms,s=o.list.length,l=new Ni({type:t,name:i||"nodeU"+s+(r?"_"+r:""),node:n,needsUpdate:a});return o.list.push(l),o[e].push(l),o[e][l.name]=l,this.uniforms[l.name]=l,l}}createVertexUniform(e,t,n,i,a){return this.createUniform("vertex",e,t,n,i,a)}createFragmentUniform(e,t,n,i,a){return this.createUniform("fragment",e,t,n,i,a)}include(e,t,n){let i;if(e="string"==typeof e?Ii.get(e):e,!1===this.context.include)return e.name;e instanceof ki?i=this.includes.functions:e instanceof ji?i=this.includes.consts:e instanceof Yi&&(i=this.includes.structs);let a=i[this.shader]=i[this.shader]||[];if(e){let i=a[e.name];if(i||(i=a[e.name]={node:e,deps:[]},a.push(i),i.src=e.build(this,"source")),e instanceof ki&&t&&a[t.name]&&-1===a[t.name].deps.indexOf(e)&&(a[t.name].deps.push(e),e.includes?.length)){let n=0;do{this.include(e.includes[n++],t)}while(n<e.includes.length)}return n&&(i.src=n),e.name}throw new Error("Include not found.")}colorToVectorProperties(e){return e.replace("r","x").replace("g","y").replace("b","z").replace("a","w")}colorToVector(e){return e.replace(/c/g,"v3")}getIncludes(e,t){return this.includes[e][t||this.shader]}getConstructorFromLength(e){return _a[e-1]}isTypeMatrix(e){return/^m/.test(e)}getTypeLength(e){return"f"===e?1:parseInt(this.colorToVector(e).substr(1))}getTypeFromLength(e){return 1===e?"f":"v"+e}findNode(...e){for(let t=0;t<arguments.length;t++){let n=e[t];if(n?.isNode)return n}}resolve(...e){for(let t=0;t<arguments.length;t++){let n=e[t];if(void 0!==n){if(n.isNode)return n;if(n.isTexture)switch(n.mapping){case nn:case sn:return new va(n);case xn:return new ma(new ea(n));default:return new ea(n)}else{if(n.isVector2)return new zi(n);if(n.isVector3)return new Bi(n);if(n.isVector4)return new Vi(n)}}}}format(e,t,n){switch(this.colorToVector(n+" <- "+t)){case"f <- v2":case"f <- v3":case"f <- v4":return e+".x";case"f <- i":case"f <- b":return"float( "+e+" )";case"v2 <- f":return"vec2( "+e+" )";case"v2 <- v3":case"v2 <- v4":return e+".xy";case"v2 <- i":case"v2 <- b":case"v3 <- i":case"v3 <- b":return"vec2( float( "+e+" ) )";case"v3 <- f":return"vec3( "+e+" )";case"v3 <- v2":return"vec3( "+e+", 0.0 )";case"v3 <- v4":return e+".xyz";case"v4 <- f":return"vec4( "+e+" )";case"v4 <- v2":return"vec4( "+e+", 0.0, 1.0 )";case"v4 <- v3":return"vec4( "+e+", 1.0 )";case"v4 <- i":case"v4 <- b":return"vec4( float( "+e+" ) )";case"i <- f":case"i <- b":return"int( "+e+" )";case"i <- v2":case"i <- v3":case"i <- v4":return"int( "+e+".x )";case"b <- f":return"( "+e+" != 0.0 )";case"b <- v2":return"( "+e+" != vec2( 0.0 ) )";case"b <- v3":return"( "+e+" != vec3( 0.0 ) )";case"b <- v4":return"( "+e+" != vec4( 0.0 ) )";case"b <- i":return"( "+e+" != 0 )"}return e}getTypeByFormat(e){return xa[e]||e}getFormatByType(e){return Sa[e]||e}getUUID(e,t){return(t=void 0===t||t)&&this.cache&&(e=this.cache+"-"+e),e}getElementByIndex(e){return ga[e]}getIndexByElement(e){return ga.indexOf(e)}isShader(e){return this.shader===e}setShader(e){return this.shader=e,this}mergeDefines(e){for(let t in e)this.defines[t]=e[t];return this.defines}mergeUniform(e){for(let t in e)this.uniforms[t]=e[t];return this.uniforms}getTextureEncodingFromMap(e){let t;return e?e.isTexture&&(t=e.colorSpace===Le?Ui:Li):t=Li,t===Li&&this.context.gamma&&(t=Ui),t}},ba=class extends Fi{constructor(e=0,t,n,i){super("c"),this.nodeType="Color",this.value=e instanceof T?e:new T(e||0,t,n,i)}setRGBA(e){this.value.setRGBA(e.r,e.g,e.b,e.a)}generate(e,t,n,i,a,r){n=e.getUUID(n??this.getUUID()),i=i??this.getType(e);let o=e.getNodeData(n),s=this.getReadonly()&&void 0!==this.generateReadonly;if(this.alpha){let t=this.alpha.build(e,"f");e.addFragmentNodeCode(`accumAlpha += ( 1.0 - accumAlpha ) * ${t};`)}return s?this.generateReadonly(e,t,n,i,a,r):e.isShader("vertex")?(o.vertex||(o.vertex=e.createVertexUniform(i,this,a,r,this.getLabel())),e.format(o.vertex.name,i,t)):(o.fragment||(o.fragment=e.createFragmentUniform(i,this,a,r,this.getLabel())),e.format(o.fragment.name,i,t))}generateReadonly(e,t,n,i,a,r){return e.format("vec3("+this.value.r+", "+this.value.g+", "+this.value.b+")",i,t)}},wa=class extends Fi{constructor(e){super("i"),this.nodeType="Int",this.value=Math.floor(e??0)}generateReadonly(e,t,n,i,a,r){return e.format(this.value.toString(),i,t)}};function Ea(){let e=null,t=!1,n=null,i=null;function a(t,r){n(t,r),i=e.requestAnimationFrame(a)}return{start:function(){!0!==t&&null!==n&&null!==e&&(i=e.requestAnimationFrame(a),t=!0)},stop:function(){null!==e&&e.cancelAnimationFrame(i),t=!1},setAnimationLoop:function(e){n=e},setContext:function(t){e=t}}}function Ma(e){let t=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),t.get(e)},remove:function(n){n.isInterleavedBufferAttribute&&(n=n.data);let i=t.get(n);i&&(e.deleteBuffer(i.buffer),t.delete(n))},update:function(n,i){if(n.isInterleavedBufferAttribute&&(n=n.data),n.isGLBufferAttribute){let e=t.get(n);return void((!e||e.version<n.version)&&t.set(n,{buffer:n.buffer,type:n.type,bytesPerElement:n.elementSize,version:n.version}))}let a=t.get(n);if(void 0===a)t.set(n,function(t,n){let i,a=t.array,r=t.usage,o=a.byteLength,s=e.createBuffer();if(e.bindBuffer(n,s),e.bufferData(n,a,r),t.onUploadCallback(),a instanceof Float32Array)i=e.FLOAT;else if(typeof Float16Array<"u"&&a instanceof Float16Array)i=e.HALF_FLOAT;else if(a instanceof Uint16Array)i=t.isFloat16BufferAttribute?e.HALF_FLOAT:e.UNSIGNED_SHORT;else if(a instanceof Int16Array)i=e.SHORT;else if(a instanceof Uint32Array)i=e.UNSIGNED_INT;else if(a instanceof Int32Array)i=e.INT;else if(a instanceof Int8Array)i=e.BYTE;else if(a instanceof Uint8Array)i=e.UNSIGNED_BYTE;else{if(!(a instanceof Uint8ClampedArray))throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+a);i=e.UNSIGNED_BYTE}return{buffer:s,type:i,bytesPerElement:a.BYTES_PER_ELEMENT,version:t.version,size:o}}(n,i));else if(a.version<n.version){if(a.size!==n.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");(function(t,n,i){let a=n.array,r=n.updateRanges;if(e.bindBuffer(i,t),0===r.length)e.bufferSubData(i,0,a);else{r.sort((e,t)=>e.start-t.start);let t=0;for(let e=1;e<r.length;e++){let n=r[t],i=r[e];i.start<=n.start+n.count+1?n.count=Math.max(n.count,i.start+i.count-n.start):(++t,r[t]=i)}r.length=t+1;for(let t=0,n=r.length;t<n;t++){let n=r[t];e.bufferSubData(i,n.start*a.BYTES_PER_ELEMENT,a,n.start,n.count)}n.clearUpdateRanges()}n.onUploadCallback()})(a.buffer,n,i),a.version=n.version}}}}var ya={alphahash_fragment:"#ifdef USE_ALPHAHASH\n\tif ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;\n#endif",alphahash_pars_fragment:"#ifdef USE_ALPHAHASH\n\tconst float ALPHA_HASH_SCALE = 0.05;\n\tfloat hash2D( vec2 value ) {\n\t\treturn fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );\n\t}\n\tfloat hash3D( vec3 value ) {\n\t\treturn hash2D( vec2( hash2D( value.xy ), value.z ) );\n\t}\n\tfloat getAlphaHashThreshold( vec3 position ) {\n\t\tfloat maxDeriv = max(\n\t\t\tlength( dFdx( position.xyz ) ),\n\t\t\tlength( dFdy( position.xyz ) )\n\t\t);\n\t\tfloat pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );\n\t\tvec2 pixScales = vec2(\n\t\t\texp2( floor( log2( pixScale ) ) ),\n\t\t\texp2( ceil( log2( pixScale ) ) )\n\t\t);\n\t\tvec2 alpha = vec2(\n\t\t\thash3D( floor( pixScales.x * position.xyz ) ),\n\t\t\thash3D( floor( pixScales.y * position.xyz ) )\n\t\t);\n\t\tfloat lerpFactor = fract( log2( pixScale ) );\n\t\tfloat x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;\n\t\tfloat a = min( lerpFactor, 1.0 - lerpFactor );\n\t\tvec3 cases = vec3(\n\t\t\tx * x / ( 2.0 * a * ( 1.0 - a ) ),\n\t\t\t( x - 0.5 * a ) / ( 1.0 - a ),\n\t\t\t1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )\n\t\t);\n\t\tfloat threshold = ( x < ( 1.0 - a ) )\n\t\t\t? ( ( x < a ) ? cases.x : cases.y )\n\t\t\t: cases.z;\n\t\treturn clamp( threshold , 1.0e-6, 1.0 );\n\t}\n#endif",alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef USE_ALPHATEST\n\t#ifdef ALPHA_TO_COVERAGE\n\tdiffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );\n\tif ( diffuseColor.a == 0.0 ) discard;\n\t#else\n\tif ( diffuseColor.a < alphaTest ) discard;\n\t#endif\n#endif",alphatest_pars_fragment:"#ifdef USE_ALPHATEST\n\tuniform float alphaTest;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_CLEARCOAT ) \n\t\tclearcoatSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_SHEEN ) \n\t\tsheenSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometryNormal, geometryViewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n\t#endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",batching_pars_vertex:"#ifdef USE_BATCHING\n\t#if ! defined( GL_ANGLE_multi_draw )\n\t#define gl_DrawID _gl_DrawID\n\tuniform int _gl_DrawID;\n\t#endif\n\tuniform highp sampler2D batchingTexture;\n\tuniform highp usampler2D batchingIdTexture;\n\tmat4 getBatchingMatrix( const in float i ) {\n\t\tint size = textureSize( batchingTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n\tfloat getIndirectIndex( const in int i ) {\n\t\tint size = textureSize( batchingIdTexture, 0 ).x;\n\t\tint x = i % size;\n\t\tint y = i / size;\n\t\treturn float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );\n\t}\n#endif\n#ifdef USE_BATCHING_COLOR\n\tuniform sampler2D batchingColorTexture;\n\tvec4 getBatchingColor( const in float i ) {\n\t\tint size = textureSize( batchingColorTexture, 0 ).x;\n\t\tint j = int( i );\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\treturn texelFetch( batchingColorTexture, ivec2( x, y ), 0 );\n\t}\n#endif",batching_vertex:"#ifdef USE_BATCHING\n\tmat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );\n#endif",begin_vertex:"vec3 transformed = vec3( position );\n#ifdef USE_ALPHAHASH\n\tvPosition = vec3( position );\n#endif",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"float G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n} ",iridescence_fragment:"#ifdef USE_IRIDESCENCE\n\tconst mat3 XYZ_TO_REC709 = mat3(\n\t\t 3.2404542, -0.9692660, 0.0556434,\n\t\t-1.5371385, 1.8760108, -0.2040259,\n\t\t-0.4985314, 0.0415560, 1.0572252\n\t);\n\tvec3 Fresnel0ToIor( vec3 fresnel0 ) {\n\t\tvec3 sqrtF0 = sqrt( fresnel0 );\n\t\treturn ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );\n\t}\n\tvec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );\n\t}\n\tfloat IorToFresnel0( float transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));\n\t}\n\tvec3 evalSensitivity( float OPD, vec3 shift ) {\n\t\tfloat phase = 2.0 * PI * OPD * 1.0e-9;\n\t\tvec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );\n\t\tvec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );\n\t\tvec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );\n\t\tvec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );\n\t\txyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );\n\t\txyz /= 1.0685e-7;\n\t\tvec3 rgb = XYZ_TO_REC709 * xyz;\n\t\treturn rgb;\n\t}\n\tvec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {\n\t\tvec3 I;\n\t\tfloat iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );\n\t\tfloat sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );\n\t\tfloat cosTheta2Sq = 1.0 - sinTheta2Sq;\n\t\tif ( cosTheta2Sq < 0.0 ) {\n\t\t\treturn vec3( 1.0 );\n\t\t}\n\t\tfloat cosTheta2 = sqrt( cosTheta2Sq );\n\t\tfloat R0 = IorToFresnel0( iridescenceIOR, outsideIOR );\n\t\tfloat R12 = F_Schlick( R0, 1.0, cosTheta1 );\n\t\tfloat T121 = 1.0 - R12;\n\t\tfloat phi12 = 0.0;\n\t\tif ( iridescenceIOR < outsideIOR ) phi12 = PI;\n\t\tfloat phi21 = PI - phi12;\n\t\tvec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) );\t\tvec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );\n\t\tvec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );\n\t\tvec3 phi23 = vec3( 0.0 );\n\t\tif ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;\n\t\tif ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;\n\t\tif ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;\n\t\tfloat OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;\n\t\tvec3 phi = vec3( phi21 ) + phi23;\n\t\tvec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );\n\t\tvec3 r123 = sqrt( R123 );\n\t\tvec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );\n\t\tvec3 C0 = R12 + Rs;\n\t\tI = C0;\n\t\tvec3 Cm = Rs - T121;\n\t\tfor ( int m = 1; m <= 2; ++ m ) {\n\t\t\tCm *= r123;\n\t\t\tvec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );\n\t\t\tI += Cm * Sm;\n\t\t}\n\t\treturn max( I, vec3( 0.0 ) );\n\t}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vBumpMapUv );\n\t\tvec2 dSTdy = dFdy( vBumpMapUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );\n\t\tvec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#ifdef ALPHA_TO_COVERAGE\n\t\tfloat distanceToPlane, distanceGradient;\n\t\tfloat clipOpacity = 1.0;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\tclipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\tif ( clipOpacity == 0.0 ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tfloat unionClipOpacity = 1.0;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\t\tunionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tclipOpacity *= 1.0 - unionClipOpacity;\n\t\t#endif\n\t\tdiffuseColor.a *= clipOpacity;\n\t\tif ( diffuseColor.a == 0.0 ) discard;\n\t#else\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tbool clipped = true;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tif ( clipped ) discard;\n\t\t#endif\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvarying vec4 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvColor = vec4( 1.0 );\n#endif\n#ifdef USE_COLOR_ALPHA\n\tvColor *= color;\n#elif defined( USE_COLOR )\n\tvColor.rgb *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.rgb *= instanceColor.rgb;\n#endif\n#ifdef USE_BATCHING_COLOR\n\tvColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) );\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\n#ifdef USE_ALPHAHASH\n\tvarying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\n#define inverseTransformDirection transformDirectionByInverseViewMatrix\nvec3 transformNormalByInverseViewMatrix( in vec3 normal, in mat4 viewMatrix ) {\n\treturn normalize( ( vec4( normal, 0.0 ) * viewMatrix ).xyz );\n}\nvec3 transformDirectionByInverseViewMatrix( in vec3 dir, in mat4 viewMatrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * viewMatrix ).xyz );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} ",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\thighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = objectTangent;\n#endif\n#ifdef USE_BATCHING\n\tmat3 bm = mat3( batchingMatrix );\n\ttransformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );\n\ttransformedNormal = bm * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = bm * transformedTangent;\n\t#endif\n#endif\n#ifdef USE_INSTANCING\n\tmat3 im = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );\n\ttransformedNormal = im * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = im * transformedTangent;\n\t#endif\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\ttransformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE\n\t\temissiveColor = sRGBTransferEOTF( emissiveColor );\n\t#endif\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",colorspace_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",colorspace_pars_fragment:"vec4 LinearTransferOETF( in vec4 value ) {\n\treturn value;\n}\nvec4 sRGBTransferEOTF( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 sRGBTransferOETF( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, envMapRotation * reflectVec );\n\t\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t\t#endif\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform mat3 envMapRotation;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#ifdef USE_ENVMAP\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );\n\t\t\treflectVec = transformDirectionByInverseViewMatrix( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\t#ifdef USE_ANISOTROPY\n\t\tvec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n\t\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\t\tvec3 bentNormal = cross( bitangent, viewDir );\n\t\t\t\tbentNormal = normalize( cross( bentNormal, bitangent ) );\n\t\t\t\tbentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n\t\t\t\treturn getIBLRadiance( viewDir, bentNormal, roughness );\n\t\t\t#else\n\t\t\t\treturn vec3( 0.0 );\n\t\t\t#endif\n\t\t}\n\t#endif\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\tvec2 fw = fwidth( coord ) * 0.5;\n\t\treturn mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n\t#endif\n}",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_fragment:"LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;",lights_lambert_pars_fragment:"varying vec3 vViewPosition;\nstruct LambertMaterial {\n\tvec3 diffuseColor;\n\tfloat 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\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.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\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n\tuniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif ( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif\n#include <lightprobes_pars_fragment>",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 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\tvec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n\treflectedLight.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\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat 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\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.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\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong",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\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor;\n\tmaterial.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = vec3( 0.04 );\n\tmaterial.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_DISPERSION\n\tmaterial.dispersion = dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tif( material.anisotropy == 0.0 ) {\n\t\tanisotropyV = vec2( 1.0, 0.0 );\n\t} else {\n\t\tanisotropyV /= material.anisotropy;\n\t\tmaterial.anisotropy = saturate( material.anisotropy );\n\t}\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;\n#endif",lights_physical_pars_fragment:"uniform sampler2D dfgLUT;\nstruct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tvec3 diffuseContribution;\n\tvec3 specularColor;\n\tvec3 specularColorBlended;\n\tfloat roughness;\n\tfloat metalness;\n\tfloat specularF90;\n\tfloat dispersion;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t\tvec3 iridescenceFresnelDielectric;\n\t\tvec3 iridescenceFresnelMetallic;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\n\t#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\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n\tfloat 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\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\treturn 0.5 / max( gv + gl, EPSILON );\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColorBlended;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn 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\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transpose( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn 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\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat rInv = 1.0 / ( roughness + 0.1 );\n\tfloat a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv;\n\tfloat b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv;\n\tfloat DG = exp( a * dotNV + b );\n\treturn 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\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n\treturn 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\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\nvec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg;\n\tvec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg;\n\tvec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y;\n\tvec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y;\n\tfloat Ess_V = dfgV.x + dfgV.y;\n\tfloat Ess_L = dfgL.x + dfgL.y;\n\tfloat Ems_V = 1.0 - Ess_V;\n\tfloat Ems_L = 1.0 - Ess_L;\n\tvec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619;\n\tvec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON );\n\tfloat compensationFactor = Ems_V * Ems_L;\n\tvec3 multiScatter = Fms * compensationFactor;\n\treturn singleScatter + multiScatter;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid 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\t\tvec3 normal = geometryNormal;\n\t\tvec3 viewDir = geometryViewDir;\n\t\tvec3 position = geometryPosition;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColorBlended * t2.x + ( material.specularF90 - material.specularColorBlended ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t\t#ifdef USE_CLEARCOAT\n\t\t\tvec3 Ncc = geometryClearcoatNormal;\n\t\t\tvec2 uvClearcoat = LTC_Uv( Ncc, viewDir, material.clearcoatRoughness );\n\t\t\tvec4 t1Clearcoat = texture2D( ltc_1, uvClearcoat );\n\t\t\tvec4 t2Clearcoat = texture2D( ltc_2, uvClearcoat );\n\t\t\tmat3 mInvClearcoat = mat3(\n\t\t\t\tvec3( t1Clearcoat.x, 0, t1Clearcoat.y ),\n\t\t\t\tvec3( 0, 1, 0 ),\n\t\t\t\tvec3( t1Clearcoat.z, 0, t1Clearcoat.w )\n\t\t\t);\n\t\t\tvec3 fresnelClearcoat = material.clearcoatF0 * t2Clearcoat.x + ( material.clearcoatF90 - material.clearcoatF0 ) * t2Clearcoat.y;\n\t\t\tclearcoatSpecularDirect += lightColor * fresnelClearcoat * LTC_Evaluate( Ncc, viewDir, position, mInvClearcoat, rectCoords );\n\t\t#endif\n\t}\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\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n \n \t\tsheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n \n \t\tfloat sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n \t\tfloat sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness );\n \n \t\tfloat sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL );\n \n \t\tirradiance *= sheenEnergyComp;\n \n \t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );\n\treflectedLight.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\tvec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution );\n\t#ifdef USE_SHEEN\n\t\tfloat sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t\tfloat sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n\t\tdiffuse *= sheenEnergyComp;\n\t#endif\n\treflectedLight.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\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI;\n \t#endif\n\tvec3 singleScatteringDielectric = vec3( 0.0 );\n\tvec3 multiScatteringDielectric = vec3( 0.0 );\n\tvec3 singleScatteringMetallic = vec3( 0.0 );\n\tvec3 multiScatteringMetallic = vec3( 0.0 );\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n\t#else\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n\t#endif\n\tvec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness );\n\tvec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness );\n\tvec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric;\n\tvec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tvec3 indirectSpecular = radiance * singleScattering;\n\tindirectSpecular += multiScattering * cosineWeightedIrradiance;\n\tvec3 indirectDiffuse = diffuse * cosineWeightedIrradiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t\tfloat sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n\t\tindirectSpecular *= sheenEnergyComp;\n\t\tindirectDiffuse *= sheenEnergyComp;\n\t#endif\n\treflectedLight.indirectSpecular += indirectSpecular;\n\treflectedLight.indirectDiffuse += indirectDiffuse;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",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\tgeometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometryViewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor );\n\t\tmaterial.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometryPosition, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometryPosition, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if defined( USE_LIGHT_PROBES )\n\t\tirradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#ifdef USE_LIGHT_PROBES_GRID\n\t\tvec3 probeWorldPos = ( ( vec4( geometryPosition, 1.0 ) - viewMatrix[ 3 ] ) * viewMatrix ).xyz;\n\t\tvec3 probeWorldNormal = transformNormalByInverseViewMatrix( geometryNormal, viewMatrix );\n\t\tirradiance += getLightProbeGridIrradiance( probeWorldPos, probeWorldNormal );\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\t#if defined( STANDARD ) || defined( LAMBERT ) || defined( PHONG )\n\t\t\tiblIrradiance += getIBLIrradiance( geometryNormal );\n\t\t#endif\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\t#ifdef USE_ANISOTROPY\n\t\tradiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n\t#else\n\t\tradiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\t#if defined( LAMBERT ) || defined( PHONG )\n\t\tirradiance += iblIrradiance;\n\t#endif\n\tRE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif",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\tvec3 res = probesResolution;\n\tvec3 gridRange = probesMax - probesMin;\n\tvec3 resMinusOne = res - 1.0;\n\tvec3 probeSpacing = gridRange / resMinusOne;\n\tvec3 samplePos = worldPos + worldNormal * probeSpacing * 0.5;\n\tvec3 uvw = clamp( ( samplePos - probesMin ) / gridRange, 0.0, 1.0 );\n\tuvw = uvw * resMinusOne / res + 0.5 / res;\n\tfloat nz = res.z;\n\tfloat paddedSlices = nz + 2.0;\n\tfloat atlasDepth = 7.0 * paddedSlices;\n\tfloat uvZBase = uvw.z * nz + 1.0;\n\tvec4 s0 = texture( probesSH, vec3( uvw.xy, ( uvZBase ) / atlasDepth ) );\n\tvec4 s1 = texture( probesSH, vec3( uvw.xy, ( uvZBase + paddedSlices ) / atlasDepth ) );\n\tvec4 s2 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 2.0 * paddedSlices ) / atlasDepth ) );\n\tvec4 s3 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 3.0 * paddedSlices ) / atlasDepth ) );\n\tvec4 s4 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 4.0 * paddedSlices ) / atlasDepth ) );\n\tvec4 s5 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 5.0 * paddedSlices ) / atlasDepth ) );\n\tvec4 s6 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 6.0 * paddedSlices ) / atlasDepth ) );\n\tvec3 c0 = s0.xyz;\n\tvec3 c1 = vec3( s0.w, s1.xy );\n\tvec3 c2 = vec3( s1.zw, s2.x );\n\tvec3 c3 = s2.yzw;\n\tvec3 c4 = s3.xyz;\n\tvec3 c5 = vec3( s3.w, s4.xy );\n\tvec3 c6 = vec3( s4.zw, s5.x );\n\tvec3 c7 = s5.yzw;\n\tvec3 c8 = s6.xyz;\n\tfloat x = worldNormal.x, y = worldNormal.y, z = worldNormal.z;\n\tvec3 result = c0 * 0.886227;\n\tresult += c1 * 2.0 * 0.511664 * y;\n\tresult += c2 * 2.0 * 0.511664 * z;\n\tresult += c3 * 2.0 * 0.511664 * x;\n\tresult += c4 * 2.0 * 0.429043 * x * y;\n\tresult += c5 * 2.0 * 0.429043 * y * z;\n\tresult += c6 * ( 0.743125 * z * z - 0.247708 );\n\tresult += c7 * 2.0 * 0.429043 * x * z;\n\tresult += c8 * 0.429043 * ( x * x - y * y );\n\treturn max( result, vec3( 0.0 ) );\n}\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n\tgl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n\tvFragDepth = 1.0 + gl_Position.w;\n\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );\n\t#endif\n\tdiffuseColor *= sampledDiffuseColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t#if defined( USE_POINTS_UV )\n\t\tvec2 uv = vUv;\n\t#else\n\t\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_POINTS_UV )\n\tvarying vec2 vUv;\n#else\n\t#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t\tuniform mat3 uvTransform;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphinstance_vertex:"#ifdef USE_INSTANCING_MORPH\n\tfloat morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\tfloat morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tmorphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;\n\t}\n#endif",morphcolor_vertex:"#if defined( USE_MORPHCOLORS )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\t#ifndef USE_INSTANCING_MORPH\n\t\tuniform float morphTargetBaseInfluence;\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t#endif\n\tuniform sampler2DArray morphTargetsTexture;\n\tuniform ivec2 morphTargetsTextureSize;\n\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t}\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = dFdx( vViewPosition );\n\tvec3 fdy = dFdy( vViewPosition );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal *= faceDirection;\n\t#endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn = getTangentFrame( - vViewPosition, normal,\n\t\t#if defined( USE_NORMALMAP )\n\t\t\tvNormalMapUv\n\t\t#elif defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tvClearcoatNormalMapUv\n\t\t#else\n\t\t\tvUv\n\t\t#endif\n\t\t);\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\ttbn[0] *= faceDirection;\n\t\ttbn[1] *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\ttbn2[0] *= faceDirection;\n\t\ttbn2[1] *= faceDirection;\n\t#endif\n#endif\nvec3 nonPerturbedNormal = normal;",normal_fragment_maps:"#ifdef USE_NORMALMAP_OBJECTSPACE\n\tnormal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n\tvec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#if defined( USE_PACKED_NORMALMAP )\n\t\tmapN = vec3( mapN.xy, sqrt( saturate( 1.0 - dot( mapN.xy, mapN.xy ) ) ) );\n\t#endif\n\tmapN.xy *= normalScale;\n\tnormal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t\t#ifdef FLIP_SIDED\n\t\t\tvBitangent = - vBitangent;\n\t\t#endif\n\t#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )\n\tmat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( uv.st );\n\t\tvec2 st1 = dFdy( uv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n\t\treturn mat3( T * scale, B * scale, N );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = nonPerturbedNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\tclearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif",iridescence_pars_fragment:"#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform sampler2D iridescenceThicknessMap;\n#endif",opaque_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;\nconst float Inv255 = 1. / 255.;\nconst vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );\nconst vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );\nconst vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );\nconst vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );\nvec4 packDepthToRGBA( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec4( 0., 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec4( 1., 1., 1., 1. );\n\tfloat vuf;\n\tfloat af = modf( v * PackFactors.a, vuf );\n\tfloat bf = modf( vuf * ShiftRight8, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );\n}\nvec3 packDepthToRGB( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec3( 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec3( 1., 1., 1. );\n\tfloat vuf;\n\tfloat bf = modf( v * PackFactors.b, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec3( vuf * Inv255, gf * PackUpscale, bf );\n}\nvec2 packDepthToRG( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec2( 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec2( 1., 1. );\n\tfloat vuf;\n\tfloat gf = modf( v * 256., vuf );\n\treturn vec2( vuf * Inv255, gf );\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors4 );\n}\nfloat unpackRGBToDepth( const in vec3 v ) {\n\treturn dot( v, UnpackFactors3 );\n}\nfloat unpackRGToDepth( const in vec2 v ) {\n\treturn v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;\n}\nvec4 pack2HalfToRGBA( const in vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( const in vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\n\t\treturn depth * ( far - near ) - far;\n\t#else\n\t\treturn depth * ( near - far ) - near;\n\t#endif\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\t\n\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\treturn ( near * far ) / ( ( near - far ) * depth - near );\n\t#else\n\t\treturn ( near * far ) / ( ( far - near ) * depth - far );\n\t#endif\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_BATCHING\n\tmvPosition = batchingMatrix * mvPosition;\n#endif\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tuniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\t#else\n\t\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\t#endif\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tuniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\t#else\n\t\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\t#endif\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tuniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\t#elif defined( SHADOWMAP_TYPE_BASIC )\n\t\t\tuniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\t#endif\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\tfloat interleavedGradientNoise( vec2 position ) {\n\t\t\treturn fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) );\n\t\t}\n\t\tvec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) {\n\t\t\tconst float goldenAngle = 2.399963229728653;\n\t\t\tfloat r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) );\n\t\t\tfloat theta = float( sampleIndex ) * goldenAngle + phi;\n\t\t\treturn vec2( cos( theta ), sin( theta ) ) * r;\n\t\t}\n\t#endif\n\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\tfloat getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\t\tfloat shadow = 1.0;\n\t\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\t\tshadowCoord.z += shadowBias;\n\t\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\t\tif ( frustumTest ) {\n\t\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\t\tfloat radius = shadowRadius * texelSize.x;\n\t\t\t\tfloat phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2;\n\t\t\t\tshadow = (\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) +\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) +\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) +\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) +\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) )\n\t\t\t\t) * 0.2;\n\t\t\t}\n\t\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t\t}\n\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\t\tfloat shadow = 1.0;\n\t\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\tshadowCoord.z -= shadowBias;\n\t\t\t#else\n\t\t\t\tshadowCoord.z += shadowBias;\n\t\t\t#endif\n\t\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\t\tif ( frustumTest ) {\n\t\t\t\tvec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg;\n\t\t\t\tfloat mean = distribution.x;\n\t\t\t\tfloat variance = distribution.y * distribution.y;\n\t\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\t\tfloat hard_shadow = step( mean, shadowCoord.z );\n\t\t\t\t#else\n\t\t\t\t\tfloat hard_shadow = step( shadowCoord.z, mean );\n\t\t\t\t#endif\n\t\t\t\t\n\t\t\t\tif ( hard_shadow == 1.0 ) {\n\t\t\t\t\tshadow = 1.0;\n\t\t\t\t} else {\n\t\t\t\t\tvariance = max( variance, 0.0000001 );\n\t\t\t\t\tfloat d = shadowCoord.z - mean;\n\t\t\t\t\tfloat p_max = variance / ( variance + d * d );\n\t\t\t\t\tp_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 );\n\t\t\t\t\tshadow = max( hard_shadow, p_max );\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t\t}\n\t#else\n\t\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\t\tfloat shadow = 1.0;\n\t\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\tshadowCoord.z -= shadowBias;\n\t\t\t#else\n\t\t\t\tshadowCoord.z += shadowBias;\n\t\t\t#endif\n\t\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\t\tif ( frustumTest ) {\n\t\t\t\tfloat depth = texture2D( shadowMap, shadowCoord.xy ).r;\n\t\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\t\tshadow = step( depth, shadowCoord.z );\n\t\t\t\t#else\n\t\t\t\t\tshadow = step( shadowCoord.z, depth );\n\t\t\t\t#endif\n\t\t\t}\n\t\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t\t}\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#if defined( SHADOWMAP_TYPE_PCF )\n\tfloat getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tfloat shadow = 1.0;\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\tvec3 absVec = abs( lightToPosition );\n\t\tfloat viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n\t\tif ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {\n\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\tfloat dp = ( shadowCameraNear * ( shadowCameraFar - viewSpaceZ ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n\t\t\t\tdp -= shadowBias;\n\t\t\t#else\n\t\t\t\tfloat dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n\t\t\t\tdp += shadowBias;\n\t\t\t#endif\n\t\t\tfloat texelSize = shadowRadius / shadowMapSize.x;\n\t\t\tvec3 absDir = abs( bd3D );\n\t\t\tvec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 );\n\t\t\ttangent = normalize( cross( bd3D, tangent ) );\n\t\t\tvec3 bitangent = cross( bd3D, tangent );\n\t\t\tfloat phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2;\n\t\t\tvec2 sample0 = vogelDiskSample( 0, 5, phi );\n\t\t\tvec2 sample1 = vogelDiskSample( 1, 5, phi );\n\t\t\tvec2 sample2 = vogelDiskSample( 2, 5, phi );\n\t\t\tvec2 sample3 = vogelDiskSample( 3, 5, phi );\n\t\t\tvec2 sample4 = vogelDiskSample( 4, 5, phi );\n\t\t\tshadow = (\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * sample0.x + bitangent * sample0.y ) * texelSize, dp ) ) +\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * sample1.x + bitangent * sample1.y ) * texelSize, dp ) ) +\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * sample2.x + bitangent * sample2.y ) * texelSize, dp ) ) +\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * sample3.x + bitangent * sample3.y ) * texelSize, dp ) ) +\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * sample4.x + bitangent * sample4.y ) * texelSize, dp ) )\n\t\t\t) * 0.2;\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n\t#elif defined( SHADOWMAP_TYPE_BASIC )\n\tfloat getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tfloat shadow = 1.0;\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tvec3 absVec = abs( lightToPosition );\n\t\tfloat viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n\t\tif ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {\n\t\t\tfloat dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n\t\t\tdp += shadowBias;\n\t\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t\tfloat depth = textureCube( shadowMap, bd3D ).r;\n\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\tdepth = 1.0 - depth;\n\t\t\t#endif\n\t\t\tshadow = step( dp, depth );\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n\t#endif\n\t#endif\n#endif",shadowmap_pars_vertex:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tuniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n\t#ifdef HAS_NORMAL\n\t\tvec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix );\n\t#else\n\t\tvec3 shadowWorldNormal = vec3( 0.0 );\n\t#endif\n\tvec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition;\n\t\t#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t\tshadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n\t\t#endif\n\t\tvSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\tuniform highp sampler2D boneTexture;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tint size = textureSize( boneTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 CineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nconst mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.6605, - 0.1246, - 0.0182 ),\n\tvec3( - 0.5876, 1.1329, - 0.1006 ),\n\tvec3( - 0.0728, - 0.0083, 1.1187 )\n);\nconst mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(\n\tvec3( 0.6274, 0.0691, 0.0164 ),\n\tvec3( 0.3293, 0.9195, 0.0880 ),\n\tvec3( 0.0433, 0.0113, 0.8956 )\n);\nvec3 agxDefaultContrastApprox( vec3 x ) {\n\tvec3 x2 = x * x;\n\tvec3 x4 = x2 * x2;\n\treturn + 15.5 * x4 * x2\n\t\t- 40.14 * x4 * x\n\t\t+ 31.96 * x4\n\t\t- 6.868 * x2 * x\n\t\t+ 0.4298 * x2\n\t\t+ 0.1191 * x\n\t\t- 0.00232;\n}\nvec3 AgXToneMapping( vec3 color ) {\n\tconst mat3 AgXInsetMatrix = mat3(\n\t\tvec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),\n\t\tvec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),\n\t\tvec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )\n\t);\n\tconst mat3 AgXOutsetMatrix = mat3(\n\t\tvec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),\n\t\tvec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),\n\t\tvec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )\n\t);\n\tconst float AgxMinEv = - 12.47393;\tconst float AgxMaxEv = 4.026069;\n\tcolor *= toneMappingExposure;\n\tcolor = LINEAR_SRGB_TO_LINEAR_REC2020 * color;\n\tcolor = AgXInsetMatrix * color;\n\tcolor = max( color, 1e-10 );\tcolor = log2( color );\n\tcolor = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );\n\tcolor = clamp( color, 0.0, 1.0 );\n\tcolor = agxDefaultContrastApprox( color );\n\tcolor = AgXOutsetMatrix * color;\n\tcolor = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );\n\tcolor = LINEAR_REC2020_TO_LINEAR_SRGB * color;\n\tcolor = clamp( color, 0.0, 1.0 );\n\treturn color;\n}\nvec3 NeutralToneMapping( vec3 color ) {\n\tconst float StartCompression = 0.8 - 0.04;\n\tconst float Desaturation = 0.15;\n\tcolor *= toneMappingExposure;\n\tfloat x = min( color.r, min( color.g, color.b ) );\n\tfloat offset = x < 0.08 ? x - 6.25 * x * x : 0.04;\n\tcolor -= offset;\n\tfloat peak = max( color.r, max( color.g, color.b ) );\n\tif ( peak < StartCompression ) return color;\n\tfloat d = 1. - StartCompression;\n\tfloat newPeak = 1. - d * d / ( peak + d - StartCompression );\n\tcolor *= newPeak / peak;\n\tfloat g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );\n\treturn mix( color, vec3( newPeak ), g );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = transformNormalByInverseViewMatrix( normal, viewMatrix );\n\tvec4 transmitted = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tfloat w0( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n\t}\n\tfloat w1( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n\t}\n\tfloat w2( float a ){\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n\t}\n\tfloat w3( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * a );\n\t}\n\tfloat g0( float a ) {\n\t\treturn w0( a ) + w1( a );\n\t}\n\tfloat g1( float a ) {\n\t\treturn w2( a ) + w3( a );\n\t}\n\tfloat h0( float a ) {\n\t\treturn - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n\t}\n\tfloat h1( float a ) {\n\t\treturn 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n\t}\n\tvec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n\t\tuv = uv * texelSize.zw + 0.5;\n\t\tvec2 iuv = floor( uv );\n\t\tvec2 fuv = fract( uv );\n\t\tfloat g0x = g0( fuv.x );\n\t\tfloat g1x = g1( fuv.x );\n\t\tfloat h0x = h0( fuv.x );\n\t\tfloat h1x = h1( fuv.x );\n\t\tfloat h0y = h0( fuv.y );\n\t\tfloat h1y = h1( fuv.y );\n\t\tvec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\treturn g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n\t\t\tg1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n\t}\n\tvec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n\t\tvec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n\t\tvec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n\t\tvec2 fLodSizeInv = 1.0 / fLodSize;\n\t\tvec2 cLodSizeInv = 1.0 / cLodSize;\n\t\tvec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n\t\tvec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n\t\treturn mix( fSample, cSample, fract( lod ) );\n\t}\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\treturn textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n\t}\n\tvec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( isinf( attenuationDistance ) ) {\n\t\t\treturn vec3( 1.0 );\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec4 transmittedLight;\n\t\tvec3 transmittance;\n\t\t#ifdef USE_DISPERSION\n\t\t\tfloat halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;\n\t\t\tvec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );\n\t\t\tfor ( int i = 0; i < 3; i ++ ) {\n\t\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );\n\t\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\t\trefractionCoords += 1.0;\n\t\t\t\trefractionCoords /= 2.0;\n\t\t\t\tvec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );\n\t\t\t\ttransmittedLight[ i ] = transmissionSample[ i ];\n\t\t\t\ttransmittedLight.a += transmissionSample.a;\n\t\t\t\ttransmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];\n\t\t\t}\n\t\t\ttransmittedLight.a /= 3.0;\n\t\t#else\n\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\trefractionCoords += 1.0;\n\t\t\trefractionCoords /= 2.0;\n\t\t\ttransmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\t\ttransmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\t#endif\n\t\tvec3 attenuatedColor = transmittance * transmittedLight.rgb;\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\tfloat transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n\t}\n#endif",uv_pars_fragment:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_pars_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tuniform mat3 mapTransform;\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform mat3 alphaMapTransform;\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tuniform mat3 lightMapTransform;\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tuniform mat3 aoMapTransform;\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tuniform mat3 bumpMapTransform;\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tuniform mat3 normalMapTransform;\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tuniform mat3 displacementMapTransform;\n\tvarying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tuniform mat3 emissiveMapTransform;\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tuniform mat3 metalnessMapTransform;\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tuniform mat3 roughnessMapTransform;\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tuniform mat3 anisotropyMapTransform;\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tuniform mat3 clearcoatMapTransform;\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform mat3 clearcoatNormalMapTransform;\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform mat3 clearcoatRoughnessMapTransform;\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tuniform mat3 sheenColorMapTransform;\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tuniform mat3 sheenRoughnessMapTransform;\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tuniform mat3 iridescenceMapTransform;\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform mat3 iridescenceThicknessMapTransform;\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tuniform mat3 specularMapTransform;\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tuniform mat3 specularColorMapTransform;\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tuniform mat3 specularIntensityMapTransform;\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n\tvMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n\tvAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n\tvLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n\tvAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n\tvBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n\tvNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tvDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n\tvMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n\tvSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tvTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n\tvThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_BATCHING\n\t\tworldPosition = batchingMatrix * worldPosition;\n\t#endif\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\ttexColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",backgroundCube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",backgroundCube_frag:"#ifdef ENVMAP_TYPE_CUBE\n\tuniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n\tuniform sampler2D envMap;\n#endif\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nuniform mat3 backgroundRotation;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 texColor = textureCube( envMap, backgroundRotation * vWorldDirection );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );\n\t#else\n\t\tvec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",cube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = texColor;\n\tgl_FragColor.a *= opacity;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",depth_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#include <morphinstance_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\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 <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <logdepthbuf_fragment>\n\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\tfloat fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];\n\t#else\n\t\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;\n\t#endif\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#elif DEPTH_PACKING == 3202\n\t\tgl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );\n\t#elif DEPTH_PACKING == 3203\n\t\tgl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );\n\t#endif\n}",distance_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#include <morphinstance_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}",distance_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\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 <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <uv_pars_vertex>\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>\nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",meshbasic_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinbase_vertex>\n\t\t#include <skinnormal_vertex>\n\t\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\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 <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshlambert_vert:"#define LAMBERT\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\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshlambert_frag:"#define LAMBERT\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 <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_lambert_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\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_lambert_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\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 <fog_pars_fragment>\n#include <normal_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\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <uv_pars_fragment>\n#include <normal_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\tvec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}",meshphong_vert:"#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\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshphong_frag:"#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\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying 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\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_DISPERSION\n\tuniform float dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\n\t#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\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include <transmission_fragment>\n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n \n\t\toutgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect;\n \n \t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;\n\t#endif\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshtoon_vert:"#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\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshtoon_frag:"#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\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",points_vert:"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\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\nvoid main() {\n\t#ifdef USE_POINTS_UV\n\t\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\t#endif\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",shadow_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <logdepthbuf_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\t#include <logdepthbuf_fragment>\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\tvec4 mvPosition = modelViewMatrix[ 3 ];\n\tvec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\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 <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}"},Ca={common:{diffuse:{value:new ft(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Me},alphaMap:{value:null},alphaMapTransform:{value:new Me},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Me}},envmap:{envMap:{value:null},envMapRotation:{value:new Me},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Me}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Me}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Me},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Me},normalScale:{value:new pe(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Me},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Me}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Me}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Me}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new ft(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new Te},probesMax:{value:new Te},probesResolution:{value:new Te}},points:{diffuse:{value:new ft(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Me},alphaTest:{value:0},uvTransform:{value:new Me}},sprite:{diffuse:{value:new ft(16777215)},opacity:{value:1},center:{value:new pe(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Me},alphaMap:{value:null},alphaMapTransform:{value:new Me},alphaTest:{value:0}}},Ra={basic:{uniforms:J([Ca.common,Ca.specularmap,Ca.envmap,Ca.aomap,Ca.lightmap,Ca.fog]),vertexShader:ya.meshbasic_vert,fragmentShader:ya.meshbasic_frag},lambert:{uniforms:J([Ca.common,Ca.specularmap,Ca.envmap,Ca.aomap,Ca.lightmap,Ca.emissivemap,Ca.bumpmap,Ca.normalmap,Ca.displacementmap,Ca.fog,Ca.lights,{emissive:{value:new ft(0)},envMapIntensity:{value:1}}]),vertexShader:ya.meshlambert_vert,fragmentShader:ya.meshlambert_frag},phong:{uniforms:J([Ca.common,Ca.specularmap,Ca.envmap,Ca.aomap,Ca.lightmap,Ca.emissivemap,Ca.bumpmap,Ca.normalmap,Ca.displacementmap,Ca.fog,Ca.lights,{emissive:{value:new ft(0)},specular:{value:new ft(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:ya.meshphong_vert,fragmentShader:ya.meshphong_frag},standard:{uniforms:J([Ca.common,Ca.envmap,Ca.aomap,Ca.lightmap,Ca.emissivemap,Ca.bumpmap,Ca.normalmap,Ca.displacementmap,Ca.roughnessmap,Ca.metalnessmap,Ca.fog,Ca.lights,{emissive:{value:new ft(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:ya.meshphysical_vert,fragmentShader:ya.meshphysical_frag},toon:{uniforms:J([Ca.common,Ca.aomap,Ca.lightmap,Ca.emissivemap,Ca.bumpmap,Ca.normalmap,Ca.displacementmap,Ca.gradientmap,Ca.fog,Ca.lights,{emissive:{value:new ft(0)}}]),vertexShader:ya.meshtoon_vert,fragmentShader:ya.meshtoon_frag},matcap:{uniforms:J([Ca.common,Ca.bumpmap,Ca.normalmap,Ca.displacementmap,Ca.fog,{matcap:{value:null}}]),vertexShader:ya.meshmatcap_vert,fragmentShader:ya.meshmatcap_frag},points:{uniforms:J([Ca.points,Ca.fog]),vertexShader:ya.points_vert,fragmentShader:ya.points_frag},dashed:{uniforms:J([Ca.common,Ca.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:ya.linedashed_vert,fragmentShader:ya.linedashed_frag},depth:{uniforms:J([Ca.common,Ca.displacementmap]),vertexShader:ya.depth_vert,fragmentShader:ya.depth_frag},normal:{uniforms:J([Ca.common,Ca.bumpmap,Ca.normalmap,Ca.displacementmap,{opacity:{value:1}}]),vertexShader:ya.meshnormal_vert,fragmentShader:ya.meshnormal_frag},sprite:{uniforms:J([Ca.sprite,Ca.fog]),vertexShader:ya.sprite_vert,fragmentShader:ya.sprite_frag},background:{uniforms:{uvTransform:{value:new Me},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:ya.background_vert,fragmentShader:ya.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Me}},vertexShader:ya.backgroundCube_vert,fragmentShader:ya.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:ya.cube_vert,fragmentShader:ya.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:ya.equirect_vert,fragmentShader:ya.equirect_frag},distance:{uniforms:J([Ca.common,Ca.displacementmap,{referencePosition:{value:new Te},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:ya.distance_vert,fragmentShader:ya.distance_frag},shadow:{uniforms:J([Ca.lights,Ca.fog,{color:{value:new ft(0)},opacity:{value:1}}]),vertexShader:ya.shadow_vert,fragmentShader:ya.shadow_frag}};Ra.physical={uniforms:J([Ra.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Me},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Me},clearcoatNormalScale:{value:new pe(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Me},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Me},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Me},sheen:{value:0},sheenColor:{value:new ft(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Me},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Me},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Me},transmissionSamplerSize:{value:new pe},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Me},attenuationDistance:{value:0},attenuationColor:{value:new ft(0)},specularColor:{value:new ft(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Me},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Me},anisotropyVector:{value:new pe},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Me}}]),vertexShader:ya.meshphysical_vert,fragmentShader:ya.meshphysical_frag};var Aa={r:0,b:0,g:0},Pa=new tt,Da=new Me;function La(e,t,n,i,a,r){let o,s,l=new ft(0),c=!0===a?0:1,d=null,u=0,f=null;function p(e){let n=!0===e.isScene?e.background:null;if(n&&n.isTexture){let i=e.backgroundBlurriness>0;n=t.get(n,i)}return n}function h(t,i){t.getRGB(Aa,Ft(e)),n.buffers.color.setClear(Aa.r,Aa.g,Aa.b,i,r)}return{getClearColor:function(){return l},setClearColor:function(e,t=1){l.set(e),c=t,h(l,c)},getClearAlpha:function(){return c},setClearAlpha:function(e){c=e,h(l,c)},render:function(t){let i=!1,a=p(t);null===a?h(l,c):a&&a.isColor&&(h(a,1),i=!0);let o=e.xr.getEnvironmentBlendMode();"additive"===o?n.buffers.color.setClear(0,0,0,1,r):"alpha-blend"===o&&n.buffers.color.setClear(0,0,0,0,r),(e.autoClear||i)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil))},addToRenderList:function(t,n){let a=p(n);a&&(a.isCubeTexture||a.mapping===xn)?(void 0===s&&(s=new Pn(new ge(1,1,1),new Xt({name:"BackgroundCubeMaterial",uniforms:Ut(Ra.backgroundCube.uniforms),vertexShader:Ra.backgroundCube.vertexShader,fragmentShader:Ra.backgroundCube.fragmentShader,side:bn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),s.geometry.deleteAttribute("normal"),s.geometry.deleteAttribute("uv"),s.onBeforeRender=function(e,t,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(s.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(s)),s.material.uniforms.envMap.value=a,s.material.uniforms.backgroundBlurriness.value=n.backgroundBlurriness,s.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,s.material.uniforms.backgroundRotation.value.setFromMatrix4(Pa.makeRotationFromEuler(n.backgroundRotation)).transpose(),a.isCubeTexture&&!1===a.isRenderTargetTexture&&s.material.uniforms.backgroundRotation.value.premultiply(Da),s.material.toneMapped=Ae.getTransfer(a.colorSpace)!==We,(d!==a||u!==a.version||f!==e.toneMapping)&&(s.material.needsUpdate=!0,d=a,u=a.version,f=e.toneMapping),s.layers.enableAll(),t.unshift(s,s.geometry,s.material,0,0,null)):a&&a.isTexture&&(void 0===o&&(o=new Pn(new _t(2,2),new Xt({name:"BackgroundMaterial",uniforms:Ut(Ra.background.uniforms),vertexShader:Ra.background.vertexShader,fragmentShader:Ra.background.fragmentShader,side:_n,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),o.geometry.deleteAttribute("normal"),Object.defineProperty(o.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(o)),o.material.uniforms.t2D.value=a,o.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,o.material.toneMapped=Ae.getTransfer(a.colorSpace)!==We,!0===a.matrixAutoUpdate&&a.updateMatrix(),o.material.uniforms.uvTransform.value.copy(a.matrix),(d!==a||u!==a.version||f!==e.toneMapping)&&(o.material.needsUpdate=!0,d=a,u=a.version,f=e.toneMapping),o.layers.enableAll(),t.unshift(o,o.geometry,o.material,0,0,null))},dispose:function(){void 0!==s&&(s.geometry.dispose(),s.material.dispose(),s=void 0),void 0!==o&&(o.geometry.dispose(),o.material.dispose(),o=void 0)}}}function Ua(e,t){let n=e.getParameter(e.MAX_VERTEX_ATTRIBS),i={},a=c(null),r=a,o=!1;function s(t){return e.bindVertexArray(t)}function l(t){return e.deleteVertexArray(t)}function c(e){let t=[],i=[],a=[];for(let e=0;e<n;e++)t[e]=0,i[e]=0,a[e]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:t,enabledAttributes:i,attributeDivisors:a,object:e,attributes:{},index:null}}function d(){let e=r.newAttributes;for(let t=0,n=e.length;t<n;t++)e[t]=0}function u(e){f(e,0)}function f(t,n){let i=r.newAttributes,a=r.enabledAttributes,o=r.attributeDivisors;i[t]=1,0===a[t]&&(e.enableVertexAttribArray(t),a[t]=1),o[t]!==n&&(e.vertexAttribDivisor(t,n),o[t]=n)}function p(){let t=r.newAttributes,n=r.enabledAttributes;for(let i=0,a=n.length;i<a;i++)n[i]!==t[i]&&(e.disableVertexAttribArray(i),n[i]=0)}function h(t,n,i,a,r,o,s){!0===s?e.vertexAttribIPointer(t,n,i,r,o):e.vertexAttribPointer(t,n,i,a,r,o)}function m(){v(),o=!0,r!==a&&(r=a,s(r.object))}function v(){a.geometry=null,a.program=null,a.wireframe=!1}return{setup:function(n,a,l,m,v){let g=!1,_=function(t,n,a,r){let o=!0===r.wireframe,s=i[n.id];void 0===s&&(s={},i[n.id]=s);let l=!0===t.isInstancedMesh?t.id:0,d=s[l];void 0===d&&(d={},s[l]=d);let u=d[a.id];void 0===u&&(u={},d[a.id]=u);let f=u[o];return void 0===f&&(f=c(e.createVertexArray()),u[o]=f),f}(n,m,l,a);r!==_&&(r=_,s(r.object)),g=function(e,t,n,i){let a=r.attributes,o=t.attributes,s=0,l=n.getAttributes();for(let t in l)if(l[t].location>=0){let n=a[t],i=o[t];if(void 0===i&&("instanceMatrix"===t&&e.instanceMatrix&&(i=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(i=e.instanceColor)),void 0===n||n.attribute!==i||i&&n.data!==i.data)return!0;s++}return r.attributesNum!==s||r.index!==i}(n,m,l,v),g&&function(e,t,n,i){let a={},o=t.attributes,s=0,l=n.getAttributes();for(let t in l)if(l[t].location>=0){let n=o[t];void 0===n&&("instanceMatrix"===t&&e.instanceMatrix&&(n=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(n=e.instanceColor));let i={};i.attribute=n,n&&n.data&&(i.data=n.data),a[t]=i,s++}r.attributes=a,r.attributesNum=s,r.index=i}(n,m,l,v),null!==v&&t.update(v,e.ELEMENT_ARRAY_BUFFER),(g||o)&&(o=!1,function(n,i,a,r){d();let o=r.attributes,s=a.getAttributes(),l=i.defaultAttributeValues;for(let i in s){let a=s[i];if(a.location>=0){let s=o[i];if(void 0===s&&("instanceMatrix"===i&&n.instanceMatrix&&(s=n.instanceMatrix),"instanceColor"===i&&n.instanceColor&&(s=n.instanceColor)),void 0!==s){let i=s.normalized,o=s.itemSize,l=t.get(s);if(void 0===l)continue;let c=l.buffer,d=l.type,p=l.bytesPerElement,m=d===e.INT||d===e.UNSIGNED_INT||s.gpuType===wi;if(s.isInterleavedBufferAttribute){let t=s.data,l=t.stride,v=s.offset;if(t.isInstancedInterleavedBuffer){for(let e=0;e<a.locationSize;e++)f(a.location+e,t.meshPerAttribute);!0!==n.isInstancedMesh&&void 0===r._maxInstanceCount&&(r._maxInstanceCount=t.meshPerAttribute*t.count)}else for(let e=0;e<a.locationSize;e++)u(a.location+e);e.bindBuffer(e.ARRAY_BUFFER,c);for(let e=0;e<a.locationSize;e++)h(a.location+e,o/a.locationSize,d,i,l*p,(v+o/a.locationSize*e)*p,m)}else{if(s.isInstancedBufferAttribute){for(let e=0;e<a.locationSize;e++)f(a.location+e,s.meshPerAttribute);!0!==n.isInstancedMesh&&void 0===r._maxInstanceCount&&(r._maxInstanceCount=s.meshPerAttribute*s.count)}else for(let e=0;e<a.locationSize;e++)u(a.location+e);e.bindBuffer(e.ARRAY_BUFFER,c);for(let e=0;e<a.locationSize;e++)h(a.location+e,o/a.locationSize,d,i,o*p,o/a.locationSize*e*p,m)}}else if(void 0!==l){let t=l[i];if(void 0!==t)switch(t.length){case 2:e.vertexAttrib2fv(a.location,t);break;case 3:e.vertexAttrib3fv(a.location,t);break;case 4:e.vertexAttrib4fv(a.location,t);break;default:e.vertexAttrib1fv(a.location,t)}}}}p()}(n,a,l,m),null!==v&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.get(v).buffer))},reset:m,resetDefaultState:v,dispose:function(){m();for(let e in i){let t=i[e];for(let e in t){let n=t[e];for(let e in n){let t=n[e];for(let e in t)l(t[e].object),delete t[e];delete n[e]}}delete i[e]}},releaseStatesOfGeometry:function(e){if(void 0===i[e.id])return;let t=i[e.id];for(let e in t){let n=t[e];for(let e in n){let t=n[e];for(let e in t)l(t[e].object),delete t[e];delete n[e]}}delete i[e.id]},releaseStatesOfObject:function(e){for(let t in i){let n=i[t],a=!0===e.isInstancedMesh?e.id:0,r=n[a];if(void 0!==r){for(let e in r){let t=r[e];for(let e in t)l(t[e].object),delete t[e];delete r[e]}delete n[a],0===Object.keys(n).length&&delete i[t]}}},releaseStatesOfProgram:function(e){for(let t in i){let n=i[t];for(let t in n){let i=n[t];if(void 0===i[e.id])continue;let a=i[e.id];for(let e in a)l(a[e].object),delete a[e];delete i[e.id]}}},initAttributes:d,enableAttribute:u,disableUnusedAttributes:p}}function Na(e,t,n){let i;this.setMode=function(e){i=e},this.render=function(t,a){e.drawArrays(i,t,a),n.update(a,i,1)},this.renderInstances=function(t,a,r){0!==r&&(e.drawArraysInstanced(i,t,a,r),n.update(a,i,r))},this.renderMultiDraw=function(e,a,r){if(0===r)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,e,0,a,0,r);let o=0;for(let e=0;e<r;e++)o+=a[e];n.update(o,i,1)}}function Ia(e,t,n,i){let a;function r(t){if("highp"===t){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let o=void 0!==n.precision?n.precision:"highp",s=r(o);s!==o&&(gi("WebGLRenderer:",o,"not supported, using",s,"instead."),o=s);let l=!0===n.logarithmicDepthBuffer,c=!0===n.reversedDepthBuffer&&t.has("EXT_clip_control");return!0===n.reversedDepthBuffer&&!1===c&&gi("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer."),{isWebGL2:!0,getMaxAnisotropy:function(){if(void 0!==a)return a;if(!0===t.has("EXT_texture_filter_anisotropic")){let n=t.get("EXT_texture_filter_anisotropic");a=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else a=0;return a},getMaxPrecision:r,textureFormatReadable:function(t){return!(t!==Ie&&i.convert(t)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_FORMAT))},textureTypeReadable:function(n){let a=n===re&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));return!(n!==si&&i.convert(n)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_TYPE)&&n!==ee&&!a)},precision:o,logarithmicDepthBuffer:l,reversedDepthBuffer:c,maxTextures:e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),maxVertexTextures:e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),maxTextureSize:e.getParameter(e.MAX_TEXTURE_SIZE),maxCubemapSize:e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),maxAttributes:e.getParameter(e.MAX_VERTEX_ATTRIBS),maxVertexUniforms:e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),maxVaryings:e.getParameter(e.MAX_VARYING_VECTORS),maxFragmentUniforms:e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),maxSamples:e.getParameter(e.MAX_SAMPLES),samples:e.getParameter(e.SAMPLES)}}function Oa(e){let t=this,n=null,i=0,a=!1,r=!1,o=new Qn,s=new Me,l={value:null,needsUpdate:!1};function c(e,n,i,a){let r=null!==e?e.length:0,c=null;if(0!==r){if(c=l.value,!0!==a||null===c){let t=i+4*r,a=n.matrixWorldInverse;s.getNormalMatrix(a),(null===c||c.length<t)&&(c=new Float32Array(t));for(let t=0,n=i;t!==r;++t,n+=4)o.copy(e[t]).applyMatrix4(a,s),o.normal.toArray(c,n),c[n+3]=o.constant}l.value=c,l.needsUpdate=!0}return t.numPlanes=r,t.numIntersection=0,c}this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(e,t){let n=0!==e.length||t||0!==i||a;return a=t,i=e.length,n},this.beginShadows=function(){r=!0,c(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(e,t){n=c(e,t,0)},this.setState=function(o,s,d){let u=o.clippingPlanes,f=o.clipIntersection,p=o.clipShadows,h=e.get(o);if(!a||null===u||0===u.length||r&&!p)r?c(null):(l.value!==n&&(l.value=n,l.needsUpdate=i>0),t.numPlanes=i,t.numIntersection=0);else{let e=r?0:i,t=4*e,a=h.clippingState||null;l.value=a,a=c(u,s,t,d);for(let e=0;e!==t;++e)a[e]=n[e];h.clippingState=a,this.numIntersection=f?this.numPlanes:0,this.numPlanes+=e}}}Da.set(-1,0,0,0,1,0,0,0,1);var Fa=class extends Xe{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;let n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];this.texture=new ne(i),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let n={tEquirect:{value:null}},i="\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t\t#include <project_vertex>\n\n\t\t\t\t}\n\t\t\t",a="\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include <common>\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t",r=new ge(5,5,5),o=new Xt({name:"CubemapFromEquirect",uniforms:Ut(n),vertexShader:i,fragmentShader:a,side:bn,blending:Ln});o.uniforms.tEquirect.value=t;let s=new Pn(r,o),l=t.minFilter;return t.minFilter===ei&&(t.minFilter=qn),(()=>{throw new Error("fromEquirectangularTexture is not supported by the Spline runtime")})().update(e,s),t.minFilter=l,s.geometry.dispose(),s.material.dispose(),this}clear(e,t=!0,n=!0,i=!0){let a=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,i);e.setRenderTarget(a)}};function za(e){let t=new WeakMap,n=new WeakMap,i=null;function a(e,t){return t===un?e.mapping=nn:t===mn&&(e.mapping=sn),e}function r(e){let n=e.target;n.removeEventListener("dispose",r);let i=t.get(n);void 0!==i&&(t.delete(n),i.dispose())}function o(e){let t=e.target;t.removeEventListener("dispose",o);let i=n.get(t);void 0!==i&&(n.delete(t),i.dispose())}return{get:function(s,l=!1){return null==s?null:l?function(e){if(e&&e.isTexture){let t=e.mapping,a=t===un||t===mn,r=t===nn||t===sn;if(a||r){let t=n.get(e),s=void 0!==t?t.texture.pmremVersion:0;if(e.isRenderTargetTexture&&e.pmremVersion!==s){if(null===i)throw new Error("PMREM environment-map conversion is not supported by the Spline runtime");return t=a?i.fromEquirectangular(e,t):i.fromCubemap(e,t),t.texture.pmremVersion=e.pmremVersion,n.set(e,t),t.texture}if(void 0!==t)return t.texture;{let s=e.image;if(a&&s&&s.height>0||r&&s&&function(e){let t=0;for(let n=0;n<6;n++)void 0!==e[n]&&t++;return 6===t}(s)){if(null===i)throw new Error("PMREM environment-map conversion is not supported by the Spline runtime");return t=a?i.fromEquirectangular(e):i.fromCubemap(e),t.texture.pmremVersion=e.pmremVersion,n.set(e,t),e.addEventListener("dispose",o),t.texture}return null}}}return e}(s):function(n){if(n&&n.isTexture){let i=n.mapping;if(i===un||i===mn){if(t.has(n))return a(t.get(n).texture,n.mapping);{let i=n.image;if(i&&i.height>0){let o=new Fa(i.height);return o.fromEquirectangularTexture(e,n),t.set(n,o),n.addEventListener("dispose",r),a(o.texture,n.mapping)}return null}}}return n}(s)},dispose:function(){t=new WeakMap,n=new WeakMap,null!==i&&(i.dispose(),i=null)}}}function Ba(e){let t={};function n(n){if(void 0!==t[n])return t[n];let i=e.getExtension(n);return t[n]=i,i}return{has:function(e){return null!==n(e)},init:function(){n("EXT_color_buffer_float"),n("WEBGL_clip_cull_distance"),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture"),n("WEBGL_render_shared_exponent")},get:function(e){let t=n(e);return null===t&&Mi("WebGLRenderer: "+e+" extension not supported."),t}}}function Va(e,t,n,i){let a={},r=new WeakMap;function o(e){let s=e.target;null!==s.index&&t.remove(s.index);for(let e in s.attributes)t.remove(s.attributes[e]);s.removeEventListener("dispose",o),delete a[s.id];let l=r.get(s);l&&(t.remove(l),r.delete(s)),i.releaseStatesOfGeometry(s),!0===s.isInstancedBufferGeometry&&delete s._maxInstanceCount,n.memory.geometries--}function s(e){let n=[],i=e.index,a=e.attributes.position,o=0;if(void 0===a)return;if(null!==i){let e=i.array;o=i.version;for(let t=0,i=e.length;t<i;t+=3){let i=e[t+0],a=e[t+1],r=e[t+2];n.push(i,a,a,r,r,i)}}else{let e=a.array;o=a.version;for(let t=0,i=e.length/3-1;t<i;t+=3){let e=t+0,i=t+1,a=t+2;n.push(e,i,i,a,a,e)}}let s=new(a.count>=65535?Z:Lt)(n,1);s.version=o;let l=r.get(e);l&&t.remove(l),r.set(e,s)}return{get:function(e,t){return!0===a[t.id]||(t.addEventListener("dispose",o),a[t.id]=!0,n.memory.geometries++),t},update:function(n){let i=n.attributes;for(let n in i)t.update(i[n],e.ARRAY_BUFFER)},getWireframeAttribute:function(e){let t=r.get(e);if(t){let n=e.index;null!==n&&t.version<n.version&&s(e)}else s(e);return r.get(e)}}}function Ha(e,t,n){let i,a,r;this.setMode=function(e){i=e},this.setIndex=function(e){a=e.type,r=e.bytesPerElement},this.render=function(t,o){e.drawElements(i,o,a,t*r),n.update(o,i,1)},this.renderInstances=function(t,o,s){0!==s&&(e.drawElementsInstanced(i,o,a,t*r,s),n.update(o,i,s))},this.renderMultiDraw=function(e,r,o){if(0===o)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,r,0,a,e,0,o);let s=0;for(let e=0;e<o;e++)s+=r[e];n.update(s,i,1)}}function Ga(e){let t={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:t,programs:null,autoReset:!0,reset:function(){t.calls=0,t.triangles=0,t.points=0,t.lines=0},update:function(n,i,a){switch(t.calls++,i){case e.TRIANGLES:t.triangles+=a*(n/3);break;case e.LINES:t.lines+=a*(n/2);break;case e.LINE_STRIP:t.lines+=a*(n-1);break;case e.LINE_LOOP:t.lines+=a*n;break;case e.POINTS:t.points+=a*n;break;default:Ti("WebGLInfo: Unknown draw mode:",i)}}}}function ka(e,t,n){let i=new WeakMap,a=new Fe;return{update:function(r,o,s){let l=r.morphTargetInfluences,c=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,d=void 0!==c?c.length:0,u=i.get(o);if(void 0===u||u.count!==d){let e=function(){g.dispose(),i.delete(o),o.removeEventListener("dispose",e)};void 0!==u&&u.texture.dispose();let n=void 0!==o.morphAttributes.position,r=void 0!==o.morphAttributes.normal,s=void 0!==o.morphAttributes.color,l=o.morphAttributes.position||[],c=o.morphAttributes.normal||[],f=o.morphAttributes.color||[],p=0;!0===n&&(p=1),!0===r&&(p=2),!0===s&&(p=3);let h=o.attributes.position.count*p,m=1;h>t.maxTextureSize&&(m=Math.ceil(h/t.maxTextureSize),h=t.maxTextureSize);let v=new Float32Array(h*m*4*d),g=new Ye(v,h,m,d);g.type=ee,g.needsUpdate=!0;let _=4*p;for(let e=0;e<d;e++){let t=l[e],i=c[e],o=f[e],d=h*m*4*e;for(let e=0;e<t.count;e++){let l=e*_;!0===n&&(a.fromBufferAttribute(t,e),v[d+l+0]=a.x,v[d+l+1]=a.y,v[d+l+2]=a.z,v[d+l+3]=0),!0===r&&(a.fromBufferAttribute(i,e),v[d+l+4]=a.x,v[d+l+5]=a.y,v[d+l+6]=a.z,v[d+l+7]=0),!0===s&&(a.fromBufferAttribute(o,e),v[d+l+8]=a.x,v[d+l+9]=a.y,v[d+l+10]=a.z,v[d+l+11]=4===o.itemSize?a.w:1)}}u={count:d,texture:g,size:new pe(h,m)},i.set(o,u),o.addEventListener("dispose",e)}if(!0===r.isInstancedMesh&&null!==r.morphTexture)s.getUniforms().setValue(e,"morphTexture",r.morphTexture,n);else{let t=0;for(let e=0;e<l.length;e++)t+=l[e];let n=o.morphTargetsRelative?1:1-t;s.getUniforms().setValue(e,"morphTargetBaseInfluence",n),s.getUniforms().setValue(e,"morphTargetInfluences",l)}s.getUniforms().setValue(e,"morphTargetsTexture",u.texture,n),s.getUniforms().setValue(e,"morphTargetsTextureSize",u.size)}}}function Wa(e,t,n,i,a){let r=new WeakMap;function o(e){let t=e.target;t.removeEventListener("dispose",o),i.releaseStatesOfObject(t),n.remove(t.instanceMatrix),null!==t.instanceColor&&n.remove(t.instanceColor)}return{update:function(i){let s=a.render.frame,l=i.geometry,c=t.get(i,l);if(r.get(c)!==s&&(t.update(c),r.set(c,s)),i.isInstancedMesh&&(!1===i.hasEventListener("dispose",o)&&i.addEventListener("dispose",o),r.get(i)!==s&&(n.update(i.instanceMatrix,e.ARRAY_BUFFER),null!==i.instanceColor&&n.update(i.instanceColor,e.ARRAY_BUFFER),r.set(i,s))),i.isSkinnedMesh){let e=i.skeleton;r.get(e)!==s&&(e.update(),r.set(e,s))}return c},dispose:function(){r=new WeakMap}}}var Xa={[yt]:"LINEAR_TONE_MAPPING",[Pt]:"REINHARD_TONE_MAPPING",[Y]:"CINEON_TONE_MAPPING",[It]:"ACES_FILMIC_TONE_MAPPING",[kt]:"AGX_TONE_MAPPING",[$t]:"NEUTRAL_TONE_MAPPING",[zt]:"CUSTOM_TONE_MAPPING"};function ja(e,t,n,i,a,r){let o=new Xe(t,n,{type:e,depthBuffer:a,stencilBuffer:r,samples:i?4:0,depthTexture:a?new de(t,n):void 0}),s=new Xe(t,n,{type:re,depthBuffer:!1,stencilBuffer:!1}),l=new Kt;l.setAttribute("position",new Vt([-1,3,0,-1,-1,0,3,-1,0],3)),l.setAttribute("uv",new Vt([0,2,0,0,2,0],2));let c,d=new Zt({uniforms:{tDiffuse:{value:null}},vertexShader:"\n\t\t\tprecision highp float;\n\n\t\t\tuniform mat4 modelViewMatrix;\n\t\t\tuniform mat4 projectionMatrix;\n\n\t\t\tattribute vec3 position;\n\t\t\tattribute vec2 uv;\n\n\t\t\tvarying vec2 vUv;\n\n\t\t\tvoid main() {\n\t\t\t\tvUv = uv;\n\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t}",fragmentShader:"\n\t\t\tprecision highp float;\n\n\t\t\tuniform sampler2D tDiffuse;\n\n\t\t\tvarying vec2 vUv;\n\n\t\t\t#include <tonemapping_pars_fragment>\n\t\t\t#include <colorspace_pars_fragment>\n\n\t\t\tvoid main() {\n\t\t\t\tgl_FragColor = texture2D( tDiffuse, vUv );\n\n\t\t\t\t#ifdef LINEAR_TONE_MAPPING\n\t\t\t\t\tgl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( REINHARD_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( CINEON_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( ACES_FILMIC_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( AGX_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( NEUTRAL_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( CUSTOM_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb );\n\t\t\t\t#endif\n\n\t\t\t\t#ifdef SRGB_TRANSFER\n\t\t\t\t\tgl_FragColor = sRGBTransferOETF( gl_FragColor );\n\t\t\t\t#endif\n\t\t\t}",depthTest:!1,depthWrite:!1}),u=new Pn(l,d),f=new ie(-1,1,1,-1,0,1),p=null,h=null,m=!1,v=null,g=[],_=!1;this.setSize=function(e,t){o.setSize(e,t),s.setSize(e,t);for(let n=0;n<g.length;n++){let i=g[n];i.setSize&&i.setSize(e,t)}},this.setEffects=function(e){g=e,_=g.length>0&&!0===g[0].isRenderPass;let t=o.width,n=o.height;for(let e=0;e<g.length;e++){let i=g[e];i.setSize&&i.setSize(t,n)}},this.begin=function(e,t){if(m||e.toneMapping===wt&&0===g.length)return!1;if(v=t,null!==t){let e=t.width,n=t.height;(o.width!==e||o.height!==n)&&this.setSize(e,n)}return!1===_&&e.setRenderTarget(o),c=e.toneMapping,e.toneMapping=wt,!0},this.hasRenderPass=function(){return _},this.end=function(e,t){e.toneMapping=c,m=!0;let n=o,i=s;for(let a=0;a<g.length;a++){let r=g[a];if(!1!==r.enabled&&(r.render(e,i,n,t),!1!==r.needsSwap)){let e=n;n=i,i=e}}if(p!==e.outputColorSpace||h!==e.toneMapping){p=e.outputColorSpace,h=e.toneMapping,d.defines={},Ae.getTransfer(p)===We&&(d.defines.SRGB_TRANSFER="");let t=Xa[h];t&&(d.defines[t]=""),d.needsUpdate=!0}d.uniforms.tDiffuse.value=n.texture,e.setRenderTarget(v),e.render(u,f),v=null,m=!1},this.isCompositing=function(){return m},this.dispose=function(){o.depthTexture&&o.depthTexture.dispose(),o.dispose(),s.dispose(),l.dispose(),d.dispose()}}var $a=new Ue,qa=new de(1,1),Ya=new Ye,Ka=new Je,Za=new ne,Ja=[],Qa=[],er=new Float32Array(16),tr=new Float32Array(9),nr=new Float32Array(4);function ir(e,t,n){let i=e[0];if(null==i||i<=0||i>0)return e;let a=t*n,r=Ja[a];if(void 0===r&&(r=new Float32Array(a),Ja[a]=r),0!==t){i.toArray(r,0);for(let i=1,a=0;i!==t;++i)a+=n,e[i].toArray(r,a)}return r}function ar(e,t){if(e.length!==t.length)return!1;for(let n=0,i=e.length;n<i;n++)if(e[n]!==t[n])return!1;return!0}function rr(e,t){for(let n=0,i=t.length;n<i;n++)e[n]=t[n]}function or(e,t){let n=Qa[t];void 0===n&&(n=new Int32Array(t),Qa[t]=n);for(let i=0;i!==t;++i)n[i]=e.allocateTextureUnit();return n}function sr(e,t){let n=this.cache;n[0]!==t&&(e.uniform1f(this.addr,t),n[0]=t)}function lr(e,t){let n=this.cache;if(void 0!==t.x)(n[0]!==t.x||n[1]!==t.y)&&(e.uniform2f(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(ar(n,t))return;e.uniform2fv(this.addr,t),rr(n,t)}}function cr(e,t){let n=this.cache;if(void 0!==t.x)(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)&&(e.uniform3f(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else if(void 0!==t.r)(n[0]!==t.r||n[1]!==t.g||n[2]!==t.b)&&(e.uniform3f(this.addr,t.r,t.g,t.b),n[0]=t.r,n[1]=t.g,n[2]=t.b);else{if(ar(n,t))return;e.uniform3fv(this.addr,t),rr(n,t)}}function dr(e,t){let n=this.cache;if(void 0!==t.x)(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)&&(e.uniform4f(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(ar(n,t))return;e.uniform4fv(this.addr,t),rr(n,t)}}function ur(e,t){let n=this.cache,i=t.elements;if(void 0===i){if(ar(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),rr(n,t)}else{if(ar(n,i))return;nr.set(i),e.uniformMatrix2fv(this.addr,!1,nr),rr(n,i)}}function fr(e,t){let n=this.cache,i=t.elements;if(void 0===i){if(ar(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),rr(n,t)}else{if(ar(n,i))return;tr.set(i),e.uniformMatrix3fv(this.addr,!1,tr),rr(n,i)}}function pr(e,t){let n=this.cache,i=t.elements;if(void 0===i){if(ar(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),rr(n,t)}else{if(ar(n,i))return;er.set(i),e.uniformMatrix4fv(this.addr,!1,er),rr(n,i)}}function hr(e,t){let n=this.cache;n[0]!==t&&(e.uniform1i(this.addr,t),n[0]=t)}function mr(e,t){let n=this.cache;if(void 0!==t.x)(n[0]!==t.x||n[1]!==t.y)&&(e.uniform2i(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(ar(n,t))return;e.uniform2iv(this.addr,t),rr(n,t)}}function vr(e,t){let n=this.cache;if(void 0!==t.x)(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)&&(e.uniform3i(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else{if(ar(n,t))return;e.uniform3iv(this.addr,t),rr(n,t)}}function gr(e,t){let n=this.cache;if(void 0!==t.x)(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)&&(e.uniform4i(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(ar(n,t))return;e.uniform4iv(this.addr,t),rr(n,t)}}function _r(e,t){let n=this.cache;n[0]!==t&&(e.uniform1ui(this.addr,t),n[0]=t)}function xr(e,t){let n=this.cache;if(void 0!==t.x)(n[0]!==t.x||n[1]!==t.y)&&(e.uniform2ui(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(ar(n,t))return;e.uniform2uiv(this.addr,t),rr(n,t)}}function Sr(e,t){let n=this.cache;if(void 0!==t.x)(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)&&(e.uniform3ui(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else{if(ar(n,t))return;e.uniform3uiv(this.addr,t),rr(n,t)}}function Tr(e,t){let n=this.cache;if(void 0!==t.x)(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)&&(e.uniform4ui(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(ar(n,t))return;e.uniform4uiv(this.addr,t),rr(n,t)}}function br(e,t,n){let i,a=this.cache,r=n.allocateTextureUnit();a[0]!==r&&(e.uniform1i(this.addr,r),a[0]=r),this.type===e.SAMPLER_2D_SHADOW?(qa.compareFunction=n.isReversedDepthBuffer()?Tn:cn,i=qa):i=$a,n.setTexture2D(t||i,r)}function wr(e,t,n){let i=this.cache,a=n.allocateTextureUnit();i[0]!==a&&(e.uniform1i(this.addr,a),i[0]=a),n.setTexture3D(t||Ka,a)}function Er(e,t,n){let i=this.cache,a=n.allocateTextureUnit();i[0]!==a&&(e.uniform1i(this.addr,a),i[0]=a),n.setTextureCube(t||Za,a)}function Mr(e,t,n){let i=this.cache,a=n.allocateTextureUnit();i[0]!==a&&(e.uniform1i(this.addr,a),i[0]=a),n.setTexture2DArray(t||Ya,a)}function yr(e,t){e.uniform1fv(this.addr,t)}function Cr(e,t){let n=ir(t,this.size,2);e.uniform2fv(this.addr,n)}function Rr(e,t){let n=ir(t,this.size,3);e.uniform3fv(this.addr,n)}function Ar(e,t){let n=ir(t,this.size,4);e.uniform4fv(this.addr,n)}function Pr(e,t){let n=ir(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,n)}function Dr(e,t){let n=ir(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,n)}function Lr(e,t){let n=ir(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,n)}function Ur(e,t){e.uniform1iv(this.addr,t)}function Nr(e,t){e.uniform2iv(this.addr,t)}function Ir(e,t){e.uniform3iv(this.addr,t)}function Or(e,t){e.uniform4iv(this.addr,t)}function Fr(e,t){e.uniform1uiv(this.addr,t)}function zr(e,t){e.uniform2uiv(this.addr,t)}function Br(e,t){e.uniform3uiv(this.addr,t)}function Vr(e,t){e.uniform4uiv(this.addr,t)}function Hr(e,t,n){let i,a=this.cache,r=t.length,o=or(n,r);ar(a,o)||(e.uniform1iv(this.addr,o),rr(a,o)),i=this.type===e.SAMPLER_2D_SHADOW?qa:$a;for(let e=0;e!==r;++e)n.setTexture2D(t[e]||i,o[e])}function Gr(e,t,n){let i=this.cache,a=t.length,r=or(n,a);ar(i,r)||(e.uniform1iv(this.addr,r),rr(i,r));for(let e=0;e!==a;++e)n.setTexture3D(t[e]||Ka,r[e])}function kr(e,t,n){let i=this.cache,a=t.length,r=or(n,a);ar(i,r)||(e.uniform1iv(this.addr,r),rr(i,r));for(let e=0;e!==a;++e)n.setTextureCube(t[e]||Za,r[e])}function Wr(e,t,n){let i=this.cache,a=t.length,r=or(n,a);ar(i,r)||(e.uniform1iv(this.addr,r),rr(i,r));for(let e=0;e!==a;++e)n.setTexture2DArray(t[e]||Ya,r[e])}var Xr=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=function(e){switch(e){case 5126:return sr;case 35664:return lr;case 35665:return cr;case 35666:return dr;case 35674:return ur;case 35675:return fr;case 35676:return pr;case 5124:case 35670:return hr;case 35667:case 35671:return mr;case 35668:case 35672:return vr;case 35669:case 35673:return gr;case 5125:return _r;case 36294:return xr;case 36295:return Sr;case 36296:return Tr;case 35678:case 36198:case 36298:case 36306:case 35682:return br;case 35679:case 36299:case 36307:return wr;case 35680:case 36300:case 36308:case 36293:return Er;case 36289:case 36303:case 36311:case 36292:return Mr}}(t.type)}},jr=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=function(e){switch(e){case 5126:return yr;case 35664:return Cr;case 35665:return Rr;case 35666:return Ar;case 35674:return Pr;case 35675:return Dr;case 35676:return Lr;case 5124:case 35670:return Ur;case 35667:case 35671:return Nr;case 35668:case 35672:return Ir;case 35669:case 35673:return Or;case 5125:return Fr;case 36294:return zr;case 36295:return Br;case 36296:return Vr;case 35678:case 36198:case 36298:case 36306:case 35682:return Hr;case 35679:case 36299:case 36307:return Gr;case 35680:case 36300:case 36308:case 36293:return kr;case 36289:case 36303:case 36311:case 36292:return Wr}}(t.type)}},$r=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){if(void 0===t)return;let i=this.seq;for(let a=0,r=i.length;a!==r;++a){let r=i[a];r.setValue(e,t[r.id],n)}}},qr=/(\w+)(\])?(\[|\.)?/g;function Yr(e,t){e.seq.push(t),e.map[t.id]=t}function Kr(e,t,n){let i=e.name,a=i.length;for(qr.lastIndex=0;;){let r=qr.exec(i),o=qr.lastIndex,s=r[1],l="]"===r[2],c=r[3];if(l&&(s|=0),void 0===c||"["===c&&o+2===a){Yr(n,void 0===c?new Xr(s,e,t):new jr(s,e,t));break}{let e=n.map[s];void 0===e&&(e=new $r(s),Yr(n,e)),n=e}}}var Zr=class{constructor(e,t){this.seq=[],this.map={};let n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let i=0;i<n;++i){let n=e.getActiveUniform(t,i);Kr(n,e.getUniformLocation(t,n.name),this)}let i=[],a=[];for(let t of this.seq)t.type===e.SAMPLER_2D_SHADOW||t.type===e.SAMPLER_CUBE_SHADOW||t.type===e.SAMPLER_2D_ARRAY_SHADOW?i.push(t):a.push(t);i.length>0&&(this.seq=i.concat(a))}setValue(e,t,n,i){let a=this.map[t];void 0!==a&&a.setValue(e,n,i)}setOptional(e,t,n){let i=t[n];void 0!==i&&this.setValue(e,n,i)}static upload(e,t,n,i){for(let a=0,r=t.length;a!==r;++a){let r=t[a],o=n[r.id];!1!==o.needsUpdate&&r.setValue(e,o.value,i)}}static seqWithValue(e,t){let n=[];for(let i=0,a=e.length;i!==a;++i){let a=e[i];a.id in t&&n.push(a)}return n}};function Jr(e,t,n){let i=e.createShader(t);return e.shaderSource(i,n),e.compileShader(i),i}var Qr=0,eo=new Me;function to(e,t,n){let i=e.getShaderParameter(t,e.COMPILE_STATUS),a=(e.getShaderInfoLog(t)||"").trim();if(i&&""===a)return"";let r=/ERROR: 0:(\d+)/.exec(a);if(r){let i=parseInt(r[1]);return n.toUpperCase()+"\n\n"+a+"\n\n"+function(e,t){let n=e.split("\n"),i=[],a=Math.max(t-6,0),r=Math.min(t+6,n.length);for(let e=a;e<r;e++){let a=e+1;i.push(`${a===t?">":" "} ${a}: ${n[e]}`)}return i.join("\n")}(e.getShaderSource(t),i)}return a}function no(e,t){let n=function(e){Ae._getMatrix(eo,Ae.workingColorSpace,e);let t=`mat3( ${eo.elements.map(e=>e.toFixed(4))} )`;switch(Ae.getTransfer(e)){case He:return[t,"LinearTransferOETF"];case We:return[t,"sRGBTransferOETF"];default:return gi("WebGLProgram: Unsupported color space: ",e),[t,"LinearTransferOETF"]}}(t);return[`vec4 ${e}( vec4 value ) {`,`\treturn ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join("\n")}var io={[yt]:"Linear",[Pt]:"Reinhard",[Y]:"Cineon",[It]:"ACESFilmic",[kt]:"AgX",[$t]:"Neutral",[zt]:"Custom"};function ao(e,t){let n=io[t];return void 0===n?(gi("WebGLProgram: Unsupported toneMapping:",t),"vec3 "+e+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}var ro=new Te;function oo(e){return""!==e}function so(e,t){let n=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return e.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function lo(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}var co=/^[ \t]*#include +<([\w\d./]+)>/gm;function uo(e){return e.replace(co,po)}var fo=new Map;function po(e,t){let n=ya[t];if(void 0===n){let e=fo.get(t);if(void 0===e)throw new Error("THREE.WebGLProgram: Can not resolve #include <"+t+">");n=ya[e],gi('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,e)}return uo(n)}var ho=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function mo(e){return e.replace(ho,vo)}function vo(e,t,n,i){let a="";for(let e=parseInt(t);e<parseInt(n);e++)a+=i.replace(/\[\s*i\s*\]/g,"[ "+e+" ]").replace(/UNROLLED_LOOP_INDEX/g,e);return a}function go(e){let t=`precision ${e.precision} float;\n\tprecision ${e.precision} int;\n\tprecision ${e.precision} sampler2D;\n\tprecision ${e.precision} samplerCube;\n\tprecision ${e.precision} sampler3D;\n\tprecision ${e.precision} sampler2DArray;\n\tprecision ${e.precision} sampler2DShadow;\n\tprecision ${e.precision} samplerCubeShadow;\n\tprecision ${e.precision} sampler2DArrayShadow;\n\tprecision ${e.precision} isampler2D;\n\tprecision ${e.precision} isampler3D;\n\tprecision ${e.precision} isamplerCube;\n\tprecision ${e.precision} isampler2DArray;\n\tprecision ${e.precision} usampler2D;\n\tprecision ${e.precision} usampler3D;\n\tprecision ${e.precision} usamplerCube;\n\tprecision ${e.precision} usampler2DArray;\n\t`;return"highp"===e.precision?t+="\n#define HIGH_PRECISION":"mediump"===e.precision?t+="\n#define MEDIUM_PRECISION":"lowp"===e.precision&&(t+="\n#define LOW_PRECISION"),t}var _o={[on]:"SHADOWMAP_TYPE_PCF",[hn]:"SHADOWMAP_TYPE_VSM"},xo={[nn]:"ENVMAP_TYPE_CUBE",[sn]:"ENVMAP_TYPE_CUBE",[xn]:"ENVMAP_TYPE_CUBE_UV"},So={[sn]:"ENVMAP_MODE_REFRACTION"},To={[mt]:"ENVMAP_BLENDING_MULTIPLY",[xt]:"ENVMAP_BLENDING_MIX",[Tt]:"ENVMAP_BLENDING_ADD"};function bo(e,t,n,i){let a,r,o=e.getContext(),s=n.defines,l=n.vertexShader,c=n.fragmentShader,d=function(e){return _o[e.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}(n),u=function(e){return!1===e.envMap?"ENVMAP_TYPE_CUBE":xo[e.envMapMode]||"ENVMAP_TYPE_CUBE"}(n),f=function(e){return!1===e.envMap?"ENVMAP_MODE_REFLECTION":So[e.envMapMode]||"ENVMAP_MODE_REFLECTION"}(n),p=function(e){return!1===e.envMap?"ENVMAP_BLENDING_NONE":To[e.combine]||"ENVMAP_BLENDING_NONE"}(n),h=function(e){let t=e.envMapCubeUVHeight;if(null===t)return null;let n=Math.log2(t)-2,i=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,n),112)),texelHeight:i,maxMip:n}}(n),m=function(e){return[e.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",e.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(oo).join("\n")}(n),v=function(e){let t=[];for(let n in e){let i=e[n];!1!==i&&t.push("#define "+n+" "+i)}return t.join("\n")}(s),g=o.createProgram(),_=n.glslVersion?"#version "+n.glslVersion+"\n":"";n.isRawShaderMaterial?(a=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,v].filter(oo).join("\n"),a.length>0&&(a+="\n"),r=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,v].filter(oo).join("\n"),r.length>0&&(r+="\n")):(a=[go(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,v,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+f:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexNormals?"#define HAS_NORMAL":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+d:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH","\tuniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(oo).join("\n"),r=[go(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,v,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.envMap?"#define "+f:"",n.envMap?"#define "+p:"",h?"#define CUBEUV_TEXEL_WIDTH "+h.texelWidth:"",h?"#define CUBEUV_TEXEL_HEIGHT "+h.texelHeight:"",h?"#define CUBEUV_MAX_MIP "+h.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas||n.batchingColor?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+d:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==wt?"#define TONE_MAPPING":"",n.toneMapping!==wt?ya.tonemapping_pars_fragment:"",n.toneMapping!==wt?ao("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",ya.colorspace_pars_fragment,no("linearToOutputTexel",n.outputColorSpace),(Ae.getLuminanceCoefficients(ro),["float luminance( const in vec3 rgb ) {",`\tconst vec3 weights = vec3( ${ro.x.toFixed(4)}, ${ro.y.toFixed(4)}, ${ro.z.toFixed(4)} );`,"\treturn dot( weights, rgb );","}"].join("\n")),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(oo).join("\n")),l=uo(l),l=so(l,n),l=lo(l,n),c=uo(c),c=so(c,n),c=lo(c,n),l=mo(l),c=mo(c),!0!==n.isRawShaderMaterial&&(_="#version 300 es\n",a=[m,"#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+a,r=["#define varying in",n.glslVersion===zn?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===zn?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+r);let x,S,T=_+a+l,b=_+r+c,w=Jr(o,o.VERTEX_SHADER,T),E=Jr(o,o.FRAGMENT_SHADER,b);function M(t){if(e.debug.checkShaderErrors){let n=o.getProgramInfoLog(g)||"",i=o.getShaderInfoLog(w)||"",s=o.getShaderInfoLog(E)||"",l=n.trim(),c=i.trim(),d=s.trim(),u=!0,f=!0;if(!1===o.getProgramParameter(g,o.LINK_STATUS))if(u=!1,"function"==typeof e.debug.onShaderError)e.debug.onShaderError(o,g,w,E);else{let e=to(o,w,"vertex"),n=to(o,E,"fragment");Ti("WebGLProgram: Shader Error "+o.getError()+" - VALIDATE_STATUS "+o.getProgramParameter(g,o.VALIDATE_STATUS)+"\n\nMaterial Name: "+t.name+"\nMaterial Type: "+t.type+"\n\nProgram Info Log: "+l+"\n"+e+"\n"+n)}else""!==l?gi("WebGLProgram: Program Info Log:",l):(""===c||""===d)&&(f=!1);f&&(t.diagnostics={runnable:u,programLog:l,vertexShader:{log:c,prefix:a},fragmentShader:{log:d,prefix:r}})}o.deleteShader(w),o.deleteShader(E),x=new Zr(o,g),S=function(e,t){let n={},i=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let a=0;a<i;a++){let i=e.getActiveAttrib(t,a),r=i.name,o=1;i.type===e.FLOAT_MAT2&&(o=2),i.type===e.FLOAT_MAT3&&(o=3),i.type===e.FLOAT_MAT4&&(o=4),n[r]={type:i.type,location:e.getAttribLocation(t,r),locationSize:o}}return n}(o,g)}o.attachShader(g,w),o.attachShader(g,E),void 0!==n.index0AttributeName?o.bindAttribLocation(g,0,n.index0AttributeName):!0===n.hasPositionAttribute&&o.bindAttribLocation(g,0,"position"),o.linkProgram(g),this.getUniforms=function(){return void 0===x&&M(this),x},this.getAttributes=function(){return void 0===S&&M(this),S};let y=!1===n.rendererExtensionParallelShaderCompile;return this.isReady=function(){return!1===y&&(y=o.getProgramParameter(g,37297)),y},this.destroy=function(){i.releaseStatesOfProgram(this),o.deleteProgram(g),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=Qr++,this.cacheKey=t,this.usedTimes=1,this.program=g,this.vertexShader=w,this.fragmentShader=E,this}var wo=0,Eo=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,n){let i=this._getShaderCacheForMaterial(e);return!1===i.has(t)&&(i.add(t),t.usedTimes++),!1===i.has(n)&&(i.add(n),n.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let e of t)e.usedTimes--,0===e.usedTimes&&this.shaderCache.delete(e.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,n=t.get(e);return void 0===n&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){let t=this.shaderCache,n=t.get(e);return void 0===n&&(n=new Mo(e),t.set(e,n)),n}},Mo=class{constructor(e){this.id=wo++,this.code=e,this.usedTimes=0}};function yo(e){return e===et||e===qt||e===Ei}function Co(e,t,n,i,a,r){let o=new rt,s=new Eo,l=new Set,c=[],d=new Map,u=i.logarithmicDepthBuffer,f=i.precision,p={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function h(e){return l.add(e),0===e?"uv":`uv${e}`}return{getParameters:function(a,o,c,d,m,v){let g=d.fog,_=m.geometry,x=a.isMeshStandardMaterial||a.isMeshLambertMaterial||a.isMeshPhongMaterial?d.environment:null,S=a.isMeshStandardMaterial||a.isMeshLambertMaterial&&!a.envMap||a.isMeshPhongMaterial&&!a.envMap,T=t.get(a.envMap||x,S),b=T&&T.mapping===xn?T.image.height:null,w=p[a.type];null!==a.precision&&(f=i.getMaxPrecision(a.precision),f!==a.precision&&gi("WebGLProgram.getParameters:",a.precision,"not supported, using",f,"instead."));let E,M,y,C,R=_.morphAttributes.position||_.morphAttributes.normal||_.morphAttributes.color,A=void 0!==R?R.length:0,P=0;if(void 0!==_.morphAttributes.position&&(P=1),void 0!==_.morphAttributes.normal&&(P=2),void 0!==_.morphAttributes.color&&(P=3),w){let e=Ra[w];E=e.vertexShader,M=e.fragmentShader}else{E=a.vertexShader,M=a.fragmentShader;let e=s.getVertexShaderStage(a),t=s.getFragmentShaderStage(a);s.update(a,e,t),y=e.id,C=t.id}let D=e.getRenderTarget(),L=e.state.buffers.depth.getReversed(),U=!0===m.isInstancedMesh,N=!0===m.isBatchedMesh,I=!!a.map,O=!!a.matcap,F=!!T,z=!!a.aoMap,B=!!a.lightMap,V=!!a.bumpMap&&!1===a.wireframe,H=!!a.normalMap,G=!!a.displacementMap,k=!!a.emissiveMap,W=!!a.metalnessMap,X=!!a.roughnessMap,j=a.anisotropy>0,$=a.clearcoat>0,q=a.dispersion>0,Y=a.iridescence>0,K=a.sheen>0,Z=a.transmission>0,J=j&&!!a.anisotropyMap,Q=$&&!!a.clearcoatMap,ee=$&&!!a.clearcoatNormalMap,te=$&&!!a.clearcoatRoughnessMap,ne=Y&&!!a.iridescenceMap,ie=Y&&!!a.iridescenceThicknessMap,ae=K&&!!a.sheenColorMap,re=K&&!!a.sheenRoughnessMap,oe=!!a.specularMap,se=!!a.specularColorMap,le=!!a.specularIntensityMap,ce=Z&&!!a.transmissionMap,de=Z&&!!a.thicknessMap,ue=!!a.gradientMap,fe=!!a.alphaMap,pe=a.alphaTest>0,he=!!a.alphaHash,me=!!a.extensions,ve=wt;a.toneMapped&&(null===D||!0===D.isXRRenderTarget)&&(ve=e.toneMapping);let ge={shaderID:w,shaderType:a.type,shaderName:a.name,vertexShader:E,fragmentShader:M,defines:a.defines,customVertexShaderID:y,customFragmentShaderID:C,isRawShaderMaterial:!0===a.isRawShaderMaterial,glslVersion:a.glslVersion,precision:f,batching:N,batchingColor:N&&null!==m._colorsTexture,instancing:U,instancingColor:U&&null!==m.instanceColor,instancingMorph:U&&null!==m.morphTexture,outputColorSpace:null===D?e.outputColorSpace:!0===D.isXRRenderTarget?D.texture.colorSpace:Ae.workingColorSpace,alphaToCoverage:!!a.alphaToCoverage,map:I,matcap:O,envMap:F,envMapMode:F&&T.mapping,envMapCubeUVHeight:b,aoMap:z,lightMap:B,bumpMap:V,normalMap:H,displacementMap:G,emissiveMap:k,normalMapObjectSpace:H&&a.normalMapType===Ee,normalMapTangentSpace:H&&a.normalMapType===Se,packedNormalMap:H&&a.normalMapType===Se&&yo(a.normalMap.format),metalnessMap:W,roughnessMap:X,anisotropy:j,anisotropyMap:J,clearcoat:$,clearcoatMap:Q,clearcoatNormalMap:ee,clearcoatRoughnessMap:te,dispersion:q,iridescence:Y,iridescenceMap:ne,iridescenceThicknessMap:ie,sheen:K,sheenColorMap:ae,sheenRoughnessMap:re,specularMap:oe,specularColorMap:se,specularIntensityMap:le,transmission:Z,transmissionMap:ce,thicknessMap:de,gradientMap:ue,opaque:!1===a.transparent&&a.blending===In&&!1===a.alphaToCoverage,alphaMap:fe,alphaTest:pe,alphaHash:he,combine:a.combine,mapUv:I&&h(a.map.channel),aoMapUv:z&&h(a.aoMap.channel),lightMapUv:B&&h(a.lightMap.channel),bumpMapUv:V&&h(a.bumpMap.channel),normalMapUv:H&&h(a.normalMap.channel),displacementMapUv:G&&h(a.displacementMap.channel),emissiveMapUv:k&&h(a.emissiveMap.channel),metalnessMapUv:W&&h(a.metalnessMap.channel),roughnessMapUv:X&&h(a.roughnessMap.channel),anisotropyMapUv:J&&h(a.anisotropyMap.channel),clearcoatMapUv:Q&&h(a.clearcoatMap.channel),clearcoatNormalMapUv:ee&&h(a.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:te&&h(a.clearcoatRoughnessMap.channel),iridescenceMapUv:ne&&h(a.iridescenceMap.channel),iridescenceThicknessMapUv:ie&&h(a.iridescenceThicknessMap.channel),sheenColorMapUv:ae&&h(a.sheenColorMap.channel),sheenRoughnessMapUv:re&&h(a.sheenRoughnessMap.channel),specularMapUv:oe&&h(a.specularMap.channel),specularColorMapUv:se&&h(a.specularColorMap.channel),specularIntensityMapUv:le&&h(a.specularIntensityMap.channel),transmissionMapUv:ce&&h(a.transmissionMap.channel),thicknessMapUv:de&&h(a.thicknessMap.channel),alphaMapUv:fe&&h(a.alphaMap.channel),vertexTangents:!!_.attributes.tangent&&(H||j),vertexNormals:!!_.attributes.normal,vertexColors:a.vertexColors,vertexAlphas:!0===a.vertexColors&&!!_.attributes.color&&4===_.attributes.color.itemSize,pointsUvs:!0===m.isPoints&&!!_.attributes.uv&&(I||fe),fog:!!g,useFog:!0===a.fog,fogExp2:!!g&&g.isFogExp2,flatShading:!1===a.wireframe&&(!0===a.flatShading||void 0===_.attributes.normal&&!1===H&&(a.isMeshLambertMaterial||a.isMeshPhongMaterial||a.isMeshStandardMaterial||a.isMeshPhysicalMaterial)),sizeAttenuation:!0===a.sizeAttenuation,logarithmicDepthBuffer:u,reversedDepthBuffer:L,skinning:!0===m.isSkinnedMesh,hasPositionAttribute:void 0!==_.attributes.position,morphTargets:void 0!==_.morphAttributes.position,morphNormals:void 0!==_.morphAttributes.normal,morphColors:void 0!==_.morphAttributes.color,morphTargetsCount:A,morphTextureStride:P,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numSpotLightMaps:o.spotLightMap.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numSpotLightShadowsWithMaps:o.numSpotLightShadowsWithMaps,numLightProbes:o.numLightProbes,numLightProbeGrids:v.length,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:a.dithering,shadowMapEnabled:e.shadowMap.enabled&&c.length>0,shadowMapType:e.shadowMap.type,toneMapping:ve,decodeVideoTexture:I&&!0===a.map.isVideoTexture&&Ae.getTransfer(a.map.colorSpace)===We,decodeVideoTextureEmissive:k&&!0===a.emissiveMap.isVideoTexture&&Ae.getTransfer(a.emissiveMap.colorSpace)===We,premultipliedAlpha:a.premultipliedAlpha,doubleSided:a.side===Cn,flipSided:a.side===bn,useDepthPacking:a.depthPacking>=0,depthPacking:a.depthPacking||0,index0AttributeName:a.index0AttributeName,extensionClipCullDistance:me&&!0===a.extensions.clipCullDistance&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(me&&!0===a.extensions.multiDraw||N)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:a.customProgramCacheKey()};return ge.vertexUv1s=l.has(1),ge.vertexUv2s=l.has(2),ge.vertexUv3s=l.has(3),l.clear(),ge},getProgramCacheKey:function(t){let n=[];if(t.shaderID?n.push(t.shaderID):(n.push(t.customVertexShaderID),n.push(t.customFragmentShaderID)),void 0!==t.defines)for(let e in t.defines)n.push(e),n.push(t.defines[e]);return!1===t.isRawShaderMaterial&&(function(e,t){e.push(t.precision),e.push(t.outputColorSpace),e.push(t.envMapMode),e.push(t.envMapCubeUVHeight),e.push(t.mapUv),e.push(t.alphaMapUv),e.push(t.lightMapUv),e.push(t.aoMapUv),e.push(t.bumpMapUv),e.push(t.normalMapUv),e.push(t.displacementMapUv),e.push(t.emissiveMapUv),e.push(t.metalnessMapUv),e.push(t.roughnessMapUv),e.push(t.anisotropyMapUv),e.push(t.clearcoatMapUv),e.push(t.clearcoatNormalMapUv),e.push(t.clearcoatRoughnessMapUv),e.push(t.iridescenceMapUv),e.push(t.iridescenceThicknessMapUv),e.push(t.sheenColorMapUv),e.push(t.sheenRoughnessMapUv),e.push(t.specularMapUv),e.push(t.specularColorMapUv),e.push(t.specularIntensityMapUv),e.push(t.transmissionMapUv),e.push(t.thicknessMapUv),e.push(t.combine),e.push(t.fogExp2),e.push(t.sizeAttenuation),e.push(t.morphTargetsCount),e.push(t.morphAttributeCount),e.push(t.numDirLights),e.push(t.numPointLights),e.push(t.numSpotLights),e.push(t.numSpotLightMaps),e.push(t.numHemiLights),e.push(t.numRectAreaLights),e.push(t.numDirLightShadows),e.push(t.numPointLightShadows),e.push(t.numSpotLightShadows),e.push(t.numSpotLightShadowsWithMaps),e.push(t.numLightProbes),e.push(t.shadowMapType),e.push(t.toneMapping),e.push(t.numClippingPlanes),e.push(t.numClipIntersection),e.push(t.depthPacking)}(n,t),function(e,t){o.disableAll(),t.instancing&&o.enable(0),t.instancingColor&&o.enable(1),t.instancingMorph&&o.enable(2),t.matcap&&o.enable(3),t.envMap&&o.enable(4),t.normalMapObjectSpace&&o.enable(5),t.normalMapTangentSpace&&o.enable(6),t.clearcoat&&o.enable(7),t.iridescence&&o.enable(8),t.alphaTest&&o.enable(9),t.vertexColors&&o.enable(10),t.vertexAlphas&&o.enable(11),t.vertexUv1s&&o.enable(12),t.vertexUv2s&&o.enable(13),t.vertexUv3s&&o.enable(14),t.vertexTangents&&o.enable(15),t.anisotropy&&o.enable(16),t.alphaHash&&o.enable(17),t.batching&&o.enable(18),t.dispersion&&o.enable(19),t.batchingColor&&o.enable(20),t.gradientMap&&o.enable(21),t.packedNormalMap&&o.enable(22),t.vertexNormals&&o.enable(23),e.push(o.mask),o.disableAll(),t.fog&&o.enable(0),t.useFog&&o.enable(1),t.flatShading&&o.enable(2),t.logarithmicDepthBuffer&&o.enable(3),t.reversedDepthBuffer&&o.enable(4),t.skinning&&o.enable(5),t.morphTargets&&o.enable(6),t.morphNormals&&o.enable(7),t.morphColors&&o.enable(8),t.premultipliedAlpha&&o.enable(9),t.shadowMapEnabled&&o.enable(10),t.doubleSided&&o.enable(11),t.flipSided&&o.enable(12),t.useDepthPacking&&o.enable(13),t.dithering&&o.enable(14),t.transmission&&o.enable(15),t.sheen&&o.enable(16),t.opaque&&o.enable(17),t.pointsUvs&&o.enable(18),t.decodeVideoTexture&&o.enable(19),t.decodeVideoTextureEmissive&&o.enable(20),t.alphaToCoverage&&o.enable(21),t.numLightProbeGrids>0&&o.enable(22),t.hasPositionAttribute&&o.enable(23),e.push(o.mask)}(n,t),n.push(e.outputColorSpace)),n.push(t.customProgramCacheKey),n.join()},getUniforms:function(e){let t,n=p[e.type];if(n){let e=Ra[n];t=Ht.clone(e.uniforms)}else t=e.uniforms;return t},acquireProgram:function(t,n){let i=d.get(n);return void 0!==i?++i.usedTimes:(i=new bo(e,n,t,a),c.push(i),d.set(n,i)),i},releaseProgram:function(e){if(0===--e.usedTimes){let t=c.indexOf(e);c[t]=c[c.length-1],c.pop(),d.delete(e.cacheKey),e.destroy()}},releaseShaderCache:function(e){s.remove(e)},programs:c,dispose:function(){s.dispose()}}}function Ro(){let e=new WeakMap;return{has:function(t){return e.has(t)},get:function(t){let n=e.get(t);return void 0===n&&(n={},e.set(t,n)),n},remove:function(t){e.delete(t)},update:function(t,n,i){e.get(t)[n]=i},dispose:function(){e=new WeakMap}}}function Ao(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.material.id!==t.material.id?e.material.id-t.material.id:e.materialVariant!==t.materialVariant?e.materialVariant-t.materialVariant:e.z!==t.z?e.z-t.z:e.id-t.id}function Po(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function Do(){let e=[],t=0,n=[],i=[],a=[];function r(e){let t=0;return e.isInstancedMesh&&(t+=2),e.isSkinnedMesh&&(t+=1),t}function o(n,i,a,o,s,l){let c=e[t];return void 0===c?(c={id:n.id,object:n,geometry:i,material:a,materialVariant:r(n),groupOrder:o,renderOrder:n.renderOrder,z:s,group:l},e[t]=c):(c.id=n.id,c.object=n,c.geometry=i,c.material=a,c.materialVariant=r(n),c.groupOrder=o,c.renderOrder=n.renderOrder,c.z=s,c.group=l),t++,c}return{opaque:n,transmissive:i,transparent:a,init:function(){t=0,n.length=0,i.length=0,a.length=0},push:function(e,t,r,s,l,c){let d=o(e,t,r,s,l,c);r.transmission>0?i.push(d):!0===r.transparent?a.push(d):n.push(d)},unshift:function(e,t,r,s,l,c){let d=o(e,t,r,s,l,c);r.transmission>0?i.unshift(d):!0===r.transparent?a.unshift(d):n.unshift(d)},finish:function(){for(let n=t,i=e.length;n<i;n++){let t=e[n];if(null===t.id)break;t.id=null,t.object=null,t.geometry=null,t.material=null,t.group=null}},sort:function(e,t,r){n.length>1&&n.sort(e||Ao),i.length>1&&i.sort(t||Po),a.length>1&&a.sort(t||Po),r&&(n.reverse(),i.reverse(),a.reverse())}}}function Lo(){let e=new WeakMap;return{get:function(t,n){let i,a=e.get(t);return void 0===a?(i=new Do,e.set(t,[i])):n>=a.length?(i=new Do,a.push(i)):i=a[n],i},dispose:function(){e=new WeakMap}}}function Uo(){let e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":n={direction:new Te,color:new ft};break;case"SpotLight":n={position:new Te,direction:new Te,color:new ft,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new Te,color:new ft,distance:0,decay:0};break;case"HemisphereLight":n={direction:new Te,skyColor:new ft,groundColor:new ft};break;case"RectAreaLight":n={color:new ft,position:new Te,halfWidth:new Te,halfHeight:new Te}}return e[t.id]=n,n}}}var No=0;function Io(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function Oo(e){let t=new Uo,n=function(){let e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new pe};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new pe,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.id]=n,n}}}(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let e=0;e<9;e++)i.probe.push(new Te);let a=new Te,r=new tt,o=new tt;return{setup:function(a){let r=0,o=0,s=0;for(let e=0;e<9;e++)i.probe[e].set(0,0,0);let l=0,c=0,d=0,u=0,f=0,p=0,h=0,m=0,v=0,g=0,_=0;a.sort(Io);for(let e=0,x=a.length;e<x;e++){let x=a[e],S=x.color,T=x.intensity,b=x.distance,w=null;if(x.shadow&&x.shadow.map&&(w=x.shadow.map.texture.format===et?x.shadow.map.texture:x.shadow.map.depthTexture||x.shadow.map.texture),x.isAmbientLight)r+=S.r*T,o+=S.g*T,s+=S.b*T;else if(x.isLightProbe){for(let e=0;e<9;e++)i.probe[e].addScaledVector(x.sh.coefficients[e],T);_++}else if(x.isDirectionalLight){let e=t.get(x);if(e.color.copy(x.color).multiplyScalar(x.intensity),x.castShadow){let e=x.shadow,t=n.get(x);t.shadowIntensity=e.intensity,t.shadowBias=e.bias,t.shadowNormalBias=e.normalBias,t.shadowRadius=e.radius,t.shadowMapSize=e.mapSize,i.directionalShadow[l]=t,i.directionalShadowMap[l]=w,i.directionalShadowMatrix[l]=x.shadow.matrix,p++}i.directional[l]=e,l++}else if(x.isSpotLight){let e=t.get(x);e.position.setFromMatrixPosition(x.matrixWorld),e.color.copy(S).multiplyScalar(T),e.distance=b,e.coneCos=Math.cos(x.angle),e.penumbraCos=Math.cos(x.angle*(1-x.penumbra)),e.decay=x.decay,i.spot[d]=e;let a=x.shadow;if(x.map&&(i.spotLightMap[v]=x.map,v++,a.updateMatrices(x),x.castShadow&&g++),i.spotLightMatrix[d]=a.matrix,x.castShadow){let e=n.get(x);e.shadowIntensity=a.intensity,e.shadowBias=a.bias,e.shadowNormalBias=a.normalBias,e.shadowRadius=a.radius,e.shadowMapSize=a.mapSize,i.spotShadow[d]=e,i.spotShadowMap[d]=w,m++}d++}else if(x.isRectAreaLight){let e=t.get(x);e.color.copy(S).multiplyScalar(T),e.halfWidth.set(.5*x.width,0,0),e.halfHeight.set(0,.5*x.height,0),i.rectArea[u]=e,u++}else if(x.isPointLight){let e=t.get(x);if(e.color.copy(x.color).multiplyScalar(x.intensity),e.distance=x.distance,e.decay=x.decay,x.castShadow){let e=x.shadow,t=n.get(x);t.shadowIntensity=e.intensity,t.shadowBias=e.bias,t.shadowNormalBias=e.normalBias,t.shadowRadius=e.radius,t.shadowMapSize=e.mapSize,t.shadowCameraNear=e.camera.near,t.shadowCameraFar=e.camera.far,i.pointShadow[c]=t,i.pointShadowMap[c]=w,i.pointShadowMatrix[c]=x.shadow.matrix,h++}i.point[c]=e,c++}else if(x.isHemisphereLight){let e=t.get(x);e.skyColor.copy(x.color).multiplyScalar(T),e.groundColor.copy(x.groundColor).multiplyScalar(T),i.hemi[f]=e,f++}}u>0&&(!0===e.has("OES_texture_float_linear")?(i.rectAreaLTC1=Ca.LTC_FLOAT_1,i.rectAreaLTC2=Ca.LTC_FLOAT_2):(i.rectAreaLTC1=Ca.LTC_HALF_1,i.rectAreaLTC2=Ca.LTC_HALF_2)),i.ambient[0]=r,i.ambient[1]=o,i.ambient[2]=s;let x=i.hash;(x.directionalLength!==l||x.pointLength!==c||x.spotLength!==d||x.rectAreaLength!==u||x.hemiLength!==f||x.numDirectionalShadows!==p||x.numPointShadows!==h||x.numSpotShadows!==m||x.numSpotMaps!==v||x.numLightProbes!==_)&&(i.directional.length=l,i.spot.length=d,i.rectArea.length=u,i.point.length=c,i.hemi.length=f,i.directionalShadow.length=p,i.directionalShadowMap.length=p,i.pointShadow.length=h,i.pointShadowMap.length=h,i.spotShadow.length=m,i.spotShadowMap.length=m,i.directionalShadowMatrix.length=p,i.pointShadowMatrix.length=h,i.spotLightMatrix.length=m+v-g,i.spotLightMap.length=v,i.numSpotLightShadowsWithMaps=g,i.numLightProbes=_,x.directionalLength=l,x.pointLength=c,x.spotLength=d,x.rectAreaLength=u,x.hemiLength=f,x.numDirectionalShadows=p,x.numPointShadows=h,x.numSpotShadows=m,x.numSpotMaps=v,x.numLightProbes=_,i.version=No++)},setupView:function(e,t){let n=0,s=0,l=0,c=0,d=0,u=t.matrixWorldInverse;for(let t=0,f=e.length;t<f;t++){let f=e[t];if(f.isDirectionalLight){let e=i.directional[n];e.direction.setFromMatrixPosition(f.matrixWorld),a.setFromMatrixPosition(f.target.matrixWorld),e.direction.sub(a),e.direction.transformDirection(u),n++}else if(f.isSpotLight){let e=i.spot[l];e.position.setFromMatrixPosition(f.matrixWorld),e.position.applyMatrix4(u),e.direction.setFromMatrixPosition(f.matrixWorld),a.setFromMatrixPosition(f.target.matrixWorld),e.direction.sub(a),e.direction.transformDirection(u),l++}else if(f.isRectAreaLight){let e=i.rectArea[c];e.position.setFromMatrixPosition(f.matrixWorld),e.position.applyMatrix4(u),o.identity(),r.copy(f.matrixWorld),r.premultiply(u),o.extractRotation(r),e.halfWidth.set(.5*f.width,0,0),e.halfHeight.set(0,.5*f.height,0),e.halfWidth.applyMatrix4(o),e.halfHeight.applyMatrix4(o),c++}else if(f.isPointLight){let e=i.point[s];e.position.setFromMatrixPosition(f.matrixWorld),e.position.applyMatrix4(u),s++}else if(f.isHemisphereLight){let e=i.hemi[d];e.direction.setFromMatrixPosition(f.matrixWorld),e.direction.transformDirection(u),d++}}},state:i}}function Fo(e){let t=new Oo(e),n=[],i=[],a=[],r={lightsArray:n,shadowsArray:i,lightProbeGridArray:a,camera:null,lights:t,transmissionRenderTarget:{},textureUnits:0};return{init:function(e){r.camera=e,n.length=0,i.length=0,a.length=0},state:r,setupLights:function(){t.setup(n)},setupLightsView:function(e){t.setupView(n,e)},pushLight:function(e){n.push(e)},pushShadow:function(e){i.push(e)},pushLightProbeGrid:function(e){a.push(e)}}}function zo(e){let t=new WeakMap;return{get:function(n,i=0){let a,r=t.get(n);return void 0===r?(a=new Fo(e),t.set(n,[a])):i>=r.length?(a=new Fo(e),r.push(a)):a=r[i],a},dispose:function(){t=new WeakMap}}}var Bo=[new Te(1,0,0),new Te(-1,0,0),new Te(0,1,0),new Te(0,-1,0),new Te(0,0,1),new Te(0,0,-1)],Vo=[new Te(0,-1,0),new Te(0,-1,0),new Te(0,0,1),new Te(0,0,-1),new Te(0,-1,0),new Te(0,-1,0)],Ho=new tt,Go=new Te,ko=new Te;function Wo(e,t,n){let i=new ni,a=new pe,r=new pe,o=new Fe,s=new yn,l=new Dn,c={},d=n.maxTextureSize,u={[_n]:bn,[bn]:_n,[Cn]:Cn},f=new Xt({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new pe},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg;\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r;\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );\n\tgl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );\n}"}),p=f.clone();p.defines.HORIZONTAL_PASS=1;let h=new Kt;h.setAttribute("position",new Rt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let m=new Pn(h,f),v=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=on;let g=this.type;function _(n,i){let r=t.update(m);f.defines.VSM_SAMPLES!==n.blurSamples&&(f.defines.VSM_SAMPLES=n.blurSamples,p.defines.VSM_SAMPLES=n.blurSamples,f.needsUpdate=!0,p.needsUpdate=!0),null===n.mapPass&&(n.mapPass=new Xe(a.x,a.y,{format:et,type:re})),f.uniforms.shadow_pass.value=n.map.depthTexture,f.uniforms.resolution.value=n.mapSize,f.uniforms.radius.value=n.radius,e.setRenderTarget(n.mapPass),e.clear(),e.renderBufferDirect(i,null,r,f,m,null),p.uniforms.shadow_pass.value=n.mapPass.texture,p.uniforms.resolution.value=n.mapSize,p.uniforms.radius.value=n.radius,e.setRenderTarget(n.map),e.clear(),e.renderBufferDirect(i,null,r,p,m,null)}function x(t,n,i,a){let r=null,o=!0===i.isPointLight?t.customDistanceMaterial:t.customDepthMaterial;if(void 0!==o)r=o;else if(r=!0===i.isPointLight?l:s,e.localClippingEnabled&&!0===n.clipShadows&&Array.isArray(n.clippingPlanes)&&0!==n.clippingPlanes.length||n.displacementMap&&0!==n.displacementScale||n.alphaMap&&n.alphaTest>0||n.map&&n.alphaTest>0||!0===n.alphaToCoverage){let e=r.uuid,t=n.uuid,i=c[e];void 0===i&&(i={},c[e]=i);let a=i[t];void 0===a&&(a=r.clone(),i[t]=a,n.addEventListener("dispose",T)),r=a}return r.visible=n.visible,r.wireframe=n.wireframe,r.side=a===hn?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:u[n.side],r.alphaMap=n.alphaMap,r.alphaTest=!0===n.alphaToCoverage?.5:n.alphaTest,r.map=n.map,r.clipShadows=n.clipShadows,r.clippingPlanes=n.clippingPlanes,r.clipIntersection=n.clipIntersection,r.displacementMap=n.displacementMap,r.displacementScale=n.displacementScale,r.displacementBias=n.displacementBias,r.wireframeLinewidth=n.wireframeLinewidth,r.linewidth=n.linewidth,!0===i.isPointLight&&!0===r.isMeshDistanceMaterial&&(e.properties.get(r).light=i),r}function S(n,a,r,o,s){if(!1===n.visible)return;if(n.layers.test(a.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&s===hn)&&(!n.frustumCulled||i.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,n.matrixWorld);let i=t.update(n),l=n.material;if(Array.isArray(l)){let t=i.groups;for(let c=0,d=t.length;c<d;c++){let d=t[c],u=l[d.materialIndex];if(u&&u.visible){let t=x(n,u,o,s);n.onBeforeShadow(e,n,a,r,i,t,d),e.renderBufferDirect(r,null,i,t,n,d),n.onAfterShadow(e,n,a,r,i,t,d)}}}else if(l.visible){let t=x(n,l,o,s);n.onBeforeShadow(e,n,a,r,i,t,null),e.renderBufferDirect(r,null,i,t,n,null),n.onAfterShadow(e,n,a,r,i,t,null)}}let l=n.children;for(let e=0,t=l.length;e<t;e++)S(l[e],a,r,o,s)}function T(e){e.target.removeEventListener("dispose",T);for(let t in c){let n=c[t],i=e.target.uuid;i in n&&(n[i].dispose(),delete n[i])}}this.render=function(t,n,s){if(!1===v.enabled||!1===v.autoUpdate&&!1===v.needsUpdate||0===t.length)return;this.type===dn&&(gi("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=on);let l=e.getRenderTarget(),c=e.getActiveCubeFace(),u=e.getActiveMipmapLevel(),f=e.state;f.setBlending(Ln),!0===f.buffers.depth.getReversed()?f.buffers.color.setClear(0,0,0,0):f.buffers.color.setClear(1,1,1,1),f.buffers.depth.setTest(!0),f.setScissorTest(!1);let p=g!==this.type;p&&n.traverse(function(e){e.material&&(Array.isArray(e.material)?e.material.forEach(e=>e.needsUpdate=!0):e.material.needsUpdate=!0)});for(let l=0,c=t.length;l<c;l++){let c=t[l],u=c.shadow;if(void 0===u){gi("WebGLShadowMap:",c,"has no shadow.");continue}if(!1===u.autoUpdate&&!1===u.needsUpdate)continue;a.copy(u.mapSize);let h=u.getFrameExtents();a.multiply(h),r.copy(u.mapSize),(a.x>d||a.y>d)&&(a.x>d&&(r.x=Math.floor(d/h.x),a.x=r.x*h.x,u.mapSize.x=r.x),a.y>d&&(r.y=Math.floor(d/h.y),a.y=r.y*h.y,u.mapSize.y=r.y));let m=e.state.buffers.depth.getReversed();if(u.camera._reversedDepth=m,null===u.map||!0===p){if(null!==u.map&&(null!==u.map.depthTexture&&(u.map.depthTexture.dispose(),u.map.depthTexture=null),u.map.dispose()),this.type===hn){if(c.isPointLight){gi("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}u.map=new Xe(a.x,a.y,{format:et,type:re,minFilter:qn,magFilter:qn,generateMipmaps:!1}),u.map.texture.name=c.name+".shadowMap",u.map.depthTexture=new de(a.x,a.y,ee),u.map.depthTexture.name=c.name+".shadowMapDepth",u.map.depthTexture.format=Ve,u.map.depthTexture.compareFunction=null,u.map.depthTexture.minFilter=On,u.map.depthTexture.magFilter=On}else c.isPointLight?(u.map=new Fa(a.x),u.map.depthTexture=new he(a.x,Ci)):(u.map=new Xe(a.x,a.y),u.map.depthTexture=new de(a.x,a.y,Ci)),u.map.depthTexture.name=c.name+".shadowMap",u.map.depthTexture.format=Ve,this.type===on?(u.map.depthTexture.compareFunction=m?Tn:cn,u.map.depthTexture.minFilter=qn,u.map.depthTexture.magFilter=qn):(u.map.depthTexture.compareFunction=null,u.map.depthTexture.minFilter=On,u.map.depthTexture.magFilter=On);u.camera.updateProjectionMatrix()}let v=u.map.isWebGLCubeRenderTarget?6:1;for(let t=0;t<v;t++){if(u.map.isWebGLCubeRenderTarget)e.setRenderTarget(u.map,t),e.clear();else{0===t&&(e.setRenderTarget(u.map),e.clear());let n=u.getViewport(t);o.set(r.x*n.x,r.y*n.y,r.x*n.z,r.y*n.w),f.viewport(o)}if(c.isPointLight){let e=u.camera,n=u.matrix,i=c.distance||e.far;i!==e.far&&(e.far=i,e.updateProjectionMatrix()),Go.setFromMatrixPosition(c.matrixWorld),e.position.copy(Go),ko.copy(e.position),ko.add(Bo[t]),e.up.copy(Vo[t]),e.lookAt(ko),e.updateMatrixWorld(),n.makeTranslation(-Go.x,-Go.y,-Go.z),Ho.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),u._frustum.setFromProjectionMatrix(Ho,e.coordinateSystem,e.reversedDepth)}else u.updateMatrices(c);i=u.getFrustum(),S(n,s,u.camera,c,this.type)}!0!==u.isPointLightShadow&&this.type===hn&&_(u,s),u.needsUpdate=!1}g=this.type,v.needsUpdate=!1,e.setRenderTarget(l,c,u)}}function Xo(e,t){let n=new function(){let t=!1,n=new Fe,i=null,a=new Fe(0,0,0,0);return{setMask:function(n){i!==n&&!t&&(e.colorMask(n,n,n,n),i=n)},setLocked:function(e){t=e},setClear:function(t,i,r,o,s){!0===s&&(t*=o,i*=o,r*=o),n.set(t,i,r,o),!1===a.equals(n)&&(e.clearColor(t,i,r,o),a.copy(n))},reset:function(){t=!1,i=null,a.set(-1,0,0,0)}}},i=new function(){let n=!1,i=!1,a=null,r=null,o=null;return{setReversed:function(e){if(i!==e){let n=t.get("EXT_clip_control");e?n.clipControlEXT(n.LOWER_LEFT_EXT,n.ZERO_TO_ONE_EXT):n.clipControlEXT(n.LOWER_LEFT_EXT,n.NEGATIVE_ONE_TO_ONE_EXT),i=e;let a=o;o=null,this.setClear(a)}},getReversed:function(){return i},setTest:function(t){t?H(e.DEPTH_TEST):G(e.DEPTH_TEST)},setMask:function(t){a!==t&&!n&&(e.depthMask(t),a=t)},setFunc:function(t){if(i&&(t=te[t]),r!==t){switch(t){case Ke:e.depthFunc(e.NEVER);break;case Qe:e.depthFunc(e.ALWAYS);break;case nt:e.depthFunc(e.LESS);break;case at:e.depthFunc(e.LEQUAL);break;case ot:e.depthFunc(e.EQUAL);break;case lt:e.depthFunc(e.GEQUAL);break;case dt:e.depthFunc(e.GREATER);break;case pt:e.depthFunc(e.NOTEQUAL);break;default:e.depthFunc(e.LEQUAL)}r=t}},setLocked:function(e){n=e},setClear:function(t){o!==t&&(o=t,i&&(t=1-t),e.clearDepth(t))},reset:function(){n=!1,a=null,r=null,o=null,i=!1}}},a=new function(){let t=!1,n=null,i=null,a=null,r=null,o=null,s=null,l=null,c=null;return{setTest:function(n){t||(n?H(e.STENCIL_TEST):G(e.STENCIL_TEST))},setMask:function(i){n!==i&&!t&&(e.stencilMask(i),n=i)},setFunc:function(t,n,o){(i!==t||a!==n||r!==o)&&(e.stencilFunc(t,n,o),i=t,a=n,r=o)},setOp:function(t,n,i){(o!==t||s!==n||l!==i)&&(e.stencilOp(t,n,i),o=t,s=n,l=i)},setLocked:function(e){t=e},setClear:function(t){c!==t&&(e.clearStencil(t),c=t)},reset:function(){t=!1,n=null,i=null,a=null,r=null,o=null,s=null,l=null,c=null}}},r=new WeakMap,o=new WeakMap,s={},l={},c={},d=new WeakMap,u=[],f=null,p=!1,h=null,m=null,v=null,g=null,_=null,x=null,S=null,T=new ft(0,0,0),b=0,w=!1,E=null,M=null,y=null,C=null,R=null,A=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS),P=!1,D=0,L=e.getParameter(e.VERSION);-1!==L.indexOf("WebGL")?(D=parseFloat(/^WebGL (\d)/.exec(L)[1]),P=D>=1):-1!==L.indexOf("OpenGL ES")&&(D=parseFloat(/^OpenGL ES (\d)/.exec(L)[1]),P=D>=2);let U=null,N={},I=e.getParameter(e.SCISSOR_BOX),O=e.getParameter(e.VIEWPORT),F=(new Fe).fromArray(I),z=(new Fe).fromArray(O);function B(t,n,i,a){let r=new Uint8Array(4),o=e.createTexture();e.bindTexture(t,o),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let o=0;o<i;o++)t===e.TEXTURE_3D||t===e.TEXTURE_2D_ARRAY?e.texImage3D(n,0,e.RGBA,1,1,a,0,e.RGBA,e.UNSIGNED_BYTE,r):e.texImage2D(n+o,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,r);return o}let V={};function H(t){!0!==s[t]&&(e.enable(t),s[t]=!0)}function G(t){!1!==s[t]&&(e.disable(t),s[t]=!1)}V[e.TEXTURE_2D]=B(e.TEXTURE_2D,e.TEXTURE_2D,1),V[e.TEXTURE_CUBE_MAP]=B(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),V[e.TEXTURE_2D_ARRAY]=B(e.TEXTURE_2D_ARRAY,e.TEXTURE_2D_ARRAY,1,1),V[e.TEXTURE_3D]=B(e.TEXTURE_3D,e.TEXTURE_3D,1,1),n.setClear(0,0,0,1),i.setClear(1),a.setClear(0),H(e.DEPTH_TEST),i.setFunc(at),j(!1),$(jt),H(e.CULL_FACE),X(Ln);let k={[ii]:e.FUNC_ADD,[oi]:e.FUNC_SUBTRACT,[di]:e.FUNC_REVERSE_SUBTRACT};k[hi]=e.MIN,k[_i]=e.MAX;let W={[bi]:e.ZERO,[yi]:e.ONE,[Q]:e.SRC_COLOR,[se]:e.SRC_ALPHA,[Pe]:e.SRC_ALPHA_SATURATE,[be]:e.DST_COLOR,[me]:e.DST_ALPHA,[ae]:e.ONE_MINUS_SRC_COLOR,[ue]:e.ONE_MINUS_SRC_ALPHA,[ye]:e.ONE_MINUS_DST_COLOR,[_e]:e.ONE_MINUS_DST_ALPHA,[Ne]:e.CONSTANT_COLOR,[Be]:e.ONE_MINUS_CONSTANT_COLOR,[Ge]:e.CONSTANT_ALPHA,[$e]:e.ONE_MINUS_CONSTANT_ALPHA};function X(t,n,i,a,r,o,s,l,c,d){if(t!==Ln){if(!1===p&&(H(e.BLEND),p=!0),t===Kn)r=r||n,o=o||i,s=s||a,(n!==m||r!==_)&&(e.blendEquationSeparate(k[n],k[r]),m=n,_=r),(i!==v||a!==g||o!==x||s!==S)&&(e.blendFuncSeparate(W[i],W[a],W[o],W[s]),v=i,g=a,x=o,S=s),(!1===l.equals(T)||c!==b)&&(e.blendColor(l.r,l.g,l.b,c),T.copy(l),b=c),h=t,w=!1;else if(t!==h||d!==w){if((m!==ii||_!==ii)&&(e.blendEquation(e.FUNC_ADD),m=ii,_=ii),d)switch(t){case In:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case Vn:e.blendFunc(e.ONE,e.ONE);break;case Wn:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case $n:e.blendFuncSeparate(e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA,e.ZERO,e.ONE);break;default:Ti("WebGLState: Invalid blending: ",t)}else switch(t){case In:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case Vn:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE,e.ONE,e.ONE);break;case Wn:Ti("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case $n:Ti("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Ti("WebGLState: Invalid blending: ",t)}v=null,g=null,x=null,S=null,T.set(0,0,0),b=0,h=t,w=d}}else!0===p&&(G(e.BLEND),p=!1)}function j(t){E!==t&&(t?e.frontFace(e.CW):e.frontFace(e.CCW),E=t)}function $(t){t!==Gt?(H(e.CULL_FACE),t!==M&&(t===jt?e.cullFace(e.BACK):t===Jt?e.cullFace(e.FRONT):e.cullFace(e.FRONT_AND_BACK))):G(e.CULL_FACE),M=t}function q(t,n,a){t?(H(e.POLYGON_OFFSET_FILL),(C!==n||R!==a)&&(C=n,R=a,i.getReversed()&&(n=-n),e.polygonOffset(n,a))):G(e.POLYGON_OFFSET_FILL)}return{buffers:{color:n,depth:i,stencil:a},enable:H,disable:G,bindFramebuffer:function(t,n){return c[t]!==n&&(e.bindFramebuffer(t,n),c[t]=n,t===e.DRAW_FRAMEBUFFER&&(c[e.FRAMEBUFFER]=n),t===e.FRAMEBUFFER&&(c[e.DRAW_FRAMEBUFFER]=n),!0)},drawBuffers:function(t,n){let i=u,a=!1;if(t){i=d.get(n),void 0===i&&(i=[],d.set(n,i));let r=t.textures;if(i.length!==r.length||i[0]!==e.COLOR_ATTACHMENT0){for(let t=0,n=r.length;t<n;t++)i[t]=e.COLOR_ATTACHMENT0+t;i.length=r.length,a=!0}}else i[0]!==e.BACK&&(i[0]=e.BACK,a=!0);a&&e.drawBuffers(i)},useProgram:function(t){return f!==t&&(e.useProgram(t),f=t,!0)},setBlending:X,setMaterial:function(t,r){t.side===Cn?G(e.CULL_FACE):H(e.CULL_FACE);let o=t.side===bn;r&&(o=!o),j(o),t.blending===In&&!1===t.transparent?X(Ln):X(t.blending,t.blendEquation,t.blendSrc,t.blendDst,t.blendEquationAlpha,t.blendSrcAlpha,t.blendDstAlpha,t.blendColor,t.blendAlpha,t.premultipliedAlpha),i.setFunc(t.depthFunc),i.setTest(t.depthTest),i.setMask(t.depthWrite),n.setMask(t.colorWrite);let s=t.stencilWrite;a.setTest(s),s&&(a.setMask(t.stencilWriteMask),a.setFunc(t.stencilFunc,t.stencilRef,t.stencilFuncMask),a.setOp(t.stencilFail,t.stencilZFail,t.stencilZPass)),q(t.polygonOffset,t.polygonOffsetFactor,t.polygonOffsetUnits),!0===t.alphaToCoverage?H(e.SAMPLE_ALPHA_TO_COVERAGE):G(e.SAMPLE_ALPHA_TO_COVERAGE)},setFlipSided:j,setCullFace:$,setLineWidth:function(t){t!==y&&(P&&e.lineWidth(t),y=t)},setPolygonOffset:q,setScissorTest:function(t){t?H(e.SCISSOR_TEST):G(e.SCISSOR_TEST)},activeTexture:function(t){void 0===t&&(t=e.TEXTURE0+A-1),U!==t&&(e.activeTexture(t),U=t)},bindTexture:function(t,n,i){void 0===i&&(i=null===U?e.TEXTURE0+A-1:U);let a=N[i];void 0===a&&(a={type:void 0,texture:void 0},N[i]=a),(a.type!==t||a.texture!==n)&&(U!==i&&(e.activeTexture(i),U=i),e.bindTexture(t,n||V[t]),a.type=t,a.texture=n)},unbindTexture:function(){let t=N[U];void 0!==t&&void 0!==t.type&&(e.bindTexture(t.type,null),t.type=void 0,t.texture=void 0)},compressedTexImage2D:function(){try{e.compressedTexImage2D(...arguments)}catch(e){Ti("WebGLState:",e)}},compressedTexImage3D:function(){try{e.compressedTexImage3D(...arguments)}catch(e){Ti("WebGLState:",e)}},texImage2D:function(){try{e.texImage2D(...arguments)}catch(e){Ti("WebGLState:",e)}},texImage3D:function(){try{e.texImage3D(...arguments)}catch(e){Ti("WebGLState:",e)}},pixelStorei:function(t,n){l[t]!==n&&(e.pixelStorei(t,n),l[t]=n)},getParameter:function(t){return void 0!==l[t]?l[t]:e.getParameter(t)},updateUBOMapping:function(t,n){let i=o.get(n);void 0===i&&(i=new WeakMap,o.set(n,i));let a=i.get(t);void 0===a&&(a=e.getUniformBlockIndex(n,t.name),i.set(t,a))},uniformBlockBinding:function(t,n){let i=o.get(n).get(t);r.get(n)!==i&&(e.uniformBlockBinding(n,i,t.__bindingPointIndex),r.set(n,i))},texStorage2D:function(){try{e.texStorage2D(...arguments)}catch(e){Ti("WebGLState:",e)}},texStorage3D:function(){try{e.texStorage3D(...arguments)}catch(e){Ti("WebGLState:",e)}},texSubImage2D:function(){try{e.texSubImage2D(...arguments)}catch(e){Ti("WebGLState:",e)}},texSubImage3D:function(){try{e.texSubImage3D(...arguments)}catch(e){Ti("WebGLState:",e)}},compressedTexSubImage2D:function(){try{e.compressedTexSubImage2D(...arguments)}catch(e){Ti("WebGLState:",e)}},compressedTexSubImage3D:function(){try{e.compressedTexSubImage3D(...arguments)}catch(e){Ti("WebGLState:",e)}},scissor:function(t){!1===F.equals(t)&&(e.scissor(t.x,t.y,t.z,t.w),F.copy(t))},viewport:function(t){!1===z.equals(t)&&(e.viewport(t.x,t.y,t.z,t.w),z.copy(t))},reset:function(){e.disable(e.BLEND),e.disable(e.CULL_FACE),e.disable(e.DEPTH_TEST),e.disable(e.POLYGON_OFFSET_FILL),e.disable(e.SCISSOR_TEST),e.disable(e.STENCIL_TEST),e.disable(e.SAMPLE_ALPHA_TO_COVERAGE),e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ZERO),e.blendFuncSeparate(e.ONE,e.ZERO,e.ONE,e.ZERO),e.blendColor(0,0,0,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(e.LESS),i.setReversed(!1),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(e.ALWAYS,0,4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP),e.clearStencil(0),e.cullFace(e.BACK),e.frontFace(e.CCW),e.polygonOffset(0,0),e.activeTexture(e.TEXTURE0),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),e.bindFramebuffer(e.READ_FRAMEBUFFER,null),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),e.pixelStorei(e.PACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!1),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.BROWSER_DEFAULT_WEBGL),e.pixelStorei(e.PACK_ROW_LENGTH,0),e.pixelStorei(e.PACK_SKIP_PIXELS,0),e.pixelStorei(e.PACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_ROW_LENGTH,0),e.pixelStorei(e.UNPACK_IMAGE_HEIGHT,0),e.pixelStorei(e.UNPACK_SKIP_PIXELS,0),e.pixelStorei(e.UNPACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_SKIP_IMAGES,0),s={},l={},U=null,N={},c={},d=new WeakMap,u=[],f=null,p=!1,h=null,m=null,v=null,g=null,_=null,x=null,S=null,T=new ft(0,0,0),b=0,w=!1,E=null,M=null,y=null,C=null,R=null,F.set(0,0,e.canvas.width,e.canvas.height),z.set(0,0,e.canvas.width,e.canvas.height),n.reset(),i.reset(),a.reset()}}}function jo(e,t,n,i,a,r,o){let s,l=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,c=!(typeof navigator>"u")&&/OculusBrowser/g.test(navigator.userAgent),d=new pe,u=new WeakMap,f=new Set,p=new WeakMap,h=!1;try{h=typeof OffscreenCanvas<"u"&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch{}function m(e,t){return h?new OffscreenCanvas(e,t):ri("canvas")}function v(e,t,n){let i=1,a=W(e);if((a.width>n||a.height>n)&&(i=n/Math.max(a.width,a.height)),i<1){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap||typeof VideoFrame<"u"&&e instanceof VideoFrame){let n=Math.floor(i*a.width),r=Math.floor(i*a.height);void 0===s&&(s=m(n,r));let o=t?m(n,r):s;return o.width=n,o.height=r,o.getContext("2d").drawImage(e,0,0,n,r),gi("WebGLRenderer: Texture has been resized from ("+a.width+"x"+a.height+") to ("+n+"x"+r+")."),o}return"data"in e&&gi("WebGLRenderer: Image in DataTexture is too big ("+a.width+"x"+a.height+")."),e}return e}function g(e){return e.generateMipmaps}function _(t){e.generateMipmap(t)}function x(t){return t.isWebGLCubeRenderTarget?e.TEXTURE_CUBE_MAP:t.isWebGL3DRenderTarget?e.TEXTURE_3D:t.isWebGLArrayRenderTarget||t.isCompressedArrayTexture?e.TEXTURE_2D_ARRAY:e.TEXTURE_2D}function S(n,i,a,r,o,s=!1){if(null!==n){if(void 0!==e[n])return e[n];gi("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+n+"'")}let l;r&&(l=t.get("EXT_texture_norm16"),l||gi("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let c=i;if(i===e.RED&&(a===e.FLOAT&&(c=e.R32F),a===e.HALF_FLOAT&&(c=e.R16F),a===e.UNSIGNED_BYTE&&(c=e.R8),a===e.UNSIGNED_SHORT&&l&&(c=l.R16_EXT),a===e.SHORT&&l&&(c=l.R16_SNORM_EXT)),i===e.RED_INTEGER&&(a===e.UNSIGNED_BYTE&&(c=e.R8UI),a===e.UNSIGNED_SHORT&&(c=e.R16UI),a===e.UNSIGNED_INT&&(c=e.R32UI),a===e.BYTE&&(c=e.R8I),a===e.SHORT&&(c=e.R16I),a===e.INT&&(c=e.R32I)),i===e.RG&&(a===e.FLOAT&&(c=e.RG32F),a===e.HALF_FLOAT&&(c=e.RG16F),a===e.UNSIGNED_BYTE&&(c=e.RG8),a===e.UNSIGNED_SHORT&&l&&(c=l.RG16_EXT),a===e.SHORT&&l&&(c=l.RG16_SNORM_EXT)),i===e.RG_INTEGER&&(a===e.UNSIGNED_BYTE&&(c=e.RG8UI),a===e.UNSIGNED_SHORT&&(c=e.RG16UI),a===e.UNSIGNED_INT&&(c=e.RG32UI),a===e.BYTE&&(c=e.RG8I),a===e.SHORT&&(c=e.RG16I),a===e.INT&&(c=e.RG32I)),i===e.RGB_INTEGER&&(a===e.UNSIGNED_BYTE&&(c=e.RGB8UI),a===e.UNSIGNED_SHORT&&(c=e.RGB16UI),a===e.UNSIGNED_INT&&(c=e.RGB32UI),a===e.BYTE&&(c=e.RGB8I),a===e.SHORT&&(c=e.RGB16I),a===e.INT&&(c=e.RGB32I)),i===e.RGBA_INTEGER&&(a===e.UNSIGNED_BYTE&&(c=e.RGBA8UI),a===e.UNSIGNED_SHORT&&(c=e.RGBA16UI),a===e.UNSIGNED_INT&&(c=e.RGBA32UI),a===e.BYTE&&(c=e.RGBA8I),a===e.SHORT&&(c=e.RGBA16I),a===e.INT&&(c=e.RGBA32I)),i===e.RGB&&(a===e.UNSIGNED_SHORT&&l&&(c=l.RGB16_EXT),a===e.SHORT&&l&&(c=l.RGB16_SNORM_EXT),a===e.UNSIGNED_INT_5_9_9_9_REV&&(c=e.RGB9_E5),a===e.UNSIGNED_INT_10F_11F_11F_REV&&(c=e.R11F_G11F_B10F)),i===e.RGBA){let t=s?He:Ae.getTransfer(o);a===e.FLOAT&&(c=e.RGBA32F),a===e.HALF_FLOAT&&(c=e.RGBA16F),a===e.UNSIGNED_BYTE&&(c=t===We?e.SRGB8_ALPHA8:e.RGBA8),a===e.UNSIGNED_SHORT&&l&&(c=l.RGBA16_EXT),a===e.SHORT&&l&&(c=l.RGBA16_SNORM_EXT),a===e.UNSIGNED_SHORT_4_4_4_4&&(c=e.RGBA4),a===e.UNSIGNED_SHORT_5_5_5_1&&(c=e.RGB5_A1)}return(c===e.R16F||c===e.R32F||c===e.RG16F||c===e.RG32F||c===e.RGBA16F||c===e.RGBA32F)&&t.get("EXT_color_buffer_float"),c}function T(t,n){let i;return t?null===n||n===Ci||n===ve?i=e.DEPTH24_STENCIL8:n===ee?i=e.DEPTH32F_STENCIL8:n===xi&&(i=e.DEPTH24_STENCIL8,gi("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):null===n||n===Ci||n===ve?i=e.DEPTH_COMPONENT24:n===ee?i=e.DEPTH_COMPONENT32F:n===xi&&(i=e.DEPTH_COMPONENT16),i}function b(e,t){return!0===g(e)||e.isFramebufferTexture&&e.minFilter!==On&&e.minFilter!==qn?Math.log2(Math.max(t.width,t.height))+1:void 0!==e.mipmaps&&e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?t.mipmaps.length:1}function w(e){let t=e.target;t.removeEventListener("dispose",w),function(e){let t=i.get(e);if(void 0===t.__webglInit)return;let n=e.source,a=p.get(n);if(a){let i=a[t.__cacheKey];i.usedTimes--,0===i.usedTimes&&M(e),0===Object.keys(a).length&&p.delete(n)}i.remove(e)}(t),t.isVideoTexture&&u.delete(t),t.isHTMLTexture&&f.delete(t)}function E(t){let n=t.target;n.removeEventListener("dispose",E),function(t){let n=i.get(t);if(t.depthTexture&&(t.depthTexture.dispose(),i.remove(t.depthTexture)),t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++){if(Array.isArray(n.__webglFramebuffer[t]))for(let i=0;i<n.__webglFramebuffer[t].length;i++)e.deleteFramebuffer(n.__webglFramebuffer[t][i]);else e.deleteFramebuffer(n.__webglFramebuffer[t]);n.__webglDepthbuffer&&e.deleteRenderbuffer(n.__webglDepthbuffer[t])}else{if(Array.isArray(n.__webglFramebuffer))for(let t=0;t<n.__webglFramebuffer.length;t++)e.deleteFramebuffer(n.__webglFramebuffer[t]);else e.deleteFramebuffer(n.__webglFramebuffer);if(n.__webglDepthbuffer&&e.deleteRenderbuffer(n.__webglDepthbuffer),n.__webglMultisampledFramebuffer&&e.deleteFramebuffer(n.__webglMultisampledFramebuffer),n.__webglColorRenderbuffer)for(let t=0;t<n.__webglColorRenderbuffer.length;t++)n.__webglColorRenderbuffer[t]&&e.deleteRenderbuffer(n.__webglColorRenderbuffer[t]);n.__webglDepthRenderbuffer&&e.deleteRenderbuffer(n.__webglDepthRenderbuffer)}let a=t.textures;for(let t=0,n=a.length;t<n;t++){let n=i.get(a[t]);n.__webglTexture&&(e.deleteTexture(n.__webglTexture),o.memory.textures--),i.remove(a[t])}i.remove(t)}(n)}function M(t){let n=i.get(t);e.deleteTexture(n.__webglTexture);let a=t.source;delete p.get(a)[n.__cacheKey],o.memory.textures--}let y=0;function C(t,a){let r=i.get(t);if(t.isVideoTexture&&function(e){let t=o.render.frame;u.get(e)!==t&&(u.set(e,t),e.update())}(t),!1===t.isRenderTargetTexture&&!0!==t.isExternalTexture&&t.version>0&&r.__version!==t.version){let e=t.image;if(null===e)gi("WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==e.complete)return void N(r,t,a);gi("WebGLRenderer: Texture marked for update but image is incomplete")}}else t.isExternalTexture&&(r.__webglTexture=t.sourceTexture?t.sourceTexture:null);n.bindTexture(e.TEXTURE_2D,r.__webglTexture,e.TEXTURE0+a)}let R={[wn]:e.REPEAT,[Rn]:e.CLAMP_TO_EDGE,[Un]:e.MIRRORED_REPEAT},A={[On]:e.NEAREST,[Hn]:e.NEAREST_MIPMAP_NEAREST,[Xn]:e.NEAREST_MIPMAP_LINEAR,[qn]:e.LINEAR,[Zn]:e.LINEAR_MIPMAP_NEAREST,[ei]:e.LINEAR_MIPMAP_LINEAR},P={[Yt]:e.NEVER,[Mn]:e.ALWAYS,[en]:e.LESS,[cn]:e.LEQUAL,[rn]:e.EQUAL,[Tn]:e.GEQUAL,[pn]:e.GREATER,[gn]:e.NOTEQUAL};function D(n,r){if(r.type===ee&&!1===t.has("OES_texture_float_linear")&&(r.magFilter===qn||r.magFilter===Zn||r.magFilter===Xn||r.magFilter===ei||r.minFilter===qn||r.minFilter===Zn||r.minFilter===Xn||r.minFilter===ei)&&gi("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),e.texParameteri(n,e.TEXTURE_WRAP_S,R[r.wrapS]),e.texParameteri(n,e.TEXTURE_WRAP_T,R[r.wrapT]),(n===e.TEXTURE_3D||n===e.TEXTURE_2D_ARRAY)&&e.texParameteri(n,e.TEXTURE_WRAP_R,R[r.wrapR]),e.texParameteri(n,e.TEXTURE_MAG_FILTER,A[r.magFilter]),e.texParameteri(n,e.TEXTURE_MIN_FILTER,A[r.minFilter]),r.compareFunction&&(e.texParameteri(n,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(n,e.TEXTURE_COMPARE_FUNC,P[r.compareFunction])),!0===t.has("EXT_texture_filter_anisotropic")){if(r.magFilter===On||r.minFilter!==Xn&&r.minFilter!==ei||r.type===ee&&!1===t.has("OES_texture_float_linear"))return;if(r.anisotropy>1||i.get(r).__currentAnisotropy){let o=t.get("EXT_texture_filter_anisotropic");e.texParameterf(n,o.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(r.anisotropy,a.getMaxAnisotropy())),i.get(r).__currentAnisotropy=r.anisotropy}}}function L(t,n){let i=!1;void 0===t.__webglInit&&(t.__webglInit=!0,n.addEventListener("dispose",w));let a=n.source,r=p.get(a);void 0===r&&(r={},p.set(a,r));let s=function(e){let t=[];return t.push(e.wrapS),t.push(e.wrapT),t.push(e.wrapR||0),t.push(e.magFilter),t.push(e.minFilter),t.push(e.anisotropy),t.push(e.internalFormat),t.push(e.format),t.push(e.type),t.push(e.generateMipmaps),t.push(e.premultiplyAlpha),t.push(e.flipY),t.push(e.unpackAlignment),t.push(e.colorSpace),t.join()}(n);if(s!==t.__cacheKey){void 0===r[s]&&(r[s]={texture:e.createTexture(),usedTimes:0},o.memory.textures++,i=!0),r[s].usedTimes++;let a=r[t.__cacheKey];void 0!==a&&(r[t.__cacheKey].usedTimes--,0===a.usedTimes&&M(n)),t.__cacheKey=s,t.__webglTexture=r[s].texture}return i}function U(e,t,n){return Math.floor(Math.floor(e/n)/t)}function N(t,o,s){let l=e.TEXTURE_2D;(o.isDataArrayTexture||o.isCompressedArrayTexture)&&(l=e.TEXTURE_2D_ARRAY),o.isData3DTexture&&(l=e.TEXTURE_3D);let c=L(t,o),d=o.source;n.bindTexture(l,t.__webglTexture,e.TEXTURE0+s);let u=i.get(d);if(d.version!==u.__version||!0===c){if(n.activeTexture(e.TEXTURE0+s),0==(typeof ImageBitmap<"u"&&o.image instanceof ImageBitmap)){let t=Ae.getPrimaries(Ae.workingColorSpace),i=o.colorSpace===Re?null:Ae.getPrimaries(o.colorSpace),a=o.colorSpace===Re||t===i?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,o.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,o.premultiplyAlpha),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,a)}n.pixelStorei(e.UNPACK_ALIGNMENT,o.unpackAlignment);let t=v(o.image,!1,a.maxTextureSize);t=k(o,t);let i=r.convert(o.format,o.colorSpace),p=r.convert(o.type),h=S(o.internalFormat,i,p,o.normalized,o.colorSpace,o.isVideoTexture);D(l,o);let m,x=o.mipmaps,w=!0!==o.isVideoTexture,E=void 0===u.__version||!0===c,M=d.dataReady,y=b(o,t);if(o.isDepthTexture)h=T(o.format===ke,o.type),E&&(w?n.texStorage2D(e.TEXTURE_2D,1,h,t.width,t.height):n.texImage2D(e.TEXTURE_2D,0,h,t.width,t.height,0,i,p,null));else if(o.isDataTexture)if(x.length>0){w&&E&&n.texStorage2D(e.TEXTURE_2D,y,h,x[0].width,x[0].height);for(let t=0,a=x.length;t<a;t++)m=x[t],w?M&&n.texSubImage2D(e.TEXTURE_2D,t,0,0,m.width,m.height,i,p,m.data):n.texImage2D(e.TEXTURE_2D,t,h,m.width,m.height,0,i,p,m.data);o.generateMipmaps=!1}else w?(E&&n.texStorage2D(e.TEXTURE_2D,y,h,t.width,t.height),M&&function(t,i,a,r){let o=t.updateRanges;if(0===o.length)n.texSubImage2D(e.TEXTURE_2D,0,0,0,i.width,i.height,a,r,i.data);else{o.sort((e,t)=>e.start-t.start);let s=0;for(let e=1;e<o.length;e++){let t=o[s],n=o[e],a=t.start+t.count,r=U(n.start,i.width,4),l=U(t.start,i.width,4);n.start<=a+1&&r===l&&U(n.start+n.count-1,i.width,4)===r?t.count=Math.max(t.count,n.start+n.count-t.start):(++s,o[s]=n)}o.length=s+1;let l=n.getParameter(e.UNPACK_ROW_LENGTH),c=n.getParameter(e.UNPACK_SKIP_PIXELS),d=n.getParameter(e.UNPACK_SKIP_ROWS);n.pixelStorei(e.UNPACK_ROW_LENGTH,i.width);for(let t=0,s=o.length;t<s;t++){let s=o[t],l=Math.floor(s.start/4),c=Math.ceil(s.count/4),d=l%i.width,u=Math.floor(l/i.width),f=c,p=1;n.pixelStorei(e.UNPACK_SKIP_PIXELS,d),n.pixelStorei(e.UNPACK_SKIP_ROWS,u),n.texSubImage2D(e.TEXTURE_2D,0,d,u,f,p,a,r,i.data)}t.clearUpdateRanges(),n.pixelStorei(e.UNPACK_ROW_LENGTH,l),n.pixelStorei(e.UNPACK_SKIP_PIXELS,c),n.pixelStorei(e.UNPACK_SKIP_ROWS,d)}}(o,t,i,p)):n.texImage2D(e.TEXTURE_2D,0,h,t.width,t.height,0,i,p,t.data);else if(o.isCompressedTexture)if(o.isCompressedArrayTexture){w&&E&&n.texStorage3D(e.TEXTURE_2D_ARRAY,y,h,x[0].width,x[0].height,t.depth);for(let a=0,r=x.length;a<r;a++)if(m=x[a],o.format!==Ie)if(null!==i)if(w){if(M)if(o.layerUpdates.size>0){let t=Mt(m.width,m.height,o.format,o.type);for(let r of o.layerUpdates){let o=m.data.subarray(r*t/m.data.BYTES_PER_ELEMENT,(r+1)*t/m.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,a,0,0,r,m.width,m.height,1,i,o)}o.clearLayerUpdates()}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,a,0,0,0,m.width,m.height,t.depth,i,m.data)}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,a,h,m.width,m.height,t.depth,0,m.data,0,0);else gi("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else w?M&&n.texSubImage3D(e.TEXTURE_2D_ARRAY,a,0,0,0,m.width,m.height,t.depth,i,p,m.data):n.texImage3D(e.TEXTURE_2D_ARRAY,a,h,m.width,m.height,t.depth,0,i,p,m.data)}else{w&&E&&n.texStorage2D(e.TEXTURE_2D,y,h,x[0].width,x[0].height);for(let t=0,a=x.length;t<a;t++)m=x[t],o.format!==Ie?null!==i?w?M&&n.compressedTexSubImage2D(e.TEXTURE_2D,t,0,0,m.width,m.height,i,m.data):n.compressedTexImage2D(e.TEXTURE_2D,t,h,m.width,m.height,0,m.data):gi("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):w?M&&n.texSubImage2D(e.TEXTURE_2D,t,0,0,m.width,m.height,i,p,m.data):n.texImage2D(e.TEXTURE_2D,t,h,m.width,m.height,0,i,p,m.data)}else if(o.isDataArrayTexture)if(w){if(E&&n.texStorage3D(e.TEXTURE_2D_ARRAY,y,h,t.width,t.height,t.depth),M)if(o.layerUpdates.size>0){let a=Mt(t.width,t.height,o.format,o.type);for(let r of o.layerUpdates){let o=t.data.subarray(r*a/t.data.BYTES_PER_ELEMENT,(r+1)*a/t.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,r,t.width,t.height,1,i,p,o)}o.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,t.width,t.height,t.depth,i,p,t.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,h,t.width,t.height,t.depth,0,i,p,t.data);else if(o.isData3DTexture)w?(E&&n.texStorage3D(e.TEXTURE_3D,y,h,t.width,t.height,t.depth),M&&n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,t.width,t.height,t.depth,i,p,t.data)):n.texImage3D(e.TEXTURE_3D,0,h,t.width,t.height,t.depth,0,i,p,t.data);else if(o.isFramebufferTexture){if(E)if(w)n.texStorage2D(e.TEXTURE_2D,y,h,t.width,t.height);else{let a=t.width,r=t.height;for(let t=0;t<y;t++)n.texImage2D(e.TEXTURE_2D,t,h,a,r,0,i,p,null),a>>=1,r>>=1}}else if(o.isHTMLTexture){if("texElementImage2D"in e){let n=e.canvas;if(n.hasAttribute("layoutsubtree")||n.setAttribute("layoutsubtree","true"),t.parentNode!==n)return n.appendChild(t),f.add(o),n.onpaint=e=>{let t=e.changedElements;for(let e of f)t.includes(e.image)&&(e.needsUpdate=!0)},void n.requestPaint();if(3===e.texElementImage2D.length)e.texElementImage2D(e.TEXTURE_2D,e.RGBA8,t);else{let n=e.RGBA,i=e.RGBA,a=e.UNSIGNED_BYTE;e.texElementImage2D(e.TEXTURE_2D,0,n,i,a,t)}e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)}}else if(x.length>0){if(w&&E){let t=W(x[0]);n.texStorage2D(e.TEXTURE_2D,y,h,t.width,t.height)}for(let t=0,a=x.length;t<a;t++)m=x[t],w?M&&n.texSubImage2D(e.TEXTURE_2D,t,0,0,i,p,m):n.texImage2D(e.TEXTURE_2D,t,h,i,p,m);o.generateMipmaps=!1}else if(w){if(E){let i=W(t);n.texStorage2D(e.TEXTURE_2D,y,h,i.width,i.height)}M&&n.texSubImage2D(e.TEXTURE_2D,0,0,0,i,p,t)}else n.texImage2D(e.TEXTURE_2D,0,h,i,p,t);g(o)&&_(l),u.__version=d.version,o.onUpdate&&o.onUpdate(o)}t.__version=o.version}function I(t,a,o,s,c,d){let u=r.convert(o.format,o.colorSpace),f=r.convert(o.type),p=S(o.internalFormat,u,f,o.normalized,o.colorSpace),h=i.get(a),m=i.get(o);if(m.__renderTarget=a,!h.__hasExternalTextures){let t=Math.max(1,a.width>>d),i=Math.max(1,a.height>>d);c===e.TEXTURE_3D||c===e.TEXTURE_2D_ARRAY?n.texImage3D(c,d,p,t,i,a.depth,0,u,f,null):n.texImage2D(c,d,p,t,i,0,u,f,null)}n.bindFramebuffer(e.FRAMEBUFFER,t),G(a)?l.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,s,c,m.__webglTexture,0,H(a)):(c===e.TEXTURE_2D||c>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&c<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&e.framebufferTexture2D(e.FRAMEBUFFER,s,c,m.__webglTexture,d),n.bindFramebuffer(e.FRAMEBUFFER,null)}function O(t,n,i){if(e.bindRenderbuffer(e.RENDERBUFFER,t),n.depthBuffer){let a=n.depthTexture,r=a&&a.isDepthTexture?a.type:null,o=T(n.stencilBuffer,r),s=n.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;G(n)?l.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,H(n),o,n.width,n.height):i?e.renderbufferStorageMultisample(e.RENDERBUFFER,H(n),o,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,o,n.width,n.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,s,e.RENDERBUFFER,t)}else{let t=n.textures;for(let a=0;a<t.length;a++){let o=t[a],s=r.convert(o.format,o.colorSpace),c=r.convert(o.type),d=S(o.internalFormat,s,c,o.normalized,o.colorSpace);G(n)?l.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,H(n),d,n.width,n.height):i?e.renderbufferStorageMultisample(e.RENDERBUFFER,H(n),d,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,d,n.width,n.height)}}e.bindRenderbuffer(e.RENDERBUFFER,null)}function F(t,a,o){let s=!0===a.isWebGLCubeRenderTarget;if(n.bindFramebuffer(e.FRAMEBUFFER,t),!a.depthTexture||!a.depthTexture.isDepthTexture)throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");let c=i.get(a.depthTexture);if(c.__renderTarget=a,(!c.__webglTexture||a.depthTexture.image.width!==a.width||a.depthTexture.image.height!==a.height)&&(a.depthTexture.image.width=a.width,a.depthTexture.image.height=a.height,a.depthTexture.needsUpdate=!0),s){if(void 0===c.__webglInit&&(c.__webglInit=!0,a.depthTexture.addEventListener("dispose",w)),void 0===c.__webglTexture){c.__webglTexture=e.createTexture(),n.bindTexture(e.TEXTURE_CUBE_MAP,c.__webglTexture),D(e.TEXTURE_CUBE_MAP,a.depthTexture);let t,i=r.convert(a.depthTexture.format),o=r.convert(a.depthTexture.type);a.depthTexture.format===Ve?t=e.DEPTH_COMPONENT24:a.depthTexture.format===ke&&(t=e.DEPTH24_STENCIL8);for(let n=0;n<6;n++)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+n,0,t,a.width,a.height,0,i,o,null)}}else C(a.depthTexture,0);let d=c.__webglTexture,u=H(a),f=s?e.TEXTURE_CUBE_MAP_POSITIVE_X+o:e.TEXTURE_2D,p=a.depthTexture.format===ke?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(a.depthTexture.format===Ve)G(a)?l.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,p,f,d,0,u):e.framebufferTexture2D(e.FRAMEBUFFER,p,f,d,0);else{if(a.depthTexture.format!==ke)throw new Error("THREE.WebGLTextures: Unknown depthTexture format.");G(a)?l.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,p,f,d,0,u):e.framebufferTexture2D(e.FRAMEBUFFER,p,f,d,0)}}function z(t){let a=i.get(t),r=!0===t.isWebGLCubeRenderTarget;if(a.__boundDepthTexture!==t.depthTexture){let e=t.depthTexture;if(a.__depthDisposeCallback&&a.__depthDisposeCallback(),e){let t=()=>{delete a.__boundDepthTexture,delete a.__depthDisposeCallback,e.removeEventListener("dispose",t)};e.addEventListener("dispose",t),a.__depthDisposeCallback=t}a.__boundDepthTexture=e}if(t.depthTexture&&!a.__autoAllocateDepthBuffer)if(r)for(let e=0;e<6;e++)F(a.__webglFramebuffer[e],t,e);else{let e=t.texture.mipmaps;e&&e.length>0?F(a.__webglFramebuffer[0],t,0):F(a.__webglFramebuffer,t,0)}else if(r){a.__webglDepthbuffer=[];for(let i=0;i<6;i++)if(n.bindFramebuffer(e.FRAMEBUFFER,a.__webglFramebuffer[i]),void 0===a.__webglDepthbuffer[i])a.__webglDepthbuffer[i]=e.createRenderbuffer(),O(a.__webglDepthbuffer[i],t,!1);else{let n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,r=a.__webglDepthbuffer[i];e.bindRenderbuffer(e.RENDERBUFFER,r),e.framebufferRenderbuffer(e.FRAMEBUFFER,n,e.RENDERBUFFER,r)}}else{let i=t.texture.mipmaps;if(i&&i.length>0?n.bindFramebuffer(e.FRAMEBUFFER,a.__webglFramebuffer[0]):n.bindFramebuffer(e.FRAMEBUFFER,a.__webglFramebuffer),void 0===a.__webglDepthbuffer)a.__webglDepthbuffer=e.createRenderbuffer(),O(a.__webglDepthbuffer,t,!1);else{let n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,i=a.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,i),e.framebufferRenderbuffer(e.FRAMEBUFFER,n,e.RENDERBUFFER,i)}}n.bindFramebuffer(e.FRAMEBUFFER,null)}let B=[],V=[];function H(e){return Math.min(a.maxSamples,e.samples)}function G(e){let n=i.get(e);return e.samples>0&&!0===t.has("WEBGL_multisampled_render_to_texture")&&!1!==n.__useRenderToTexture}function k(e,t){let n=e.colorSpace,i=e.format,a=e.type;return!0===e.isCompressedTexture||!0===e.isVideoTexture||n!==Oe&&n!==Re&&(Ae.getTransfer(n)===We?(i!==Ie||a!==si)&&gi("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Ti("WebGLTextures: Unsupported texture color space:",n)),t}function W(e){return typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement?(d.width=e.naturalWidth||e.width,d.height=e.naturalHeight||e.height):typeof VideoFrame<"u"&&e instanceof VideoFrame?(d.width=e.displayWidth,d.height=e.displayHeight):(d.width=e.width,d.height=e.height),d}this.allocateTextureUnit=function(){let e=y;return e>=a.maxTextures&&gi("WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+a.maxTextures),y+=1,e},this.resetTextureUnits=function(){y=0},this.getTextureUnits=function(){return y},this.setTextureUnits=function(e){y=e},this.setTexture2D=C,this.setTexture2DArray=function(t,a){let r=i.get(t);!1===t.isRenderTargetTexture&&t.version>0&&r.__version!==t.version?N(r,t,a):(t.isExternalTexture&&(r.__webglTexture=t.sourceTexture?t.sourceTexture:null),n.bindTexture(e.TEXTURE_2D_ARRAY,r.__webglTexture,e.TEXTURE0+a))},this.setTexture3D=function(t,a){let r=i.get(t);!1===t.isRenderTargetTexture&&t.version>0&&r.__version!==t.version?N(r,t,a):n.bindTexture(e.TEXTURE_3D,r.__webglTexture,e.TEXTURE0+a)},this.setTextureCube=function(t,o){let s=i.get(t);!0!==t.isCubeDepthTexture&&t.version>0&&s.__version!==t.version?function(t,o,s){if(6!==o.image.length)return;let l=L(t,o),c=o.source;n.bindTexture(e.TEXTURE_CUBE_MAP,t.__webglTexture,e.TEXTURE0+s);let d=i.get(c);if(c.version!==d.__version||!0===l){n.activeTexture(e.TEXTURE0+s);let t=Ae.getPrimaries(Ae.workingColorSpace),i=o.colorSpace===Re?null:Ae.getPrimaries(o.colorSpace),u=o.colorSpace===Re||t===i?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,o.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,o.premultiplyAlpha),n.pixelStorei(e.UNPACK_ALIGNMENT,o.unpackAlignment),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,u);let f=o.isCompressedTexture||o.image[0].isCompressedTexture,p=o.image[0]&&o.image[0].isDataTexture,h=[];for(let e=0;e<6;e++)h[e]=f||p?p?o.image[e].image:o.image[e]:v(o.image[e],!0,a.maxCubemapSize),h[e]=k(o,h[e]);let m,x=h[0],T=r.convert(o.format,o.colorSpace),w=r.convert(o.type),E=S(o.internalFormat,T,w,o.normalized,o.colorSpace),M=!0!==o.isVideoTexture,y=void 0===d.__version||!0===l,C=c.dataReady,R=b(o,x);if(D(e.TEXTURE_CUBE_MAP,o),f){M&&y&&n.texStorage2D(e.TEXTURE_CUBE_MAP,R,E,x.width,x.height);for(let t=0;t<6;t++){m=h[t].mipmaps;for(let i=0;i<m.length;i++){let a=m[i];o.format!==Ie?null!==T?M?C&&n.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i,0,0,a.width,a.height,T,a.data):n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i,E,a.width,a.height,0,a.data):gi("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):M?C&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i,0,0,a.width,a.height,T,w,a.data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i,E,a.width,a.height,0,T,w,a.data)}}}else{if(m=o.mipmaps,M&&y){m.length>0&&R++;let t=W(h[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,R,E,t.width,t.height)}for(let t=0;t<6;t++)if(p){M?C&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,h[t].width,h[t].height,T,w,h[t].data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,E,h[t].width,h[t].height,0,T,w,h[t].data);for(let i=0;i<m.length;i++){let a=m[i].image[t].image;M?C&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i+1,0,0,a.width,a.height,T,w,a.data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i+1,E,a.width,a.height,0,T,w,a.data)}}else{M?C&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,T,w,h[t]):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,E,T,w,h[t]);for(let i=0;i<m.length;i++){let a=m[i];M?C&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i+1,0,0,T,w,a.image[t]):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i+1,E,T,w,a.image[t])}}}g(o)&&_(e.TEXTURE_CUBE_MAP),d.__version=c.version,o.onUpdate&&o.onUpdate(o)}t.__version=o.version}(s,t,o):n.bindTexture(e.TEXTURE_CUBE_MAP,s.__webglTexture,e.TEXTURE0+o)},this.rebindTextures=function(t,n,a){let r=i.get(t);void 0!==n&&I(r.__webglFramebuffer,t,t.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0),void 0!==a&&z(t)},this.setupRenderTarget=function(t){let a=t.texture,s=i.get(t),l=i.get(a);t.addEventListener("dispose",E);let c=t.textures,d=!0===t.isWebGLCubeRenderTarget,u=c.length>1;if(u||(void 0===l.__webglTexture&&(l.__webglTexture=e.createTexture()),l.__version=a.version,o.memory.textures++),d){s.__webglFramebuffer=[];for(let t=0;t<6;t++)if(a.mipmaps&&a.mipmaps.length>0){s.__webglFramebuffer[t]=[];for(let n=0;n<a.mipmaps.length;n++)s.__webglFramebuffer[t][n]=e.createFramebuffer()}else s.__webglFramebuffer[t]=e.createFramebuffer()}else{if(a.mipmaps&&a.mipmaps.length>0){s.__webglFramebuffer=[];for(let t=0;t<a.mipmaps.length;t++)s.__webglFramebuffer[t]=e.createFramebuffer()}else s.__webglFramebuffer=e.createFramebuffer();if(u)for(let t=0,n=c.length;t<n;t++){let n=i.get(c[t]);void 0===n.__webglTexture&&(n.__webglTexture=e.createTexture(),o.memory.textures++)}if(t.samples>0&&!1===G(t)){s.__webglMultisampledFramebuffer=e.createFramebuffer(),s.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,s.__webglMultisampledFramebuffer);for(let n=0;n<c.length;n++){let i=c[n];s.__webglColorRenderbuffer[n]=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,s.__webglColorRenderbuffer[n]);let a=r.convert(i.format,i.colorSpace),o=r.convert(i.type),l=S(i.internalFormat,a,o,i.normalized,i.colorSpace,!0===t.isXRRenderTarget),d=H(t);e.renderbufferStorageMultisample(e.RENDERBUFFER,d,l,t.width,t.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+n,e.RENDERBUFFER,s.__webglColorRenderbuffer[n])}e.bindRenderbuffer(e.RENDERBUFFER,null),t.depthBuffer&&(s.__webglDepthRenderbuffer=e.createRenderbuffer(),O(s.__webglDepthRenderbuffer,t,!0)),n.bindFramebuffer(e.FRAMEBUFFER,null)}}if(d){n.bindTexture(e.TEXTURE_CUBE_MAP,l.__webglTexture),D(e.TEXTURE_CUBE_MAP,a);for(let n=0;n<6;n++)if(a.mipmaps&&a.mipmaps.length>0)for(let i=0;i<a.mipmaps.length;i++)I(s.__webglFramebuffer[n][i],t,a,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+n,i);else I(s.__webglFramebuffer[n],t,a,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+n,0);g(a)&&_(e.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(u){for(let a=0,r=c.length;a<r;a++){let r=c[a],o=i.get(r),l=e.TEXTURE_2D;(t.isWebGL3DRenderTarget||t.isWebGLArrayRenderTarget)&&(l=t.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY),n.bindTexture(l,o.__webglTexture),D(l,r),I(s.__webglFramebuffer,t,r,e.COLOR_ATTACHMENT0+a,l,0),g(r)&&_(l)}n.unbindTexture()}else{let i=e.TEXTURE_2D;if((t.isWebGL3DRenderTarget||t.isWebGLArrayRenderTarget)&&(i=t.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY),n.bindTexture(i,l.__webglTexture),D(i,a),a.mipmaps&&a.mipmaps.length>0)for(let n=0;n<a.mipmaps.length;n++)I(s.__webglFramebuffer[n],t,a,e.COLOR_ATTACHMENT0,i,n);else I(s.__webglFramebuffer,t,a,e.COLOR_ATTACHMENT0,i,0);g(a)&&_(i),n.unbindTexture()}t.depthBuffer&&z(t)},this.updateRenderTargetMipmap=function(e){let t=e.textures;for(let a=0,r=t.length;a<r;a++){let r=t[a];if(g(r)){let t=x(e),a=i.get(r).__webglTexture;n.bindTexture(t,a),_(t),n.unbindTexture()}}},this.updateMultisampleRenderTarget=function(t){if(t.samples>0)if(!1===G(t)){let a=t.textures,r=t.width,o=t.height,s=e.COLOR_BUFFER_BIT,l=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,d=i.get(t),u=a.length>1;if(u)for(let t=0;t<a.length;t++)n.bindFramebuffer(e.FRAMEBUFFER,d.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.RENDERBUFFER,null),n.bindFramebuffer(e.FRAMEBUFFER,d.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.TEXTURE_2D,null,0);n.bindFramebuffer(e.READ_FRAMEBUFFER,d.__webglMultisampledFramebuffer);let f=t.texture.mipmaps;f&&f.length>0?n.bindFramebuffer(e.DRAW_FRAMEBUFFER,d.__webglFramebuffer[0]):n.bindFramebuffer(e.DRAW_FRAMEBUFFER,d.__webglFramebuffer);for(let n=0;n<a.length;n++){if(t.resolveDepthBuffer&&(t.depthBuffer&&(s|=e.DEPTH_BUFFER_BIT),t.stencilBuffer&&t.resolveStencilBuffer&&(s|=e.STENCIL_BUFFER_BIT)),u){e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,d.__webglColorRenderbuffer[n]);let t=i.get(a[n]).__webglTexture;e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0)}e.blitFramebuffer(0,0,r,o,0,0,r,o,s,e.NEAREST),!0===c&&(B.length=0,V.length=0,B.push(e.COLOR_ATTACHMENT0+n),t.depthBuffer&&!1===t.resolveDepthBuffer&&(B.push(l),V.push(l),e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,V)),e.invalidateFramebuffer(e.READ_FRAMEBUFFER,B))}if(n.bindFramebuffer(e.READ_FRAMEBUFFER,null),n.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),u)for(let t=0;t<a.length;t++){n.bindFramebuffer(e.FRAMEBUFFER,d.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.RENDERBUFFER,d.__webglColorRenderbuffer[t]);let r=i.get(a[t]).__webglTexture;n.bindFramebuffer(e.FRAMEBUFFER,d.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.TEXTURE_2D,r,0)}n.bindFramebuffer(e.DRAW_FRAMEBUFFER,d.__webglMultisampledFramebuffer)}else if(t.depthBuffer&&!1===t.resolveDepthBuffer&&c){let n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,[n])}},this.setupDepthRenderbuffer=z,this.setupFrameBufferTexture=I,this.useMultisampledRTT=G,this.isReversedDepthBuffer=function(){return n.buffers.depth.getReversed()}}function $o(e,t){return{convert:function(n,i=Re){let a,r=Ae.getTransfer(i);if(n===si)return e.UNSIGNED_BYTE;if(n===le)return e.UNSIGNED_SHORT_4_4_4_4;if(n===fe)return e.UNSIGNED_SHORT_5_5_5_1;if(n===xe)return e.UNSIGNED_INT_5_9_9_9_REV;if(n===we)return e.UNSIGNED_INT_10F_11F_11F_REV;if(n===ui)return e.BYTE;if(n===mi)return e.SHORT;if(n===xi)return e.UNSIGNED_SHORT;if(n===wi)return e.INT;if(n===Ci)return e.UNSIGNED_INT;if(n===ee)return e.FLOAT;if(n===re)return e.HALF_FLOAT;if(n===Ce)return e.ALPHA;if(n===De)return e.RGB;if(n===Ie)return e.RGBA;if(n===Ve)return e.DEPTH_COMPONENT;if(n===ke)return e.DEPTH_STENCIL;if(n===qe)return e.RED;if(n===Ze)return e.RED_INTEGER;if(n===et)return e.RG;if(n===it)return e.RG_INTEGER;if(n===st)return e.RGBA_INTEGER;if(n===ct||n===ut||n===ht||n===vt)if(r===We){if(a=t.get("WEBGL_compressed_texture_s3tc_srgb"),null===a)return null;if(n===ct)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===ut)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===ht)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===vt)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(a=t.get("WEBGL_compressed_texture_s3tc"),null===a)return null;if(n===ct)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===ut)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===ht)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===vt)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(n===St||n===bt||n===Et||n===Ct){if(a=t.get("WEBGL_compressed_texture_pvrtc"),null===a)return null;if(n===St)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===bt)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Et)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Ct)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(n===Dt||n===K||n===Ot||n===Bt||n===Wt||n===qt||n===Qt){if(a=t.get("WEBGL_compressed_texture_etc"),null===a)return null;if(n===Dt||n===K)return r===We?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(n===Ot)return r===We?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC;if(n===Bt)return a.COMPRESSED_R11_EAC;if(n===Wt)return a.COMPRESSED_SIGNED_R11_EAC;if(n===qt)return a.COMPRESSED_RG11_EAC;if(n===Qt)return a.COMPRESSED_SIGNED_RG11_EAC}if(n===an||n===ln||n===fn||n===vn||n===Sn||n===En||n===An||n===Nn||n===Fn||n===Gn||n===jn||n===Yn||n===Jn||n===ti){if(a=t.get("WEBGL_compressed_texture_astc"),null===a)return null;if(n===an)return r===We?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===ln)return r===We?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===fn)return r===We?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===vn)return r===We?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Sn)return r===We?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===En)return r===We?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===An)return r===We?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Nn)return r===We?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Fn)return r===We?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Gn)return r===We?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===jn)return r===We?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Yn)return r===We?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Jn)return r===We?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===ti)return r===We?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}if(n===ai||n===li||n===fi){if(a=t.get("EXT_texture_compression_bptc"),null===a)return null;if(n===ai)return r===We?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===li)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===fi)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}if(n===vi||n===Si||n===Ei||n===Ri){if(a=t.get("EXT_texture_compression_rgtc"),null===a)return null;if(n===vi)return a.COMPRESSED_RED_RGTC1_EXT;if(n===Si)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Ei)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Ri)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}return n===ve?e.UNSIGNED_INT_24_8:void 0!==e[n]?e[n]:null}}}var qo=new tt,Yo=new Me;function Ko(e,t){function n(e,t){!0===e.matrixAutoUpdate&&e.updateMatrix(),t.value.copy(e.matrix)}function i(e,i){e.opacity.value=i.opacity,i.color&&e.diffuse.value.copy(i.color),i.emissive&&e.emissive.value.copy(i.emissive).multiplyScalar(i.emissiveIntensity),i.map&&(e.map.value=i.map,n(i.map,e.mapTransform)),i.alphaMap&&(e.alphaMap.value=i.alphaMap,n(i.alphaMap,e.alphaMapTransform)),i.bumpMap&&(e.bumpMap.value=i.bumpMap,n(i.bumpMap,e.bumpMapTransform),e.bumpScale.value=i.bumpScale,i.side===bn&&(e.bumpScale.value*=-1)),i.normalMap&&(e.normalMap.value=i.normalMap,n(i.normalMap,e.normalMapTransform),e.normalScale.value.copy(i.normalScale),i.side===bn&&e.normalScale.value.negate()),i.displacementMap&&(e.displacementMap.value=i.displacementMap,n(i.displacementMap,e.displacementMapTransform),e.displacementScale.value=i.displacementScale,e.displacementBias.value=i.displacementBias),i.emissiveMap&&(e.emissiveMap.value=i.emissiveMap,n(i.emissiveMap,e.emissiveMapTransform)),i.specularMap&&(e.specularMap.value=i.specularMap,n(i.specularMap,e.specularMapTransform)),i.alphaTest>0&&(e.alphaTest.value=i.alphaTest);let a=t.get(i),r=a.envMap,o=a.envMapRotation;r&&(e.envMap.value=r,e.envMapRotation.value.setFromMatrix4(qo.makeRotationFromEuler(o)).transpose(),r.isCubeTexture&&!1===r.isRenderTargetTexture&&e.envMapRotation.value.premultiply(Yo),e.reflectivity.value=i.reflectivity,e.ior.value=i.ior,e.refractionRatio.value=i.refractionRatio),i.lightMap&&(e.lightMap.value=i.lightMap,e.lightMapIntensity.value=i.lightMapIntensity,n(i.lightMap,e.lightMapTransform)),i.aoMap&&(e.aoMap.value=i.aoMap,e.aoMapIntensity.value=i.aoMapIntensity,n(i.aoMap,e.aoMapTransform))}return{refreshFogUniforms:function(t,n){n.color.getRGB(t.fogColor.value,Ft(e)),n.isFog?(t.fogNear.value=n.near,t.fogFar.value=n.far):n.isFogExp2&&(t.fogDensity.value=n.density)},refreshMaterialUniforms:function(e,a,r,o,s){a.isNodeMaterial?a.uniformsNeedUpdate=!1:a.isMeshBasicMaterial?i(e,a):a.isMeshLambertMaterial?(i(e,a),a.envMap&&(e.envMapIntensity.value=a.envMapIntensity)):a.isMeshToonMaterial?(i(e,a),function(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}(e,a)):a.isMeshPhongMaterial?(i(e,a),function(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}(e,a),a.envMap&&(e.envMapIntensity.value=a.envMapIntensity)):a.isMeshStandardMaterial?(i(e,a),function(e,t){e.metalness.value=t.metalness,t.metalnessMap&&(e.metalnessMap.value=t.metalnessMap,n(t.metalnessMap,e.metalnessMapTransform)),e.roughness.value=t.roughness,t.roughnessMap&&(e.roughnessMap.value=t.roughnessMap,n(t.roughnessMap,e.roughnessMapTransform)),t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)}(e,a),a.isMeshPhysicalMaterial&&function(e,t,i){e.ior.value=t.ior,t.sheen>0&&(e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen),e.sheenRoughness.value=t.sheenRoughness,t.sheenColorMap&&(e.sheenColorMap.value=t.sheenColorMap,n(t.sheenColorMap,e.sheenColorMapTransform)),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap,n(t.sheenRoughnessMap,e.sheenRoughnessMapTransform))),t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap,n(t.clearcoatMap,e.clearcoatMapTransform)),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap,n(t.clearcoatRoughnessMap,e.clearcoatRoughnessMapTransform)),t.clearcoatNormalMap&&(e.clearcoatNormalMap.value=t.clearcoatNormalMap,n(t.clearcoatNormalMap,e.clearcoatNormalMapTransform),e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),t.side===bn&&e.clearcoatNormalScale.value.negate())),t.dispersion>0&&(e.dispersion.value=t.dispersion),t.iridescence>0&&(e.iridescence.value=t.iridescence,e.iridescenceIOR.value=t.iridescenceIOR,e.iridescenceThicknessMinimum.value=t.iridescenceThicknessRange[0],e.iridescenceThicknessMaximum.value=t.iridescenceThicknessRange[1],t.iridescenceMap&&(e.iridescenceMap.value=t.iridescenceMap,n(t.iridescenceMap,e.iridescenceMapTransform)),t.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=t.iridescenceThicknessMap,n(t.iridescenceThicknessMap,e.iridescenceThicknessMapTransform))),t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=i.texture,e.transmissionSamplerSize.value.set(i.width,i.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap,n(t.transmissionMap,e.transmissionMapTransform)),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap,n(t.thicknessMap,e.thicknessMapTransform)),e.attenuationDistance.value=t.attenuationDistance,e.attenuationColor.value.copy(t.attenuationColor)),t.anisotropy>0&&(e.anisotropyVector.value.set(t.anisotropy*Math.cos(t.anisotropyRotation),t.anisotropy*Math.sin(t.anisotropyRotation)),t.anisotropyMap&&(e.anisotropyMap.value=t.anisotropyMap,n(t.anisotropyMap,e.anisotropyMapTransform))),e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap,n(t.specularColorMap,e.specularColorMapTransform)),t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap,n(t.specularIntensityMap,e.specularIntensityMapTransform))}(e,a,s)):a.isMeshMatcapMaterial?(i(e,a),function(e,t){t.matcap&&(e.matcap.value=t.matcap)}(e,a)):a.isMeshDepthMaterial?i(e,a):a.isMeshDistanceMaterial?(i(e,a),function(e,n){let i=t.get(n).light;e.referencePosition.value.setFromMatrixPosition(i.matrixWorld),e.nearDistance.value=i.shadow.camera.near,e.farDistance.value=i.shadow.camera.far}(e,a)):a.isMeshNormalMaterial?i(e,a):a.isLineBasicMaterial?(function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform))}(e,a),a.isLineDashedMaterial&&function(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}(e,a)):a.isPointsMaterial?function(e,t,i,a){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*i,e.scale.value=.5*a,t.map&&(e.map.value=t.map,n(t.map,e.uvTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,a,r,o):a.isSpriteMaterial?function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,a):a.isShadowMaterial?(e.color.value.copy(a.color),e.opacity.value=a.opacity):a.isShaderMaterial&&(a.uniformsNeedUpdate=!1)}}}Yo.set(-1,0,0,0,1,0,0,0,1);var Zo=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]),Jo=null,Qo=class{constructor(e={}){let t,{canvas:n=ci(),context:i=null,depth:a=!0,stencil:r=!1,alpha:o=!1,antialias:s=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:f=!1,outputBufferType:p=si}=e;if(this.isWebGLRenderer=!0,null!==i){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");t=i.getContextAttributes().alpha}else t=o;let h=p,m=new Set([st,it,Ze]),v=new Set([si,Ci,xi,ve,le,fe]),g=new Uint32Array(4),_=new Int32Array(4),x=new Te,S=null,T=null,b=[],w=[],E=null;this.domElement=n,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=wt,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let M=this,y=!1,C=null,R=null,A=null,P=null;this._outputColorSpace=Le;let D=0,L=0,U=null,N=-1,I=null,O=new Fe,F=new Fe,z=null,B=new ft(0),V=0,H=n.width,G=n.height,k=1,W=null,X=null,j=new Fe(0,0,H,G),$=new Fe(0,0,H,G),q=!1,Y=new ni,K=!1,Z=!1,J=new tt,Q=new Te,ee=new Fe,te={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},ne=!1;function ie(){return null===U?k:1}let ae,se,ce,de,ue,pe,he,me,ge,_e,xe,Se,be,we,Ee,Me,ye,Ce,Re,Pe,De,Ue,Ne,Ie=i;function Oe(e,t){return n.getContext(e,t)}try{let e={alpha:!0,depth:a,stencil:r,antialias:s,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:d,failIfMajorPerformanceCaveat:u};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${Nt}`),n.addEventListener("webglcontextlost",Ve,!1),n.addEventListener("webglcontextrestored",He,!1),n.addEventListener("webglcontextcreationerror",Ge,!1),null===Ie){let t="webgl2";if(Ie=Oe(t,e),null===Ie)throw Oe(t)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(e){throw Ti("WebGLRenderer: "+e.message),e}function ze(){ae=new Ba(Ie),ae.init(),De=new $o(Ie,ae),se=new Ia(Ie,ae,e,De),ce=new Xo(Ie,ae),se.reversedDepthBuffer&&f&&ce.buffers.depth.setReversed(!0),R=Ie.createFramebuffer(),A=Ie.createFramebuffer(),P=Ie.createFramebuffer(),de=new Ga(Ie),ue=new Ro,pe=new jo(Ie,ae,ce,ue,se,De,de),he=new za(M),me=new Ma(Ie),Ue=new Ua(Ie,me),ge=new Va(Ie,me,de,Ue),_e=new Wa(Ie,ge,me,Ue,de),Ce=new ka(Ie,se,pe),Ee=new Oa(ue),xe=new Co(M,he,ae,se,Ue,Ee),Se=new Ko(M,ue),be=new Lo,we=new zo(ae),ye=new La(M,he,ce,_e,t,l),Me=new Wo(M,_e,se),Ne={update(){throw new Error("UniformsGroups are not supported by the Spline runtime")},bind(){throw new Error("UniformsGroups are not supported by the Spline runtime")},dispose(){}},Re=new Na(Ie,ae,de),Pe=new Ha(Ie,ae,de),de.programs=xe.programs,M.capabilities=se,M.extensions=ae,M.properties=ue,M.renderLists=be,M.shadowMap=Me,M.state=ce,M.info=de}ze(),h!==si&&(E=new ja(h,n.width,n.height,s,a,r));let Be=Object.assign(new oe,{enabled:!1,isPresenting:!1,cameraAutoUpdate:!0,setFramebufferScaleFactor(){},setReferenceSpaceType(){},getReferenceSpace:()=>null,setReferenceSpace(){},getBaseLayer:()=>null,getBinding:()=>null,getFrame:()=>null,getSession:()=>null,async setSession(){throw new Error("WebXR is not supported by the Spline runtime")},getEnvironmentBlendMode(){},getDepthTexture:()=>null,updateCamera(){},getCamera:()=>null,getFoveation(){},setFoveation(){},hasDepthSensing:()=>!1,getDepthSensingMesh:()=>null,setAnimationLoop(){},getController:()=>null,getControllerGrip:()=>null,getHand:()=>null,dispose(){}});function Ve(e){e.preventDefault(),pi("WebGLRenderer: Context Lost."),y=!0}function He(){pi("WebGLRenderer: Context Restored."),y=!1;let e=de.autoReset,t=Me.enabled,n=Me.autoUpdate,i=Me.needsUpdate,a=Me.type;ze(),de.autoReset=e,Me.enabled=t,Me.autoUpdate=n,Me.needsUpdate=i,Me.type=a}function Ge(e){Ti("WebGLRenderer: A WebGL context could not be created. Reason: ",e.statusMessage)}function ke(e){let t=e.target;t.removeEventListener("dispose",ke),function(e){(function(e){let t=ue.get(e).programs;void 0!==t&&(t.forEach(function(e){xe.releaseProgram(e)}),e.isShaderMaterial&&xe.releaseShaderCache(e))})(e),ue.remove(e)}(t)}function We(e,t,n){!0===e.transparent&&e.side===Cn&&!1===e.forceSinglePass?(e.side=bn,e.needsUpdate=!0,rt(e,t,n),e.side=_n,e.needsUpdate=!0,rt(e,t,n),e.side=Cn):rt(e,t,n)}this.xr=Be,this.getContext=function(){return Ie},this.getContextAttributes=function(){return Ie.getContextAttributes()},this.forceContextLoss=function(){let e=ae.get("WEBGL_lose_context");e&&e.loseContext()},this.forceContextRestore=function(){let e=ae.get("WEBGL_lose_context");e&&e.restoreContext()},this.getPixelRatio=function(){return k},this.setPixelRatio=function(e){void 0!==e&&(k=e,this.setSize(H,G,!1))},this.getSize=function(e){return e.set(H,G)},this.setSize=function(e,t,i=!0){Be.isPresenting?gi("WebGLRenderer: Can't change size while VR device is presenting."):(H=e,G=t,n.width=Math.floor(e*k),n.height=Math.floor(t*k),!0===i&&(n.style.width=e+"px",n.style.height=t+"px"),null!==E&&E.setSize(n.width,n.height),this.setViewport(0,0,e,t))},this.getDrawingBufferSize=function(e){return e.set(H*k,G*k).floor()},this.setDrawingBufferSize=function(e,t,i){H=e,G=t,k=i,n.width=Math.floor(e*i),n.height=Math.floor(t*i),this.setViewport(0,0,e,t)},this.setEffects=function(e){if(h!==si){if(e)for(let t=0;t<e.length;t++)if(!0===e[t].isOutputPass){gi("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}E.setEffects(e||[])}else Ti("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.")},this.getCurrentViewport=function(e){return e.copy(O)},this.getViewport=function(e){return e.copy(j)},this.setViewport=function(e,t,n,i){e.isVector4?j.set(e.x,e.y,e.z,e.w):j.set(e,t,n,i),ce.viewport(O.copy(j).multiplyScalar(k).round())},this.getScissor=function(e){return e.copy($)},this.setScissor=function(e,t,n,i){e.isVector4?$.set(e.x,e.y,e.z,e.w):$.set(e,t,n,i),ce.scissor(F.copy($).multiplyScalar(k).round())},this.getScissorTest=function(){return q},this.setScissorTest=function(e){ce.setScissorTest(q=e)},this.setOpaqueSort=function(e){W=e},this.setTransparentSort=function(e){X=e},this.getClearColor=function(e){return e.copy(ye.getClearColor())},this.setClearColor=function(){ye.setClearColor(...arguments)},this.getClearAlpha=function(){return ye.getClearAlpha()},this.setClearAlpha=function(){ye.setClearAlpha(...arguments)},this.clear=function(e=!0,t=!0,n=!0){let i=0;if(e){let e=!1;if(null!==U){let t=U.texture.format;e=m.has(t)}if(e){let e=U.texture.type,t=v.has(e),n=ye.getClearColor(),i=ye.getClearAlpha(),a=n.r,r=n.g,o=n.b;t?(g[0]=a,g[1]=r,g[2]=o,g[3]=i,Ie.clearBufferuiv(Ie.COLOR,0,g)):(_[0]=a,_[1]=r,_[2]=o,_[3]=i,Ie.clearBufferiv(Ie.COLOR,0,_))}else i|=Ie.COLOR_BUFFER_BIT}t&&(i|=Ie.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),n&&(i|=Ie.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),0!==i&&Ie.clear(i)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(e){e.setRenderer(this),C=e},this.dispose=function(){n.removeEventListener("webglcontextlost",Ve,!1),n.removeEventListener("webglcontextrestored",He,!1),n.removeEventListener("webglcontextcreationerror",Ge,!1),ye.dispose(),be.dispose(),we.dispose(),ue.dispose(),he.dispose(),_e.dispose(),Ue.dispose(),Ne.dispose(),xe.dispose(),Be.dispose(),Be.removeEventListener("sessionstart",$e),Be.removeEventListener("sessionend",qe),Ye.stop()},this.renderBufferDirect=function(e,t,n,i,a,r){null===t&&(t=te);let o=a.isMesh&&a.matrixWorld.determinantAffine()<0,s=function(e,t,n,i,a){!0!==t.isScene&&(t=te),pe.resetTextureUnits();let r=t.fog,o=i.isMeshStandardMaterial||i.isMeshLambertMaterial||i.isMeshPhongMaterial?t.environment:null,s=null===U?M.outputColorSpace:!0===U.isXRRenderTarget?U.texture.colorSpace:Ae.workingColorSpace,l=i.isMeshStandardMaterial||i.isMeshLambertMaterial&&!i.envMap||i.isMeshPhongMaterial&&!i.envMap,c=he.get(i.envMap||o,l),d=!0===i.vertexColors&&!!n.attributes.color&&4===n.attributes.color.itemSize,u=!!n.attributes.tangent&&(!!i.normalMap||i.anisotropy>0),f=!!n.morphAttributes.position,p=!!n.morphAttributes.normal,h=!!n.morphAttributes.color,m=wt;i.toneMapped&&(null===U||!0===U.isXRRenderTarget)&&(m=M.toneMapping);let v=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,g=void 0!==v?v.length:0,_=ue.get(i),S=T.state.lights;if(!0===K&&(!0===Z||e!==I)){let t=e===I&&i.id===N;Ee.setState(i,e,t)}let b=!1;i.version===_.__version?(_.needsLights&&_.lightsStateVersion!==S.state.version||_.outputColorSpace!==s||a.isBatchedMesh&&!1===_.batching||!a.isBatchedMesh&&!0===_.batching||a.isBatchedMesh&&!0===_.batchingColor&&null===a.colorTexture||a.isBatchedMesh&&!1===_.batchingColor&&null!==a.colorTexture||a.isInstancedMesh&&!1===_.instancing||!a.isInstancedMesh&&!0===_.instancing||a.isSkinnedMesh&&!1===_.skinning||!a.isSkinnedMesh&&!0===_.skinning||a.isInstancedMesh&&!0===_.instancingColor&&null===a.instanceColor||a.isInstancedMesh&&!1===_.instancingColor&&null!==a.instanceColor||a.isInstancedMesh&&!0===_.instancingMorph&&null===a.morphTexture||a.isInstancedMesh&&!1===_.instancingMorph&&null!==a.morphTexture||_.envMap!==c||!0===i.fog&&_.fog!==r||void 0!==_.numClippingPlanes&&(_.numClippingPlanes!==Ee.numPlanes||_.numIntersection!==Ee.numIntersection)||_.vertexAlphas!==d||_.vertexTangents!==u||_.morphTargets!==f||_.morphNormals!==p||_.morphColors!==h||_.toneMapping!==m||_.morphTargetsCount!==g||!!_.lightProbeGrid!=T.state.lightProbeGridArray.length>0)&&(b=!0):(b=!0,_.__version=i.version);let w=_.currentProgram;!0===b&&(w=rt(i,t,a),C&&i.isNodeMaterial&&C.onUpdateProgram(i,w,_));let E=!1,y=!1,R=!1,A=w.getUniforms(),P=_.uniforms;if(ce.useProgram(w.program)&&(E=!0,y=!0,R=!0),i.id!==N&&(N=i.id,y=!0),_.needsLights){let e=function(e,t){if(0===e.length)return null;if(1===e.length)return null!==e[0].texture?e[0]:null;x.setFromMatrixPosition(t.matrixWorld);for(let t=0,n=e.length;t<n;t++){let n=e[t];if(null!==n.texture&&n.boundingBox.containsPoint(x))return n}return null}(T.state.lightProbeGridArray,a);_.lightProbeGrid!==e&&(_.lightProbeGrid=e,y=!0)}if(E||I!==e){ce.buffers.depth.getReversed()&&!0!==e.reversedDepth&&(e._reversedDepth=!0,e.updateProjectionMatrix()),A.setValue(Ie,"projectionMatrix",e.projectionMatrix),A.setValue(Ie,"viewMatrix",e.matrixWorldInverse);let t=A.map.cameraPosition;void 0!==t&&t.setValue(Ie,Q.setFromMatrixPosition(e.matrixWorld)),se.logarithmicDepthBuffer&&A.setValue(Ie,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial)&&A.setValue(Ie,"isOrthographic",!0===e.isOrthographicCamera),I!==e&&(I=e,y=!0,R=!0)}if(_.needsLights&&(S.state.directionalShadowMap.length>0&&A.setValue(Ie,"directionalShadowMap",S.state.directionalShadowMap,pe),S.state.spotShadowMap.length>0&&A.setValue(Ie,"spotShadowMap",S.state.spotShadowMap,pe),S.state.pointShadowMap.length>0&&A.setValue(Ie,"pointShadowMap",S.state.pointShadowMap,pe)),a.isSkinnedMesh){A.setOptional(Ie,a,"bindMatrix"),A.setOptional(Ie,a,"bindMatrixInverse");let e=a.skeleton;e&&(null===e.boneTexture&&e.computeBoneTexture(),A.setValue(Ie,"boneTexture",e.boneTexture,pe))}a.isBatchedMesh&&(A.setOptional(Ie,a,"batchingTexture"),A.setValue(Ie,"batchingTexture",a._matricesTexture,pe),A.setOptional(Ie,a,"batchingIdTexture"),A.setValue(Ie,"batchingIdTexture",a._indirectTexture,pe),A.setOptional(Ie,a,"batchingColorTexture"),null!==a._colorsTexture&&A.setValue(Ie,"batchingColorTexture",a._colorsTexture,pe));let D=n.morphAttributes;if((void 0!==D.position||void 0!==D.normal||void 0!==D.color)&&Ce.update(a,n,w),(y||_.receiveShadow!==a.receiveShadow)&&(_.receiveShadow=a.receiveShadow,A.setValue(Ie,"receiveShadow",a.receiveShadow)),(i.isMeshStandardMaterial||i.isMeshLambertMaterial||i.isMeshPhongMaterial)&&null===i.envMap&&null!==t.environment&&(P.envMapIntensity.value=t.environmentIntensity),void 0!==P.dfgLUT&&(P.dfgLUT.value=(null===Jo&&((Jo=new Bn(Zo,16,16,et,re)).name="DFG_LUT",Jo.minFilter=qn,Jo.magFilter=qn,Jo.wrapS=Rn,Jo.wrapT=Rn,Jo.generateMipmaps=!1,Jo.needsUpdate=!0),Jo)),y){if(A.setValue(Ie,"toneMappingExposure",M.toneMappingExposure),_.needsLights&&function(e,t){e.ambientLightColor.needsUpdate=t,e.lightProbe.needsUpdate=t,e.directionalLights.needsUpdate=t,e.directionalLightShadows.needsUpdate=t,e.pointLights.needsUpdate=t,e.pointLightShadows.needsUpdate=t,e.spotLights.needsUpdate=t,e.spotLightShadows.needsUpdate=t,e.rectAreaLights.needsUpdate=t,e.hemisphereLights.needsUpdate=t}(P,R),r&&!0===i.fog&&Se.refreshFogUniforms(P,r),Se.refreshMaterialUniforms(P,i,k,G,T.state.transmissionRenderTarget[e.id]),_.needsLights&&_.lightProbeGrid){let e=_.lightProbeGrid;P.probesSH.value=e.texture,P.probesMin.value.copy(e.boundingBox.min),P.probesMax.value.copy(e.boundingBox.max),P.probesResolution.value.copy(e.resolution)}Zr.upload(Ie,ot(_),P,pe)}if(i.isShaderMaterial&&!0===i.uniformsNeedUpdate&&(Zr.upload(Ie,ot(_),P,pe),i.uniformsNeedUpdate=!1),i.isSpriteMaterial&&A.setValue(Ie,"center",a.center),A.setValue(Ie,"modelViewMatrix",a.modelViewMatrix),A.setValue(Ie,"normalMatrix",a.normalMatrix),A.setValue(Ie,"modelMatrix",a.matrixWorld),a.previousModelViewMatrix&&A.setValue(Ie,"previousModelViewMatrix",a.previousModelViewMatrix),e.previousProjectionMatrix&&A.setValue(Ie,"previousProjectionMatrix",e.previousProjectionMatrix),void 0!==i.uniformsGroups){let e=i.uniformsGroups;for(let t=0,n=e.length;t<n;t++){let n=e[t];Ne.update(n,w),Ne.bind(n,w)}}return w}(e,t,n,i,a);ce.setMaterial(i,o);let l=n.index,c=1;if(!0===i.wireframe){if(l=ge.getWireframeAttribute(n),void 0===l)return;c=2}let d=n.drawRange,u=n.attributes.position,f=d.start*c,p=(d.start+d.count)*c;null!==r&&(f=Math.max(f,r.start*c),p=Math.min(p,(r.start+r.count)*c)),null!==l?(f=Math.max(f,0),p=Math.min(p,l.count)):null!=u&&(f=Math.max(f,0),p=Math.min(p,u.count));let h=p-f;if(h<0||h===1/0)return;Ue.setup(a,i,s,n,l);let m,v=Re;if(null!==l&&(m=me.get(l),v=Pe,v.setIndex(m)),a.isMesh)!0===i.wireframe?(ce.setLineWidth(i.wireframeLinewidth*ie()),v.setMode(Ie.LINES)):v.setMode(Ie.TRIANGLES);else if(a.isLine){let e=i.linewidth;void 0===e&&(e=1),ce.setLineWidth(e*ie()),a.isLineSegments?v.setMode(Ie.LINES):a.isLineLoop?v.setMode(Ie.LINE_LOOP):v.setMode(Ie.LINE_STRIP)}else a.isPoints?v.setMode(Ie.POINTS):a.isSprite&&v.setMode(Ie.TRIANGLES);if(a.isBatchedMesh)if(ae.get("WEBGL_multi_draw"))v.renderMultiDraw(a._multiDrawStarts,a._multiDrawCounts,a._multiDrawCount);else{let e=a._multiDrawStarts,t=a._multiDrawCounts,n=a._multiDrawCount,r=l?me.get(l).bytesPerElement:1,o=ue.get(i).currentProgram.getUniforms();for(let i=0;i<n;i++)o.setValue(Ie,"_gl_DrawID",i),v.render(e[i]/r,t[i])}else if(a.isInstancedMesh)v.renderInstances(f,h,a.count);else if(n.isInstancedBufferGeometry){let e=void 0!==n._maxInstanceCount?n._maxInstanceCount:1/0,t=Math.min(n.instanceCount,e);v.renderInstances(f,h,t)}else v.render(f,h)},this.compile=function(e,t,n=null){null===n&&(n=e),T=we.get(n),T.init(t),w.push(T),n.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&(T.pushLight(e),e.castShadow&&T.pushShadow(e))}),e!==n&&e.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&(T.pushLight(e),e.castShadow&&T.pushShadow(e))}),T.setupLights();let i=new Set;return e.traverse(function(e){if(!(e.isMesh||e.isPoints||e.isLine||e.isSprite))return;let t=e.material;if(t)if(Array.isArray(t))for(let a=0;a<t.length;a++){let r=t[a];We(r,n,e),i.add(r)}else We(t,n,e),i.add(t)}),T=w.pop(),i},this.compileAsync=function(e,t,n=null){let i=this.compile(e,t,n);return new Promise(t=>{function n(){i.forEach(function(e){ue.get(e).currentProgram.isReady()&&i.delete(e)}),0!==i.size?setTimeout(n,10):t(e)}null!==ae.get("KHR_parallel_shader_compile")?n():setTimeout(n,10)})};let je=null;function $e(){Ye.stop()}function qe(){Ye.start()}let Ye=new Ea;function Ke(e,t,n,i){if(!1===e.visible)return;if(e.layers.test(t.layers))if(e.isGroup)n=e.renderOrder;else if(e.isLOD)!0===e.autoUpdate&&e.update(t);else if(e.isLightProbeGrid)T.pushLightProbeGrid(e);else if(e.isLight)T.pushLight(e),e.castShadow&&T.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||Y.intersectsSprite(e)){i&&ee.setFromMatrixPosition(e.matrixWorld).applyMatrix4(J);let t=_e.update(e),a=e.material;a.visible&&S.push(e,t,a,n,ee.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||Y.intersectsObject(e))){let t=_e.update(e),a=e.material;if(i&&(void 0!==e.boundingSphere?(null===e.boundingSphere&&e.computeBoundingSphere(),ee.copy(e.boundingSphere.center)):(null===t.boundingSphere&&t.computeBoundingSphere(),ee.copy(t.boundingSphere.center)),ee.applyMatrix4(e.matrixWorld).applyMatrix4(J)),Array.isArray(a)){let i=t.groups;for(let r=0,o=i.length;r<o;r++){let o=i[r],s=a[o.materialIndex];s&&s.visible&&S.push(e,t,s,n,ee.z,o)}}else a.visible&&S.push(e,t,a,n,ee.z,null)}let a=e.children;for(let e=0,r=a.length;e<r;e++)Ke(a[e],t,n,i)}function Je(e,t,n,i){let{opaque:a,transmissive:r,transparent:o}=e;T.setupLightsView(n),!0===K&&Ee.setGlobalState(M.clippingPlanes,n),i&&ce.viewport(O.copy(i)),a.length>0&&nt(a,t,n),r.length>0&&nt(r,t,n),o.length>0&&nt(o,t,n),ce.buffers.depth.setTest(!0),ce.buffers.depth.setMask(!0),ce.buffers.color.setMask(!0),ce.setPolygonOffset(!1)}function Qe(e,t,n,i){if(null!==(!0===n.isScene?n.overrideMaterial:null))return;if(void 0===T.state.transmissionRenderTarget[i.id]){let e=ae.has("EXT_color_buffer_half_float")||ae.has("EXT_color_buffer_float");T.state.transmissionRenderTarget[i.id]=new Xe(1,1,{generateMipmaps:!0,type:e?re:si,minFilter:ei,samples:Math.max(4,se.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Ae.workingColorSpace})}let a=T.state.transmissionRenderTarget[i.id],o=i.viewport||O;a.setSize(o.z*M.transmissionResolutionScale,o.w*M.transmissionResolutionScale);let s=M.getRenderTarget(),l=M.getActiveCubeFace(),c=M.getActiveMipmapLevel();M.setRenderTarget(a),M.getClearColor(B),V=M.getClearAlpha(),V<1&&M.setClearColor(16777215,.5),M.clear(),ne&&ye.render(n);let d=M.toneMapping;M.toneMapping=wt;let u=i.viewport;if(void 0!==i.viewport&&(i.viewport=void 0),T.setupLightsView(i),!0===K&&Ee.setGlobalState(M.clippingPlanes,i),nt(e,n,i),pe.updateMultisampleRenderTarget(a),pe.updateRenderTargetMipmap(a),!1===ae.has("WEBGL_multisampled_render_to_texture")){let e=!1;for(let a=0,r=t.length;a<r;a++){let r=t[a],{object:o,geometry:s,material:l,group:c}=r;if(l.side===Cn&&o.layers.test(i.layers)){let t=l.side;l.side=bn,l.needsUpdate=!0,at(o,n,i,s,l,c),l.side=t,l.needsUpdate=!0,e=!0}}!0===e&&(pe.updateMultisampleRenderTarget(a),pe.updateRenderTargetMipmap(a))}M.setRenderTarget(s,l,c),M.setClearColor(B,V),void 0!==u&&(i.viewport=u),M.toneMapping=d}function nt(e,t,n){let i=!0===t.isScene?t.overrideMaterial:null;for(let a=0,r=e.length;a<r;a++){let r=e[a],{object:o,geometry:s,group:l}=r,c=r.material;!0===c.allowOverride&&null!==i&&(c=i),o.layers.test(n.layers)&&at(o,t,n,s,c,l)}}function at(e,t,n,i,a,r){e.onBeforeRender(M,t,n,i,a,r),e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix),a.onBeforeRender(M,t,n,i,e,r),!0===a.transparent&&a.side===Cn&&!1===a.forceSinglePass?(a.side=bn,a.needsUpdate=!0,M.renderBufferDirect(n,t,i,a,e,r),a.side=_n,a.needsUpdate=!0,M.renderBufferDirect(n,t,i,a,e,r),a.side=Cn):M.renderBufferDirect(n,t,i,a,e,r),e.onAfterRender(M,t,n,i,a,r)}function rt(e,t,n){!0!==t.isScene&&(t=te);let i=ue.get(e),a=T.state.lights,r=T.state.shadowsArray,o=a.state.version,s=xe.getParameters(e,a.state,r,t,n,T.state.lightProbeGridArray),l=xe.getProgramCacheKey(s),c=i.programs;i.environment=e.isMeshStandardMaterial||e.isMeshLambertMaterial||e.isMeshPhongMaterial?t.environment:null,i.fog=t.fog;let d=e.isMeshStandardMaterial||e.isMeshLambertMaterial&&!e.envMap||e.isMeshPhongMaterial&&!e.envMap;i.envMap=he.get(e.envMap||i.environment,d),i.envMapRotation=null!==i.environment&&null===e.envMap?t.environmentRotation:e.envMapRotation,void 0===c&&(e.addEventListener("dispose",ke),c=new Map,i.programs=c);let u=c.get(l);if(void 0!==u){if(i.currentProgram===u&&i.lightsStateVersion===o)return lt(e,s),u}else s.uniforms=xe.getUniforms(e),null!==C&&e.isNodeMaterial&&C.build(e,n,s),e.onBeforeCompile(s,M),u=xe.acquireProgram(s,l),c.set(l,u),i.uniforms=s.uniforms;let f=i.uniforms;return(!e.isShaderMaterial&&!e.isRawShaderMaterial||!0===e.clipping)&&(f.clippingPlanes=Ee.uniform),lt(e,s),i.needsLights=function(e){return e.isMeshLambertMaterial||e.isMeshToonMaterial||e.isMeshPhongMaterial||e.isMeshStandardMaterial||e.isShadowMaterial||e.isShaderMaterial&&!0===e.lights}(e),i.lightsStateVersion=o,i.needsLights&&(f.ambientLightColor.value=a.state.ambient,f.lightProbe.value=a.state.probe,f.directionalLights.value=a.state.directional,f.directionalLightShadows.value=a.state.directionalShadow,f.spotLights.value=a.state.spot,f.spotLightShadows.value=a.state.spotShadow,f.rectAreaLights.value=a.state.rectArea,f.ltc_1.value=a.state.rectAreaLTC1,f.ltc_2.value=a.state.rectAreaLTC2,f.pointLights.value=a.state.point,f.pointLightShadows.value=a.state.pointShadow,f.hemisphereLights.value=a.state.hemi,f.directionalShadowMatrix.value=a.state.directionalShadowMatrix,f.spotLightMatrix.value=a.state.spotLightMatrix,f.spotLightMap.value=a.state.spotLightMap,f.pointShadowMatrix.value=a.state.pointShadowMatrix),i.lightProbeGrid=T.state.lightProbeGridArray.length>0,i.currentProgram=u,i.uniformsList=null,u}function ot(e){if(null===e.uniformsList){let t=e.currentProgram.getUniforms();e.uniformsList=Zr.seqWithValue(t.seq,e.uniforms)}return e.uniformsList}function lt(e,t){let n=ue.get(e);n.outputColorSpace=t.outputColorSpace,n.batching=t.batching,n.batchingColor=t.batchingColor,n.instancing=t.instancing,n.instancingColor=t.instancingColor,n.instancingMorph=t.instancingMorph,n.skinning=t.skinning,n.morphTargets=t.morphTargets,n.morphNormals=t.morphNormals,n.morphColors=t.morphColors,n.morphTargetsCount=t.morphTargetsCount,n.numClippingPlanes=t.numClippingPlanes,n.numIntersection=t.numClipIntersection,n.vertexAlphas=t.vertexAlphas,n.vertexTangents=t.vertexTangents,n.toneMapping=t.toneMapping}Ye.setAnimationLoop(function(e){je&&je(e)}),typeof self<"u"&&Ye.setContext(self),this.setAnimationLoop=function(e){je=e,Be.setAnimationLoop(e),null===e?Ye.stop():Ye.start()},Be.addEventListener("sessionstart",$e),Be.addEventListener("sessionend",qe),this.render=function(e,t){if(void 0!==t&&!0!==t.isCamera)return void Ti("WebGLRenderer.render: camera is not an instance of THREE.Camera.");if(!0===y)return;null!==C&&C.renderStart(e,t);let n=!0===Be.enabled&&!0===Be.isPresenting,i=null!==E&&(null===U||n)&&E.begin(M,U);if(!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===t.parent&&!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),!0===Be.enabled&&!0===Be.isPresenting&&(null===E||!1===E.isCompositing())&&(!0===Be.cameraAutoUpdate&&Be.updateCamera(t),t=Be.getCamera()),!0===e.isScene&&e.onBeforeRender(M,e,t,U),T=we.get(e,w.length),T.init(t),T.state.textureUnits=pe.getTextureUnits(),w.push(T),J.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),Y.setFromProjectionMatrix(J,kn,t.reversedDepth),Z=this.localClippingEnabled,K=Ee.init(this.clippingPlanes,Z),S=be.get(e,b.length),S.init(),b.push(S),!0===Be.enabled&&!0===Be.isPresenting){let e=M.xr.getDepthSensingMesh();null!==e&&Ke(e,t,-1/0,M.sortObjects)}Ke(e,t,0,M.sortObjects),S.finish(),!0===M.sortObjects&&S.sort(W,X,t.reversedDepth),ne=!1===Be.enabled||!1===Be.isPresenting||!1===Be.hasDepthSensing(),ne&&ye.addToRenderList(S,e),this.info.render.frame++,!0===this.info.autoReset&&this.info.reset(),!0===K&&Ee.beginShadows();let a=T.state.shadowsArray;if(Me.render(a,e,t),!0===K&&Ee.endShadows(),!1===(i&&E.hasRenderPass())){let n=S.opaque,i=S.transmissive;if(T.setupLights(),t.isArrayCamera){let a=t.cameras;if(i.length>0)for(let t=0,r=a.length;t<r;t++)Qe(n,i,e,a[t]);ne&&ye.render(e);for(let t=0,n=a.length;t<n;t++){let n=a[t];Je(S,e,n,n.viewport)}}else i.length>0&&Qe(n,i,e,t),ne&&ye.render(e),Je(S,e,t)}null!==U&&0===L&&(pe.updateMultisampleRenderTarget(U),pe.updateRenderTargetMipmap(U)),i&&E.end(M),!0===e.isScene&&e.onAfterRender(M,e,t),Ue.resetDefaultState(),N=-1,I=null,w.pop(),w.length>0?(T=w[w.length-1],pe.setTextureUnits(T.state.textureUnits),!0===K&&Ee.setGlobalState(M.clippingPlanes,T.state.camera)):T=null,b.pop(),S=b.length>0?b[b.length-1]:null,null!==C&&C.renderEnd()},this.getActiveCubeFace=function(){return D},this.getActiveMipmapLevel=function(){return L},this.getRenderTarget=function(){return U},this.setRenderTargetTextures=function(e,t,n){let i=ue.get(e);i.__autoAllocateDepthBuffer=!1===e.resolveDepthBuffer,!1===i.__autoAllocateDepthBuffer&&(i.__useRenderToTexture=!1),ue.get(e.texture).__webglTexture=t,ue.get(e.depthTexture).__webglTexture=i.__autoAllocateDepthBuffer?void 0:n,i.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(e,t){let n=ue.get(e);n.__webglFramebuffer=t,n.__useDefaultFramebuffer=void 0===t},this.setRenderTarget=function(e,t=0,n=0){U=e,D=t,L=n;let i=null,a=!1,r=!1;if(e){let o=ue.get(e);if(void 0!==o.__useDefaultFramebuffer)return ce.bindFramebuffer(Ie.FRAMEBUFFER,o.__webglFramebuffer),O.copy(e.viewport),F.copy(e.scissor),z=e.scissorTest,ce.viewport(O),ce.scissor(F),ce.setScissorTest(z),void(N=-1);if(void 0===o.__webglFramebuffer)pe.setupRenderTarget(e);else if(o.__hasExternalTextures)pe.rebindTextures(e,ue.get(e.texture).__webglTexture,ue.get(e.depthTexture).__webglTexture);else if(e.depthBuffer){let t=e.depthTexture;if(o.__boundDepthTexture!==t){if(null!==t&&ue.has(t)&&(e.width!==t.image.width||e.height!==t.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");pe.setupDepthRenderbuffer(e)}}let s=e.texture;(s.isData3DTexture||s.isDataArrayTexture||s.isCompressedArrayTexture)&&(r=!0);let l=ue.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(i=Array.isArray(l[t])?l[t][n]:l[t],a=!0):i=e.samples>0&&!1===pe.useMultisampledRTT(e)?ue.get(e).__webglMultisampledFramebuffer:Array.isArray(l)?l[n]:l,O.copy(e.viewport),F.copy(e.scissor),z=e.scissorTest}else O.copy(j).multiplyScalar(k).floor(),F.copy($).multiplyScalar(k).floor(),z=q;if(0!==n&&(i=R),ce.bindFramebuffer(Ie.FRAMEBUFFER,i)&&ce.drawBuffers(e,i),ce.viewport(O),ce.scissor(F),ce.setScissorTest(z),a){let i=ue.get(e.texture);Ie.framebufferTexture2D(Ie.FRAMEBUFFER,Ie.COLOR_ATTACHMENT0,Ie.TEXTURE_CUBE_MAP_POSITIVE_X+t,i.__webglTexture,n)}else if(r){let i=t;for(let t=0;t<e.textures.length;t++){let a=ue.get(e.textures[t]);Ie.framebufferTextureLayer(Ie.FRAMEBUFFER,Ie.COLOR_ATTACHMENT0+t,a.__webglTexture,n,i)}}else if(null!==e&&0!==n){let t=ue.get(e.texture);Ie.framebufferTexture2D(Ie.FRAMEBUFFER,Ie.COLOR_ATTACHMENT0,Ie.TEXTURE_2D,t.__webglTexture,n)}N=-1},this.readRenderTargetPixels=function(e,t,n,i,a,r,o,s=0){if(!e||!e.isWebGLRenderTarget)return void Ti("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let l=ue.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==o&&(l=l[o]),l){ce.bindFramebuffer(Ie.FRAMEBUFFER,l);try{let o=e.textures[s],l=o.format,c=o.type;if(e.textures.length>1&&Ie.readBuffer(Ie.COLOR_ATTACHMENT0+s),!se.textureFormatReadable(l))return void Ti("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!se.textureTypeReadable(c))return void Ti("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");t>=0&&t<=e.width-i&&n>=0&&n<=e.height-a&&Ie.readPixels(t,n,i,a,De.convert(l),De.convert(c),r)}finally{let e=null!==U?ue.get(U).__webglFramebuffer:null;ce.bindFramebuffer(Ie.FRAMEBUFFER,e)}}},this.readRenderTargetPixelsAsync=async function(e,t,n,i,a,r,o,s=0){if(!e||!e.isWebGLRenderTarget)throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let l=ue.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==o&&(l=l[o]),l){if(t>=0&&t<=e.width-i&&n>=0&&n<=e.height-a){ce.bindFramebuffer(Ie.FRAMEBUFFER,l);let o=e.textures[s],c=o.format,d=o.type;if(e.textures.length>1&&Ie.readBuffer(Ie.COLOR_ATTACHMENT0+s),!se.textureFormatReadable(c))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!se.textureTypeReadable(d))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let u=Ie.createBuffer();Ie.bindBuffer(Ie.PIXEL_PACK_BUFFER,u),Ie.bufferData(Ie.PIXEL_PACK_BUFFER,r.byteLength,Ie.STREAM_READ),Ie.readPixels(t,n,i,a,De.convert(c),De.convert(d),0);let f=null!==U?ue.get(U).__webglFramebuffer:null;ce.bindFramebuffer(Ie.FRAMEBUFFER,f);let p=Ie.fenceSync(Ie.SYNC_GPU_COMMANDS_COMPLETE,0);return Ie.flush(),await Ai(Ie,p,4),Ie.bindBuffer(Ie.PIXEL_PACK_BUFFER,u),Ie.getBufferSubData(Ie.PIXEL_PACK_BUFFER,0,r),Ie.deleteBuffer(u),Ie.deleteSync(p),r}throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(e,t=null,n=0){let i=Math.pow(2,-n),a=Math.floor(e.image.width*i),r=Math.floor(e.image.height*i),o=null!==t?t.x:0,s=null!==t?t.y:0;pe.setTexture2D(e,0),Ie.copyTexSubImage2D(Ie.TEXTURE_2D,n,0,0,o,s,a,r),ce.unbindTexture()},this.copyTextureToTexture=function(e,t,n=null,i=null,a=0,r=0){let o,s,l,c,d,u,f,p,h,m=e.isCompressedTexture?e.mipmaps[r]:e.image;if(null!==n)o=n.max.x-n.min.x,s=n.max.y-n.min.y,l=n.isBox3?n.max.z-n.min.z:1,c=n.min.x,d=n.min.y,u=n.isBox3?n.min.z:0;else{let t=Math.pow(2,-a);o=Math.floor(m.width*t),s=Math.floor(m.height*t),l=e.isDataArrayTexture?m.depth:e.isData3DTexture?Math.floor(m.depth*t):1,c=0,d=0,u=0}null!==i?(f=i.x,p=i.y,h=i.z):(f=0,p=0,h=0);let v,g=De.convert(t.format),_=De.convert(t.type);t.isData3DTexture?(pe.setTexture3D(t,0),v=Ie.TEXTURE_3D):t.isDataArrayTexture||t.isCompressedArrayTexture?(pe.setTexture2DArray(t,0),v=Ie.TEXTURE_2D_ARRAY):(pe.setTexture2D(t,0),v=Ie.TEXTURE_2D),ce.activeTexture(Ie.TEXTURE0),ce.pixelStorei(Ie.UNPACK_FLIP_Y_WEBGL,t.flipY),ce.pixelStorei(Ie.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),ce.pixelStorei(Ie.UNPACK_ALIGNMENT,t.unpackAlignment);let x=ce.getParameter(Ie.UNPACK_ROW_LENGTH),S=ce.getParameter(Ie.UNPACK_IMAGE_HEIGHT),T=ce.getParameter(Ie.UNPACK_SKIP_PIXELS),b=ce.getParameter(Ie.UNPACK_SKIP_ROWS),w=ce.getParameter(Ie.UNPACK_SKIP_IMAGES);ce.pixelStorei(Ie.UNPACK_ROW_LENGTH,m.width),ce.pixelStorei(Ie.UNPACK_IMAGE_HEIGHT,m.height),ce.pixelStorei(Ie.UNPACK_SKIP_PIXELS,c),ce.pixelStorei(Ie.UNPACK_SKIP_ROWS,d),ce.pixelStorei(Ie.UNPACK_SKIP_IMAGES,u);let E=e.isDataArrayTexture||e.isData3DTexture,M=t.isDataArrayTexture||t.isData3DTexture;if(e.isDepthTexture){let n=ue.get(e),i=ue.get(t),m=ue.get(n.__renderTarget),v=ue.get(i.__renderTarget);ce.bindFramebuffer(Ie.READ_FRAMEBUFFER,m.__webglFramebuffer),ce.bindFramebuffer(Ie.DRAW_FRAMEBUFFER,v.__webglFramebuffer);for(let n=0;n<l;n++)E&&(Ie.framebufferTextureLayer(Ie.READ_FRAMEBUFFER,Ie.COLOR_ATTACHMENT0,ue.get(e).__webglTexture,a,u+n),Ie.framebufferTextureLayer(Ie.DRAW_FRAMEBUFFER,Ie.COLOR_ATTACHMENT0,ue.get(t).__webglTexture,r,h+n)),Ie.blitFramebuffer(c,d,o,s,f,p,o,s,Ie.DEPTH_BUFFER_BIT,Ie.NEAREST);ce.bindFramebuffer(Ie.READ_FRAMEBUFFER,null),ce.bindFramebuffer(Ie.DRAW_FRAMEBUFFER,null)}else if(0!==a||e.isRenderTargetTexture||ue.has(e)){let n=ue.get(e),i=ue.get(t);ce.bindFramebuffer(Ie.READ_FRAMEBUFFER,A),ce.bindFramebuffer(Ie.DRAW_FRAMEBUFFER,P);for(let e=0;e<l;e++)E?Ie.framebufferTextureLayer(Ie.READ_FRAMEBUFFER,Ie.COLOR_ATTACHMENT0,n.__webglTexture,a,u+e):Ie.framebufferTexture2D(Ie.READ_FRAMEBUFFER,Ie.COLOR_ATTACHMENT0,Ie.TEXTURE_2D,n.__webglTexture,a),M?Ie.framebufferTextureLayer(Ie.DRAW_FRAMEBUFFER,Ie.COLOR_ATTACHMENT0,i.__webglTexture,r,h+e):Ie.framebufferTexture2D(Ie.DRAW_FRAMEBUFFER,Ie.COLOR_ATTACHMENT0,Ie.TEXTURE_2D,i.__webglTexture,r),0!==a?Ie.blitFramebuffer(c,d,o,s,f,p,o,s,Ie.COLOR_BUFFER_BIT,Ie.NEAREST):M?Ie.copyTexSubImage3D(v,r,f,p,h+e,c,d,o,s):Ie.copyTexSubImage2D(v,r,f,p,c,d,o,s);ce.bindFramebuffer(Ie.READ_FRAMEBUFFER,null),ce.bindFramebuffer(Ie.DRAW_FRAMEBUFFER,null)}else M?e.isDataTexture||e.isData3DTexture?Ie.texSubImage3D(v,r,f,p,h,o,s,l,g,_,m.data):t.isCompressedArrayTexture?Ie.compressedTexSubImage3D(v,r,f,p,h,o,s,l,g,m.data):Ie.texSubImage3D(v,r,f,p,h,o,s,l,g,_,m):e.isDataTexture?Ie.texSubImage2D(Ie.TEXTURE_2D,r,f,p,o,s,g,_,m.data):e.isCompressedTexture?Ie.compressedTexSubImage2D(Ie.TEXTURE_2D,r,f,p,m.width,m.height,g,m.data):Ie.texSubImage2D(Ie.TEXTURE_2D,r,f,p,o,s,g,_,m);ce.pixelStorei(Ie.UNPACK_ROW_LENGTH,x),ce.pixelStorei(Ie.UNPACK_IMAGE_HEIGHT,S),ce.pixelStorei(Ie.UNPACK_SKIP_PIXELS,T),ce.pixelStorei(Ie.UNPACK_SKIP_ROWS,b),ce.pixelStorei(Ie.UNPACK_SKIP_IMAGES,w),0===r&&t.generateMipmaps&&Ie.generateMipmap(v),ce.unbindTexture()},this.initRenderTarget=function(e){void 0===ue.get(e).__webglFramebuffer&&pe.setupRenderTarget(e)},this.initTexture=function(e){e.isCubeTexture?pe.setTextureCube(e,0):e.isData3DTexture?pe.setTexture3D(e,0):e.isDataArrayTexture||e.isCompressedArrayTexture?pe.setTexture2DArray(e,0):pe.setTexture2D(e,0),ce.unbindTexture()},this.resetState=function(){D=0,L=0,U=null,ce.reset(),Ue.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return kn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=Ae._getDrawingBufferColorSpace(e),t.unpackColorSpace=Ae._getUnpackColorSpace()}},es=class extends Fi{constructor(e){super("b"),this.nodeType="Bool",this.value=e??!1}generateReadonly(e,t,n,i){return e.format(this.value?"true":"false",i,t)}},ts=class extends Fi{constructor(e=1,t){super("f[]"),this.nodeType="FloatArray",this.size=e,this.value=Array.isArray(t)?t:"number"==typeof t?new Array(e).fill(t):new Array(e).fill(0)}},ns=class extends Fi{},is=class extends ns{constructor(e){super("v3"),this.image=e,this._value=new Te}get value(){return this._value.x=this.image.isVideo?this.image.img.videoWidth??0:this.image.img.width,this._value.y=this.image.isVideo?this.image.img.videoHeight??0:this.image.img.height,this._value}},as=class extends ns{constructor(e,t,n=1008,i=1006){super("t"),this.image=e,this.wrap=t,this.minFilter=n,this.magFilter=i}get value(){return this.image.getTexture(this.wrap,this.minFilter,this.magFilter)}},rs=class extends Fi{constructor(e){super("m3"),this.nodeType="Matrix3",this.value=e??new Me}generateReadonly(e,t,n,i,a,r){return e.format("mat3("+this.value.elements.join(", ")+")",i,t)}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}},os=class extends Fi{constructor(e){super("m4"),this.nodeType="Matrix4",this.value=e??new tt}generateReadonly(e,t,n,i,a,r){return e.format("mat4("+this.value.elements.join(", ")+")",i,t)}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}};function ss(e,t,n,i=0){e.setUvTransform(n[0],n[1],t[0],t[1],0,0,0).premultiply((new Me).makeRotation(i*ce.DEG2RAD))}var ls=class extends rs{constructor(e,t,n=0){super(new Me),this.repeat=e,this.offset=t,this.rotation=n,ss(this.value,e,t,n)}updateMatrix(){ss(this.value,this.repeat,this.offset,this.rotation)}},cs=class extends Fi{constructor(e=1,t){super("v4[]"),this.nodeType="Vector4Array",this.size=e,this.value=Array.isArray(t)?t:t instanceof Fe?new Array(e).fill(t):new Array(e).fill(new Fe(0))}},ds=class extends Oi{constructor(e,t,n,i){super("v3"),this.nodeType="Blend",this.a=e,this.b=t,this.alpha=n,this.mode=i}generate(e,t){if(e.isShader("fragment")){let n=[];return n.push(this.a.build(e,"c")),n.push(this.b.build(e,"c")),n.push(this.alpha.build(e,"f")),n.push(this.mode.build(e,"i")),e.format("spe_blend("+n.join(",")+")",this.getType(e),t)}return console.warn("BlendNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},us=class extends Oi{constructor(e,t){super("v3"),this.nodeType="CustomColor",this.color=e,this.alpha=t,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.isShader("fragment")){let n=e.include(us.Nodes.customColor);e.addFragmentVariable(this.calpha,"float");let i=[];return i.push(this.color.build(e,"v3")),i.push(this.mask?`luminance(${this.mask.build(e,"v3")})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(n+"("+i.join(",")+")",this.getType(e),t)}return console.warn("CustomColorNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},fs=us;fs.Nodes={customColor:new ki("vec3 customColor(vec3 color, float mask, float alpha, out float calpha) {\n\t\t\t\tfloat lalpha = alpha * mask;\n\t\t\t\tcalpha = lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0);\n\t\t\t\taccumAlpha += (1.0 - accumAlpha) * lalpha;\n\n\t\t\t\treturn color;\n\t\t\t}")};var ps=class extends Oi{constructor(e,t){super("v3"),this.nodeType="CustomNormal",this.cnormal=e,this.alpha=t,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.isShader("fragment")){let n=e.include(ps.Nodes.customNormal);e.addFragmentVariable(this.calpha,"float");let i=[];return i.push(this.cnormal.build(e,"v3")),i.push("normal"),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(n+"("+i.join(",")+")",this.getType(e),t)}return console.warn("CustomNormalNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},hs=ps;hs.Nodes={customNormal:new ki("vec3 customNormal(vec3 cnormal, vec3 norm, float mask, float alpha, out float calpha) {\n\t\t\t\tvec3 normal = packNormalToRGB( norm ).rgb;\n\t\t\t\tnormal *= step( vec3(0.5), cnormal );\n\n\t\t\t\tfloat lalpha = alpha * mask;\n\t\t\t\tcalpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );\n\t\t\t\taccumAlpha += ( 1.0 - accumAlpha ) * lalpha;\n\n\t\t\t\treturn normal;\n\t\t\t}")};var ms=[{a:"y",b:"z",pole:"x"},{a:"z",b:"x",pole:"y"},{a:"x",b:"y",pole:"z"}],vs=class extends Oi{constructor(e,t,n,i,a,r,o,s,l,c,d,u,f=-1){super("v3"),this.nodeType="CustomTexture",this.texture=e,this.textureSize=t,this.crop=n,this.projection=i,this.axis=a,this.projectionAxis=f,this.side=r,this.size=o,this.blending=s,this.mat=l,this.isMask=u,this.alpha=c,this.mode=d,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){e.require("position"),e.require("normal"),e.require("uv"),e.requires.uv=[!0],e.extensions.shaderTextureLOD=!0,e.extensions.derivatives=!0;let n,i=`g${this.uuid.toString().replace(/-/g,"")}`;switch(this.projection.value){case 3:{let t=this.projectionAxis;if(0===t||2===t){let{a:a,b:r,pole:o}=ms[t];n=e.include(new ki(`\nvec3 ${i}_cylindricalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUv) {\n vec3 posN = normalize(position);\n float u = 0.5 + atan(posN.${a}, posN.${r}) / (2.*3.1415);\n float scaledHeight = position.${o} / (size.y * 0.5);\n float v = (scaledHeight / 2.) + .5;\n\n vec2 calculatedUv = vec2(u,v);\n\t\t\t\tvec2 uvs = ( mat * vec3( calculatedUv * 2. - 1., 1. ) / 2. + 0.5 ).xy;\n\t\t\t\twriteUv = uvs;\n\n // Seam-safe FILTERED sample: the atan()-derived u jumps a whole\n // period at the wrap seam, so implicit derivatives would smear a\n // lowest-mip column across it. Folding the u-derivatives to the\n // nearest period keeps the true footprint — and, unlike the\n // forced-LOD sample this replaces (log2(fwidth*texSize), up to a\n // full mip too low), it leaves mip selection to the sampler, so\n // the layer's Sharpness filters and anisotropy actually apply.\n vec2 uvDx = dFdx(uvs); uvDx.x -= floor(uvDx.x + 0.5);\n vec2 uvDy = dFdy(uvs); uvDy.x -= floor(uvDy.x + 0.5);\n\t\t\t\t#ifdef GL_EXT_shader_texture_lod\n vec4 tmp = texture2DGradEXT(tex, uvs, uvDx, uvDy);\n\t\t\t\t#else\n vec4 tmp = textureGrad(tex, uvs, uvDx, uvDy);\n\t\t\t\t#endif\n\n\t\t\t\tvec3 col = tmp.rgb;\n\t\t\t\tfloat lalpha = alpha * tmp.a;\n\t\t\t\tif ( crop > 0.5 ) {\n\t\t\t\t\tif ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {\n\t\t\t\t\t\tlalpha = 0.0;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tlalpha *= mask;\n\n\t\t\t\tcalpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );\n\t\t\t\taccumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));\n\n\t\t\t\treturn col;\n\t\t\t}\n`))}else n=e.include(vs.Nodes.cylindrical);break}case 2:{let t=this.projectionAxis;if(0===t||2===t){let{a:a,b:r,pole:o}=ms[t];n=e.include(new ki(`\nvec3 ${i}_sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUv) {\n vec3 posN = normalize(vPosition);\n float u = 0.5 + atan(posN.${a}, posN.${r}) / (2.*3.1415);\n float v = 0.5 + asin(posN.${o}) / 3.1415;\n\n vec2 calculatedUv = vec2(u,v);\n\t\t\t\tvec2 uvs = ( mat * vec3( calculatedUv * 2. - 1., 1. ) / 2. + 0.5 ).xy;\n\t\t\t\twriteUv = uvs;\n\n // Seam-safe FILTERED sample: the atan()-derived u jumps a whole\n // period at the wrap seam, so implicit derivatives would smear a\n // lowest-mip column across it. Folding the u-derivatives to the\n // nearest period keeps the true footprint — and, unlike the\n // forced-LOD sample this replaces (log2(fwidth*texSize), up to a\n // full mip too low), it leaves mip selection to the sampler, so\n // the layer's Sharpness filters and anisotropy actually apply.\n vec2 uvDx = dFdx(uvs); uvDx.x -= floor(uvDx.x + 0.5);\n vec2 uvDy = dFdy(uvs); uvDy.x -= floor(uvDy.x + 0.5);\n\t\t\t\t#ifdef GL_EXT_shader_texture_lod\n vec4 tmp = texture2DGradEXT(tex, uvs, uvDx, uvDy);\n\t\t\t\t#else\n vec4 tmp = textureGrad(tex, uvs, uvDx, uvDy);\n\t\t\t\t#endif\n\n\t\t\t\tvec3 col = tmp.rgb;\n\t\t\t\tfloat lalpha = alpha * tmp.a;\n\t\t\t\tif ( crop > 0.5 ) {\n\t\t\t\t\tif ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {\n\t\t\t\t\t\tlalpha = 0.0;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tlalpha *= mask;\n\n\t\t\t\tcalpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );\n\t\t\t\taccumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));\n\n\t\t\t\treturn col;\n\t\t\t}\n`))}else n=e.include(vs.Nodes.spherical);break}case 1:{let t=["vec3(1.0, 0.0, 0.0)","vec3(0.0, 1.0, 0.0)","vec3(0.0, 0.0, 1.0)"][this.axis.value],a=["zy","xz","xy"][this.axis.value],r=new ki(`\n\t\tvec3 ${i}_planarTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUv) {\n\t\t\t\tvec2 projected = (1. + (position.${a})) / 2.;\n\t\t\t\tvec2 uvs = ( mat * vec3( (projected * 2. - 1.) / (size * .5), 1. ) / 2. + 0.5 ).xy;\n\t\t\t\twriteUv = uvs;\n\n\t\t\t\tvec4 tmp = texture2D( tex, uvs );\n\n\t\t\t\tvec3 col = tmp.rgb;\n\t\t\t\tfloat lalpha = alpha * tmp.a;\n\t\t\t\t${2===this.side.value?"":`lalpha *= step(0.0, ${1===this.side.value?"-1.0 * ":""}dot(vObjectNormal, ${t}));`}\n\n\t\t\t\tif ( crop > 0.5 ) {\n\t\t\t\t\tif ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {\n\t\t\t\t\t\tlalpha = 0.0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tlalpha *= mask;\n\n\t\t\t\tcalpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );\n\t\t\t\taccumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));\n\n\t\t\t\treturn col;\n\t\t\t}`);n=e.include(r);break}case 4:n=e.include(vs.Nodes.triplanar);break;case 0:{let t=vs.Nodes.uv.src,a=new ki(t.replace("uvTexture",`${i}_uvTexture`));n=e.include(a);break}default:n=e.include(vs.Nodes.uv)}e.addFragmentVariable(this.calpha,"float");let a=[];if(a.push("normal"),a.push(this.texture.generate(e,"t")),a.push(this.textureSize.build(e,"v2")),a.push(this.crop.build(e,"f")),a.push(this.mat.build(e,"mat3")),a.push(this.size.build(e,"v2")),a.push(this.blending.build(e,"f")),a.push(this.isMask.build(e,"b")),a.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),a.push(this.alpha.build(e,"f")),a.push(this.mode.build(e,"i")),a.push(this.calpha),4===this.projection.value){let t=`${i}_writeUvs`,n=t+"0",r=t+"1",o=t+"2",s=`${i}_triplanarWeights`;e.addFragmentVariable(n,"vec2"),e.addFragmentVariable(r,"vec2"),e.addFragmentVariable(o,"vec2"),e.addFragmentVariable(s,"vec3"),a.push(n),a.push(r),a.push(o),a.push(s)}else{let t=`${i}_writeUvs`;e.addFragmentVariable(t,"vec2"),a.push(t)}return e.format(n+"("+a.join(",")+")",this.getType(e),t)}},gs=vs;gs.Nodes={cylindrical:new ki("\nvec3 cylindricalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUv) {\n vec3 posN = normalize(position);\n float u = 0.5 + atan(posN.z, posN.x) / (2.*3.1415);\n float scaledHeight = position.y / (size.y * 0.5);\n float v = (scaledHeight / 2.) + .5;\n\n vec2 calculatedUv = vec2(u,v);\n\t\t\t\tvec2 uvs = ( mat * vec3( calculatedUv * 2. - 1., 1. ) / 2. + 0.5 ).xy;\n\t\t\t\twriteUv = uvs;\n\n // Seam-safe FILTERED sample: the atan()-derived u jumps a whole\n // period at the wrap seam, so implicit derivatives would smear a\n // lowest-mip column across it. Folding the u-derivatives to the\n // nearest period keeps the true footprint — and, unlike the\n // forced-LOD sample this replaces (log2(fwidth*texSize), up to a\n // full mip too low), it leaves mip selection to the sampler, so\n // the layer's Sharpness filters and anisotropy actually apply.\n vec2 uvDx = dFdx(uvs); uvDx.x -= floor(uvDx.x + 0.5);\n vec2 uvDy = dFdy(uvs); uvDy.x -= floor(uvDy.x + 0.5);\n\t\t\t\t#ifdef GL_EXT_shader_texture_lod\n vec4 tmp = texture2DGradEXT(tex, uvs, uvDx, uvDy);\n\t\t\t\t#else\n vec4 tmp = textureGrad(tex, uvs, uvDx, uvDy);\n\t\t\t\t#endif\n\n\t\t\t\tvec3 col = tmp.rgb;\n\t\t\t\tfloat lalpha = alpha * tmp.a;\n\t\t\t\tif ( crop > 0.5 ) {\n\t\t\t\t\tif ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {\n\t\t\t\t\t\tlalpha = 0.0;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tlalpha *= mask;\n\t\t\t\t\n\t\t\t\tcalpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );\n\t\t\t\taccumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));\n\n\t\t\t\treturn col;\n\t\t\t}\n"),spherical:new ki("\nvec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUv) {\n vec3 posN = normalize(vPosition);\n float u = 0.5 + atan(posN.z, posN.x) / (2.*3.1415);\n float v = 0.5 + asin(posN.y) / 3.1415;\n\n vec2 calculatedUv = vec2(u,v);\n\t\t\t\tvec2 uvs = ( mat * vec3( calculatedUv * 2. - 1., 1. ) / 2. + 0.5 ).xy;\n\t\t\t\twriteUv = uvs;\n\n // Seam-safe FILTERED sample: the atan()-derived u jumps a whole\n // period at the wrap seam, so implicit derivatives would smear a\n // lowest-mip column across it. Folding the u-derivatives to the\n // nearest period keeps the true footprint — and, unlike the\n // forced-LOD sample this replaces (log2(fwidth*texSize), up to a\n // full mip too low), it leaves mip selection to the sampler, so\n // the layer's Sharpness filters and anisotropy actually apply.\n vec2 uvDx = dFdx(uvs); uvDx.x -= floor(uvDx.x + 0.5);\n vec2 uvDy = dFdy(uvs); uvDy.x -= floor(uvDy.x + 0.5);\n\t\t\t\t#ifdef GL_EXT_shader_texture_lod\n vec4 tmp = texture2DGradEXT(tex, uvs, uvDx, uvDy);\n\t\t\t\t#else\n vec4 tmp = textureGrad(tex, uvs, uvDx, uvDy);\n\t\t\t\t#endif\n\n\t\t\t\tvec3 col = tmp.rgb;\n\t\t\t\tfloat lalpha = alpha * tmp.a;\n\t\t\t\tif ( crop > 0.5 ) {\n\t\t\t\t\tif ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {\n\t\t\t\t\t\tlalpha = 0.0;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tlalpha *= mask;\n\n\t\t\t\tcalpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );\n\t\t\t\taccumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));\n\n\t\t\t\treturn col;\n\t\t\t}\n"),uv:new ki("vec3 uvTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUv) {\n\t\t\t\tvec2 uvs = ( mat * vec3( vUv * 2. - 1., 1. ) / 2. + 0.5 ).xy;\n\t\t\t\twriteUv = uvs;\n\n\t\t\t\tvec4 tmp = texture2D( tex, uvs );\n\n\t\t\t\tvec3 col = tmp.rgb;\n\n\t\t\t\tfloat lalpha = alpha * tmp.a;\n\t\t\t\tif ( crop > 0.5 ) {\n\t\t\t\t\tif ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {\n\t\t\t\t\t\tlalpha = 0.0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tlalpha *= mask;\n\n\t\t\t\tcalpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );\n\t\t\t\taccumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));\n\n\t\t\t\treturn col;\n\t\t\t}"),triplanar:new ki("vec3 triplanarTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUvs0, out vec2 writeUvs1, out vec2 writeUvs2, out vec3 writeWeights) {\n\t\t\t\tvec3 p = position;\n\t\t\t\tvec2 uv0 = (1.0 + p.xy) / 2.0; \n\t\t\t\tvec2 uv1 = (1.0 + p.zy) / 2.0;\t\t\n\t\t\t\tvec2 uv2 = (1.0 + p.xz) / 2.0;\t\t\n\t\n\t\t\t\tuv0 = (mat * vec3((uv0 * 2.0 - 1.0) / (size * 0.5), 1.0) / 2.0 + 0.5).xy;\n\t\t\t\tuv1 = (mat * vec3((uv1 * 2.0 - 1.0) / (size * 0.5), 1.0) / 2.0 + 0.5).xy;\n\t\t\t\tuv2 = (mat * vec3((uv2 * 2.0 - 1.0) / (size * 0.5), 1.0) / 2.0 + 0.5).xy;\n\n\t\t\t\t// Range from 3 to 128 seems to be good\n\t\t\t\tfloat exponent = (1.0 - blending) * 125.0 + 3.0;\n\n\t\t\t\tvec3 n = vObjectNormal;\n\t\t\t\tvec3 weights = abs(normalize(n));\n\t\t\t\tweights = pow(weights, vec3(exponent));\n\t\t\t\tweights /= dot(weights, vec3(1.0));\n\n\t\t\t\t// Write out all sets of UVs that we generated\n\t\t\t\twriteUvs0 = uv0;\n\t\t\t\twriteUvs1 = uv1;\n\t\t\t\twriteUvs2 = uv2;\n\t\t\t\twriteWeights = weights;\n\n\t\t\t\t// Plain filtered samples: triplanar UVs are continuous (no wrap\n\t\t\t\t// seam), so implicit derivatives are already correct — the\n\t\t\t\t// forced-LOD sample this replaces bypassed the layer's Sharpness\n\t\t\t\t// filters and over-blurred by up to a mip (fwidth overestimates\n\t\t\t\t// the footprint; see the spherical/cylindrical variants).\n\t\t\t\tvec4 tmp = \n\t\t\t\t\ttexture2D(tex, uv0) * weights.z + \n\t\t\t\t\ttexture2D(tex, uv1) * weights.x + \n\t\t\t\t\ttexture2D(tex, uv2) * weights.y;\n\n\t\t\t\tvec3 col = tmp.rgb;\n\t\t\t\tfloat lalpha = alpha * tmp.a;\n\n\t\t\t\t// Apply cropping across all 3 planes\n\t\t\t\tif ( crop > 0.5 ) {\n\t\t\t\t\tif ( uv0.x < 0.0 || uv0.x > 1.0 || uv0.y < 0.0 || uv0.y > 1.0 ) {\n\t\t\t\t\t\tlalpha = 0.0;\n\t\t\t\t\t}\n\t\t\t\t\tif ( uv1.x < 0.0 || uv1.x > 1.0 || uv1.y < 0.0 || uv1.y > 1.0 ) {\n\t\t\t\t\t\tlalpha = 0.0;\n\t\t\t\t\t}\n\t\t\t\t\tif ( uv2.x < 0.0 || uv2.x > 1.0 || uv2.y < 0.0 || uv2.y > 1.0 ) {\n\t\t\t\t\t\tlalpha = 0.0;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tlalpha *= mask;\n\t\t\t\tcalpha = lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0);\n\t\t\t\taccumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));\n\n\t\t\t\treturn col;//n * 0.5 + 0.5;\n\t\t\t}\t\t\t\n\t\t\t")};var _s=class extends Oi{constructor(e,t,n,i,a,r,o,s,l,c,d,u){super("v3"),this.nodeType="Depth",this.gradientType=e,this.smooth=t,this.near=n,this.far=i,this.isVector=a,this.isWorldSpace=r,this.origin=o,this.direction=s,this.colors=l,this.steps=c,this.isMask=u,this.alpha=d,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){let n=`g${this.uuid.toString().replace(/-/g,"")}`,i=new ki(`vec3 ${n}_sdepth(float near, float far, vec3 origin, vec3 direction, vec4 colors[${n}_MAX_COLORS], float steps[${n}_MAX_COLORS], bool isMask, float mask, float alpha, out float calpha) {\n vec4 color = colors[0];\n #ifdef ${n}_IS_VECTOR\n #ifdef ${n}_LINEAR\n #ifdef ${n}_WORLDSPACE\n float depth = vectorLinearWorldSpaceDepth(direction, origin, near, far);\n #else\n float depth = vectorLinearObjectSpaceDepth(direction, origin, near, far);\n #endif\n #else\n #ifdef ${n}_WORLDSPACE\n float depth = vectorSphericalWorldSpaceDepth(origin, near, far);\n #else\n float depth = vectorSphericalObjectSpaceDepth(origin, near, far);\n #endif\n #endif\n #else\n float dist = length(vWPosition - cameraPosition);\n\t\t\t float depth = ( dist - near ) / ( far - near );\n #endif\n\n\n float p;\n #ifdef ${n}_SMOOTH\n\t\t\t\tfor ( int i = 1; i < ${n}_MAX_COLORS; i++ ) {\n\t\t\t\t\t\tp = clamp( ( depth - steps[i-1] ) / ( steps[i] - steps[i-1] ), 0.0, 1.0 );\n\t\t\t\t\t\tcolor = mix(color, colors[i], smoothstep(0.0, 1.0, p));\n\t\t\t\t\t}\n #else\n for ( int i = 1; i < ${n}_MAX_COLORS; i++ ) {\n p = clamp(( depth - steps[i - 1] ) / ( steps[i] - steps[i - 1] ), 0.0, 1.0);\n color = mix(color, colors[i], p);\n }\n #endif\n\n float lalpha = alpha * color.a * mask;\n calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));\n\t\t\t accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));\n\t\t\t \n return color.rgb;\n\t\t\t}`,[_s.Nodes.vectorLinearWorldSpaceDepth,_s.Nodes.vectorLinearObjectSpaceDepth,_s.Nodes.vectorSphericalObjectSpaceDepth,_s.Nodes.vectorSphericalWorldSpaceDepth]);if(e.isShader("fragment")){e.define(`${n}_MAX_COLORS`,this.colors.value.length),this.smooth.value&&e.define(`${n}_SMOOTH`),this.isVector.value>.5&&e.define(`${n}_IS_VECTOR`),0===this.gradientType.value&&e.define(`${n}_LINEAR`),this.isWorldSpace.value>.5&&e.define(`${n}_WORLDSPACE`),e.require("worldPosition"),e.addFragmentVariable(this.calpha,"float");let a=e.include(i),r=[];return r.push(this.near.build(e,"f")),r.push(this.far.build(e,"f")),r.push(this.origin.build(e,"v3")),r.push(this.direction.build(e,"v3")),r.push(this.colors.build(e,"v4[]")),r.push(this.steps.build(e,"f[]")),r.push(this.isMask.build(e,"b")),r.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),r.push(this.alpha.build(e,"f")),r.push(this.calpha),e.format(a+"("+r.join(",")+")",this.getType(e),t)}return console.warn("DepthNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},xs=_s;xs.Nodes={vectorLinearWorldSpaceDepth:new ki("float vectorLinearWorldSpaceDepth(vec3 direction, vec3 origin, float near, float far) {\n vec3 n = normalize(direction);\n float dist = (n.x*(vWPosition.x - origin.x) + n.y*(vWPosition.y - origin.y) + n.z*(vWPosition.z - origin.z));\n return ( dist - near ) / ( far - near );\n }"),vectorLinearObjectSpaceDepth:new ki("float vectorLinearObjectSpaceDepth(vec3 direction, vec3 origin, float near, float far) {\n vec3 n = normalize(direction);\n float dist = (n.x*(position.x - origin.x) + n.y*(position.y - origin.y) + n.z*(position.z - origin.z));\n return ( dist - near ) / ( far - near );\n }"),vectorSphericalWorldSpaceDepth:new ki("float vectorSphericalWorldSpaceDepth(vec3 origin, float near, float far) {\n float dist = length(vWPosition - origin);\n return ( dist - near ) / ( far - near );\n }"),vectorSphericalObjectSpaceDepth:new ki("float vectorSphericalObjectSpaceDepth(vec3 origin, float near, float far) {\n float dist = length(position - origin);\n return ( dist - near ) / ( far - near );\n }")};var Ss=class extends Oi{constructor(e,t,n,i,a,r,o){super("v3"),this.nodeType="Cavity",this.firstTime=!0,this.ridge=e,this.valley=t,this.normalViewMap=n,this.resolution=i,this.isMask=o,this.alpha=a,this.mode=r,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(this.firstTime&&(e.addVertexParsVariable("randomColor","attribute vec3"),e.addVertexParsVariable("vID","flat out float"),e.addFragmentParsVariable("vID","flat in float"),e.addVertexFinalCode("\n vID = randomColor.r;\n ")),e.isShader("fragment")){e.addFragmentVariable(this.calpha,"float");let n=e.include(Ss.Nodes.cavity),i=[];return i.push(this.normalViewMap.getTexture(e,"t")),i.push(this.resolution.build(e,"v2")),i.push(this.ridge.build(e,"f")),i.push(this.valley.build(e,"f")),i.push(this.isMask.build(e,"b")),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.mode.build(e,"i")),i.push(this.calpha),this.firstTime=!this.firstTime,e.format(n+"("+i.join(",")+")",this.getType(e),t)}return console.warn("CavityNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},Ts=Ss;Ts.Nodes=function(){let e=new ki("float cavitySoftClamp(float c, float control) {\n\t\t\t\tif (c < 0.5 / control) return c * (1.0 - c * control);\n\t\t\t\treturn 0.25 / control;\n\t\t\t}");return{cavity:new ki("vec3 cavity(sampler2D normalViewMap, vec2 resolution, float ridge, float valley, bool isMask, float mask, float alpha, int mode, out float calpha) {\n\t\t\t\t// The factors saturate the soft clamp by 2 — beyond that the\n\t\t\t\t// response is visually identical, so 2 is the ceiling\n\t\t\t\t// everywhere (panel, DSL, variables, old files).\n\t\t\t\tridge = clamp(ridge, 0.0, 2.0);\n\t\t\t\tvalley = clamp(valley, 0.0, 2.0);\n\n\t\t\t\tvec2 nuv = gl_FragCoord.xy / resolution;\n\t\t\t\tvec2 texel = vec2(1.0) / resolution;\n\n\t\t\t\tvec4 nUp = texture2D(normalViewMap, nuv + vec2(0.0, texel.y));\n\t\t\t\tvec4 nDown = texture2D(normalViewMap, nuv - vec2(0.0, texel.y));\n\t\t\t\tvec4 nLeft = texture2D(normalViewMap, nuv - vec2(texel.x, 0.0));\n\t\t\t\tvec4 nRight = texture2D(normalViewMap, nuv + vec2(texel.x, 0.0));\n\n\t\t\t\tfloat curv = 0.0;\n\t\t\t\tif (nUp.a == vID && nDown.a == vID && nLeft.a == vID && nRight.a == vID &&\n\t\t\t\t\tdot(nUp.xyz, nUp.xyz) > 0.5 && dot(nDown.xyz, nDown.xyz) > 0.5 &&\n\t\t\t\t\tdot(nLeft.xyz, nLeft.xyz) > 0.5 && dot(nRight.xyz, nRight.xyz) > 0.5) {\n\t\t\t\t\tfloat ndiff = (nUp.y - nDown.y) + (nRight.x - nLeft.x);\n\t\t\t\t\t// Blender's control mapping (workbench_data.c): a bigger\n\t\t\t\t\t// factor lowers the control, which raises both the linear\n\t\t\t\t\t// range and the clamp ceiling of the soft clamp — the\n\t\t\t\t\t// factors get a real O(1) signal to scale.\n\t\t\t\t\tfloat ridgeControl = 0.5 / max(ridge * ridge, 0.0001);\n\t\t\t\t\tfloat valleyControl = 0.7 / max(valley * valley, 0.0001);\n\t\t\t\t\tcurv = ndiff > 0.0\n\t\t\t\t\t\t? 2.0 * cavitySoftClamp(ndiff, ridgeControl)\n\t\t\t\t\t\t: -2.0 * cavitySoftClamp(-ndiff, valleyControl);\n\t\t\t\t\t// Dead-zone: sub-visible curvature (buffer quantization\n\t\t\t\t\t// noise, near-zero factors) is no curvature.\n\t\t\t\t\tif (abs(curv) < 0.001) curv = 0.0;\n\t\t\t\t}\n\n\t\t\t\t// Where there is no curvature the layer says NOTHING: composite\n\t\t\t\t// with weight 0 (the outline layer's pattern) so flat pixels are\n\t\t\t\t// a bit-exact passthrough. Compositing the identity mid-grey at\n\t\t\t\t// full alpha instead perturbs the frame by float ulps\n\t\t\t\t// (1-2(1-b)(1-o) != b exactly), which downstream edge-AA\n\t\t\t\t// amplified into visible silhouette speckles. Mask mode keeps\n\t\t\t\t// the full-coverage grey — the mask IS the color output.\n\t\t\t\t// (\"active\" is a GLSL ES reserved word — hence cavityOn.)\n\t\t\t\tfloat cavityOn = curv != 0.0 ? 1.0 : 0.0;\n\t\t\t\tfloat lalpha = alpha * mask * mix(cavityOn, 1.0, float(isMask));\n\t\t\t\tcalpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));\n\t\t\t\taccumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));\n\n\t\t\t\treturn vec3(clamp(0.5 + 0.5 * curv, 0.0, 1.0));\n\t\t\t}",[e])}}();var bs=function(){let e=new ki("vec3 random3(vec3 c) {\n\t\t\tfloat j = 4096.0*sin(dot(c,vec3(17.0, 59.4, 15.0)));\n\t\t\tvec3 r;\n\t\t\tr.z = fract(512.0*j);\n\t\t\tj *= .125;\n\t\t\tr.x = fract(512.0*j);\n\t\t\tj *= .125;\n\t\t\tr.y = fract(512.0*j);\n\t\t\treturn r-0.5;\n\t\t}"),t=new ki("float simplexFast(vec3 p) {\n\t\t\t vec3 s = floor(p + dot(p, vec3(F3)));\n\t\t\t mediump vec3 x = p - s + dot(s, vec3(G3));\n\t\t\t mediump vec3 hs = s;\n\t\t\t \n\t\t\t mediump vec3 e = step(vec3(0.0), x - x.yzx);\n\t\t\t mediump vec3 i1 = e*(1.0 - e.zxy);\n\t\t\t mediump vec3 i2 = 1.0 - e.zxy*(1.0 - e);\n\t\t\t\t\n\t\t\t mediump vec3 x1 = x - i1 + G3;\n\t\t\t mediump vec3 x2 = x - i2 + 2.0*G3;\n\t\t\t mediump vec3 x3 = x - 1.0 + 3.0*G3;\n\t\t\t \n\t\t\t mediump vec4 w, d;\n\t\t\t \n\t\t\t w.x = dot(x, x);\n\t\t\t w.y = dot(x1, x1);\n\t\t\t w.z = dot(x2, x2);\n\t\t\t w.w = dot(x3, x3);\n\t\t\t \n\t\t\t w = max(0.6 - w, 0.0);\n\t\t\t \n\t\t\t d.x = dot(random3(hs), x);\n\t\t\t d.y = dot(random3(hs + i1), x1);\n\t\t\t d.z = dot(random3(hs + i2), x2);\n\t\t\t d.w = dot(random3(hs + 1.0), x3);\n\t\t\t \n\t\t\t w *= w;\n\t\t\t w *= w;\n\t\t\t d *= w;\n\t\t\t \n\t\t\t return dot(d, vec4(52.0));\n\t\t}",[e]);t.keywords.F3=new ji("float F3 0.3333333"),t.keywords.G3=new ji("float G3 0.1666667");let n=new ki("float simplexPrecise(vec3 p) {\n\t\t\t vec3 s = floor(p + dot(p, vec3(F3)));\n\t\t\t vec3 x = p - s + dot(s, vec3(G3));\n\t\t\t \n\t\t\t vec3 e = step(vec3(0.0), x - x.yzx);\n\t\t\t vec3 i1 = e*(1.0 - e.zxy);\n\t\t\t vec3 i2 = 1.0 - e.zxy*(1.0 - e);\n\t\t\t\t\n\t\t\t vec3 x1 = x - i1 + G3;\n\t\t\t vec3 x2 = x - i2 + 2.0*G3;\n\t\t\t vec3 x3 = x - 1.0 + 3.0*G3;\n\t\t\t \n\t\t\t vec4 w, d;\n\t\t\t \n\t\t\t w.x = dot(x, x);\n\t\t\t w.y = dot(x1, x1);\n\t\t\t w.z = dot(x2, x2);\n\t\t\t w.w = dot(x3, x3);\n\t\t\t \n\t\t\t w = max(0.6 - w, 0.0);\n\t\t\t \n\t\t\t d.x = dot(random3(s), x);\n\t\t\t d.y = dot(random3(s + i1), x1);\n\t\t\t d.z = dot(random3(s + i2), x2);\n\t\t\t d.w = dot(random3(s + 1.0), x3);\n\t\t\t \n\t\t\t w *= w;\n\t\t\t w *= w;\n\t\t\t d *= w;\n\t\t\t \n\t\t\t return dot(d, vec4(52.0));\n\t\t}",[e]);n.keywords.F3=new ji("float F3 0.3333333"),n.keywords.G3=new ji("float G3 0.1666667");let i=new ki("float simplexFractal(vec3 m) {\n\t\t\tmat3 rot1 = mat3(-0.37, 0.36, 0.85,-0.14,-0.93, 0.34,0.92, 0.01,0.4);\n\t\t\tmat3 rot2 = mat3(-0.55,-0.39, 0.74, 0.33,-0.91,-0.24,0.77, 0.12,0.63);\n\t\t\tmat3 rot3 = mat3(-0.71, 0.52,-0.47,-0.08,-0.72,-0.68,-0.7,-0.45,0.56);\n\t\t\treturn 0.5333333 * simplexFast(m * rot1)\n\t\t\t\t + 0.2666667 * simplexFast(2.0 * m * rot2)\n\t\t\t\t + 0.1333333 * simplexFast(4.0 * m * rot3)\n\t\t\t\t + 0.0666667 * simplexFast(8.0 * m);\n\t\t}",[t]),a=new ki("vec4 permute(vec4 x){return mod(((x*34.0)+1.0)*x, 289.0);}"),r=new ki("vec4 taylorInvSqrt(vec4 r){return 1.79284291400159 - 0.85373472095314 * r;}"),o=new ki("float simplexAshima(vec3 v) {\n\t\t const vec2 C = vec2(1.0/6.0, 1.0/3.0) ;\n\t\t const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);\n\t\t vec3 i = floor(v + dot(v, C.yyy) );\n\t\t vec3 x0 = v - i + dot(i, C.xxx) ;\n\t\t vec3 g = step(x0.yzx, x0.xyz);\n\t\t vec3 l = 1.0 - g;\n\t\t vec3 i1 = min( g.xyz, l.zxy );\n\t\t vec3 i2 = max( g.xyz, l.zxy );\n\t\t vec3 x1 = x0 - i1 + 1.0 * C.xxx;\n\t\t vec3 x2 = x0 - i2 + 2.0 * C.xxx;\n\t\t vec3 x3 = x0 - 1. + 3.0 * C.xxx;\n\t\t i = mod(i, 289.0 ); \n\t\t vec4 p = permute( permute( permute( \n\t\t\t\t\t i.z + vec4(0.0, i1.z, i2.z, 1.0 ))\n\t\t\t\t + i.y + vec4(0.0, i1.y, i2.y, 1.0 )) \n\t\t\t\t + i.x + vec4(0.0, i1.x, i2.x, 1.0 ));\n\t\t float n_ = 1.0/7.0; \n\t\t vec3 ns = n_ * D.wyz - D.xzx;\n\t\t vec4 j = p - 49.0 * floor(p * ns.z *ns.z); \n\t\t vec4 x_ = floor(j * ns.z);\n\t\t vec4 y_ = floor(j - 7.0 * x_ ); \n\t\t vec4 x = x_ *ns.x + ns.yyyy;\n\t\t vec4 y = y_ *ns.x + ns.yyyy;\n\t\t vec4 h = 1.0 - abs(x) - abs(y);\n\t\t vec4 b0 = vec4( x.xy, y.xy );\n\t\t vec4 b1 = vec4( x.zw, y.zw );\n\t\t vec4 s0 = floor(b0)*2.0 + 1.0;\n\t\t vec4 s1 = floor(b1)*2.0 + 1.0;\n\t\t vec4 sh = -step(h, vec4(0.0));\n\t\t vec4 a0 = b0.xzyw + s0.xzyw*sh.xxyy ;\n\t\t vec4 a1 = b1.xzyw + s1.xzyw*sh.zzww ;\n\t\t vec3 p0 = vec3(a0.xy,h.x);\n\t\t vec3 p1 = vec3(a0.zw,h.y);\n\t\t vec3 p2 = vec3(a1.xy,h.z);\n\t\t vec3 p3 = vec3(a1.zw,h.w);\n\t\t vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3)));\n\t\t p0 *= norm.x;\n\t\t p1 *= norm.y;\n\t\t p2 *= norm.z;\n\t\t p3 *= norm.w;\n\t\t vec4 m = max(0.6 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0);\n\t\t m = m * m;\n\t\t return 42.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1), \n\t\t\t\t\t\t\t\t\t\tdot(p2,x2), dot(p3,x3) ) );\n\t\t}",[a,r]),s=new ki("vec4 mod289(vec4 x){return x - floor(x * (1.0 / 289.0)) * 289.0;}"),l=new ki("vec4 perm(vec4 x){return mod289(((x * 34.0) + 1.0) * x);}",[s]),c=new ki("float noise(vec3 p){\n\t\t\tvec3 a = floor(p);\n\t\t\tvec3 d = p - a;\n\t\t\td = d * d * (3.0 - 2.0 * d);\n\t\t\tvec4 b = a.xxyy + vec4(0.0, 1.0, 0.0, 1.0);\n\t\t\tvec4 k1 = perm(b.xyxy);\n\t\t\tvec4 k2 = perm(k1.xyxy + b.zzww);\n\t\t\tvec4 c = k2 + a.zzzz;\n\t\t\tvec4 k3 = perm(c);\n\t\t\tvec4 k4 = perm(c + 1.0);\n\t\t\tvec4 o1 = fract(k3 * (1.0 / 41.0));\n\t\t\tvec4 o2 = fract(k4 * (1.0 / 41.0));\n\t\t\tvec4 o3 = o2 * d.z + o1 * (1.0 - d.z);\n\t\t\tvec2 o4 = o3.yw * d.x + o3.xz * (1.0 - d.x);\n\t\t\treturn o4.y * d.y + o4.x * (1.0 - d.y);\n\t\t}",[l]),d=new ki("float fbm(vec3 x) {\n\t\t\tfloat v = 0.0;\n\t\t\tfloat a = 0.5;\n\t\t\tvec3 shift = vec3(100);\n\t\t\tfor (int i = 0; i < NUM_OCTAVES; ++i) {\n\t\t\t\tv += a * noise(x);\n\t\t\t\tx = x * 2.0 + shift;\n\t\t\t\ta *= 0.5;\n\t\t\t}\n\t\t\treturn v;\n\t\t}",[c]);d.keywords.NUM_OCTAVES=new ji("int NUM_OCTAVES 5");let u=new ki("vec3 fade(vec3 t) {return t*t*t*(t*(t*6.0-15.0)+10.0);}"),f=new ki("float perlin(vec3 P){\n\t\t vec3 Pi0 = floor(P);\n\t\t vec3 Pi1 = Pi0 + vec3(1.0);\n\t\t Pi0 = mod(Pi0, 289.0);\n\t\t Pi1 = mod(Pi1, 289.0);\n\t\t vec3 Pf0 = fract(P);\n\t\t vec3 Pf1 = Pf0 - vec3(1.0);\n\t\t vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);\n\t\t vec4 iy = vec4(Pi0.yy, Pi1.yy);\n\t\t vec4 iz0 = Pi0.zzzz;\n\t\t vec4 iz1 = Pi1.zzzz;\n\t\t vec4 ixy = permute(permute(ix) + iy);\n\t\t vec4 ixy0 = permute(ixy + iz0);\n\t\t vec4 ixy1 = permute(ixy + iz1);\n\t\t vec4 gx0 = ixy0 / 7.0;\n\t\t vec4 gy0 = fract(floor(gx0) / 7.0) - 0.5;\n\t\t gx0 = fract(gx0);\n\t\t vec4 gz0 = vec4(0.5) - abs(gx0) - abs(gy0);\n\t\t vec4 sz0 = step(gz0, vec4(0.0));\n\t\t gx0 -= sz0 * (step(0.0, gx0) - 0.5);\n\t\t gy0 -= sz0 * (step(0.0, gy0) - 0.5);\n\t\t vec4 gx1 = ixy1 / 7.0;\n\t\t vec4 gy1 = fract(floor(gx1) / 7.0) - 0.5;\n\t\t gx1 = fract(gx1);\n\t\t vec4 gz1 = vec4(0.5) - abs(gx1) - abs(gy1);\n\t\t vec4 sz1 = step(gz1, vec4(0.0));\n\t\t gx1 -= sz1 * (step(0.0, gx1) - 0.5);\n\t\t gy1 -= sz1 * (step(0.0, gy1) - 0.5);\n\t\t vec3 g000 = vec3(gx0.x,gy0.x,gz0.x);\n\t\t vec3 g100 = vec3(gx0.y,gy0.y,gz0.y);\n\t\t vec3 g010 = vec3(gx0.z,gy0.z,gz0.z);\n\t\t vec3 g110 = vec3(gx0.w,gy0.w,gz0.w);\n\t\t vec3 g001 = vec3(gx1.x,gy1.x,gz1.x);\n\t\t vec3 g101 = vec3(gx1.y,gy1.y,gz1.y);\n\t\t vec3 g011 = vec3(gx1.z,gy1.z,gz1.z);\n\t\t vec3 g111 = vec3(gx1.w,gy1.w,gz1.w);\n\t\t vec4 norm0 = taylorInvSqrt(vec4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110)));\n\t\t g000 *= norm0.x;\n\t\t g010 *= norm0.y;\n\t\t g100 *= norm0.z;\n\t\t g110 *= norm0.w;\n\t\t vec4 norm1 = taylorInvSqrt(vec4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111)));\n\t\t g001 *= norm1.x;\n\t\t g011 *= norm1.y;\n\t\t g101 *= norm1.z;\n\t\t g111 *= norm1.w;\n\t\t float n000 = dot(g000, Pf0);\n\t\t float n100 = dot(g100, vec3(Pf1.x, Pf0.yz));\n\t\t float n010 = dot(g010, vec3(Pf0.x, Pf1.y, Pf0.z));\n\t\t float n110 = dot(g110, vec3(Pf1.xy, Pf0.z));\n\t\t float n001 = dot(g001, vec3(Pf0.xy, Pf1.z));\n\t\t float n101 = dot(g101, vec3(Pf1.x, Pf0.y, Pf1.z));\n\t\t float n011 = dot(g011, vec3(Pf0.x, Pf1.yz));\n\t\t float n111 = dot(g111, Pf1);\n\t\t vec3 fade_xyz = fade(Pf0);\n\t\t vec4 n_z = mix(vec4(n000, n100, n010, n110), vec4(n001, n101, n011, n111), fade_xyz.z);\n\t\t vec2 n_yz = mix(n_z.xy, n_z.zw, fade_xyz.y);\n\t\t float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x); \n\t\t return 2.2 * n_xyz;\n\t\t}",[a,r,u]),p=new ki("float hashwithoutsine13(vec3 p3)\n\t\t{\n\t\t\tp3 = fract(p3 * .1031);\n\t\t\tp3 += dot(p3, p3.yzx + 33.33);\n\t\t\treturn fract((p3.x + p3.y) * p3.z);\n\t\t}"),h=new ki("vec3 hashwithoutsine33(vec3 p3)\n\t\t{\n\t\t\tp3 = fract(p3 * vec3(.1031, .1030, .0973));\n\t\t\tp3 += dot(p3, p3.yxz+33.33);\n\t\t\treturn fract((p3.xxy + p3.yxx)*p3.zyx);\n\t\t}"),m=new ki("float metric(in vec3 p)\n\t\t{\n\t\t\t\n\t\t\treturn length(p);\n\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t}"),v=new ki("float smin( float a, float b, float k )\n\t\t{\n\t\t\tfloat h = smoothstep(0.0, 1.0, 0.5 + 0.5 * (b - a) / k);\n\t\t\tfloat correction = k * h * (1.0 - h);\n\t\t\treturn mix(b, a, h) - correction;\n\t\t}"),g=new ki("float smax( float a, float b, float k )\n\t\t{\n\t\t\tfloat h = smoothstep(1.0, 0.0, 0.5 + 0.5 * (a - b) / k);\n\t\t\tfloat correction = k * h * (1.0 - h);\n\t\t\treturn mix(a, b, h) + correction;\n\t\t}"),_=new ki("float remap(float value, float input_min, float input_max, float output_min, float output_max) {\n\t\t\t// Compute width of each interval\n\t\t\tfloat input_width = input_max - input_min;\n\t\t\tfloat output_width = output_max - output_min;\n\t\t\n\t\t\t// Convert input range into a 0-1 range \n\t\t\tfloat scaled = (value - input_min) / input_width;\n\t\t\n\t\t\t// Convert the 0-1 range into a value in output range\n\t\t\treturn output_min + (scaled * output_width);\n\t\t}");return{simplexFast:t,simplexPrecise:n,simplexFractal:i,simplexAshima:o,fbm:d,perlin:f,voronoi:new ki("float voronoi(in vec3 x, in int style, in float smoothness, in float seed, in int quality) \n\t\t{\n\t\t\t\n\t\t\tivec3 p = ivec3(floor(x));\n\t\t\tvec3 f = fract(x);\n\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\tfloat f1_smooth = 8.0;\n\t\t\tfloat f1 = 8.0;\n\t\t\tfloat f2_smooth = 8.0;\n\t\t\tfloat f2 = 8.0;\n\t\t\tfloat e_smooth = 8.0;\n\t\t\tfloat e = 8.0;\n\n\t\t\t\n\t\t\tivec3 mb;\n\t\t\tvec3 mr; \n\n\t\t\tint steps = quality;\n\t\t\t\n\t\t\tfor (int x = -steps; x <= steps; x++) \n\t\t\tfor (int y = -steps; y <= steps; y++)\n\t\t\tfor (int z = -steps; z <= steps; z++)\n\t\t\t{\n\t\t\t\tivec3 b = ivec3(x, y, z);\n\t\t\t\tvec3 r = vec3(b) + hashwithoutsine33(vec3(p + b) + seed) - f;\n\t\t\t\tfloat d = length(r);\n\t\t\t\t\n\t\t\t\tf1_smooth = smin(d, f1_smooth, smoothness);\n\n\t\t\t\t\n\t\t\t\tif (d < f1) \n\t\t\t\t{\n\t\t\t\t\tf2 = f1;\n\t\t\t\t\tf1 = d;\n\n\t\t\t\t\tmb = ivec3(x, y, z);\n\t\t\t\t\tmr = r;\n\t\t\t\t} \n\t\t\t\telse if (d < f2) \n\t\t\t\t{\n\t\t\t\t\tf2 = d;\n\t\t\t\t}\n\t\t\t}\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\tif (style != 0 && style != 5 && style != 7)\n\t\t\tfor (int x = -steps; x <= steps; x++) \n\t\t\tfor (int y = -steps; y <= steps; y++)\n\t\t\tfor (int z = -steps; z <= steps; z++)\n\t\t\t{\n\t\t\t\t\n\t\t\t\tivec3 b = mb + ivec3(x, y, z);\n\t\t\t\tvec3 r = vec3(b) + hashwithoutsine33(vec3(p + b) + seed) - f;\n\t\t\t\tfloat d1 = dot(0.5 * (mr + r), (r - mr)); \t\t\t\t\n\t\t\t\tfloat d2 = dot(0.5 * (mr + r), normalize(r - mr));\n\n\t\t\t\te_smooth = smin(d1, e_smooth, smoothness);\n\n\t\t\t\te = min(e, d2);\n\n\t\t\t\t\n\t\t\t\t{\n\t\t\t\t\tivec3 b = ivec3(x, y, z);\n\t\t\t\t\tif (b != mb) \n\t\t\t\t\t{\n\t\t\t\t\t\tvec3 r = vec3(b) + hashwithoutsine33(vec3(p + b) + seed) - f;\n\t\t\t\t\t\tfloat d = length(r);\n\n\t\t\t\t\t\tf2_smooth = smin(d, f2_smooth, smoothness);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t\n\t\t\tif (style == 0) \n\t\t\t{\n\t\t\t\treturn f1_smooth;\n\t\t\t}\n\t\t\tif (style == 1) \n\t\t\t{\n\t\t\t\treturn f2_smooth;\n\t\t\t}\n\t\t\tif (style == 2) \n\t\t\t{\n\t\t\t\treturn f2_smooth - f1_smooth;\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t}\n\t\t\tif (style == 3) \n\t\t\t{\n\t\t\t\t\n\t\t\t\tfloat a = f1; \n\t\t\t\tfloat b = f2;\n\t\t\t\tfloat k = 3.0;\n\t\t\t\tfloat h = max(k - abs(a - b), 0.0) / k;\n\t\t\t\tfloat final = min(a, b) - h * h * k * (1.0 / 4.0);\n\t\t\t\treturn final;\n\t\t\t}\n\t\t\tif (style == 4) \n\t\t\t{\n\t\t\t\t\n\t\t\t\treturn exp(5.0 * e_smooth);\n\t\t\t}\n\t\t\tif (style == 5) \n\t\t\t{\n\t\t\t\treturn pow(f1_smooth, 3.0);\n\t\t\t}\n\t\t\tif (style == 6) \n\t\t\t{\t\t\t\t\n\t\t\t\tconst float eps = 0.0125;\n\n\t\t\t\t\n\t\t\t\tfloat thickness = smoothness * 0.25 + eps;\n\n\t\t\t\t\n\t\t\t\tfloat blur = pow(smoothness, 3.0) * 0.25 + eps;\n\n\t\t\t\treturn smoothstep(\n\t\t\t\t\tthickness - thickness * blur, \n\t\t\t\t\tthickness + thickness * blur, \n\t\t\t\t\te\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (style == 7) \n\t\t\t{\n\t\t\t\treturn hashwithoutsine13(vec3(p + mb) + seed);\n\t\t\t}\n\t\t}\n\t",[p,h,m,v,g,_])}}(),ws=class extends Oi{constructor(e,t,n,i,a,r,o){super("v3"),this.nodeType="Dust",this.color=e,this.coverage=t,this.softness=n,this.noiseStrength=i,this.noiseScale=a,this.isMask=o,this.alpha=r,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.require("worldNormal"),e.isShader("fragment")){e.addFragmentVariable(this.calpha,"float");let n=e.include(ws.Nodes.dust),i=[];return i.push(this.color.build(e,"c")),i.push(this.coverage.build(e,"f")),i.push(this.softness.build(e,"f")),i.push(this.noiseStrength.build(e,"f")),i.push(this.noiseScale.build(e,"f")),i.push(this.isMask.build(e,"b")),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(n+"("+i.join(",")+")",this.getType(e),t)}return console.warn("DustNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},Es=ws;Es.Nodes={dust:new ki("vec3 dust(vec3 color, float coverage, float softness, float noiseStrength, float noiseScale, bool isMask, float mask, float alpha, out float calpha) {\n\t\t\t\tfloat facingUp = dot(normalize(vWNormal), vec3(0.0, 1.0, 0.0));\n\n\t\t\t\tfloat breakup = 0.0;\n\t\t\t\tif (noiseStrength != 0.0) {\n\t\t\t\t\tvec3 st = position / noiseScale;\n\t\t\t\t\tfloat noise = simplexFast(st + vec3(1.7, 9.2, 1.0));\n\t\t\t\t\tbreakup = noise * noiseStrength;\n\t\t\t\t}\n\n\t\t\t\tfloat soft = max(softness, 0.0001);\n\t\t\t\tfloat settle = mix(1.0 + soft, -1.0 - soft, clamp(coverage, 0.0, 1.0));\n\t\t\t\tfloat amount = smoothstep(settle - soft, settle + soft, facingUp + breakup);\n\n\t\t\t\tfloat lalpha = amount * alpha * mask;\n\t\t\t\tcalpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));\n\t\t\t\taccumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));\n\n\t\t\t\treturn color;\n\t\t\t }",[bs.simplexFast])};var Ms=class extends Oi{constructor(e,t,n,i,a,r,o,s){super("v3"),this.nodeType="Fresnel",this.color=e,this.bias=t,this.scale=n,this.intensity=i,this.factor=a,this.isMask=s,this.alpha=r,this.mode=o,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.require("vWorldViewDir"),e.require("worldNormal"),e.isShader("fragment")){e.addFragmentVariable(this.calpha,"float");let n=new ki("vec3 fresnel(vec3 color, float bias, float scale, float intensity, float factor, bool isMask, float mask, float alpha, int mode, out float calpha) {\n\t\t\t\t\tfloat fresnel = bias + scale * pow( abs( factor + dot( normalize( vWorldViewDir ), normalize( vWNormal ) ) ), intensity );\n\n\t\t\t\t\tfloat lalpha = clamp(fresnel, 0.0, 1.0) * alpha * mask;\n\t\t\t\t\tcalpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));\n\t\t\t\t\taccumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));\n\n\t\t\t\t\treturn color;\n\t\t\t\t}"),i=e.include(n),a=[];return a.push(this.color.build(e,"c")),a.push(this.bias.build(e,"f")),a.push(this.scale.build(e,"f")),a.push(this.intensity.build(e,"f")),a.push(this.factor.build(e,"f")),a.push(this.isMask.build(e,"b")),a.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),a.push(this.alpha.build(e,"f")),a.push(this.mode.build(e,"i")),a.push(this.calpha),e.format(i+"("+a.join(",")+")",this.getType(e),t)}return console.warn("FresnelNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},ys=class extends Oi{constructor(e,t,n,i,a,r,o,s,l){super("v3"),this.nodeType="Gradient",this.gradientType=e,this.smooth=t,this.colors=n,this.steps=i,this.offset=a,this.morph=r,this.angle=o,this.isMask=l,this.alpha=s,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.isShader("fragment")){e.define("GRAD_MAX",10),e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let n=e.include(ys.Nodes.gradient),i=[];return i.push(this.gradientType.build(e,"i")),i.push(this.smooth.build(e,"b")),i.push(this.colors.build(e,"v4[]")),i.push(this.steps.build(e,"f[]")),i.push(this.offset.build(e,"v2")),i.push(this.morph.build(e,"v2")),i.push(this.angle.build(e,"f")),i.push(this.isMask.build(e,"b")),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(n+"("+i.join(",")+")",this.getType(e),t)}return console.warn("GradientNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},Cs=ys;Cs.Nodes={gradient:new ki("vec3 gradient(int gradientType, bool smoothed, vec4 colors[GRAD_MAX], float steps[GRAD_MAX], vec2 offset, vec2 morph, float angle, bool isMask, float mask, float alpha, out float calpha) {\n\t\t\t\tvec4 color = colors[0];\n\t\t\t\tvec2 m = morph / vUv.xy;\n\t\t\t\tvec2 rot = vec2( 0.5 + m.x, m.y );\n\t\t\t\tvec2 dt = vec2(\n\t\t\t\t\tcos( angle ) * rot.x - sin( angle ) * rot.y,\n\t\t\t\t\tsin( angle ) * rot.x + cos( angle ) * rot.y\n\t\t\t\t);\n\t\t\t\tvec2 pt = ( vUv - 0.5 + offset ) / 2.0 + dt / 2.0;\n\t\t\t\tfloat t = dot( pt, dt ) / dot( dt, dt );\n\t\t\t\tif ( gradientType == 1 ) {\n\t\t\t\t\tt = distance (\n\t\t\t\t\t\t( vUv + morph ) * 3.0,\n\t\t\t\t\t\t( vUv + offset ) + 1.0\n\t\t\t\t\t) + angle;\n\t\t\t\t} else if ( gradientType == 2 ) {\n\t\t\t\t\tfloat polar = atan(\n\t\t\t\t\t\tvUv.x + morph.x - 0.5 + offset.x,\n\t\t\t\t\t\tvUv.y + morph.y - 0.5 + offset.y\n\t\t\t\t\t) * -1.0;\n\t\t\t\t\tt = fract( ( angle / PI / -2.0 ) + 0.5 * ( polar / PI ) );\n\t\t\t\t}\n\n\t\t\t\tfloat p;\n\t\t\t\tif (smoothed) {\n\t\t\t\t\tfor ( int i = 1; i < GRAD_MAX; i++ ) {\n\t\t\t\t\t\tp = clamp( ( t - steps[i-1] ) / ( steps[i] - steps[i-1] ), 0.0, 1.0 );\n\t\t\t\t\t\tcolor = mix(color, colors[i], smoothstep(0.0, 1.0, p));\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\t\t\t\t\tfor ( int i = 1; i < GRAD_MAX; i++ ) {\n\t\t\t\t\t\tp = clamp( ( t - steps[i-1] ) / ( steps[i] - steps[i-1] ), 0.0, 1.0 );\n\t\t\t\t\t\tcolor = mix(color, colors[i], p);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tfloat lalpha = alpha * color.a * mask;\n\t\t\t\tcalpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));\n\t\t\t\taccumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));\n\t\t\t\t\n\t\t\t\treturn color.xyz;\n\t\t\t}")};var Rs=class extends Oi{constructor(e,t,n,i,a){super("v3"),this.nodeType="Matcap",this.texture=e,this.isMask=i,this.alpha=t,this.mode=n,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`,this.rotation=a}generate(e,t){if(e.isShader("fragment")){e.addFragmentVariable(this.calpha,"float");let n=e.include(Rs.Nodes.matcap);e.require("normal"),e.requires.normal=!0;let i=[];return i.push(this.texture.generate(e,"t")),i.push("normal"),i.push(this.isMask.build(e,"b")),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.mode.build(e,"i")),i.push(this.calpha),i.push(this.rotation.build(e,"f")),e.format(n+"("+i.join(",")+")",this.getType(e),t)}return console.warn("MatcapNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},As=Rs;As.Nodes={matcap:new ki("vec3 matcap(sampler2D matcapTex, vec3 normal, bool isMask, float mask, float alpha, int mode, out float calpha, float rotation) {\n\t\t\t\t\tvec3 viewDir = normalize( vViewPosition );\n\t\t\t\t\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\t\t\t\t\tvec3 y = cross( viewDir, x );\n\t\t\t\t\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) );\n\t\t\t\t\tuv = mat2( cos(rotation), sin(rotation), -sin(rotation), cos(rotation) ) * uv;\n\t\t\t\t\tuv = uv * 0.495 + 0.5;\n\t\t\t\t\tvec4 matcapColor = texture2D( matcapTex, uv );\n\n\t\t\t\t\tfloat lalpha = alpha * mask;\n\t\t\t\t\tcalpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));\n\t\t\t\t\taccumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));\n\t\t\t\t\t\n\t\t\t\t\treturn matcapColor.rgb;\n \t}")};var Ps=class extends Oi{constructor(e,t,n,i,a,r,o,s,l,c,d,u,f,p,h,m,v,g,_){super("v3"),this.nodeType="Noise",this.scale=e,this.size=t,this.move=n,this.fA=i,this.fB=a,this.distortion=r,this.colorA=o,this.colorB=s,this.colorC=l,this.colorD=c,this.noiseType=u,this.voronoiStyle=p,this.highCut=h,this.lowCut=m,this.smoothness=v,this.seed=g,this.quality=_,this.isMask=f,this.alpha=d,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t,n,i,a){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let r=["simplexFast","simplexFractal","simplexAshima","fbm","perlin","voronoi"][this.noiseType.value],o=new ki(`vec3 ${r}customNoise(float scale, vec3 size, float move, vec2 fA, vec2 fB, vec2 distortion, vec4 colorA, vec4 colorB, vec4 colorC, vec4 colorD, int voronoiStyle, float highCut, float lowCut, float smoothness, float seed, int quality, bool isMask, float mask, float alpha, out float calpha) \n\t\t\t{\n \n\t\t\t\tscale = max(abs(scale), 0.001);\n\n\t\t\t\tvec3 st = position / size;\n\t\t\t\tst /= scale;\n\n\t\t\t\t${"voronoi"==r?`\n\t\tfloat v = ${r}(st + move, voronoiStyle, smoothness, seed, quality);\n\n\t\t\n\t\tv = remap(v, lowCut, highCut, 0.0, 1.0);\n\t\tv = smax(v, 0.0, smoothness * 0.25);\n\t\tv = smin(v, 1.0, smoothness * 0.25);\n\n\t\t\n\t\tvec4 color = mix(colorA, colorC, v); \n\t\t`:`\n\t\tvec3 q = vec3(${r}(st),\n\t\t\t\t\t ${r}(st + vec3(1.0)),\n\t\t\t\t\t ${r}(st + vec3(1.0)));\n\t\tvec3 r = vec3(${r}(st + vec3(distortion, 1.0) * q + vec3(fA, 1.0) + move),\n\t\t\t\t\t ${r}(st + vec3(distortion, 1.0) * q + vec3(fB, 1.0) + move), \n\t\t\t\t\t ${r}(st * q));\n\t\tfloat f = ${r}(st + r);\n\t\tvec4 color;\n\t\tcolor = mix(colorA, colorB, clamp((f * f) * 4.0, 0.0, 1.0));\n\t\tcolor = mix(color, colorC, clamp(length(q), 0.0, 1.0));\n\t\tcolor = mix(color, colorD, clamp(length(r.x), 0.0, 1.0));\n\t\t`}\n\n\t\t\t\tfloat lalpha = alpha * color.a * mask;\n\t\t\t\tcalpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));\n\t\t\t\taccumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));\n\n\t\t\t\treturn clamp(color, 0.0, 1.0).rgb;\n\t\t\t}`,[bs.simplexFast,bs.simplexFractal,bs.simplexAshima,bs.fbm,bs.perlin,bs.voronoi]),s=e.include(o),l=[];return l.push(this.scale.build(e,"f")),l.push(this.size.build(e,"v3")),l.push(this.move.build(e,"f")),l.push(this.fA.build(e,"v2")),l.push(this.fB.build(e,"v2")),l.push(this.distortion.build(e,"v2")),l.push(this.colorA.build(e,"v4")),l.push(this.colorB.build(e,"v4")),l.push(this.colorC.build(e,"v4")),l.push(this.colorD.build(e,"v4")),l.push(this.voronoiStyle.build(e,"i")),l.push(this.highCut.build(e,"f")),l.push(this.lowCut.build(e,"f")),l.push(this.smoothness.build(e,"f")),l.push(this.seed.build(e,"f")),l.push(this.quality.build(e,"i")),l.push(this.isMask.build(e,"b")),l.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),l.push(this.alpha.build(e,"f")),l.push(this.calpha),e.format(s+"("+l.join(",")+")",this.getType(e),t)}};Ps.numOctaves=5;var Ds=class extends Oi{constructor(e,t,n,i,a,r,o,s,l,c,d,u,f,p,h,m){super("v3"),this.nodeType="Outline",this.firstTime=!0,this.outlineColor=e,this.contourColor=t,this.outlineWidth=n,this.contourWidth=i,this.contourThreshold=a,this.outlineThreshold=r,this.contourFrequency=o,this.outlineSmoothing=s,this.contourDirection=l,this.positionalLines=c,this.compensation=d,this.resolution=u,this.normalMap=f,this.depthMap=p,this.pixelRatio=h,this.alpha=m,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){let n=`g${this.uuid.toString().replace(/-/g,"")}`;if(e.require("vWorldViewDir"),e.require("worldNormal"),e.extensions.derivatives=!0,this.compensation.value&&e.define("OUTLINE_COMPENSATION",`${n}_offset`),this.firstTime){let t=this.outlineWidth.build(e,"f"),i=this.resolution.build(e,"v2"),a=this.compensation.build(e,"b"),r=this.pixelRatio.build(e,"f");e.addVertexParsVariable("randomColor","attribute vec3"),e.addVertexParsVariable("extrudeNormal","attribute vec3"),e.addVertexParsVariable(t,"uniform float"),e.addVertexParsVariable(i,"uniform vec2"),e.addVertexParsVariable(a,"uniform bool"),e.addVertexParsVariable(r,"uniform float"),e.addVertexParsVariable("vID","flat out float"),e.addFragmentParsVariable("vID","flat in float"),e.addVertexFinalCode(`\n vID = randomColor.r;\n vec2 ${n}_offset = vec2(0.0);\n if (${a}) {\n // Instanced draws (cloner instancing): 'transformed' is still\n // instance-local here — three's chunks only apply instanceMatrix\n // inside project_vertex — so apply it by hand like they do.\n vec4 ${n}_localPosition = vec4(transformed, 1.0);\n vec3 ${n}_extrudeNormal = extrudeNormal;\n #ifdef USE_INSTANCING\n ${n}_localPosition = instanceMatrix * ${n}_localPosition;\n ${n}_extrudeNormal = mat3(instanceMatrix) * ${n}_extrudeNormal;\n #endif\n vec4 ${n}_clipPosition = projectionMatrix * (modelViewMatrix * ${n}_localPosition);\n \n \n \n vec3 ${n}_clipNormal = mat3(projectionMatrix) * (mat3(modelViewMatrix) * ${n}_extrudeNormal) + 0.0000001;\n ${n}_offset = normalize(${n}_clipNormal.xy) / ${i} * (${t} / 2.0) * ${n}_clipPosition.w * 2.0 * ${r};\n ${n}_clipPosition.xy += ${n}_offset;\n \n \n gl_Position = ${n}_clipPosition;\n }\n `)}if(e.isShader("fragment")){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let n=e.include(Ds.Nodes.outline),i=[];return i.push(this.outlineColor.build(e,"c")),i.push(this.contourColor.build(e,"c")),i.push(this.outlineWidth.build(e,"f")),i.push(this.contourWidth.build(e,"f")),i.push(this.contourThreshold.build(e,"f")),i.push(this.outlineThreshold.build(e,"f")),i.push(this.contourFrequency.build(e,"f")),i.push(this.outlineSmoothing.build(e,"f")),i.push(this.contourDirection.build(e,"v3")),i.push(this.positionalLines.build(e,"b")),i.push(this.resolution.build(e,"v2")),i.push(this.normalMap.getTexture(e,"t")),i.push(this.depthMap.getTexture(e,"t")),i.push(this.pixelRatio.build(e,"f")),i.push(this.compensation.build(e,"b")),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),this.firstTime=!this.firstTime,e.format(n+"("+i.join(",")+")",this.getType(e),t)}return console.warn("OutlineNode is not compatible with "+e.shader+" shader."),""}},Ls=Ds;Ls.Nodes=function(){let e=new ki("\nfloat sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outlineWidth, float pixelRatio)\n{\n vec2 halton = haltonSequence[frameIndex];\n float temporalOffset = getNoiseInterleavedGradient(gl_FragCoord.xy + halton);\n float temporalAngle = temporalOffset * PI2;\n\n vec2 texelSize = (vec2(1.0) / resolution);\n vec2 offsetSize = texelSize * outlineWidth * pixelRatio;\n\n vec2 uvSamples[9];\n vec4 normalSamples[9];\n\n\tuvSamples[0] = uv + vec2( -offsetSize.x, -offsetSize.y) + (vogelDiskSample(0, 9, temporalAngle) * texelSize);\n\tuvSamples[1] = uv + vec2(0.0, -offsetSize.y) + (vogelDiskSample(1, 9, temporalAngle) * texelSize);\n\tuvSamples[2] = uv + vec2( offsetSize.x, -offsetSize.y) + (vogelDiskSample(2, 9, temporalAngle) * texelSize);\n\tuvSamples[3] = uv + vec2( -offsetSize.x, 0.0) + (vogelDiskSample(3, 9, temporalAngle) * texelSize);\n\tuvSamples[4] = uv;\n\tuvSamples[5] = uv + vec2( offsetSize.x, 0.0) + (vogelDiskSample(5, 9, temporalAngle) * texelSize);\n\tuvSamples[6] = uv + vec2( -offsetSize.x, offsetSize.y) + (vogelDiskSample(6, 9, temporalAngle) * texelSize);\n\tuvSamples[7] = uv + vec2(0.0, offsetSize.y) + (vogelDiskSample(7, 9, temporalAngle) * texelSize);\n\tuvSamples[8] = uv + vec2( offsetSize.x, offsetSize.y) + (vogelDiskSample(8, 9, temporalAngle) * texelSize);\n\n\n normalSamples[0] = texture2D(t, uvSamples[0]);\n normalSamples[1] = texture2D(t, uvSamples[1]);\n normalSamples[2] = texture2D(t, uvSamples[2]);\n normalSamples[3] = texture2D(t, uvSamples[3]);\n normalSamples[4] = texture2D(t, uvSamples[4]);\n normalSamples[5] = texture2D(t, uvSamples[5]);\n normalSamples[6] = texture2D(t, uvSamples[6]);\n normalSamples[7] = texture2D(t, uvSamples[7]);\n normalSamples[8] = texture2D(t, uvSamples[8]);\n\n float depthBias = 0.0001;\n \n if (normalSamples[0].a != vID && normalSamples[0].a != 0.0) {\n float depthAtSample = texture2D(d, uvSamples[0]).r + depthBias;\n if (gl_FragCoord.z > depthAtSample) {\n return 0.0;\n }\n }\n\n if (normalSamples[1].a != vID && normalSamples[1].a != 0.0) {\n float depthAtSample = texture2D(d, uvSamples[1]).r + depthBias;\n if (gl_FragCoord.z > depthAtSample) {\n return 0.0;\n }\n }\n\n if (normalSamples[2].a != vID && normalSamples[2].a != 0.0) {\n float depthAtSample = texture2D(d, uvSamples[2]).r + depthBias;\n if (gl_FragCoord.z > depthAtSample) {\n return 0.0;\n }\n }\n\n if (normalSamples[3].a != vID && normalSamples[3].a != 0.0) {\n float depthAtSample = texture2D(d, uvSamples[3]).r + depthBias;\n if (gl_FragCoord.z > depthAtSample) {\n return 0.0;\n }\n }\n\n\n if (normalSamples[4].a != vID && normalSamples[4].a != 0.0) {\n float depthAtSample = texture2D(d, uvSamples[4]).r + depthBias;\n if (gl_FragCoord.z > depthAtSample) {\n return 0.0;\n }\n }\n\n if (normalSamples[5].a != vID && normalSamples[5].a != 0.0) {\n float depthAtSample = texture2D(d, uvSamples[5]).r + depthBias;\n if (gl_FragCoord.z > depthAtSample) {\n return 0.0;\n }\n }\n\n if (normalSamples[6].a != vID && normalSamples[6].a != 0.0) {\n float depthAtSample = texture2D(d, uvSamples[6]).r + depthBias;\n if (gl_FragCoord.z > depthAtSample) {\n return 0.0;\n }\n }\n\n if (normalSamples[7].a != vID && normalSamples[7].a != 0.0) {\n float depthAtSample = texture2D(d, uvSamples[7]).r + depthBias;\n if (gl_FragCoord.z > depthAtSample) {\n return 0.0;\n }\n }\n\n if (normalSamples[8].a != vID && normalSamples[8].a != 0.0) {\n float depthAtSample = texture2D(d, uvSamples[8]).r + depthBias;\n if (gl_FragCoord.z > depthAtSample) {\n return 0.0;\n }\n }\n\n vec3 sobel_edge_h = normalSamples[2].rgb + (2.0*normalSamples[5].rgb) + normalSamples[8].rgb - (normalSamples[0].rgb + (2.0*normalSamples[3].rgb) + normalSamples[6].rgb);\n \tvec3 sobel_edge_v = normalSamples[0].rgb + (2.0*normalSamples[1].rgb) + normalSamples[2].rgb - (normalSamples[6].rgb + (2.0*normalSamples[7].rgb) + normalSamples[8].rgb);\n\n float edgeNormal = sqrt(dot(sobel_edge_h, sobel_edge_h) + dot(sobel_edge_v, sobel_edge_v));\n return edgeNormal;\n}\n");return{outline:new ki("vec3 outline(vec3 outlineColor, vec3 contourColor, float outlineWidth, float contourWidth, float outlineThreshold, float contourThreshold, float outlineSmoothing, float contourFrequency, vec3 contourDirection, bool positionalLines, vec2 resolution, sampler2D normalMap, sampler2D depthMap, float pixelRatio, bool compensation, float mask, float alpha, out float calpha) {\n vec3 result = outlineColor;\n float resultAlpha = 0.0;\n\n vec3 N = normalize(vWNormal);\n vec2 nuv = (gl_FragCoord.xy / resolution);\n float sobelSample = compensation ? sobelSample(normalMap, depthMap, nuv, resolution, outlineWidth / 2., pixelRatio) : sobelSample(normalMap, depthMap, nuv, resolution, outlineWidth, pixelRatio);\n resultAlpha = smoothstep(outlineThreshold - outlineSmoothing, outlineThreshold + outlineSmoothing, sobelSample);\n\n \n \n\n float t = 1.0 - contourThreshold;\n if(positionalLines) {\n vec3 NDir = position * contourDirection;\n float NT = NDir.x + NDir.y + NDir.z;\n float f = fract(NT * contourFrequency * 0.01);\n float df = fwidth(NT * contourFrequency);\n\n float g = smoothstep(df * (contourWidth * 0.01), df * (contourWidth * 0.01 * 2.0), f);\n if (g < 1.0 && resultAlpha == 0.0) {\n result = contourColor;\n resultAlpha = 1.0;\n }\n }\n else {\n vec3 NDir = N * contourDirection;\n float NT = NDir.x + NDir.y + NDir.z;\n float df = fwidth(NT * contourThreshold);\n float f = sin(NT * 1.0 * contourFrequency);\n float g = smoothstep(0.0, df * contourWidth, 1.0 - f);\n\n if (df > (t * 0.5) && g < 1.0 && resultAlpha == 0.0) {\n result = contourColor;\n resultAlpha = 1.0 - g;\n }\n }\n\n float lalpha = alpha * resultAlpha * mask;\n calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );\n accumAlpha += ( 1.0 - accumAlpha ) * lalpha;\n\t\t\t\t \n return result;\n }",[e])}}();var Us=class extends Oi{constructor(e,t,n,i,a,r,o,s,l,c,d,u,f,p,h,m,v,g){super("v3"),this.nodeType="Pattern",this.style=e,this.projection=t,this.axis=n,this.blending=i,this.offset=a,this.colorA=r,this.colorB=o,this.frequency=s,this.size=l,this.variation=c,this.smoothness=d,this.zigzag=u,this.rotation=f,this.vertical=p,this.horizontal=h,this.sides=m,this.isMask=g,this.alpha=v,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.isShader("fragment")){let n;switch(e.require("position"),e.require("uv"),e.requires.uv=[!0],e.require("normal"),e.requires.normal=!0,e.addFragmentVariable(this.calpha,"float"),this.style.value){case 0:default:n="circle";break;case 1:n="ring";break;case 2:n="polygon";break;case 3:n="xcross";break;case 4:n="diamond";break;case 5:n="checkerboard";break;case 6:n="line";break;case 7:n="wave"}let i=`g${this.uuid.toString().replace(/-/g,"")}`,a=new ki("float hashwithoutsine12(vec2 p)\n\t\t\t\t{\n\t\t\t\t\tvec3 p3 = fract(vec3(p.xyx) * .1031);\n\t\t\t\t\tp3 += dot(p3, p3.yzx + 33.33);\n\t\t\t\t\treturn fract((p3.x + p3.y) * p3.z);\n\t\t\t\t}"),r=new ki("vec2 rotate_uv(in vec2 uv, float a, bool repeat) \n\t\t\t\t{\n\t\t\t\t\tconst float mid = 0.5;\n\t\t\t\t\tfloat radians = a * (PI / 180.0);\n\t\t\t\t\tvec2 rotated = vec2(\n\t\t\t\t\t\tcos(radians) * (uv.x - mid) + sin(radians) * (uv.y - mid) + mid,\n\t\t\t\t\t\tcos(radians) * (uv.y - mid) - sin(radians) * (uv.x - mid) + mid\n\t\t\t\t\t);\n\t\t\t\t\treturn repeat ? fract(rotated): rotated;\n\t\t\t\t}"),o="";if(4===this.projection.value)o=`\n\t\t\t\tvec3 p = position;\n\t\t\t\tfloat factor = 0.0125;\n\t\t\t\tvec2 uv0 = fract(p.xy * factor);\n\t\t\t\tvec2 uv1 = fract(p.zy * factor);\n\t\t\t\tvec2 uv2 = fract(p.xz * factor);\n\t\t\t\t\n\t\t\t\tuv0 = rotate_uv(uv0 + offset, rotation, true);\n\t\t\t\tuv1 = rotate_uv(uv1 + offset, rotation, true);\n\t\t\t\tuv2 = rotate_uv(uv2 + offset, rotation, true);\n\t\n\t\t\t\tfloat d0 = ${2===this.style.value?`${n}(uv0, frequency, size, variation, smoothness_remapped, zigzag, rotation, sides)`:`${n}(uv0, frequency, size, variation, smoothness_remapped, zigzag, rotation)`};\n\t\t\t\tfloat d1 = ${2===this.style.value?`${n}(uv1, frequency, size, variation, smoothness_remapped, zigzag, rotation, sides)`:`${n}(uv1, frequency, size, variation, smoothness_remapped, zigzag, rotation)`};\n\t\t\t\tfloat d2 = ${2===this.style.value?`${n}(uv2, frequency, size, variation, smoothness_remapped, zigzag, rotation, sides)`:`${n}(uv2, frequency, size, variation, smoothness_remapped, zigzag, rotation)`};\n\t\t\t\t\n\t\t\t\t\n\t\t\t\tfloat exponent = (1.0 - blending) * 125.0 + 3.0;\n\n\t\t\t\tvec3 n = vObjectNormal;\n\t\t\t\tvec3 weights = abs(normalize(n));\n\t\t\t\tweights = pow(weights, vec3(exponent));\n\t\t\t\tweights /= dot(weights, vec3(1.0));\n\t\t\t\td0 *= weights.z;\n\t\t\t\td1 *= weights.x;\n\t\t\t\td2 *= weights.y;\n\t\t\t\tfloat draw = d0 + d1 + d2;\n\t\n\t\t\t\tvec2 custom_uv = uv0 * weights.z + uv1 * weights.x + uv2 * weights.y;\n\t\t\t\t`;else{let e=2===this.style.value?`${n}(custom_uv, frequency, size, variation, smoothness_remapped, zigzag, rotation, sides)`:`${n}(custom_uv, frequency, size, variation, smoothness_remapped, zigzag, rotation)`,t="";0===this.axis.value?t="float radius = length(p);\n\t\t\t\t\tfloat theta = atan(p.y, p.z);\n\t\t\t\t\tfloat phi = acos(p.x / radius);":1===this.axis.value?t="float radius = length(p);\n\t\t\t\t\tfloat theta = atan(p.x, p.z);\n\t\t\t\t\tfloat phi = acos(p.y / radius);":(this.axis.value,t="float radius = length(p);\n\t\t\t\t\tfloat theta = atan(p.y, p.x);\n\t\t\t\t\tfloat phi = acos(p.z / radius);");let i="";switch(this.projection.value){case 0:i="custom_uv = vUv.st;";break;case 1:case 3:default:break;case 2:i=`\n\t\t\t\t\t\t\tvec3 p = position;\n\t\t\t\t\t\t\t${t}\n\t\t\t\t\t\t\tcustom_uv = vec2(theta, phi);\n\t\t\t\t\t\t\tcustom_uv /= PI;\n\t\t\t\t\t\t\t`}o=`\n\t\t\t\tvec2 custom_uv;\n\t\t\t\t${i}\n\t\n\t\t\t\tcustom_uv += offset;\n\t\t\t\tcustom_uv = fract(custom_uv);\n\t\t\t\tcustom_uv = rotate_uv(custom_uv, rotation, true);\n\t\n\t\t\t\tfloat draw = ${e};\n\t\t\t\t`}let s=new ki(`vec3 ${i}_pattern(vec3 normal, float blending, int style, vec2 offset, vec4 colorA, vec4 colorB, vec2 frequency, float size, float variation, float smoothness, float zigzag, float rotation, vec2 vertical, vec2 horizontal, int sides, bool isMask, float mask, float alpha, out float calpha) {\n\t\t\t\t\tconst float TWO_PI = PI * 2.0;\n\t\t\t\t\tfloat smoothness_remapped = pow(smoothness, 5.0);\t\n\n\t\t\t\t\t${o}\n\n\t\t\t\t\t\n\t\t\t\t\tvec4 color = mix(colorA, colorB, draw);\n\t\t\t\t\tcolor.a = clamp(color.a, 0.0, 1.0);\n\n\t\t\t\t\t\n\t\t\t\t\tcolor.a *= \n\t\t\t\t\t\tstep(vertical.x, custom_uv.y) * \n\t\t\t\t\t\tstep(custom_uv.y, vertical.y);\n\t\t\t\t\tcolor.a *= \n\t\t\t\t\t\tstep(horizontal.x, abs(custom_uv.x)) * \n\t\t\t\t\t\tstep(abs(custom_uv.x), horizontal.y);\n\n\t\t\t\t\t\n\t\t\t\t\tfloat lalpha = alpha * clamp(color.a, 0.0, 1.0) * mask;\n\t\t\t\t\tcalpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));\n\t\t\t\t\taccumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));\n\n\t\t\t\t\treturn clamp(color, 0.0, 1.0).rgb;\n\t\t\t\t}`,[r,a,Us.DrawFunctions.circle,Us.DrawFunctions.ring,Us.DrawFunctions.polygon,Us.DrawFunctions.cross,Us.DrawFunctions.diamond,Us.DrawFunctions.checkerboard,Us.DrawFunctions.line,Us.DrawFunctions.wave]),l=e.include(s),c=[];return c.push("normal"),c.push(this.blending.build(e,"f")),c.push(this.style.build(e,"i")),c.push(this.offset.build(e,"v2")),c.push(this.colorA.build(e,"v4")),c.push(this.colorB.build(e,"v4")),c.push(this.frequency.build(e,"v2")),c.push(this.size.build(e,"f")),c.push(this.variation.build(e,"f")),c.push(this.smoothness.build(e,"f")),c.push(this.zigzag.build(e,"f")),c.push(this.rotation.build(e,"f")),c.push(this.vertical.build(e,"v2")),c.push(this.horizontal.build(e,"v2")),c.push(this.sides.build(e,"i")),c.push(this.isMask.build(e,"b")),c.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),c.push(this.alpha.build(e,"f")),c.push(this.calpha),e.format(l+"("+c.join(",")+")",this.getType(e),t)}return console.warn("PatterNode is not compatible with "+e.shader+" shader."),e.format("vec3(0.0)",this.getType(e),t)}},Ns=Us;Ns.DrawFunctions=function(){let e=new ki("float hashwithoutsine12(vec2 p) {\n\t\t\t\tvec3 p3 = fract(vec3(p.xyx) * 0.1031);\n\t\t\t\tp3 += dot(p3, p3.yzx + 33.33);\n\t\t\t\treturn fract((p3.x + p3.y) * p3.z);\n\t\t\t}"),t=new ki("vec2 tile_and_center(in vec2 uv, in vec2 frequency, in float variation, in float zigzag, in float rotation) {\n \n uv *= frequency;\n\n \n vec2 i = floor(uv);\n\n \n float row_offset = mod(i.y, 2.0);\n uv.x += row_offset * zigzag;\n vec2 f = fract(uv);\n\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\n f = f * 2.0 - 1.0;\n\n\t\t\t\t\n\t\t\t\ti = floor(uv);\n\t\t\t\tfloat rand = (hashwithoutsine12(i) * 5.0 + 1.0);\n\t\t\t\tfloat jitter = mix(1.0, rand, variation);\n\t\t\t\tf *= jitter;\n\n return f;\n }",[e]);return{tileAndCenter:t,circle:new ki("float circle(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {\n vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation);\n return smoothstep(\n -smoothness, \n smoothness, \n length(f) - size\n );\n }",[t]),ring:new ki("float ring(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {\n vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation);\n\n\t\t\t\tfloat d = length(f);\n const float inner_width = 0.5;\n\n float outer = smoothstep(-smoothness, smoothness, d - size);\n float inner = smoothstep(-smoothness, smoothness, d - size * inner_width);\n\t\t\t\treturn outer + (1.0 - inner); \n }",[t]),polygon:new ki("float sdf_ngon(in vec2 p, in float r, in int n) {\n float an = (PI * 2.0) / float(n);\n float he = r * tan(0.5 * an);\n \n \n p = -p.yx; \n float bn = an * floor((atan(p.y, p.x) + 0.5 * an) / an);\n vec2 cs = vec2(cos(bn), sin(bn));\n p = mat2(cs.x, -cs.y, cs.y, cs.x)*p;\n \n \n return length(p - vec2(r, clamp(p.y, -he, he))) * sign(p.x - r);\n }\n \n float polygon(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation, in int sides) {\n vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation);\n return smoothstep(-smoothness, smoothness, sdf_ngon(f, size, sides));\n }",[t]),cross:new ki("float sdf_cross(in vec2 p, in vec2 b, float r ) {\n p = abs(p); \n\t\t\t\tp = (p.y > p.x) ? p.yx : p.xy;\n vec2 q = p - b;\n float k = max(q.y, q.x);\n vec2 w = (k > 0.0) ? q : vec2(b.y - p.x, -k);\n return sign(k) * length(max(w, 0.0)) + r;\n }\n \n \n float xcross(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {\n vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation);\n return smoothstep(-smoothness, smoothness, sdf_cross(f, vec2(size, size * 0.25), smoothness));\n }",[t]),diamond:new ki("float ndot(vec2 a, vec2 b) { \n return a.x*b.x - a.y*b.y; \n }\n \n float sdf_diamond(in vec2 p, in vec2 b) {\n p = abs(p);\n float h = clamp(ndot(b - 2.0 * p, b) / dot(b, b), -1.0, 1.0);\n float d = length(p - 0.5 * b * vec2(1.0 - h, 1.0 + h));\n return d * sign(p.x * b.y + p.y * b.x - b.x * b.y);\n }\n\n float diamond(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {\n vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation);\n\t return smoothstep(-smoothness, smoothness, sdf_diamond(f, vec2(size)));\n }",[t]),checkerboard:new ki("float checkerboard(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {\n uv *= frequency;\n vec2 i = floor(uv);\n\n float offset = mod(i.y, 2.0);\n\n uv.x += offset + zigzag * offset;\n float x = floor(uv.x);\n \n return mod(x, 2.0);\n }"),line:new ki("float line(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {\n vec2 f = tile_and_center(uv, frequency, 0.0, zigzag, rotation);\n\t\t\t\t\n\t\t\t\t\n\t\t\t\tfloat row = floor(uv * frequency).y;\n\t\t\t\tfloat rand = hashwithoutsine12(vec2(row));\n\t\t\t\tfloat s = mix(size, size * rand, variation);\n\n\t\t\t\treturn smoothstep(\n\t\t\t\t\ts - smoothness, \n\t\t\t\t\ts + smoothness, \n\t\t\t\t\tabs(f.y)\n\t\t\t\t);\n }",[t]),wave:new ki("\n float udf_cos(in vec2 p, in float a, in float b, in float c, in float d) {\n \n p = c * (p - vec2(d, a));\n \n const float TWO_PI = PI * 2.0;\n\n \n p.x = mod(p.x, TWO_PI); \n if (p.x > PI) {\n p.x = TWO_PI - p.x;\n }\n \n \n float xa = 0.0;\n float xb = TWO_PI;\n\n \n for (int i = 0; i < 24; i++) {\n float x = 0.5 * (xa + xb);\n float y = x - p.x + b * c * sin(x) * (p.y - b * c * cos(x));\n if (y < 0.0) xa = x; \n else xb = x;\n }\n float x = 0.5 * (xa + xb);\n \n \n vec2 q = vec2(x, b * c * cos(x));\n return length(p - q) / c;\n }\n\n float wave(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {\n float repeat = frequency.x;\n uv *= repeat;\n vec2 i = floor(uv);\n float row_offset = mod(i.y, 2.0);\n uv.x += row_offset * zigzag;\n vec2 f = vec2(uv.x, fract(uv.y));\n\n \n const float amplitude = 0.125;\n float wave_frequency = frequency.y * 0.1;\n float distance_estimate = udf_cos(f, 0.50, amplitude, wave_frequency * (2.0 * PI), 0.0);\n\n\t\t\t\t\n\t\t\t\tfloat rand = hashwithoutsine12(vec2(i.y));\n\t\t\t\tfloat s = mix(size, size * rand, variation);\n\n return smoothstep(-smoothness, smoothness, distance_estimate - s * 0.5);\n }")}}();var Is=class extends Oi{constructor(e,t,n,i,a,r,o,s,l=!0){super("v3"),this.nodeType="Rainbow",this.filmThickness=e,this.movement=t,this.wavelengths=n,this.noiseStrength=i,this.noiseScale=a,this.offset=r,this.isMask=s,this.alpha=o,this.noiseEnabled=l,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.require("vWorldViewDir"),e.require("worldNormal"),e.isShader("fragment")){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let n=e.include(this.noiseEnabled?Is.Nodes.rainbow:Is.Nodes.rainbowNN),i=[];return i.push(this.filmThickness.build(e,"f")),i.push(this.movement.build(e,"f")),i.push(this.wavelengths.build(e,"v3")),i.push(this.noiseStrength.build(e,"f")),i.push(this.noiseScale.build(e,"f")),i.push(this.offset.build(e,"v3")),i.push(this.isMask.build(e,"b")),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(n+"("+i.join(",")+")",this.getType(e),t)}return console.warn("RainbowNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},Os=Is;Os.Nodes=function(){let e=new ki("vec3 attenuation(vec3 wavelengths, float filmThickness, float movement, float noiseStrength, float noiseScale, vec3 offset) {\n\t\t\t\tfloat f = 0.0;\n\n\t\t\t\tif (noiseStrength != 0.0) {\n\t\t\t\t\tvec3 st = position / noiseScale;\n\t\t\t\t\tfloat noise = simplexFast(1.6 * st + vec3(1.8, 1.5, 1.9) * simplexFast(st) + vec3(1.7, 9.2, 1.0));\n\t\t\t\t\tf = noise * noiseStrength;\n\t\t\t\t}\n\n\t\t\t\tvec3 waves = wavelengths * vec3(1.0, 0.8, 0.6) + 1.0;\n\t\t\t\tfloat angle = dot(normalize(vWorldViewDir + (offset * -0.001)), normalize(vWNormal));\n\n\t\t\t\tmediump vec3 color = cos((((filmThickness + f) / waves) * angle) + movement);\n\t\t\t\treturn .5 + .5 * color;\n\t\t\t }",[bs.simplexFast]),t=new ki("vec3 rainbow(float filmThickness, float movement, vec3 wavelengths, float noiseStrength, float noiseScale, vec3 offset, bool isMask, float mask, float alpha, out float calpha) {\n\t\t\t\tmediump vec3 res = clamp(attenuation(wavelengths, filmThickness, movement, noiseStrength, noiseScale, offset), 0.0, 2.0);\n\n\t\t\t\tfloat rainbowContribution = clamp(res.r + res.g + res.b, 0.0, 1.0);\n\n\t\t\t\tfloat lalpha = alpha * rainbowContribution * mask;\n\t\t\t\tcalpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));\n\t\t\t\taccumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));\n\n\t\t\t\treturn res;\n\t\t\t }",[e]),n=new ki("vec3 attenuationNN(vec3 wavelengths, float filmThickness, float movement, float noiseStrength, float noiseScale, vec3 offset) {\n\t\t\t\tvec3 waves = wavelengths * vec3(1.0, 0.8, 0.6) + 1.0;\n\t\t\t\tfloat angle = dot(normalize(vWorldViewDir + (offset * -0.001)), normalize(vWNormal));\n\n\t\t\t\tmediump vec3 color = cos(((filmThickness / waves) * angle) + movement);\n\t\t\t\treturn .5 + .5 * color;\n\t\t\t }");return{rainbow:t,rainbowNN:new ki("vec3 rainbowNN(float filmThickness, float movement, vec3 wavelengths, float noiseStrength, float noiseScale, vec3 offset, bool isMask, float mask, float alpha, out float calpha) {\n\t\t\t\tmediump vec3 res = clamp(attenuationNN(wavelengths, filmThickness, movement, noiseStrength, noiseScale, offset), 0.0, 2.0);\n\n\t\t\t\tfloat rainbowContribution = clamp(res.r + res.g + res.b, 0.0, 1.0);\n\n\t\t\t\tfloat lalpha = alpha * rainbowContribution * mask;\n\t\t\t\tcalpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));\n\t\t\t\taccumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));\n\n\t\t\t\treturn res;\n\t\t\t }",[n])}}();var Fs=class extends Oi{constructor(e,t,n,i,a,r,o,s,l,c){super("v3"),this.nodeType="Toon",this.positioning=e,this.colors=t,this.steps=n,this.source=i,this.isWorldSpace=a,this.noiseStrength=r,this.noiseScale=o,this.shadowColor=s,this.offset=l,this.alpha=c,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.require("worldNormal"),e.require("worldPosition"),e.isShader("fragment")){e.define("COLORS_MAX",10),e.addFragmentVariable(this.calpha,"float");let n=e.include(Fs.Nodes.toon),i=[];return i.push(this.positioning.build(e,"i")),i.push(this.colors.build(e,"v4[]")),i.push(this.steps.build(e,"f[]")),i.push(this.source.build(e,"v3")),i.push(this.isWorldSpace.build(e,"b")),i.push(this.noiseStrength.build(e,"f")),i.push(this.noiseScale.build(e,"f")),i.push(this.shadowColor.build(e,"v4")),i.push(this.offset.build(e,"v3")),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(n+"("+i.join(",")+")",this.getType(e),t)}return console.warn("ToonNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},zs=Fs;zs.Nodes=function(){let e=new ki("float rand(float n) {\n\t\t\t\treturn fract(sin(n) * 43758.5453123);\n\t\t\t}"),t=new ki("float hash1(float p) { \n\t\t\t\tp = fract(p * 0.011); \n\t\t\t\tp *= p + 7.5; \n\t\t\t\tp *= p + p; \n\t\t\t\treturn fract(p); \n\t\t\t}"),n=new ki("float valueNoise(vec3 x) {\n\t\t\t\tconst vec3 step = vec3(110, 241, 171);\n\t\t\t\n\t\t\t\tvec3 i = floor(x);\n\t\t\t\tvec3 f = fract(x);\n\t\t\t \n\t\t\t\t\n\t\t\t\t\n\t\t\t\tfloat n = dot(i, step);\n\t\t\t\n\t\t\t\tvec3 u = f * f * (3.0 - 2.0 * f);\n\t\t\t\treturn mix(mix(mix( hash1(n + dot(step, vec3(0, 0, 0))), hash1(n + dot(step, vec3(1, 0, 0))), u.x),\n\t\t\t\t\t\t\t mix( hash1(n + dot(step, vec3(0, 1, 0))), hash1(n + dot(step, vec3(1, 1, 0))), u.x), u.y),\n\t\t\t\t\t\t mix(mix( hash1(n + dot(step, vec3(0, 0, 1))), hash1(n + dot(step, vec3(1, 0, 1))), u.x),\n\t\t\t\t\t\t\t mix( hash1(n + dot(step, vec3(0, 1, 1))), hash1(n + dot(step, vec3(1, 1, 1))), u.x), u.y), u.z);\n\t\t\t}",[t]),i=new ki("vec3 hash3(vec3 x) {\n\t\t\t\tx = vec3(dot(x,vec3(127.1, 311.7, 74.7)),\n\t\t\t\t\t\t dot(x,vec3(269.5, 183.3, 246.1)),\n\t\t\t\t\t\t dot(x,vec3(113.5, 271.9, 124.6)));\n\t\t\t\n\t\t\t\treturn fract(sin(x)*43758.5453123);\n\t\t\t}"),a=new ki("vec3 voronoiNoise(in vec3 x)\n\t\t\t{\n\t\t\t\tvec3 p = floor(x);\n\t\t\t\tvec3 f = fract(x);\n\n\t\t\t\tfloat id = 0.0;\n\t\t\t\tvec2 res = vec2(100.0);\n\n\t\t\t\tfor(int k=-1; k<=1; k++)\n\t\t\t\tfor(int j=-1; j<=1; j++)\n\t\t\t\tfor(int i=-1; i<=1; i++)\n\t\t\t\t{\n\t\t\t\t\tvec3 b = vec3(float(i), float(j), float(k));\n\n\t\t\t\t\t\n\t\t\t\t\tvec3 r = vec3(b) - f + hash3(p + b);\n\t\t\t\t\tfloat d = dot(r, r);\n\n\t\t\t\t\tif (d < res.x)\n\t\t\t\t\t{\n\t\t\t\t\t\tid = dot(p + b, vec3(1.0, 57.0, 113.0));\n\t\t\t\t\t\tres = vec2(d, res.x);\t\t\t\n\t\t\t\t\t}\n\t\t\t\t\telse if (d < res.y)\n\t\t\t\t\t{\n\t\t\t\t\t\tres.y = d;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn vec3(sqrt(res), abs(id));\n\t\t\t}\n\t\t\t",[i]);return{toon:new ki("vec3 toon(int positioning, vec4 colors[COLORS_MAX], float steps[COLORS_MAX], vec3 source, bool isWorldSpace, float noiseStrength, float noiseScale, vec4 shadowColor, vec3 offset, float mask, float alpha, out float calpha) {\n\t\t\t\tfloat t = 0.0;\n\t\t\t\tfloat shadow = 1.0;\n\n\t\t\t\tif (positioning == 0) {\n\n\t\t\t\t\t\n\t\t\t\t\t#if (defined(PHONG) || defined(LAMBERT) || defined(STANDARD))\n\n\t\t\t\t\t\t\n\t\t\t\t\t\tconst vec3 weights = vec3(0.2125, 0.7154, 0.0721);\n\t\t\t\t\t\tvec3 lpos;\n\t\t\t\t\t\tvec3 l;\n\t\t\t\t\t\tfloat dproduct;\n\n\t\t\t\t\t\t#if (NUM_POINT_LIGHTS > 0)\n\n\t\t\t\t\t\t\t#if defined(USE_SHADOWMAP) && (NUM_POINT_LIGHT_SHADOWS > 0)\n\t\t\t\t\t\t\t\tPointLightShadow pointLightShadow;\n\t\t\t\t\t\t\t#endif \n\n\t\t\t\t\t\t\t#pragma unroll_loop_start\n\t\t\t\t\t\t\tfor (int i = 0; i < NUM_POINT_LIGHTS; i++) {\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tlpos = (inverse(viewMatrix) * vec4(pointLights[UNROLLED_LOOP_INDEX].position, 1.0)).xyz;\n\t\t\t\t\t\t\t\tl = normalize(lpos - worldPosition);\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tdproduct = dot(l, normalize(worldNormal)) * 0.5 + 0.5;\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\n\t\t\t\t\t\t\t\tt = max(t, dproduct);\n\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t#if defined(USE_SHADOWMAP) && (UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS)\n\t\t\t\t\t\t\t\t\tpointLightShadow = pointLightShadows[UNROLLED_LOOP_INDEX];\n\t\t\t\t\t\t\t\t\tshadow *= getPointShadow( \n\t\t\t\t\t\t\t\t\t\t\tpointShadowMap[UNROLLED_LOOP_INDEX], \n\t\t\t\t\t\t\t\t\t\t\tpointLightShadow.shadowMapSize,\n\t\t\t\t\t\t\t\t\t\t\tpointLightShadow.shadowIntensity,\n\t\t\t\t\t\t\t\t\t\t\tpointLightShadow.shadowBias, \n\t\t\t\t\t\t\t\t\t\t\tpointLightShadow.shadowRadius,\n\t\t\t\t\t\t\t\t\t\t\tvPointShadowCoord[UNROLLED_LOOP_INDEX], \n\t\t\t\t\t\t\t\t\t\t\tpointLightShadow.shadowCameraNear, \n\t\t\t\t\t\t\t\t\t\t\tpointLightShadow.shadowCameraFar);\n\t\t\t\t\t\t\t\t#endif\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t#pragma unroll_loop_end\n\n\t\t\t\t\t\t#endif\n\n\t\t\t\t\t\t#if NUM_DIR_LIGHTS > 0 \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t#if defined(USE_SHADOWMAP) && (NUM_DIR_LIGHT_SHADOWS > 0)\n\t\t\t\t\t\t\t\tDirectionalLightShadow directionalLightShadow;\n\t\t\t\t\t\t\t#endif \n\n\t\t\t\t\t\t\t#pragma unroll_loop_start\n\t\t\t\t\t\t\tfor (int i = 0; i < NUM_DIR_LIGHTS; i++) {\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tl = (inverse(viewMatrix) * vec4(directionalLights[UNROLLED_LOOP_INDEX].direction, 0.0)).xyz;\n\t\t\n\t\t\t\t\t\t\t\tdproduct = dot(l, normalize(worldNormal)) * 0.5 + 0.5;\n\t\t\t\t\t\t\t\tt = max(t, dproduct);\n\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t#if defined(USE_SHADOWMAP) && (UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS)\n\t\t\t\t\t\t\t\t\tdirectionalLightShadow = directionalLightShadows[UNROLLED_LOOP_INDEX];\n\t\t\t\t\t\t\t\t\tshadow *= getShadow( \n\t\t\t\t\t\t\t\t\t\tUNROLLED_LOOP_INDEX,\n\t\t\t\t\t\t\t\t\t\tdirectionalShadowMap[UNROLLED_LOOP_INDEX], \n\t\t\t\t\t\t\t\t\t\tdirectionalLightShadow.shadowMapSize,\n\t\t\t\t\t\t\t\t\t\tdirectionalLightShadow.shadowIntensity,\n\t\t\t\t\t\t\t\t\t\tdirectionalLightShadow.shadowBias, \n\t\t\t\t\t\t\t\t\t\tdirectionalLightShadow.shadowRadius, \n\t\t\t\t\t\t\t\t\t\tvDirectionalShadowCoord[UNROLLED_LOOP_INDEX]);\n\t\t\t\t\t\t\t\t#endif\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t#pragma unroll_loop_end\n\n\t\t\t\t\t\t#endif\n\n\t\t\t\t\t\t#if NUM_SPOT_LIGHTS > 0 \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t#if defined(USE_SHADOWMAP) && (NUM_SPOT_LIGHT_SHADOWS > 0)\n\t\t\t\t\t\t\t\tSpotLightShadow spotLightShadow;\n\t\t\t\t\t\t\t#endif \n\n\t\t\t\t\t\t\t#pragma unroll_loop_start\n\t\t\t\t\t\t\tfor (int i = 0; i < NUM_SPOT_LIGHTS; i++) {\n\t\t\t\t\t\t\t\tlpos = (inverse(viewMatrix) * vec4(spotLights[UNROLLED_LOOP_INDEX].position, 1.0)).xyz;\n\t\t\t\t\t\t\t\tl = normalize(lpos - worldPosition);\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tdproduct = dot(l, normalize(worldNormal)) * 0.5 + 0.5;\n\t\t\t\t\t\t\t\tt = max(t, dproduct);\n\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t#if defined(USE_SHADOWMAP) && (UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS)\n\t\t\t\t\t\t\t\t\tspotLightShadow = spotLightShadows[UNROLLED_LOOP_INDEX];\n\t\t\t\t\t\t\t\t\tshadow *= getShadow(\n\t\t\t\t\t\t\t\t\t\tUNROLLED_LOOP_INDEX,\n\t\t\t\t\t\t\t\t\t\tspotShadowMap[UNROLLED_LOOP_INDEX], \n\t\t\t\t\t\t\t\t\t\tspotLightShadow.shadowMapSize,\n\t\t\t\t\t\t\t\t\t\tspotLightShadow.shadowIntensity,\n\t\t\t\t\t\t\t\t\t\tspotLightShadow.shadowBias, \n\t\t\t\t\t\t\t\t\t\tspotLightShadow.shadowRadius, \n\t\t\t\t\t\t\t\t\t\tvSpotLightCoord[UNROLLED_LOOP_INDEX]);\n\t\t\t\t\t\t\t\t#endif\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t#pragma unroll_loop_end\n\n\t\t\t\t\t\t#endif\n\n\t\t\t\t\t\tt = clamp(t, 0.0, 1.0);\n\t\t\t\t\n\t\t\t\t\t#endif\n\n\t\t\t\t} else if (positioning == 1) {\n\t\t\t\t\t\n\t\t\t\t\tvec3 origin = mix(position, worldPosition, float(isWorldSpace));\n\t\t\t\t\tvec3 direction = normalize(source - origin);\n\t\t\t\t\tt = dot(direction, normalize(worldNormal)) * 0.5 + 0.5;\t\n\n\t\t\t\t} else {\n\n\t\t\t\t\tvec3 origin = worldPosition;\n\t\t\t\t\tvec3 source = cameraPosition - offset;\n\t\t\t\t\tvec3 direction = normalize(source - origin);\n\t\t\t\t\tt = dot(direction, normalize(worldNormal)) * 0.5 + 0.5;\t\n\t\t\t\t\t\n\t\t\t\t}\n\n\t\t\t\tif (noiseStrength > 0.0) {\n\t\t\t\t\t\n\t\t\t\t\tvec3 st = position / noiseScale;\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\tfloat noise = 1.0 - voronoiNoise(st).x;\n\n\t\t\t\t\t\n\t\t\t\t\t\n\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\n\t\t\t\t\tt += noise * noiseStrength;\n\t\t\t\t}\n\n\t\t\t\tt = clamp(t, 0.0, 1.0);\n\n\t\t\t\t\n\t\t\t\tfloat p;\n\t\t\t\tvec4 color = colors[0];\n\t\t\t\tfor (int i = 1; i < COLORS_MAX; i++) {\n\t\t\t\t\tp = clamp((t - steps[i-1]) / (steps[i] - steps[i-1]), 0.0, 1.0);\n\t\t\t\t\tcolor = mix(color, colors[i], smoothstep(0.0, 1.0, p));\n\t\t\t\t}\n\n\t\t\t\t\n\t\t\t\tif (positioning == 0) {\n\n\t\t\t\t\tvec3 blendedShadow = mix(color.rgb, shadowColor.rgb, shadowColor.a);\n\t\t\t\t\tcolor.rgb = mix(blendedShadow, color.rgb, shadow);\n\t\t\t\t\n\t\t\t\t}\n\n\t\t\t\t\n\t\t\t\tfloat lalpha = alpha * color.a * mask;\n\t\t\t\tcalpha = lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0);\n\t\t\t\taccumAlpha += (1.0 - accumAlpha) * lalpha;\n\n\t\t\t\treturn color.xyz;\n\n }",[bs.simplexFast,e,n,a])}}();var Bs={textureBicubic:new ki("float w0( float a ) {\n return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n }\n \n float w1( float a ) {\n return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n }\n \n float w2( float a ){\n return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n }\n \n float w3( float a ) {\n return ( 1.0 / 6.0 ) * ( a * a * a );\n }\n \n \n float g0( float a ) {\n return w0( a ) + w1( a );\n }\n \n float g1( float a ) {\n return w2( a ) + w3( a );\n }\n \n \n float h0( float a ) {\n return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n }\n \n float h1( float a ) {\n return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n }\n \n vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n uv = uv * texelSize.zw + 0.5;\n \n vec2 iuv = floor( uv );\n vec2 fuv = fract( uv );\n \n float g0x = g0( fuv.x );\n float g1x = g1( fuv.x );\n float h0x = h0( fuv.x );\n float h1x = h1( fuv.x );\n float h0y = h0( fuv.y );\n float h1y = h1( fuv.y );\n \n vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n \n return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) + \n g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n }\n\n vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n vec2 fLodSizeInv = 1.0 / fLodSize;\n vec2 cLodSizeInv = 1.0 / cLodSize;\n vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n return mix( fSample, cSample, fract( lod ) );\n }")},Vs=class extends Oi{constructor(e,t,n,i,a,r,o,s){super("v3"),this.nodeType="Transmission",this.thickness=e,this.ior=t,this.roughness=n,this.transmissionSamplerSize=i,this.transmissionSamplerMap=a,this.transmissionDepthMap=r,this.aspectRatio=o,this.alpha=s,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.extensions.shaderTextureLOD=!0,e.extensions.derivatives=!0,e.isShader("fragment")){e.define("NUM_SAMPLES",6),e.define("BLUR_SLOD",Math.pow(2,qs.transmissionLod.value)),e.require("worldPosition"),e.requires.worldNormal=!0,e.requires.modelMatrix=!0,e.requires.projectionMatrix=!0,e.addFragmentVariable(this.calpha,"float");let n=e.include(Vs.Nodes.transmission),i=[];return i.push(this.thickness.build(e,"f")),i.push(this.ior.build(e,"f")),i.push(this.roughness.build(e,"f")),i.push(this.transmissionSamplerSize.build(e,"v2")),i.push(this.transmissionSamplerMap.getTexture(e,"t")),i.push(this.transmissionDepthMap.getTexture(e,"t")),i.push(this.aspectRatio.build(e,"v2")),i.push("normal"),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(n+"("+i.join(",")+")",this.getType(e),t)}return console.warn("TransmissionNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},Hs=Vs;Hs.Nodes=function(){let e=new ki("vec3 blur(sampler2D sp, vec2 U, vec2 scale, float lod, sampler2D dm, vec2 unrefractedU, vec2 aspectRatio) {\n \n \n\n\t\t\t\t\n\t\t\t\tif (lod == 0.0) {\n\t\t\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\t\treturn texture2DLodEXT( sp, U, 0.0).rgb;\n\t\t\t\t\t#else\n\t\t\t\t\treturn textureLod( sp, U, 0.0).rgb;\n\t\t\t\t\t#endif\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tvec2 texelSize = vec2(1.0) / resolution;\n vec2 halton = haltonSequence[frameIndex];\n float temporalOffset = getNoiseInterleavedGradient(gl_FragCoord.xy + halton);\n float temporalAngle = temporalOffset * PI2;\n\t\t\t\tvec3 res = vec3(0.0);\n vec2 uv = vec2(0.0);\n vec2 offset = vec2(0.0);\n vec2 vogelSample = vec2(0.0);\n for (int i = 0; i < NUM_SAMPLES; i++) {\n vogelSample = vogelDiskSample(i, NUM_SAMPLES, temporalAngle) * texelSize;\n offset = vogelSample * scale * (lod * 10.0); \n uv = U + offset;\n float opaqueDepth = unpackRGBAToDepth(textureLod(dm, uv, lod));\n if (opaqueDepth != 0.0 && opaqueDepth < gl_FragCoord.z) {\n uv = unrefractedU;\n lod = lod > 4.0 ? lod : lod / 2.0;\n }\n res += textureLod(sp, uv, lod).rgb;\n }\n return res / float(NUM_SAMPLES);\n }"),t=new ki("vec3 getVolumeTransmissionRay( vec3 n, vec3 v, float thickness, float ior, mat4 modelMatrix ) {\n\t\t \n\t\t vec3 refractionVector = refract( -v, n, 1.0 / ior );\n\t\t \n\t\t\t\t\n\t\t vec3 modelScale;\n\t\t modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\t modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\t modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\n\t\t \n\t\t return normalize( refractionVector ) * thickness * modelScale;\n\t }"),n=new ki("float applyIorToRoughness( float roughness, float ior ) {\n\t\t\t\t// Scale roughness with IOR so that an IOR of 1.0 results in no microfacet refraction and\n\t\t\t\t// an IOR of 1.5 results in the default amount of microfacet refraction.\n\t\t\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t\t\t}"),i=new ki("vec3 getTransmissionSample( vec2 fragCoord, float roughness, float ior, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 unrefractedCoords, vec2 aspectRatio) {\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t#ifdef IS_THREEJS_EXPORT\n\t\t\t\t\tfloat lod = log2(transmissionSamplerSize.x) * applyIorToRoughness(roughness / 5.0, ior);\n\t\t\t\t\treturn textureBicubic(transmissionSamplerMap, fragCoord.xy, lod).rgb;\n\t\t\t\t#else\n\t\t\t\t\tfloat framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\t\t\t\tfloat lod = applyIorToRoughness(roughness, ior);\n\t\t\t\t\treturn blur(transmissionSamplerMap, fragCoord, vec2(lod), min(framebufferLod / 5.5, 8.5), transmissionDepthMap, unrefractedCoords, aspectRatio);\n\t\t\t\t#endif\n\t\t\t}",[Bs.textureBicubic,n,e]),a=new ki("vec3 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat4 modelMatrix, mat4 viewMatrix, mat4 projMatrix, float ior, float thickness, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 aspectRatio ) {\n\t\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\n\t\t\t\t\n\t\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\t\trefractionCoords += 1.0;\n\t\t\t\trefractionCoords /= 2.0;\n\n\t\t\t\tvec4 ndcPosUnrefracted = projMatrix * viewMatrix * vec4(position, 1.0 );\n\t\t\t\tvec2 unrefractedCoords = ndcPosUnrefracted.xy / ndcPosUnrefracted.w;\n\t\t\t\tunrefractedCoords += 1.0;\n\t\t\t\tunrefractedCoords /= 2.0;\n\n\t\t\t\t\n\t\t\t\treturn getTransmissionSample( refractionCoords, roughness, ior, transmissionSamplerSize, transmissionSamplerMap, transmissionDepthMap, unrefractedCoords, aspectRatio );\n \t\t}",[i,t]);return{transmission:new ki("vec3 transmission(float thickness, float ior, float roughness, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 aspectRatio, vec3 normal, float mask, float alpha, out float calpha) {\n vec3 v = vec3(0.);\n if (isOrthographic) {\n v = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n } else {\n v = normalize(vWPosition - cameraPosition);\n }\n vec3 transmission = getIBLVolumeRefraction(vWNormal, -v, roughness, vWPosition, modelMatrix, viewMatrix, projectionMatrix, ior, thickness, transmissionSamplerSize, transmissionSamplerMap, transmissionDepthMap, aspectRatio );\n \n\t\t\t\tfloat lalpha = alpha * mask;\n\t\t\t\tcalpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );\n\t\t\t\taccumAlpha += ( 1.0 - accumAlpha ) * alpha;\n\n\t\t\t\treturn transmission;\n }",[a])}}();var Gs=class extends Oi{constructor(e){super("v3"),this.nodeType="VertexColor",this.alpha=e,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.isShader("fragment")){e.requires.color[0]=!0;let n=e.include(Gs.Nodes.vertexColorLayer);e.addFragmentVariable(this.calpha,"float");let i=[];return i.push("vColor"),i.push(this.mask?`luminance(${this.mask.build(e,"v3")})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(n+"("+i.join(",")+")",this.getType(e),t)}return console.warn("VertexColorNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},ks=Gs;ks.Nodes={vertexColorLayer:new ki("vec3 vertexColorLayer(vec4 vcolor, float mask, float alpha, out float calpha) {\n\t\t\t\tfloat lalpha = alpha * mask * vcolor.a;\n\t\t\t\tcalpha = lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0);\n\t\t\t\taccumAlpha += (1.0 - accumAlpha) * lalpha;\n\n\t\t\t\treturn vcolor.rgb;\n\t\t\t}")};var Ws,Xs=((Ws=Xs||{}).NOISE="noise",Ws.MAP="map",Ws),js=class extends Oi{constructor(e,t,n,i,a,r,o,s,l,c,d){super("v3"),this.displacementTypeIndex=new wa(0),this.nodeType="VertexDisplacement",this.intensity=e,this.movementOrTexture=t,"map"===Object.values(Xs)[this.displacementTypeIndex.value]&&(this.mat=new rs(this.movementOrTexture.value.matrix)),this.cropOrOffset=n,this.scale=c,this.noiseFunctionIndex=d,this.voronoiStyle=i,this.smoothness=a,this.seed=r,this.highCut=o,this.lowCut=s,this.quality=l}generate(e,t){if(e.isShader("vertex")){e.define("USE_LAYER_DISPLACE");let n,i=[];switch(i.push("displaced_position"),i.push("displaced_normal"),Object.values(Xs)[this.displacementTypeIndex.value]){case"map":n=e.include(js.Nodes.map),i.push(this.movementOrTexture.getTexture(e,"t")),i.push("uv"),i.push(this.cropOrOffset.build(e,"f")),this.mat&&i.push(this.mat.build(e,"mat3"));break;case"noise":{let t=["simplexPrecise","simplexFractal","simplexAshima","fbm","perlin","voronoi"][this.noiseFunctionIndex.value],a=new ki("vec3 orthogonal(vec3 v) {\n\t\t\t\t\t\t\treturn normalize(abs(v.x) > abs(v.z) ? vec3(-v.y, v.x, 0.0) : vec3(0.0, -v.z, v.y));\n\t\t\t\t\t\t}"),r=new ki(`vec3 distorted(vec3 p, vec3 n, float scale, float intensity, vec3 offset, float neighbour_offset, float movement, int voronoiStyle, float smoothness, float seed, float highCut, float lowCut, int quality) {\n\t\t\t\t\t\t\t${"voronoi"==t?`\n\t\t\t\t\tfloat v = ${t}((p + offset) * scale * 0.001 + neighbour_offset + (movement * 0.1), voronoiStyle, smoothness, seed, quality);\n\t\t\t\t\tv = remap(v, lowCut, highCut, 0.0, 1.0);\n\t\t\t\t\tv = smax(v, 0.0, smoothness * 0.25);\n\t\t\t\t\tv = smin(v, 1.0, smoothness * 0.25);\n\n\t\t\t\t\treturn p + n * v * intensity;\n\t\t\t\t\t`:`\n\t\t\t\t\treturn p + n * ${t}((p + offset) * scale * 0.001 + neighbour_offset + (movement * 0.1)) * intensity;\n\t\t\t\t\t`}\n\t\t\t\t\t\t}`,[bs.simplexPrecise,bs.simplexFractal,bs.simplexAshima,bs.fbm,bs.perlin,bs.voronoi]),o=new ki("vec3 vertexDisplacementNoise(vec3 position, vec3 normal, float scale, vec3 offset, float movement, int voronoiStyle, float smoothness, float seed, float highCut, float lowCut, int quality, float intensity, out vec3 displaced_normal) {\n\t\t\t\t\t\t\tvec3 displaced_position = distorted(position, normal, scale, intensity, offset, neighbor_offset, movement, voronoiStyle, smoothness, seed, highCut, lowCut, quality);\n\t\t\t\t\t\t\tvec3 tangent1 = orthogonal(normal);\n\t\t\t\t\t\t\tvec3 tangent2 = normalize(cross(normal, tangent1));\n\n \n \n \n \n \n\t\t\t\t\t\t\tvec3 nearby1 = position + tangent1;\n\t\t\t\t\t\t\tvec3 nearby2 = position + tangent2;\n\t\t\t\t\t\t\tvec3 distorted1 = distorted(nearby1, normal, scale, intensity, offset, neighbor_offset, movement, voronoiStyle, smoothness, seed, highCut, lowCut, quality);\n\t\t\t\t\t\t\tvec3 distorted2 = distorted(nearby2, normal, scale, intensity, offset, neighbor_offset, movement, voronoiStyle, smoothness, seed, highCut, lowCut, quality);\n\t\t\t\t\t\t\tdisplaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));\n\t\t\t\t\t\t\treturn displaced_position;\n\t\t\t\t\t\t}",[r,a]);n=e.include(o),i.push(this.scale.build(e,"f")),i.push(this.cropOrOffset.build(e,"v3")),i.push(this.movementOrTexture.build(e,"f")),i.push(this.voronoiStyle.build(e,"i")),i.push(this.smoothness.build(e,"f")),i.push(this.seed.build(e,"f")),i.push(this.highCut.build(e,"f")),i.push(this.lowCut.build(e,"f")),i.push(this.quality.build(e,"i"));break}}return i.push(this.intensity.build(e,"f")),i.push("displaced_normal"),e.format(n+"("+i.join(",")+")",this.getType(e),t)}return console.warn("VertexDisplacementNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},$s=js;$s.Nodes=function(){let e=new ki("vec3 orthogonal(vec3 v) {\n\t\t\t\treturn normalize(abs(v.x) > abs(v.z) ? vec3(-v.y, v.x, 0.0) : vec3(0.0, -v.z, v.y));\n\t\t\t}"),t=new ki("float displacementMapTexture(sampler2D tex, float crop, vec2 uv, mat3 mat, vec2 offset) {\n\t\t\t\tvec2 uvs = (mat * vec3(uv * 2.0 - 1.0, 1.0) / 2.0 + 0.5).xy + offset;\n\t\t\t\tvec4 tmp = texture2D(tex, uvs);\n\t\t\t\tvec3 col = tmp.rgb;\n\t\t\t\tif (crop > 0.5) {\n\t\t\t\t\tif ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {\n\t\t\t\t\t\treturn 0.0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn col.r;\n\t\t\t}");return{map:new ki("vec3 vertexDisplacementMap(vec3 position, vec3 normal, sampler2D tex, vec2 uv, float crop, mat3 mat, float intensity, out vec3 displaced_normal) {\n\t\t\t\tvec3 displaced_position = position + normal * displacementMapTexture(tex, crop, uv, mat, vec2(0.0)) * intensity;\n\t\t\t\tvec3 tangent1 = normalize(orthogonal(normal));\n\t\t\t\tvec3 tangent2 = normalize(cross(normal, tangent1));\n\t\t\t\tvec3 nearby1 = position + tangent1 * 0.1;\n\t\t\t\tvec3 nearby2 = position + tangent2 * 0.1;\n\t\t\t\tvec3 distorted1 = nearby1 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity;\n\t\t\t\tvec3 distorted2 = nearby2 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity;\n\t\t\t\tdisplaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));\n\t\t\t\treturn displaced_position;\n\t\t\t}",[e,t])}}();var qs={normalRenderTarget:new ea,normalRenderTargetDepth:new ea,normalViewRenderTarget:new ea,transmissionRenderTarget:new ea,aspectRatio:new zi,transmissionSize:new zi(2048,2048),transmissionRenderTargetDepth:new ea,aoRenderTarget:new ea,aoEnabled:new es,pixelRatioNode:new ta(1),resolution:new zi,penumbraSize:new ts(x,.5),frameIndex:new wa(0),transmissionLod:new wa(2),taaEnabled:new es(!0)};for(let e of Object.values(qs))e.isRenderGlobal=!0;var Ys={spe_fogMode:new je(0),spe_fogHeightParams:new je(new Te(.005,.01,0))},Ks="\n#include <fog_pars_fragment>\n#ifdef USE_FOG\n\tuniform float spe_fogMode;\n\tuniform vec3 spe_fogHeightParams;\n\n\t// Analytic optical depth of an exponential height-fog layer along the\n\t// camera->fragment ray (see FogChunk.ts). fogWorldDelta = fragment -\n\t// camera in WORLD space, fogDist = its length. With x = falloff *\n\t// fogWorldDelta.y the integral collapses to camDensity * fogDist * F(x),\n\t// F(x) = (1 - e^-x)/x. F is evaluated on a sign-preserving |x| >= 1e-4:\n\t// that keeps F's x->0 limit of 1 (horizontal rays / falloff 0 degrade to\n\t// classic exponential fog) without a branch — deliberate, because the\n\t// WGSL twins' select() evaluates BOTH sides, so a guarded division, not\n\t// a branch, is what actually prevents inf/NaN there, and all four\n\t// implementations stay line-for-line identical.\n\tfloat speHeightFogFactor(const in vec3 fogWorldDelta, const in float fogDist) {\n\t\tfloat density = spe_fogHeightParams.x;\n\t\tfloat falloff = spe_fogHeightParams.y;\n\t\tfloat relY = cameraPosition.y - spe_fogHeightParams.z;\n\t\t// Density at the camera's own height, overflow-clamped: far below\n\t\t// the fog base the exponent explodes; the fog factor saturates to 1\n\t\t// long before, so the clamp is invisible.\n\t\tfloat camDensity = density * exp(clamp(-falloff * relY, -60.0, 60.0));\n\t\tfloat x = clamp(falloff * fogWorldDelta.y, -60.0, 60.0);\n\t\tfloat xSafe = (x >= 0.0 ? 1.0 : -1.0) * max(abs(x), 1e-4);\n\t\tfloat opticalDepth =\n\t\t\tcamDensity * fogDist * (1.0 - exp(-xSafe)) / xSafe;\n\t\treturn 1.0 - exp(-max(opticalDepth, 0.0));\n\t}\n#endif\n",Zs="\n#ifdef USE_FOG\n\tfloat speFogLinear = smoothstep(fogNear, fogFar, vFogDepth);\n\tvec3 speFogViewPos = -vViewPosition;\n\tfloat speFogDist = length(speFogViewPos);\n\tvec3 speFogWorldDelta = speFogViewPos * mat3(viewMatrix);\n\tfloat speFogHeight = speHeightFogFactor(speFogWorldDelta, speFogDist);\n\tfloat speFogWLinear = 1.0 - step(0.5, spe_fogMode) + step(1.5, spe_fogMode);\n\tfloat speFogWHeight = step(0.5, spe_fogMode);\n\tfloat speFogFactor = 1.0 -\n\t\t(1.0 - speFogLinear * speFogWLinear) *\n\t\t\t(1.0 - speFogHeight * speFogWHeight);\n\tgl_FragColor.rgb = mix(gl_FragColor.rgb, fogColor, speFogFactor);\n#endif\n",Js=class extends Di{constructor(){super("basic"),this.nodeType="Basic",this.color=new ba(D),this.shadingAlpha=new ta(1),this.shadingBlend=new wa(0),this.previousModelViewMatrix=new os,this.previouseProjectionMatrix=new os}get category(){return"phong"}generate(e){let t;if(e.isShader("vertex")){let n=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:qs.frameIndex}),e.mergeUniform({resolution:qs.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(Ht.merge([Ca.fog])),e.mergeUniform(Ys),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <morphtarget_pars_vertex>"].join("\n"));let i=["#include <beginnormal_vertex>","#include <morphnormal_vertex>","\n\t\t\t\t#include <skinbase_vertex>\n\t\t\t\t#include <skinnormal_vertex>\n\t\t\t\t#if !defined( USE_LAYER_DISPLACE )\n\t\t\t\t\t#include <defaultnormal_vertex>\n\t\t\t\t#endif\n\n\t\t\t\tvec3 displaced_position = position;\n\t\t\t\tvec3 displaced_normal = normal;\n\n\t\t\t\t#if defined( USE_LAYER_DISPLACE )\n\t\t\t\t\tvec3 transformed;\n\t\t\t\t\tvec3 transformedNormal;\n\t\t\t\t#endif\n\t\t\t\t","#include <normal_vertex>","\n\t\t\t\t#if !defined( USE_LAYER_DISPLACE )\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t#endif /* !USE_LAYER_DISPLACE */\n\t\t\t\t"];n&&i.push(n.code,n.result?"displaced_position = "+n.result+";":""),i.push("transformed = displaced_position;","#include <morphtarget_vertex>","#include <skinning_vertex>","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED","\tvNormal = transformedNormal;","#endif"),i.push("#include <project_vertex>","#include <fog_vertex>","#include <clipping_planes_vertex>","\tvViewPosition = - mvPosition.xyz;","#include <worldpos_vertex>"),i.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),t=i.join("\n")}else{void 0===this.color&&(this.color=new ba(D)),this.color.analyze(e,{slot:"color"}),this.alpha&&this.alpha.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"});let n=this.color.flow(e,"c",{slot:"color"}),i=this.alpha?this.alpha.flow(e,"f"):void 0,a=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0,r=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0;e.requires.transparent=void 0!==i,e.addParsCode(["varying vec3 vWPosition;",Ks,"#include <dithering_pars_fragment>","varying vec3 vViewPosition;","#include <normal_pars_fragment>"].join("\n"));let o=["#include <normal_fragment_begin>",n.code];i&&o.push(i.code,"#ifdef ALPHATEST"," if ( "+i.result+" <= ALPHATEST ) discard;","#endif"),r?o.push(r.code,`vec3 outgoingLight = ${n.result};`,`vec3 finalColor = spe_blend(outgoingLight, ${r.result}, 1.0, SPE_BLENDING_NORMAL);`):o.push(`vec3 finalColor = ${n.result};`);let s="1.0";this.mask&&(this.mask.analyze(e),s=`luminance(${this.mask.flow(e,"v3").result})`),i?o.push(`gl_FragColor = vec4( finalColor, accumAlpha * ${i.result} * ${s} );`):o.push("gl_FragColor = vec4("+n.result+", 1.0 );"),a&&o.push(`gl_FragColor.a *= ${a.result};`),o.push(Zs,"#include <dithering_fragment>"),t=o.join("\n")}return t}},Qs=class extends Di{constructor(){super("lambert"),this.nodeType="Lambert",this.color=new ba(D),this.emissive=new ba(0),this.emissiveIntensity=new ta(1),this.previousModelViewMatrix=new os,this.previouseProjectionMatrix=new os,this.shadingAlpha=new ta(1),this.shadingBlend=new wa(0),this.occlusion=new es(!0)}get category(){return"lambert"}build(e){let t;if(e.define("LAMBERT"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let n=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:qs.frameIndex}),e.mergeUniform({resolution:qs.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(Ht.merge([Ca.fog,Ca.lights])),e.mergeUniform(Ys),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","varying vec3 vLightFront;","varying vec3 vIndirectFront;","#ifndef DOUBLE_SIDED"," #define DOUBLE_SIDED","#endif","#ifdef DOUBLE_SIDED","\tvarying vec3 vLightBack;","\tvarying vec3 vIndirectBack;","#endif","#include <bsdfs>","#include <lights_pars_begin>","#include <color_pars_vertex>","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <morphtarget_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join("\n"));let i=["#include <beginnormal_vertex>","#include <morphnormal_vertex>","\n\t\t\t\t#include <skinbase_vertex>\n\t\t\t\t#include <skinnormal_vertex>\n\t\t\t\t#ifndef USE_LAYER_DISPLACE\n\t\t\t\t\t#include <defaultnormal_vertex>\n\t\t\t\t#endif\n\n\t\t\t\tvec3 displaced_position = position;\n\t\t\t\tvec3 displaced_normal = objectNormal;\n\n\t\t\t\t#ifdef USE_LAYER_DISPLACE\n\t\t\t\t\tvec3 transformed;\n\t\t\t\t\tvec3 transformedNormal;\n\t\t\t\t#endif\n\t\t\t\t","#include <normal_vertex>","\n\t\t\t\t#ifndef USE_LAYER_DISPLACE\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t#endif\n\t\t\t\t"];n&&i.push(n.code,n.result?"displaced_position = "+n.result+";":""),i.push("transformed = displaced_position;","#include <morphtarget_vertex>","#include <skinning_vertex>","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),i.push("\t#include <project_vertex>","\t#include <clipping_planes_vertex>","\tvViewPosition = - mvPosition.xyz;","\t#include <worldpos_vertex>","\n\t\t\t\t\tvec3 diffuse = vec3( 1.0 );\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\tstruct GeometricContext { vec3 position; vec3 normal; vec3 viewDir; };\n\t\t\t\t\tGeometricContext geometry;\n\t\t\t\t\tgeometry.position = mvPosition.xyz;\n\t\t\t\t\tgeometry.normal = normalize( transformedNormal );\n\t\t\t\t\tgeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\n\t\t\t\t"),i.push("\n\t\t\t\t\tGeometricContext backGeometry;\n\t\t\t\t\tbackGeometry.position = geometry.position;\n\t\t\t\t\tbackGeometry.normal = -geometry.normal;\n\t\t\t\t\tbackGeometry.viewDir = geometry.viewDir;\n\t\t\t\t\tvLightFront = vec3( 0.0 );\n\t\t\t\t\tvIndirectFront = vec3( 0.0 );\n\t\t\t\t\t#ifdef DOUBLE_SIDED\n\t\t\t\t\t\tvLightBack = vec3( 0.0 );\n\t\t\t\t\t\tvIndirectBack = vec3( 0.0 );\n\t\t\t\t\t#endif\n\t\t\t\t\tIncidentLight directLight;\n\t\t\t\t\tfloat dotNL;\n\t\t\t\t\tvec3 directLightColor_Diffuse;\n\t\t\t\t\tvIndirectFront += getAmbientLightIrradiance( ambientLightColor );\n\t\t\t\t\t#if defined( USE_LIGHT_PROBES )\n\t\t\t\t\t\tvIndirectFront += getLightProbeIrradiance( lightProbe, geometry.normal );\n\t\t\t\t\t#endif\n\t\t\t\t\t#ifdef DOUBLE_SIDED\n\t\t\t\t\t\tvIndirectBack += getAmbientLightIrradiance( ambientLightColor );\n\t\t\t\t\t\t#if defined( USE_LIGHT_PROBES )\n\t\t\t\t\t\t\tvIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry.normal );\n\t\t\t\t\t\t#endif\n\t\t\t\t\t#endif\n\t\t\t\t\t#if NUM_POINT_LIGHTS > 0\n\t\t\t\t\t\t#pragma unroll_loop_start\n\t\t\t\t\t\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\t\t\t\t\t\tgetPointLightInfo( pointLights[ i ], geometry.position, directLight );\n\t\t\t\t\t\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\t\t\t\t\t\tdirectLightColor_Diffuse = directLight.color;\n\t\t\t\t\t\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t\t\t\t\t\t#ifdef DOUBLE_SIDED\n\t\t\t\t\t\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t\t\t\t\t\t#endif\n\t\t\t\t\t\t}\n\t\t\t\t\t\t#pragma unroll_loop_end\n\t\t\t\t\t#endif\n\t\t\t\t\t#if NUM_SPOT_LIGHTS > 0\n\t\t\t\t\t\t#pragma unroll_loop_start\n\t\t\t\t\t\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\t\t\t\t\t\tgetSpotLightInfo( spotLights[ i ], geometry.position, directLight );\n\t\t\t\t\t\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\t\t\t\t\t\tdirectLightColor_Diffuse = directLight.color;\n\t\t\t\t\t\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t\t\t\t\t\t#ifdef DOUBLE_SIDED\n\t\t\t\t\t\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t\t\t\t\t\t#endif\n\t\t\t\t\t\t}\n\t\t\t\t\t\t#pragma unroll_loop_end\n\t\t\t\t\t#endif\n\t\t\t\t\t#if NUM_DIR_LIGHTS > 0\n\t\t\t\t\t\t#pragma unroll_loop_start\n\t\t\t\t\t\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\t\t\t\t\t\tgetDirectionalLightInfo( directionalLights[ i ], directLight );\n\t\t\t\t\t\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\t\t\t\t\t\tdirectLightColor_Diffuse = directLight.color;\n\t\t\t\t\t\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t\t\t\t\t\t#ifdef DOUBLE_SIDED\n\t\t\t\t\t\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t\t\t\t\t\t#endif\n\t\t\t\t\t\t}\n\t\t\t\t\t\t#pragma unroll_loop_end\n\t\t\t\t\t#endif\n\t\t\t\t\t#if NUM_HEMI_LIGHTS > 0\n\t\t\t\t\t\t#pragma unroll_loop_start\n\t\t\t\t\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\t\t\t\t\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );\n\t\t\t\t\t\t\t#ifdef DOUBLE_SIDED\n\t\t\t\t\t\t\t\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry.normal );\n\t\t\t\t\t\t\t#endif\n\t\t\t\t\t\t}\n\t\t\t\t\t\t#pragma unroll_loop_end\n\t\t\t\t\t#endif\n\t\t\t\t","\t#include <shadowmap_vertex>","\t#include <fog_vertex>"),i.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),t=i.join("\n")}else{e.mergeUniform({penumbraSize:qs.penumbraSize}),e.mergeUniform({frameIndex:qs.frameIndex}),e.mergeUniform({aoMap:qs.aoRenderTarget}),e.mergeUniform({aoEnabled:qs.aoEnabled}),void 0===this.color&&(this.color=new ba(D)),this.color.analyze(e,{slot:"color"}),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);let n=this.color.flow(e,"c",{slot:"color"}),i=this.emissive.flow(e,"c",{slot:"emissive"}),a=this.emissiveIntensity.flow(e,"f",{slot:"emissive"}),r=this.occlusion.flow(e,"b",{slot:"occlusion"}),o=this.shadingAlpha.flow(e,"f"),s=this.shadingBlend.flow(e,"i"),l=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,c=this.alpha?this.alpha.flow(e,"f"):void 0,d=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0;e.requires.transparent=void 0!==c,e.addParsCode([`uniform float penumbraSize[${x}];`,"uniform sampler2D aoMap;","uniform bool aoEnabled;","varying vec3 vViewPosition;","varying vec3 vWPosition;","varying vec3 vLightFront;","varying vec3 vIndirectFront;","#ifndef DOUBLE_SIDED"," #define DOUBLE_SIDED","#endif","#include <normal_pars_fragment>","#ifdef DOUBLE_SIDED","\tvarying vec3 vLightBack;","\tvarying vec3 vIndirectBack;","#endif","#include <bsdfs>","#include <lights_pars_begin>",Ks,"#include <shadowmap_pars_fragment>","#include <shadowmask_pars_fragment>","#include <clipping_planes_pars_fragment>","#include <dithering_pars_fragment>"].join("\n"));let u=["#include <normal_fragment_begin>","\n\t\t\t\t\n\t\t\t\tvec3 viewdx = dFdx(vViewPosition);\n\t\t\t\tvec3 viewdy = dFdy(vViewPosition);\n\t\t\t\tvec3 faceNormal = normalize(cross(viewdx, viewdy));\n\t\t\t\tbool isFrontFacing = (dot(normal, faceNormal) >= 0.0);\n\t\t\t\t","#include <clipping_planes_fragment>"];u.push(n.code,"vec3 diffuseColor = "+n.result+";","ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );"),c&&u.push(c.code,"#ifdef ALPHATEST","if ( "+c.result+" <= ALPHATEST ) discard;","#endif"),u.push("#ifdef DOUBLE_SIDED","\treflectedLight.indirectDiffuse += ( isFrontFacing ) ? vIndirectFront : vIndirectBack;","#else","\treflectedLight.indirectDiffuse += vIndirectFront;","#endif","#ifdef USE_LIGHTMAP","\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );","\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity;","#endif","reflectedLight.indirectDiffuse *= BRDF_Lambert( diffuseColor.rgb );","#ifdef DOUBLE_SIDED","\treflectedLight.directDiffuse = ( isFrontFacing ) ? vLightFront : vLightBack;","#else","\treflectedLight.directDiffuse = vLightFront;","#endif","reflectedLight.directDiffuse *= BRDF_Lambert( diffuseColor.rgb ) * getShadowMask();"),i&&u.push(i.code,"reflectedLight.directDiffuse += "+i.result+" * "+a.result+";"),u.push("vec3 ao = aoEnabled && "+r.result+" ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);","vec3 outgoingLight = (reflectedLight.directDiffuse + reflectedLight.indirectDiffuse) ;");let f="1.0";this.mask&&(this.mask.analyze(e),f=`luminance(${this.mask.flow(e,"v3").result})`),u.push(`\n\t\t\t\tif (outgoingLight != diffuseColor) {\n\t\t\t\t\tfloat lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );\n\t\t\t\t\taccumAlpha += ( 1.0 - accumAlpha ) * ${o.result} * ${f} * lightAccu;\n\t\t\t\t\toutgoingLight = spe_blend( diffuseColor, outgoingLight, ${o.result} * ${f}, ${s.result} );\n\n\t\t\t\t\toutgoingLight *= ao;\n\t\t\t\t}\n\t\t\t\t`),l&&u.push(l.code,`outgoingLight = spe_blend(outgoingLight, ${l.result}, 1.0, SPE_BLENDING_NORMAL);`),c?u.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${c.result} );`):u.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),d&&u.push(`gl_FragColor.a *= ${d.result};`),u.push("#include <colorspace_fragment>",Zs,"#include <dithering_fragment>"),t=u.join("\n")}return t}},el={dHdxy:new ki("vec2 dHdxy(sampler2D bumpMap, vec2 bumpMapUv, float bumpScale) {\n\n \n vec2 dSTdx = dFdx(bumpMapUv);\n\n \n vec2 dSTdy = dFdy(bumpMapUv);\n \n \n float Hll = bumpScale * luminance(texture(bumpMap, bumpMapUv).rgb);\n float dBx = bumpScale * luminance(texture(bumpMap, bumpMapUv + dSTdx).rgb) - Hll;\n float dBy = bumpScale * luminance(texture(bumpMap, bumpMapUv + dSTdy).rgb) - Hll;\n \n return vec2( dBx, dBy );\n }"),perturbNormalArb:new ki("vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n vec3 vSigmaX = dFdx( surf_pos.xyz );\n vec3 vSigmaY = dFdy( surf_pos.xyz );\n vec3 vN = surf_norm; \n \n vN = normalize(vN);\n\n vec3 R1 = cross( vSigmaY, vN );\n vec3 R2 = cross( vN, vSigmaX );\n\n R1 = normalize(R1);\n R2 = normalize(R2);\n \n float fDet = dot( vSigmaX, R1 ) * faceDirection;\n \n vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n return normalize( abs( fDet ) * vN - vGrad );\n }")},tl=class extends Di{constructor(){super("standard"),this.nodeType="Standard",this.color=new ba(D),this.roughness=new ta(.3),this.metalness=new ta(0),this.reflectivity=new ta(.5),this.previousModelViewMatrix=new os,this.previouseProjectionMatrix=new os,this.shadingAlpha=new ta(1),this.shadingBlend=new wa(0),this.occlusion=new es(!0)}get category(){return"physical"}build(e){let t;if(e.define("STANDARD"),e.requires.lights=!0,e.extensions.derivatives=!0,e.extensions.shaderTextureLOD=!0,e.isShader("vertex")){let n=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:qs.frameIndex}),e.mergeUniform({resolution:qs.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(Ht.merge([Ca.fog,Ca.lights])),e.mergeUniform(Ys),Ca.LTC_1&&(e.uniforms.ltc_1={value:void 0},e.uniforms.ltc_2={value:void 0}),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <morphtarget_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join("\n"));let i=["#include <beginnormal_vertex>","#include <morphnormal_vertex>","\n\t\t\t\t#include <skinbase_vertex>\n\t\t\t\t#include <skinnormal_vertex>\n\t\t\t\t#if !defined( USE_LAYER_DISPLACE )\n\t\t\t\t\t#include <defaultnormal_vertex>\n\t\t\t\t#endif\n\n\t\t\t\tvec3 displaced_position = position;\n\t\t\t\tvec3 displaced_normal = objectNormal;\n\n\t\t\t\t#if defined( USE_LAYER_DISPLACE )\n\t\t\t\t\tvec3 transformed;\n\t\t\t\t\tvec3 transformedNormal;\n\t\t\t\t#endif\n\t\t\t\t","#include <normal_vertex>","\n\t\t\t\t#if !defined( USE_LAYER_DISPLACE )\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t#endif /* !USE_LAYER_DISPLACE */\n\t\t\t\t"];n&&i.push(n.code,n.result?"displaced_position = "+n.result+";":""),i.push("transformed = displaced_position;","#include <morphtarget_vertex>","#include <skinning_vertex>","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),i.push("#include <project_vertex>","#include <fog_vertex>","#include <clipping_planes_vertex>","\tvViewPosition = - mvPosition.xyz;","#include <worldpos_vertex>","#include <shadowmap_vertex>"),i.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),t=i.join("\n")}else{e.mergeUniform({penumbraSize:qs.penumbraSize}),e.mergeUniform({frameIndex:qs.frameIndex}),e.mergeUniform({aoMap:qs.aoRenderTarget}),e.mergeUniform({aoEnabled:qs.aoEnabled}),e.mergeUniform({dfgLUT:{value:null}});let n={gamma:!0};void 0===this.color&&(this.color=new ba(D)),this.color.analyze(e,{slot:"color",context:n}),this.roughness.analyze(e),this.metalness.analyze(e);let i=this.occlusion.flow(e,"b",{slot:"occlusion"});this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e),this.reflectivity&&this.reflectivity.analyze(e);let a=this.color.flow(e,"c",{slot:"color",context:n}),r=this.roughness.flow(e,"f"),o=this.metalness.flow(e,"f"),s=this.shadingAlpha.flow(e,"f"),l=this.shadingBlend.flow(e,"i"),c=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,d=this.alpha?this.alpha.flow(e,"f"):void 0,u=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0,f=this.reflectivity?this.reflectivity.flow(e,"f"):void 0;e.requires.transparent=void 0!==d,e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;",`uniform float penumbraSize[${x}];`,"uniform sampler2D aoMap;","uniform bool aoEnabled;","#include <normal_pars_fragment>","#include <dithering_pars_fragment>",Ks,"#include <bsdfs>","#include <lights_pars_begin>","#include <lights_physical_pars_fragment>","#include <shadowmap_pars_fragment>"].join("\n"));let p=["#include <clipping_planes_fragment>","\t#include <normal_fragment_begin>","\n\t\t\t\t\n\t\t\t\tvec3 viewdx = dFdx(vViewPosition);\n\t\t\t\tvec3 viewdy = dFdy(vViewPosition);\n\t\t\t\tvec3 faceNormal = normalize(cross(viewdx,viewdy));\n\t\t\t\tif (dot(normal, faceNormal) < 0.0) {\n\t\t\t\t\tnormal *= -1.0;\n\t\t\t\t}\n\t\t\t\t","\tPhysicalMaterial material;","\tmaterial.diffuseColor = vec3( 1.0 );"];if(this.bumpMap){e.include(el.dHdxy),e.include(el.perturbNormalArb);let t=this.bumpMap.texture.flow(e,"t"),n=this.bumpMap.flow(e,"v3"),i=this.bumpMapIntensity?this.bumpMapIntensity.flow(e,"f").result:"1.0",a="";a=4===this.bumpMap.projection.value?`\n\t\t\t\t\tvec3 bumpNormal = vec3(0.0);\n\t\t\t\t\t{\n\t\t\t\t\t\tvec2 uv0 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs0;\n\t\t\t\t\t\tvec2 uv1 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs1;\n\t\t\t\t\t\tvec2 uv2 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs2;\n\t\t\t\t\t\tvec3 weights = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_triplanarWeights;\n\n\t\t\t\t\t\tvec2 grad0 = dHdxy(${t.result}, uv0, ${i});\n\t\t\t\t\t\tvec3 n0 = perturbNormalArb(-vViewPosition, normal, grad0, faceDirection);\n\n\t\t\t\t\t\tvec2 grad1 = dHdxy(${t.result}, uv1, ${i});\n\t\t\t\t\t\tvec3 n1 = perturbNormalArb(-vViewPosition, normal, grad1, faceDirection);\n\n\t\t\t\t\t\tvec2 grad2 = dHdxy(${t.result}, uv2, ${i});\n\t\t\t\t\t\tvec3 n2 = perturbNormalArb(-vViewPosition, normal, grad2, faceDirection);\n\t\t\t\t\t\t\n\t\t\t\t\t\tbumpNormal = n0 * weights.z + n1 * weights.x + n2 * weights.y;\n\t\t\t\t\t\tbumpNormal = normalize(bumpNormal);\n\t\t\t\t\t}\n\n\t\t\t\t\tnormal = bumpNormal;\n\t\t\t\t\t`:`\n\t\t\t\t\tvec2 bumpMapCachedUv = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs;\n\t\t\t\t\tvec2 grad = dHdxy(${t.result}, bumpMapCachedUv, ${i});\n\t\t\t\t\tnormal = perturbNormalArb( - vViewPosition, normal, grad, faceDirection );\n\t\t\t\t\t`,p.push(`// Call the Texture Layer's function once here so that it writes out its procedural UV coordinates\n\t\t\t\t\t${n.result};\n\t\t\t\t\t${a}\n\t\t\t\t\t`)}if(p.push(a.code,"\tvec3 diffuseColor = "+a.result+";","\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );",o.code,"\tfloat metalnessFactor = "+o.result+";"),this.roughnessMap){let t=this.roughnessMap.texture.flow(e,"t"),n=this.roughnessMap.flow(e,"v3"),i="";i=4===this.roughnessMap.projection.value?`\n\t\t\t\t\tfloat roughnessChange = 1.0;\n\t\t\t\t\t{\n\t\t\t\t\t\tvec2 uv0 = g${this.roughnessMap.uuid.toString().replace(/-/g,"")}_writeUvs0;\n\t\t\t\t\t\tvec2 uv1 = g${this.roughnessMap.uuid.toString().replace(/-/g,"")}_writeUvs1;\n\t\t\t\t\t\tvec2 uv2 = g${this.roughnessMap.uuid.toString().replace(/-/g,"")}_writeUvs2;\n\t\t\t\t\t\tvec3 weights = g${this.roughnessMap.uuid.toString().replace(/-/g,"")}_triplanarWeights;\n\n\t\t\t\t\t\tfloat r0 = luminance(texture(${t.result}, uv0).rgb) * roughnessScale;\n\t\t\t\t\t\tfloat r1 = luminance(texture(${t.result}, uv1).rgb) * roughnessScale;\n\t\t\t\t\t\tfloat r2 = luminance(texture(${t.result}, uv2).rgb) * roughnessScale;\n\n\t\t\t\t\t\troughnessChange = (r0 * weights.z + r1 * weights.x + r2 * weights.y);\n\t\t\t\t\t}\n\t\t\t\t\tfloat roughnessFactor = roughnessChange * ${r.result};\n\t\t\t\t\t`:`\n\t\t\t\t\tvec2 roughnessMapCachedUv = g${this.roughnessMap.uuid.toString().replace(/-/g,"")}_writeUvs;\n\n\t\t\t\t\tvec4 vals = texture(${t.result}, roughnessMapCachedUv);\n\t\t\t\t\tfloat roughnessFactor = luminance(vals.rgb) * ${r.result};\n\t\t\t\t\t`,p.push(`// Call the Texture Layer's function once here so that it writes out its procedural UV coordinates\n\t\t\t\t\t${n.result};\n\n\t\t\t\t\tconst float roughnessScale = 1.0;\n\n\t\t\t\t\t${i}\n\t\t\t\t`)}else p.push(r.code,"\tfloat roughnessFactor = "+r.result+";");d&&p.push(d.code,"#ifdef ALPHATEST","\tif ( "+d.result+" <= ALPHATEST ) discard;","#endif"),p.push("vec3 dxy = max( abs( dFdx( normal ) ), abs( dFdy( normal ) ) );","float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );"),p.push("material.diffuseColor = diffuseColor;","material.diffuseContribution = diffuseColor * ( 1.0 - metalnessFactor );","material.metalness = metalnessFactor;","material.specularF90 = 1.0;","material.roughness = max( roughnessFactor, 0.0525 );","material.roughness += geometryRoughness;","material.roughness = min( material.roughness, 1.0 );","material.roughness = clamp( roughnessFactor, 0.04, 1.0 );"),f?p.push(f.code,"material.specularColor = vec3( 0.16 * pow2( "+f.result+" ) );","material.specularColorBlended = mix( material.specularColor, diffuseColor, metalnessFactor );"):p.push("material.specularColor = vec3( 0.04 );","material.specularColorBlended = mix( material.specularColor, diffuseColor, metalnessFactor );"),p.push("#include <lights_fragment_begin>"),p.push("#include <lights_fragment_end>"),p.push("vec3 ao = aoEnabled && "+i.result+" ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);","vec3 outgoingLight = ((reflectedLight.directDiffuse + reflectedLight.indirectDiffuse)) + reflectedLight.directSpecular + reflectedLight.indirectSpecular;");let h="1.0";this.mask&&(this.mask.analyze(e),h=`luminance(${this.mask.flow(e,"v3").result})`),p.push(`\n\t\t\t\tif (outgoingLight != diffuseColor) {\n\t\t\t\t\tfloat lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );\n\t\t\t\t\taccumAlpha += ( 1.0 - accumAlpha ) * ${s.result} * ${h} * lightAccu;\n\t\t\t\t\toutgoingLight = spe_blend( diffuseColor, outgoingLight, ${s.result} * ${h}, ${l.result} );\n\t\t\t\t\t\n\t\t\t\t\toutgoingLight *= ao;\n\t\t\t\t}\n\t\t\t\t`),c&&p.push(c.code,`outgoingLight = spe_blend(outgoingLight, ${c.result}, 1.0, SPE_BLENDING_NORMAL);`),d?p.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${d.result} );`):p.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),u&&p.push(`gl_FragColor.a *= ${u.result};`),p.push("#include <colorspace_fragment>",Zs,"#include <dithering_fragment>"),t=p.join("\n")}return t}},nl=class extends Di{constructor(){super("toon"),this.nodeType="Toon",this.color=new ba(D),this.specular=new ba(1118481),this.shininess=new ta(30),this.previousModelViewMatrix=new os,this.previouseProjectionMatrix=new os,this.shadingAlpha=new ta(1),this.shadingBlend=new wa(0)}get category(){return"toon"}build(e){let t;if(e.define("TOON"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let n=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:qs.frameIndex}),e.mergeUniform({resolution:qs.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(Ht.merge([Ca.fog,Ca.lights])),e.mergeUniform(Ys),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <morphtarget_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join("\n"));let i=["#include <beginnormal_vertex>","#include <morphnormal_vertex>","\n\t\t\t\t#include <skinbase_vertex>\n\t\t\t\t#include <skinnormal_vertex>\n\t\t\t\t#ifndef USE_LAYER_DISPLACE\n\t\t\t\t\t#include <defaultnormal_vertex>\n\t\t\t\t#endif\n\n\t\t\t\tvec3 displaced_position = position;\n\t\t\t\tvec3 displaced_normal = objectNormal;\n\n\t\t\t\t#ifdef USE_LAYER_DISPLACE\n\t\t\t\t\tvec3 transformed;\n\t\t\t\t\tvec3 transformedNormal;\n\t\t\t\t#endif\n\t\t\t\t","#include <normal_vertex>","\n\t\t\t\t#ifndef USE_LAYER_DISPLACE\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t#endif\n\t\t\t\t"];n&&i.push(n.code,n.result?"displaced_position = "+n.result+";":""),i.push("transformed = displaced_position;","#include <morphtarget_vertex>","#include <skinning_vertex>","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),i.push("\t#include <project_vertex>","\t#include <fog_vertex>","\t#include <clipping_planes_vertex>","\tvViewPosition = - mvPosition.xyz;","\t#include <worldpos_vertex>","\t#include <shadowmap_vertex>","\t#include <fog_vertex>"),i.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),t=i.join("\n")}else{e.mergeUniform({penumbraSize:qs.penumbraSize}),e.mergeUniform({frameIndex:qs.frameIndex}),e.mergeUniform({aoMap:qs.aoRenderTarget}),e.mergeUniform({aoEnabled:qs.aoEnabled}),void 0===this.color&&(this.color=new ba(D)),this.color.analyze(e,{slot:"color"}),this.specular.analyze(e),this.shininess.analyze(e),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);let n=this.color.flow(e,"c",{slot:"color"}),i=this.specular.flow(e,"c"),a=this.shininess.flow(e,"f"),r=this.shadingAlpha.flow(e,"f"),o=this.shadingBlend.flow(e,"i"),s=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,l=this.alpha?this.alpha.flow(e,"f"):void 0,c=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0;e.requires.transparent=void 0!==l,e.addParsCode([`uniform float penumbraSize[${x}];`,"uniform sampler2D aoMap;","uniform bool aoEnabled;","varying vec3 vWPosition;","#include <normal_pars_fragment>","#include <gradientmap_pars_fragment>",Ks,"#include <bsdfs>","#include <lights_pars_begin>","#include <dithering_pars_fragment>","\n\t\t\t\t\tvarying vec3 vViewPosition;\n\t\t\t\t\tstruct ToonMaterial {\n\t\t\t\t\t\tvec3\tdiffuseColor;\n\t\t\t\t\t\tvec3\tspecularColor;\n\t\t\t\t\t\tfloat\tspecularShininess;\n\t\t\t\t\t\tfloat\tspecularStrength;\n\t\t\t\t\t};\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\tvoid 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\t\t\t\t\t\tvec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n\n\t\t\t\t\t\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\t\t\t\t\t\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n\t\t\t\t\t}\n\t\t\t\t\tvoid 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\t\t\t\t\t\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\t\t\t\t\t}\n\t\t\t\t\t#define RE_Direct\t\t\t\tRE_Direct_Toon\n\t\t\t\t\t#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon\n\t\t\t\t\t#define Material_LightProbeLOD( material )\t(0)\n\t\t\t\t\t","#include <shadowmap_pars_fragment>","#include <bumpmap_pars_fragment>","#include <normalmap_pars_fragment>"].join("\n"));let d=["#include <normal_fragment_begin>","\n\t\t\t\t\n\t\t\t\tvec3 viewdx = dFdx(vViewPosition);\n\t\t\t\tvec3 viewdy = dFdy(vViewPosition);\n\t\t\t\tvec3 faceNormal = normalize(cross(viewdx,viewdy));\n\t\t\t\tif (dot(normal, faceNormal) < 0.0) {\n\t\t\t\t\tnormal *= -1.0;\n\t\t\t\t}\n\t\t\t\t","\tToonMaterial material;"];if(this.bumpMap){e.include(el.dHdxy),e.include(el.perturbNormalArb);let t=this.bumpMap.texture.flow(e,"t"),n=this.bumpMap.flow(e,"v3"),i=this.bumpMapIntensity?this.bumpMapIntensity.flow(e,"f").result:"1.0",a="";a=4===this.bumpMap.projection.value?`\n\t\t\t\t\tvec3 bumpNormal = vec3(0.0);\n\t\t\t\t\t{\n\t\t\t\t\t\tvec2 uv0 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs0;\n\t\t\t\t\t\tvec2 uv1 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs1;\n\t\t\t\t\t\tvec2 uv2 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs2;\n\t\t\t\t\t\tvec3 weights = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_triplanarWeights;\n\n\t\t\t\t\t\tvec2 grad0 = dHdxy(${t.result}, uv0, ${i});\n\t\t\t\t\t\tvec3 n0 = perturbNormalArb(-vViewPosition, normal, grad0, faceDirection);\n\n\t\t\t\t\t\tvec2 grad1 = dHdxy(${t.result}, uv1, ${i});\n\t\t\t\t\t\tvec3 n1 = perturbNormalArb(-vViewPosition, normal, grad1, faceDirection);\n\n\t\t\t\t\t\tvec2 grad2 = dHdxy(${t.result}, uv2, ${i});\n\t\t\t\t\t\tvec3 n2 = perturbNormalArb(-vViewPosition, normal, grad2, faceDirection);\n\t\t\t\t\t\t\n\t\t\t\t\t\tbumpNormal = n0 * weights.z + n1 * weights.x + n2 * weights.y;\n\t\t\t\t\t\tbumpNormal = normalize(bumpNormal);\n\t\t\t\t\t}\n\n\t\t\t\t\tnormal = bumpNormal;\n\t\t\t\t\t`:`\n\t\t\t\t\tvec2 bumpMapCachedUv = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs;\n\t\t\t\t\tvec2 grad = dHdxy(${t.result}, bumpMapCachedUv, ${i});\n\t\t\t\t\tnormal = perturbNormalArb( - vViewPosition, normal, grad, faceDirection );\n\t\t\t\t\t`,d.push(`// Call the Texture Layer's function once here so that it writes out its procedural UV coordinates\n\t\t\t\t\t${n.result};\n\t\t\t\t\t${a}\n\t\t\t\t\t`)}d.push(n.code,"\tvec3 diffuseColor = "+n.result+";","\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );",i.code,"\tvec3 specular = "+i.result+";",a.code,"\tfloat shininess = max( 0.0001, "+a.result+" );","\tfloat specularStrength = 1.0;"),l&&d.push(l.code,"#ifdef ALPHATEST","if ( "+l.result+" <= ALPHATEST ) discard;","#endif"),d.push("material.diffuseColor = diffuseColor;"),d.push("material.specularColor = specular;","material.specularShininess = shininess;","material.specularStrength = specularStrength;","#include <lights_fragment_begin>","#include <lights_fragment_end>"),d.push("vec3 ao = aoEnabled ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);","vec3 outgoingLight = ((reflectedLight.directDiffuse + reflectedLight.indirectDiffuse) * ao) + reflectedLight.directSpecular;");let u="1.0";this.mask&&(this.mask.analyze(e),u=`luminance(${this.mask.flow(e,"v3").result})`),d.push(`\n\t\t\t\tif (outgoingLight != diffuseColor) {\n\t\t\t\t\tfloat lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );\n\t\t\t\t\taccumAlpha += ( 1.0 - accumAlpha ) * ${r.result} * ${u} * lightAccu;\n\t\t\t\t\toutgoingLight = spe_blend( diffuseColor, outgoingLight, ${r.result} * ${u}, ${o.result} );\n\t\t\t\t}\n\t\t\t\t`),s&&d.push(s.code,`outgoingLight = spe_blend(outgoingLight, ${s.result}, 1.0, SPE_BLENDING_NORMAL);`),l?d.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${l.result} );`):d.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),c&&d.push(`gl_FragColor.a *= ${c.result};`),d.push("#include <colorspace_fragment>",Zs,"#include <dithering_fragment>"),t=d.join("\n")}return t}},il=class extends Di{constructor(){super("phong"),this.nodeType="Phong",this.color=new ba(D),this.specular=new ba(1118481),this.shininess=new ta(30),this.previousModelViewMatrix=new os,this.previouseProjectionMatrix=new os,this.shadingAlpha=new ta(1),this.shadingBlend=new wa(0),this.occlusion=new es(!0)}get category(){return"phong"}build(e){let t;if(e.define("PHONG"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let n=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:qs.frameIndex}),e.mergeUniform({resolution:qs.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(Ht.merge([Ca.fog,Ca.lights])),e.mergeUniform(Ys),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <morphtarget_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join("\n"));let i=["#include <beginnormal_vertex>","#include <morphnormal_vertex>","\n\t\t\t\t#include <skinbase_vertex>\n\t\t\t\t#include <skinnormal_vertex>\n\t\t\t\t#ifndef USE_LAYER_DISPLACE\n\t\t\t\t\t#include <defaultnormal_vertex>\n\t\t\t\t#endif\n\n\t\t\t\tvec3 displaced_position = position;\n\t\t\t\tvec3 displaced_normal = objectNormal;\n\n\t\t\t\t#ifdef USE_LAYER_DISPLACE\n\t\t\t\t\tvec3 transformed;\n\t\t\t\t\tvec3 transformedNormal;\n\t\t\t\t#endif\n\t\t\t\t","#include <normal_vertex>","\n\t\t\t\t#ifndef USE_LAYER_DISPLACE\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t#endif\n\t\t\t\t"];n&&i.push(n.code,n.result?"displaced_position = "+n.result+";":""),i.push("transformed = displaced_position;","#include <morphtarget_vertex>","#include <skinning_vertex>","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),i.push("\t#include <project_vertex>","\t#include <clipping_planes_vertex>","\tvViewPosition = - mvPosition.xyz;","\t#include <worldpos_vertex>","\t#include <shadowmap_vertex>","\t#include <fog_vertex>"),i.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),t=i.join("\n")}else{e.mergeUniform({penumbraSize:qs.penumbraSize}),e.mergeUniform({frameIndex:qs.frameIndex}),e.mergeUniform({aoMap:qs.aoRenderTarget}),e.mergeUniform({aoEnabled:qs.aoEnabled}),void 0===this.color&&(this.color=new ba(D)),this.color.analyze(e,{slot:"color"}),this.specular.analyze(e),this.shininess.analyze(e);let n=this.occlusion.flow(e,"b",{slot:"occlusion"});this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);let i=this.color.flow(e,"c",{slot:"color"}),a=this.specular.flow(e,"c"),r=this.shininess.flow(e,"f"),o=this.shadingAlpha.flow(e,"f"),s=this.shadingBlend.flow(e,"i"),l=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,c=this.alpha?this.alpha.flow(e,"f"):void 0,d=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0;e.requires.transparent=void 0!==c,e.addParsCode(["varying vec3 vWPosition;","uniform vec3 emissive;",`uniform float penumbraSize[${x}];`,"uniform sampler2D aoMap;","uniform bool aoEnabled;","#include <normal_pars_fragment>",Ks,"#include <bsdfs>","#include <lights_pars_begin>","#include <lights_phong_pars_fragment>","#include <shadowmap_pars_fragment>","#include <dithering_pars_fragment>"].join("\n"));let u=["#include <normal_fragment_begin>","\n\t\t\t\t\n\t\t\t\tvec3 viewdx = dFdx(vViewPosition);\n\t\t\t\tvec3 viewdy = dFdy(vViewPosition);\n\t\t\t\tvec3 faceNormal = normalize(cross(viewdx,viewdy));\n\t\t\t\tif (dot(normal, faceNormal) < 0.0) {\n\t\t\t\t\tnormal *= -1.0;\n\t\t\t\t}\n\t\t\t\t","\tBlinnPhongMaterial material;"];if(this.bumpMap){e.include(el.dHdxy),e.include(el.perturbNormalArb);let t=this.bumpMap.texture.flow(e,"t"),n=this.bumpMap.flow(e,"v3"),i=this.bumpMapIntensity?this.bumpMapIntensity.flow(e,"f").result:"1.0",a="";a=4===this.bumpMap.projection.value?`\n\t\t\t\t\tvec3 bumpNormal = vec3(0.0);\n\t\t\t\t\t{\n\t\t\t\t\t\tvec2 uv0 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs0;\n\t\t\t\t\t\tvec2 uv1 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs1;\n\t\t\t\t\t\tvec2 uv2 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs2;\n\t\t\t\t\t\tvec3 weights = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_triplanarWeights;\n\n\t\t\t\t\t\tvec2 grad0 = dHdxy(${t.result}, uv0, ${i});\n\t\t\t\t\t\tvec3 n0 = perturbNormalArb(-vViewPosition, normal, grad0, faceDirection);\n\n\t\t\t\t\t\tvec2 grad1 = dHdxy(${t.result}, uv1, ${i});\n\t\t\t\t\t\tvec3 n1 = perturbNormalArb(-vViewPosition, normal, grad1, faceDirection);\n\n\t\t\t\t\t\tvec2 grad2 = dHdxy(${t.result}, uv2, ${i});\n\t\t\t\t\t\tvec3 n2 = perturbNormalArb(-vViewPosition, normal, grad2, faceDirection);\n\t\t\t\t\t\t\n\t\t\t\t\t\tbumpNormal = n0 * weights.z + n1 * weights.x + n2 * weights.y;\n\t\t\t\t\t\tbumpNormal = normalize(bumpNormal);\n\t\t\t\t\t}\n\n\t\t\t\t\tnormal = bumpNormal;\n\t\t\t\t\t`:`\n\t\t\t\t\tvec2 bumpMapCachedUv = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs;\n\t\t\t\t\tvec2 grad = dHdxy(${t.result}, bumpMapCachedUv, ${i});\n\t\t\t\t\tnormal = perturbNormalArb( - vViewPosition, normal, grad, faceDirection );\n\t\t\t\t\t`,u.push(`// Call the Texture Layer's function once here so that it writes out its procedural UV coordinates\n\t\t\t\t\t${n.result};\n\t\t\t\t\t${a}\n\t\t\t\t\t`)}u.push(i.code,"\tvec3 diffuseColor = "+i.result+";","\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );","\tvec3 totalEmissiveRadiance = emissive;",a.code,"\tvec3 specular = "+a.result+";",r.code,"\tfloat shininess = max( 0.0001, "+r.result+" );","\tfloat specularStrength = 1.0;"),c&&u.push(c.code,"#ifdef ALPHATEST","if ( "+c.result+" <= ALPHATEST ) discard;","#endif"),u.push("material.diffuseColor = diffuseColor;"),u.push("material.specularColor = specular;","material.specularShininess = shininess;","material.specularStrength = specularStrength;","#include <lights_fragment_begin>","#include <lights_fragment_end>"),u.push("vec3 ao = aoEnabled && "+n.result+" ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);","vec3 outgoingLight = ((reflectedLight.directDiffuse + reflectedLight.indirectDiffuse)) + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;");let f="1.0";this.mask&&(this.mask.analyze(e),f=`luminance(${this.mask.flow(e,"v3").result})`),u.push(`\n\t\t\t\tif (outgoingLight != diffuseColor) {\n\t\t\t\t\tfloat lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );\n\t\t\t\t\taccumAlpha += ( 1.0 - accumAlpha ) * ${o.result} * ${f} * lightAccu;\n\t\t\t\t\toutgoingLight = spe_blend( diffuseColor, outgoingLight, ${o.result} * ${f}, ${s.result} );\n\t\t\t\t\t\n\t\t\t\t\toutgoingLight *= ao;\n\t\t\t\t}\n\t\t\t\t`),l&&u.push(l.code,`outgoingLight = spe_blend(outgoingLight, ${l.result}, 1.0, SPE_BLENDING_NORMAL);`),c?u.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${c.result});`):u.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),d&&u.push(`gl_FragColor.a *= ${d.result};`),u.push("#include <colorspace_fragment>",Zs,"#include <dithering_fragment>"),t=u.join("\n")}return t}},al=new Map;function rl(e,t){al.set(e,t)}var ol=new Set;function sl(e,t,n){if("isMask"===t||"rainbow"===e.type&&"noiseStrength"===t&&void 0!==e.noiseCompiledIn&&(!0===e.noiseForced||v(n))!==e.noiseCompiledIn)return!0;let i=g[e.type],a=_[e.type];if(void 0!==a){let i=e.color;if(a.includes(t)){let e=i[t]?.value?.length;if(void 0!==e&&e!==n.length)return!0}}return void 0!==i&&i.includes(t)}function ll(e,t){if(Array.isArray(t)){if(!Array.isArray(e)||e.length!==t.length)return!1;for(let[n,i]of t.entries()){let t=e[n];if("string"==typeof i||"number"==typeof i&&"string"==typeof t)return!0}return!1}let n="string"==typeof e,i="string"==typeof t;return n!==i||n&&i}function cl(e,t,n){let i=n.uniforms[`f${n.id}_texture`];if(!i)return!1;let a=!1,r=e;if("image"in r){let e=r.image,n=t.image(e),a=i;a.image instanceof w||a.image.deref(),a.image=n}if("video"in r){let e=r.video,n=t.video(e),a=i;a.image instanceof w||a.image.deref(),a.image=n}if("wrapping"in r&&(i.wrap=r.wrapping),"minFilter"in r&&(i.minFilter=r.minFilter),"magFilter"in r&&(i.magFilter=r.magFilter),"rotation"in r&&n.uniforms[`f${n.id}_rotation`])return n.uniforms[`f${n.id}_rotation`].value=(h(r.rotation??0,t)??0)*ce.DEG2RAD,a;if("repeat"in r||"offset"in r||"rotation"in r){let e="mat",i=n.uniforms[`f${n.id}_${e}`];if(!i)return a;if("repeat"in r){let e=r.repeat;ll(n.data.texture.repeat,e)&&(a=!0),i.repeat=fl(e,t).map((t,n)=>"string"==typeof e[n]?1/t:t)}if("offset"in r){let e=r.offset;ll(n.data.texture.offset,e)&&(a=!0),i.offset=fl(e,t).map((t,n)=>"string"==typeof e[n]?-t:t)}if("rotation"in r){let e=n.data.texture.rotation,o=r.rotation??0;(void 0===e||ll(e,o))&&(a=!0),i.rotation=h(o,t)??0}i.updateMatrix()}return a}var dl=(e,t)=>(e||(e=new Te),e.x=h(e.x,t)??0,e.y=h(e.y,t)??0,e.z=h(e.z,t)??0,e),ul=(e,t)=>(e||(e=new pe),e.x=h(e.x,t)??0,e.y=h(e.y,t)??0,e),fl=(e,t)=>{let n=e.map(e=>h(e,t)??0);return[n[0],n[1]]},pl=class{constructor(e,t,n,i,a){this.id=e,this.uuid=t,this.data=n,this.uniforms={};for(let e in i)this.uniforms[`f${this.id}_${e}`]=i[e];for(let e in n)_l(e,this,n,a)}get type(){return this.data.type}static create(e,t,i,a,r){if("light"===i.type)return vl.createLightLayer(e,t,i,a);if("color"===i.type)return function(e,t,i,a){let r=n(i,a),o=new ba(r.color??D),s=gl(r),l=new fs(o,s.alpha),c=new Qi(l.calpha,"f");return new hl(e,t,i,{color:o,...s},l,s.mode,c,s.isMask,a)}(e,t,i,a);let o=(s=i.type,al.get(s));var s;return o?o(e,t,i,a,r):(function(e){ol.has(e)||(ol.add(e),console.warn(`[spe] Material layer type "${e}" is not available in this runtime build (compiled out) — rendering flat red. Re-export the scene with its full layer set or load the full runtime build.`))}(i.type),function(e,t,n,i){let a=n,r=gl({alpha:"string"==typeof a.alpha?Number(i.getVariable(a.alpha)??100)/100:a.alpha,mode:a.mode,isMask:a.isMask}),o=new ba(1,0,0,1),s=new fs(o,r.alpha),l=new Qi(s.calpha,"f");return new hl(e,t,n,{color:o,...r},s,r.mode,l,r.isMask,i)}(e,t,i,a))}updateByOp(e,t,n){let i=e,a=!1;if(void 0===i.path[0]){for(let e of Object.keys(i.props))try{let n=this.data[e],i=t[e];if(Array.isArray(n)&&Array.isArray(i)){for(let[e,t]of i.entries()){let i=n[e];if("string"==typeof t||"number"==typeof t&&"string"==typeof i){a=!0;break}}if(a)break}else if("string"==typeof i&&"number"==typeof n||"number"==typeof i&&"string"==typeof n||"string"==typeof i&&"string"==typeof n&&i!==n){a=!0;break}}catch(e){console.error(e)}if(0===i.type)return"type"in i.props||"category"in i.props||"visible"in i.props||"noiseType"in i.props?(n.scene.markNeedsUpdateRendererDirty(),!0):function(e,t,n,i){let a=!1;for(let[r,o]of Object.entries(e)){if("bumpMap"===r||"roughnessMap"===r){a=!0;continue}if(!r||void 0===o)continue;if(_l(r,n,i,t)){"visible"===r&&"light"===n.type&&(a=!0);continue}n.visible=i.visible;let e=n.uniforms[`f${n.id}_${r}`];if(e&&!(e instanceof ns))switch(a=a||sl(n,r,o),e.constructor){case ba:if("string"==typeof o){let n=t.getColor(o);n&&(e.value=n);break}{let t=o;e.value instanceof b?e.value=new T(t.r,t.g,t.b,t.a):e.setRGBA(t);break}case Vi:if("string"==typeof o){let n=t.getColor(o);n&&(e.value=n);break}{let t=o;e.value instanceof b?e.value=new T(t.r,t.g,t.b,t.a):e.value.setRGBA(t.r,t.g,t.b,t.a);break}case zi:{let t=o;e.value.setX(t[0]),e.value.setY(t[1]);break}case Bi:{let t=o;e.value.setX(t[0]),e.value.setY(t[1]),e.value.setZ(t[2]);break}case ea:cl(o,t,n);break;case cs:e.value=o.map(e=>new Fe(...e));break;default:e.value=o}}return a}(i.props,n.shared,this,t)||a}else if("texture"===i.path[0])return!("texture"in t)&&!("video"in t)||cl(i.props,n.shared,this)||a;return a}dispose(){if(m(this)){let e=this.uniforms[`f${this.id}_texture`];if(!e)return!1;let t=e;t.image instanceof w||t.image.deref()}}hasValueByKey(e){return void 0!==this.uniforms[e]}hasValue(e){return this.hasValueByKey(`f${this.id}_${e}`)}setValue(e,t){let n=`f${this.id}_${e}`;if(this.hasValueByKey(n)&&void 0!==t&&(this.uniforms[n].value=t,"noiseStrength"===e&&!1===this.noiseCompiledIn&&"number"==typeof t&&0!==t&&void 0!==this.onNoiseMismatch)){let e=this.onNoiseMismatch;this.onNoiseMismatch=void 0,e(t)&&(this.noiseCompiledIn=!0)}}getNode(e){let t=`f${this.id}_${e}`;if(this.hasValueByKey(t))return this.uniforms[t]}getValue(e){let t=`f${this.id}_${e}`;if(this.hasValueByKey(t))return this.uniforms[t].value}getName(e){let t=/f\d+_(.*)/.exec(e);if(t&&t.length>1)return t[1];console.log(`Layer.getName: error ${e}`)}getNames(){let e=[];for(let t in this.uniforms){let n=this.getName(t);n&&e.push(n)}return e}},hl=class extends pl{constructor(e,t,n,i,a,r,o,s,l){super(e,t,n,i,l),this.params=i,this.color=a,this.mode=r,this.alpha=o,this.isMask=s}},ml=class extends pl{constructor(e,t,n,i,a,r){super(e,t,n,i,r),this.position=a}},vl=class extends pl{constructor(e,t,n,i,a,r){super(e,t,n,a,r),this.node=i}static createLightLayer(e,t,n,i){let a,r,o=new ta(p(n.alpha,i)),s=new wa(n.mode),l=new ta(n.bumpMapIntensity),c=new ta(p(n.alphaOverride,i));if(n.visible)if("lambert"===n.category){a=new Qs;let e=new ba(i.color(n.emissive)??0),t=new es(n.occlusion??!0);r={emissive:e,occlusion:t},a.emissive=e,a.occlusion=t}else if("toon"===n.category){a=new nl;let e=new ta(n.shininess??30),t=new ba(i.color(n.specular)??1118481);r={shininess:e,specular:t},a.shininess=e,a.specular=t}else if("physical"===n.category){a=new tl;let e=new ta(n.roughness??.3),t=new ta(n.metalness??0),i=new ta(n.reflectivity??.5),o=new es(n.occlusion??!0);r={roughness:e,metalness:t,reflectivity:i,occlusion:o},a.roughness=e,a.metalness=t,a.reflectivity=i,a.occlusion=o}else{a=new il;let e=new ta(n.shininess??30),t=new ba(void 0!==n.specular?i.color(n.specular)??1118481:1118481),o=new es(n.occlusion??!0);r={shininess:e,specular:t,occlusion:o},a.shininess=e,a.specular=t,a.occlusion=o}else a=new Js,r={};return a.alpha=new ta(1),a.shadingAlpha=o,a.shadingBlend=s,a.bumpMapIntensity=l,a.alphaOverride=c,r.alpha=a.shadingAlpha,r.mode=a.shadingBlend,r.bumpMapIntensity=a.bumpMapIntensity,r.alphaOverride=a.alphaOverride,new vl(e,t,n,a,r,i)}get category(){return this.node.category}};function gl(e){return{alpha:new ta(e.alpha??1),mode:new wa(e.mode??0),isMask:new es(e.isMask??!1)}}function _l(e,t,n,i){if("displace"===n.type&&("intensity"===e||"visible"===e)){let e=t.uniforms[`f${t.id}_intensity`];return e?(e.value=(h(n.intensity,i)??1)*(n.visible?1:0),e):void 0}if("displace"!==n.type&&("alpha"===e||"visible"===e)){let a=t.uniforms[`f${t.id}_alpha`];if(!a)return;if(a.value=p(n.alpha,i)*(n.visible?1:0),"outline"===n.type&&"visible"===e){let e=t.uniforms[`f${t.id}_compensation`];e&&(e.value=n.compensation&&n.visible)}return a}}function xl(e,t,n,i,a,r,o=[]){let s=n;for(let e of o)e in s&&(s=s[e]);for(let t of e)t in s&&a.getVariable(s[t],["material",r,"layer",i,...o,String(t)]);for(let e of t)e in s&&s[e].forEach((t,n)=>{a.getVariable(t,["material",r,"layer",i,...o,String(e),0===n?"x":1===n?"y":"z"])})}var Sl=class extends Xt{constructor(){super(void 0),this.isClassicNodeMaterial=!0,this.flatShading=!1,this.needsJitter=!0,this.shadersPatchedForShapeBlend=!1,this.nodeExtensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.nodeContextUuid=0,this.fog=!0,this.dithering=!0,this.vertexColors=!0,this.transparent=!0}customProgramCacheKey(){return""}},Tl=!1,bl=class extends Sl{constructor(e,t,n,i){super(),this.flatShading=e,this.side=t,this.wireframe=n,this.root=i}updateAfterBuild(){let e=this.root;this.lights=e.lights,this.vertexShader=e.vertexShader,this.fragmentShader=e.fragmentShader,Object.assign(this.defines,e.defines),Object.assign(this.uniforms,e.uniforms),this.nodeExtensions=e.nodeExtensions,this.transparent=e.transparent,this.cacheKey=e.customProgramCacheKey()+"flat"+this.flatShading+this.side}onBeforeCompile(e,t){this.root.onBeforeCompile(e)}get data(){return this.root.data}get category(){return this.root.category}get hasAO(){return this.root.hasAO}getFlavor(e,t,n,i){return this.root.getFlavor(e,t,n,i)}get layers(){return this.root.layers}get fragment(){return this.root.fragment}getLayersOfType(e){return this.root.getLayersOfType(e)}getLayerByUuid(e){return this.root.getLayerByUuid(e)}ensureRainbowNoiseCompiled(e,t){return this.root.ensureRainbowNoiseCompiled(e,t)}updateByOp(e,t,n){this.root.updateByOp(e,t,n)}nodeMaterialDispose(){this.root.nodeMaterialDispose()}},wl=class extends Sl{constructor(e,t,n=!0){super(),this.data=e,this.allowVariableSaves=n,this.layerIdGen=0,this.flavors=[],this.masks={},this.type="NodeMaterial",this.forceRainbowNoise=new Set,this.syntheticMapLayers=new Map,this.updaters=[],this.needsJitter=t.shared.needsJitter,Di.startContext(this),this.reset0(e,t),Di.endContext(this)}setTransparent(e,t){if(this.transparent!==e){this.transparent=e,this.needsUpdate=!0;for(let t of this.flavors)void 0!==t&&(t.transparent=e,t.needsUpdate=!0);t?.markNeedsUpdateRendererDirty()}}get nodeMaterial(){return this}getFlavor(e,t,n,i){let a=n?6:(e?3:0)+t;if(a+=7*((i?.resolutionLevel??0)-(i?.useChildrenColors?4:0)),0===a)return this;void 0===this.flavors&&(this.flavors=[]),a-=1;let r=this.flavors[a];return void 0===r&&(r=new bl(e,t,n,this),r.needsJitter=this.needsJitter,this.flavors[a]=r,r.flatShading=e,r.side=t,r.updateAfterBuild(),i&&(r.defines.SHAPEBLEND=i.resolutionLevel,r.defines.SHAPEBLEND_C=i.useChildrenColors?1:0)),r}get fragment(){return this.lightLayer.node}get category(){return this.lightLayer.category}get hasAO(){return this.lightLayer.getNode("occlusion")?.value??!1}ensureRainbowNoiseCompiled(e,t){let n=this.data.layers?.data(e);return void 0!==n&&"rainbow"===n.type&&(!this.forceRainbowNoise.has(e)&&!v(n.noiseStrength)||!1===this.getLayerByUuid(e)?.noiseCompiledIn)&&(this.forceRainbowNoise.add(e),Di.startContext(this),this.reset0(this.data,this.lastContext),Di.endContext(this),void 0!==t&&this.getLayerByUuid(e)?.setValue("noiseStrength",t),!0)}reset(e,t,n=!1){Di.startContext(this),(this.data!==e||n)&&this.reset0(e,t),Di.endContext(this)}reset0(e,t){this.lastContext=t,this.data=e;let n=e.layers??C.defaultTwoLayerData("phong").layers,i=[];for(let e of n)try{let n=pl.create(this.layerIdGen++,e.id,e.data,t.shared,this.forceRainbowNoise.has(e.id)?{forceRainbowNoise:!0}:void 0);if("rainbow"===n.type&&!1===n.noiseCompiledIn){let t=e.id;n.onNoiseMismatch=e=>this.ensureRainbowNoiseCompiled(t,e)}i.push(n)}catch(t){console.warn(`[spe] material layer '${e.data.type}' (${e.id}) failed to build — skipping this layer`,t)}this.layers=i,this.layers.reverse(),this.name=e.name??"Untitled Material",this.onUpdate(t.shared),this.setTransparent(f(e,t.shared),t.scene),this.saveVariableLocations(t)}onVariableUpdate(e,t,n){if("alphaOverride"===e[0])this.setTransparent(f(this.data,n.shared),n.scene),this.lightLayer.setValue("alphaOverride",Math.max(0,Math.min(Number(t)/100,1)));else if("layer"===e[0]){let i=e[1],a=e[2];if(i&&a){let r=this.layers.find(e=>e.uuid===i);if(r?.hasValue(a))if("alpha"===a)this.setTransparent(f(this.data,n.shared),n.scene),r.setValue(a,Math.max(0,Math.min(Number(t)/100,1)));else{let i=r.getValue(a),o=e[3],s=e[4];if(i instanceof Ue){let e,a=i[o];return"number"==typeof a?e=Number(t):a.isVector2&&(e=a.toArray(),"x"===s?e[0]=Number(t):"y"===s&&(e[1]=Number(t))),void cl({[o]:e},n.shared,r)}("x"===o||"y"===o||"z"===o)&&i.isVector3||("x"===o||"y"===o)&&i.isVector2?i[o]=Number(t):r.setValue(a,t)}}}}saveVariableLocations(e){if(!this.allowVariableSaves)return;let t=this.data.layers?.find(e=>"light"===e.data.type);t&&e.shared.getVariable(t.data.alphaOverride,["material",this.uuid,"alphaOverride"]),this.data.layers?.forEach(t=>{"alpha"in t.data&&"string"==typeof t.data.alpha&&e.shared.getVariable(t.data.alpha,["material",this.uuid,"layer",t.id,"alpha"]),"displace"===t.data.type?"noise"===t.data.displacementType?xl(["intensity","scale","movement","smoothness","seed","highCut","lowCut"],["offset"],t.data,t.id,e.shared,this.uuid):xl(["intensity"],[],t.data,t.id,e.shared,this.uuid):"depth"===t.data.type?xl(["near","far"],["origin","direction"],t.data,t.id,e.shared,this.uuid):"cavity"===t.data.type?xl(["ridge","valley"],[],t.data,t.id,e.shared,this.uuid):"fresnel"===t.data.type?xl(["bias","scale","intensity","factor"],[],t.data,t.id,e.shared,this.uuid):"dust"===t.data.type?xl(["coverage","softness","noiseStrength","noiseScale"],[],t.data,t.id,e.shared,this.uuid):"rainbow"===t.data.type?xl(["filmThickness","movement","noiseStrength","noiseScale"],["offset","wavelengths"],t.data,t.id,e.shared,this.uuid):"noise"===t.data.type?xl(["scale","move","seed","highCut","lowCut","smoothness"],["size","distortion","fA","fB"],t.data,t.id,e.shared,this.uuid):"pattern"===t.data.type?xl(["blending","size","variation","smoothness","zigzag","rotation"],["offset","frequency","vertical","horizontal"],t.data,t.id,e.shared,this.uuid):"outline"===t.data.type?xl(["outlineWidth","contourWidth","outlineThreshold","contourThreshold","outlineSmoothing","contourFrequency"],["contourDirection"],t.data,t.id,e.shared,this.uuid):"toon"===t.data.type?xl(["noiseStrength","noiseScale"],["offset","source"],t.data,t.id,e.shared,this.uuid):"transmission"===t.data.type?xl(["roughness","thickness","ior"],[],t.data,t.id,e.shared,this.uuid):"texture"===t.data.type||"video"===t.data.type?(xl([],["size"],t.data,t.id,e.shared,this.uuid),xl(["rotation"],["repeat","offset"],t.data,t.id,e.shared,this.uuid,["texture"])):"gradient"===t.data.type?xl(["angle"],["offset","morph"],t.data,t.id,e.shared,this.uuid):"matcap"===t.data.type&&xl(["rotation"],[],t.data,t.id,e.shared,this.uuid,["texture"])})}getLayersOfType(e){return this.layers.filter(t=>t.type===e)}getLayerByUuid(e){return this.layers.find(t=>t.uuid===e)}onUpdate(e){this.lightLayer=this.layers.find(e=>e instanceof vl),void 0===this.lightLayer&&(this.lightLayer=new vl(0,"",{...y.defaultData("light","phong"),visible:!1},new Js,{},e)),this.dispose();for(let e of this.flavors)e&&e.dispose();this.applyTextureMaps(e),this.applyMasks(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),this.build(),this.nodeContextUuid=0}syntheticMapNode(e,t){let n=this.syntheticMapLayers.get(e);if(void 0===n)try{let i=y.defaultData("texture"),a={...i,visible:!1,texture:{...i.texture,image:e.image,wrapping:e.wrapping??1e3,offset:e.offset??[0,0],repeat:e.repeat??[1,1],minFilter:e.minFilter??1008,magFilter:e.magFilter??1006}};n=pl.create(this.layerIdGen++,`mapImage${this.layerIdGen}`,a,t),this.syntheticMapLayers.set(e,n)}catch(e){return void console.warn("[spe] light-layer map image failed to build — skipped",e)}let i=n.color;return i instanceof gs?i:void 0}applyTextureMaps(e){let t=this.layers.find(e=>e instanceof vl);if(!t)return;let n=t.data,i=n.bumpMap,a=n.roughnessMap;t.node.bumpMap=void 0,t.node.roughnessMap=void 0;for(let e of this.syntheticMapLayers.values())e.dispose();this.syntheticMapLayers.clear(),M.is(i)&&(t.node.bumpMap=this.syntheticMapNode(i,e)),M.is(a)&&(t.node.roughnessMap=this.syntheticMapNode(a,e));let r=n;!Tl&&(void 0!==r.metalnessMap||void 0!==r.normalMap||void 0!==r.aoMap||void 0!==r.emissiveMap||void 0!==r.roughnessMapChannel&&"luminance"!==r.roughnessMapChannel||void 0!==r.clearcoat||void 0!==r.sheen||void 0!==r.ior||void 0!==r.iridescence||void 0!==r.emissive&&"object"==typeof r.emissive&&(r.emissive.r>0||r.emissive.g>0||r.emissive.b>0))&&(Tl=!0,console.warn("[spline] this document uses PBR material maps (metalness/normal/AO/emissive), which the classic WebGL pipeline does not render — the WebGPU renderer shows them"));for(let e=0;e<this.layers.length;++e){let n=this.layers[e];n instanceof hl&&n.color instanceof gs&&(n.uuid===i&&(t.node.bumpMap=n.color),n.uuid===a&&(t.node.roughnessMap=n.color))}}updateByOp(e,t,n){if(Di.startContext(this),void 0!==t?this.data=t:t=this.data,this.setTransparent(f(t,n.shared),n.scene),"layers"===e.path[0]){let i=n.shared,a=e.path[1];if(void 0===a)n.scene.markNeedsUpdateRendererDirty(),this.reset0(t,n);else{0===e.type&&void 0!==e.props.occlusion&&n.scene.markNeedsUpdateRendererDirty();let r=this.layers.find(e=>e.uuid===a);if(r){let o,s=t.layers.data(a);0===e.type&&("alpha"in e.props||"alphaOverride"in e.props)&&(o="alpha"in e.props?{...e.props,alpha:p(e.props.alpha,i,["material",this.uuid,"layer",a,"alpha"])}:{...e.props,alphaOverride:p(e.props.alphaOverride,i,["material",this.uuid,"alphaOverride"])}),r.updateByOp({...e,...o?{props:o}:{},path:e.path.slice(2)},s,n)&&this.reset0(t,n)}}}else this.reset0(t,n);Di.endContext(this)}applyMasks(){for(let e=0;e<this.layers.length;++e){let t=this.layers[e];t instanceof hl?t.color.mask=void 0:t instanceof vl&&(t.node.mask=void 0)}for(let e=0;e<this.layers.length;++e){let t=this.layers[e];if(t instanceof hl&&t.isMask.value&&t.data.visible&&e>0){let n=e-1,i=this.layers[n];i instanceof vl?i.node.mask=new aa(t.color,t.alpha,aa.MUL):i instanceof hl&&(i.isMask.value||(i.color.mask=new aa(t.color,t.alpha,aa.MUL)))}}}blendColors(){let e=this.layers.findIndex(e=>e instanceof hl),t=this.layers.findIndex(e=>e instanceof vl);if(-1!==e&&e<t){let n=this.layers[e].color;for(let i=e+1;i<t;++i){let e=this.layers[i];if(e instanceof hl){if(e.isMask.value)continue;n=new ds(n,e.color,e.alpha,e.mode)}}this.fragment.color=n}else this.fragment.color=void 0}blendAfterColors(){let e=new Qi("outgoingLight","f"),t=this.layers.findIndex(e=>e instanceof vl);if(this.layers.length>t+1){for(let n=t+1;n<this.layers.length;++n){let t=this.layers[n];if(t instanceof hl){if(t.isMask.value)continue;e=new ds(e,t.color,t.alpha,t.mode)}}this.fragment.afterColor=e}else this.fragment.afterColor=void 0}blendPositions(){let e=this.layers.filter(e=>e instanceof ml);if(e.length>0){let t=e[0].position;for(let n=1;n<e.length;++n)e[n]&&(t=new aa(t,e[n].position,aa.ADD),t=new aa(t,new ta(.5).setReadonly(!0),aa.MUL));this.fragment.position=t}else this.fragment.position=void 0}getDefines(){return this.defines}getUniforms(){return this.uniforms}getVertexShader(){return this.vertexShader}getFragmentShader(){return this.fragmentShader}onBeforeCompile(e){this.shapeBlendhack&&this.shapeBlendhack(this),e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.extensionDerivatives=!0===this.nodeExtensions.derivatives,e.extensionFragDepth=!0===this.nodeExtensions.fragDepth,e.extensionDrawBuffers=!0===this.nodeExtensions.drawBuffers,e.extensionShaderTextureLOD=!0===this.nodeExtensions.shaderTextureLOD}clampUniformsForPreview(e,t){let n=(e,t,n)=>Math.min(Math.max(e,t),n);for(let i of this.layers)if("displace"===i.type){let a=n(i.uniforms[`f${i.id}_intensity`].value,e,t);i.uniforms[`f${i.id}_intensity`].value=a}}updateFrame(e){for(let t=0;t<this.updaters.length;++t)e.updateNode(this.updaters[t])}build(){let e=new Ta;e.needsJitter=this.needsJitter,this.lights=this.lightLayer.data.visible,e.build(this.fragment,this.fragment),this.vertexShader=e.getCode("vertex"),this.fragmentShader=e.getCode("fragment"),this.defines=e.defines,this.uniforms=e.uniforms,this.nodeExtensions=e.extensions,this.updaters=e.updaters;for(let e of this.flavors)e&&e.updateAfterBuild();return this.shadersPatchedForShapeBlend=!1,this}nodeMaterialDispose(){this.layers.forEach(e=>e.dispose());for(let e of this.syntheticMapLayers.values())e.dispose();this.syntheticMapLayers.clear(),super.dispose();for(let e of this.flavors)e&&e.dispose()}assetsLoaded(){for(let e of this.layers)if(e instanceof hl){let t=e.params.texture;if(t instanceof as&&!t.image.loaded)return!1}for(let e of this.syntheticMapLayers.values()){let t=e.params?.texture;if(t instanceof as&&!t.image.loaded)return!1}return!0}};Object.defineProperties(Sl.prototype,{properties:{get:function(){return this.fragment.properties}}});var El=class extends wl{constructor(e,t,n){super(e,t,!1),this.isClassicSharedMaterial=!0,this.uuid=n,this.allowVariableSaves=!0,this.saveVariableLocations(t)}},Ml="\nvec2 receiverPlaneDepthBias(vec3 dcdx, vec3 dcdy)\n{\n float det = dcdx.x * dcdy.y - dcdx.y * dcdy.x;\n \n \n float invDet = 1.0 / (abs(det) < 1e-10 ? (det < 0.0 ? -1e-10 : 1e-10) : det);\n return vec2(\n (dcdy.y * dcdx.z - dcdx.y * dcdy.z) * invDet,\n (dcdx.x * dcdy.z - dcdy.x * dcdx.z) * invDet\n );\n}\n\n\n\n\nfloat receiverPlaneAdjust(vec2 dzduv, vec2 offset)\n{\n return clamp(dot(dzduv, offset), -0.05, 0.05);\n}\n",yl=globalThis,Cl=yl.__SPE_ORIGINAL_LIGHTS_FRAGMENT_BEGIN__??(yl.__SPE_ORIGINAL_LIGHTS_FRAGMENT_BEGIN__=ya.lights_fragment_begin),Rl=yl.__SPE_ORIGINAL_SHADOWMASK_PARS__??(yl.__SPE_ORIGINAL_SHADOWMASK_PARS__=ya.shadowmask_pars_fragment),Al=yl.__SPE_ORIGINAL_SHADOWMAP_PARS__??(yl.__SPE_ORIGINAL_SHADOWMAP_PARS__=ya.shadowmap_pars_fragment),Pl=null,Dl=()=>{let e=Al.replaceAll("vogelDiskSample","spStockVogelDiskSample").replaceAll("interleavedGradientNoise","spStockInterleavedGradientNoise"),t=e.indexOf("#if defined( SHADOWMAP_TYPE_PCF )"),n=e.indexOf("#elif defined( SHADOWMAP_TYPE_VSM )");if(t<0||n<=t)return e;let i=e.slice(t,n),a=i.replace(/texture\( shadowMap, vec3\( shadowCoord\.xy \+ spStockVogelDiskSample\( ([0-4]), 5, phi \) \* radius, shadowCoord\.z \) \)/g,"texture( shadowMap, vec3( shadowCoord.xy + spStockOffset$1, shadowCoord.z + receiverPlaneAdjust( spStockDzduv, spStockOffset$1 ) ) )"),r="float phi = spStockInterleavedGradientNoise( gl_FragCoord.xy ) * PI2;";return a!==i&&a.includes(r)?(i=a.replace(r,r+"\n\t\t\t\tvec2 spStockDzduv = receiverPlaneDepthBias( dFdx( shadowCoord.xyz ), dFdy( shadowCoord.xyz ) );\n\t\t\t\tvec2 spStockOffset0 = spStockVogelDiskSample( 0, 5, phi ) * radius;\n\t\t\t\tvec2 spStockOffset1 = spStockVogelDiskSample( 1, 5, phi ) * radius;\n\t\t\t\tvec2 spStockOffset2 = spStockVogelDiskSample( 2, 5, phi ) * radius;\n\t\t\t\tvec2 spStockOffset3 = spStockVogelDiskSample( 3, 5, phi ) * radius;\n\t\t\t\tvec2 spStockOffset4 = spStockVogelDiskSample( 4, 5, phi ) * radius;"),i=i.replace("#if defined( SHADOWMAP_TYPE_PCF )",Ml+"\n#if defined( SHADOWMAP_TYPE_PCF )"),e.slice(0,t)+i+e.slice(n)):e},Ll="\n\n // Linear Fade In\n float linearFadeIn(float t) {\n return t;\n }\n\n\n // linear fade out\n float linearFadeOut(float t) {\n return 1.0 - t;\n }\n \n float linearInOut(float t) {\n return t < 0.5 ? t : (1.0 - t); \n }\n\n // lerp\n float lerp(float a, float b, float t) {\n return a + (b - a) * t;\n }\n\n // Ease In Out Quart\n float exponentialInOut(float t) {\n return t < 0.4 ? lerp(0.0, 1.0, t / 0.4) :\n t > 0.6 ? lerp(1.0, 0.0, (t - 0.6) / 0.4) :\n 1.0;\n }\n\n // constant\n float constant(float t) {\n return 1.0;\n } \n",Ul=`\n uniform sampler2D uPosition;\n uniform float uSize;\n uniform float uSizeEnd;\n uniform vec3 uWorldOffset;\n uniform vec4 uWorldQuaternion;\n \n uniform float uRotation;\n uniform float uRotationEnd;\n uniform vec2 center;\n\n \n uniform float uRandScaleFactor;\n uniform float uRandRotationFactor;\n\n attribute vec2 ref;\n\n varying float v_LifeLeft; \n varying vec2 vUv;\n varying vec2 vRef;\n\n \n\nfloat rand(vec3 co){\n return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);\n}\n\nvec3 applyQuaternionToVector( vec4 q, vec3 v ){\n return v + 2.0 * cross( q.xyz, cross( q.xyz, v ) + q.w * v );\n}\n\nvec3 applyForce(vec3 force, float mass) {\n vec3 acceleration = force / mass;\n \n return acceleration;\n}\n\n ${Ll}\n`,Nl="\n uniform vec4 uColor; \n uniform vec4 uColor2; \n uniform sampler2D uTexture; \n varying float v_LifeLeft; \n varying vec2 vUv;\n varying vec2 vRef;\n\n float random(vec2 co) {\n return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);\n }\n "+Ll+" \n \nvec3 rgb2xyz (in vec3 rgb) {\n float r = rgb.r;\n\tfloat g = rgb.g;\n\tfloat b = rgb.b;\n\n\tr = r > 0.04045 ? pow(((r + 0.055) / 1.055), 2.4) : (r / 12.92);\n\tg = g > 0.04045 ? pow(((g + 0.055) / 1.055), 2.4) : (g / 12.92);\n\tb = b > 0.04045 ? pow(((b + 0.055) / 1.055), 2.4) : (b / 12.92);\n\n\tfloat x = (r * 0.4124) + (g * 0.3576) + (b * 0.1805);\n\tfloat y = (r * 0.2126) + (g * 0.7152) + (b * 0.0722);\n\tfloat z = (r * 0.0193) + (g * 0.1192) + (b * 0.9505);\n \n vec3 xyz = vec3(\n (r * 0.4124) + (g * 0.3576) + (b * 0.1805) * 100.0,\n (r * 0.2126) + (g * 0.7152) + (b * 0.0722) * 100.0,\n (r * 0.0193) + (g * 0.1192) + (b * 0.9505) * 100.0\n );\n return(xyz);\n}\n\nvec3 xyz2lab (in vec3 xyz) {\n\tfloat x = xyz.x / 95.047;\n\tfloat y = xyz.y / 100.0;\n\tfloat z = xyz.z / 108.883;\n\n\tx = x > 0.008856 ? pow(x, 1.0 / 3.0) : (7.787 * x) + (16.0 / 116.0);\n\ty = y > 0.008856 ? pow(y, 1.0 / 3.0) : (7.787 * y) + (16.0 / 116.0);\n\tz = z > 0.008856 ? pow(z, 1.0 / 3.0) : (7.787 * z) + (16.0 / 116.0);\n\n vec3 lab = vec3((116.0 * y) - 16.0, 500.0 * (x - y), 200.0 * (y - z));\n return(lab);\n}\n\nvec3 rgb2lab(in vec3 rgb) {\n vec3 xyz = rgb2xyz(rgb);\n vec3 lab = xyz2lab(xyz);\n return(lab);\n}\n\nvec3 xyz2rgb (in vec3 xyz) {\n\tfloat x = xyz.x / 100.0;\n\tfloat y = xyz.y / 100.0;\n\tfloat z = xyz.z / 100.0;\n\t\n \n\tfloat r = (x * 3.2406) + (y * -1.5372) + (z * -0.4986);\n\tfloat g = (x * -0.9689) + (y * 1.8758) + (z * 0.0415);\n\tfloat b = (x * 0.0557) + (y * -0.2040) + (z * 1.0570);\n\n\tr = r > 0.0031308 ? ((1.055 * pow(r, 1.0 / 2.4)) - 0.055) : r * 12.92;\n\tg = g > 0.0031308 ? ((1.055 * pow(g, 1.0 / 2.4)) - 0.055) : g * 12.92;\n\tb = b > 0.0031308 ? ((1.055 * pow(b, 1.0 / 2.4)) - 0.055) : b * 12.92;\n\n\tr = min(max(0.0, r), 1.0);\n\tg = min(max(0.0, g), 1.0);\n\tb = min(max(0.0, b), 1.0);\n\n\treturn(vec3(r, g, b));\n}\n\nvec3 lab2xyz (in vec3 lab) {\n float l = lab.x;\n\tfloat a = lab.y;\n\tfloat b = lab.z;\n\n \tfloat y = (l + 16.0) / 116.0;\n\tfloat x = a / 500.0 + y;\n\tfloat z = y - b / 200.0;\n\n\tfloat y2 = pow(y, 3.0);\n\tfloat x2 = pow(x, 3.0);\n\tfloat z2 = pow(z, 3.0);\n\n \ty = y2 > 0.008856 ? y2 : (y - 16.0 / 116.0) / 7.787;\n\tx = x2 > 0.008856 ? x2 : (x - 16.0 / 116.0) / 7.787;\n\tz = z2 > 0.008856 ? z2 : (z - 16.0 / 116.0) / 7.787;\n\n\tx *= 95.047;\n\ty *= 100.0;\n\tz *= 108.883;\n\n\treturn(vec3(x, y, z));\n}\nvec3 lab2rgb (in vec3 lab) {\n vec3 xyz = lab2xyz(lab);\n vec3 rgb = xyz2rgb(xyz);\n return(rgb);\n}\n\n\n\n",Il=class extends Xt{constructor(e,t){super(),this.needsJitter=!0,this.type="ParticleMaterial",this.nodeExtensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.easeOpacity="linearFadeIn",this.easeSize="linearFadeIn",this.useSizeEnd=!1,this.isColoringRandom=!1,this.init(e,t),this.context=t}reset(){}init(e,t){this.transparent=!0,this.depthTest=!0,this.depthWrite=!1,this.easeOpacity=e.ease,this.easeSize=e.easeSize,this.layers=[],Di.startContext(Di.globalContext),this.lightLayer=new vl(0,"",{...y.defaultData("light","phong"),visible:!1},new Js,{},t.shared),Di.endContext(Di.globalContext),this.build()}updateState(e){void 0!==e.coloring&&(this.isColoringRandom="random"===e.coloring),void 0!==e.color&&(e.color instanceof Array?this.uniforms.uColor.value=e.color:this.uniforms.uColor.value=this.context.shared.color(e.color)),void 0!==e.color2&&(e.color2 instanceof Array?this.uniforms.uColor2.value=e.color2:this.uniforms.uColor2.value=this.context.shared.color(e.color2)),void 0!==e.size&&(this.uniforms.uSize.value=e.size[0],this.uniforms.uSizeEnd.value=e.size[1],e.size[0]!==e.size[1]?this.useSizeEnd=!0:this.useSizeEnd=!1),void 0!==e.ease&&(this.easeOpacity=e.ease,this.build()),void 0!==e.easeSize&&(this.easeSize=e.easeSize,this.build()),this.needsUpdate=!0}onBeforeCompile(e){this.build(),e.defines=this.defines,e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader}build(){let e=new Ta;return e.needsJitter=this.needsJitter,e.addFragmentParsCode("\nlayout(location = 1) out vec4 gVelocity;\n"),e.buildShader("vertex",this.fragment),e.buildShader("fragment",this.fragment),e.addFragmentFinalCode("\n \n if (gl_FragColor.a <= 0.0) discard;\n\n gVelocity = vec4(0.0, 0.0, 0.0, 1.0);\n"),this.isColoringRandom&&e.define("USE_RANDOM_COLORING"),this.useSizeEnd&&e.define("USE_SIZE_END"),e.addVertexParsCode(Ul),e.addFragmentParsCode(Nl),e.addVertexFinalCode((({easeSize:e="linearFadeOut"})=>`\n vUv = uv; \n vRef = ref;\n \n float lifeLeft = texture2D(uPosition, ref).w;\n v_LifeLeft = lifeLeft;\n \n vec3 pos = texture2D(uPosition, ref).rgb - uWorldOffset;\n \n pos = applyQuaternionToVector(uWorldQuaternion, pos); \n \n #ifdef USE_SIZE_END\n \n float t = 1. - lifeLeft;\n float currentSize = mix(uSize, uSizeEnd, t); \n vec3 scaledPosition = position * vec3(currentSize);\n #else\n \n float easeSize = ${e}(1. - lifeLeft);\n \n vec3 scaledPosition = position * vec3(uSize * easeSize);\n #endif\n\n \n vec2 scale;\n scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) ); \n \n float randRef = rand(ref);\n scale *= (1.0 - (uRandScaleFactor * randRef));\n \n float randRotation = 2.0 * PI * ( uRandRotationFactor * randRef);\n float originalRotation = (1.0 - uRotation) * 2.0 * PI;\n float originalRotationEnd = (1.0 - uRotationEnd) * 2.0 * PI;\n \n float finalRotation = mix(originalRotation + randRotation, originalRotationEnd + randRotation, lifeLeft);\n\n vec2 alignedPosition = ( scaledPosition.xy - ( center - vec2( 0.5 ) ) ) * scale;\n vec2 rotatedPosition;\n rotatedPosition.x = cos( finalRotation ) * alignedPosition.x - sin( finalRotation ) * alignedPosition.y;\n rotatedPosition.y = sin( finalRotation ) * alignedPosition.x + cos( finalRotation ) * alignedPosition.y;\n \n mat4 instanceMatrix = mat4(\n vec4(1.0, 0.0, 0.0, 0.0),\n vec4(0.0, 1.0, 0.0, 0.0),\n vec4(0.0, 0.0, 1.0, 0.0),\n vec4(pos.x, pos.y, pos.z, 1.0)\n ); \n\n mvPosition = modelViewMatrix * instanceMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n mvPosition.xy += rotatedPosition;\n gl_Position = projectionMatrix * mvPosition; \n`)({easeSize:this.easeSize})),e.addFragmentFinalCode((({easeOpacity:e="linearFadeOut"})=>` \n \n if (v_LifeLeft <= 0.005 ) {\n discard;\n }\n\n #ifdef USE_RANDOM_COLORING\n float randVal = random(vRef); \n vec4 color = mix(uColor, uColor2, randVal); \n #else\n vec4 color = mix(uColor, uColor2, 1. - v_LifeLeft);\n #endif\n\n \n float finalAlpha = ${e}(1. - v_LifeLeft); \n vec4 textureColor = texture2D(uTexture, vUv).rgba; \n finalColor = textureColor.rgb * color.rgb;\n finalAlpha = color.a * textureColor.a * finalAlpha;\n \n gl_FragColor = vec4(finalColor, finalAlpha); \n\n`)({easeOpacity:this.easeOpacity})),this.vertexShader=e.getCode("vertex"),this.fragmentShader=e.getCode("fragment"),this.defines=e.defines,this.uniforms={...e.uniforms,...this.uniforms},this.nodeExtensions=e.extensions,this}get nodeMaterial(){return this}get fragment(){return this.lightLayer.node}getDefines(){return this.defines}nodeMaterialDispose(){this.layers.forEach(e=>e.dispose()),super.dispose()}},Ol=new ie(-1,1,1,-1,0,1),Fl=new class extends Kt{constructor(){super(),this.setAttribute("position",new Vt([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Vt([0,2,0,0,2,0],2))}},zl=class{constructor(e){this._mesh=new Pn(Fl,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,Ol)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}},Bl=class{constructor(e,t,n){this.variables=[],this.currentTextureIndex=0;let i=ee,a={passThruTexture:{value:null}},r=l("uniform sampler2D passThruTexture;\n\nvoid main() {\n\n\tvec2 uv = gl_FragCoord.xy / resolution.xy;\n\n\tgl_FragColor = texture2D( passThruTexture, uv );\n\n}\n",a),o=new zl(r);function s(n){n.defines.resolution="vec2( "+e.toFixed(1)+", "+t.toFixed(1)+" )"}function l(e,t){let n=new Xt({name:"GPUComputationShader",uniforms:t=t||{},vertexShader:"void main()\t{\n\n\tgl_Position = vec4( position, 1.0 );\n\n}\n",fragmentShader:e});return s(n),n}this.setDataType=function(e){return i=e,this},this.addVariable=function(e,t,n){let i={name:e,initialValueTexture:n,material:this.createShaderMaterial(t),dependencies:null,renderTargets:[],wrapS:null,wrapT:null,minFilter:On,magFilter:On};return this.variables.push(i),i},this.setVariableDependencies=function(e,t){e.dependencies=t},this.init=function(){if(0===n.capabilities.maxVertexTextures)return"No support for vertex shader textures.";for(let n=0;n<this.variables.length;n++){let i=this.variables[n];i.renderTargets[0]=this.createRenderTarget(e,t,i.wrapS,i.wrapT,i.minFilter,i.magFilter),i.renderTargets[1]=this.createRenderTarget(e,t,i.wrapS,i.wrapT,i.minFilter,i.magFilter),this.renderTexture(i.initialValueTexture,i.renderTargets[0]),this.renderTexture(i.initialValueTexture,i.renderTargets[1]);let a=i.material,r=a.uniforms;if(null!==i.dependencies)for(let e=0;e<i.dependencies.length;e++){let t=i.dependencies[e];if(t.name!==i.name){let e=!1;for(let n=0;n<this.variables.length;n++)if(t.name===this.variables[n].name){e=!0;break}if(!e)return"Variable dependency not found. Variable="+i.name+", dependency="+t.name}r[t.name]={value:null},a.fragmentShader="\nuniform sampler2D "+t.name+";\n"+a.fragmentShader}}return this.currentTextureIndex=0,null},this.compute=function(){let e=this.currentTextureIndex,t=0===this.currentTextureIndex?1:0;for(let n=0,i=this.variables.length;n<i;n++){let i=this.variables[n];if(null!==i.dependencies){let t=i.material.uniforms;for(let n=0,a=i.dependencies.length;n<a;n++){let a=i.dependencies[n];t[a.name].value=a.renderTargets[e].texture}}this.doRenderTarget(i.material,i.renderTargets[t])}this.currentTextureIndex=t},this.getCurrentRenderTarget=function(e){return e.renderTargets[this.currentTextureIndex]},this.getAlternateRenderTarget=function(e){return e.renderTargets[0===this.currentTextureIndex?1:0]},this.dispose=function(){o.dispose();let e=this.variables;for(let t=0;t<e.length;t++){let n=e[t];n.initialValueTexture&&n.initialValueTexture.dispose();let i=n.renderTargets;for(let e=0;e<i.length;e++)i[e].dispose();n.material.dispose()}},this.addResolutionDefine=s,this.createShaderMaterial=l,this.createRenderTarget=function(n,a,r,o,s,l){return new Xe(n=n||e,a=a||t,{wrapS:r=r||Rn,wrapT:o=o||Rn,minFilter:s=s||On,magFilter:l=l||On,format:Ie,type:i,depthBuffer:!1})},this.createTexture=function(){let n=new Float32Array(e*t*4),i=new Bn(n,e,t,Ie,ee);return i.needsUpdate=!0,i},this.renderTexture=function(e,t){a.passThruTexture.value=e,this.doRenderTarget(r,t),a.passThruTexture.value=null},this.doRenderTarget=function(e,t){let i=n.getRenderTarget(),a=n.xr.enabled,s=n.shadowMap.autoUpdate;n.xr.enabled=!1,n.shadowMap.autoUpdate=!1,o.material=e,n.setRenderTarget(t),o.render(n),o.material=r,n.xr.enabled=a,n.shadowMap.autoUpdate=s,n.setRenderTarget(i)}}};function Vl(e,t,n,i){let a=n,r="texture"===a.type?null!=a.texture.image?i.uiBuffer(a.texture.image)??i.image(a.texture.image):i.getImage(""):i.video(a.texture.video),o=new as(r,a.texture.wrapping??("texture"===a.type?1e3:1001),a.texture.minFilter??1008,a.texture.magFilter??1006),s=new is(r),l=new ls(fl(a.texture.repeat??[1,1],i),fl(a.texture.offset??[0,0],i),h(a.texture.rotation??0,i)),c=new ta(a.crop?1:0),d=new wa(a.projection??0),u=new wa(["x","y","z"].indexOf(a.axis)??0),f=a.projectionAxis?["x","y","z"].indexOf(a.projectionAxis):-1,m=new wa(a.side??0),v=new zi(a.size?new pe(...fl(a.size,i)):new pe(100,100)),g=new ta(a.blending??0),_=new ta(p(a.alpha,i)),x=new wa(a.mode??0),S=new es(a.isMask??!1),T=new gs(o,s,c,d,u,m,v,g,l,_,x,S,f),b=new Qi(T.calpha,"f");return new hl(e,t,a,{texture:o,textureSize:s,crop:c,projection:d,axis:u,side:m,size:v,blending:g,mat:l,alpha:_,mode:x,isMask:S},T,x,b,S,i)}a({createMaterial:(e,t)=>new Il(e,t),createComputation:(e,t,n)=>new Bl(e,t,n)}),rl("texture",Vl),rl("video",Vl),rl("matcap",(e,t,n,i)=>{let a=n,r=null!=a.texture.image?i.image(a.texture.image):i.getImage(""),o=new as(r,a.texture.wrapping??1001,a.texture.minFilter??1008,a.texture.magFilter??1006),s=new ta(p(a.alpha,i)),l=new wa(a.mode??0),c=new es(a.isMask??!1),d=new ta((h(a.texture.rotation??0,i)??0)*ce.DEG2RAD),u=new As(o,s,l,c,d),f=new Qi(u.calpha,"f");return new hl(e,t,a,{texture:o,alpha:s,mode:l,isMask:c,rotation:d},u,l,f,c,i)}),rl("displace",(e,t,n,i)=>{let a=n;if("noise"===a.displacementType){let n=new Bi(new Te(...a.offset.map(e=>h(e,i)??0))),r=new ta(h(a.scale,i)??10),o=new ta(h(a.intensity,i)??8),s=new ta(h(a.movement,i)??1),l=new wa(a.noiseType??0),c=new wa(a.voronoiStyle??0),d=new ta(h(a.smoothness,i)??.5),u=new ta(h(a.seed,i)??0),f=new ta(h(a.highCut,i)??1),p=new ta(h(a.lowCut,i)??0),m=new wa(h(a.quality,i)??1),v=new $s(o,s,n,c,d,u,f,p,m,r,l);return new ml(e,t,a,{offset:n,scale:r,intensity:o,movement:s,noiseType:l,voronoiStyle:c,smoothness:d,seed:u,highCut:f,lowCut:p,quality:m},v,i)}throw new Error}),rl("cavity",(e,t,i,a)=>{let r=n(i,a),o=new ta(h(r.ridge,a)??1),s=new ta(h(r.valley,a)??1),l=gl(r),c=new Ts(o,s,qs.normalViewRenderTarget,qs.resolution,l.alpha,l.mode,l.isMask),d=new Qi(c.calpha,"f");return new hl(e,t,i,{ridge:o,valley:s,...l},c,l.mode,d,l.isMask,a)}),rl("dust",(e,t,i,a)=>{let r=n(i,a),o=new ba(r.color??10323813),s=new ta(r.coverage??.2),l=new ta(r.softness??.2),c=new ta(r.noiseStrength??.2),d=new ta(r.noiseScale??1),u=gl(r),f=new Es(o,s,l,c,d,u.alpha,u.isMask),p=new Qi(f.calpha,"f");return new hl(e,t,i,{color:o,coverage:s,softness:l,noiseStrength:c,noiseScale:d,...u},f,u.mode,p,u.isMask,a)}),rl("fresnel",(e,t,i,a)=>{let r=n(i,a),o=new ba(r.color??16777215),s=new ta(h(r.bias,a)??.1),l=new ta(h(r.scale,a)??1),c=new ta(h(r.intensity,a)??2),d=new ta(h(r.factor,a)??1),u=gl(r),f=new Ms(o,s,l,c,d,u.alpha,u.mode,u.isMask),p=new Qi(f.calpha,"f");return new hl(e,t,i,{color:o,bias:s,scale:l,intensity:c,factor:d,...u},f,u.mode,p,u.isMask,a)}),rl("gradient",(e,t,i,a)=>{let r,o,s=n(i,a),l=new wa(s.gradientType??0),c=new es(s.smooth??!1);s.colors?r=new cs(s.colors.length,s.colors):(r=new cs(10,new Fe(0,0,0,1)),r.value[1]=new Fe(1,1,1,1)),s.steps?o=new ts(s.steps.length,s.steps):(o=new ts(10,1),o.value[0]=0);let d=new zi(ul(s.offset??new pe(0,0),a)),u=new zi(ul(s.morph??new pe(0,0),a)),f=new ta(h(s.angle??0,a)),p=gl(s),m=new Cs(l,c,r,o,d,u,f,p.alpha,p.isMask),v=new Qi(m.calpha,"f");return new hl(e,t,i,{gradientType:l,smooth:c,colors:r,steps:o,offset:d,morph:u,angle:f,...p},m,p.mode,v,p.isMask,a)}),rl("depth",(e,t,i,a)=>{let r,o,s=n(i,a),l=new wa(s.gradientType??0),c=new es(s.smooth??!1),d=new ta(h(s.near,a)??50),u=new ta(h(s.far,a)??200),f=new ta(s.isVector??1),p=new ta(s.isWorldSpace??0),m=new Bi(dl(s.origin,a)),v=new Bi(dl(s.direction,a));s.colors?r=new cs(s.colors.length,s.colors):(r=new cs(2,new Fe(0,0,0,1)),r.value[1]=new Fe(1,1,1,1)),s.steps?o=new ts(s.steps.length,s.steps):(o=new ts(2,1),o.value[0]=0);let g=gl(s),_=new xs(l,c,d,u,f,p,m,v,r,o,g.alpha,g.isMask),x=new Qi(_.calpha,"f");return new hl(e,t,i,{gradientType:l,smooth:c,near:d,far:u,isVector:f,isWorldSpace:p,origin:m,direction:v,colors:r,steps:o,...g},_,g.mode,x,g.isMask,a)}),rl("normal",(e,t,i,a)=>{let r=n(i,a),o=new Bi(r.cnormal??new Te(1,1,1)),s=gl(r),l=new hs(o,s.alpha),c=new Qi(l.calpha,"f");return new hl(e,t,i,{cnormal:o,...s},l,s.mode,c,s.isMask,a)}),rl("noise",(e,t,i,a)=>{let r=n(i,a),o=new ta(h(r.scale,a)??1),s=new Bi(dl(r.size??new Te(100,100,100),a)),l=new ta(h(r.move,a)??1),c=new zi(ul(r.fA??new pe(1.7,9.2),a)),d=new zi(ul(r.fB??new pe(8.3,2.8),a)),u=new zi(ul(r.distortion??new pe(1,1),a)),f=new Vi(r.colorA),p=new Vi(r.colorB),m=new Vi(r.colorC),v=new Vi(r.colorD),g=new wa(r.noiseType??0),_=new wa(r.voronoiStyle??0),x=new ta(h(r.highCut,a)??1),S=new ta(h(r.lowCut,a)??0),T=new ta(h(r.smoothness,a)??.5),b=new ta(h(r.seed,a)??.5),w=new wa(r.quality??1),E=gl(r),M=new Ps(o,s,l,c,d,u,f,p,m,v,E.alpha,g,E.isMask,_,x,S,T,b,w),y=new Qi(M.calpha,"f");return new hl(e,t,i,{scale:o,size:s,move:l,fA:c,fB:d,distortion:u,colorA:f,colorB:p,colorC:m,colorD:v,noiseType:g,...E,voronoiStyle:_,highCut:x,lowCut:S,smoothness:T,seed:b,quality:w},M,E.mode,y,E.isMask,a)}),rl("rainbow",(e,t,i,a,r)=>{let o=n(i,a),s=new ta(h(o.filmThickness,a)??30),l=new ta(h(o.movement,a)??0),c=new Bi(dl(o.wavelengths,a)),d=new ta(h(o.noiseStrength,a)??0),u=new ta(h(o.noiseScale,a)??1),f=new Bi(dl(o.offset,a)),p=gl(o),m=!0===r?.forceRainbowNoise,g=m||v(o.noiseStrength),_=new Os(s,l,c,d,u,f,p.alpha,p.isMask,g),x=new Qi(_.calpha,"f"),S=new hl(e,t,i,{filmThickness:s,movement:l,wavelengths:c,noiseStrength:d,noiseScale:u,offset:f,...p},_,p.mode,x,p.isMask,a);return S.noiseCompiledIn=g,S.noiseForced=m,S}),rl("toon",(e,t,i,a)=>{let r,o,s=n(i,a),l=new wa(s.positioning??0);s.colors?r=new cs(s.colors.length,s.colors):(r=new cs(10,new Fe(0,0,0,1)),r.value[1]=new Fe(1,1,1,1)),s.steps?o=new ts(s.steps.length,s.steps):(o=new ts(10,1),o.value[0]=0);let c=new Bi(dl(s.source??new Te(0,0,0),a)),d=new es(s.isWorldSpace??!0),u=new ta(h(s.noiseStrength??0,a)),f=new ta(h(s.noiseScale??1,a)),p=new Vi(s.shadowColor),m=new Bi(dl(s.offset??new Te(0,0,0),a)),v=gl(s),g=new zs(l,r,o,c,d,u,f,p,m,v.alpha),_=new Qi(g.calpha,"f");return new hl(e,t,i,{positioning:l,colors:r,steps:o,source:c,isWorldSpace:d,noiseStrength:u,noiseScale:f,shadowColor:p,offset:m,...v},g,v.mode,_,v.isMask,a)}),rl("outline",(e,t,i,a)=>{let r=n(i,a),o=new ba(r.outlineColor??16777215),s=new ba(r.contourColor??16777215),l=new ta(h(r.outlineWidth??.1,a)),c=new ta(h(r.contourWidth??.1,a)),d=new ta(h(r.outlineThreshold??.1,a)),u=new ta(h(r.contourThreshold??.1,a)),f=new ta(h(r.outlineSmoothing??.1,a)),p=new ta(h(r.contourFrequency??.1,a)),m=new Bi(dl(r.contourDirection??new Te(0,1,0),a)),v=new es(r.positionalLines??!1),g=new es(r.compensation??!0),_=qs.normalRenderTarget,x=qs.normalRenderTargetDepth,S=qs.pixelRatioNode,T=qs.resolution,b=gl(r),w=new Ls(o,s,l,c,d,u,f,p,m,v,g,T,_,x,S,b.alpha),E=new Qi(w.calpha,"f");return new hl(e,t,i,{outlineColor:o,contourColor:s,outlineWidth:l,contourWidth:c,outlineThreshold:d,contourThreshold:u,outlineSmoothing:f,contourFrequency:p,contourDirection:m,positionalLines:v,compensation:g,...b},w,b.mode,E,b.isMask,a)}),rl("transmission",(e,t,i,a)=>{let r=n(i,a),o=new ta(h(r.thickness??10,a)),s=new ta(h(r.ior??1.5,a)),l=new ta(h(r.roughness??.5,a)),c=qs.transmissionSize,d=qs.transmissionRenderTarget,u=qs.transmissionRenderTargetDepth,f=window.innerWidth,p=window.innerHeight,m=f>=p?new zi(p/f,1):new zi(1,f/p),v=gl(r),g=new Hs(o,s,l,c,d,u,m,v.alpha),_=new Qi(g.calpha,"f");return new hl(e,t,i,{thickness:o,ior:s,roughness:l,aspectRatio:m,...v},g,v.mode,_,v.isMask,a)});var Hl=!1;rl("reflection",(e,t,i,a)=>{Hl||(Hl=!0,console.warn("[spline] The reflection material layer requires the WebGPU renderer — it renders as invisible on the classic WebGL pipeline."));let r=n(i,a),o=new ta(r.blur??0),s=new ta(r.thickness??.001),l=new wa(r.steps??60),c=new ta(r.stepSize??.005),d=new wa(r.tracingMode??1),u=gl(r),f=new ba(0,0,0,1),p=new ta(0),h=new fs(f,p),m=new Qi(h.calpha,"f");return new hl(e,t,i,{blur:o,thickness:s,steps:l,stepSize:c,tracingMode:d,...u},h,u.mode,m,u.isMask,a)}),rl("pattern",(e,t,i,a)=>{let r=n(i,a),o=new wa(r.style??0),s=new wa(r.projection??0),l=new wa(["x","y","z"].indexOf(r.axis)??0),c=new ta(h(r.blending??0,a)),d=new zi(ul(r.offset,a)),u=new Vi(r.colorA),f=new Vi(r.colorB),p=new zi(ul(r.frequency??new pe(10,10),a)),m=new ta(h(r.size??.5,a)),v=new ta(h(r.variation??0,a)),g=new ta(h(r.smoothness??.5,a)),_=new ta(h(r.zigzag??0,a)),x=new ta(h(r.rotation??0,a)),S=new zi(ul(r.vertical??new pe(0,1),a)),T=new zi(ul(r.horizontal??new pe(0,1),a)),b=new wa(r.sides??6),w=gl(r),E=new Ns(o,s,l,c,d,u,f,p,m,v,g,_,x,S,T,b,w.alpha,w.isMask),M=new Qi(E.calpha,"f");return new hl(e,t,i,{style:o,projection:s,axis:l,blending:c,offset:d,colorA:u,colorB:f,frequency:p,size:m,variation:v,smoothness:g,zigzag:_,rotation:x,vertical:S,horizontal:T,sides:b,...w},E,w.mode,M,w.isMask,a)}),rl("vertexColor",(e,t,i,a)=>{let r=gl(n(i,a)),o=new ks(r.alpha),s=new Qi(o.calpha,"f");return new hl(e,t,i,{...r},o,r.mode,s,r.isMask,a)}),c({createRootMaterial:(e,t)=>new wl(e,t),createSharedMaterial:(e,t,n)=>new El(e,t,n)}),u((e,t)=>e?((e="medium")=>{if(Pl===e)return!1;Pl=e;let t=(e=>{switch(e){case"low":return 8;case"medium":default:return 16;case"high":return 32}})(e);ya.shadowmap_pars_fragment=(e=>`\n\n// PCSS implementation based on:\n// https://www.gamedev.net/articles/programming/graphics/contact-hardening-soft-shadows-made-fast-r4906/\n// NOTE: This number affects how big the shadow blur can\n// possibly get. Bigger number == bigger blur, but less precise results\n\nconst float gPenumbraFilterSize = 80.0;\n// Blocker search at half the PCF budget (min 4): the average-blocker-depth\n// estimate feeds the squared/clamped penumbra term, which tolerates far\n// more estimator variance than the visible PCF edge — and the per-frame\n// vogel rotation integrates the residual under TAA. The reduced count is\n// ALSO the vogelDiskSample count in computePenumbra so the sparser spiral\n// still spans the full search radius (classic N with i < N/2 would only\n// cover the inner sqrt(1/2) of the disk and miss far blockers). Mirrors\n// the WebGPU filter's split (splinePCSS.ts blockerSampleCount).\nconst int gPenumbraSamples = ${Math.max(4,e>>1)};\nconst int gShadowSamples = ${e};\nconst float gShadowSamplesRpc = 1.0f / float(gShadowSamples);\n\n#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n\n uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\n struct DirectionalLightShadow {\n // Field order must match three r185's stock struct\n // (shadowmap_pars_vertex) or the uniform layout differs between the\n // vertex and fragment stages. shadowIntensity was added in r185.\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n\n uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\n #endif\n\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n\n uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\n struct SpotLightShadow {\n // Field order must match three r185's stock struct\n // (shadowmap_pars_vertex) or the uniform layout differs between the\n // vertex and fragment stages. shadowIntensity was added in r185.\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n\n uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\n #endif\n\n #if NUM_POINT_LIGHT_SHADOWS > 0\n\n // r185 renders point-light shadows into a cube render target with a\n // CubeDepthTexture (WebGLShadowMap always uses WebGLCubeRenderTarget\n // for point lights), so the map binds as a cube sampler — the old\n // 2D cube-atlas (cubeToUV) layout no longer exists. BasicShadowMap\n // leaves compareFunction null, so raw depth reads work.\n uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\n struct PointLightShadow {\n // Field order must match three r185's stock struct.\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n float shadowCameraNear;\n float shadowCameraFar;\n };\n\n uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\n #endif\n\n /*\n #if NUM_RECT_AREA_LIGHTS > 0\n\n // TODO (abelnation): create uniforms for area light shadows\n\n #endif\n */\n\n${Ml}\n\nfloat computePenumbra(int index, sampler2D shadowMap, float temporalAngle, float texelSize, vec2 uv, float compare, float texelScalar, float shadowRadius, vec2 dzduv)\n{\n float penumbra = 1.0;\n float blockerDepthAvg = 0.0;\n float blockerCount = 0.0;\n\n #pragma unroll_loop_start\n for(int i = 0; i < gPenumbraSamples; i ++)\n {\n vec2 offset = (vogelDiskSample(i, gPenumbraSamples, temporalAngle) * texelSize) * texelScalar;\n float depth = texture2D( shadowMap, uv + offset ).r;\n\n if(depth < compare + receiverPlaneAdjust(dzduv, offset) + 0.0001)\n {\n blockerDepthAvg += depth;\n blockerCount++;\n }\n }\n #pragma unroll_loop_end\n\n if (blockerCount > 0.0)\n {\n blockerDepthAvg /= blockerCount;\n\n \n penumbra = (compare - blockerDepthAvg) / (blockerDepthAvg);\n penumbra *= penumbra;\n penumbra *= 200.0 * penumbraSize[min(index, ${x} - 1)]; // Magic number that affects how quickly the penumbra grows\n\n return clamp(penumbra, 0.00, 1.0);\n }\n return 0.0;\n}\n\nfloat vogelShadow(int index, sampler2D shadowMap, vec2 uv, float texelSize, float compare, float shadowRadius, vec2 dzduv)\n{\n float shadow = 0.0f;\n\n // NOTE: When using TAA, we should use screen space interleaved gradient noise\n vec2 halton = haltonSequence[frameIndex];\n float temporalOffset = getNoiseInterleavedGradient(gl_FragCoord.xy + halton);\n float temporalAngle = temporalOffset * PI2;\n\n float texelScalar = (gPenumbraFilterSize) / (texelSize * 1024.);\n float penumbra = computePenumbra(index, shadowMap, temporalAngle, texelSize, uv, compare, texelScalar, shadowRadius, dzduv);\n if (penumbra == -1.0) {\n return 1.0;\n }\n\n #pragma unroll_loop_start\n for (int i = 0; i < gShadowSamples; i++)\n {\n vec2 vogelSample = vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize;\n // Overall blurring offset\n vec2 offset = vogelSample * (shadowRadius * 2.);\n\n // Penumbra offset\n offset += vogelSample * (penumbra * texelScalar);\n\n shadow += step( compare + receiverPlaneAdjust(dzduv, offset), texture2D( shadowMap, uv + offset ).r );\n }\n #pragma unroll_loop_end\n\n return shadow * gShadowSamplesRpc;\n}\n\n\n float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\n // r185: shadow maps are DepthTextures bound without compare mode\n // (BasicShadowMap), so depth is read directly from .r rather than from\n // an RGBA-packed encoding.\n return step( compare, texture2D( depths, uv ).r );\n\n }\n\n float textureCubeCompare( samplerCube depths, vec3 dir, float compare ) {\n\n float depth = textureCube( depths, dir ).r;\n\n #ifdef USE_REVERSED_DEPTH_BUFFER\n\n depth = 1.0 - depth;\n\n #endif\n\n return step( compare, depth );\n\n }\n\n vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\n return unpackRGBATo2Half( texture2D( shadow, uv ) );\n\n }\n\n float VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\n float occlusion = 1.0;\n\n vec2 distribution = texture2DDistribution( shadow, uv );\n\n float hard_shadow = step( compare , distribution.x ); // Hard Shadow\n\n if (hard_shadow != 1.0 ) {\n\n float distance = compare - distribution.x ;\n float variance = max( 0.00000, distribution.y * distribution.y );\n float softness_probability = variance / (variance + distance * distance ); // Chebeyshevs inequality\n softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); // 0.3 reduces light bleed\n occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\n }\n return occlusion;\n\n }\n\n float getShadow( int i, sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\n float shadow = 1.0;\n\n shadowCoord.xyz /= shadowCoord.w;\n shadowCoord.z += shadowBias;\n\n // Receiver-plane depth gradient — derivatives taken BEFORE the\n // frustum branch (well-defined across the quad) of the projected\n // coord, so the vogel taps can slope-correct their compares.\n vec2 dzduv = receiverPlaneDepthBias( dFdx( shadowCoord.xyz ), dFdy( shadowCoord.xyz ) );\n\n // if ( something && something ) breaks ATI OpenGL shader compiler\n // if ( all( something, something ) ) using this instead\n\n bvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n bool inFrustum = all( inFrustumVec );\n\n bvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\n bool frustumTest = all( frustumTestVec );\n\n if ( frustumTest ) {\n\n // SHADOWMAP_TYPE_BASIC included: on r185 the renderer must use\n // BasicShadowMap (PCFShadowMap binds the depth texture as a\n // sampler2DShadow with hardware compare, which this custom PCSS\n // sampling can't read from), so BASIC is the define our PCSS path\n // now runs under.\n #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC )\n\n vec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n return vogelShadow(i, shadowMap, shadowCoord.xy, texelSize.x, shadowCoord.z, shadowRadius, dzduv );\n\n #elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\n vec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n float dx = texelSize.x;\n float dy = texelSize.y;\n\n vec2 uv = shadowCoord.xy;\n vec2 f = fract( uv * shadowMapSize + 0.5 );\n uv -= f * texelSize;\n\n shadow = (\n texture2DCompare( shadowMap, uv, shadowCoord.z ) +\n texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n f.x ) +\n mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n f.x ) +\n mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n f.y ) +\n mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n f.y ) +\n mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n f.x ),\n mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n f.x ),\n f.y )\n ) * ( 1.0 / 9.0 );\n\n #elif defined( SHADOWMAP_TYPE_VSM )\n\n shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\n #else // no percentage-closer filtering:\n\n shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\n #endif\n\n }\n\n return shadow;\n\n }\n\n float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\n float shadow = 1.0;\n // Offset magnitude matches the pre-r185 2D cube-atlas texel size so the\n // blur radius is visually unchanged.\n vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\n // for point lights, the uniform @vShadowCoord is re-purposed to hold\n // the vector from the light to the world-space position of the fragment.\n vec3 lightToPosition = shadowCoord.xyz;\n\n // r185 cube shadow maps store perspective depth along the sampled\n // face's view axis (not radial distance): view-space depth is the\n // largest component of the light-to-fragment vector.\n vec3 absVec = abs( lightToPosition );\n float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n\n if ( viewSpaceZ - shadowCameraFar > 0.0 || viewSpaceZ - shadowCameraNear < 0.0 ) {\n\n return shadow;\n\n }\n\n // viewZ to perspective depth\n float compare = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n compare += shadowBias;\n\n // bd3D = base direction 3D\n vec3 bd3D = normalize( lightToPosition );\n\n vec2 halton = haltonSequence[frameIndex];\n float temporalOffset = getNoiseInterleavedGradient(gl_FragCoord.xy + halton);\n float temporalAngle = temporalOffset * PI2;\n\n #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_VSM ) || defined( SHADOWMAP_TYPE_BASIC )\n for (int i = 0; i < gShadowSamples; i++) {\n vec2 vogelSample = vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize;\n\n // Overall blurring offset\n vec3 offset = vec3(vogelSample.x, vogelSample.y, -vogelSample.x) * (shadowRadius + 5.);\n\n // NOTE: Removed for now\n // Penumbra offset\n //offset += vec3(vogelSample.x, vogelSample.y, vogelSample.y) * (penumbra * gPenumbraFilterSize);\n\n shadow += textureCubeCompare( shadowMap, bd3D + offset, compare );\n\n }\n return shadow * gShadowSamplesRpc;\n\n #elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n for (int i = 0; i < 16; i++) {\n vec2 vogelSample = vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize;\n\n // Overall blurring offset\n vec3 offset = vec3(vogelSample.x, vogelSample.y, -vogelSample.x) * (shadowRadius + 5.);\n\n shadow += textureCubeCompare( shadowMap, bd3D + offset, compare );\n\n }\n return shadow * (1.0 / 16.0);\n #else // no percentage-closer filtering\n\n return textureCubeCompare( shadowMap, bd3D, compare );\n\n #endif\n\n }\n\n#endif\n`)(t);let n=Cl.slice();n=n.replace("getShadow( spotShadowMap[ i ]",`getShadow( UNROLLED_LOOP_INDEX + ${S}, spotShadowMap[ i ]`),n=n.replace("getShadow( directionalShadowMap[ i ]","getShadow( UNROLLED_LOOP_INDEX, directionalShadowMap[ i ]"),ya.lights_fragment_begin=n;let i=Rl.slice();return i=i.replaceAll("getShadow(","getShadow( UNROLLED_LOOP_INDEX, "),ya.shadowmask_pars_fragment=i,!0})(t):(()=>{if(null===Pl||"off"===Pl){let e=null===Pl;return Pl="off",e&&(ya.shadowmap_pars_fragment=Dl()),!1}return Pl="off",ya.shadowmap_pars_fragment=Dl(),ya.lights_fragment_begin=Cl,ya.shadowmask_pars_fragment=Rl,!0})()),d(()=>{let e=new At;return e.depthWrite=!1,e.opacity=.5,e.onBeforeCompile=e=>{e.fragmentShader="layout(location = 1) out vec4 gVelocity;\n"+e.fragmentShader.replace("void main() {","void main() {\n\tgVelocity = vec4(0.0);")},e});var Gl="\nvec3 normal = (normalize(vNormal)).rgb;\n\nfloat contrastDepth = (gl_FragCoord.z - 0.5) * depthContrast + 0.5;\n\nvec3 resultColor = mix(mix(vColor, normal, 0.2), vec3(contrastDepth), 0.4);\n",kl="\nvec3 nv = normalize(vNormalView);\nif (!gl_FrontFacing) nv = -nv;\n",Wl=`\nuniform float depthContrast;\nvarying vec3 vNormal;\nvarying vec3 vNormalView;\nflat in vec3 vColor;\nvoid main()\n{\n${kl}\ngl_FragColor = vec4(nv, vColor.r);\n}\n`,Xl=`\nlayout(location = 1) out vec4 gViewNormal;\nuniform float depthContrast;\nvarying vec3 vNormal;\nvarying vec3 vNormalView;\nflat in vec3 vColor;\nvoid main()\n{\n${Gl}\ngl_FragColor = vec4(resultColor, vColor.r);\n\n${kl}\ngViewNormal = vec4(nv, vColor.r);\n}\n`,jl={value:1},$l=e=>new Xt({vertexShader:"\nattribute vec3 randomColor;\nvarying vec3 vNormal;\nvarying vec3 vNormalView;\nflat out vec3 vColor;\n#include <skinning_pars_vertex>\n#include <morphtarget_pars_vertex>\n\nvoid main()\n{\n#include <beginnormal_vertex>\n#include <morphnormal_vertex>\n#include <skinbase_vertex>\n#include <skinnormal_vertex>\nvec3 transformed = vec3(position);\n#include <morphtarget_vertex>\n#include <skinning_vertex>\n\n\n\n\n\nvec4 localPosition = vec4(transformed, 1.0);\n#ifdef USE_INSTANCING\nlocalPosition = instanceMatrix * localPosition;\nobjectNormal = mat3(instanceMatrix) * objectNormal;\n#endif\n\nvNormal = normal;\nvNormalView = normalMatrix * objectNormal;\nvColor = randomColor;\ngl_Position = projectionMatrix * (modelViewMatrix * localPosition);\n}\n",fragmentShader:e,uniforms:{depthContrast:jl}}),ql=$l(`\nuniform float depthContrast;\nvarying vec3 vNormal;\nvarying vec3 vNormalView;\nflat in vec3 vColor;\nvoid main()\n{\n${Gl}\ngl_FragColor = vec4(resultColor, vColor.r);\n}\n`),Yl=$l(Wl),Kl=$l(Xl),Zl="float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\n\tif ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\n\t\treturn pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\n\t}\n\n\treturn 1.0;\n\n}",Jl=/float getDistanceAttenuation\([^)]*\)\s*\{[\s\S]*?\n\}/,Ql=class extends Xt{constructor(){super({name:"PassthroughMaterial",uniforms:{inputBuffer:new je(null)},blending:Ln,depthWrite:!1,depthTest:!1,vertexShader:"#define GLSLIFY 1\nvarying vec2 vUv;void main(){gl_Position=vec4(position.xy,1.0,1.0);vUv=position.xy*0.5+0.5;}",fragmentShader:"#define GLSLIFY 1\nlayout(location=1)out vec4 gVelocity;varying vec2 vUv;uniform sampler2D inputBuffer;void main(){gl_FragColor=texture2D(inputBuffer,vUv);gVelocity=vec4(0.0);}"})}set inputBuffer(e){this.uniforms.inputBuffer.value=e}},ec=class extends U{constructor(){super("TAAResolvePass"),this.MRTCompatible=!0,this.needsSwap=!1,this.passThroughMaterial=new Ql,this.resolutionVector=new pe,this.resolveMaterial=new Xt({name:"TAAResolveMaterial",uniforms:{inputBuffer:new je(null),historyBuffer:new je(null),velocityBuffer:new je(null),depthBuffer:new je(null),resolution:new je(new pe)},blending:Ln,depthWrite:!1,depthTest:!1,vertexShader:"#define GLSLIFY 1\nvarying vec2 vUv;varying vec2 vTexCoords[9];uniform vec2 resolution;void main(){vUv=position.xy*0.5+0.5;vec2 texelSize=vec2(1.0)/resolution;vTexCoords[0]=vUv+vec2(-texelSize.x,-texelSize.y);vTexCoords[1]=vUv+vec2(0.0,-texelSize.y);vTexCoords[2]=vUv+vec2(texelSize.x,-texelSize.y);vTexCoords[3]=vUv+vec2(-texelSize.x,0.0);vTexCoords[4]=vUv+vec2(0.0,0.0);vTexCoords[5]=vUv+vec2(texelSize.x,0.0);vTexCoords[6]=vUv+vec2(-texelSize.x,texelSize.y);vTexCoords[7]=vUv+vec2(0.0,texelSize.y);vTexCoords[8]=vUv+vec2(texelSize.x,texelSize.y);gl_Position=vec4(position.xy,1.0,1.0);}",fragmentShader:"#define GLSLIFY 1\n#include <common>\nvarying vec2 vUv;varying vec2 vTexCoords[9];uniform sampler2D inputBuffer;uniform sampler2D historyBuffer;uniform sampler2D velocityBuffer;uniform sampler2D depthBuffer;uniform vec2 resolution;\n#define USE_YCOCG\n#define USE_CATMULL_ROM\nconst float feedback_min=0.5;const float feedback_max=0.95;vec3 RGB_YCoCg(vec3 c){return vec3(c.x/4.0+c.y/2.0+c.z/4.0,c.x/2.0-c.z/2.0,-c.x/4.0+c.y/2.0-c.z/4.0);}vec3 YCoCg_RGB(vec3 c){return clamp(vec3(c.x+c.y-c.z,c.x+c.z,c.x-c.y-c.z),vec3(0.0),vec3(1.0));}vec4 sample_color(sampler2D tex,vec2 uv){\n#ifdef USE_YCOCG\nvec4 c=texture(tex,uv);return vec4(RGB_YCoCg(c.rgb),c.a);\n#else\nreturn texture(tex,uv);\n#endif\n}vec4 sample_catmull_rom(sampler2D tex,vec2 uv,vec2 texSize){vec2 samplePos=uv*texSize;vec2 texPos1=floor(samplePos-0.5)+0.5;vec2 f=samplePos-texPos1;vec2 w0=f*(-0.5+f*(1.0-0.5*f));vec2 w1=1.0+f*f*(-2.5+1.5*f);vec2 w2=f*(0.5+f*(2.0-1.5*f));vec2 w3=f*f*(-0.5+0.5*f);vec2 w12=w1+w2;vec2 offset12=w2/(w1+w2);vec2 texPos0=texPos1-1.0;vec2 texPos3=texPos1+2.0;vec2 texPos12=texPos1+offset12;texPos0/=texSize;texPos3/=texSize;texPos12/=texSize;vec4 result=vec4(0.0);result+=texture2D(tex,vec2(texPos12.x,texPos0.y))*w12.x*w0.y;result+=texture2D(tex,vec2(texPos0.x,texPos12.y))*w0.x*w12.y;result+=texture2D(tex,vec2(texPos12.x,texPos12.y))*w12.x*w12.y;result+=texture2D(tex,vec2(texPos3.x,texPos12.y))*w3.x*w12.y;result+=texture2D(tex,vec2(texPos12.x,texPos3.y))*w12.x*w3.y;return result;}vec3 choose_motion_vector(){\n#ifdef CHOOSE_LONGEST_MOTION_VECTOR\nfloat longest=-1.0;vec3 v_choose=vec3(-1.0);for(int i=0;i<9;i++){vec3 v=texture2D(velocityBuffer,vTexCoords[i]).rgb;float l=length(v.xy);if(l>longest){longest=l;v_choose=v;}}return v_choose;\n#else\nfloat closest_depth=1000.0;vec2 closest_uv_offset=vec2(0.0);for(int i=0;i<9;i++){float neighbor_depth=texture2D(depthBuffer,vTexCoords[i]).r;if(neighbor_depth<closest_depth){closest_uv_offset=vTexCoords[i];closest_depth=neighbor_depth;}}return texture2D(velocityBuffer,closest_uv_offset).rgb;\n#endif\n}vec4 clipAabb(vec3 aabb_min,vec3 aabb_max,vec4 avg,vec4 input_texel){const float FLT_EPS=0.00000001;vec3 p_clip=0.5*(aabb_max+aabb_min);vec3 e_clip=0.5*(aabb_max-aabb_min)+FLT_EPS;vec4 v_clip=input_texel-vec4(p_clip,avg.w);vec3 v_unit=v_clip.xyz/e_clip;vec3 a_unit=abs(v_unit);float ma_unit=max(a_unit.x,max(a_unit.y,a_unit.z));if(ma_unit>1.0){return vec4(p_clip,avg.w)+v_clip/ma_unit;}else{return input_texel;}}vec3 clip_aabb_variance(in vec3 cOld,in vec3 cNew,in vec3 centre,in vec3 halfSize){if(all(lessThanEqual(abs(cOld-centre),halfSize))){return cOld;}vec3 dir=(cNew-cOld);vec3 near=centre-sign(dir)*halfSize;vec3 tAll=(near-cOld)/dir;float t=0.0001;for(int i=0;i<3;i++){if(tAll[i]>=0.0&&tAll[i]<t){t=tAll[i];}}if(t>=0.0001){return cOld;}return cOld+dir*t;}void main(){vec3 v=choose_motion_vector();vec2 velocity=v.rg;vec2 previousPixelPos=vUv-velocity;vec4 currentColor=sample_color(inputBuffer,vUv);\n#ifdef USE_CATMULL_ROM\nvec4 previousColor=sample_catmull_rom(historyBuffer,previousPixelPos,resolution);\n#else\nvec4 previousColor=sample_color(historyBuffer,previousPixelPos);\n#endif\n#ifdef USE_YCOCG\npreviousColor=vec4(RGB_YCoCg(previousColor.rgb),previousColor.a);\n#endif\nvec4 ctl=sample_color(inputBuffer,vTexCoords[0]);vec4 ctc=sample_color(inputBuffer,vTexCoords[1]);vec4 ctr=sample_color(inputBuffer,vTexCoords[2]);vec4 cml=sample_color(inputBuffer,vTexCoords[3]);vec4 cmc=sample_color(inputBuffer,vTexCoords[4]);vec4 cmr=sample_color(inputBuffer,vTexCoords[5]);vec4 cbl=sample_color(inputBuffer,vTexCoords[6]);vec4 cbc=sample_color(inputBuffer,vTexCoords[7]);vec4 cbr=sample_color(inputBuffer,vTexCoords[8]);vec4 cmin=min(ctl,min(ctc,min(ctr,min(cml,min(cmc,min(cmr,min(cbl,min(cbc,cbr))))))));vec4 cmax=max(ctl,max(ctc,max(ctr,max(cml,max(cmc,max(cmr,max(cbl,max(cbc,cbr))))))));vec4 cavg=(ctl+ctc+ctr+cml+cmc+cmr+cbl+cbc+cbr)/9.0;vec4 cmin5=min(ctc,min(cml,min(cmc,min(cmr,cbc))));vec4 cmax5=max(ctc,max(cml,max(cmc,max(cmr,cbc))));vec4 cavg5=(ctc+cml+cmc+cmr+cbc)/5.0;cmin=0.5*(cmin+cmin5);cmax=0.5*(cmax+cmax5);cavg=0.5*(cavg+cavg5);\n#ifdef USE_YCOCG\nvec2 chroma_extent=vec2(0.25*0.5*(cmax.r-cmin.r));vec2 chroma_center=currentColor.gb;cmin.yz=chroma_center-chroma_extent;cmax.yz=chroma_center+chroma_extent;cavg.yz=chroma_center;\n#endif\nvec4 previousColorClipped=clamp(previousColor,cmin,cmax);\n#ifdef LUMINANCE_DIFFERENCES\n#ifdef USE_YCOCG\nfloat lum0=currentColor.r;float lum1=previousColorClipped.r;\n#else\nfloat lum0=luminance(currentColor.rgb);float lum1=luminance(previousColorClipped.rgb);\n#endif\nfloat unbiased_diff=abs(lum0-lum1)/max(lum0,max(lum1,0.2));float unbiased_weight=1.0-unbiased_diff;float unbiased_weight_sqr=unbiased_weight*unbiased_weight;float k_feedback=mix(feedback_min,feedback_max,unbiased_weight_sqr);vec4 result=mix(currentColor,previousColorClipped,vec4(k_feedback));\n#else\nconst float alpha=0.1;vec4 result=mix(currentColor,previousColorClipped,1.0-alpha);\n#endif\n#ifdef USE_YCOCG\ngl_FragColor=vec4(YCoCg_RGB(result.rgb).rgb,result.a);\n#else\ngl_FragColor=result;\n#endif\n}"}),this.historyRenderTarget=new Xe(1024,1024,{minFilter:qn,stencilBuffer:!1,depthBuffer:!1}),this.historyRenderTarget.texture.name="TAA.History",this.resultRenderTarget=new Xe(1024,1024,{minFilter:qn,stencilBuffer:!1,depthBuffer:!1}),this.resultRenderTarget.texture.name="TAA.Output"}setSize(e,t){this.historyRenderTarget.setSize(e,t),this.resultRenderTarget.setSize(e,t)}render(e,t){this.fullscreenMaterial=this.resolveMaterial,this.resolveMaterial.uniforms.inputBuffer.value=t.textures[0],this.resolveMaterial.uniforms.velocityBuffer.value=t.textures[1],this.resolveMaterial.uniforms.depthBuffer.value=t.depthTexture,this.resolveMaterial.uniforms.historyBuffer.value=this.historyRenderTarget.texture,this.resolveMaterial.uniforms.resolution.value.set(t.width,t.height),e.setRenderTarget(this.resultRenderTarget),e.render(this.scene,this.camera),this.fullscreenMaterial=this.passThroughMaterial,this.passThroughMaterial.inputBuffer=this.resultRenderTarget.texture,e.setRenderTarget(this.historyRenderTarget),e.render(this.scene,this.camera);let n=this.renderToScreen?null:t;this.fullscreenMaterial=this.passThroughMaterial,this.passThroughMaterial.inputBuffer=this.resultRenderTarget.texture,e.setRenderTarget(n),e.render(this.scene,this.camera)}dispose(){super.dispose(),this.resultRenderTarget.dispose(),this.historyRenderTarget.dispose(),this.resolveMaterial.dispose(),this.passThroughMaterial.dispose()}},tc=class extends U{constructor(e,t,n){super("TransmissionPass",void 0,t),this.MRTCompatible=!0,this.depthPass=new O(e,t,{renderTarget:n.transmissionDepthTarget}),this.passThroughMaterial=new Ql,this.splineScene=e,this.needsSwap=!1}updatePasses(e){this.passThroughMaterial.dispose(),this.passThroughMaterial=new Ql,this.depthPass.dispose(),this.depthPass=new O(this.splineScene,this.camera,{renderTarget:e.transmissionDepthTarget})}setCamera(e){this.camera=e}setScene(e){this.splineScene=e}render(e,t,n){let i=this.camera.layers.mask,a=e;a.setRenderTarget(a.transmissionRenderTarget),this.fullscreenMaterial=this.passThroughMaterial,this.passThroughMaterial.inputBuffer=t.textures[0],a.clear(),a.render(this.scene,this.camera),a.shadowMap.needsUpdate=!1,a.shadowMap.autoUpdate=!1,this.camera.layers.disable(3),this.depthPass.render(e,t,n);let r=this.renderToScreen?null:t;this.camera.layers.set(3),e.setRenderTarget(r),e.render(this.splineScene,this.camera),this.camera.layers.mask=i}dispose(){super.dispose(),this.depthPass?.renderPass.dispose(),this.depthPass.dispose(),this.passThroughMaterial.dispose(),this.depthPass=void 0,this.passThroughMaterial=void 0,this.splineScene=void 0,this.scene=void 0,this.camera=void 0}},nc=new gt,ic=new Xt({transparent:!0,vertexShader:"\n void main() {\n gl_Position = vec4(0.0);\n }\n ",fragmentShader:"\n layout(location = 1) out vec4 gVelocity;\n\n void main() {\n gl_FragColor = vec4(0.0);\n\t\t\tgVelocity = vec4(0.0);\n }\n "}),ac=class extends U{constructor(e,t,n){super("OpaquePass",t??nc,n),this.MRTCompatible=!0,this.originalMaterials=[],this.hasTransmissionPass=!1,this.clear=!0,this.clearColorOnly=!1,this.clearDepth=!1,this.needsSwap=!1,this.MRTCompatible=e}setCamera(e){this.camera=e}setScene(e){this.scene=e??nc}getScene(){return this.scene}render(e,t){this.camera.layers.enable(3),this.hasTransmissionPass&&(this.originalMaterials.length=0,this.scene.traverse(e=>{e.layers.isEnabled(3)&&e instanceof E&&(this.originalMaterials.push([e,e.material]),e.material=ic)}),!0!==e.manageShadowUpdates&&(e.shadowMap.needsUpdate=!0,e.shadowMap.autoUpdate=!0)),this.camera.layers.enable(8),this.camera.layers.enable(4);let n=this.renderToScreen?null:t;e.setRenderTarget(n),this.clearColorOnly&&e.clear(!0,!1,!0),this.clear&&e.clear(),e.render(this.scene,this.camera),this.clearDepth&&e.clear(!1,!0,!1),this.hasTransmissionPass&&this.originalMaterials.forEach(e=>{e[0].material=e[1]})}dispose(){super.dispose(),this.originalMaterials.length=0,this.scene=void 0,this.camera=void 0}},rc=class{constructor(e,{depthBuffer:t=!0,stencilBuffer:n=!1,multisampling:i=0,frameBufferType:a=0}={}){this.renderer=e,this.helperStartIndex=0,this.copyPass=new N,this.depthTexture=null,this.timer=new G,this._width=1,this._height=1,this.passes=[],this.helperPasses=[],this.autoRenderToScreen=!0,this.inputBuffer=this.createBuffer(t,n,a,i,!0,"input buffer mrt"),this.inputBufferSingle=this.createBuffer(t,n,a,i,!1," input buffer single"),this.inputBufferSingle.texture.dispose(),this.inputBufferSingle.depthTexture.dispose(),this.inputBufferSingle.texture=this.inputBuffer.textures[0],this.inputBufferSingle.depthTexture=this.inputBuffer.depthTexture,this.outputBuffer=this.inputBuffer.clone(),this.outputBuffer.name="output buffer mrt",this.outputBufferSingle=this.createBuffer(t,n,a,i,!1,"output buffer single"),this.outputBufferSingle.texture.dispose(),this.outputBufferSingle.depthTexture.dispose(),this.outputBufferSingle.texture=this.outputBuffer.textures[0],this.outputBufferSingle.depthTexture=this.outputBuffer.depthTexture,this.setRenderer(e)}get multisampling(){return this.inputBuffer.samples||0}set multisampling(e){let t=this.inputBuffer,n=this.multisampling;n>0&&e>0?(this.inputBuffer.samples=e,this.outputBuffer.samples=e,this.inputBuffer.dispose(),this.outputBuffer.dispose()):n!==e&&(this.inputBuffer.dispose(),this.outputBuffer.dispose(),console.log("creating new input buffer"),this.inputBuffer=this.createBuffer(t.depthBuffer,t.stencilBuffer,t.texture.type,e,!0,"new input buffer"),this.inputBuffer.depthTexture=this.depthTexture,this.outputBuffer=this.inputBuffer.clone())}getTimer(){return this.timer}getRenderer(){return this.renderer}setRenderer(e){if(this.renderer=e,null!==e){let t=e.getSize(new pe),n=e.getContext().getContextAttributes()?.alpha??!1,i=this.inputBuffer.textures[0].type;i===si&&e.outputColorSpace===Le&&(this.inputBuffer.textures[0].colorSpace=Le,this.outputBuffer.textures[0].colorSpace=Le,this.inputBuffer.dispose(),this.outputBuffer.dispose()),e.autoClear=!1,this.setSize(t.width,t.height,!1);for(let t of this.passes)t.initialize(e,n,i)}}replaceRenderer(e,t=!0){let n=this.renderer,i=n.domElement.parentNode;return this.setRenderer(e),t&&null!==i&&(i.removeChild(n.domElement),i.appendChild(e.domElement)),n}createDepthTexture(){let e=this.depthTexture=new de(this._width,this._height);return this.inputBuffer.depthTexture=e,this.inputBuffer.stencilBuffer?(e.format=ke,e.type=ve):e.type=Ci,e}deleteDepthTexture(){if(null!==this.depthTexture){this.depthTexture.dispose(),this.depthTexture=null,this.inputBuffer.depthTexture=null,this.inputBuffer.dispose();for(let e of this.passes)e.setDepthTexture(null)}}createBuffer(e,t,n,i,a,r){let o,s=this.renderer,l=null===s?new pe:s.getDrawingBufferSize(new pe),c={minFilter:qn,magFilter:qn,wrapS:Rn,wrapT:Rn,stencilBuffer:t,depthBuffer:e};i>0?(o=new Xe(l.width,l.height,c),o.samples=i):(a?(o=new Xe(l.width,l.height,{...c,count:2}),o.textures[1].type=re):o=new Xe(l.width,l.height,c),o.depthTexture=new de(2048,2048),o.depthTexture.type=ee);let d=o.textures.length>1;return n===si&&null!==s&&s.outputColorSpace===Le&&(d?o.textures.forEach(e=>e.colorSpace=Le):o.texture.colorSpace=Le),d?o.textures.forEach((e,t)=>{e.name=`EffectComposer.Buffer ${a} ${t}`,e.generateMipmaps=!1}):(o.texture.name=`EffectComposer.Buffer ${a}`,o.texture.generateMipmaps=!1),o.name=r,o}addPass(e,t){let n,i=this.passes,a=this.renderer,r=a.getDrawingBufferSize(new pe),o=a.getContext().getContextAttributes()?.alpha??!1;if(e.MRTCompatible&&(n=this.inputBuffer.textures[0].type),e.MRTCompatible||(n=this.inputBuffer.texture.type),e.setRenderer(a),e.setSize(r.width,r.height),e.initialize(a,o,n),this.autoRenderToScreen&&(i.length>0&&(i[i.length-1].renderToScreen=!1),e.renderToScreen&&(this.autoRenderToScreen=!1)),void 0!==t?i.splice(t,0,e):i.push(e),this.autoRenderToScreen&&(i[i.length-1].renderToScreen=!0),e.needsDepthTexture||null!==this.depthTexture)if(null===this.depthTexture){let t=this.createDepthTexture();for(e of i)e.setDepthTexture(t)}else e.setDepthTexture(this.depthTexture)}setHelperStartIndex(e){this.helperStartIndex=e}removePass(e){let t=this.passes,n=t.indexOf(e);if(-1!==n&&t.splice(n,1).length>0){if(null!==this.depthTexture){let n=(e,t)=>e||t.needsDepthTexture;t.reduce(n,!1)||e.getDepthTexture()===this.depthTexture&&e.setDepthTexture(null)}this.autoRenderToScreen&&n===t.length&&(e.renderToScreen=!1,t.length>0&&(t[t.length-1].renderToScreen=!0))}}removeAllPasses(){let e=this.passes;e.length>0&&(this.autoRenderToScreen&&(e[e.length-1].renderToScreen=!1),this.passes=[])}render(e){let t,n,i,a,r=this.renderer,o=this.copyPass,s=this.inputBuffer,l=this.outputBuffer,c=this.inputBufferSingle,d=this.outputBufferSingle,u=!1;void 0===e&&(e=this.timer.update().getDelta());for(let f of this.passes)f.enabled&&(f.MRTCompatible?f.render(r,s,l,e,u):f.render(r,c,d,e,u),f.needsSwap&&(u&&(o.renderToScreen=f.renderToScreen,t=r.getContext(),n=r.state.buffers.stencil,n.setFunc(t.NOTEQUAL,1,4294967295),o.render(r,s,l,e,u),n.setFunc(t.EQUAL,1,4294967295)),i=s,a=c,s=l,c=d,l=i,d=a),f instanceof V?u=!0:f instanceof I&&(u=!1))}setSize(e,t,n){let i=this.renderer;if(this._width=e,this._height=t,void 0===e||void 0===t){let n=i.getSize(new pe);e=n.width,t=n.height}i.setSize(e,t,n);let a=i.getDrawingBufferSize(new pe);this.inputBuffer.setSize(a.width,a.height),this.outputBuffer.setSize(a.width,a.height),this.inputBufferSingle.setSize(a.width,a.height),this.outputBufferSingle.setSize(a.width,a.height);for(let e of this.passes)e.setSize(a.width,a.height)}reset(){let e=this.timer.isAutoResetEnabled();this.dispose(),this.autoRenderToScreen=!0,this.timer.setAutoResetEnabled(e)}dispose(){for(let e of this.passes)e.dispose();this.passes=[],null!==this.inputBuffer&&this.inputBuffer.dispose(),null!==this.outputBuffer&&this.outputBuffer.dispose(),null!==this.inputBufferSingle&&this.inputBufferSingle.dispose(),null!==this.outputBufferSingle&&this.outputBufferSingle.dispose(),this.deleteDepthTexture(),this.copyPass.dispose(),this.timer.dispose()}},oc=new Xt({name:"CombineMaterial",uniforms:{inputBufferA:new je(null),inputBufferB:new je(null)},blending:Ln,depthWrite:!1,depthTest:!1,vertexShader:"\nvarying vec2 vUv;\nvoid main() {\n gl_Position = vec4(position.xy, 1.0, 1.0);\n vUv = position.xy * 0.5 + 0.5;\n}\n",fragmentShader:"\n varying vec2 vUv;\n uniform sampler2D inputBufferA;\n uniform sampler2D inputBufferB;\n\n \n layout(location = 1) out vec4 gVelocity;\n\n void main() {\n\tvec4 resA = texture2D(inputBufferA, vUv);\n\tvec4 resB = texture2D(inputBufferB, vUv);\n float a = resA.a + resB.a * ( 1.0 - resA.a );\n\n\tvec4 res;\n\tres.rgb = resA.rgb + (resB.rgb * (1.0 - resA.a));\n\tres.a = resA.a + resB.a * (1.0 - resA.a);\n\tgl_FragColor = res;\n gVelocity = vec4(0.0);\n }\n"}),sc=class extends U{constructor(e){super("HelperPass",void 0,e),this.MRTCompatible=!1,this._width=10,this._height=10,this.fullscreenMaterial=oc,this.helperPass=new ac(!1,void 0,this.camera),this.helperPass.hasTransmissionPass=!1,this.helperPass.clear=!1,this.helperPass.renderToScreen=!1,this.helperPassOnTop=new ac(!1,void 0,this.camera),this.helperPassOnTop.hasTransmissionPass=!1,this.helperPassOnTop.clear=!1,this.helperPassOnTop.renderToScreen=!1,this.rt=new Xe(10,10,{minFilter:qn,magFilter:qn,wrapS:Rn,wrapT:Rn,depthBuffer:!0})}_ensureEffectPass(){if(this.effectPass)return this.effectPass;let e=new X({preset:W.LOW,edgeDetectionMode:L.COLOR});return e.addEventListener("load",()=>this.onSmaaTexturesLoaded?.()),this.effectPass=new z(this.camera,e),this._initializeArgs&&this.effectPass.initialize(...this._initializeArgs),this.effectPass.setSize(this._width,this._height),this.effectPass}setSize(e,t){this._width=e,this._height=t,this.rt.setSize(e,t),this.effectPass?.setSize(e,t)}set sceneHelpers(e){this.helperPass.setScene(e)}get sceneHelpers(){return this.helperPass.getScene()}set sceneHelpersOnTop(e){this.helperPassOnTop.setScene(e)}get sceneHelpersOnTop(){return this.helperPassOnTop.getScene()}setCamera(e){this.helperPass.setCamera(e),this.helperPassOnTop.setCamera(e)}initialize(e,t,n){super.initialize(e,t,n),this._initializeArgs=[e,t,n],this.effectPass?.initialize(e,t,n)}dispose(){super.dispose(),this.rt.dispose(),this.effectPass?.dispose(),this.helperPass.dispose(),this.helperPassOnTop.dispose()}render(e,t,n){this.rt.depthTexture=t.depthTexture;let i=e.getClearAlpha();e.setClearAlpha(0),this.helperPass.clearDepth=!0,this.helperPass.clearColorOnly=!0,this.helperPass.render(e,this.rt),this.helperPassOnTop.render(e,this.rt);let a=this._ensureEffectPass();a.renderToScreen=!1,a.render(e,this.rt,n),this.fullscreenMaterial.uniforms.inputBufferA.value=n.texture,this.fullscreenMaterial.uniforms.inputBufferB.value=t.texture,e.setClearAlpha(i),e.setRenderTarget(null),e.clear(),e.render(this.scene,this.camera)}},lc=new Xt({vertexShader:"#define GLSLIFY 1\n#include <skinning_pars_vertex>\n#include <morphtarget_pars_vertex>\nout vec3 n;void main(){\n#include <beginnormal_vertex>\n#include <morphnormal_vertex>\n#include <skinbase_vertex>\n#include <skinnormal_vertex>\n#include <defaultnormal_vertex>\n#include <begin_vertex>\n#include <morphtarget_vertex>\n#include <skinning_vertex>\nvec4 view_space=viewMatrix*modelMatrix*vec4(transformed,1.0);gl_Position=projectionMatrix*view_space;n=normalize(transformedNormal);}",fragmentShader:"#define GLSLIFY 1\nin vec3 n;void main(){gl_FragColor=vec4(gl_FrontFacing ? n :-n,1.0);}",side:Cn}),cc=new Xt({vertexShader:"#define GLSLIFY 1\nout vec2 v_uv;void main(){gl_Position=vec4(position.xy,1.0,1.0);v_uv=uv;}",fragmentShader:"#define GLSLIFY 1\nin vec2 v_uv;uniform sampler2D texture_ao_lrez;uniform sampler2D texture_depth_lrez;uniform sampler2D texture_depth_hrez;uniform float near;uniform float far;float linearize_depth(float depth_sampled){float z=depth_sampled*2.0-1.0;return(2.0*near*far)/(far+near-z*(far-near));}vec2 nearest_depth_filter(in vec2 uv){vec2 resolution=vec2(textureSize(texture_depth_lrez,0));vec2 texel_size=1.0/resolution;vec2 offset=uv-0.5*texel_size;float d_hrez=texture(texture_depth_hrez,uv).r;float a=abs(d_hrez-texture(texture_depth_lrez,offset).r);float b=abs(d_hrez-texture(texture_depth_lrez,offset+vec2(texel_size.x,0.0)).r);float c=abs(d_hrez-texture(texture_depth_lrez,offset+vec2(0.0,texel_size.y)).r);float d=abs(d_hrez-texture(texture_depth_lrez,offset+vec2(texel_size.x,texel_size.y)).r);float min_diff=min(a,min(b,min(c,d)));if(min_diff==a)return offset;if(min_diff==b)return offset+vec2(texel_size.x,0.0);if(min_diff==c)return offset+vec2(0.0,texel_size.y);if(min_diff==d)return offset+vec2(texel_size.x,texel_size.y);}void main(){\n#ifdef DEBUG\nfloat d_lrez=texture(texture_depth_lrez,v_uv).r;float d_hrez=texture(texture_depth_hrez,v_uv).r;float output_d=mix(linearize_depth(d_lrez)/far,linearize_depth(d_hrez)/far,step(0.5,v_uv.x));gl_FragColor=vec4(vec3(output_d),1.0);\n#else\nvec2 filtered_uv=nearest_depth_filter(v_uv);vec4 ao=texture(texture_ao_lrez,filtered_uv);gl_FragColor=vec4(ao.rgb,1.0);gl_FragColor=ao;\n#endif\n}",uniforms:{texture_ao_lrez:new je(null),texture_depth_lrez:new je(null),texture_depth_hrez:new je(null),near:new je(null),far:new je(null)}}),dc=class extends U{constructor(e,t){super("AmbientOcclusionPass",void 0,t),this.fogEnabled=!1,this.fogNear=1,this.fogFar=1e3,this.fogMode=0,this.fogHeightParams=new Te(.005,.01,0),this.frameIndex=0,this.sanitizeViewport=!1,this._runHalfRes=!0,this._width=1,this._height=1;let n=1024,i=1024;this.gBuffer=new Xe(n,i,{type:s?re:ee,depthTexture:new de(n,i),minFilter:qn,magFilter:qn}),this.depthBufferHighRes=new Xe(n,i,{depthTexture:new de(n,i)}),this.aoBuffer=new Xe(n,i,{minFilter:qn,magFilter:qn}),this.splineScene=e,this.splineCamera=t,this.hbaoMaterial=new Xt({vertexShader:"#define GLSLIFY 1\nout vec2 v_uv;void main(){v_uv=uv;gl_Position=vec4(position.xy,1.0,1.0);}",fragmentShader:"precision highp float;precision highp int;precision highp sampler2D;\n#define GLSLIFY 1\nin vec2 v_uv;const float pi=3.14159265;const float num_steps=4.0;const float num_directions=4.0;uniform float near;uniform float far;uniform float fov;uniform vec4 proj_info;uniform bool is_ortho;uniform vec2 resolution;uniform float radius_of_influence;uniform float radius_in_screen_space;uniform float exponent;uniform vec3 ao_color;uniform float bias;uniform sampler2D texture_depth;uniform sampler2D texture_normals;uniform sampler2D texture_blue_noise;uniform sampler2D texture_color_pass;const vec2 blue_noise_in_disk[16]=vec2[16](vec2(0.4787119925022125,0.875764012336731),vec2(-0.3379560112953186,-0.7939590215682983),vec2(-0.9552590250968933,-0.028163999319076538),vec2(0.8645269870758057,0.3256889879703522),vec2(0.20934200286865234,-0.3956570029258728),vec2(-0.10677900165319443,0.6725850105285645),vec2(0.15621300041675568,0.2351129949092865),vec2(-0.4136439859867096,-0.08285599946975708),vec2(-0.41566699743270874,0.3239090144634247),vec2(0.14189599454402924,-0.9399799704551697),vec2(0.9549319744110107,-0.18251599371433258),vec2(-0.7661839723587036,0.4107989966869354),vec2(-0.4349119961261749,-0.45884498953819275),vec2(0.4152419865131378,-0.07872399687767029),vec2(0.7283350229263306,-0.4917770028114319),vec2(-0.05808600038290024,-0.06640099734067917));uniform int frame_index;uniform bool fog_enabled;uniform float fog_near;uniform float fog_far;uniform float fog_mode;uniform vec3 fog_height_params;uniform mat4 camera_world_matrix;float height_fog_factor(vec3 fog_world_delta,float fog_dist,vec3 camera_world_pos){float density=fog_height_params.x;float falloff=fog_height_params.y;float rel_y=camera_world_pos.y-fog_height_params.z;float cam_density=density*exp(clamp(-falloff*rel_y,-60.0,60.0));float x=clamp(falloff*fog_world_delta.y,-60.0,60.0);float x_safe=(x>=0.0 ? 1.0 :-1.0)*max(abs(x),1e-4);float optical_depth=cam_density*fog_dist*(1.0-exp(-x_safe))/x_safe;return 1.0-exp(-max(optical_depth,0.0));}vec3 uv_to_view_space(vec2 uv,float eye_z){return vec3((uv*proj_info.xy+proj_info.zw)*(is_ortho ? 1.0 : eye_z),eye_z);}float linearize_depth(float depth_sampled){float z=is_ortho ? depth_sampled : depth_sampled*2.0-1.0;return mix((2.0*near*far)/(far+near-z*(far-near)),near+z*(far-near),float(is_ortho));}vec3 get_view_position(vec2 uv_coords){float linear_depth=linearize_depth(texture(texture_depth,uv_coords).x);return uv_to_view_space(uv_coords,linear_depth);}vec3 min_difference(vec3 p,vec3 right,vec3 left){vec3 v1=right-p;vec3 v2=p-left;return(dot(v1,v1)<dot(v2,v2))? v1 : v2;}vec3 rebuild_normal(in vec2 uv,in vec3 p){vec2 one_over_resolution=1.0/resolution;vec3 r=get_view_position(uv+vec2(one_over_resolution.x,0));vec3 l=get_view_position(uv+vec2(-one_over_resolution.x,0));vec3 t=get_view_position(uv+vec2(0,one_over_resolution.y));vec3 b=get_view_position(uv+vec2(0,-one_over_resolution.y));return normalize(cross(min_difference(p,r,l),min_difference(p,t,b)));}float falloff(float distance_squared){float neg_inv_r2=-1.0/(radius_of_influence*radius_of_influence);return distance_squared*neg_inv_r2+1.0;}float ao_contribution(vec3 P,vec3 N,vec3 S){vec3 to_sample=S-P;float norm_squared=dot(to_sample,to_sample);float norm=sqrt(norm_squared);float cos_theta=dot(N,to_sample)/max(norm,1e-4);return clamp(cos_theta-bias,0.0,1.0)*clamp(falloff(norm_squared),0.0,1.0);}float compute_ambient_occlusion(vec2 uv,float radius_in_screen_space,vec3 pc,vec3 view_space_n){vec2 one_over_resolution=1.0/resolution;ivec2 noise_uv=ivec2(gl_FragCoord.xy)&ivec2(127);float noise=texelFetch(texture_blue_noise,noise_uv,0).r;noise=fract(noise+0.61803398875*float(frame_index));float theta=noise*2.0*3.1415;float ct=cos(theta);float st=sin(theta);float step_size=radius_in_screen_space/(num_steps+1.0);const float angle_step=2.0*pi/num_directions;float contribution=0.0;for(int i=0;i<int(num_directions);++i){float current_pixel=step_size+1.0;for(int j=0;j<int(num_steps);++j){int index=i*int(num_steps)+j;vec2 blue_noise_sample=blue_noise_in_disk[index];vec2 disk_point;disk_point.x=blue_noise_sample.x*ct-blue_noise_sample.y*st;disk_point.y=blue_noise_sample.x*st+blue_noise_sample.y*ct;vec2 sample_direction=disk_point;vec2 snapped_uv=round(current_pixel*sample_direction)*one_over_resolution+uv;vec3 ps=get_view_position(snapped_uv);current_pixel+=step_size;contribution+=ao_contribution(pc,view_space_n,ps);}}float mult=1.0/(1.0-bias);contribution*=mult/(num_directions*num_steps);return clamp(1.0-contribution*2.0,0.0,1.0);}\n#define USE_GBUFFER_NORMALS\nvoid main(){vec3 view_space_p=get_view_position(v_uv);\n#ifdef USE_GBUFFER_NORMALS\nvec3 view_space_n=texture(texture_normals,v_uv).rgb;view_space_n.z*=-1.0;\n#else\nvec3 view_space_n=-rebuild_normal(v_uv,view_space_p);\n#endif\nfloat radius_ss=max(radius_in_screen_space/(is_ortho ? 1.0 : view_space_p.z),num_steps+1.0);float ao=compute_ambient_occlusion(v_uv,radius_ss,view_space_p,view_space_n);float final=pow(ao,exponent);if(view_space_p.z>=far){final=1.0;}vec3 color=mix(ao_color,vec3(1.0),final);if(fog_enabled){float fog_linear=smoothstep(fog_near,fog_far,view_space_p.z);vec3 world_p=(camera_world_matrix*vec4(view_space_p.xy,-view_space_p.z,1.0)).xyz;vec3 cam_pos=camera_world_matrix[3].xyz;float fog_height=height_fog_factor(world_p-cam_pos,max(length(world_p-cam_pos),1e-6),cam_pos);float w_linear=1.0-step(0.5,fog_mode)+step(1.5,fog_mode);float w_height=step(0.5,fog_mode);float fog_factor=1.0-(1.0-fog_linear*w_linear)*(1.0-fog_height*w_height);color=mix(color,vec3(1.0),fog_factor);}gl_FragColor=vec4(color,1.0);}",uniforms:{near:new je(null),far:new je(null),fov:new je(null),proj_info:new je(new Fe),is_ortho:new je(!1),resolution:new je(new pe),radius_of_influence:new je(8),radius_in_screen_space:new je(1),exponent:new je(1),ao_color:new je(new Te),bias:new je(.5),texture_depth:new je(null),texture_normals:new je(null),texture_blue_noise:new je(null),frame_index:new je(0),fog_enabled:new je(!1),fog_near:new je(1),fog_far:new je(1e3),fog_mode:new je(0),fog_height_params:new je(new Te(.005,.01,0)),camera_world_matrix:new je(new tt)}}),this.radius=128,this.aoColor={r:0,g:0,b:0},this.bias=.5,this.hbaoMaterial.uniforms.texture_depth.value=this.gBuffer.depthTexture,this.hbaoMaterial.uniforms.texture_normals.value=this.gBuffer.texture,this.needsSwap=!0,this.aaBuffer=new Xe(n,i,{minFilter:qn,magFilter:qn,wrapS:Rn,wrapT:Rn,depthBuffer:!1,type:ee})}_ensureEffectPass(){if(this.effectPass)return this.effectPass;let e=new X({preset:W.ULTRA,edgeDetectionMode:L.COLOR});e.addEventListener("load",()=>this.onSmaaTexturesLoaded?.()),this.effectPass=new z(this.camera,e),this._initializeArgs&&this.effectPass.initialize(...this._initializeArgs);let t=this._runHalfRes?.5:1;return this.effectPass.setSize(this._width*t,this._height*t),this.effectPass}initialize(e,t,n){super.initialize(e,t,n),this._initializeArgs=[e,t,n],this.effectPass?.initialize(e,t,n)}setBlueNoiseTexture(e){this.hbaoMaterial.uniforms.texture_blue_noise.value=e}setSize(e,t){this._width=e,this._height=t,this.depthBufferHighRes.setSize(e,t);let n=this._runHalfRes?.5:1,i=e*n,a=t*n;this.gBuffer.setSize(i,a),this.aoBuffer.setSize(i,a),this.hbaoMaterial.uniforms.resolution.value.set(i,a),this.aaBuffer.setSize(i,a),this.effectPass?.setSize(i,a)}get runHalfRes(){return this._runHalfRes}set runHalfRes(e){this._runHalfRes=e,this.setSize(this._width,this._height)}setCamera(e){this.splineCamera=e}setScene(e){this.splineScene=e}setDepthTexture(e){this.depthBufferHighRes.depthTexture=e,cc.uniforms.texture_depth_hrez.value=e,cc.needsUpdate=!0}render(e,t,n){let i=null,a=null,r=null,o=null,s=t=>{e.setViewport(0,0,t.width,t.height)};this.sanitizeViewport&&(i=new Fe,a=new Fe,e.getViewport(i),e.getScissor(a),r=e.getScissorTest(),o=e.getRenderTarget(),e.setScissorTest(!1)),this.splineScene.overrideMaterial=lc;let l=this.splineCamera.layers.mask;if(this.splineCamera.layers.set(5),e.setRenderTarget(this.gBuffer),this.sanitizeViewport&&s(this.gBuffer),e.clear(),e.render(this.splineScene,this.splineCamera),this.runHalfRes&&(lc.colorWrite=!1,e.setRenderTarget(this.depthBufferHighRes),this.sanitizeViewport&&s(this.depthBufferHighRes),e.clear(),e.render(this.splineScene,this.splineCamera),lc.colorWrite=!0,e.state.buffers.color.setMask(!0)),this.splineScene.overrideMaterial=null,this.splineCamera.layers.mask=l,this.hbaoMaterial.uniforms.radius_of_influence.value=this.radius,this.hbaoMaterial.uniforms.ao_color.value.set(this.aoColor.r,this.aoColor.g,this.aoColor.b),this.hbaoMaterial.uniforms.bias.value=this.bias,this.hbaoMaterial.uniforms.fog_enabled.value=this.fogEnabled,this.hbaoMaterial.uniforms.fog_near.value=this.fogNear,this.hbaoMaterial.uniforms.fog_far.value=this.fogFar,this.hbaoMaterial.uniforms.fog_mode.value=this.fogMode,this.hbaoMaterial.uniforms.fog_height_params.value.copy(this.fogHeightParams),this.hbaoMaterial.uniforms.camera_world_matrix.value.copy(this.splineCamera.matrixWorld),this.hbaoMaterial.uniforms.frame_index.value=this.frameIndex,this.frameIndex++,this.splineCamera.isPerspectiveCamera){this.hbaoMaterial.uniforms.near.value=this.splineCamera.perspCamera.near,this.hbaoMaterial.uniforms.far.value=this.splineCamera.perspCamera.far;let e=this.splineCamera.perspCamera.projectionMatrix.elements,t=2/e[0],n=2/e[5],i=-(1-e[8])/e[0],a=-(1+e[9])/e[5];this.hbaoMaterial.uniforms.proj_info.value.set(t,n,i,a);let r=this.splineCamera.perspCamera.fov*(Math.PI/180),o=this.hbaoMaterial.uniforms.resolution.value.y/(2*Math.tan(.5*r)),s=.5*this.hbaoMaterial.uniforms.radius_of_influence.value*o;this.hbaoMaterial.uniforms.radius_in_screen_space.value=s,this.hbaoMaterial.uniforms.is_ortho.value=!1}else{this.hbaoMaterial.uniforms.near.value=this.splineCamera.orthoCamera.near,this.hbaoMaterial.uniforms.far.value=this.splineCamera.orthoCamera.far;let e=this.splineCamera.orthoCamera.projectionMatrix.elements,t=2/e[0],n=2/e[5],i=-(1+e[12])/e[0],a=-(1-e[13])/e[5];this.hbaoMaterial.uniforms.proj_info.value.set(t,n,i,a);let r=this.hbaoMaterial.uniforms.resolution.value.y/n*.5,o=this.hbaoMaterial.uniforms.radius_of_influence.value*r;this.hbaoMaterial.uniforms.radius_in_screen_space.value=o,this.hbaoMaterial.uniforms.is_ortho.value=!0}let c=e.aoRenderTarget;if(this.runHalfRes)this.fullscreenMaterial=this.hbaoMaterial,e.setRenderTarget(this.aoBuffer),this.sanitizeViewport&&s(this.aoBuffer),e.clear(),e.render(this.scene,this.camera),this.fullscreenMaterial=cc,cc.uniforms.texture_ao_lrez.value=this.aoBuffer.texture,cc.uniforms.texture_depth_lrez.value=this.gBuffer.depthTexture,cc.uniforms.texture_depth_hrez.value=this.depthBufferHighRes.depthTexture,e.setRenderTarget(c),this.sanitizeViewport&&s(c),e.clear(),e.render(this.scene,this.camera);else{this.fullscreenMaterial=this.hbaoMaterial,e.setRenderTarget(this.aaBuffer),this.sanitizeViewport&&s(this.aaBuffer),e.clear(),e.render(this.scene,this.camera);let t=this._ensureEffectPass();t.renderToScreen=!1,t.render(e,this.aaBuffer,c)}this.sanitizeViewport&&i&&a&&null!==r&&(e.setRenderTarget(o),e.setViewport(i.x,i.y,i.z,i.w),e.setScissor(a.x,a.y,a.z,a.w),e.setScissorTest(r))}dispose(){super.dispose(),this.gBuffer.dispose(),this.depthBufferHighRes.dispose(),this.aoBuffer.dispose(),this.aaBuffer.dispose(),this.effectPass?.dispose(),this.hbaoMaterial.dispose(),this.splineScene=null,this.splineCamera=null}},uc=class extends H{constructor(){super(new Xt({vertexShader:"\nvarying vec2 vUv;\nvoid main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"\nuniform sampler2D tInput;\nuniform sampler2D tMap;\nuniform vec2 resolution;\nvarying vec2 vUv;\n\nuniform vec2 uResolution;\nuniform vec2 uCoords;\n\n\nfloat rectangle(vec2 st, vec2 size) {\n size = vec2(0.5) - size * 0.5;\n vec2 uv = vec2(step(size.x, st.x), step(size.y, st.y));\n uv *= vec2(step(size.x, 1.0 - st.x), step(size.y, 1.0 - st.y));\n\n return uv.x * uv.y;\n}\n\nuniform vec2 uSize;\nuniform float uScale;\nuniform float uDPR;\nuniform float uCurrent;\nuniform vec3 uSceneColor;\n\nvoid main() {\n vec2 screenUv = gl_FragCoord.xy / uResolution.xy;\n screenUv *= 1.0 / uDPR;\n\n vec2 center = vec2(0.5, -0.5);\n vec2 outsideUv = screenUv;\n outsideUv += center;\n outsideUv -= uCoords.xy / uResolution.xy;\n outsideUv = (outsideUv - 0.5) + 0.5;\n outsideUv -= center;\n vec2 s = (uSize / uResolution) * uScale;\n float isOutside = 1.0 - rectangle(outsideUv, s);\n \n vec2 mid = vec2(0.5);\n vec2 insideUv = (screenUv - mid + s * mid) / s;\n vec4 background = texture2D(tInput, screenUv);\n vec4 image = texture2D(tMap, insideUv);\n gl_FragColor = mix(image, background, isOutside);\n}\n",uniforms:{tInput:new je(null),tMap:new je(null),uResolution:new je(new pe),uSize:new je(new pe),uCoords:new je(new pe),uScale:new je(1),uSceneColor:new je(new ft(16711680)),uDPR:new je(1),uCurrent:new je(0)}}),"tInput"),this.needsSwap=!0}get uniforms(){return this.fullscreenMaterial.uniforms}get texture(){return this.uniforms.tMap.value}set texture(e){this.uniforms.tMap.value=e}},fc=[],pc=class extends H{constructor(){super(new Xt({vertexShader:"\nvoid main() {\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"\nuniform sampler2D toScene;\nuniform sampler2D fromScene;\nuniform vec2 resolution;\n\nuniform vec2 uResolution;\nuniform float uDPR;\n\nuniform float mixRatio;\nuniform sampler2D tMixTexture;\nuniform int useTexture;\nuniform float threshold;\n\nvoid main() {\n\tvec2 screenUv = gl_FragCoord.xy / uResolution.xy;\n\tscreenUv *= 1.0 / uDPR;\n\n\tvec4 texel1 = texture2D( fromScene, screenUv );\n\tvec4 texel2 = texture2D( toScene, screenUv );\n\n\tif (useTexture==1) {\n\t\t\n\t\tvec4 transitionTexel = texture2D( tMixTexture, screenUv );\n\t\tfloat r = mixRatio * (1.0 + threshold * 2.0) - threshold;\n\t\tfloat mixf=clamp((transitionTexel.r - r)*(1.0/threshold), 0.0, 1.0);\n\t\t\n\t\tgl_FragColor = mix( texel1, texel2, mixf );\n\t} else {\n\t\t\n\t\tgl_FragColor = mix( texel1, texel2, mixRatio );\n\t\t\n\t}\n}\n",uniforms:{toScene:new je(null),fromScene:new je(null),uResolution:new je(new pe),uDPR:new je(1),mixRatio:new je(0),threshold:new je(.1),useTexture:new je(0),tMixTexture:{value:fc[0]}}}),"toScene"),this.needsSwap=!0}get uniforms(){return this.fullscreenMaterial.uniforms}get texture(){return this.uniforms.fromScene.value}set texture(e){this.uniforms.fromScene.value=e}},hc=class extends H{constructor(){super(new Xt({vertexShader:"\nvoid main() {\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"\nuniform sampler2D inputBuffer;\nuniform sampler2D blurredInputBuffer;\nuniform sampler2D overlay;\nuniform float blurIntensity;\n\nuniform vec2 uResolution;\nuniform float uDPR;\n\nvoid main() {\n\tvec2 screenUv = gl_FragCoord.xy / uResolution.xy;\n\tscreenUv *= 1.0 / uDPR;\n\n\tvec4 texel1 = texture2D( overlay, screenUv );\n\tvec4 texel2 = texture2D( inputBuffer, screenUv );\n\tvec4 texel3 = texture2D( blurredInputBuffer, screenUv );\n\n\tfloat blurMask2 = max(sign(texel1.a), 0.0) * blurIntensity;\n gl_FragColor = mix( mix(texel2, texel3, blurMask2), texel1, texel1.a );\n}\n",uniforms:{inputBuffer:new je(null),blurredInputBuffer:new je(null),overlay:new je(null),uResolution:new je(new pe),uDPR:new je(1),blurIntensity:new je(0)}})),this._blurEnabled=!1,this.blurTarget=new Xe(1,1,{minFilter:qn,magFilter:qn,wrapS:Rn,wrapT:Rn}),this.blurPass=new B({width:window.innerWidth,height:window.innerHeight,kernelSize:k.HUGE,resolutionScale:.25}),this.blurPass.renderToScreen=!1,this.uniforms.blurredInputBuffer.value=this.blurTarget.texture}get uniforms(){return this.fullscreenMaterial.uniforms}get texture(){return this.uniforms.overlay.value}set texture(e){this.uniforms.overlay.value=e}setResolution(e,t,n=1){this.uniforms.uResolution.value.set(e,t),this.uniforms.uDPR.value=n,this.blurPass.setSize(e,t),this.blurTarget.setSize(e,t),this.blurPass.setSize(e,t)}get uiCanvas(){return this._uiCanvas}set uiCanvas(e){this._uiCanvas=e,e.texture&&(this.uniforms.overlay.value=e.texture);let t=e.frame;if(t){let e=t.data.backgroundBlur,n=e.radius;this._blurEnabled=e.enabled,this.uniforms.blurIntensity.value=this._blurEnabled?1:0,this.blurPass.scale=n/3}}render(e,t,n,i,a){this._blurEnabled&&(this.blurPass.setDepthTexture(this.getDepthTexture()),this.blurPass.render(e,t,this.blurTarget,i,a)),super.render(e,t,n,i,a)}dispose(){super.dispose(),this.blurTarget.dispose(),this.blurPass.dispose(),this.fullscreenMaterial.dispose(),this._uiCanvas=void 0}},mc=class extends H{constructor(){super(new Xt({vertexShader:"\nvarying vec2 vUv;\nvoid main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"\nuniform sampler2D tInput;\nuniform sampler2D tOverlayImage;\nvarying vec2 vUv;\nuniform vec2 uResolution;\nuniform vec2 uRightBottom;\nuniform vec2 uImageSize;\nuniform float uScale;\nuniform float uDPR;\n\nvec3 blendNormal(vec3 base, vec3 blend) {\n\treturn blend;\n}\n\nvec3 blendNormal(vec3 base, vec3 blend, float opacity) {\n\treturn (blendNormal(base, blend) * opacity + base * (1.0 - opacity));\n}\n\nvec4 drawFixedSizeImage(sampler2D image, vec2 screenUV, vec2 imageSize, vec2 imageCoords, vec2 screenSize, float dpr) {\n\tvec2 uv = (screenUV * screenSize * dpr - imageCoords) / (imageSize * dpr);\n\tif (uv.x < 0.0 || uv.x > 1.0 || uv.y < 0.0 || uv.y > 1.0) {\n\t\treturn vec4(0.0);\n\t}\n\treturn texture2D(image, uv);\n}\n\nvoid main() {\n vec2 screenUV = gl_FragCoord.xy / (uResolution.xy * uDPR);\n\tvec2 imageCoords = vec2(uResolution.x * uDPR - uImageSize.x * uScale * uDPR - uRightBottom.x * uDPR, uRightBottom.y * uDPR);\n vec4 background = texture2D(tInput, screenUV);\n vec4 image = drawFixedSizeImage(tOverlayImage, screenUV, uImageSize * uScale, imageCoords, uResolution, uDPR);\n gl_FragColor = vec4(blendNormal(background.rgb, image.rgb, image.a), max(background.a, image.a));\n}\n",uniforms:{tInput:new je(null),tOverlayImage:new je(null),uResolution:new je(new pe),uImageSize:new je(new pe),uRightBottom:new je(new pe(20,20)),uScale:new je(.25),uDPR:new je(1)}}),"tInput")}get uniforms(){return this.fullscreenMaterial.uniforms}get texture(){return this.uniforms.tOverlayImage.value}set texture(e){this.uniforms.tOverlayImage.value=e;let t=e.image;this.uniforms.uImageSize.value.set(t.width,t.height)}},vc=class extends H{constructor(){super(new Xt({vertexShader:"\nvarying vec2 vUv;\nvoid main() {\n\tvUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"\nuniform sampler2D inputBuffer;\nvarying vec2 vUv;\n\nvec3 SrgbToLinear(vec3 color) {\n\t\n\tvec3 sRGB = color.rgb;\n\tcolor.rgb = sRGB * (sRGB * (sRGB * 0.305306011 + 0.682171111) + 0.012522878);\n\treturn color;\n}\n\nvoid main() {\n\tvec4 texel = texture2D(inputBuffer, vUv);\n\ttexel.rgb = SrgbToLinear(texel.rgb);\n gl_FragColor = texel;\n}\n",uniforms:{inputBuffer:new je(null),uResolution:new je(new pe),uDPR:new je(1)}}),"inputBuffer"),this.needsSwap=!0}get uniforms(){return this.fullscreenMaterial.uniforms}};function gc(e,t){return t&&t.enabled&&e.push(t.effect),e}var _c=e=>Object.values(F).includes(e)?e:F.NORMAL,xc=class extends oe{constructor(e,t){super(),this._needsDOFResize=t,this.postprocessingState=A.defaultData,this._scene=new gt,this._camera=new l,this.effects=new Map,this.blueNoiseTexture=new Bn,this._renderToScreen=!0,this._isUIOverlayEnabled=!1,this.timer=new ze,this.renderer=e,this.debug=!1;for(let[e,t]of $())this.effects.set(e,t());this.effectComposer=new rc(this.renderer),this.effectComposer.autoRenderToScreen=!1,this.opaquePass=new ac(!0,this.scene,this.camera),this.opaquePass.clear=!0,this.transmissionPass=new tc(this.scene,this.camera,this.renderer),this.aoPass=new dc(this.scene,this.camera),this.taaPass=new ec,this.taaPass.renderToScreen=!1,this.helperPass=new sc(this.camera),this.helperPass.renderToScreen=!1;let n=()=>{this.dispatchEvent({type:"smaaloaded"})};this.aoPass.onSmaaTexturesLoaded=n,this.helperPass.onSmaaTexturesLoaded=n,this.stylesOverlayPass=new uc,this.stylesOverlayPass.enabled=!1,this.uiOverlayPass=new hc,this.uiOverlayPass.enabled=!1,this.logoOverlayPass=new mc,this.logoOverlayPass.enabled=!1,this.sceneTransitionPass=new pc,this.sceneTransitionPass.enabled=!1,this.srgbToLinear=new vc,this.srgbToLinear.enabled=!1,this._initCopyPass(),this._initPasses()}set overlayTexture(e){void 0!==e?(this.stylesOverlayPass.texture=e,this.stylesOverlayPass.enabled=!0):this.stylesOverlayPass.enabled=!1}get overlayTexture(){return this.stylesOverlayPass.texture}set sceneHelpers(e){this.helperPass.sceneHelpers=e}get sceneHelpers(){return this.helperPass.sceneHelpers}set sceneHelpersOnTop(e){this.helperPass.sceneHelpersOnTop=e}get sceneHelpersOnTop(){return this.helperPass.sceneHelpersOnTop}get scene(){return this._scene}set scene(e){this._scene=e,this.opaquePass.setScene(e),this.transmissionPass.setScene(e),this.aoPass.setScene(e)}get camera(){return this._camera}set camera(e){let t=this._camera!==e;this._camera=e,this.opaquePass.setCamera(e),this.transmissionPass.setCamera(e),t&&this.transmissionPass.updatePasses(this.renderer),this.aoPass.setCamera(e),this.helperPass.setCamera(e),this.effects.get("depthOfField")?.setCamera(e)}updateRenderToScreen(){let e=!1;for(let t=this.effectComposer.passes.length-1;t>=0;t--){let n=this.effectComposer.passes[t];!0!==n.enabled||e||!this._renderToScreen?n.renderToScreen=!1:(n.renderToScreen=!0,e=!0)}}get isUIOverlayEnabled(){return this._isUIOverlayEnabled}disableUIOverlay(){this._isUIOverlayEnabled=!1}enableUIOverlay(){this._isUIOverlayEnabled=!0}disableHelpers(){this.helperPass.enabled=!1,this.updateRenderToScreen()}enableHelpers(){this.helperPass.enabled=!0,this.updateRenderToScreen()}updateBlueNoiseTexture(e){this.blueNoiseTexture=new Bn(e,128,128),this.blueNoiseTexture.wrapS=wn,this.blueNoiseTexture.wrapT=wn,this.blueNoiseTexture.minFilter=On,this.blueNoiseTexture.magFilter=On,this.blueNoiseTexture.needsUpdate=!0}setAmbientOcclusionParams(e,t,n,i,a,r,o,s,l){this.aoPass.enabled=e,this.aoPass.radius=t,this.aoPass.bias=n,this.aoPass.aoColor=i,this.aoPass.fogEnabled=a,this.aoPass.fogNear=r,this.aoPass.fogFar=o,this.aoPass.fogMode=R.getModeIndex({mode:s.mode}),this.aoPass.fogHeightParams.set(s.density,s.heightFalloff,s.heightBase),this.aoPass.runHalfRes!==!l&&(this.aoPass.runHalfRes=!l)}setTransmissionPassEnabled(e){this.transmissionPass.enabled=e,this.opaquePass.hasTransmissionPass=e}_initPasses(){if(this.uvEffectPass?.dispose(),this.effectPass?.dispose(),this.effectComposer.removeAllPasses(),this.transmissionPass.updatePasses(this.renderer),this.effectComposer.addPass(this.aoPass),this.effectComposer.addPass(this.opaquePass),this.effectComposer.addPass(this.transmissionPass),this.effectComposer.addPass(this.taaPass),this.postprocessingState.enabled){let e=[this.effects.get("pixelation")].reduce(gc,[]);e.length>0&&(this.uvEffectPass=new z(this.camera,...e),this.uvEffectPass.renderToScreen=!1,this.uvEffectPass.encodeOutput=!1,this.effectComposer.addPass(this.uvEffectPass));let t=[this.effects.get("chromaticAberration"),this.effects.get("bloom"),this.effects.get("depthOfField"),this.effects.get("colorAverage"),this.effects.get("hueSaturation"),this.effects.get("brightnessContrast"),this.effects.get("vignette"),this.effects.get("noise")].reduce(gc,[]);if(t.length>0&&(this.effectPass=new z(this.camera,...t),this.effectPass.renderToScreen=!1,this.effectPass.encodeOutput=!1,this.effectComposer.addPass(this.effectPass),this._needsDOFResize&&this.effects.get("depthOfField")?.enabled&&void 0!==window)){let e=this.renderer.viewportWidth,t=this.renderer.viewportHeight;this.renderer.setSize(e-1,t-1),this.renderer.setSize(e,t)}}this.effectComposer.addPass(this.stylesOverlayPass),this.effectComposer.addPass(this.uiOverlayPass),this.effectComposer.addPass(this.sceneTransitionPass),this.effectComposer.addPass(this.helperPass),this.effectComposer.addPass(this.srgbToLinear),this.effectComposer.addPass(this.logoOverlayPass)}_initCopyPass(){if(this._savePass)return;let e=new pe;this.renderer.getDrawingBufferSize(e),this._rt=new Xe(e.x,e.y,{depthBuffer:!1,stencilBuffer:!1,wrapS:wn,wrapT:wn}),this._rt.samples=0,this.renderer.outputColorSpace===Le&&(this._rt.texture.colorSpace=Le),this._savePass=new N(this._rt,!1),this._savePass.renderToScreen=!1}setCopyPass(e){this._rt=e,this._savePass=new N(this._rt,!1),this.renderToScreen=!1}get renderToScreen(){return this._renderToScreen}set renderToScreen(e){if(this._renderToScreen===e)return;let t=this.effectComposer;!t||(!0===e?t.removePass(this._savePass):t.addPass(this._savePass),this._renderToScreen=e,this.updateRenderToScreen())}get sceneTransitionFromTexture(){return this.sceneTransitionPass.texture}set sceneTransitionFromTexture(e){e!==this.sceneTransitionPass.texture&&(null!==e?this.sceneTransitionPass.enabled=!0:(this.sceneTransitionPass.enabled=!1,this.updateRenderToScreen()),this.sceneTransitionPass.texture=e)}setWatermark(e){this.logoOverlayPass.enabled=null!==e,e&&(this.logoOverlayPass.texture=e)}get texture(){return this._rt&&this._rt.texture}get renderTarget(){return this._rt}updatePostprocessing(e){let{enabled:t,...n}=e,i=!1;t!==this.postprocessingState.enabled&&(i=!0);for(let e of Object.entries(n)){let t=e[1],n=this.effects.get(e[0]);if(!n){let i=j(e[0]);i?(n=i(),this.effects.set(e[0],n),"depthOfField"===e[0]&&n.setCamera(this._camera)):t?.enabled&&q(e[0],"webgl")}if(n){n.enabled!==t.enabled&&(i=!0),n.enabled=t.enabled;for(let[e,i]of Object.entries(t))"blendFunction"===e?n.blendFunction=_c(i):n[e]=i}}this.postprocessingState=e,i&&this._initPasses()}render(){this.renderer.shadowMap.type===tn&&this._normalizeShadowDepthTextures(),this.timer.update(),this.effectComposer.render(this.timer.getDelta())}_normalizeShadowDepthTextures(){this._scene.traverse(e=>{let t=e;if(!t.isLight)return;let n=t.shadow?.map?.depthTexture;n&&null!==n.compareFunction&&(n.compareFunction=null,n.minFilter=On,n.magFilter=On,n.needsUpdate=!0)})}setScissor(e,t,n,i){e instanceof Fe?(this.effectComposer.inputBuffer.scissor.set(e.x,e.y,e.z,e.w),this.effectComposer.outputBuffer.scissor.set(e.x,e.y,e.z,e.w)):(this.effectComposer.inputBuffer.scissor.set(e,t,n,i),this.effectComposer.outputBuffer.scissor.set(e,t,n,i));let a=this.renderer.getPixelRatio();this.effectComposer.inputBuffer.scissor.multiplyScalar(a),this.effectComposer.outputBuffer.scissor.multiplyScalar(a),this.renderer.setScissor(e,t,n,i)}setScissorTest(e){this.effectComposer.inputBuffer.scissorTest=e,this.effectComposer.outputBuffer.scissorTest=e,this.renderer.setScissorTest(e)}setViewport(e,t,n,i){e instanceof Fe?(this.effectComposer.inputBuffer.viewport.copy(e),this.effectComposer.outputBuffer.viewport.copy(e)):(this.effectComposer.inputBuffer.viewport.set(e,t,n,i),this.effectComposer.outputBuffer.viewport.set(e,t,n,i))}resize(e,t,n){if(this.effectComposer.setSize(e,t,n),this._rt){let n=this.renderer.getPixelRatio();this._rt.setSize(e*n,t*n)}}dispose(){this.uvEffectPass?.dispose(),this.effectPass?.dispose(),this.effectComposer.dispose(),this.blueNoiseTexture.dispose(),this._rt?.dispose(),this.effects.forEach(e=>e.dispose()),this.effects.clear(),this._scene=void 0,this._camera=void 0,this.renderer=void 0}},Sc=new Ue,Tc=new pe,bc=class extends Qo{constructor(e){super(e),this._pixelRatio=this.getPixelRatio(),this.viewportWidth=1,this.viewportHeight=1,this.resolution=new pe,this.dummyCamera=new l,this.sceneTransitionDuration=0,this.sceneTransitionTimeRemaining=-1,this.manageShadowUpdates=!1,this.forceShadowUpdates=!1,this.clear=(e=!0,t=!0,n=!0)=>{let i=this.getContext(),a=0;e&&(a|=i.COLOR_BUFFER_BIT),t&&(a|=i.DEPTH_BUFFER_BIT),n&&(a|=i.STENCIL_BUFFER_BIT),i.clear(a),i.clearBufferfv(i.COLOR,1,[0,0,0,1])},(()=>{if(!Jl.test(ya.lights_pars_begin)){if(ya.lights_pars_begin.includes(Zl))return;throw new Error("spe: could not find getDistanceAttenuation in lights_pars_begin — three shader chunk layout changed")}ya.lights_pars_begin=ya.lights_pars_begin.replace(Jl,Zl)})(),this.pipeline=new xc(this,e?.needsDOFResize??!1),this.autoClear=!1;let t=this.setPixelRatio.bind(this),n=this.setSize.bind(this);this.shadowMap.enabled=!0,this.shadowMap.type=tn,this.dummyCamera.matrixAutoUpdate=!1,this.domElement.removeAttribute("data-engine"),this._applyPreferredDrawingBufferColorSpace(),this.setPixelRatio=e=>{this._pixelRatio!==e&&(this._pixelRatio=e,t(e))},this.setSize=(e,t,i=!0)=>{(this.viewportWidth!==e||this.viewportHeight!==t)&&(this.viewportWidth=e,this.viewportHeight=t,n(e,t,i),this.normalRenderTarget?.setSize(e*this._pixelRatio,t*this._pixelRatio),this._resizeTransmission(e,t),this.transmissionDepthTarget?.setSize(e*this._pixelRatio/2,t*this._pixelRatio/2),this.pipeline.resize(e,t,i))},this._superDispose=this.dispose,this.dispose=this._currentDispose}_applyPreferredDrawingBufferColorSpace(){let e=this.getContext();if(e&&"drawingBufferColorSpace"in e)try{e.drawingBufferColorSpace="display-p3"}catch(e){console.warn(e)}}get outputColorSpace(){return super.outputColorSpace}set outputColorSpace(e){super.outputColorSpace=e,this._applyPreferredDrawingBufferColorSpace()}createAORenderTarget(){void 0===this.aoRenderTarget&&(this.aoRenderTarget=new Xe(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{generateMipmaps:!1,minFilter:qn,magFilter:qn,wrapS:Rn,wrapT:Rn,depthBuffer:!1}))}_resizeTransmission(e,t){this.transmissionRenderTarget?.setSize(e*this._pixelRatio/(this.hdTransmission?1:2),t*this._pixelRatio/(this.hdTransmission?1:2)),this.aoRenderTarget?.setSize(e*this._pixelRatio/1,t*this._pixelRatio/1)}get hdTransmission(){return 1===qs.transmissionLod.value}set hdTransmission(e){qs.transmissionLod.value=!0===e?1:2,this._resizeTransmission(this.viewportWidth,this.viewportHeight)}createTransmissionRenderTarget(){void 0===this.transmissionRenderTarget&&(this.transmissionRenderTarget=new Xe(this.viewportWidth*this._pixelRatio/(this.hdTransmission?1:2),this.viewportHeight*this._pixelRatio/(this.hdTransmission?1:2),{generateMipmaps:!0,minFilter:ei,magFilter:qn,wrapS:Rn,wrapT:Rn,depthBuffer:!1}),this.transmissionDepthTarget=new Xe(this.viewportWidth*this._pixelRatio/2,this.viewportHeight*this._pixelRatio/2,{minFilter:On,magFilter:On,depthBuffer:!1}))}createNormalRenderTarget(e){let t=e.outline&&e.cavity?"both":e.cavity?"normals":"hash";void 0!==this.normalRenderTarget&&this.normalRenderTargetFlavor!==t&&(this.normalRenderTarget.depthTexture?.dispose(),this.normalRenderTarget.dispose(),this.normalRenderTarget=void 0),void 0===this.normalRenderTarget&&(this.normalRenderTarget=new Xe(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{count:"both"===t?2:1,generateMipmaps:!1,minFilter:On,magFilter:On,type:"normals"===t?re:ee,depthTexture:new de(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio)}),"both"===t&&(this.normalRenderTarget.textures[1].type=re),this.normalRenderTargetFlavor=t)}renderNormal(e,t,n){if(this.normalRenderTarget){this.setClearColor(0),n.layers.enable(8),n.layers.disable(0),n.layers.disable(3),t.traverseEntity(e=>{e.layers.isEnabled(8)&&(e.copyPreviousMatrix=!1)}),this.setRenderTarget(this.normalRenderTarget),this.clear(),jl.value=n instanceof l?(n.far-n.near)/1e4:1;let i=this.normalRenderTargetFlavor??"hash";t.overrideMaterial="both"===i?Kl:"normals"===i?Yl:ql,this.render(t,n),this.setClearColor(t.bgColor,t.bgColor.a),this.setRenderTarget(null),t.overrideMaterial=e.wireframeState?r:null,n.layers.enable(0),n.layers.enable(3),t.traverseEntity(e=>{e.layers.isEnabled(8)&&(e.copyPreviousMatrix=!0)})}}renderSplineSceneWithDummyCamera(e,t,n=1){this.dummyCamera.updateCameraState(t.dataPatched),this.dummyCamera.matrix.copy(t.matrixWorld);let i=t.height,a=t.width,r=this.viewportWidth/this.viewportHeight;a<i?a=i*r:i=a/r,this.dummyCamera.setViewplaneSize(a,i);for(let t=0;t<n;t++)this.renderSplineScene(e,this.dummyCamera)}renderSplineScene(n,a,{sceneHelpers:c=this.sceneHelpers,sceneHelpersOnTop:d=this.sceneHelpersOnTop,overrideTransmission:u,overrideNormal:f}={}){i(this);let p=n instanceof o?n.activePage:n,h=p.visible;p.visible=!0;let m=p.scene,v=P.isSoft(p.data.shadow)?tn:on;if(this.shadowMap.type!==v&&(this.shadowMap.type=v,p.traverseEntity(e=>{let t=e;t.isLight&&t.shadow?.map&&(t.shadow.map.dispose(),t.shadow.map=null,t.shadow.needsUpdate=!0)}),m.markShadowsDirty()),this.setClearColor(p.bgColor,p.bgColor.a),p.penumbraSizeArray.forEach((e,t)=>{qs.penumbraSize.value[t]=e}),qs.pixelRatioNode.value=this.getPixelRatio(),0!==this.resolution.x&&0!==this.resolution.y?qs.resolution.value.set(this.resolution.x,this.resolution.y):qs.resolution.value.set(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio),void 0!==f)qs.normalRenderTarget.value=f,qs.normalRenderTargetDepth.value=Sc,qs.normalViewRenderTarget.value=Sc;else if(m.needsNormal()){let e=m.normalPassNeeds();this.createNormalRenderTarget(e);let t=this.normalRenderTargetFlavor,n=this.normalRenderTarget.textures;qs.normalRenderTarget.value="normals"===t?Sc:n[0],qs.normalRenderTargetDepth.value=this.normalRenderTarget.depthTexture,qs.normalViewRenderTarget.value="both"===t?n[1]:"normals"===t?n[0]:Sc,this.renderNormal(m,p,a)}Ys.spe_fogMode.value=R.getModeIndex({mode:p.fogMode}),Ys.spe_fogHeightParams.value.set(p.fogDensity??R.getDensity({}),p.fogHeightFalloff??R.getHeightFalloff({}),p.fogHeightBase??R.getHeightBase({}));let g=p.data.ao,_=g.occlusion&&!e.enabled;if(_&&(this.createAORenderTarget(),qs.aoRenderTarget.value=this.aoRenderTarget.texture),qs.aoEnabled.value=_,this.pipeline.setAmbientOcclusionParams(_,g.radius,g.bias,p.aoColor,null!==p.fog,p.backupFog.near,p.backupFog.far,{mode:p.fogMode??"linear",density:p.fogDensity??R.getDensity({}),heightFalloff:p.fogHeightFalloff??R.getHeightFalloff({}),heightBase:p.fogHeightBase??R.getHeightBase({})},g.aoFullRes&&!s),this.pipeline.aoPass.setBlueNoiseTexture(this.pipeline.blueNoiseTexture),this.pipeline.isUIOverlayEnabled&&p.uiCanvas?.enabled&&p.uiCanvas.texture&&p.uiCanvas.texture.image.width>0){let e=this.getSize(Tc),t=this.getPixelRatio();(p.uiCanvas.width!==this.viewportWidth||p.uiCanvas.height!==this.viewportHeight||p.uiCanvas.dpr!==t)&&p.uiCanvas.applySize({width:this.viewportWidth,height:this.viewportHeight},t),p.uiCanvas.render(this),this.pipeline.uiOverlayPass.uiCanvas=p.uiCanvas,this.pipeline.uiOverlayPass.enabled=!0,this.pipeline.uiOverlayPass.setResolution(e.x,e.y,t),this.pipeline.updateRenderToScreen()}else this.pipeline.uiOverlayPass.enabled=!1,this.pipeline.updateRenderToScreen();if(this.pipeline.logoOverlayPass.enabled){let e=this.getSize(Tc),t=this.getPixelRatio();this.pipeline.logoOverlayPass.uniforms.uResolution.value.set(e.x,e.y),this.pipeline.logoOverlayPass.uniforms.uDPR.value=t}let x=!1;if(void 0!==u)qs.transmissionRenderTarget.value=u,qs.transmissionRenderTargetDepth.value=Sc,this.pipeline.setTransmissionPassEnabled(!1);else{let e=m.needsTransmission();e&&(void 0===this.transmissionRenderTarget&&(x=!0),this.createTransmissionRenderTarget(),qs.transmissionRenderTarget.value=this.transmissionRenderTarget.texture,qs.aspectRatio.value=(S=this.viewportWidth)>=(T=this.viewportHeight)?new pe(T/S,1):new pe(1,S/T),qs.transmissionRenderTargetDepth.value=this.transmissionDepthTarget.texture),this.pipeline.setTransmissionPassEnabled(e)}var S,T;a.layers.enable(3),a.layers.enable(8),a.layers.enable(4),this.pipeline.sceneHelpers=c,this.pipeline.sceneHelpersOnTop=d,this.pipeline.taaPass.enabled=qs.taaEnabled.value,this.pipeline.scene=p,this.pipeline.camera=a,x&&this.pipeline.transmissionPass.updatePasses(this);let b=t(p.postprocessing);this.pipeline.postprocessingState!==b&&(this.pipeline.updatePostprocessing(b),!c&&!d&&this.pipeline.disableHelpers()),void 0!==this.clearAlphaOverride&&this.setClearAlpha(this.clearAlphaOverride),m.shapeBlendIntances.forEach(e=>{e.onBeforeShadowPass(this)}),this.manageShadowUpdates&&(this.shadowMap.autoUpdate=!1,(m.shadowsDirty||this.forceShadowUpdates)&&(this.shadowMap.needsUpdate=!0)),p.overrideMaterial=m.wireframeState?r:null,this.pipeline.render(),this.manageShadowUpdates&&(m.shadowsDirty=!1),qs.taaEnabled.value&&(qs.frameIndex.value=(qs.frameIndex.value+1)%16),a instanceof l&&a.copyHistory(),p.visible=h}renderFromSceneForSceneTransitionPass(e,t,n){this.pipeline.renderToScreen=!1,this.pipeline.renderTarget,this.renderSplineScene(e,t),this.pipeline.sceneTransitionFromTexture=this.pipeline.renderTarget.texture,this.sceneTransitionDuration=n,this.sceneTransitionTimeRemaining=n,this.pipeline.renderToScreen=!0;let i=this.pipeline.sceneTransitionPass.uniforms;i.uDPR.value=window.devicePixelRatio,i.uResolution.value.set(this.domElement.width,this.domElement.height).divideScalar(window.devicePixelRatio)}_currentDispose(){this._superDispose(),this.pipeline.dispose(),this.aoRenderTarget?.dispose(),this.aoRenderTarget=void 0,this.transmissionRenderTarget?.dispose(),this.transmissionRenderTarget=void 0,this.transmissionDepthTarget?.dispose(),this.transmissionDepthTarget=void 0,this.normalRenderTarget?.depthTexture?.dispose(),this.normalRenderTarget?.dispose(),this.normalRenderTarget=void 0,this.normalRenderTargetFlavor=void 0,this.dummyCamera.dispose(),this.dummyCamera=void 0,qs.normalRenderTarget.value=Sc,qs.normalRenderTargetDepth.value=Sc,qs.normalViewRenderTarget.value=Sc,qs.transmissionRenderTarget.value=Sc,qs.transmissionRenderTargetDepth.value=Sc,qs.aoRenderTarget.value=Sc}};export{bc as SplineRenderer,qs as rendererGlobals};
1
+ import{a as e,b as t,d as n}from"./runtime-chunk-FN2C54JM.js";import{b as i}from"./runtime-chunk-CVUJ3GMH.js";import{c as a}from"./runtime-chunk-GFTBNL2W.js";import{e as r,f as o}from"./runtime-chunk-KKDM5MC5.js";import"./runtime-chunk-ZM7N5SZG.js";import"./runtime-chunk-UHCXLQHA.js";import"./runtime-chunk-CDYE22J6.js";import"./runtime-chunk-RTRWO43P.js";import"./runtime-chunk-ZASM3KKC.js";import"./runtime-chunk-TU4KDRKR.js";import"./runtime-chunk-WQ2NXI3U.js";import{c as s}from"./runtime-chunk-FQNSP44B.js";import{a as l}from"./runtime-chunk-YS7K3AW3.js";import"./runtime-chunk-MVJAFW5H.js";import"./runtime-chunk-JSRKKIOS.js";import"./runtime-chunk-M4BPCY7K.js";import"./runtime-chunk-QSJVWNNM.js";import"./runtime-chunk-VNO2DW74.js";import{M as c,P as d,S as u,U as f,V as p,W as h,X as m,Y as v,Z as g,_,d as x,e as S,h as T,i as b,m as w}from"./runtime-chunk-7FDJ7IIR.js";import"./runtime-chunk-4YV3EXSU.js";import"./runtime-chunk-NSD7DU3P.js";import{v as E}from"./runtime-chunk-MOZWC42D.js";import"./runtime-chunk-2PT2WH66.js";import"./runtime-chunk-4KZXQGUQ.js";import"./runtime-chunk-U4QOT2PX.js";import"./runtime-chunk-TZCHGFVF.js";import{W as M,ea as y,fa as C,qa as R,sa as A,ta as P,x as D}from"./runtime-chunk-VPEJ5BFD.js";import{a as L,b as U,c as N,d as I,e as O,f as F,g as z,h as B,i as V,j as H,k as G,l as k,m as W,n as X}from"./runtime-chunk-OFPUAZKY.js";import{b as j,c as $,f as q}from"./runtime-chunk-EOV2DL2V.js";import"./runtime-chunk-Y3BMDVJ7.js";import{$ as Y,$a as K,$c as Z,$d as J,A as Q,Aa as ee,Ac as te,Ad as ne,Ae as ie,B as ae,Ba as re,Bc as oe,C as se,Ca as le,Cc as ce,Cd as de,D as ue,Da as fe,Dc as pe,Dd as he,E as me,Ea as ve,Ed as ge,F as _e,Fa as xe,Fb as Se,Fc as Te,G as be,Ga as we,Gb as Ee,Gc as Me,H as ye,Ha as Ce,Hb as Re,Hc as Ae,I as Pe,Ia as De,Ib as Le,Ic as Ue,J as Ne,Ja as Ie,Jb as Oe,Jc as Fe,Je as ze,K as Be,Ka as Ve,Kb as He,L as Ge,La as ke,Lb as We,Lc as Xe,Le as je,M as $e,Ma as qe,Mc as Ye,N as Ke,Na as Ze,Nc as Je,O as Qe,Oa as et,Oc as tt,P as nt,Pa as it,Q as at,Qc as rt,R as ot,Ra as st,S as lt,Sa as ct,T as dt,Ta as ut,Tc as ft,U as pt,Ua as ht,V as mt,Va as vt,Vc as gt,Vd as _t,W as xt,Wa as St,X as Tt,Xa as bt,Y as wt,Ya as Et,Ye as Mt,Z as yt,Za as Ct,Zc as Rt,Zd as At,_ as Pt,_a as Dt,_c as Lt,_d as Ut,a as Nt,aa as It,ab as Ot,ae as Ft,ba as zt,bb as Bt,bd as Vt,be as Ht,c as Gt,ca as kt,cb as Wt,ce as Xt,d as jt,da as $t,db as qt,dc as Yt,dd as Kt,de as Zt,e as Jt,eb as Qt,ec as en,f as tn,fa as nn,fb as an,fc as rn,g as on,ga as sn,gb as ln,gc as cn,h as dn,ha as un,hb as fn,hc as pn,i as hn,ia as mn,ib as vn,ic as gn,j as _n,ja as xn,jb as Sn,jc as Tn,k as bn,ka as wn,kb as En,kc as Mn,ke as yn,l as Cn,la as Rn,lb as An,ld as Pn,le as Dn,m as Ln,ma as Un,mb as Nn,n as In,na as On,nb as Fn,nc as zn,nd as Bn,o as Vn,oa as Hn,ob as Gn,oc as kn,p as Wn,pa as Xn,pb as jn,q as $n,qa as qn,qb as Yn,r as Kn,ra as Zn,rb as Jn,rd as Qn,sa as ei,sb as ti,sd as ni,t as ii,tb as ai,tc as ri,u as oi,ua as si,ub as li,uc as ci,v as di,va as ui,vb as fi,vc as pi,w as hi,wa as mi,wb as vi,wc as gi,x as _i,xa as xi,xb as Si,xc as Ti,y as bi,ya as wi,yb as Ei,yc as Mi,z as yi,za as Ci,zb as Ri,zc as Ai}from"./runtime-chunk-VGN7YHB7.js";import"./runtime-chunk-ML3Z74BL.js";var Pi=class{constructor(e){if(this.hashProperties=void 0,this.isNode=!0,this.shortcuts={},null===Pi.uuidContext)throw new Error("plz startContext");Pi.uuidContext===Pi.globalContext?this.uuid="_gid"+Pi.uuidContext.nodeContextUuid++:this.uuid="_uid"+Pi.uuidContext.nodeContextUuid++,this.type=e,this.name=""}static startContext(e){null===this.uuidContext||this.uuidContext===Pi.globalContext?this.uuidContext=e:console.error("Can't start context twice")}static endContext(e){this.uuidContext!==e&&console.error("Can't end context twice"),this.uuidContext=null}analyze(e,t){t=t??{},e.analyzing=!0,this.build(e.addFlow(t.slot,t.cache,t.context),"v4"),e.clearVertexNodeCode(),e.clearFragmentNodeCode(),e.removeFlow(),e.analyzing=!1}analyzeAndFlow(e,t,n){return n=n??{},this.analyze(e,n),this.flow(e,t,n)}flow(e,t,n){n=n??{},e.addFlow(n.slot,n.cache,n.context);let i={result:this.build(e,t),code:e.clearNodeCode(),extra:e.context.extra};return e.removeFlow(),i}build(e,t,n){t=t??this.getType(e,t);let i=e.getNodeData(n??this);return e.analyzing&&this.appendDepsNode(e,i,t),-1===e.nodes.indexOf(this)&&e.nodes.push(this),void 0!==this.updateFrame&&-1===e.updaters.indexOf(this)&&e.updaters.push(this),this.generate(e,t,n)}updateFrame(e){}generateReadonly(e,t,n,i,a,r){return""}generate(e,t,n,i,a){return""}parse(e,t,n,i){}appendDepsNode(e,t,n){t.deps=(t.deps||0)+1;let i=e.getTypeLength(n);(i>(t.outputMax||0)||this.getType(e,n))&&(t.outputMax=i,t.output=n)}setName(e){this.name=e}getName(){return this.name}getType(e,t){return"sampler2D"===t||"samplerCube"===t?t:this.type}},Di=Pi;Di.globalContext={nodeContextUuid:0},Di.uuidContext=Pi.globalContext;var Li=3e3,Ui=3001,Ni=class{constructor(e){e=e??{},this.name=e.name,this.type=e.type,this.node=e.node,this.size=e.size,this.needsUpdate=e.needsUpdate}get value(){return this.node.value}set value(e){this.node.value=e}},Ii=new class{constructor(){this.nodes={},this.keywords={}}add(e){this.nodes[e.name]=e}addKeyword(e,t,n){n=void 0===n||n,this.keywords[e]={callback:t,cache:n}}remove(e){delete this.nodes[e.name]}removeKeyword(e){delete this.keywords[e]}get(e){return this.nodes[e]}getKeyword(e,t){return this.keywords[e].callback(t)}getKeywordData(e){return this.keywords[e]}contains(e){return void 0!==this.nodes[e]}containsKeyword(e){return void 0!==this.keywords[e]}},Oi=class extends Di{constructor(e,t){super(e),this.scope="",t=t??{},this.shared=void 0===t.shared||t.shared,this.unique=void 0!==t.unique&&t.unique}build(e,t,n,i){if(t=t??this.getType(e),this.getShared(e,t)){let a=this.getUnique(e,t);a&&void 0===this.uuid&&(this.uuid=ce.generateUUID()),n=e.getUUID(n??this.getUUID(),!a);let r=e.getNodeData(n),o=r.output||this.getType(e);if(e.analyzing)return(r.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,r,t),this.generate(e,t,n)):super.build(e,t,n);if(a)return r.name=r.name||super.build(e,t,n),r.name;if(!this.getLabel()&&(!this.getShared(e,o)||e.context.ignoreCache||1===r.deps))return super.build(e,t,n);n=this.getUUID(!1);let s=this.getTemp(e,n);if(s)return e.format(s,o,t);{s=super.generate(e,t,n,r.output,i);let a=this.generate(e,o,n);return e.addNodeCode(s+" = "+a+";"),e.format(s,o,t)}}return super.build(e,t,n)}getShared(e,t){return"sampler2D"!==t&&"samplerCube"!==t&&this.shared}getUnique(e,t){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let t=this.uuid;return"string"==typeof this.scope&&(t=this.scope+"-"+t),t}getTemp(e,t){t=t||this.uuid;let n=e.getVars()[t];return n?n.name:void 0}generate(e,t,n,i,a){return this.getShared(e,t)||console.error("TempNode is not shared"),n=n??this.uuid,e.getTempVar(n,i??this.getType(e),a,this.getLabel()).name}},Fi=class extends Oi{constructor(e,t){(t=t??{}).shared=void 0!==t.shared&&t.shared,super(e,t),this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,t,n,i,a,r){n=e.getUUID(n??this.getUUID()),i=i??this.getType(e);let o=e.getNodeData(n);return this.getReadonly()&&void 0!==this.generateReadonly?this.generateReadonly(e,t,n,i,a,r):e.isShader("vertex")?(o.vertex||(o.vertex=e.createVertexUniform(i,this,a,r,this.getLabel())),e.format(o.vertex.name,i,t)):(o.fragment||(o.fragment=e.createFragmentUniform(i,this,a,r,this.getLabel())),e.format(o.fragment.name,i,t))}},zi=class extends Fi{constructor(e=0,t){super("v2"),this.nodeType="Vector2",this.value=e instanceof pe?e:new pe(e,t)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,t,n,i,a,r){return e.format("vec2("+this.value.x+", "+this.value.y+")",i,t)}},Bi=class extends Fi{constructor(e=0,t,n){super("v3"),this.nodeType="Vector3",this.value=e instanceof Te?e:new Te(e,t,n)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,t,n,i,a,r){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",i,t)}},Vi=class extends Fi{constructor(e){super("v4"),this.nodeType="Vector4",this.value=e instanceof T?e:new T(e.r,e.g,e.b,e.a)}generateReadonly(e,t,n,i,a,r){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",i,t)}},Hi=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,Gi=/[a-z_0-9]+/gi,ki=class extends Oi{constructor(e,t,n,i,a){super(a),this.src="",this.nodeType="Function",this.useKeywords=!0,this.includes=[],this.extensions={},this.keywords={},this.isMethod=void 0===a,this.isInterface=!1,this.parse(e,t,n,i)}getShared(e,t){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}}getIncludeByName(e){if(this.includes){let t=this.includes.length;for(;t--;)if(this.includes[t].name===e)return this.includes[t]}}generate(e,t,n,i,a){let r,o=0,s=this.src;if(this.includes)for(let t=0;t<this.includes.length;t++)e.include(this.includes[t],this);for(let t in this.extensions)e.extensions[t]=!0;let l=[];for(;r=Gi.exec(this.src);)l.push(r);for(let t=0;t<l.length;t++){let n=l[t],i=n[0],a=!this.isMethod||!this.getInputByName(i),r=i;if(this.keywords[i]||this.useKeywords&&a&&Ii.containsKeyword(i)){let t=this.keywords[i];if(!t){let n=Ii.getKeywordData(i);n.cache&&(t=e.keywords[i]),t=t||Ii.getKeyword(i,e),n.cache&&(e.keywords[i]=t)}r=t.build(e)}i!==r&&"."!==s[n.index+o-1]&&(s=s.substring(0,n.index+o)+r+s.substring(n.index+i.length+o),o+=r.length-i.length),void 0===this.getIncludeByName(r)&&Ii.contains(r)&&e.include(Ii.get(r))}return"source"===t?s:this.isMethod?(this.isInterface||e.include(this,void 0,s),this.name):e.format("( "+s+" )",this.getType(e),t)}parse(e,t,n,i){if(this.src=e||"",this.includes=t??[],this.extensions=n??{},this.keywords=i??{},this.isMethod){let e=Hi.exec(this.src);if(this.inputs=[],e&&4==e.length){this.type=e[1],this.name=e[2];let t=e[3].match(Gi);if(t){let e=0;for(;e<t.length;){let n,i=t[e++];"in"===i||"out"===i||"inout"===i?n=t[e++]:(n=i,i="");let a=t[e++];this.inputs.push({name:a,type:n,qualifier:i})}}this.isInterface=-1===this.src.indexOf("{")}else this.type="",this.name=""}}},Wi=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?=?\s?(.*?)(;|$)/i,Xi=class extends Oi{constructor(e="",t){super(),this.src="",this.useDefine=!1,this.nodeType="Const",this.parse(e||Xi.PI,void 0,void 0,void 0,t)}getType(e){return e.getTypeByFormat(this.type)}parse(e,t,n,i,a){this.src=e||"";let r,o,s="",l=Wi.exec(e);this.useDefine=a??"#"===this.src.charAt(0),l&&l.length>1?(o=l[1],r=l[2],s=l[3]):(r=this.src,o="f"),this.name=r,this.type=o,this.value=s}build(e,t){if("source"===t){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),t)}generate(e,t,n,i,a){return e.format(this.name,this.getType(e),t)}},ji=Xi;ji.PI="PI",ji.PI2="PI2",ji.RECIPROCAL_PI="RECIPROCAL_PI",ji.RECIPROCAL_PI2="RECIPROCAL_PI2",ji.LOG2="LOG2",ji.EPSILON="EPSILON";var $i=new RegExp("^structs*([a-z_0-9]+)s*{s*((.|\n)*?)}","gim"),qi=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),Yi=class extends Oi{constructor(e=""){super(),this.inputs=[],this.src="",this.nodeType="Struct",this.parse(e)}getType(e){return e.getTypeByFormat(this.name)}getInputByName(e){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}generate(e,t,n,i,a){return"source"===t?this.src+";":e.format("( "+this.src+" )",this.getType(e),t)}parse(e=""){this.src=e,this.inputs=[];let t=$i.exec(e);if(t){let e,n=t[2];for(;e=qi.exec(n);)this.inputs.push({type:e[1],name:e[2]});this.name=t[1]}else this.name="";this.type=this.name}},Ki=class extends Oi{constructor(e){super("v2",{shared:!1}),this.nodeType="UV",this.index=e??0}generate(e,t){e.requires.uv[this.index]=!0;let n=this.index>0?this.index+1:"",i=e.isShader("vertex")?"uv"+n:"vUv"+n;return e.format(i,this.getType(e),t)}};Ii.addKeyword("uv",function(){return new Ki}),Ii.addKeyword("uv2",function(){return new Ki(1)});var Zi=class extends Oi{constructor(e,t){super("v4"),this.nodeType="ColorSpace",this.input=e,this.method=t??Zi.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case Li:return["Linear"];case Ui:return["sRGB"];default:return[]}}generate(e,t){let n=this.input.build(e,"v4"),i=this.getType(e),a=Zi.Nodes[this.method],r=e.include(a);if(r===Zi.LINEAR_TO_LINEAR)return e.format(n,i,t);if(2===a.inputs?.length){let a=this.factor.build(e,"f");return e.format(r+"( "+n+", "+a+" )",i,t)}return e.format(r+"( "+n+" )",i,t)}fromEncoding(e){let t=Zi.getEncodingComponents(e);this.method="LinearTo"+t[0],this.factor=t[1]}fromDecoding(e){let t=Zi.getEncodingComponents(e);this.method=t[0]+"ToLinear",this.factor=t[1]}},Ji=Zi;Ji.Nodes={LinearToLinear:new ki(["vec4 LinearToLinear( in vec4 value ) {","\treturn value;","}"].join("\n")),sRGBToLinear:new ki(["vec4 sRGBToLinear( in vec4 value ) {","\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );","}"].join("\n")),LinearTosRGB:new ki(["vec4 LinearTosRGB( in vec4 value ) {","\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );","}"].join("\n"))},Ji.LINEAR_TO_LINEAR="LinearToLinear",Ji.SRGB_TO_LINEAR="sRGBToLinear",Ji.LINEAR_TO_SRGB="LinearTosRGB";var Qi=class extends ki{constructor(e="",t,n,i,a){super(e,a,i,n,t),this.nodeType="Expression"}},ea=class extends Fi{constructor(e=new Ue,t,n,i){super("v4",{shared:!0}),this.nodeType="Texture",this.value=e,this.uv=t??new Ki,this.bias=n,this.project=void 0!==i&&i}getTexture(e,t){return super.generate(e,t,this.value.uuid,"t")}generate(e,t){if("sampler2D"===t)return this.getTexture(e,t);let n,i,a=this.getTexture(e,t),r=this.uv.build(e,this.project?"v4":"v2"),o=this.bias?this.bias.build(e,"f"):void 0;void 0===o&&e.context.bias&&(o=e.context.bias.setTexture(this).build(e,"f")),n=this.project?"texture2DProj":o?"tex2DBias":"tex2D",i=o?n+"( "+a+", "+r+", "+o+" )":n+"( "+a+", "+r+" )";let s={include:e.isShader("vertex"),ignoreCache:!0},l=this.getType(e);return e.addContext(s),this.colorSpace=this.colorSpace??new Ji(new Qi("",l)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(i),i=this.colorSpace.build(e,l),e.removeContext(),e.format(i,l,t)}},ta=class extends Fi{constructor(e){super("f"),this.nodeType="Float",this.value=e??0}generateReadonly(e,t,n,i,a,r){return e.format(this.value+(this.value%1?"":".0"),i,t)}},na=class extends Oi{constructor(e,t){super(),this.inputs=[],this.nodeType="FunctionCall",this.value=e,this.inputs=t??[]}getFunction(){return this.value}getType(e){return this.value.getType(e)}generate(e,t,n,i,a){i=this.getType(e);let r=this.value,o=r.build(e,t)+"( ",s=[];if(r.inputs){for(let t=0;t<r.inputs.length;t++){let n=r.inputs[t],i=this.inputs[t]||this.inputs[n.name];s.push(i.build(e,e.getTypeByFormat(n.type)))}o+=s.join(", ")+" )"}return e.format(o,i,t)}},ia=class extends Oi{constructor(e,t,n=ia.ADD){super(),this.nodeType="Operator",this.type=e.type,this.a=e,this.b=t,this.op=n}getType(e){let t=this.a.getType(e),n=this.b.getType(e);return e.isTypeMatrix(t)?"v4":e.getTypeLength(n)>e.getTypeLength(t)?n:t}generate(e,t){let n=this.getType(e);this.type=n;let i=this.a.build(e,n),a=this.b.build(e,n);return e.format("( "+i+" "+this.op+" "+a+" )",n,t)}},aa=ia;aa.ADD="+",aa.SUB="-",aa.MUL="*",aa.DIV="/";var ra=class extends Oi{constructor(e,t=ra.ABS,n,i){super(),this.nodeType="Math",this.a=e,"string"!=typeof t?this.b=t:i=t,"string"!=typeof n?this.c=n:i=n,this.method=i,this.hashProperties=["method"]}getNumInputs(e){switch(this.method){case ra.MIX:case ra.CLAMP:case ra.REFRACT:case ra.SMOOTHSTEP:case ra.FACEFORWARD:return 3;case ra.MIN:case ra.MAX:case ra.MOD:case ra.STEP:case ra.REFLECT:case ra.DISTANCE:case ra.DOT:case ra.CROSS:case ra.POW:return 2;default:return 1}}getInputType(e){let t=e.getTypeLength(this.a.getType(e)),n=this.b?e.getTypeLength(this.b.getType(e)):0,i=this.c?e.getTypeLength(this.c.getType(e)):0;return t>n&&t>i?this.a.getType(e):n>i?this.b.getType(e):this.c.getType(e)}getType(e){switch(this.method){case ra.LENGTH:case ra.DISTANCE:case ra.DOT:return"f";case ra.CROSS:return"v3"}return this.getInputType(e)}generate(e,t){let n,i,a,r=this.a?e.getTypeLength(this.a.getType(e)):0,o=this.b?e.getTypeLength(this.b.getType(e)):0,s=this.c?e.getTypeLength(this.c.getType(e)):0,l=this.getInputType(e),c=this.getType(e);switch(this.type=c,this.method){case ra.NEGATE:return e.format("( -"+this.a.build(e,l)+" )",l,t);case ra.INVERT:return e.format("( 1.0 - "+this.a.build(e,l)+" )",l,t);case ra.CROSS:n=this.a.build(e,"v3"),i=this.b.build(e,"v3");break;case ra.STEP:n=this.a.build(e,1===r?"f":l),i=this.b.build(e,l);break;case ra.MIN:case ra.MAX:case ra.MOD:n=this.a.build(e,l),i=this.b.build(e,1===o?"f":l);break;case ra.REFRACT:n=this.a.build(e,l),i=this.b.build(e,l),a=this.c.build(e,"f");break;case ra.MIX:n=this.a.build(e,l),i=this.b.build(e,l),a=this.c.build(e,1===s?"f":l);break;default:n=this.a.build(e,l),this.b&&(i=this.b.build(e,l)),this.c&&(a=this.c.build(e,l))}let d=[];d.push(n),i&&d.push(i),a&&d.push(a);let u=this.getNumInputs(e);if(d.length!==u)throw Error(`Arguments not match used in "${this.method}". Require ${u}, currently ${d.length}.`);return e.format(this.method+"( "+d.join(", ")+" )",c,t)}},oa=ra;oa.RAD="radians",oa.DEG="degrees",oa.EXP="exp",oa.EXP2="exp2",oa.LOG="log",oa.LOG2="log2",oa.SQRT="sqrt",oa.INV_SQRT="inversesqrt",oa.FLOOR="floor",oa.CEIL="ceil",oa.NORMALIZE="normalize",oa.FRACT="fract",oa.SATURATE="saturate",oa.SIN="sin",oa.COS="cos",oa.TAN="tan",oa.ASIN="asin",oa.ACOS="acos",oa.ARCTAN="atan",oa.ABS="abs",oa.SIGN="sign",oa.LENGTH="length",oa.NEGATE="negate",oa.INVERT="invert",oa.MIN="min",oa.MAX="max",oa.MOD="mod",oa.STEP="step",oa.REFLECT="reflect",oa.DISTANCE="distance",oa.DOT="dot",oa.CROSS="cross",oa.POW="pow",oa.MIX="mix",oa.CLAMP="clamp",oa.REFRACT="refract",oa.SMOOTHSTEP="smoothstep",oa.FACEFORWARD="faceforward";var sa=class extends Oi{constructor(e,t,n){super("v4"),this.nodeType="TextureCubeUV",this.value=e,this.uv=t,this.bias=n}bilinearCubeUV(e,t,n,i){let a=new na(sa.Nodes.bilinearCubeUV,[t,n,i]);this.colorSpaceTL=this.colorSpaceTL??new Ji(new Qi("","v4")),this.colorSpaceTL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTL.input.parse(a.build(e)+".tl"),this.colorSpaceTR=this.colorSpaceTR??new Ji(new Qi("","v4")),this.colorSpaceTR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTR.input.parse(a.build(e)+".tr"),this.colorSpaceBL=this.colorSpaceBL??new Ji(new Qi("","v4")),this.colorSpaceBL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBL.input.parse(a.build(e)+".bl"),this.colorSpaceBR=this.colorSpaceBR??new Ji(new Qi("","v4")),this.colorSpaceBR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBR.input.parse(a.build(e)+".br");let r={include:e.isShader("vertex"),ignoreCache:!0};e.addContext(r),this.colorSpaceTLExp=new Qi(this.colorSpaceTL.build(e,"v4"),"v4"),this.colorSpaceTRExp=new Qi(this.colorSpaceTR.build(e,"v4"),"v4"),this.colorSpaceBLExp=new Qi(this.colorSpaceBL.build(e,"v4"),"v4"),this.colorSpaceBRExp=new Qi(this.colorSpaceBR.build(e,"v4"),"v4"),e.removeContext();let o=new Qi("mix( mix( cubeUV_TL, cubeUV_TR, cubeUV.f.x ), mix( cubeUV_BL, cubeUV_BR, cubeUV.f.x ), cubeUV.f.y )","v4");return o.keywords.cubeUV_TL=this.colorSpaceTLExp,o.keywords.cubeUV_TR=this.colorSpaceTRExp,o.keywords.cubeUV_BL=this.colorSpaceBLExp,o.keywords.cubeUV_BR=this.colorSpaceBRExp,o.keywords.cubeUV=a,o}generate(e,t){if(e.isShader("fragment")){let n=this.uv,i=this.bias||e.context.roughness,a=new na(sa.Nodes.roughnessToMip,[i]),r=new oa(a,sa.Nodes.m0,sa.Nodes.cubeUV_maxMipLevel,oa.CLAMP),o=new oa(r,oa.FLOOR),s=new oa(r,oa.FRACT),l=this.bilinearCubeUV(e,this.value,n,o),c=this.bilinearCubeUV(e,this.value,n,new aa(o,new ta(1).setReadonly(!0),aa.ADD)),d=new oa(l,c,s,oa.MIX);return e.format(d.build(e),"v4",t)}return console.warn("TextureCubeUVNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),t)}},la=sa;la.Nodes=function(){let e=new Yi("struct TextureCubeUVData {\n\t\t\tvec4 tl;\n\t\t\tvec4 tr;\n\t\t\tvec4 br;\n\t\t\tvec4 bl;\n\t\t\tvec2 f;\n\t\t}"),t=new ji("float cubeUV_maxMipLevel 8.0",!0),n=new ji("float cubeUV_minMipLevel 4.0",!0),i=new ji("float cubeUV_maxTileSize 256.0",!0),a=new ji("float cubeUV_minTileSize 16.0",!0),r=new ki("float getFace(vec3 direction) {\n\t\t\t\tvec3 absDirection = abs(direction);\n\t\t\t\tfloat face = -1.0;\n\t\t\t\tif (absDirection.x > absDirection.z) {\n\t\t\t\t\tif (absDirection.x > absDirection.y)\n\t\t\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\t\t\telse\n\t\t\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t\t\t} else {\n\t\t\t\t\tif (absDirection.z > absDirection.y)\n\t\t\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\t\t\telse\n\t\t\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t\t\t}\n\t\t\t\treturn face;\n\t\t}");r.useKeywords=!1;let o=new ki("vec2 getUV(vec3 direction, float face) {\n\t\t\t\tvec2 uv;\n\t\t\t\tif (face == 0.0) {\n\t\t\t\t\tuv = vec2(direction.z, direction.y) / abs(direction.x); \n\t\t\t\t} else if (face == 1.0) {\n\t\t\t\t\tuv = vec2(-direction.x, -direction.z) / abs(direction.y); \n\t\t\t\t} else if (face == 2.0) {\n\t\t\t\t\tuv = vec2(-direction.x, direction.y) / abs(direction.z); \n\t\t\t\t} else if (face == 3.0) {\n\t\t\t\t\tuv = vec2(-direction.z, direction.y) / abs(direction.x); \n\t\t\t\t} else if (face == 4.0) {\n\t\t\t\t\tuv = vec2(-direction.x, direction.z) / abs(direction.y); \n\t\t\t\t} else {\n\t\t\t\t\tuv = vec2(direction.x, direction.y) / abs(direction.z); \n\t\t\t\t}\n\t\t\t\treturn 0.5 * (uv + 1.0);\n\t\t}");o.useKeywords=!1;let s=new ki("TextureCubeUVData bilinearCubeUV(sampler2D envMap, vec3 direction, float mipInt) {\n\t\t\tfloat face = getFace(direction);\n\t\t\tfloat filterInt = max(cubeUV_minMipLevel - mipInt, 0.0);\n\t\t\tmipInt = max(mipInt, cubeUV_minMipLevel);\n\t\t\tfloat faceSize = exp2(mipInt);\n\t\t\tfloat texelSize = 1.0 / (3.0 * cubeUV_maxTileSize);\n\t\t\tvec2 uv = getUV(direction, face) * (faceSize - 1.0);\n\t\t\tvec2 f = fract(uv);\n\t\t\tuv += 0.5 - f;\n\t\t\tif (face > 2.0) {\n\t\t\t\tuv.y += faceSize;\n\t\t\t\tface -= 3.0;\n\t\t\t}\n\t\t\tuv.x += face * faceSize;\n\t\t\tif(mipInt < cubeUV_maxMipLevel){\n\t\t\t\tuv.y += 2.0 * cubeUV_maxTileSize;\n\t\t\t}\n\t\t\tuv.y += filterInt * 2.0 * cubeUV_minTileSize;\n\t\t\tuv.x += 3.0 * max(0.0, cubeUV_maxTileSize - 2.0 * faceSize);\n\t\t\tuv *= texelSize;\n\t\t\tvec4 tl = texture2D(envMap, uv);\n\t\t\tuv.x += texelSize;\n\t\t\tvec4 tr = texture2D(envMap, uv);\n\t\t\tuv.y += texelSize;\n\t\t\tvec4 br = texture2D(envMap, uv);\n\t\t\tuv.x -= texelSize;\n\t\t\tvec4 bl = texture2D(envMap, uv);\n\t\t\treturn TextureCubeUVData( tl, tr, br, bl, f );\n\t\t}",[e,r,o,t,n,i,a]);s.useKeywords=!1;let l=new ji("float r0 1.0",!0),c=new ji("float v0 0.339",!0),d=new ji("float m0 -2.0",!0),u=new ji("float r1 0.8",!0),f=new ji("float v1 0.276",!0),p=new ji("float m1 -1.0",!0),h=new ji("float r4 0.4",!0),m=new ji("float v4 0.046",!0),v=new ji("float m4 2.0",!0),g=new ji("float r5 0.305",!0),_=new ji("float v5 0.016",!0),x=new ji("float m5 3.0",!0),S=new ji("float r6 0.21",!0),T=new ji("float v6 0.0038",!0),b=new ji("float m6 4.0",!0);return{bilinearCubeUV:s,roughnessToMip:new ki("float roughnessToMip(float roughness) {\n\t\t\tfloat mip = 0.0;\n\t\t\tif (roughness >= r1) {\n\t\t\t\tmip = (r0 - roughness) * (m1 - m0) / (r0 - r1) + m0;\n\t\t\t} else if (roughness >= r4) {\n\t\t\t\tmip = (r1 - roughness) * (m4 - m1) / (r1 - r4) + m1;\n\t\t\t} else if (roughness >= r5) {\n\t\t\t\tmip = (r4 - roughness) * (m5 - m4) / (r4 - r5) + m4;\n\t\t\t} else if (roughness >= r6) {\n\t\t\t\tmip = (r5 - roughness) * (m6 - m5) / (r5 - r6) + m5;\n\t\t\t} else {\n\t\t\t\tmip = -2.0 * log2(1.16 * roughness);// 1.16 = 1.79^0.25\n\t\t\t}\n\t\t\treturn mip;\n\t\t}",[l,c,d,u,f,p,h,m,v,g,_,x,S,T,b]),m0:d,cubeUV_maxMipLevel:t}}();var ca=class extends Oi{constructor(e){super("v3"),this.nodeType="Normal",this.scope=e??ca.VIEW}getShared(){return this.scope===ca.WORLD}build(e,t,n,i){let a=e.context[this.scope+"Normal"];return a?a.build(e,t,n,i):super.build(e,t,n)}generate(e,t,n,i,a){let r;switch(this.scope){case ca.VIEW:r=e.isShader("vertex")?"transformedNormal":"geometryNormal";break;case ca.LOCAL:e.isShader("vertex")?r="objectNormal":(e.requires.normal=!0,r="vObjectNormal");break;case ca.WORLD:e.isShader("vertex")?r="inverseTransformDirection( transformedNormal, viewMatrix ).xyz":(e.requires.worldNormal=!0,r="vWNormal")}return e.format(r,this.getType(e),t)}},da=ca;da.LOCAL="local",da.WORLD="world",da.VIEW="view",da.NORMAL="normal",Ii.addKeyword("viewNormal",function(){return new da(da.VIEW)}),Ii.addKeyword("localNormal",function(){return new da(da.NORMAL)}),Ii.addKeyword("worldNormal",function(){return new da(da.WORLD)});var ua=class extends Oi{constructor(e){super("v3"),this.nodeType="Position",this.scope=e??ua.LOCAL}getType(){return this.scope===ua.PROJECTION?"v4":this.type}getShader(){switch(this.scope){case ua.LOCAL:case ua.WORLD:return!1}return!0}generate(e,t,n,i,a){let r;switch(this.scope){case ua.LOCAL:e.isShader("vertex")?r="transformed":(e.requires.position=!0,r="vPosition");break;case ua.WORLD:if(e.isShader("vertex"))return"( modelMatrix * vec4( transformed, 1.0 ) ).xyz";e.requires.worldPosition=!0,r="vWPosition";break;case ua.VIEW:r=e.isShader("vertex")?"-mvPosition.xyz":"vViewPosition";break;case ua.PROJECTION:r=e.isShader("vertex")?"( projectionMatrix * modelViewMatrix * vec4( position, 1.0 ) )":"vec4( 0.0 )"}return e.format(r,this.getType(),t)}},fa=ua;fa.LOCAL="local",fa.WORLD="world",fa.VIEW="view",fa.PROJECTION="projection",Ii.addKeyword("position",function(){return new fa}),Ii.addKeyword("worldPosition",function(){return new fa(fa.WORLD)}),Ii.addKeyword("viewPosition",function(){return new fa(fa.VIEW)});var pa=class extends Oi{constructor(e){super("v3"),this.nodeType="Reflect",this.scope=e??pa.CUBE}getUnique(e){return!e.context.viewNormal}getType(){return this.scope===pa.SPHERE?"v2":this.type}generate(e,t){let n=this.getUnique(e);if(e.isShader("fragment")){let i;switch(this.scope){case pa.VECTOR:{let t=new da(da.VIEW),a=e.context.roughness,r=t.build(e,"v3"),o=new fa(fa.VIEW).build(e,"v3"),s=a?a.build(e,"f"):void 0,l=`reflect( -normalize( ${o} ), ${r} )`;s&&(l=`normalize( mix( ${l}, ${r}, ${s} * ${s} ) )`);let c=`inverseTransformDirection( ${l}, viewMatrix )`;n?(e.addNodeCode(`vec3 reflectVec = ${c};`),i="reflectVec"):i=c;break}case pa.CUBE:{let t=new pa(pa.VECTOR).build(e,"v3"),a="vec3( -"+t+".x, "+t+".yz )";n?(e.addNodeCode(`vec3 reflectCubeVec = ${a};`),i="reflectCubeVec"):i=a;break}case pa.SPHERE:{let t="normalize( ( viewMatrix * vec4( "+new pa(pa.VECTOR).build(e,"v3")+", 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) ).xy * 0.5 + 0.5";n?(e.addNodeCode(`vec2 reflectSphereVec = ${t};`),i="reflectSphereVec"):i=t;break}}return e.format(i,this.getType(),t)}return console.warn("ReflectNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.type,t)}},ha=pa;ha.CUBE="cube",ha.SPHERE="sphere",ha.VECTOR="vector";var ma=class extends Oi{constructor(e=new ea,t,n){super("v4"),this.nodeType="TextureCube",this.value=e,this.radianceNode=new la(this.value,t??new ha(ha.VECTOR),n),this.irradianceNode=new la(this.value,new da(da.WORLD),new ta(1).setReadonly(!0))}generate(e,t){return e.isShader("fragment")?(e.require("irradiance"),e.context.bias&&e.context.bias.setTexture(this.value),("irradiance"===e.slot?this.irradianceNode:this.radianceNode).build(e,t)):(console.warn("TextureCubeNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),t))}},va=class extends Fi{constructor(e=new ne,t,n){super("v4",{shared:!0}),this.nodeType="CubeTexture",this.value=e,this.uv=t??new ha,this.bias=n}getTexture(e,t){return super.generate(e,t,this.value.uuid,"tc")}generate(e,t){if("samplerCube"===t)return this.getTexture(e,t);let n,i=this.getTexture(e,t),a=this.uv?.build(e,"v3"),r=this.bias?this.bias.build(e,"f"):void 0;void 0===r&&e.context.bias&&(r=e.context.bias.setTexture(this).build(e,"f")),n=r?"texCubeBias( "+i+", "+a+", "+r+" )":"texCube( "+i+", "+a+" )";let o={include:e.isShader("vertex"),ignoreCache:!0},s=this.getType(e);return e.addContext(o),this.colorSpace=this.colorSpace??new Ji(new Qi("",s)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(n),n=this.colorSpace.build(e,s),e.removeContext(),e.format(n,s,t)}},ga=["x","y","z","w"],_a=["float","vec2","vec3","vec4"],xa={float:"f",vec2:"v2",vec3:"v3",vec4:"v4",mat4:"v4",int:"i",bool:"b","float[]":"f[]","vec4[]":"v4[]"},Sa={t:"sampler2D",tc:"samplerCube",b:"bool",i:"int",f:"float",c:"vec3",v2:"vec2",v3:"vec3",v4:"vec4",m3:"mat3",m4:"mat4","f[]":"float[]","v4[]":"vec4[]"},Ta=class{constructor(){this.includes={consts:{},functions:{},structs:{}},this.cache="",this.slot="",this.shader="",this.context={},this.needsJitter=!0,this.getIncludesCode=function(){function e(e,t){return e.deps.length-t.deps.length}return function(t,n){let i=this.getIncludes(t,n);if(!i)return"";let a="";i=i.sort(e);for(let e=0;e<i.length;e++)i[e].src&&(a+=i[e].src+"\n");return a}}(),this.slots=[],this.caches=[],this.contexts=[],this.keywords={},this.nodeData={},this.fragmentVariables={},this.fragmentParsVariables={},this.vertexParsVariables={},this.requires={uv:[],color:[],transparent:!1,irradiance:!1,position:!1,worldPosition:!1,normal:!1,worldNormal:!1,vWorldViewDir:!1,modelMatrix:!1,viewMatrix:!1,projectionMatrix:!1},this.includes={consts:[],functions:[],structs:[]},this.attributes={},this.prefixCode=["#ifdef TEXTURE_LOD_EXT","\t#define texCube(a, b) textureCube(a, b)","\t#define texCubeBias(a, b, c) textureCubeLodEXT(a, b, c)","\t#define tex2D(a, b) texture2D(a, b)","\t#define tex2DBias(a, b, c) texture2DLodEXT(a, b, c)","#else","\t#define texCube(a, b) textureCube(a, b)","\t#define texCubeBias(a, b, c) textureCube(a, b, c)","\t#define tex2D(a, b) texture2D(a, b)","\t#define tex2DBias(a, b, c) texture2D(a, b, c)","#endif","\n\t\t\t\n\t\t\t#define SPE_BLENDING_NORMAL 0\n\t\t\t#define SPE_BLENDING_MULTIPLY 1\n\t\t\t#define SPE_BLENDING_SCREEN 2\n\t\t\t#define SPE_BLENDING_OVERLAY 3\n\n\t\t\tvec3 spe_normalBlend( vec3 a, vec3 b, float alpha ) {\n\t\t\t\treturn mix( a, b, alpha );\n\t\t\t}\n\n\t\t\tvec3 spe_multiplyBlend( vec3 a, vec3 b, float alpha ) {\n\t\t\t\treturn mix( a, a * b, alpha );\n\t\t\t}\n\n\t\t\tvec3 spe_screenBlend( vec3 a, vec3 b, float alpha ) {\n\t\t\t\tvec3 tmp = 1.0 - ( 1.0 - a ) * ( 1.0 - b );\n\t\t\t\treturn mix( a, tmp, alpha );\n\t\t\t}\n\n\t\t\tvec3 spe_overlayBlend( vec3 a, vec3 b, float alpha ) {\n\t\t\t\tvec3 tmp = mix( 1. - 2. * (1. - a) * (1. - b), 2. * a * b, step( a, vec3(.5) ) );\n\t\t\t\treturn clamp( mix( a, tmp, alpha ), 0.0, 1.0 );\n\t\t\t}\n\n\t\t\tvec3 spe_blend( vec3 a, vec3 b, float alpha, int mode ) {\n\t\t\t\tif ( mode == SPE_BLENDING_NORMAL ) return spe_normalBlend( a, b, alpha );\n\t\t\t\telse if ( mode == SPE_BLENDING_MULTIPLY ) return spe_multiplyBlend( a, b, alpha );\n\t\t\t\telse if ( mode == SPE_BLENDING_SCREEN ) return spe_screenBlend( a, b, alpha );\n\t\t\t\telse if ( mode == SPE_BLENDING_OVERLAY ) return spe_overlayBlend( a, b, alpha );\n\t\t\t\treturn vec3( 1.0 );\n\t\t\t}\n\t\t\t","#include <packing>","#include <common>"].join("\n"),this.parsCode={vertex:["float neighbor_offset = 0.0001;",""].join("\n"),fragment:["float accumAlpha = 0.0;","void accumulateAlpha(float alpha) {\n\t\t\t\t\taccumAlpha += (1.0 - accumAlpha) * alpha;\n\t\t\t\t}",""].join("\n")},this.code={vertex:"",fragment:""},this.nodeCode={vertex:"",fragment:""},this.resultCode={vertex:"",fragment:""},this.finalCode={vertex:"",fragment:""},this.inputs={uniforms:{list:[],vertex:[],fragment:[]},arrayUniforms:{list:[],vertex:[],fragment:[]},vars:{varying:[],vertex:[],fragment:[]}},this.defines={},this.uniforms={},this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.updaters=[],this.nodes=[],this.analyzing=!1}build(e,t){this.addVertexParsCode("\nuniform int frameIndex;\nuniform vec2 resolution;\nuniform mat4 previousModelViewMatrix;\nuniform mat4 previousProjectionMatrix;\n\nvarying vec4 vCurrentPosition;\nvarying vec4 vPreviousPosition;\n"),this.addFragmentParsCode("\nlayout(location = 1) out vec4 gVelocity;\n\nuniform int frameIndex;\nuniform vec2 resolution;\n\nvarying vec4 vCurrentPosition;\nvarying vec4 vPreviousPosition;\n\nconst vec2 haltonSequence[16] = vec2[16](\nvec2( 0.000000,-0.333334),\nvec2(-0.500000, 0.333334),\nvec2( 0.500000,-0.777778),\nvec2(-0.750000,-0.111112),\nvec2( 0.250000, 0.555556),\nvec2(-0.250000,-0.555556),\nvec2( 0.750000, 0.111112),\nvec2(-0.875000, 0.777778),\nvec2(0.125000, -0.925926),\nvec2(-0.375000, -0.259260),\nvec2(0.625000, 0.407408),\nvec2(-0.625000, -0.703704),\nvec2(0.375000, -0.037038),\nvec2(-0.125000, 0.629630),\nvec2(0.875000, -0.481482),\nvec2(-0.937500, 0.185186));\n\nvec2 vogelDiskSample(int sampleIndex, int sampleCount, float angle) {\n const float goldenAngle = 2.399963f; \n float r = sqrt(float(sampleIndex) + 0.5f) / sqrt(float(sampleCount));\n float theta = float(sampleIndex) * goldenAngle + angle;\n float sine = sin(theta);\n float cosine = cos(theta);\n return vec2(cosine, sine) * r;\n}\n\n\nfloat getNoiseInterleavedGradient(vec2 screenPos) {\n vec3 magic = vec3(0.06711056f, 0.00583715f, 52.9829189f);\n return fract(magic.z * fract(dot(screenPos, magic.xy)));\n}\n\n"),this.buildShader("vertex",e),this.buildShader("fragment",t);for(let e=0;e<this.requires.uv.length;e++)if(this.requires.uv[e]){let t=e>0?e+1:"";this.addVaryCode("varying vec2 vUv"+t+";"),e>0&&this.addVertexParsCode("attribute vec2 uv"+t+";"),this.addVertexFinalCode("vUv"+t+" = uv"+t+";")}return this.requires.color[0]&&(this.addVaryCode("varying vec4 vColor;"),this.addVertexFinalCode("\n\t\t\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\t\t\tvColor = color;\n\t\t\t\t#elif defined( USE_COLOR )\n\t\t\t\t\tvColor = vec4( color, 1.0 );\n\t\t\t\t#else\n\t\t\t\t\tvColor = vec4( 1.0 );\n\t\t\t\t#endif\n\t\t\t")),this.requires.color[1]&&(this.addVaryCode("varying vec4 vColor2;"),this.addVertexParsCode("attribute vec4 color2;"),this.addVertexFinalCode("vColor2 = color2;")),this.requires.position&&(this.addVaryCode("varying vec3 vPosition;"),this.addVertexFinalCode("vPosition = transformed;")),this.requires.worldPosition,this.requires.normal&&(this.addVaryCode("varying vec3 vObjectNormal;"),this.addVertexFinalCode("\n\t\t\t\t#ifndef SHAPEBLEND \n\t\t\t\t\tvObjectNormal = normal;\n\t\t\t\t#else\n\t\t\t\t\tvObjectNormal = objectNormal;\n\t\t\t\t#endif\n\t\t\t")),this.requires.modelMatrix&&this.addFragmentParsCode("uniform mat4 modelMatrix;"),this.requires.viewMatrix&&this.addFragmentParsCode("uniform mat4 viewMatrix;"),this.requires.projectionMatrix&&this.addFragmentParsCode("uniform mat4 projectionMatrix;"),this.requires.worldNormal&&(this.addVaryCode("varying vec3 vWNormal;"),this.addVertexFinalCode("vWNormal = inverseTransformDirection( transformedNormal, viewMatrix ).xyz;")),this.requires.vWorldViewDir&&(this.addVaryCode("varying vec3 vWorldViewDir;"),this.addVertexFinalCode("vWorldViewDir = isPerspectiveMatrix( projectionMatrix ) ? ( (modelMatrix * vec4(position, 1.0)).xyz - cameraPosition ) : vec3( -viewMatrix[0][2], -viewMatrix[1][2], -viewMatrix[2][2] );")),this.needsJitter&&(this.addVertexFinalCode("\n\nconst vec2 haltonSequence[16] = vec2[16](\nvec2( 0.000000,-0.333334),\nvec2(-0.500000, 0.333334),\nvec2( 0.500000,-0.777778),\nvec2(-0.750000,-0.111112),\nvec2( 0.250000, 0.555556),\nvec2(-0.250000,-0.555556),\nvec2( 0.750000, 0.111112),\nvec2(-0.875000, 0.777778),\nvec2(0.125000, -0.925926),\nvec2(-0.375000, -0.259260),\nvec2(0.625000, 0.407408),\nvec2(-0.625000, -0.703704),\nvec2(0.375000, -0.037038),\nvec2(-0.125000, 0.629630),\nvec2(0.875000, -0.481482),\nvec2(-0.937500, 0.185186));\n\n\nvec2 offset = haltonSequence[frameIndex];\noffset.x /= resolution.x;\noffset.y /= resolution.y;\n\nvec4 currentPosition = gl_Position;\nvec4 currentPositionJittered = currentPosition + (vec4(offset.x, offset.y, 0.0, 0.0) * currentPosition.w);\n\n\n\nvCurrentPosition = currentPosition;\nvec4 previousLocalPosition = vec4(transformed, 1.0);\n#ifdef USE_INSTANCING\n\n\n\npreviousLocalPosition = instanceMatrix * previousLocalPosition;\n#endif\nvPreviousPosition = previousProjectionMatrix * previousModelViewMatrix * previousLocalPosition;\n#ifdef OUTLINE_COMPENSATION\nvPreviousPosition.xy += OUTLINE_COMPENSATION;\n#endif\ngl_Position = currentPositionJittered;\n\n"),this.addFragmentFinalCode("\nvec2 oldPos = vPreviousPosition.xy;\n oldPos /= vPreviousPosition.w;\n oldPos.xy = (oldPos.xy+1.)/2.0;\n\nvec2 newPos = vCurrentPosition.xy;\n newPos /= vCurrentPosition.w;\n newPos.xy = (newPos.xy+1.)/2.0;\n\nvec2 velocity = (newPos - oldPos);\n\n\nif (gl_FragColor.a <= 0.0) discard;\n\ngVelocity = vec4(velocity, 0.0, 1.0);\n")),this}buildShader(e,t){this.resultCode[e]=t.build(this.setShader(e),"v4")}setMaterial(e,t){return this.defines={},this}addFlow(e,t,n){return this.addSlot(e).addCache(t).addContext(n)}removeFlow(){return this.removeSlot().removeCache().removeContext()}addCache(e){return this.cache=e??"",this.caches.push(this.cache),this}removeCache(){return this.caches.pop(),this.cache=this.caches[this.caches.length-1]||"",this}addContext(e){return this.context=Object.assign({},this.context,e),this.context.extra=this.context.extra||{},this.contexts.push(this.context),this}removeContext(){return this.contexts.pop(),this.context=this.contexts[this.contexts.length-1]||{},this}addSlot(e){return this.slot=e||"",this.slots.push(this.slot),this}removeSlot(){return this.slots.pop(),this.slot=this.slots[this.slots.length-1]||"",this}addFragmentVariable(e,t){void 0===this.fragmentVariables[e]&&(this.addFragmentCode(`${t} ${e};`),this.fragmentVariables[e]="")}addFragmentParsVariable(e,t){void 0===this.fragmentParsVariables[e]&&(this.addFragmentParsCode(`${t} ${e};`),this.fragmentParsVariables[e]="")}addVertexParsVariable(e,t){void 0===this.vertexParsVariables[e]&&(this.addVertexParsCode(`${t} ${e};`),this.vertexParsVariables[e]="")}addVertexCode(e){this.addCode(e,"vertex")}addFragmentCode(e){this.addCode(e,"fragment")}addCode(e,t){this.code[t??this.shader]+=e+"\n"}addVertexNodeCode(e){this.addNodeCode(e,"vertex")}addFragmentNodeCode(e){this.addNodeCode(e,"fragment")}addNodeCode(e,t){this.nodeCode[t??this.shader]+=e+"\n"}clearNodeCode(e){e=e??this.shader;let t=this.nodeCode[e];return this.nodeCode[e]="",t}clearVertexNodeCode(){return this.clearNodeCode("vertex")}clearFragmentNodeCode(){return this.clearNodeCode("fragment")}addVertexFinalCode(e){this.addFinalCode(e,"vertex")}addFragmentFinalCode(e){this.addFinalCode(e,"fragment")}addFinalCode(e,t){this.finalCode[t??this.shader]+=e+"\n"}addVertexParsCode(e){this.addParsCode(e,"vertex")}addFragmentParsCode(e){this.addParsCode(e,"fragment")}addParsCode(e,t){this.parsCode[t??this.shader]+=e+"\n"}addVaryCode(e){this.addVertexParsCode(e),this.addFragmentParsCode(e)}isCache(e){return-1!==this.caches.indexOf(e)}isSlot(e){return-1!==this.slots.indexOf(e)}define(e,t){this.defines[e]=void 0===t?1:t}require(e){this.requires[e]=!0}isDefined(e){return void 0!==this.defines[e]}getVar(e,t,n,i="varying",a="V",r=""){let o=this.getVars(i),s=o[e];if(!s){let i=o.length;s={name:n||"node"+a+i+(r?"_"+r:""),type:t},o.push(s),o[e]=s}return s}getTempVar(e,t,n,i){return this.getVar(e,t,n,this.shader,"T",i)}getAttribute(e,t){if(!this.attributes[e]){let n=this.getVar(e,t);this.addVertexParsCode("attribute "+t+" "+e+";"),this.addVertexFinalCode(n.name+" = "+e+";"),this.attributes[e]={varying:n,name:e,type:t}}return this.attributes[e]}getCode(e){return[this.prefixCode,this.parsCode[e],this.getVarListCode(this.getVars("varying"),"varying"),this.getVarListCode(this.inputs.uniforms[e],"uniform"),this.getVarListCode(this.inputs.arrayUniforms[e],"uniform"),this.getIncludesCode("consts",e),this.getIncludesCode("structs",e),this.getIncludesCode("functions",e),"void main() {",this.getVarListCode(this.getVars(e)),this.code[e],this.resultCode[e],this.finalCode[e],"}"].join("\n")}getVarListCode(e,t){t=t??"";let n="";for(let i=0,a=e.length;i<a;++i){let a=e[i],r=a.type,o=a.name,s=a.size,l=this.getFormatByType(r);if(void 0===l)throw new Error("Node pars "+l+" not found.");l.includes("[]")?n+=t+" "+l.substring(0,l.length-2)+" "+o+`[${s}];\n`:n+=t+" "+l+" "+o+";\n"}return n}getVars(e){return this.inputs.vars[e??this.shader]}getNodeData(e){let t=e instanceof Di?e.uuid:e;return this.nodeData[t]=this.nodeData[t]||{}}createUniform(e,t,n,i,a,r){if(t.includes("[]")){let o=this.inputs.arrayUniforms,s=o.list.length,l=new Ni({type:t,size:n.size,name:i||"nodeUA"+s+(r?"_"+r:""),node:n,needsUpdate:a});return o.list.push(l),o[e].push(l),o[e][l.name]=l,this.uniforms[l.name]=l,l}{let o=this.inputs.uniforms,s=o.list.length,l=new Ni({type:t,name:i||"nodeU"+s+(r?"_"+r:""),node:n,needsUpdate:a});return o.list.push(l),o[e].push(l),o[e][l.name]=l,this.uniforms[l.name]=l,l}}createVertexUniform(e,t,n,i,a){return this.createUniform("vertex",e,t,n,i,a)}createFragmentUniform(e,t,n,i,a){return this.createUniform("fragment",e,t,n,i,a)}include(e,t,n){let i;if(e="string"==typeof e?Ii.get(e):e,!1===this.context.include)return e.name;e instanceof ki?i=this.includes.functions:e instanceof ji?i=this.includes.consts:e instanceof Yi&&(i=this.includes.structs);let a=i[this.shader]=i[this.shader]||[];if(e){let i=a[e.name];if(i||(i=a[e.name]={node:e,deps:[]},a.push(i),i.src=e.build(this,"source")),e instanceof ki&&t&&a[t.name]&&-1===a[t.name].deps.indexOf(e)&&(a[t.name].deps.push(e),e.includes?.length)){let n=0;do{this.include(e.includes[n++],t)}while(n<e.includes.length)}return n&&(i.src=n),e.name}throw new Error("Include not found.")}colorToVectorProperties(e){return e.replace("r","x").replace("g","y").replace("b","z").replace("a","w")}colorToVector(e){return e.replace(/c/g,"v3")}getIncludes(e,t){return this.includes[e][t||this.shader]}getConstructorFromLength(e){return _a[e-1]}isTypeMatrix(e){return/^m/.test(e)}getTypeLength(e){return"f"===e?1:parseInt(this.colorToVector(e).substr(1))}getTypeFromLength(e){return 1===e?"f":"v"+e}findNode(...e){for(let t=0;t<arguments.length;t++){let n=e[t];if(n?.isNode)return n}}resolve(...e){for(let t=0;t<arguments.length;t++){let n=e[t];if(void 0!==n){if(n.isNode)return n;if(n.isTexture)switch(n.mapping){case nn:case sn:return new va(n);case xn:return new ma(new ea(n));default:return new ea(n)}else{if(n.isVector2)return new zi(n);if(n.isVector3)return new Bi(n);if(n.isVector4)return new Vi(n)}}}}format(e,t,n){switch(this.colorToVector(n+" <- "+t)){case"f <- v2":case"f <- v3":case"f <- v4":return e+".x";case"f <- i":case"f <- b":return"float( "+e+" )";case"v2 <- f":return"vec2( "+e+" )";case"v2 <- v3":case"v2 <- v4":return e+".xy";case"v2 <- i":case"v2 <- b":case"v3 <- i":case"v3 <- b":return"vec2( float( "+e+" ) )";case"v3 <- f":return"vec3( "+e+" )";case"v3 <- v2":return"vec3( "+e+", 0.0 )";case"v3 <- v4":return e+".xyz";case"v4 <- f":return"vec4( "+e+" )";case"v4 <- v2":return"vec4( "+e+", 0.0, 1.0 )";case"v4 <- v3":return"vec4( "+e+", 1.0 )";case"v4 <- i":case"v4 <- b":return"vec4( float( "+e+" ) )";case"i <- f":case"i <- b":return"int( "+e+" )";case"i <- v2":case"i <- v3":case"i <- v4":return"int( "+e+".x )";case"b <- f":return"( "+e+" != 0.0 )";case"b <- v2":return"( "+e+" != vec2( 0.0 ) )";case"b <- v3":return"( "+e+" != vec3( 0.0 ) )";case"b <- v4":return"( "+e+" != vec4( 0.0 ) )";case"b <- i":return"( "+e+" != 0 )"}return e}getTypeByFormat(e){return xa[e]||e}getFormatByType(e){return Sa[e]||e}getUUID(e,t){return(t=void 0===t||t)&&this.cache&&(e=this.cache+"-"+e),e}getElementByIndex(e){return ga[e]}getIndexByElement(e){return ga.indexOf(e)}isShader(e){return this.shader===e}setShader(e){return this.shader=e,this}mergeDefines(e){for(let t in e)this.defines[t]=e[t];return this.defines}mergeUniform(e){for(let t in e)this.uniforms[t]=e[t];return this.uniforms}getTextureEncodingFromMap(e){let t;return e?e.isTexture&&(t=e.colorSpace===Le?Ui:Li):t=Li,t===Li&&this.context.gamma&&(t=Ui),t}},ba=class extends Fi{constructor(e=0,t,n,i){super("c"),this.nodeType="Color",this.value=e instanceof T?e:new T(e||0,t,n,i)}setRGBA(e){this.value.setRGBA(e.r,e.g,e.b,e.a)}generate(e,t,n,i,a,r){n=e.getUUID(n??this.getUUID()),i=i??this.getType(e);let o=e.getNodeData(n),s=this.getReadonly()&&void 0!==this.generateReadonly;if(this.alpha){let t=this.alpha.build(e,"f");e.addFragmentNodeCode(`accumAlpha += ( 1.0 - accumAlpha ) * ${t};`)}return s?this.generateReadonly(e,t,n,i,a,r):e.isShader("vertex")?(o.vertex||(o.vertex=e.createVertexUniform(i,this,a,r,this.getLabel())),e.format(o.vertex.name,i,t)):(o.fragment||(o.fragment=e.createFragmentUniform(i,this,a,r,this.getLabel())),e.format(o.fragment.name,i,t))}generateReadonly(e,t,n,i,a,r){return e.format("vec3("+this.value.r+", "+this.value.g+", "+this.value.b+")",i,t)}},wa=class extends Fi{constructor(e){super("i"),this.nodeType="Int",this.value=Math.floor(e??0)}generateReadonly(e,t,n,i,a,r){return e.format(this.value.toString(),i,t)}};function Ea(){let e=null,t=!1,n=null,i=null;function a(t,r){n(t,r),i=e.requestAnimationFrame(a)}return{start:function(){!0!==t&&null!==n&&null!==e&&(i=e.requestAnimationFrame(a),t=!0)},stop:function(){null!==e&&e.cancelAnimationFrame(i),t=!1},setAnimationLoop:function(e){n=e},setContext:function(t){e=t}}}function Ma(e){let t=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),t.get(e)},remove:function(n){n.isInterleavedBufferAttribute&&(n=n.data);let i=t.get(n);i&&(e.deleteBuffer(i.buffer),t.delete(n))},update:function(n,i){if(n.isInterleavedBufferAttribute&&(n=n.data),n.isGLBufferAttribute){let e=t.get(n);return void((!e||e.version<n.version)&&t.set(n,{buffer:n.buffer,type:n.type,bytesPerElement:n.elementSize,version:n.version}))}let a=t.get(n);if(void 0===a)t.set(n,function(t,n){let i,a=t.array,r=t.usage,o=a.byteLength,s=e.createBuffer();if(e.bindBuffer(n,s),e.bufferData(n,a,r),t.onUploadCallback(),a instanceof Float32Array)i=e.FLOAT;else if(typeof Float16Array<"u"&&a instanceof Float16Array)i=e.HALF_FLOAT;else if(a instanceof Uint16Array)i=t.isFloat16BufferAttribute?e.HALF_FLOAT:e.UNSIGNED_SHORT;else if(a instanceof Int16Array)i=e.SHORT;else if(a instanceof Uint32Array)i=e.UNSIGNED_INT;else if(a instanceof Int32Array)i=e.INT;else if(a instanceof Int8Array)i=e.BYTE;else if(a instanceof Uint8Array)i=e.UNSIGNED_BYTE;else{if(!(a instanceof Uint8ClampedArray))throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+a);i=e.UNSIGNED_BYTE}return{buffer:s,type:i,bytesPerElement:a.BYTES_PER_ELEMENT,version:t.version,size:o}}(n,i));else if(a.version<n.version){if(a.size!==n.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");(function(t,n,i){let a=n.array,r=n.updateRanges;if(e.bindBuffer(i,t),0===r.length)e.bufferSubData(i,0,a);else{r.sort((e,t)=>e.start-t.start);let t=0;for(let e=1;e<r.length;e++){let n=r[t],i=r[e];i.start<=n.start+n.count+1?n.count=Math.max(n.count,i.start+i.count-n.start):(++t,r[t]=i)}r.length=t+1;for(let t=0,n=r.length;t<n;t++){let n=r[t];e.bufferSubData(i,n.start*a.BYTES_PER_ELEMENT,a,n.start,n.count)}n.clearUpdateRanges()}n.onUploadCallback()})(a.buffer,n,i),a.version=n.version}}}}var ya={alphahash_fragment:"#ifdef USE_ALPHAHASH\n\tif ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;\n#endif",alphahash_pars_fragment:"#ifdef USE_ALPHAHASH\n\tconst float ALPHA_HASH_SCALE = 0.05;\n\tfloat hash2D( vec2 value ) {\n\t\treturn fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );\n\t}\n\tfloat hash3D( vec3 value ) {\n\t\treturn hash2D( vec2( hash2D( value.xy ), value.z ) );\n\t}\n\tfloat getAlphaHashThreshold( vec3 position ) {\n\t\tfloat maxDeriv = max(\n\t\t\tlength( dFdx( position.xyz ) ),\n\t\t\tlength( dFdy( position.xyz ) )\n\t\t);\n\t\tfloat pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );\n\t\tvec2 pixScales = vec2(\n\t\t\texp2( floor( log2( pixScale ) ) ),\n\t\t\texp2( ceil( log2( pixScale ) ) )\n\t\t);\n\t\tvec2 alpha = vec2(\n\t\t\thash3D( floor( pixScales.x * position.xyz ) ),\n\t\t\thash3D( floor( pixScales.y * position.xyz ) )\n\t\t);\n\t\tfloat lerpFactor = fract( log2( pixScale ) );\n\t\tfloat x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;\n\t\tfloat a = min( lerpFactor, 1.0 - lerpFactor );\n\t\tvec3 cases = vec3(\n\t\t\tx * x / ( 2.0 * a * ( 1.0 - a ) ),\n\t\t\t( x - 0.5 * a ) / ( 1.0 - a ),\n\t\t\t1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )\n\t\t);\n\t\tfloat threshold = ( x < ( 1.0 - a ) )\n\t\t\t? ( ( x < a ) ? cases.x : cases.y )\n\t\t\t: cases.z;\n\t\treturn clamp( threshold , 1.0e-6, 1.0 );\n\t}\n#endif",alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef USE_ALPHATEST\n\t#ifdef ALPHA_TO_COVERAGE\n\tdiffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );\n\tif ( diffuseColor.a == 0.0 ) discard;\n\t#else\n\tif ( diffuseColor.a < alphaTest ) discard;\n\t#endif\n#endif",alphatest_pars_fragment:"#ifdef USE_ALPHATEST\n\tuniform float alphaTest;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_CLEARCOAT ) \n\t\tclearcoatSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_SHEEN ) \n\t\tsheenSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometryNormal, geometryViewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n\t#endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",batching_pars_vertex:"#ifdef USE_BATCHING\n\t#if ! defined( GL_ANGLE_multi_draw )\n\t#define gl_DrawID _gl_DrawID\n\tuniform int _gl_DrawID;\n\t#endif\n\tuniform highp sampler2D batchingTexture;\n\tuniform highp usampler2D batchingIdTexture;\n\tmat4 getBatchingMatrix( const in float i ) {\n\t\tint size = textureSize( batchingTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n\tfloat getIndirectIndex( const in int i ) {\n\t\tint size = textureSize( batchingIdTexture, 0 ).x;\n\t\tint x = i % size;\n\t\tint y = i / size;\n\t\treturn float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );\n\t}\n#endif\n#ifdef USE_BATCHING_COLOR\n\tuniform sampler2D batchingColorTexture;\n\tvec4 getBatchingColor( const in float i ) {\n\t\tint size = textureSize( batchingColorTexture, 0 ).x;\n\t\tint j = int( i );\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\treturn texelFetch( batchingColorTexture, ivec2( x, y ), 0 );\n\t}\n#endif",batching_vertex:"#ifdef USE_BATCHING\n\tmat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );\n#endif",begin_vertex:"vec3 transformed = vec3( position );\n#ifdef USE_ALPHAHASH\n\tvPosition = vec3( position );\n#endif",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"float G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n} ",iridescence_fragment:"#ifdef USE_IRIDESCENCE\n\tconst mat3 XYZ_TO_REC709 = mat3(\n\t\t 3.2404542, -0.9692660, 0.0556434,\n\t\t-1.5371385, 1.8760108, -0.2040259,\n\t\t-0.4985314, 0.0415560, 1.0572252\n\t);\n\tvec3 Fresnel0ToIor( vec3 fresnel0 ) {\n\t\tvec3 sqrtF0 = sqrt( fresnel0 );\n\t\treturn ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );\n\t}\n\tvec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );\n\t}\n\tfloat IorToFresnel0( float transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));\n\t}\n\tvec3 evalSensitivity( float OPD, vec3 shift ) {\n\t\tfloat phase = 2.0 * PI * OPD * 1.0e-9;\n\t\tvec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );\n\t\tvec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );\n\t\tvec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );\n\t\tvec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );\n\t\txyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );\n\t\txyz /= 1.0685e-7;\n\t\tvec3 rgb = XYZ_TO_REC709 * xyz;\n\t\treturn rgb;\n\t}\n\tvec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {\n\t\tvec3 I;\n\t\tfloat iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );\n\t\tfloat sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );\n\t\tfloat cosTheta2Sq = 1.0 - sinTheta2Sq;\n\t\tif ( cosTheta2Sq < 0.0 ) {\n\t\t\treturn vec3( 1.0 );\n\t\t}\n\t\tfloat cosTheta2 = sqrt( cosTheta2Sq );\n\t\tfloat R0 = IorToFresnel0( iridescenceIOR, outsideIOR );\n\t\tfloat R12 = F_Schlick( R0, 1.0, cosTheta1 );\n\t\tfloat T121 = 1.0 - R12;\n\t\tfloat phi12 = 0.0;\n\t\tif ( iridescenceIOR < outsideIOR ) phi12 = PI;\n\t\tfloat phi21 = PI - phi12;\n\t\tvec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) );\t\tvec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );\n\t\tvec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );\n\t\tvec3 phi23 = vec3( 0.0 );\n\t\tif ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;\n\t\tif ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;\n\t\tif ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;\n\t\tfloat OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;\n\t\tvec3 phi = vec3( phi21 ) + phi23;\n\t\tvec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );\n\t\tvec3 r123 = sqrt( R123 );\n\t\tvec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );\n\t\tvec3 C0 = R12 + Rs;\n\t\tI = C0;\n\t\tvec3 Cm = Rs - T121;\n\t\tfor ( int m = 1; m <= 2; ++ m ) {\n\t\t\tCm *= r123;\n\t\t\tvec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );\n\t\t\tI += Cm * Sm;\n\t\t}\n\t\treturn max( I, vec3( 0.0 ) );\n\t}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vBumpMapUv );\n\t\tvec2 dSTdy = dFdy( vBumpMapUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );\n\t\tvec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#ifdef ALPHA_TO_COVERAGE\n\t\tfloat distanceToPlane, distanceGradient;\n\t\tfloat clipOpacity = 1.0;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\tclipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\tif ( clipOpacity == 0.0 ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tfloat unionClipOpacity = 1.0;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\t\tunionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tclipOpacity *= 1.0 - unionClipOpacity;\n\t\t#endif\n\t\tdiffuseColor.a *= clipOpacity;\n\t\tif ( diffuseColor.a == 0.0 ) discard;\n\t#else\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tbool clipped = true;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tif ( clipped ) discard;\n\t\t#endif\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvarying vec4 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvColor = vec4( 1.0 );\n#endif\n#ifdef USE_COLOR_ALPHA\n\tvColor *= color;\n#elif defined( USE_COLOR )\n\tvColor.rgb *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.rgb *= instanceColor.rgb;\n#endif\n#ifdef USE_BATCHING_COLOR\n\tvColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) );\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\n#ifdef USE_ALPHAHASH\n\tvarying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\n#define inverseTransformDirection transformDirectionByInverseViewMatrix\nvec3 transformNormalByInverseViewMatrix( in vec3 normal, in mat4 viewMatrix ) {\n\treturn normalize( ( vec4( normal, 0.0 ) * viewMatrix ).xyz );\n}\nvec3 transformDirectionByInverseViewMatrix( in vec3 dir, in mat4 viewMatrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * viewMatrix ).xyz );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} ",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\thighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = objectTangent;\n#endif\n#ifdef USE_BATCHING\n\tmat3 bm = mat3( batchingMatrix );\n\ttransformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );\n\ttransformedNormal = bm * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = bm * transformedTangent;\n\t#endif\n#endif\n#ifdef USE_INSTANCING\n\tmat3 im = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );\n\ttransformedNormal = im * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = im * transformedTangent;\n\t#endif\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\ttransformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE\n\t\temissiveColor = sRGBTransferEOTF( emissiveColor );\n\t#endif\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",colorspace_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",colorspace_pars_fragment:"vec4 LinearTransferOETF( in vec4 value ) {\n\treturn value;\n}\nvec4 sRGBTransferEOTF( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 sRGBTransferOETF( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, envMapRotation * reflectVec );\n\t\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t\t#endif\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform mat3 envMapRotation;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#ifdef USE_ENVMAP\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );\n\t\t\treflectVec = transformDirectionByInverseViewMatrix( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\t#ifdef USE_ANISOTROPY\n\t\tvec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n\t\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\t\tvec3 bentNormal = cross( bitangent, viewDir );\n\t\t\t\tbentNormal = normalize( cross( bentNormal, bitangent ) );\n\t\t\t\tbentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n\t\t\t\treturn getIBLRadiance( viewDir, bentNormal, roughness );\n\t\t\t#else\n\t\t\t\treturn vec3( 0.0 );\n\t\t\t#endif\n\t\t}\n\t#endif\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\tvec2 fw = fwidth( coord ) * 0.5;\n\t\treturn mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n\t#endif\n}",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_fragment:"LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;",lights_lambert_pars_fragment:"varying vec3 vViewPosition;\nstruct LambertMaterial {\n\tvec3 diffuseColor;\n\tfloat 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\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.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\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n\tuniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif ( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif\n#include <lightprobes_pars_fragment>",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 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\tvec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n\treflectedLight.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\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat 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\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.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\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong",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\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor;\n\tmaterial.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = vec3( 0.04 );\n\tmaterial.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_DISPERSION\n\tmaterial.dispersion = dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tif( material.anisotropy == 0.0 ) {\n\t\tanisotropyV = vec2( 1.0, 0.0 );\n\t} else {\n\t\tanisotropyV /= material.anisotropy;\n\t\tmaterial.anisotropy = saturate( material.anisotropy );\n\t}\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;\n#endif",lights_physical_pars_fragment:"uniform sampler2D dfgLUT;\nstruct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tvec3 diffuseContribution;\n\tvec3 specularColor;\n\tvec3 specularColorBlended;\n\tfloat roughness;\n\tfloat metalness;\n\tfloat specularF90;\n\tfloat dispersion;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t\tvec3 iridescenceFresnelDielectric;\n\t\tvec3 iridescenceFresnelMetallic;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\n\t#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\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n\tfloat 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\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\treturn 0.5 / max( gv + gl, EPSILON );\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColorBlended;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn 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\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transpose( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn 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\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat rInv = 1.0 / ( roughness + 0.1 );\n\tfloat a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv;\n\tfloat b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv;\n\tfloat DG = exp( a * dotNV + b );\n\treturn 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\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n\treturn 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\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\nvec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg;\n\tvec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg;\n\tvec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y;\n\tvec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y;\n\tfloat Ess_V = dfgV.x + dfgV.y;\n\tfloat Ess_L = dfgL.x + dfgL.y;\n\tfloat Ems_V = 1.0 - Ess_V;\n\tfloat Ems_L = 1.0 - Ess_L;\n\tvec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619;\n\tvec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON );\n\tfloat compensationFactor = Ems_V * Ems_L;\n\tvec3 multiScatter = Fms * compensationFactor;\n\treturn singleScatter + multiScatter;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid 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\t\tvec3 normal = geometryNormal;\n\t\tvec3 viewDir = geometryViewDir;\n\t\tvec3 position = geometryPosition;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColorBlended * t2.x + ( material.specularF90 - material.specularColorBlended ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t\t#ifdef USE_CLEARCOAT\n\t\t\tvec3 Ncc = geometryClearcoatNormal;\n\t\t\tvec2 uvClearcoat = LTC_Uv( Ncc, viewDir, material.clearcoatRoughness );\n\t\t\tvec4 t1Clearcoat = texture2D( ltc_1, uvClearcoat );\n\t\t\tvec4 t2Clearcoat = texture2D( ltc_2, uvClearcoat );\n\t\t\tmat3 mInvClearcoat = mat3(\n\t\t\t\tvec3( t1Clearcoat.x, 0, t1Clearcoat.y ),\n\t\t\t\tvec3( 0, 1, 0 ),\n\t\t\t\tvec3( t1Clearcoat.z, 0, t1Clearcoat.w )\n\t\t\t);\n\t\t\tvec3 fresnelClearcoat = material.clearcoatF0 * t2Clearcoat.x + ( material.clearcoatF90 - material.clearcoatF0 ) * t2Clearcoat.y;\n\t\t\tclearcoatSpecularDirect += lightColor * fresnelClearcoat * LTC_Evaluate( Ncc, viewDir, position, mInvClearcoat, rectCoords );\n\t\t#endif\n\t}\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\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n \n \t\tsheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n \n \t\tfloat sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n \t\tfloat sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness );\n \n \t\tfloat sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL );\n \n \t\tirradiance *= sheenEnergyComp;\n \n \t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );\n\treflectedLight.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\tvec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution );\n\t#ifdef USE_SHEEN\n\t\tfloat sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t\tfloat sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n\t\tdiffuse *= sheenEnergyComp;\n\t#endif\n\treflectedLight.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\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI;\n \t#endif\n\tvec3 singleScatteringDielectric = vec3( 0.0 );\n\tvec3 multiScatteringDielectric = vec3( 0.0 );\n\tvec3 singleScatteringMetallic = vec3( 0.0 );\n\tvec3 multiScatteringMetallic = vec3( 0.0 );\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n\t#else\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n\t#endif\n\tvec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness );\n\tvec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness );\n\tvec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric;\n\tvec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tvec3 indirectSpecular = radiance * singleScattering;\n\tindirectSpecular += multiScattering * cosineWeightedIrradiance;\n\tvec3 indirectDiffuse = diffuse * cosineWeightedIrradiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t\tfloat sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n\t\tindirectSpecular *= sheenEnergyComp;\n\t\tindirectDiffuse *= sheenEnergyComp;\n\t#endif\n\treflectedLight.indirectSpecular += indirectSpecular;\n\treflectedLight.indirectDiffuse += indirectDiffuse;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",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\tgeometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometryViewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor );\n\t\tmaterial.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometryPosition, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometryPosition, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if defined( USE_LIGHT_PROBES )\n\t\tirradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#ifdef USE_LIGHT_PROBES_GRID\n\t\tvec3 probeWorldPos = ( ( vec4( geometryPosition, 1.0 ) - viewMatrix[ 3 ] ) * viewMatrix ).xyz;\n\t\tvec3 probeWorldNormal = transformNormalByInverseViewMatrix( geometryNormal, viewMatrix );\n\t\tirradiance += getLightProbeGridIrradiance( probeWorldPos, probeWorldNormal );\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\t#if defined( STANDARD ) || defined( LAMBERT ) || defined( PHONG )\n\t\t\tiblIrradiance += getIBLIrradiance( geometryNormal );\n\t\t#endif\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\t#ifdef USE_ANISOTROPY\n\t\tradiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n\t#else\n\t\tradiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\t#if defined( LAMBERT ) || defined( PHONG )\n\t\tirradiance += iblIrradiance;\n\t#endif\n\tRE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif",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\tvec3 res = probesResolution;\n\tvec3 gridRange = probesMax - probesMin;\n\tvec3 resMinusOne = res - 1.0;\n\tvec3 probeSpacing = gridRange / resMinusOne;\n\tvec3 samplePos = worldPos + worldNormal * probeSpacing * 0.5;\n\tvec3 uvw = clamp( ( samplePos - probesMin ) / gridRange, 0.0, 1.0 );\n\tuvw = uvw * resMinusOne / res + 0.5 / res;\n\tfloat nz = res.z;\n\tfloat paddedSlices = nz + 2.0;\n\tfloat atlasDepth = 7.0 * paddedSlices;\n\tfloat uvZBase = uvw.z * nz + 1.0;\n\tvec4 s0 = texture( probesSH, vec3( uvw.xy, ( uvZBase ) / atlasDepth ) );\n\tvec4 s1 = texture( probesSH, vec3( uvw.xy, ( uvZBase + paddedSlices ) / atlasDepth ) );\n\tvec4 s2 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 2.0 * paddedSlices ) / atlasDepth ) );\n\tvec4 s3 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 3.0 * paddedSlices ) / atlasDepth ) );\n\tvec4 s4 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 4.0 * paddedSlices ) / atlasDepth ) );\n\tvec4 s5 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 5.0 * paddedSlices ) / atlasDepth ) );\n\tvec4 s6 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 6.0 * paddedSlices ) / atlasDepth ) );\n\tvec3 c0 = s0.xyz;\n\tvec3 c1 = vec3( s0.w, s1.xy );\n\tvec3 c2 = vec3( s1.zw, s2.x );\n\tvec3 c3 = s2.yzw;\n\tvec3 c4 = s3.xyz;\n\tvec3 c5 = vec3( s3.w, s4.xy );\n\tvec3 c6 = vec3( s4.zw, s5.x );\n\tvec3 c7 = s5.yzw;\n\tvec3 c8 = s6.xyz;\n\tfloat x = worldNormal.x, y = worldNormal.y, z = worldNormal.z;\n\tvec3 result = c0 * 0.886227;\n\tresult += c1 * 2.0 * 0.511664 * y;\n\tresult += c2 * 2.0 * 0.511664 * z;\n\tresult += c3 * 2.0 * 0.511664 * x;\n\tresult += c4 * 2.0 * 0.429043 * x * y;\n\tresult += c5 * 2.0 * 0.429043 * y * z;\n\tresult += c6 * ( 0.743125 * z * z - 0.247708 );\n\tresult += c7 * 2.0 * 0.429043 * x * z;\n\tresult += c8 * 0.429043 * ( x * x - y * y );\n\treturn max( result, vec3( 0.0 ) );\n}\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n\tgl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n\tvFragDepth = 1.0 + gl_Position.w;\n\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );\n\t#endif\n\tdiffuseColor *= sampledDiffuseColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t#if defined( USE_POINTS_UV )\n\t\tvec2 uv = vUv;\n\t#else\n\t\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_POINTS_UV )\n\tvarying vec2 vUv;\n#else\n\t#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t\tuniform mat3 uvTransform;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphinstance_vertex:"#ifdef USE_INSTANCING_MORPH\n\tfloat morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\tfloat morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tmorphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;\n\t}\n#endif",morphcolor_vertex:"#if defined( USE_MORPHCOLORS )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\t#ifndef USE_INSTANCING_MORPH\n\t\tuniform float morphTargetBaseInfluence;\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t#endif\n\tuniform sampler2DArray morphTargetsTexture;\n\tuniform ivec2 morphTargetsTextureSize;\n\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t}\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = dFdx( vViewPosition );\n\tvec3 fdy = dFdy( vViewPosition );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal *= faceDirection;\n\t#endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn = getTangentFrame( - vViewPosition, normal,\n\t\t#if defined( USE_NORMALMAP )\n\t\t\tvNormalMapUv\n\t\t#elif defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tvClearcoatNormalMapUv\n\t\t#else\n\t\t\tvUv\n\t\t#endif\n\t\t);\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\ttbn[0] *= faceDirection;\n\t\ttbn[1] *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\ttbn2[0] *= faceDirection;\n\t\ttbn2[1] *= faceDirection;\n\t#endif\n#endif\nvec3 nonPerturbedNormal = normal;",normal_fragment_maps:"#ifdef USE_NORMALMAP_OBJECTSPACE\n\tnormal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n\tvec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#if defined( USE_PACKED_NORMALMAP )\n\t\tmapN = vec3( mapN.xy, sqrt( saturate( 1.0 - dot( mapN.xy, mapN.xy ) ) ) );\n\t#endif\n\tmapN.xy *= normalScale;\n\tnormal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t\t#ifdef FLIP_SIDED\n\t\t\tvBitangent = - vBitangent;\n\t\t#endif\n\t#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )\n\tmat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( uv.st );\n\t\tvec2 st1 = dFdy( uv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n\t\treturn mat3( T * scale, B * scale, N );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = nonPerturbedNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\tclearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif",iridescence_pars_fragment:"#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform sampler2D iridescenceThicknessMap;\n#endif",opaque_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;\nconst float Inv255 = 1. / 255.;\nconst vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );\nconst vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );\nconst vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );\nconst vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );\nvec4 packDepthToRGBA( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec4( 0., 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec4( 1., 1., 1., 1. );\n\tfloat vuf;\n\tfloat af = modf( v * PackFactors.a, vuf );\n\tfloat bf = modf( vuf * ShiftRight8, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );\n}\nvec3 packDepthToRGB( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec3( 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec3( 1., 1., 1. );\n\tfloat vuf;\n\tfloat bf = modf( v * PackFactors.b, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec3( vuf * Inv255, gf * PackUpscale, bf );\n}\nvec2 packDepthToRG( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec2( 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec2( 1., 1. );\n\tfloat vuf;\n\tfloat gf = modf( v * 256., vuf );\n\treturn vec2( vuf * Inv255, gf );\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors4 );\n}\nfloat unpackRGBToDepth( const in vec3 v ) {\n\treturn dot( v, UnpackFactors3 );\n}\nfloat unpackRGToDepth( const in vec2 v ) {\n\treturn v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;\n}\nvec4 pack2HalfToRGBA( const in vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( const in vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\n\t\treturn depth * ( far - near ) - far;\n\t#else\n\t\treturn depth * ( near - far ) - near;\n\t#endif\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\t\n\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\treturn ( near * far ) / ( ( near - far ) * depth - near );\n\t#else\n\t\treturn ( near * far ) / ( ( far - near ) * depth - far );\n\t#endif\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_BATCHING\n\tmvPosition = batchingMatrix * mvPosition;\n#endif\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tuniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\t#else\n\t\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\t#endif\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tuniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\t#else\n\t\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\t#endif\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tuniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\t#elif defined( SHADOWMAP_TYPE_BASIC )\n\t\t\tuniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\t#endif\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\tfloat interleavedGradientNoise( vec2 position ) {\n\t\t\treturn fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) );\n\t\t}\n\t\tvec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) {\n\t\t\tconst float goldenAngle = 2.399963229728653;\n\t\t\tfloat r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) );\n\t\t\tfloat theta = float( sampleIndex ) * goldenAngle + phi;\n\t\t\treturn vec2( cos( theta ), sin( theta ) ) * r;\n\t\t}\n\t#endif\n\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\tfloat getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\t\tfloat shadow = 1.0;\n\t\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\t\tshadowCoord.z += shadowBias;\n\t\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\t\tif ( frustumTest ) {\n\t\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\t\tfloat radius = shadowRadius * texelSize.x;\n\t\t\t\tfloat phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2;\n\t\t\t\tshadow = (\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) +\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) +\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) +\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) +\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) )\n\t\t\t\t) * 0.2;\n\t\t\t}\n\t\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t\t}\n\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\t\tfloat shadow = 1.0;\n\t\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\tshadowCoord.z -= shadowBias;\n\t\t\t#else\n\t\t\t\tshadowCoord.z += shadowBias;\n\t\t\t#endif\n\t\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\t\tif ( frustumTest ) {\n\t\t\t\tvec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg;\n\t\t\t\tfloat mean = distribution.x;\n\t\t\t\tfloat variance = distribution.y * distribution.y;\n\t\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\t\tfloat hard_shadow = step( mean, shadowCoord.z );\n\t\t\t\t#else\n\t\t\t\t\tfloat hard_shadow = step( shadowCoord.z, mean );\n\t\t\t\t#endif\n\t\t\t\t\n\t\t\t\tif ( hard_shadow == 1.0 ) {\n\t\t\t\t\tshadow = 1.0;\n\t\t\t\t} else {\n\t\t\t\t\tvariance = max( variance, 0.0000001 );\n\t\t\t\t\tfloat d = shadowCoord.z - mean;\n\t\t\t\t\tfloat p_max = variance / ( variance + d * d );\n\t\t\t\t\tp_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 );\n\t\t\t\t\tshadow = max( hard_shadow, p_max );\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t\t}\n\t#else\n\t\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\t\tfloat shadow = 1.0;\n\t\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\tshadowCoord.z -= shadowBias;\n\t\t\t#else\n\t\t\t\tshadowCoord.z += shadowBias;\n\t\t\t#endif\n\t\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\t\tif ( frustumTest ) {\n\t\t\t\tfloat depth = texture2D( shadowMap, shadowCoord.xy ).r;\n\t\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\t\tshadow = step( depth, shadowCoord.z );\n\t\t\t\t#else\n\t\t\t\t\tshadow = step( shadowCoord.z, depth );\n\t\t\t\t#endif\n\t\t\t}\n\t\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t\t}\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#if defined( SHADOWMAP_TYPE_PCF )\n\tfloat getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tfloat shadow = 1.0;\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\tvec3 absVec = abs( lightToPosition );\n\t\tfloat viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n\t\tif ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {\n\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\tfloat dp = ( shadowCameraNear * ( shadowCameraFar - viewSpaceZ ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n\t\t\t\tdp -= shadowBias;\n\t\t\t#else\n\t\t\t\tfloat dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n\t\t\t\tdp += shadowBias;\n\t\t\t#endif\n\t\t\tfloat texelSize = shadowRadius / shadowMapSize.x;\n\t\t\tvec3 absDir = abs( bd3D );\n\t\t\tvec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 );\n\t\t\ttangent = normalize( cross( bd3D, tangent ) );\n\t\t\tvec3 bitangent = cross( bd3D, tangent );\n\t\t\tfloat phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2;\n\t\t\tvec2 sample0 = vogelDiskSample( 0, 5, phi );\n\t\t\tvec2 sample1 = vogelDiskSample( 1, 5, phi );\n\t\t\tvec2 sample2 = vogelDiskSample( 2, 5, phi );\n\t\t\tvec2 sample3 = vogelDiskSample( 3, 5, phi );\n\t\t\tvec2 sample4 = vogelDiskSample( 4, 5, phi );\n\t\t\tshadow = (\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * sample0.x + bitangent * sample0.y ) * texelSize, dp ) ) +\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * sample1.x + bitangent * sample1.y ) * texelSize, dp ) ) +\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * sample2.x + bitangent * sample2.y ) * texelSize, dp ) ) +\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * sample3.x + bitangent * sample3.y ) * texelSize, dp ) ) +\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * sample4.x + bitangent * sample4.y ) * texelSize, dp ) )\n\t\t\t) * 0.2;\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n\t#elif defined( SHADOWMAP_TYPE_BASIC )\n\tfloat getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tfloat shadow = 1.0;\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tvec3 absVec = abs( lightToPosition );\n\t\tfloat viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n\t\tif ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {\n\t\t\tfloat dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n\t\t\tdp += shadowBias;\n\t\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t\tfloat depth = textureCube( shadowMap, bd3D ).r;\n\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\tdepth = 1.0 - depth;\n\t\t\t#endif\n\t\t\tshadow = step( dp, depth );\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n\t#endif\n\t#endif\n#endif",shadowmap_pars_vertex:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tuniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n\t#ifdef HAS_NORMAL\n\t\tvec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix );\n\t#else\n\t\tvec3 shadowWorldNormal = vec3( 0.0 );\n\t#endif\n\tvec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition;\n\t\t#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t\tshadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n\t\t#endif\n\t\tvSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\tuniform highp sampler2D boneTexture;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tint size = textureSize( boneTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 CineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nconst mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.6605, - 0.1246, - 0.0182 ),\n\tvec3( - 0.5876, 1.1329, - 0.1006 ),\n\tvec3( - 0.0728, - 0.0083, 1.1187 )\n);\nconst mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(\n\tvec3( 0.6274, 0.0691, 0.0164 ),\n\tvec3( 0.3293, 0.9195, 0.0880 ),\n\tvec3( 0.0433, 0.0113, 0.8956 )\n);\nvec3 agxDefaultContrastApprox( vec3 x ) {\n\tvec3 x2 = x * x;\n\tvec3 x4 = x2 * x2;\n\treturn + 15.5 * x4 * x2\n\t\t- 40.14 * x4 * x\n\t\t+ 31.96 * x4\n\t\t- 6.868 * x2 * x\n\t\t+ 0.4298 * x2\n\t\t+ 0.1191 * x\n\t\t- 0.00232;\n}\nvec3 AgXToneMapping( vec3 color ) {\n\tconst mat3 AgXInsetMatrix = mat3(\n\t\tvec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),\n\t\tvec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),\n\t\tvec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )\n\t);\n\tconst mat3 AgXOutsetMatrix = mat3(\n\t\tvec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),\n\t\tvec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),\n\t\tvec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )\n\t);\n\tconst float AgxMinEv = - 12.47393;\tconst float AgxMaxEv = 4.026069;\n\tcolor *= toneMappingExposure;\n\tcolor = LINEAR_SRGB_TO_LINEAR_REC2020 * color;\n\tcolor = AgXInsetMatrix * color;\n\tcolor = max( color, 1e-10 );\tcolor = log2( color );\n\tcolor = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );\n\tcolor = clamp( color, 0.0, 1.0 );\n\tcolor = agxDefaultContrastApprox( color );\n\tcolor = AgXOutsetMatrix * color;\n\tcolor = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );\n\tcolor = LINEAR_REC2020_TO_LINEAR_SRGB * color;\n\tcolor = clamp( color, 0.0, 1.0 );\n\treturn color;\n}\nvec3 NeutralToneMapping( vec3 color ) {\n\tconst float StartCompression = 0.8 - 0.04;\n\tconst float Desaturation = 0.15;\n\tcolor *= toneMappingExposure;\n\tfloat x = min( color.r, min( color.g, color.b ) );\n\tfloat offset = x < 0.08 ? x - 6.25 * x * x : 0.04;\n\tcolor -= offset;\n\tfloat peak = max( color.r, max( color.g, color.b ) );\n\tif ( peak < StartCompression ) return color;\n\tfloat d = 1. - StartCompression;\n\tfloat newPeak = 1. - d * d / ( peak + d - StartCompression );\n\tcolor *= newPeak / peak;\n\tfloat g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );\n\treturn mix( color, vec3( newPeak ), g );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = transformNormalByInverseViewMatrix( normal, viewMatrix );\n\tvec4 transmitted = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tfloat w0( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n\t}\n\tfloat w1( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n\t}\n\tfloat w2( float a ){\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n\t}\n\tfloat w3( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * a );\n\t}\n\tfloat g0( float a ) {\n\t\treturn w0( a ) + w1( a );\n\t}\n\tfloat g1( float a ) {\n\t\treturn w2( a ) + w3( a );\n\t}\n\tfloat h0( float a ) {\n\t\treturn - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n\t}\n\tfloat h1( float a ) {\n\t\treturn 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n\t}\n\tvec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n\t\tuv = uv * texelSize.zw + 0.5;\n\t\tvec2 iuv = floor( uv );\n\t\tvec2 fuv = fract( uv );\n\t\tfloat g0x = g0( fuv.x );\n\t\tfloat g1x = g1( fuv.x );\n\t\tfloat h0x = h0( fuv.x );\n\t\tfloat h1x = h1( fuv.x );\n\t\tfloat h0y = h0( fuv.y );\n\t\tfloat h1y = h1( fuv.y );\n\t\tvec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\treturn g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n\t\t\tg1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n\t}\n\tvec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n\t\tvec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n\t\tvec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n\t\tvec2 fLodSizeInv = 1.0 / fLodSize;\n\t\tvec2 cLodSizeInv = 1.0 / cLodSize;\n\t\tvec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n\t\tvec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n\t\treturn mix( fSample, cSample, fract( lod ) );\n\t}\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\treturn textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n\t}\n\tvec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( isinf( attenuationDistance ) ) {\n\t\t\treturn vec3( 1.0 );\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec4 transmittedLight;\n\t\tvec3 transmittance;\n\t\t#ifdef USE_DISPERSION\n\t\t\tfloat halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;\n\t\t\tvec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );\n\t\t\tfor ( int i = 0; i < 3; i ++ ) {\n\t\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );\n\t\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\t\trefractionCoords += 1.0;\n\t\t\t\trefractionCoords /= 2.0;\n\t\t\t\tvec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );\n\t\t\t\ttransmittedLight[ i ] = transmissionSample[ i ];\n\t\t\t\ttransmittedLight.a += transmissionSample.a;\n\t\t\t\ttransmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];\n\t\t\t}\n\t\t\ttransmittedLight.a /= 3.0;\n\t\t#else\n\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\trefractionCoords += 1.0;\n\t\t\trefractionCoords /= 2.0;\n\t\t\ttransmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\t\ttransmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\t#endif\n\t\tvec3 attenuatedColor = transmittance * transmittedLight.rgb;\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\tfloat transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n\t}\n#endif",uv_pars_fragment:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_pars_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tuniform mat3 mapTransform;\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform mat3 alphaMapTransform;\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tuniform mat3 lightMapTransform;\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tuniform mat3 aoMapTransform;\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tuniform mat3 bumpMapTransform;\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tuniform mat3 normalMapTransform;\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tuniform mat3 displacementMapTransform;\n\tvarying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tuniform mat3 emissiveMapTransform;\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tuniform mat3 metalnessMapTransform;\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tuniform mat3 roughnessMapTransform;\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tuniform mat3 anisotropyMapTransform;\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tuniform mat3 clearcoatMapTransform;\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform mat3 clearcoatNormalMapTransform;\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform mat3 clearcoatRoughnessMapTransform;\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tuniform mat3 sheenColorMapTransform;\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tuniform mat3 sheenRoughnessMapTransform;\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tuniform mat3 iridescenceMapTransform;\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform mat3 iridescenceThicknessMapTransform;\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tuniform mat3 specularMapTransform;\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tuniform mat3 specularColorMapTransform;\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tuniform mat3 specularIntensityMapTransform;\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n\tvMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n\tvAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n\tvLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n\tvAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n\tvBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n\tvNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tvDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n\tvMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n\tvSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tvTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n\tvThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_BATCHING\n\t\tworldPosition = batchingMatrix * worldPosition;\n\t#endif\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\ttexColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",backgroundCube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",backgroundCube_frag:"#ifdef ENVMAP_TYPE_CUBE\n\tuniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n\tuniform sampler2D envMap;\n#endif\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nuniform mat3 backgroundRotation;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 texColor = textureCube( envMap, backgroundRotation * vWorldDirection );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );\n\t#else\n\t\tvec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",cube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = texColor;\n\tgl_FragColor.a *= opacity;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",depth_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#include <morphinstance_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\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 <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <logdepthbuf_fragment>\n\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\tfloat fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];\n\t#else\n\t\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;\n\t#endif\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#elif DEPTH_PACKING == 3202\n\t\tgl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );\n\t#elif DEPTH_PACKING == 3203\n\t\tgl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );\n\t#endif\n}",distance_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#include <morphinstance_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}",distance_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\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 <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <uv_pars_vertex>\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>\nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",meshbasic_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinbase_vertex>\n\t\t#include <skinnormal_vertex>\n\t\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\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 <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshlambert_vert:"#define LAMBERT\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\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshlambert_frag:"#define LAMBERT\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 <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_lambert_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\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_lambert_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\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 <fog_pars_fragment>\n#include <normal_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\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <uv_pars_fragment>\n#include <normal_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\tvec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}",meshphong_vert:"#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\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshphong_frag:"#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\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying 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\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_DISPERSION\n\tuniform float dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\n\t#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\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include <transmission_fragment>\n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n \n\t\toutgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect;\n \n \t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;\n\t#endif\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshtoon_vert:"#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\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshtoon_frag:"#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\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",points_vert:"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\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\nvoid main() {\n\t#ifdef USE_POINTS_UV\n\t\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\t#endif\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",shadow_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <logdepthbuf_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\t#include <logdepthbuf_fragment>\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\tvec4 mvPosition = modelViewMatrix[ 3 ];\n\tvec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\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 <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}"},Ca={common:{diffuse:{value:new ft(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Me},alphaMap:{value:null},alphaMapTransform:{value:new Me},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Me}},envmap:{envMap:{value:null},envMapRotation:{value:new Me},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Me}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Me}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Me},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Me},normalScale:{value:new pe(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Me},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Me}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Me}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Me}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new ft(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new Te},probesMax:{value:new Te},probesResolution:{value:new Te}},points:{diffuse:{value:new ft(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Me},alphaTest:{value:0},uvTransform:{value:new Me}},sprite:{diffuse:{value:new ft(16777215)},opacity:{value:1},center:{value:new pe(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Me},alphaMap:{value:null},alphaMapTransform:{value:new Me},alphaTest:{value:0}}},Ra={basic:{uniforms:J([Ca.common,Ca.specularmap,Ca.envmap,Ca.aomap,Ca.lightmap,Ca.fog]),vertexShader:ya.meshbasic_vert,fragmentShader:ya.meshbasic_frag},lambert:{uniforms:J([Ca.common,Ca.specularmap,Ca.envmap,Ca.aomap,Ca.lightmap,Ca.emissivemap,Ca.bumpmap,Ca.normalmap,Ca.displacementmap,Ca.fog,Ca.lights,{emissive:{value:new ft(0)},envMapIntensity:{value:1}}]),vertexShader:ya.meshlambert_vert,fragmentShader:ya.meshlambert_frag},phong:{uniforms:J([Ca.common,Ca.specularmap,Ca.envmap,Ca.aomap,Ca.lightmap,Ca.emissivemap,Ca.bumpmap,Ca.normalmap,Ca.displacementmap,Ca.fog,Ca.lights,{emissive:{value:new ft(0)},specular:{value:new ft(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:ya.meshphong_vert,fragmentShader:ya.meshphong_frag},standard:{uniforms:J([Ca.common,Ca.envmap,Ca.aomap,Ca.lightmap,Ca.emissivemap,Ca.bumpmap,Ca.normalmap,Ca.displacementmap,Ca.roughnessmap,Ca.metalnessmap,Ca.fog,Ca.lights,{emissive:{value:new ft(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:ya.meshphysical_vert,fragmentShader:ya.meshphysical_frag},toon:{uniforms:J([Ca.common,Ca.aomap,Ca.lightmap,Ca.emissivemap,Ca.bumpmap,Ca.normalmap,Ca.displacementmap,Ca.gradientmap,Ca.fog,Ca.lights,{emissive:{value:new ft(0)}}]),vertexShader:ya.meshtoon_vert,fragmentShader:ya.meshtoon_frag},matcap:{uniforms:J([Ca.common,Ca.bumpmap,Ca.normalmap,Ca.displacementmap,Ca.fog,{matcap:{value:null}}]),vertexShader:ya.meshmatcap_vert,fragmentShader:ya.meshmatcap_frag},points:{uniforms:J([Ca.points,Ca.fog]),vertexShader:ya.points_vert,fragmentShader:ya.points_frag},dashed:{uniforms:J([Ca.common,Ca.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:ya.linedashed_vert,fragmentShader:ya.linedashed_frag},depth:{uniforms:J([Ca.common,Ca.displacementmap]),vertexShader:ya.depth_vert,fragmentShader:ya.depth_frag},normal:{uniforms:J([Ca.common,Ca.bumpmap,Ca.normalmap,Ca.displacementmap,{opacity:{value:1}}]),vertexShader:ya.meshnormal_vert,fragmentShader:ya.meshnormal_frag},sprite:{uniforms:J([Ca.sprite,Ca.fog]),vertexShader:ya.sprite_vert,fragmentShader:ya.sprite_frag},background:{uniforms:{uvTransform:{value:new Me},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:ya.background_vert,fragmentShader:ya.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Me}},vertexShader:ya.backgroundCube_vert,fragmentShader:ya.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:ya.cube_vert,fragmentShader:ya.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:ya.equirect_vert,fragmentShader:ya.equirect_frag},distance:{uniforms:J([Ca.common,Ca.displacementmap,{referencePosition:{value:new Te},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:ya.distance_vert,fragmentShader:ya.distance_frag},shadow:{uniforms:J([Ca.lights,Ca.fog,{color:{value:new ft(0)},opacity:{value:1}}]),vertexShader:ya.shadow_vert,fragmentShader:ya.shadow_frag}};Ra.physical={uniforms:J([Ra.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Me},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Me},clearcoatNormalScale:{value:new pe(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Me},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Me},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Me},sheen:{value:0},sheenColor:{value:new ft(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Me},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Me},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Me},transmissionSamplerSize:{value:new pe},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Me},attenuationDistance:{value:0},attenuationColor:{value:new ft(0)},specularColor:{value:new ft(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Me},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Me},anisotropyVector:{value:new pe},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Me}}]),vertexShader:ya.meshphysical_vert,fragmentShader:ya.meshphysical_frag};var Aa={r:0,b:0,g:0},Pa=new tt,Da=new Me;function La(e,t,n,i,a,r){let o,s,l=new ft(0),c=!0===a?0:1,d=null,u=0,f=null;function p(e){let n=!0===e.isScene?e.background:null;if(n&&n.isTexture){let i=e.backgroundBlurriness>0;n=t.get(n,i)}return n}function h(t,i){t.getRGB(Aa,Ft(e)),n.buffers.color.setClear(Aa.r,Aa.g,Aa.b,i,r)}return{getClearColor:function(){return l},setClearColor:function(e,t=1){l.set(e),c=t,h(l,c)},getClearAlpha:function(){return c},setClearAlpha:function(e){c=e,h(l,c)},render:function(t){let i=!1,a=p(t);null===a?h(l,c):a&&a.isColor&&(h(a,1),i=!0);let o=e.xr.getEnvironmentBlendMode();"additive"===o?n.buffers.color.setClear(0,0,0,1,r):"alpha-blend"===o&&n.buffers.color.setClear(0,0,0,0,r),(e.autoClear||i)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil))},addToRenderList:function(t,n){let a=p(n);a&&(a.isCubeTexture||a.mapping===xn)?(void 0===s&&(s=new Pn(new ge(1,1,1),new Xt({name:"BackgroundCubeMaterial",uniforms:Ut(Ra.backgroundCube.uniforms),vertexShader:Ra.backgroundCube.vertexShader,fragmentShader:Ra.backgroundCube.fragmentShader,side:bn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),s.geometry.deleteAttribute("normal"),s.geometry.deleteAttribute("uv"),s.onBeforeRender=function(e,t,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(s.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(s)),s.material.uniforms.envMap.value=a,s.material.uniforms.backgroundBlurriness.value=n.backgroundBlurriness,s.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,s.material.uniforms.backgroundRotation.value.setFromMatrix4(Pa.makeRotationFromEuler(n.backgroundRotation)).transpose(),a.isCubeTexture&&!1===a.isRenderTargetTexture&&s.material.uniforms.backgroundRotation.value.premultiply(Da),s.material.toneMapped=Ae.getTransfer(a.colorSpace)!==We,(d!==a||u!==a.version||f!==e.toneMapping)&&(s.material.needsUpdate=!0,d=a,u=a.version,f=e.toneMapping),s.layers.enableAll(),t.unshift(s,s.geometry,s.material,0,0,null)):a&&a.isTexture&&(void 0===o&&(o=new Pn(new _t(2,2),new Xt({name:"BackgroundMaterial",uniforms:Ut(Ra.background.uniforms),vertexShader:Ra.background.vertexShader,fragmentShader:Ra.background.fragmentShader,side:_n,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),o.geometry.deleteAttribute("normal"),Object.defineProperty(o.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(o)),o.material.uniforms.t2D.value=a,o.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,o.material.toneMapped=Ae.getTransfer(a.colorSpace)!==We,!0===a.matrixAutoUpdate&&a.updateMatrix(),o.material.uniforms.uvTransform.value.copy(a.matrix),(d!==a||u!==a.version||f!==e.toneMapping)&&(o.material.needsUpdate=!0,d=a,u=a.version,f=e.toneMapping),o.layers.enableAll(),t.unshift(o,o.geometry,o.material,0,0,null))},dispose:function(){void 0!==s&&(s.geometry.dispose(),s.material.dispose(),s=void 0),void 0!==o&&(o.geometry.dispose(),o.material.dispose(),o=void 0)}}}function Ua(e,t){let n=e.getParameter(e.MAX_VERTEX_ATTRIBS),i={},a=c(null),r=a,o=!1;function s(t){return e.bindVertexArray(t)}function l(t){return e.deleteVertexArray(t)}function c(e){let t=[],i=[],a=[];for(let e=0;e<n;e++)t[e]=0,i[e]=0,a[e]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:t,enabledAttributes:i,attributeDivisors:a,object:e,attributes:{},index:null}}function d(){let e=r.newAttributes;for(let t=0,n=e.length;t<n;t++)e[t]=0}function u(e){f(e,0)}function f(t,n){let i=r.newAttributes,a=r.enabledAttributes,o=r.attributeDivisors;i[t]=1,0===a[t]&&(e.enableVertexAttribArray(t),a[t]=1),o[t]!==n&&(e.vertexAttribDivisor(t,n),o[t]=n)}function p(){let t=r.newAttributes,n=r.enabledAttributes;for(let i=0,a=n.length;i<a;i++)n[i]!==t[i]&&(e.disableVertexAttribArray(i),n[i]=0)}function h(t,n,i,a,r,o,s){!0===s?e.vertexAttribIPointer(t,n,i,r,o):e.vertexAttribPointer(t,n,i,a,r,o)}function m(){v(),o=!0,r!==a&&(r=a,s(r.object))}function v(){a.geometry=null,a.program=null,a.wireframe=!1}return{setup:function(n,a,l,m,v){let g=!1,_=function(t,n,a,r){let o=!0===r.wireframe,s=i[n.id];void 0===s&&(s={},i[n.id]=s);let l=!0===t.isInstancedMesh?t.id:0,d=s[l];void 0===d&&(d={},s[l]=d);let u=d[a.id];void 0===u&&(u={},d[a.id]=u);let f=u[o];return void 0===f&&(f=c(e.createVertexArray()),u[o]=f),f}(n,m,l,a);r!==_&&(r=_,s(r.object)),g=function(e,t,n,i){let a=r.attributes,o=t.attributes,s=0,l=n.getAttributes();for(let t in l)if(l[t].location>=0){let n=a[t],i=o[t];if(void 0===i&&("instanceMatrix"===t&&e.instanceMatrix&&(i=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(i=e.instanceColor)),void 0===n||n.attribute!==i||i&&n.data!==i.data)return!0;s++}return r.attributesNum!==s||r.index!==i}(n,m,l,v),g&&function(e,t,n,i){let a={},o=t.attributes,s=0,l=n.getAttributes();for(let t in l)if(l[t].location>=0){let n=o[t];void 0===n&&("instanceMatrix"===t&&e.instanceMatrix&&(n=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(n=e.instanceColor));let i={};i.attribute=n,n&&n.data&&(i.data=n.data),a[t]=i,s++}r.attributes=a,r.attributesNum=s,r.index=i}(n,m,l,v),null!==v&&t.update(v,e.ELEMENT_ARRAY_BUFFER),(g||o)&&(o=!1,function(n,i,a,r){d();let o=r.attributes,s=a.getAttributes(),l=i.defaultAttributeValues;for(let i in s){let a=s[i];if(a.location>=0){let s=o[i];if(void 0===s&&("instanceMatrix"===i&&n.instanceMatrix&&(s=n.instanceMatrix),"instanceColor"===i&&n.instanceColor&&(s=n.instanceColor)),void 0!==s){let i=s.normalized,o=s.itemSize,l=t.get(s);if(void 0===l)continue;let c=l.buffer,d=l.type,p=l.bytesPerElement,m=d===e.INT||d===e.UNSIGNED_INT||s.gpuType===wi;if(s.isInterleavedBufferAttribute){let t=s.data,l=t.stride,v=s.offset;if(t.isInstancedInterleavedBuffer){for(let e=0;e<a.locationSize;e++)f(a.location+e,t.meshPerAttribute);!0!==n.isInstancedMesh&&void 0===r._maxInstanceCount&&(r._maxInstanceCount=t.meshPerAttribute*t.count)}else for(let e=0;e<a.locationSize;e++)u(a.location+e);e.bindBuffer(e.ARRAY_BUFFER,c);for(let e=0;e<a.locationSize;e++)h(a.location+e,o/a.locationSize,d,i,l*p,(v+o/a.locationSize*e)*p,m)}else{if(s.isInstancedBufferAttribute){for(let e=0;e<a.locationSize;e++)f(a.location+e,s.meshPerAttribute);!0!==n.isInstancedMesh&&void 0===r._maxInstanceCount&&(r._maxInstanceCount=s.meshPerAttribute*s.count)}else for(let e=0;e<a.locationSize;e++)u(a.location+e);e.bindBuffer(e.ARRAY_BUFFER,c);for(let e=0;e<a.locationSize;e++)h(a.location+e,o/a.locationSize,d,i,o*p,o/a.locationSize*e*p,m)}}else if(void 0!==l){let t=l[i];if(void 0!==t)switch(t.length){case 2:e.vertexAttrib2fv(a.location,t);break;case 3:e.vertexAttrib3fv(a.location,t);break;case 4:e.vertexAttrib4fv(a.location,t);break;default:e.vertexAttrib1fv(a.location,t)}}}}p()}(n,a,l,m),null!==v&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.get(v).buffer))},reset:m,resetDefaultState:v,dispose:function(){m();for(let e in i){let t=i[e];for(let e in t){let n=t[e];for(let e in n){let t=n[e];for(let e in t)l(t[e].object),delete t[e];delete n[e]}}delete i[e]}},releaseStatesOfGeometry:function(e){if(void 0===i[e.id])return;let t=i[e.id];for(let e in t){let n=t[e];for(let e in n){let t=n[e];for(let e in t)l(t[e].object),delete t[e];delete n[e]}}delete i[e.id]},releaseStatesOfObject:function(e){for(let t in i){let n=i[t],a=!0===e.isInstancedMesh?e.id:0,r=n[a];if(void 0!==r){for(let e in r){let t=r[e];for(let e in t)l(t[e].object),delete t[e];delete r[e]}delete n[a],0===Object.keys(n).length&&delete i[t]}}},releaseStatesOfProgram:function(e){for(let t in i){let n=i[t];for(let t in n){let i=n[t];if(void 0===i[e.id])continue;let a=i[e.id];for(let e in a)l(a[e].object),delete a[e];delete i[e.id]}}},initAttributes:d,enableAttribute:u,disableUnusedAttributes:p}}function Na(e,t,n){let i;this.setMode=function(e){i=e},this.render=function(t,a){e.drawArrays(i,t,a),n.update(a,i,1)},this.renderInstances=function(t,a,r){0!==r&&(e.drawArraysInstanced(i,t,a,r),n.update(a,i,r))},this.renderMultiDraw=function(e,a,r){if(0===r)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,e,0,a,0,r);let o=0;for(let e=0;e<r;e++)o+=a[e];n.update(o,i,1)}}function Ia(e,t,n,i){let a;function r(t){if("highp"===t){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let o=void 0!==n.precision?n.precision:"highp",s=r(o);s!==o&&(gi("WebGLRenderer:",o,"not supported, using",s,"instead."),o=s);let l=!0===n.logarithmicDepthBuffer,c=!0===n.reversedDepthBuffer&&t.has("EXT_clip_control");return!0===n.reversedDepthBuffer&&!1===c&&gi("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer."),{isWebGL2:!0,getMaxAnisotropy:function(){if(void 0!==a)return a;if(!0===t.has("EXT_texture_filter_anisotropic")){let n=t.get("EXT_texture_filter_anisotropic");a=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else a=0;return a},getMaxPrecision:r,textureFormatReadable:function(t){return!(t!==Ie&&i.convert(t)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_FORMAT))},textureTypeReadable:function(n){let a=n===re&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));return!(n!==si&&i.convert(n)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_TYPE)&&n!==ee&&!a)},precision:o,logarithmicDepthBuffer:l,reversedDepthBuffer:c,maxTextures:e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),maxVertexTextures:e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),maxTextureSize:e.getParameter(e.MAX_TEXTURE_SIZE),maxCubemapSize:e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),maxAttributes:e.getParameter(e.MAX_VERTEX_ATTRIBS),maxVertexUniforms:e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),maxVaryings:e.getParameter(e.MAX_VARYING_VECTORS),maxFragmentUniforms:e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),maxSamples:e.getParameter(e.MAX_SAMPLES),samples:e.getParameter(e.SAMPLES)}}function Oa(e){let t=this,n=null,i=0,a=!1,r=!1,o=new Qn,s=new Me,l={value:null,needsUpdate:!1};function c(e,n,i,a){let r=null!==e?e.length:0,c=null;if(0!==r){if(c=l.value,!0!==a||null===c){let t=i+4*r,a=n.matrixWorldInverse;s.getNormalMatrix(a),(null===c||c.length<t)&&(c=new Float32Array(t));for(let t=0,n=i;t!==r;++t,n+=4)o.copy(e[t]).applyMatrix4(a,s),o.normal.toArray(c,n),c[n+3]=o.constant}l.value=c,l.needsUpdate=!0}return t.numPlanes=r,t.numIntersection=0,c}this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(e,t){let n=0!==e.length||t||0!==i||a;return a=t,i=e.length,n},this.beginShadows=function(){r=!0,c(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(e,t){n=c(e,t,0)},this.setState=function(o,s,d){let u=o.clippingPlanes,f=o.clipIntersection,p=o.clipShadows,h=e.get(o);if(!a||null===u||0===u.length||r&&!p)r?c(null):(l.value!==n&&(l.value=n,l.needsUpdate=i>0),t.numPlanes=i,t.numIntersection=0);else{let e=r?0:i,t=4*e,a=h.clippingState||null;l.value=a,a=c(u,s,t,d);for(let e=0;e!==t;++e)a[e]=n[e];h.clippingState=a,this.numIntersection=f?this.numPlanes:0,this.numPlanes+=e}}}Da.set(-1,0,0,0,1,0,0,0,1);var Fa=class extends Xe{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;let n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];this.texture=new ne(i),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let n={tEquirect:{value:null}},i="\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t\t#include <project_vertex>\n\n\t\t\t\t}\n\t\t\t",a="\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include <common>\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t",r=new ge(5,5,5),o=new Xt({name:"CubemapFromEquirect",uniforms:Ut(n),vertexShader:i,fragmentShader:a,side:bn,blending:Ln});o.uniforms.tEquirect.value=t;let s=new Pn(r,o),l=t.minFilter;return t.minFilter===ei&&(t.minFilter=qn),(()=>{throw new Error("fromEquirectangularTexture is not supported by the Spline runtime")})().update(e,s),t.minFilter=l,s.geometry.dispose(),s.material.dispose(),this}clear(e,t=!0,n=!0,i=!0){let a=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,i);e.setRenderTarget(a)}};function za(e){let t=new WeakMap,n=new WeakMap,i=null;function a(e,t){return t===un?e.mapping=nn:t===mn&&(e.mapping=sn),e}function r(e){let n=e.target;n.removeEventListener("dispose",r);let i=t.get(n);void 0!==i&&(t.delete(n),i.dispose())}function o(e){let t=e.target;t.removeEventListener("dispose",o);let i=n.get(t);void 0!==i&&(n.delete(t),i.dispose())}return{get:function(s,l=!1){return null==s?null:l?function(e){if(e&&e.isTexture){let t=e.mapping,a=t===un||t===mn,r=t===nn||t===sn;if(a||r){let t=n.get(e),s=void 0!==t?t.texture.pmremVersion:0;if(e.isRenderTargetTexture&&e.pmremVersion!==s){if(null===i)throw new Error("PMREM environment-map conversion is not supported by the Spline runtime");return t=a?i.fromEquirectangular(e,t):i.fromCubemap(e,t),t.texture.pmremVersion=e.pmremVersion,n.set(e,t),t.texture}if(void 0!==t)return t.texture;{let s=e.image;if(a&&s&&s.height>0||r&&s&&function(e){let t=0;for(let n=0;n<6;n++)void 0!==e[n]&&t++;return 6===t}(s)){if(null===i)throw new Error("PMREM environment-map conversion is not supported by the Spline runtime");return t=a?i.fromEquirectangular(e):i.fromCubemap(e),t.texture.pmremVersion=e.pmremVersion,n.set(e,t),e.addEventListener("dispose",o),t.texture}return null}}}return e}(s):function(n){if(n&&n.isTexture){let i=n.mapping;if(i===un||i===mn){if(t.has(n))return a(t.get(n).texture,n.mapping);{let i=n.image;if(i&&i.height>0){let o=new Fa(i.height);return o.fromEquirectangularTexture(e,n),t.set(n,o),n.addEventListener("dispose",r),a(o.texture,n.mapping)}return null}}}return n}(s)},dispose:function(){t=new WeakMap,n=new WeakMap,null!==i&&(i.dispose(),i=null)}}}function Ba(e){let t={};function n(n){if(void 0!==t[n])return t[n];let i=e.getExtension(n);return t[n]=i,i}return{has:function(e){return null!==n(e)},init:function(){n("EXT_color_buffer_float"),n("WEBGL_clip_cull_distance"),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture"),n("WEBGL_render_shared_exponent")},get:function(e){let t=n(e);return null===t&&Mi("WebGLRenderer: "+e+" extension not supported."),t}}}function Va(e,t,n,i){let a={},r=new WeakMap;function o(e){let s=e.target;null!==s.index&&t.remove(s.index);for(let e in s.attributes)t.remove(s.attributes[e]);s.removeEventListener("dispose",o),delete a[s.id];let l=r.get(s);l&&(t.remove(l),r.delete(s)),i.releaseStatesOfGeometry(s),!0===s.isInstancedBufferGeometry&&delete s._maxInstanceCount,n.memory.geometries--}function s(e){let n=[],i=e.index,a=e.attributes.position,o=0;if(void 0===a)return;if(null!==i){let e=i.array;o=i.version;for(let t=0,i=e.length;t<i;t+=3){let i=e[t+0],a=e[t+1],r=e[t+2];n.push(i,a,a,r,r,i)}}else{let e=a.array;o=a.version;for(let t=0,i=e.length/3-1;t<i;t+=3){let e=t+0,i=t+1,a=t+2;n.push(e,i,i,a,a,e)}}let s=new(a.count>=65535?Z:Lt)(n,1);s.version=o;let l=r.get(e);l&&t.remove(l),r.set(e,s)}return{get:function(e,t){return!0===a[t.id]||(t.addEventListener("dispose",o),a[t.id]=!0,n.memory.geometries++),t},update:function(n){let i=n.attributes;for(let n in i)t.update(i[n],e.ARRAY_BUFFER)},getWireframeAttribute:function(e){let t=r.get(e);if(t){let n=e.index;null!==n&&t.version<n.version&&s(e)}else s(e);return r.get(e)}}}function Ha(e,t,n){let i,a,r;this.setMode=function(e){i=e},this.setIndex=function(e){a=e.type,r=e.bytesPerElement},this.render=function(t,o){e.drawElements(i,o,a,t*r),n.update(o,i,1)},this.renderInstances=function(t,o,s){0!==s&&(e.drawElementsInstanced(i,o,a,t*r,s),n.update(o,i,s))},this.renderMultiDraw=function(e,r,o){if(0===o)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,r,0,a,e,0,o);let s=0;for(let e=0;e<o;e++)s+=r[e];n.update(s,i,1)}}function Ga(e){let t={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:t,programs:null,autoReset:!0,reset:function(){t.calls=0,t.triangles=0,t.points=0,t.lines=0},update:function(n,i,a){switch(t.calls++,i){case e.TRIANGLES:t.triangles+=a*(n/3);break;case e.LINES:t.lines+=a*(n/2);break;case e.LINE_STRIP:t.lines+=a*(n-1);break;case e.LINE_LOOP:t.lines+=a*n;break;case e.POINTS:t.points+=a*n;break;default:Ti("WebGLInfo: Unknown draw mode:",i)}}}}function ka(e,t,n){let i=new WeakMap,a=new Fe;return{update:function(r,o,s){let l=r.morphTargetInfluences,c=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,d=void 0!==c?c.length:0,u=i.get(o);if(void 0===u||u.count!==d){let e=function(){g.dispose(),i.delete(o),o.removeEventListener("dispose",e)};void 0!==u&&u.texture.dispose();let n=void 0!==o.morphAttributes.position,r=void 0!==o.morphAttributes.normal,s=void 0!==o.morphAttributes.color,l=o.morphAttributes.position||[],c=o.morphAttributes.normal||[],f=o.morphAttributes.color||[],p=0;!0===n&&(p=1),!0===r&&(p=2),!0===s&&(p=3);let h=o.attributes.position.count*p,m=1;h>t.maxTextureSize&&(m=Math.ceil(h/t.maxTextureSize),h=t.maxTextureSize);let v=new Float32Array(h*m*4*d),g=new Ye(v,h,m,d);g.type=ee,g.needsUpdate=!0;let _=4*p;for(let e=0;e<d;e++){let t=l[e],i=c[e],o=f[e],d=h*m*4*e;for(let e=0;e<t.count;e++){let l=e*_;!0===n&&(a.fromBufferAttribute(t,e),v[d+l+0]=a.x,v[d+l+1]=a.y,v[d+l+2]=a.z,v[d+l+3]=0),!0===r&&(a.fromBufferAttribute(i,e),v[d+l+4]=a.x,v[d+l+5]=a.y,v[d+l+6]=a.z,v[d+l+7]=0),!0===s&&(a.fromBufferAttribute(o,e),v[d+l+8]=a.x,v[d+l+9]=a.y,v[d+l+10]=a.z,v[d+l+11]=4===o.itemSize?a.w:1)}}u={count:d,texture:g,size:new pe(h,m)},i.set(o,u),o.addEventListener("dispose",e)}if(!0===r.isInstancedMesh&&null!==r.morphTexture)s.getUniforms().setValue(e,"morphTexture",r.morphTexture,n);else{let t=0;for(let e=0;e<l.length;e++)t+=l[e];let n=o.morphTargetsRelative?1:1-t;s.getUniforms().setValue(e,"morphTargetBaseInfluence",n),s.getUniforms().setValue(e,"morphTargetInfluences",l)}s.getUniforms().setValue(e,"morphTargetsTexture",u.texture,n),s.getUniforms().setValue(e,"morphTargetsTextureSize",u.size)}}}function Wa(e,t,n,i,a){let r=new WeakMap;function o(e){let t=e.target;t.removeEventListener("dispose",o),i.releaseStatesOfObject(t),n.remove(t.instanceMatrix),null!==t.instanceColor&&n.remove(t.instanceColor)}return{update:function(i){let s=a.render.frame,l=i.geometry,c=t.get(i,l);if(r.get(c)!==s&&(t.update(c),r.set(c,s)),i.isInstancedMesh&&(!1===i.hasEventListener("dispose",o)&&i.addEventListener("dispose",o),r.get(i)!==s&&(n.update(i.instanceMatrix,e.ARRAY_BUFFER),null!==i.instanceColor&&n.update(i.instanceColor,e.ARRAY_BUFFER),r.set(i,s))),i.isSkinnedMesh){let e=i.skeleton;r.get(e)!==s&&(e.update(),r.set(e,s))}return c},dispose:function(){r=new WeakMap}}}var Xa={[yt]:"LINEAR_TONE_MAPPING",[Pt]:"REINHARD_TONE_MAPPING",[Y]:"CINEON_TONE_MAPPING",[It]:"ACES_FILMIC_TONE_MAPPING",[kt]:"AGX_TONE_MAPPING",[$t]:"NEUTRAL_TONE_MAPPING",[zt]:"CUSTOM_TONE_MAPPING"};function ja(e,t,n,i,a,r){let o=new Xe(t,n,{type:e,depthBuffer:a,stencilBuffer:r,samples:i?4:0,depthTexture:a?new de(t,n):void 0}),s=new Xe(t,n,{type:re,depthBuffer:!1,stencilBuffer:!1}),l=new Kt;l.setAttribute("position",new Vt([-1,3,0,-1,-1,0,3,-1,0],3)),l.setAttribute("uv",new Vt([0,2,0,0,2,0],2));let c,d=new Zt({uniforms:{tDiffuse:{value:null}},vertexShader:"\n\t\t\tprecision highp float;\n\n\t\t\tuniform mat4 modelViewMatrix;\n\t\t\tuniform mat4 projectionMatrix;\n\n\t\t\tattribute vec3 position;\n\t\t\tattribute vec2 uv;\n\n\t\t\tvarying vec2 vUv;\n\n\t\t\tvoid main() {\n\t\t\t\tvUv = uv;\n\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t}",fragmentShader:"\n\t\t\tprecision highp float;\n\n\t\t\tuniform sampler2D tDiffuse;\n\n\t\t\tvarying vec2 vUv;\n\n\t\t\t#include <tonemapping_pars_fragment>\n\t\t\t#include <colorspace_pars_fragment>\n\n\t\t\tvoid main() {\n\t\t\t\tgl_FragColor = texture2D( tDiffuse, vUv );\n\n\t\t\t\t#ifdef LINEAR_TONE_MAPPING\n\t\t\t\t\tgl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( REINHARD_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( CINEON_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( ACES_FILMIC_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( AGX_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( NEUTRAL_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( CUSTOM_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb );\n\t\t\t\t#endif\n\n\t\t\t\t#ifdef SRGB_TRANSFER\n\t\t\t\t\tgl_FragColor = sRGBTransferOETF( gl_FragColor );\n\t\t\t\t#endif\n\t\t\t}",depthTest:!1,depthWrite:!1}),u=new Pn(l,d),f=new ie(-1,1,1,-1,0,1),p=null,h=null,m=!1,v=null,g=[],_=!1;this.setSize=function(e,t){o.setSize(e,t),s.setSize(e,t);for(let n=0;n<g.length;n++){let i=g[n];i.setSize&&i.setSize(e,t)}},this.setEffects=function(e){g=e,_=g.length>0&&!0===g[0].isRenderPass;let t=o.width,n=o.height;for(let e=0;e<g.length;e++){let i=g[e];i.setSize&&i.setSize(t,n)}},this.begin=function(e,t){if(m||e.toneMapping===wt&&0===g.length)return!1;if(v=t,null!==t){let e=t.width,n=t.height;(o.width!==e||o.height!==n)&&this.setSize(e,n)}return!1===_&&e.setRenderTarget(o),c=e.toneMapping,e.toneMapping=wt,!0},this.hasRenderPass=function(){return _},this.end=function(e,t){e.toneMapping=c,m=!0;let n=o,i=s;for(let a=0;a<g.length;a++){let r=g[a];if(!1!==r.enabled&&(r.render(e,i,n,t),!1!==r.needsSwap)){let e=n;n=i,i=e}}if(p!==e.outputColorSpace||h!==e.toneMapping){p=e.outputColorSpace,h=e.toneMapping,d.defines={},Ae.getTransfer(p)===We&&(d.defines.SRGB_TRANSFER="");let t=Xa[h];t&&(d.defines[t]=""),d.needsUpdate=!0}d.uniforms.tDiffuse.value=n.texture,e.setRenderTarget(v),e.render(u,f),v=null,m=!1},this.isCompositing=function(){return m},this.dispose=function(){o.depthTexture&&o.depthTexture.dispose(),o.dispose(),s.dispose(),l.dispose(),d.dispose()}}var $a=new Ue,qa=new de(1,1),Ya=new Ye,Ka=new Je,Za=new ne,Ja=[],Qa=[],er=new Float32Array(16),tr=new Float32Array(9),nr=new Float32Array(4);function ir(e,t,n){let i=e[0];if(null==i||i<=0||i>0)return e;let a=t*n,r=Ja[a];if(void 0===r&&(r=new Float32Array(a),Ja[a]=r),0!==t){i.toArray(r,0);for(let i=1,a=0;i!==t;++i)a+=n,e[i].toArray(r,a)}return r}function ar(e,t){if(e.length!==t.length)return!1;for(let n=0,i=e.length;n<i;n++)if(e[n]!==t[n])return!1;return!0}function rr(e,t){for(let n=0,i=t.length;n<i;n++)e[n]=t[n]}function or(e,t){let n=Qa[t];void 0===n&&(n=new Int32Array(t),Qa[t]=n);for(let i=0;i!==t;++i)n[i]=e.allocateTextureUnit();return n}function sr(e,t){let n=this.cache;n[0]!==t&&(e.uniform1f(this.addr,t),n[0]=t)}function lr(e,t){let n=this.cache;if(void 0!==t.x)(n[0]!==t.x||n[1]!==t.y)&&(e.uniform2f(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(ar(n,t))return;e.uniform2fv(this.addr,t),rr(n,t)}}function cr(e,t){let n=this.cache;if(void 0!==t.x)(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)&&(e.uniform3f(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else if(void 0!==t.r)(n[0]!==t.r||n[1]!==t.g||n[2]!==t.b)&&(e.uniform3f(this.addr,t.r,t.g,t.b),n[0]=t.r,n[1]=t.g,n[2]=t.b);else{if(ar(n,t))return;e.uniform3fv(this.addr,t),rr(n,t)}}function dr(e,t){let n=this.cache;if(void 0!==t.x)(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)&&(e.uniform4f(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(ar(n,t))return;e.uniform4fv(this.addr,t),rr(n,t)}}function ur(e,t){let n=this.cache,i=t.elements;if(void 0===i){if(ar(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),rr(n,t)}else{if(ar(n,i))return;nr.set(i),e.uniformMatrix2fv(this.addr,!1,nr),rr(n,i)}}function fr(e,t){let n=this.cache,i=t.elements;if(void 0===i){if(ar(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),rr(n,t)}else{if(ar(n,i))return;tr.set(i),e.uniformMatrix3fv(this.addr,!1,tr),rr(n,i)}}function pr(e,t){let n=this.cache,i=t.elements;if(void 0===i){if(ar(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),rr(n,t)}else{if(ar(n,i))return;er.set(i),e.uniformMatrix4fv(this.addr,!1,er),rr(n,i)}}function hr(e,t){let n=this.cache;n[0]!==t&&(e.uniform1i(this.addr,t),n[0]=t)}function mr(e,t){let n=this.cache;if(void 0!==t.x)(n[0]!==t.x||n[1]!==t.y)&&(e.uniform2i(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(ar(n,t))return;e.uniform2iv(this.addr,t),rr(n,t)}}function vr(e,t){let n=this.cache;if(void 0!==t.x)(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)&&(e.uniform3i(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else{if(ar(n,t))return;e.uniform3iv(this.addr,t),rr(n,t)}}function gr(e,t){let n=this.cache;if(void 0!==t.x)(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)&&(e.uniform4i(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(ar(n,t))return;e.uniform4iv(this.addr,t),rr(n,t)}}function _r(e,t){let n=this.cache;n[0]!==t&&(e.uniform1ui(this.addr,t),n[0]=t)}function xr(e,t){let n=this.cache;if(void 0!==t.x)(n[0]!==t.x||n[1]!==t.y)&&(e.uniform2ui(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(ar(n,t))return;e.uniform2uiv(this.addr,t),rr(n,t)}}function Sr(e,t){let n=this.cache;if(void 0!==t.x)(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)&&(e.uniform3ui(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else{if(ar(n,t))return;e.uniform3uiv(this.addr,t),rr(n,t)}}function Tr(e,t){let n=this.cache;if(void 0!==t.x)(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)&&(e.uniform4ui(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(ar(n,t))return;e.uniform4uiv(this.addr,t),rr(n,t)}}function br(e,t,n){let i,a=this.cache,r=n.allocateTextureUnit();a[0]!==r&&(e.uniform1i(this.addr,r),a[0]=r),this.type===e.SAMPLER_2D_SHADOW?(qa.compareFunction=n.isReversedDepthBuffer()?Tn:cn,i=qa):i=$a,n.setTexture2D(t||i,r)}function wr(e,t,n){let i=this.cache,a=n.allocateTextureUnit();i[0]!==a&&(e.uniform1i(this.addr,a),i[0]=a),n.setTexture3D(t||Ka,a)}function Er(e,t,n){let i=this.cache,a=n.allocateTextureUnit();i[0]!==a&&(e.uniform1i(this.addr,a),i[0]=a),n.setTextureCube(t||Za,a)}function Mr(e,t,n){let i=this.cache,a=n.allocateTextureUnit();i[0]!==a&&(e.uniform1i(this.addr,a),i[0]=a),n.setTexture2DArray(t||Ya,a)}function yr(e,t){e.uniform1fv(this.addr,t)}function Cr(e,t){let n=ir(t,this.size,2);e.uniform2fv(this.addr,n)}function Rr(e,t){let n=ir(t,this.size,3);e.uniform3fv(this.addr,n)}function Ar(e,t){let n=ir(t,this.size,4);e.uniform4fv(this.addr,n)}function Pr(e,t){let n=ir(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,n)}function Dr(e,t){let n=ir(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,n)}function Lr(e,t){let n=ir(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,n)}function Ur(e,t){e.uniform1iv(this.addr,t)}function Nr(e,t){e.uniform2iv(this.addr,t)}function Ir(e,t){e.uniform3iv(this.addr,t)}function Or(e,t){e.uniform4iv(this.addr,t)}function Fr(e,t){e.uniform1uiv(this.addr,t)}function zr(e,t){e.uniform2uiv(this.addr,t)}function Br(e,t){e.uniform3uiv(this.addr,t)}function Vr(e,t){e.uniform4uiv(this.addr,t)}function Hr(e,t,n){let i,a=this.cache,r=t.length,o=or(n,r);ar(a,o)||(e.uniform1iv(this.addr,o),rr(a,o)),i=this.type===e.SAMPLER_2D_SHADOW?qa:$a;for(let e=0;e!==r;++e)n.setTexture2D(t[e]||i,o[e])}function Gr(e,t,n){let i=this.cache,a=t.length,r=or(n,a);ar(i,r)||(e.uniform1iv(this.addr,r),rr(i,r));for(let e=0;e!==a;++e)n.setTexture3D(t[e]||Ka,r[e])}function kr(e,t,n){let i=this.cache,a=t.length,r=or(n,a);ar(i,r)||(e.uniform1iv(this.addr,r),rr(i,r));for(let e=0;e!==a;++e)n.setTextureCube(t[e]||Za,r[e])}function Wr(e,t,n){let i=this.cache,a=t.length,r=or(n,a);ar(i,r)||(e.uniform1iv(this.addr,r),rr(i,r));for(let e=0;e!==a;++e)n.setTexture2DArray(t[e]||Ya,r[e])}var Xr=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=function(e){switch(e){case 5126:return sr;case 35664:return lr;case 35665:return cr;case 35666:return dr;case 35674:return ur;case 35675:return fr;case 35676:return pr;case 5124:case 35670:return hr;case 35667:case 35671:return mr;case 35668:case 35672:return vr;case 35669:case 35673:return gr;case 5125:return _r;case 36294:return xr;case 36295:return Sr;case 36296:return Tr;case 35678:case 36198:case 36298:case 36306:case 35682:return br;case 35679:case 36299:case 36307:return wr;case 35680:case 36300:case 36308:case 36293:return Er;case 36289:case 36303:case 36311:case 36292:return Mr}}(t.type)}},jr=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=function(e){switch(e){case 5126:return yr;case 35664:return Cr;case 35665:return Rr;case 35666:return Ar;case 35674:return Pr;case 35675:return Dr;case 35676:return Lr;case 5124:case 35670:return Ur;case 35667:case 35671:return Nr;case 35668:case 35672:return Ir;case 35669:case 35673:return Or;case 5125:return Fr;case 36294:return zr;case 36295:return Br;case 36296:return Vr;case 35678:case 36198:case 36298:case 36306:case 35682:return Hr;case 35679:case 36299:case 36307:return Gr;case 35680:case 36300:case 36308:case 36293:return kr;case 36289:case 36303:case 36311:case 36292:return Wr}}(t.type)}},$r=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){if(void 0===t)return;let i=this.seq;for(let a=0,r=i.length;a!==r;++a){let r=i[a];r.setValue(e,t[r.id],n)}}},qr=/(\w+)(\])?(\[|\.)?/g;function Yr(e,t){e.seq.push(t),e.map[t.id]=t}function Kr(e,t,n){let i=e.name,a=i.length;for(qr.lastIndex=0;;){let r=qr.exec(i),o=qr.lastIndex,s=r[1],l="]"===r[2],c=r[3];if(l&&(s|=0),void 0===c||"["===c&&o+2===a){Yr(n,void 0===c?new Xr(s,e,t):new jr(s,e,t));break}{let e=n.map[s];void 0===e&&(e=new $r(s),Yr(n,e)),n=e}}}var Zr=class{constructor(e,t){this.seq=[],this.map={};let n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let i=0;i<n;++i){let n=e.getActiveUniform(t,i);Kr(n,e.getUniformLocation(t,n.name),this)}let i=[],a=[];for(let t of this.seq)t.type===e.SAMPLER_2D_SHADOW||t.type===e.SAMPLER_CUBE_SHADOW||t.type===e.SAMPLER_2D_ARRAY_SHADOW?i.push(t):a.push(t);i.length>0&&(this.seq=i.concat(a))}setValue(e,t,n,i){let a=this.map[t];void 0!==a&&a.setValue(e,n,i)}setOptional(e,t,n){let i=t[n];void 0!==i&&this.setValue(e,n,i)}static upload(e,t,n,i){for(let a=0,r=t.length;a!==r;++a){let r=t[a],o=n[r.id];!1!==o.needsUpdate&&r.setValue(e,o.value,i)}}static seqWithValue(e,t){let n=[];for(let i=0,a=e.length;i!==a;++i){let a=e[i];a.id in t&&n.push(a)}return n}};function Jr(e,t,n){let i=e.createShader(t);return e.shaderSource(i,n),e.compileShader(i),i}var Qr=0,eo=new Me;function to(e,t,n){let i=e.getShaderParameter(t,e.COMPILE_STATUS),a=(e.getShaderInfoLog(t)||"").trim();if(i&&""===a)return"";let r=/ERROR: 0:(\d+)/.exec(a);if(r){let i=parseInt(r[1]);return n.toUpperCase()+"\n\n"+a+"\n\n"+function(e,t){let n=e.split("\n"),i=[],a=Math.max(t-6,0),r=Math.min(t+6,n.length);for(let e=a;e<r;e++){let a=e+1;i.push(`${a===t?">":" "} ${a}: ${n[e]}`)}return i.join("\n")}(e.getShaderSource(t),i)}return a}function no(e,t){let n=function(e){Ae._getMatrix(eo,Ae.workingColorSpace,e);let t=`mat3( ${eo.elements.map(e=>e.toFixed(4))} )`;switch(Ae.getTransfer(e)){case He:return[t,"LinearTransferOETF"];case We:return[t,"sRGBTransferOETF"];default:return gi("WebGLProgram: Unsupported color space: ",e),[t,"LinearTransferOETF"]}}(t);return[`vec4 ${e}( vec4 value ) {`,`\treturn ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join("\n")}var io={[yt]:"Linear",[Pt]:"Reinhard",[Y]:"Cineon",[It]:"ACESFilmic",[kt]:"AgX",[$t]:"Neutral",[zt]:"Custom"};function ao(e,t){let n=io[t];return void 0===n?(gi("WebGLProgram: Unsupported toneMapping:",t),"vec3 "+e+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}var ro=new Te;function oo(e){return""!==e}function so(e,t){let n=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return e.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function lo(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}var co=/^[ \t]*#include +<([\w\d./]+)>/gm;function uo(e){return e.replace(co,po)}var fo=new Map;function po(e,t){let n=ya[t];if(void 0===n){let e=fo.get(t);if(void 0===e)throw new Error("THREE.WebGLProgram: Can not resolve #include <"+t+">");n=ya[e],gi('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,e)}return uo(n)}var ho=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function mo(e){return e.replace(ho,vo)}function vo(e,t,n,i){let a="";for(let e=parseInt(t);e<parseInt(n);e++)a+=i.replace(/\[\s*i\s*\]/g,"[ "+e+" ]").replace(/UNROLLED_LOOP_INDEX/g,e);return a}function go(e){let t=`precision ${e.precision} float;\n\tprecision ${e.precision} int;\n\tprecision ${e.precision} sampler2D;\n\tprecision ${e.precision} samplerCube;\n\tprecision ${e.precision} sampler3D;\n\tprecision ${e.precision} sampler2DArray;\n\tprecision ${e.precision} sampler2DShadow;\n\tprecision ${e.precision} samplerCubeShadow;\n\tprecision ${e.precision} sampler2DArrayShadow;\n\tprecision ${e.precision} isampler2D;\n\tprecision ${e.precision} isampler3D;\n\tprecision ${e.precision} isamplerCube;\n\tprecision ${e.precision} isampler2DArray;\n\tprecision ${e.precision} usampler2D;\n\tprecision ${e.precision} usampler3D;\n\tprecision ${e.precision} usamplerCube;\n\tprecision ${e.precision} usampler2DArray;\n\t`;return"highp"===e.precision?t+="\n#define HIGH_PRECISION":"mediump"===e.precision?t+="\n#define MEDIUM_PRECISION":"lowp"===e.precision&&(t+="\n#define LOW_PRECISION"),t}var _o={[on]:"SHADOWMAP_TYPE_PCF",[hn]:"SHADOWMAP_TYPE_VSM"},xo={[nn]:"ENVMAP_TYPE_CUBE",[sn]:"ENVMAP_TYPE_CUBE",[xn]:"ENVMAP_TYPE_CUBE_UV"},So={[sn]:"ENVMAP_MODE_REFRACTION"},To={[mt]:"ENVMAP_BLENDING_MULTIPLY",[xt]:"ENVMAP_BLENDING_MIX",[Tt]:"ENVMAP_BLENDING_ADD"};function bo(e,t,n,i){let a,r,o=e.getContext(),s=n.defines,l=n.vertexShader,c=n.fragmentShader,d=function(e){return _o[e.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}(n),u=function(e){return!1===e.envMap?"ENVMAP_TYPE_CUBE":xo[e.envMapMode]||"ENVMAP_TYPE_CUBE"}(n),f=function(e){return!1===e.envMap?"ENVMAP_MODE_REFLECTION":So[e.envMapMode]||"ENVMAP_MODE_REFLECTION"}(n),p=function(e){return!1===e.envMap?"ENVMAP_BLENDING_NONE":To[e.combine]||"ENVMAP_BLENDING_NONE"}(n),h=function(e){let t=e.envMapCubeUVHeight;if(null===t)return null;let n=Math.log2(t)-2,i=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,n),112)),texelHeight:i,maxMip:n}}(n),m=function(e){return[e.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",e.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(oo).join("\n")}(n),v=function(e){let t=[];for(let n in e){let i=e[n];!1!==i&&t.push("#define "+n+" "+i)}return t.join("\n")}(s),g=o.createProgram(),_=n.glslVersion?"#version "+n.glslVersion+"\n":"";n.isRawShaderMaterial?(a=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,v].filter(oo).join("\n"),a.length>0&&(a+="\n"),r=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,v].filter(oo).join("\n"),r.length>0&&(r+="\n")):(a=[go(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,v,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+f:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexNormals?"#define HAS_NORMAL":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+d:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH","\tuniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(oo).join("\n"),r=[go(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,v,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.envMap?"#define "+f:"",n.envMap?"#define "+p:"",h?"#define CUBEUV_TEXEL_WIDTH "+h.texelWidth:"",h?"#define CUBEUV_TEXEL_HEIGHT "+h.texelHeight:"",h?"#define CUBEUV_MAX_MIP "+h.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas||n.batchingColor?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+d:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==wt?"#define TONE_MAPPING":"",n.toneMapping!==wt?ya.tonemapping_pars_fragment:"",n.toneMapping!==wt?ao("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",ya.colorspace_pars_fragment,no("linearToOutputTexel",n.outputColorSpace),(Ae.getLuminanceCoefficients(ro),["float luminance( const in vec3 rgb ) {",`\tconst vec3 weights = vec3( ${ro.x.toFixed(4)}, ${ro.y.toFixed(4)}, ${ro.z.toFixed(4)} );`,"\treturn dot( weights, rgb );","}"].join("\n")),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(oo).join("\n")),l=uo(l),l=so(l,n),l=lo(l,n),c=uo(c),c=so(c,n),c=lo(c,n),l=mo(l),c=mo(c),!0!==n.isRawShaderMaterial&&(_="#version 300 es\n",a=[m,"#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+a,r=["#define varying in",n.glslVersion===zn?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===zn?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+r);let x,S,T=_+a+l,b=_+r+c,w=Jr(o,o.VERTEX_SHADER,T),E=Jr(o,o.FRAGMENT_SHADER,b);function M(t){if(e.debug.checkShaderErrors){let n=o.getProgramInfoLog(g)||"",i=o.getShaderInfoLog(w)||"",s=o.getShaderInfoLog(E)||"",l=n.trim(),c=i.trim(),d=s.trim(),u=!0,f=!0;if(!1===o.getProgramParameter(g,o.LINK_STATUS))if(u=!1,"function"==typeof e.debug.onShaderError)e.debug.onShaderError(o,g,w,E);else{let e=to(o,w,"vertex"),n=to(o,E,"fragment");Ti("WebGLProgram: Shader Error "+o.getError()+" - VALIDATE_STATUS "+o.getProgramParameter(g,o.VALIDATE_STATUS)+"\n\nMaterial Name: "+t.name+"\nMaterial Type: "+t.type+"\n\nProgram Info Log: "+l+"\n"+e+"\n"+n)}else""!==l?gi("WebGLProgram: Program Info Log:",l):(""===c||""===d)&&(f=!1);f&&(t.diagnostics={runnable:u,programLog:l,vertexShader:{log:c,prefix:a},fragmentShader:{log:d,prefix:r}})}o.deleteShader(w),o.deleteShader(E),x=new Zr(o,g),S=function(e,t){let n={},i=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let a=0;a<i;a++){let i=e.getActiveAttrib(t,a),r=i.name,o=1;i.type===e.FLOAT_MAT2&&(o=2),i.type===e.FLOAT_MAT3&&(o=3),i.type===e.FLOAT_MAT4&&(o=4),n[r]={type:i.type,location:e.getAttribLocation(t,r),locationSize:o}}return n}(o,g)}o.attachShader(g,w),o.attachShader(g,E),void 0!==n.index0AttributeName?o.bindAttribLocation(g,0,n.index0AttributeName):!0===n.hasPositionAttribute&&o.bindAttribLocation(g,0,"position"),o.linkProgram(g),this.getUniforms=function(){return void 0===x&&M(this),x},this.getAttributes=function(){return void 0===S&&M(this),S};let y=!1===n.rendererExtensionParallelShaderCompile;return this.isReady=function(){return!1===y&&(y=o.getProgramParameter(g,37297)),y},this.destroy=function(){i.releaseStatesOfProgram(this),o.deleteProgram(g),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=Qr++,this.cacheKey=t,this.usedTimes=1,this.program=g,this.vertexShader=w,this.fragmentShader=E,this}var wo=0,Eo=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,n){let i=this._getShaderCacheForMaterial(e);return!1===i.has(t)&&(i.add(t),t.usedTimes++),!1===i.has(n)&&(i.add(n),n.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let e of t)e.usedTimes--,0===e.usedTimes&&this.shaderCache.delete(e.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,n=t.get(e);return void 0===n&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){let t=this.shaderCache,n=t.get(e);return void 0===n&&(n=new Mo(e),t.set(e,n)),n}},Mo=class{constructor(e){this.id=wo++,this.code=e,this.usedTimes=0}};function yo(e){return e===et||e===qt||e===Ei}function Co(e,t,n,i,a,r){let o=new rt,s=new Eo,l=new Set,c=[],d=new Map,u=i.logarithmicDepthBuffer,f=i.precision,p={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function h(e){return l.add(e),0===e?"uv":`uv${e}`}return{getParameters:function(a,o,c,d,m,v){let g=d.fog,_=m.geometry,x=a.isMeshStandardMaterial||a.isMeshLambertMaterial||a.isMeshPhongMaterial?d.environment:null,S=a.isMeshStandardMaterial||a.isMeshLambertMaterial&&!a.envMap||a.isMeshPhongMaterial&&!a.envMap,T=t.get(a.envMap||x,S),b=T&&T.mapping===xn?T.image.height:null,w=p[a.type];null!==a.precision&&(f=i.getMaxPrecision(a.precision),f!==a.precision&&gi("WebGLProgram.getParameters:",a.precision,"not supported, using",f,"instead."));let E,M,y,C,R=_.morphAttributes.position||_.morphAttributes.normal||_.morphAttributes.color,A=void 0!==R?R.length:0,P=0;if(void 0!==_.morphAttributes.position&&(P=1),void 0!==_.morphAttributes.normal&&(P=2),void 0!==_.morphAttributes.color&&(P=3),w){let e=Ra[w];E=e.vertexShader,M=e.fragmentShader}else{E=a.vertexShader,M=a.fragmentShader;let e=s.getVertexShaderStage(a),t=s.getFragmentShaderStage(a);s.update(a,e,t),y=e.id,C=t.id}let D=e.getRenderTarget(),L=e.state.buffers.depth.getReversed(),U=!0===m.isInstancedMesh,N=!0===m.isBatchedMesh,I=!!a.map,O=!!a.matcap,F=!!T,z=!!a.aoMap,B=!!a.lightMap,V=!!a.bumpMap&&!1===a.wireframe,H=!!a.normalMap,G=!!a.displacementMap,k=!!a.emissiveMap,W=!!a.metalnessMap,X=!!a.roughnessMap,j=a.anisotropy>0,$=a.clearcoat>0,q=a.dispersion>0,Y=a.iridescence>0,K=a.sheen>0,Z=a.transmission>0,J=j&&!!a.anisotropyMap,Q=$&&!!a.clearcoatMap,ee=$&&!!a.clearcoatNormalMap,te=$&&!!a.clearcoatRoughnessMap,ne=Y&&!!a.iridescenceMap,ie=Y&&!!a.iridescenceThicknessMap,ae=K&&!!a.sheenColorMap,re=K&&!!a.sheenRoughnessMap,oe=!!a.specularMap,se=!!a.specularColorMap,le=!!a.specularIntensityMap,ce=Z&&!!a.transmissionMap,de=Z&&!!a.thicknessMap,ue=!!a.gradientMap,fe=!!a.alphaMap,pe=a.alphaTest>0,he=!!a.alphaHash,me=!!a.extensions,ve=wt;a.toneMapped&&(null===D||!0===D.isXRRenderTarget)&&(ve=e.toneMapping);let ge={shaderID:w,shaderType:a.type,shaderName:a.name,vertexShader:E,fragmentShader:M,defines:a.defines,customVertexShaderID:y,customFragmentShaderID:C,isRawShaderMaterial:!0===a.isRawShaderMaterial,glslVersion:a.glslVersion,precision:f,batching:N,batchingColor:N&&null!==m._colorsTexture,instancing:U,instancingColor:U&&null!==m.instanceColor,instancingMorph:U&&null!==m.morphTexture,outputColorSpace:null===D?e.outputColorSpace:!0===D.isXRRenderTarget?D.texture.colorSpace:Ae.workingColorSpace,alphaToCoverage:!!a.alphaToCoverage,map:I,matcap:O,envMap:F,envMapMode:F&&T.mapping,envMapCubeUVHeight:b,aoMap:z,lightMap:B,bumpMap:V,normalMap:H,displacementMap:G,emissiveMap:k,normalMapObjectSpace:H&&a.normalMapType===Ee,normalMapTangentSpace:H&&a.normalMapType===Se,packedNormalMap:H&&a.normalMapType===Se&&yo(a.normalMap.format),metalnessMap:W,roughnessMap:X,anisotropy:j,anisotropyMap:J,clearcoat:$,clearcoatMap:Q,clearcoatNormalMap:ee,clearcoatRoughnessMap:te,dispersion:q,iridescence:Y,iridescenceMap:ne,iridescenceThicknessMap:ie,sheen:K,sheenColorMap:ae,sheenRoughnessMap:re,specularMap:oe,specularColorMap:se,specularIntensityMap:le,transmission:Z,transmissionMap:ce,thicknessMap:de,gradientMap:ue,opaque:!1===a.transparent&&a.blending===In&&!1===a.alphaToCoverage,alphaMap:fe,alphaTest:pe,alphaHash:he,combine:a.combine,mapUv:I&&h(a.map.channel),aoMapUv:z&&h(a.aoMap.channel),lightMapUv:B&&h(a.lightMap.channel),bumpMapUv:V&&h(a.bumpMap.channel),normalMapUv:H&&h(a.normalMap.channel),displacementMapUv:G&&h(a.displacementMap.channel),emissiveMapUv:k&&h(a.emissiveMap.channel),metalnessMapUv:W&&h(a.metalnessMap.channel),roughnessMapUv:X&&h(a.roughnessMap.channel),anisotropyMapUv:J&&h(a.anisotropyMap.channel),clearcoatMapUv:Q&&h(a.clearcoatMap.channel),clearcoatNormalMapUv:ee&&h(a.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:te&&h(a.clearcoatRoughnessMap.channel),iridescenceMapUv:ne&&h(a.iridescenceMap.channel),iridescenceThicknessMapUv:ie&&h(a.iridescenceThicknessMap.channel),sheenColorMapUv:ae&&h(a.sheenColorMap.channel),sheenRoughnessMapUv:re&&h(a.sheenRoughnessMap.channel),specularMapUv:oe&&h(a.specularMap.channel),specularColorMapUv:se&&h(a.specularColorMap.channel),specularIntensityMapUv:le&&h(a.specularIntensityMap.channel),transmissionMapUv:ce&&h(a.transmissionMap.channel),thicknessMapUv:de&&h(a.thicknessMap.channel),alphaMapUv:fe&&h(a.alphaMap.channel),vertexTangents:!!_.attributes.tangent&&(H||j),vertexNormals:!!_.attributes.normal,vertexColors:a.vertexColors,vertexAlphas:!0===a.vertexColors&&!!_.attributes.color&&4===_.attributes.color.itemSize,pointsUvs:!0===m.isPoints&&!!_.attributes.uv&&(I||fe),fog:!!g,useFog:!0===a.fog,fogExp2:!!g&&g.isFogExp2,flatShading:!1===a.wireframe&&(!0===a.flatShading||void 0===_.attributes.normal&&!1===H&&(a.isMeshLambertMaterial||a.isMeshPhongMaterial||a.isMeshStandardMaterial||a.isMeshPhysicalMaterial)),sizeAttenuation:!0===a.sizeAttenuation,logarithmicDepthBuffer:u,reversedDepthBuffer:L,skinning:!0===m.isSkinnedMesh,hasPositionAttribute:void 0!==_.attributes.position,morphTargets:void 0!==_.morphAttributes.position,morphNormals:void 0!==_.morphAttributes.normal,morphColors:void 0!==_.morphAttributes.color,morphTargetsCount:A,morphTextureStride:P,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numSpotLightMaps:o.spotLightMap.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numSpotLightShadowsWithMaps:o.numSpotLightShadowsWithMaps,numLightProbes:o.numLightProbes,numLightProbeGrids:v.length,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:a.dithering,shadowMapEnabled:e.shadowMap.enabled&&c.length>0,shadowMapType:e.shadowMap.type,toneMapping:ve,decodeVideoTexture:I&&!0===a.map.isVideoTexture&&Ae.getTransfer(a.map.colorSpace)===We,decodeVideoTextureEmissive:k&&!0===a.emissiveMap.isVideoTexture&&Ae.getTransfer(a.emissiveMap.colorSpace)===We,premultipliedAlpha:a.premultipliedAlpha,doubleSided:a.side===Cn,flipSided:a.side===bn,useDepthPacking:a.depthPacking>=0,depthPacking:a.depthPacking||0,index0AttributeName:a.index0AttributeName,extensionClipCullDistance:me&&!0===a.extensions.clipCullDistance&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(me&&!0===a.extensions.multiDraw||N)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:a.customProgramCacheKey()};return ge.vertexUv1s=l.has(1),ge.vertexUv2s=l.has(2),ge.vertexUv3s=l.has(3),l.clear(),ge},getProgramCacheKey:function(t){let n=[];if(t.shaderID?n.push(t.shaderID):(n.push(t.customVertexShaderID),n.push(t.customFragmentShaderID)),void 0!==t.defines)for(let e in t.defines)n.push(e),n.push(t.defines[e]);return!1===t.isRawShaderMaterial&&(function(e,t){e.push(t.precision),e.push(t.outputColorSpace),e.push(t.envMapMode),e.push(t.envMapCubeUVHeight),e.push(t.mapUv),e.push(t.alphaMapUv),e.push(t.lightMapUv),e.push(t.aoMapUv),e.push(t.bumpMapUv),e.push(t.normalMapUv),e.push(t.displacementMapUv),e.push(t.emissiveMapUv),e.push(t.metalnessMapUv),e.push(t.roughnessMapUv),e.push(t.anisotropyMapUv),e.push(t.clearcoatMapUv),e.push(t.clearcoatNormalMapUv),e.push(t.clearcoatRoughnessMapUv),e.push(t.iridescenceMapUv),e.push(t.iridescenceThicknessMapUv),e.push(t.sheenColorMapUv),e.push(t.sheenRoughnessMapUv),e.push(t.specularMapUv),e.push(t.specularColorMapUv),e.push(t.specularIntensityMapUv),e.push(t.transmissionMapUv),e.push(t.thicknessMapUv),e.push(t.combine),e.push(t.fogExp2),e.push(t.sizeAttenuation),e.push(t.morphTargetsCount),e.push(t.morphAttributeCount),e.push(t.numDirLights),e.push(t.numPointLights),e.push(t.numSpotLights),e.push(t.numSpotLightMaps),e.push(t.numHemiLights),e.push(t.numRectAreaLights),e.push(t.numDirLightShadows),e.push(t.numPointLightShadows),e.push(t.numSpotLightShadows),e.push(t.numSpotLightShadowsWithMaps),e.push(t.numLightProbes),e.push(t.shadowMapType),e.push(t.toneMapping),e.push(t.numClippingPlanes),e.push(t.numClipIntersection),e.push(t.depthPacking)}(n,t),function(e,t){o.disableAll(),t.instancing&&o.enable(0),t.instancingColor&&o.enable(1),t.instancingMorph&&o.enable(2),t.matcap&&o.enable(3),t.envMap&&o.enable(4),t.normalMapObjectSpace&&o.enable(5),t.normalMapTangentSpace&&o.enable(6),t.clearcoat&&o.enable(7),t.iridescence&&o.enable(8),t.alphaTest&&o.enable(9),t.vertexColors&&o.enable(10),t.vertexAlphas&&o.enable(11),t.vertexUv1s&&o.enable(12),t.vertexUv2s&&o.enable(13),t.vertexUv3s&&o.enable(14),t.vertexTangents&&o.enable(15),t.anisotropy&&o.enable(16),t.alphaHash&&o.enable(17),t.batching&&o.enable(18),t.dispersion&&o.enable(19),t.batchingColor&&o.enable(20),t.gradientMap&&o.enable(21),t.packedNormalMap&&o.enable(22),t.vertexNormals&&o.enable(23),e.push(o.mask),o.disableAll(),t.fog&&o.enable(0),t.useFog&&o.enable(1),t.flatShading&&o.enable(2),t.logarithmicDepthBuffer&&o.enable(3),t.reversedDepthBuffer&&o.enable(4),t.skinning&&o.enable(5),t.morphTargets&&o.enable(6),t.morphNormals&&o.enable(7),t.morphColors&&o.enable(8),t.premultipliedAlpha&&o.enable(9),t.shadowMapEnabled&&o.enable(10),t.doubleSided&&o.enable(11),t.flipSided&&o.enable(12),t.useDepthPacking&&o.enable(13),t.dithering&&o.enable(14),t.transmission&&o.enable(15),t.sheen&&o.enable(16),t.opaque&&o.enable(17),t.pointsUvs&&o.enable(18),t.decodeVideoTexture&&o.enable(19),t.decodeVideoTextureEmissive&&o.enable(20),t.alphaToCoverage&&o.enable(21),t.numLightProbeGrids>0&&o.enable(22),t.hasPositionAttribute&&o.enable(23),e.push(o.mask)}(n,t),n.push(e.outputColorSpace)),n.push(t.customProgramCacheKey),n.join()},getUniforms:function(e){let t,n=p[e.type];if(n){let e=Ra[n];t=Ht.clone(e.uniforms)}else t=e.uniforms;return t},acquireProgram:function(t,n){let i=d.get(n);return void 0!==i?++i.usedTimes:(i=new bo(e,n,t,a),c.push(i),d.set(n,i)),i},releaseProgram:function(e){if(0===--e.usedTimes){let t=c.indexOf(e);c[t]=c[c.length-1],c.pop(),d.delete(e.cacheKey),e.destroy()}},releaseShaderCache:function(e){s.remove(e)},programs:c,dispose:function(){s.dispose()}}}function Ro(){let e=new WeakMap;return{has:function(t){return e.has(t)},get:function(t){let n=e.get(t);return void 0===n&&(n={},e.set(t,n)),n},remove:function(t){e.delete(t)},update:function(t,n,i){e.get(t)[n]=i},dispose:function(){e=new WeakMap}}}function Ao(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.material.id!==t.material.id?e.material.id-t.material.id:e.materialVariant!==t.materialVariant?e.materialVariant-t.materialVariant:e.z!==t.z?e.z-t.z:e.id-t.id}function Po(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function Do(){let e=[],t=0,n=[],i=[],a=[];function r(e){let t=0;return e.isInstancedMesh&&(t+=2),e.isSkinnedMesh&&(t+=1),t}function o(n,i,a,o,s,l){let c=e[t];return void 0===c?(c={id:n.id,object:n,geometry:i,material:a,materialVariant:r(n),groupOrder:o,renderOrder:n.renderOrder,z:s,group:l},e[t]=c):(c.id=n.id,c.object=n,c.geometry=i,c.material=a,c.materialVariant=r(n),c.groupOrder=o,c.renderOrder=n.renderOrder,c.z=s,c.group=l),t++,c}return{opaque:n,transmissive:i,transparent:a,init:function(){t=0,n.length=0,i.length=0,a.length=0},push:function(e,t,r,s,l,c){let d=o(e,t,r,s,l,c);r.transmission>0?i.push(d):!0===r.transparent?a.push(d):n.push(d)},unshift:function(e,t,r,s,l,c){let d=o(e,t,r,s,l,c);r.transmission>0?i.unshift(d):!0===r.transparent?a.unshift(d):n.unshift(d)},finish:function(){for(let n=t,i=e.length;n<i;n++){let t=e[n];if(null===t.id)break;t.id=null,t.object=null,t.geometry=null,t.material=null,t.group=null}},sort:function(e,t,r){n.length>1&&n.sort(e||Ao),i.length>1&&i.sort(t||Po),a.length>1&&a.sort(t||Po),r&&(n.reverse(),i.reverse(),a.reverse())}}}function Lo(){let e=new WeakMap;return{get:function(t,n){let i,a=e.get(t);return void 0===a?(i=new Do,e.set(t,[i])):n>=a.length?(i=new Do,a.push(i)):i=a[n],i},dispose:function(){e=new WeakMap}}}function Uo(){let e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":n={direction:new Te,color:new ft};break;case"SpotLight":n={position:new Te,direction:new Te,color:new ft,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new Te,color:new ft,distance:0,decay:0};break;case"HemisphereLight":n={direction:new Te,skyColor:new ft,groundColor:new ft};break;case"RectAreaLight":n={color:new ft,position:new Te,halfWidth:new Te,halfHeight:new Te}}return e[t.id]=n,n}}}var No=0;function Io(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function Oo(e){let t=new Uo,n=function(){let e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new pe};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new pe,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.id]=n,n}}}(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let e=0;e<9;e++)i.probe.push(new Te);let a=new Te,r=new tt,o=new tt;return{setup:function(a){let r=0,o=0,s=0;for(let e=0;e<9;e++)i.probe[e].set(0,0,0);let l=0,c=0,d=0,u=0,f=0,p=0,h=0,m=0,v=0,g=0,_=0;a.sort(Io);for(let e=0,x=a.length;e<x;e++){let x=a[e],S=x.color,T=x.intensity,b=x.distance,w=null;if(x.shadow&&x.shadow.map&&(w=x.shadow.map.texture.format===et?x.shadow.map.texture:x.shadow.map.depthTexture||x.shadow.map.texture),x.isAmbientLight)r+=S.r*T,o+=S.g*T,s+=S.b*T;else if(x.isLightProbe){for(let e=0;e<9;e++)i.probe[e].addScaledVector(x.sh.coefficients[e],T);_++}else if(x.isDirectionalLight){let e=t.get(x);if(e.color.copy(x.color).multiplyScalar(x.intensity),x.castShadow){let e=x.shadow,t=n.get(x);t.shadowIntensity=e.intensity,t.shadowBias=e.bias,t.shadowNormalBias=e.normalBias,t.shadowRadius=e.radius,t.shadowMapSize=e.mapSize,i.directionalShadow[l]=t,i.directionalShadowMap[l]=w,i.directionalShadowMatrix[l]=x.shadow.matrix,p++}i.directional[l]=e,l++}else if(x.isSpotLight){let e=t.get(x);e.position.setFromMatrixPosition(x.matrixWorld),e.color.copy(S).multiplyScalar(T),e.distance=b,e.coneCos=Math.cos(x.angle),e.penumbraCos=Math.cos(x.angle*(1-x.penumbra)),e.decay=x.decay,i.spot[d]=e;let a=x.shadow;if(x.map&&(i.spotLightMap[v]=x.map,v++,a.updateMatrices(x),x.castShadow&&g++),i.spotLightMatrix[d]=a.matrix,x.castShadow){let e=n.get(x);e.shadowIntensity=a.intensity,e.shadowBias=a.bias,e.shadowNormalBias=a.normalBias,e.shadowRadius=a.radius,e.shadowMapSize=a.mapSize,i.spotShadow[d]=e,i.spotShadowMap[d]=w,m++}d++}else if(x.isRectAreaLight){let e=t.get(x);e.color.copy(S).multiplyScalar(T),e.halfWidth.set(.5*x.width,0,0),e.halfHeight.set(0,.5*x.height,0),i.rectArea[u]=e,u++}else if(x.isPointLight){let e=t.get(x);if(e.color.copy(x.color).multiplyScalar(x.intensity),e.distance=x.distance,e.decay=x.decay,x.castShadow){let e=x.shadow,t=n.get(x);t.shadowIntensity=e.intensity,t.shadowBias=e.bias,t.shadowNormalBias=e.normalBias,t.shadowRadius=e.radius,t.shadowMapSize=e.mapSize,t.shadowCameraNear=e.camera.near,t.shadowCameraFar=e.camera.far,i.pointShadow[c]=t,i.pointShadowMap[c]=w,i.pointShadowMatrix[c]=x.shadow.matrix,h++}i.point[c]=e,c++}else if(x.isHemisphereLight){let e=t.get(x);e.skyColor.copy(x.color).multiplyScalar(T),e.groundColor.copy(x.groundColor).multiplyScalar(T),i.hemi[f]=e,f++}}u>0&&(!0===e.has("OES_texture_float_linear")?(i.rectAreaLTC1=Ca.LTC_FLOAT_1,i.rectAreaLTC2=Ca.LTC_FLOAT_2):(i.rectAreaLTC1=Ca.LTC_HALF_1,i.rectAreaLTC2=Ca.LTC_HALF_2)),i.ambient[0]=r,i.ambient[1]=o,i.ambient[2]=s;let x=i.hash;(x.directionalLength!==l||x.pointLength!==c||x.spotLength!==d||x.rectAreaLength!==u||x.hemiLength!==f||x.numDirectionalShadows!==p||x.numPointShadows!==h||x.numSpotShadows!==m||x.numSpotMaps!==v||x.numLightProbes!==_)&&(i.directional.length=l,i.spot.length=d,i.rectArea.length=u,i.point.length=c,i.hemi.length=f,i.directionalShadow.length=p,i.directionalShadowMap.length=p,i.pointShadow.length=h,i.pointShadowMap.length=h,i.spotShadow.length=m,i.spotShadowMap.length=m,i.directionalShadowMatrix.length=p,i.pointShadowMatrix.length=h,i.spotLightMatrix.length=m+v-g,i.spotLightMap.length=v,i.numSpotLightShadowsWithMaps=g,i.numLightProbes=_,x.directionalLength=l,x.pointLength=c,x.spotLength=d,x.rectAreaLength=u,x.hemiLength=f,x.numDirectionalShadows=p,x.numPointShadows=h,x.numSpotShadows=m,x.numSpotMaps=v,x.numLightProbes=_,i.version=No++)},setupView:function(e,t){let n=0,s=0,l=0,c=0,d=0,u=t.matrixWorldInverse;for(let t=0,f=e.length;t<f;t++){let f=e[t];if(f.isDirectionalLight){let e=i.directional[n];e.direction.setFromMatrixPosition(f.matrixWorld),a.setFromMatrixPosition(f.target.matrixWorld),e.direction.sub(a),e.direction.transformDirection(u),n++}else if(f.isSpotLight){let e=i.spot[l];e.position.setFromMatrixPosition(f.matrixWorld),e.position.applyMatrix4(u),e.direction.setFromMatrixPosition(f.matrixWorld),a.setFromMatrixPosition(f.target.matrixWorld),e.direction.sub(a),e.direction.transformDirection(u),l++}else if(f.isRectAreaLight){let e=i.rectArea[c];e.position.setFromMatrixPosition(f.matrixWorld),e.position.applyMatrix4(u),o.identity(),r.copy(f.matrixWorld),r.premultiply(u),o.extractRotation(r),e.halfWidth.set(.5*f.width,0,0),e.halfHeight.set(0,.5*f.height,0),e.halfWidth.applyMatrix4(o),e.halfHeight.applyMatrix4(o),c++}else if(f.isPointLight){let e=i.point[s];e.position.setFromMatrixPosition(f.matrixWorld),e.position.applyMatrix4(u),s++}else if(f.isHemisphereLight){let e=i.hemi[d];e.direction.setFromMatrixPosition(f.matrixWorld),e.direction.transformDirection(u),d++}}},state:i}}function Fo(e){let t=new Oo(e),n=[],i=[],a=[],r={lightsArray:n,shadowsArray:i,lightProbeGridArray:a,camera:null,lights:t,transmissionRenderTarget:{},textureUnits:0};return{init:function(e){r.camera=e,n.length=0,i.length=0,a.length=0},state:r,setupLights:function(){t.setup(n)},setupLightsView:function(e){t.setupView(n,e)},pushLight:function(e){n.push(e)},pushShadow:function(e){i.push(e)},pushLightProbeGrid:function(e){a.push(e)}}}function zo(e){let t=new WeakMap;return{get:function(n,i=0){let a,r=t.get(n);return void 0===r?(a=new Fo(e),t.set(n,[a])):i>=r.length?(a=new Fo(e),r.push(a)):a=r[i],a},dispose:function(){t=new WeakMap}}}var Bo=[new Te(1,0,0),new Te(-1,0,0),new Te(0,1,0),new Te(0,-1,0),new Te(0,0,1),new Te(0,0,-1)],Vo=[new Te(0,-1,0),new Te(0,-1,0),new Te(0,0,1),new Te(0,0,-1),new Te(0,-1,0),new Te(0,-1,0)],Ho=new tt,Go=new Te,ko=new Te;function Wo(e,t,n){let i=new ni,a=new pe,r=new pe,o=new Fe,s=new yn,l=new Dn,c={},d=n.maxTextureSize,u={[_n]:bn,[bn]:_n,[Cn]:Cn},f=new Xt({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new pe},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg;\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r;\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );\n\tgl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );\n}"}),p=f.clone();p.defines.HORIZONTAL_PASS=1;let h=new Kt;h.setAttribute("position",new Rt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let m=new Pn(h,f),v=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=on;let g=this.type;function _(n,i){let r=t.update(m);f.defines.VSM_SAMPLES!==n.blurSamples&&(f.defines.VSM_SAMPLES=n.blurSamples,p.defines.VSM_SAMPLES=n.blurSamples,f.needsUpdate=!0,p.needsUpdate=!0),null===n.mapPass&&(n.mapPass=new Xe(a.x,a.y,{format:et,type:re})),f.uniforms.shadow_pass.value=n.map.depthTexture,f.uniforms.resolution.value=n.mapSize,f.uniforms.radius.value=n.radius,e.setRenderTarget(n.mapPass),e.clear(),e.renderBufferDirect(i,null,r,f,m,null),p.uniforms.shadow_pass.value=n.mapPass.texture,p.uniforms.resolution.value=n.mapSize,p.uniforms.radius.value=n.radius,e.setRenderTarget(n.map),e.clear(),e.renderBufferDirect(i,null,r,p,m,null)}function x(t,n,i,a){let r=null,o=!0===i.isPointLight?t.customDistanceMaterial:t.customDepthMaterial;if(void 0!==o)r=o;else if(r=!0===i.isPointLight?l:s,e.localClippingEnabled&&!0===n.clipShadows&&Array.isArray(n.clippingPlanes)&&0!==n.clippingPlanes.length||n.displacementMap&&0!==n.displacementScale||n.alphaMap&&n.alphaTest>0||n.map&&n.alphaTest>0||!0===n.alphaToCoverage){let e=r.uuid,t=n.uuid,i=c[e];void 0===i&&(i={},c[e]=i);let a=i[t];void 0===a&&(a=r.clone(),i[t]=a,n.addEventListener("dispose",T)),r=a}return r.visible=n.visible,r.wireframe=n.wireframe,r.side=a===hn?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:u[n.side],r.alphaMap=n.alphaMap,r.alphaTest=!0===n.alphaToCoverage?.5:n.alphaTest,r.map=n.map,r.clipShadows=n.clipShadows,r.clippingPlanes=n.clippingPlanes,r.clipIntersection=n.clipIntersection,r.displacementMap=n.displacementMap,r.displacementScale=n.displacementScale,r.displacementBias=n.displacementBias,r.wireframeLinewidth=n.wireframeLinewidth,r.linewidth=n.linewidth,!0===i.isPointLight&&!0===r.isMeshDistanceMaterial&&(e.properties.get(r).light=i),r}function S(n,a,r,o,s){if(!1===n.visible)return;if(n.layers.test(a.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&s===hn)&&(!n.frustumCulled||i.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,n.matrixWorld);let i=t.update(n),l=n.material;if(Array.isArray(l)){let t=i.groups;for(let c=0,d=t.length;c<d;c++){let d=t[c],u=l[d.materialIndex];if(u&&u.visible){let t=x(n,u,o,s);n.onBeforeShadow(e,n,a,r,i,t,d),e.renderBufferDirect(r,null,i,t,n,d),n.onAfterShadow(e,n,a,r,i,t,d)}}}else if(l.visible){let t=x(n,l,o,s);n.onBeforeShadow(e,n,a,r,i,t,null),e.renderBufferDirect(r,null,i,t,n,null),n.onAfterShadow(e,n,a,r,i,t,null)}}let l=n.children;for(let e=0,t=l.length;e<t;e++)S(l[e],a,r,o,s)}function T(e){e.target.removeEventListener("dispose",T);for(let t in c){let n=c[t],i=e.target.uuid;i in n&&(n[i].dispose(),delete n[i])}}this.render=function(t,n,s){if(!1===v.enabled||!1===v.autoUpdate&&!1===v.needsUpdate||0===t.length)return;this.type===dn&&(gi("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=on);let l=e.getRenderTarget(),c=e.getActiveCubeFace(),u=e.getActiveMipmapLevel(),f=e.state;f.setBlending(Ln),!0===f.buffers.depth.getReversed()?f.buffers.color.setClear(0,0,0,0):f.buffers.color.setClear(1,1,1,1),f.buffers.depth.setTest(!0),f.setScissorTest(!1);let p=g!==this.type;p&&n.traverse(function(e){e.material&&(Array.isArray(e.material)?e.material.forEach(e=>e.needsUpdate=!0):e.material.needsUpdate=!0)});for(let l=0,c=t.length;l<c;l++){let c=t[l],u=c.shadow;if(void 0===u){gi("WebGLShadowMap:",c,"has no shadow.");continue}if(!1===u.autoUpdate&&!1===u.needsUpdate)continue;a.copy(u.mapSize);let h=u.getFrameExtents();a.multiply(h),r.copy(u.mapSize),(a.x>d||a.y>d)&&(a.x>d&&(r.x=Math.floor(d/h.x),a.x=r.x*h.x,u.mapSize.x=r.x),a.y>d&&(r.y=Math.floor(d/h.y),a.y=r.y*h.y,u.mapSize.y=r.y));let m=e.state.buffers.depth.getReversed();if(u.camera._reversedDepth=m,null===u.map||!0===p){if(null!==u.map&&(null!==u.map.depthTexture&&(u.map.depthTexture.dispose(),u.map.depthTexture=null),u.map.dispose()),this.type===hn){if(c.isPointLight){gi("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}u.map=new Xe(a.x,a.y,{format:et,type:re,minFilter:qn,magFilter:qn,generateMipmaps:!1}),u.map.texture.name=c.name+".shadowMap",u.map.depthTexture=new de(a.x,a.y,ee),u.map.depthTexture.name=c.name+".shadowMapDepth",u.map.depthTexture.format=Ve,u.map.depthTexture.compareFunction=null,u.map.depthTexture.minFilter=On,u.map.depthTexture.magFilter=On}else c.isPointLight?(u.map=new Fa(a.x),u.map.depthTexture=new he(a.x,Ci)):(u.map=new Xe(a.x,a.y),u.map.depthTexture=new de(a.x,a.y,Ci)),u.map.depthTexture.name=c.name+".shadowMap",u.map.depthTexture.format=Ve,this.type===on?(u.map.depthTexture.compareFunction=m?Tn:cn,u.map.depthTexture.minFilter=qn,u.map.depthTexture.magFilter=qn):(u.map.depthTexture.compareFunction=null,u.map.depthTexture.minFilter=On,u.map.depthTexture.magFilter=On);u.camera.updateProjectionMatrix()}let v=u.map.isWebGLCubeRenderTarget?6:1;for(let t=0;t<v;t++){if(u.map.isWebGLCubeRenderTarget)e.setRenderTarget(u.map,t),e.clear();else{0===t&&(e.setRenderTarget(u.map),e.clear());let n=u.getViewport(t);o.set(r.x*n.x,r.y*n.y,r.x*n.z,r.y*n.w),f.viewport(o)}if(c.isPointLight){let e=u.camera,n=u.matrix,i=c.distance||e.far;i!==e.far&&(e.far=i,e.updateProjectionMatrix()),Go.setFromMatrixPosition(c.matrixWorld),e.position.copy(Go),ko.copy(e.position),ko.add(Bo[t]),e.up.copy(Vo[t]),e.lookAt(ko),e.updateMatrixWorld(),n.makeTranslation(-Go.x,-Go.y,-Go.z),Ho.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),u._frustum.setFromProjectionMatrix(Ho,e.coordinateSystem,e.reversedDepth)}else u.updateMatrices(c);i=u.getFrustum(),S(n,s,u.camera,c,this.type)}!0!==u.isPointLightShadow&&this.type===hn&&_(u,s),u.needsUpdate=!1}g=this.type,v.needsUpdate=!1,e.setRenderTarget(l,c,u)}}function Xo(e,t){let n=new function(){let t=!1,n=new Fe,i=null,a=new Fe(0,0,0,0);return{setMask:function(n){i!==n&&!t&&(e.colorMask(n,n,n,n),i=n)},setLocked:function(e){t=e},setClear:function(t,i,r,o,s){!0===s&&(t*=o,i*=o,r*=o),n.set(t,i,r,o),!1===a.equals(n)&&(e.clearColor(t,i,r,o),a.copy(n))},reset:function(){t=!1,i=null,a.set(-1,0,0,0)}}},i=new function(){let n=!1,i=!1,a=null,r=null,o=null;return{setReversed:function(e){if(i!==e){let n=t.get("EXT_clip_control");e?n.clipControlEXT(n.LOWER_LEFT_EXT,n.ZERO_TO_ONE_EXT):n.clipControlEXT(n.LOWER_LEFT_EXT,n.NEGATIVE_ONE_TO_ONE_EXT),i=e;let a=o;o=null,this.setClear(a)}},getReversed:function(){return i},setTest:function(t){t?H(e.DEPTH_TEST):G(e.DEPTH_TEST)},setMask:function(t){a!==t&&!n&&(e.depthMask(t),a=t)},setFunc:function(t){if(i&&(t=te[t]),r!==t){switch(t){case Ke:e.depthFunc(e.NEVER);break;case Qe:e.depthFunc(e.ALWAYS);break;case nt:e.depthFunc(e.LESS);break;case at:e.depthFunc(e.LEQUAL);break;case ot:e.depthFunc(e.EQUAL);break;case lt:e.depthFunc(e.GEQUAL);break;case dt:e.depthFunc(e.GREATER);break;case pt:e.depthFunc(e.NOTEQUAL);break;default:e.depthFunc(e.LEQUAL)}r=t}},setLocked:function(e){n=e},setClear:function(t){o!==t&&(o=t,i&&(t=1-t),e.clearDepth(t))},reset:function(){n=!1,a=null,r=null,o=null,i=!1}}},a=new function(){let t=!1,n=null,i=null,a=null,r=null,o=null,s=null,l=null,c=null;return{setTest:function(n){t||(n?H(e.STENCIL_TEST):G(e.STENCIL_TEST))},setMask:function(i){n!==i&&!t&&(e.stencilMask(i),n=i)},setFunc:function(t,n,o){(i!==t||a!==n||r!==o)&&(e.stencilFunc(t,n,o),i=t,a=n,r=o)},setOp:function(t,n,i){(o!==t||s!==n||l!==i)&&(e.stencilOp(t,n,i),o=t,s=n,l=i)},setLocked:function(e){t=e},setClear:function(t){c!==t&&(e.clearStencil(t),c=t)},reset:function(){t=!1,n=null,i=null,a=null,r=null,o=null,s=null,l=null,c=null}}},r=new WeakMap,o=new WeakMap,s={},l={},c={},d=new WeakMap,u=[],f=null,p=!1,h=null,m=null,v=null,g=null,_=null,x=null,S=null,T=new ft(0,0,0),b=0,w=!1,E=null,M=null,y=null,C=null,R=null,A=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS),P=!1,D=0,L=e.getParameter(e.VERSION);-1!==L.indexOf("WebGL")?(D=parseFloat(/^WebGL (\d)/.exec(L)[1]),P=D>=1):-1!==L.indexOf("OpenGL ES")&&(D=parseFloat(/^OpenGL ES (\d)/.exec(L)[1]),P=D>=2);let U=null,N={},I=e.getParameter(e.SCISSOR_BOX),O=e.getParameter(e.VIEWPORT),F=(new Fe).fromArray(I),z=(new Fe).fromArray(O);function B(t,n,i,a){let r=new Uint8Array(4),o=e.createTexture();e.bindTexture(t,o),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let o=0;o<i;o++)t===e.TEXTURE_3D||t===e.TEXTURE_2D_ARRAY?e.texImage3D(n,0,e.RGBA,1,1,a,0,e.RGBA,e.UNSIGNED_BYTE,r):e.texImage2D(n+o,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,r);return o}let V={};function H(t){!0!==s[t]&&(e.enable(t),s[t]=!0)}function G(t){!1!==s[t]&&(e.disable(t),s[t]=!1)}V[e.TEXTURE_2D]=B(e.TEXTURE_2D,e.TEXTURE_2D,1),V[e.TEXTURE_CUBE_MAP]=B(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),V[e.TEXTURE_2D_ARRAY]=B(e.TEXTURE_2D_ARRAY,e.TEXTURE_2D_ARRAY,1,1),V[e.TEXTURE_3D]=B(e.TEXTURE_3D,e.TEXTURE_3D,1,1),n.setClear(0,0,0,1),i.setClear(1),a.setClear(0),H(e.DEPTH_TEST),i.setFunc(at),j(!1),$(jt),H(e.CULL_FACE),X(Ln);let k={[ii]:e.FUNC_ADD,[oi]:e.FUNC_SUBTRACT,[di]:e.FUNC_REVERSE_SUBTRACT};k[hi]=e.MIN,k[_i]=e.MAX;let W={[bi]:e.ZERO,[yi]:e.ONE,[Q]:e.SRC_COLOR,[se]:e.SRC_ALPHA,[Pe]:e.SRC_ALPHA_SATURATE,[be]:e.DST_COLOR,[me]:e.DST_ALPHA,[ae]:e.ONE_MINUS_SRC_COLOR,[ue]:e.ONE_MINUS_SRC_ALPHA,[ye]:e.ONE_MINUS_DST_COLOR,[_e]:e.ONE_MINUS_DST_ALPHA,[Ne]:e.CONSTANT_COLOR,[Be]:e.ONE_MINUS_CONSTANT_COLOR,[Ge]:e.CONSTANT_ALPHA,[$e]:e.ONE_MINUS_CONSTANT_ALPHA};function X(t,n,i,a,r,o,s,l,c,d){if(t!==Ln){if(!1===p&&(H(e.BLEND),p=!0),t===Kn)r=r||n,o=o||i,s=s||a,(n!==m||r!==_)&&(e.blendEquationSeparate(k[n],k[r]),m=n,_=r),(i!==v||a!==g||o!==x||s!==S)&&(e.blendFuncSeparate(W[i],W[a],W[o],W[s]),v=i,g=a,x=o,S=s),(!1===l.equals(T)||c!==b)&&(e.blendColor(l.r,l.g,l.b,c),T.copy(l),b=c),h=t,w=!1;else if(t!==h||d!==w){if((m!==ii||_!==ii)&&(e.blendEquation(e.FUNC_ADD),m=ii,_=ii),d)switch(t){case In:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case Vn:e.blendFunc(e.ONE,e.ONE);break;case Wn:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case $n:e.blendFuncSeparate(e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA,e.ZERO,e.ONE);break;default:Ti("WebGLState: Invalid blending: ",t)}else switch(t){case In:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case Vn:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE,e.ONE,e.ONE);break;case Wn:Ti("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case $n:Ti("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Ti("WebGLState: Invalid blending: ",t)}v=null,g=null,x=null,S=null,T.set(0,0,0),b=0,h=t,w=d}}else!0===p&&(G(e.BLEND),p=!1)}function j(t){E!==t&&(t?e.frontFace(e.CW):e.frontFace(e.CCW),E=t)}function $(t){t!==Gt?(H(e.CULL_FACE),t!==M&&(t===jt?e.cullFace(e.BACK):t===Jt?e.cullFace(e.FRONT):e.cullFace(e.FRONT_AND_BACK))):G(e.CULL_FACE),M=t}function q(t,n,a){t?(H(e.POLYGON_OFFSET_FILL),(C!==n||R!==a)&&(C=n,R=a,i.getReversed()&&(n=-n),e.polygonOffset(n,a))):G(e.POLYGON_OFFSET_FILL)}return{buffers:{color:n,depth:i,stencil:a},enable:H,disable:G,bindFramebuffer:function(t,n){return c[t]!==n&&(e.bindFramebuffer(t,n),c[t]=n,t===e.DRAW_FRAMEBUFFER&&(c[e.FRAMEBUFFER]=n),t===e.FRAMEBUFFER&&(c[e.DRAW_FRAMEBUFFER]=n),!0)},drawBuffers:function(t,n){let i=u,a=!1;if(t){i=d.get(n),void 0===i&&(i=[],d.set(n,i));let r=t.textures;if(i.length!==r.length||i[0]!==e.COLOR_ATTACHMENT0){for(let t=0,n=r.length;t<n;t++)i[t]=e.COLOR_ATTACHMENT0+t;i.length=r.length,a=!0}}else i[0]!==e.BACK&&(i[0]=e.BACK,a=!0);a&&e.drawBuffers(i)},useProgram:function(t){return f!==t&&(e.useProgram(t),f=t,!0)},setBlending:X,setMaterial:function(t,r){t.side===Cn?G(e.CULL_FACE):H(e.CULL_FACE);let o=t.side===bn;r&&(o=!o),j(o),t.blending===In&&!1===t.transparent?X(Ln):X(t.blending,t.blendEquation,t.blendSrc,t.blendDst,t.blendEquationAlpha,t.blendSrcAlpha,t.blendDstAlpha,t.blendColor,t.blendAlpha,t.premultipliedAlpha),i.setFunc(t.depthFunc),i.setTest(t.depthTest),i.setMask(t.depthWrite),n.setMask(t.colorWrite);let s=t.stencilWrite;a.setTest(s),s&&(a.setMask(t.stencilWriteMask),a.setFunc(t.stencilFunc,t.stencilRef,t.stencilFuncMask),a.setOp(t.stencilFail,t.stencilZFail,t.stencilZPass)),q(t.polygonOffset,t.polygonOffsetFactor,t.polygonOffsetUnits),!0===t.alphaToCoverage?H(e.SAMPLE_ALPHA_TO_COVERAGE):G(e.SAMPLE_ALPHA_TO_COVERAGE)},setFlipSided:j,setCullFace:$,setLineWidth:function(t){t!==y&&(P&&e.lineWidth(t),y=t)},setPolygonOffset:q,setScissorTest:function(t){t?H(e.SCISSOR_TEST):G(e.SCISSOR_TEST)},activeTexture:function(t){void 0===t&&(t=e.TEXTURE0+A-1),U!==t&&(e.activeTexture(t),U=t)},bindTexture:function(t,n,i){void 0===i&&(i=null===U?e.TEXTURE0+A-1:U);let a=N[i];void 0===a&&(a={type:void 0,texture:void 0},N[i]=a),(a.type!==t||a.texture!==n)&&(U!==i&&(e.activeTexture(i),U=i),e.bindTexture(t,n||V[t]),a.type=t,a.texture=n)},unbindTexture:function(){let t=N[U];void 0!==t&&void 0!==t.type&&(e.bindTexture(t.type,null),t.type=void 0,t.texture=void 0)},compressedTexImage2D:function(){try{e.compressedTexImage2D(...arguments)}catch(e){Ti("WebGLState:",e)}},compressedTexImage3D:function(){try{e.compressedTexImage3D(...arguments)}catch(e){Ti("WebGLState:",e)}},texImage2D:function(){try{e.texImage2D(...arguments)}catch(e){Ti("WebGLState:",e)}},texImage3D:function(){try{e.texImage3D(...arguments)}catch(e){Ti("WebGLState:",e)}},pixelStorei:function(t,n){l[t]!==n&&(e.pixelStorei(t,n),l[t]=n)},getParameter:function(t){return void 0!==l[t]?l[t]:e.getParameter(t)},updateUBOMapping:function(t,n){let i=o.get(n);void 0===i&&(i=new WeakMap,o.set(n,i));let a=i.get(t);void 0===a&&(a=e.getUniformBlockIndex(n,t.name),i.set(t,a))},uniformBlockBinding:function(t,n){let i=o.get(n).get(t);r.get(n)!==i&&(e.uniformBlockBinding(n,i,t.__bindingPointIndex),r.set(n,i))},texStorage2D:function(){try{e.texStorage2D(...arguments)}catch(e){Ti("WebGLState:",e)}},texStorage3D:function(){try{e.texStorage3D(...arguments)}catch(e){Ti("WebGLState:",e)}},texSubImage2D:function(){try{e.texSubImage2D(...arguments)}catch(e){Ti("WebGLState:",e)}},texSubImage3D:function(){try{e.texSubImage3D(...arguments)}catch(e){Ti("WebGLState:",e)}},compressedTexSubImage2D:function(){try{e.compressedTexSubImage2D(...arguments)}catch(e){Ti("WebGLState:",e)}},compressedTexSubImage3D:function(){try{e.compressedTexSubImage3D(...arguments)}catch(e){Ti("WebGLState:",e)}},scissor:function(t){!1===F.equals(t)&&(e.scissor(t.x,t.y,t.z,t.w),F.copy(t))},viewport:function(t){!1===z.equals(t)&&(e.viewport(t.x,t.y,t.z,t.w),z.copy(t))},reset:function(){e.disable(e.BLEND),e.disable(e.CULL_FACE),e.disable(e.DEPTH_TEST),e.disable(e.POLYGON_OFFSET_FILL),e.disable(e.SCISSOR_TEST),e.disable(e.STENCIL_TEST),e.disable(e.SAMPLE_ALPHA_TO_COVERAGE),e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ZERO),e.blendFuncSeparate(e.ONE,e.ZERO,e.ONE,e.ZERO),e.blendColor(0,0,0,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(e.LESS),i.setReversed(!1),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(e.ALWAYS,0,4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP),e.clearStencil(0),e.cullFace(e.BACK),e.frontFace(e.CCW),e.polygonOffset(0,0),e.activeTexture(e.TEXTURE0),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),e.bindFramebuffer(e.READ_FRAMEBUFFER,null),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),e.pixelStorei(e.PACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!1),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.BROWSER_DEFAULT_WEBGL),e.pixelStorei(e.PACK_ROW_LENGTH,0),e.pixelStorei(e.PACK_SKIP_PIXELS,0),e.pixelStorei(e.PACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_ROW_LENGTH,0),e.pixelStorei(e.UNPACK_IMAGE_HEIGHT,0),e.pixelStorei(e.UNPACK_SKIP_PIXELS,0),e.pixelStorei(e.UNPACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_SKIP_IMAGES,0),s={},l={},U=null,N={},c={},d=new WeakMap,u=[],f=null,p=!1,h=null,m=null,v=null,g=null,_=null,x=null,S=null,T=new ft(0,0,0),b=0,w=!1,E=null,M=null,y=null,C=null,R=null,F.set(0,0,e.canvas.width,e.canvas.height),z.set(0,0,e.canvas.width,e.canvas.height),n.reset(),i.reset(),a.reset()}}}function jo(e,t,n,i,a,r,o){let s,l=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,c=!(typeof navigator>"u")&&/OculusBrowser/g.test(navigator.userAgent),d=new pe,u=new WeakMap,f=new Set,p=new WeakMap,h=!1;try{h=typeof OffscreenCanvas<"u"&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch{}function m(e,t){return h?new OffscreenCanvas(e,t):ri("canvas")}function v(e,t,n){let i=1,a=W(e);if((a.width>n||a.height>n)&&(i=n/Math.max(a.width,a.height)),i<1){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap||typeof VideoFrame<"u"&&e instanceof VideoFrame){let n=Math.floor(i*a.width),r=Math.floor(i*a.height);void 0===s&&(s=m(n,r));let o=t?m(n,r):s;return o.width=n,o.height=r,o.getContext("2d").drawImage(e,0,0,n,r),gi("WebGLRenderer: Texture has been resized from ("+a.width+"x"+a.height+") to ("+n+"x"+r+")."),o}return"data"in e&&gi("WebGLRenderer: Image in DataTexture is too big ("+a.width+"x"+a.height+")."),e}return e}function g(e){return e.generateMipmaps}function _(t){e.generateMipmap(t)}function x(t){return t.isWebGLCubeRenderTarget?e.TEXTURE_CUBE_MAP:t.isWebGL3DRenderTarget?e.TEXTURE_3D:t.isWebGLArrayRenderTarget||t.isCompressedArrayTexture?e.TEXTURE_2D_ARRAY:e.TEXTURE_2D}function S(n,i,a,r,o,s=!1){if(null!==n){if(void 0!==e[n])return e[n];gi("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+n+"'")}let l;r&&(l=t.get("EXT_texture_norm16"),l||gi("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let c=i;if(i===e.RED&&(a===e.FLOAT&&(c=e.R32F),a===e.HALF_FLOAT&&(c=e.R16F),a===e.UNSIGNED_BYTE&&(c=e.R8),a===e.UNSIGNED_SHORT&&l&&(c=l.R16_EXT),a===e.SHORT&&l&&(c=l.R16_SNORM_EXT)),i===e.RED_INTEGER&&(a===e.UNSIGNED_BYTE&&(c=e.R8UI),a===e.UNSIGNED_SHORT&&(c=e.R16UI),a===e.UNSIGNED_INT&&(c=e.R32UI),a===e.BYTE&&(c=e.R8I),a===e.SHORT&&(c=e.R16I),a===e.INT&&(c=e.R32I)),i===e.RG&&(a===e.FLOAT&&(c=e.RG32F),a===e.HALF_FLOAT&&(c=e.RG16F),a===e.UNSIGNED_BYTE&&(c=e.RG8),a===e.UNSIGNED_SHORT&&l&&(c=l.RG16_EXT),a===e.SHORT&&l&&(c=l.RG16_SNORM_EXT)),i===e.RG_INTEGER&&(a===e.UNSIGNED_BYTE&&(c=e.RG8UI),a===e.UNSIGNED_SHORT&&(c=e.RG16UI),a===e.UNSIGNED_INT&&(c=e.RG32UI),a===e.BYTE&&(c=e.RG8I),a===e.SHORT&&(c=e.RG16I),a===e.INT&&(c=e.RG32I)),i===e.RGB_INTEGER&&(a===e.UNSIGNED_BYTE&&(c=e.RGB8UI),a===e.UNSIGNED_SHORT&&(c=e.RGB16UI),a===e.UNSIGNED_INT&&(c=e.RGB32UI),a===e.BYTE&&(c=e.RGB8I),a===e.SHORT&&(c=e.RGB16I),a===e.INT&&(c=e.RGB32I)),i===e.RGBA_INTEGER&&(a===e.UNSIGNED_BYTE&&(c=e.RGBA8UI),a===e.UNSIGNED_SHORT&&(c=e.RGBA16UI),a===e.UNSIGNED_INT&&(c=e.RGBA32UI),a===e.BYTE&&(c=e.RGBA8I),a===e.SHORT&&(c=e.RGBA16I),a===e.INT&&(c=e.RGBA32I)),i===e.RGB&&(a===e.UNSIGNED_SHORT&&l&&(c=l.RGB16_EXT),a===e.SHORT&&l&&(c=l.RGB16_SNORM_EXT),a===e.UNSIGNED_INT_5_9_9_9_REV&&(c=e.RGB9_E5),a===e.UNSIGNED_INT_10F_11F_11F_REV&&(c=e.R11F_G11F_B10F)),i===e.RGBA){let t=s?He:Ae.getTransfer(o);a===e.FLOAT&&(c=e.RGBA32F),a===e.HALF_FLOAT&&(c=e.RGBA16F),a===e.UNSIGNED_BYTE&&(c=t===We?e.SRGB8_ALPHA8:e.RGBA8),a===e.UNSIGNED_SHORT&&l&&(c=l.RGBA16_EXT),a===e.SHORT&&l&&(c=l.RGBA16_SNORM_EXT),a===e.UNSIGNED_SHORT_4_4_4_4&&(c=e.RGBA4),a===e.UNSIGNED_SHORT_5_5_5_1&&(c=e.RGB5_A1)}return(c===e.R16F||c===e.R32F||c===e.RG16F||c===e.RG32F||c===e.RGBA16F||c===e.RGBA32F)&&t.get("EXT_color_buffer_float"),c}function T(t,n){let i;return t?null===n||n===Ci||n===ve?i=e.DEPTH24_STENCIL8:n===ee?i=e.DEPTH32F_STENCIL8:n===xi&&(i=e.DEPTH24_STENCIL8,gi("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):null===n||n===Ci||n===ve?i=e.DEPTH_COMPONENT24:n===ee?i=e.DEPTH_COMPONENT32F:n===xi&&(i=e.DEPTH_COMPONENT16),i}function b(e,t){return!0===g(e)||e.isFramebufferTexture&&e.minFilter!==On&&e.minFilter!==qn?Math.log2(Math.max(t.width,t.height))+1:void 0!==e.mipmaps&&e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?t.mipmaps.length:1}function w(e){let t=e.target;t.removeEventListener("dispose",w),function(e){let t=i.get(e);if(void 0===t.__webglInit)return;let n=e.source,a=p.get(n);if(a){let i=a[t.__cacheKey];i.usedTimes--,0===i.usedTimes&&M(e),0===Object.keys(a).length&&p.delete(n)}i.remove(e)}(t),t.isVideoTexture&&u.delete(t),t.isHTMLTexture&&f.delete(t)}function E(t){let n=t.target;n.removeEventListener("dispose",E),function(t){let n=i.get(t);if(t.depthTexture&&(t.depthTexture.dispose(),i.remove(t.depthTexture)),t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++){if(Array.isArray(n.__webglFramebuffer[t]))for(let i=0;i<n.__webglFramebuffer[t].length;i++)e.deleteFramebuffer(n.__webglFramebuffer[t][i]);else e.deleteFramebuffer(n.__webglFramebuffer[t]);n.__webglDepthbuffer&&e.deleteRenderbuffer(n.__webglDepthbuffer[t])}else{if(Array.isArray(n.__webglFramebuffer))for(let t=0;t<n.__webglFramebuffer.length;t++)e.deleteFramebuffer(n.__webglFramebuffer[t]);else e.deleteFramebuffer(n.__webglFramebuffer);if(n.__webglDepthbuffer&&e.deleteRenderbuffer(n.__webglDepthbuffer),n.__webglMultisampledFramebuffer&&e.deleteFramebuffer(n.__webglMultisampledFramebuffer),n.__webglColorRenderbuffer)for(let t=0;t<n.__webglColorRenderbuffer.length;t++)n.__webglColorRenderbuffer[t]&&e.deleteRenderbuffer(n.__webglColorRenderbuffer[t]);n.__webglDepthRenderbuffer&&e.deleteRenderbuffer(n.__webglDepthRenderbuffer)}let a=t.textures;for(let t=0,n=a.length;t<n;t++){let n=i.get(a[t]);n.__webglTexture&&(e.deleteTexture(n.__webglTexture),o.memory.textures--),i.remove(a[t])}i.remove(t)}(n)}function M(t){let n=i.get(t);e.deleteTexture(n.__webglTexture);let a=t.source;delete p.get(a)[n.__cacheKey],o.memory.textures--}let y=0;function C(t,a){let r=i.get(t);if(t.isVideoTexture&&function(e){let t=o.render.frame;u.get(e)!==t&&(u.set(e,t),e.update())}(t),!1===t.isRenderTargetTexture&&!0!==t.isExternalTexture&&t.version>0&&r.__version!==t.version){let e=t.image;if(null===e)gi("WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==e.complete)return void N(r,t,a);gi("WebGLRenderer: Texture marked for update but image is incomplete")}}else t.isExternalTexture&&(r.__webglTexture=t.sourceTexture?t.sourceTexture:null);n.bindTexture(e.TEXTURE_2D,r.__webglTexture,e.TEXTURE0+a)}let R={[wn]:e.REPEAT,[Rn]:e.CLAMP_TO_EDGE,[Un]:e.MIRRORED_REPEAT},A={[On]:e.NEAREST,[Hn]:e.NEAREST_MIPMAP_NEAREST,[Xn]:e.NEAREST_MIPMAP_LINEAR,[qn]:e.LINEAR,[Zn]:e.LINEAR_MIPMAP_NEAREST,[ei]:e.LINEAR_MIPMAP_LINEAR},P={[Yt]:e.NEVER,[Mn]:e.ALWAYS,[en]:e.LESS,[cn]:e.LEQUAL,[rn]:e.EQUAL,[Tn]:e.GEQUAL,[pn]:e.GREATER,[gn]:e.NOTEQUAL};function D(n,r){if(r.type===ee&&!1===t.has("OES_texture_float_linear")&&(r.magFilter===qn||r.magFilter===Zn||r.magFilter===Xn||r.magFilter===ei||r.minFilter===qn||r.minFilter===Zn||r.minFilter===Xn||r.minFilter===ei)&&gi("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),e.texParameteri(n,e.TEXTURE_WRAP_S,R[r.wrapS]),e.texParameteri(n,e.TEXTURE_WRAP_T,R[r.wrapT]),(n===e.TEXTURE_3D||n===e.TEXTURE_2D_ARRAY)&&e.texParameteri(n,e.TEXTURE_WRAP_R,R[r.wrapR]),e.texParameteri(n,e.TEXTURE_MAG_FILTER,A[r.magFilter]),e.texParameteri(n,e.TEXTURE_MIN_FILTER,A[r.minFilter]),r.compareFunction&&(e.texParameteri(n,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(n,e.TEXTURE_COMPARE_FUNC,P[r.compareFunction])),!0===t.has("EXT_texture_filter_anisotropic")){if(r.magFilter===On||r.minFilter!==Xn&&r.minFilter!==ei||r.type===ee&&!1===t.has("OES_texture_float_linear"))return;if(r.anisotropy>1||i.get(r).__currentAnisotropy){let o=t.get("EXT_texture_filter_anisotropic");e.texParameterf(n,o.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(r.anisotropy,a.getMaxAnisotropy())),i.get(r).__currentAnisotropy=r.anisotropy}}}function L(t,n){let i=!1;void 0===t.__webglInit&&(t.__webglInit=!0,n.addEventListener("dispose",w));let a=n.source,r=p.get(a);void 0===r&&(r={},p.set(a,r));let s=function(e){let t=[];return t.push(e.wrapS),t.push(e.wrapT),t.push(e.wrapR||0),t.push(e.magFilter),t.push(e.minFilter),t.push(e.anisotropy),t.push(e.internalFormat),t.push(e.format),t.push(e.type),t.push(e.generateMipmaps),t.push(e.premultiplyAlpha),t.push(e.flipY),t.push(e.unpackAlignment),t.push(e.colorSpace),t.join()}(n);if(s!==t.__cacheKey){void 0===r[s]&&(r[s]={texture:e.createTexture(),usedTimes:0},o.memory.textures++,i=!0),r[s].usedTimes++;let a=r[t.__cacheKey];void 0!==a&&(r[t.__cacheKey].usedTimes--,0===a.usedTimes&&M(n)),t.__cacheKey=s,t.__webglTexture=r[s].texture}return i}function U(e,t,n){return Math.floor(Math.floor(e/n)/t)}function N(t,o,s){let l=e.TEXTURE_2D;(o.isDataArrayTexture||o.isCompressedArrayTexture)&&(l=e.TEXTURE_2D_ARRAY),o.isData3DTexture&&(l=e.TEXTURE_3D);let c=L(t,o),d=o.source;n.bindTexture(l,t.__webglTexture,e.TEXTURE0+s);let u=i.get(d);if(d.version!==u.__version||!0===c){if(n.activeTexture(e.TEXTURE0+s),0==(typeof ImageBitmap<"u"&&o.image instanceof ImageBitmap)){let t=Ae.getPrimaries(Ae.workingColorSpace),i=o.colorSpace===Re?null:Ae.getPrimaries(o.colorSpace),a=o.colorSpace===Re||t===i?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,o.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,o.premultiplyAlpha),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,a)}n.pixelStorei(e.UNPACK_ALIGNMENT,o.unpackAlignment);let t=v(o.image,!1,a.maxTextureSize);t=k(o,t);let i=r.convert(o.format,o.colorSpace),p=r.convert(o.type),h=S(o.internalFormat,i,p,o.normalized,o.colorSpace,o.isVideoTexture);D(l,o);let m,x=o.mipmaps,w=!0!==o.isVideoTexture,E=void 0===u.__version||!0===c,M=d.dataReady,y=b(o,t);if(o.isDepthTexture)h=T(o.format===ke,o.type),E&&(w?n.texStorage2D(e.TEXTURE_2D,1,h,t.width,t.height):n.texImage2D(e.TEXTURE_2D,0,h,t.width,t.height,0,i,p,null));else if(o.isDataTexture)if(x.length>0){w&&E&&n.texStorage2D(e.TEXTURE_2D,y,h,x[0].width,x[0].height);for(let t=0,a=x.length;t<a;t++)m=x[t],w?M&&n.texSubImage2D(e.TEXTURE_2D,t,0,0,m.width,m.height,i,p,m.data):n.texImage2D(e.TEXTURE_2D,t,h,m.width,m.height,0,i,p,m.data);o.generateMipmaps=!1}else w?(E&&n.texStorage2D(e.TEXTURE_2D,y,h,t.width,t.height),M&&function(t,i,a,r){let o=t.updateRanges;if(0===o.length)n.texSubImage2D(e.TEXTURE_2D,0,0,0,i.width,i.height,a,r,i.data);else{o.sort((e,t)=>e.start-t.start);let s=0;for(let e=1;e<o.length;e++){let t=o[s],n=o[e],a=t.start+t.count,r=U(n.start,i.width,4),l=U(t.start,i.width,4);n.start<=a+1&&r===l&&U(n.start+n.count-1,i.width,4)===r?t.count=Math.max(t.count,n.start+n.count-t.start):(++s,o[s]=n)}o.length=s+1;let l=n.getParameter(e.UNPACK_ROW_LENGTH),c=n.getParameter(e.UNPACK_SKIP_PIXELS),d=n.getParameter(e.UNPACK_SKIP_ROWS);n.pixelStorei(e.UNPACK_ROW_LENGTH,i.width);for(let t=0,s=o.length;t<s;t++){let s=o[t],l=Math.floor(s.start/4),c=Math.ceil(s.count/4),d=l%i.width,u=Math.floor(l/i.width),f=c,p=1;n.pixelStorei(e.UNPACK_SKIP_PIXELS,d),n.pixelStorei(e.UNPACK_SKIP_ROWS,u),n.texSubImage2D(e.TEXTURE_2D,0,d,u,f,p,a,r,i.data)}t.clearUpdateRanges(),n.pixelStorei(e.UNPACK_ROW_LENGTH,l),n.pixelStorei(e.UNPACK_SKIP_PIXELS,c),n.pixelStorei(e.UNPACK_SKIP_ROWS,d)}}(o,t,i,p)):n.texImage2D(e.TEXTURE_2D,0,h,t.width,t.height,0,i,p,t.data);else if(o.isCompressedTexture)if(o.isCompressedArrayTexture){w&&E&&n.texStorage3D(e.TEXTURE_2D_ARRAY,y,h,x[0].width,x[0].height,t.depth);for(let a=0,r=x.length;a<r;a++)if(m=x[a],o.format!==Ie)if(null!==i)if(w){if(M)if(o.layerUpdates.size>0){let t=Mt(m.width,m.height,o.format,o.type);for(let r of o.layerUpdates){let o=m.data.subarray(r*t/m.data.BYTES_PER_ELEMENT,(r+1)*t/m.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,a,0,0,r,m.width,m.height,1,i,o)}o.clearLayerUpdates()}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,a,0,0,0,m.width,m.height,t.depth,i,m.data)}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,a,h,m.width,m.height,t.depth,0,m.data,0,0);else gi("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else w?M&&n.texSubImage3D(e.TEXTURE_2D_ARRAY,a,0,0,0,m.width,m.height,t.depth,i,p,m.data):n.texImage3D(e.TEXTURE_2D_ARRAY,a,h,m.width,m.height,t.depth,0,i,p,m.data)}else{w&&E&&n.texStorage2D(e.TEXTURE_2D,y,h,x[0].width,x[0].height);for(let t=0,a=x.length;t<a;t++)m=x[t],o.format!==Ie?null!==i?w?M&&n.compressedTexSubImage2D(e.TEXTURE_2D,t,0,0,m.width,m.height,i,m.data):n.compressedTexImage2D(e.TEXTURE_2D,t,h,m.width,m.height,0,m.data):gi("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):w?M&&n.texSubImage2D(e.TEXTURE_2D,t,0,0,m.width,m.height,i,p,m.data):n.texImage2D(e.TEXTURE_2D,t,h,m.width,m.height,0,i,p,m.data)}else if(o.isDataArrayTexture)if(w){if(E&&n.texStorage3D(e.TEXTURE_2D_ARRAY,y,h,t.width,t.height,t.depth),M)if(o.layerUpdates.size>0){let a=Mt(t.width,t.height,o.format,o.type);for(let r of o.layerUpdates){let o=t.data.subarray(r*a/t.data.BYTES_PER_ELEMENT,(r+1)*a/t.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,r,t.width,t.height,1,i,p,o)}o.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,t.width,t.height,t.depth,i,p,t.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,h,t.width,t.height,t.depth,0,i,p,t.data);else if(o.isData3DTexture)w?(E&&n.texStorage3D(e.TEXTURE_3D,y,h,t.width,t.height,t.depth),M&&n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,t.width,t.height,t.depth,i,p,t.data)):n.texImage3D(e.TEXTURE_3D,0,h,t.width,t.height,t.depth,0,i,p,t.data);else if(o.isFramebufferTexture){if(E)if(w)n.texStorage2D(e.TEXTURE_2D,y,h,t.width,t.height);else{let a=t.width,r=t.height;for(let t=0;t<y;t++)n.texImage2D(e.TEXTURE_2D,t,h,a,r,0,i,p,null),a>>=1,r>>=1}}else if(o.isHTMLTexture){if("texElementImage2D"in e){let n=e.canvas;if(n.hasAttribute("layoutsubtree")||n.setAttribute("layoutsubtree","true"),t.parentNode!==n)return n.appendChild(t),f.add(o),n.onpaint=e=>{let t=e.changedElements;for(let e of f)t.includes(e.image)&&(e.needsUpdate=!0)},void n.requestPaint();if(3===e.texElementImage2D.length)e.texElementImage2D(e.TEXTURE_2D,e.RGBA8,t);else{let n=e.RGBA,i=e.RGBA,a=e.UNSIGNED_BYTE;e.texElementImage2D(e.TEXTURE_2D,0,n,i,a,t)}e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)}}else if(x.length>0){if(w&&E){let t=W(x[0]);n.texStorage2D(e.TEXTURE_2D,y,h,t.width,t.height)}for(let t=0,a=x.length;t<a;t++)m=x[t],w?M&&n.texSubImage2D(e.TEXTURE_2D,t,0,0,i,p,m):n.texImage2D(e.TEXTURE_2D,t,h,i,p,m);o.generateMipmaps=!1}else if(w){if(E){let i=W(t);n.texStorage2D(e.TEXTURE_2D,y,h,i.width,i.height)}M&&n.texSubImage2D(e.TEXTURE_2D,0,0,0,i,p,t)}else n.texImage2D(e.TEXTURE_2D,0,h,i,p,t);g(o)&&_(l),u.__version=d.version,o.onUpdate&&o.onUpdate(o)}t.__version=o.version}function I(t,a,o,s,c,d){let u=r.convert(o.format,o.colorSpace),f=r.convert(o.type),p=S(o.internalFormat,u,f,o.normalized,o.colorSpace),h=i.get(a),m=i.get(o);if(m.__renderTarget=a,!h.__hasExternalTextures){let t=Math.max(1,a.width>>d),i=Math.max(1,a.height>>d);c===e.TEXTURE_3D||c===e.TEXTURE_2D_ARRAY?n.texImage3D(c,d,p,t,i,a.depth,0,u,f,null):n.texImage2D(c,d,p,t,i,0,u,f,null)}n.bindFramebuffer(e.FRAMEBUFFER,t),G(a)?l.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,s,c,m.__webglTexture,0,H(a)):(c===e.TEXTURE_2D||c>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&c<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&e.framebufferTexture2D(e.FRAMEBUFFER,s,c,m.__webglTexture,d),n.bindFramebuffer(e.FRAMEBUFFER,null)}function O(t,n,i){if(e.bindRenderbuffer(e.RENDERBUFFER,t),n.depthBuffer){let a=n.depthTexture,r=a&&a.isDepthTexture?a.type:null,o=T(n.stencilBuffer,r),s=n.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;G(n)?l.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,H(n),o,n.width,n.height):i?e.renderbufferStorageMultisample(e.RENDERBUFFER,H(n),o,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,o,n.width,n.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,s,e.RENDERBUFFER,t)}else{let t=n.textures;for(let a=0;a<t.length;a++){let o=t[a],s=r.convert(o.format,o.colorSpace),c=r.convert(o.type),d=S(o.internalFormat,s,c,o.normalized,o.colorSpace);G(n)?l.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,H(n),d,n.width,n.height):i?e.renderbufferStorageMultisample(e.RENDERBUFFER,H(n),d,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,d,n.width,n.height)}}e.bindRenderbuffer(e.RENDERBUFFER,null)}function F(t,a,o){let s=!0===a.isWebGLCubeRenderTarget;if(n.bindFramebuffer(e.FRAMEBUFFER,t),!a.depthTexture||!a.depthTexture.isDepthTexture)throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");let c=i.get(a.depthTexture);if(c.__renderTarget=a,(!c.__webglTexture||a.depthTexture.image.width!==a.width||a.depthTexture.image.height!==a.height)&&(a.depthTexture.image.width=a.width,a.depthTexture.image.height=a.height,a.depthTexture.needsUpdate=!0),s){if(void 0===c.__webglInit&&(c.__webglInit=!0,a.depthTexture.addEventListener("dispose",w)),void 0===c.__webglTexture){c.__webglTexture=e.createTexture(),n.bindTexture(e.TEXTURE_CUBE_MAP,c.__webglTexture),D(e.TEXTURE_CUBE_MAP,a.depthTexture);let t,i=r.convert(a.depthTexture.format),o=r.convert(a.depthTexture.type);a.depthTexture.format===Ve?t=e.DEPTH_COMPONENT24:a.depthTexture.format===ke&&(t=e.DEPTH24_STENCIL8);for(let n=0;n<6;n++)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+n,0,t,a.width,a.height,0,i,o,null)}}else C(a.depthTexture,0);let d=c.__webglTexture,u=H(a),f=s?e.TEXTURE_CUBE_MAP_POSITIVE_X+o:e.TEXTURE_2D,p=a.depthTexture.format===ke?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(a.depthTexture.format===Ve)G(a)?l.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,p,f,d,0,u):e.framebufferTexture2D(e.FRAMEBUFFER,p,f,d,0);else{if(a.depthTexture.format!==ke)throw new Error("THREE.WebGLTextures: Unknown depthTexture format.");G(a)?l.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,p,f,d,0,u):e.framebufferTexture2D(e.FRAMEBUFFER,p,f,d,0)}}function z(t){let a=i.get(t),r=!0===t.isWebGLCubeRenderTarget;if(a.__boundDepthTexture!==t.depthTexture){let e=t.depthTexture;if(a.__depthDisposeCallback&&a.__depthDisposeCallback(),e){let t=()=>{delete a.__boundDepthTexture,delete a.__depthDisposeCallback,e.removeEventListener("dispose",t)};e.addEventListener("dispose",t),a.__depthDisposeCallback=t}a.__boundDepthTexture=e}if(t.depthTexture&&!a.__autoAllocateDepthBuffer)if(r)for(let e=0;e<6;e++)F(a.__webglFramebuffer[e],t,e);else{let e=t.texture.mipmaps;e&&e.length>0?F(a.__webglFramebuffer[0],t,0):F(a.__webglFramebuffer,t,0)}else if(r){a.__webglDepthbuffer=[];for(let i=0;i<6;i++)if(n.bindFramebuffer(e.FRAMEBUFFER,a.__webglFramebuffer[i]),void 0===a.__webglDepthbuffer[i])a.__webglDepthbuffer[i]=e.createRenderbuffer(),O(a.__webglDepthbuffer[i],t,!1);else{let n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,r=a.__webglDepthbuffer[i];e.bindRenderbuffer(e.RENDERBUFFER,r),e.framebufferRenderbuffer(e.FRAMEBUFFER,n,e.RENDERBUFFER,r)}}else{let i=t.texture.mipmaps;if(i&&i.length>0?n.bindFramebuffer(e.FRAMEBUFFER,a.__webglFramebuffer[0]):n.bindFramebuffer(e.FRAMEBUFFER,a.__webglFramebuffer),void 0===a.__webglDepthbuffer)a.__webglDepthbuffer=e.createRenderbuffer(),O(a.__webglDepthbuffer,t,!1);else{let n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,i=a.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,i),e.framebufferRenderbuffer(e.FRAMEBUFFER,n,e.RENDERBUFFER,i)}}n.bindFramebuffer(e.FRAMEBUFFER,null)}let B=[],V=[];function H(e){return Math.min(a.maxSamples,e.samples)}function G(e){let n=i.get(e);return e.samples>0&&!0===t.has("WEBGL_multisampled_render_to_texture")&&!1!==n.__useRenderToTexture}function k(e,t){let n=e.colorSpace,i=e.format,a=e.type;return!0===e.isCompressedTexture||!0===e.isVideoTexture||n!==Oe&&n!==Re&&(Ae.getTransfer(n)===We?(i!==Ie||a!==si)&&gi("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Ti("WebGLTextures: Unsupported texture color space:",n)),t}function W(e){return typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement?(d.width=e.naturalWidth||e.width,d.height=e.naturalHeight||e.height):typeof VideoFrame<"u"&&e instanceof VideoFrame?(d.width=e.displayWidth,d.height=e.displayHeight):(d.width=e.width,d.height=e.height),d}this.allocateTextureUnit=function(){let e=y;return e>=a.maxTextures&&gi("WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+a.maxTextures),y+=1,e},this.resetTextureUnits=function(){y=0},this.getTextureUnits=function(){return y},this.setTextureUnits=function(e){y=e},this.setTexture2D=C,this.setTexture2DArray=function(t,a){let r=i.get(t);!1===t.isRenderTargetTexture&&t.version>0&&r.__version!==t.version?N(r,t,a):(t.isExternalTexture&&(r.__webglTexture=t.sourceTexture?t.sourceTexture:null),n.bindTexture(e.TEXTURE_2D_ARRAY,r.__webglTexture,e.TEXTURE0+a))},this.setTexture3D=function(t,a){let r=i.get(t);!1===t.isRenderTargetTexture&&t.version>0&&r.__version!==t.version?N(r,t,a):n.bindTexture(e.TEXTURE_3D,r.__webglTexture,e.TEXTURE0+a)},this.setTextureCube=function(t,o){let s=i.get(t);!0!==t.isCubeDepthTexture&&t.version>0&&s.__version!==t.version?function(t,o,s){if(6!==o.image.length)return;let l=L(t,o),c=o.source;n.bindTexture(e.TEXTURE_CUBE_MAP,t.__webglTexture,e.TEXTURE0+s);let d=i.get(c);if(c.version!==d.__version||!0===l){n.activeTexture(e.TEXTURE0+s);let t=Ae.getPrimaries(Ae.workingColorSpace),i=o.colorSpace===Re?null:Ae.getPrimaries(o.colorSpace),u=o.colorSpace===Re||t===i?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,o.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,o.premultiplyAlpha),n.pixelStorei(e.UNPACK_ALIGNMENT,o.unpackAlignment),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,u);let f=o.isCompressedTexture||o.image[0].isCompressedTexture,p=o.image[0]&&o.image[0].isDataTexture,h=[];for(let e=0;e<6;e++)h[e]=f||p?p?o.image[e].image:o.image[e]:v(o.image[e],!0,a.maxCubemapSize),h[e]=k(o,h[e]);let m,x=h[0],T=r.convert(o.format,o.colorSpace),w=r.convert(o.type),E=S(o.internalFormat,T,w,o.normalized,o.colorSpace),M=!0!==o.isVideoTexture,y=void 0===d.__version||!0===l,C=c.dataReady,R=b(o,x);if(D(e.TEXTURE_CUBE_MAP,o),f){M&&y&&n.texStorage2D(e.TEXTURE_CUBE_MAP,R,E,x.width,x.height);for(let t=0;t<6;t++){m=h[t].mipmaps;for(let i=0;i<m.length;i++){let a=m[i];o.format!==Ie?null!==T?M?C&&n.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i,0,0,a.width,a.height,T,a.data):n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i,E,a.width,a.height,0,a.data):gi("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):M?C&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i,0,0,a.width,a.height,T,w,a.data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i,E,a.width,a.height,0,T,w,a.data)}}}else{if(m=o.mipmaps,M&&y){m.length>0&&R++;let t=W(h[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,R,E,t.width,t.height)}for(let t=0;t<6;t++)if(p){M?C&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,h[t].width,h[t].height,T,w,h[t].data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,E,h[t].width,h[t].height,0,T,w,h[t].data);for(let i=0;i<m.length;i++){let a=m[i].image[t].image;M?C&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i+1,0,0,a.width,a.height,T,w,a.data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i+1,E,a.width,a.height,0,T,w,a.data)}}else{M?C&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,T,w,h[t]):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,E,T,w,h[t]);for(let i=0;i<m.length;i++){let a=m[i];M?C&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i+1,0,0,T,w,a.image[t]):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i+1,E,T,w,a.image[t])}}}g(o)&&_(e.TEXTURE_CUBE_MAP),d.__version=c.version,o.onUpdate&&o.onUpdate(o)}t.__version=o.version}(s,t,o):n.bindTexture(e.TEXTURE_CUBE_MAP,s.__webglTexture,e.TEXTURE0+o)},this.rebindTextures=function(t,n,a){let r=i.get(t);void 0!==n&&I(r.__webglFramebuffer,t,t.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0),void 0!==a&&z(t)},this.setupRenderTarget=function(t){let a=t.texture,s=i.get(t),l=i.get(a);t.addEventListener("dispose",E);let c=t.textures,d=!0===t.isWebGLCubeRenderTarget,u=c.length>1;if(u||(void 0===l.__webglTexture&&(l.__webglTexture=e.createTexture()),l.__version=a.version,o.memory.textures++),d){s.__webglFramebuffer=[];for(let t=0;t<6;t++)if(a.mipmaps&&a.mipmaps.length>0){s.__webglFramebuffer[t]=[];for(let n=0;n<a.mipmaps.length;n++)s.__webglFramebuffer[t][n]=e.createFramebuffer()}else s.__webglFramebuffer[t]=e.createFramebuffer()}else{if(a.mipmaps&&a.mipmaps.length>0){s.__webglFramebuffer=[];for(let t=0;t<a.mipmaps.length;t++)s.__webglFramebuffer[t]=e.createFramebuffer()}else s.__webglFramebuffer=e.createFramebuffer();if(u)for(let t=0,n=c.length;t<n;t++){let n=i.get(c[t]);void 0===n.__webglTexture&&(n.__webglTexture=e.createTexture(),o.memory.textures++)}if(t.samples>0&&!1===G(t)){s.__webglMultisampledFramebuffer=e.createFramebuffer(),s.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,s.__webglMultisampledFramebuffer);for(let n=0;n<c.length;n++){let i=c[n];s.__webglColorRenderbuffer[n]=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,s.__webglColorRenderbuffer[n]);let a=r.convert(i.format,i.colorSpace),o=r.convert(i.type),l=S(i.internalFormat,a,o,i.normalized,i.colorSpace,!0===t.isXRRenderTarget),d=H(t);e.renderbufferStorageMultisample(e.RENDERBUFFER,d,l,t.width,t.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+n,e.RENDERBUFFER,s.__webglColorRenderbuffer[n])}e.bindRenderbuffer(e.RENDERBUFFER,null),t.depthBuffer&&(s.__webglDepthRenderbuffer=e.createRenderbuffer(),O(s.__webglDepthRenderbuffer,t,!0)),n.bindFramebuffer(e.FRAMEBUFFER,null)}}if(d){n.bindTexture(e.TEXTURE_CUBE_MAP,l.__webglTexture),D(e.TEXTURE_CUBE_MAP,a);for(let n=0;n<6;n++)if(a.mipmaps&&a.mipmaps.length>0)for(let i=0;i<a.mipmaps.length;i++)I(s.__webglFramebuffer[n][i],t,a,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+n,i);else I(s.__webglFramebuffer[n],t,a,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+n,0);g(a)&&_(e.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(u){for(let a=0,r=c.length;a<r;a++){let r=c[a],o=i.get(r),l=e.TEXTURE_2D;(t.isWebGL3DRenderTarget||t.isWebGLArrayRenderTarget)&&(l=t.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY),n.bindTexture(l,o.__webglTexture),D(l,r),I(s.__webglFramebuffer,t,r,e.COLOR_ATTACHMENT0+a,l,0),g(r)&&_(l)}n.unbindTexture()}else{let i=e.TEXTURE_2D;if((t.isWebGL3DRenderTarget||t.isWebGLArrayRenderTarget)&&(i=t.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY),n.bindTexture(i,l.__webglTexture),D(i,a),a.mipmaps&&a.mipmaps.length>0)for(let n=0;n<a.mipmaps.length;n++)I(s.__webglFramebuffer[n],t,a,e.COLOR_ATTACHMENT0,i,n);else I(s.__webglFramebuffer,t,a,e.COLOR_ATTACHMENT0,i,0);g(a)&&_(i),n.unbindTexture()}t.depthBuffer&&z(t)},this.updateRenderTargetMipmap=function(e){let t=e.textures;for(let a=0,r=t.length;a<r;a++){let r=t[a];if(g(r)){let t=x(e),a=i.get(r).__webglTexture;n.bindTexture(t,a),_(t),n.unbindTexture()}}},this.updateMultisampleRenderTarget=function(t){if(t.samples>0)if(!1===G(t)){let a=t.textures,r=t.width,o=t.height,s=e.COLOR_BUFFER_BIT,l=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,d=i.get(t),u=a.length>1;if(u)for(let t=0;t<a.length;t++)n.bindFramebuffer(e.FRAMEBUFFER,d.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.RENDERBUFFER,null),n.bindFramebuffer(e.FRAMEBUFFER,d.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.TEXTURE_2D,null,0);n.bindFramebuffer(e.READ_FRAMEBUFFER,d.__webglMultisampledFramebuffer);let f=t.texture.mipmaps;f&&f.length>0?n.bindFramebuffer(e.DRAW_FRAMEBUFFER,d.__webglFramebuffer[0]):n.bindFramebuffer(e.DRAW_FRAMEBUFFER,d.__webglFramebuffer);for(let n=0;n<a.length;n++){if(t.resolveDepthBuffer&&(t.depthBuffer&&(s|=e.DEPTH_BUFFER_BIT),t.stencilBuffer&&t.resolveStencilBuffer&&(s|=e.STENCIL_BUFFER_BIT)),u){e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,d.__webglColorRenderbuffer[n]);let t=i.get(a[n]).__webglTexture;e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0)}e.blitFramebuffer(0,0,r,o,0,0,r,o,s,e.NEAREST),!0===c&&(B.length=0,V.length=0,B.push(e.COLOR_ATTACHMENT0+n),t.depthBuffer&&!1===t.resolveDepthBuffer&&(B.push(l),V.push(l),e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,V)),e.invalidateFramebuffer(e.READ_FRAMEBUFFER,B))}if(n.bindFramebuffer(e.READ_FRAMEBUFFER,null),n.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),u)for(let t=0;t<a.length;t++){n.bindFramebuffer(e.FRAMEBUFFER,d.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.RENDERBUFFER,d.__webglColorRenderbuffer[t]);let r=i.get(a[t]).__webglTexture;n.bindFramebuffer(e.FRAMEBUFFER,d.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.TEXTURE_2D,r,0)}n.bindFramebuffer(e.DRAW_FRAMEBUFFER,d.__webglMultisampledFramebuffer)}else if(t.depthBuffer&&!1===t.resolveDepthBuffer&&c){let n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,[n])}},this.setupDepthRenderbuffer=z,this.setupFrameBufferTexture=I,this.useMultisampledRTT=G,this.isReversedDepthBuffer=function(){return n.buffers.depth.getReversed()}}function $o(e,t){return{convert:function(n,i=Re){let a,r=Ae.getTransfer(i);if(n===si)return e.UNSIGNED_BYTE;if(n===le)return e.UNSIGNED_SHORT_4_4_4_4;if(n===fe)return e.UNSIGNED_SHORT_5_5_5_1;if(n===xe)return e.UNSIGNED_INT_5_9_9_9_REV;if(n===we)return e.UNSIGNED_INT_10F_11F_11F_REV;if(n===ui)return e.BYTE;if(n===mi)return e.SHORT;if(n===xi)return e.UNSIGNED_SHORT;if(n===wi)return e.INT;if(n===Ci)return e.UNSIGNED_INT;if(n===ee)return e.FLOAT;if(n===re)return e.HALF_FLOAT;if(n===Ce)return e.ALPHA;if(n===De)return e.RGB;if(n===Ie)return e.RGBA;if(n===Ve)return e.DEPTH_COMPONENT;if(n===ke)return e.DEPTH_STENCIL;if(n===qe)return e.RED;if(n===Ze)return e.RED_INTEGER;if(n===et)return e.RG;if(n===it)return e.RG_INTEGER;if(n===st)return e.RGBA_INTEGER;if(n===ct||n===ut||n===ht||n===vt)if(r===We){if(a=t.get("WEBGL_compressed_texture_s3tc_srgb"),null===a)return null;if(n===ct)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===ut)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===ht)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===vt)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(a=t.get("WEBGL_compressed_texture_s3tc"),null===a)return null;if(n===ct)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===ut)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===ht)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===vt)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(n===St||n===bt||n===Et||n===Ct){if(a=t.get("WEBGL_compressed_texture_pvrtc"),null===a)return null;if(n===St)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===bt)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Et)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Ct)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(n===Dt||n===K||n===Ot||n===Bt||n===Wt||n===qt||n===Qt){if(a=t.get("WEBGL_compressed_texture_etc"),null===a)return null;if(n===Dt||n===K)return r===We?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(n===Ot)return r===We?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC;if(n===Bt)return a.COMPRESSED_R11_EAC;if(n===Wt)return a.COMPRESSED_SIGNED_R11_EAC;if(n===qt)return a.COMPRESSED_RG11_EAC;if(n===Qt)return a.COMPRESSED_SIGNED_RG11_EAC}if(n===an||n===ln||n===fn||n===vn||n===Sn||n===En||n===An||n===Nn||n===Fn||n===Gn||n===jn||n===Yn||n===Jn||n===ti){if(a=t.get("WEBGL_compressed_texture_astc"),null===a)return null;if(n===an)return r===We?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===ln)return r===We?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===fn)return r===We?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===vn)return r===We?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Sn)return r===We?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===En)return r===We?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===An)return r===We?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Nn)return r===We?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Fn)return r===We?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Gn)return r===We?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===jn)return r===We?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Yn)return r===We?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Jn)return r===We?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===ti)return r===We?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}if(n===ai||n===li||n===fi){if(a=t.get("EXT_texture_compression_bptc"),null===a)return null;if(n===ai)return r===We?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===li)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===fi)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}if(n===vi||n===Si||n===Ei||n===Ri){if(a=t.get("EXT_texture_compression_rgtc"),null===a)return null;if(n===vi)return a.COMPRESSED_RED_RGTC1_EXT;if(n===Si)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Ei)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Ri)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}return n===ve?e.UNSIGNED_INT_24_8:void 0!==e[n]?e[n]:null}}}var qo=new tt,Yo=new Me;function Ko(e,t){function n(e,t){!0===e.matrixAutoUpdate&&e.updateMatrix(),t.value.copy(e.matrix)}function i(e,i){e.opacity.value=i.opacity,i.color&&e.diffuse.value.copy(i.color),i.emissive&&e.emissive.value.copy(i.emissive).multiplyScalar(i.emissiveIntensity),i.map&&(e.map.value=i.map,n(i.map,e.mapTransform)),i.alphaMap&&(e.alphaMap.value=i.alphaMap,n(i.alphaMap,e.alphaMapTransform)),i.bumpMap&&(e.bumpMap.value=i.bumpMap,n(i.bumpMap,e.bumpMapTransform),e.bumpScale.value=i.bumpScale,i.side===bn&&(e.bumpScale.value*=-1)),i.normalMap&&(e.normalMap.value=i.normalMap,n(i.normalMap,e.normalMapTransform),e.normalScale.value.copy(i.normalScale),i.side===bn&&e.normalScale.value.negate()),i.displacementMap&&(e.displacementMap.value=i.displacementMap,n(i.displacementMap,e.displacementMapTransform),e.displacementScale.value=i.displacementScale,e.displacementBias.value=i.displacementBias),i.emissiveMap&&(e.emissiveMap.value=i.emissiveMap,n(i.emissiveMap,e.emissiveMapTransform)),i.specularMap&&(e.specularMap.value=i.specularMap,n(i.specularMap,e.specularMapTransform)),i.alphaTest>0&&(e.alphaTest.value=i.alphaTest);let a=t.get(i),r=a.envMap,o=a.envMapRotation;r&&(e.envMap.value=r,e.envMapRotation.value.setFromMatrix4(qo.makeRotationFromEuler(o)).transpose(),r.isCubeTexture&&!1===r.isRenderTargetTexture&&e.envMapRotation.value.premultiply(Yo),e.reflectivity.value=i.reflectivity,e.ior.value=i.ior,e.refractionRatio.value=i.refractionRatio),i.lightMap&&(e.lightMap.value=i.lightMap,e.lightMapIntensity.value=i.lightMapIntensity,n(i.lightMap,e.lightMapTransform)),i.aoMap&&(e.aoMap.value=i.aoMap,e.aoMapIntensity.value=i.aoMapIntensity,n(i.aoMap,e.aoMapTransform))}return{refreshFogUniforms:function(t,n){n.color.getRGB(t.fogColor.value,Ft(e)),n.isFog?(t.fogNear.value=n.near,t.fogFar.value=n.far):n.isFogExp2&&(t.fogDensity.value=n.density)},refreshMaterialUniforms:function(e,a,r,o,s){a.isNodeMaterial?a.uniformsNeedUpdate=!1:a.isMeshBasicMaterial?i(e,a):a.isMeshLambertMaterial?(i(e,a),a.envMap&&(e.envMapIntensity.value=a.envMapIntensity)):a.isMeshToonMaterial?(i(e,a),function(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}(e,a)):a.isMeshPhongMaterial?(i(e,a),function(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}(e,a),a.envMap&&(e.envMapIntensity.value=a.envMapIntensity)):a.isMeshStandardMaterial?(i(e,a),function(e,t){e.metalness.value=t.metalness,t.metalnessMap&&(e.metalnessMap.value=t.metalnessMap,n(t.metalnessMap,e.metalnessMapTransform)),e.roughness.value=t.roughness,t.roughnessMap&&(e.roughnessMap.value=t.roughnessMap,n(t.roughnessMap,e.roughnessMapTransform)),t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)}(e,a),a.isMeshPhysicalMaterial&&function(e,t,i){e.ior.value=t.ior,t.sheen>0&&(e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen),e.sheenRoughness.value=t.sheenRoughness,t.sheenColorMap&&(e.sheenColorMap.value=t.sheenColorMap,n(t.sheenColorMap,e.sheenColorMapTransform)),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap,n(t.sheenRoughnessMap,e.sheenRoughnessMapTransform))),t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap,n(t.clearcoatMap,e.clearcoatMapTransform)),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap,n(t.clearcoatRoughnessMap,e.clearcoatRoughnessMapTransform)),t.clearcoatNormalMap&&(e.clearcoatNormalMap.value=t.clearcoatNormalMap,n(t.clearcoatNormalMap,e.clearcoatNormalMapTransform),e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),t.side===bn&&e.clearcoatNormalScale.value.negate())),t.dispersion>0&&(e.dispersion.value=t.dispersion),t.iridescence>0&&(e.iridescence.value=t.iridescence,e.iridescenceIOR.value=t.iridescenceIOR,e.iridescenceThicknessMinimum.value=t.iridescenceThicknessRange[0],e.iridescenceThicknessMaximum.value=t.iridescenceThicknessRange[1],t.iridescenceMap&&(e.iridescenceMap.value=t.iridescenceMap,n(t.iridescenceMap,e.iridescenceMapTransform)),t.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=t.iridescenceThicknessMap,n(t.iridescenceThicknessMap,e.iridescenceThicknessMapTransform))),t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=i.texture,e.transmissionSamplerSize.value.set(i.width,i.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap,n(t.transmissionMap,e.transmissionMapTransform)),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap,n(t.thicknessMap,e.thicknessMapTransform)),e.attenuationDistance.value=t.attenuationDistance,e.attenuationColor.value.copy(t.attenuationColor)),t.anisotropy>0&&(e.anisotropyVector.value.set(t.anisotropy*Math.cos(t.anisotropyRotation),t.anisotropy*Math.sin(t.anisotropyRotation)),t.anisotropyMap&&(e.anisotropyMap.value=t.anisotropyMap,n(t.anisotropyMap,e.anisotropyMapTransform))),e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap,n(t.specularColorMap,e.specularColorMapTransform)),t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap,n(t.specularIntensityMap,e.specularIntensityMapTransform))}(e,a,s)):a.isMeshMatcapMaterial?(i(e,a),function(e,t){t.matcap&&(e.matcap.value=t.matcap)}(e,a)):a.isMeshDepthMaterial?i(e,a):a.isMeshDistanceMaterial?(i(e,a),function(e,n){let i=t.get(n).light;e.referencePosition.value.setFromMatrixPosition(i.matrixWorld),e.nearDistance.value=i.shadow.camera.near,e.farDistance.value=i.shadow.camera.far}(e,a)):a.isMeshNormalMaterial?i(e,a):a.isLineBasicMaterial?(function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform))}(e,a),a.isLineDashedMaterial&&function(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}(e,a)):a.isPointsMaterial?function(e,t,i,a){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*i,e.scale.value=.5*a,t.map&&(e.map.value=t.map,n(t.map,e.uvTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,a,r,o):a.isSpriteMaterial?function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,a):a.isShadowMaterial?(e.color.value.copy(a.color),e.opacity.value=a.opacity):a.isShaderMaterial&&(a.uniformsNeedUpdate=!1)}}}Yo.set(-1,0,0,0,1,0,0,0,1);var Zo=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]),Jo=null,Qo=class{constructor(e={}){let t,{canvas:n=ci(),context:i=null,depth:a=!0,stencil:r=!1,alpha:o=!1,antialias:s=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:f=!1,outputBufferType:p=si}=e;if(this.isWebGLRenderer=!0,null!==i){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");t=i.getContextAttributes().alpha}else t=o;let h=p,m=new Set([st,it,Ze]),v=new Set([si,Ci,xi,ve,le,fe]),g=new Uint32Array(4),_=new Int32Array(4),x=new Te,S=null,T=null,b=[],w=[],E=null;this.domElement=n,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=wt,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let M=this,y=!1,C=null,R=null,A=null,P=null;this._outputColorSpace=Le;let D=0,L=0,U=null,N=-1,I=null,O=new Fe,F=new Fe,z=null,B=new ft(0),V=0,H=n.width,G=n.height,k=1,W=null,X=null,j=new Fe(0,0,H,G),$=new Fe(0,0,H,G),q=!1,Y=new ni,K=!1,Z=!1,J=new tt,Q=new Te,ee=new Fe,te={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},ne=!1;function ie(){return null===U?k:1}let ae,se,ce,de,ue,pe,he,me,ge,_e,xe,Se,be,we,Ee,Me,ye,Ce,Re,Pe,De,Ue,Ne,Ie=i;function Oe(e,t){return n.getContext(e,t)}try{let e={alpha:!0,depth:a,stencil:r,antialias:s,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:d,failIfMajorPerformanceCaveat:u};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${Nt}`),n.addEventListener("webglcontextlost",Ve,!1),n.addEventListener("webglcontextrestored",He,!1),n.addEventListener("webglcontextcreationerror",Ge,!1),null===Ie){let t="webgl2";if(Ie=Oe(t,e),null===Ie)throw Oe(t)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(e){throw Ti("WebGLRenderer: "+e.message),e}function ze(){ae=new Ba(Ie),ae.init(),De=new $o(Ie,ae),se=new Ia(Ie,ae,e,De),ce=new Xo(Ie,ae),se.reversedDepthBuffer&&f&&ce.buffers.depth.setReversed(!0),R=Ie.createFramebuffer(),A=Ie.createFramebuffer(),P=Ie.createFramebuffer(),de=new Ga(Ie),ue=new Ro,pe=new jo(Ie,ae,ce,ue,se,De,de),he=new za(M),me=new Ma(Ie),Ue=new Ua(Ie,me),ge=new Va(Ie,me,de,Ue),_e=new Wa(Ie,ge,me,Ue,de),Ce=new ka(Ie,se,pe),Ee=new Oa(ue),xe=new Co(M,he,ae,se,Ue,Ee),Se=new Ko(M,ue),be=new Lo,we=new zo(ae),ye=new La(M,he,ce,_e,t,l),Me=new Wo(M,_e,se),Ne={update(){throw new Error("UniformsGroups are not supported by the Spline runtime")},bind(){throw new Error("UniformsGroups are not supported by the Spline runtime")},dispose(){}},Re=new Na(Ie,ae,de),Pe=new Ha(Ie,ae,de),de.programs=xe.programs,M.capabilities=se,M.extensions=ae,M.properties=ue,M.renderLists=be,M.shadowMap=Me,M.state=ce,M.info=de}ze(),h!==si&&(E=new ja(h,n.width,n.height,s,a,r));let Be=Object.assign(new oe,{enabled:!1,isPresenting:!1,cameraAutoUpdate:!0,setFramebufferScaleFactor(){},setReferenceSpaceType(){},getReferenceSpace:()=>null,setReferenceSpace(){},getBaseLayer:()=>null,getBinding:()=>null,getFrame:()=>null,getSession:()=>null,async setSession(){throw new Error("WebXR is not supported by the Spline runtime")},getEnvironmentBlendMode(){},getDepthTexture:()=>null,updateCamera(){},getCamera:()=>null,getFoveation(){},setFoveation(){},hasDepthSensing:()=>!1,getDepthSensingMesh:()=>null,setAnimationLoop(){},getController:()=>null,getControllerGrip:()=>null,getHand:()=>null,dispose(){}});function Ve(e){e.preventDefault(),pi("WebGLRenderer: Context Lost."),y=!0}function He(){pi("WebGLRenderer: Context Restored."),y=!1;let e=de.autoReset,t=Me.enabled,n=Me.autoUpdate,i=Me.needsUpdate,a=Me.type;ze(),de.autoReset=e,Me.enabled=t,Me.autoUpdate=n,Me.needsUpdate=i,Me.type=a}function Ge(e){Ti("WebGLRenderer: A WebGL context could not be created. Reason: ",e.statusMessage)}function ke(e){let t=e.target;t.removeEventListener("dispose",ke),function(e){(function(e){let t=ue.get(e).programs;void 0!==t&&(t.forEach(function(e){xe.releaseProgram(e)}),e.isShaderMaterial&&xe.releaseShaderCache(e))})(e),ue.remove(e)}(t)}function We(e,t,n){!0===e.transparent&&e.side===Cn&&!1===e.forceSinglePass?(e.side=bn,e.needsUpdate=!0,rt(e,t,n),e.side=_n,e.needsUpdate=!0,rt(e,t,n),e.side=Cn):rt(e,t,n)}this.xr=Be,this.getContext=function(){return Ie},this.getContextAttributes=function(){return Ie.getContextAttributes()},this.forceContextLoss=function(){let e=ae.get("WEBGL_lose_context");e&&e.loseContext()},this.forceContextRestore=function(){let e=ae.get("WEBGL_lose_context");e&&e.restoreContext()},this.getPixelRatio=function(){return k},this.setPixelRatio=function(e){void 0!==e&&(k=e,this.setSize(H,G,!1))},this.getSize=function(e){return e.set(H,G)},this.setSize=function(e,t,i=!0){Be.isPresenting?gi("WebGLRenderer: Can't change size while VR device is presenting."):(H=e,G=t,n.width=Math.floor(e*k),n.height=Math.floor(t*k),!0===i&&(n.style.width=e+"px",n.style.height=t+"px"),null!==E&&E.setSize(n.width,n.height),this.setViewport(0,0,e,t))},this.getDrawingBufferSize=function(e){return e.set(H*k,G*k).floor()},this.setDrawingBufferSize=function(e,t,i){H=e,G=t,k=i,n.width=Math.floor(e*i),n.height=Math.floor(t*i),this.setViewport(0,0,e,t)},this.setEffects=function(e){if(h!==si){if(e)for(let t=0;t<e.length;t++)if(!0===e[t].isOutputPass){gi("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}E.setEffects(e||[])}else Ti("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.")},this.getCurrentViewport=function(e){return e.copy(O)},this.getViewport=function(e){return e.copy(j)},this.setViewport=function(e,t,n,i){e.isVector4?j.set(e.x,e.y,e.z,e.w):j.set(e,t,n,i),ce.viewport(O.copy(j).multiplyScalar(k).round())},this.getScissor=function(e){return e.copy($)},this.setScissor=function(e,t,n,i){e.isVector4?$.set(e.x,e.y,e.z,e.w):$.set(e,t,n,i),ce.scissor(F.copy($).multiplyScalar(k).round())},this.getScissorTest=function(){return q},this.setScissorTest=function(e){ce.setScissorTest(q=e)},this.setOpaqueSort=function(e){W=e},this.setTransparentSort=function(e){X=e},this.getClearColor=function(e){return e.copy(ye.getClearColor())},this.setClearColor=function(){ye.setClearColor(...arguments)},this.getClearAlpha=function(){return ye.getClearAlpha()},this.setClearAlpha=function(){ye.setClearAlpha(...arguments)},this.clear=function(e=!0,t=!0,n=!0){let i=0;if(e){let e=!1;if(null!==U){let t=U.texture.format;e=m.has(t)}if(e){let e=U.texture.type,t=v.has(e),n=ye.getClearColor(),i=ye.getClearAlpha(),a=n.r,r=n.g,o=n.b;t?(g[0]=a,g[1]=r,g[2]=o,g[3]=i,Ie.clearBufferuiv(Ie.COLOR,0,g)):(_[0]=a,_[1]=r,_[2]=o,_[3]=i,Ie.clearBufferiv(Ie.COLOR,0,_))}else i|=Ie.COLOR_BUFFER_BIT}t&&(i|=Ie.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),n&&(i|=Ie.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),0!==i&&Ie.clear(i)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(e){e.setRenderer(this),C=e},this.dispose=function(){n.removeEventListener("webglcontextlost",Ve,!1),n.removeEventListener("webglcontextrestored",He,!1),n.removeEventListener("webglcontextcreationerror",Ge,!1),ye.dispose(),be.dispose(),we.dispose(),ue.dispose(),he.dispose(),_e.dispose(),Ue.dispose(),Ne.dispose(),xe.dispose(),Be.dispose(),Be.removeEventListener("sessionstart",$e),Be.removeEventListener("sessionend",qe),Ye.stop()},this.renderBufferDirect=function(e,t,n,i,a,r){null===t&&(t=te);let o=a.isMesh&&a.matrixWorld.determinantAffine()<0,s=function(e,t,n,i,a){!0!==t.isScene&&(t=te),pe.resetTextureUnits();let r=t.fog,o=i.isMeshStandardMaterial||i.isMeshLambertMaterial||i.isMeshPhongMaterial?t.environment:null,s=null===U?M.outputColorSpace:!0===U.isXRRenderTarget?U.texture.colorSpace:Ae.workingColorSpace,l=i.isMeshStandardMaterial||i.isMeshLambertMaterial&&!i.envMap||i.isMeshPhongMaterial&&!i.envMap,c=he.get(i.envMap||o,l),d=!0===i.vertexColors&&!!n.attributes.color&&4===n.attributes.color.itemSize,u=!!n.attributes.tangent&&(!!i.normalMap||i.anisotropy>0),f=!!n.morphAttributes.position,p=!!n.morphAttributes.normal,h=!!n.morphAttributes.color,m=wt;i.toneMapped&&(null===U||!0===U.isXRRenderTarget)&&(m=M.toneMapping);let v=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,g=void 0!==v?v.length:0,_=ue.get(i),S=T.state.lights;if(!0===K&&(!0===Z||e!==I)){let t=e===I&&i.id===N;Ee.setState(i,e,t)}let b=!1;i.version===_.__version?(_.needsLights&&_.lightsStateVersion!==S.state.version||_.outputColorSpace!==s||a.isBatchedMesh&&!1===_.batching||!a.isBatchedMesh&&!0===_.batching||a.isBatchedMesh&&!0===_.batchingColor&&null===a.colorTexture||a.isBatchedMesh&&!1===_.batchingColor&&null!==a.colorTexture||a.isInstancedMesh&&!1===_.instancing||!a.isInstancedMesh&&!0===_.instancing||a.isSkinnedMesh&&!1===_.skinning||!a.isSkinnedMesh&&!0===_.skinning||a.isInstancedMesh&&!0===_.instancingColor&&null===a.instanceColor||a.isInstancedMesh&&!1===_.instancingColor&&null!==a.instanceColor||a.isInstancedMesh&&!0===_.instancingMorph&&null===a.morphTexture||a.isInstancedMesh&&!1===_.instancingMorph&&null!==a.morphTexture||_.envMap!==c||!0===i.fog&&_.fog!==r||void 0!==_.numClippingPlanes&&(_.numClippingPlanes!==Ee.numPlanes||_.numIntersection!==Ee.numIntersection)||_.vertexAlphas!==d||_.vertexTangents!==u||_.morphTargets!==f||_.morphNormals!==p||_.morphColors!==h||_.toneMapping!==m||_.morphTargetsCount!==g||!!_.lightProbeGrid!=T.state.lightProbeGridArray.length>0)&&(b=!0):(b=!0,_.__version=i.version);let w=_.currentProgram;!0===b&&(w=rt(i,t,a),C&&i.isNodeMaterial&&C.onUpdateProgram(i,w,_));let E=!1,y=!1,R=!1,A=w.getUniforms(),P=_.uniforms;if(ce.useProgram(w.program)&&(E=!0,y=!0,R=!0),i.id!==N&&(N=i.id,y=!0),_.needsLights){let e=function(e,t){if(0===e.length)return null;if(1===e.length)return null!==e[0].texture?e[0]:null;x.setFromMatrixPosition(t.matrixWorld);for(let t=0,n=e.length;t<n;t++){let n=e[t];if(null!==n.texture&&n.boundingBox.containsPoint(x))return n}return null}(T.state.lightProbeGridArray,a);_.lightProbeGrid!==e&&(_.lightProbeGrid=e,y=!0)}if(E||I!==e){ce.buffers.depth.getReversed()&&!0!==e.reversedDepth&&(e._reversedDepth=!0,e.updateProjectionMatrix()),A.setValue(Ie,"projectionMatrix",e.projectionMatrix),A.setValue(Ie,"viewMatrix",e.matrixWorldInverse);let t=A.map.cameraPosition;void 0!==t&&t.setValue(Ie,Q.setFromMatrixPosition(e.matrixWorld)),se.logarithmicDepthBuffer&&A.setValue(Ie,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial)&&A.setValue(Ie,"isOrthographic",!0===e.isOrthographicCamera),I!==e&&(I=e,y=!0,R=!0)}if(_.needsLights&&(S.state.directionalShadowMap.length>0&&A.setValue(Ie,"directionalShadowMap",S.state.directionalShadowMap,pe),S.state.spotShadowMap.length>0&&A.setValue(Ie,"spotShadowMap",S.state.spotShadowMap,pe),S.state.pointShadowMap.length>0&&A.setValue(Ie,"pointShadowMap",S.state.pointShadowMap,pe)),a.isSkinnedMesh){A.setOptional(Ie,a,"bindMatrix"),A.setOptional(Ie,a,"bindMatrixInverse");let e=a.skeleton;e&&(null===e.boneTexture&&e.computeBoneTexture(),A.setValue(Ie,"boneTexture",e.boneTexture,pe))}a.isBatchedMesh&&(A.setOptional(Ie,a,"batchingTexture"),A.setValue(Ie,"batchingTexture",a._matricesTexture,pe),A.setOptional(Ie,a,"batchingIdTexture"),A.setValue(Ie,"batchingIdTexture",a._indirectTexture,pe),A.setOptional(Ie,a,"batchingColorTexture"),null!==a._colorsTexture&&A.setValue(Ie,"batchingColorTexture",a._colorsTexture,pe));let D=n.morphAttributes;if((void 0!==D.position||void 0!==D.normal||void 0!==D.color)&&Ce.update(a,n,w),(y||_.receiveShadow!==a.receiveShadow)&&(_.receiveShadow=a.receiveShadow,A.setValue(Ie,"receiveShadow",a.receiveShadow)),(i.isMeshStandardMaterial||i.isMeshLambertMaterial||i.isMeshPhongMaterial)&&null===i.envMap&&null!==t.environment&&(P.envMapIntensity.value=t.environmentIntensity),void 0!==P.dfgLUT&&(P.dfgLUT.value=(null===Jo&&((Jo=new Bn(Zo,16,16,et,re)).name="DFG_LUT",Jo.minFilter=qn,Jo.magFilter=qn,Jo.wrapS=Rn,Jo.wrapT=Rn,Jo.generateMipmaps=!1,Jo.needsUpdate=!0),Jo)),y){if(A.setValue(Ie,"toneMappingExposure",M.toneMappingExposure),_.needsLights&&function(e,t){e.ambientLightColor.needsUpdate=t,e.lightProbe.needsUpdate=t,e.directionalLights.needsUpdate=t,e.directionalLightShadows.needsUpdate=t,e.pointLights.needsUpdate=t,e.pointLightShadows.needsUpdate=t,e.spotLights.needsUpdate=t,e.spotLightShadows.needsUpdate=t,e.rectAreaLights.needsUpdate=t,e.hemisphereLights.needsUpdate=t}(P,R),r&&!0===i.fog&&Se.refreshFogUniforms(P,r),Se.refreshMaterialUniforms(P,i,k,G,T.state.transmissionRenderTarget[e.id]),_.needsLights&&_.lightProbeGrid){let e=_.lightProbeGrid;P.probesSH.value=e.texture,P.probesMin.value.copy(e.boundingBox.min),P.probesMax.value.copy(e.boundingBox.max),P.probesResolution.value.copy(e.resolution)}Zr.upload(Ie,ot(_),P,pe)}if(i.isShaderMaterial&&!0===i.uniformsNeedUpdate&&(Zr.upload(Ie,ot(_),P,pe),i.uniformsNeedUpdate=!1),i.isSpriteMaterial&&A.setValue(Ie,"center",a.center),A.setValue(Ie,"modelViewMatrix",a.modelViewMatrix),A.setValue(Ie,"normalMatrix",a.normalMatrix),A.setValue(Ie,"modelMatrix",a.matrixWorld),a.previousModelViewMatrix&&A.setValue(Ie,"previousModelViewMatrix",a.previousModelViewMatrix),e.previousProjectionMatrix&&A.setValue(Ie,"previousProjectionMatrix",e.previousProjectionMatrix),void 0!==i.uniformsGroups){let e=i.uniformsGroups;for(let t=0,n=e.length;t<n;t++){let n=e[t];Ne.update(n,w),Ne.bind(n,w)}}return w}(e,t,n,i,a);ce.setMaterial(i,o);let l=n.index,c=1;if(!0===i.wireframe){if(l=ge.getWireframeAttribute(n),void 0===l)return;c=2}let d=n.drawRange,u=n.attributes.position,f=d.start*c,p=(d.start+d.count)*c;null!==r&&(f=Math.max(f,r.start*c),p=Math.min(p,(r.start+r.count)*c)),null!==l?(f=Math.max(f,0),p=Math.min(p,l.count)):null!=u&&(f=Math.max(f,0),p=Math.min(p,u.count));let h=p-f;if(h<0||h===1/0)return;Ue.setup(a,i,s,n,l);let m,v=Re;if(null!==l&&(m=me.get(l),v=Pe,v.setIndex(m)),a.isMesh)!0===i.wireframe?(ce.setLineWidth(i.wireframeLinewidth*ie()),v.setMode(Ie.LINES)):v.setMode(Ie.TRIANGLES);else if(a.isLine){let e=i.linewidth;void 0===e&&(e=1),ce.setLineWidth(e*ie()),a.isLineSegments?v.setMode(Ie.LINES):a.isLineLoop?v.setMode(Ie.LINE_LOOP):v.setMode(Ie.LINE_STRIP)}else a.isPoints?v.setMode(Ie.POINTS):a.isSprite&&v.setMode(Ie.TRIANGLES);if(a.isBatchedMesh)if(ae.get("WEBGL_multi_draw"))v.renderMultiDraw(a._multiDrawStarts,a._multiDrawCounts,a._multiDrawCount);else{let e=a._multiDrawStarts,t=a._multiDrawCounts,n=a._multiDrawCount,r=l?me.get(l).bytesPerElement:1,o=ue.get(i).currentProgram.getUniforms();for(let i=0;i<n;i++)o.setValue(Ie,"_gl_DrawID",i),v.render(e[i]/r,t[i])}else if(a.isInstancedMesh)v.renderInstances(f,h,a.count);else if(n.isInstancedBufferGeometry){let e=void 0!==n._maxInstanceCount?n._maxInstanceCount:1/0,t=Math.min(n.instanceCount,e);v.renderInstances(f,h,t)}else v.render(f,h)},this.compile=function(e,t,n=null){null===n&&(n=e),T=we.get(n),T.init(t),w.push(T),n.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&(T.pushLight(e),e.castShadow&&T.pushShadow(e))}),e!==n&&e.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&(T.pushLight(e),e.castShadow&&T.pushShadow(e))}),T.setupLights();let i=new Set;return e.traverse(function(e){if(!(e.isMesh||e.isPoints||e.isLine||e.isSprite))return;let t=e.material;if(t)if(Array.isArray(t))for(let a=0;a<t.length;a++){let r=t[a];We(r,n,e),i.add(r)}else We(t,n,e),i.add(t)}),T=w.pop(),i},this.compileAsync=function(e,t,n=null){let i=this.compile(e,t,n);return new Promise(t=>{function n(){i.forEach(function(e){ue.get(e).currentProgram.isReady()&&i.delete(e)}),0!==i.size?setTimeout(n,10):t(e)}null!==ae.get("KHR_parallel_shader_compile")?n():setTimeout(n,10)})};let je=null;function $e(){Ye.stop()}function qe(){Ye.start()}let Ye=new Ea;function Ke(e,t,n,i){if(!1===e.visible)return;if(e.layers.test(t.layers))if(e.isGroup)n=e.renderOrder;else if(e.isLOD)!0===e.autoUpdate&&e.update(t);else if(e.isLightProbeGrid)T.pushLightProbeGrid(e);else if(e.isLight)T.pushLight(e),e.castShadow&&T.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||Y.intersectsSprite(e)){i&&ee.setFromMatrixPosition(e.matrixWorld).applyMatrix4(J);let t=_e.update(e),a=e.material;a.visible&&S.push(e,t,a,n,ee.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||Y.intersectsObject(e))){let t=_e.update(e),a=e.material;if(i&&(void 0!==e.boundingSphere?(null===e.boundingSphere&&e.computeBoundingSphere(),ee.copy(e.boundingSphere.center)):(null===t.boundingSphere&&t.computeBoundingSphere(),ee.copy(t.boundingSphere.center)),ee.applyMatrix4(e.matrixWorld).applyMatrix4(J)),Array.isArray(a)){let i=t.groups;for(let r=0,o=i.length;r<o;r++){let o=i[r],s=a[o.materialIndex];s&&s.visible&&S.push(e,t,s,n,ee.z,o)}}else a.visible&&S.push(e,t,a,n,ee.z,null)}let a=e.children;for(let e=0,r=a.length;e<r;e++)Ke(a[e],t,n,i)}function Je(e,t,n,i){let{opaque:a,transmissive:r,transparent:o}=e;T.setupLightsView(n),!0===K&&Ee.setGlobalState(M.clippingPlanes,n),i&&ce.viewport(O.copy(i)),a.length>0&&nt(a,t,n),r.length>0&&nt(r,t,n),o.length>0&&nt(o,t,n),ce.buffers.depth.setTest(!0),ce.buffers.depth.setMask(!0),ce.buffers.color.setMask(!0),ce.setPolygonOffset(!1)}function Qe(e,t,n,i){if(null!==(!0===n.isScene?n.overrideMaterial:null))return;if(void 0===T.state.transmissionRenderTarget[i.id]){let e=ae.has("EXT_color_buffer_half_float")||ae.has("EXT_color_buffer_float");T.state.transmissionRenderTarget[i.id]=new Xe(1,1,{generateMipmaps:!0,type:e?re:si,minFilter:ei,samples:Math.max(4,se.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Ae.workingColorSpace})}let a=T.state.transmissionRenderTarget[i.id],o=i.viewport||O;a.setSize(o.z*M.transmissionResolutionScale,o.w*M.transmissionResolutionScale);let s=M.getRenderTarget(),l=M.getActiveCubeFace(),c=M.getActiveMipmapLevel();M.setRenderTarget(a),M.getClearColor(B),V=M.getClearAlpha(),V<1&&M.setClearColor(16777215,.5),M.clear(),ne&&ye.render(n);let d=M.toneMapping;M.toneMapping=wt;let u=i.viewport;if(void 0!==i.viewport&&(i.viewport=void 0),T.setupLightsView(i),!0===K&&Ee.setGlobalState(M.clippingPlanes,i),nt(e,n,i),pe.updateMultisampleRenderTarget(a),pe.updateRenderTargetMipmap(a),!1===ae.has("WEBGL_multisampled_render_to_texture")){let e=!1;for(let a=0,r=t.length;a<r;a++){let r=t[a],{object:o,geometry:s,material:l,group:c}=r;if(l.side===Cn&&o.layers.test(i.layers)){let t=l.side;l.side=bn,l.needsUpdate=!0,at(o,n,i,s,l,c),l.side=t,l.needsUpdate=!0,e=!0}}!0===e&&(pe.updateMultisampleRenderTarget(a),pe.updateRenderTargetMipmap(a))}M.setRenderTarget(s,l,c),M.setClearColor(B,V),void 0!==u&&(i.viewport=u),M.toneMapping=d}function nt(e,t,n){let i=!0===t.isScene?t.overrideMaterial:null;for(let a=0,r=e.length;a<r;a++){let r=e[a],{object:o,geometry:s,group:l}=r,c=r.material;!0===c.allowOverride&&null!==i&&(c=i),o.layers.test(n.layers)&&at(o,t,n,s,c,l)}}function at(e,t,n,i,a,r){e.onBeforeRender(M,t,n,i,a,r),e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix),a.onBeforeRender(M,t,n,i,e,r),!0===a.transparent&&a.side===Cn&&!1===a.forceSinglePass?(a.side=bn,a.needsUpdate=!0,M.renderBufferDirect(n,t,i,a,e,r),a.side=_n,a.needsUpdate=!0,M.renderBufferDirect(n,t,i,a,e,r),a.side=Cn):M.renderBufferDirect(n,t,i,a,e,r),e.onAfterRender(M,t,n,i,a,r)}function rt(e,t,n){!0!==t.isScene&&(t=te);let i=ue.get(e),a=T.state.lights,r=T.state.shadowsArray,o=a.state.version,s=xe.getParameters(e,a.state,r,t,n,T.state.lightProbeGridArray),l=xe.getProgramCacheKey(s),c=i.programs;i.environment=e.isMeshStandardMaterial||e.isMeshLambertMaterial||e.isMeshPhongMaterial?t.environment:null,i.fog=t.fog;let d=e.isMeshStandardMaterial||e.isMeshLambertMaterial&&!e.envMap||e.isMeshPhongMaterial&&!e.envMap;i.envMap=he.get(e.envMap||i.environment,d),i.envMapRotation=null!==i.environment&&null===e.envMap?t.environmentRotation:e.envMapRotation,void 0===c&&(e.addEventListener("dispose",ke),c=new Map,i.programs=c);let u=c.get(l);if(void 0!==u){if(i.currentProgram===u&&i.lightsStateVersion===o)return lt(e,s),u}else s.uniforms=xe.getUniforms(e),null!==C&&e.isNodeMaterial&&C.build(e,n,s),e.onBeforeCompile(s,M),u=xe.acquireProgram(s,l),c.set(l,u),i.uniforms=s.uniforms;let f=i.uniforms;return(!e.isShaderMaterial&&!e.isRawShaderMaterial||!0===e.clipping)&&(f.clippingPlanes=Ee.uniform),lt(e,s),i.needsLights=function(e){return e.isMeshLambertMaterial||e.isMeshToonMaterial||e.isMeshPhongMaterial||e.isMeshStandardMaterial||e.isShadowMaterial||e.isShaderMaterial&&!0===e.lights}(e),i.lightsStateVersion=o,i.needsLights&&(f.ambientLightColor.value=a.state.ambient,f.lightProbe.value=a.state.probe,f.directionalLights.value=a.state.directional,f.directionalLightShadows.value=a.state.directionalShadow,f.spotLights.value=a.state.spot,f.spotLightShadows.value=a.state.spotShadow,f.rectAreaLights.value=a.state.rectArea,f.ltc_1.value=a.state.rectAreaLTC1,f.ltc_2.value=a.state.rectAreaLTC2,f.pointLights.value=a.state.point,f.pointLightShadows.value=a.state.pointShadow,f.hemisphereLights.value=a.state.hemi,f.directionalShadowMatrix.value=a.state.directionalShadowMatrix,f.spotLightMatrix.value=a.state.spotLightMatrix,f.spotLightMap.value=a.state.spotLightMap,f.pointShadowMatrix.value=a.state.pointShadowMatrix),i.lightProbeGrid=T.state.lightProbeGridArray.length>0,i.currentProgram=u,i.uniformsList=null,u}function ot(e){if(null===e.uniformsList){let t=e.currentProgram.getUniforms();e.uniformsList=Zr.seqWithValue(t.seq,e.uniforms)}return e.uniformsList}function lt(e,t){let n=ue.get(e);n.outputColorSpace=t.outputColorSpace,n.batching=t.batching,n.batchingColor=t.batchingColor,n.instancing=t.instancing,n.instancingColor=t.instancingColor,n.instancingMorph=t.instancingMorph,n.skinning=t.skinning,n.morphTargets=t.morphTargets,n.morphNormals=t.morphNormals,n.morphColors=t.morphColors,n.morphTargetsCount=t.morphTargetsCount,n.numClippingPlanes=t.numClippingPlanes,n.numIntersection=t.numClipIntersection,n.vertexAlphas=t.vertexAlphas,n.vertexTangents=t.vertexTangents,n.toneMapping=t.toneMapping}Ye.setAnimationLoop(function(e){je&&je(e)}),typeof self<"u"&&Ye.setContext(self),this.setAnimationLoop=function(e){je=e,Be.setAnimationLoop(e),null===e?Ye.stop():Ye.start()},Be.addEventListener("sessionstart",$e),Be.addEventListener("sessionend",qe),this.render=function(e,t){if(void 0!==t&&!0!==t.isCamera)return void Ti("WebGLRenderer.render: camera is not an instance of THREE.Camera.");if(!0===y)return;null!==C&&C.renderStart(e,t);let n=!0===Be.enabled&&!0===Be.isPresenting,i=null!==E&&(null===U||n)&&E.begin(M,U);if(!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===t.parent&&!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),!0===Be.enabled&&!0===Be.isPresenting&&(null===E||!1===E.isCompositing())&&(!0===Be.cameraAutoUpdate&&Be.updateCamera(t),t=Be.getCamera()),!0===e.isScene&&e.onBeforeRender(M,e,t,U),T=we.get(e,w.length),T.init(t),T.state.textureUnits=pe.getTextureUnits(),w.push(T),J.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),Y.setFromProjectionMatrix(J,kn,t.reversedDepth),Z=this.localClippingEnabled,K=Ee.init(this.clippingPlanes,Z),S=be.get(e,b.length),S.init(),b.push(S),!0===Be.enabled&&!0===Be.isPresenting){let e=M.xr.getDepthSensingMesh();null!==e&&Ke(e,t,-1/0,M.sortObjects)}Ke(e,t,0,M.sortObjects),S.finish(),!0===M.sortObjects&&S.sort(W,X,t.reversedDepth),ne=!1===Be.enabled||!1===Be.isPresenting||!1===Be.hasDepthSensing(),ne&&ye.addToRenderList(S,e),this.info.render.frame++,!0===this.info.autoReset&&this.info.reset(),!0===K&&Ee.beginShadows();let a=T.state.shadowsArray;if(Me.render(a,e,t),!0===K&&Ee.endShadows(),!1===(i&&E.hasRenderPass())){let n=S.opaque,i=S.transmissive;if(T.setupLights(),t.isArrayCamera){let a=t.cameras;if(i.length>0)for(let t=0,r=a.length;t<r;t++)Qe(n,i,e,a[t]);ne&&ye.render(e);for(let t=0,n=a.length;t<n;t++){let n=a[t];Je(S,e,n,n.viewport)}}else i.length>0&&Qe(n,i,e,t),ne&&ye.render(e),Je(S,e,t)}null!==U&&0===L&&(pe.updateMultisampleRenderTarget(U),pe.updateRenderTargetMipmap(U)),i&&E.end(M),!0===e.isScene&&e.onAfterRender(M,e,t),Ue.resetDefaultState(),N=-1,I=null,w.pop(),w.length>0?(T=w[w.length-1],pe.setTextureUnits(T.state.textureUnits),!0===K&&Ee.setGlobalState(M.clippingPlanes,T.state.camera)):T=null,b.pop(),S=b.length>0?b[b.length-1]:null,null!==C&&C.renderEnd()},this.getActiveCubeFace=function(){return D},this.getActiveMipmapLevel=function(){return L},this.getRenderTarget=function(){return U},this.setRenderTargetTextures=function(e,t,n){let i=ue.get(e);i.__autoAllocateDepthBuffer=!1===e.resolveDepthBuffer,!1===i.__autoAllocateDepthBuffer&&(i.__useRenderToTexture=!1),ue.get(e.texture).__webglTexture=t,ue.get(e.depthTexture).__webglTexture=i.__autoAllocateDepthBuffer?void 0:n,i.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(e,t){let n=ue.get(e);n.__webglFramebuffer=t,n.__useDefaultFramebuffer=void 0===t},this.setRenderTarget=function(e,t=0,n=0){U=e,D=t,L=n;let i=null,a=!1,r=!1;if(e){let o=ue.get(e);if(void 0!==o.__useDefaultFramebuffer)return ce.bindFramebuffer(Ie.FRAMEBUFFER,o.__webglFramebuffer),O.copy(e.viewport),F.copy(e.scissor),z=e.scissorTest,ce.viewport(O),ce.scissor(F),ce.setScissorTest(z),void(N=-1);if(void 0===o.__webglFramebuffer)pe.setupRenderTarget(e);else if(o.__hasExternalTextures)pe.rebindTextures(e,ue.get(e.texture).__webglTexture,ue.get(e.depthTexture).__webglTexture);else if(e.depthBuffer){let t=e.depthTexture;if(o.__boundDepthTexture!==t){if(null!==t&&ue.has(t)&&(e.width!==t.image.width||e.height!==t.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");pe.setupDepthRenderbuffer(e)}}let s=e.texture;(s.isData3DTexture||s.isDataArrayTexture||s.isCompressedArrayTexture)&&(r=!0);let l=ue.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(i=Array.isArray(l[t])?l[t][n]:l[t],a=!0):i=e.samples>0&&!1===pe.useMultisampledRTT(e)?ue.get(e).__webglMultisampledFramebuffer:Array.isArray(l)?l[n]:l,O.copy(e.viewport),F.copy(e.scissor),z=e.scissorTest}else O.copy(j).multiplyScalar(k).floor(),F.copy($).multiplyScalar(k).floor(),z=q;if(0!==n&&(i=R),ce.bindFramebuffer(Ie.FRAMEBUFFER,i)&&ce.drawBuffers(e,i),ce.viewport(O),ce.scissor(F),ce.setScissorTest(z),a){let i=ue.get(e.texture);Ie.framebufferTexture2D(Ie.FRAMEBUFFER,Ie.COLOR_ATTACHMENT0,Ie.TEXTURE_CUBE_MAP_POSITIVE_X+t,i.__webglTexture,n)}else if(r){let i=t;for(let t=0;t<e.textures.length;t++){let a=ue.get(e.textures[t]);Ie.framebufferTextureLayer(Ie.FRAMEBUFFER,Ie.COLOR_ATTACHMENT0+t,a.__webglTexture,n,i)}}else if(null!==e&&0!==n){let t=ue.get(e.texture);Ie.framebufferTexture2D(Ie.FRAMEBUFFER,Ie.COLOR_ATTACHMENT0,Ie.TEXTURE_2D,t.__webglTexture,n)}N=-1},this.readRenderTargetPixels=function(e,t,n,i,a,r,o,s=0){if(!e||!e.isWebGLRenderTarget)return void Ti("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let l=ue.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==o&&(l=l[o]),l){ce.bindFramebuffer(Ie.FRAMEBUFFER,l);try{let o=e.textures[s],l=o.format,c=o.type;if(e.textures.length>1&&Ie.readBuffer(Ie.COLOR_ATTACHMENT0+s),!se.textureFormatReadable(l))return void Ti("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!se.textureTypeReadable(c))return void Ti("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");t>=0&&t<=e.width-i&&n>=0&&n<=e.height-a&&Ie.readPixels(t,n,i,a,De.convert(l),De.convert(c),r)}finally{let e=null!==U?ue.get(U).__webglFramebuffer:null;ce.bindFramebuffer(Ie.FRAMEBUFFER,e)}}},this.readRenderTargetPixelsAsync=async function(e,t,n,i,a,r,o,s=0){if(!e||!e.isWebGLRenderTarget)throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let l=ue.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==o&&(l=l[o]),l){if(t>=0&&t<=e.width-i&&n>=0&&n<=e.height-a){ce.bindFramebuffer(Ie.FRAMEBUFFER,l);let o=e.textures[s],c=o.format,d=o.type;if(e.textures.length>1&&Ie.readBuffer(Ie.COLOR_ATTACHMENT0+s),!se.textureFormatReadable(c))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!se.textureTypeReadable(d))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let u=Ie.createBuffer();Ie.bindBuffer(Ie.PIXEL_PACK_BUFFER,u),Ie.bufferData(Ie.PIXEL_PACK_BUFFER,r.byteLength,Ie.STREAM_READ),Ie.readPixels(t,n,i,a,De.convert(c),De.convert(d),0);let f=null!==U?ue.get(U).__webglFramebuffer:null;ce.bindFramebuffer(Ie.FRAMEBUFFER,f);let p=Ie.fenceSync(Ie.SYNC_GPU_COMMANDS_COMPLETE,0);return Ie.flush(),await Ai(Ie,p,4),Ie.bindBuffer(Ie.PIXEL_PACK_BUFFER,u),Ie.getBufferSubData(Ie.PIXEL_PACK_BUFFER,0,r),Ie.deleteBuffer(u),Ie.deleteSync(p),r}throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(e,t=null,n=0){let i=Math.pow(2,-n),a=Math.floor(e.image.width*i),r=Math.floor(e.image.height*i),o=null!==t?t.x:0,s=null!==t?t.y:0;pe.setTexture2D(e,0),Ie.copyTexSubImage2D(Ie.TEXTURE_2D,n,0,0,o,s,a,r),ce.unbindTexture()},this.copyTextureToTexture=function(e,t,n=null,i=null,a=0,r=0){let o,s,l,c,d,u,f,p,h,m=e.isCompressedTexture?e.mipmaps[r]:e.image;if(null!==n)o=n.max.x-n.min.x,s=n.max.y-n.min.y,l=n.isBox3?n.max.z-n.min.z:1,c=n.min.x,d=n.min.y,u=n.isBox3?n.min.z:0;else{let t=Math.pow(2,-a);o=Math.floor(m.width*t),s=Math.floor(m.height*t),l=e.isDataArrayTexture?m.depth:e.isData3DTexture?Math.floor(m.depth*t):1,c=0,d=0,u=0}null!==i?(f=i.x,p=i.y,h=i.z):(f=0,p=0,h=0);let v,g=De.convert(t.format),_=De.convert(t.type);t.isData3DTexture?(pe.setTexture3D(t,0),v=Ie.TEXTURE_3D):t.isDataArrayTexture||t.isCompressedArrayTexture?(pe.setTexture2DArray(t,0),v=Ie.TEXTURE_2D_ARRAY):(pe.setTexture2D(t,0),v=Ie.TEXTURE_2D),ce.activeTexture(Ie.TEXTURE0),ce.pixelStorei(Ie.UNPACK_FLIP_Y_WEBGL,t.flipY),ce.pixelStorei(Ie.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),ce.pixelStorei(Ie.UNPACK_ALIGNMENT,t.unpackAlignment);let x=ce.getParameter(Ie.UNPACK_ROW_LENGTH),S=ce.getParameter(Ie.UNPACK_IMAGE_HEIGHT),T=ce.getParameter(Ie.UNPACK_SKIP_PIXELS),b=ce.getParameter(Ie.UNPACK_SKIP_ROWS),w=ce.getParameter(Ie.UNPACK_SKIP_IMAGES);ce.pixelStorei(Ie.UNPACK_ROW_LENGTH,m.width),ce.pixelStorei(Ie.UNPACK_IMAGE_HEIGHT,m.height),ce.pixelStorei(Ie.UNPACK_SKIP_PIXELS,c),ce.pixelStorei(Ie.UNPACK_SKIP_ROWS,d),ce.pixelStorei(Ie.UNPACK_SKIP_IMAGES,u);let E=e.isDataArrayTexture||e.isData3DTexture,M=t.isDataArrayTexture||t.isData3DTexture;if(e.isDepthTexture){let n=ue.get(e),i=ue.get(t),m=ue.get(n.__renderTarget),v=ue.get(i.__renderTarget);ce.bindFramebuffer(Ie.READ_FRAMEBUFFER,m.__webglFramebuffer),ce.bindFramebuffer(Ie.DRAW_FRAMEBUFFER,v.__webglFramebuffer);for(let n=0;n<l;n++)E&&(Ie.framebufferTextureLayer(Ie.READ_FRAMEBUFFER,Ie.COLOR_ATTACHMENT0,ue.get(e).__webglTexture,a,u+n),Ie.framebufferTextureLayer(Ie.DRAW_FRAMEBUFFER,Ie.COLOR_ATTACHMENT0,ue.get(t).__webglTexture,r,h+n)),Ie.blitFramebuffer(c,d,o,s,f,p,o,s,Ie.DEPTH_BUFFER_BIT,Ie.NEAREST);ce.bindFramebuffer(Ie.READ_FRAMEBUFFER,null),ce.bindFramebuffer(Ie.DRAW_FRAMEBUFFER,null)}else if(0!==a||e.isRenderTargetTexture||ue.has(e)){let n=ue.get(e),i=ue.get(t);ce.bindFramebuffer(Ie.READ_FRAMEBUFFER,A),ce.bindFramebuffer(Ie.DRAW_FRAMEBUFFER,P);for(let e=0;e<l;e++)E?Ie.framebufferTextureLayer(Ie.READ_FRAMEBUFFER,Ie.COLOR_ATTACHMENT0,n.__webglTexture,a,u+e):Ie.framebufferTexture2D(Ie.READ_FRAMEBUFFER,Ie.COLOR_ATTACHMENT0,Ie.TEXTURE_2D,n.__webglTexture,a),M?Ie.framebufferTextureLayer(Ie.DRAW_FRAMEBUFFER,Ie.COLOR_ATTACHMENT0,i.__webglTexture,r,h+e):Ie.framebufferTexture2D(Ie.DRAW_FRAMEBUFFER,Ie.COLOR_ATTACHMENT0,Ie.TEXTURE_2D,i.__webglTexture,r),0!==a?Ie.blitFramebuffer(c,d,o,s,f,p,o,s,Ie.COLOR_BUFFER_BIT,Ie.NEAREST):M?Ie.copyTexSubImage3D(v,r,f,p,h+e,c,d,o,s):Ie.copyTexSubImage2D(v,r,f,p,c,d,o,s);ce.bindFramebuffer(Ie.READ_FRAMEBUFFER,null),ce.bindFramebuffer(Ie.DRAW_FRAMEBUFFER,null)}else M?e.isDataTexture||e.isData3DTexture?Ie.texSubImage3D(v,r,f,p,h,o,s,l,g,_,m.data):t.isCompressedArrayTexture?Ie.compressedTexSubImage3D(v,r,f,p,h,o,s,l,g,m.data):Ie.texSubImage3D(v,r,f,p,h,o,s,l,g,_,m):e.isDataTexture?Ie.texSubImage2D(Ie.TEXTURE_2D,r,f,p,o,s,g,_,m.data):e.isCompressedTexture?Ie.compressedTexSubImage2D(Ie.TEXTURE_2D,r,f,p,m.width,m.height,g,m.data):Ie.texSubImage2D(Ie.TEXTURE_2D,r,f,p,o,s,g,_,m);ce.pixelStorei(Ie.UNPACK_ROW_LENGTH,x),ce.pixelStorei(Ie.UNPACK_IMAGE_HEIGHT,S),ce.pixelStorei(Ie.UNPACK_SKIP_PIXELS,T),ce.pixelStorei(Ie.UNPACK_SKIP_ROWS,b),ce.pixelStorei(Ie.UNPACK_SKIP_IMAGES,w),0===r&&t.generateMipmaps&&Ie.generateMipmap(v),ce.unbindTexture()},this.initRenderTarget=function(e){void 0===ue.get(e).__webglFramebuffer&&pe.setupRenderTarget(e)},this.initTexture=function(e){e.isCubeTexture?pe.setTextureCube(e,0):e.isData3DTexture?pe.setTexture3D(e,0):e.isDataArrayTexture||e.isCompressedArrayTexture?pe.setTexture2DArray(e,0):pe.setTexture2D(e,0),ce.unbindTexture()},this.resetState=function(){D=0,L=0,U=null,ce.reset(),Ue.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return kn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=Ae._getDrawingBufferColorSpace(e),t.unpackColorSpace=Ae._getUnpackColorSpace()}},es=class extends Fi{constructor(e){super("b"),this.nodeType="Bool",this.value=e??!1}generateReadonly(e,t,n,i){return e.format(this.value?"true":"false",i,t)}},ts=class extends Fi{constructor(e=1,t){super("f[]"),this.nodeType="FloatArray",this.size=e,this.value=Array.isArray(t)?t:"number"==typeof t?new Array(e).fill(t):new Array(e).fill(0)}},ns=class extends Fi{},is=class extends ns{constructor(e){super("v3"),this.image=e,this._value=new Te}get value(){return this._value.x=this.image.isVideo?this.image.img.videoWidth??0:this.image.img.width,this._value.y=this.image.isVideo?this.image.img.videoHeight??0:this.image.img.height,this._value}},as=class extends ns{constructor(e,t,n=1008,i=1006){super("t"),this.image=e,this.wrap=t,this.minFilter=n,this.magFilter=i}get value(){return this.image.getTexture(this.wrap,this.minFilter,this.magFilter)}},rs=class extends Fi{constructor(e){super("m3"),this.nodeType="Matrix3",this.value=e??new Me}generateReadonly(e,t,n,i,a,r){return e.format("mat3("+this.value.elements.join(", ")+")",i,t)}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}},os=class extends Fi{constructor(e){super("m4"),this.nodeType="Matrix4",this.value=e??new tt}generateReadonly(e,t,n,i,a,r){return e.format("mat4("+this.value.elements.join(", ")+")",i,t)}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}};function ss(e,t,n,i=0){e.setUvTransform(n[0],n[1],t[0],t[1],0,0,0).premultiply((new Me).makeRotation(i*ce.DEG2RAD))}var ls=class extends rs{constructor(e,t,n=0){super(new Me),this.repeat=e,this.offset=t,this.rotation=n,ss(this.value,e,t,n)}updateMatrix(){ss(this.value,this.repeat,this.offset,this.rotation)}},cs=class extends Fi{constructor(e=1,t){super("v4[]"),this.nodeType="Vector4Array",this.size=e,this.value=Array.isArray(t)?t:t instanceof Fe?new Array(e).fill(t):new Array(e).fill(new Fe(0))}},ds=class extends Oi{constructor(e,t,n,i){super("v3"),this.nodeType="Blend",this.a=e,this.b=t,this.alpha=n,this.mode=i}generate(e,t){if(e.isShader("fragment")){let n=[];return n.push(this.a.build(e,"c")),n.push(this.b.build(e,"c")),n.push(this.alpha.build(e,"f")),n.push(this.mode.build(e,"i")),e.format("spe_blend("+n.join(",")+")",this.getType(e),t)}return console.warn("BlendNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},us=class extends Oi{constructor(e,t){super("v3"),this.nodeType="CustomColor",this.color=e,this.alpha=t,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.isShader("fragment")){let n=e.include(us.Nodes.customColor);e.addFragmentVariable(this.calpha,"float");let i=[];return i.push(this.color.build(e,"v3")),i.push(this.mask?`luminance(${this.mask.build(e,"v3")})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(n+"("+i.join(",")+")",this.getType(e),t)}return console.warn("CustomColorNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},fs=us;fs.Nodes={customColor:new ki("vec3 customColor(vec3 color, float mask, float alpha, out float calpha) {\n\t\t\t\tfloat lalpha = alpha * mask;\n\t\t\t\tcalpha = lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0);\n\t\t\t\taccumAlpha += (1.0 - accumAlpha) * lalpha;\n\n\t\t\t\treturn color;\n\t\t\t}")};var ps=class extends Oi{constructor(e,t){super("v3"),this.nodeType="CustomNormal",this.cnormal=e,this.alpha=t,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.isShader("fragment")){let n=e.include(ps.Nodes.customNormal);e.addFragmentVariable(this.calpha,"float");let i=[];return i.push(this.cnormal.build(e,"v3")),i.push("normal"),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(n+"("+i.join(",")+")",this.getType(e),t)}return console.warn("CustomNormalNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},hs=ps;hs.Nodes={customNormal:new ki("vec3 customNormal(vec3 cnormal, vec3 norm, float mask, float alpha, out float calpha) {\n\t\t\t\tvec3 normal = packNormalToRGB( norm ).rgb;\n\t\t\t\tnormal *= step( vec3(0.5), cnormal );\n\n\t\t\t\tfloat lalpha = alpha * mask;\n\t\t\t\tcalpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );\n\t\t\t\taccumAlpha += ( 1.0 - accumAlpha ) * lalpha;\n\n\t\t\t\treturn normal;\n\t\t\t}")};var ms=[{a:"y",b:"z",pole:"x"},{a:"z",b:"x",pole:"y"},{a:"x",b:"y",pole:"z"}],vs=class extends Oi{constructor(e,t,n,i,a,r,o,s,l,c,d,u,f=-1){super("v3"),this.nodeType="CustomTexture",this.texture=e,this.textureSize=t,this.crop=n,this.projection=i,this.axis=a,this.projectionAxis=f,this.side=r,this.size=o,this.blending=s,this.mat=l,this.isMask=u,this.alpha=c,this.mode=d,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){e.require("position"),e.require("normal"),e.require("uv"),e.requires.uv=[!0],e.extensions.shaderTextureLOD=!0,e.extensions.derivatives=!0;let n,i=`g${this.uuid.toString().replace(/-/g,"")}`;switch(this.projection.value){case 3:{let t=this.projectionAxis;if(0===t||2===t){let{a:a,b:r,pole:o}=ms[t];n=e.include(new ki(`\nvec3 ${i}_cylindricalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUv) {\n vec3 posN = normalize(position);\n float u = 0.5 + atan(posN.${a}, posN.${r}) / (2.*3.1415);\n float scaledHeight = position.${o} / (size.y * 0.5);\n float v = (scaledHeight / 2.) + .5;\n\n vec2 calculatedUv = vec2(u,v);\n\t\t\t\tvec2 uvs = ( mat * vec3( calculatedUv * 2. - 1., 1. ) / 2. + 0.5 ).xy;\n\t\t\t\twriteUv = uvs;\n\n // Seam-safe FILTERED sample: the atan()-derived u jumps a whole\n // period at the wrap seam, so implicit derivatives would smear a\n // lowest-mip column across it. Folding the u-derivatives to the\n // nearest period keeps the true footprint — and, unlike the\n // forced-LOD sample this replaces (log2(fwidth*texSize), up to a\n // full mip too low), it leaves mip selection to the sampler, so\n // the layer's Sharpness filters and anisotropy actually apply.\n vec2 uvDx = dFdx(uvs); uvDx.x -= floor(uvDx.x + 0.5);\n vec2 uvDy = dFdy(uvs); uvDy.x -= floor(uvDy.x + 0.5);\n\t\t\t\t#ifdef GL_EXT_shader_texture_lod\n vec4 tmp = texture2DGradEXT(tex, uvs, uvDx, uvDy);\n\t\t\t\t#else\n vec4 tmp = textureGrad(tex, uvs, uvDx, uvDy);\n\t\t\t\t#endif\n\n\t\t\t\tvec3 col = tmp.rgb;\n\t\t\t\tfloat lalpha = alpha * tmp.a;\n\t\t\t\tif ( crop > 0.5 ) {\n\t\t\t\t\tif ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {\n\t\t\t\t\t\tlalpha = 0.0;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tlalpha *= mask;\n\n\t\t\t\tcalpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );\n\t\t\t\taccumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));\n\n\t\t\t\treturn col;\n\t\t\t}\n`))}else n=e.include(vs.Nodes.cylindrical);break}case 2:{let t=this.projectionAxis;if(0===t||2===t){let{a:a,b:r,pole:o}=ms[t];n=e.include(new ki(`\nvec3 ${i}_sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUv) {\n vec3 posN = normalize(vPosition);\n float u = 0.5 + atan(posN.${a}, posN.${r}) / (2.*3.1415);\n float v = 0.5 + asin(posN.${o}) / 3.1415;\n\n vec2 calculatedUv = vec2(u,v);\n\t\t\t\tvec2 uvs = ( mat * vec3( calculatedUv * 2. - 1., 1. ) / 2. + 0.5 ).xy;\n\t\t\t\twriteUv = uvs;\n\n // Seam-safe FILTERED sample: the atan()-derived u jumps a whole\n // period at the wrap seam, so implicit derivatives would smear a\n // lowest-mip column across it. Folding the u-derivatives to the\n // nearest period keeps the true footprint — and, unlike the\n // forced-LOD sample this replaces (log2(fwidth*texSize), up to a\n // full mip too low), it leaves mip selection to the sampler, so\n // the layer's Sharpness filters and anisotropy actually apply.\n vec2 uvDx = dFdx(uvs); uvDx.x -= floor(uvDx.x + 0.5);\n vec2 uvDy = dFdy(uvs); uvDy.x -= floor(uvDy.x + 0.5);\n\t\t\t\t#ifdef GL_EXT_shader_texture_lod\n vec4 tmp = texture2DGradEXT(tex, uvs, uvDx, uvDy);\n\t\t\t\t#else\n vec4 tmp = textureGrad(tex, uvs, uvDx, uvDy);\n\t\t\t\t#endif\n\n\t\t\t\tvec3 col = tmp.rgb;\n\t\t\t\tfloat lalpha = alpha * tmp.a;\n\t\t\t\tif ( crop > 0.5 ) {\n\t\t\t\t\tif ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {\n\t\t\t\t\t\tlalpha = 0.0;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tlalpha *= mask;\n\n\t\t\t\tcalpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );\n\t\t\t\taccumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));\n\n\t\t\t\treturn col;\n\t\t\t}\n`))}else n=e.include(vs.Nodes.spherical);break}case 1:{let t=["vec3(1.0, 0.0, 0.0)","vec3(0.0, 1.0, 0.0)","vec3(0.0, 0.0, 1.0)"][this.axis.value],a=["zy","xz","xy"][this.axis.value],r=new ki(`\n\t\tvec3 ${i}_planarTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUv) {\n\t\t\t\tvec2 projected = (1. + (position.${a})) / 2.;\n\t\t\t\tvec2 uvs = ( mat * vec3( (projected * 2. - 1.) / (size * .5), 1. ) / 2. + 0.5 ).xy;\n\t\t\t\twriteUv = uvs;\n\n\t\t\t\tvec4 tmp = texture2D( tex, uvs );\n\n\t\t\t\tvec3 col = tmp.rgb;\n\t\t\t\tfloat lalpha = alpha * tmp.a;\n\t\t\t\t${2===this.side.value?"":`lalpha *= step(0.0, ${1===this.side.value?"-1.0 * ":""}dot(vObjectNormal, ${t}));`}\n\n\t\t\t\tif ( crop > 0.5 ) {\n\t\t\t\t\tif ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {\n\t\t\t\t\t\tlalpha = 0.0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tlalpha *= mask;\n\n\t\t\t\tcalpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );\n\t\t\t\taccumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));\n\n\t\t\t\treturn col;\n\t\t\t}`);n=e.include(r);break}case 4:n=e.include(vs.Nodes.triplanar);break;case 0:{let t=vs.Nodes.uv.src,a=new ki(t.replace("uvTexture",`${i}_uvTexture`));n=e.include(a);break}default:n=e.include(vs.Nodes.uv)}e.addFragmentVariable(this.calpha,"float");let a=[];if(a.push("normal"),a.push(this.texture.generate(e,"t")),a.push(this.textureSize.build(e,"v2")),a.push(this.crop.build(e,"f")),a.push(this.mat.build(e,"mat3")),a.push(this.size.build(e,"v2")),a.push(this.blending.build(e,"f")),a.push(this.isMask.build(e,"b")),a.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),a.push(this.alpha.build(e,"f")),a.push(this.mode.build(e,"i")),a.push(this.calpha),4===this.projection.value){let t=`${i}_writeUvs`,n=t+"0",r=t+"1",o=t+"2",s=`${i}_triplanarWeights`;e.addFragmentVariable(n,"vec2"),e.addFragmentVariable(r,"vec2"),e.addFragmentVariable(o,"vec2"),e.addFragmentVariable(s,"vec3"),a.push(n),a.push(r),a.push(o),a.push(s)}else{let t=`${i}_writeUvs`;e.addFragmentVariable(t,"vec2"),a.push(t)}return e.format(n+"("+a.join(",")+")",this.getType(e),t)}},gs=vs;gs.Nodes={cylindrical:new ki("\nvec3 cylindricalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUv) {\n vec3 posN = normalize(position);\n float u = 0.5 + atan(posN.z, posN.x) / (2.*3.1415);\n float scaledHeight = position.y / (size.y * 0.5);\n float v = (scaledHeight / 2.) + .5;\n\n vec2 calculatedUv = vec2(u,v);\n\t\t\t\tvec2 uvs = ( mat * vec3( calculatedUv * 2. - 1., 1. ) / 2. + 0.5 ).xy;\n\t\t\t\twriteUv = uvs;\n\n // Seam-safe FILTERED sample: the atan()-derived u jumps a whole\n // period at the wrap seam, so implicit derivatives would smear a\n // lowest-mip column across it. Folding the u-derivatives to the\n // nearest period keeps the true footprint — and, unlike the\n // forced-LOD sample this replaces (log2(fwidth*texSize), up to a\n // full mip too low), it leaves mip selection to the sampler, so\n // the layer's Sharpness filters and anisotropy actually apply.\n vec2 uvDx = dFdx(uvs); uvDx.x -= floor(uvDx.x + 0.5);\n vec2 uvDy = dFdy(uvs); uvDy.x -= floor(uvDy.x + 0.5);\n\t\t\t\t#ifdef GL_EXT_shader_texture_lod\n vec4 tmp = texture2DGradEXT(tex, uvs, uvDx, uvDy);\n\t\t\t\t#else\n vec4 tmp = textureGrad(tex, uvs, uvDx, uvDy);\n\t\t\t\t#endif\n\n\t\t\t\tvec3 col = tmp.rgb;\n\t\t\t\tfloat lalpha = alpha * tmp.a;\n\t\t\t\tif ( crop > 0.5 ) {\n\t\t\t\t\tif ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {\n\t\t\t\t\t\tlalpha = 0.0;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tlalpha *= mask;\n\t\t\t\t\n\t\t\t\tcalpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );\n\t\t\t\taccumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));\n\n\t\t\t\treturn col;\n\t\t\t}\n"),spherical:new ki("\nvec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUv) {\n vec3 posN = normalize(vPosition);\n float u = 0.5 + atan(posN.z, posN.x) / (2.*3.1415);\n float v = 0.5 + asin(posN.y) / 3.1415;\n\n vec2 calculatedUv = vec2(u,v);\n\t\t\t\tvec2 uvs = ( mat * vec3( calculatedUv * 2. - 1., 1. ) / 2. + 0.5 ).xy;\n\t\t\t\twriteUv = uvs;\n\n // Seam-safe FILTERED sample: the atan()-derived u jumps a whole\n // period at the wrap seam, so implicit derivatives would smear a\n // lowest-mip column across it. Folding the u-derivatives to the\n // nearest period keeps the true footprint — and, unlike the\n // forced-LOD sample this replaces (log2(fwidth*texSize), up to a\n // full mip too low), it leaves mip selection to the sampler, so\n // the layer's Sharpness filters and anisotropy actually apply.\n vec2 uvDx = dFdx(uvs); uvDx.x -= floor(uvDx.x + 0.5);\n vec2 uvDy = dFdy(uvs); uvDy.x -= floor(uvDy.x + 0.5);\n\t\t\t\t#ifdef GL_EXT_shader_texture_lod\n vec4 tmp = texture2DGradEXT(tex, uvs, uvDx, uvDy);\n\t\t\t\t#else\n vec4 tmp = textureGrad(tex, uvs, uvDx, uvDy);\n\t\t\t\t#endif\n\n\t\t\t\tvec3 col = tmp.rgb;\n\t\t\t\tfloat lalpha = alpha * tmp.a;\n\t\t\t\tif ( crop > 0.5 ) {\n\t\t\t\t\tif ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {\n\t\t\t\t\t\tlalpha = 0.0;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tlalpha *= mask;\n\n\t\t\t\tcalpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );\n\t\t\t\taccumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));\n\n\t\t\t\treturn col;\n\t\t\t}\n"),uv:new ki("vec3 uvTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUv) {\n\t\t\t\tvec2 uvs = ( mat * vec3( vUv * 2. - 1., 1. ) / 2. + 0.5 ).xy;\n\t\t\t\twriteUv = uvs;\n\n\t\t\t\tvec4 tmp = texture2D( tex, uvs );\n\n\t\t\t\tvec3 col = tmp.rgb;\n\n\t\t\t\tfloat lalpha = alpha * tmp.a;\n\t\t\t\tif ( crop > 0.5 ) {\n\t\t\t\t\tif ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {\n\t\t\t\t\t\tlalpha = 0.0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tlalpha *= mask;\n\n\t\t\t\tcalpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );\n\t\t\t\taccumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));\n\n\t\t\t\treturn col;\n\t\t\t}"),triplanar:new ki("vec3 triplanarTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUvs0, out vec2 writeUvs1, out vec2 writeUvs2, out vec3 writeWeights) {\n\t\t\t\tvec3 p = position;\n\t\t\t\tvec2 uv0 = (1.0 + p.xy) / 2.0; \n\t\t\t\tvec2 uv1 = (1.0 + p.zy) / 2.0;\t\t\n\t\t\t\tvec2 uv2 = (1.0 + p.xz) / 2.0;\t\t\n\t\n\t\t\t\tuv0 = (mat * vec3((uv0 * 2.0 - 1.0) / (size * 0.5), 1.0) / 2.0 + 0.5).xy;\n\t\t\t\tuv1 = (mat * vec3((uv1 * 2.0 - 1.0) / (size * 0.5), 1.0) / 2.0 + 0.5).xy;\n\t\t\t\tuv2 = (mat * vec3((uv2 * 2.0 - 1.0) / (size * 0.5), 1.0) / 2.0 + 0.5).xy;\n\n\t\t\t\t// Range from 3 to 128 seems to be good\n\t\t\t\tfloat exponent = (1.0 - blending) * 125.0 + 3.0;\n\n\t\t\t\tvec3 n = vObjectNormal;\n\t\t\t\tvec3 weights = abs(normalize(n));\n\t\t\t\tweights = pow(weights, vec3(exponent));\n\t\t\t\tweights /= dot(weights, vec3(1.0));\n\n\t\t\t\t// Write out all sets of UVs that we generated\n\t\t\t\twriteUvs0 = uv0;\n\t\t\t\twriteUvs1 = uv1;\n\t\t\t\twriteUvs2 = uv2;\n\t\t\t\twriteWeights = weights;\n\n\t\t\t\t// Plain filtered samples: triplanar UVs are continuous (no wrap\n\t\t\t\t// seam), so implicit derivatives are already correct — the\n\t\t\t\t// forced-LOD sample this replaces bypassed the layer's Sharpness\n\t\t\t\t// filters and over-blurred by up to a mip (fwidth overestimates\n\t\t\t\t// the footprint; see the spherical/cylindrical variants).\n\t\t\t\tvec4 tmp = \n\t\t\t\t\ttexture2D(tex, uv0) * weights.z + \n\t\t\t\t\ttexture2D(tex, uv1) * weights.x + \n\t\t\t\t\ttexture2D(tex, uv2) * weights.y;\n\n\t\t\t\tvec3 col = tmp.rgb;\n\t\t\t\tfloat lalpha = alpha * tmp.a;\n\n\t\t\t\t// Apply cropping across all 3 planes\n\t\t\t\tif ( crop > 0.5 ) {\n\t\t\t\t\tif ( uv0.x < 0.0 || uv0.x > 1.0 || uv0.y < 0.0 || uv0.y > 1.0 ) {\n\t\t\t\t\t\tlalpha = 0.0;\n\t\t\t\t\t}\n\t\t\t\t\tif ( uv1.x < 0.0 || uv1.x > 1.0 || uv1.y < 0.0 || uv1.y > 1.0 ) {\n\t\t\t\t\t\tlalpha = 0.0;\n\t\t\t\t\t}\n\t\t\t\t\tif ( uv2.x < 0.0 || uv2.x > 1.0 || uv2.y < 0.0 || uv2.y > 1.0 ) {\n\t\t\t\t\t\tlalpha = 0.0;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tlalpha *= mask;\n\t\t\t\tcalpha = lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0);\n\t\t\t\taccumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));\n\n\t\t\t\treturn col;//n * 0.5 + 0.5;\n\t\t\t}\t\t\t\n\t\t\t")};var _s=class extends Oi{constructor(e,t,n,i,a,r,o,s,l,c,d,u){super("v3"),this.nodeType="Depth",this.gradientType=e,this.smooth=t,this.near=n,this.far=i,this.isVector=a,this.isWorldSpace=r,this.origin=o,this.direction=s,this.colors=l,this.steps=c,this.isMask=u,this.alpha=d,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){let n=`g${this.uuid.toString().replace(/-/g,"")}`,i=new ki(`vec3 ${n}_sdepth(float near, float far, vec3 origin, vec3 direction, vec4 colors[${n}_MAX_COLORS], float steps[${n}_MAX_COLORS], bool isMask, float mask, float alpha, out float calpha) {\n vec4 color = colors[0];\n #ifdef ${n}_IS_VECTOR\n #ifdef ${n}_LINEAR\n #ifdef ${n}_WORLDSPACE\n float depth = vectorLinearWorldSpaceDepth(direction, origin, near, far);\n #else\n float depth = vectorLinearObjectSpaceDepth(direction, origin, near, far);\n #endif\n #else\n #ifdef ${n}_WORLDSPACE\n float depth = vectorSphericalWorldSpaceDepth(origin, near, far);\n #else\n float depth = vectorSphericalObjectSpaceDepth(origin, near, far);\n #endif\n #endif\n #else\n float dist = length(vWPosition - cameraPosition);\n\t\t\t float depth = ( dist - near ) / ( far - near );\n #endif\n\n\n float p;\n #ifdef ${n}_SMOOTH\n\t\t\t\tfor ( int i = 1; i < ${n}_MAX_COLORS; i++ ) {\n\t\t\t\t\t\tp = clamp( ( depth - steps[i-1] ) / ( steps[i] - steps[i-1] ), 0.0, 1.0 );\n\t\t\t\t\t\tcolor = mix(color, colors[i], smoothstep(0.0, 1.0, p));\n\t\t\t\t\t}\n #else\n for ( int i = 1; i < ${n}_MAX_COLORS; i++ ) {\n p = clamp(( depth - steps[i - 1] ) / ( steps[i] - steps[i - 1] ), 0.0, 1.0);\n color = mix(color, colors[i], p);\n }\n #endif\n\n float lalpha = alpha * color.a * mask;\n calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));\n\t\t\t accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));\n\t\t\t \n return color.rgb;\n\t\t\t}`,[_s.Nodes.vectorLinearWorldSpaceDepth,_s.Nodes.vectorLinearObjectSpaceDepth,_s.Nodes.vectorSphericalObjectSpaceDepth,_s.Nodes.vectorSphericalWorldSpaceDepth]);if(e.isShader("fragment")){e.define(`${n}_MAX_COLORS`,this.colors.value.length),this.smooth.value&&e.define(`${n}_SMOOTH`),this.isVector.value>.5&&e.define(`${n}_IS_VECTOR`),0===this.gradientType.value&&e.define(`${n}_LINEAR`),this.isWorldSpace.value>.5&&e.define(`${n}_WORLDSPACE`),e.require("worldPosition"),e.addFragmentVariable(this.calpha,"float");let a=e.include(i),r=[];return r.push(this.near.build(e,"f")),r.push(this.far.build(e,"f")),r.push(this.origin.build(e,"v3")),r.push(this.direction.build(e,"v3")),r.push(this.colors.build(e,"v4[]")),r.push(this.steps.build(e,"f[]")),r.push(this.isMask.build(e,"b")),r.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),r.push(this.alpha.build(e,"f")),r.push(this.calpha),e.format(a+"("+r.join(",")+")",this.getType(e),t)}return console.warn("DepthNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},xs=_s;xs.Nodes={vectorLinearWorldSpaceDepth:new ki("float vectorLinearWorldSpaceDepth(vec3 direction, vec3 origin, float near, float far) {\n vec3 n = normalize(direction);\n float dist = (n.x*(vWPosition.x - origin.x) + n.y*(vWPosition.y - origin.y) + n.z*(vWPosition.z - origin.z));\n return ( dist - near ) / ( far - near );\n }"),vectorLinearObjectSpaceDepth:new ki("float vectorLinearObjectSpaceDepth(vec3 direction, vec3 origin, float near, float far) {\n vec3 n = normalize(direction);\n float dist = (n.x*(position.x - origin.x) + n.y*(position.y - origin.y) + n.z*(position.z - origin.z));\n return ( dist - near ) / ( far - near );\n }"),vectorSphericalWorldSpaceDepth:new ki("float vectorSphericalWorldSpaceDepth(vec3 origin, float near, float far) {\n float dist = length(vWPosition - origin);\n return ( dist - near ) / ( far - near );\n }"),vectorSphericalObjectSpaceDepth:new ki("float vectorSphericalObjectSpaceDepth(vec3 origin, float near, float far) {\n float dist = length(position - origin);\n return ( dist - near ) / ( far - near );\n }")};var Ss=class extends Oi{constructor(e,t,n,i,a,r,o){super("v3"),this.nodeType="Cavity",this.firstTime=!0,this.ridge=e,this.valley=t,this.normalViewMap=n,this.resolution=i,this.isMask=o,this.alpha=a,this.mode=r,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(this.firstTime&&(e.addVertexParsVariable("randomColor","attribute vec3"),e.addVertexParsVariable("vID","flat out float"),e.addFragmentParsVariable("vID","flat in float"),e.addVertexFinalCode("\n vID = randomColor.r;\n ")),e.isShader("fragment")){e.addFragmentVariable(this.calpha,"float");let n=e.include(Ss.Nodes.cavity),i=[];return i.push(this.normalViewMap.getTexture(e,"t")),i.push(this.resolution.build(e,"v2")),i.push(this.ridge.build(e,"f")),i.push(this.valley.build(e,"f")),i.push(this.isMask.build(e,"b")),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.mode.build(e,"i")),i.push(this.calpha),this.firstTime=!this.firstTime,e.format(n+"("+i.join(",")+")",this.getType(e),t)}return console.warn("CavityNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},Ts=Ss;Ts.Nodes=function(){let e=new ki("float cavitySoftClamp(float c, float control) {\n\t\t\t\tif (c < 0.5 / control) return c * (1.0 - c * control);\n\t\t\t\treturn 0.25 / control;\n\t\t\t}");return{cavity:new ki("vec3 cavity(sampler2D normalViewMap, vec2 resolution, float ridge, float valley, bool isMask, float mask, float alpha, int mode, out float calpha) {\n\t\t\t\t// The factors saturate the soft clamp by 2 — beyond that the\n\t\t\t\t// response is visually identical, so 2 is the ceiling\n\t\t\t\t// everywhere (panel, DSL, variables, old files).\n\t\t\t\tridge = clamp(ridge, 0.0, 2.0);\n\t\t\t\tvalley = clamp(valley, 0.0, 2.0);\n\n\t\t\t\tvec2 nuv = gl_FragCoord.xy / resolution;\n\t\t\t\tvec2 texel = vec2(1.0) / resolution;\n\n\t\t\t\tvec4 nUp = texture2D(normalViewMap, nuv + vec2(0.0, texel.y));\n\t\t\t\tvec4 nDown = texture2D(normalViewMap, nuv - vec2(0.0, texel.y));\n\t\t\t\tvec4 nLeft = texture2D(normalViewMap, nuv - vec2(texel.x, 0.0));\n\t\t\t\tvec4 nRight = texture2D(normalViewMap, nuv + vec2(texel.x, 0.0));\n\n\t\t\t\tfloat curv = 0.0;\n\t\t\t\tif (nUp.a == vID && nDown.a == vID && nLeft.a == vID && nRight.a == vID &&\n\t\t\t\t\tdot(nUp.xyz, nUp.xyz) > 0.5 && dot(nDown.xyz, nDown.xyz) > 0.5 &&\n\t\t\t\t\tdot(nLeft.xyz, nLeft.xyz) > 0.5 && dot(nRight.xyz, nRight.xyz) > 0.5) {\n\t\t\t\t\tfloat ndiff = (nUp.y - nDown.y) + (nRight.x - nLeft.x);\n\t\t\t\t\t// Blender's control mapping (workbench_data.c): a bigger\n\t\t\t\t\t// factor lowers the control, which raises both the linear\n\t\t\t\t\t// range and the clamp ceiling of the soft clamp — the\n\t\t\t\t\t// factors get a real O(1) signal to scale.\n\t\t\t\t\tfloat ridgeControl = 0.5 / max(ridge * ridge, 0.0001);\n\t\t\t\t\tfloat valleyControl = 0.7 / max(valley * valley, 0.0001);\n\t\t\t\t\tcurv = ndiff > 0.0\n\t\t\t\t\t\t? 2.0 * cavitySoftClamp(ndiff, ridgeControl)\n\t\t\t\t\t\t: -2.0 * cavitySoftClamp(-ndiff, valleyControl);\n\t\t\t\t\t// Dead-zone: sub-visible curvature (buffer quantization\n\t\t\t\t\t// noise, near-zero factors) is no curvature.\n\t\t\t\t\tif (abs(curv) < 0.001) curv = 0.0;\n\t\t\t\t}\n\n\t\t\t\t// Where there is no curvature the layer says NOTHING: composite\n\t\t\t\t// with weight 0 (the outline layer's pattern) so flat pixels are\n\t\t\t\t// a bit-exact passthrough. Compositing the identity mid-grey at\n\t\t\t\t// full alpha instead perturbs the frame by float ulps\n\t\t\t\t// (1-2(1-b)(1-o) != b exactly), which downstream edge-AA\n\t\t\t\t// amplified into visible silhouette speckles. Mask mode keeps\n\t\t\t\t// the full-coverage grey — the mask IS the color output.\n\t\t\t\t// (\"active\" is a GLSL ES reserved word — hence cavityOn.)\n\t\t\t\tfloat cavityOn = curv != 0.0 ? 1.0 : 0.0;\n\t\t\t\tfloat lalpha = alpha * mask * mix(cavityOn, 1.0, float(isMask));\n\t\t\t\tcalpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));\n\t\t\t\taccumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));\n\n\t\t\t\treturn vec3(clamp(0.5 + 0.5 * curv, 0.0, 1.0));\n\t\t\t}",[e])}}();var bs=function(){let e=new ki("vec3 random3(vec3 c) {\n\t\t\tfloat j = 4096.0*sin(dot(c,vec3(17.0, 59.4, 15.0)));\n\t\t\tvec3 r;\n\t\t\tr.z = fract(512.0*j);\n\t\t\tj *= .125;\n\t\t\tr.x = fract(512.0*j);\n\t\t\tj *= .125;\n\t\t\tr.y = fract(512.0*j);\n\t\t\treturn r-0.5;\n\t\t}"),t=new ki("float simplexFast(vec3 p) {\n\t\t\t vec3 s = floor(p + dot(p, vec3(F3)));\n\t\t\t mediump vec3 x = p - s + dot(s, vec3(G3));\n\t\t\t mediump vec3 hs = s;\n\t\t\t \n\t\t\t mediump vec3 e = step(vec3(0.0), x - x.yzx);\n\t\t\t mediump vec3 i1 = e*(1.0 - e.zxy);\n\t\t\t mediump vec3 i2 = 1.0 - e.zxy*(1.0 - e);\n\t\t\t\t\n\t\t\t mediump vec3 x1 = x - i1 + G3;\n\t\t\t mediump vec3 x2 = x - i2 + 2.0*G3;\n\t\t\t mediump vec3 x3 = x - 1.0 + 3.0*G3;\n\t\t\t \n\t\t\t mediump vec4 w, d;\n\t\t\t \n\t\t\t w.x = dot(x, x);\n\t\t\t w.y = dot(x1, x1);\n\t\t\t w.z = dot(x2, x2);\n\t\t\t w.w = dot(x3, x3);\n\t\t\t \n\t\t\t w = max(0.6 - w, 0.0);\n\t\t\t \n\t\t\t d.x = dot(random3(hs), x);\n\t\t\t d.y = dot(random3(hs + i1), x1);\n\t\t\t d.z = dot(random3(hs + i2), x2);\n\t\t\t d.w = dot(random3(hs + 1.0), x3);\n\t\t\t \n\t\t\t w *= w;\n\t\t\t w *= w;\n\t\t\t d *= w;\n\t\t\t \n\t\t\t return dot(d, vec4(52.0));\n\t\t}",[e]);t.keywords.F3=new ji("float F3 0.3333333"),t.keywords.G3=new ji("float G3 0.1666667");let n=new ki("float simplexPrecise(vec3 p) {\n\t\t\t vec3 s = floor(p + dot(p, vec3(F3)));\n\t\t\t vec3 x = p - s + dot(s, vec3(G3));\n\t\t\t \n\t\t\t vec3 e = step(vec3(0.0), x - x.yzx);\n\t\t\t vec3 i1 = e*(1.0 - e.zxy);\n\t\t\t vec3 i2 = 1.0 - e.zxy*(1.0 - e);\n\t\t\t\t\n\t\t\t vec3 x1 = x - i1 + G3;\n\t\t\t vec3 x2 = x - i2 + 2.0*G3;\n\t\t\t vec3 x3 = x - 1.0 + 3.0*G3;\n\t\t\t \n\t\t\t vec4 w, d;\n\t\t\t \n\t\t\t w.x = dot(x, x);\n\t\t\t w.y = dot(x1, x1);\n\t\t\t w.z = dot(x2, x2);\n\t\t\t w.w = dot(x3, x3);\n\t\t\t \n\t\t\t w = max(0.6 - w, 0.0);\n\t\t\t \n\t\t\t d.x = dot(random3(s), x);\n\t\t\t d.y = dot(random3(s + i1), x1);\n\t\t\t d.z = dot(random3(s + i2), x2);\n\t\t\t d.w = dot(random3(s + 1.0), x3);\n\t\t\t \n\t\t\t w *= w;\n\t\t\t w *= w;\n\t\t\t d *= w;\n\t\t\t \n\t\t\t return dot(d, vec4(52.0));\n\t\t}",[e]);n.keywords.F3=new ji("float F3 0.3333333"),n.keywords.G3=new ji("float G3 0.1666667");let i=new ki("float simplexFractal(vec3 m) {\n\t\t\tmat3 rot1 = mat3(-0.37, 0.36, 0.85,-0.14,-0.93, 0.34,0.92, 0.01,0.4);\n\t\t\tmat3 rot2 = mat3(-0.55,-0.39, 0.74, 0.33,-0.91,-0.24,0.77, 0.12,0.63);\n\t\t\tmat3 rot3 = mat3(-0.71, 0.52,-0.47,-0.08,-0.72,-0.68,-0.7,-0.45,0.56);\n\t\t\treturn 0.5333333 * simplexFast(m * rot1)\n\t\t\t\t + 0.2666667 * simplexFast(2.0 * m * rot2)\n\t\t\t\t + 0.1333333 * simplexFast(4.0 * m * rot3)\n\t\t\t\t + 0.0666667 * simplexFast(8.0 * m);\n\t\t}",[t]),a=new ki("vec4 permute(vec4 x){return mod(((x*34.0)+1.0)*x, 289.0);}"),r=new ki("vec4 taylorInvSqrt(vec4 r){return 1.79284291400159 - 0.85373472095314 * r;}"),o=new ki("float simplexAshima(vec3 v) {\n\t\t const vec2 C = vec2(1.0/6.0, 1.0/3.0) ;\n\t\t const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);\n\t\t vec3 i = floor(v + dot(v, C.yyy) );\n\t\t vec3 x0 = v - i + dot(i, C.xxx) ;\n\t\t vec3 g = step(x0.yzx, x0.xyz);\n\t\t vec3 l = 1.0 - g;\n\t\t vec3 i1 = min( g.xyz, l.zxy );\n\t\t vec3 i2 = max( g.xyz, l.zxy );\n\t\t vec3 x1 = x0 - i1 + 1.0 * C.xxx;\n\t\t vec3 x2 = x0 - i2 + 2.0 * C.xxx;\n\t\t vec3 x3 = x0 - 1. + 3.0 * C.xxx;\n\t\t i = mod(i, 289.0 ); \n\t\t vec4 p = permute( permute( permute( \n\t\t\t\t\t i.z + vec4(0.0, i1.z, i2.z, 1.0 ))\n\t\t\t\t + i.y + vec4(0.0, i1.y, i2.y, 1.0 )) \n\t\t\t\t + i.x + vec4(0.0, i1.x, i2.x, 1.0 ));\n\t\t float n_ = 1.0/7.0; \n\t\t vec3 ns = n_ * D.wyz - D.xzx;\n\t\t vec4 j = p - 49.0 * floor(p * ns.z *ns.z); \n\t\t vec4 x_ = floor(j * ns.z);\n\t\t vec4 y_ = floor(j - 7.0 * x_ ); \n\t\t vec4 x = x_ *ns.x + ns.yyyy;\n\t\t vec4 y = y_ *ns.x + ns.yyyy;\n\t\t vec4 h = 1.0 - abs(x) - abs(y);\n\t\t vec4 b0 = vec4( x.xy, y.xy );\n\t\t vec4 b1 = vec4( x.zw, y.zw );\n\t\t vec4 s0 = floor(b0)*2.0 + 1.0;\n\t\t vec4 s1 = floor(b1)*2.0 + 1.0;\n\t\t vec4 sh = -step(h, vec4(0.0));\n\t\t vec4 a0 = b0.xzyw + s0.xzyw*sh.xxyy ;\n\t\t vec4 a1 = b1.xzyw + s1.xzyw*sh.zzww ;\n\t\t vec3 p0 = vec3(a0.xy,h.x);\n\t\t vec3 p1 = vec3(a0.zw,h.y);\n\t\t vec3 p2 = vec3(a1.xy,h.z);\n\t\t vec3 p3 = vec3(a1.zw,h.w);\n\t\t vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3)));\n\t\t p0 *= norm.x;\n\t\t p1 *= norm.y;\n\t\t p2 *= norm.z;\n\t\t p3 *= norm.w;\n\t\t vec4 m = max(0.6 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0);\n\t\t m = m * m;\n\t\t return 42.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1), \n\t\t\t\t\t\t\t\t\t\tdot(p2,x2), dot(p3,x3) ) );\n\t\t}",[a,r]),s=new ki("vec4 mod289(vec4 x){return x - floor(x * (1.0 / 289.0)) * 289.0;}"),l=new ki("vec4 perm(vec4 x){return mod289(((x * 34.0) + 1.0) * x);}",[s]),c=new ki("float noise(vec3 p){\n\t\t\tvec3 a = floor(p);\n\t\t\tvec3 d = p - a;\n\t\t\td = d * d * (3.0 - 2.0 * d);\n\t\t\tvec4 b = a.xxyy + vec4(0.0, 1.0, 0.0, 1.0);\n\t\t\tvec4 k1 = perm(b.xyxy);\n\t\t\tvec4 k2 = perm(k1.xyxy + b.zzww);\n\t\t\tvec4 c = k2 + a.zzzz;\n\t\t\tvec4 k3 = perm(c);\n\t\t\tvec4 k4 = perm(c + 1.0);\n\t\t\tvec4 o1 = fract(k3 * (1.0 / 41.0));\n\t\t\tvec4 o2 = fract(k4 * (1.0 / 41.0));\n\t\t\tvec4 o3 = o2 * d.z + o1 * (1.0 - d.z);\n\t\t\tvec2 o4 = o3.yw * d.x + o3.xz * (1.0 - d.x);\n\t\t\treturn o4.y * d.y + o4.x * (1.0 - d.y);\n\t\t}",[l]),d=new ki("float fbm(vec3 x) {\n\t\t\tfloat v = 0.0;\n\t\t\tfloat a = 0.5;\n\t\t\tvec3 shift = vec3(100);\n\t\t\tfor (int i = 0; i < NUM_OCTAVES; ++i) {\n\t\t\t\tv += a * noise(x);\n\t\t\t\tx = x * 2.0 + shift;\n\t\t\t\ta *= 0.5;\n\t\t\t}\n\t\t\treturn v;\n\t\t}",[c]);d.keywords.NUM_OCTAVES=new ji("int NUM_OCTAVES 5");let u=new ki("vec3 fade(vec3 t) {return t*t*t*(t*(t*6.0-15.0)+10.0);}"),f=new ki("float perlin(vec3 P){\n\t\t vec3 Pi0 = floor(P);\n\t\t vec3 Pi1 = Pi0 + vec3(1.0);\n\t\t Pi0 = mod(Pi0, 289.0);\n\t\t Pi1 = mod(Pi1, 289.0);\n\t\t vec3 Pf0 = fract(P);\n\t\t vec3 Pf1 = Pf0 - vec3(1.0);\n\t\t vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);\n\t\t vec4 iy = vec4(Pi0.yy, Pi1.yy);\n\t\t vec4 iz0 = Pi0.zzzz;\n\t\t vec4 iz1 = Pi1.zzzz;\n\t\t vec4 ixy = permute(permute(ix) + iy);\n\t\t vec4 ixy0 = permute(ixy + iz0);\n\t\t vec4 ixy1 = permute(ixy + iz1);\n\t\t vec4 gx0 = ixy0 / 7.0;\n\t\t vec4 gy0 = fract(floor(gx0) / 7.0) - 0.5;\n\t\t gx0 = fract(gx0);\n\t\t vec4 gz0 = vec4(0.5) - abs(gx0) - abs(gy0);\n\t\t vec4 sz0 = step(gz0, vec4(0.0));\n\t\t gx0 -= sz0 * (step(0.0, gx0) - 0.5);\n\t\t gy0 -= sz0 * (step(0.0, gy0) - 0.5);\n\t\t vec4 gx1 = ixy1 / 7.0;\n\t\t vec4 gy1 = fract(floor(gx1) / 7.0) - 0.5;\n\t\t gx1 = fract(gx1);\n\t\t vec4 gz1 = vec4(0.5) - abs(gx1) - abs(gy1);\n\t\t vec4 sz1 = step(gz1, vec4(0.0));\n\t\t gx1 -= sz1 * (step(0.0, gx1) - 0.5);\n\t\t gy1 -= sz1 * (step(0.0, gy1) - 0.5);\n\t\t vec3 g000 = vec3(gx0.x,gy0.x,gz0.x);\n\t\t vec3 g100 = vec3(gx0.y,gy0.y,gz0.y);\n\t\t vec3 g010 = vec3(gx0.z,gy0.z,gz0.z);\n\t\t vec3 g110 = vec3(gx0.w,gy0.w,gz0.w);\n\t\t vec3 g001 = vec3(gx1.x,gy1.x,gz1.x);\n\t\t vec3 g101 = vec3(gx1.y,gy1.y,gz1.y);\n\t\t vec3 g011 = vec3(gx1.z,gy1.z,gz1.z);\n\t\t vec3 g111 = vec3(gx1.w,gy1.w,gz1.w);\n\t\t vec4 norm0 = taylorInvSqrt(vec4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110)));\n\t\t g000 *= norm0.x;\n\t\t g010 *= norm0.y;\n\t\t g100 *= norm0.z;\n\t\t g110 *= norm0.w;\n\t\t vec4 norm1 = taylorInvSqrt(vec4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111)));\n\t\t g001 *= norm1.x;\n\t\t g011 *= norm1.y;\n\t\t g101 *= norm1.z;\n\t\t g111 *= norm1.w;\n\t\t float n000 = dot(g000, Pf0);\n\t\t float n100 = dot(g100, vec3(Pf1.x, Pf0.yz));\n\t\t float n010 = dot(g010, vec3(Pf0.x, Pf1.y, Pf0.z));\n\t\t float n110 = dot(g110, vec3(Pf1.xy, Pf0.z));\n\t\t float n001 = dot(g001, vec3(Pf0.xy, Pf1.z));\n\t\t float n101 = dot(g101, vec3(Pf1.x, Pf0.y, Pf1.z));\n\t\t float n011 = dot(g011, vec3(Pf0.x, Pf1.yz));\n\t\t float n111 = dot(g111, Pf1);\n\t\t vec3 fade_xyz = fade(Pf0);\n\t\t vec4 n_z = mix(vec4(n000, n100, n010, n110), vec4(n001, n101, n011, n111), fade_xyz.z);\n\t\t vec2 n_yz = mix(n_z.xy, n_z.zw, fade_xyz.y);\n\t\t float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x); \n\t\t return 2.2 * n_xyz;\n\t\t}",[a,r,u]),p=new ki("float hashwithoutsine13(vec3 p3)\n\t\t{\n\t\t\tp3 = fract(p3 * .1031);\n\t\t\tp3 += dot(p3, p3.yzx + 33.33);\n\t\t\treturn fract((p3.x + p3.y) * p3.z);\n\t\t}"),h=new ki("vec3 hashwithoutsine33(vec3 p3)\n\t\t{\n\t\t\tp3 = fract(p3 * vec3(.1031, .1030, .0973));\n\t\t\tp3 += dot(p3, p3.yxz+33.33);\n\t\t\treturn fract((p3.xxy + p3.yxx)*p3.zyx);\n\t\t}"),m=new ki("float metric(in vec3 p)\n\t\t{\n\t\t\t\n\t\t\treturn length(p);\n\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t}"),v=new ki("float smin( float a, float b, float k )\n\t\t{\n\t\t\tfloat h = smoothstep(0.0, 1.0, 0.5 + 0.5 * (b - a) / k);\n\t\t\tfloat correction = k * h * (1.0 - h);\n\t\t\treturn mix(b, a, h) - correction;\n\t\t}"),g=new ki("float smax( float a, float b, float k )\n\t\t{\n\t\t\tfloat h = smoothstep(1.0, 0.0, 0.5 + 0.5 * (a - b) / k);\n\t\t\tfloat correction = k * h * (1.0 - h);\n\t\t\treturn mix(a, b, h) + correction;\n\t\t}"),_=new ki("float remap(float value, float input_min, float input_max, float output_min, float output_max) {\n\t\t\t// Compute width of each interval\n\t\t\tfloat input_width = input_max - input_min;\n\t\t\tfloat output_width = output_max - output_min;\n\t\t\n\t\t\t// Convert input range into a 0-1 range \n\t\t\tfloat scaled = (value - input_min) / input_width;\n\t\t\n\t\t\t// Convert the 0-1 range into a value in output range\n\t\t\treturn output_min + (scaled * output_width);\n\t\t}");return{simplexFast:t,simplexPrecise:n,simplexFractal:i,simplexAshima:o,fbm:d,perlin:f,voronoi:new ki("float voronoi(in vec3 x, in int style, in float smoothness, in float seed, in int quality) \n\t\t{\n\t\t\t\n\t\t\tivec3 p = ivec3(floor(x));\n\t\t\tvec3 f = fract(x);\n\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\tfloat f1_smooth = 8.0;\n\t\t\tfloat f1 = 8.0;\n\t\t\tfloat f2_smooth = 8.0;\n\t\t\tfloat f2 = 8.0;\n\t\t\tfloat e_smooth = 8.0;\n\t\t\tfloat e = 8.0;\n\n\t\t\t\n\t\t\tivec3 mb;\n\t\t\tvec3 mr; \n\n\t\t\tint steps = quality;\n\t\t\t\n\t\t\tfor (int x = -steps; x <= steps; x++) \n\t\t\tfor (int y = -steps; y <= steps; y++)\n\t\t\tfor (int z = -steps; z <= steps; z++)\n\t\t\t{\n\t\t\t\tivec3 b = ivec3(x, y, z);\n\t\t\t\tvec3 r = vec3(b) + hashwithoutsine33(vec3(p + b) + seed) - f;\n\t\t\t\tfloat d = length(r);\n\t\t\t\t\n\t\t\t\tf1_smooth = smin(d, f1_smooth, smoothness);\n\n\t\t\t\t\n\t\t\t\tif (d < f1) \n\t\t\t\t{\n\t\t\t\t\tf2 = f1;\n\t\t\t\t\tf1 = d;\n\n\t\t\t\t\tmb = ivec3(x, y, z);\n\t\t\t\t\tmr = r;\n\t\t\t\t} \n\t\t\t\telse if (d < f2) \n\t\t\t\t{\n\t\t\t\t\tf2 = d;\n\t\t\t\t}\n\t\t\t}\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\tif (style != 0 && style != 5 && style != 7)\n\t\t\tfor (int x = -steps; x <= steps; x++) \n\t\t\tfor (int y = -steps; y <= steps; y++)\n\t\t\tfor (int z = -steps; z <= steps; z++)\n\t\t\t{\n\t\t\t\t\n\t\t\t\tivec3 b = mb + ivec3(x, y, z);\n\t\t\t\tvec3 r = vec3(b) + hashwithoutsine33(vec3(p + b) + seed) - f;\n\t\t\t\tfloat d1 = dot(0.5 * (mr + r), (r - mr)); \t\t\t\t\n\t\t\t\tfloat d2 = dot(0.5 * (mr + r), normalize(r - mr));\n\n\t\t\t\te_smooth = smin(d1, e_smooth, smoothness);\n\n\t\t\t\te = min(e, d2);\n\n\t\t\t\t\n\t\t\t\t{\n\t\t\t\t\tivec3 b = ivec3(x, y, z);\n\t\t\t\t\tif (b != mb) \n\t\t\t\t\t{\n\t\t\t\t\t\tvec3 r = vec3(b) + hashwithoutsine33(vec3(p + b) + seed) - f;\n\t\t\t\t\t\tfloat d = length(r);\n\n\t\t\t\t\t\tf2_smooth = smin(d, f2_smooth, smoothness);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t\n\t\t\tif (style == 0) \n\t\t\t{\n\t\t\t\treturn f1_smooth;\n\t\t\t}\n\t\t\tif (style == 1) \n\t\t\t{\n\t\t\t\treturn f2_smooth;\n\t\t\t}\n\t\t\tif (style == 2) \n\t\t\t{\n\t\t\t\treturn f2_smooth - f1_smooth;\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t}\n\t\t\tif (style == 3) \n\t\t\t{\n\t\t\t\t\n\t\t\t\tfloat a = f1; \n\t\t\t\tfloat b = f2;\n\t\t\t\tfloat k = 3.0;\n\t\t\t\tfloat h = max(k - abs(a - b), 0.0) / k;\n\t\t\t\tfloat final = min(a, b) - h * h * k * (1.0 / 4.0);\n\t\t\t\treturn final;\n\t\t\t}\n\t\t\tif (style == 4) \n\t\t\t{\n\t\t\t\t\n\t\t\t\treturn exp(5.0 * e_smooth);\n\t\t\t}\n\t\t\tif (style == 5) \n\t\t\t{\n\t\t\t\treturn pow(f1_smooth, 3.0);\n\t\t\t}\n\t\t\tif (style == 6) \n\t\t\t{\t\t\t\t\n\t\t\t\tconst float eps = 0.0125;\n\n\t\t\t\t\n\t\t\t\tfloat thickness = smoothness * 0.25 + eps;\n\n\t\t\t\t\n\t\t\t\tfloat blur = pow(smoothness, 3.0) * 0.25 + eps;\n\n\t\t\t\treturn smoothstep(\n\t\t\t\t\tthickness - thickness * blur, \n\t\t\t\t\tthickness + thickness * blur, \n\t\t\t\t\te\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (style == 7) \n\t\t\t{\n\t\t\t\treturn hashwithoutsine13(vec3(p + mb) + seed);\n\t\t\t}\n\t\t}\n\t",[p,h,m,v,g,_])}}(),ws=class extends Oi{constructor(e,t,n,i,a,r,o){super("v3"),this.nodeType="Dust",this.color=e,this.coverage=t,this.softness=n,this.noiseStrength=i,this.noiseScale=a,this.isMask=o,this.alpha=r,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.require("worldNormal"),e.isShader("fragment")){e.addFragmentVariable(this.calpha,"float");let n=e.include(ws.Nodes.dust),i=[];return i.push(this.color.build(e,"c")),i.push(this.coverage.build(e,"f")),i.push(this.softness.build(e,"f")),i.push(this.noiseStrength.build(e,"f")),i.push(this.noiseScale.build(e,"f")),i.push(this.isMask.build(e,"b")),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(n+"("+i.join(",")+")",this.getType(e),t)}return console.warn("DustNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},Es=ws;Es.Nodes={dust:new ki("vec3 dust(vec3 color, float coverage, float softness, float noiseStrength, float noiseScale, bool isMask, float mask, float alpha, out float calpha) {\n\t\t\t\tfloat facingUp = dot(normalize(vWNormal), vec3(0.0, 1.0, 0.0));\n\n\t\t\t\tfloat breakup = 0.0;\n\t\t\t\tif (noiseStrength != 0.0) {\n\t\t\t\t\tvec3 st = position / noiseScale;\n\t\t\t\t\tfloat noise = simplexFast(st + vec3(1.7, 9.2, 1.0));\n\t\t\t\t\tbreakup = noise * noiseStrength;\n\t\t\t\t}\n\n\t\t\t\tfloat soft = max(softness, 0.0001);\n\t\t\t\tfloat settle = mix(1.0 + soft, -1.0 - soft, clamp(coverage, 0.0, 1.0));\n\t\t\t\tfloat amount = smoothstep(settle - soft, settle + soft, facingUp + breakup);\n\n\t\t\t\tfloat lalpha = amount * alpha * mask;\n\t\t\t\tcalpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));\n\t\t\t\taccumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));\n\n\t\t\t\treturn color;\n\t\t\t }",[bs.simplexFast])};var Ms=class extends Oi{constructor(e,t,n,i,a,r,o,s){super("v3"),this.nodeType="Fresnel",this.color=e,this.bias=t,this.scale=n,this.intensity=i,this.factor=a,this.isMask=s,this.alpha=r,this.mode=o,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.require("vWorldViewDir"),e.require("worldNormal"),e.isShader("fragment")){e.addFragmentVariable(this.calpha,"float");let n=new ki("vec3 fresnel(vec3 color, float bias, float scale, float intensity, float factor, bool isMask, float mask, float alpha, int mode, out float calpha) {\n\t\t\t\t\tfloat fresnel = bias + scale * pow( abs( factor + dot( normalize( vWorldViewDir ), normalize( vWNormal ) ) ), intensity );\n\n\t\t\t\t\tfloat lalpha = clamp(fresnel, 0.0, 1.0) * alpha * mask;\n\t\t\t\t\tcalpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));\n\t\t\t\t\taccumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));\n\n\t\t\t\t\treturn color;\n\t\t\t\t}"),i=e.include(n),a=[];return a.push(this.color.build(e,"c")),a.push(this.bias.build(e,"f")),a.push(this.scale.build(e,"f")),a.push(this.intensity.build(e,"f")),a.push(this.factor.build(e,"f")),a.push(this.isMask.build(e,"b")),a.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),a.push(this.alpha.build(e,"f")),a.push(this.mode.build(e,"i")),a.push(this.calpha),e.format(i+"("+a.join(",")+")",this.getType(e),t)}return console.warn("FresnelNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},ys=class extends Oi{constructor(e,t,n,i,a,r,o,s,l){super("v3"),this.nodeType="Gradient",this.gradientType=e,this.smooth=t,this.colors=n,this.steps=i,this.offset=a,this.morph=r,this.angle=o,this.isMask=l,this.alpha=s,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.isShader("fragment")){e.define("GRAD_MAX",10),e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let n=e.include(ys.Nodes.gradient),i=[];return i.push(this.gradientType.build(e,"i")),i.push(this.smooth.build(e,"b")),i.push(this.colors.build(e,"v4[]")),i.push(this.steps.build(e,"f[]")),i.push(this.offset.build(e,"v2")),i.push(this.morph.build(e,"v2")),i.push(this.angle.build(e,"f")),i.push(this.isMask.build(e,"b")),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(n+"("+i.join(",")+")",this.getType(e),t)}return console.warn("GradientNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},Cs=ys;Cs.Nodes={gradient:new ki("vec3 gradient(int gradientType, bool smoothed, vec4 colors[GRAD_MAX], float steps[GRAD_MAX], vec2 offset, vec2 morph, float angle, bool isMask, float mask, float alpha, out float calpha) {\n\t\t\t\tvec4 color = colors[0];\n\t\t\t\tvec2 m = morph / vUv.xy;\n\t\t\t\tvec2 rot = vec2( 0.5 + m.x, m.y );\n\t\t\t\tvec2 dt = vec2(\n\t\t\t\t\tcos( angle ) * rot.x - sin( angle ) * rot.y,\n\t\t\t\t\tsin( angle ) * rot.x + cos( angle ) * rot.y\n\t\t\t\t);\n\t\t\t\tvec2 pt = ( vUv - 0.5 + offset ) / 2.0 + dt / 2.0;\n\t\t\t\tfloat t = dot( pt, dt ) / dot( dt, dt );\n\t\t\t\tif ( gradientType == 1 ) {\n\t\t\t\t\tt = distance (\n\t\t\t\t\t\t( vUv + morph ) * 3.0,\n\t\t\t\t\t\t( vUv + offset ) + 1.0\n\t\t\t\t\t) + angle;\n\t\t\t\t} else if ( gradientType == 2 ) {\n\t\t\t\t\tfloat polar = atan(\n\t\t\t\t\t\tvUv.x + morph.x - 0.5 + offset.x,\n\t\t\t\t\t\tvUv.y + morph.y - 0.5 + offset.y\n\t\t\t\t\t) * -1.0;\n\t\t\t\t\tt = fract( ( angle / PI / -2.0 ) + 0.5 * ( polar / PI ) );\n\t\t\t\t}\n\n\t\t\t\tfloat p;\n\t\t\t\tif (smoothed) {\n\t\t\t\t\tfor ( int i = 1; i < GRAD_MAX; i++ ) {\n\t\t\t\t\t\tp = clamp( ( t - steps[i-1] ) / ( steps[i] - steps[i-1] ), 0.0, 1.0 );\n\t\t\t\t\t\tcolor = mix(color, colors[i], smoothstep(0.0, 1.0, p));\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\t\t\t\t\tfor ( int i = 1; i < GRAD_MAX; i++ ) {\n\t\t\t\t\t\tp = clamp( ( t - steps[i-1] ) / ( steps[i] - steps[i-1] ), 0.0, 1.0 );\n\t\t\t\t\t\tcolor = mix(color, colors[i], p);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tfloat lalpha = alpha * color.a * mask;\n\t\t\t\tcalpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));\n\t\t\t\taccumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));\n\t\t\t\t\n\t\t\t\treturn color.xyz;\n\t\t\t}")};var Rs=class extends Oi{constructor(e,t,n,i,a){super("v3"),this.nodeType="Matcap",this.texture=e,this.isMask=i,this.alpha=t,this.mode=n,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`,this.rotation=a}generate(e,t){if(e.isShader("fragment")){e.addFragmentVariable(this.calpha,"float");let n=e.include(Rs.Nodes.matcap);e.require("normal"),e.requires.normal=!0;let i=[];return i.push(this.texture.generate(e,"t")),i.push("normal"),i.push(this.isMask.build(e,"b")),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.mode.build(e,"i")),i.push(this.calpha),i.push(this.rotation.build(e,"f")),e.format(n+"("+i.join(",")+")",this.getType(e),t)}return console.warn("MatcapNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},As=Rs;As.Nodes={matcap:new ki("vec3 matcap(sampler2D matcapTex, vec3 normal, bool isMask, float mask, float alpha, int mode, out float calpha, float rotation) {\n\t\t\t\t\tvec3 viewDir = normalize( vViewPosition );\n\t\t\t\t\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\t\t\t\t\tvec3 y = cross( viewDir, x );\n\t\t\t\t\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) );\n\t\t\t\t\tuv = mat2( cos(rotation), sin(rotation), -sin(rotation), cos(rotation) ) * uv;\n\t\t\t\t\tuv = uv * 0.495 + 0.5;\n\t\t\t\t\tvec4 matcapColor = texture2D( matcapTex, uv );\n\n\t\t\t\t\tfloat lalpha = alpha * mask;\n\t\t\t\t\tcalpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));\n\t\t\t\t\taccumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));\n\t\t\t\t\t\n\t\t\t\t\treturn matcapColor.rgb;\n \t}")};var Ps=class extends Oi{constructor(e,t,n,i,a,r,o,s,l,c,d,u,f,p,h,m,v,g,_){super("v3"),this.nodeType="Noise",this.scale=e,this.size=t,this.move=n,this.fA=i,this.fB=a,this.distortion=r,this.colorA=o,this.colorB=s,this.colorC=l,this.colorD=c,this.noiseType=u,this.voronoiStyle=p,this.highCut=h,this.lowCut=m,this.smoothness=v,this.seed=g,this.quality=_,this.isMask=f,this.alpha=d,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t,n,i,a){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let r=["simplexFast","simplexFractal","simplexAshima","fbm","perlin","voronoi"][this.noiseType.value],o=new ki(`vec3 ${r}customNoise(float scale, vec3 size, float move, vec2 fA, vec2 fB, vec2 distortion, vec4 colorA, vec4 colorB, vec4 colorC, vec4 colorD, int voronoiStyle, float highCut, float lowCut, float smoothness, float seed, int quality, bool isMask, float mask, float alpha, out float calpha) \n\t\t\t{\n \n\t\t\t\tscale = max(abs(scale), 0.001);\n\n\t\t\t\tvec3 st = position / size;\n\t\t\t\tst /= scale;\n\n\t\t\t\t${"voronoi"==r?`\n\t\tfloat v = ${r}(st + move, voronoiStyle, smoothness, seed, quality);\n\n\t\t\n\t\tv = remap(v, lowCut, highCut, 0.0, 1.0);\n\t\tv = smax(v, 0.0, smoothness * 0.25);\n\t\tv = smin(v, 1.0, smoothness * 0.25);\n\n\t\t\n\t\tvec4 color = mix(colorA, colorC, v); \n\t\t`:`\n\t\tvec3 q = vec3(${r}(st),\n\t\t\t\t\t ${r}(st + vec3(1.0)),\n\t\t\t\t\t ${r}(st + vec3(1.0)));\n\t\tvec3 r = vec3(${r}(st + vec3(distortion, 1.0) * q + vec3(fA, 1.0) + move),\n\t\t\t\t\t ${r}(st + vec3(distortion, 1.0) * q + vec3(fB, 1.0) + move), \n\t\t\t\t\t ${r}(st * q));\n\t\tfloat f = ${r}(st + r);\n\t\tvec4 color;\n\t\tcolor = mix(colorA, colorB, clamp((f * f) * 4.0, 0.0, 1.0));\n\t\tcolor = mix(color, colorC, clamp(length(q), 0.0, 1.0));\n\t\tcolor = mix(color, colorD, clamp(length(r.x), 0.0, 1.0));\n\t\t`}\n\n\t\t\t\tfloat lalpha = alpha * color.a * mask;\n\t\t\t\tcalpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));\n\t\t\t\taccumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));\n\n\t\t\t\treturn clamp(color, 0.0, 1.0).rgb;\n\t\t\t}`,[bs.simplexFast,bs.simplexFractal,bs.simplexAshima,bs.fbm,bs.perlin,bs.voronoi]),s=e.include(o),l=[];return l.push(this.scale.build(e,"f")),l.push(this.size.build(e,"v3")),l.push(this.move.build(e,"f")),l.push(this.fA.build(e,"v2")),l.push(this.fB.build(e,"v2")),l.push(this.distortion.build(e,"v2")),l.push(this.colorA.build(e,"v4")),l.push(this.colorB.build(e,"v4")),l.push(this.colorC.build(e,"v4")),l.push(this.colorD.build(e,"v4")),l.push(this.voronoiStyle.build(e,"i")),l.push(this.highCut.build(e,"f")),l.push(this.lowCut.build(e,"f")),l.push(this.smoothness.build(e,"f")),l.push(this.seed.build(e,"f")),l.push(this.quality.build(e,"i")),l.push(this.isMask.build(e,"b")),l.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),l.push(this.alpha.build(e,"f")),l.push(this.calpha),e.format(s+"("+l.join(",")+")",this.getType(e),t)}};Ps.numOctaves=5;var Ds=class extends Oi{constructor(e,t,n,i,a,r,o,s,l,c,d,u,f,p,h,m){super("v3"),this.nodeType="Outline",this.firstTime=!0,this.outlineColor=e,this.contourColor=t,this.outlineWidth=n,this.contourWidth=i,this.contourThreshold=a,this.outlineThreshold=r,this.contourFrequency=o,this.outlineSmoothing=s,this.contourDirection=l,this.positionalLines=c,this.compensation=d,this.resolution=u,this.normalMap=f,this.depthMap=p,this.pixelRatio=h,this.alpha=m,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){let n=`g${this.uuid.toString().replace(/-/g,"")}`;if(e.require("vWorldViewDir"),e.require("worldNormal"),e.extensions.derivatives=!0,this.compensation.value&&e.define("OUTLINE_COMPENSATION",`${n}_offset`),this.firstTime){let t=this.outlineWidth.build(e,"f"),i=this.resolution.build(e,"v2"),a=this.compensation.build(e,"b"),r=this.pixelRatio.build(e,"f");e.addVertexParsVariable("randomColor","attribute vec3"),e.addVertexParsVariable("extrudeNormal","attribute vec3"),e.addVertexParsVariable(t,"uniform float"),e.addVertexParsVariable(i,"uniform vec2"),e.addVertexParsVariable(a,"uniform bool"),e.addVertexParsVariable(r,"uniform float"),e.addVertexParsVariable("vID","flat out float"),e.addFragmentParsVariable("vID","flat in float"),e.addVertexFinalCode(`\n vID = randomColor.r;\n vec2 ${n}_offset = vec2(0.0);\n if (${a}) {\n // Instanced draws (cloner instancing): 'transformed' is still\n // instance-local here — three's chunks only apply instanceMatrix\n // inside project_vertex — so apply it by hand like they do.\n vec4 ${n}_localPosition = vec4(transformed, 1.0);\n vec3 ${n}_extrudeNormal = extrudeNormal;\n #ifdef USE_INSTANCING\n ${n}_localPosition = instanceMatrix * ${n}_localPosition;\n ${n}_extrudeNormal = mat3(instanceMatrix) * ${n}_extrudeNormal;\n #endif\n vec4 ${n}_clipPosition = projectionMatrix * (modelViewMatrix * ${n}_localPosition);\n \n \n \n vec3 ${n}_clipNormal = mat3(projectionMatrix) * (mat3(modelViewMatrix) * ${n}_extrudeNormal) + 0.0000001;\n ${n}_offset = normalize(${n}_clipNormal.xy) / ${i} * (${t} / 2.0) * ${n}_clipPosition.w * 2.0 * ${r};\n ${n}_clipPosition.xy += ${n}_offset;\n \n \n gl_Position = ${n}_clipPosition;\n }\n `)}if(e.isShader("fragment")){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let n=e.include(Ds.Nodes.outline),i=[];return i.push(this.outlineColor.build(e,"c")),i.push(this.contourColor.build(e,"c")),i.push(this.outlineWidth.build(e,"f")),i.push(this.contourWidth.build(e,"f")),i.push(this.contourThreshold.build(e,"f")),i.push(this.outlineThreshold.build(e,"f")),i.push(this.contourFrequency.build(e,"f")),i.push(this.outlineSmoothing.build(e,"f")),i.push(this.contourDirection.build(e,"v3")),i.push(this.positionalLines.build(e,"b")),i.push(this.resolution.build(e,"v2")),i.push(this.normalMap.getTexture(e,"t")),i.push(this.depthMap.getTexture(e,"t")),i.push(this.pixelRatio.build(e,"f")),i.push(this.compensation.build(e,"b")),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),this.firstTime=!this.firstTime,e.format(n+"("+i.join(",")+")",this.getType(e),t)}return console.warn("OutlineNode is not compatible with "+e.shader+" shader."),""}},Ls=Ds;Ls.Nodes=function(){let e=new ki("\nfloat sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outlineWidth, float pixelRatio)\n{\n vec2 halton = haltonSequence[frameIndex];\n float temporalOffset = getNoiseInterleavedGradient(gl_FragCoord.xy + halton);\n float temporalAngle = temporalOffset * PI2;\n\n vec2 texelSize = (vec2(1.0) / resolution);\n vec2 offsetSize = texelSize * outlineWidth * pixelRatio;\n\n vec2 uvSamples[9];\n vec4 normalSamples[9];\n\n\tuvSamples[0] = uv + vec2( -offsetSize.x, -offsetSize.y) + (vogelDiskSample(0, 9, temporalAngle) * texelSize);\n\tuvSamples[1] = uv + vec2(0.0, -offsetSize.y) + (vogelDiskSample(1, 9, temporalAngle) * texelSize);\n\tuvSamples[2] = uv + vec2( offsetSize.x, -offsetSize.y) + (vogelDiskSample(2, 9, temporalAngle) * texelSize);\n\tuvSamples[3] = uv + vec2( -offsetSize.x, 0.0) + (vogelDiskSample(3, 9, temporalAngle) * texelSize);\n\tuvSamples[4] = uv;\n\tuvSamples[5] = uv + vec2( offsetSize.x, 0.0) + (vogelDiskSample(5, 9, temporalAngle) * texelSize);\n\tuvSamples[6] = uv + vec2( -offsetSize.x, offsetSize.y) + (vogelDiskSample(6, 9, temporalAngle) * texelSize);\n\tuvSamples[7] = uv + vec2(0.0, offsetSize.y) + (vogelDiskSample(7, 9, temporalAngle) * texelSize);\n\tuvSamples[8] = uv + vec2( offsetSize.x, offsetSize.y) + (vogelDiskSample(8, 9, temporalAngle) * texelSize);\n\n\n normalSamples[0] = texture2D(t, uvSamples[0]);\n normalSamples[1] = texture2D(t, uvSamples[1]);\n normalSamples[2] = texture2D(t, uvSamples[2]);\n normalSamples[3] = texture2D(t, uvSamples[3]);\n normalSamples[4] = texture2D(t, uvSamples[4]);\n normalSamples[5] = texture2D(t, uvSamples[5]);\n normalSamples[6] = texture2D(t, uvSamples[6]);\n normalSamples[7] = texture2D(t, uvSamples[7]);\n normalSamples[8] = texture2D(t, uvSamples[8]);\n\n float depthBias = 0.0001;\n \n if (normalSamples[0].a != vID && normalSamples[0].a != 0.0) {\n float depthAtSample = texture2D(d, uvSamples[0]).r + depthBias;\n if (gl_FragCoord.z > depthAtSample) {\n return 0.0;\n }\n }\n\n if (normalSamples[1].a != vID && normalSamples[1].a != 0.0) {\n float depthAtSample = texture2D(d, uvSamples[1]).r + depthBias;\n if (gl_FragCoord.z > depthAtSample) {\n return 0.0;\n }\n }\n\n if (normalSamples[2].a != vID && normalSamples[2].a != 0.0) {\n float depthAtSample = texture2D(d, uvSamples[2]).r + depthBias;\n if (gl_FragCoord.z > depthAtSample) {\n return 0.0;\n }\n }\n\n if (normalSamples[3].a != vID && normalSamples[3].a != 0.0) {\n float depthAtSample = texture2D(d, uvSamples[3]).r + depthBias;\n if (gl_FragCoord.z > depthAtSample) {\n return 0.0;\n }\n }\n\n\n if (normalSamples[4].a != vID && normalSamples[4].a != 0.0) {\n float depthAtSample = texture2D(d, uvSamples[4]).r + depthBias;\n if (gl_FragCoord.z > depthAtSample) {\n return 0.0;\n }\n }\n\n if (normalSamples[5].a != vID && normalSamples[5].a != 0.0) {\n float depthAtSample = texture2D(d, uvSamples[5]).r + depthBias;\n if (gl_FragCoord.z > depthAtSample) {\n return 0.0;\n }\n }\n\n if (normalSamples[6].a != vID && normalSamples[6].a != 0.0) {\n float depthAtSample = texture2D(d, uvSamples[6]).r + depthBias;\n if (gl_FragCoord.z > depthAtSample) {\n return 0.0;\n }\n }\n\n if (normalSamples[7].a != vID && normalSamples[7].a != 0.0) {\n float depthAtSample = texture2D(d, uvSamples[7]).r + depthBias;\n if (gl_FragCoord.z > depthAtSample) {\n return 0.0;\n }\n }\n\n if (normalSamples[8].a != vID && normalSamples[8].a != 0.0) {\n float depthAtSample = texture2D(d, uvSamples[8]).r + depthBias;\n if (gl_FragCoord.z > depthAtSample) {\n return 0.0;\n }\n }\n\n vec3 sobel_edge_h = normalSamples[2].rgb + (2.0*normalSamples[5].rgb) + normalSamples[8].rgb - (normalSamples[0].rgb + (2.0*normalSamples[3].rgb) + normalSamples[6].rgb);\n \tvec3 sobel_edge_v = normalSamples[0].rgb + (2.0*normalSamples[1].rgb) + normalSamples[2].rgb - (normalSamples[6].rgb + (2.0*normalSamples[7].rgb) + normalSamples[8].rgb);\n\n float edgeNormal = sqrt(dot(sobel_edge_h, sobel_edge_h) + dot(sobel_edge_v, sobel_edge_v));\n return edgeNormal;\n}\n");return{outline:new ki("vec3 outline(vec3 outlineColor, vec3 contourColor, float outlineWidth, float contourWidth, float outlineThreshold, float contourThreshold, float outlineSmoothing, float contourFrequency, vec3 contourDirection, bool positionalLines, vec2 resolution, sampler2D normalMap, sampler2D depthMap, float pixelRatio, bool compensation, float mask, float alpha, out float calpha) {\n vec3 result = outlineColor;\n float resultAlpha = 0.0;\n\n vec3 N = normalize(vWNormal);\n vec2 nuv = (gl_FragCoord.xy / resolution);\n float sobelSample = compensation ? sobelSample(normalMap, depthMap, nuv, resolution, outlineWidth / 2., pixelRatio) : sobelSample(normalMap, depthMap, nuv, resolution, outlineWidth, pixelRatio);\n resultAlpha = smoothstep(outlineThreshold - outlineSmoothing, outlineThreshold + outlineSmoothing, sobelSample);\n\n \n \n\n float t = 1.0 - contourThreshold;\n if(positionalLines) {\n vec3 NDir = position * contourDirection;\n float NT = NDir.x + NDir.y + NDir.z;\n float f = fract(NT * contourFrequency * 0.01);\n float df = fwidth(NT * contourFrequency);\n\n float g = smoothstep(df * (contourWidth * 0.01), df * (contourWidth * 0.01 * 2.0), f);\n if (g < 1.0 && resultAlpha == 0.0) {\n result = contourColor;\n resultAlpha = 1.0;\n }\n }\n else {\n vec3 NDir = N * contourDirection;\n float NT = NDir.x + NDir.y + NDir.z;\n float df = fwidth(NT * contourThreshold);\n float f = sin(NT * 1.0 * contourFrequency);\n float g = smoothstep(0.0, df * contourWidth, 1.0 - f);\n\n if (df > (t * 0.5) && g < 1.0 && resultAlpha == 0.0) {\n result = contourColor;\n resultAlpha = 1.0 - g;\n }\n }\n\n float lalpha = alpha * resultAlpha * mask;\n calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );\n accumAlpha += ( 1.0 - accumAlpha ) * lalpha;\n\t\t\t\t \n return result;\n }",[e])}}();var Us=class extends Oi{constructor(e,t,n,i,a,r,o,s,l,c,d,u,f,p,h,m,v,g){super("v3"),this.nodeType="Pattern",this.style=e,this.projection=t,this.axis=n,this.blending=i,this.offset=a,this.colorA=r,this.colorB=o,this.frequency=s,this.size=l,this.variation=c,this.smoothness=d,this.zigzag=u,this.rotation=f,this.vertical=p,this.horizontal=h,this.sides=m,this.isMask=g,this.alpha=v,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.isShader("fragment")){let n;switch(e.require("position"),e.require("uv"),e.requires.uv=[!0],e.require("normal"),e.requires.normal=!0,e.addFragmentVariable(this.calpha,"float"),this.style.value){case 0:default:n="circle";break;case 1:n="ring";break;case 2:n="polygon";break;case 3:n="xcross";break;case 4:n="diamond";break;case 5:n="checkerboard";break;case 6:n="line";break;case 7:n="wave"}let i=`g${this.uuid.toString().replace(/-/g,"")}`,a=new ki("float hashwithoutsine12(vec2 p)\n\t\t\t\t{\n\t\t\t\t\tvec3 p3 = fract(vec3(p.xyx) * .1031);\n\t\t\t\t\tp3 += dot(p3, p3.yzx + 33.33);\n\t\t\t\t\treturn fract((p3.x + p3.y) * p3.z);\n\t\t\t\t}"),r=new ki("vec2 rotate_uv(in vec2 uv, float a, bool repeat) \n\t\t\t\t{\n\t\t\t\t\tconst float mid = 0.5;\n\t\t\t\t\tfloat radians = a * (PI / 180.0);\n\t\t\t\t\tvec2 rotated = vec2(\n\t\t\t\t\t\tcos(radians) * (uv.x - mid) + sin(radians) * (uv.y - mid) + mid,\n\t\t\t\t\t\tcos(radians) * (uv.y - mid) - sin(radians) * (uv.x - mid) + mid\n\t\t\t\t\t);\n\t\t\t\t\treturn repeat ? fract(rotated): rotated;\n\t\t\t\t}"),o="";if(4===this.projection.value)o=`\n\t\t\t\tvec3 p = position;\n\t\t\t\tfloat factor = 0.0125;\n\t\t\t\tvec2 uv0 = fract(p.xy * factor);\n\t\t\t\tvec2 uv1 = fract(p.zy * factor);\n\t\t\t\tvec2 uv2 = fract(p.xz * factor);\n\t\t\t\t\n\t\t\t\tuv0 = rotate_uv(uv0 + offset, rotation, true);\n\t\t\t\tuv1 = rotate_uv(uv1 + offset, rotation, true);\n\t\t\t\tuv2 = rotate_uv(uv2 + offset, rotation, true);\n\t\n\t\t\t\tfloat d0 = ${2===this.style.value?`${n}(uv0, frequency, size, variation, smoothness_remapped, zigzag, rotation, sides)`:`${n}(uv0, frequency, size, variation, smoothness_remapped, zigzag, rotation)`};\n\t\t\t\tfloat d1 = ${2===this.style.value?`${n}(uv1, frequency, size, variation, smoothness_remapped, zigzag, rotation, sides)`:`${n}(uv1, frequency, size, variation, smoothness_remapped, zigzag, rotation)`};\n\t\t\t\tfloat d2 = ${2===this.style.value?`${n}(uv2, frequency, size, variation, smoothness_remapped, zigzag, rotation, sides)`:`${n}(uv2, frequency, size, variation, smoothness_remapped, zigzag, rotation)`};\n\t\t\t\t\n\t\t\t\t\n\t\t\t\tfloat exponent = (1.0 - blending) * 125.0 + 3.0;\n\n\t\t\t\tvec3 n = vObjectNormal;\n\t\t\t\tvec3 weights = abs(normalize(n));\n\t\t\t\tweights = pow(weights, vec3(exponent));\n\t\t\t\tweights /= dot(weights, vec3(1.0));\n\t\t\t\td0 *= weights.z;\n\t\t\t\td1 *= weights.x;\n\t\t\t\td2 *= weights.y;\n\t\t\t\tfloat draw = d0 + d1 + d2;\n\t\n\t\t\t\tvec2 custom_uv = uv0 * weights.z + uv1 * weights.x + uv2 * weights.y;\n\t\t\t\t`;else{let e=2===this.style.value?`${n}(custom_uv, frequency, size, variation, smoothness_remapped, zigzag, rotation, sides)`:`${n}(custom_uv, frequency, size, variation, smoothness_remapped, zigzag, rotation)`,t="";0===this.axis.value?t="float radius = length(p);\n\t\t\t\t\tfloat theta = atan(p.y, p.z);\n\t\t\t\t\tfloat phi = acos(p.x / radius);":1===this.axis.value?t="float radius = length(p);\n\t\t\t\t\tfloat theta = atan(p.x, p.z);\n\t\t\t\t\tfloat phi = acos(p.y / radius);":(this.axis.value,t="float radius = length(p);\n\t\t\t\t\tfloat theta = atan(p.y, p.x);\n\t\t\t\t\tfloat phi = acos(p.z / radius);");let i="";switch(this.projection.value){case 0:i="custom_uv = vUv.st;";break;case 1:case 3:default:break;case 2:i=`\n\t\t\t\t\t\t\tvec3 p = position;\n\t\t\t\t\t\t\t${t}\n\t\t\t\t\t\t\tcustom_uv = vec2(theta, phi);\n\t\t\t\t\t\t\tcustom_uv /= PI;\n\t\t\t\t\t\t\t`}o=`\n\t\t\t\tvec2 custom_uv;\n\t\t\t\t${i}\n\t\n\t\t\t\tcustom_uv += offset;\n\t\t\t\tcustom_uv = fract(custom_uv);\n\t\t\t\tcustom_uv = rotate_uv(custom_uv, rotation, true);\n\t\n\t\t\t\tfloat draw = ${e};\n\t\t\t\t`}let s=new ki(`vec3 ${i}_pattern(vec3 normal, float blending, int style, vec2 offset, vec4 colorA, vec4 colorB, vec2 frequency, float size, float variation, float smoothness, float zigzag, float rotation, vec2 vertical, vec2 horizontal, int sides, bool isMask, float mask, float alpha, out float calpha) {\n\t\t\t\t\tconst float TWO_PI = PI * 2.0;\n\t\t\t\t\tfloat smoothness_remapped = pow(smoothness, 5.0);\t\n\n\t\t\t\t\t${o}\n\n\t\t\t\t\t\n\t\t\t\t\tvec4 color = mix(colorA, colorB, draw);\n\t\t\t\t\tcolor.a = clamp(color.a, 0.0, 1.0);\n\n\t\t\t\t\t\n\t\t\t\t\tcolor.a *= \n\t\t\t\t\t\tstep(vertical.x, custom_uv.y) * \n\t\t\t\t\t\tstep(custom_uv.y, vertical.y);\n\t\t\t\t\tcolor.a *= \n\t\t\t\t\t\tstep(horizontal.x, abs(custom_uv.x)) * \n\t\t\t\t\t\tstep(abs(custom_uv.x), horizontal.y);\n\n\t\t\t\t\t\n\t\t\t\t\tfloat lalpha = alpha * clamp(color.a, 0.0, 1.0) * mask;\n\t\t\t\t\tcalpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));\n\t\t\t\t\taccumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));\n\n\t\t\t\t\treturn clamp(color, 0.0, 1.0).rgb;\n\t\t\t\t}`,[r,a,Us.DrawFunctions.circle,Us.DrawFunctions.ring,Us.DrawFunctions.polygon,Us.DrawFunctions.cross,Us.DrawFunctions.diamond,Us.DrawFunctions.checkerboard,Us.DrawFunctions.line,Us.DrawFunctions.wave]),l=e.include(s),c=[];return c.push("normal"),c.push(this.blending.build(e,"f")),c.push(this.style.build(e,"i")),c.push(this.offset.build(e,"v2")),c.push(this.colorA.build(e,"v4")),c.push(this.colorB.build(e,"v4")),c.push(this.frequency.build(e,"v2")),c.push(this.size.build(e,"f")),c.push(this.variation.build(e,"f")),c.push(this.smoothness.build(e,"f")),c.push(this.zigzag.build(e,"f")),c.push(this.rotation.build(e,"f")),c.push(this.vertical.build(e,"v2")),c.push(this.horizontal.build(e,"v2")),c.push(this.sides.build(e,"i")),c.push(this.isMask.build(e,"b")),c.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),c.push(this.alpha.build(e,"f")),c.push(this.calpha),e.format(l+"("+c.join(",")+")",this.getType(e),t)}return console.warn("PatterNode is not compatible with "+e.shader+" shader."),e.format("vec3(0.0)",this.getType(e),t)}},Ns=Us;Ns.DrawFunctions=function(){let e=new ki("float hashwithoutsine12(vec2 p) {\n\t\t\t\tvec3 p3 = fract(vec3(p.xyx) * 0.1031);\n\t\t\t\tp3 += dot(p3, p3.yzx + 33.33);\n\t\t\t\treturn fract((p3.x + p3.y) * p3.z);\n\t\t\t}"),t=new ki("vec2 tile_and_center(in vec2 uv, in vec2 frequency, in float variation, in float zigzag, in float rotation) {\n \n uv *= frequency;\n\n \n vec2 i = floor(uv);\n\n \n float row_offset = mod(i.y, 2.0);\n uv.x += row_offset * zigzag;\n vec2 f = fract(uv);\n\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\n f = f * 2.0 - 1.0;\n\n\t\t\t\t\n\t\t\t\ti = floor(uv);\n\t\t\t\tfloat rand = (hashwithoutsine12(i) * 5.0 + 1.0);\n\t\t\t\tfloat jitter = mix(1.0, rand, variation);\n\t\t\t\tf *= jitter;\n\n return f;\n }",[e]);return{tileAndCenter:t,circle:new ki("float circle(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {\n vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation);\n return smoothstep(\n -smoothness, \n smoothness, \n length(f) - size\n );\n }",[t]),ring:new ki("float ring(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {\n vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation);\n\n\t\t\t\tfloat d = length(f);\n const float inner_width = 0.5;\n\n float outer = smoothstep(-smoothness, smoothness, d - size);\n float inner = smoothstep(-smoothness, smoothness, d - size * inner_width);\n\t\t\t\treturn outer + (1.0 - inner); \n }",[t]),polygon:new ki("float sdf_ngon(in vec2 p, in float r, in int n) {\n float an = (PI * 2.0) / float(n);\n float he = r * tan(0.5 * an);\n \n \n p = -p.yx; \n float bn = an * floor((atan(p.y, p.x) + 0.5 * an) / an);\n vec2 cs = vec2(cos(bn), sin(bn));\n p = mat2(cs.x, -cs.y, cs.y, cs.x)*p;\n \n \n return length(p - vec2(r, clamp(p.y, -he, he))) * sign(p.x - r);\n }\n \n float polygon(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation, in int sides) {\n vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation);\n return smoothstep(-smoothness, smoothness, sdf_ngon(f, size, sides));\n }",[t]),cross:new ki("float sdf_cross(in vec2 p, in vec2 b, float r ) {\n p = abs(p); \n\t\t\t\tp = (p.y > p.x) ? p.yx : p.xy;\n vec2 q = p - b;\n float k = max(q.y, q.x);\n vec2 w = (k > 0.0) ? q : vec2(b.y - p.x, -k);\n return sign(k) * length(max(w, 0.0)) + r;\n }\n \n \n float xcross(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {\n vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation);\n return smoothstep(-smoothness, smoothness, sdf_cross(f, vec2(size, size * 0.25), smoothness));\n }",[t]),diamond:new ki("float ndot(vec2 a, vec2 b) { \n return a.x*b.x - a.y*b.y; \n }\n \n float sdf_diamond(in vec2 p, in vec2 b) {\n p = abs(p);\n float h = clamp(ndot(b - 2.0 * p, b) / dot(b, b), -1.0, 1.0);\n float d = length(p - 0.5 * b * vec2(1.0 - h, 1.0 + h));\n return d * sign(p.x * b.y + p.y * b.x - b.x * b.y);\n }\n\n float diamond(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {\n vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation);\n\t return smoothstep(-smoothness, smoothness, sdf_diamond(f, vec2(size)));\n }",[t]),checkerboard:new ki("float checkerboard(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {\n uv *= frequency;\n vec2 i = floor(uv);\n\n float offset = mod(i.y, 2.0);\n\n uv.x += offset + zigzag * offset;\n float x = floor(uv.x);\n \n return mod(x, 2.0);\n }"),line:new ki("float line(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {\n vec2 f = tile_and_center(uv, frequency, 0.0, zigzag, rotation);\n\t\t\t\t\n\t\t\t\t\n\t\t\t\tfloat row = floor(uv * frequency).y;\n\t\t\t\tfloat rand = hashwithoutsine12(vec2(row));\n\t\t\t\tfloat s = mix(size, size * rand, variation);\n\n\t\t\t\treturn smoothstep(\n\t\t\t\t\ts - smoothness, \n\t\t\t\t\ts + smoothness, \n\t\t\t\t\tabs(f.y)\n\t\t\t\t);\n }",[t]),wave:new ki("\n float udf_cos(in vec2 p, in float a, in float b, in float c, in float d) {\n \n p = c * (p - vec2(d, a));\n \n const float TWO_PI = PI * 2.0;\n\n \n p.x = mod(p.x, TWO_PI); \n if (p.x > PI) {\n p.x = TWO_PI - p.x;\n }\n \n \n float xa = 0.0;\n float xb = TWO_PI;\n\n \n for (int i = 0; i < 24; i++) {\n float x = 0.5 * (xa + xb);\n float y = x - p.x + b * c * sin(x) * (p.y - b * c * cos(x));\n if (y < 0.0) xa = x; \n else xb = x;\n }\n float x = 0.5 * (xa + xb);\n \n \n vec2 q = vec2(x, b * c * cos(x));\n return length(p - q) / c;\n }\n\n float wave(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {\n float repeat = frequency.x;\n uv *= repeat;\n vec2 i = floor(uv);\n float row_offset = mod(i.y, 2.0);\n uv.x += row_offset * zigzag;\n vec2 f = vec2(uv.x, fract(uv.y));\n\n \n const float amplitude = 0.125;\n float wave_frequency = frequency.y * 0.1;\n float distance_estimate = udf_cos(f, 0.50, amplitude, wave_frequency * (2.0 * PI), 0.0);\n\n\t\t\t\t\n\t\t\t\tfloat rand = hashwithoutsine12(vec2(i.y));\n\t\t\t\tfloat s = mix(size, size * rand, variation);\n\n return smoothstep(-smoothness, smoothness, distance_estimate - s * 0.5);\n }")}}();var Is=class extends Oi{constructor(e,t,n,i,a,r,o,s,l=!0){super("v3"),this.nodeType="Rainbow",this.filmThickness=e,this.movement=t,this.wavelengths=n,this.noiseStrength=i,this.noiseScale=a,this.offset=r,this.isMask=s,this.alpha=o,this.noiseEnabled=l,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.require("vWorldViewDir"),e.require("worldNormal"),e.isShader("fragment")){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let n=e.include(this.noiseEnabled?Is.Nodes.rainbow:Is.Nodes.rainbowNN),i=[];return i.push(this.filmThickness.build(e,"f")),i.push(this.movement.build(e,"f")),i.push(this.wavelengths.build(e,"v3")),i.push(this.noiseStrength.build(e,"f")),i.push(this.noiseScale.build(e,"f")),i.push(this.offset.build(e,"v3")),i.push(this.isMask.build(e,"b")),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(n+"("+i.join(",")+")",this.getType(e),t)}return console.warn("RainbowNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},Os=Is;Os.Nodes=function(){let e=new ki("vec3 attenuation(vec3 wavelengths, float filmThickness, float movement, float noiseStrength, float noiseScale, vec3 offset) {\n\t\t\t\tfloat f = 0.0;\n\n\t\t\t\tif (noiseStrength != 0.0) {\n\t\t\t\t\tvec3 st = position / noiseScale;\n\t\t\t\t\tfloat noise = simplexFast(1.6 * st + vec3(1.8, 1.5, 1.9) * simplexFast(st) + vec3(1.7, 9.2, 1.0));\n\t\t\t\t\tf = noise * noiseStrength;\n\t\t\t\t}\n\n\t\t\t\tvec3 waves = wavelengths * vec3(1.0, 0.8, 0.6) + 1.0;\n\t\t\t\tfloat angle = dot(normalize(vWorldViewDir + (offset * -0.001)), normalize(vWNormal));\n\n\t\t\t\tmediump vec3 color = cos((((filmThickness + f) / waves) * angle) + movement);\n\t\t\t\treturn .5 + .5 * color;\n\t\t\t }",[bs.simplexFast]),t=new ki("vec3 rainbow(float filmThickness, float movement, vec3 wavelengths, float noiseStrength, float noiseScale, vec3 offset, bool isMask, float mask, float alpha, out float calpha) {\n\t\t\t\tmediump vec3 res = clamp(attenuation(wavelengths, filmThickness, movement, noiseStrength, noiseScale, offset), 0.0, 2.0);\n\n\t\t\t\tfloat rainbowContribution = clamp(res.r + res.g + res.b, 0.0, 1.0);\n\n\t\t\t\tfloat lalpha = alpha * rainbowContribution * mask;\n\t\t\t\tcalpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));\n\t\t\t\taccumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));\n\n\t\t\t\treturn res;\n\t\t\t }",[e]),n=new ki("vec3 attenuationNN(vec3 wavelengths, float filmThickness, float movement, float noiseStrength, float noiseScale, vec3 offset) {\n\t\t\t\tvec3 waves = wavelengths * vec3(1.0, 0.8, 0.6) + 1.0;\n\t\t\t\tfloat angle = dot(normalize(vWorldViewDir + (offset * -0.001)), normalize(vWNormal));\n\n\t\t\t\tmediump vec3 color = cos(((filmThickness / waves) * angle) + movement);\n\t\t\t\treturn .5 + .5 * color;\n\t\t\t }");return{rainbow:t,rainbowNN:new ki("vec3 rainbowNN(float filmThickness, float movement, vec3 wavelengths, float noiseStrength, float noiseScale, vec3 offset, bool isMask, float mask, float alpha, out float calpha) {\n\t\t\t\tmediump vec3 res = clamp(attenuationNN(wavelengths, filmThickness, movement, noiseStrength, noiseScale, offset), 0.0, 2.0);\n\n\t\t\t\tfloat rainbowContribution = clamp(res.r + res.g + res.b, 0.0, 1.0);\n\n\t\t\t\tfloat lalpha = alpha * rainbowContribution * mask;\n\t\t\t\tcalpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));\n\t\t\t\taccumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));\n\n\t\t\t\treturn res;\n\t\t\t }",[n])}}();var Fs=class extends Oi{constructor(e,t,n,i,a,r,o,s,l,c){super("v3"),this.nodeType="Toon",this.positioning=e,this.colors=t,this.steps=n,this.source=i,this.isWorldSpace=a,this.noiseStrength=r,this.noiseScale=o,this.shadowColor=s,this.offset=l,this.alpha=c,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.require("worldNormal"),e.require("worldPosition"),e.isShader("fragment")){e.define("COLORS_MAX",10),e.addFragmentVariable(this.calpha,"float");let n=e.include(Fs.Nodes.toon),i=[];return i.push(this.positioning.build(e,"i")),i.push(this.colors.build(e,"v4[]")),i.push(this.steps.build(e,"f[]")),i.push(this.source.build(e,"v3")),i.push(this.isWorldSpace.build(e,"b")),i.push(this.noiseStrength.build(e,"f")),i.push(this.noiseScale.build(e,"f")),i.push(this.shadowColor.build(e,"v4")),i.push(this.offset.build(e,"v3")),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(n+"("+i.join(",")+")",this.getType(e),t)}return console.warn("ToonNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},zs=Fs;zs.Nodes=function(){let e=new ki("float rand(float n) {\n\t\t\t\treturn fract(sin(n) * 43758.5453123);\n\t\t\t}"),t=new ki("float hash1(float p) { \n\t\t\t\tp = fract(p * 0.011); \n\t\t\t\tp *= p + 7.5; \n\t\t\t\tp *= p + p; \n\t\t\t\treturn fract(p); \n\t\t\t}"),n=new ki("float valueNoise(vec3 x) {\n\t\t\t\tconst vec3 step = vec3(110, 241, 171);\n\t\t\t\n\t\t\t\tvec3 i = floor(x);\n\t\t\t\tvec3 f = fract(x);\n\t\t\t \n\t\t\t\t\n\t\t\t\t\n\t\t\t\tfloat n = dot(i, step);\n\t\t\t\n\t\t\t\tvec3 u = f * f * (3.0 - 2.0 * f);\n\t\t\t\treturn mix(mix(mix( hash1(n + dot(step, vec3(0, 0, 0))), hash1(n + dot(step, vec3(1, 0, 0))), u.x),\n\t\t\t\t\t\t\t mix( hash1(n + dot(step, vec3(0, 1, 0))), hash1(n + dot(step, vec3(1, 1, 0))), u.x), u.y),\n\t\t\t\t\t\t mix(mix( hash1(n + dot(step, vec3(0, 0, 1))), hash1(n + dot(step, vec3(1, 0, 1))), u.x),\n\t\t\t\t\t\t\t mix( hash1(n + dot(step, vec3(0, 1, 1))), hash1(n + dot(step, vec3(1, 1, 1))), u.x), u.y), u.z);\n\t\t\t}",[t]),i=new ki("vec3 hash3(vec3 x) {\n\t\t\t\tx = vec3(dot(x,vec3(127.1, 311.7, 74.7)),\n\t\t\t\t\t\t dot(x,vec3(269.5, 183.3, 246.1)),\n\t\t\t\t\t\t dot(x,vec3(113.5, 271.9, 124.6)));\n\t\t\t\n\t\t\t\treturn fract(sin(x)*43758.5453123);\n\t\t\t}"),a=new ki("vec3 voronoiNoise(in vec3 x)\n\t\t\t{\n\t\t\t\tvec3 p = floor(x);\n\t\t\t\tvec3 f = fract(x);\n\n\t\t\t\tfloat id = 0.0;\n\t\t\t\tvec2 res = vec2(100.0);\n\n\t\t\t\tfor(int k=-1; k<=1; k++)\n\t\t\t\tfor(int j=-1; j<=1; j++)\n\t\t\t\tfor(int i=-1; i<=1; i++)\n\t\t\t\t{\n\t\t\t\t\tvec3 b = vec3(float(i), float(j), float(k));\n\n\t\t\t\t\t\n\t\t\t\t\tvec3 r = vec3(b) - f + hash3(p + b);\n\t\t\t\t\tfloat d = dot(r, r);\n\n\t\t\t\t\tif (d < res.x)\n\t\t\t\t\t{\n\t\t\t\t\t\tid = dot(p + b, vec3(1.0, 57.0, 113.0));\n\t\t\t\t\t\tres = vec2(d, res.x);\t\t\t\n\t\t\t\t\t}\n\t\t\t\t\telse if (d < res.y)\n\t\t\t\t\t{\n\t\t\t\t\t\tres.y = d;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn vec3(sqrt(res), abs(id));\n\t\t\t}\n\t\t\t",[i]);return{toon:new ki("vec3 toon(int positioning, vec4 colors[COLORS_MAX], float steps[COLORS_MAX], vec3 source, bool isWorldSpace, float noiseStrength, float noiseScale, vec4 shadowColor, vec3 offset, float mask, float alpha, out float calpha) {\n\t\t\t\tfloat t = 0.0;\n\t\t\t\tfloat shadow = 1.0;\n\n\t\t\t\tif (positioning == 0) {\n\n\t\t\t\t\t\n\t\t\t\t\t#if (defined(PHONG) || defined(LAMBERT) || defined(STANDARD))\n\n\t\t\t\t\t\t\n\t\t\t\t\t\tconst vec3 weights = vec3(0.2125, 0.7154, 0.0721);\n\t\t\t\t\t\tvec3 lpos;\n\t\t\t\t\t\tvec3 l;\n\t\t\t\t\t\tfloat dproduct;\n\n\t\t\t\t\t\t#if (NUM_POINT_LIGHTS > 0)\n\n\t\t\t\t\t\t\t#if defined(USE_SHADOWMAP) && (NUM_POINT_LIGHT_SHADOWS > 0)\n\t\t\t\t\t\t\t\tPointLightShadow pointLightShadow;\n\t\t\t\t\t\t\t#endif \n\n\t\t\t\t\t\t\t#pragma unroll_loop_start\n\t\t\t\t\t\t\tfor (int i = 0; i < NUM_POINT_LIGHTS; i++) {\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tlpos = (inverse(viewMatrix) * vec4(pointLights[UNROLLED_LOOP_INDEX].position, 1.0)).xyz;\n\t\t\t\t\t\t\t\tl = normalize(lpos - worldPosition);\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tdproduct = dot(l, normalize(worldNormal)) * 0.5 + 0.5;\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\n\t\t\t\t\t\t\t\tt = max(t, dproduct);\n\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t#if defined(USE_SHADOWMAP) && (UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS)\n\t\t\t\t\t\t\t\t\tpointLightShadow = pointLightShadows[UNROLLED_LOOP_INDEX];\n\t\t\t\t\t\t\t\t\tshadow *= getPointShadow( \n\t\t\t\t\t\t\t\t\t\t\tpointShadowMap[UNROLLED_LOOP_INDEX], \n\t\t\t\t\t\t\t\t\t\t\tpointLightShadow.shadowMapSize,\n\t\t\t\t\t\t\t\t\t\t\tpointLightShadow.shadowIntensity,\n\t\t\t\t\t\t\t\t\t\t\tpointLightShadow.shadowBias, \n\t\t\t\t\t\t\t\t\t\t\tpointLightShadow.shadowRadius,\n\t\t\t\t\t\t\t\t\t\t\tvPointShadowCoord[UNROLLED_LOOP_INDEX], \n\t\t\t\t\t\t\t\t\t\t\tpointLightShadow.shadowCameraNear, \n\t\t\t\t\t\t\t\t\t\t\tpointLightShadow.shadowCameraFar);\n\t\t\t\t\t\t\t\t#endif\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t#pragma unroll_loop_end\n\n\t\t\t\t\t\t#endif\n\n\t\t\t\t\t\t#if NUM_DIR_LIGHTS > 0 \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t#if defined(USE_SHADOWMAP) && (NUM_DIR_LIGHT_SHADOWS > 0)\n\t\t\t\t\t\t\t\tDirectionalLightShadow directionalLightShadow;\n\t\t\t\t\t\t\t#endif \n\n\t\t\t\t\t\t\t#pragma unroll_loop_start\n\t\t\t\t\t\t\tfor (int i = 0; i < NUM_DIR_LIGHTS; i++) {\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tl = (inverse(viewMatrix) * vec4(directionalLights[UNROLLED_LOOP_INDEX].direction, 0.0)).xyz;\n\t\t\n\t\t\t\t\t\t\t\tdproduct = dot(l, normalize(worldNormal)) * 0.5 + 0.5;\n\t\t\t\t\t\t\t\tt = max(t, dproduct);\n\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t#if defined(USE_SHADOWMAP) && (UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS)\n\t\t\t\t\t\t\t\t\tdirectionalLightShadow = directionalLightShadows[UNROLLED_LOOP_INDEX];\n\t\t\t\t\t\t\t\t\tshadow *= getShadow( \n\t\t\t\t\t\t\t\t\t\tUNROLLED_LOOP_INDEX,\n\t\t\t\t\t\t\t\t\t\tdirectionalShadowMap[UNROLLED_LOOP_INDEX], \n\t\t\t\t\t\t\t\t\t\tdirectionalLightShadow.shadowMapSize,\n\t\t\t\t\t\t\t\t\t\tdirectionalLightShadow.shadowIntensity,\n\t\t\t\t\t\t\t\t\t\tdirectionalLightShadow.shadowBias, \n\t\t\t\t\t\t\t\t\t\tdirectionalLightShadow.shadowRadius, \n\t\t\t\t\t\t\t\t\t\tvDirectionalShadowCoord[UNROLLED_LOOP_INDEX]);\n\t\t\t\t\t\t\t\t#endif\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t#pragma unroll_loop_end\n\n\t\t\t\t\t\t#endif\n\n\t\t\t\t\t\t#if NUM_SPOT_LIGHTS > 0 \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t#if defined(USE_SHADOWMAP) && (NUM_SPOT_LIGHT_SHADOWS > 0)\n\t\t\t\t\t\t\t\tSpotLightShadow spotLightShadow;\n\t\t\t\t\t\t\t#endif \n\n\t\t\t\t\t\t\t#pragma unroll_loop_start\n\t\t\t\t\t\t\tfor (int i = 0; i < NUM_SPOT_LIGHTS; i++) {\n\t\t\t\t\t\t\t\tlpos = (inverse(viewMatrix) * vec4(spotLights[UNROLLED_LOOP_INDEX].position, 1.0)).xyz;\n\t\t\t\t\t\t\t\tl = normalize(lpos - worldPosition);\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tdproduct = dot(l, normalize(worldNormal)) * 0.5 + 0.5;\n\t\t\t\t\t\t\t\tt = max(t, dproduct);\n\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t#if defined(USE_SHADOWMAP) && (UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS)\n\t\t\t\t\t\t\t\t\tspotLightShadow = spotLightShadows[UNROLLED_LOOP_INDEX];\n\t\t\t\t\t\t\t\t\tshadow *= getShadow(\n\t\t\t\t\t\t\t\t\t\tUNROLLED_LOOP_INDEX,\n\t\t\t\t\t\t\t\t\t\tspotShadowMap[UNROLLED_LOOP_INDEX], \n\t\t\t\t\t\t\t\t\t\tspotLightShadow.shadowMapSize,\n\t\t\t\t\t\t\t\t\t\tspotLightShadow.shadowIntensity,\n\t\t\t\t\t\t\t\t\t\tspotLightShadow.shadowBias, \n\t\t\t\t\t\t\t\t\t\tspotLightShadow.shadowRadius, \n\t\t\t\t\t\t\t\t\t\tvSpotLightCoord[UNROLLED_LOOP_INDEX]);\n\t\t\t\t\t\t\t\t#endif\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t#pragma unroll_loop_end\n\n\t\t\t\t\t\t#endif\n\n\t\t\t\t\t\tt = clamp(t, 0.0, 1.0);\n\t\t\t\t\n\t\t\t\t\t#endif\n\n\t\t\t\t} else if (positioning == 1) {\n\t\t\t\t\t\n\t\t\t\t\tvec3 origin = mix(position, worldPosition, float(isWorldSpace));\n\t\t\t\t\tvec3 direction = normalize(source - origin);\n\t\t\t\t\tt = dot(direction, normalize(worldNormal)) * 0.5 + 0.5;\t\n\n\t\t\t\t} else {\n\n\t\t\t\t\tvec3 origin = worldPosition;\n\t\t\t\t\tvec3 source = cameraPosition - offset;\n\t\t\t\t\tvec3 direction = normalize(source - origin);\n\t\t\t\t\tt = dot(direction, normalize(worldNormal)) * 0.5 + 0.5;\t\n\t\t\t\t\t\n\t\t\t\t}\n\n\t\t\t\tif (noiseStrength > 0.0) {\n\t\t\t\t\t\n\t\t\t\t\tvec3 st = position / noiseScale;\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\tfloat noise = 1.0 - voronoiNoise(st).x;\n\n\t\t\t\t\t\n\t\t\t\t\t\n\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\n\t\t\t\t\tt += noise * noiseStrength;\n\t\t\t\t}\n\n\t\t\t\tt = clamp(t, 0.0, 1.0);\n\n\t\t\t\t\n\t\t\t\tfloat p;\n\t\t\t\tvec4 color = colors[0];\n\t\t\t\tfor (int i = 1; i < COLORS_MAX; i++) {\n\t\t\t\t\tp = clamp((t - steps[i-1]) / (steps[i] - steps[i-1]), 0.0, 1.0);\n\t\t\t\t\tcolor = mix(color, colors[i], smoothstep(0.0, 1.0, p));\n\t\t\t\t}\n\n\t\t\t\t\n\t\t\t\tif (positioning == 0) {\n\n\t\t\t\t\tvec3 blendedShadow = mix(color.rgb, shadowColor.rgb, shadowColor.a);\n\t\t\t\t\tcolor.rgb = mix(blendedShadow, color.rgb, shadow);\n\t\t\t\t\n\t\t\t\t}\n\n\t\t\t\t\n\t\t\t\tfloat lalpha = alpha * color.a * mask;\n\t\t\t\tcalpha = lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0);\n\t\t\t\taccumAlpha += (1.0 - accumAlpha) * lalpha;\n\n\t\t\t\treturn color.xyz;\n\n }",[bs.simplexFast,e,n,a])}}();var Bs={textureBicubic:new ki("float w0( float a ) {\n return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n }\n \n float w1( float a ) {\n return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n }\n \n float w2( float a ){\n return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n }\n \n float w3( float a ) {\n return ( 1.0 / 6.0 ) * ( a * a * a );\n }\n \n \n float g0( float a ) {\n return w0( a ) + w1( a );\n }\n \n float g1( float a ) {\n return w2( a ) + w3( a );\n }\n \n \n float h0( float a ) {\n return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n }\n \n float h1( float a ) {\n return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n }\n \n vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n uv = uv * texelSize.zw + 0.5;\n \n vec2 iuv = floor( uv );\n vec2 fuv = fract( uv );\n \n float g0x = g0( fuv.x );\n float g1x = g1( fuv.x );\n float h0x = h0( fuv.x );\n float h1x = h1( fuv.x );\n float h0y = h0( fuv.y );\n float h1y = h1( fuv.y );\n \n vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n \n return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) + \n g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n }\n\n vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n vec2 fLodSizeInv = 1.0 / fLodSize;\n vec2 cLodSizeInv = 1.0 / cLodSize;\n vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n return mix( fSample, cSample, fract( lod ) );\n }")},Vs=class extends Oi{constructor(e,t,n,i,a,r,o,s){super("v3"),this.nodeType="Transmission",this.thickness=e,this.ior=t,this.roughness=n,this.transmissionSamplerSize=i,this.transmissionSamplerMap=a,this.transmissionDepthMap=r,this.aspectRatio=o,this.alpha=s,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.extensions.shaderTextureLOD=!0,e.extensions.derivatives=!0,e.isShader("fragment")){e.define("NUM_SAMPLES",6),e.define("BLUR_SLOD",Math.pow(2,qs.transmissionLod.value)),e.require("worldPosition"),e.requires.worldNormal=!0,e.requires.modelMatrix=!0,e.requires.projectionMatrix=!0,e.addFragmentVariable(this.calpha,"float");let n=e.include(Vs.Nodes.transmission),i=[];return i.push(this.thickness.build(e,"f")),i.push(this.ior.build(e,"f")),i.push(this.roughness.build(e,"f")),i.push(this.transmissionSamplerSize.build(e,"v2")),i.push(this.transmissionSamplerMap.getTexture(e,"t")),i.push(this.transmissionDepthMap.getTexture(e,"t")),i.push(this.aspectRatio.build(e,"v2")),i.push("normal"),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(n+"("+i.join(",")+")",this.getType(e),t)}return console.warn("TransmissionNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},Hs=Vs;Hs.Nodes=function(){let e=new ki("vec3 blur(sampler2D sp, vec2 U, vec2 scale, float lod, sampler2D dm, vec2 unrefractedU, vec2 aspectRatio) {\n \n \n\n\t\t\t\t\n\t\t\t\tif (lod == 0.0) {\n\t\t\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\t\treturn texture2DLodEXT( sp, U, 0.0).rgb;\n\t\t\t\t\t#else\n\t\t\t\t\treturn textureLod( sp, U, 0.0).rgb;\n\t\t\t\t\t#endif\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tvec2 texelSize = vec2(1.0) / resolution;\n vec2 halton = haltonSequence[frameIndex];\n float temporalOffset = getNoiseInterleavedGradient(gl_FragCoord.xy + halton);\n float temporalAngle = temporalOffset * PI2;\n\t\t\t\tvec3 res = vec3(0.0);\n vec2 uv = vec2(0.0);\n vec2 offset = vec2(0.0);\n vec2 vogelSample = vec2(0.0);\n for (int i = 0; i < NUM_SAMPLES; i++) {\n vogelSample = vogelDiskSample(i, NUM_SAMPLES, temporalAngle) * texelSize;\n offset = vogelSample * scale * (lod * 10.0); \n uv = U + offset;\n float opaqueDepth = unpackRGBAToDepth(textureLod(dm, uv, lod));\n if (opaqueDepth != 0.0 && opaqueDepth < gl_FragCoord.z) {\n uv = unrefractedU;\n lod = lod > 4.0 ? lod : lod / 2.0;\n }\n res += textureLod(sp, uv, lod).rgb;\n }\n return res / float(NUM_SAMPLES);\n }"),t=new ki("vec3 getVolumeTransmissionRay( vec3 n, vec3 v, float thickness, float ior, mat4 modelMatrix ) {\n\t\t \n\t\t vec3 refractionVector = refract( -v, n, 1.0 / ior );\n\t\t \n\t\t\t\t\n\t\t vec3 modelScale;\n\t\t modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\t modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\t modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\n\t\t \n\t\t return normalize( refractionVector ) * thickness * modelScale;\n\t }"),n=new ki("float applyIorToRoughness( float roughness, float ior ) {\n\t\t\t\t// Scale roughness with IOR so that an IOR of 1.0 results in no microfacet refraction and\n\t\t\t\t// an IOR of 1.5 results in the default amount of microfacet refraction.\n\t\t\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t\t\t}"),i=new ki("vec3 getTransmissionSample( vec2 fragCoord, float roughness, float ior, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 unrefractedCoords, vec2 aspectRatio) {\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t#ifdef IS_THREEJS_EXPORT\n\t\t\t\t\tfloat lod = log2(transmissionSamplerSize.x) * applyIorToRoughness(roughness / 5.0, ior);\n\t\t\t\t\treturn textureBicubic(transmissionSamplerMap, fragCoord.xy, lod).rgb;\n\t\t\t\t#else\n\t\t\t\t\tfloat framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\t\t\t\tfloat lod = applyIorToRoughness(roughness, ior);\n\t\t\t\t\treturn blur(transmissionSamplerMap, fragCoord, vec2(lod), min(framebufferLod / 5.5, 8.5), transmissionDepthMap, unrefractedCoords, aspectRatio);\n\t\t\t\t#endif\n\t\t\t}",[Bs.textureBicubic,n,e]),a=new ki("vec3 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat4 modelMatrix, mat4 viewMatrix, mat4 projMatrix, float ior, float thickness, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 aspectRatio ) {\n\t\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\n\t\t\t\t\n\t\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\t\trefractionCoords += 1.0;\n\t\t\t\trefractionCoords /= 2.0;\n\n\t\t\t\tvec4 ndcPosUnrefracted = projMatrix * viewMatrix * vec4(position, 1.0 );\n\t\t\t\tvec2 unrefractedCoords = ndcPosUnrefracted.xy / ndcPosUnrefracted.w;\n\t\t\t\tunrefractedCoords += 1.0;\n\t\t\t\tunrefractedCoords /= 2.0;\n\n\t\t\t\t\n\t\t\t\treturn getTransmissionSample( refractionCoords, roughness, ior, transmissionSamplerSize, transmissionSamplerMap, transmissionDepthMap, unrefractedCoords, aspectRatio );\n \t\t}",[i,t]);return{transmission:new ki("vec3 transmission(float thickness, float ior, float roughness, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 aspectRatio, vec3 normal, float mask, float alpha, out float calpha) {\n vec3 v = vec3(0.);\n if (isOrthographic) {\n v = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n } else {\n v = normalize(vWPosition - cameraPosition);\n }\n vec3 transmission = getIBLVolumeRefraction(vWNormal, -v, roughness, vWPosition, modelMatrix, viewMatrix, projectionMatrix, ior, thickness, transmissionSamplerSize, transmissionSamplerMap, transmissionDepthMap, aspectRatio );\n \n\t\t\t\tfloat lalpha = alpha * mask;\n\t\t\t\tcalpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );\n\t\t\t\taccumAlpha += ( 1.0 - accumAlpha ) * alpha;\n\n\t\t\t\treturn transmission;\n }",[a])}}();var Gs=class extends Oi{constructor(e){super("v3"),this.nodeType="VertexColor",this.alpha=e,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.isShader("fragment")){e.requires.color[0]=!0;let n=e.include(Gs.Nodes.vertexColorLayer);e.addFragmentVariable(this.calpha,"float");let i=[];return i.push("vColor"),i.push(this.mask?`luminance(${this.mask.build(e,"v3")})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(n+"("+i.join(",")+")",this.getType(e),t)}return console.warn("VertexColorNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},ks=Gs;ks.Nodes={vertexColorLayer:new ki("vec3 vertexColorLayer(vec4 vcolor, float mask, float alpha, out float calpha) {\n\t\t\t\tfloat lalpha = alpha * mask * vcolor.a;\n\t\t\t\tcalpha = lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0);\n\t\t\t\taccumAlpha += (1.0 - accumAlpha) * lalpha;\n\n\t\t\t\treturn vcolor.rgb;\n\t\t\t}")};var Ws,Xs=((Ws=Xs||{}).NOISE="noise",Ws.MAP="map",Ws),js=class extends Oi{constructor(e,t,n,i,a,r,o,s,l,c,d){super("v3"),this.displacementTypeIndex=new wa(0),this.nodeType="VertexDisplacement",this.intensity=e,this.movementOrTexture=t,"map"===Object.values(Xs)[this.displacementTypeIndex.value]&&(this.mat=new rs(this.movementOrTexture.value.matrix)),this.cropOrOffset=n,this.scale=c,this.noiseFunctionIndex=d,this.voronoiStyle=i,this.smoothness=a,this.seed=r,this.highCut=o,this.lowCut=s,this.quality=l}generate(e,t){if(e.isShader("vertex")){e.define("USE_LAYER_DISPLACE");let n,i=[];switch(i.push("displaced_position"),i.push("displaced_normal"),Object.values(Xs)[this.displacementTypeIndex.value]){case"map":n=e.include(js.Nodes.map),i.push(this.movementOrTexture.getTexture(e,"t")),i.push("uv"),i.push(this.cropOrOffset.build(e,"f")),this.mat&&i.push(this.mat.build(e,"mat3"));break;case"noise":{let t=["simplexPrecise","simplexFractal","simplexAshima","fbm","perlin","voronoi"][this.noiseFunctionIndex.value],a=new ki("vec3 orthogonal(vec3 v) {\n\t\t\t\t\t\t\treturn normalize(abs(v.x) > abs(v.z) ? vec3(-v.y, v.x, 0.0) : vec3(0.0, -v.z, v.y));\n\t\t\t\t\t\t}"),r=new ki(`vec3 distorted(vec3 p, vec3 n, float scale, float intensity, vec3 offset, float neighbour_offset, float movement, int voronoiStyle, float smoothness, float seed, float highCut, float lowCut, int quality) {\n\t\t\t\t\t\t\t${"voronoi"==t?`\n\t\t\t\t\tfloat v = ${t}((p + offset) * scale * 0.001 + neighbour_offset + (movement * 0.1), voronoiStyle, smoothness, seed, quality);\n\t\t\t\t\tv = remap(v, lowCut, highCut, 0.0, 1.0);\n\t\t\t\t\tv = smax(v, 0.0, smoothness * 0.25);\n\t\t\t\t\tv = smin(v, 1.0, smoothness * 0.25);\n\n\t\t\t\t\treturn p + n * v * intensity;\n\t\t\t\t\t`:`\n\t\t\t\t\treturn p + n * ${t}((p + offset) * scale * 0.001 + neighbour_offset + (movement * 0.1)) * intensity;\n\t\t\t\t\t`}\n\t\t\t\t\t\t}`,[bs.simplexPrecise,bs.simplexFractal,bs.simplexAshima,bs.fbm,bs.perlin,bs.voronoi]),o=new ki("vec3 vertexDisplacementNoise(vec3 position, vec3 normal, float scale, vec3 offset, float movement, int voronoiStyle, float smoothness, float seed, float highCut, float lowCut, int quality, float intensity, out vec3 displaced_normal) {\n\t\t\t\t\t\t\tvec3 displaced_position = distorted(position, normal, scale, intensity, offset, neighbor_offset, movement, voronoiStyle, smoothness, seed, highCut, lowCut, quality);\n\t\t\t\t\t\t\tvec3 tangent1 = orthogonal(normal);\n\t\t\t\t\t\t\tvec3 tangent2 = normalize(cross(normal, tangent1));\n\n \n \n \n \n \n\t\t\t\t\t\t\tvec3 nearby1 = position + tangent1;\n\t\t\t\t\t\t\tvec3 nearby2 = position + tangent2;\n\t\t\t\t\t\t\tvec3 distorted1 = distorted(nearby1, normal, scale, intensity, offset, neighbor_offset, movement, voronoiStyle, smoothness, seed, highCut, lowCut, quality);\n\t\t\t\t\t\t\tvec3 distorted2 = distorted(nearby2, normal, scale, intensity, offset, neighbor_offset, movement, voronoiStyle, smoothness, seed, highCut, lowCut, quality);\n\t\t\t\t\t\t\tdisplaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));\n\t\t\t\t\t\t\treturn displaced_position;\n\t\t\t\t\t\t}",[r,a]);n=e.include(o),i.push(this.scale.build(e,"f")),i.push(this.cropOrOffset.build(e,"v3")),i.push(this.movementOrTexture.build(e,"f")),i.push(this.voronoiStyle.build(e,"i")),i.push(this.smoothness.build(e,"f")),i.push(this.seed.build(e,"f")),i.push(this.highCut.build(e,"f")),i.push(this.lowCut.build(e,"f")),i.push(this.quality.build(e,"i"));break}}return i.push(this.intensity.build(e,"f")),i.push("displaced_normal"),e.format(n+"("+i.join(",")+")",this.getType(e),t)}return console.warn("VertexDisplacementNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},$s=js;$s.Nodes=function(){let e=new ki("vec3 orthogonal(vec3 v) {\n\t\t\t\treturn normalize(abs(v.x) > abs(v.z) ? vec3(-v.y, v.x, 0.0) : vec3(0.0, -v.z, v.y));\n\t\t\t}"),t=new ki("float displacementMapTexture(sampler2D tex, float crop, vec2 uv, mat3 mat, vec2 offset) {\n\t\t\t\tvec2 uvs = (mat * vec3(uv * 2.0 - 1.0, 1.0) / 2.0 + 0.5).xy + offset;\n\t\t\t\tvec4 tmp = texture2D(tex, uvs);\n\t\t\t\tvec3 col = tmp.rgb;\n\t\t\t\tif (crop > 0.5) {\n\t\t\t\t\tif ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {\n\t\t\t\t\t\treturn 0.0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn col.r;\n\t\t\t}");return{map:new ki("vec3 vertexDisplacementMap(vec3 position, vec3 normal, sampler2D tex, vec2 uv, float crop, mat3 mat, float intensity, out vec3 displaced_normal) {\n\t\t\t\tvec3 displaced_position = position + normal * displacementMapTexture(tex, crop, uv, mat, vec2(0.0)) * intensity;\n\t\t\t\tvec3 tangent1 = normalize(orthogonal(normal));\n\t\t\t\tvec3 tangent2 = normalize(cross(normal, tangent1));\n\t\t\t\tvec3 nearby1 = position + tangent1 * 0.1;\n\t\t\t\tvec3 nearby2 = position + tangent2 * 0.1;\n\t\t\t\tvec3 distorted1 = nearby1 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity;\n\t\t\t\tvec3 distorted2 = nearby2 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity;\n\t\t\t\tdisplaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));\n\t\t\t\treturn displaced_position;\n\t\t\t}",[e,t])}}();var qs={normalRenderTarget:new ea,normalRenderTargetDepth:new ea,normalViewRenderTarget:new ea,transmissionRenderTarget:new ea,aspectRatio:new zi,transmissionSize:new zi(2048,2048),transmissionRenderTargetDepth:new ea,aoRenderTarget:new ea,aoEnabled:new es,pixelRatioNode:new ta(1),resolution:new zi,penumbraSize:new ts(x,.5),frameIndex:new wa(0),transmissionLod:new wa(2),taaEnabled:new es(!0)};for(let e of Object.values(qs))e.isRenderGlobal=!0;var Ys={spe_fogMode:new je(0),spe_fogHeightParams:new je(new Te(.005,.01,0))},Ks="\n#include <fog_pars_fragment>\n#ifdef USE_FOG\n\tuniform float spe_fogMode;\n\tuniform vec3 spe_fogHeightParams;\n\n\t// Analytic optical depth of an exponential height-fog layer along the\n\t// camera->fragment ray (see FogChunk.ts). fogWorldDelta = fragment -\n\t// camera in WORLD space, fogDist = its length. With x = falloff *\n\t// fogWorldDelta.y the integral collapses to camDensity * fogDist * F(x),\n\t// F(x) = (1 - e^-x)/x. F is evaluated on a sign-preserving |x| >= 1e-4:\n\t// that keeps F's x->0 limit of 1 (horizontal rays / falloff 0 degrade to\n\t// classic exponential fog) without a branch — deliberate, because the\n\t// WGSL twins' select() evaluates BOTH sides, so a guarded division, not\n\t// a branch, is what actually prevents inf/NaN there, and all four\n\t// implementations stay line-for-line identical.\n\tfloat speHeightFogFactor(const in vec3 fogWorldDelta, const in float fogDist) {\n\t\tfloat density = spe_fogHeightParams.x;\n\t\tfloat falloff = spe_fogHeightParams.y;\n\t\tfloat relY = cameraPosition.y - spe_fogHeightParams.z;\n\t\t// Density at the camera's own height, overflow-clamped: far below\n\t\t// the fog base the exponent explodes; the fog factor saturates to 1\n\t\t// long before, so the clamp is invisible.\n\t\tfloat camDensity = density * exp(clamp(-falloff * relY, -60.0, 60.0));\n\t\tfloat x = clamp(falloff * fogWorldDelta.y, -60.0, 60.0);\n\t\tfloat xSafe = (x >= 0.0 ? 1.0 : -1.0) * max(abs(x), 1e-4);\n\t\tfloat opticalDepth =\n\t\t\tcamDensity * fogDist * (1.0 - exp(-xSafe)) / xSafe;\n\t\treturn 1.0 - exp(-max(opticalDepth, 0.0));\n\t}\n#endif\n",Zs="\n#ifdef USE_FOG\n\tfloat speFogLinear = smoothstep(fogNear, fogFar, vFogDepth);\n\tvec3 speFogViewPos = -vViewPosition;\n\tfloat speFogDist = length(speFogViewPos);\n\tvec3 speFogWorldDelta = speFogViewPos * mat3(viewMatrix);\n\tfloat speFogHeight = speHeightFogFactor(speFogWorldDelta, speFogDist);\n\tfloat speFogWLinear = 1.0 - step(0.5, spe_fogMode) + step(1.5, spe_fogMode);\n\tfloat speFogWHeight = step(0.5, spe_fogMode);\n\tfloat speFogFactor = 1.0 -\n\t\t(1.0 - speFogLinear * speFogWLinear) *\n\t\t\t(1.0 - speFogHeight * speFogWHeight);\n\tgl_FragColor.rgb = mix(gl_FragColor.rgb, fogColor, speFogFactor);\n#endif\n",Js=class extends Di{constructor(){super("basic"),this.nodeType="Basic",this.color=new ba(D),this.shadingAlpha=new ta(1),this.shadingBlend=new wa(0),this.previousModelViewMatrix=new os,this.previouseProjectionMatrix=new os}get category(){return"phong"}generate(e){let t;if(e.isShader("vertex")){let n=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:qs.frameIndex}),e.mergeUniform({resolution:qs.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(Ht.merge([Ca.fog])),e.mergeUniform(Ys),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <morphtarget_pars_vertex>"].join("\n"));let i=["#include <beginnormal_vertex>","#include <morphnormal_vertex>","\n\t\t\t\t#include <skinbase_vertex>\n\t\t\t\t#include <skinnormal_vertex>\n\t\t\t\t#if !defined( USE_LAYER_DISPLACE )\n\t\t\t\t\t#include <defaultnormal_vertex>\n\t\t\t\t#endif\n\n\t\t\t\tvec3 displaced_position = position;\n\t\t\t\tvec3 displaced_normal = normal;\n\n\t\t\t\t#if defined( USE_LAYER_DISPLACE )\n\t\t\t\t\tvec3 transformed;\n\t\t\t\t\tvec3 transformedNormal;\n\t\t\t\t#endif\n\t\t\t\t","#include <normal_vertex>","\n\t\t\t\t#if !defined( USE_LAYER_DISPLACE )\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t#endif /* !USE_LAYER_DISPLACE */\n\t\t\t\t"];n&&i.push(n.code,n.result?"displaced_position = "+n.result+";":""),i.push("transformed = displaced_position;","#include <morphtarget_vertex>","#include <skinning_vertex>","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED","\tvNormal = transformedNormal;","#endif"),i.push("#include <project_vertex>","#include <fog_vertex>","#include <clipping_planes_vertex>","\tvViewPosition = - mvPosition.xyz;","#include <worldpos_vertex>"),i.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),t=i.join("\n")}else{void 0===this.color&&(this.color=new ba(D)),this.color.analyze(e,{slot:"color"}),this.alpha&&this.alpha.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"});let n=this.color.flow(e,"c",{slot:"color"}),i=this.alpha?this.alpha.flow(e,"f"):void 0,a=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0,r=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0;e.requires.transparent=void 0!==i,e.addParsCode(["varying vec3 vWPosition;",Ks,"#include <dithering_pars_fragment>","varying vec3 vViewPosition;","#include <normal_pars_fragment>"].join("\n"));let o=["#include <normal_fragment_begin>",n.code];i&&o.push(i.code,"#ifdef ALPHATEST"," if ( "+i.result+" <= ALPHATEST ) discard;","#endif"),r?o.push(r.code,`vec3 outgoingLight = ${n.result};`,`vec3 finalColor = spe_blend(outgoingLight, ${r.result}, 1.0, SPE_BLENDING_NORMAL);`):o.push(`vec3 finalColor = ${n.result};`);let s="1.0";this.mask&&(this.mask.analyze(e),s=`luminance(${this.mask.flow(e,"v3").result})`),i?o.push(`gl_FragColor = vec4( finalColor, accumAlpha * ${i.result} * ${s} );`):o.push("gl_FragColor = vec4("+n.result+", 1.0 );"),a&&o.push(`gl_FragColor.a *= ${a.result};`),o.push(Zs,"#include <dithering_fragment>"),t=o.join("\n")}return t}},Qs=class extends Di{constructor(){super("lambert"),this.nodeType="Lambert",this.color=new ba(D),this.emissive=new ba(0),this.emissiveIntensity=new ta(1),this.previousModelViewMatrix=new os,this.previouseProjectionMatrix=new os,this.shadingAlpha=new ta(1),this.shadingBlend=new wa(0),this.occlusion=new es(!0)}get category(){return"lambert"}build(e){let t;if(e.define("LAMBERT"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let n=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:qs.frameIndex}),e.mergeUniform({resolution:qs.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(Ht.merge([Ca.fog,Ca.lights])),e.mergeUniform(Ys),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","varying vec3 vLightFront;","varying vec3 vIndirectFront;","#ifndef DOUBLE_SIDED"," #define DOUBLE_SIDED","#endif","#ifdef DOUBLE_SIDED","\tvarying vec3 vLightBack;","\tvarying vec3 vIndirectBack;","#endif","#include <bsdfs>","#include <lights_pars_begin>","#include <color_pars_vertex>","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <morphtarget_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join("\n"));let i=["#include <beginnormal_vertex>","#include <morphnormal_vertex>","\n\t\t\t\t#include <skinbase_vertex>\n\t\t\t\t#include <skinnormal_vertex>\n\t\t\t\t#ifndef USE_LAYER_DISPLACE\n\t\t\t\t\t#include <defaultnormal_vertex>\n\t\t\t\t#endif\n\n\t\t\t\tvec3 displaced_position = position;\n\t\t\t\tvec3 displaced_normal = objectNormal;\n\n\t\t\t\t#ifdef USE_LAYER_DISPLACE\n\t\t\t\t\tvec3 transformed;\n\t\t\t\t\tvec3 transformedNormal;\n\t\t\t\t#endif\n\t\t\t\t","#include <normal_vertex>","\n\t\t\t\t#ifndef USE_LAYER_DISPLACE\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t#endif\n\t\t\t\t"];n&&i.push(n.code,n.result?"displaced_position = "+n.result+";":""),i.push("transformed = displaced_position;","#include <morphtarget_vertex>","#include <skinning_vertex>","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),i.push("\t#include <project_vertex>","\t#include <clipping_planes_vertex>","\tvViewPosition = - mvPosition.xyz;","\t#include <worldpos_vertex>","\n\t\t\t\t\tvec3 diffuse = vec3( 1.0 );\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\tstruct GeometricContext { vec3 position; vec3 normal; vec3 viewDir; };\n\t\t\t\t\tGeometricContext geometry;\n\t\t\t\t\tgeometry.position = mvPosition.xyz;\n\t\t\t\t\tgeometry.normal = normalize( transformedNormal );\n\t\t\t\t\tgeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\n\t\t\t\t"),i.push("\n\t\t\t\t\tGeometricContext backGeometry;\n\t\t\t\t\tbackGeometry.position = geometry.position;\n\t\t\t\t\tbackGeometry.normal = -geometry.normal;\n\t\t\t\t\tbackGeometry.viewDir = geometry.viewDir;\n\t\t\t\t\tvLightFront = vec3( 0.0 );\n\t\t\t\t\tvIndirectFront = vec3( 0.0 );\n\t\t\t\t\t#ifdef DOUBLE_SIDED\n\t\t\t\t\t\tvLightBack = vec3( 0.0 );\n\t\t\t\t\t\tvIndirectBack = vec3( 0.0 );\n\t\t\t\t\t#endif\n\t\t\t\t\tIncidentLight directLight;\n\t\t\t\t\tfloat dotNL;\n\t\t\t\t\tvec3 directLightColor_Diffuse;\n\t\t\t\t\tvIndirectFront += getAmbientLightIrradiance( ambientLightColor );\n\t\t\t\t\t#if defined( USE_LIGHT_PROBES )\n\t\t\t\t\t\tvIndirectFront += getLightProbeIrradiance( lightProbe, geometry.normal );\n\t\t\t\t\t#endif\n\t\t\t\t\t#ifdef DOUBLE_SIDED\n\t\t\t\t\t\tvIndirectBack += getAmbientLightIrradiance( ambientLightColor );\n\t\t\t\t\t\t#if defined( USE_LIGHT_PROBES )\n\t\t\t\t\t\t\tvIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry.normal );\n\t\t\t\t\t\t#endif\n\t\t\t\t\t#endif\n\t\t\t\t\t#if NUM_POINT_LIGHTS > 0\n\t\t\t\t\t\t#pragma unroll_loop_start\n\t\t\t\t\t\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\t\t\t\t\t\tgetPointLightInfo( pointLights[ i ], geometry.position, directLight );\n\t\t\t\t\t\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\t\t\t\t\t\tdirectLightColor_Diffuse = directLight.color;\n\t\t\t\t\t\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t\t\t\t\t\t#ifdef DOUBLE_SIDED\n\t\t\t\t\t\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t\t\t\t\t\t#endif\n\t\t\t\t\t\t}\n\t\t\t\t\t\t#pragma unroll_loop_end\n\t\t\t\t\t#endif\n\t\t\t\t\t#if NUM_SPOT_LIGHTS > 0\n\t\t\t\t\t\t#pragma unroll_loop_start\n\t\t\t\t\t\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\t\t\t\t\t\tgetSpotLightInfo( spotLights[ i ], geometry.position, directLight );\n\t\t\t\t\t\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\t\t\t\t\t\tdirectLightColor_Diffuse = directLight.color;\n\t\t\t\t\t\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t\t\t\t\t\t#ifdef DOUBLE_SIDED\n\t\t\t\t\t\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t\t\t\t\t\t#endif\n\t\t\t\t\t\t}\n\t\t\t\t\t\t#pragma unroll_loop_end\n\t\t\t\t\t#endif\n\t\t\t\t\t#if NUM_DIR_LIGHTS > 0\n\t\t\t\t\t\t#pragma unroll_loop_start\n\t\t\t\t\t\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\t\t\t\t\t\tgetDirectionalLightInfo( directionalLights[ i ], directLight );\n\t\t\t\t\t\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\t\t\t\t\t\tdirectLightColor_Diffuse = directLight.color;\n\t\t\t\t\t\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t\t\t\t\t\t#ifdef DOUBLE_SIDED\n\t\t\t\t\t\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t\t\t\t\t\t#endif\n\t\t\t\t\t\t}\n\t\t\t\t\t\t#pragma unroll_loop_end\n\t\t\t\t\t#endif\n\t\t\t\t\t#if NUM_HEMI_LIGHTS > 0\n\t\t\t\t\t\t#pragma unroll_loop_start\n\t\t\t\t\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\t\t\t\t\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );\n\t\t\t\t\t\t\t#ifdef DOUBLE_SIDED\n\t\t\t\t\t\t\t\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry.normal );\n\t\t\t\t\t\t\t#endif\n\t\t\t\t\t\t}\n\t\t\t\t\t\t#pragma unroll_loop_end\n\t\t\t\t\t#endif\n\t\t\t\t","\t#include <shadowmap_vertex>","\t#include <fog_vertex>"),i.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),t=i.join("\n")}else{e.mergeUniform({penumbraSize:qs.penumbraSize}),e.mergeUniform({frameIndex:qs.frameIndex}),e.mergeUniform({aoMap:qs.aoRenderTarget}),e.mergeUniform({aoEnabled:qs.aoEnabled}),void 0===this.color&&(this.color=new ba(D)),this.color.analyze(e,{slot:"color"}),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);let n=this.color.flow(e,"c",{slot:"color"}),i=this.emissive.flow(e,"c",{slot:"emissive"}),a=this.emissiveIntensity.flow(e,"f",{slot:"emissive"}),r=this.occlusion.flow(e,"b",{slot:"occlusion"}),o=this.shadingAlpha.flow(e,"f"),s=this.shadingBlend.flow(e,"i"),l=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,c=this.alpha?this.alpha.flow(e,"f"):void 0,d=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0;e.requires.transparent=void 0!==c,e.addParsCode([`uniform float penumbraSize[${x}];`,"uniform sampler2D aoMap;","uniform bool aoEnabled;","varying vec3 vViewPosition;","varying vec3 vWPosition;","varying vec3 vLightFront;","varying vec3 vIndirectFront;","#ifndef DOUBLE_SIDED"," #define DOUBLE_SIDED","#endif","#include <normal_pars_fragment>","#ifdef DOUBLE_SIDED","\tvarying vec3 vLightBack;","\tvarying vec3 vIndirectBack;","#endif","#include <bsdfs>","#include <lights_pars_begin>",Ks,"#include <shadowmap_pars_fragment>","#include <shadowmask_pars_fragment>","#include <clipping_planes_pars_fragment>","#include <dithering_pars_fragment>"].join("\n"));let u=["#include <normal_fragment_begin>","\n\t\t\t\t\n\t\t\t\tvec3 viewdx = dFdx(vViewPosition);\n\t\t\t\tvec3 viewdy = dFdy(vViewPosition);\n\t\t\t\tvec3 faceNormal = normalize(cross(viewdx, viewdy));\n\t\t\t\tbool isFrontFacing = (dot(normal, faceNormal) >= 0.0);\n\t\t\t\t","#include <clipping_planes_fragment>"];u.push(n.code,"vec3 diffuseColor = "+n.result+";","ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );"),c&&u.push(c.code,"#ifdef ALPHATEST","if ( "+c.result+" <= ALPHATEST ) discard;","#endif"),u.push("#ifdef DOUBLE_SIDED","\treflectedLight.indirectDiffuse += ( isFrontFacing ) ? vIndirectFront : vIndirectBack;","#else","\treflectedLight.indirectDiffuse += vIndirectFront;","#endif","#ifdef USE_LIGHTMAP","\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );","\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity;","#endif","reflectedLight.indirectDiffuse *= BRDF_Lambert( diffuseColor.rgb );","#ifdef DOUBLE_SIDED","\treflectedLight.directDiffuse = ( isFrontFacing ) ? vLightFront : vLightBack;","#else","\treflectedLight.directDiffuse = vLightFront;","#endif","reflectedLight.directDiffuse *= BRDF_Lambert( diffuseColor.rgb ) * getShadowMask();"),i&&u.push(i.code,"reflectedLight.directDiffuse += "+i.result+" * "+a.result+";"),u.push("vec3 ao = aoEnabled && "+r.result+" ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);","vec3 outgoingLight = (reflectedLight.directDiffuse + reflectedLight.indirectDiffuse) ;");let f="1.0";this.mask&&(this.mask.analyze(e),f=`luminance(${this.mask.flow(e,"v3").result})`),u.push(`\n\t\t\t\tif (outgoingLight != diffuseColor) {\n\t\t\t\t\tfloat lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );\n\t\t\t\t\taccumAlpha += ( 1.0 - accumAlpha ) * ${o.result} * ${f} * lightAccu;\n\t\t\t\t\toutgoingLight = spe_blend( diffuseColor, outgoingLight, ${o.result} * ${f}, ${s.result} );\n\n\t\t\t\t\toutgoingLight *= ao;\n\t\t\t\t}\n\t\t\t\t`),l&&u.push(l.code,`outgoingLight = spe_blend(outgoingLight, ${l.result}, 1.0, SPE_BLENDING_NORMAL);`),c?u.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${c.result} );`):u.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),d&&u.push(`gl_FragColor.a *= ${d.result};`),u.push("#include <colorspace_fragment>",Zs,"#include <dithering_fragment>"),t=u.join("\n")}return t}},el={dHdxy:new ki("vec2 dHdxy(sampler2D bumpMap, vec2 bumpMapUv, float bumpScale) {\n\n \n vec2 dSTdx = dFdx(bumpMapUv);\n\n \n vec2 dSTdy = dFdy(bumpMapUv);\n \n \n float Hll = bumpScale * luminance(texture(bumpMap, bumpMapUv).rgb);\n float dBx = bumpScale * luminance(texture(bumpMap, bumpMapUv + dSTdx).rgb) - Hll;\n float dBy = bumpScale * luminance(texture(bumpMap, bumpMapUv + dSTdy).rgb) - Hll;\n \n return vec2( dBx, dBy );\n }"),perturbNormalArb:new ki("vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n vec3 vSigmaX = dFdx( surf_pos.xyz );\n vec3 vSigmaY = dFdy( surf_pos.xyz );\n vec3 vN = surf_norm; \n \n vN = normalize(vN);\n\n vec3 R1 = cross( vSigmaY, vN );\n vec3 R2 = cross( vN, vSigmaX );\n\n R1 = normalize(R1);\n R2 = normalize(R2);\n \n float fDet = dot( vSigmaX, R1 ) * faceDirection;\n \n vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n return normalize( abs( fDet ) * vN - vGrad );\n }")},tl=class extends Di{constructor(){super("standard"),this.nodeType="Standard",this.color=new ba(D),this.roughness=new ta(.3),this.metalness=new ta(0),this.reflectivity=new ta(.5),this.previousModelViewMatrix=new os,this.previouseProjectionMatrix=new os,this.shadingAlpha=new ta(1),this.shadingBlend=new wa(0),this.occlusion=new es(!0)}get category(){return"physical"}build(e){let t;if(e.define("STANDARD"),e.requires.lights=!0,e.extensions.derivatives=!0,e.extensions.shaderTextureLOD=!0,e.isShader("vertex")){let n=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:qs.frameIndex}),e.mergeUniform({resolution:qs.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(Ht.merge([Ca.fog,Ca.lights])),e.mergeUniform(Ys),Ca.LTC_1&&(e.uniforms.ltc_1={value:void 0},e.uniforms.ltc_2={value:void 0}),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <morphtarget_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join("\n"));let i=["#include <beginnormal_vertex>","#include <morphnormal_vertex>","\n\t\t\t\t#include <skinbase_vertex>\n\t\t\t\t#include <skinnormal_vertex>\n\t\t\t\t#if !defined( USE_LAYER_DISPLACE )\n\t\t\t\t\t#include <defaultnormal_vertex>\n\t\t\t\t#endif\n\n\t\t\t\tvec3 displaced_position = position;\n\t\t\t\tvec3 displaced_normal = objectNormal;\n\n\t\t\t\t#if defined( USE_LAYER_DISPLACE )\n\t\t\t\t\tvec3 transformed;\n\t\t\t\t\tvec3 transformedNormal;\n\t\t\t\t#endif\n\t\t\t\t","#include <normal_vertex>","\n\t\t\t\t#if !defined( USE_LAYER_DISPLACE )\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t#endif /* !USE_LAYER_DISPLACE */\n\t\t\t\t"];n&&i.push(n.code,n.result?"displaced_position = "+n.result+";":""),i.push("transformed = displaced_position;","#include <morphtarget_vertex>","#include <skinning_vertex>","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),i.push("#include <project_vertex>","#include <fog_vertex>","#include <clipping_planes_vertex>","\tvViewPosition = - mvPosition.xyz;","#include <worldpos_vertex>","#include <shadowmap_vertex>"),i.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),t=i.join("\n")}else{e.mergeUniform({penumbraSize:qs.penumbraSize}),e.mergeUniform({frameIndex:qs.frameIndex}),e.mergeUniform({aoMap:qs.aoRenderTarget}),e.mergeUniform({aoEnabled:qs.aoEnabled}),e.mergeUniform({dfgLUT:{value:null}});let n={gamma:!0};void 0===this.color&&(this.color=new ba(D)),this.color.analyze(e,{slot:"color",context:n}),this.roughness.analyze(e),this.metalness.analyze(e);let i=this.occlusion.flow(e,"b",{slot:"occlusion"});this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e),this.reflectivity&&this.reflectivity.analyze(e);let a=this.color.flow(e,"c",{slot:"color",context:n}),r=this.roughness.flow(e,"f"),o=this.metalness.flow(e,"f"),s=this.shadingAlpha.flow(e,"f"),l=this.shadingBlend.flow(e,"i"),c=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,d=this.alpha?this.alpha.flow(e,"f"):void 0,u=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0,f=this.reflectivity?this.reflectivity.flow(e,"f"):void 0;e.requires.transparent=void 0!==d,e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;",`uniform float penumbraSize[${x}];`,"uniform sampler2D aoMap;","uniform bool aoEnabled;","#include <normal_pars_fragment>","#include <dithering_pars_fragment>",Ks,"#include <bsdfs>","#include <lights_pars_begin>","#include <lights_physical_pars_fragment>","#include <shadowmap_pars_fragment>"].join("\n"));let p=["#include <clipping_planes_fragment>","\t#include <normal_fragment_begin>","\n\t\t\t\t\n\t\t\t\tvec3 viewdx = dFdx(vViewPosition);\n\t\t\t\tvec3 viewdy = dFdy(vViewPosition);\n\t\t\t\tvec3 faceNormal = normalize(cross(viewdx,viewdy));\n\t\t\t\tif (dot(normal, faceNormal) < 0.0) {\n\t\t\t\t\tnormal *= -1.0;\n\t\t\t\t}\n\t\t\t\t","\tPhysicalMaterial material;","\tmaterial.diffuseColor = vec3( 1.0 );"];if(this.bumpMap){e.include(el.dHdxy),e.include(el.perturbNormalArb);let t=this.bumpMap.texture.flow(e,"t"),n=this.bumpMap.flow(e,"v3"),i=this.bumpMapIntensity?this.bumpMapIntensity.flow(e,"f").result:"1.0",a="";a=4===this.bumpMap.projection.value?`\n\t\t\t\t\tvec3 bumpNormal = vec3(0.0);\n\t\t\t\t\t{\n\t\t\t\t\t\tvec2 uv0 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs0;\n\t\t\t\t\t\tvec2 uv1 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs1;\n\t\t\t\t\t\tvec2 uv2 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs2;\n\t\t\t\t\t\tvec3 weights = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_triplanarWeights;\n\n\t\t\t\t\t\tvec2 grad0 = dHdxy(${t.result}, uv0, ${i});\n\t\t\t\t\t\tvec3 n0 = perturbNormalArb(-vViewPosition, normal, grad0, faceDirection);\n\n\t\t\t\t\t\tvec2 grad1 = dHdxy(${t.result}, uv1, ${i});\n\t\t\t\t\t\tvec3 n1 = perturbNormalArb(-vViewPosition, normal, grad1, faceDirection);\n\n\t\t\t\t\t\tvec2 grad2 = dHdxy(${t.result}, uv2, ${i});\n\t\t\t\t\t\tvec3 n2 = perturbNormalArb(-vViewPosition, normal, grad2, faceDirection);\n\t\t\t\t\t\t\n\t\t\t\t\t\tbumpNormal = n0 * weights.z + n1 * weights.x + n2 * weights.y;\n\t\t\t\t\t\tbumpNormal = normalize(bumpNormal);\n\t\t\t\t\t}\n\n\t\t\t\t\tnormal = bumpNormal;\n\t\t\t\t\t`:`\n\t\t\t\t\tvec2 bumpMapCachedUv = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs;\n\t\t\t\t\tvec2 grad = dHdxy(${t.result}, bumpMapCachedUv, ${i});\n\t\t\t\t\tnormal = perturbNormalArb( - vViewPosition, normal, grad, faceDirection );\n\t\t\t\t\t`,p.push(`// Call the Texture Layer's function once here so that it writes out its procedural UV coordinates\n\t\t\t\t\t${n.result};\n\t\t\t\t\t${a}\n\t\t\t\t\t`)}if(p.push(a.code,"\tvec3 diffuseColor = "+a.result+";","\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );",o.code,"\tfloat metalnessFactor = "+o.result+";"),this.roughnessMap){let t=this.roughnessMap.texture.flow(e,"t"),n=this.roughnessMap.flow(e,"v3"),i="";i=4===this.roughnessMap.projection.value?`\n\t\t\t\t\tfloat roughnessChange = 1.0;\n\t\t\t\t\t{\n\t\t\t\t\t\tvec2 uv0 = g${this.roughnessMap.uuid.toString().replace(/-/g,"")}_writeUvs0;\n\t\t\t\t\t\tvec2 uv1 = g${this.roughnessMap.uuid.toString().replace(/-/g,"")}_writeUvs1;\n\t\t\t\t\t\tvec2 uv2 = g${this.roughnessMap.uuid.toString().replace(/-/g,"")}_writeUvs2;\n\t\t\t\t\t\tvec3 weights = g${this.roughnessMap.uuid.toString().replace(/-/g,"")}_triplanarWeights;\n\n\t\t\t\t\t\tfloat r0 = luminance(texture(${t.result}, uv0).rgb) * roughnessScale;\n\t\t\t\t\t\tfloat r1 = luminance(texture(${t.result}, uv1).rgb) * roughnessScale;\n\t\t\t\t\t\tfloat r2 = luminance(texture(${t.result}, uv2).rgb) * roughnessScale;\n\n\t\t\t\t\t\troughnessChange = (r0 * weights.z + r1 * weights.x + r2 * weights.y);\n\t\t\t\t\t}\n\t\t\t\t\tfloat roughnessFactor = roughnessChange * ${r.result};\n\t\t\t\t\t`:`\n\t\t\t\t\tvec2 roughnessMapCachedUv = g${this.roughnessMap.uuid.toString().replace(/-/g,"")}_writeUvs;\n\n\t\t\t\t\tvec4 vals = texture(${t.result}, roughnessMapCachedUv);\n\t\t\t\t\tfloat roughnessFactor = luminance(vals.rgb) * ${r.result};\n\t\t\t\t\t`,p.push(`// Call the Texture Layer's function once here so that it writes out its procedural UV coordinates\n\t\t\t\t\t${n.result};\n\n\t\t\t\t\tconst float roughnessScale = 1.0;\n\n\t\t\t\t\t${i}\n\t\t\t\t`)}else p.push(r.code,"\tfloat roughnessFactor = "+r.result+";");d&&p.push(d.code,"#ifdef ALPHATEST","\tif ( "+d.result+" <= ALPHATEST ) discard;","#endif"),p.push("vec3 dxy = max( abs( dFdx( normal ) ), abs( dFdy( normal ) ) );","float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );"),p.push("material.diffuseColor = diffuseColor;","material.diffuseContribution = diffuseColor * ( 1.0 - metalnessFactor );","material.metalness = metalnessFactor;","material.specularF90 = 1.0;","material.roughness = max( roughnessFactor, 0.0525 );","material.roughness += geometryRoughness;","material.roughness = min( material.roughness, 1.0 );","material.roughness = clamp( roughnessFactor, 0.04, 1.0 );"),f?p.push(f.code,"material.specularColor = vec3( 0.16 * pow2( "+f.result+" ) );","material.specularColorBlended = mix( material.specularColor, diffuseColor, metalnessFactor );"):p.push("material.specularColor = vec3( 0.04 );","material.specularColorBlended = mix( material.specularColor, diffuseColor, metalnessFactor );"),p.push("#include <lights_fragment_begin>"),p.push("#include <lights_fragment_end>"),p.push("vec3 ao = aoEnabled && "+i.result+" ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);","vec3 outgoingLight = ((reflectedLight.directDiffuse + reflectedLight.indirectDiffuse)) + reflectedLight.directSpecular + reflectedLight.indirectSpecular;");let h="1.0";this.mask&&(this.mask.analyze(e),h=`luminance(${this.mask.flow(e,"v3").result})`),p.push(`\n\t\t\t\tif (outgoingLight != diffuseColor) {\n\t\t\t\t\tfloat lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );\n\t\t\t\t\taccumAlpha += ( 1.0 - accumAlpha ) * ${s.result} * ${h} * lightAccu;\n\t\t\t\t\toutgoingLight = spe_blend( diffuseColor, outgoingLight, ${s.result} * ${h}, ${l.result} );\n\t\t\t\t\t\n\t\t\t\t\toutgoingLight *= ao;\n\t\t\t\t}\n\t\t\t\t`),c&&p.push(c.code,`outgoingLight = spe_blend(outgoingLight, ${c.result}, 1.0, SPE_BLENDING_NORMAL);`),d?p.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${d.result} );`):p.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),u&&p.push(`gl_FragColor.a *= ${u.result};`),p.push("#include <colorspace_fragment>",Zs,"#include <dithering_fragment>"),t=p.join("\n")}return t}},nl=class extends Di{constructor(){super("toon"),this.nodeType="Toon",this.color=new ba(D),this.specular=new ba(1118481),this.shininess=new ta(30),this.previousModelViewMatrix=new os,this.previouseProjectionMatrix=new os,this.shadingAlpha=new ta(1),this.shadingBlend=new wa(0)}get category(){return"toon"}build(e){let t;if(e.define("TOON"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let n=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:qs.frameIndex}),e.mergeUniform({resolution:qs.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(Ht.merge([Ca.fog,Ca.lights])),e.mergeUniform(Ys),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <morphtarget_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join("\n"));let i=["#include <beginnormal_vertex>","#include <morphnormal_vertex>","\n\t\t\t\t#include <skinbase_vertex>\n\t\t\t\t#include <skinnormal_vertex>\n\t\t\t\t#ifndef USE_LAYER_DISPLACE\n\t\t\t\t\t#include <defaultnormal_vertex>\n\t\t\t\t#endif\n\n\t\t\t\tvec3 displaced_position = position;\n\t\t\t\tvec3 displaced_normal = objectNormal;\n\n\t\t\t\t#ifdef USE_LAYER_DISPLACE\n\t\t\t\t\tvec3 transformed;\n\t\t\t\t\tvec3 transformedNormal;\n\t\t\t\t#endif\n\t\t\t\t","#include <normal_vertex>","\n\t\t\t\t#ifndef USE_LAYER_DISPLACE\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t#endif\n\t\t\t\t"];n&&i.push(n.code,n.result?"displaced_position = "+n.result+";":""),i.push("transformed = displaced_position;","#include <morphtarget_vertex>","#include <skinning_vertex>","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),i.push("\t#include <project_vertex>","\t#include <fog_vertex>","\t#include <clipping_planes_vertex>","\tvViewPosition = - mvPosition.xyz;","\t#include <worldpos_vertex>","\t#include <shadowmap_vertex>","\t#include <fog_vertex>"),i.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),t=i.join("\n")}else{e.mergeUniform({penumbraSize:qs.penumbraSize}),e.mergeUniform({frameIndex:qs.frameIndex}),e.mergeUniform({aoMap:qs.aoRenderTarget}),e.mergeUniform({aoEnabled:qs.aoEnabled}),void 0===this.color&&(this.color=new ba(D)),this.color.analyze(e,{slot:"color"}),this.specular.analyze(e),this.shininess.analyze(e),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);let n=this.color.flow(e,"c",{slot:"color"}),i=this.specular.flow(e,"c"),a=this.shininess.flow(e,"f"),r=this.shadingAlpha.flow(e,"f"),o=this.shadingBlend.flow(e,"i"),s=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,l=this.alpha?this.alpha.flow(e,"f"):void 0,c=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0;e.requires.transparent=void 0!==l,e.addParsCode([`uniform float penumbraSize[${x}];`,"uniform sampler2D aoMap;","uniform bool aoEnabled;","varying vec3 vWPosition;","#include <normal_pars_fragment>","#include <gradientmap_pars_fragment>",Ks,"#include <bsdfs>","#include <lights_pars_begin>","#include <dithering_pars_fragment>","\n\t\t\t\t\tvarying vec3 vViewPosition;\n\t\t\t\t\tstruct ToonMaterial {\n\t\t\t\t\t\tvec3\tdiffuseColor;\n\t\t\t\t\t\tvec3\tspecularColor;\n\t\t\t\t\t\tfloat\tspecularShininess;\n\t\t\t\t\t\tfloat\tspecularStrength;\n\t\t\t\t\t};\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\tvoid 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\t\t\t\t\t\tvec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n\n\t\t\t\t\t\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\t\t\t\t\t\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n\t\t\t\t\t}\n\t\t\t\t\tvoid 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\t\t\t\t\t\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\t\t\t\t\t}\n\t\t\t\t\t#define RE_Direct\t\t\t\tRE_Direct_Toon\n\t\t\t\t\t#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon\n\t\t\t\t\t#define Material_LightProbeLOD( material )\t(0)\n\t\t\t\t\t","#include <shadowmap_pars_fragment>","#include <bumpmap_pars_fragment>","#include <normalmap_pars_fragment>"].join("\n"));let d=["#include <normal_fragment_begin>","\n\t\t\t\t\n\t\t\t\tvec3 viewdx = dFdx(vViewPosition);\n\t\t\t\tvec3 viewdy = dFdy(vViewPosition);\n\t\t\t\tvec3 faceNormal = normalize(cross(viewdx,viewdy));\n\t\t\t\tif (dot(normal, faceNormal) < 0.0) {\n\t\t\t\t\tnormal *= -1.0;\n\t\t\t\t}\n\t\t\t\t","\tToonMaterial material;"];if(this.bumpMap){e.include(el.dHdxy),e.include(el.perturbNormalArb);let t=this.bumpMap.texture.flow(e,"t"),n=this.bumpMap.flow(e,"v3"),i=this.bumpMapIntensity?this.bumpMapIntensity.flow(e,"f").result:"1.0",a="";a=4===this.bumpMap.projection.value?`\n\t\t\t\t\tvec3 bumpNormal = vec3(0.0);\n\t\t\t\t\t{\n\t\t\t\t\t\tvec2 uv0 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs0;\n\t\t\t\t\t\tvec2 uv1 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs1;\n\t\t\t\t\t\tvec2 uv2 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs2;\n\t\t\t\t\t\tvec3 weights = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_triplanarWeights;\n\n\t\t\t\t\t\tvec2 grad0 = dHdxy(${t.result}, uv0, ${i});\n\t\t\t\t\t\tvec3 n0 = perturbNormalArb(-vViewPosition, normal, grad0, faceDirection);\n\n\t\t\t\t\t\tvec2 grad1 = dHdxy(${t.result}, uv1, ${i});\n\t\t\t\t\t\tvec3 n1 = perturbNormalArb(-vViewPosition, normal, grad1, faceDirection);\n\n\t\t\t\t\t\tvec2 grad2 = dHdxy(${t.result}, uv2, ${i});\n\t\t\t\t\t\tvec3 n2 = perturbNormalArb(-vViewPosition, normal, grad2, faceDirection);\n\t\t\t\t\t\t\n\t\t\t\t\t\tbumpNormal = n0 * weights.z + n1 * weights.x + n2 * weights.y;\n\t\t\t\t\t\tbumpNormal = normalize(bumpNormal);\n\t\t\t\t\t}\n\n\t\t\t\t\tnormal = bumpNormal;\n\t\t\t\t\t`:`\n\t\t\t\t\tvec2 bumpMapCachedUv = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs;\n\t\t\t\t\tvec2 grad = dHdxy(${t.result}, bumpMapCachedUv, ${i});\n\t\t\t\t\tnormal = perturbNormalArb( - vViewPosition, normal, grad, faceDirection );\n\t\t\t\t\t`,d.push(`// Call the Texture Layer's function once here so that it writes out its procedural UV coordinates\n\t\t\t\t\t${n.result};\n\t\t\t\t\t${a}\n\t\t\t\t\t`)}d.push(n.code,"\tvec3 diffuseColor = "+n.result+";","\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );",i.code,"\tvec3 specular = "+i.result+";",a.code,"\tfloat shininess = max( 0.0001, "+a.result+" );","\tfloat specularStrength = 1.0;"),l&&d.push(l.code,"#ifdef ALPHATEST","if ( "+l.result+" <= ALPHATEST ) discard;","#endif"),d.push("material.diffuseColor = diffuseColor;"),d.push("material.specularColor = specular;","material.specularShininess = shininess;","material.specularStrength = specularStrength;","#include <lights_fragment_begin>","#include <lights_fragment_end>"),d.push("vec3 ao = aoEnabled ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);","vec3 outgoingLight = ((reflectedLight.directDiffuse + reflectedLight.indirectDiffuse) * ao) + reflectedLight.directSpecular;");let u="1.0";this.mask&&(this.mask.analyze(e),u=`luminance(${this.mask.flow(e,"v3").result})`),d.push(`\n\t\t\t\tif (outgoingLight != diffuseColor) {\n\t\t\t\t\tfloat lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );\n\t\t\t\t\taccumAlpha += ( 1.0 - accumAlpha ) * ${r.result} * ${u} * lightAccu;\n\t\t\t\t\toutgoingLight = spe_blend( diffuseColor, outgoingLight, ${r.result} * ${u}, ${o.result} );\n\t\t\t\t}\n\t\t\t\t`),s&&d.push(s.code,`outgoingLight = spe_blend(outgoingLight, ${s.result}, 1.0, SPE_BLENDING_NORMAL);`),l?d.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${l.result} );`):d.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),c&&d.push(`gl_FragColor.a *= ${c.result};`),d.push("#include <colorspace_fragment>",Zs,"#include <dithering_fragment>"),t=d.join("\n")}return t}},il=class extends Di{constructor(){super("phong"),this.nodeType="Phong",this.color=new ba(D),this.specular=new ba(1118481),this.shininess=new ta(30),this.previousModelViewMatrix=new os,this.previouseProjectionMatrix=new os,this.shadingAlpha=new ta(1),this.shadingBlend=new wa(0),this.occlusion=new es(!0)}get category(){return"phong"}build(e){let t;if(e.define("PHONG"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let n=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:qs.frameIndex}),e.mergeUniform({resolution:qs.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(Ht.merge([Ca.fog,Ca.lights])),e.mergeUniform(Ys),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <morphtarget_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join("\n"));let i=["#include <beginnormal_vertex>","#include <morphnormal_vertex>","\n\t\t\t\t#include <skinbase_vertex>\n\t\t\t\t#include <skinnormal_vertex>\n\t\t\t\t#ifndef USE_LAYER_DISPLACE\n\t\t\t\t\t#include <defaultnormal_vertex>\n\t\t\t\t#endif\n\n\t\t\t\tvec3 displaced_position = position;\n\t\t\t\tvec3 displaced_normal = objectNormal;\n\n\t\t\t\t#ifdef USE_LAYER_DISPLACE\n\t\t\t\t\tvec3 transformed;\n\t\t\t\t\tvec3 transformedNormal;\n\t\t\t\t#endif\n\t\t\t\t","#include <normal_vertex>","\n\t\t\t\t#ifndef USE_LAYER_DISPLACE\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t#endif\n\t\t\t\t"];n&&i.push(n.code,n.result?"displaced_position = "+n.result+";":""),i.push("transformed = displaced_position;","#include <morphtarget_vertex>","#include <skinning_vertex>","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),i.push("\t#include <project_vertex>","\t#include <clipping_planes_vertex>","\tvViewPosition = - mvPosition.xyz;","\t#include <worldpos_vertex>","\t#include <shadowmap_vertex>","\t#include <fog_vertex>"),i.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),t=i.join("\n")}else{e.mergeUniform({penumbraSize:qs.penumbraSize}),e.mergeUniform({frameIndex:qs.frameIndex}),e.mergeUniform({aoMap:qs.aoRenderTarget}),e.mergeUniform({aoEnabled:qs.aoEnabled}),void 0===this.color&&(this.color=new ba(D)),this.color.analyze(e,{slot:"color"}),this.specular.analyze(e),this.shininess.analyze(e);let n=this.occlusion.flow(e,"b",{slot:"occlusion"});this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);let i=this.color.flow(e,"c",{slot:"color"}),a=this.specular.flow(e,"c"),r=this.shininess.flow(e,"f"),o=this.shadingAlpha.flow(e,"f"),s=this.shadingBlend.flow(e,"i"),l=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,c=this.alpha?this.alpha.flow(e,"f"):void 0,d=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0;e.requires.transparent=void 0!==c,e.addParsCode(["varying vec3 vWPosition;","uniform vec3 emissive;",`uniform float penumbraSize[${x}];`,"uniform sampler2D aoMap;","uniform bool aoEnabled;","#include <normal_pars_fragment>",Ks,"#include <bsdfs>","#include <lights_pars_begin>","#include <lights_phong_pars_fragment>","#include <shadowmap_pars_fragment>","#include <dithering_pars_fragment>"].join("\n"));let u=["#include <normal_fragment_begin>","\n\t\t\t\t\n\t\t\t\tvec3 viewdx = dFdx(vViewPosition);\n\t\t\t\tvec3 viewdy = dFdy(vViewPosition);\n\t\t\t\tvec3 faceNormal = normalize(cross(viewdx,viewdy));\n\t\t\t\tif (dot(normal, faceNormal) < 0.0) {\n\t\t\t\t\tnormal *= -1.0;\n\t\t\t\t}\n\t\t\t\t","\tBlinnPhongMaterial material;"];if(this.bumpMap){e.include(el.dHdxy),e.include(el.perturbNormalArb);let t=this.bumpMap.texture.flow(e,"t"),n=this.bumpMap.flow(e,"v3"),i=this.bumpMapIntensity?this.bumpMapIntensity.flow(e,"f").result:"1.0",a="";a=4===this.bumpMap.projection.value?`\n\t\t\t\t\tvec3 bumpNormal = vec3(0.0);\n\t\t\t\t\t{\n\t\t\t\t\t\tvec2 uv0 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs0;\n\t\t\t\t\t\tvec2 uv1 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs1;\n\t\t\t\t\t\tvec2 uv2 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs2;\n\t\t\t\t\t\tvec3 weights = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_triplanarWeights;\n\n\t\t\t\t\t\tvec2 grad0 = dHdxy(${t.result}, uv0, ${i});\n\t\t\t\t\t\tvec3 n0 = perturbNormalArb(-vViewPosition, normal, grad0, faceDirection);\n\n\t\t\t\t\t\tvec2 grad1 = dHdxy(${t.result}, uv1, ${i});\n\t\t\t\t\t\tvec3 n1 = perturbNormalArb(-vViewPosition, normal, grad1, faceDirection);\n\n\t\t\t\t\t\tvec2 grad2 = dHdxy(${t.result}, uv2, ${i});\n\t\t\t\t\t\tvec3 n2 = perturbNormalArb(-vViewPosition, normal, grad2, faceDirection);\n\t\t\t\t\t\t\n\t\t\t\t\t\tbumpNormal = n0 * weights.z + n1 * weights.x + n2 * weights.y;\n\t\t\t\t\t\tbumpNormal = normalize(bumpNormal);\n\t\t\t\t\t}\n\n\t\t\t\t\tnormal = bumpNormal;\n\t\t\t\t\t`:`\n\t\t\t\t\tvec2 bumpMapCachedUv = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs;\n\t\t\t\t\tvec2 grad = dHdxy(${t.result}, bumpMapCachedUv, ${i});\n\t\t\t\t\tnormal = perturbNormalArb( - vViewPosition, normal, grad, faceDirection );\n\t\t\t\t\t`,u.push(`// Call the Texture Layer's function once here so that it writes out its procedural UV coordinates\n\t\t\t\t\t${n.result};\n\t\t\t\t\t${a}\n\t\t\t\t\t`)}u.push(i.code,"\tvec3 diffuseColor = "+i.result+";","\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );","\tvec3 totalEmissiveRadiance = emissive;",a.code,"\tvec3 specular = "+a.result+";",r.code,"\tfloat shininess = max( 0.0001, "+r.result+" );","\tfloat specularStrength = 1.0;"),c&&u.push(c.code,"#ifdef ALPHATEST","if ( "+c.result+" <= ALPHATEST ) discard;","#endif"),u.push("material.diffuseColor = diffuseColor;"),u.push("material.specularColor = specular;","material.specularShininess = shininess;","material.specularStrength = specularStrength;","#include <lights_fragment_begin>","#include <lights_fragment_end>"),u.push("vec3 ao = aoEnabled && "+n.result+" ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);","vec3 outgoingLight = ((reflectedLight.directDiffuse + reflectedLight.indirectDiffuse)) + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;");let f="1.0";this.mask&&(this.mask.analyze(e),f=`luminance(${this.mask.flow(e,"v3").result})`),u.push(`\n\t\t\t\tif (outgoingLight != diffuseColor) {\n\t\t\t\t\tfloat lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );\n\t\t\t\t\taccumAlpha += ( 1.0 - accumAlpha ) * ${o.result} * ${f} * lightAccu;\n\t\t\t\t\toutgoingLight = spe_blend( diffuseColor, outgoingLight, ${o.result} * ${f}, ${s.result} );\n\t\t\t\t\t\n\t\t\t\t\toutgoingLight *= ao;\n\t\t\t\t}\n\t\t\t\t`),l&&u.push(l.code,`outgoingLight = spe_blend(outgoingLight, ${l.result}, 1.0, SPE_BLENDING_NORMAL);`),c?u.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${c.result});`):u.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),d&&u.push(`gl_FragColor.a *= ${d.result};`),u.push("#include <colorspace_fragment>",Zs,"#include <dithering_fragment>"),t=u.join("\n")}return t}},al=new Map;function rl(e,t){al.set(e,t)}var ol=new Set;function sl(e,t,n){if("isMask"===t||"rainbow"===e.type&&"noiseStrength"===t&&void 0!==e.noiseCompiledIn&&(!0===e.noiseForced||v(n))!==e.noiseCompiledIn)return!0;let i=g[e.type],a=_[e.type];if(void 0!==a){let i=e.color;if(a.includes(t)){let e=i[t]?.value?.length;if(void 0!==e&&e!==n.length)return!0}}return void 0!==i&&i.includes(t)}function ll(e,t){if(Array.isArray(t)){if(!Array.isArray(e)||e.length!==t.length)return!1;for(let[n,i]of t.entries()){let t=e[n];if("string"==typeof i||"number"==typeof i&&"string"==typeof t)return!0}return!1}let n="string"==typeof e,i="string"==typeof t;return n!==i||n&&i}function cl(e,t,n){let i=n.uniforms[`f${n.id}_texture`];if(!i)return!1;let a=!1,r=e;if("image"in r){let e=r.image,n=t.image(e),a=i;a.image instanceof w||a.image.deref(),a.image=n}if("video"in r){let e=r.video,n=t.video(e),a=i;a.image instanceof w||a.image.deref(),a.image=n}if("wrapping"in r&&(i.wrap=r.wrapping),"minFilter"in r&&(i.minFilter=r.minFilter),"magFilter"in r&&(i.magFilter=r.magFilter),"rotation"in r&&n.uniforms[`f${n.id}_rotation`])return n.uniforms[`f${n.id}_rotation`].value=(h(r.rotation??0,t)??0)*ce.DEG2RAD,a;if("repeat"in r||"offset"in r||"rotation"in r){let e="mat",i=n.uniforms[`f${n.id}_${e}`];if(!i)return a;if("repeat"in r){let e=r.repeat;ll(n.data.texture.repeat,e)&&(a=!0),i.repeat=fl(e,t).map((t,n)=>"string"==typeof e[n]?1/t:t)}if("offset"in r){let e=r.offset;ll(n.data.texture.offset,e)&&(a=!0),i.offset=fl(e,t).map((t,n)=>"string"==typeof e[n]?-t:t)}if("rotation"in r){let e=n.data.texture.rotation,o=r.rotation??0;(void 0===e||ll(e,o))&&(a=!0),i.rotation=h(o,t)??0}i.updateMatrix()}return a}var dl=(e,t)=>(e||(e=new Te),e.x=h(e.x,t)??0,e.y=h(e.y,t)??0,e.z=h(e.z,t)??0,e),ul=(e,t)=>(e||(e=new pe),e.x=h(e.x,t)??0,e.y=h(e.y,t)??0,e),fl=(e,t)=>{let n=e.map(e=>h(e,t)??0);return[n[0],n[1]]},pl=class{constructor(e,t,n,i,a){this.id=e,this.uuid=t,this.data=n,this.uniforms={};for(let e in i)this.uniforms[`f${this.id}_${e}`]=i[e];for(let e in n)_l(e,this,n,a)}get type(){return this.data.type}static create(e,t,i,a,r){if("light"===i.type)return vl.createLightLayer(e,t,i,a);if("color"===i.type)return function(e,t,i,a){let r=n(i,a),o=new ba(r.color??D),s=gl(r),l=new fs(o,s.alpha),c=new Qi(l.calpha,"f");return new hl(e,t,i,{color:o,...s},l,s.mode,c,s.isMask,a)}(e,t,i,a);let o=(s=i.type,al.get(s));var s;return o?o(e,t,i,a,r):(function(e){ol.has(e)||(ol.add(e),console.warn(`[spe] Material layer type "${e}" is not available in this runtime build (compiled out) — rendering flat red. Re-export the scene with its full layer set or load the full runtime build.`))}(i.type),function(e,t,n,i){let a=n,r=gl({alpha:"string"==typeof a.alpha?Number(i.getVariable(a.alpha)??100)/100:a.alpha,mode:a.mode,isMask:a.isMask}),o=new ba(1,0,0,1),s=new fs(o,r.alpha),l=new Qi(s.calpha,"f");return new hl(e,t,n,{color:o,...r},s,r.mode,l,r.isMask,i)}(e,t,i,a))}updateByOp(e,t,n){let i=e,a=!1;if(void 0===i.path[0]){for(let e of Object.keys(i.props))try{let n=this.data[e],i=t[e];if(Array.isArray(n)&&Array.isArray(i)){for(let[e,t]of i.entries()){let i=n[e];if("string"==typeof t||"number"==typeof t&&"string"==typeof i){a=!0;break}}if(a)break}else if("string"==typeof i&&"number"==typeof n||"number"==typeof i&&"string"==typeof n||"string"==typeof i&&"string"==typeof n&&i!==n){a=!0;break}}catch(e){console.error(e)}if(0===i.type)return"type"in i.props||"category"in i.props||"visible"in i.props||"noiseType"in i.props?(n.scene.markNeedsUpdateRendererDirty(),!0):function(e,t,n,i){let a=!1;for(let[r,o]of Object.entries(e)){if("bumpMap"===r||"roughnessMap"===r){a=!0;continue}if(!r||void 0===o)continue;if(_l(r,n,i,t)){"visible"===r&&"light"===n.type&&(a=!0);continue}n.visible=i.visible;let e=n.uniforms[`f${n.id}_${r}`];if(e&&!(e instanceof ns))switch(a=a||sl(n,r,o),e.constructor){case ba:if("string"==typeof o){let n=t.getColor(o);n&&(e.value=n);break}{let t=o;e.value instanceof b?e.value=new T(t.r,t.g,t.b,t.a):e.setRGBA(t);break}case Vi:if("string"==typeof o){let n=t.getColor(o);n&&(e.value=n);break}{let t=o;e.value instanceof b?e.value=new T(t.r,t.g,t.b,t.a):e.value.setRGBA(t.r,t.g,t.b,t.a);break}case zi:{let t=o;e.value.setX(t[0]),e.value.setY(t[1]);break}case Bi:{let t=o;e.value.setX(t[0]),e.value.setY(t[1]),e.value.setZ(t[2]);break}case ea:cl(o,t,n);break;case cs:e.value=o.map(e=>new Fe(...e));break;default:e.value=o}}return a}(i.props,n.shared,this,t)||a}else if("texture"===i.path[0])return!("texture"in t)&&!("video"in t)||cl(i.props,n.shared,this)||a;return a}dispose(){if(m(this)){let e=this.uniforms[`f${this.id}_texture`];if(!e)return!1;let t=e;t.image instanceof w||t.image.deref()}}hasValueByKey(e){return void 0!==this.uniforms[e]}hasValue(e){return this.hasValueByKey(`f${this.id}_${e}`)}setValue(e,t){let n=`f${this.id}_${e}`;if(this.hasValueByKey(n)&&void 0!==t&&(this.uniforms[n].value=t,"noiseStrength"===e&&!1===this.noiseCompiledIn&&"number"==typeof t&&0!==t&&void 0!==this.onNoiseMismatch)){let e=this.onNoiseMismatch;this.onNoiseMismatch=void 0,e(t)&&(this.noiseCompiledIn=!0)}}getNode(e){let t=`f${this.id}_${e}`;if(this.hasValueByKey(t))return this.uniforms[t]}getValue(e){let t=`f${this.id}_${e}`;if(this.hasValueByKey(t))return this.uniforms[t].value}getName(e){let t=/f\d+_(.*)/.exec(e);if(t&&t.length>1)return t[1];console.log(`Layer.getName: error ${e}`)}getNames(){let e=[];for(let t in this.uniforms){let n=this.getName(t);n&&e.push(n)}return e}},hl=class extends pl{constructor(e,t,n,i,a,r,o,s,l){super(e,t,n,i,l),this.params=i,this.color=a,this.mode=r,this.alpha=o,this.isMask=s}},ml=class extends pl{constructor(e,t,n,i,a,r){super(e,t,n,i,r),this.position=a}},vl=class extends pl{constructor(e,t,n,i,a,r){super(e,t,n,a,r),this.node=i}static createLightLayer(e,t,n,i){let a,r,o=new ta(p(n.alpha,i)),s=new wa(n.mode),l=new ta(n.bumpMapIntensity),c=new ta(p(n.alphaOverride,i));if(n.visible)if("lambert"===n.category){a=new Qs;let e=new ba(i.color(n.emissive)??0),t=new es(n.occlusion??!0);r={emissive:e,occlusion:t},a.emissive=e,a.occlusion=t}else if("toon"===n.category){a=new nl;let e=new ta(n.shininess??30),t=new ba(i.color(n.specular)??1118481);r={shininess:e,specular:t},a.shininess=e,a.specular=t}else if("physical"===n.category){a=new tl;let e=new ta(n.roughness??.3),t=new ta(n.metalness??0),i=new ta(n.reflectivity??.5),o=new es(n.occlusion??!0);r={roughness:e,metalness:t,reflectivity:i,occlusion:o},a.roughness=e,a.metalness=t,a.reflectivity=i,a.occlusion=o}else{a=new il;let e=new ta(n.shininess??30),t=new ba(void 0!==n.specular?i.color(n.specular)??1118481:1118481),o=new es(n.occlusion??!0);r={shininess:e,specular:t,occlusion:o},a.shininess=e,a.specular=t,a.occlusion=o}else a=new Js,r={};return a.alpha=new ta(1),a.shadingAlpha=o,a.shadingBlend=s,a.bumpMapIntensity=l,a.alphaOverride=c,r.alpha=a.shadingAlpha,r.mode=a.shadingBlend,r.bumpMapIntensity=a.bumpMapIntensity,r.alphaOverride=a.alphaOverride,new vl(e,t,n,a,r,i)}get category(){return this.node.category}};function gl(e){return{alpha:new ta(e.alpha??1),mode:new wa(e.mode??0),isMask:new es(e.isMask??!1)}}function _l(e,t,n,i){if("displace"===n.type&&("intensity"===e||"visible"===e)){let e=t.uniforms[`f${t.id}_intensity`];return e?(e.value=(h(n.intensity,i)??1)*(n.visible?1:0),e):void 0}if("displace"!==n.type&&("alpha"===e||"visible"===e)){let a=t.uniforms[`f${t.id}_alpha`];if(!a)return;if(a.value=p(n.alpha,i)*(n.visible?1:0),"outline"===n.type&&"visible"===e){let e=t.uniforms[`f${t.id}_compensation`];e&&(e.value=n.compensation&&n.visible)}return a}}function xl(e,t,n,i,a,r,o=[]){let s=n;for(let e of o)e in s&&(s=s[e]);for(let t of e)t in s&&a.getVariable(s[t],["material",r,"layer",i,...o,String(t)]);for(let e of t)e in s&&s[e].forEach((t,n)=>{a.getVariable(t,["material",r,"layer",i,...o,String(e),0===n?"x":1===n?"y":"z"])})}var Sl=class extends Xt{constructor(){super(void 0),this.isClassicNodeMaterial=!0,this.flatShading=!1,this.needsJitter=!0,this.shadersPatchedForShapeBlend=!1,this.nodeExtensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.nodeContextUuid=0,this.fog=!0,this.dithering=!0,this.vertexColors=!0,this.transparent=!0}customProgramCacheKey(){return""}},Tl=!1,bl=class extends Sl{constructor(e,t,n,i){super(),this.flatShading=e,this.side=t,this.wireframe=n,this.root=i}updateAfterBuild(){let e=this.root;this.lights=e.lights,this.vertexShader=e.vertexShader,this.fragmentShader=e.fragmentShader,Object.assign(this.defines,e.defines),Object.assign(this.uniforms,e.uniforms),this.nodeExtensions=e.nodeExtensions,this.transparent=e.transparent,this.cacheKey=e.customProgramCacheKey()+"flat"+this.flatShading+this.side}onBeforeCompile(e,t){this.root.onBeforeCompile(e)}get data(){return this.root.data}get category(){return this.root.category}get hasAO(){return this.root.hasAO}getFlavor(e,t,n,i){return this.root.getFlavor(e,t,n,i)}get layers(){return this.root.layers}get fragment(){return this.root.fragment}getLayersOfType(e){return this.root.getLayersOfType(e)}getLayerByUuid(e){return this.root.getLayerByUuid(e)}ensureRainbowNoiseCompiled(e,t){return this.root.ensureRainbowNoiseCompiled(e,t)}updateByOp(e,t,n){this.root.updateByOp(e,t,n)}nodeMaterialDispose(){this.root.nodeMaterialDispose()}},wl=class extends Sl{constructor(e,t,n=!0){super(),this.data=e,this.allowVariableSaves=n,this.layerIdGen=0,this.flavors=[],this.masks={},this.type="NodeMaterial",this.forceRainbowNoise=new Set,this.syntheticMapLayers=new Map,this.updaters=[],this.needsJitter=t.shared.needsJitter,Di.startContext(this),this.reset0(e,t),Di.endContext(this)}setTransparent(e,t){if(this.transparent!==e){this.transparent=e,this.needsUpdate=!0;for(let t of this.flavors)void 0!==t&&(t.transparent=e,t.needsUpdate=!0);t?.markNeedsUpdateRendererDirty()}}get nodeMaterial(){return this}getFlavor(e,t,n,i){let a=n?6:(e?3:0)+t;if(a+=7*((i?.resolutionLevel??0)-(i?.useChildrenColors?4:0)),0===a)return this;void 0===this.flavors&&(this.flavors=[]),a-=1;let r=this.flavors[a];return void 0===r&&(r=new bl(e,t,n,this),r.needsJitter=this.needsJitter,this.flavors[a]=r,r.flatShading=e,r.side=t,r.updateAfterBuild(),i&&(r.defines.SHAPEBLEND=i.resolutionLevel,r.defines.SHAPEBLEND_C=i.useChildrenColors?1:0)),r}get fragment(){return this.lightLayer.node}get category(){return this.lightLayer.category}get hasAO(){return this.lightLayer.getNode("occlusion")?.value??!1}ensureRainbowNoiseCompiled(e,t){let n=this.data.layers?.data(e);return void 0!==n&&"rainbow"===n.type&&(!this.forceRainbowNoise.has(e)&&!v(n.noiseStrength)||!1===this.getLayerByUuid(e)?.noiseCompiledIn)&&(this.forceRainbowNoise.add(e),Di.startContext(this),this.reset0(this.data,this.lastContext),Di.endContext(this),void 0!==t&&this.getLayerByUuid(e)?.setValue("noiseStrength",t),!0)}reset(e,t,n=!1){Di.startContext(this),(this.data!==e||n)&&this.reset0(e,t),Di.endContext(this)}reset0(e,t){this.lastContext=t,this.data=e;let n=e.layers??C.defaultTwoLayerData("phong").layers,i=[];for(let e of n)try{let n=pl.create(this.layerIdGen++,e.id,e.data,t.shared,this.forceRainbowNoise.has(e.id)?{forceRainbowNoise:!0}:void 0);if("rainbow"===n.type&&!1===n.noiseCompiledIn){let t=e.id;n.onNoiseMismatch=e=>this.ensureRainbowNoiseCompiled(t,e)}i.push(n)}catch(t){console.warn(`[spe] material layer '${e.data.type}' (${e.id}) failed to build — skipping this layer`,t)}this.layers=i,this.layers.reverse(),this.name=e.name??"Untitled Material",this.onUpdate(t.shared),this.setTransparent(f(e,t.shared),t.scene),this.saveVariableLocations(t)}onVariableUpdate(e,t,n){if("alphaOverride"===e[0])this.setTransparent(f(this.data,n.shared),n.scene),this.lightLayer.setValue("alphaOverride",Math.max(0,Math.min(Number(t)/100,1)));else if("layer"===e[0]){let i=e[1],a=e[2];if(i&&a){let r=this.layers.find(e=>e.uuid===i);if(r?.hasValue(a))if("alpha"===a)this.setTransparent(f(this.data,n.shared),n.scene),r.setValue(a,Math.max(0,Math.min(Number(t)/100,1)));else{let i=r.getValue(a),o=e[3],s=e[4];if(i instanceof Ue){let e,a=i[o];return"number"==typeof a?e=Number(t):a.isVector2&&(e=a.toArray(),"x"===s?e[0]=Number(t):"y"===s&&(e[1]=Number(t))),void cl({[o]:e},n.shared,r)}("x"===o||"y"===o||"z"===o)&&i.isVector3||("x"===o||"y"===o)&&i.isVector2?i[o]=Number(t):r.setValue(a,t)}}}}saveVariableLocations(e){if(!this.allowVariableSaves)return;let t=this.data.layers?.find(e=>"light"===e.data.type);t&&e.shared.getVariable(t.data.alphaOverride,["material",this.uuid,"alphaOverride"]),this.data.layers?.forEach(t=>{"alpha"in t.data&&"string"==typeof t.data.alpha&&e.shared.getVariable(t.data.alpha,["material",this.uuid,"layer",t.id,"alpha"]),"displace"===t.data.type?"noise"===t.data.displacementType?xl(["intensity","scale","movement","smoothness","seed","highCut","lowCut"],["offset"],t.data,t.id,e.shared,this.uuid):xl(["intensity"],[],t.data,t.id,e.shared,this.uuid):"depth"===t.data.type?xl(["near","far"],["origin","direction"],t.data,t.id,e.shared,this.uuid):"cavity"===t.data.type?xl(["ridge","valley"],[],t.data,t.id,e.shared,this.uuid):"fresnel"===t.data.type?xl(["bias","scale","intensity","factor"],[],t.data,t.id,e.shared,this.uuid):"dust"===t.data.type?xl(["coverage","softness","noiseStrength","noiseScale"],[],t.data,t.id,e.shared,this.uuid):"rainbow"===t.data.type?xl(["filmThickness","movement","noiseStrength","noiseScale"],["offset","wavelengths"],t.data,t.id,e.shared,this.uuid):"noise"===t.data.type?xl(["scale","move","seed","highCut","lowCut","smoothness"],["size","distortion","fA","fB"],t.data,t.id,e.shared,this.uuid):"pattern"===t.data.type?xl(["blending","size","variation","smoothness","zigzag","rotation"],["offset","frequency","vertical","horizontal"],t.data,t.id,e.shared,this.uuid):"outline"===t.data.type?xl(["outlineWidth","contourWidth","outlineThreshold","contourThreshold","outlineSmoothing","contourFrequency"],["contourDirection"],t.data,t.id,e.shared,this.uuid):"toon"===t.data.type?xl(["noiseStrength","noiseScale"],["offset","source"],t.data,t.id,e.shared,this.uuid):"transmission"===t.data.type?xl(["roughness","thickness","ior"],[],t.data,t.id,e.shared,this.uuid):"texture"===t.data.type||"video"===t.data.type?(xl([],["size"],t.data,t.id,e.shared,this.uuid),xl(["rotation"],["repeat","offset"],t.data,t.id,e.shared,this.uuid,["texture"])):"gradient"===t.data.type?xl(["angle"],["offset","morph"],t.data,t.id,e.shared,this.uuid):"matcap"===t.data.type&&xl(["rotation"],[],t.data,t.id,e.shared,this.uuid,["texture"])})}getLayersOfType(e){return this.layers.filter(t=>t.type===e)}getLayerByUuid(e){return this.layers.find(t=>t.uuid===e)}onUpdate(e){this.lightLayer=this.layers.find(e=>e instanceof vl),void 0===this.lightLayer&&(this.lightLayer=new vl(0,"",{...y.defaultData("light","phong"),visible:!1},new Js,{},e)),this.dispose();for(let e of this.flavors)e&&e.dispose();this.applyTextureMaps(e),this.applyMasks(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),this.build(),this.nodeContextUuid=0}syntheticMapNode(e,t){let n=this.syntheticMapLayers.get(e);if(void 0===n)try{let i=y.defaultData("texture"),a={...i,visible:!1,texture:{...i.texture,image:e.image,wrapping:e.wrapping??1e3,offset:e.offset??[0,0],repeat:e.repeat??[1,1],minFilter:e.minFilter??1008,magFilter:e.magFilter??1006}};n=pl.create(this.layerIdGen++,`mapImage${this.layerIdGen}`,a,t),this.syntheticMapLayers.set(e,n)}catch(e){return void console.warn("[spe] light-layer map image failed to build — skipped",e)}let i=n.color;return i instanceof gs?i:void 0}applyTextureMaps(e){let t=this.layers.find(e=>e instanceof vl);if(!t)return;let n=t.data,i=n.bumpMap,a=n.roughnessMap;t.node.bumpMap=void 0,t.node.roughnessMap=void 0;for(let e of this.syntheticMapLayers.values())e.dispose();this.syntheticMapLayers.clear(),M.is(i)&&(t.node.bumpMap=this.syntheticMapNode(i,e)),M.is(a)&&(t.node.roughnessMap=this.syntheticMapNode(a,e));let r=n;!Tl&&(void 0!==r.metalnessMap||void 0!==r.normalMap||void 0!==r.aoMap||void 0!==r.emissiveMap||void 0!==r.roughnessMapChannel&&"luminance"!==r.roughnessMapChannel||void 0!==r.clearcoat||void 0!==r.sheen||void 0!==r.ior||void 0!==r.iridescence||void 0!==r.emissive&&"object"==typeof r.emissive&&(r.emissive.r>0||r.emissive.g>0||r.emissive.b>0))&&(Tl=!0,console.warn("[spline] this document uses PBR material maps (metalness/normal/AO/emissive), which the classic WebGL pipeline does not render — the WebGPU renderer shows them"));for(let e=0;e<this.layers.length;++e){let n=this.layers[e];n instanceof hl&&n.color instanceof gs&&(n.uuid===i&&(t.node.bumpMap=n.color),n.uuid===a&&(t.node.roughnessMap=n.color))}}updateByOp(e,t,n){if(Di.startContext(this),void 0!==t?this.data=t:t=this.data,this.setTransparent(f(t,n.shared),n.scene),"layers"===e.path[0]){let i=n.shared,a=e.path[1];if(void 0===a)n.scene.markNeedsUpdateRendererDirty(),this.reset0(t,n);else{0===e.type&&void 0!==e.props.occlusion&&n.scene.markNeedsUpdateRendererDirty();let r=this.layers.find(e=>e.uuid===a);if(r){let o,s=t.layers.data(a);0===e.type&&("alpha"in e.props||"alphaOverride"in e.props)&&(o="alpha"in e.props?{...e.props,alpha:p(e.props.alpha,i,["material",this.uuid,"layer",a,"alpha"])}:{...e.props,alphaOverride:p(e.props.alphaOverride,i,["material",this.uuid,"alphaOverride"])}),r.updateByOp({...e,...o?{props:o}:{},path:e.path.slice(2)},s,n)&&this.reset0(t,n)}}}else this.reset0(t,n);Di.endContext(this)}applyMasks(){for(let e=0;e<this.layers.length;++e){let t=this.layers[e];t instanceof hl?t.color.mask=void 0:t instanceof vl&&(t.node.mask=void 0)}for(let e=0;e<this.layers.length;++e){let t=this.layers[e];if(t instanceof hl&&t.isMask.value&&t.data.visible&&e>0){let n=e-1,i=this.layers[n];i instanceof vl?i.node.mask=new aa(t.color,t.alpha,aa.MUL):i instanceof hl&&(i.isMask.value||(i.color.mask=new aa(t.color,t.alpha,aa.MUL)))}}}blendColors(){let e=this.layers.findIndex(e=>e instanceof hl),t=this.layers.findIndex(e=>e instanceof vl);if(-1!==e&&e<t){let n=this.layers[e].color;for(let i=e+1;i<t;++i){let e=this.layers[i];if(e instanceof hl){if(e.isMask.value)continue;n=new ds(n,e.color,e.alpha,e.mode)}}this.fragment.color=n}else this.fragment.color=void 0}blendAfterColors(){let e=new Qi("outgoingLight","f"),t=this.layers.findIndex(e=>e instanceof vl);if(this.layers.length>t+1){for(let n=t+1;n<this.layers.length;++n){let t=this.layers[n];if(t instanceof hl){if(t.isMask.value)continue;e=new ds(e,t.color,t.alpha,t.mode)}}this.fragment.afterColor=e}else this.fragment.afterColor=void 0}blendPositions(){let e=this.layers.filter(e=>e instanceof ml);if(e.length>0){let t=e[0].position;for(let n=1;n<e.length;++n)e[n]&&(t=new aa(t,e[n].position,aa.ADD),t=new aa(t,new ta(.5).setReadonly(!0),aa.MUL));this.fragment.position=t}else this.fragment.position=void 0}getDefines(){return this.defines}getUniforms(){return this.uniforms}getVertexShader(){return this.vertexShader}getFragmentShader(){return this.fragmentShader}onBeforeCompile(e){this.shapeBlendhack&&this.shapeBlendhack(this),e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.extensionDerivatives=!0===this.nodeExtensions.derivatives,e.extensionFragDepth=!0===this.nodeExtensions.fragDepth,e.extensionDrawBuffers=!0===this.nodeExtensions.drawBuffers,e.extensionShaderTextureLOD=!0===this.nodeExtensions.shaderTextureLOD}clampUniformsForPreview(e,t){let n=(e,t,n)=>Math.min(Math.max(e,t),n);for(let i of this.layers)if("displace"===i.type){let a=n(i.uniforms[`f${i.id}_intensity`].value,e,t);i.uniforms[`f${i.id}_intensity`].value=a}}updateFrame(e){for(let t=0;t<this.updaters.length;++t)e.updateNode(this.updaters[t])}build(){let e=new Ta;e.needsJitter=this.needsJitter,this.lights=this.lightLayer.data.visible,e.build(this.fragment,this.fragment),this.vertexShader=e.getCode("vertex"),this.fragmentShader=e.getCode("fragment"),this.defines=e.defines,this.uniforms=e.uniforms,this.nodeExtensions=e.extensions,this.updaters=e.updaters;for(let e of this.flavors)e&&e.updateAfterBuild();return this.shadersPatchedForShapeBlend=!1,this}nodeMaterialDispose(){this.layers.forEach(e=>e.dispose());for(let e of this.syntheticMapLayers.values())e.dispose();this.syntheticMapLayers.clear(),super.dispose();for(let e of this.flavors)e&&e.dispose()}assetsLoaded(){for(let e of this.layers)if(e instanceof hl){let t=e.params.texture;if(t instanceof as&&!t.image.loaded)return!1}for(let e of this.syntheticMapLayers.values()){let t=e.params?.texture;if(t instanceof as&&!t.image.loaded)return!1}return!0}};Object.defineProperties(Sl.prototype,{properties:{get:function(){return this.fragment.properties}}});var El=class extends wl{constructor(e,t,n){super(e,t,!1),this.isClassicSharedMaterial=!0,this.uuid=n,this.allowVariableSaves=!0,this.saveVariableLocations(t)}},Ml="\nvec2 receiverPlaneDepthBias(vec3 dcdx, vec3 dcdy)\n{\n float det = dcdx.x * dcdy.y - dcdx.y * dcdy.x;\n \n \n float invDet = 1.0 / (abs(det) < 1e-10 ? (det < 0.0 ? -1e-10 : 1e-10) : det);\n return vec2(\n (dcdy.y * dcdx.z - dcdx.y * dcdy.z) * invDet,\n (dcdx.x * dcdy.z - dcdy.x * dcdx.z) * invDet\n );\n}\n\n\n\n\nfloat receiverPlaneAdjust(vec2 dzduv, vec2 offset)\n{\n return clamp(dot(dzduv, offset), -0.05, 0.05);\n}\n",yl=globalThis,Cl=yl.__SPE_ORIGINAL_LIGHTS_FRAGMENT_BEGIN__??(yl.__SPE_ORIGINAL_LIGHTS_FRAGMENT_BEGIN__=ya.lights_fragment_begin),Rl=yl.__SPE_ORIGINAL_SHADOWMASK_PARS__??(yl.__SPE_ORIGINAL_SHADOWMASK_PARS__=ya.shadowmask_pars_fragment),Al=yl.__SPE_ORIGINAL_SHADOWMAP_PARS__??(yl.__SPE_ORIGINAL_SHADOWMAP_PARS__=ya.shadowmap_pars_fragment),Pl=null,Dl=()=>{let e=Al.replaceAll("vogelDiskSample","spStockVogelDiskSample").replaceAll("interleavedGradientNoise","spStockInterleavedGradientNoise"),t=e.indexOf("#if defined( SHADOWMAP_TYPE_PCF )"),n=e.indexOf("#elif defined( SHADOWMAP_TYPE_VSM )");if(t<0||n<=t)return e;let i=e.slice(t,n),a=i.replace(/texture\( shadowMap, vec3\( shadowCoord\.xy \+ spStockVogelDiskSample\( ([0-4]), 5, phi \) \* radius, shadowCoord\.z \) \)/g,"texture( shadowMap, vec3( shadowCoord.xy + spStockOffset$1, shadowCoord.z + receiverPlaneAdjust( spStockDzduv, spStockOffset$1 ) ) )"),r="float phi = spStockInterleavedGradientNoise( gl_FragCoord.xy ) * PI2;";return a!==i&&a.includes(r)?(i=a.replace(r,r+"\n\t\t\t\tvec2 spStockDzduv = receiverPlaneDepthBias( dFdx( shadowCoord.xyz ), dFdy( shadowCoord.xyz ) );\n\t\t\t\tvec2 spStockOffset0 = spStockVogelDiskSample( 0, 5, phi ) * radius;\n\t\t\t\tvec2 spStockOffset1 = spStockVogelDiskSample( 1, 5, phi ) * radius;\n\t\t\t\tvec2 spStockOffset2 = spStockVogelDiskSample( 2, 5, phi ) * radius;\n\t\t\t\tvec2 spStockOffset3 = spStockVogelDiskSample( 3, 5, phi ) * radius;\n\t\t\t\tvec2 spStockOffset4 = spStockVogelDiskSample( 4, 5, phi ) * radius;"),i=i.replace("#if defined( SHADOWMAP_TYPE_PCF )",Ml+"\n#if defined( SHADOWMAP_TYPE_PCF )"),e.slice(0,t)+i+e.slice(n)):e},Ll="\n\n // Linear Fade In\n float linearFadeIn(float t) {\n return t;\n }\n\n\n // linear fade out\n float linearFadeOut(float t) {\n return 1.0 - t;\n }\n \n float linearInOut(float t) {\n return t < 0.5 ? t : (1.0 - t); \n }\n\n // lerp\n float lerp(float a, float b, float t) {\n return a + (b - a) * t;\n }\n\n // Ease In Out Quart\n float exponentialInOut(float t) {\n return t < 0.4 ? lerp(0.0, 1.0, t / 0.4) :\n t > 0.6 ? lerp(1.0, 0.0, (t - 0.6) / 0.4) :\n 1.0;\n }\n\n // constant\n float constant(float t) {\n return 1.0;\n } \n",Ul=`\n uniform sampler2D uPosition;\n uniform float uSize;\n uniform float uSizeEnd;\n uniform vec3 uWorldOffset;\n uniform vec4 uWorldQuaternion;\n \n uniform float uRotation;\n uniform float uRotationEnd;\n uniform vec2 center;\n\n \n uniform float uRandScaleFactor;\n uniform float uRandRotationFactor;\n\n attribute vec2 ref;\n\n varying float v_LifeLeft; \n varying vec2 vUv;\n varying vec2 vRef;\n\n \n\nfloat rand(vec3 co){\n return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);\n}\n\nvec3 applyQuaternionToVector( vec4 q, vec3 v ){\n return v + 2.0 * cross( q.xyz, cross( q.xyz, v ) + q.w * v );\n}\n\nvec3 applyForce(vec3 force, float mass) {\n vec3 acceleration = force / mass;\n \n return acceleration;\n}\n\n ${Ll}\n`,Nl="\n uniform vec4 uColor; \n uniform vec4 uColor2; \n uniform sampler2D uTexture; \n varying float v_LifeLeft; \n varying vec2 vUv;\n varying vec2 vRef;\n\n float random(vec2 co) {\n return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);\n }\n "+Ll+" \n \nvec3 rgb2xyz (in vec3 rgb) {\n float r = rgb.r;\n\tfloat g = rgb.g;\n\tfloat b = rgb.b;\n\n\tr = r > 0.04045 ? pow(((r + 0.055) / 1.055), 2.4) : (r / 12.92);\n\tg = g > 0.04045 ? pow(((g + 0.055) / 1.055), 2.4) : (g / 12.92);\n\tb = b > 0.04045 ? pow(((b + 0.055) / 1.055), 2.4) : (b / 12.92);\n\n\tfloat x = (r * 0.4124) + (g * 0.3576) + (b * 0.1805);\n\tfloat y = (r * 0.2126) + (g * 0.7152) + (b * 0.0722);\n\tfloat z = (r * 0.0193) + (g * 0.1192) + (b * 0.9505);\n \n vec3 xyz = vec3(\n (r * 0.4124) + (g * 0.3576) + (b * 0.1805) * 100.0,\n (r * 0.2126) + (g * 0.7152) + (b * 0.0722) * 100.0,\n (r * 0.0193) + (g * 0.1192) + (b * 0.9505) * 100.0\n );\n return(xyz);\n}\n\nvec3 xyz2lab (in vec3 xyz) {\n\tfloat x = xyz.x / 95.047;\n\tfloat y = xyz.y / 100.0;\n\tfloat z = xyz.z / 108.883;\n\n\tx = x > 0.008856 ? pow(x, 1.0 / 3.0) : (7.787 * x) + (16.0 / 116.0);\n\ty = y > 0.008856 ? pow(y, 1.0 / 3.0) : (7.787 * y) + (16.0 / 116.0);\n\tz = z > 0.008856 ? pow(z, 1.0 / 3.0) : (7.787 * z) + (16.0 / 116.0);\n\n vec3 lab = vec3((116.0 * y) - 16.0, 500.0 * (x - y), 200.0 * (y - z));\n return(lab);\n}\n\nvec3 rgb2lab(in vec3 rgb) {\n vec3 xyz = rgb2xyz(rgb);\n vec3 lab = xyz2lab(xyz);\n return(lab);\n}\n\nvec3 xyz2rgb (in vec3 xyz) {\n\tfloat x = xyz.x / 100.0;\n\tfloat y = xyz.y / 100.0;\n\tfloat z = xyz.z / 100.0;\n\t\n \n\tfloat r = (x * 3.2406) + (y * -1.5372) + (z * -0.4986);\n\tfloat g = (x * -0.9689) + (y * 1.8758) + (z * 0.0415);\n\tfloat b = (x * 0.0557) + (y * -0.2040) + (z * 1.0570);\n\n\tr = r > 0.0031308 ? ((1.055 * pow(r, 1.0 / 2.4)) - 0.055) : r * 12.92;\n\tg = g > 0.0031308 ? ((1.055 * pow(g, 1.0 / 2.4)) - 0.055) : g * 12.92;\n\tb = b > 0.0031308 ? ((1.055 * pow(b, 1.0 / 2.4)) - 0.055) : b * 12.92;\n\n\tr = min(max(0.0, r), 1.0);\n\tg = min(max(0.0, g), 1.0);\n\tb = min(max(0.0, b), 1.0);\n\n\treturn(vec3(r, g, b));\n}\n\nvec3 lab2xyz (in vec3 lab) {\n float l = lab.x;\n\tfloat a = lab.y;\n\tfloat b = lab.z;\n\n \tfloat y = (l + 16.0) / 116.0;\n\tfloat x = a / 500.0 + y;\n\tfloat z = y - b / 200.0;\n\n\tfloat y2 = pow(y, 3.0);\n\tfloat x2 = pow(x, 3.0);\n\tfloat z2 = pow(z, 3.0);\n\n \ty = y2 > 0.008856 ? y2 : (y - 16.0 / 116.0) / 7.787;\n\tx = x2 > 0.008856 ? x2 : (x - 16.0 / 116.0) / 7.787;\n\tz = z2 > 0.008856 ? z2 : (z - 16.0 / 116.0) / 7.787;\n\n\tx *= 95.047;\n\ty *= 100.0;\n\tz *= 108.883;\n\n\treturn(vec3(x, y, z));\n}\nvec3 lab2rgb (in vec3 lab) {\n vec3 xyz = lab2xyz(lab);\n vec3 rgb = xyz2rgb(xyz);\n return(rgb);\n}\n\n\n\n",Il=class extends Xt{constructor(e,t){super(),this.needsJitter=!0,this.type="ParticleMaterial",this.nodeExtensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.easeOpacity="linearFadeIn",this.easeSize="linearFadeIn",this.useSizeEnd=!1,this.isColoringRandom=!1,this.init(e,t),this.context=t}reset(){}init(e,t){this.transparent=!0,this.depthTest=!0,this.depthWrite=!1,this.easeOpacity=e.ease,this.easeSize=e.easeSize,this.layers=[],Di.startContext(Di.globalContext),this.lightLayer=new vl(0,"",{...y.defaultData("light","phong"),visible:!1},new Js,{},t.shared),Di.endContext(Di.globalContext),this.build()}updateState(e){void 0!==e.coloring&&(this.isColoringRandom="random"===e.coloring),void 0!==e.color&&(e.color instanceof Array?this.uniforms.uColor.value=e.color:this.uniforms.uColor.value=this.context.shared.color(e.color)),void 0!==e.color2&&(e.color2 instanceof Array?this.uniforms.uColor2.value=e.color2:this.uniforms.uColor2.value=this.context.shared.color(e.color2)),void 0!==e.size&&(this.uniforms.uSize.value=e.size[0],this.uniforms.uSizeEnd.value=e.size[1],e.size[0]!==e.size[1]?this.useSizeEnd=!0:this.useSizeEnd=!1),void 0!==e.ease&&(this.easeOpacity=e.ease,this.build()),void 0!==e.easeSize&&(this.easeSize=e.easeSize,this.build()),this.needsUpdate=!0}onBeforeCompile(e){this.build(),e.defines=this.defines,e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader}build(){let e=new Ta;return e.needsJitter=this.needsJitter,e.addFragmentParsCode("\nlayout(location = 1) out vec4 gVelocity;\n"),e.buildShader("vertex",this.fragment),e.buildShader("fragment",this.fragment),e.addFragmentFinalCode("\n \n if (gl_FragColor.a <= 0.0) discard;\n\n gVelocity = vec4(0.0, 0.0, 0.0, 1.0);\n"),this.isColoringRandom&&e.define("USE_RANDOM_COLORING"),this.useSizeEnd&&e.define("USE_SIZE_END"),e.addVertexParsCode(Ul),e.addFragmentParsCode(Nl),e.addVertexFinalCode((({easeSize:e="linearFadeOut"})=>`\n vUv = uv; \n vRef = ref;\n \n float lifeLeft = texture2D(uPosition, ref).w;\n v_LifeLeft = lifeLeft;\n \n vec3 pos = texture2D(uPosition, ref).rgb - uWorldOffset;\n \n pos = applyQuaternionToVector(uWorldQuaternion, pos); \n \n #ifdef USE_SIZE_END\n \n float t = 1. - lifeLeft;\n float currentSize = mix(uSize, uSizeEnd, t); \n vec3 scaledPosition = position * vec3(currentSize);\n #else\n \n float easeSize = ${e}(1. - lifeLeft);\n \n vec3 scaledPosition = position * vec3(uSize * easeSize);\n #endif\n\n \n vec2 scale;\n scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) ); \n \n float randRef = rand(ref);\n scale *= (1.0 - (uRandScaleFactor * randRef));\n \n float randRotation = 2.0 * PI * ( uRandRotationFactor * randRef);\n float originalRotation = (1.0 - uRotation) * 2.0 * PI;\n float originalRotationEnd = (1.0 - uRotationEnd) * 2.0 * PI;\n \n float finalRotation = mix(originalRotation + randRotation, originalRotationEnd + randRotation, lifeLeft);\n\n vec2 alignedPosition = ( scaledPosition.xy - ( center - vec2( 0.5 ) ) ) * scale;\n vec2 rotatedPosition;\n rotatedPosition.x = cos( finalRotation ) * alignedPosition.x - sin( finalRotation ) * alignedPosition.y;\n rotatedPosition.y = sin( finalRotation ) * alignedPosition.x + cos( finalRotation ) * alignedPosition.y;\n \n mat4 instanceMatrix = mat4(\n vec4(1.0, 0.0, 0.0, 0.0),\n vec4(0.0, 1.0, 0.0, 0.0),\n vec4(0.0, 0.0, 1.0, 0.0),\n vec4(pos.x, pos.y, pos.z, 1.0)\n ); \n\n mvPosition = modelViewMatrix * instanceMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n mvPosition.xy += rotatedPosition;\n gl_Position = projectionMatrix * mvPosition; \n`)({easeSize:this.easeSize})),e.addFragmentFinalCode((({easeOpacity:e="linearFadeOut"})=>` \n \n if (v_LifeLeft <= 0.005 ) {\n discard;\n }\n\n #ifdef USE_RANDOM_COLORING\n float randVal = random(vRef); \n vec4 color = mix(uColor, uColor2, randVal); \n #else\n vec4 color = mix(uColor, uColor2, 1. - v_LifeLeft);\n #endif\n\n \n float finalAlpha = ${e}(1. - v_LifeLeft); \n vec4 textureColor = texture2D(uTexture, vUv).rgba; \n finalColor = textureColor.rgb * color.rgb;\n finalAlpha = color.a * textureColor.a * finalAlpha;\n \n gl_FragColor = vec4(finalColor, finalAlpha); \n\n`)({easeOpacity:this.easeOpacity})),this.vertexShader=e.getCode("vertex"),this.fragmentShader=e.getCode("fragment"),this.defines=e.defines,this.uniforms={...e.uniforms,...this.uniforms},this.nodeExtensions=e.extensions,this}get nodeMaterial(){return this}get fragment(){return this.lightLayer.node}getDefines(){return this.defines}nodeMaterialDispose(){this.layers.forEach(e=>e.dispose()),super.dispose()}},Ol=new ie(-1,1,1,-1,0,1),Fl=new class extends Kt{constructor(){super(),this.setAttribute("position",new Vt([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Vt([0,2,0,0,2,0],2))}},zl=class{constructor(e){this._mesh=new Pn(Fl,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,Ol)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}},Bl=class{constructor(e,t,n){this.variables=[],this.currentTextureIndex=0;let i=ee,a={passThruTexture:{value:null}},r=l("uniform sampler2D passThruTexture;\n\nvoid main() {\n\n\tvec2 uv = gl_FragCoord.xy / resolution.xy;\n\n\tgl_FragColor = texture2D( passThruTexture, uv );\n\n}\n",a),o=new zl(r);function s(n){n.defines.resolution="vec2( "+e.toFixed(1)+", "+t.toFixed(1)+" )"}function l(e,t){let n=new Xt({name:"GPUComputationShader",uniforms:t=t||{},vertexShader:"void main()\t{\n\n\tgl_Position = vec4( position, 1.0 );\n\n}\n",fragmentShader:e});return s(n),n}this.setDataType=function(e){return i=e,this},this.addVariable=function(e,t,n){let i={name:e,initialValueTexture:n,material:this.createShaderMaterial(t),dependencies:null,renderTargets:[],wrapS:null,wrapT:null,minFilter:On,magFilter:On};return this.variables.push(i),i},this.setVariableDependencies=function(e,t){e.dependencies=t},this.init=function(){if(0===n.capabilities.maxVertexTextures)return"No support for vertex shader textures.";for(let n=0;n<this.variables.length;n++){let i=this.variables[n];i.renderTargets[0]=this.createRenderTarget(e,t,i.wrapS,i.wrapT,i.minFilter,i.magFilter),i.renderTargets[1]=this.createRenderTarget(e,t,i.wrapS,i.wrapT,i.minFilter,i.magFilter),this.renderTexture(i.initialValueTexture,i.renderTargets[0]),this.renderTexture(i.initialValueTexture,i.renderTargets[1]);let a=i.material,r=a.uniforms;if(null!==i.dependencies)for(let e=0;e<i.dependencies.length;e++){let t=i.dependencies[e];if(t.name!==i.name){let e=!1;for(let n=0;n<this.variables.length;n++)if(t.name===this.variables[n].name){e=!0;break}if(!e)return"Variable dependency not found. Variable="+i.name+", dependency="+t.name}r[t.name]={value:null},a.fragmentShader="\nuniform sampler2D "+t.name+";\n"+a.fragmentShader}}return this.currentTextureIndex=0,null},this.compute=function(){let e=this.currentTextureIndex,t=0===this.currentTextureIndex?1:0;for(let n=0,i=this.variables.length;n<i;n++){let i=this.variables[n];if(null!==i.dependencies){let t=i.material.uniforms;for(let n=0,a=i.dependencies.length;n<a;n++){let a=i.dependencies[n];t[a.name].value=a.renderTargets[e].texture}}this.doRenderTarget(i.material,i.renderTargets[t])}this.currentTextureIndex=t},this.getCurrentRenderTarget=function(e){return e.renderTargets[this.currentTextureIndex]},this.getAlternateRenderTarget=function(e){return e.renderTargets[0===this.currentTextureIndex?1:0]},this.dispose=function(){o.dispose();let e=this.variables;for(let t=0;t<e.length;t++){let n=e[t];n.initialValueTexture&&n.initialValueTexture.dispose();let i=n.renderTargets;for(let e=0;e<i.length;e++)i[e].dispose();n.material.dispose()}},this.addResolutionDefine=s,this.createShaderMaterial=l,this.createRenderTarget=function(n,a,r,o,s,l){return new Xe(n=n||e,a=a||t,{wrapS:r=r||Rn,wrapT:o=o||Rn,minFilter:s=s||On,magFilter:l=l||On,format:Ie,type:i,depthBuffer:!1})},this.createTexture=function(){let n=new Float32Array(e*t*4),i=new Bn(n,e,t,Ie,ee);return i.needsUpdate=!0,i},this.renderTexture=function(e,t){a.passThruTexture.value=e,this.doRenderTarget(r,t),a.passThruTexture.value=null},this.doRenderTarget=function(e,t){let i=n.getRenderTarget(),a=n.xr.enabled,s=n.shadowMap.autoUpdate;n.xr.enabled=!1,n.shadowMap.autoUpdate=!1,o.material=e,n.setRenderTarget(t),o.render(n),o.material=r,n.xr.enabled=a,n.shadowMap.autoUpdate=s,n.setRenderTarget(i)}}};function Vl(e,t,n,i){let a=n,r="texture"===a.type?null!=a.texture.image?i.uiBuffer(a.texture.image)??i.image(a.texture.image):i.getImage(""):i.video(a.texture.video),o=new as(r,a.texture.wrapping??("texture"===a.type?1e3:1001),a.texture.minFilter??1008,a.texture.magFilter??1006),s=new is(r),l=new ls(fl(a.texture.repeat??[1,1],i),fl(a.texture.offset??[0,0],i),h(a.texture.rotation??0,i)),c=new ta(a.crop?1:0),d=new wa(a.projection??0),u=new wa(["x","y","z"].indexOf(a.axis)??0),f=a.projectionAxis?["x","y","z"].indexOf(a.projectionAxis):-1,m=new wa(a.side??0),v=new zi(a.size?new pe(...fl(a.size,i)):new pe(100,100)),g=new ta(a.blending??0),_=new ta(p(a.alpha,i)),x=new wa(a.mode??0),S=new es(a.isMask??!1),T=new gs(o,s,c,d,u,m,v,g,l,_,x,S,f),b=new Qi(T.calpha,"f");return new hl(e,t,a,{texture:o,textureSize:s,crop:c,projection:d,axis:u,side:m,size:v,blending:g,mat:l,alpha:_,mode:x,isMask:S},T,x,b,S,i)}a({createMaterial:(e,t)=>new Il(e,t),createComputation:(e,t,n)=>new Bl(e,t,n)}),rl("texture",Vl),rl("video",Vl),rl("matcap",(e,t,n,i)=>{let a=n,r=null!=a.texture.image?i.image(a.texture.image):i.getImage(""),o=new as(r,a.texture.wrapping??1001,a.texture.minFilter??1008,a.texture.magFilter??1006),s=new ta(p(a.alpha,i)),l=new wa(a.mode??0),c=new es(a.isMask??!1),d=new ta((h(a.texture.rotation??0,i)??0)*ce.DEG2RAD),u=new As(o,s,l,c,d),f=new Qi(u.calpha,"f");return new hl(e,t,a,{texture:o,alpha:s,mode:l,isMask:c,rotation:d},u,l,f,c,i)}),rl("displace",(e,t,n,i)=>{let a=n;if("noise"===a.displacementType){let n=new Bi(new Te(...a.offset.map(e=>h(e,i)??0))),r=new ta(h(a.scale,i)??10),o=new ta(h(a.intensity,i)??8),s=new ta(h(a.movement,i)??1),l=new wa(a.noiseType??0),c=new wa(a.voronoiStyle??0),d=new ta(h(a.smoothness,i)??.5),u=new ta(h(a.seed,i)??0),f=new ta(h(a.highCut,i)??1),p=new ta(h(a.lowCut,i)??0),m=new wa(h(a.quality,i)??1),v=new $s(o,s,n,c,d,u,f,p,m,r,l);return new ml(e,t,a,{offset:n,scale:r,intensity:o,movement:s,noiseType:l,voronoiStyle:c,smoothness:d,seed:u,highCut:f,lowCut:p,quality:m},v,i)}throw new Error}),rl("cavity",(e,t,i,a)=>{let r=n(i,a),o=new ta(h(r.ridge,a)??1),s=new ta(h(r.valley,a)??1),l=gl(r),c=new Ts(o,s,qs.normalViewRenderTarget,qs.resolution,l.alpha,l.mode,l.isMask),d=new Qi(c.calpha,"f");return new hl(e,t,i,{ridge:o,valley:s,...l},c,l.mode,d,l.isMask,a)}),rl("dust",(e,t,i,a)=>{let r=n(i,a),o=new ba(r.color??10323813),s=new ta(r.coverage??.2),l=new ta(r.softness??.2),c=new ta(r.noiseStrength??.2),d=new ta(r.noiseScale??1),u=gl(r),f=new Es(o,s,l,c,d,u.alpha,u.isMask),p=new Qi(f.calpha,"f");return new hl(e,t,i,{color:o,coverage:s,softness:l,noiseStrength:c,noiseScale:d,...u},f,u.mode,p,u.isMask,a)}),rl("fresnel",(e,t,i,a)=>{let r=n(i,a),o=new ba(r.color??16777215),s=new ta(h(r.bias,a)??.1),l=new ta(h(r.scale,a)??1),c=new ta(h(r.intensity,a)??2),d=new ta(h(r.factor,a)??1),u=gl(r),f=new Ms(o,s,l,c,d,u.alpha,u.mode,u.isMask),p=new Qi(f.calpha,"f");return new hl(e,t,i,{color:o,bias:s,scale:l,intensity:c,factor:d,...u},f,u.mode,p,u.isMask,a)}),rl("gradient",(e,t,i,a)=>{let r,o,s=n(i,a),l=new wa(s.gradientType??0),c=new es(s.smooth??!1);s.colors?r=new cs(s.colors.length,s.colors):(r=new cs(10,new Fe(0,0,0,1)),r.value[1]=new Fe(1,1,1,1)),s.steps?o=new ts(s.steps.length,s.steps):(o=new ts(10,1),o.value[0]=0);let d=new zi(ul(s.offset??new pe(0,0),a)),u=new zi(ul(s.morph??new pe(0,0),a)),f=new ta(h(s.angle??0,a)),p=gl(s),m=new Cs(l,c,r,o,d,u,f,p.alpha,p.isMask),v=new Qi(m.calpha,"f");return new hl(e,t,i,{gradientType:l,smooth:c,colors:r,steps:o,offset:d,morph:u,angle:f,...p},m,p.mode,v,p.isMask,a)}),rl("depth",(e,t,i,a)=>{let r,o,s=n(i,a),l=new wa(s.gradientType??0),c=new es(s.smooth??!1),d=new ta(h(s.near,a)??50),u=new ta(h(s.far,a)??200),f=new ta(s.isVector??1),p=new ta(s.isWorldSpace??0),m=new Bi(dl(s.origin,a)),v=new Bi(dl(s.direction,a));s.colors?r=new cs(s.colors.length,s.colors):(r=new cs(2,new Fe(0,0,0,1)),r.value[1]=new Fe(1,1,1,1)),s.steps?o=new ts(s.steps.length,s.steps):(o=new ts(2,1),o.value[0]=0);let g=gl(s),_=new xs(l,c,d,u,f,p,m,v,r,o,g.alpha,g.isMask),x=new Qi(_.calpha,"f");return new hl(e,t,i,{gradientType:l,smooth:c,near:d,far:u,isVector:f,isWorldSpace:p,origin:m,direction:v,colors:r,steps:o,...g},_,g.mode,x,g.isMask,a)}),rl("normal",(e,t,i,a)=>{let r=n(i,a),o=new Bi(r.cnormal??new Te(1,1,1)),s=gl(r),l=new hs(o,s.alpha),c=new Qi(l.calpha,"f");return new hl(e,t,i,{cnormal:o,...s},l,s.mode,c,s.isMask,a)}),rl("noise",(e,t,i,a)=>{let r=n(i,a),o=new ta(h(r.scale,a)??1),s=new Bi(dl(r.size??new Te(100,100,100),a)),l=new ta(h(r.move,a)??1),c=new zi(ul(r.fA??new pe(1.7,9.2),a)),d=new zi(ul(r.fB??new pe(8.3,2.8),a)),u=new zi(ul(r.distortion??new pe(1,1),a)),f=new Vi(r.colorA),p=new Vi(r.colorB),m=new Vi(r.colorC),v=new Vi(r.colorD),g=new wa(r.noiseType??0),_=new wa(r.voronoiStyle??0),x=new ta(h(r.highCut,a)??1),S=new ta(h(r.lowCut,a)??0),T=new ta(h(r.smoothness,a)??.5),b=new ta(h(r.seed,a)??.5),w=new wa(r.quality??1),E=gl(r),M=new Ps(o,s,l,c,d,u,f,p,m,v,E.alpha,g,E.isMask,_,x,S,T,b,w),y=new Qi(M.calpha,"f");return new hl(e,t,i,{scale:o,size:s,move:l,fA:c,fB:d,distortion:u,colorA:f,colorB:p,colorC:m,colorD:v,noiseType:g,...E,voronoiStyle:_,highCut:x,lowCut:S,smoothness:T,seed:b,quality:w},M,E.mode,y,E.isMask,a)}),rl("rainbow",(e,t,i,a,r)=>{let o=n(i,a),s=new ta(h(o.filmThickness,a)??30),l=new ta(h(o.movement,a)??0),c=new Bi(dl(o.wavelengths,a)),d=new ta(h(o.noiseStrength,a)??0),u=new ta(h(o.noiseScale,a)??1),f=new Bi(dl(o.offset,a)),p=gl(o),m=!0===r?.forceRainbowNoise,g=m||v(o.noiseStrength),_=new Os(s,l,c,d,u,f,p.alpha,p.isMask,g),x=new Qi(_.calpha,"f"),S=new hl(e,t,i,{filmThickness:s,movement:l,wavelengths:c,noiseStrength:d,noiseScale:u,offset:f,...p},_,p.mode,x,p.isMask,a);return S.noiseCompiledIn=g,S.noiseForced=m,S}),rl("toon",(e,t,i,a)=>{let r,o,s=n(i,a),l=new wa(s.positioning??0);s.colors?r=new cs(s.colors.length,s.colors):(r=new cs(10,new Fe(0,0,0,1)),r.value[1]=new Fe(1,1,1,1)),s.steps?o=new ts(s.steps.length,s.steps):(o=new ts(10,1),o.value[0]=0);let c=new Bi(dl(s.source??new Te(0,0,0),a)),d=new es(s.isWorldSpace??!0),u=new ta(h(s.noiseStrength??0,a)),f=new ta(h(s.noiseScale??1,a)),p=new Vi(s.shadowColor),m=new Bi(dl(s.offset??new Te(0,0,0),a)),v=gl(s),g=new zs(l,r,o,c,d,u,f,p,m,v.alpha),_=new Qi(g.calpha,"f");return new hl(e,t,i,{positioning:l,colors:r,steps:o,source:c,isWorldSpace:d,noiseStrength:u,noiseScale:f,shadowColor:p,offset:m,...v},g,v.mode,_,v.isMask,a)}),rl("outline",(e,t,i,a)=>{let r=n(i,a),o=new ba(r.outlineColor??16777215),s=new ba(r.contourColor??16777215),l=new ta(h(r.outlineWidth??.1,a)),c=new ta(h(r.contourWidth??.1,a)),d=new ta(h(r.outlineThreshold??.1,a)),u=new ta(h(r.contourThreshold??.1,a)),f=new ta(h(r.outlineSmoothing??.1,a)),p=new ta(h(r.contourFrequency??.1,a)),m=new Bi(dl(r.contourDirection??new Te(0,1,0),a)),v=new es(r.positionalLines??!1),g=new es(r.compensation??!0),_=qs.normalRenderTarget,x=qs.normalRenderTargetDepth,S=qs.pixelRatioNode,T=qs.resolution,b=gl(r),w=new Ls(o,s,l,c,d,u,f,p,m,v,g,T,_,x,S,b.alpha),E=new Qi(w.calpha,"f");return new hl(e,t,i,{outlineColor:o,contourColor:s,outlineWidth:l,contourWidth:c,outlineThreshold:d,contourThreshold:u,outlineSmoothing:f,contourFrequency:p,contourDirection:m,positionalLines:v,compensation:g,...b},w,b.mode,E,b.isMask,a)}),rl("transmission",(e,t,i,a)=>{let r=n(i,a),o=new ta(h(r.thickness??10,a)),s=new ta(h(r.ior??1.5,a)),l=new ta(h(r.roughness??.5,a)),c=qs.transmissionSize,d=qs.transmissionRenderTarget,u=qs.transmissionRenderTargetDepth,f=window.innerWidth,p=window.innerHeight,m=f>=p?new zi(p/f,1):new zi(1,f/p),v=gl(r),g=new Hs(o,s,l,c,d,u,m,v.alpha),_=new Qi(g.calpha,"f");return new hl(e,t,i,{thickness:o,ior:s,roughness:l,aspectRatio:m,...v},g,v.mode,_,v.isMask,a)});var Hl=!1;rl("reflection",(e,t,i,a)=>{Hl||(Hl=!0,console.warn("[spline] The reflection material layer requires the WebGPU renderer — it renders as invisible on the classic WebGL pipeline."));let r=n(i,a),o=new ta(r.blur??0),s=new ta(r.thickness??.001),l=new wa(r.steps??60),c=new ta(r.stepSize??.005),d=new wa(r.tracingMode??1),u=gl(r),f=new ba(0,0,0,1),p=new ta(0),h=new fs(f,p),m=new Qi(h.calpha,"f");return new hl(e,t,i,{blur:o,thickness:s,steps:l,stepSize:c,tracingMode:d,...u},h,u.mode,m,u.isMask,a)}),rl("pattern",(e,t,i,a)=>{let r=n(i,a),o=new wa(r.style??0),s=new wa(r.projection??0),l=new wa(["x","y","z"].indexOf(r.axis)??0),c=new ta(h(r.blending??0,a)),d=new zi(ul(r.offset,a)),u=new Vi(r.colorA),f=new Vi(r.colorB),p=new zi(ul(r.frequency??new pe(10,10),a)),m=new ta(h(r.size??.5,a)),v=new ta(h(r.variation??0,a)),g=new ta(h(r.smoothness??.5,a)),_=new ta(h(r.zigzag??0,a)),x=new ta(h(r.rotation??0,a)),S=new zi(ul(r.vertical??new pe(0,1),a)),T=new zi(ul(r.horizontal??new pe(0,1),a)),b=new wa(r.sides??6),w=gl(r),E=new Ns(o,s,l,c,d,u,f,p,m,v,g,_,x,S,T,b,w.alpha,w.isMask),M=new Qi(E.calpha,"f");return new hl(e,t,i,{style:o,projection:s,axis:l,blending:c,offset:d,colorA:u,colorB:f,frequency:p,size:m,variation:v,smoothness:g,zigzag:_,rotation:x,vertical:S,horizontal:T,sides:b,...w},E,w.mode,M,w.isMask,a)}),rl("vertexColor",(e,t,i,a)=>{let r=gl(n(i,a)),o=new ks(r.alpha),s=new Qi(o.calpha,"f");return new hl(e,t,i,{...r},o,r.mode,s,r.isMask,a)}),c({createRootMaterial:(e,t)=>new wl(e,t),createSharedMaterial:(e,t,n)=>new El(e,t,n)}),u((e,t)=>e?((e="medium")=>{if(Pl===e)return!1;Pl=e;let t=(e=>{switch(e){case"low":return 8;case"medium":default:return 16;case"high":return 32}})(e);ya.shadowmap_pars_fragment=(e=>`\n\n// PCSS implementation based on:\n// https://www.gamedev.net/articles/programming/graphics/contact-hardening-soft-shadows-made-fast-r4906/\n// NOTE: This number affects how big the shadow blur can\n// possibly get. Bigger number == bigger blur, but less precise results\n\nconst float gPenumbraFilterSize = 80.0;\n// Blocker search at half the PCF budget (min 4): the average-blocker-depth\n// estimate feeds the squared/clamped penumbra term, which tolerates far\n// more estimator variance than the visible PCF edge — and the per-frame\n// vogel rotation integrates the residual under TAA. The reduced count is\n// ALSO the vogelDiskSample count in computePenumbra so the sparser spiral\n// still spans the full search radius (classic N with i < N/2 would only\n// cover the inner sqrt(1/2) of the disk and miss far blockers). Mirrors\n// the WebGPU filter's split (splinePCSS.ts blockerSampleCount).\nconst int gPenumbraSamples = ${Math.max(4,e>>1)};\nconst int gShadowSamples = ${e};\nconst float gShadowSamplesRpc = 1.0f / float(gShadowSamples);\n\n#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n\n uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\n struct DirectionalLightShadow {\n // Field order must match three r185's stock struct\n // (shadowmap_pars_vertex) or the uniform layout differs between the\n // vertex and fragment stages. shadowIntensity was added in r185.\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n\n uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\n #endif\n\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n\n uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\n struct SpotLightShadow {\n // Field order must match three r185's stock struct\n // (shadowmap_pars_vertex) or the uniform layout differs between the\n // vertex and fragment stages. shadowIntensity was added in r185.\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n\n uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\n #endif\n\n #if NUM_POINT_LIGHT_SHADOWS > 0\n\n // r185 renders point-light shadows into a cube render target with a\n // CubeDepthTexture (WebGLShadowMap always uses WebGLCubeRenderTarget\n // for point lights), so the map binds as a cube sampler — the old\n // 2D cube-atlas (cubeToUV) layout no longer exists. BasicShadowMap\n // leaves compareFunction null, so raw depth reads work.\n uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\n struct PointLightShadow {\n // Field order must match three r185's stock struct.\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n float shadowCameraNear;\n float shadowCameraFar;\n };\n\n uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\n #endif\n\n /*\n #if NUM_RECT_AREA_LIGHTS > 0\n\n // TODO (abelnation): create uniforms for area light shadows\n\n #endif\n */\n\n${Ml}\n\nfloat computePenumbra(int index, sampler2D shadowMap, float temporalAngle, float texelSize, vec2 uv, float compare, float texelScalar, float shadowRadius, vec2 dzduv)\n{\n float penumbra = 1.0;\n float blockerDepthAvg = 0.0;\n float blockerCount = 0.0;\n\n #pragma unroll_loop_start\n for(int i = 0; i < gPenumbraSamples; i ++)\n {\n vec2 offset = (vogelDiskSample(i, gPenumbraSamples, temporalAngle) * texelSize) * texelScalar;\n float depth = texture2D( shadowMap, uv + offset ).r;\n\n if(depth < compare + receiverPlaneAdjust(dzduv, offset) + 0.0001)\n {\n blockerDepthAvg += depth;\n blockerCount++;\n }\n }\n #pragma unroll_loop_end\n\n if (blockerCount > 0.0)\n {\n blockerDepthAvg /= blockerCount;\n\n \n penumbra = (compare - blockerDepthAvg) / (blockerDepthAvg);\n penumbra *= penumbra;\n penumbra *= 200.0 * penumbraSize[min(index, ${x} - 1)]; // Magic number that affects how quickly the penumbra grows\n\n return clamp(penumbra, 0.00, 1.0);\n }\n return 0.0;\n}\n\nfloat vogelShadow(int index, sampler2D shadowMap, vec2 uv, float texelSize, float compare, float shadowRadius, vec2 dzduv)\n{\n float shadow = 0.0f;\n\n // NOTE: When using TAA, we should use screen space interleaved gradient noise\n vec2 halton = haltonSequence[frameIndex];\n float temporalOffset = getNoiseInterleavedGradient(gl_FragCoord.xy + halton);\n float temporalAngle = temporalOffset * PI2;\n\n float texelScalar = (gPenumbraFilterSize) / (texelSize * 1024.);\n float penumbra = computePenumbra(index, shadowMap, temporalAngle, texelSize, uv, compare, texelScalar, shadowRadius, dzduv);\n if (penumbra == -1.0) {\n return 1.0;\n }\n\n #pragma unroll_loop_start\n for (int i = 0; i < gShadowSamples; i++)\n {\n vec2 vogelSample = vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize;\n // Overall blurring offset\n vec2 offset = vogelSample * (shadowRadius * 2.);\n\n // Penumbra offset\n offset += vogelSample * (penumbra * texelScalar);\n\n shadow += step( compare + receiverPlaneAdjust(dzduv, offset), texture2D( shadowMap, uv + offset ).r );\n }\n #pragma unroll_loop_end\n\n return shadow * gShadowSamplesRpc;\n}\n\n\n float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\n // r185: shadow maps are DepthTextures bound without compare mode\n // (BasicShadowMap), so depth is read directly from .r rather than from\n // an RGBA-packed encoding.\n return step( compare, texture2D( depths, uv ).r );\n\n }\n\n float textureCubeCompare( samplerCube depths, vec3 dir, float compare ) {\n\n float depth = textureCube( depths, dir ).r;\n\n #ifdef USE_REVERSED_DEPTH_BUFFER\n\n depth = 1.0 - depth;\n\n #endif\n\n return step( compare, depth );\n\n }\n\n vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\n return unpackRGBATo2Half( texture2D( shadow, uv ) );\n\n }\n\n float VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\n float occlusion = 1.0;\n\n vec2 distribution = texture2DDistribution( shadow, uv );\n\n float hard_shadow = step( compare , distribution.x ); // Hard Shadow\n\n if (hard_shadow != 1.0 ) {\n\n float distance = compare - distribution.x ;\n float variance = max( 0.00000, distribution.y * distribution.y );\n float softness_probability = variance / (variance + distance * distance ); // Chebeyshevs inequality\n softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); // 0.3 reduces light bleed\n occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\n }\n return occlusion;\n\n }\n\n float getShadow( int i, sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\n float shadow = 1.0;\n\n shadowCoord.xyz /= shadowCoord.w;\n shadowCoord.z += shadowBias;\n\n // Receiver-plane depth gradient — derivatives taken BEFORE the\n // frustum branch (well-defined across the quad) of the projected\n // coord, so the vogel taps can slope-correct their compares.\n vec2 dzduv = receiverPlaneDepthBias( dFdx( shadowCoord.xyz ), dFdy( shadowCoord.xyz ) );\n\n // if ( something && something ) breaks ATI OpenGL shader compiler\n // if ( all( something, something ) ) using this instead\n\n bvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n bool inFrustum = all( inFrustumVec );\n\n bvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\n bool frustumTest = all( frustumTestVec );\n\n if ( frustumTest ) {\n\n // SHADOWMAP_TYPE_BASIC included: on r185 the renderer must use\n // BasicShadowMap (PCFShadowMap binds the depth texture as a\n // sampler2DShadow with hardware compare, which this custom PCSS\n // sampling can't read from), so BASIC is the define our PCSS path\n // now runs under.\n #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC )\n\n vec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n return vogelShadow(i, shadowMap, shadowCoord.xy, texelSize.x, shadowCoord.z, shadowRadius, dzduv );\n\n #elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\n vec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n float dx = texelSize.x;\n float dy = texelSize.y;\n\n vec2 uv = shadowCoord.xy;\n vec2 f = fract( uv * shadowMapSize + 0.5 );\n uv -= f * texelSize;\n\n shadow = (\n texture2DCompare( shadowMap, uv, shadowCoord.z ) +\n texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n f.x ) +\n mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n f.x ) +\n mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n f.y ) +\n mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n f.y ) +\n mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n f.x ),\n mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n f.x ),\n f.y )\n ) * ( 1.0 / 9.0 );\n\n #elif defined( SHADOWMAP_TYPE_VSM )\n\n shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\n #else // no percentage-closer filtering:\n\n shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\n #endif\n\n }\n\n return shadow;\n\n }\n\n float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\n float shadow = 1.0;\n // Offset magnitude matches the pre-r185 2D cube-atlas texel size so the\n // blur radius is visually unchanged.\n vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\n // for point lights, the uniform @vShadowCoord is re-purposed to hold\n // the vector from the light to the world-space position of the fragment.\n vec3 lightToPosition = shadowCoord.xyz;\n\n // r185 cube shadow maps store perspective depth along the sampled\n // face's view axis (not radial distance): view-space depth is the\n // largest component of the light-to-fragment vector.\n vec3 absVec = abs( lightToPosition );\n float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n\n if ( viewSpaceZ - shadowCameraFar > 0.0 || viewSpaceZ - shadowCameraNear < 0.0 ) {\n\n return shadow;\n\n }\n\n // viewZ to perspective depth\n float compare = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n compare += shadowBias;\n\n // bd3D = base direction 3D\n vec3 bd3D = normalize( lightToPosition );\n\n vec2 halton = haltonSequence[frameIndex];\n float temporalOffset = getNoiseInterleavedGradient(gl_FragCoord.xy + halton);\n float temporalAngle = temporalOffset * PI2;\n\n #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_VSM ) || defined( SHADOWMAP_TYPE_BASIC )\n for (int i = 0; i < gShadowSamples; i++) {\n vec2 vogelSample = vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize;\n\n // Overall blurring offset\n vec3 offset = vec3(vogelSample.x, vogelSample.y, -vogelSample.x) * (shadowRadius + 5.);\n\n // NOTE: Removed for now\n // Penumbra offset\n //offset += vec3(vogelSample.x, vogelSample.y, vogelSample.y) * (penumbra * gPenumbraFilterSize);\n\n shadow += textureCubeCompare( shadowMap, bd3D + offset, compare );\n\n }\n return shadow * gShadowSamplesRpc;\n\n #elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n for (int i = 0; i < 16; i++) {\n vec2 vogelSample = vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize;\n\n // Overall blurring offset\n vec3 offset = vec3(vogelSample.x, vogelSample.y, -vogelSample.x) * (shadowRadius + 5.);\n\n shadow += textureCubeCompare( shadowMap, bd3D + offset, compare );\n\n }\n return shadow * (1.0 / 16.0);\n #else // no percentage-closer filtering\n\n return textureCubeCompare( shadowMap, bd3D, compare );\n\n #endif\n\n }\n\n#endif\n`)(t);let n=Cl.slice();n=n.replace("getShadow( spotShadowMap[ i ]",`getShadow( UNROLLED_LOOP_INDEX + ${S}, spotShadowMap[ i ]`),n=n.replace("getShadow( directionalShadowMap[ i ]","getShadow( UNROLLED_LOOP_INDEX, directionalShadowMap[ i ]"),ya.lights_fragment_begin=n;let i=Rl.slice();return i=i.replaceAll("getShadow(","getShadow( UNROLLED_LOOP_INDEX, "),ya.shadowmask_pars_fragment=i,!0})(t):(()=>{if(null===Pl||"off"===Pl){let e=null===Pl;return Pl="off",e&&(ya.shadowmap_pars_fragment=Dl()),!1}return Pl="off",ya.shadowmap_pars_fragment=Dl(),ya.lights_fragment_begin=Cl,ya.shadowmask_pars_fragment=Rl,!0})()),d(()=>{let e=new At;return e.depthWrite=!1,e.opacity=.5,e.onBeforeCompile=e=>{e.fragmentShader="layout(location = 1) out vec4 gVelocity;\n"+e.fragmentShader.replace("void main() {","void main() {\n\tgVelocity = vec4(0.0);")},e});var Gl="\nvec3 normal = (normalize(vNormal)).rgb;\n\nfloat contrastDepth = (gl_FragCoord.z - 0.5) * depthContrast + 0.5;\n\nvec3 resultColor = mix(mix(vColor, normal, 0.2), vec3(contrastDepth), 0.4);\n",kl="\nvec3 nv = normalize(vNormalView);\nif (!gl_FrontFacing) nv = -nv;\n",Wl=`\nuniform float depthContrast;\nvarying vec3 vNormal;\nvarying vec3 vNormalView;\nflat in vec3 vColor;\nvoid main()\n{\n${kl}\ngl_FragColor = vec4(nv, vColor.r);\n}\n`,Xl=`\nlayout(location = 1) out vec4 gViewNormal;\nuniform float depthContrast;\nvarying vec3 vNormal;\nvarying vec3 vNormalView;\nflat in vec3 vColor;\nvoid main()\n{\n${Gl}\ngl_FragColor = vec4(resultColor, vColor.r);\n\n${kl}\ngViewNormal = vec4(nv, vColor.r);\n}\n`,jl={value:1},$l=e=>new Xt({vertexShader:"\nattribute vec3 randomColor;\nvarying vec3 vNormal;\nvarying vec3 vNormalView;\nflat out vec3 vColor;\n#include <skinning_pars_vertex>\n#include <morphtarget_pars_vertex>\n\nvoid main()\n{\n#include <beginnormal_vertex>\n#include <morphnormal_vertex>\n#include <skinbase_vertex>\n#include <skinnormal_vertex>\nvec3 transformed = vec3(position);\n#include <morphtarget_vertex>\n#include <skinning_vertex>\n\n\n\n\n\nvec4 localPosition = vec4(transformed, 1.0);\n#ifdef USE_INSTANCING\nlocalPosition = instanceMatrix * localPosition;\nobjectNormal = mat3(instanceMatrix) * objectNormal;\n#endif\n\nvNormal = normal;\nvNormalView = normalMatrix * objectNormal;\nvColor = randomColor;\ngl_Position = projectionMatrix * (modelViewMatrix * localPosition);\n}\n",fragmentShader:e,uniforms:{depthContrast:jl}}),ql=$l(`\nuniform float depthContrast;\nvarying vec3 vNormal;\nvarying vec3 vNormalView;\nflat in vec3 vColor;\nvoid main()\n{\n${Gl}\ngl_FragColor = vec4(resultColor, vColor.r);\n}\n`),Yl=$l(Wl),Kl=$l(Xl),Zl="float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\n\tif ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\n\t\treturn pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\n\t}\n\n\treturn 1.0;\n\n}",Jl=/float getDistanceAttenuation\([^)]*\)\s*\{[\s\S]*?\n\}/,Ql=class extends Xt{constructor(){super({name:"PassthroughMaterial",uniforms:{inputBuffer:new je(null)},blending:Ln,depthWrite:!1,depthTest:!1,vertexShader:"#define GLSLIFY 1\nvarying vec2 vUv;void main(){gl_Position=vec4(position.xy,1.0,1.0);vUv=position.xy*0.5+0.5;}",fragmentShader:"#define GLSLIFY 1\nlayout(location=1)out vec4 gVelocity;varying vec2 vUv;uniform sampler2D inputBuffer;void main(){gl_FragColor=texture2D(inputBuffer,vUv);gVelocity=vec4(0.0);}"})}set inputBuffer(e){this.uniforms.inputBuffer.value=e}},ec=class extends U{constructor(){super("TAAResolvePass"),this.MRTCompatible=!0,this.needsSwap=!1,this.passThroughMaterial=new Ql,this.resolutionVector=new pe,this.resolveMaterial=new Xt({name:"TAAResolveMaterial",uniforms:{inputBuffer:new je(null),historyBuffer:new je(null),velocityBuffer:new je(null),depthBuffer:new je(null),resolution:new je(new pe)},blending:Ln,depthWrite:!1,depthTest:!1,vertexShader:"#define GLSLIFY 1\nvarying vec2 vUv;varying vec2 vTexCoords[9];uniform vec2 resolution;void main(){vUv=position.xy*0.5+0.5;vec2 texelSize=vec2(1.0)/resolution;vTexCoords[0]=vUv+vec2(-texelSize.x,-texelSize.y);vTexCoords[1]=vUv+vec2(0.0,-texelSize.y);vTexCoords[2]=vUv+vec2(texelSize.x,-texelSize.y);vTexCoords[3]=vUv+vec2(-texelSize.x,0.0);vTexCoords[4]=vUv+vec2(0.0,0.0);vTexCoords[5]=vUv+vec2(texelSize.x,0.0);vTexCoords[6]=vUv+vec2(-texelSize.x,texelSize.y);vTexCoords[7]=vUv+vec2(0.0,texelSize.y);vTexCoords[8]=vUv+vec2(texelSize.x,texelSize.y);gl_Position=vec4(position.xy,1.0,1.0);}",fragmentShader:"#define GLSLIFY 1\n#include <common>\nvarying vec2 vUv;varying vec2 vTexCoords[9];uniform sampler2D inputBuffer;uniform sampler2D historyBuffer;uniform sampler2D velocityBuffer;uniform sampler2D depthBuffer;uniform vec2 resolution;\n#define USE_YCOCG\n#define USE_CATMULL_ROM\nconst float feedback_min=0.5;const float feedback_max=0.95;vec3 RGB_YCoCg(vec3 c){return vec3(c.x/4.0+c.y/2.0+c.z/4.0,c.x/2.0-c.z/2.0,-c.x/4.0+c.y/2.0-c.z/4.0);}vec3 YCoCg_RGB(vec3 c){return clamp(vec3(c.x+c.y-c.z,c.x+c.z,c.x-c.y-c.z),vec3(0.0),vec3(1.0));}vec4 sample_color(sampler2D tex,vec2 uv){\n#ifdef USE_YCOCG\nvec4 c=texture(tex,uv);return vec4(RGB_YCoCg(c.rgb),c.a);\n#else\nreturn texture(tex,uv);\n#endif\n}vec4 sample_catmull_rom(sampler2D tex,vec2 uv,vec2 texSize){vec2 samplePos=uv*texSize;vec2 texPos1=floor(samplePos-0.5)+0.5;vec2 f=samplePos-texPos1;vec2 w0=f*(-0.5+f*(1.0-0.5*f));vec2 w1=1.0+f*f*(-2.5+1.5*f);vec2 w2=f*(0.5+f*(2.0-1.5*f));vec2 w3=f*f*(-0.5+0.5*f);vec2 w12=w1+w2;vec2 offset12=w2/(w1+w2);vec2 texPos0=texPos1-1.0;vec2 texPos3=texPos1+2.0;vec2 texPos12=texPos1+offset12;texPos0/=texSize;texPos3/=texSize;texPos12/=texSize;vec4 result=vec4(0.0);result+=texture2D(tex,vec2(texPos12.x,texPos0.y))*w12.x*w0.y;result+=texture2D(tex,vec2(texPos0.x,texPos12.y))*w0.x*w12.y;result+=texture2D(tex,vec2(texPos12.x,texPos12.y))*w12.x*w12.y;result+=texture2D(tex,vec2(texPos3.x,texPos12.y))*w3.x*w12.y;result+=texture2D(tex,vec2(texPos12.x,texPos3.y))*w12.x*w3.y;return result;}vec3 choose_motion_vector(){\n#ifdef CHOOSE_LONGEST_MOTION_VECTOR\nfloat longest=-1.0;vec3 v_choose=vec3(-1.0);for(int i=0;i<9;i++){vec3 v=texture2D(velocityBuffer,vTexCoords[i]).rgb;float l=length(v.xy);if(l>longest){longest=l;v_choose=v;}}return v_choose;\n#else\nfloat closest_depth=1000.0;vec2 closest_uv_offset=vec2(0.0);for(int i=0;i<9;i++){float neighbor_depth=texture2D(depthBuffer,vTexCoords[i]).r;if(neighbor_depth<closest_depth){closest_uv_offset=vTexCoords[i];closest_depth=neighbor_depth;}}return texture2D(velocityBuffer,closest_uv_offset).rgb;\n#endif\n}vec4 clipAabb(vec3 aabb_min,vec3 aabb_max,vec4 avg,vec4 input_texel){const float FLT_EPS=0.00000001;vec3 p_clip=0.5*(aabb_max+aabb_min);vec3 e_clip=0.5*(aabb_max-aabb_min)+FLT_EPS;vec4 v_clip=input_texel-vec4(p_clip,avg.w);vec3 v_unit=v_clip.xyz/e_clip;vec3 a_unit=abs(v_unit);float ma_unit=max(a_unit.x,max(a_unit.y,a_unit.z));if(ma_unit>1.0){return vec4(p_clip,avg.w)+v_clip/ma_unit;}else{return input_texel;}}vec3 clip_aabb_variance(in vec3 cOld,in vec3 cNew,in vec3 centre,in vec3 halfSize){if(all(lessThanEqual(abs(cOld-centre),halfSize))){return cOld;}vec3 dir=(cNew-cOld);vec3 near=centre-sign(dir)*halfSize;vec3 tAll=(near-cOld)/dir;float t=0.0001;for(int i=0;i<3;i++){if(tAll[i]>=0.0&&tAll[i]<t){t=tAll[i];}}if(t>=0.0001){return cOld;}return cOld+dir*t;}void main(){vec3 v=choose_motion_vector();vec2 velocity=v.rg;vec2 previousPixelPos=vUv-velocity;vec4 currentColor=sample_color(inputBuffer,vUv);\n#ifdef USE_CATMULL_ROM\nvec4 previousColor=sample_catmull_rom(historyBuffer,previousPixelPos,resolution);\n#else\nvec4 previousColor=sample_color(historyBuffer,previousPixelPos);\n#endif\n#ifdef USE_YCOCG\npreviousColor=vec4(RGB_YCoCg(previousColor.rgb),previousColor.a);\n#endif\nvec4 ctl=sample_color(inputBuffer,vTexCoords[0]);vec4 ctc=sample_color(inputBuffer,vTexCoords[1]);vec4 ctr=sample_color(inputBuffer,vTexCoords[2]);vec4 cml=sample_color(inputBuffer,vTexCoords[3]);vec4 cmc=sample_color(inputBuffer,vTexCoords[4]);vec4 cmr=sample_color(inputBuffer,vTexCoords[5]);vec4 cbl=sample_color(inputBuffer,vTexCoords[6]);vec4 cbc=sample_color(inputBuffer,vTexCoords[7]);vec4 cbr=sample_color(inputBuffer,vTexCoords[8]);vec4 cmin=min(ctl,min(ctc,min(ctr,min(cml,min(cmc,min(cmr,min(cbl,min(cbc,cbr))))))));vec4 cmax=max(ctl,max(ctc,max(ctr,max(cml,max(cmc,max(cmr,max(cbl,max(cbc,cbr))))))));vec4 cavg=(ctl+ctc+ctr+cml+cmc+cmr+cbl+cbc+cbr)/9.0;vec4 cmin5=min(ctc,min(cml,min(cmc,min(cmr,cbc))));vec4 cmax5=max(ctc,max(cml,max(cmc,max(cmr,cbc))));vec4 cavg5=(ctc+cml+cmc+cmr+cbc)/5.0;cmin=0.5*(cmin+cmin5);cmax=0.5*(cmax+cmax5);cavg=0.5*(cavg+cavg5);\n#ifdef USE_YCOCG\nvec2 chroma_extent=vec2(0.25*0.5*(cmax.r-cmin.r));vec2 chroma_center=currentColor.gb;cmin.yz=chroma_center-chroma_extent;cmax.yz=chroma_center+chroma_extent;cavg.yz=chroma_center;\n#endif\nvec4 previousColorClipped=clamp(previousColor,cmin,cmax);\n#ifdef LUMINANCE_DIFFERENCES\n#ifdef USE_YCOCG\nfloat lum0=currentColor.r;float lum1=previousColorClipped.r;\n#else\nfloat lum0=luminance(currentColor.rgb);float lum1=luminance(previousColorClipped.rgb);\n#endif\nfloat unbiased_diff=abs(lum0-lum1)/max(lum0,max(lum1,0.2));float unbiased_weight=1.0-unbiased_diff;float unbiased_weight_sqr=unbiased_weight*unbiased_weight;float k_feedback=mix(feedback_min,feedback_max,unbiased_weight_sqr);vec4 result=mix(currentColor,previousColorClipped,vec4(k_feedback));\n#else\nconst float alpha=0.1;vec4 result=mix(currentColor,previousColorClipped,1.0-alpha);\n#endif\n#ifdef USE_YCOCG\ngl_FragColor=vec4(YCoCg_RGB(result.rgb).rgb,result.a);\n#else\ngl_FragColor=result;\n#endif\n}"}),this.historyRenderTarget=new Xe(1024,1024,{minFilter:qn,stencilBuffer:!1,depthBuffer:!1}),this.historyRenderTarget.texture.name="TAA.History",this.resultRenderTarget=new Xe(1024,1024,{minFilter:qn,stencilBuffer:!1,depthBuffer:!1}),this.resultRenderTarget.texture.name="TAA.Output"}setSize(e,t){this.historyRenderTarget.setSize(e,t),this.resultRenderTarget.setSize(e,t)}render(e,t){this.fullscreenMaterial=this.resolveMaterial,this.resolveMaterial.uniforms.inputBuffer.value=t.textures[0],this.resolveMaterial.uniforms.velocityBuffer.value=t.textures[1],this.resolveMaterial.uniforms.depthBuffer.value=t.depthTexture,this.resolveMaterial.uniforms.historyBuffer.value=this.historyRenderTarget.texture,this.resolveMaterial.uniforms.resolution.value.set(t.width,t.height),e.setRenderTarget(this.resultRenderTarget),e.render(this.scene,this.camera),this.fullscreenMaterial=this.passThroughMaterial,this.passThroughMaterial.inputBuffer=this.resultRenderTarget.texture,e.setRenderTarget(this.historyRenderTarget),e.render(this.scene,this.camera);let n=this.renderToScreen?null:t;this.fullscreenMaterial=this.passThroughMaterial,this.passThroughMaterial.inputBuffer=this.resultRenderTarget.texture,e.setRenderTarget(n),e.render(this.scene,this.camera)}dispose(){super.dispose(),this.resultRenderTarget.dispose(),this.historyRenderTarget.dispose(),this.resolveMaterial.dispose(),this.passThroughMaterial.dispose()}},tc=class extends U{constructor(e,t,n){super("TransmissionPass",void 0,t),this.MRTCompatible=!0,this.depthPass=new O(e,t,{renderTarget:n.transmissionDepthTarget}),this.passThroughMaterial=new Ql,this.splineScene=e,this.needsSwap=!1}updatePasses(e){this.passThroughMaterial.dispose(),this.passThroughMaterial=new Ql,this.depthPass.dispose(),this.depthPass=new O(this.splineScene,this.camera,{renderTarget:e.transmissionDepthTarget})}setCamera(e){this.camera=e}setScene(e){this.splineScene=e}render(e,t,n){let i=this.camera.layers.mask,a=e;a.setRenderTarget(a.transmissionRenderTarget),this.fullscreenMaterial=this.passThroughMaterial,this.passThroughMaterial.inputBuffer=t.textures[0],a.clear(),a.render(this.scene,this.camera),a.shadowMap.needsUpdate=!1,a.shadowMap.autoUpdate=!1,this.camera.layers.disable(3),this.depthPass.render(e,t,n);let r=this.renderToScreen?null:t;this.camera.layers.set(3),e.setRenderTarget(r),e.render(this.splineScene,this.camera),this.camera.layers.mask=i}dispose(){super.dispose(),this.depthPass?.renderPass.dispose(),this.depthPass.dispose(),this.passThroughMaterial.dispose(),this.depthPass=void 0,this.passThroughMaterial=void 0,this.splineScene=void 0,this.scene=void 0,this.camera=void 0}},nc=new gt,ic=new Xt({transparent:!0,vertexShader:"\n void main() {\n gl_Position = vec4(0.0);\n }\n ",fragmentShader:"\n layout(location = 1) out vec4 gVelocity;\n\n void main() {\n gl_FragColor = vec4(0.0);\n\t\t\tgVelocity = vec4(0.0);\n }\n "}),ac=class extends U{constructor(e,t,n){super("OpaquePass",t??nc,n),this.MRTCompatible=!0,this.originalMaterials=[],this.hasTransmissionPass=!1,this.clear=!0,this.clearColorOnly=!1,this.clearDepth=!1,this.needsSwap=!1,this.MRTCompatible=e}setCamera(e){this.camera=e}setScene(e){this.scene=e??nc}getScene(){return this.scene}render(e,t){this.camera.layers.enable(3),this.hasTransmissionPass&&(this.originalMaterials.length=0,this.scene.traverse(e=>{e.layers.isEnabled(3)&&e instanceof E&&(this.originalMaterials.push([e,e.material]),e.material=ic)}),!0!==e.manageShadowUpdates&&(e.shadowMap.needsUpdate=!0,e.shadowMap.autoUpdate=!0)),this.camera.layers.enable(8),this.camera.layers.enable(4);let n=this.renderToScreen?null:t;e.setRenderTarget(n),this.clearColorOnly&&e.clear(!0,!1,!0),this.clear&&e.clear(),e.render(this.scene,this.camera),this.clearDepth&&e.clear(!1,!0,!1),this.hasTransmissionPass&&this.originalMaterials.forEach(e=>{e[0].material=e[1]})}dispose(){super.dispose(),this.originalMaterials.length=0,this.scene=void 0,this.camera=void 0}},rc=class{constructor(e,{depthBuffer:t=!0,stencilBuffer:n=!1,multisampling:i=0,frameBufferType:a=0}={}){this.renderer=e,this.helperStartIndex=0,this.copyPass=new N,this.depthTexture=null,this.timer=new G,this._width=1,this._height=1,this.passes=[],this.helperPasses=[],this.autoRenderToScreen=!0,this.inputBuffer=this.createBuffer(t,n,a,i,!0,"input buffer mrt"),this.inputBufferSingle=this.createBuffer(t,n,a,i,!1," input buffer single"),this.inputBufferSingle.texture.dispose(),this.inputBufferSingle.depthTexture.dispose(),this.inputBufferSingle.texture=this.inputBuffer.textures[0],this.inputBufferSingle.depthTexture=this.inputBuffer.depthTexture,this.outputBuffer=this.inputBuffer.clone(),this.outputBuffer.name="output buffer mrt",this.outputBufferSingle=this.createBuffer(t,n,a,i,!1,"output buffer single"),this.outputBufferSingle.texture.dispose(),this.outputBufferSingle.depthTexture.dispose(),this.outputBufferSingle.texture=this.outputBuffer.textures[0],this.outputBufferSingle.depthTexture=this.outputBuffer.depthTexture,this.setRenderer(e)}get multisampling(){return this.inputBuffer.samples||0}set multisampling(e){let t=this.inputBuffer,n=this.multisampling;n>0&&e>0?(this.inputBuffer.samples=e,this.outputBuffer.samples=e,this.inputBuffer.dispose(),this.outputBuffer.dispose()):n!==e&&(this.inputBuffer.dispose(),this.outputBuffer.dispose(),console.log("creating new input buffer"),this.inputBuffer=this.createBuffer(t.depthBuffer,t.stencilBuffer,t.texture.type,e,!0,"new input buffer"),this.inputBuffer.depthTexture=this.depthTexture,this.outputBuffer=this.inputBuffer.clone())}getTimer(){return this.timer}getRenderer(){return this.renderer}setRenderer(e){if(this.renderer=e,null!==e){let t=e.getSize(new pe),n=e.getContext().getContextAttributes()?.alpha??!1,i=this.inputBuffer.textures[0].type;i===si&&e.outputColorSpace===Le&&(this.inputBuffer.textures[0].colorSpace=Le,this.outputBuffer.textures[0].colorSpace=Le,this.inputBuffer.dispose(),this.outputBuffer.dispose()),e.autoClear=!1,this.setSize(t.width,t.height,!1);for(let t of this.passes)t.initialize(e,n,i)}}replaceRenderer(e,t=!0){let n=this.renderer,i=n.domElement.parentNode;return this.setRenderer(e),t&&null!==i&&(i.removeChild(n.domElement),i.appendChild(e.domElement)),n}createDepthTexture(){let e=this.depthTexture=new de(this._width,this._height);return this.inputBuffer.depthTexture=e,this.inputBuffer.stencilBuffer?(e.format=ke,e.type=ve):e.type=Ci,e}deleteDepthTexture(){if(null!==this.depthTexture){this.depthTexture.dispose(),this.depthTexture=null,this.inputBuffer.depthTexture=null,this.inputBuffer.dispose();for(let e of this.passes)e.setDepthTexture(null)}}createBuffer(e,t,n,i,a,r){let o,s=this.renderer,l=null===s?new pe:s.getDrawingBufferSize(new pe),c={minFilter:qn,magFilter:qn,wrapS:Rn,wrapT:Rn,stencilBuffer:t,depthBuffer:e};i>0?(o=new Xe(l.width,l.height,c),o.samples=i):(a?(o=new Xe(l.width,l.height,{...c,count:2}),o.textures[1].type=re):o=new Xe(l.width,l.height,c),o.depthTexture=new de(2048,2048),o.depthTexture.type=ee);let d=o.textures.length>1;return n===si&&null!==s&&s.outputColorSpace===Le&&(d?o.textures.forEach(e=>e.colorSpace=Le):o.texture.colorSpace=Le),d?o.textures.forEach((e,t)=>{e.name=`EffectComposer.Buffer ${a} ${t}`,e.generateMipmaps=!1}):(o.texture.name=`EffectComposer.Buffer ${a}`,o.texture.generateMipmaps=!1),o.name=r,o}addPass(e,t){let n,i=this.passes,a=this.renderer,r=a.getDrawingBufferSize(new pe),o=a.getContext().getContextAttributes()?.alpha??!1;if(e.MRTCompatible&&(n=this.inputBuffer.textures[0].type),e.MRTCompatible||(n=this.inputBuffer.texture.type),e.setRenderer(a),e.setSize(r.width,r.height),e.initialize(a,o,n),this.autoRenderToScreen&&(i.length>0&&(i[i.length-1].renderToScreen=!1),e.renderToScreen&&(this.autoRenderToScreen=!1)),void 0!==t?i.splice(t,0,e):i.push(e),this.autoRenderToScreen&&(i[i.length-1].renderToScreen=!0),e.needsDepthTexture||null!==this.depthTexture)if(null===this.depthTexture){let t=this.createDepthTexture();for(e of i)e.setDepthTexture(t)}else e.setDepthTexture(this.depthTexture)}setHelperStartIndex(e){this.helperStartIndex=e}removePass(e){let t=this.passes,n=t.indexOf(e);if(-1!==n&&t.splice(n,1).length>0){if(null!==this.depthTexture){let n=(e,t)=>e||t.needsDepthTexture;t.reduce(n,!1)||e.getDepthTexture()===this.depthTexture&&e.setDepthTexture(null)}this.autoRenderToScreen&&n===t.length&&(e.renderToScreen=!1,t.length>0&&(t[t.length-1].renderToScreen=!0))}}removeAllPasses(){let e=this.passes;e.length>0&&(this.autoRenderToScreen&&(e[e.length-1].renderToScreen=!1),this.passes=[])}render(e){let t,n,i,a,r=this.renderer,o=this.copyPass,s=this.inputBuffer,l=this.outputBuffer,c=this.inputBufferSingle,d=this.outputBufferSingle,u=!1;void 0===e&&(e=this.timer.update().getDelta());for(let f of this.passes)f.enabled&&(f.MRTCompatible?f.render(r,s,l,e,u):f.render(r,c,d,e,u),f.needsSwap&&(u&&(o.renderToScreen=f.renderToScreen,t=r.getContext(),n=r.state.buffers.stencil,n.setFunc(t.NOTEQUAL,1,4294967295),o.render(r,s,l,e,u),n.setFunc(t.EQUAL,1,4294967295)),i=s,a=c,s=l,c=d,l=i,d=a),f instanceof V?u=!0:f instanceof I&&(u=!1))}setSize(e,t,n){let i=this.renderer;if(this._width=e,this._height=t,void 0===e||void 0===t){let n=i.getSize(new pe);e=n.width,t=n.height}i.setSize(e,t,n);let a=i.getDrawingBufferSize(new pe);this.inputBuffer.setSize(a.width,a.height),this.outputBuffer.setSize(a.width,a.height),this.inputBufferSingle.setSize(a.width,a.height),this.outputBufferSingle.setSize(a.width,a.height);for(let e of this.passes)e.setSize(a.width,a.height)}reset(){let e=this.timer.isAutoResetEnabled();this.dispose(),this.autoRenderToScreen=!0,this.timer.setAutoResetEnabled(e)}dispose(){for(let e of this.passes)e.dispose();this.passes=[],null!==this.inputBuffer&&this.inputBuffer.dispose(),null!==this.outputBuffer&&this.outputBuffer.dispose(),null!==this.inputBufferSingle&&this.inputBufferSingle.dispose(),null!==this.outputBufferSingle&&this.outputBufferSingle.dispose(),this.deleteDepthTexture(),this.copyPass.dispose(),this.timer.dispose()}},oc=new Xt({name:"CombineMaterial",uniforms:{inputBufferA:new je(null),inputBufferB:new je(null)},blending:Ln,depthWrite:!1,depthTest:!1,vertexShader:"\nvarying vec2 vUv;\nvoid main() {\n gl_Position = vec4(position.xy, 1.0, 1.0);\n vUv = position.xy * 0.5 + 0.5;\n}\n",fragmentShader:"\n varying vec2 vUv;\n uniform sampler2D inputBufferA;\n uniform sampler2D inputBufferB;\n\n \n layout(location = 1) out vec4 gVelocity;\n\n void main() {\n\tvec4 resA = texture2D(inputBufferA, vUv);\n\tvec4 resB = texture2D(inputBufferB, vUv);\n float a = resA.a + resB.a * ( 1.0 - resA.a );\n\n\tvec4 res;\n\tres.rgb = resA.rgb + (resB.rgb * (1.0 - resA.a));\n\tres.a = resA.a + resB.a * (1.0 - resA.a);\n\tgl_FragColor = res;\n gVelocity = vec4(0.0);\n }\n"}),sc=class extends U{constructor(e){super("HelperPass",void 0,e),this.MRTCompatible=!1,this._width=10,this._height=10,this.fullscreenMaterial=oc,this.helperPass=new ac(!1,void 0,this.camera),this.helperPass.hasTransmissionPass=!1,this.helperPass.clear=!1,this.helperPass.renderToScreen=!1,this.helperPassOnTop=new ac(!1,void 0,this.camera),this.helperPassOnTop.hasTransmissionPass=!1,this.helperPassOnTop.clear=!1,this.helperPassOnTop.renderToScreen=!1,this.rt=new Xe(10,10,{minFilter:qn,magFilter:qn,wrapS:Rn,wrapT:Rn,depthBuffer:!0})}_ensureEffectPass(){if(this.effectPass)return this.effectPass;let e=new X({preset:W.LOW,edgeDetectionMode:L.COLOR});return e.addEventListener("load",()=>this.onSmaaTexturesLoaded?.()),this.effectPass=new z(this.camera,e),this._initializeArgs&&this.effectPass.initialize(...this._initializeArgs),this.effectPass.setSize(this._width,this._height),this.effectPass}setSize(e,t){this._width=e,this._height=t,this.rt.setSize(e,t),this.effectPass?.setSize(e,t)}set sceneHelpers(e){this.helperPass.setScene(e)}get sceneHelpers(){return this.helperPass.getScene()}set sceneHelpersOnTop(e){this.helperPassOnTop.setScene(e)}get sceneHelpersOnTop(){return this.helperPassOnTop.getScene()}setCamera(e){this.helperPass.setCamera(e),this.helperPassOnTop.setCamera(e)}initialize(e,t,n){super.initialize(e,t,n),this._initializeArgs=[e,t,n],this.effectPass?.initialize(e,t,n)}dispose(){super.dispose(),this.rt.dispose(),this.effectPass?.dispose(),this.helperPass.dispose(),this.helperPassOnTop.dispose()}render(e,t,n){this.rt.depthTexture=t.depthTexture;let i=e.getClearAlpha();e.setClearAlpha(0),this.helperPass.clearDepth=!0,this.helperPass.clearColorOnly=!0,this.helperPass.render(e,this.rt),this.helperPassOnTop.render(e,this.rt);let a=this._ensureEffectPass();a.renderToScreen=!1,a.render(e,this.rt,n),this.fullscreenMaterial.uniforms.inputBufferA.value=n.texture,this.fullscreenMaterial.uniforms.inputBufferB.value=t.texture,e.setClearAlpha(i),e.setRenderTarget(null),e.clear(),e.render(this.scene,this.camera)}},lc=new Xt({vertexShader:"#define GLSLIFY 1\n#include <skinning_pars_vertex>\n#include <morphtarget_pars_vertex>\nout vec3 n;void main(){\n#include <beginnormal_vertex>\n#include <morphnormal_vertex>\n#include <skinbase_vertex>\n#include <skinnormal_vertex>\n#include <defaultnormal_vertex>\n#include <begin_vertex>\n#include <morphtarget_vertex>\n#include <skinning_vertex>\nvec4 view_space=viewMatrix*modelMatrix*vec4(transformed,1.0);gl_Position=projectionMatrix*view_space;n=normalize(transformedNormal);}",fragmentShader:"#define GLSLIFY 1\nin vec3 n;void main(){gl_FragColor=vec4(gl_FrontFacing ? n :-n,1.0);}",side:Cn}),cc=new Xt({vertexShader:"#define GLSLIFY 1\nout vec2 v_uv;void main(){gl_Position=vec4(position.xy,1.0,1.0);v_uv=uv;}",fragmentShader:"#define GLSLIFY 1\nin vec2 v_uv;uniform sampler2D texture_ao_lrez;uniform sampler2D texture_depth_lrez;uniform sampler2D texture_depth_hrez;uniform float near;uniform float far;float linearize_depth(float depth_sampled){float z=depth_sampled*2.0-1.0;return(2.0*near*far)/(far+near-z*(far-near));}vec2 nearest_depth_filter(in vec2 uv){vec2 resolution=vec2(textureSize(texture_depth_lrez,0));vec2 texel_size=1.0/resolution;vec2 offset=uv-0.5*texel_size;float d_hrez=texture(texture_depth_hrez,uv).r;float a=abs(d_hrez-texture(texture_depth_lrez,offset).r);float b=abs(d_hrez-texture(texture_depth_lrez,offset+vec2(texel_size.x,0.0)).r);float c=abs(d_hrez-texture(texture_depth_lrez,offset+vec2(0.0,texel_size.y)).r);float d=abs(d_hrez-texture(texture_depth_lrez,offset+vec2(texel_size.x,texel_size.y)).r);float min_diff=min(a,min(b,min(c,d)));if(min_diff==a)return offset;if(min_diff==b)return offset+vec2(texel_size.x,0.0);if(min_diff==c)return offset+vec2(0.0,texel_size.y);if(min_diff==d)return offset+vec2(texel_size.x,texel_size.y);}void main(){\n#ifdef DEBUG\nfloat d_lrez=texture(texture_depth_lrez,v_uv).r;float d_hrez=texture(texture_depth_hrez,v_uv).r;float output_d=mix(linearize_depth(d_lrez)/far,linearize_depth(d_hrez)/far,step(0.5,v_uv.x));gl_FragColor=vec4(vec3(output_d),1.0);\n#else\nvec2 filtered_uv=nearest_depth_filter(v_uv);vec4 ao=texture(texture_ao_lrez,filtered_uv);gl_FragColor=vec4(ao.rgb,1.0);gl_FragColor=ao;\n#endif\n}",uniforms:{texture_ao_lrez:new je(null),texture_depth_lrez:new je(null),texture_depth_hrez:new je(null),near:new je(null),far:new je(null)}}),dc=class extends U{constructor(e,t){super("AmbientOcclusionPass",void 0,t),this.fogEnabled=!1,this.fogNear=1,this.fogFar=1e3,this.fogMode=0,this.fogHeightParams=new Te(.005,.01,0),this.frameIndex=0,this.sanitizeViewport=!1,this._runHalfRes=!0,this._width=1,this._height=1;let n=1024,i=1024;this.gBuffer=new Xe(n,i,{type:s?re:ee,depthTexture:new de(n,i),minFilter:qn,magFilter:qn}),this.depthBufferHighRes=new Xe(n,i,{depthTexture:new de(n,i)}),this.aoBuffer=new Xe(n,i,{minFilter:qn,magFilter:qn}),this.splineScene=e,this.splineCamera=t,this.hbaoMaterial=new Xt({vertexShader:"#define GLSLIFY 1\nout vec2 v_uv;void main(){v_uv=uv;gl_Position=vec4(position.xy,1.0,1.0);}",fragmentShader:"precision highp float;precision highp int;precision highp sampler2D;\n#define GLSLIFY 1\nin vec2 v_uv;const float pi=3.14159265;const float num_steps=4.0;const float num_directions=4.0;uniform float near;uniform float far;uniform float fov;uniform vec4 proj_info;uniform bool is_ortho;uniform vec2 resolution;uniform float radius_of_influence;uniform float radius_in_screen_space;uniform float exponent;uniform vec3 ao_color;uniform float bias;uniform sampler2D texture_depth;uniform sampler2D texture_normals;uniform sampler2D texture_blue_noise;uniform sampler2D texture_color_pass;const vec2 blue_noise_in_disk[16]=vec2[16](vec2(0.4787119925022125,0.875764012336731),vec2(-0.3379560112953186,-0.7939590215682983),vec2(-0.9552590250968933,-0.028163999319076538),vec2(0.8645269870758057,0.3256889879703522),vec2(0.20934200286865234,-0.3956570029258728),vec2(-0.10677900165319443,0.6725850105285645),vec2(0.15621300041675568,0.2351129949092865),vec2(-0.4136439859867096,-0.08285599946975708),vec2(-0.41566699743270874,0.3239090144634247),vec2(0.14189599454402924,-0.9399799704551697),vec2(0.9549319744110107,-0.18251599371433258),vec2(-0.7661839723587036,0.4107989966869354),vec2(-0.4349119961261749,-0.45884498953819275),vec2(0.4152419865131378,-0.07872399687767029),vec2(0.7283350229263306,-0.4917770028114319),vec2(-0.05808600038290024,-0.06640099734067917));uniform int frame_index;uniform bool fog_enabled;uniform float fog_near;uniform float fog_far;uniform float fog_mode;uniform vec3 fog_height_params;uniform mat4 camera_world_matrix;float height_fog_factor(vec3 fog_world_delta,float fog_dist,vec3 camera_world_pos){float density=fog_height_params.x;float falloff=fog_height_params.y;float rel_y=camera_world_pos.y-fog_height_params.z;float cam_density=density*exp(clamp(-falloff*rel_y,-60.0,60.0));float x=clamp(falloff*fog_world_delta.y,-60.0,60.0);float x_safe=(x>=0.0 ? 1.0 :-1.0)*max(abs(x),1e-4);float optical_depth=cam_density*fog_dist*(1.0-exp(-x_safe))/x_safe;return 1.0-exp(-max(optical_depth,0.0));}vec3 uv_to_view_space(vec2 uv,float eye_z){return vec3((uv*proj_info.xy+proj_info.zw)*(is_ortho ? 1.0 : eye_z),eye_z);}float linearize_depth(float depth_sampled){float z=is_ortho ? depth_sampled : depth_sampled*2.0-1.0;return mix((2.0*near*far)/(far+near-z*(far-near)),near+z*(far-near),float(is_ortho));}vec3 get_view_position(vec2 uv_coords){float linear_depth=linearize_depth(texture(texture_depth,uv_coords).x);return uv_to_view_space(uv_coords,linear_depth);}vec3 min_difference(vec3 p,vec3 right,vec3 left){vec3 v1=right-p;vec3 v2=p-left;return(dot(v1,v1)<dot(v2,v2))? v1 : v2;}vec3 rebuild_normal(in vec2 uv,in vec3 p){vec2 one_over_resolution=1.0/resolution;vec3 r=get_view_position(uv+vec2(one_over_resolution.x,0));vec3 l=get_view_position(uv+vec2(-one_over_resolution.x,0));vec3 t=get_view_position(uv+vec2(0,one_over_resolution.y));vec3 b=get_view_position(uv+vec2(0,-one_over_resolution.y));return normalize(cross(min_difference(p,r,l),min_difference(p,t,b)));}float falloff(float distance_squared){float neg_inv_r2=-1.0/(radius_of_influence*radius_of_influence);return distance_squared*neg_inv_r2+1.0;}float ao_contribution(vec3 P,vec3 N,vec3 S){vec3 to_sample=S-P;float norm_squared=dot(to_sample,to_sample);float norm=sqrt(norm_squared);float cos_theta=dot(N,to_sample)/max(norm,1e-4);return clamp(cos_theta-bias,0.0,1.0)*clamp(falloff(norm_squared),0.0,1.0);}float compute_ambient_occlusion(vec2 uv,float radius_in_screen_space,vec3 pc,vec3 view_space_n){vec2 one_over_resolution=1.0/resolution;ivec2 noise_uv=ivec2(gl_FragCoord.xy)&ivec2(127);float noise=texelFetch(texture_blue_noise,noise_uv,0).r;noise=fract(noise+0.61803398875*float(frame_index));float theta=noise*2.0*3.1415;float ct=cos(theta);float st=sin(theta);float step_size=radius_in_screen_space/(num_steps+1.0);const float angle_step=2.0*pi/num_directions;float contribution=0.0;for(int i=0;i<int(num_directions);++i){float current_pixel=step_size+1.0;for(int j=0;j<int(num_steps);++j){int index=i*int(num_steps)+j;vec2 blue_noise_sample=blue_noise_in_disk[index];vec2 disk_point;disk_point.x=blue_noise_sample.x*ct-blue_noise_sample.y*st;disk_point.y=blue_noise_sample.x*st+blue_noise_sample.y*ct;vec2 sample_direction=disk_point;vec2 snapped_uv=round(current_pixel*sample_direction)*one_over_resolution+uv;vec3 ps=get_view_position(snapped_uv);current_pixel+=step_size;contribution+=ao_contribution(pc,view_space_n,ps);}}float mult=1.0/(1.0-bias);contribution*=mult/(num_directions*num_steps);return clamp(1.0-contribution*2.0,0.0,1.0);}\n#define USE_GBUFFER_NORMALS\nvoid main(){vec3 view_space_p=get_view_position(v_uv);\n#ifdef USE_GBUFFER_NORMALS\nvec3 view_space_n=texture(texture_normals,v_uv).rgb;view_space_n.z*=-1.0;\n#else\nvec3 view_space_n=-rebuild_normal(v_uv,view_space_p);\n#endif\nfloat radius_ss=max(radius_in_screen_space/(is_ortho ? 1.0 : view_space_p.z),num_steps+1.0);float ao=compute_ambient_occlusion(v_uv,radius_ss,view_space_p,view_space_n);float final=pow(ao,exponent);if(view_space_p.z>=far){final=1.0;}vec3 color=mix(ao_color,vec3(1.0),final);if(fog_enabled){float fog_linear=smoothstep(fog_near,fog_far,view_space_p.z);vec3 world_p=(camera_world_matrix*vec4(view_space_p.xy,-view_space_p.z,1.0)).xyz;vec3 cam_pos=camera_world_matrix[3].xyz;float fog_height=height_fog_factor(world_p-cam_pos,max(length(world_p-cam_pos),1e-6),cam_pos);float w_linear=1.0-step(0.5,fog_mode)+step(1.5,fog_mode);float w_height=step(0.5,fog_mode);float fog_factor=1.0-(1.0-fog_linear*w_linear)*(1.0-fog_height*w_height);color=mix(color,vec3(1.0),fog_factor);}gl_FragColor=vec4(color,1.0);}",uniforms:{near:new je(null),far:new je(null),fov:new je(null),proj_info:new je(new Fe),is_ortho:new je(!1),resolution:new je(new pe),radius_of_influence:new je(8),radius_in_screen_space:new je(1),exponent:new je(1),ao_color:new je(new Te),bias:new je(.5),texture_depth:new je(null),texture_normals:new je(null),texture_blue_noise:new je(null),frame_index:new je(0),fog_enabled:new je(!1),fog_near:new je(1),fog_far:new je(1e3),fog_mode:new je(0),fog_height_params:new je(new Te(.005,.01,0)),camera_world_matrix:new je(new tt)}}),this.radius=128,this.aoColor={r:0,g:0,b:0},this.bias=.5,this.hbaoMaterial.uniforms.texture_depth.value=this.gBuffer.depthTexture,this.hbaoMaterial.uniforms.texture_normals.value=this.gBuffer.texture,this.needsSwap=!0,this.aaBuffer=new Xe(n,i,{minFilter:qn,magFilter:qn,wrapS:Rn,wrapT:Rn,depthBuffer:!1,type:ee})}_ensureEffectPass(){if(this.effectPass)return this.effectPass;let e=new X({preset:W.ULTRA,edgeDetectionMode:L.COLOR});e.addEventListener("load",()=>this.onSmaaTexturesLoaded?.()),this.effectPass=new z(this.camera,e),this._initializeArgs&&this.effectPass.initialize(...this._initializeArgs);let t=this._runHalfRes?.5:1;return this.effectPass.setSize(this._width*t,this._height*t),this.effectPass}initialize(e,t,n){super.initialize(e,t,n),this._initializeArgs=[e,t,n],this.effectPass?.initialize(e,t,n)}setBlueNoiseTexture(e){this.hbaoMaterial.uniforms.texture_blue_noise.value=e}setSize(e,t){this._width=e,this._height=t,this.depthBufferHighRes.setSize(e,t);let n=this._runHalfRes?.5:1,i=e*n,a=t*n;this.gBuffer.setSize(i,a),this.aoBuffer.setSize(i,a),this.hbaoMaterial.uniforms.resolution.value.set(i,a),this.aaBuffer.setSize(i,a),this.effectPass?.setSize(i,a)}get runHalfRes(){return this._runHalfRes}set runHalfRes(e){this._runHalfRes=e,this.setSize(this._width,this._height)}setCamera(e){this.splineCamera=e}setScene(e){this.splineScene=e}setDepthTexture(e){this.depthBufferHighRes.depthTexture=e,cc.uniforms.texture_depth_hrez.value=e,cc.needsUpdate=!0}render(e,t,n){let i=null,a=null,r=null,o=null,s=t=>{e.setViewport(0,0,t.width,t.height)};this.sanitizeViewport&&(i=new Fe,a=new Fe,e.getViewport(i),e.getScissor(a),r=e.getScissorTest(),o=e.getRenderTarget(),e.setScissorTest(!1)),this.splineScene.overrideMaterial=lc;let l=this.splineCamera.layers.mask;if(this.splineCamera.layers.set(5),e.setRenderTarget(this.gBuffer),this.sanitizeViewport&&s(this.gBuffer),e.clear(),e.render(this.splineScene,this.splineCamera),this.runHalfRes&&(lc.colorWrite=!1,e.setRenderTarget(this.depthBufferHighRes),this.sanitizeViewport&&s(this.depthBufferHighRes),e.clear(),e.render(this.splineScene,this.splineCamera),lc.colorWrite=!0,e.state.buffers.color.setMask(!0)),this.splineScene.overrideMaterial=null,this.splineCamera.layers.mask=l,this.hbaoMaterial.uniforms.radius_of_influence.value=this.radius,this.hbaoMaterial.uniforms.ao_color.value.set(this.aoColor.r,this.aoColor.g,this.aoColor.b),this.hbaoMaterial.uniforms.bias.value=this.bias,this.hbaoMaterial.uniforms.fog_enabled.value=this.fogEnabled,this.hbaoMaterial.uniforms.fog_near.value=this.fogNear,this.hbaoMaterial.uniforms.fog_far.value=this.fogFar,this.hbaoMaterial.uniforms.fog_mode.value=this.fogMode,this.hbaoMaterial.uniforms.fog_height_params.value.copy(this.fogHeightParams),this.hbaoMaterial.uniforms.camera_world_matrix.value.copy(this.splineCamera.matrixWorld),this.hbaoMaterial.uniforms.frame_index.value=this.frameIndex,this.frameIndex++,this.splineCamera.isPerspectiveCamera){this.hbaoMaterial.uniforms.near.value=this.splineCamera.perspCamera.near,this.hbaoMaterial.uniforms.far.value=this.splineCamera.perspCamera.far;let e=this.splineCamera.perspCamera.projectionMatrix.elements,t=2/e[0],n=2/e[5],i=-(1-e[8])/e[0],a=-(1+e[9])/e[5];this.hbaoMaterial.uniforms.proj_info.value.set(t,n,i,a);let r=this.splineCamera.perspCamera.fov*(Math.PI/180),o=this.hbaoMaterial.uniforms.resolution.value.y/(2*Math.tan(.5*r)),s=.5*this.hbaoMaterial.uniforms.radius_of_influence.value*o;this.hbaoMaterial.uniforms.radius_in_screen_space.value=s,this.hbaoMaterial.uniforms.is_ortho.value=!1}else{this.hbaoMaterial.uniforms.near.value=this.splineCamera.orthoCamera.near,this.hbaoMaterial.uniforms.far.value=this.splineCamera.orthoCamera.far;let e=this.splineCamera.orthoCamera.projectionMatrix.elements,t=2/e[0],n=2/e[5],i=-(1+e[12])/e[0],a=-(1-e[13])/e[5];this.hbaoMaterial.uniforms.proj_info.value.set(t,n,i,a);let r=this.hbaoMaterial.uniforms.resolution.value.y/n*.5,o=this.hbaoMaterial.uniforms.radius_of_influence.value*r;this.hbaoMaterial.uniforms.radius_in_screen_space.value=o,this.hbaoMaterial.uniforms.is_ortho.value=!0}let c=e.aoRenderTarget;if(this.runHalfRes)this.fullscreenMaterial=this.hbaoMaterial,e.setRenderTarget(this.aoBuffer),this.sanitizeViewport&&s(this.aoBuffer),e.clear(),e.render(this.scene,this.camera),this.fullscreenMaterial=cc,cc.uniforms.texture_ao_lrez.value=this.aoBuffer.texture,cc.uniforms.texture_depth_lrez.value=this.gBuffer.depthTexture,cc.uniforms.texture_depth_hrez.value=this.depthBufferHighRes.depthTexture,e.setRenderTarget(c),this.sanitizeViewport&&s(c),e.clear(),e.render(this.scene,this.camera);else{this.fullscreenMaterial=this.hbaoMaterial,e.setRenderTarget(this.aaBuffer),this.sanitizeViewport&&s(this.aaBuffer),e.clear(),e.render(this.scene,this.camera);let t=this._ensureEffectPass();t.renderToScreen=!1,t.render(e,this.aaBuffer,c)}this.sanitizeViewport&&i&&a&&null!==r&&(e.setRenderTarget(o),e.setViewport(i.x,i.y,i.z,i.w),e.setScissor(a.x,a.y,a.z,a.w),e.setScissorTest(r))}dispose(){super.dispose(),this.gBuffer.dispose(),this.depthBufferHighRes.dispose(),this.aoBuffer.dispose(),this.aaBuffer.dispose(),this.effectPass?.dispose(),this.hbaoMaterial.dispose(),this.splineScene=null,this.splineCamera=null}},uc=class extends H{constructor(){super(new Xt({vertexShader:"\nvarying vec2 vUv;\nvoid main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"\nuniform sampler2D tInput;\nuniform sampler2D tMap;\nuniform vec2 resolution;\nvarying vec2 vUv;\n\nuniform vec2 uResolution;\nuniform vec2 uCoords;\n\n\nfloat rectangle(vec2 st, vec2 size) {\n size = vec2(0.5) - size * 0.5;\n vec2 uv = vec2(step(size.x, st.x), step(size.y, st.y));\n uv *= vec2(step(size.x, 1.0 - st.x), step(size.y, 1.0 - st.y));\n\n return uv.x * uv.y;\n}\n\nuniform vec2 uSize;\nuniform float uScale;\nuniform float uDPR;\nuniform float uCurrent;\nuniform vec3 uSceneColor;\n\nvoid main() {\n vec2 screenUv = gl_FragCoord.xy / uResolution.xy;\n screenUv *= 1.0 / uDPR;\n\n vec2 center = vec2(0.5, -0.5);\n vec2 outsideUv = screenUv;\n outsideUv += center;\n outsideUv -= uCoords.xy / uResolution.xy;\n outsideUv = (outsideUv - 0.5) + 0.5;\n outsideUv -= center;\n vec2 s = (uSize / uResolution) * uScale;\n float isOutside = 1.0 - rectangle(outsideUv, s);\n \n vec2 mid = vec2(0.5);\n vec2 insideUv = (screenUv - mid + s * mid) / s;\n vec4 background = texture2D(tInput, screenUv);\n vec4 image = texture2D(tMap, insideUv);\n gl_FragColor = mix(image, background, isOutside);\n}\n",uniforms:{tInput:new je(null),tMap:new je(null),uResolution:new je(new pe),uSize:new je(new pe),uCoords:new je(new pe),uScale:new je(1),uSceneColor:new je(new ft(16711680)),uDPR:new je(1),uCurrent:new je(0)}}),"tInput"),this.needsSwap=!0}get uniforms(){return this.fullscreenMaterial.uniforms}get texture(){return this.uniforms.tMap.value}set texture(e){this.uniforms.tMap.value=e}},fc=[],pc=class extends H{constructor(){super(new Xt({vertexShader:"\nvoid main() {\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"\nuniform sampler2D toScene;\nuniform sampler2D fromScene;\nuniform vec2 resolution;\n\nuniform vec2 uResolution;\nuniform float uDPR;\n\nuniform float mixRatio;\nuniform sampler2D tMixTexture;\nuniform int useTexture;\nuniform float threshold;\n\nvoid main() {\n\tvec2 screenUv = gl_FragCoord.xy / uResolution.xy;\n\tscreenUv *= 1.0 / uDPR;\n\n\tvec4 texel1 = texture2D( fromScene, screenUv );\n\tvec4 texel2 = texture2D( toScene, screenUv );\n\n\tif (useTexture==1) {\n\t\t\n\t\tvec4 transitionTexel = texture2D( tMixTexture, screenUv );\n\t\tfloat r = mixRatio * (1.0 + threshold * 2.0) - threshold;\n\t\tfloat mixf=clamp((transitionTexel.r - r)*(1.0/threshold), 0.0, 1.0);\n\t\t\n\t\tgl_FragColor = mix( texel1, texel2, mixf );\n\t} else {\n\t\t\n\t\tgl_FragColor = mix( texel1, texel2, mixRatio );\n\t\t\n\t}\n}\n",uniforms:{toScene:new je(null),fromScene:new je(null),uResolution:new je(new pe),uDPR:new je(1),mixRatio:new je(0),threshold:new je(.1),useTexture:new je(0),tMixTexture:{value:fc[0]}}}),"toScene"),this.needsSwap=!0}get uniforms(){return this.fullscreenMaterial.uniforms}get texture(){return this.uniforms.fromScene.value}set texture(e){this.uniforms.fromScene.value=e}},hc=class extends H{constructor(){super(new Xt({vertexShader:"\nvoid main() {\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"\nuniform sampler2D inputBuffer;\nuniform sampler2D blurredInputBuffer;\nuniform sampler2D overlay;\nuniform float blurIntensity;\n\nuniform vec2 uResolution;\nuniform float uDPR;\n\nvoid main() {\n\tvec2 screenUv = gl_FragCoord.xy / uResolution.xy;\n\tscreenUv *= 1.0 / uDPR;\n\n\tvec4 texel1 = texture2D( overlay, screenUv );\n\tvec4 texel2 = texture2D( inputBuffer, screenUv );\n\tvec4 texel3 = texture2D( blurredInputBuffer, screenUv );\n\n\tfloat blurMask2 = max(sign(texel1.a), 0.0) * blurIntensity;\n gl_FragColor = mix( mix(texel2, texel3, blurMask2), texel1, texel1.a );\n}\n",uniforms:{inputBuffer:new je(null),blurredInputBuffer:new je(null),overlay:new je(null),uResolution:new je(new pe),uDPR:new je(1),blurIntensity:new je(0)}})),this._blurEnabled=!1,this.blurTarget=new Xe(1,1,{minFilter:qn,magFilter:qn,wrapS:Rn,wrapT:Rn}),this.blurPass=new B({width:window.innerWidth,height:window.innerHeight,kernelSize:k.HUGE,resolutionScale:.25}),this.blurPass.renderToScreen=!1,this.uniforms.blurredInputBuffer.value=this.blurTarget.texture}get uniforms(){return this.fullscreenMaterial.uniforms}get texture(){return this.uniforms.overlay.value}set texture(e){this.uniforms.overlay.value=e}setResolution(e,t,n=1){this.uniforms.uResolution.value.set(e,t),this.uniforms.uDPR.value=n,this.blurPass.setSize(e,t),this.blurTarget.setSize(e,t),this.blurPass.setSize(e,t)}get uiCanvas(){return this._uiCanvas}set uiCanvas(e){this._uiCanvas=e,e.texture&&(this.uniforms.overlay.value=e.texture);let t=e.frame;if(t){let e=t.data.backgroundBlur,n=e.radius;this._blurEnabled=e.enabled,this.uniforms.blurIntensity.value=this._blurEnabled?1:0,this.blurPass.scale=n/3}}render(e,t,n,i,a){this._blurEnabled&&(this.blurPass.setDepthTexture(this.getDepthTexture()),this.blurPass.render(e,t,this.blurTarget,i,a)),super.render(e,t,n,i,a)}dispose(){super.dispose(),this.blurTarget.dispose(),this.blurPass.dispose(),this.fullscreenMaterial.dispose(),this._uiCanvas=void 0}},mc=class extends H{constructor(){super(new Xt({vertexShader:"\nvarying vec2 vUv;\nvoid main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"\nuniform sampler2D tInput;\nuniform sampler2D tOverlayImage;\nvarying vec2 vUv;\nuniform vec2 uResolution;\nuniform vec2 uRightBottom;\nuniform vec2 uImageSize;\nuniform float uScale;\nuniform float uDPR;\n\nvec3 blendNormal(vec3 base, vec3 blend) {\n\treturn blend;\n}\n\nvec3 blendNormal(vec3 base, vec3 blend, float opacity) {\n\treturn (blendNormal(base, blend) * opacity + base * (1.0 - opacity));\n}\n\nvec4 drawFixedSizeImage(sampler2D image, vec2 screenUV, vec2 imageSize, vec2 imageCoords, vec2 screenSize, float dpr) {\n\tvec2 uv = (screenUV * screenSize * dpr - imageCoords) / (imageSize * dpr);\n\tif (uv.x < 0.0 || uv.x > 1.0 || uv.y < 0.0 || uv.y > 1.0) {\n\t\treturn vec4(0.0);\n\t}\n\treturn texture2D(image, uv);\n}\n\nvoid main() {\n vec2 screenUV = gl_FragCoord.xy / (uResolution.xy * uDPR);\n\tvec2 imageCoords = vec2(uResolution.x * uDPR - uImageSize.x * uScale * uDPR - uRightBottom.x * uDPR, uRightBottom.y * uDPR);\n vec4 background = texture2D(tInput, screenUV);\n vec4 image = drawFixedSizeImage(tOverlayImage, screenUV, uImageSize * uScale, imageCoords, uResolution, uDPR);\n gl_FragColor = vec4(blendNormal(background.rgb, image.rgb, image.a), max(background.a, image.a));\n}\n",uniforms:{tInput:new je(null),tOverlayImage:new je(null),uResolution:new je(new pe),uImageSize:new je(new pe),uRightBottom:new je(new pe(20,20)),uScale:new je(.25),uDPR:new je(1)}}),"tInput")}get uniforms(){return this.fullscreenMaterial.uniforms}get texture(){return this.uniforms.tOverlayImage.value}set texture(e){this.uniforms.tOverlayImage.value=e;let t=e.image;this.uniforms.uImageSize.value.set(t.width,t.height)}},vc=class extends H{constructor(){super(new Xt({vertexShader:"\nvarying vec2 vUv;\nvoid main() {\n\tvUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"\nuniform sampler2D inputBuffer;\nvarying vec2 vUv;\n\nvec3 SrgbToLinear(vec3 color) {\n\t\n\tvec3 sRGB = color.rgb;\n\tcolor.rgb = sRGB * (sRGB * (sRGB * 0.305306011 + 0.682171111) + 0.012522878);\n\treturn color;\n}\n\nvoid main() {\n\tvec4 texel = texture2D(inputBuffer, vUv);\n\ttexel.rgb = SrgbToLinear(texel.rgb);\n gl_FragColor = texel;\n}\n",uniforms:{inputBuffer:new je(null),uResolution:new je(new pe),uDPR:new je(1)}}),"inputBuffer"),this.needsSwap=!0}get uniforms(){return this.fullscreenMaterial.uniforms}};function gc(e,t){return t&&t.enabled&&e.push(t.effect),e}var _c=e=>Object.values(F).includes(e)?e:F.NORMAL,xc=class extends oe{constructor(e,t){super(),this._needsDOFResize=t,this.postprocessingState=A.defaultData,this._scene=new gt,this._camera=new l,this.effects=new Map,this.blueNoiseTexture=new Bn,this._renderToScreen=!0,this._isUIOverlayEnabled=!1,this.timer=new ze,this.renderer=e,this.debug=!1;for(let[e,t]of $())this.effects.set(e,t());this.effectComposer=new rc(this.renderer),this.effectComposer.autoRenderToScreen=!1,this.opaquePass=new ac(!0,this.scene,this.camera),this.opaquePass.clear=!0,this.transmissionPass=new tc(this.scene,this.camera,this.renderer),this.aoPass=new dc(this.scene,this.camera),this.taaPass=new ec,this.taaPass.renderToScreen=!1,this.helperPass=new sc(this.camera),this.helperPass.renderToScreen=!1;let n=()=>{this.dispatchEvent({type:"smaaloaded"})};this.aoPass.onSmaaTexturesLoaded=n,this.helperPass.onSmaaTexturesLoaded=n,this.stylesOverlayPass=new uc,this.stylesOverlayPass.enabled=!1,this.uiOverlayPass=new hc,this.uiOverlayPass.enabled=!1,this.logoOverlayPass=new mc,this.logoOverlayPass.enabled=!1,this.sceneTransitionPass=new pc,this.sceneTransitionPass.enabled=!1,this.srgbToLinear=new vc,this.srgbToLinear.enabled=!1,this._initCopyPass(),this._initPasses()}set overlayTexture(e){void 0!==e?(this.stylesOverlayPass.texture=e,this.stylesOverlayPass.enabled=!0):this.stylesOverlayPass.enabled=!1}get overlayTexture(){return this.stylesOverlayPass.texture}set sceneHelpers(e){this.helperPass.sceneHelpers=e}get sceneHelpers(){return this.helperPass.sceneHelpers}set sceneHelpersOnTop(e){this.helperPass.sceneHelpersOnTop=e}get sceneHelpersOnTop(){return this.helperPass.sceneHelpersOnTop}get scene(){return this._scene}set scene(e){this._scene=e,this.opaquePass.setScene(e),this.transmissionPass.setScene(e),this.aoPass.setScene(e)}get camera(){return this._camera}set camera(e){let t=this._camera!==e;this._camera=e,this.opaquePass.setCamera(e),this.transmissionPass.setCamera(e),t&&this.transmissionPass.updatePasses(this.renderer),this.aoPass.setCamera(e),this.helperPass.setCamera(e),this.effects.get("depthOfField")?.setCamera(e)}updateRenderToScreen(){let e=!1;for(let t=this.effectComposer.passes.length-1;t>=0;t--){let n=this.effectComposer.passes[t];!0!==n.enabled||e||!this._renderToScreen?n.renderToScreen=!1:(n.renderToScreen=!0,e=!0)}}get isUIOverlayEnabled(){return this._isUIOverlayEnabled}disableUIOverlay(){this._isUIOverlayEnabled=!1}enableUIOverlay(){this._isUIOverlayEnabled=!0}disableHelpers(){this.helperPass.enabled=!1,this.updateRenderToScreen()}enableHelpers(){this.helperPass.enabled=!0,this.updateRenderToScreen()}updateBlueNoiseTexture(e){this.blueNoiseTexture=new Bn(e,128,128),this.blueNoiseTexture.wrapS=wn,this.blueNoiseTexture.wrapT=wn,this.blueNoiseTexture.minFilter=On,this.blueNoiseTexture.magFilter=On,this.blueNoiseTexture.needsUpdate=!0}setAmbientOcclusionParams(e,t,n,i,a,r,o,s,l){this.aoPass.enabled=e,this.aoPass.radius=t,this.aoPass.bias=n,this.aoPass.aoColor=i,this.aoPass.fogEnabled=a,this.aoPass.fogNear=r,this.aoPass.fogFar=o,this.aoPass.fogMode=R.getModeIndex({mode:s.mode}),this.aoPass.fogHeightParams.set(s.density,s.heightFalloff,s.heightBase),this.aoPass.runHalfRes!==!l&&(this.aoPass.runHalfRes=!l)}setTransmissionPassEnabled(e){this.transmissionPass.enabled=e,this.opaquePass.hasTransmissionPass=e}_initPasses(){if(this.uvEffectPass?.dispose(),this.effectPass?.dispose(),this.effectComposer.removeAllPasses(),this.transmissionPass.updatePasses(this.renderer),this.effectComposer.addPass(this.aoPass),this.effectComposer.addPass(this.opaquePass),this.effectComposer.addPass(this.transmissionPass),this.effectComposer.addPass(this.taaPass),this.postprocessingState.enabled){let e=[this.effects.get("pixelation")].reduce(gc,[]);e.length>0&&(this.uvEffectPass=new z(this.camera,...e),this.uvEffectPass.renderToScreen=!1,this.uvEffectPass.encodeOutput=!1,this.effectComposer.addPass(this.uvEffectPass));let t=[this.effects.get("chromaticAberration"),this.effects.get("bloom"),this.effects.get("depthOfField"),this.effects.get("colorAverage"),this.effects.get("hueSaturation"),this.effects.get("brightnessContrast"),this.effects.get("vignette"),this.effects.get("noise")].reduce(gc,[]);if(t.length>0&&(this.effectPass=new z(this.camera,...t),this.effectPass.renderToScreen=!1,this.effectPass.encodeOutput=!1,this.effectComposer.addPass(this.effectPass),this._needsDOFResize&&this.effects.get("depthOfField")?.enabled&&void 0!==window)){let e=this.renderer.viewportWidth,t=this.renderer.viewportHeight;this.renderer.setSize(e-1,t-1),this.renderer.setSize(e,t)}}this.effectComposer.addPass(this.stylesOverlayPass),this.effectComposer.addPass(this.uiOverlayPass),this.effectComposer.addPass(this.sceneTransitionPass),this.effectComposer.addPass(this.helperPass),this.effectComposer.addPass(this.srgbToLinear),this.effectComposer.addPass(this.logoOverlayPass)}_initCopyPass(){if(this._savePass)return;let e=new pe;this.renderer.getDrawingBufferSize(e),this._rt=new Xe(e.x,e.y,{depthBuffer:!1,stencilBuffer:!1,wrapS:wn,wrapT:wn}),this._rt.samples=0,this.renderer.outputColorSpace===Le&&(this._rt.texture.colorSpace=Le),this._savePass=new N(this._rt,!1),this._savePass.renderToScreen=!1}setCopyPass(e){this._rt=e,this._savePass=new N(this._rt,!1),this.renderToScreen=!1}get renderToScreen(){return this._renderToScreen}set renderToScreen(e){if(this._renderToScreen===e)return;let t=this.effectComposer;!t||(!0===e?t.removePass(this._savePass):t.addPass(this._savePass),this._renderToScreen=e,this.updateRenderToScreen())}get sceneTransitionFromTexture(){return this.sceneTransitionPass.texture}set sceneTransitionFromTexture(e){e!==this.sceneTransitionPass.texture&&(null!==e?this.sceneTransitionPass.enabled=!0:(this.sceneTransitionPass.enabled=!1,this.updateRenderToScreen()),this.sceneTransitionPass.texture=e)}setWatermark(e){this.logoOverlayPass.enabled=null!==e,e&&(this.logoOverlayPass.texture=e)}get texture(){return this._rt&&this._rt.texture}get renderTarget(){return this._rt}updatePostprocessing(e){let{enabled:t,...n}=e,i=!1;t!==this.postprocessingState.enabled&&(i=!0);for(let e of Object.entries(n)){let t=e[1],n=this.effects.get(e[0]);if(!n){let i=j(e[0]);i?(n=i(),this.effects.set(e[0],n),"depthOfField"===e[0]&&n.setCamera(this._camera)):t?.enabled&&q(e[0],"webgl")}if(n){n.enabled!==t.enabled&&(i=!0),n.enabled=t.enabled;for(let[e,i]of Object.entries(t))"blendFunction"===e?n.blendFunction=_c(i):n[e]=i}}this.postprocessingState=e,i&&this._initPasses()}render(){this.renderer.shadowMap.type===tn&&this._normalizeShadowDepthTextures(),this.timer.update(),this.effectComposer.render(this.timer.getDelta())}_normalizeShadowDepthTextures(){this._scene.traverse(e=>{let t=e;if(!t.isLight)return;let n=t.shadow?.map?.depthTexture;n&&null!==n.compareFunction&&(n.compareFunction=null,n.minFilter=On,n.magFilter=On,n.needsUpdate=!0)})}setScissor(e,t,n,i){e instanceof Fe?(this.effectComposer.inputBuffer.scissor.set(e.x,e.y,e.z,e.w),this.effectComposer.outputBuffer.scissor.set(e.x,e.y,e.z,e.w)):(this.effectComposer.inputBuffer.scissor.set(e,t,n,i),this.effectComposer.outputBuffer.scissor.set(e,t,n,i));let a=this.renderer.getPixelRatio();this.effectComposer.inputBuffer.scissor.multiplyScalar(a),this.effectComposer.outputBuffer.scissor.multiplyScalar(a),this.renderer.setScissor(e,t,n,i)}setScissorTest(e){this.effectComposer.inputBuffer.scissorTest=e,this.effectComposer.outputBuffer.scissorTest=e,this.renderer.setScissorTest(e)}setViewport(e,t,n,i){e instanceof Fe?(this.effectComposer.inputBuffer.viewport.copy(e),this.effectComposer.outputBuffer.viewport.copy(e)):(this.effectComposer.inputBuffer.viewport.set(e,t,n,i),this.effectComposer.outputBuffer.viewport.set(e,t,n,i))}resize(e,t,n){if(this.effectComposer.setSize(e,t,n),this._rt){let n=this.renderer.getPixelRatio();this._rt.setSize(e*n,t*n)}}dispose(){this.uvEffectPass?.dispose(),this.effectPass?.dispose(),this.effectComposer.dispose(),this.blueNoiseTexture.dispose(),this._rt?.dispose(),this.effects.forEach(e=>e.dispose()),this.effects.clear(),this._scene=void 0,this._camera=void 0,this.renderer=void 0}},Sc=new Ue,Tc=new pe,bc=class extends Qo{constructor(e){super(e),this._pixelRatio=this.getPixelRatio(),this.viewportWidth=1,this.viewportHeight=1,this.resolution=new pe,this.dummyCamera=new l,this.sceneTransitionDuration=0,this.sceneTransitionTimeRemaining=-1,this.manageShadowUpdates=!1,this.forceShadowUpdates=!1,this.clear=(e=!0,t=!0,n=!0)=>{let i=this.getContext(),a=0;e&&(a|=i.COLOR_BUFFER_BIT),t&&(a|=i.DEPTH_BUFFER_BIT),n&&(a|=i.STENCIL_BUFFER_BIT),i.clear(a),i.clearBufferfv(i.COLOR,1,[0,0,0,1])},(()=>{if(!Jl.test(ya.lights_pars_begin)){if(ya.lights_pars_begin.includes(Zl))return;throw new Error("spe: could not find getDistanceAttenuation in lights_pars_begin — three shader chunk layout changed")}ya.lights_pars_begin=ya.lights_pars_begin.replace(Jl,Zl)})(),this.pipeline=new xc(this,e?.needsDOFResize??!1),this.autoClear=!1;let t=this.setPixelRatio.bind(this),n=this.setSize.bind(this);this.shadowMap.enabled=!0,this.shadowMap.type=tn,this.dummyCamera.matrixAutoUpdate=!1,this.domElement.removeAttribute("data-engine"),this._applyPreferredDrawingBufferColorSpace(),this.setPixelRatio=e=>{this._pixelRatio!==e&&(this._pixelRatio=e,t(e))},this.setSize=(e,t,i=!0)=>{(this.viewportWidth!==e||this.viewportHeight!==t)&&(this.viewportWidth=e,this.viewportHeight=t,n(e,t,i),this.normalRenderTarget?.setSize(e*this._pixelRatio,t*this._pixelRatio),this._resizeTransmission(e,t),this.transmissionDepthTarget?.setSize(e*this._pixelRatio/2,t*this._pixelRatio/2),this.pipeline.resize(e,t,i))},this._superDispose=this.dispose,this.dispose=this._currentDispose}_applyPreferredDrawingBufferColorSpace(){let e=this.getContext();if(e&&"drawingBufferColorSpace"in e)try{e.drawingBufferColorSpace="display-p3"}catch(e){console.warn(e)}}get outputColorSpace(){return super.outputColorSpace}set outputColorSpace(e){super.outputColorSpace=e,this._applyPreferredDrawingBufferColorSpace()}createAORenderTarget(){void 0===this.aoRenderTarget&&(this.aoRenderTarget=new Xe(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{generateMipmaps:!1,minFilter:qn,magFilter:qn,wrapS:Rn,wrapT:Rn,depthBuffer:!1}))}_resizeTransmission(e,t){this.transmissionRenderTarget?.setSize(e*this._pixelRatio/(this.hdTransmission?1:2),t*this._pixelRatio/(this.hdTransmission?1:2)),this.aoRenderTarget?.setSize(e*this._pixelRatio/1,t*this._pixelRatio/1)}get hdTransmission(){return 1===qs.transmissionLod.value}set hdTransmission(e){qs.transmissionLod.value=!0===e?1:2,this._resizeTransmission(this.viewportWidth,this.viewportHeight)}createTransmissionRenderTarget(){void 0===this.transmissionRenderTarget&&(this.transmissionRenderTarget=new Xe(this.viewportWidth*this._pixelRatio/(this.hdTransmission?1:2),this.viewportHeight*this._pixelRatio/(this.hdTransmission?1:2),{generateMipmaps:!0,minFilter:ei,magFilter:qn,wrapS:Rn,wrapT:Rn,depthBuffer:!1}),this.transmissionDepthTarget=new Xe(this.viewportWidth*this._pixelRatio/2,this.viewportHeight*this._pixelRatio/2,{minFilter:On,magFilter:On,depthBuffer:!1}))}createNormalRenderTarget(e){let t=e.outline&&e.cavity?"both":e.cavity?"normals":"hash";void 0!==this.normalRenderTarget&&this.normalRenderTargetFlavor!==t&&(this.normalRenderTarget.depthTexture?.dispose(),this.normalRenderTarget.dispose(),this.normalRenderTarget=void 0),void 0===this.normalRenderTarget&&(this.normalRenderTarget=new Xe(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{count:"both"===t?2:1,generateMipmaps:!1,minFilter:On,magFilter:On,type:"normals"===t?re:ee,depthTexture:new de(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio)}),"both"===t&&(this.normalRenderTarget.textures[1].type=re),this.normalRenderTargetFlavor=t)}renderNormal(e,t,n){if(this.normalRenderTarget){this.setClearColor(0),n.layers.enable(8),n.layers.disable(0),n.layers.disable(3),t.traverseEntity(e=>{e.layers.isEnabled(8)&&(e.copyPreviousMatrix=!1)}),this.setRenderTarget(this.normalRenderTarget),this.clear(),jl.value=n instanceof l?(n.far-n.near)/1e4:1;let i=this.normalRenderTargetFlavor??"hash";t.overrideMaterial="both"===i?Kl:"normals"===i?Yl:ql,this.render(t,n),this.setClearColor(t.bgColor,t.bgColor.a),this.setRenderTarget(null),t.overrideMaterial=e.wireframeState?r:null,n.layers.enable(0),n.layers.enable(3),t.traverseEntity(e=>{e.layers.isEnabled(8)&&(e.copyPreviousMatrix=!0)})}}renderSplineSceneWithDummyCamera(e,t,n=1){this.dummyCamera.updateCameraState(t.dataPatched),this.dummyCamera.matrix.copy(t.matrixWorld);let i=t.height,a=t.width,r=this.viewportWidth/this.viewportHeight;a<i?a=i*r:i=a/r,this.dummyCamera.setViewplaneSize(a,i);for(let t=0;t<n;t++)this.renderSplineScene(e,this.dummyCamera)}renderSplineScene(n,a,{sceneHelpers:c=this.sceneHelpers,sceneHelpersOnTop:d=this.sceneHelpersOnTop,overrideTransmission:u,overrideNormal:f}={}){i(this);let p=n instanceof o?n.activePage:n,h=p.visible;p.visible=!0;let m=p.scene,v=P.isSoft(p.data.shadow)?tn:on;if(this.shadowMap.type!==v&&(this.shadowMap.type=v,p.traverseEntity(e=>{let t=e;t.isLight&&t.shadow?.map&&(t.shadow.map.dispose(),t.shadow.map=null,t.shadow.needsUpdate=!0)}),m.markShadowsDirty()),this.setClearColor(p.bgColor,p.bgColor.a),p.penumbraSizeArray.forEach((e,t)=>{qs.penumbraSize.value[t]=e}),qs.pixelRatioNode.value=this.getPixelRatio(),0!==this.resolution.x&&0!==this.resolution.y?qs.resolution.value.set(this.resolution.x,this.resolution.y):qs.resolution.value.set(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio),void 0!==f)qs.normalRenderTarget.value=f,qs.normalRenderTargetDepth.value=Sc,qs.normalViewRenderTarget.value=Sc;else if(m.needsNormal()){let e=m.normalPassNeeds();this.createNormalRenderTarget(e);let t=this.normalRenderTargetFlavor,n=this.normalRenderTarget.textures;qs.normalRenderTarget.value="normals"===t?Sc:n[0],qs.normalRenderTargetDepth.value=this.normalRenderTarget.depthTexture,qs.normalViewRenderTarget.value="both"===t?n[1]:"normals"===t?n[0]:Sc,this.renderNormal(m,p,a)}Ys.spe_fogMode.value=R.getModeIndex({mode:p.fogMode}),Ys.spe_fogHeightParams.value.set(p.fogDensity??R.getDensity({}),p.fogHeightFalloff??R.getHeightFalloff({}),p.fogHeightBase??R.getHeightBase({}));let g=p.data.ao,_=g.occlusion&&!e.enabled;if(_&&(this.createAORenderTarget(),qs.aoRenderTarget.value=this.aoRenderTarget.texture),qs.aoEnabled.value=_,this.pipeline.setAmbientOcclusionParams(_,g.radius,g.bias,p.aoColor,null!==p.fog,p.backupFog.near,p.backupFog.far,{mode:p.fogMode??"linear",density:p.fogDensity??R.getDensity({}),heightFalloff:p.fogHeightFalloff??R.getHeightFalloff({}),heightBase:p.fogHeightBase??R.getHeightBase({})},g.aoFullRes&&!s),this.pipeline.aoPass.setBlueNoiseTexture(this.pipeline.blueNoiseTexture),this.pipeline.isUIOverlayEnabled&&p.uiCanvas?.enabled&&p.uiCanvas.texture&&p.uiCanvas.texture.image.width>0){let e=this.getSize(Tc),t=this.getPixelRatio();(p.uiCanvas.width!==this.viewportWidth||p.uiCanvas.height!==this.viewportHeight||p.uiCanvas.dpr!==t)&&p.uiCanvas.applySize({width:this.viewportWidth,height:this.viewportHeight},t),p.uiCanvas.render(this),this.pipeline.uiOverlayPass.uiCanvas=p.uiCanvas,this.pipeline.uiOverlayPass.enabled=!0,this.pipeline.uiOverlayPass.setResolution(e.x,e.y,t),this.pipeline.updateRenderToScreen()}else this.pipeline.uiOverlayPass.enabled=!1,this.pipeline.updateRenderToScreen();if(this.pipeline.logoOverlayPass.enabled){let e=this.getSize(Tc),t=this.getPixelRatio();this.pipeline.logoOverlayPass.uniforms.uResolution.value.set(e.x,e.y),this.pipeline.logoOverlayPass.uniforms.uDPR.value=t}let x=!1;if(void 0!==u)qs.transmissionRenderTarget.value=u,qs.transmissionRenderTargetDepth.value=Sc,this.pipeline.setTransmissionPassEnabled(!1);else{let e=m.needsTransmission();e&&(void 0===this.transmissionRenderTarget&&(x=!0),this.createTransmissionRenderTarget(),qs.transmissionRenderTarget.value=this.transmissionRenderTarget.texture,qs.aspectRatio.value=(S=this.viewportWidth)>=(T=this.viewportHeight)?new pe(T/S,1):new pe(1,S/T),qs.transmissionRenderTargetDepth.value=this.transmissionDepthTarget.texture),this.pipeline.setTransmissionPassEnabled(e)}var S,T;a.layers.enable(3),a.layers.enable(8),a.layers.enable(4),this.pipeline.sceneHelpers=c,this.pipeline.sceneHelpersOnTop=d,this.pipeline.taaPass.enabled=qs.taaEnabled.value,this.pipeline.scene=p,this.pipeline.camera=a,x&&this.pipeline.transmissionPass.updatePasses(this);let b=t(p.postprocessing);this.pipeline.postprocessingState!==b&&(this.pipeline.updatePostprocessing(b),!c&&!d&&this.pipeline.disableHelpers()),void 0!==this.clearAlphaOverride&&this.setClearAlpha(this.clearAlphaOverride),m.shapeBlendIntances.forEach(e=>{e.onBeforeShadowPass(this)}),this.manageShadowUpdates&&(this.shadowMap.autoUpdate=!1,(m.shadowsDirty||this.forceShadowUpdates)&&(this.shadowMap.needsUpdate=!0)),p.overrideMaterial=m.wireframeState?r:null,this.pipeline.render(),this.manageShadowUpdates&&(m.shadowsDirty=!1),qs.taaEnabled.value&&(qs.frameIndex.value=(qs.frameIndex.value+1)%16),a instanceof l&&a.copyHistory(),p.visible=h}renderFromSceneForSceneTransitionPass(e,t,n){this.pipeline.renderToScreen=!1,this.pipeline.renderTarget,this.renderSplineScene(e,t),this.pipeline.sceneTransitionFromTexture=this.pipeline.renderTarget.texture,this.sceneTransitionDuration=n,this.sceneTransitionTimeRemaining=n,this.pipeline.renderToScreen=!0;let i=this.pipeline.sceneTransitionPass.uniforms;i.uDPR.value=window.devicePixelRatio,i.uResolution.value.set(this.domElement.width,this.domElement.height).divideScalar(window.devicePixelRatio)}_currentDispose(){this._superDispose(),this.pipeline.dispose(),this.aoRenderTarget?.dispose(),this.aoRenderTarget=void 0,this.transmissionRenderTarget?.dispose(),this.transmissionRenderTarget=void 0,this.transmissionDepthTarget?.dispose(),this.transmissionDepthTarget=void 0,this.normalRenderTarget?.depthTexture?.dispose(),this.normalRenderTarget?.dispose(),this.normalRenderTarget=void 0,this.normalRenderTargetFlavor=void 0,this.dummyCamera.dispose(),this.dummyCamera=void 0,qs.normalRenderTarget.value=Sc,qs.normalRenderTargetDepth.value=Sc,qs.normalViewRenderTarget.value=Sc,qs.transmissionRenderTarget.value=Sc,qs.transmissionRenderTargetDepth.value=Sc,qs.aoRenderTarget.value=Sc}};export{bc as SplineRenderer,qs as rendererGlobals};