pi-roundtable-web 0.28.0 → 0.29.1

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 (236) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/README.md +4 -4
  3. package/dist/chunk-account-66e6ezdq.js +1 -0
  4. package/dist/{chunk-action-menu-qpp9bdxh.js → chunk-action-menu-ap5xn7bf.js} +1 -1
  5. package/dist/chunk-agent-sapt5qhn.js +1 -0
  6. package/dist/chunk-arranged-rooms-n6bk696f.js +1 -0
  7. package/dist/chunk-attachments-p5v9gqyt.js +102 -0
  8. package/dist/chunk-bulk-actions-aze4ewc4.js +1 -0
  9. package/dist/chunk-character-creator-m7tw20ef.js +225 -0
  10. package/dist/{chunk-codeeditor-jgj32247.js → chunk-codeeditor-yy6pq8mv.js} +2 -2
  11. package/dist/chunk-confirm-0cajsfhk.js +1 -0
  12. package/dist/chunk-connectors-tw0tbm21.js +37 -0
  13. package/dist/chunk-conversations-wkm23m5r.js +1 -0
  14. package/dist/chunk-council-sheet-mz7s23nq.js +2 -0
  15. package/dist/chunk-council-view-zgvzxtgn.js +1 -0
  16. package/dist/{chunk-drag-04qfef58.js → chunk-drag-d1bpy8w6.js} +1 -1
  17. package/dist/{chunk-entry-mws704mc.js → chunk-entry-7zr5b1fp.js} +1 -1
  18. package/dist/chunk-folder-list-bs4eh3g9.js +1 -0
  19. package/dist/chunk-folds-eez1q41c.js +1 -0
  20. package/dist/{chunk-gate-vxetvn8t.js → chunk-gate-dt91egcd.js} +1 -1
  21. package/dist/chunk-host-icons-nfe2t8tk.js +1 -0
  22. package/dist/chunk-host-picture-4rtswxwa.js +1 -0
  23. package/dist/chunk-host-state-1vxzmmq6.js +1 -0
  24. package/dist/chunk-host-ui-x38bf0et.js +1 -0
  25. package/dist/{chunk-index-zj0gjcvr.js → chunk-index-0h99xcs3.js} +2 -2
  26. package/dist/{chunk-index-e2gy763y.js → chunk-index-1kb8tv4v.js} +2 -2
  27. package/dist/chunk-index-24cggw6k.js +50 -0
  28. package/dist/chunk-index-2g8xtwqg.js +2 -0
  29. package/dist/chunk-index-3n38xe7m.js +2 -0
  30. package/dist/{chunk-index-n0cmnwd2.js → chunk-index-3tksdmx7.js} +2 -2
  31. package/dist/{chunk-index-2822z600.js → chunk-index-4a1tdadd.js} +3 -3
  32. package/dist/{chunk-index-2syyyjnq.js → chunk-index-53fwc7sc.js} +2 -2
  33. package/dist/chunk-index-55ps4x5n.js +2 -0
  34. package/dist/{chunk-index-q5fyrtx4.js → chunk-index-5j1v2q7w.js} +1 -1
  35. package/dist/chunk-index-5w6tb7p0.js +2 -0
  36. package/dist/chunk-index-6btdp13p.js +2 -0
  37. package/dist/chunk-index-6m7dwsmv.js +1 -0
  38. package/dist/{chunk-index-20xgx0k2.js → chunk-index-6rdywten.js} +2 -2
  39. package/dist/{chunk-index-3gfbhmpb.js → chunk-index-6s2pqwna.js} +2 -2
  40. package/dist/{chunk-index-fepsbhr6.js → chunk-index-7mrkq793.js} +2 -2
  41. package/dist/chunk-index-7xcbpeqz.js +2 -0
  42. package/dist/chunk-index-88wh5eyj.js +2 -0
  43. package/dist/{chunk-index-6cg8xp1c.js → chunk-index-8pbwr3rs.js} +1 -1
  44. package/dist/{chunk-index-jc3r4qam.js → chunk-index-8wpvj7k5.js} +2 -2
  45. package/dist/chunk-index-97dcp1vh.js +1 -0
  46. package/dist/chunk-index-a7e6rhxy.js +2 -0
  47. package/dist/{chunk-index-2tr41qht.js → chunk-index-bxf8eq1s.js} +2 -2
  48. package/dist/chunk-index-c8gm1crh.js +120 -0
  49. package/dist/{chunk-index-2y8r4s4f.js → chunk-index-ce7hsda9.js} +2 -2
  50. package/dist/chunk-index-cfesmk1f.js +2 -0
  51. package/dist/{chunk-index-m81362sc.js → chunk-index-cmzvq3nf.js} +1 -1
  52. package/dist/{chunk-index-7qd604rq.js → chunk-index-d4mx2vvf.js} +1 -1
  53. package/dist/chunk-index-d74tpnkd.js +2 -0
  54. package/dist/chunk-index-d941ae7c.js +2 -0
  55. package/dist/{chunk-index-e35v554x.js → chunk-index-dr0jr7d3.js} +3 -3
  56. package/dist/chunk-index-en728705.js +2 -0
  57. package/dist/chunk-index-fb3kzyyp.js +2 -0
  58. package/dist/{chunk-index-3yy10a5h.js → chunk-index-ffnd0jcj.js} +2 -2
  59. package/dist/chunk-index-fn6305vn.js +3 -0
  60. package/dist/{chunk-index-zcfr8jdv.js → chunk-index-gdh7wsd5.js} +12 -12
  61. package/dist/{chunk-index-2hvn2kte.js → chunk-index-m76gdwnk.js} +2 -2
  62. package/dist/chunk-index-mr391t49.js +2 -0
  63. package/dist/chunk-index-n3khm9fq.js +2 -0
  64. package/dist/{chunk-index-sm7kfb07.js → chunk-index-nn4w6a04.js} +2 -2
  65. package/dist/{chunk-index-gwkhs8s3.js → chunk-index-nr275sa7.js} +2 -2
  66. package/dist/{chunk-index-x60n1me6.js → chunk-index-pgxgq61x.js} +2 -2
  67. package/dist/chunk-index-prq011b6.js +2 -0
  68. package/dist/{chunk-index-v9gbt5tz.js → chunk-index-q4k9vk04.js} +19 -3
  69. package/dist/chunk-index-rgdaec7y.js +2 -0
  70. package/dist/chunk-index-rjs1can6.js +2 -0
  71. package/dist/chunk-index-s4a8e4qm.js +2 -0
  72. package/dist/{chunk-index-s9p27f9b.js → chunk-index-sz381vda.js} +3 -3
  73. package/dist/{chunk-index-5hbq6g2e.css → chunk-index-t7csmbpy.css} +1 -1
  74. package/dist/{chunk-index-rgf4rvns.js → chunk-index-v9jqyr1f.js} +3 -3
  75. package/dist/{chunk-index-rsd8rftk.js → chunk-index-vpq2cj14.js} +2 -2
  76. package/dist/chunk-index-vsaggfns.js +2 -0
  77. package/dist/{chunk-index-p7jkr7gv.js → chunk-index-w17wgjby.js} +5 -5
  78. package/dist/{chunk-index-c7dbvkrq.js → chunk-index-wgrx2ybn.js} +2 -2
  79. package/dist/chunk-index-wsv46y9p.js +2 -0
  80. package/dist/{chunk-index-4t6vnwap.js → chunk-index-xbj816p0.js} +2 -2
  81. package/dist/{chunk-index-s53bxwkk.js → chunk-index-yr758n6t.js} +2 -2
  82. package/dist/{chunk-index-5t2jkecy.js → chunk-index-ysv36nbk.js} +2 -2
  83. package/dist/{chunk-index-zt19fdmc.js → chunk-index-ze9p4npm.js} +2 -2
  84. package/dist/chunk-index-zfdvyrjt.js +2 -0
  85. package/dist/chunk-lang-css-3h22se37.js +1 -0
  86. package/dist/{chunk-lang-dockerfile-n4bt8jbt.js → chunk-lang-dockerfile-y24eejnh.js} +1 -1
  87. package/dist/{chunk-lang-go-9k4y107e.js → chunk-lang-go-qzgv1161.js} +3 -3
  88. package/dist/chunk-lang-html-9rvrmmpg.js +1 -0
  89. package/dist/chunk-lang-javascript-4kv8s3tk.js +1 -0
  90. package/dist/{chunk-lang-json-hr12bzs1.js → chunk-lang-json-99v80v88.js} +1 -1
  91. package/dist/{chunk-lang-markdown-ttzcpgkg.js → chunk-lang-markdown-gn8he877.js} +4 -4
  92. package/dist/{chunk-lang-python-ntj8maem.js → chunk-lang-python-prsw4p4k.js} +2 -2
  93. package/dist/{chunk-lang-rust-gv8y859d.js → chunk-lang-rust-g6xqta16.js} +1 -1
  94. package/dist/{chunk-lang-shell-5zzs09b7.js → chunk-lang-shell-dmpnzc6w.js} +1 -1
  95. package/dist/{chunk-lang-sql-6vmze4pg.js → chunk-lang-sql-wz7ca27b.js} +2 -2
  96. package/dist/{chunk-lang-toml-tt0d4rw9.js → chunk-lang-toml-160prtq4.js} +1 -1
  97. package/dist/chunk-lang-typescript-mp0yw903.js +1 -0
  98. package/dist/{chunk-lang-xml-r2sbqnjv.js → chunk-lang-xml-9htkz2dd.js} +1 -1
  99. package/dist/{chunk-lang-yaml-ex31qbph.js → chunk-lang-yaml-08749wd5.js} +1 -1
  100. package/dist/chunk-layout-actions-tdx896xf.js +1 -0
  101. package/dist/chunk-menu-items-trhybv1g.js +1 -0
  102. package/dist/chunk-mode-toggle-4dtfphq4.js +1 -0
  103. package/dist/{chunk-note-row-40ypghn9.js → chunk-note-row-28e5x7n8.js} +33 -4
  104. package/dist/chunk-notes-5nkayhw8.js +1 -0
  105. package/dist/chunk-notice-bell-xz8a04am.js +1 -0
  106. package/dist/{chunk-notices-tefx93s6.js → chunk-notices-d0cwvk27.js} +1 -1
  107. package/dist/chunk-onboarding-zs4rtea9.js +1 -0
  108. package/dist/{chunk-overview-zrx3bpwf.js → chunk-overview-9sb3ywa8.js} +1 -1
  109. package/dist/chunk-palette-5sfhrv4x.js +1 -0
  110. package/dist/chunk-placement-items-e2neja55.js +1 -0
  111. package/dist/{chunk-profile-tyb48b79.js → chunk-profile-jffhtpqf.js} +1 -1
  112. package/dist/chunk-prompt-history-1jz2gk3v.js +1 -0
  113. package/dist/chunk-prompts-0t30ttd0.js +1 -0
  114. package/dist/chunk-room-confirms-6595921h.js +1 -0
  115. package/dist/{chunk-room-menu-ha1evv71.js → chunk-room-menu-hwkjyxwe.js} +1 -1
  116. package/dist/chunk-rooms-menu-button-k0eq1tcr.js +1 -0
  117. package/dist/{chunk-schedules-a5pewkhd.js → chunk-schedules-e12y8fw2.js} +1 -1
  118. package/dist/{chunk-seat-menu-eh3ymmks.js → chunk-seat-menu-n2bcw0mf.js} +1 -1
  119. package/dist/chunk-sheet-hosts-myvm2vhd.js +29 -0
  120. package/dist/chunk-shortcut-help-434sqnxc.js +26 -0
  121. package/dist/chunk-shortcuts-mjxph0g7.js +1 -0
  122. package/dist/chunk-skill-editor-98492yrt.js +8 -0
  123. package/dist/chunk-skills-mfv8ppfh.js +1 -0
  124. package/dist/chunk-start-over-line-m526193z.js +16 -0
  125. package/dist/{chunk-switcher-list-dtfh87zy.js → chunk-switcher-list-5ngjar24.js} +1 -1
  126. package/dist/{chunk-tab-dot-qd640mjr.js → chunk-tab-dot-tzjkahj5.js} +1 -1
  127. package/dist/chunk-table-xbtbex2z.js +1 -0
  128. package/dist/{chunk-table2d-5nrhfwft.js → chunk-table2d-61bvrykm.js} +1 -1
  129. package/dist/{chunk-table3d-5cb66d99.js → chunk-table3d-5a7vbgyj.js} +172 -172
  130. package/dist/chunk-thread-actions-bf6vf2mt.js +1 -0
  131. package/dist/{chunk-thread-cards-kgt22sbp.js → chunk-thread-cards-n0n603vf.js} +1 -1
  132. package/dist/chunk-thread-list-7bkdn51x.js +227 -0
  133. package/dist/{chunk-transcript-a0p3vwh6.js → chunk-transcript-8ztrkt6g.js} +1 -1
  134. package/dist/chunk-waiting-chip-y83c90v3.js +32 -0
  135. package/dist/chunk-waiting-s273kcgz.js +1 -0
  136. package/dist/chunk-where-jr791gzj.js +1 -0
  137. package/dist/chunk-workspace-dw71mshw.js +586 -0
  138. package/dist/chunk-zh-tw-vm5d0w6j.js +1 -0
  139. package/dist/index.html +1 -1
  140. package/dist/sw.js +1 -1
  141. package/package.json +3 -3
  142. package/src/api-types.ts +51 -0
  143. package/src/app/app.ts +7 -0
  144. package/src/app/card-log.ts +10 -2
  145. package/src/app/protocol.ts +18 -0
  146. package/src/app/queued-delivery.ts +107 -0
  147. package/src/app/queued-frames.ts +115 -0
  148. package/src/app/room-log.ts +39 -7
  149. package/src/app/rooms.ts +30 -2
  150. package/src/app/routes.ts +123 -7
  151. package/src/app/skill-group-routes.ts +126 -0
  152. package/src/app/socket.ts +12 -2
  153. package/src/app/surface.ts +37 -6
  154. package/src/app/zip.ts +124 -0
  155. package/src/auth/sessions.ts +9 -1
  156. package/src/authz.ts +1 -0
  157. package/src/host/cards.ts +10 -3
  158. package/src/host/stored-json.ts +23 -0
  159. package/src/i18n/zh-tw.ts +45 -2
  160. package/src/notices/mount.ts +1 -0
  161. package/src/notices/store.ts +9 -1
  162. package/src/push/channel.ts +1 -0
  163. package/src/web-plugin.ts +5 -1
  164. package/dist/chunk-account-678dgbww.js +0 -1
  165. package/dist/chunk-agent-x0yvvdq2.js +0 -1
  166. package/dist/chunk-arranged-rooms-6rdkk8t1.js +0 -1
  167. package/dist/chunk-bulk-actions-zbwdaxtc.js +0 -1
  168. package/dist/chunk-character-creator-215psy17.js +0 -1
  169. package/dist/chunk-confirm-2pzrt272.js +0 -1
  170. package/dist/chunk-connectors-zha2d834.js +0 -37
  171. package/dist/chunk-conversations-fb071rez.js +0 -1
  172. package/dist/chunk-council-sheet-k5fycefd.js +0 -2
  173. package/dist/chunk-folder-list-qxhmczwv.js +0 -1
  174. package/dist/chunk-folds-b7asegfs.js +0 -1
  175. package/dist/chunk-group-scene-63yhh1mh.js +0 -1
  176. package/dist/chunk-group-table-zy4hmgk3.js +0 -1
  177. package/dist/chunk-host-icons-tyktazzz.js +0 -1
  178. package/dist/chunk-host-picture-ebhejn2k.js +0 -1
  179. package/dist/chunk-host-state-wajep0yr.js +0 -1
  180. package/dist/chunk-host-ui-pc9r24e3.js +0 -1
  181. package/dist/chunk-index-1af8vsyb.js +0 -2
  182. package/dist/chunk-index-254701sm.js +0 -3
  183. package/dist/chunk-index-31m1b2f5.js +0 -2
  184. package/dist/chunk-index-5vatmakn.js +0 -2
  185. package/dist/chunk-index-6yra9kdq.js +0 -2
  186. package/dist/chunk-index-9bdstf8t.js +0 -2
  187. package/dist/chunk-index-acj4xxgq.js +0 -100
  188. package/dist/chunk-index-aexy023z.js +0 -2
  189. package/dist/chunk-index-amxa2bn3.js +0 -2
  190. package/dist/chunk-index-bef0fc2m.js +0 -2
  191. package/dist/chunk-index-c6tphrjr.js +0 -1
  192. package/dist/chunk-index-cn49mawx.js +0 -50
  193. package/dist/chunk-index-gcmmwh8t.js +0 -2
  194. package/dist/chunk-index-h2vhv4kh.js +0 -2
  195. package/dist/chunk-index-h9ccz1r3.js +0 -2
  196. package/dist/chunk-index-n0ejy0wd.js +0 -2
  197. package/dist/chunk-index-nkdg1dfz.js +0 -7
  198. package/dist/chunk-index-qxynr1hf.js +0 -2
  199. package/dist/chunk-index-r7fdgzy1.js +0 -2
  200. package/dist/chunk-index-sdcpf5dp.js +0 -2
  201. package/dist/chunk-index-sw9r4aa4.js +0 -2
  202. package/dist/chunk-index-t5bmsqqd.js +0 -1
  203. package/dist/chunk-index-v8mma5np.js +0 -2
  204. package/dist/chunk-index-vsfsv8hd.js +0 -2
  205. package/dist/chunk-index-wxft0aqb.js +0 -2
  206. package/dist/chunk-index-zvvwxkev.js +0 -2
  207. package/dist/chunk-lang-css-7q1dtpgm.js +0 -1
  208. package/dist/chunk-lang-html-xgvba8rn.js +0 -1
  209. package/dist/chunk-lang-javascript-vgxmgd0a.js +0 -1
  210. package/dist/chunk-lang-typescript-2v652sh5.js +0 -1
  211. package/dist/chunk-layout-actions-bfqtg71d.js +0 -1
  212. package/dist/chunk-menu-items-rztgekfj.js +0 -1
  213. package/dist/chunk-mode-toggle-m5kgb7c7.js +0 -1
  214. package/dist/chunk-notes-a8nqffbf.js +0 -1
  215. package/dist/chunk-notice-bell-rdnfmtf2.js +0 -1
  216. package/dist/chunk-onboarding-wvh0s3vg.js +0 -1
  217. package/dist/chunk-palette-5xtdvy9a.js +0 -1
  218. package/dist/chunk-placement-items-rgyrktvy.js +0 -1
  219. package/dist/chunk-prompt-history-wv0vdsjv.js +0 -1
  220. package/dist/chunk-prompts-75hgb0t0.js +0 -1
  221. package/dist/chunk-room-confirms-bcvhpcry.js +0 -1
  222. package/dist/chunk-rooms-menu-button-ej3a2hyc.js +0 -1
  223. package/dist/chunk-sheet-hosts-d5zbwbbr.js +0 -29
  224. package/dist/chunk-shortcut-help-bh9ntk9s.js +0 -26
  225. package/dist/chunk-shortcuts-6em0atk9.js +0 -1
  226. package/dist/chunk-skill-editor-e43mwz01.js +0 -8
  227. package/dist/chunk-skills-vp107wrp.js +0 -1
  228. package/dist/chunk-start-over-line-xd1v2p0g.js +0 -16
  229. package/dist/chunk-table-svb2xhfd.js +0 -1
  230. package/dist/chunk-thread-actions-926eab0w.js +0 -1
  231. package/dist/chunk-thread-list-j2v1pqkz.js +0 -217
  232. package/dist/chunk-waiting-cdyz7r1g.js +0 -1
  233. package/dist/chunk-waiting-chip-58ttx9av.js +0 -28
  234. package/dist/chunk-where-9jp6g029.js +0 -1
  235. package/dist/chunk-workspace-d34njy4p.js +0 -578
  236. package/dist/chunk-zh-tw-y3jb20wc.js +0 -1
@@ -1,10 +1,10 @@
1
- import{zr}from"./chunk-index-cn49mawx.js";import{nn,Tn,cr,rn,Lt,oo,Ts,yt,Ps,Zn,Qs,Ms,Qi,Rs,Cs,so,Es,As,$s,Ns,ao}from"./chunk-index-r7fdgzy1.js";import{An,Mt,Bo,an,ln,Rt,Fo,di,Ii,Go,Di,Zo,Wo,Pr}from"./chunk-index-zj0gjcvr.js";import{Ct,Zt}from"./chunk-index-x60n1me6.js";var vc="186";var yc=0,Wa=1,Sc=2;var ks=1,Mc=2,ds=3,fs=0,Ve=1,on=2,Bn=0,Pn=1,Qn=2,Xa=3,qa=4,bc=5;var ps=100,Tc=101,wc=102,Ec=103,Ac=104,Cc=200,Rc=201,Ic=202,Pc=203,Lc=204,Nc=205,Dc=206,Uc=207,Fc=208,Oc=209,Bc=210,zc=211,kc=212,Gc=213,Hc=214,Vc=0,Wc=1,Xc=2,Ya=3,qc=4,Yc=5,Zc=6,Jc=7,$c=0,Kc=1,Qc=2,Ln=0,Za=1,Ja=2,$a=3,Ka=4,Qa=5,ja=6,to=7;var ms=301,Ai=302,Fr=303,Or=304,Gs=306,Hs=1000,zn=1001,jc=1002,Nn=1003,th=1004;var Vs=1005;var Qe=1006,Br=1007;var Ci=1008;var mn=1009,eh=1010,nh=1011,Ws=1012,eo=1013,mi=1014,jn=1015,kn=1016,no=1017,io=1018,gs=1020,ih=35902,sh=35899,rh=1021,ah=1022,Gn=1023,Ri=1026,Pi=1027,kr=1028,ro=1029,Li=1030,lo=1031;var co=1033,Gr=33776,Hr=33777,Vr=33778,Wr=33779,ho=35840,uo=35841,fo=35842,po=35843,mo=36196,go=37492,_o=37496,xo=37488,vo=37489,Xr=37490,yo=37491,So=37808,Mo=37809,bo=37810,To=37811,wo=37812,Eo=37813,Ao=37814,Co=37815,Ro=37816,Io=37817,Po=37818,Lo=37819,No=37820,Do=37821,Uo=36492,Oo=36494,zo=36495,ko=36283,Ho=36284,qr=36285,Vo=36286;var Xo=0,oh=1,Ni="",gi="srgb",qo="srgb-linear",Yo="linear",Me="srgb";var lh=512,ch=513,hh=514,Yr=515,uh=516,dh=517,Zr=518,fh=519;var Jo="300 es",$o=2000;function Lu(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function Nu(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Os(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function ph(){let t=Os("canvas");return t.style.display="block",t}var Zl={},us=null;function Bs(...t){let e="THREE."+t.shift();if(us)us("log",e,...t);else console.log(e,...t)}function mh(t){let e=t[0];if(typeof e==="string"&&e.startsWith("TSL:")){let n=t[1];if(n&&n.isStackTrace)t[0]+=" "+n.getLocation();else t[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return t}function Ht(...t){t=mh(t);let e="THREE."+t.shift();if(us)us("warn",e,...t);else{let n=t[0];if(n&&n.isStackTrace)console.warn(n.getError(e));else console.warn(e,...t)}}function Gt(...t){t=mh(t);let e="THREE."+t.shift();if(us)us("error",e,...t);else{let n=t[0];if(n&&n.isStackTrace)console.error(n.getError(e));else console.error(e,...t)}}function Ei(...t){let e=t.join(" ");if(e in Zl)return;Zl[e]=!0,Ht(...t)}function gh(t,e,n){return new Promise(function(i,s){function r(){switch(t.clientWaitSync(e,t.SYNC_FLUSH_COMMANDS_BIT,0)){case t.WAIT_FAILED:s();break;case t.TIMEOUT_EXPIRED:setTimeout(r,n);break;default:i()}}setTimeout(r,n)})}var _h={[0]:1,[2]:6,[4]:7,[3]:5,[1]:0,[6]:2,[7]:4,[5]:3};class ti{addEventListener(t,e){if(this._listeners===void 0)this._listeners={};let n=this._listeners;if(n[t]===void 0)n[t]=[];if(n[t].indexOf(e)===-1)n[t].push(e)}hasEventListener(t,e){let n=this._listeners;if(n===void 0)return!1;return n[t]!==void 0&&n[t].indexOf(e)!==-1}removeEventListener(t,e){let n=this._listeners;if(n===void 0)return;let i=n[t];if(i!==void 0){let s=i.indexOf(e);if(s!==-1)i.splice(s,1)}}dispatchEvent(t){let e=this._listeners;if(e===void 0)return;let n=e[t.type];if(n!==void 0){t.target=this;let i=n.slice(0);for(let s=0,r=i.length;s<r;s++)i[s].call(this,t);t.target=null}}}var $e=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];var va=Math.PI/180,Ur=180/Math.PI;function fi(){let t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return($e[t&255]+$e[t>>8&255]+$e[t>>16&255]+$e[t>>24&255]+"-"+$e[e&255]+$e[e>>8&255]+"-"+$e[e>>16&15|64]+$e[e>>24&255]+"-"+$e[n&63|128]+$e[n>>8&255]+"-"+$e[n>>16&255]+$e[n>>24&255]+$e[i&255]+$e[i>>8&255]+$e[i>>16&255]+$e[i>>24&255]).toLowerCase()}function oe(t,e,n){return Math.max(e,Math.min(n,t))}function Du(t,e){return(t%e+e)%e}function ya(t,e,n){return(1-n)*t+n*e}function On(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:case Uint8ClampedArray:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw Error("THREE.MathUtils: Invalid component type.")}}function xe(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(t*4294967295);case Uint16Array:return Math.round(t*65535);case Uint8Array:case Uint8ClampedArray:return Math.round(t*255);case Int32Array:return Math.round(t*2147483647);case Int16Array:return Math.round(t*32767);case Int8Array:return Math.round(t*127);default:throw Error("THREE.MathUtils: Invalid component type.")}}class Xt{static{Xt.prototype.isVector2=!0}constructor(t=0,e=0){this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw Error("THREE.Vector2: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw Error("THREE.Vector2: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){let e=this.x,n=this.y,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6],this.y=i[1]*e+i[4]*n+i[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=oe(this.x,t.x,e.x),this.y=oe(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=oe(this.x,t,e),this.y=oe(this.y,t,e),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(oe(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let n=this.dot(t)/e;return Math.acos(oe(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){let n=Math.cos(e),i=Math.sin(e),s=this.x-t.x,r=this.y-t.y;return this.x=s*n-r*i+t.x,this.y=s*i+r*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class ei{constructor(t=0,e=0,n=0,i=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=i}static slerpFlat(t,e,n,i,s,r,a){let o=n[i+0],l=n[i+1],c=n[i+2],u=n[i+3],d=s[r+0],h=s[r+1],p=s[r+2],v=s[r+3];if(u!==v||o!==d||l!==h||c!==p){let T=o*d+l*h+c*p+u*v;if(T<0)d=-d,h=-h,p=-p,v=-v,T=-T;let m=1-a;if(T<0.9995){let f=Math.acos(T),w=Math.sin(f);m=Math.sin(m*f)/w,a=Math.sin(a*f)/w,o=o*m+d*a,l=l*m+h*a,c=c*m+p*a,u=u*m+v*a}else{o=o*m+d*a,l=l*m+h*a,c=c*m+p*a,u=u*m+v*a;let f=1/Math.sqrt(o*o+l*l+c*c+u*u);o*=f,l*=f,c*=f,u*=f}}t[e]=o,t[e+1]=l,t[e+2]=c,t[e+3]=u}static multiplyQuaternionsFlat(t,e,n,i,s,r){let a=n[i],o=n[i+1],l=n[i+2],c=n[i+3],u=s[r],d=s[r+1],h=s[r+2],p=s[r+3];return t[e]=a*p+c*u+o*h-l*d,t[e+1]=o*p+c*d+l*u-a*h,t[e+2]=l*p+c*h+a*d-o*u,t[e+3]=c*p-a*u-o*d-l*h,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,i){return this._x=t,this._y=e,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){let{_x:n,_y:i,_z:s,_order:r}=t,{cos:a,sin:o}=Math,l=a(n/2),c=a(i/2),u=a(s/2),d=o(n/2),h=o(i/2),p=o(s/2);switch(r){case"XYZ":this._x=d*c*u+l*h*p,this._y=l*h*u-d*c*p,this._z=l*c*p+d*h*u,this._w=l*c*u-d*h*p;break;case"YXZ":this._x=d*c*u+l*h*p,this._y=l*h*u-d*c*p,this._z=l*c*p-d*h*u,this._w=l*c*u+d*h*p;break;case"ZXY":this._x=d*c*u-l*h*p,this._y=l*h*u+d*c*p,this._z=l*c*p+d*h*u,this._w=l*c*u-d*h*p;break;case"ZYX":this._x=d*c*u-l*h*p,this._y=l*h*u+d*c*p,this._z=l*c*p-d*h*u,this._w=l*c*u+d*h*p;break;case"YZX":this._x=d*c*u+l*h*p,this._y=l*h*u+d*c*p,this._z=l*c*p-d*h*u,this._w=l*c*u-d*h*p;break;case"XZY":this._x=d*c*u-l*h*p,this._y=l*h*u-d*c*p,this._z=l*c*p+d*h*u,this._w=l*c*u+d*h*p;break;default:Ht("Quaternion: .setFromEuler() encountered an unknown order: "+r)}if(e===!0)this._onChangeCallback();return this}setFromAxisAngle(t,e){let n=e/2,i=Math.sin(n);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){let e=t.elements,n=e[0],i=e[4],s=e[8],r=e[1],a=e[5],o=e[9],l=e[2],c=e[6],u=e[10],d=n+a+u;if(d>0){let h=0.5/Math.sqrt(d+1);this._w=0.25/h,this._x=(c-o)*h,this._y=(s-l)*h,this._z=(r-i)*h}else if(n>a&&n>u){let h=2*Math.sqrt(1+n-a-u);this._w=(c-o)/h,this._x=0.25*h,this._y=(i+r)/h,this._z=(s+l)/h}else if(a>u){let h=2*Math.sqrt(1+a-n-u);this._w=(s-l)/h,this._x=(i+r)/h,this._y=0.25*h,this._z=(o+c)/h}else{let h=2*Math.sqrt(1+u-n-a);this._w=(r-i)/h,this._x=(s+l)/h,this._y=(o+c)/h,this._z=0.25*h}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;if(n<0.00000001)if(n=0,Math.abs(t.x)>Math.abs(t.z))this._x=-t.y,this._y=t.x,this._z=0,this._w=n;else this._x=0,this._y=-t.z,this._z=t.y,this._w=n;else this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n;return this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(oe(this.dot(t),-1,1)))}rotateTowards(t,e){let n=this.angleTo(t);if(n===0)return this;let i=Math.min(1,e/n);return this.slerp(t,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();if(t===0)this._x=0,this._y=0,this._z=0,this._w=1;else t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t;return this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){let{_x:n,_y:i,_z:s,_w:r}=t,{_x:a,_y:o,_z:l,_w:c}=e;return this._x=n*c+r*a+i*l-s*o,this._y=i*c+r*o+s*a-n*l,this._z=s*c+r*l+n*o-i*a,this._w=r*c-n*a-i*o-s*l,this._onChangeCallback(),this}slerp(t,e){let{_x:n,_y:i,_z:s,_w:r}=t,a=this.dot(t);if(a<0)n=-n,i=-i,s=-s,r=-r,a=-a;let o=1-e;if(a<0.9995){let l=Math.acos(a),c=Math.sin(l);o=Math.sin(o*l)/c,e=Math.sin(e*l)/c,this._x=this._x*o+n*e,this._y=this._y*o+i*e,this._z=this._z*o+s*e,this._w=this._w*o+r*e,this._onChangeCallback()}else this._x=this._x*o+n*e,this._y=this._y*o+i*e,this._z=this._z*o+s*e,this._w=this._w*o+r*e,this.normalize();return this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){let t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),s=Math.sqrt(n);return this.set(i*Math.sin(t),i*Math.cos(t),s*Math.sin(e),s*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class O{static{O.prototype.isVector3=!0}constructor(t=0,e=0,n=0){this.x=t,this.y=e,this.z=n}set(t,e,n){if(n===void 0)n=this.z;return this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw Error("THREE.Vector3: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error("THREE.Vector3: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(Jl.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Jl.setFromAxisAngle(t,e))}applyMatrix3(t){let e=this.x,n=this.y,i=this.z,s=t.elements;return this.x=s[0]*e+s[3]*n+s[6]*i,this.y=s[1]*e+s[4]*n+s[7]*i,this.z=s[2]*e+s[5]*n+s[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){let e=this.x,n=this.y,i=this.z,s=t.elements,r=1/(s[3]*e+s[7]*n+s[11]*i+s[15]);return this.x=(s[0]*e+s[4]*n+s[8]*i+s[12])*r,this.y=(s[1]*e+s[5]*n+s[9]*i+s[13])*r,this.z=(s[2]*e+s[6]*n+s[10]*i+s[14])*r,this}applyQuaternion(t){let e=this.x,n=this.y,i=this.z,{x:s,y:r,z:a,w:o}=t,l=2*(r*i-a*n),c=2*(a*e-s*i),u=2*(s*n-r*e);return this.x=e+o*l+r*u-a*c,this.y=n+o*c+a*l-s*u,this.z=i+o*u+s*c-r*l,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){let e=this.x,n=this.y,i=this.z,s=t.elements;return this.x=s[0]*e+s[4]*n+s[8]*i,this.y=s[1]*e+s[5]*n+s[9]*i,this.z=s[2]*e+s[6]*n+s[10]*i,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=oe(this.x,t.x,e.x),this.y=oe(this.y,t.y,e.y),this.z=oe(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=oe(this.x,t,e),this.y=oe(this.y,t,e),this.z=oe(this.z,t,e),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(oe(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){let{x:n,y:i,z:s}=t,{x:r,y:a,z:o}=e;return this.x=i*o-s*a,this.y=s*r-n*o,this.z=n*a-i*r,this}projectOnVector(t){let e=t.lengthSq();if(e===0)return this.set(0,0,0);let n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return Sa.copy(this).projectOnVector(t),this.sub(Sa)}reflect(t){return this.sub(Sa.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let n=this.dot(t)/e;return Math.acos(oe(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,n=this.y-t.y,i=this.z-t.z;return e*e+n*n+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){let i=Math.sin(e)*t;return this.x=i*Math.sin(n),this.y=Math.cos(e)*t,this.z=i*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){let e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){let e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=i,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let t=Math.random()*Math.PI*2,e=Math.random()*2-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}var Sa=new O,Jl=new ei;class qt{static{qt.prototype.isMatrix3=!0}constructor(t,e,n,i,s,r,a,o,l){if(this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0)this.set(t,e,n,i,s,r,a,o,l)}set(t,e,n,i,s,r,a,o,l){let c=this.elements;return c[0]=t,c[1]=i,c[2]=a,c[3]=e,c[4]=s,c[5]=o,c[6]=n,c[7]=r,c[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){let e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){let e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let n=t.elements,i=e.elements,s=this.elements,r=n[0],a=n[3],o=n[6],l=n[1],c=n[4],u=n[7],d=n[2],h=n[5],p=n[8],v=i[0],T=i[3],m=i[6],f=i[1],w=i[4],C=i[7],y=i[2],b=i[5],A=i[8];return s[0]=r*v+a*f+o*y,s[3]=r*T+a*w+o*b,s[6]=r*m+a*C+o*A,s[1]=l*v+c*f+u*y,s[4]=l*T+c*w+u*b,s[7]=l*m+c*C+u*A,s[2]=d*v+h*f+p*y,s[5]=d*T+h*w+p*b,s[8]=d*m+h*C+p*A,this}multiplyScalar(t){let e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){let t=this.elements,e=t[0],n=t[1],i=t[2],s=t[3],r=t[4],a=t[5],o=t[6],l=t[7],c=t[8];return e*r*c-e*a*l-n*s*c+n*a*o+i*s*l-i*r*o}invert(){let t=this.elements,e=t[0],n=t[1],i=t[2],s=t[3],r=t[4],a=t[5],o=t[6],l=t[7],c=t[8],u=c*r-a*l,d=a*o-c*s,h=l*s-r*o,p=e*u+n*d+i*h;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let v=1/p;return t[0]=u*v,t[1]=(i*l-c*n)*v,t[2]=(a*n-i*r)*v,t[3]=d*v,t[4]=(c*e-i*o)*v,t[5]=(i*s-a*e)*v,t[6]=h*v,t[7]=(n*o-l*e)*v,t[8]=(r*e-n*s)*v,this}transpose(){let t,e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){let e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,i,s,r,a){let o=Math.cos(s),l=Math.sin(s);return this.set(n*o,n*l,-n*(o*r+l*a)+r+t,-i*l,i*o,-i*(-l*r+o*a)+a+e,0,0,1),this}scale(t,e){return Ei("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Ma.makeScale(t,e)),this}rotate(t){return Ei("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Ma.makeRotation(-t)),this}translate(t,e){return Ei("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Ma.makeTranslation(t,e)),this}makeTranslation(t,e){if(t.isVector2)this.set(1,0,t.x,0,1,t.y,0,0,1);else this.set(1,0,t,0,1,e,0,0,1);return this}makeRotation(t){let e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){let e=this.elements,n=t.elements;for(let i=0;i<9;i++)if(e[i]!==n[i])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){let n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return new this.constructor().fromArray(this.elements)}}var Ma=new qt,$l=new qt().set(0.4123908,0.3575843,0.1804808,0.212639,0.7151687,0.0721923,0.0193308,0.1191948,0.9505322),Kl=new qt().set(3.2409699,-1.5373832,-0.4986108,-0.9692436,1.8759675,0.0415551,0.0556301,-0.203977,1.0569715);function Uu(){let t={enabled:!0,workingColorSpace:"srgb-linear",spaces:{},convert:function(s,r,a){if(this.enabled===!1||r===a||!r||!a)return s;if(this.spaces[r].transfer==="srgb")s.r=Kn(s.r),s.g=Kn(s.g),s.b=Kn(s.b);if(this.spaces[r].primaries!==this.spaces[a].primaries)s.applyMatrix3(this.spaces[r].toXYZ),s.applyMatrix3(this.spaces[a].fromXYZ);if(this.spaces[a].transfer==="srgb")s.r=hs(s.r),s.g=hs(s.g),s.b=hs(s.b);return s},workingToColorSpace:function(s,r){return this.convert(s,this.workingColorSpace,r)},colorSpaceToWorking:function(s,r){return this.convert(s,r,this.workingColorSpace)},getPrimaries:function(s){return this.spaces[s].primaries},getTransfer:function(s){if(s==="")return"linear";return this.spaces[s].transfer},getToneMappingMode:function(s){return this.spaces[s].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(s,r=this.workingColorSpace){return s.fromArray(this.spaces[r].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s)},_getMatrix:function(s,r,a){return s.copy(this.spaces[r].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(s,r){return Ei("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(s,r)},toWorkingColorSpace:function(s,r){return Ei("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),t.colorSpaceToWorking(s,r)}},e=[0.64,0.33,0.3,0.6,0.15,0.06],n=[0.2126,0.7152,0.0722],i=[0.3127,0.329];return t.define({["srgb-linear"]:{primaries:e,whitePoint:i,transfer:"linear",toXYZ:$l,fromXYZ:Kl,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:"srgb"},outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}},["srgb"]:{primaries:e,whitePoint:i,transfer:"srgb",toXYZ:$l,fromXYZ:Kl,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}}}),t}var re=Uu();function Kn(t){return t<0.04045?t*0.0773993808:Math.pow(t*0.9478672986+0.0521327014,2.4)}function hs(t){return t<0.0031308?t*12.92:1.055*Math.pow(t,0.41666)-0.055}var qi;class Ko{static getDataURL(t,e="image/png"){if(/^data:/i.test(t.src))return t.src;if(typeof HTMLCanvasElement>"u")return t.src;let n;if(t instanceof HTMLCanvasElement)n=t;else{if(qi===void 0)qi=Os("canvas");qi.width=t.width,qi.height=t.height;let i=qi.getContext("2d");if(t instanceof ImageData)i.putImageData(t,0,0);else i.drawImage(t,0,0,t.width,t.height);n=qi}return n.toDataURL(e)}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){let e=Os("canvas");e.width=t.width,e.height=t.height;let n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);let i=n.getImageData(0,0,t.width,t.height),s=i.data;for(let r=0;r<s.length;r++)s[r]=Kn(s[r]/255)*255;return n.putImageData(i,0,0),e}else if(t.data){let e=t.data.slice(0);for(let n=0;n<e.length;n++)if(e instanceof Uint8Array||e instanceof Uint8ClampedArray)e[n]=Math.floor(Kn(e[n]/255)*255);else e[n]=Kn(e[n]);return{data:e,width:t.width,height:t.height}}else return Ht("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}var Fu=0;class Xs{constructor(t=null){this.isTextureSource=!0,Object.defineProperty(this,"id",{value:Fu++}),this.uuid=fi(),this.data=t,this.dataReady=!0,this.version=0}getSize(t){let e=this.data;if(typeof HTMLVideoElement<"u"&&e instanceof HTMLVideoElement)t.set(e.videoWidth,e.videoHeight,0);else if(typeof VideoFrame<"u"&&e instanceof VideoFrame)t.set(e.displayWidth,e.displayHeight,0);else if(e!==null)t.set(e.width,e.height,e.depth||0);else t.set(0,0,0);return t}set needsUpdate(t){if(t===!0)this.version++}toJSON(t){let e=t===void 0||typeof t==="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];let n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let s;if(Array.isArray(i)){s=[];for(let r=0,a=i.length;r<a;r++)if(i[r].isDataTexture)s.push(ba(i[r].image));else s.push(ba(i[r]))}else s=ba(i);n.url=s}if(!e)t.images[this.uuid]=n;return n}}function ba(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap)return Ko.getDataURL(t);else if(t.data)return{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name};else return Ht("Texture: Unable to serialize Texture."),{}}var Ou=0,Ta=new O;class qe extends ti{constructor(t=qe.DEFAULT_IMAGE,e=qe.DEFAULT_MAPPING,n=1001,i=1001,s=1006,r=1008,a=1023,o=1009,l=qe.DEFAULT_ANISOTROPY,c=""){super();this.isTexture=!0,Object.defineProperty(this,"id",{value:Ou++}),this.uuid=fi(),this.name="",this.source=new Xs(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=s,this.minFilter=r,this.anisotropy=l,this.format=a,this.internalFormat=null,this.type=o,this.offset=new Xt(0,0),this.repeat=new Xt(1,1),this.center=new Xt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new qt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=c,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=t&&t.depth&&t.depth>1?!0:!1,this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(Ta).x}get height(){return this.source.getSize(Ta).y}get depth(){return this.source.getSize(Ta).z}get image(){return this.source.data}set image(t){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.normalized=t.normalized,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.renderTarget=t.renderTarget,this.isRenderTargetTexture=t.isRenderTargetTexture,this.isArrayTexture=t.isArrayTexture,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}setValues(t){for(let e in t){let n=t[e];if(n===void 0){Ht(`Texture.setValues(): parameter '${e}' has value of undefined.`);continue}let i=this[e];if(i===void 0){Ht(`Texture.setValues(): property '${e}' does not exist.`);continue}if(i&&n&&(i.isVector2&&n.isVector2))i.copy(n);else if(i&&n&&(i.isVector3&&n.isVector3))i.copy(n);else if(i&&n&&(i.isMatrix3&&n.isMatrix3))i.copy(n);else this[e]=n}}toJSON(t){let e=t===void 0||typeof t==="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];let n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(Object.keys(this.userData).length>0)n.userData=this.userData;if(!e)t.textures[this.uuid]=n;return n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==300)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case 1000:t.x=t.x-Math.floor(t.x);break;case 1001:t.x=t.x<0?0:1;break;case 1002:if(Math.abs(Math.floor(t.x)%2)===1)t.x=Math.ceil(t.x)-t.x;else t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case 1000:t.y=t.y-Math.floor(t.y);break;case 1001:t.y=t.y<0?0:1;break;case 1002:if(Math.abs(Math.floor(t.y)%2)===1)t.y=Math.ceil(t.y)-t.y;else t.y=t.y-Math.floor(t.y);break}if(this.flipY)t.y=1-t.y;return t}set needsUpdate(t){if(t===!0)this.version++,this.source.needsUpdate=!0}set needsPMREMUpdate(t){if(t===!0)this.pmremVersion++}}qe.DEFAULT_IMAGE=null;qe.DEFAULT_MAPPING=300;qe.DEFAULT_ANISOTROPY=1;class Ae{static{Ae.prototype.isVector4=!0}constructor(t=0,e=0,n=0,i=1){this.x=t,this.y=e,this.z=n,this.w=i}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,i){return this.x=t,this.y=e,this.z=n,this.w=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw Error("THREE.Vector4: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error("THREE.Vector4: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){let e=this.x,n=this.y,i=this.z,s=this.w,r=t.elements;return this.x=r[0]*e+r[4]*n+r[8]*i+r[12]*s,this.y=r[1]*e+r[5]*n+r[9]*i+r[13]*s,this.z=r[2]*e+r[6]*n+r[10]*i+r[14]*s,this.w=r[3]*e+r[7]*n+r[11]*i+r[15]*s,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);let e=Math.sqrt(1-t.w*t.w);if(e<0.0001)this.x=1,this.y=0,this.z=0;else this.x=t.x/e,this.y=t.y/e,this.z=t.z/e;return this}setAxisAngleFromRotationMatrix(t){let e,n,i,s,r=0.01,a=0.1,o=t.elements,l=o[0],c=o[4],u=o[8],d=o[1],h=o[5],p=o[9],v=o[2],T=o[6],m=o[10];if(Math.abs(c-d)<0.01&&Math.abs(u-v)<0.01&&Math.abs(p-T)<0.01){if(Math.abs(c+d)<0.1&&Math.abs(u+v)<0.1&&Math.abs(p+T)<0.1&&Math.abs(l+h+m-3)<0.1)return this.set(1,0,0,0),this;e=Math.PI;let w=(l+1)/2,C=(h+1)/2,y=(m+1)/2,b=(c+d)/4,A=(u+v)/4,E=(p+T)/4;if(w>C&&w>y)if(w<0.01)n=0,i=0.707106781,s=0.707106781;else n=Math.sqrt(w),i=b/n,s=A/n;else if(C>y)if(C<0.01)n=0.707106781,i=0,s=0.707106781;else i=Math.sqrt(C),n=b/i,s=E/i;else if(y<0.01)n=0.707106781,i=0.707106781,s=0;else s=Math.sqrt(y),n=A/s,i=E/s;return this.set(n,i,s,e),this}let f=Math.sqrt((T-p)*(T-p)+(u-v)*(u-v)+(d-c)*(d-c));if(Math.abs(f)<0.001)f=1;return this.x=(T-p)/f,this.y=(u-v)/f,this.z=(d-c)/f,this.w=Math.acos((l+h+m-1)/2),this}setFromMatrixPosition(t){let e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=oe(this.x,t.x,e.x),this.y=oe(this.y,t.y,e.y),this.z=oe(this.z,t.z,e.z),this.w=oe(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=oe(this.x,t,e),this.y=oe(this.y,t,e),this.z=oe(this.z,t,e),this.w=oe(this.w,t,e),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(oe(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class Qo extends ti{constructor(t=1,e=1,n={}){super();n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:1006,depthBuffer:!0,stencilBuffer:!1,resolveColorBuffer:!0,resolveDepthBuffer:!0,resolveStencilBuffer:!0,storeMultisampledColorBuffer:!0,storeMultisampledDepthBuffer:!0,storeMultisampledStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=n.depth,this.scissor=new Ae(0,0,t,e),this.scissorTest=!1,this.viewport=new Ae(0,0,t,e),this.textures=[];let i={width:t,height:e,depth:n.depth},s=new qe(i),r=n.count;for(let a=0;a<r;a++)this.textures[a]=s.clone(),this.textures[a].isRenderTargetTexture=!0,this.textures[a].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveColorBuffer=n.resolveColorBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this.storeMultisampledColorBuffer=n.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=n.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=n.storeMultisampledStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview,this.useArrayDepthTexture=n.useArrayDepthTexture}_setTextureOptions(t={}){let e={minFilter:1006,generateMipmaps:!1,flipY:!1,internalFormat:null};if(t.mapping!==void 0)e.mapping=t.mapping;if(t.wrapS!==void 0)e.wrapS=t.wrapS;if(t.wrapT!==void 0)e.wrapT=t.wrapT;if(t.wrapR!==void 0)e.wrapR=t.wrapR;if(t.magFilter!==void 0)e.magFilter=t.magFilter;if(t.minFilter!==void 0)e.minFilter=t.minFilter;if(t.format!==void 0)e.format=t.format;if(t.type!==void 0)e.type=t.type;if(t.anisotropy!==void 0)e.anisotropy=t.anisotropy;if(t.colorSpace!==void 0)e.colorSpace=t.colorSpace;if(t.flipY!==void 0)e.flipY=t.flipY;if(t.generateMipmaps!==void 0)e.generateMipmaps=t.generateMipmaps;if(t.internalFormat!==void 0)e.internalFormat=t.internalFormat;for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(e)}get texture(){return this.textures[0]}set texture(t){this.textures[0]=t}set depthTexture(t){if(this._depthTexture!==null&&this._depthTexture.renderTarget===this)this._depthTexture.renderTarget=null;if(t!==null&&t.renderTarget===null)t.renderTarget=this;this._depthTexture=t}get depthTexture(){return this._depthTexture}setSize(t,e,n=1){if(this.width!==t||this.height!==e||this.depth!==n){this.width=t,this.height=e,this.depth=n;for(let i=0,s=this.textures.length;i<s;i++)if(this.textures[i].image.width=t,this.textures[i].image.height=e,this.textures[i].image.depth=n,this.textures[i].isData3DTexture!==!0)this.textures[i].isArrayTexture=this.textures[i].image.depth>1;this.dispose()}this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return new this.constructor().copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.textures.length=0;for(let e=0,n=t.textures.length;e<n;e++){this.textures[e]=t.textures[e].clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;let i=Object.assign({},t.textures[e].image);this.textures[e].source=new Xs(i)}if(this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.resolveColorBuffer=t.resolveColorBuffer,this.resolveDepthBuffer=t.resolveDepthBuffer,this.resolveStencilBuffer=t.resolveStencilBuffer,this.storeMultisampledColorBuffer=t.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=t.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=t.storeMultisampledStencilBuffer,t.depthTexture!==null)if(t.depthTexture.renderTarget===t){let e=t.depthTexture.clone();e.renderTarget=null,this.depthTexture=e}else this.depthTexture=t.depthTexture;return this.samples=t.samples,this.multiview=t.multiview,this.useArrayDepthTexture=t.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}class gn extends Qo{constructor(t=1,e=1,n={}){super(t,e,n);this.isWebGLRenderTarget=!0}}class Jr extends qe{constructor(t=null,e=1,n=1,i=1){super(null);this.isDataArrayTexture=!0,this.image={data:t,width:e,height:n,depth:i},this.magFilter=1003,this.minFilter=1003,this.wrapR=1001,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}copy(t){return super.copy(t),this.wrapR=t.wrapR,this}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class jo extends qe{constructor(t=null,e=1,n=1,i=1){super(null);this.isData3DTexture=!0,this.image={data:t,width:e,height:n,depth:i},this.magFilter=1003,this.minFilter=1003,this.wrapR=1001,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}copy(t){return super.copy(t),this.wrapR=t.wrapR,this}}class we{static{we.prototype.isMatrix4=!0}constructor(t,e,n,i,s,r,a,o,l,c,u,d,h,p,v,T){if(this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0)this.set(t,e,n,i,s,r,a,o,l,c,u,d,h,p,v,T)}set(t,e,n,i,s,r,a,o,l,c,u,d,h,p,v,T){let m=this.elements;return m[0]=t,m[4]=e,m[8]=n,m[12]=i,m[1]=s,m[5]=r,m[9]=a,m[13]=o,m[2]=l,m[6]=c,m[10]=u,m[14]=d,m[3]=h,m[7]=p,m[11]=v,m[15]=T,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new we().fromArray(this.elements)}copy(t){let e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){let e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){let e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){if(this.determinantAffine()===0)return t.set(1,0,0),e.set(0,1,0),n.set(0,0,1),this;return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){if(t.determinantAffine()===0)return this.identity();let e=this.elements,n=t.elements,i=1/Yi.setFromMatrixColumn(t,0).length(),s=1/Yi.setFromMatrixColumn(t,1).length(),r=1/Yi.setFromMatrixColumn(t,2).length();return e[0]=n[0]*i,e[1]=n[1]*i,e[2]=n[2]*i,e[3]=0,e[4]=n[4]*s,e[5]=n[5]*s,e[6]=n[6]*s,e[7]=0,e[8]=n[8]*r,e[9]=n[9]*r,e[10]=n[10]*r,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){let e=this.elements,{x:n,y:i,z:s}=t,r=Math.cos(n),a=Math.sin(n),o=Math.cos(i),l=Math.sin(i),c=Math.cos(s),u=Math.sin(s);if(t.order==="XYZ"){let d=r*c,h=r*u,p=a*c,v=a*u;e[0]=o*c,e[4]=-o*u,e[8]=l,e[1]=h+p*l,e[5]=d-v*l,e[9]=-a*o,e[2]=v-d*l,e[6]=p+h*l,e[10]=r*o}else if(t.order==="YXZ"){let d=o*c,h=o*u,p=l*c,v=l*u;e[0]=d+v*a,e[4]=p*a-h,e[8]=r*l,e[1]=r*u,e[5]=r*c,e[9]=-a,e[2]=h*a-p,e[6]=v+d*a,e[10]=r*o}else if(t.order==="ZXY"){let d=o*c,h=o*u,p=l*c,v=l*u;e[0]=d-v*a,e[4]=-r*u,e[8]=p+h*a,e[1]=h+p*a,e[5]=r*c,e[9]=v-d*a,e[2]=-r*l,e[6]=a,e[10]=r*o}else if(t.order==="ZYX"){let d=r*c,h=r*u,p=a*c,v=a*u;e[0]=o*c,e[4]=p*l-h,e[8]=d*l+v,e[1]=o*u,e[5]=v*l+d,e[9]=h*l-p,e[2]=-l,e[6]=a*o,e[10]=r*o}else if(t.order==="YZX"){let d=r*o,h=r*l,p=a*o,v=a*l;e[0]=o*c,e[4]=v-d*u,e[8]=p*u+h,e[1]=u,e[5]=r*c,e[9]=-a*c,e[2]=-l*c,e[6]=h*u+p,e[10]=d-v*u}else if(t.order==="XZY"){let d=r*o,h=r*l,p=a*o,v=a*l;e[0]=o*c,e[4]=-u,e[8]=l*c,e[1]=d*u+v,e[5]=r*c,e[9]=h*u-p,e[2]=p*u-h,e[6]=a*c,e[10]=v*u+d}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(Bu,t,zu)}lookAt(t,e,n){let i=this.elements;if(dn.subVectors(t,e),dn.lengthSq()===0)dn.z=1;if(dn.normalize(),oi.crossVectors(n,dn),oi.lengthSq()===0){if(Math.abs(n.z)===1)dn.x+=0.0001;else dn.z+=0.0001;dn.normalize(),oi.crossVectors(n,dn)}return oi.normalize(),dr.crossVectors(dn,oi),i[0]=oi.x,i[4]=dr.x,i[8]=dn.x,i[1]=oi.y,i[5]=dr.y,i[9]=dn.y,i[2]=oi.z,i[6]=dr.z,i[10]=dn.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let n=t.elements,i=e.elements,s=this.elements,r=n[0],a=n[4],o=n[8],l=n[12],c=n[1],u=n[5],d=n[9],h=n[13],p=n[2],v=n[6],T=n[10],m=n[14],f=n[3],w=n[7],C=n[11],y=n[15],b=i[0],A=i[4],E=i[8],g=i[12],M=i[1],G=i[5],N=i[9],F=i[13],X=i[2],R=i[6],k=i[10],Z=i[14],H=i[3],at=i[7],K=i[11],et=i[15];return s[0]=r*b+a*M+o*X+l*H,s[4]=r*A+a*G+o*R+l*at,s[8]=r*E+a*N+o*k+l*K,s[12]=r*g+a*F+o*Z+l*et,s[1]=c*b+u*M+d*X+h*H,s[5]=c*A+u*G+d*R+h*at,s[9]=c*E+u*N+d*k+h*K,s[13]=c*g+u*F+d*Z+h*et,s[2]=p*b+v*M+T*X+m*H,s[6]=p*A+v*G+T*R+m*at,s[10]=p*E+v*N+T*k+m*K,s[14]=p*g+v*F+T*Z+m*et,s[3]=f*b+w*M+C*X+y*H,s[7]=f*A+w*G+C*R+y*at,s[11]=f*E+w*N+C*k+y*K,s[15]=f*g+w*F+C*Z+y*et,this}multiplyScalar(t){let e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){let t=this.elements,e=t[0],n=t[4],i=t[8],s=t[12],r=t[1],a=t[5],o=t[9],l=t[13],c=t[2],u=t[6],d=t[10],h=t[14],p=t[3],v=t[7],T=t[11],m=t[15],f=o*h-l*d,w=a*h-l*u,C=a*d-o*u,y=r*h-l*c,b=r*d-o*c,A=r*u-a*c;return e*(v*f-T*w+m*C)-n*(p*f-T*y+m*b)+i*(p*w-v*y+m*A)-s*(p*C-v*b+T*A)}determinantAffine(){let t=this.elements,e=t[0],n=t[4],i=t[8],s=t[1],r=t[5],a=t[9],o=t[2],l=t[6],c=t[10];return e*(r*c-a*l)-n*(s*c-a*o)+i*(s*l-r*o)}transpose(){let t=this.elements,e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){let i=this.elements;if(t.isVector3)i[12]=t.x,i[13]=t.y,i[14]=t.z;else i[12]=t,i[13]=e,i[14]=n;return this}invert(){let t=this.elements,e=t[0],n=t[1],i=t[2],s=t[3],r=t[4],a=t[5],o=t[6],l=t[7],c=t[8],u=t[9],d=t[10],h=t[11],p=t[12],v=t[13],T=t[14],m=t[15],f=e*a-n*r,w=e*o-i*r,C=e*l-s*r,y=n*o-i*a,b=n*l-s*a,A=i*l-s*o,E=c*v-u*p,g=c*T-d*p,M=c*m-h*p,G=u*T-d*v,N=u*m-h*v,F=d*m-h*T,X=f*F-w*N+C*G+y*M-b*g+A*E;if(X===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let R=1/X;return t[0]=(a*F-o*N+l*G)*R,t[1]=(i*N-n*F-s*G)*R,t[2]=(v*A-T*b+m*y)*R,t[3]=(d*b-u*A-h*y)*R,t[4]=(o*M-r*F-l*g)*R,t[5]=(e*F-i*M+s*g)*R,t[6]=(T*C-p*A-m*w)*R,t[7]=(c*A-d*C+h*w)*R,t[8]=(r*N-a*M+l*E)*R,t[9]=(n*M-e*N-s*E)*R,t[10]=(p*b-v*C+m*f)*R,t[11]=(u*C-c*b-h*f)*R,t[12]=(a*g-r*G-o*E)*R,t[13]=(e*G-n*g+i*E)*R,t[14]=(v*w-p*y-T*f)*R,t[15]=(c*y-u*w+d*f)*R,this}scale(t){let e=this.elements,{x:n,y:i,z:s}=t;return e[0]*=n,e[4]*=i,e[8]*=s,e[1]*=n,e[5]*=i,e[9]*=s,e[2]*=n,e[6]*=i,e[10]*=s,e[3]*=n,e[7]*=i,e[11]*=s,this}getMaxScaleOnAxis(){let t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,i))}makeTranslation(t,e,n){if(t.isVector3)this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1);else this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1);return this}makeRotationX(t){let e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){let e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){let e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){let n=Math.cos(e),i=Math.sin(e),s=1-n,{x:r,y:a,z:o}=t,l=s*r,c=s*a;return this.set(l*r+n,l*a-i*o,l*o+i*a,0,l*a+i*o,c*a+n,c*o-i*r,0,l*o-i*a,c*o+i*r,s*o*o+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,i,s,r){return this.set(1,n,s,0,t,1,r,0,e,i,1,0,0,0,0,1),this}compose(t,e,n){let i=this.elements,{_x:s,_y:r,_z:a,_w:o}=e,l=s+s,c=r+r,u=a+a,d=s*l,h=s*c,p=s*u,v=r*c,T=r*u,m=a*u,f=o*l,w=o*c,C=o*u,{x:y,y:b,z:A}=n;return i[0]=(1-(v+m))*y,i[1]=(h+C)*y,i[2]=(p-w)*y,i[3]=0,i[4]=(h-C)*b,i[5]=(1-(d+m))*b,i[6]=(T+f)*b,i[7]=0,i[8]=(p+w)*A,i[9]=(T-f)*A,i[10]=(1-(d+v))*A,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,n){let i=this.elements;t.x=i[12],t.y=i[13],t.z=i[14];let s=this.determinantAffine();if(s===0)return n.set(1,1,1),e.identity(),this;let r=Yi.set(i[0],i[1],i[2]).length(),a=Yi.set(i[4],i[5],i[6]).length(),o=Yi.set(i[8],i[9],i[10]).length();if(s<0)r=-r;Cn.copy(this);let l=1/r,c=1/a,u=1/o;return Cn.elements[0]*=l,Cn.elements[1]*=l,Cn.elements[2]*=l,Cn.elements[4]*=c,Cn.elements[5]*=c,Cn.elements[6]*=c,Cn.elements[8]*=u,Cn.elements[9]*=u,Cn.elements[10]*=u,e.setFromRotationMatrix(Cn),n.x=r,n.y=a,n.z=o,this}makePerspective(t,e,n,i,s,r,a=2000,o=!1){let l=this.elements,c=2*s/(e-t),u=2*s/(n-i),d=(e+t)/(e-t),h=(n+i)/(n-i),p,v;if(o)p=s/(r-s),v=r*s/(r-s);else if(a===2000)p=-(r+s)/(r-s),v=-2*r*s/(r-s);else if(a===2001)p=-r/(r-s),v=-r*s/(r-s);else throw Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return l[0]=c,l[4]=0,l[8]=d,l[12]=0,l[1]=0,l[5]=u,l[9]=h,l[13]=0,l[2]=0,l[6]=0,l[10]=p,l[14]=v,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(t,e,n,i,s,r,a=2000,o=!1){let l=this.elements,c=2/(e-t),u=2/(n-i),d=-(e+t)/(e-t),h=-(n+i)/(n-i),p,v;if(o)p=1/(r-s),v=r/(r-s);else if(a===2000)p=-2/(r-s),v=-(r+s)/(r-s);else if(a===2001)p=-1/(r-s),v=-s/(r-s);else throw Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return l[0]=c,l[4]=0,l[8]=0,l[12]=d,l[1]=0,l[5]=u,l[9]=0,l[13]=h,l[2]=0,l[6]=0,l[10]=p,l[14]=v,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(t){let e=this.elements,n=t.elements;for(let i=0;i<16;i++)if(e[i]!==n[i])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){let n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}}var Yi=new O,Cn=new we,Bu=new O(0,0,0),zu=new O(1,1,1),oi=new O,dr=new O,dn=new O,Ql=new we,jl=new ei;class pi{constructor(t=0,e=0,n=0,i=pi.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=i}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,i=this._order){return this._x=t,this._y=e,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,n=!0){let i=t.elements,s=i[0],r=i[4],a=i[8],o=i[1],l=i[5],c=i[9],u=i[2],d=i[6],h=i[10];switch(e){case"XYZ":if(this._y=Math.asin(oe(a,-1,1)),Math.abs(a)<0.9999999)this._x=Math.atan2(-c,h),this._z=Math.atan2(-r,s);else this._x=Math.atan2(d,l),this._z=0;break;case"YXZ":if(this._x=Math.asin(-oe(c,-1,1)),Math.abs(c)<0.9999999)this._y=Math.atan2(a,h),this._z=Math.atan2(o,l);else this._y=Math.atan2(-u,s),this._z=0;break;case"ZXY":if(this._x=Math.asin(oe(d,-1,1)),Math.abs(d)<0.9999999)this._y=Math.atan2(-u,h),this._z=Math.atan2(-r,l);else this._y=0,this._z=Math.atan2(o,s);break;case"ZYX":if(this._y=Math.asin(-oe(u,-1,1)),Math.abs(u)<0.9999999)this._x=Math.atan2(d,h),this._z=Math.atan2(o,s);else this._x=0,this._z=Math.atan2(-r,l);break;case"YZX":if(this._z=Math.asin(oe(o,-1,1)),Math.abs(o)<0.9999999)this._x=Math.atan2(-c,l),this._y=Math.atan2(-u,s);else this._x=0,this._y=Math.atan2(a,h);break;case"XZY":if(this._z=Math.asin(-oe(r,-1,1)),Math.abs(r)<0.9999999)this._x=Math.atan2(d,l),this._y=Math.atan2(a,s);else this._x=Math.atan2(-c,h),this._y=0;break;default:Ht("Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}if(this._order=e,n===!0)this._onChangeCallback();return this}setFromQuaternion(t,e,n){return Ql.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Ql,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return jl.setFromEuler(this),this.setFromQuaternion(jl,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){if(this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0)this._order=t[3];return this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}pi.DEFAULT_ORDER="XYZ";class qs{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}isEnabled(t){return(this.mask&(1<<t|0))!==0}}var ku=0,tc=new O,Zi=new ei,Xn=new we,fr=new O,bs=new O,Gu=new O,Hu=new ei,ec=new O(1,0,0),nc=new O(0,1,0),ic=new O(0,0,1),sc={type:"added"},Vu={type:"removed"},Ji={type:"childadded",child:null},wa={type:"childremoved",child:null};class He extends ti{constructor(){super();this.isObject3D=!0,Object.defineProperty(this,"id",{value:ku++}),this.uuid=fi(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=He.DEFAULT_UP.clone();let t=new O,e=new pi,n=new ei,i=new O(1,1,1);function s(){n.setFromEuler(e,!1)}function r(){e.setFromQuaternion(n,void 0,!1)}e._onChange(s),n._onChange(r),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new we},normalMatrix:{value:new qt}}),this.matrix=new we,this.matrixWorld=new we,this.matrixAutoUpdate=He.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=He.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new qs,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){if(this.matrixAutoUpdate)this.updateMatrix();this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return Zi.setFromAxisAngle(t,e),this.quaternion.multiply(Zi),this}rotateOnWorldAxis(t,e){return Zi.setFromAxisAngle(t,e),this.quaternion.premultiply(Zi),this}rotateX(t){return this.rotateOnAxis(ec,t)}rotateY(t){return this.rotateOnAxis(nc,t)}rotateZ(t){return this.rotateOnAxis(ic,t)}translateOnAxis(t,e){return tc.copy(t).applyQuaternion(this.quaternion),this.position.add(tc.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(ec,t)}translateY(t){return this.translateOnAxis(nc,t)}translateZ(t){return this.translateOnAxis(ic,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(Xn.copy(this.matrixWorld).invert())}lookAt(t,e,n){if(t.isVector3)fr.copy(t);else fr.set(t,e,n);let i=this.parent;if(this.updateWorldMatrix(!0,!1),bs.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight)Xn.lookAt(bs,fr,this.up);else Xn.lookAt(fr,bs,this.up);if(this.quaternion.setFromRotationMatrix(Xn),i)Xn.extractRotation(i.matrixWorld),Zi.setFromRotationMatrix(Xn),this.quaternion.premultiply(Zi.invert())}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}if(t===this)return Gt("Object3D.add: object can't be added as a child of itself.",t),this;if(t&&t.isObject3D)t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(sc),Ji.child=t,this.dispatchEvent(Ji),Ji.child=null;else Gt("Object3D.add: object not an instance of THREE.Object3D.",t);return this}remove(t){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}let e=this.children.indexOf(t);if(e!==-1)t.parent=null,this.children.splice(e,1),t.dispatchEvent(Vu),wa.child=t,this.dispatchEvent(wa),wa.child=null;return this}removeFromParent(){let t=this.parent;if(t!==null)t.remove(this);return this}clear(){return this.remove(...this.children)}attach(t){if(this.updateWorldMatrix(!0,!1),Xn.copy(this.matrixWorld).invert(),t.parent!==null)t.parent.updateWorldMatrix(!0,!1),Xn.multiply(t.parent.matrixWorld);return t.applyMatrix4(Xn),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(sc),Ji.child=t,this.dispatchEvent(Ji),Ji.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let n=0,i=this.children.length;n<i;n++){let r=this.children[n].getObjectByProperty(t,e);if(r!==void 0)return r}return}getObjectsByProperty(t,e,n=[]){if(this[t]===e)n.push(this);let i=this.children;for(let s=0,r=i.length;s<r;s++)i[s].getObjectsByProperty(t,e,n);return n}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(bs,t,Gu),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(bs,Hu,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);let e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}intersectsFrustum(){}traverse(t){t(this);let e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);let e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverseVisible(t)}traverseAncestors(t){let e=this.parent;if(e!==null)t(e),e.traverseAncestors(t)}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let t=this.pivot;if(t!==null){let{x:e,y:n,z:i}=t,s=this.matrix.elements;s[12]+=e-s[0]*e-s[4]*n-s[8]*i,s[13]+=n-s[1]*e-s[5]*n-s[9]*i,s[14]+=i-s[2]*e-s[6]*n-s[10]*i}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){if(this.matrixAutoUpdate)this.updateMatrix();if(this.matrixWorldNeedsUpdate||t){if(this.matrixWorldAutoUpdate===!0)if(this.parent===null)this.matrixWorld.copy(this.matrix);else this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix);this.matrixWorldNeedsUpdate=!1,t=!0}let e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].updateMatrixWorld(t)}updateWorldMatrix(t,e,n=!1){let i=this.parent;if(t===!0&&i!==null)i.updateWorldMatrix(!0,!1);if(this.matrixAutoUpdate)this.updateMatrix();if(this.matrixWorldNeedsUpdate||n){if(this.matrixWorldAutoUpdate===!0)if(this.parent===null)this.matrixWorld.copy(this.matrix);else this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix);this.matrixWorldNeedsUpdate=!1,n=!0}if(e===!0){let s=this.children;for(let r=0,a=s.length;r<a;r++)s[r].updateWorldMatrix(!1,!0,n)}}toJSON(t){let e=t===void 0||typeof t==="string",n={};if(e)t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"};let i={};if(i.uuid=this.uuid,i.type=this.type,i.name=this.name,i.castShadow=this.castShadow,i.receiveShadow=this.receiveShadow,i.visible=this.visible,i.frustumCulled=this.frustumCulled,i.renderOrder=this.renderOrder,i.static=this.static,i.matrixAutoUpdate=this.matrixAutoUpdate,Object.keys(this.userData).length>0)i.userData=this.userData;if(i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.pivot!==null)i.pivot=this.pivot.toArray();if(this.morphTargetDictionary!==void 0)i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary);if(this.morphTargetInfluences!==void 0)i.morphTargetInfluences=this.morphTargetInfluences.slice();if(this.isInstancedMesh){if(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null)i.instanceColor=this.instanceColor.toJSON()}if(this.isBatchedMesh){if(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map((a)=>({...a,boundingBox:a.boundingBox?a.boundingBox.toJSON():void 0,boundingSphere:a.boundingSphere?a.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map((a)=>({...a})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(t),i.indirectTexture=this._indirectTexture.toJSON(t),this._colorsTexture!==null)i.colorsTexture=this._colorsTexture.toJSON(t);if(this.boundingSphere!==null)i.boundingSphere=this.boundingSphere.toJSON();if(this.boundingBox!==null)i.boundingBox=this.boundingBox.toJSON()}function s(a,o){if(a[o.uuid]===void 0)a[o.uuid]=o.toJSON(t);return o.uuid}if(this.isScene){if(this.background){if(this.background.isColor)i.background=this.background.toJSON();else if(this.background.isTexture)i.background=this.background.toJSON(t).uuid}if(this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0)i.environment=this.environment.toJSON(t).uuid}else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(t.geometries,this.geometry);let a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){let o=a.shapes;if(Array.isArray(o))for(let l=0,c=o.length;l<c;l++){let u=o[l];s(t.shapes,u)}else s(t.shapes,o)}}if(this.isSkinnedMesh){if(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0)s(t.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid}if(this.material!==void 0)if(Array.isArray(this.material)){let a=[];for(let o=0,l=this.material.length;o<l;o++)a.push(s(t.materials,this.material[o]));i.material=a}else i.material=s(t.materials,this.material);if(this.children.length>0){i.children=[];for(let a=0;a<this.children.length;a++)i.children.push(this.children[a].toJSON(t).object)}if(this.animations.length>0){i.animations=[];for(let a=0;a<this.animations.length;a++){let o=this.animations[a];i.animations.push(s(t.animations,o))}}if(e){let a=r(t.geometries),o=r(t.materials),l=r(t.textures),c=r(t.images),u=r(t.shapes),d=r(t.skeletons),h=r(t.animations),p=r(t.nodes);if(a.length>0)n.geometries=a;if(o.length>0)n.materials=o;if(l.length>0)n.textures=l;if(c.length>0)n.images=c;if(u.length>0)n.shapes=u;if(d.length>0)n.skeletons=d;if(h.length>0)n.animations=h;if(p.length>0)n.nodes=p}return n.object=i,n;function r(a){let o=[];for(let l in a){let c=a[l];delete c.metadata,o.push(c)}return o}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.pivot=t.pivot!==null?t.pivot.clone():null,this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.static=t.static,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let n=0;n<t.children.length;n++){let i=t.children[n];this.add(i.clone())}return this}dispose(){this.dispatchEvent({type:"dispose"})}}He.DEFAULT_UP=new O(0,1,0);He.DEFAULT_MATRIX_AUTO_UPDATE=!0;He.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class Xe extends He{constructor(){super();this.isGroup=!0,this.type="Group"}}var Wu={type:"move"};class Ys{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){if(this._hand===null)this._hand=new Xe,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1};return this._hand}getTargetRaySpace(){if(this._targetRay===null)this._targetRay=new Xe,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new O,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new O;return this._targetRay}getGripSpace(){if(this._grip===null)this._grip=new Xe,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new O,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new O,this._grip.eventsEnabled=!1;return this._grip}dispatchEvent(t){if(this._targetRay!==null)this._targetRay.dispatchEvent(t);if(this._grip!==null)this._grip.dispatchEvent(t);if(this._hand!==null)this._hand.dispatchEvent(t);return this}connect(t){if(t&&t.hand){let e=this._hand;if(e)for(let n of t.hand.values())this._getHandJoint(e,n)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){if(this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null)this._targetRay.visible=!1;if(this._grip!==null)this._grip.visible=!1;if(this._hand!==null)this._hand.visible=!1;return this}update(t,e,n){let i=null,s=null,r=null,a=this._targetRay,o=this._grip,l=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(l&&t.hand){r=!0;for(let v of t.hand.values()){let T=e.getJointPose(v,n),m=this._getHandJoint(l,v);if(T!==null)m.matrix.fromArray(T.transform.matrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.matrixWorldNeedsUpdate=!0,m.jointRadius=T.radius;m.visible=T!==null}let c=l.joints["index-finger-tip"],u=l.joints["thumb-tip"],d=c.position.distanceTo(u.position),h=0.02,p=0.005;if(l.inputState.pinching&&d>h+p)l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this});else if(!l.inputState.pinching&&d<=h-p)l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this})}else if(o!==null&&t.gripSpace){if(s=e.getPose(t.gripSpace,n),s!==null){if(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,s.linearVelocity)o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity);else o.hasLinearVelocity=!1;if(s.angularVelocity)o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity);else o.hasAngularVelocity=!1;if(o.eventsEnabled)o.dispatchEvent({type:"gripUpdated",data:t,target:this})}}if(a!==null){if(i=e.getPose(t.targetRaySpace,n),i===null&&s!==null)i=s;if(i!==null){if(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,i.linearVelocity)a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity);else a.hasLinearVelocity=!1;if(i.angularVelocity)a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity);else a.hasAngularVelocity=!1;this.dispatchEvent(Wu)}}}if(a!==null)a.visible=i!==null;if(o!==null)o.visible=s!==null;if(l!==null)l.visible=r!==null;return this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){let n=new Xe;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}}var xh={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},li={h:0,s:0,l:0},pr={h:0,s:0,l:0};function Ea(t,e,n){if(n<0)n+=1;if(n>1)n-=1;if(n<0.16666666666666666)return t+(e-t)*6*n;if(n<0.5)return e;if(n<0.6666666666666666)return t+(e-t)*6*(0.6666666666666666-n);return t}class Kt{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(e===void 0&&n===void 0){let i=t;if(i&&i.isColor)this.copy(i);else if(typeof i==="number")this.setHex(i);else if(typeof i==="string")this.setStyle(i)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e="srgb"){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,re.colorSpaceToWorking(this,e),this}setRGB(t,e,n,i=re.workingColorSpace){return this.r=t,this.g=e,this.b=n,re.colorSpaceToWorking(this,i),this}setHSL(t,e,n,i=re.workingColorSpace){if(t=Du(t,1),e=oe(e,0,1),n=oe(n,0,1),e===0)this.r=this.g=this.b=n;else{let s=n<=0.5?n*(1+e):n+e-n*e,r=2*n-s;this.r=Ea(r,s,t+0.3333333333333333),this.g=Ea(r,s,t),this.b=Ea(r,s,t-0.3333333333333333)}return re.colorSpaceToWorking(this,i),this}setStyle(t,e="srgb"){function n(s){if(s===void 0)return;if(parseFloat(s)<1)Ht("Color: Alpha component of "+t+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(t)){let s,r=i[1],a=i[2];switch(r){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,e);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,e);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,e);break;default:Ht("Color: Unknown color model "+t)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(t)){let s=i[1],r=s.length;if(r===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,e);else if(r===6)return this.setHex(parseInt(s,16),e);else Ht("Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e="srgb"){let n=xh[t.toLowerCase()];if(n!==void 0)this.setHex(n,e);else Ht("Color: Unknown color "+t);return this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=Kn(t.r),this.g=Kn(t.g),this.b=Kn(t.b),this}copyLinearToSRGB(t){return this.r=hs(t.r),this.g=hs(t.g),this.b=hs(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t="srgb"){return re.workingToColorSpace(Ke.copy(this),t),Math.round(oe(Ke.r*255,0,255))*65536+Math.round(oe(Ke.g*255,0,255))*256+Math.round(oe(Ke.b*255,0,255))}getHexString(t="srgb"){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=re.workingColorSpace){re.workingToColorSpace(Ke.copy(this),e);let{r:n,g:i,b:s}=Ke,r=Math.max(n,i,s),a=Math.min(n,i,s),o,l,c=(a+r)/2;if(a===r)o=0,l=0;else{let u=r-a;switch(l=c<=0.5?u/(r+a):u/(2-r-a),r){case n:o=(i-s)/u+(i<s?6:0);break;case i:o=(s-n)/u+2;break;case s:o=(n-i)/u+4;break}o/=6}return t.h=o,t.s=l,t.l=c,t}getRGB(t,e=re.workingColorSpace){return re.workingToColorSpace(Ke.copy(this),e),t.r=Ke.r,t.g=Ke.g,t.b=Ke.b,t}getStyle(t="srgb"){re.workingToColorSpace(Ke.copy(this),t);let{r:e,g:n,b:i}=Ke;if(t!=="srgb")return`color(${t} ${e.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`;return`rgb(${Math.round(e*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(t,e,n){return this.getHSL(li),this.setHSL(li.h+t,li.s+e,li.l+n)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,n){return this.r=t.r+(e.r-t.r)*n,this.g=t.g+(e.g-t.g)*n,this.b=t.b+(e.b-t.b)*n,this}lerpHSL(t,e){this.getHSL(li),t.getHSL(pr);let n=ya(li.h,pr.h,e),i=ya(li.s,pr.s,e),s=ya(li.l,pr.l,e);return this.setHSL(n,i,s),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){let e=this.r,n=this.g,i=this.b,s=t.elements;return this.r=s[0]*e+s[3]*n+s[6]*i,this.g=s[1]*e+s[4]*n+s[7]*i,this.b=s[2]*e+s[5]*n+s[8]*i,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}var Ke=new Kt;Kt.NAMES=xh;class Zs{constructor(t,e=1,n=1000){this.isFog=!0,this.name="",this.color=new Kt(t),this.near=e,this.far=n}clone(){return new Zs(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class $r extends He{constructor(){super();if(this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new pi,this.environmentIntensity=1,this.environmentRotation=new pi,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){if(super.copy(t,e),t.background!==null)this.background=t.background.clone();if(t.environment!==null)this.environment=t.environment.clone();if(t.fog!==null)this.fog=t.fog.clone();if(this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,this.backgroundRotation.copy(t.backgroundRotation),this.environmentIntensity=t.environmentIntensity,this.environmentRotation.copy(t.environmentRotation),t.overrideMaterial!==null)this.overrideMaterial=t.overrideMaterial.clone();return this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){let e=super.toJSON(t);if(this.fog!==null)e.object.fog=this.fog.toJSON();return e.object.backgroundBlurriness=this.backgroundBlurriness,e.object.backgroundIntensity=this.backgroundIntensity,e.object.backgroundRotation=this.backgroundRotation.toArray(),e.object.environmentIntensity=this.environmentIntensity,e.object.environmentRotation=this.environmentRotation.toArray(),e}}var Rn=new O,qn=new O,Aa=new O,Yn=new O,$i=new O,Ki=new O,rc=new O,Ca=new O,Ra=new O,Ia=new O,Pa=new Ae,La=new Ae,Na=new Ae;class pn{constructor(t=new O,e=new O,n=new O){this.a=t,this.b=e,this.c=n}static getNormal(t,e,n,i){i.subVectors(n,e),Rn.subVectors(t,e),i.cross(Rn);let s=i.lengthSq();if(s>0)return i.multiplyScalar(1/Math.sqrt(s));return i.set(0,0,0)}static getBarycoord(t,e,n,i,s){Rn.subVectors(i,e),qn.subVectors(n,e),Aa.subVectors(t,e);let r=Rn.dot(Rn),a=Rn.dot(qn),o=Rn.dot(Aa),l=qn.dot(qn),c=qn.dot(Aa),u=r*l-a*a;if(u===0)return s.set(0,0,0),null;let d=1/u,h=(l*o-a*c)*d,p=(r*c-a*o)*d;return s.set(1-h-p,p,h)}static containsPoint(t,e,n,i){if(this.getBarycoord(t,e,n,i,Yn)===null)return!1;return Yn.x>=0&&Yn.y>=0&&Yn.x+Yn.y<=1}static getInterpolation(t,e,n,i,s,r,a,o){if(this.getBarycoord(t,e,n,i,Yn)===null){if(o.x=0,o.y=0,"z"in o)o.z=0;if("w"in o)o.w=0;return null}return o.setScalar(0),o.addScaledVector(s,Yn.x),o.addScaledVector(r,Yn.y),o.addScaledVector(a,Yn.z),o}static getInterpolatedAttribute(t,e,n,i,s,r){return Pa.setScalar(0),La.setScalar(0),Na.setScalar(0),Pa.fromBufferAttribute(t,e),La.fromBufferAttribute(t,n),Na.fromBufferAttribute(t,i),r.setScalar(0),r.addScaledVector(Pa,s.x),r.addScaledVector(La,s.y),r.addScaledVector(Na,s.z),r}static isFrontFacing(t,e,n,i){return Rn.subVectors(n,e),qn.subVectors(t,e),Rn.cross(qn).dot(i)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,i){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[i]),this}setFromAttributeAndIndices(t,e,n,i){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,i),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return Rn.subVectors(this.c,this.b),qn.subVectors(this.a,this.b),Rn.cross(qn).length()*0.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(0.3333333333333333)}getNormal(t){return pn.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return pn.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,i,s){return pn.getInterpolation(t,this.a,this.b,this.c,e,n,i,s)}containsPoint(t){return pn.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return pn.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){let n=this.a,i=this.b,s=this.c,r,a;$i.subVectors(i,n),Ki.subVectors(s,n),Ca.subVectors(t,n);let o=$i.dot(Ca),l=Ki.dot(Ca);if(o<=0&&l<=0)return e.copy(n);Ra.subVectors(t,i);let c=$i.dot(Ra),u=Ki.dot(Ra);if(c>=0&&u<=c)return e.copy(i);let d=o*u-c*l;if(d<=0&&o>=0&&c<=0)return r=o/(o-c),e.copy(n).addScaledVector($i,r);Ia.subVectors(t,s);let h=$i.dot(Ia),p=Ki.dot(Ia);if(p>=0&&h<=p)return e.copy(s);let v=h*l-o*p;if(v<=0&&l>=0&&p<=0)return a=l/(l-p),e.copy(n).addScaledVector(Ki,a);let T=c*p-h*u;if(T<=0&&u-c>=0&&h-p>=0)return rc.subVectors(s,i),a=(u-c)/(u-c+(h-p)),e.copy(i).addScaledVector(rc,a);let m=1/(T+v+d);return r=v*m,a=d*m,e.copy(n).addScaledVector($i,r).addScaledVector(Ki,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}class Ui{constructor(t=new O(1/0,1/0,1/0),e=new O(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e+=3)this.expandByPoint(In.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,n=t.count;e<n;e++)this.expandByPoint(In.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){let n=In.copy(e).multiplyScalar(0.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(0.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);let n=t.geometry;if(n!==void 0){let s=n.getAttribute("position");if(e===!0&&s!==void 0&&t.isInstancedMesh!==!0)for(let r=0,a=s.count;r<a;r++){if(t.isMesh===!0)t.getVertexPosition(r,In);else In.fromBufferAttribute(s,r);In.applyMatrix4(t.matrixWorld),this.expandByPoint(In)}else{if(t.boundingBox!==void 0){if(t.boundingBox===null)t.computeBoundingBox();mr.copy(t.boundingBox)}else{if(n.boundingBox===null)n.computeBoundingBox();mr.copy(n.boundingBox)}mr.applyMatrix4(t.matrixWorld),this.union(mr)}}let i=t.children;for(let s=0,r=i.length;s<r;s++)this.expandByObject(i[s],e);return this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,In),In.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;if(t.normal.x>0)e=t.normal.x*this.min.x,n=t.normal.x*this.max.x;else e=t.normal.x*this.max.x,n=t.normal.x*this.min.x;if(t.normal.y>0)e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y;else e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y;if(t.normal.z>0)e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z;else e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z;return e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(ws),gr.subVectors(this.max,ws),ji.subVectors(t.a,ws),ts.subVectors(t.b,ws),es.subVectors(t.c,ws),ci.subVectors(ts,ji),hi.subVectors(es,ts),Mi.subVectors(ji,es);let e=[0,-ci.z,ci.y,0,-hi.z,hi.y,0,-Mi.z,Mi.y,ci.z,0,-ci.x,hi.z,0,-hi.x,Mi.z,0,-Mi.x,-ci.y,ci.x,0,-hi.y,hi.x,0,-Mi.y,Mi.x,0];if(!Da(e,ji,ts,es,gr))return!1;if(e=[1,0,0,0,1,0,0,0,1],!Da(e,ji,ts,es,gr))return!1;return _r.crossVectors(ci,hi),e=[_r.x,_r.y,_r.z],Da(e,ji,ts,es,gr)}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,In).distanceTo(t)}getBoundingSphere(t){if(this.isEmpty())t.makeEmpty();else this.getCenter(t.center),t.radius=this.getSize(In).length()*0.5;return t}intersect(t){if(this.min.max(t.min),this.max.min(t.max),this.isEmpty())this.makeEmpty();return this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){if(this.isEmpty())return this;return Jn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Jn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Jn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Jn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Jn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Jn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Jn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Jn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Jn),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(t){return this.min.fromArray(t.min),this.max.fromArray(t.max),this}}var Jn=[new O,new O,new O,new O,new O,new O,new O,new O],In=new O,mr=new Ui,ji=new O,ts=new O,es=new O,ci=new O,hi=new O,Mi=new O,ws=new O,gr=new O,_r=new O,bi=new O;function Da(t,e,n,i,s){for(let r=0,a=t.length-3;r<=a;r+=3){bi.fromArray(t,r);let o=s.x*Math.abs(bi.x)+s.y*Math.abs(bi.y)+s.z*Math.abs(bi.z),l=e.dot(bi),c=n.dot(bi),u=i.dot(bi);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>o)return!1}return!0}var Oe=new O,xr=new Xt,Xu=0;class Mn extends ti{constructor(t,e,n=!1){super();if(Array.isArray(t))throw TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Xu++}),this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=n,this.usage=35044,this.updateRanges=[],this.gpuType=1015,this.version=0}onUploadCallback(){}set needsUpdate(t){if(t===!0)this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let i=0,s=this.itemSize;i<s;i++)this.array[t+i]=e.array[n+i];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,n=this.count;e<n;e++)xr.fromBufferAttribute(this,e),xr.applyMatrix3(t),this.setXY(e,xr.x,xr.y);else if(this.itemSize===3)for(let e=0,n=this.count;e<n;e++)Oe.fromBufferAttribute(this,e),Oe.applyMatrix3(t),this.setXYZ(e,Oe.x,Oe.y,Oe.z);return this}applyMatrix4(t){for(let e=0,n=this.count;e<n;e++)Oe.fromBufferAttribute(this,e),Oe.applyMatrix4(t),this.setXYZ(e,Oe.x,Oe.y,Oe.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)Oe.fromBufferAttribute(this,e),Oe.applyNormalMatrix(t),this.setXYZ(e,Oe.x,Oe.y,Oe.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)Oe.fromBufferAttribute(this,e),Oe.transformDirection(t),this.setXYZ(e,Oe.x,Oe.y,Oe.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let n=this.array[t*this.itemSize+e];if(this.normalized)n=On(n,this.array);return n}setComponent(t,e,n){if(this.normalized)n=xe(n,this.array);return this.array[t*this.itemSize+e]=n,this}getX(t){let e=this.array[t*this.itemSize];if(this.normalized)e=On(e,this.array);return e}setX(t,e){if(this.normalized)e=xe(e,this.array);return this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];if(this.normalized)e=On(e,this.array);return e}setY(t,e){if(this.normalized)e=xe(e,this.array);return this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];if(this.normalized)e=On(e,this.array);return e}setZ(t,e){if(this.normalized)e=xe(e,this.array);return this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];if(this.normalized)e=On(e,this.array);return e}setW(t,e){if(this.normalized)e=xe(e,this.array);return this.array[t*this.itemSize+3]=e,this}setXY(t,e,n){if(t*=this.itemSize,this.normalized)e=xe(e,this.array),n=xe(n,this.array);return this.array[t+0]=e,this.array[t+1]=n,this}setXYZ(t,e,n,i){if(t*=this.itemSize,this.normalized)e=xe(e,this.array),n=xe(n,this.array),i=xe(i,this.array);return this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this}setXYZW(t,e,n,i,s){if(t*=this.itemSize,this.normalized)e=xe(e,this.array),n=xe(n,this.array),i=xe(i,this.array),s=xe(s,this.array);return this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this.array[t+3]=s,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return t.name=this.name,t.usage=this.usage,t.gpuType=this.gpuType,t}dispose(){this.dispatchEvent({type:"dispose"})}}class Kr extends Mn{constructor(t,e,n){super(new Uint16Array(t),e,n)}}class Qr extends Mn{constructor(t,e,n){super(new Uint32Array(t),e,n)}}class Ye extends Mn{constructor(t,e,n){super(new Float32Array(t),e,n)}}var qu=new Ui,Is=new O,Ua=new O;class Js{constructor(t=new O,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){let n=this.center;if(e!==void 0)n.copy(e);else qu.setFromPoints(t).getCenter(n);let i=0;for(let s=0,r=t.length;s<r;s++)i=Math.max(i,n.distanceToSquared(t[s]));return this.radius=Math.sqrt(i),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){let e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){let n=this.center.distanceToSquared(t);if(e.copy(t),n>this.radius*this.radius)e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center);return e}getBoundingBox(t){if(this.isEmpty())return t.makeEmpty(),t;return t.set(this.center,this.center),t.expandByScalar(this.radius),t}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;Is.subVectors(t,this.center);let e=Is.lengthSq();if(e>this.radius*this.radius){let n=Math.sqrt(e),i=(n-this.radius)*0.5;this.center.addScaledVector(Is,i/n),this.radius+=i}return this}union(t){if(t.isEmpty())return this;if(this.isEmpty())return this.copy(t),this;if(this.center.equals(t.center)===!0)this.radius=Math.max(this.radius,t.radius);else Ua.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Is.copy(t.center).add(Ua)),this.expandByPoint(Is.copy(t.center).sub(Ua));return this}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(t){return this.radius=t.radius,this.center.fromArray(t.center),this}}var Yu=0,Sn=new we,Fa=new He,ns=new O,fn=new Ui,Ls=new Ui,Ge=new O;class _n extends ti{constructor(){super();this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Yu++}),this.uuid=fi(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(t){if(Array.isArray(t))this.index=new((Lu(t))?Qr:Kr)(t,1);else this.index=t;return this}setIndirect(t,e=0){return this.indirect=t,this.indirectOffset=e,this}getIndirect(){return this.indirect}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,n=0){this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){let e=this.attributes.position;if(e!==void 0)e.applyMatrix4(t),e.needsUpdate=!0;let n=this.attributes.normal;if(n!==void 0){let s=new qt().getNormalMatrix(t);n.applyNormalMatrix(s),n.needsUpdate=!0}let i=this.attributes.tangent;if(i!==void 0)i.transformDirection(t),i.needsUpdate=!0;if(this.boundingBox!==null)this.computeBoundingBox();if(this.boundingSphere!==null)this.computeBoundingSphere();return this._transformed=!0,this}applyQuaternion(t){return Sn.makeRotationFromQuaternion(t),this.applyMatrix4(Sn),this}rotateX(t){return Sn.makeRotationX(t),this.applyMatrix4(Sn),this}rotateY(t){return Sn.makeRotationY(t),this.applyMatrix4(Sn),this}rotateZ(t){return Sn.makeRotationZ(t),this.applyMatrix4(Sn),this}translate(t,e,n){return Sn.makeTranslation(t,e,n),this.applyMatrix4(Sn),this}scale(t,e,n){return Sn.makeScale(t,e,n),this.applyMatrix4(Sn),this}lookAt(t){return Fa.lookAt(t),Fa.updateMatrix(),this.applyMatrix4(Fa.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ns).negate(),this.translate(ns.x,ns.y,ns.z),this}setFromPoints(t){let e=this.getAttribute("position");if(e===void 0){let n=[];for(let i=0,s=t.length;i<s;i++){let r=t[i];n.push(r.x,r.y,r.z||0)}this.setAttribute("position",new Ye(n,3))}else{let n=Math.min(t.length,e.count);for(let i=0;i<n;i++){let s=t[i];e.setXYZ(i,s.x,s.y,s.z||0)}if(t.length>e.count)Ht("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.");e.needsUpdate=!0}return this}computeBoundingBox(){if(this.boundingBox===null)this.boundingBox=new Ui;let t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){Gt("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new O(-1/0,-1/0,-1/0),new O(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let n=0,i=e.length;n<i;n++){let s=e[n];if(fn.setFromBufferAttribute(s),this.morphTargetsRelative)Ge.addVectors(this.boundingBox.min,fn.min),this.boundingBox.expandByPoint(Ge),Ge.addVectors(this.boundingBox.max,fn.max),this.boundingBox.expandByPoint(Ge);else this.boundingBox.expandByPoint(fn.min),this.boundingBox.expandByPoint(fn.max)}}else this.boundingBox.makeEmpty();if(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))Gt('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){if(this.boundingSphere===null)this.boundingSphere=new Js;let t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){Gt("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new O,1/0);return}if(t){let n=this.boundingSphere.center;if(fn.setFromBufferAttribute(t),e)for(let s=0,r=e.length;s<r;s++){let a=e[s];if(Ls.setFromBufferAttribute(a),this.morphTargetsRelative)Ge.addVectors(fn.min,Ls.min),fn.expandByPoint(Ge),Ge.addVectors(fn.max,Ls.max),fn.expandByPoint(Ge);else fn.expandByPoint(Ls.min),fn.expandByPoint(Ls.max)}fn.getCenter(n);let i=0;for(let s=0,r=t.count;s<r;s++)Ge.fromBufferAttribute(t,s),i=Math.max(i,n.distanceToSquared(Ge));if(e)for(let s=0,r=e.length;s<r;s++){let a=e[s],o=this.morphTargetsRelative;for(let l=0,c=a.count;l<c;l++){if(Ge.fromBufferAttribute(a,l),o)ns.fromBufferAttribute(t,l),Ge.add(ns);i=Math.max(i,n.distanceToSquared(Ge))}}if(this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius))Gt('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){Gt("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let{position:n,normal:i,uv:s}=e,r=this.getAttribute("tangent");if(r===void 0||r.count!==n.count)r=new Mn(new Float32Array(4*n.count),4),this.setAttribute("tangent",r);let a=[],o=[];for(let E=0;E<n.count;E++)a[E]=new O,o[E]=new O;let l=new O,c=new O,u=new O,d=new Xt,h=new Xt,p=new Xt,v=new O,T=new O;function m(E,g,M){l.fromBufferAttribute(n,E),c.fromBufferAttribute(n,g),u.fromBufferAttribute(n,M),d.fromBufferAttribute(s,E),h.fromBufferAttribute(s,g),p.fromBufferAttribute(s,M),c.sub(l),u.sub(l),h.sub(d),p.sub(d);let G=1/(h.x*p.y-p.x*h.y);if(!isFinite(G))return;v.copy(c).multiplyScalar(p.y).addScaledVector(u,-h.y).multiplyScalar(G),T.copy(u).multiplyScalar(h.x).addScaledVector(c,-p.x).multiplyScalar(G),a[E].add(v),a[g].add(v),a[M].add(v),o[E].add(T),o[g].add(T),o[M].add(T)}let f=this.groups;if(f.length===0)f=[{start:0,count:t.count}];for(let E=0,g=f.length;E<g;++E){let M=f[E],{start:G,count:N}=M;for(let F=G,X=G+N;F<X;F+=3)m(t.getX(F+0),t.getX(F+1),t.getX(F+2))}let w=new O,C=new O,y=new O,b=new O;function A(E){y.fromBufferAttribute(i,E),b.copy(y);let g=a[E];w.copy(g),w.sub(y.multiplyScalar(y.dot(g))).normalize(),C.crossVectors(b,g);let G=C.dot(o[E])<0?-1:1;r.setXYZW(E,w.x,w.y,w.z,G)}for(let E=0,g=f.length;E<g;++E){let M=f[E],{start:G,count:N}=M;for(let F=G,X=G+N;F<X;F+=3)A(t.getX(F+0)),A(t.getX(F+1)),A(t.getX(F+2))}this._transformed=!0}computeVertexNormals(){let t=this.index,e=this.getAttribute("position");if(e!==void 0){let n=this.getAttribute("normal");if(n===void 0||n.count!==e.count)n=new Mn(new Float32Array(e.count*3),3),this.setAttribute("normal",n);else for(let d=0,h=n.count;d<h;d++)n.setXYZ(d,0,0,0);let i=new O,s=new O,r=new O,a=new O,o=new O,l=new O,c=new O,u=new O;if(t)for(let d=0,h=t.count;d<h;d+=3){let p=t.getX(d+0),v=t.getX(d+1),T=t.getX(d+2);i.fromBufferAttribute(e,p),s.fromBufferAttribute(e,v),r.fromBufferAttribute(e,T),c.subVectors(r,s),u.subVectors(i,s),c.cross(u),a.fromBufferAttribute(n,p),o.fromBufferAttribute(n,v),l.fromBufferAttribute(n,T),a.add(c),o.add(c),l.add(c),n.setXYZ(p,a.x,a.y,a.z),n.setXYZ(v,o.x,o.y,o.z),n.setXYZ(T,l.x,l.y,l.z)}else for(let d=0,h=e.count;d<h;d+=3)i.fromBufferAttribute(e,d+0),s.fromBufferAttribute(e,d+1),r.fromBufferAttribute(e,d+2),c.subVectors(r,s),u.subVectors(i,s),c.cross(u),n.setXYZ(d+0,c.x,c.y,c.z),n.setXYZ(d+1,c.x,c.y,c.z),n.setXYZ(d+2,c.x,c.y,c.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let t=this.attributes.normal;for(let e=0,n=t.count;e<n;e++)Ge.fromBufferAttribute(t,e),Ge.normalize(),t.setXYZ(e,Ge.x,Ge.y,Ge.z)}toNonIndexed(){function t(a,o){let{array:l,itemSize:c,normalized:u}=a,d=new l.constructor(o.length*c),h=0,p=0;for(let v=0,T=o.length;v<T;v++){if(a.isInterleavedBufferAttribute)h=o[v]*a.data.stride+a.offset;else h=o[v]*c;for(let m=0;m<c;m++)d[p++]=l[h++]}return new Mn(d,c,u)}if(this.index===null)return Ht("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let e=new _n,n=this.index.array,i=this.attributes;for(let a in i){let o=i[a],l=t(o,n);e.setAttribute(a,l)}let s=this.morphAttributes;for(let a in s){let o=[],l=s[a];for(let c=0,u=l.length;c<u;c++){let d=l[c],h=t(d,n);o.push(h)}e.morphAttributes[a]=o}e.morphTargetsRelative=this.morphTargetsRelative;let r=this.groups;for(let a=0,o=r.length;a<o;a++){let l=r[a];e.addGroup(l.start,l.count,l.materialIndex)}return e}toJSON(){let t={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,t.name=this.name,Object.keys(this.userData).length>0)t.userData=this.userData;if(this.parameters!==void 0&&this._transformed!==!0){let o=this.parameters;for(let l in o)if(o[l]!==void 0)t[l]=o[l];return t}t.data={attributes:{}};let e=this.index;if(e!==null)t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)};let n=this.attributes;for(let o in n){let l=n[o];t.data.attributes[o]=l.toJSON(t.data)}let i={},s=!1;for(let o in this.morphAttributes){let l=this.morphAttributes[o],c=[];for(let u=0,d=l.length;u<d;u++){let h=l[u];c.push(h.toJSON(t.data))}if(c.length>0)i[o]=c,s=!0}if(s)t.data.morphAttributes=i,t.data.morphTargetsRelative=this.morphTargetsRelative;let r=this.groups;if(r.length>0)t.data.groups=JSON.parse(JSON.stringify(r));let a=this.boundingSphere;if(a!==null)t.data.boundingSphere=a.toJSON();return t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let e={};this.name=t.name;let n=t.index;if(n!==null)this.setIndex(n.clone());let i=t.attributes;for(let l in i){let c=i[l];this.setAttribute(l,c.clone(e))}let s=t.morphAttributes;for(let l in s){let c=[],u=s[l];for(let d=0,h=u.length;d<h;d++)c.push(u[d].clone(e));this.morphAttributes[l]=c}this.morphTargetsRelative=t.morphTargetsRelative;let r=t.groups;for(let l=0,c=r.length;l<c;l++){let u=r[l];this.addGroup(u.start,u.count,u.materialIndex)}let a=t.boundingBox;if(a!==null)this.boundingBox=a.clone();let o=t.boundingSphere;if(o!==null)this.boundingSphere=o.clone();return this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this._transformed=t._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}class tl{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=35044,this.updateRanges=[],this.version=0,this.uuid=fi()}onUploadCallback(){}set needsUpdate(t){if(t===!0)this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,n){t*=this.stride,n*=e.stride;for(let i=0,s=this.stride;i<s;i++)this.array[t+i]=e.array[n+i];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){if(t.arrayBuffers===void 0)t.arrayBuffers={};if(this.array.buffer._uuid===void 0)this.array.buffer._uuid=fi();if(t.arrayBuffers[this.array.buffer._uuid]===void 0)t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer;let e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(e,this.stride);return n.setUsage(this.usage),n}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){if(t.arrayBuffers===void 0)t.arrayBuffers={};if(this.array.buffer._uuid===void 0)this.array.buffer._uuid=fi();if(t.arrayBuffers[this.array.buffer._uuid]===void 0)t.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer));let e={uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride};return e.usage=this.usage,e}}var en=new O;class zs{constructor(t,e,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,n=this.data.count;e<n;e++)en.fromBufferAttribute(this,e),en.applyMatrix4(t),this.setXYZ(e,en.x,en.y,en.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)en.fromBufferAttribute(this,e),en.applyNormalMatrix(t),this.setXYZ(e,en.x,en.y,en.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)en.fromBufferAttribute(this,e),en.transformDirection(t),this.setXYZ(e,en.x,en.y,en.z);return this}getComponent(t,e){let n=this.array[t*this.data.stride+this.offset+e];if(this.normalized)n=On(n,this.array);return n}setComponent(t,e,n){if(this.normalized)n=xe(n,this.array);return this.data.array[t*this.data.stride+this.offset+e]=n,this}setX(t,e){if(this.normalized)e=xe(e,this.array);return this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){if(this.normalized)e=xe(e,this.array);return this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){if(this.normalized)e=xe(e,this.array);return this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){if(this.normalized)e=xe(e,this.array);return this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];if(this.normalized)e=On(e,this.array);return e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];if(this.normalized)e=On(e,this.array);return e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];if(this.normalized)e=On(e,this.array);return e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];if(this.normalized)e=On(e,this.array);return e}setXY(t,e,n){if(t=t*this.data.stride+this.offset,this.normalized)e=xe(e,this.array),n=xe(n,this.array);return this.data.array[t+0]=e,this.data.array[t+1]=n,this}setXYZ(t,e,n,i){if(t=t*this.data.stride+this.offset,this.normalized)e=xe(e,this.array),n=xe(n,this.array),i=xe(i,this.array);return this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this}setXYZW(t,e,n,i,s){if(t=t*this.data.stride+this.offset,this.normalized)e=xe(e,this.array),n=xe(n,this.array),i=xe(i,this.array),s=xe(s,this.array);return this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this.data.array[t+3]=s,this}clone(t){if(t===void 0){Bs("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let e=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[i+s])}return new Mn(new this.array.constructor(e),this.itemSize,this.normalized)}else{if(t.interleavedBuffers===void 0)t.interleavedBuffers={};if(t.interleavedBuffers[this.data.uuid]===void 0)t.interleavedBuffers[this.data.uuid]=this.data.clone(t);return new zs(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}}toJSON(t){if(t===void 0){Bs("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let e=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[i+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else{if(t.interleavedBuffers===void 0)t.interleavedBuffers={};if(t.interleavedBuffers[this.data.uuid]===void 0)t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t);return{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}}var Oa=new O,Zu=new O,Ju=new qt;class Fn{constructor(t=new O(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,n,i){return this.normal.set(t,e,n),this.constant=i,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){let i=Oa.subVectors(n,e).cross(Zu.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(i,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){let t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e,n=!0){let i=t.delta(Oa),s=this.normal.dot(i);if(s===0){if(this.distanceToPoint(t.start)===0)return e.copy(t.start);return null}let r=-(t.start.dot(this.normal)+this.constant)/s;if(n===!0&&(r<0||r>1))return null;return e.copy(t.start).addScaledVector(i,r)}intersectsLine(t){let e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){let n=e||Ju.getNormalMatrix(t),i=this.coplanarPoint(Oa).applyMatrix4(t),s=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(s),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}toJSON(){return{normal:this.normal.toArray(),constant:this.constant}}fromJSON(t){return this.normal.fromArray(t.normal),this.constant=t.constant,this}}var $u=0;class _i extends ti{constructor(){super();this.isMaterial=!0,Object.defineProperty(this,"id",{value:$u++}),this.uuid=fi(),this.name="",this.type="Material",this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Kt(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=7680,this.stencilZFail=7680,this.stencilZPass=7680,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){if(this._alphaTest>0!==t>0)this.version++;this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t===void 0)return;for(let e in t){let n=t[e];if(n===void 0){Ht(`Material: parameter '${e}' has value of undefined.`);continue}let i=this[e];if(i===void 0){Ht(`Material: '${e}' is not a property of THREE.${this.type}.`);continue}if(i&&i.isColor)i.set(n);else if(i&&i.isVector2&&(n&&n.isVector2)||i&&i.isEuler&&(n&&n.isEuler)||i&&i.isVector3&&(n&&n.isVector3))i.copy(n);else this[e]=n}}toJSON(t){let e=t===void 0||typeof t==="string";if(e)t={textures:{},images:{}};let n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};if(n.uuid=this.uuid,n.type=this.type,n.blending=this.blending,n.side=this.side,n.shadowSide=this.shadowSide,n.vertexColors=this.vertexColors,n.opacity=this.opacity,n.transparent=this.transparent,n.blendSrc=this.blendSrc,n.blendDst=this.blendDst,n.blendEquation=this.blendEquation,n.blendSrcAlpha=this.blendSrcAlpha,n.blendDstAlpha=this.blendDstAlpha,n.blendEquationAlpha=this.blendEquationAlpha,n.blendColor=this.blendColor.getHex(),n.blendAlpha=this.blendAlpha,n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.clipIntersection=this.clipIntersection,n.clipShadows=this.clipShadows,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,n.stencilWrite=this.stencilWrite,n.polygonOffset=this.polygonOffset,n.polygonOffsetFactor=this.polygonOffsetFactor,n.polygonOffsetUnits=this.polygonOffsetUnits,n.dithering=this.dithering,n.alphaTest=this.alphaTest,n.alphaHash=this.alphaHash,n.alphaToCoverage=this.alphaToCoverage,n.premultipliedAlpha=this.premultipliedAlpha,n.forceSinglePass=this.forceSinglePass,n.allowOverride=this.allowOverride,n.visible=this.visible,n.toneMapped=this.toneMapped,n.name=this.name,this.color&&this.color.isColor)n.color=this.color.getHex();if(this.roughness!==void 0)n.roughness=this.roughness;if(this.metalness!==void 0)n.metalness=this.metalness;if(this.sheen!==void 0)n.sheen=this.sheen;if(this.sheenColor&&this.sheenColor.isColor)n.sheenColor=this.sheenColor.getHex();if(this.sheenRoughness!==void 0)n.sheenRoughness=this.sheenRoughness;if(this.emissive&&this.emissive.isColor)n.emissive=this.emissive.getHex();if(this.emissiveIntensity!==void 0)n.emissiveIntensity=this.emissiveIntensity;if(this.specular&&this.specular.isColor)n.specular=this.specular.getHex();if(this.specularIntensity!==void 0)n.specularIntensity=this.specularIntensity;if(this.specularColor&&this.specularColor.isColor)n.specularColor=this.specularColor.getHex();if(this.shininess!==void 0)n.shininess=this.shininess;if(this.clearcoat!==void 0)n.clearcoat=this.clearcoat;if(this.clearcoatRoughness!==void 0)n.clearcoatRoughness=this.clearcoatRoughness;if(this.clearcoatMap&&this.clearcoatMap.isTexture)n.clearcoatMap=this.clearcoatMap.toJSON(t).uuid;if(this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture)n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid;if(this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture)n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray();if(this.sheenColorMap&&this.sheenColorMap.isTexture)n.sheenColorMap=this.sheenColorMap.toJSON(t).uuid;if(this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture)n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(t).uuid;if(this.dispersion!==void 0)n.dispersion=this.dispersion;if(this.retroreflectivity!==void 0)n.retroreflectivity=this.retroreflectivity;if(this.iridescence!==void 0)n.iridescence=this.iridescence;if(this.iridescenceIOR!==void 0)n.iridescenceIOR=this.iridescenceIOR;if(this.iridescenceThicknessRange!==void 0)n.iridescenceThicknessRange=this.iridescenceThicknessRange;if(this.iridescenceMap&&this.iridescenceMap.isTexture)n.iridescenceMap=this.iridescenceMap.toJSON(t).uuid;if(this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture)n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid;if(this.anisotropy!==void 0)n.anisotropy=this.anisotropy;if(this.anisotropyRotation!==void 0)n.anisotropyRotation=this.anisotropyRotation;if(this.anisotropyMap&&this.anisotropyMap.isTexture)n.anisotropyMap=this.anisotropyMap.toJSON(t).uuid;if(this.map&&this.map.isTexture)n.map=this.map.toJSON(t).uuid;if(this.matcap&&this.matcap.isTexture)n.matcap=this.matcap.toJSON(t).uuid;if(this.alphaMap&&this.alphaMap.isTexture)n.alphaMap=this.alphaMap.toJSON(t).uuid;if(this.lightMap&&this.lightMap.isTexture)n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity;if(this.aoMap&&this.aoMap.isTexture)n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity;if(this.bumpMap&&this.bumpMap.isTexture)n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale;if(this.normalMap&&this.normalMap.isTexture)n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray();if(this.displacementMap&&this.displacementMap.isTexture)n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias;if(this.roughnessMap&&this.roughnessMap.isTexture)n.roughnessMap=this.roughnessMap.toJSON(t).uuid;if(this.metalnessMap&&this.metalnessMap.isTexture)n.metalnessMap=this.metalnessMap.toJSON(t).uuid;if(this.emissiveMap&&this.emissiveMap.isTexture)n.emissiveMap=this.emissiveMap.toJSON(t).uuid;if(this.specularMap&&this.specularMap.isTexture)n.specularMap=this.specularMap.toJSON(t).uuid;if(this.specularIntensityMap&&this.specularIntensityMap.isTexture)n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid;if(this.specularColorMap&&this.specularColorMap.isTexture)n.specularColorMap=this.specularColorMap.toJSON(t).uuid;if(this.envMap&&this.envMap.isTexture){if(n.envMap=this.envMap.toJSON(t).uuid,this.combine!==void 0)n.combine=this.combine}if(this.envMapRotation!==void 0)n.envMapRotation=this.envMapRotation.toArray();if(this.envMapIntensity!==void 0)n.envMapIntensity=this.envMapIntensity;if(this.reflectivity!==void 0)n.reflectivity=this.reflectivity;if(this.refractionRatio!==void 0)n.refractionRatio=this.refractionRatio;if(this.gradientMap&&this.gradientMap.isTexture)n.gradientMap=this.gradientMap.toJSON(t).uuid;if(this.transmission!==void 0)n.transmission=this.transmission;if(this.transmissionMap&&this.transmissionMap.isTexture)n.transmissionMap=this.transmissionMap.toJSON(t).uuid;if(this.thickness!==void 0)n.thickness=this.thickness;if(this.thicknessMap&&this.thicknessMap.isTexture)n.thicknessMap=this.thicknessMap.toJSON(t).uuid;if(this.attenuationDistance!==void 0)n.attenuationDistance=this.attenuationDistance;if(this.attenuationColor!==void 0)n.attenuationColor=this.attenuationColor.getHex();if(this.size!==void 0)n.size=this.size;if(this.sizeAttenuation!==void 0)n.sizeAttenuation=this.sizeAttenuation;if(Array.isArray(this.clippingPlanes)&&this.clippingPlanes.length>0)n.clippingPlanes=this.clippingPlanes.map((s)=>s.toJSON());if(this.rotation!==void 0)n.rotation=this.rotation;if(this.depthPacking!==void 0)n.depthPacking=this.depthPacking;if(this.linewidth!==void 0)n.linewidth=this.linewidth;if(this.linecap!==void 0)n.linecap=this.linecap;if(this.linejoin!==void 0)n.linejoin=this.linejoin;if(this.dashSize!==void 0)n.dashSize=this.dashSize;if(this.gapSize!==void 0)n.gapSize=this.gapSize;if(this.scale!==void 0)n.scale=this.scale;if(this.wireframe!==void 0)n.wireframe=this.wireframe;if(this.wireframeLinewidth!==void 0)n.wireframeLinewidth=this.wireframeLinewidth;if(this.wireframeLinecap!==void 0)n.wireframeLinecap=this.wireframeLinecap;if(this.wireframeLinejoin!==void 0)n.wireframeLinejoin=this.wireframeLinejoin;if(this.flatShading!==void 0)n.flatShading=this.flatShading;if(this.fog!==void 0)n.fog=this.fog;if(Object.keys(this.userData).length>0)n.userData=this.userData;function i(s){let r=[];for(let a in s){let o=s[a];delete o.metadata,r.push(o)}return r}if(e){let s=i(t.textures),r=i(t.images);if(s.length>0)n.textures=s;if(r.length>0)n.images=r}return n}fromJSON(t,e){if(t.uuid!==void 0)this.uuid=t.uuid;if(t.name!==void 0)this.name=t.name;if(t.color!==void 0&&this.color!==void 0)this.color.setHex(t.color);if(t.roughness!==void 0)this.roughness=t.roughness;if(t.metalness!==void 0)this.metalness=t.metalness;if(t.sheen!==void 0)this.sheen=t.sheen;if(t.sheenColor!==void 0)this.sheenColor=new Kt().setHex(t.sheenColor);if(t.sheenRoughness!==void 0)this.sheenRoughness=t.sheenRoughness;if(t.emissive!==void 0&&this.emissive!==void 0)this.emissive.setHex(t.emissive);if(t.specular!==void 0&&this.specular!==void 0)this.specular.setHex(t.specular);if(t.specularIntensity!==void 0)this.specularIntensity=t.specularIntensity;if(t.specularColor!==void 0&&this.specularColor!==void 0)this.specularColor.setHex(t.specularColor);if(t.shininess!==void 0)this.shininess=t.shininess;if(t.clearcoat!==void 0)this.clearcoat=t.clearcoat;if(t.clearcoatRoughness!==void 0)this.clearcoatRoughness=t.clearcoatRoughness;if(t.dispersion!==void 0)this.dispersion=t.dispersion;if(t.retroreflectivity!==void 0)this.retroreflectivity=t.retroreflectivity;if(t.iridescence!==void 0)this.iridescence=t.iridescence;if(t.iridescenceIOR!==void 0)this.iridescenceIOR=t.iridescenceIOR;if(t.iridescenceThicknessRange!==void 0)this.iridescenceThicknessRange=t.iridescenceThicknessRange;if(t.transmission!==void 0)this.transmission=t.transmission;if(t.thickness!==void 0)this.thickness=t.thickness;if(t.attenuationDistance!==void 0)this.attenuationDistance=t.attenuationDistance;if(t.attenuationColor!==void 0&&this.attenuationColor!==void 0)this.attenuationColor.setHex(t.attenuationColor);if(t.anisotropy!==void 0)this.anisotropy=t.anisotropy;if(t.anisotropyRotation!==void 0)this.anisotropyRotation=t.anisotropyRotation;if(t.fog!==void 0)this.fog=t.fog;if(t.flatShading!==void 0)this.flatShading=t.flatShading;if(t.blending!==void 0)this.blending=t.blending;if(t.combine!==void 0)this.combine=t.combine;if(t.side!==void 0)this.side=t.side;if(t.shadowSide!==void 0)this.shadowSide=t.shadowSide;if(t.opacity!==void 0)this.opacity=t.opacity;if(t.transparent!==void 0)this.transparent=t.transparent;if(t.alphaTest!==void 0)this.alphaTest=t.alphaTest;if(t.alphaHash!==void 0)this.alphaHash=t.alphaHash;if(t.depthFunc!==void 0)this.depthFunc=t.depthFunc;if(t.depthTest!==void 0)this.depthTest=t.depthTest;if(t.depthWrite!==void 0)this.depthWrite=t.depthWrite;if(t.colorWrite!==void 0)this.colorWrite=t.colorWrite;if(t.clippingPlanes!==void 0)this.clippingPlanes=t.clippingPlanes.map((n)=>new Fn().fromJSON(n));if(t.clipIntersection!==void 0)this.clipIntersection=t.clipIntersection;if(t.clipShadows!==void 0)this.clipShadows=t.clipShadows;if(t.depthPacking!==void 0)this.depthPacking=t.depthPacking;if(t.blendSrc!==void 0)this.blendSrc=t.blendSrc;if(t.blendDst!==void 0)this.blendDst=t.blendDst;if(t.blendEquation!==void 0)this.blendEquation=t.blendEquation;if(t.blendSrcAlpha!==void 0)this.blendSrcAlpha=t.blendSrcAlpha;if(t.blendDstAlpha!==void 0)this.blendDstAlpha=t.blendDstAlpha;if(t.blendEquationAlpha!==void 0)this.blendEquationAlpha=t.blendEquationAlpha;if(t.blendColor!==void 0&&this.blendColor!==void 0)this.blendColor.setHex(t.blendColor);if(t.blendAlpha!==void 0)this.blendAlpha=t.blendAlpha;if(t.stencilWriteMask!==void 0)this.stencilWriteMask=t.stencilWriteMask;if(t.stencilFunc!==void 0)this.stencilFunc=t.stencilFunc;if(t.stencilRef!==void 0)this.stencilRef=t.stencilRef;if(t.stencilFuncMask!==void 0)this.stencilFuncMask=t.stencilFuncMask;if(t.stencilFail!==void 0)this.stencilFail=t.stencilFail;if(t.stencilZFail!==void 0)this.stencilZFail=t.stencilZFail;if(t.stencilZPass!==void 0)this.stencilZPass=t.stencilZPass;if(t.stencilWrite!==void 0)this.stencilWrite=t.stencilWrite;if(t.wireframe!==void 0)this.wireframe=t.wireframe;if(t.wireframeLinewidth!==void 0)this.wireframeLinewidth=t.wireframeLinewidth;if(t.wireframeLinecap!==void 0)this.wireframeLinecap=t.wireframeLinecap;if(t.wireframeLinejoin!==void 0)this.wireframeLinejoin=t.wireframeLinejoin;if(t.rotation!==void 0)this.rotation=t.rotation;if(t.linewidth!==void 0)this.linewidth=t.linewidth;if(t.linecap!==void 0)this.linecap=t.linecap;if(t.linejoin!==void 0)this.linejoin=t.linejoin;if(t.dashSize!==void 0)this.dashSize=t.dashSize;if(t.gapSize!==void 0)this.gapSize=t.gapSize;if(t.scale!==void 0)this.scale=t.scale;if(t.polygonOffset!==void 0)this.polygonOffset=t.polygonOffset;if(t.polygonOffsetFactor!==void 0)this.polygonOffsetFactor=t.polygonOffsetFactor;if(t.polygonOffsetUnits!==void 0)this.polygonOffsetUnits=t.polygonOffsetUnits;if(t.dithering!==void 0)this.dithering=t.dithering;if(t.alphaToCoverage!==void 0)this.alphaToCoverage=t.alphaToCoverage;if(t.premultipliedAlpha!==void 0)this.premultipliedAlpha=t.premultipliedAlpha;if(t.forceSinglePass!==void 0)this.forceSinglePass=t.forceSinglePass;if(t.allowOverride!==void 0)this.allowOverride=t.allowOverride;if(t.visible!==void 0)this.visible=t.visible;if(t.toneMapped!==void 0)this.toneMapped=t.toneMapped;if(t.userData!==void 0)this.userData=t.userData;if(t.vertexColors!==void 0)if(typeof t.vertexColors==="number")this.vertexColors=t.vertexColors>0;else this.vertexColors=t.vertexColors;if(t.size!==void 0)this.size=t.size;if(t.sizeAttenuation!==void 0)this.sizeAttenuation=t.sizeAttenuation;if(t.map!==void 0)this.map=e[t.map]||null;if(t.matcap!==void 0)this.matcap=e[t.matcap]||null;if(t.alphaMap!==void 0)this.alphaMap=e[t.alphaMap]||null;if(t.bumpMap!==void 0)this.bumpMap=e[t.bumpMap]||null;if(t.bumpScale!==void 0)this.bumpScale=t.bumpScale;if(t.normalMap!==void 0)this.normalMap=e[t.normalMap]||null;if(t.normalMapType!==void 0)this.normalMapType=t.normalMapType;if(t.normalScale!==void 0){let n=t.normalScale;if(Array.isArray(n)===!1)n=[n,n];this.normalScale=new Xt().fromArray(n)}if(t.displacementMap!==void 0)this.displacementMap=e[t.displacementMap]||null;if(t.displacementScale!==void 0)this.displacementScale=t.displacementScale;if(t.displacementBias!==void 0)this.displacementBias=t.displacementBias;if(t.roughnessMap!==void 0)this.roughnessMap=e[t.roughnessMap]||null;if(t.metalnessMap!==void 0)this.metalnessMap=e[t.metalnessMap]||null;if(t.emissiveMap!==void 0)this.emissiveMap=e[t.emissiveMap]||null;if(t.emissiveIntensity!==void 0)this.emissiveIntensity=t.emissiveIntensity;if(t.specularMap!==void 0)this.specularMap=e[t.specularMap]||null;if(t.specularIntensityMap!==void 0)this.specularIntensityMap=e[t.specularIntensityMap]||null;if(t.specularColorMap!==void 0)this.specularColorMap=e[t.specularColorMap]||null;if(t.envMap!==void 0)this.envMap=e[t.envMap]||null;if(t.envMapRotation!==void 0)this.envMapRotation.fromArray(t.envMapRotation);if(t.envMapIntensity!==void 0)this.envMapIntensity=t.envMapIntensity;if(t.reflectivity!==void 0)this.reflectivity=t.reflectivity;if(t.refractionRatio!==void 0)this.refractionRatio=t.refractionRatio;if(t.lightMap!==void 0)this.lightMap=e[t.lightMap]||null;if(t.lightMapIntensity!==void 0)this.lightMapIntensity=t.lightMapIntensity;if(t.aoMap!==void 0)this.aoMap=e[t.aoMap]||null;if(t.aoMapIntensity!==void 0)this.aoMapIntensity=t.aoMapIntensity;if(t.gradientMap!==void 0)this.gradientMap=e[t.gradientMap]||null;if(t.clearcoatMap!==void 0)this.clearcoatMap=e[t.clearcoatMap]||null;if(t.clearcoatRoughnessMap!==void 0)this.clearcoatRoughnessMap=e[t.clearcoatRoughnessMap]||null;if(t.clearcoatNormalMap!==void 0)this.clearcoatNormalMap=e[t.clearcoatNormalMap]||null;if(t.clearcoatNormalScale!==void 0)this.clearcoatNormalScale=new Xt().fromArray(t.clearcoatNormalScale);if(t.iridescenceMap!==void 0)this.iridescenceMap=e[t.iridescenceMap]||null;if(t.iridescenceThicknessMap!==void 0)this.iridescenceThicknessMap=e[t.iridescenceThicknessMap]||null;if(t.transmissionMap!==void 0)this.transmissionMap=e[t.transmissionMap]||null;if(t.thicknessMap!==void 0)this.thicknessMap=e[t.thicknessMap]||null;if(t.anisotropyMap!==void 0)this.anisotropyMap=e[t.anisotropyMap]||null;if(t.sheenColorMap!==void 0)this.sheenColorMap=e[t.sheenColorMap]||null;if(t.sheenRoughnessMap!==void 0)this.sheenRoughnessMap=e[t.sheenRoughnessMap]||null;return this}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;let e=t.clippingPlanes,n=null;if(e!==null){let i=e.length;n=Array(i);for(let s=0;s!==i;++s)n[s]=e[s].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.allowOverride=t.allowOverride,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){if(t===!0)this.version++}}class _s extends _i{constructor(t){super();this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Kt(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.rotation=t.rotation,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}}var is,Ds=new O,ss=new O,rs=new O,as=new Xt,Us=new Xt,vh=new we,vr=new O,Fs=new O,yr=new O,ac=new Xt,Ba=new Xt,oc=new Xt;class Ks extends He{constructor(t=new _s){super();if(this.isSprite=!0,this.type="Sprite",is===void 0){is=new _n;let e=new Float32Array([-0.5,-0.5,0,0,0,0.5,-0.5,0,1,0,0.5,0.5,0,1,1,-0.5,0.5,0,0,1]),n=new tl(e,5);is.setIndex([0,1,2,0,2,3]),is.setAttribute("position",new zs(n,3,0,!1)),is.setAttribute("uv",new zs(n,2,3,!1))}this.geometry=is,this.material=t,this.center=new Xt(0.5,0.5),this.count=1}intersectsFrustum(t){return t.intersectsSprite(this)}raycast(t,e){if(t.camera===null)Gt('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.');if(ss.setFromMatrixScale(this.matrixWorld),vh.copy(t.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(t.camera.matrixWorldInverse,this.matrixWorld),rs.setFromMatrixPosition(this.modelViewMatrix),t.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1)ss.multiplyScalar(-rs.z);let n=this.material.rotation,i,s;if(n!==0)s=Math.cos(n),i=Math.sin(n);let r=this.center;Sr(vr.set(-0.5,-0.5,0),rs,r,ss,i,s),Sr(Fs.set(0.5,-0.5,0),rs,r,ss,i,s),Sr(yr.set(0.5,0.5,0),rs,r,ss,i,s),ac.set(0,0),Ba.set(1,0),oc.set(1,1);let a=t.ray.intersectTriangle(vr,Fs,yr,!1,Ds);if(a===null){if(Sr(Fs.set(-0.5,0.5,0),rs,r,ss,i,s),Ba.set(0,1),a=t.ray.intersectTriangle(vr,yr,Fs,!1,Ds),a===null)return}let o=t.ray.origin.distanceTo(Ds);if(o<t.near||o>t.far)return;e.push({distance:o,point:Ds.clone(),uv:pn.getInterpolation(Ds,vr,Fs,yr,ac,Ba,oc,new Xt),face:null,object:this})}copy(t,e){if(super.copy(t,e),t.center!==void 0)this.center.copy(t.center);return this.material=t.material,this}}function Sr(t,e,n,i,s,r){if(as.subVectors(t,n).addScalar(0.5).multiply(i),s!==void 0)Us.x=r*as.x-s*as.y,Us.y=s*as.x+r*as.y;else Us.copy(as);t.copy(e),t.x+=Us.x,t.y+=Us.y,t.applyMatrix4(vh)}var $n=new O,za=new O,Mr=new O,br=new O;class jr{constructor(t=new O,e=new O(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,$n)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);let n=e.dot(this.direction);if(n<0)return e.copy(this.origin);return e.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){let e=$n.subVectors(t,this.origin).dot(this.direction);if(e<0)return this.origin.distanceToSquared(t);return $n.copy(this.origin).addScaledVector(this.direction,e),$n.distanceToSquared(t)}distanceSqToSegment(t,e,n,i){za.copy(t).add(e).multiplyScalar(0.5),Mr.copy(e).sub(t).normalize(),br.copy(this.origin).sub(za);let s=t.distanceTo(e)*0.5,r=-this.direction.dot(Mr),a=br.dot(this.direction),o=-br.dot(Mr),l=br.lengthSq(),c=Math.abs(1-r*r),u,d,h,p;if(c>0)if(u=r*o-a,d=r*a-o,p=s*c,u>=0)if(d>=-p)if(d<=p){let v=1/c;u*=v,d*=v,h=u*(u+r*d+2*a)+d*(r*u+d+2*o)+l}else d=s,u=Math.max(0,-(r*d+a)),h=-u*u+d*(d+2*o)+l;else d=-s,u=Math.max(0,-(r*d+a)),h=-u*u+d*(d+2*o)+l;else if(d<=-p)u=Math.max(0,-(-r*s+a)),d=u>0?-s:Math.min(Math.max(-s,-o),s),h=-u*u+d*(d+2*o)+l;else if(d<=p)u=0,d=Math.min(Math.max(-s,-o),s),h=d*(d+2*o)+l;else u=Math.max(0,-(r*s+a)),d=u>0?s:Math.min(Math.max(-s,-o),s),h=-u*u+d*(d+2*o)+l;else d=r>0?-s:s,u=Math.max(0,-(r*d+a)),h=-u*u+d*(d+2*o)+l;if(n)n.copy(this.origin).addScaledVector(this.direction,u);if(i)i.copy(za).addScaledVector(Mr,d);return h}intersectSphere(t,e){if(t.radius<0)return null;$n.subVectors(t.center,this.origin);let n=$n.dot(this.direction),i=$n.dot($n)-n*n,s=t.radius*t.radius;if(i>s)return null;let r=Math.sqrt(s-i),a=n-r,o=n+r;if(o<0)return null;if(a<0)return this.at(o,e);return this.at(a,e)}intersectsSphere(t){if(t.radius<0)return!1;return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){let e=t.normal.dot(this.direction);if(e===0){if(t.distanceToPoint(this.origin)===0)return 0;return null}let n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){let n=this.distanceToPlane(t);if(n===null)return null;return this.at(n,e)}intersectsPlane(t){let e=t.distanceToPoint(this.origin);if(e===0)return!0;if(t.normal.dot(this.direction)*e<0)return!0;return!1}intersectBox(t,e){let n,i,s,r,a,o,l=1/this.direction.x,c=1/this.direction.y,u=1/this.direction.z,d=this.origin;if(l>=0)n=(t.min.x-d.x)*l,i=(t.max.x-d.x)*l;else n=(t.max.x-d.x)*l,i=(t.min.x-d.x)*l;if(c>=0)s=(t.min.y-d.y)*c,r=(t.max.y-d.y)*c;else s=(t.max.y-d.y)*c,r=(t.min.y-d.y)*c;if(n>r||s>i)return null;if(s>n||isNaN(n))n=s;if(r<i||isNaN(i))i=r;if(u>=0)a=(t.min.z-d.z)*u,o=(t.max.z-d.z)*u;else a=(t.max.z-d.z)*u,o=(t.min.z-d.z)*u;if(n>o||a>i)return null;if(a>n||n!==n)n=a;if(o<i||i!==i)i=o;if(i<0)return null;return this.at(n>=0?n:i,e)}intersectsBox(t){return this.intersectBox(t,$n)!==null}intersectTriangle(t,e,n,i,s){let r=this.origin,a=this.direction,{x:o,y:l,z:c}=a,u=t.x-r.x,d=t.y-r.y,h=t.z-r.z,p=e.x-r.x,v=e.y-r.y,T=e.z-r.z,m=n.x-r.x,f=n.y-r.y,w=n.z-r.z,C=Math.abs(o),y=Math.abs(l),b=Math.abs(c),A,E,g,M,G,N,F,X,R,k,Z,H;if(C>=y&&C>=b)if(g=o,N=u,R=p,H=m,o>=0)A=l,E=c,M=d,G=h,F=v,X=T,k=f,Z=w;else A=c,E=l,M=h,G=d,F=T,X=v,k=w,Z=f;else if(y>=b)if(g=l,N=d,R=v,H=f,l>=0)A=c,E=o,M=h,G=u,F=T,X=p,k=w,Z=m;else A=o,E=c,M=u,G=h,F=p,X=T,k=m,Z=w;else if(g=c,N=h,R=T,H=w,c>=0)A=o,E=l,M=u,G=d,F=p,X=v,k=m,Z=f;else A=l,E=o,M=d,G=u,F=v,X=p,k=f,Z=m;if(g===0)return null;let at=A/g,K=E/g,et=1/g,tt=M-at*N,dt=G-K*N,At=F-at*R,te=X-K*R,zt=k-at*H,Y=Z-K*H,rt=zt*te-Y*At,lt=tt*Y-dt*zt,It=At*dt-te*tt;if(i){if(rt<0||lt<0||It<0)return null}else if((rt<0||lt<0||It<0)&&(rt>0||lt>0||It>0))return null;let Ot=rt+lt+It;if(Ot===0)return null;let Ft=et*(rt*N+lt*R+It*H);if(Ot>0?Ft<0:Ft>0)return null;return this.at(Ft/Ot,s)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Be extends _i{constructor(t){super();this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Kt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new pi,this.combine=0,this.reflectivity=1,this.refractionRatio=0.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}var lc=new we,Ti=new jr,Tr=new Js,cc=new O,wr=new O,Er=new O,Ar=new O,ka=new O,Cr=new O,hc=new O,Rr=new O;class Jt extends He{constructor(t=new _n,e=new Be){super();this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(t,e){if(super.copy(t,e),t.morphTargetInfluences!==void 0)this.morphTargetInfluences=t.morphTargetInfluences.slice();if(t.morphTargetDictionary!==void 0)this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary);return this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){let e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){let i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,r=i.length;s<r;s++){let a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}getVertexPosition(t,e){let n=this.geometry,i=n.attributes.position,s=n.morphAttributes.position,r=n.morphTargetsRelative;e.fromBufferAttribute(i,t);let a=this.morphTargetInfluences;if(s&&a){Cr.set(0,0,0);for(let o=0,l=s.length;o<l;o++){let c=a[o],u=s[o];if(c===0)continue;if(ka.fromBufferAttribute(u,t),r)Cr.addScaledVector(ka,c);else Cr.addScaledVector(ka.sub(e),c)}e.add(Cr)}return e}intersectsFrustum(t){return t.intersectsObject(this)}raycast(t,e){let n=this.geometry,i=this.material,s=this.matrixWorld;if(i===void 0)return;if(n.boundingSphere===null)n.computeBoundingSphere();if(Tr.copy(n.boundingSphere),Tr.applyMatrix4(s),Ti.copy(t.ray).recast(t.near),Tr.containsPoint(Ti.origin)===!1){if(Ti.intersectSphere(Tr,cc)===null)return;if(Ti.origin.distanceToSquared(cc)>(t.far-t.near)**2)return}if(lc.copy(s).invert(),Ti.copy(t.ray).applyMatrix4(lc),n.boundingBox!==null){if(Ti.intersectsBox(n.boundingBox)===!1)return}this._computeIntersections(t,e,Ti)}_computeIntersections(t,e,n){let i,s=this.geometry,r=this.material,a=s.index,o=s.attributes.position,l=s.attributes.uv,c=s.attributes.uv1,u=s.attributes.normal,{groups:d,drawRange:h}=s;if(a!==null)if(Array.isArray(r))for(let p=0,v=d.length;p<v;p++){let T=d[p],m=r[T.materialIndex],f=Math.max(T.start,h.start),w=Math.min(a.count,Math.min(T.start+T.count,h.start+h.count));for(let C=f,y=w;C<y;C+=3){let b=a.getX(C),A=a.getX(C+1),E=a.getX(C+2);if(i=Ir(this,m,t,n,l,c,u,b,A,E),i)i.faceIndex=Math.floor(C/3),i.face.materialIndex=T.materialIndex,e.push(i)}}else{let p=Math.max(0,h.start),v=Math.min(a.count,h.start+h.count);for(let T=p,m=v;T<m;T+=3){let f=a.getX(T),w=a.getX(T+1),C=a.getX(T+2);if(i=Ir(this,r,t,n,l,c,u,f,w,C),i)i.faceIndex=Math.floor(T/3),e.push(i)}}else if(o!==void 0)if(Array.isArray(r))for(let p=0,v=d.length;p<v;p++){let T=d[p],m=r[T.materialIndex],f=Math.max(T.start,h.start),w=Math.min(o.count,Math.min(T.start+T.count,h.start+h.count));for(let C=f,y=w;C<y;C+=3){let b=C,A=C+1,E=C+2;if(i=Ir(this,m,t,n,l,c,u,b,A,E),i)i.faceIndex=Math.floor(C/3),i.face.materialIndex=T.materialIndex,e.push(i)}}else{let p=Math.max(0,h.start),v=Math.min(o.count,h.start+h.count);for(let T=p,m=v;T<m;T+=3){let f=T,w=T+1,C=T+2;if(i=Ir(this,r,t,n,l,c,u,f,w,C),i)i.faceIndex=Math.floor(T/3),e.push(i)}}}}function Ku(t,e,n,i,s,r,a,o){let l;if(e.side===1)l=i.intersectTriangle(a,r,s,!0,o);else l=i.intersectTriangle(s,r,a,e.side===0,o);if(l===null)return null;Rr.copy(o),Rr.applyMatrix4(t.matrixWorld);let c=n.ray.origin.distanceTo(Rr);if(c<n.near||c>n.far)return null;return{distance:c,point:Rr.clone(),object:t}}function Ir(t,e,n,i,s,r,a,o,l,c){t.getVertexPosition(o,wr),t.getVertexPosition(l,Er),t.getVertexPosition(c,Ar);let u=Ku(t,e,n,i,wr,Er,Ar,hc);if(u){let d=new O;if(pn.getBarycoord(hc,wr,Er,Ar,d),s)u.uv=pn.getInterpolatedAttribute(s,o,l,c,d,new Xt);if(r)u.uv1=pn.getInterpolatedAttribute(r,o,l,c,d,new Xt);if(a){if(u.normal=pn.getInterpolatedAttribute(a,o,l,c,d,new O),u.normal.dot(i.direction)>0)u.normal.multiplyScalar(-1)}let h={a:o,b:l,c,normal:new O,materialIndex:0};pn.getNormal(wr,Er,Ar,h.normal),u.face=h,u.barycoord=d}return u}class js extends qe{constructor(t=null,e=1,n=1,i,s,r,a,o,l=1003,c=1003,u,d){super(null,r,a,o,l,c,i,s,u,d);this.isDataTexture=!0,this.image={data:t,width:e,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}var wi=new Js,Qu=new Xt(0.5,0.5),Lr=new O;class tr{constructor(t=new Fn,e=new Fn,n=new Fn,i=new Fn,s=new Fn,r=new Fn){this.planes=[t,e,n,i,s,r]}set(t,e,n,i,s,r){let a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(n),a[3].copy(i),a[4].copy(s),a[5].copy(r),this}copy(t){let e=this.planes;for(let n=0;n<6;n++)e[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t,e=2000,n=!1){let i=this.planes,s=t.elements,r=s[0],a=s[1],o=s[2],l=s[3],c=s[4],u=s[5],d=s[6],h=s[7],p=s[8],v=s[9],T=s[10],m=s[11],f=s[12],w=s[13],C=s[14],y=s[15];if(i[0].setComponents(l-r,h-c,m-p,y-f).normalize(),i[1].setComponents(l+r,h+c,m+p,y+f).normalize(),i[2].setComponents(l+a,h+u,m+v,y+w).normalize(),i[3].setComponents(l-a,h-u,m-v,y-w).normalize(),n)i[4].setComponents(o,d,T,C).normalize(),i[5].setComponents(l-o,h-d,m-T,y-C).normalize();else if(i[4].setComponents(l-o,h-d,m-T,y-C).normalize(),e===2000)i[5].setComponents(l+o,h+d,m+T,y+C).normalize();else if(e===2001)i[5].setComponents(o,d,T,C).normalize();else throw Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);return this}intersectsObject(t){if(t.boundingSphere!==void 0){if(t.boundingSphere===null)t.computeBoundingSphere();wi.copy(t.boundingSphere).applyMatrix4(t.matrixWorld)}else{let e=t.geometry;if(e.boundingSphere===null)e.computeBoundingSphere();wi.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(wi)}intersectsSprite(t){wi.center.set(0,0,0);let e=Qu.distanceTo(t.center);return wi.radius=0.7071067811865476+e,wi.applyMatrix4(t.matrixWorld),this.intersectsSphere(wi)}intersectsSphere(t){let e=this.planes,n=t.center,i=-t.radius;for(let s=0;s<6;s++)if(e[s].distanceToPoint(n)<i)return!1;return!0}intersectsBox(t){let e=this.planes;for(let n=0;n<6;n++){let i=e[n];if(Lr.x=i.normal.x>0?t.max.x:t.min.x,Lr.y=i.normal.y>0?t.max.y:t.min.y,Lr.z=i.normal.z>0?t.max.z:t.min.z,i.distanceToPoint(Lr)<0)return!1}return!0}containsPoint(t){let e=this.planes;for(let n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class ta extends qe{constructor(t=[],e=301,n,i,s,r,a,o,l,c){super(t,e,n,i,s,r,a,o,l,c);this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}class xi extends qe{constructor(t,e,n,i,s,r,a,o,l){super(t,e,n,i,s,r,a,o,l);this.isCanvasTexture=!0,this.needsUpdate=!0}}class Fi extends qe{constructor(t,e,n=1014,i,s,r,a=1003,o=1003,l,c=1026,u=1){if(c!==1026&&c!==1027)throw Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let d={width:t,height:e,depth:u};super(d,i,s,r,a,o,c,n,l);this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.source=new Xs(Object.assign({},t.image)),this.compareFunction=t.compareFunction,this}toJSON(t){let e=super.toJSON(t);return e.compareFunction=this.compareFunction,e}}class el extends Fi{constructor(t,e=1014,n=301,i,s,r=1003,a=1003,o,l=1026){let c={width:t,height:t,depth:1},u=[c,c,c,c,c,c];super(t,t,e,n,i,s,r,a,o,l);this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(t){this.image=t}}class ea extends qe{constructor(t=null){super();this.sourceTexture=t,this.isExternalTexture=!0}copy(t){return super.copy(t),this.sourceTexture=t.sourceTexture,this}}class Hn extends _n{constructor(t=1,e=1,n=1,i=1,s=1,r=1){super();this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:i,heightSegments:s,depthSegments:r};let a=this;i=Math.floor(i),s=Math.floor(s),r=Math.floor(r);let o=[],l=[],c=[],u=[],d=0,h=0;p("z","y","x",-1,-1,n,e,t,r,s,0),p("z","y","x",1,-1,n,e,-t,r,s,1),p("x","z","y",1,1,t,n,e,i,r,2),p("x","z","y",1,-1,t,n,-e,i,r,3),p("x","y","z",1,-1,t,e,n,i,s,4),p("x","y","z",-1,-1,t,e,-n,i,s,5),this.setIndex(o),this.setAttribute("position",new Ye(l,3)),this.setAttribute("normal",new Ye(c,3)),this.setAttribute("uv",new Ye(u,2));function p(v,T,m,f,w,C,y,b,A,E,g){let M=C/A,G=y/E,N=C/2,F=y/2,X=b/2,R=A+1,k=E+1,Z=0,H=0,at=new O;for(let K=0;K<k;K++){let et=K*G-F;for(let tt=0;tt<R;tt++){let dt=tt*M-N;at[v]=dt*f,at[T]=et*w,at[m]=X,l.push(at.x,at.y,at.z),at[v]=0,at[T]=0,at[m]=b>0?1:-1,c.push(at.x,at.y,at.z),u.push(tt/A),u.push(1-K/E),Z+=1}}for(let K=0;K<E;K++)for(let et=0;et<A;et++){let tt=d+et+R*K,dt=d+et+R*(K+1),At=d+(et+1)+R*(K+1),te=d+(et+1)+R*K;o.push(tt,dt,te),o.push(dt,At,te),H+=6}a.addGroup(h,H,g),h+=H,d+=Z}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Hn(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}class xs extends _n{constructor(t=1,e=32,n=0,i=Math.PI*2){super();this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:n,thetaLength:i},e=Math.max(3,e);let s=[],r=[],a=[],o=[],l=new O,c=new Xt;r.push(0,0,0),a.push(0,0,1),o.push(0.5,0.5);for(let u=0,d=3;u<=e;u++,d+=3){let h=n+u/e*i;l.x=t*Math.cos(h),l.y=t*Math.sin(h),r.push(l.x,l.y,l.z),a.push(0,0,1),c.x=(r[d]/t+1)/2,c.y=(r[d+1]/t+1)/2,o.push(c.x,c.y)}for(let u=1;u<=e;u++)s.push(u,u+1,0);this.setIndex(s),this.setAttribute("position",new Ye(r,3)),this.setAttribute("normal",new Ye(a,3)),this.setAttribute("uv",new Ye(o,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new xs(t.radius,t.segments,t.thetaStart,t.thetaLength)}}class xn extends _n{constructor(t=1,e=1,n=1,i=32,s=1,r=!1,a=0,o=Math.PI*2){super();this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:n,radialSegments:i,heightSegments:s,openEnded:r,thetaStart:a,thetaLength:o};let l=this;i=Math.floor(i),s=Math.floor(s);let c=[],u=[],d=[],h=[],p=0,v=[],T=n/2,m=0;if(f(),r===!1){if(t>0)w(!0);if(e>0)w(!1)}this.setIndex(c),this.setAttribute("position",new Ye(u,3)),this.setAttribute("normal",new Ye(d,3)),this.setAttribute("uv",new Ye(h,2));function f(){let C=new O,y=new O,b=0,A=(e-t)/n;for(let E=0;E<=s;E++){let g=[],M=E/s,G=M*(e-t)+t;for(let N=0;N<=i;N++){let F=N/i,X=F*o+a,R=Math.sin(X),k=Math.cos(X);y.x=G*R,y.y=-M*n+T,y.z=G*k,u.push(y.x,y.y,y.z),C.set(R,A,k).normalize(),d.push(C.x,C.y,C.z),h.push(F,1-M),g.push(p++)}v.push(g)}for(let E=0;E<i;E++)for(let g=0;g<s;g++){let M=v[g][E],G=v[g+1][E],N=v[g+1][E+1],F=v[g][E+1];if(t>0||g!==0)c.push(M,G,F),b+=3;if(e>0||g!==s-1)c.push(G,N,F),b+=3}l.addGroup(m,b,0),m+=b}function w(C){let y=p,b=new Xt,A=new O,E=0,g=C===!0?t:e,M=C===!0?1:-1;for(let N=1;N<=i;N++)u.push(0,T*M,0),d.push(0,M,0),h.push(0.5,0.5),p++;let G=p;for(let N=0;N<=i;N++){let X=N/i*o+a,R=Math.cos(X),k=Math.sin(X);A.x=g*k,A.y=T*M,A.z=g*R,u.push(A.x,A.y,A.z),d.push(0,M,0),b.x=R*0.5+0.5,b.y=k*0.5*M+0.5,h.push(b.x,b.y),p++}for(let N=0;N<i;N++){let F=y+N,X=G+N;if(C===!0)c.push(X,X+1,F);else c.push(X+1,X,F);E+=3}l.addGroup(m,E,C===!0?1:2),m+=E}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new xn(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class Ie extends _n{constructor(t=1,e=1,n=1,i=1){super();this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:n,heightSegments:i};let s=t/2,r=e/2,a=Math.floor(n),o=Math.floor(i),l=a+1,c=o+1,u=t/a,d=e/o,h=[],p=[],v=[],T=[];for(let m=0;m<c;m++){let f=m*d-r;for(let w=0;w<l;w++){let C=w*u-s;p.push(C,-f,0),v.push(0,0,1),T.push(w/a),T.push(1-m/o)}}for(let m=0;m<o;m++)for(let f=0;f<a;f++){let w=f+l*m,C=f+l*(m+1),y=f+1+l*(m+1),b=f+1+l*m;h.push(w,C,b),h.push(C,y,b)}this.setIndex(h),this.setAttribute("position",new Ye(p,3)),this.setAttribute("normal",new Ye(v,3)),this.setAttribute("uv",new Ye(T,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Ie(t.width,t.height,t.widthSegments,t.heightSegments)}}function Oi(t){let e={};for(let n in t){e[n]={};for(let i in t[n]){let s=t[n][i];if(uc(s))if(s.isRenderTargetTexture)Ht("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[n][i]=null;else e[n][i]=s.clone();else if(Array.isArray(s))if(uc(s[0])){let r=[];for(let a=0,o=s.length;a<o;a++)r[a]=s[a].clone();e[n][i]=r}else e[n][i]=s.slice();else e[n][i]=s}}return e}function je(t){let e={};for(let n=0;n<t.length;n++){let i=Oi(t[n]);for(let s in i)e[s]=i[s]}return e}function uc(t){return t&&(t.isColor||t.isMatrix3||t.isMatrix4||t.isVector2||t.isVector3||t.isVector4||t.isTexture||t.isQuaternion)}function ju(t){let e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function nl(t){let e=t.getRenderTarget();if(e===null)return t.outputColorSpace;if(e.isXRRenderTarget===!0)return e.texture.colorSpace;return re.workingColorSpace}var yh={clone:Oi,merge:je},td=`void main() {
1
+ import{Wr}from"./chunk-index-24cggw6k.js";import{rn,Rn,vr,on,zt,Oo,Is,yt,Ds,Kn,Us,Vs,Ni,qs,Bs,yo,Fs,Gs,Zs,Ws,Ys,bo}from"./chunk-index-rjs1can6.js";import{zn,Mt,es,un,dn,Rt,ts,pi,Zi,ns,Wi,is,rs,Cr}from"./chunk-index-0h99xcs3.js";import{Ct,Gt}from"./chunk-index-pgxgq61x.js";var yc="186";var Sc=0,$a=1,Mc=2;var Xs=1,bc=2,_s=3,xs=0,Ve=1,sn=2,On=0,In=1,Qn=2,Ka=3,Qa=4,Tc=5;var vs=100,wc=101,Ec=102,Ac=103,Cc=104,Rc=200,Ic=201,Pc=202,Lc=203,Nc=204,Dc=205,Uc=206,Fc=207,Oc=208,Bc=209,zc=210,kc=211,Gc=212,Hc=213,Vc=214,Wc=0,Xc=1,qc=2,ja=3,Yc=4,Zc=5,Jc=6,$c=7,Kc=0,Qc=1,jc=2,Pn=0,to=1,eo=2,no=3,io=4,so=5,ro=6,ao=7;var ys=301,Ai=302,Hr=303,Vr=304,Js=306,$s=1000,Bn=1001,th=1002,Ln=1003,eh=1004;var Ks=1005;var Qe=1006,Xr=1007;var Ci=1008;var mn=1009,nh=1010,ih=1011,Qs=1012,oo=1013,mi=1014,jn=1015,kn=1016,lo=1017,co=1018,Ss=1020,sh=35902,rh=35899,ah=1021,oh=1022,Gn=1023,Ri=1026,Ii=1027,qr=1028,ho=1029,Pi=1030,uo=1031;var fo=1033,Yr=33776,Zr=33777,Jr=33778,$r=33779,po=35840,mo=35841,go=35842,_o=35843,xo=36196,vo=37492,So=37496,Mo=37488,To=37489,Kr=37490,wo=37491,Eo=37808,Ao=37809,Co=37810,Ro=37811,Io=37812,Po=37813,Lo=37814,No=37815,Do=37816,Uo=37817,Fo=37818,Bo=37819,zo=37820,ko=37821,Go=36492,Ho=36494,Vo=36495,Wo=36283,Xo=36284,Qr=36285,qo=36286;var Yo=0,lh=1,Li="",gi="srgb",Zo="srgb-linear",Jo="linear",Me="srgb";var ch=512,hh=513,uh=514,jr=515,dh=516,fh=517,ta=518,ph=519;var $o="300 es",Ko=2000;function Nu(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function Du(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function zs(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function mh(){let t=zs("canvas");return t.style.display="block",t}var Jl={},gs=null;function ks(...t){let e="THREE."+t.shift();if(gs)gs("log",e,...t);else console.log(e,...t)}function gh(t){let e=t[0];if(typeof e==="string"&&e.startsWith("TSL:")){let n=t[1];if(n&&n.isStackTrace)t[0]+=" "+n.getLocation();else t[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return t}function Vt(...t){t=gh(t);let e="THREE."+t.shift();if(gs)gs("warn",e,...t);else{let n=t[0];if(n&&n.isStackTrace)console.warn(n.getError(e));else console.warn(e,...t)}}function Ht(...t){t=gh(t);let e="THREE."+t.shift();if(gs)gs("error",e,...t);else{let n=t[0];if(n&&n.isStackTrace)console.error(n.getError(e));else console.error(e,...t)}}function Ei(...t){let e=t.join(" ");if(e in Jl)return;Jl[e]=!0,Vt(...t)}function _h(t,e,n){return new Promise(function(i,s){function r(){switch(t.clientWaitSync(e,t.SYNC_FLUSH_COMMANDS_BIT,0)){case t.WAIT_FAILED:s();break;case t.TIMEOUT_EXPIRED:setTimeout(r,n);break;default:i()}}setTimeout(r,n)})}var xh={[0]:1,[2]:6,[4]:7,[3]:5,[1]:0,[6]:2,[7]:4,[5]:3};class ti{addEventListener(t,e){if(this._listeners===void 0)this._listeners={};let n=this._listeners;if(n[t]===void 0)n[t]=[];if(n[t].indexOf(e)===-1)n[t].push(e)}hasEventListener(t,e){let n=this._listeners;if(n===void 0)return!1;return n[t]!==void 0&&n[t].indexOf(e)!==-1}removeEventListener(t,e){let n=this._listeners;if(n===void 0)return;let i=n[t];if(i!==void 0){let s=i.indexOf(e);if(s!==-1)i.splice(s,1)}}dispatchEvent(t){let e=this._listeners;if(e===void 0)return;let n=e[t.type];if(n!==void 0){t.target=this;let i=n.slice(0);for(let s=0,r=i.length;s<r;s++)i[s].call(this,t);t.target=null}}}var $e=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];var wa=Math.PI/180,Gr=180/Math.PI;function di(){let t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return($e[t&255]+$e[t>>8&255]+$e[t>>16&255]+$e[t>>24&255]+"-"+$e[e&255]+$e[e>>8&255]+"-"+$e[e>>16&15|64]+$e[e>>24&255]+"-"+$e[n&63|128]+$e[n>>8&255]+"-"+$e[n>>16&255]+$e[n>>24&255]+$e[i&255]+$e[i>>8&255]+$e[i>>16&255]+$e[i>>24&255]).toLowerCase()}function oe(t,e,n){return Math.max(e,Math.min(n,t))}function Uu(t,e){return(t%e+e)%e}function Ea(t,e,n){return(1-n)*t+n*e}function Fn(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:case Uint8ClampedArray:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw Error("THREE.MathUtils: Invalid component type.")}}function xe(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(t*4294967295);case Uint16Array:return Math.round(t*65535);case Uint8Array:case Uint8ClampedArray:return Math.round(t*255);case Int32Array:return Math.round(t*2147483647);case Int16Array:return Math.round(t*32767);case Int8Array:return Math.round(t*127);default:throw Error("THREE.MathUtils: Invalid component type.")}}class qt{static{qt.prototype.isVector2=!0}constructor(t=0,e=0){this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw Error("THREE.Vector2: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw Error("THREE.Vector2: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){let e=this.x,n=this.y,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6],this.y=i[1]*e+i[4]*n+i[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=oe(this.x,t.x,e.x),this.y=oe(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=oe(this.x,t,e),this.y=oe(this.y,t,e),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(oe(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let n=this.dot(t)/e;return Math.acos(oe(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){let n=Math.cos(e),i=Math.sin(e),s=this.x-t.x,r=this.y-t.y;return this.x=s*n-r*i+t.x,this.y=s*i+r*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class ei{constructor(t=0,e=0,n=0,i=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=i}static slerpFlat(t,e,n,i,s,r,a){let o=n[i+0],l=n[i+1],c=n[i+2],u=n[i+3],d=s[r+0],h=s[r+1],p=s[r+2],v=s[r+3];if(u!==v||o!==d||l!==h||c!==p){let T=o*d+l*h+c*p+u*v;if(T<0)d=-d,h=-h,p=-p,v=-v,T=-T;let m=1-a;if(T<0.9995){let f=Math.acos(T),w=Math.sin(f);m=Math.sin(m*f)/w,a=Math.sin(a*f)/w,o=o*m+d*a,l=l*m+h*a,c=c*m+p*a,u=u*m+v*a}else{o=o*m+d*a,l=l*m+h*a,c=c*m+p*a,u=u*m+v*a;let f=1/Math.sqrt(o*o+l*l+c*c+u*u);o*=f,l*=f,c*=f,u*=f}}t[e]=o,t[e+1]=l,t[e+2]=c,t[e+3]=u}static multiplyQuaternionsFlat(t,e,n,i,s,r){let a=n[i],o=n[i+1],l=n[i+2],c=n[i+3],u=s[r],d=s[r+1],h=s[r+2],p=s[r+3];return t[e]=a*p+c*u+o*h-l*d,t[e+1]=o*p+c*d+l*u-a*h,t[e+2]=l*p+c*h+a*d-o*u,t[e+3]=c*p-a*u-o*d-l*h,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,i){return this._x=t,this._y=e,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){let{_x:n,_y:i,_z:s,_order:r}=t,{cos:a,sin:o}=Math,l=a(n/2),c=a(i/2),u=a(s/2),d=o(n/2),h=o(i/2),p=o(s/2);switch(r){case"XYZ":this._x=d*c*u+l*h*p,this._y=l*h*u-d*c*p,this._z=l*c*p+d*h*u,this._w=l*c*u-d*h*p;break;case"YXZ":this._x=d*c*u+l*h*p,this._y=l*h*u-d*c*p,this._z=l*c*p-d*h*u,this._w=l*c*u+d*h*p;break;case"ZXY":this._x=d*c*u-l*h*p,this._y=l*h*u+d*c*p,this._z=l*c*p+d*h*u,this._w=l*c*u-d*h*p;break;case"ZYX":this._x=d*c*u-l*h*p,this._y=l*h*u+d*c*p,this._z=l*c*p-d*h*u,this._w=l*c*u+d*h*p;break;case"YZX":this._x=d*c*u+l*h*p,this._y=l*h*u+d*c*p,this._z=l*c*p-d*h*u,this._w=l*c*u-d*h*p;break;case"XZY":this._x=d*c*u-l*h*p,this._y=l*h*u-d*c*p,this._z=l*c*p+d*h*u,this._w=l*c*u+d*h*p;break;default:Vt("Quaternion: .setFromEuler() encountered an unknown order: "+r)}if(e===!0)this._onChangeCallback();return this}setFromAxisAngle(t,e){let n=e/2,i=Math.sin(n);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){let e=t.elements,n=e[0],i=e[4],s=e[8],r=e[1],a=e[5],o=e[9],l=e[2],c=e[6],u=e[10],d=n+a+u;if(d>0){let h=0.5/Math.sqrt(d+1);this._w=0.25/h,this._x=(c-o)*h,this._y=(s-l)*h,this._z=(r-i)*h}else if(n>a&&n>u){let h=2*Math.sqrt(1+n-a-u);this._w=(c-o)/h,this._x=0.25*h,this._y=(i+r)/h,this._z=(s+l)/h}else if(a>u){let h=2*Math.sqrt(1+a-n-u);this._w=(s-l)/h,this._x=(i+r)/h,this._y=0.25*h,this._z=(o+c)/h}else{let h=2*Math.sqrt(1+u-n-a);this._w=(r-i)/h,this._x=(s+l)/h,this._y=(o+c)/h,this._z=0.25*h}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;if(n<0.00000001)if(n=0,Math.abs(t.x)>Math.abs(t.z))this._x=-t.y,this._y=t.x,this._z=0,this._w=n;else this._x=0,this._y=-t.z,this._z=t.y,this._w=n;else this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n;return this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(oe(this.dot(t),-1,1)))}rotateTowards(t,e){let n=this.angleTo(t);if(n===0)return this;let i=Math.min(1,e/n);return this.slerp(t,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();if(t===0)this._x=0,this._y=0,this._z=0,this._w=1;else t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t;return this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){let{_x:n,_y:i,_z:s,_w:r}=t,{_x:a,_y:o,_z:l,_w:c}=e;return this._x=n*c+r*a+i*l-s*o,this._y=i*c+r*o+s*a-n*l,this._z=s*c+r*l+n*o-i*a,this._w=r*c-n*a-i*o-s*l,this._onChangeCallback(),this}slerp(t,e){let{_x:n,_y:i,_z:s,_w:r}=t,a=this.dot(t);if(a<0)n=-n,i=-i,s=-s,r=-r,a=-a;let o=1-e;if(a<0.9995){let l=Math.acos(a),c=Math.sin(l);o=Math.sin(o*l)/c,e=Math.sin(e*l)/c,this._x=this._x*o+n*e,this._y=this._y*o+i*e,this._z=this._z*o+s*e,this._w=this._w*o+r*e,this._onChangeCallback()}else this._x=this._x*o+n*e,this._y=this._y*o+i*e,this._z=this._z*o+s*e,this._w=this._w*o+r*e,this.normalize();return this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){let t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),s=Math.sqrt(n);return this.set(i*Math.sin(t),i*Math.cos(t),s*Math.sin(e),s*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class O{static{O.prototype.isVector3=!0}constructor(t=0,e=0,n=0){this.x=t,this.y=e,this.z=n}set(t,e,n){if(n===void 0)n=this.z;return this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw Error("THREE.Vector3: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error("THREE.Vector3: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion($l.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion($l.setFromAxisAngle(t,e))}applyMatrix3(t){let e=this.x,n=this.y,i=this.z,s=t.elements;return this.x=s[0]*e+s[3]*n+s[6]*i,this.y=s[1]*e+s[4]*n+s[7]*i,this.z=s[2]*e+s[5]*n+s[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){let e=this.x,n=this.y,i=this.z,s=t.elements,r=1/(s[3]*e+s[7]*n+s[11]*i+s[15]);return this.x=(s[0]*e+s[4]*n+s[8]*i+s[12])*r,this.y=(s[1]*e+s[5]*n+s[9]*i+s[13])*r,this.z=(s[2]*e+s[6]*n+s[10]*i+s[14])*r,this}applyQuaternion(t){let e=this.x,n=this.y,i=this.z,{x:s,y:r,z:a,w:o}=t,l=2*(r*i-a*n),c=2*(a*e-s*i),u=2*(s*n-r*e);return this.x=e+o*l+r*u-a*c,this.y=n+o*c+a*l-s*u,this.z=i+o*u+s*c-r*l,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){let e=this.x,n=this.y,i=this.z,s=t.elements;return this.x=s[0]*e+s[4]*n+s[8]*i,this.y=s[1]*e+s[5]*n+s[9]*i,this.z=s[2]*e+s[6]*n+s[10]*i,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=oe(this.x,t.x,e.x),this.y=oe(this.y,t.y,e.y),this.z=oe(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=oe(this.x,t,e),this.y=oe(this.y,t,e),this.z=oe(this.z,t,e),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(oe(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){let{x:n,y:i,z:s}=t,{x:r,y:a,z:o}=e;return this.x=i*o-s*a,this.y=s*r-n*o,this.z=n*a-i*r,this}projectOnVector(t){let e=t.lengthSq();if(e===0)return this.set(0,0,0);let n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return Aa.copy(this).projectOnVector(t),this.sub(Aa)}reflect(t){return this.sub(Aa.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let n=this.dot(t)/e;return Math.acos(oe(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,n=this.y-t.y,i=this.z-t.z;return e*e+n*n+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){let i=Math.sin(e)*t;return this.x=i*Math.sin(n),this.y=Math.cos(e)*t,this.z=i*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){let e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){let e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=i,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let t=Math.random()*Math.PI*2,e=Math.random()*2-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}var Aa=new O,$l=new ei;class Yt{static{Yt.prototype.isMatrix3=!0}constructor(t,e,n,i,s,r,a,o,l){if(this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0)this.set(t,e,n,i,s,r,a,o,l)}set(t,e,n,i,s,r,a,o,l){let c=this.elements;return c[0]=t,c[1]=i,c[2]=a,c[3]=e,c[4]=s,c[5]=o,c[6]=n,c[7]=r,c[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){let e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){let e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let n=t.elements,i=e.elements,s=this.elements,r=n[0],a=n[3],o=n[6],l=n[1],c=n[4],u=n[7],d=n[2],h=n[5],p=n[8],v=i[0],T=i[3],m=i[6],f=i[1],w=i[4],C=i[7],y=i[2],b=i[5],A=i[8];return s[0]=r*v+a*f+o*y,s[3]=r*T+a*w+o*b,s[6]=r*m+a*C+o*A,s[1]=l*v+c*f+u*y,s[4]=l*T+c*w+u*b,s[7]=l*m+c*C+u*A,s[2]=d*v+h*f+p*y,s[5]=d*T+h*w+p*b,s[8]=d*m+h*C+p*A,this}multiplyScalar(t){let e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){let t=this.elements,e=t[0],n=t[1],i=t[2],s=t[3],r=t[4],a=t[5],o=t[6],l=t[7],c=t[8];return e*r*c-e*a*l-n*s*c+n*a*o+i*s*l-i*r*o}invert(){let t=this.elements,e=t[0],n=t[1],i=t[2],s=t[3],r=t[4],a=t[5],o=t[6],l=t[7],c=t[8],u=c*r-a*l,d=a*o-c*s,h=l*s-r*o,p=e*u+n*d+i*h;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let v=1/p;return t[0]=u*v,t[1]=(i*l-c*n)*v,t[2]=(a*n-i*r)*v,t[3]=d*v,t[4]=(c*e-i*o)*v,t[5]=(i*s-a*e)*v,t[6]=h*v,t[7]=(n*o-l*e)*v,t[8]=(r*e-n*s)*v,this}transpose(){let t,e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){let e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,i,s,r,a){let o=Math.cos(s),l=Math.sin(s);return this.set(n*o,n*l,-n*(o*r+l*a)+r+t,-i*l,i*o,-i*(-l*r+o*a)+a+e,0,0,1),this}scale(t,e){return Ei("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Ca.makeScale(t,e)),this}rotate(t){return Ei("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Ca.makeRotation(-t)),this}translate(t,e){return Ei("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Ca.makeTranslation(t,e)),this}makeTranslation(t,e){if(t.isVector2)this.set(1,0,t.x,0,1,t.y,0,0,1);else this.set(1,0,t,0,1,e,0,0,1);return this}makeRotation(t){let e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){let e=this.elements,n=t.elements;for(let i=0;i<9;i++)if(e[i]!==n[i])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){let n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return new this.constructor().fromArray(this.elements)}}var Ca=new Yt,Kl=new Yt().set(0.4123908,0.3575843,0.1804808,0.212639,0.7151687,0.0721923,0.0193308,0.1191948,0.9505322),Ql=new Yt().set(3.2409699,-1.5373832,-0.4986108,-0.9692436,1.8759675,0.0415551,0.0556301,-0.203977,1.0569715);function Fu(){let t={enabled:!0,workingColorSpace:"srgb-linear",spaces:{},convert:function(s,r,a){if(this.enabled===!1||r===a||!r||!a)return s;if(this.spaces[r].transfer==="srgb")s.r=$n(s.r),s.g=$n(s.g),s.b=$n(s.b);if(this.spaces[r].primaries!==this.spaces[a].primaries)s.applyMatrix3(this.spaces[r].toXYZ),s.applyMatrix3(this.spaces[a].fromXYZ);if(this.spaces[a].transfer==="srgb")s.r=ms(s.r),s.g=ms(s.g),s.b=ms(s.b);return s},workingToColorSpace:function(s,r){return this.convert(s,this.workingColorSpace,r)},colorSpaceToWorking:function(s,r){return this.convert(s,r,this.workingColorSpace)},getPrimaries:function(s){return this.spaces[s].primaries},getTransfer:function(s){if(s==="")return"linear";return this.spaces[s].transfer},getToneMappingMode:function(s){return this.spaces[s].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(s,r=this.workingColorSpace){return s.fromArray(this.spaces[r].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s)},_getMatrix:function(s,r,a){return s.copy(this.spaces[r].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(s,r){return Ei("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(s,r)},toWorkingColorSpace:function(s,r){return Ei("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),t.colorSpaceToWorking(s,r)}},e=[0.64,0.33,0.3,0.6,0.15,0.06],n=[0.2126,0.7152,0.0722],i=[0.3127,0.329];return t.define({["srgb-linear"]:{primaries:e,whitePoint:i,transfer:"linear",toXYZ:Kl,fromXYZ:Ql,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:"srgb"},outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}},["srgb"]:{primaries:e,whitePoint:i,transfer:"srgb",toXYZ:Kl,fromXYZ:Ql,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}}}),t}var re=Fu();function $n(t){return t<0.04045?t*0.0773993808:Math.pow(t*0.9478672986+0.0521327014,2.4)}function ms(t){return t<0.0031308?t*12.92:1.055*Math.pow(t,0.41666)-0.055}var qi;class Qo{static getDataURL(t,e="image/png"){if(/^data:/i.test(t.src))return t.src;if(typeof HTMLCanvasElement>"u")return t.src;let n;if(t instanceof HTMLCanvasElement)n=t;else{if(qi===void 0)qi=zs("canvas");qi.width=t.width,qi.height=t.height;let i=qi.getContext("2d");if(t instanceof ImageData)i.putImageData(t,0,0);else i.drawImage(t,0,0,t.width,t.height);n=qi}return n.toDataURL(e)}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){let e=zs("canvas");e.width=t.width,e.height=t.height;let n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);let i=n.getImageData(0,0,t.width,t.height),s=i.data;for(let r=0;r<s.length;r++)s[r]=$n(s[r]/255)*255;return n.putImageData(i,0,0),e}else if(t.data){let e=t.data.slice(0);for(let n=0;n<e.length;n++)if(e instanceof Uint8Array||e instanceof Uint8ClampedArray)e[n]=Math.floor($n(e[n]/255)*255);else e[n]=$n(e[n]);return{data:e,width:t.width,height:t.height}}else return Vt("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}var Ou=0;class js{constructor(t=null){this.isTextureSource=!0,Object.defineProperty(this,"id",{value:Ou++}),this.uuid=di(),this.data=t,this.dataReady=!0,this.version=0}getSize(t){let e=this.data;if(typeof HTMLVideoElement<"u"&&e instanceof HTMLVideoElement)t.set(e.videoWidth,e.videoHeight,0);else if(typeof VideoFrame<"u"&&e instanceof VideoFrame)t.set(e.displayWidth,e.displayHeight,0);else if(e!==null)t.set(e.width,e.height,e.depth||0);else t.set(0,0,0);return t}set needsUpdate(t){if(t===!0)this.version++}toJSON(t){let e=t===void 0||typeof t==="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];let n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let s;if(Array.isArray(i)){s=[];for(let r=0,a=i.length;r<a;r++)if(i[r].isDataTexture)s.push(Ra(i[r].image));else s.push(Ra(i[r]))}else s=Ra(i);n.url=s}if(!e)t.images[this.uuid]=n;return n}}function Ra(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap)return Qo.getDataURL(t);else if(t.data)return{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name};else return Vt("Texture: Unable to serialize Texture."),{}}var Bu=0,Ia=new O;class qe extends ti{constructor(t=qe.DEFAULT_IMAGE,e=qe.DEFAULT_MAPPING,n=1001,i=1001,s=1006,r=1008,a=1023,o=1009,l=qe.DEFAULT_ANISOTROPY,c=""){super();this.isTexture=!0,Object.defineProperty(this,"id",{value:Bu++}),this.uuid=di(),this.name="",this.source=new js(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=s,this.minFilter=r,this.anisotropy=l,this.format=a,this.internalFormat=null,this.type=o,this.offset=new qt(0,0),this.repeat=new qt(1,1),this.center=new qt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Yt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=c,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=t&&t.depth&&t.depth>1?!0:!1,this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(Ia).x}get height(){return this.source.getSize(Ia).y}get depth(){return this.source.getSize(Ia).z}get image(){return this.source.data}set image(t){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.normalized=t.normalized,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.renderTarget=t.renderTarget,this.isRenderTargetTexture=t.isRenderTargetTexture,this.isArrayTexture=t.isArrayTexture,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}setValues(t){for(let e in t){let n=t[e];if(n===void 0){Vt(`Texture.setValues(): parameter '${e}' has value of undefined.`);continue}let i=this[e];if(i===void 0){Vt(`Texture.setValues(): property '${e}' does not exist.`);continue}if(i&&n&&(i.isVector2&&n.isVector2))i.copy(n);else if(i&&n&&(i.isVector3&&n.isVector3))i.copy(n);else if(i&&n&&(i.isMatrix3&&n.isMatrix3))i.copy(n);else this[e]=n}}toJSON(t){let e=t===void 0||typeof t==="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];let n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(Object.keys(this.userData).length>0)n.userData=this.userData;if(!e)t.textures[this.uuid]=n;return n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==300)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case 1000:t.x=t.x-Math.floor(t.x);break;case 1001:t.x=t.x<0?0:1;break;case 1002:if(Math.abs(Math.floor(t.x)%2)===1)t.x=Math.ceil(t.x)-t.x;else t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case 1000:t.y=t.y-Math.floor(t.y);break;case 1001:t.y=t.y<0?0:1;break;case 1002:if(Math.abs(Math.floor(t.y)%2)===1)t.y=Math.ceil(t.y)-t.y;else t.y=t.y-Math.floor(t.y);break}if(this.flipY)t.y=1-t.y;return t}set needsUpdate(t){if(t===!0)this.version++,this.source.needsUpdate=!0}set needsPMREMUpdate(t){if(t===!0)this.pmremVersion++}}qe.DEFAULT_IMAGE=null;qe.DEFAULT_MAPPING=300;qe.DEFAULT_ANISOTROPY=1;class Ae{static{Ae.prototype.isVector4=!0}constructor(t=0,e=0,n=0,i=1){this.x=t,this.y=e,this.z=n,this.w=i}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,i){return this.x=t,this.y=e,this.z=n,this.w=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw Error("THREE.Vector4: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error("THREE.Vector4: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){let e=this.x,n=this.y,i=this.z,s=this.w,r=t.elements;return this.x=r[0]*e+r[4]*n+r[8]*i+r[12]*s,this.y=r[1]*e+r[5]*n+r[9]*i+r[13]*s,this.z=r[2]*e+r[6]*n+r[10]*i+r[14]*s,this.w=r[3]*e+r[7]*n+r[11]*i+r[15]*s,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);let e=Math.sqrt(1-t.w*t.w);if(e<0.0001)this.x=1,this.y=0,this.z=0;else this.x=t.x/e,this.y=t.y/e,this.z=t.z/e;return this}setAxisAngleFromRotationMatrix(t){let e,n,i,s,r=0.01,a=0.1,o=t.elements,l=o[0],c=o[4],u=o[8],d=o[1],h=o[5],p=o[9],v=o[2],T=o[6],m=o[10];if(Math.abs(c-d)<0.01&&Math.abs(u-v)<0.01&&Math.abs(p-T)<0.01){if(Math.abs(c+d)<0.1&&Math.abs(u+v)<0.1&&Math.abs(p+T)<0.1&&Math.abs(l+h+m-3)<0.1)return this.set(1,0,0,0),this;e=Math.PI;let w=(l+1)/2,C=(h+1)/2,y=(m+1)/2,b=(c+d)/4,A=(u+v)/4,E=(p+T)/4;if(w>C&&w>y)if(w<0.01)n=0,i=0.707106781,s=0.707106781;else n=Math.sqrt(w),i=b/n,s=A/n;else if(C>y)if(C<0.01)n=0.707106781,i=0,s=0.707106781;else i=Math.sqrt(C),n=b/i,s=E/i;else if(y<0.01)n=0.707106781,i=0.707106781,s=0;else s=Math.sqrt(y),n=A/s,i=E/s;return this.set(n,i,s,e),this}let f=Math.sqrt((T-p)*(T-p)+(u-v)*(u-v)+(d-c)*(d-c));if(Math.abs(f)<0.001)f=1;return this.x=(T-p)/f,this.y=(u-v)/f,this.z=(d-c)/f,this.w=Math.acos((l+h+m-1)/2),this}setFromMatrixPosition(t){let e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=oe(this.x,t.x,e.x),this.y=oe(this.y,t.y,e.y),this.z=oe(this.z,t.z,e.z),this.w=oe(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=oe(this.x,t,e),this.y=oe(this.y,t,e),this.z=oe(this.z,t,e),this.w=oe(this.w,t,e),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(oe(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class jo extends ti{constructor(t=1,e=1,n={}){super();n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:1006,depthBuffer:!0,stencilBuffer:!1,resolveColorBuffer:!0,resolveDepthBuffer:!0,resolveStencilBuffer:!0,storeMultisampledColorBuffer:!0,storeMultisampledDepthBuffer:!0,storeMultisampledStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=n.depth,this.scissor=new Ae(0,0,t,e),this.scissorTest=!1,this.viewport=new Ae(0,0,t,e),this.textures=[];let i={width:t,height:e,depth:n.depth},s=new qe(i),r=n.count;for(let a=0;a<r;a++)this.textures[a]=s.clone(),this.textures[a].isRenderTargetTexture=!0,this.textures[a].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveColorBuffer=n.resolveColorBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this.storeMultisampledColorBuffer=n.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=n.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=n.storeMultisampledStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview,this.useArrayDepthTexture=n.useArrayDepthTexture}_setTextureOptions(t={}){let e={minFilter:1006,generateMipmaps:!1,flipY:!1,internalFormat:null};if(t.mapping!==void 0)e.mapping=t.mapping;if(t.wrapS!==void 0)e.wrapS=t.wrapS;if(t.wrapT!==void 0)e.wrapT=t.wrapT;if(t.wrapR!==void 0)e.wrapR=t.wrapR;if(t.magFilter!==void 0)e.magFilter=t.magFilter;if(t.minFilter!==void 0)e.minFilter=t.minFilter;if(t.format!==void 0)e.format=t.format;if(t.type!==void 0)e.type=t.type;if(t.anisotropy!==void 0)e.anisotropy=t.anisotropy;if(t.colorSpace!==void 0)e.colorSpace=t.colorSpace;if(t.flipY!==void 0)e.flipY=t.flipY;if(t.generateMipmaps!==void 0)e.generateMipmaps=t.generateMipmaps;if(t.internalFormat!==void 0)e.internalFormat=t.internalFormat;for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(e)}get texture(){return this.textures[0]}set texture(t){this.textures[0]=t}set depthTexture(t){if(this._depthTexture!==null&&this._depthTexture.renderTarget===this)this._depthTexture.renderTarget=null;if(t!==null&&t.renderTarget===null)t.renderTarget=this;this._depthTexture=t}get depthTexture(){return this._depthTexture}setSize(t,e,n=1){if(this.width!==t||this.height!==e||this.depth!==n){this.width=t,this.height=e,this.depth=n;for(let i=0,s=this.textures.length;i<s;i++)if(this.textures[i].image.width=t,this.textures[i].image.height=e,this.textures[i].image.depth=n,this.textures[i].isData3DTexture!==!0)this.textures[i].isArrayTexture=this.textures[i].image.depth>1;this.dispose()}this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return new this.constructor().copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.textures.length=0;for(let e=0,n=t.textures.length;e<n;e++){this.textures[e]=t.textures[e].clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;let i=Object.assign({},t.textures[e].image);this.textures[e].source=new js(i)}if(this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.resolveColorBuffer=t.resolveColorBuffer,this.resolveDepthBuffer=t.resolveDepthBuffer,this.resolveStencilBuffer=t.resolveStencilBuffer,this.storeMultisampledColorBuffer=t.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=t.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=t.storeMultisampledStencilBuffer,t.depthTexture!==null)if(t.depthTexture.renderTarget===t){let e=t.depthTexture.clone();e.renderTarget=null,this.depthTexture=e}else this.depthTexture=t.depthTexture;return this.samples=t.samples,this.multiview=t.multiview,this.useArrayDepthTexture=t.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}class gn extends jo{constructor(t=1,e=1,n={}){super(t,e,n);this.isWebGLRenderTarget=!0}}class ea extends qe{constructor(t=null,e=1,n=1,i=1){super(null);this.isDataArrayTexture=!0,this.image={data:t,width:e,height:n,depth:i},this.magFilter=1003,this.minFilter=1003,this.wrapR=1001,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}copy(t){return super.copy(t),this.wrapR=t.wrapR,this}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class tl extends qe{constructor(t=null,e=1,n=1,i=1){super(null);this.isData3DTexture=!0,this.image={data:t,width:e,height:n,depth:i},this.magFilter=1003,this.minFilter=1003,this.wrapR=1001,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}copy(t){return super.copy(t),this.wrapR=t.wrapR,this}}class we{static{we.prototype.isMatrix4=!0}constructor(t,e,n,i,s,r,a,o,l,c,u,d,h,p,v,T){if(this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0)this.set(t,e,n,i,s,r,a,o,l,c,u,d,h,p,v,T)}set(t,e,n,i,s,r,a,o,l,c,u,d,h,p,v,T){let m=this.elements;return m[0]=t,m[4]=e,m[8]=n,m[12]=i,m[1]=s,m[5]=r,m[9]=a,m[13]=o,m[2]=l,m[6]=c,m[10]=u,m[14]=d,m[3]=h,m[7]=p,m[11]=v,m[15]=T,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new we().fromArray(this.elements)}copy(t){let e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){let e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){let e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){if(this.determinantAffine()===0)return t.set(1,0,0),e.set(0,1,0),n.set(0,0,1),this;return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){if(t.determinantAffine()===0)return this.identity();let e=this.elements,n=t.elements,i=1/Yi.setFromMatrixColumn(t,0).length(),s=1/Yi.setFromMatrixColumn(t,1).length(),r=1/Yi.setFromMatrixColumn(t,2).length();return e[0]=n[0]*i,e[1]=n[1]*i,e[2]=n[2]*i,e[3]=0,e[4]=n[4]*s,e[5]=n[5]*s,e[6]=n[6]*s,e[7]=0,e[8]=n[8]*r,e[9]=n[9]*r,e[10]=n[10]*r,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){let e=this.elements,{x:n,y:i,z:s}=t,r=Math.cos(n),a=Math.sin(n),o=Math.cos(i),l=Math.sin(i),c=Math.cos(s),u=Math.sin(s);if(t.order==="XYZ"){let d=r*c,h=r*u,p=a*c,v=a*u;e[0]=o*c,e[4]=-o*u,e[8]=l,e[1]=h+p*l,e[5]=d-v*l,e[9]=-a*o,e[2]=v-d*l,e[6]=p+h*l,e[10]=r*o}else if(t.order==="YXZ"){let d=o*c,h=o*u,p=l*c,v=l*u;e[0]=d+v*a,e[4]=p*a-h,e[8]=r*l,e[1]=r*u,e[5]=r*c,e[9]=-a,e[2]=h*a-p,e[6]=v+d*a,e[10]=r*o}else if(t.order==="ZXY"){let d=o*c,h=o*u,p=l*c,v=l*u;e[0]=d-v*a,e[4]=-r*u,e[8]=p+h*a,e[1]=h+p*a,e[5]=r*c,e[9]=v-d*a,e[2]=-r*l,e[6]=a,e[10]=r*o}else if(t.order==="ZYX"){let d=r*c,h=r*u,p=a*c,v=a*u;e[0]=o*c,e[4]=p*l-h,e[8]=d*l+v,e[1]=o*u,e[5]=v*l+d,e[9]=h*l-p,e[2]=-l,e[6]=a*o,e[10]=r*o}else if(t.order==="YZX"){let d=r*o,h=r*l,p=a*o,v=a*l;e[0]=o*c,e[4]=v-d*u,e[8]=p*u+h,e[1]=u,e[5]=r*c,e[9]=-a*c,e[2]=-l*c,e[6]=h*u+p,e[10]=d-v*u}else if(t.order==="XZY"){let d=r*o,h=r*l,p=a*o,v=a*l;e[0]=o*c,e[4]=-u,e[8]=l*c,e[1]=d*u+v,e[5]=r*c,e[9]=h*u-p,e[2]=p*u-h,e[6]=a*c,e[10]=v*u+d}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(zu,t,ku)}lookAt(t,e,n){let i=this.elements;if(hn.subVectors(t,e),hn.lengthSq()===0)hn.z=1;if(hn.normalize(),oi.crossVectors(n,hn),oi.lengthSq()===0){if(Math.abs(n.z)===1)hn.x+=0.0001;else hn.z+=0.0001;hn.normalize(),oi.crossVectors(n,hn)}return oi.normalize(),_r.crossVectors(hn,oi),i[0]=oi.x,i[4]=_r.x,i[8]=hn.x,i[1]=oi.y,i[5]=_r.y,i[9]=hn.y,i[2]=oi.z,i[6]=_r.z,i[10]=hn.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let n=t.elements,i=e.elements,s=this.elements,r=n[0],a=n[4],o=n[8],l=n[12],c=n[1],u=n[5],d=n[9],h=n[13],p=n[2],v=n[6],T=n[10],m=n[14],f=n[3],w=n[7],C=n[11],y=n[15],b=i[0],A=i[4],E=i[8],g=i[12],M=i[1],G=i[5],N=i[9],F=i[13],X=i[2],R=i[6],k=i[10],Z=i[14],H=i[3],at=i[7],K=i[11],et=i[15];return s[0]=r*b+a*M+o*X+l*H,s[4]=r*A+a*G+o*R+l*at,s[8]=r*E+a*N+o*k+l*K,s[12]=r*g+a*F+o*Z+l*et,s[1]=c*b+u*M+d*X+h*H,s[5]=c*A+u*G+d*R+h*at,s[9]=c*E+u*N+d*k+h*K,s[13]=c*g+u*F+d*Z+h*et,s[2]=p*b+v*M+T*X+m*H,s[6]=p*A+v*G+T*R+m*at,s[10]=p*E+v*N+T*k+m*K,s[14]=p*g+v*F+T*Z+m*et,s[3]=f*b+w*M+C*X+y*H,s[7]=f*A+w*G+C*R+y*at,s[11]=f*E+w*N+C*k+y*K,s[15]=f*g+w*F+C*Z+y*et,this}multiplyScalar(t){let e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){let t=this.elements,e=t[0],n=t[4],i=t[8],s=t[12],r=t[1],a=t[5],o=t[9],l=t[13],c=t[2],u=t[6],d=t[10],h=t[14],p=t[3],v=t[7],T=t[11],m=t[15],f=o*h-l*d,w=a*h-l*u,C=a*d-o*u,y=r*h-l*c,b=r*d-o*c,A=r*u-a*c;return e*(v*f-T*w+m*C)-n*(p*f-T*y+m*b)+i*(p*w-v*y+m*A)-s*(p*C-v*b+T*A)}determinantAffine(){let t=this.elements,e=t[0],n=t[4],i=t[8],s=t[1],r=t[5],a=t[9],o=t[2],l=t[6],c=t[10];return e*(r*c-a*l)-n*(s*c-a*o)+i*(s*l-r*o)}transpose(){let t=this.elements,e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){let i=this.elements;if(t.isVector3)i[12]=t.x,i[13]=t.y,i[14]=t.z;else i[12]=t,i[13]=e,i[14]=n;return this}invert(){let t=this.elements,e=t[0],n=t[1],i=t[2],s=t[3],r=t[4],a=t[5],o=t[6],l=t[7],c=t[8],u=t[9],d=t[10],h=t[11],p=t[12],v=t[13],T=t[14],m=t[15],f=e*a-n*r,w=e*o-i*r,C=e*l-s*r,y=n*o-i*a,b=n*l-s*a,A=i*l-s*o,E=c*v-u*p,g=c*T-d*p,M=c*m-h*p,G=u*T-d*v,N=u*m-h*v,F=d*m-h*T,X=f*F-w*N+C*G+y*M-b*g+A*E;if(X===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let R=1/X;return t[0]=(a*F-o*N+l*G)*R,t[1]=(i*N-n*F-s*G)*R,t[2]=(v*A-T*b+m*y)*R,t[3]=(d*b-u*A-h*y)*R,t[4]=(o*M-r*F-l*g)*R,t[5]=(e*F-i*M+s*g)*R,t[6]=(T*C-p*A-m*w)*R,t[7]=(c*A-d*C+h*w)*R,t[8]=(r*N-a*M+l*E)*R,t[9]=(n*M-e*N-s*E)*R,t[10]=(p*b-v*C+m*f)*R,t[11]=(u*C-c*b-h*f)*R,t[12]=(a*g-r*G-o*E)*R,t[13]=(e*G-n*g+i*E)*R,t[14]=(v*w-p*y-T*f)*R,t[15]=(c*y-u*w+d*f)*R,this}scale(t){let e=this.elements,{x:n,y:i,z:s}=t;return e[0]*=n,e[4]*=i,e[8]*=s,e[1]*=n,e[5]*=i,e[9]*=s,e[2]*=n,e[6]*=i,e[10]*=s,e[3]*=n,e[7]*=i,e[11]*=s,this}getMaxScaleOnAxis(){let t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,i))}makeTranslation(t,e,n){if(t.isVector3)this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1);else this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1);return this}makeRotationX(t){let e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){let e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){let e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){let n=Math.cos(e),i=Math.sin(e),s=1-n,{x:r,y:a,z:o}=t,l=s*r,c=s*a;return this.set(l*r+n,l*a-i*o,l*o+i*a,0,l*a+i*o,c*a+n,c*o-i*r,0,l*o-i*a,c*o+i*r,s*o*o+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,i,s,r){return this.set(1,n,s,0,t,1,r,0,e,i,1,0,0,0,0,1),this}compose(t,e,n){let i=this.elements,{_x:s,_y:r,_z:a,_w:o}=e,l=s+s,c=r+r,u=a+a,d=s*l,h=s*c,p=s*u,v=r*c,T=r*u,m=a*u,f=o*l,w=o*c,C=o*u,{x:y,y:b,z:A}=n;return i[0]=(1-(v+m))*y,i[1]=(h+C)*y,i[2]=(p-w)*y,i[3]=0,i[4]=(h-C)*b,i[5]=(1-(d+m))*b,i[6]=(T+f)*b,i[7]=0,i[8]=(p+w)*A,i[9]=(T-f)*A,i[10]=(1-(d+v))*A,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,n){let i=this.elements;t.x=i[12],t.y=i[13],t.z=i[14];let s=this.determinantAffine();if(s===0)return n.set(1,1,1),e.identity(),this;let r=Yi.set(i[0],i[1],i[2]).length(),a=Yi.set(i[4],i[5],i[6]).length(),o=Yi.set(i[8],i[9],i[10]).length();if(s<0)r=-r;En.copy(this);let l=1/r,c=1/a,u=1/o;return En.elements[0]*=l,En.elements[1]*=l,En.elements[2]*=l,En.elements[4]*=c,En.elements[5]*=c,En.elements[6]*=c,En.elements[8]*=u,En.elements[9]*=u,En.elements[10]*=u,e.setFromRotationMatrix(En),n.x=r,n.y=a,n.z=o,this}makePerspective(t,e,n,i,s,r,a=2000,o=!1){let l=this.elements,c=2*s/(e-t),u=2*s/(n-i),d=(e+t)/(e-t),h=(n+i)/(n-i),p,v;if(o)p=s/(r-s),v=r*s/(r-s);else if(a===2000)p=-(r+s)/(r-s),v=-2*r*s/(r-s);else if(a===2001)p=-r/(r-s),v=-r*s/(r-s);else throw Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return l[0]=c,l[4]=0,l[8]=d,l[12]=0,l[1]=0,l[5]=u,l[9]=h,l[13]=0,l[2]=0,l[6]=0,l[10]=p,l[14]=v,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(t,e,n,i,s,r,a=2000,o=!1){let l=this.elements,c=2/(e-t),u=2/(n-i),d=-(e+t)/(e-t),h=-(n+i)/(n-i),p,v;if(o)p=1/(r-s),v=r/(r-s);else if(a===2000)p=-2/(r-s),v=-(r+s)/(r-s);else if(a===2001)p=-1/(r-s),v=-s/(r-s);else throw Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return l[0]=c,l[4]=0,l[8]=0,l[12]=d,l[1]=0,l[5]=u,l[9]=0,l[13]=h,l[2]=0,l[6]=0,l[10]=p,l[14]=v,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(t){let e=this.elements,n=t.elements;for(let i=0;i<16;i++)if(e[i]!==n[i])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){let n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}}var Yi=new O,En=new we,zu=new O(0,0,0),ku=new O(1,1,1),oi=new O,_r=new O,hn=new O,jl=new we,tc=new ei;class fi{constructor(t=0,e=0,n=0,i=fi.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=i}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,i=this._order){return this._x=t,this._y=e,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,n=!0){let i=t.elements,s=i[0],r=i[4],a=i[8],o=i[1],l=i[5],c=i[9],u=i[2],d=i[6],h=i[10];switch(e){case"XYZ":if(this._y=Math.asin(oe(a,-1,1)),Math.abs(a)<0.9999999)this._x=Math.atan2(-c,h),this._z=Math.atan2(-r,s);else this._x=Math.atan2(d,l),this._z=0;break;case"YXZ":if(this._x=Math.asin(-oe(c,-1,1)),Math.abs(c)<0.9999999)this._y=Math.atan2(a,h),this._z=Math.atan2(o,l);else this._y=Math.atan2(-u,s),this._z=0;break;case"ZXY":if(this._x=Math.asin(oe(d,-1,1)),Math.abs(d)<0.9999999)this._y=Math.atan2(-u,h),this._z=Math.atan2(-r,l);else this._y=0,this._z=Math.atan2(o,s);break;case"ZYX":if(this._y=Math.asin(-oe(u,-1,1)),Math.abs(u)<0.9999999)this._x=Math.atan2(d,h),this._z=Math.atan2(o,s);else this._x=0,this._z=Math.atan2(-r,l);break;case"YZX":if(this._z=Math.asin(oe(o,-1,1)),Math.abs(o)<0.9999999)this._x=Math.atan2(-c,l),this._y=Math.atan2(-u,s);else this._x=0,this._y=Math.atan2(a,h);break;case"XZY":if(this._z=Math.asin(-oe(r,-1,1)),Math.abs(r)<0.9999999)this._x=Math.atan2(d,l),this._y=Math.atan2(a,s);else this._x=Math.atan2(-c,h),this._y=0;break;default:Vt("Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}if(this._order=e,n===!0)this._onChangeCallback();return this}setFromQuaternion(t,e,n){return jl.makeRotationFromQuaternion(t),this.setFromRotationMatrix(jl,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return tc.setFromEuler(this),this.setFromQuaternion(tc,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){if(this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0)this._order=t[3];return this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}fi.DEFAULT_ORDER="XYZ";class tr{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}isEnabled(t){return(this.mask&(1<<t|0))!==0}}var Gu=0,ec=new O,Ji=new ei,Xn=new we,xr=new O,As=new O,Hu=new O,Vu=new ei,nc=new O(1,0,0),ic=new O(0,1,0),sc=new O(0,0,1),rc={type:"added"},Wu={type:"removed"},$i={type:"childadded",child:null},Pa={type:"childremoved",child:null};class He extends ti{constructor(){super();this.isObject3D=!0,Object.defineProperty(this,"id",{value:Gu++}),this.uuid=di(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=He.DEFAULT_UP.clone();let t=new O,e=new fi,n=new ei,i=new O(1,1,1);function s(){n.setFromEuler(e,!1)}function r(){e.setFromQuaternion(n,void 0,!1)}e._onChange(s),n._onChange(r),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new we},normalMatrix:{value:new Yt}}),this.matrix=new we,this.matrixWorld=new we,this.matrixAutoUpdate=He.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=He.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new tr,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){if(this.matrixAutoUpdate)this.updateMatrix();this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return Ji.setFromAxisAngle(t,e),this.quaternion.multiply(Ji),this}rotateOnWorldAxis(t,e){return Ji.setFromAxisAngle(t,e),this.quaternion.premultiply(Ji),this}rotateX(t){return this.rotateOnAxis(nc,t)}rotateY(t){return this.rotateOnAxis(ic,t)}rotateZ(t){return this.rotateOnAxis(sc,t)}translateOnAxis(t,e){return ec.copy(t).applyQuaternion(this.quaternion),this.position.add(ec.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(nc,t)}translateY(t){return this.translateOnAxis(ic,t)}translateZ(t){return this.translateOnAxis(sc,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(Xn.copy(this.matrixWorld).invert())}lookAt(t,e,n){if(t.isVector3)xr.copy(t);else xr.set(t,e,n);let i=this.parent;if(this.updateWorldMatrix(!0,!1),As.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight)Xn.lookAt(As,xr,this.up);else Xn.lookAt(xr,As,this.up);if(this.quaternion.setFromRotationMatrix(Xn),i)Xn.extractRotation(i.matrixWorld),Ji.setFromRotationMatrix(Xn),this.quaternion.premultiply(Ji.invert())}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}if(t===this)return Ht("Object3D.add: object can't be added as a child of itself.",t),this;if(t&&t.isObject3D)t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(rc),$i.child=t,this.dispatchEvent($i),$i.child=null;else Ht("Object3D.add: object not an instance of THREE.Object3D.",t);return this}remove(t){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}let e=this.children.indexOf(t);if(e!==-1)t.parent=null,this.children.splice(e,1),t.dispatchEvent(Wu),Pa.child=t,this.dispatchEvent(Pa),Pa.child=null;return this}removeFromParent(){let t=this.parent;if(t!==null)t.remove(this);return this}clear(){return this.remove(...this.children)}attach(t){if(this.updateWorldMatrix(!0,!1),Xn.copy(this.matrixWorld).invert(),t.parent!==null)t.parent.updateWorldMatrix(!0,!1),Xn.multiply(t.parent.matrixWorld);return t.applyMatrix4(Xn),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(rc),$i.child=t,this.dispatchEvent($i),$i.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let n=0,i=this.children.length;n<i;n++){let r=this.children[n].getObjectByProperty(t,e);if(r!==void 0)return r}return}getObjectsByProperty(t,e,n=[]){if(this[t]===e)n.push(this);let i=this.children;for(let s=0,r=i.length;s<r;s++)i[s].getObjectsByProperty(t,e,n);return n}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(As,t,Hu),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(As,Vu,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);let e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}intersectsFrustum(){}traverse(t){t(this);let e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);let e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverseVisible(t)}traverseAncestors(t){let e=this.parent;if(e!==null)t(e),e.traverseAncestors(t)}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let t=this.pivot;if(t!==null){let{x:e,y:n,z:i}=t,s=this.matrix.elements;s[12]+=e-s[0]*e-s[4]*n-s[8]*i,s[13]+=n-s[1]*e-s[5]*n-s[9]*i,s[14]+=i-s[2]*e-s[6]*n-s[10]*i}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){if(this.matrixAutoUpdate)this.updateMatrix();if(this.matrixWorldNeedsUpdate||t){if(this.matrixWorldAutoUpdate===!0)if(this.parent===null)this.matrixWorld.copy(this.matrix);else this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix);this.matrixWorldNeedsUpdate=!1,t=!0}let e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].updateMatrixWorld(t)}updateWorldMatrix(t,e,n=!1){let i=this.parent;if(t===!0&&i!==null)i.updateWorldMatrix(!0,!1);if(this.matrixAutoUpdate)this.updateMatrix();if(this.matrixWorldNeedsUpdate||n){if(this.matrixWorldAutoUpdate===!0)if(this.parent===null)this.matrixWorld.copy(this.matrix);else this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix);this.matrixWorldNeedsUpdate=!1,n=!0}if(e===!0){let s=this.children;for(let r=0,a=s.length;r<a;r++)s[r].updateWorldMatrix(!1,!0,n)}}toJSON(t){let e=t===void 0||typeof t==="string",n={};if(e)t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"};let i={};if(i.uuid=this.uuid,i.type=this.type,i.name=this.name,i.castShadow=this.castShadow,i.receiveShadow=this.receiveShadow,i.visible=this.visible,i.frustumCulled=this.frustumCulled,i.renderOrder=this.renderOrder,i.static=this.static,i.matrixAutoUpdate=this.matrixAutoUpdate,Object.keys(this.userData).length>0)i.userData=this.userData;if(i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.pivot!==null)i.pivot=this.pivot.toArray();if(this.morphTargetDictionary!==void 0)i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary);if(this.morphTargetInfluences!==void 0)i.morphTargetInfluences=this.morphTargetInfluences.slice();if(this.isInstancedMesh){if(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null)i.instanceColor=this.instanceColor.toJSON()}if(this.isBatchedMesh){if(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map((a)=>({...a,boundingBox:a.boundingBox?a.boundingBox.toJSON():void 0,boundingSphere:a.boundingSphere?a.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map((a)=>({...a})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(t),i.indirectTexture=this._indirectTexture.toJSON(t),this._colorsTexture!==null)i.colorsTexture=this._colorsTexture.toJSON(t);if(this.boundingSphere!==null)i.boundingSphere=this.boundingSphere.toJSON();if(this.boundingBox!==null)i.boundingBox=this.boundingBox.toJSON()}function s(a,o){if(a[o.uuid]===void 0)a[o.uuid]=o.toJSON(t);return o.uuid}if(this.isScene){if(this.background){if(this.background.isColor)i.background=this.background.toJSON();else if(this.background.isTexture)i.background=this.background.toJSON(t).uuid}if(this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0)i.environment=this.environment.toJSON(t).uuid}else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(t.geometries,this.geometry);let a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){let o=a.shapes;if(Array.isArray(o))for(let l=0,c=o.length;l<c;l++){let u=o[l];s(t.shapes,u)}else s(t.shapes,o)}}if(this.isSkinnedMesh){if(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0)s(t.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid}if(this.material!==void 0)if(Array.isArray(this.material)){let a=[];for(let o=0,l=this.material.length;o<l;o++)a.push(s(t.materials,this.material[o]));i.material=a}else i.material=s(t.materials,this.material);if(this.children.length>0){i.children=[];for(let a=0;a<this.children.length;a++)i.children.push(this.children[a].toJSON(t).object)}if(this.animations.length>0){i.animations=[];for(let a=0;a<this.animations.length;a++){let o=this.animations[a];i.animations.push(s(t.animations,o))}}if(e){let a=r(t.geometries),o=r(t.materials),l=r(t.textures),c=r(t.images),u=r(t.shapes),d=r(t.skeletons),h=r(t.animations),p=r(t.nodes);if(a.length>0)n.geometries=a;if(o.length>0)n.materials=o;if(l.length>0)n.textures=l;if(c.length>0)n.images=c;if(u.length>0)n.shapes=u;if(d.length>0)n.skeletons=d;if(h.length>0)n.animations=h;if(p.length>0)n.nodes=p}return n.object=i,n;function r(a){let o=[];for(let l in a){let c=a[l];delete c.metadata,o.push(c)}return o}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.pivot=t.pivot!==null?t.pivot.clone():null,this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.static=t.static,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let n=0;n<t.children.length;n++){let i=t.children[n];this.add(i.clone())}return this}dispose(){this.dispatchEvent({type:"dispose"})}}He.DEFAULT_UP=new O(0,1,0);He.DEFAULT_MATRIX_AUTO_UPDATE=!0;He.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class Xe extends He{constructor(){super();this.isGroup=!0,this.type="Group"}}var Xu={type:"move"};class er{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){if(this._hand===null)this._hand=new Xe,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1};return this._hand}getTargetRaySpace(){if(this._targetRay===null)this._targetRay=new Xe,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new O,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new O;return this._targetRay}getGripSpace(){if(this._grip===null)this._grip=new Xe,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new O,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new O,this._grip.eventsEnabled=!1;return this._grip}dispatchEvent(t){if(this._targetRay!==null)this._targetRay.dispatchEvent(t);if(this._grip!==null)this._grip.dispatchEvent(t);if(this._hand!==null)this._hand.dispatchEvent(t);return this}connect(t){if(t&&t.hand){let e=this._hand;if(e)for(let n of t.hand.values())this._getHandJoint(e,n)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){if(this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null)this._targetRay.visible=!1;if(this._grip!==null)this._grip.visible=!1;if(this._hand!==null)this._hand.visible=!1;return this}update(t,e,n){let i=null,s=null,r=null,a=this._targetRay,o=this._grip,l=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(l&&t.hand){r=!0;for(let v of t.hand.values()){let T=e.getJointPose(v,n),m=this._getHandJoint(l,v);if(T!==null)m.matrix.fromArray(T.transform.matrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.matrixWorldNeedsUpdate=!0,m.jointRadius=T.radius;m.visible=T!==null}let c=l.joints["index-finger-tip"],u=l.joints["thumb-tip"],d=c.position.distanceTo(u.position),h=0.02,p=0.005;if(l.inputState.pinching&&d>h+p)l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this});else if(!l.inputState.pinching&&d<=h-p)l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this})}else if(o!==null&&t.gripSpace){if(s=e.getPose(t.gripSpace,n),s!==null){if(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,s.linearVelocity)o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity);else o.hasLinearVelocity=!1;if(s.angularVelocity)o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity);else o.hasAngularVelocity=!1;if(o.eventsEnabled)o.dispatchEvent({type:"gripUpdated",data:t,target:this})}}if(a!==null){if(i=e.getPose(t.targetRaySpace,n),i===null&&s!==null)i=s;if(i!==null){if(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,i.linearVelocity)a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity);else a.hasLinearVelocity=!1;if(i.angularVelocity)a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity);else a.hasAngularVelocity=!1;this.dispatchEvent(Xu)}}}if(a!==null)a.visible=i!==null;if(o!==null)o.visible=s!==null;if(l!==null)l.visible=r!==null;return this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){let n=new Xe;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}}var vh={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},li={h:0,s:0,l:0},yr={h:0,s:0,l:0};function La(t,e,n){if(n<0)n+=1;if(n>1)n-=1;if(n<0.16666666666666666)return t+(e-t)*6*n;if(n<0.5)return e;if(n<0.6666666666666666)return t+(e-t)*6*(0.6666666666666666-n);return t}class Kt{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(e===void 0&&n===void 0){let i=t;if(i&&i.isColor)this.copy(i);else if(typeof i==="number")this.setHex(i);else if(typeof i==="string")this.setStyle(i)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e="srgb"){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,re.colorSpaceToWorking(this,e),this}setRGB(t,e,n,i=re.workingColorSpace){return this.r=t,this.g=e,this.b=n,re.colorSpaceToWorking(this,i),this}setHSL(t,e,n,i=re.workingColorSpace){if(t=Uu(t,1),e=oe(e,0,1),n=oe(n,0,1),e===0)this.r=this.g=this.b=n;else{let s=n<=0.5?n*(1+e):n+e-n*e,r=2*n-s;this.r=La(r,s,t+0.3333333333333333),this.g=La(r,s,t),this.b=La(r,s,t-0.3333333333333333)}return re.colorSpaceToWorking(this,i),this}setStyle(t,e="srgb"){function n(s){if(s===void 0)return;if(parseFloat(s)<1)Vt("Color: Alpha component of "+t+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(t)){let s,r=i[1],a=i[2];switch(r){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,e);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,e);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,e);break;default:Vt("Color: Unknown color model "+t)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(t)){let s=i[1],r=s.length;if(r===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,e);else if(r===6)return this.setHex(parseInt(s,16),e);else Vt("Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e="srgb"){let n=vh[t.toLowerCase()];if(n!==void 0)this.setHex(n,e);else Vt("Color: Unknown color "+t);return this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=$n(t.r),this.g=$n(t.g),this.b=$n(t.b),this}copyLinearToSRGB(t){return this.r=ms(t.r),this.g=ms(t.g),this.b=ms(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t="srgb"){return re.workingToColorSpace(Ke.copy(this),t),Math.round(oe(Ke.r*255,0,255))*65536+Math.round(oe(Ke.g*255,0,255))*256+Math.round(oe(Ke.b*255,0,255))}getHexString(t="srgb"){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=re.workingColorSpace){re.workingToColorSpace(Ke.copy(this),e);let{r:n,g:i,b:s}=Ke,r=Math.max(n,i,s),a=Math.min(n,i,s),o,l,c=(a+r)/2;if(a===r)o=0,l=0;else{let u=r-a;switch(l=c<=0.5?u/(r+a):u/(2-r-a),r){case n:o=(i-s)/u+(i<s?6:0);break;case i:o=(s-n)/u+2;break;case s:o=(n-i)/u+4;break}o/=6}return t.h=o,t.s=l,t.l=c,t}getRGB(t,e=re.workingColorSpace){return re.workingToColorSpace(Ke.copy(this),e),t.r=Ke.r,t.g=Ke.g,t.b=Ke.b,t}getStyle(t="srgb"){re.workingToColorSpace(Ke.copy(this),t);let{r:e,g:n,b:i}=Ke;if(t!=="srgb")return`color(${t} ${e.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`;return`rgb(${Math.round(e*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(t,e,n){return this.getHSL(li),this.setHSL(li.h+t,li.s+e,li.l+n)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,n){return this.r=t.r+(e.r-t.r)*n,this.g=t.g+(e.g-t.g)*n,this.b=t.b+(e.b-t.b)*n,this}lerpHSL(t,e){this.getHSL(li),t.getHSL(yr);let n=Ea(li.h,yr.h,e),i=Ea(li.s,yr.s,e),s=Ea(li.l,yr.l,e);return this.setHSL(n,i,s),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){let e=this.r,n=this.g,i=this.b,s=t.elements;return this.r=s[0]*e+s[3]*n+s[6]*i,this.g=s[1]*e+s[4]*n+s[7]*i,this.b=s[2]*e+s[5]*n+s[8]*i,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}var Ke=new Kt;Kt.NAMES=vh;class nr{constructor(t,e=1,n=1000){this.isFog=!0,this.name="",this.color=new Kt(t),this.near=e,this.far=n}clone(){return new nr(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class na extends He{constructor(){super();if(this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new fi,this.environmentIntensity=1,this.environmentRotation=new fi,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){if(super.copy(t,e),t.background!==null)this.background=t.background.clone();if(t.environment!==null)this.environment=t.environment.clone();if(t.fog!==null)this.fog=t.fog.clone();if(this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,this.backgroundRotation.copy(t.backgroundRotation),this.environmentIntensity=t.environmentIntensity,this.environmentRotation.copy(t.environmentRotation),t.overrideMaterial!==null)this.overrideMaterial=t.overrideMaterial.clone();return this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){let e=super.toJSON(t);if(this.fog!==null)e.object.fog=this.fog.toJSON();return e.object.backgroundBlurriness=this.backgroundBlurriness,e.object.backgroundIntensity=this.backgroundIntensity,e.object.backgroundRotation=this.backgroundRotation.toArray(),e.object.environmentIntensity=this.environmentIntensity,e.object.environmentRotation=this.environmentRotation.toArray(),e}}var An=new O,qn=new O,Na=new O,Yn=new O,Ki=new O,Qi=new O,ac=new O,Da=new O,Ua=new O,Fa=new O,Oa=new Ae,Ba=new Ae,za=new Ae;class pn{constructor(t=new O,e=new O,n=new O){this.a=t,this.b=e,this.c=n}static getNormal(t,e,n,i){i.subVectors(n,e),An.subVectors(t,e),i.cross(An);let s=i.lengthSq();if(s>0)return i.multiplyScalar(1/Math.sqrt(s));return i.set(0,0,0)}static getBarycoord(t,e,n,i,s){An.subVectors(i,e),qn.subVectors(n,e),Na.subVectors(t,e);let r=An.dot(An),a=An.dot(qn),o=An.dot(Na),l=qn.dot(qn),c=qn.dot(Na),u=r*l-a*a;if(u===0)return s.set(0,0,0),null;let d=1/u,h=(l*o-a*c)*d,p=(r*c-a*o)*d;return s.set(1-h-p,p,h)}static containsPoint(t,e,n,i){if(this.getBarycoord(t,e,n,i,Yn)===null)return!1;return Yn.x>=0&&Yn.y>=0&&Yn.x+Yn.y<=1}static getInterpolation(t,e,n,i,s,r,a,o){if(this.getBarycoord(t,e,n,i,Yn)===null){if(o.x=0,o.y=0,"z"in o)o.z=0;if("w"in o)o.w=0;return null}return o.setScalar(0),o.addScaledVector(s,Yn.x),o.addScaledVector(r,Yn.y),o.addScaledVector(a,Yn.z),o}static getInterpolatedAttribute(t,e,n,i,s,r){return Oa.setScalar(0),Ba.setScalar(0),za.setScalar(0),Oa.fromBufferAttribute(t,e),Ba.fromBufferAttribute(t,n),za.fromBufferAttribute(t,i),r.setScalar(0),r.addScaledVector(Oa,s.x),r.addScaledVector(Ba,s.y),r.addScaledVector(za,s.z),r}static isFrontFacing(t,e,n,i){return An.subVectors(n,e),qn.subVectors(t,e),An.cross(qn).dot(i)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,i){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[i]),this}setFromAttributeAndIndices(t,e,n,i){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,i),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return An.subVectors(this.c,this.b),qn.subVectors(this.a,this.b),An.cross(qn).length()*0.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(0.3333333333333333)}getNormal(t){return pn.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return pn.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,i,s){return pn.getInterpolation(t,this.a,this.b,this.c,e,n,i,s)}containsPoint(t){return pn.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return pn.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){let n=this.a,i=this.b,s=this.c,r,a;Ki.subVectors(i,n),Qi.subVectors(s,n),Da.subVectors(t,n);let o=Ki.dot(Da),l=Qi.dot(Da);if(o<=0&&l<=0)return e.copy(n);Ua.subVectors(t,i);let c=Ki.dot(Ua),u=Qi.dot(Ua);if(c>=0&&u<=c)return e.copy(i);let d=o*u-c*l;if(d<=0&&o>=0&&c<=0)return r=o/(o-c),e.copy(n).addScaledVector(Ki,r);Fa.subVectors(t,s);let h=Ki.dot(Fa),p=Qi.dot(Fa);if(p>=0&&h<=p)return e.copy(s);let v=h*l-o*p;if(v<=0&&l>=0&&p<=0)return a=l/(l-p),e.copy(n).addScaledVector(Qi,a);let T=c*p-h*u;if(T<=0&&u-c>=0&&h-p>=0)return ac.subVectors(s,i),a=(u-c)/(u-c+(h-p)),e.copy(i).addScaledVector(ac,a);let m=1/(T+v+d);return r=v*m,a=d*m,e.copy(n).addScaledVector(Ki,r).addScaledVector(Qi,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}class Di{constructor(t=new O(1/0,1/0,1/0),e=new O(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e+=3)this.expandByPoint(Cn.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,n=t.count;e<n;e++)this.expandByPoint(Cn.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){let n=Cn.copy(e).multiplyScalar(0.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(0.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);let n=t.geometry;if(n!==void 0){let s=n.getAttribute("position");if(e===!0&&s!==void 0&&t.isInstancedMesh!==!0)for(let r=0,a=s.count;r<a;r++){if(t.isMesh===!0)t.getVertexPosition(r,Cn);else Cn.fromBufferAttribute(s,r);Cn.applyMatrix4(t.matrixWorld),this.expandByPoint(Cn)}else{if(t.boundingBox!==void 0){if(t.boundingBox===null)t.computeBoundingBox();Sr.copy(t.boundingBox)}else{if(n.boundingBox===null)n.computeBoundingBox();Sr.copy(n.boundingBox)}Sr.applyMatrix4(t.matrixWorld),this.union(Sr)}}let i=t.children;for(let s=0,r=i.length;s<r;s++)this.expandByObject(i[s],e);return this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,Cn),Cn.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;if(t.normal.x>0)e=t.normal.x*this.min.x,n=t.normal.x*this.max.x;else e=t.normal.x*this.max.x,n=t.normal.x*this.min.x;if(t.normal.y>0)e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y;else e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y;if(t.normal.z>0)e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z;else e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z;return e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Cs),Mr.subVectors(this.max,Cs),ji.subVectors(t.a,Cs),ss.subVectors(t.b,Cs),as.subVectors(t.c,Cs),ci.subVectors(ss,ji),hi.subVectors(as,ss),Mi.subVectors(ji,as);let e=[0,-ci.z,ci.y,0,-hi.z,hi.y,0,-Mi.z,Mi.y,ci.z,0,-ci.x,hi.z,0,-hi.x,Mi.z,0,-Mi.x,-ci.y,ci.x,0,-hi.y,hi.x,0,-Mi.y,Mi.x,0];if(!ka(e,ji,ss,as,Mr))return!1;if(e=[1,0,0,0,1,0,0,0,1],!ka(e,ji,ss,as,Mr))return!1;return br.crossVectors(ci,hi),e=[br.x,br.y,br.z],ka(e,ji,ss,as,Mr)}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Cn).distanceTo(t)}getBoundingSphere(t){if(this.isEmpty())t.makeEmpty();else this.getCenter(t.center),t.radius=this.getSize(Cn).length()*0.5;return t}intersect(t){if(this.min.max(t.min),this.max.min(t.max),this.isEmpty())this.makeEmpty();return this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){if(this.isEmpty())return this;return Zn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Zn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Zn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Zn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Zn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Zn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Zn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Zn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Zn),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(t){return this.min.fromArray(t.min),this.max.fromArray(t.max),this}}var Zn=[new O,new O,new O,new O,new O,new O,new O,new O],Cn=new O,Sr=new Di,ji=new O,ss=new O,as=new O,ci=new O,hi=new O,Mi=new O,Cs=new O,Mr=new O,br=new O,bi=new O;function ka(t,e,n,i,s){for(let r=0,a=t.length-3;r<=a;r+=3){bi.fromArray(t,r);let o=s.x*Math.abs(bi.x)+s.y*Math.abs(bi.y)+s.z*Math.abs(bi.z),l=e.dot(bi),c=n.dot(bi),u=i.dot(bi);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>o)return!1}return!0}var Oe=new O,Tr=new qt,qu=0;class Mn extends ti{constructor(t,e,n=!1){super();if(Array.isArray(t))throw TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:qu++}),this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=n,this.usage=35044,this.updateRanges=[],this.gpuType=1015,this.version=0}onUploadCallback(){}set needsUpdate(t){if(t===!0)this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let i=0,s=this.itemSize;i<s;i++)this.array[t+i]=e.array[n+i];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,n=this.count;e<n;e++)Tr.fromBufferAttribute(this,e),Tr.applyMatrix3(t),this.setXY(e,Tr.x,Tr.y);else if(this.itemSize===3)for(let e=0,n=this.count;e<n;e++)Oe.fromBufferAttribute(this,e),Oe.applyMatrix3(t),this.setXYZ(e,Oe.x,Oe.y,Oe.z);return this}applyMatrix4(t){for(let e=0,n=this.count;e<n;e++)Oe.fromBufferAttribute(this,e),Oe.applyMatrix4(t),this.setXYZ(e,Oe.x,Oe.y,Oe.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)Oe.fromBufferAttribute(this,e),Oe.applyNormalMatrix(t),this.setXYZ(e,Oe.x,Oe.y,Oe.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)Oe.fromBufferAttribute(this,e),Oe.transformDirection(t),this.setXYZ(e,Oe.x,Oe.y,Oe.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let n=this.array[t*this.itemSize+e];if(this.normalized)n=Fn(n,this.array);return n}setComponent(t,e,n){if(this.normalized)n=xe(n,this.array);return this.array[t*this.itemSize+e]=n,this}getX(t){let e=this.array[t*this.itemSize];if(this.normalized)e=Fn(e,this.array);return e}setX(t,e){if(this.normalized)e=xe(e,this.array);return this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];if(this.normalized)e=Fn(e,this.array);return e}setY(t,e){if(this.normalized)e=xe(e,this.array);return this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];if(this.normalized)e=Fn(e,this.array);return e}setZ(t,e){if(this.normalized)e=xe(e,this.array);return this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];if(this.normalized)e=Fn(e,this.array);return e}setW(t,e){if(this.normalized)e=xe(e,this.array);return this.array[t*this.itemSize+3]=e,this}setXY(t,e,n){if(t*=this.itemSize,this.normalized)e=xe(e,this.array),n=xe(n,this.array);return this.array[t+0]=e,this.array[t+1]=n,this}setXYZ(t,e,n,i){if(t*=this.itemSize,this.normalized)e=xe(e,this.array),n=xe(n,this.array),i=xe(i,this.array);return this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this}setXYZW(t,e,n,i,s){if(t*=this.itemSize,this.normalized)e=xe(e,this.array),n=xe(n,this.array),i=xe(i,this.array),s=xe(s,this.array);return this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this.array[t+3]=s,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return t.name=this.name,t.usage=this.usage,t.gpuType=this.gpuType,t}dispose(){this.dispatchEvent({type:"dispose"})}}class ia extends Mn{constructor(t,e,n){super(new Uint16Array(t),e,n)}}class sa extends Mn{constructor(t,e,n){super(new Uint32Array(t),e,n)}}class Ye extends Mn{constructor(t,e,n){super(new Float32Array(t),e,n)}}var Yu=new Di,Rs=new O,Ga=new O;class ir{constructor(t=new O,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){let n=this.center;if(e!==void 0)n.copy(e);else Yu.setFromPoints(t).getCenter(n);let i=0;for(let s=0,r=t.length;s<r;s++)i=Math.max(i,n.distanceToSquared(t[s]));return this.radius=Math.sqrt(i),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){let e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){let n=this.center.distanceToSquared(t);if(e.copy(t),n>this.radius*this.radius)e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center);return e}getBoundingBox(t){if(this.isEmpty())return t.makeEmpty(),t;return t.set(this.center,this.center),t.expandByScalar(this.radius),t}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;Rs.subVectors(t,this.center);let e=Rs.lengthSq();if(e>this.radius*this.radius){let n=Math.sqrt(e),i=(n-this.radius)*0.5;this.center.addScaledVector(Rs,i/n),this.radius+=i}return this}union(t){if(t.isEmpty())return this;if(this.isEmpty())return this.copy(t),this;if(this.center.equals(t.center)===!0)this.radius=Math.max(this.radius,t.radius);else Ga.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Rs.copy(t.center).add(Ga)),this.expandByPoint(Rs.copy(t.center).sub(Ga));return this}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(t){return this.radius=t.radius,this.center.fromArray(t.center),this}}var Zu=0,Sn=new we,Ha=new He,os=new O,fn=new Di,Ps=new Di,Ge=new O;class _n extends ti{constructor(){super();this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Zu++}),this.uuid=di(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(t){if(Array.isArray(t))this.index=new((Nu(t))?sa:ia)(t,1);else this.index=t;return this}setIndirect(t,e=0){return this.indirect=t,this.indirectOffset=e,this}getIndirect(){return this.indirect}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,n=0){this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){let e=this.attributes.position;if(e!==void 0)e.applyMatrix4(t),e.needsUpdate=!0;let n=this.attributes.normal;if(n!==void 0){let s=new Yt().getNormalMatrix(t);n.applyNormalMatrix(s),n.needsUpdate=!0}let i=this.attributes.tangent;if(i!==void 0)i.transformDirection(t),i.needsUpdate=!0;if(this.boundingBox!==null)this.computeBoundingBox();if(this.boundingSphere!==null)this.computeBoundingSphere();return this._transformed=!0,this}applyQuaternion(t){return Sn.makeRotationFromQuaternion(t),this.applyMatrix4(Sn),this}rotateX(t){return Sn.makeRotationX(t),this.applyMatrix4(Sn),this}rotateY(t){return Sn.makeRotationY(t),this.applyMatrix4(Sn),this}rotateZ(t){return Sn.makeRotationZ(t),this.applyMatrix4(Sn),this}translate(t,e,n){return Sn.makeTranslation(t,e,n),this.applyMatrix4(Sn),this}scale(t,e,n){return Sn.makeScale(t,e,n),this.applyMatrix4(Sn),this}lookAt(t){return Ha.lookAt(t),Ha.updateMatrix(),this.applyMatrix4(Ha.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(os).negate(),this.translate(os.x,os.y,os.z),this}setFromPoints(t){let e=this.getAttribute("position");if(e===void 0){let n=[];for(let i=0,s=t.length;i<s;i++){let r=t[i];n.push(r.x,r.y,r.z||0)}this.setAttribute("position",new Ye(n,3))}else{let n=Math.min(t.length,e.count);for(let i=0;i<n;i++){let s=t[i];e.setXYZ(i,s.x,s.y,s.z||0)}if(t.length>e.count)Vt("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.");e.needsUpdate=!0}return this}computeBoundingBox(){if(this.boundingBox===null)this.boundingBox=new Di;let t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){Ht("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new O(-1/0,-1/0,-1/0),new O(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let n=0,i=e.length;n<i;n++){let s=e[n];if(fn.setFromBufferAttribute(s),this.morphTargetsRelative)Ge.addVectors(this.boundingBox.min,fn.min),this.boundingBox.expandByPoint(Ge),Ge.addVectors(this.boundingBox.max,fn.max),this.boundingBox.expandByPoint(Ge);else this.boundingBox.expandByPoint(fn.min),this.boundingBox.expandByPoint(fn.max)}}else this.boundingBox.makeEmpty();if(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))Ht('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){if(this.boundingSphere===null)this.boundingSphere=new ir;let t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){Ht("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new O,1/0);return}if(t){let n=this.boundingSphere.center;if(fn.setFromBufferAttribute(t),e)for(let s=0,r=e.length;s<r;s++){let a=e[s];if(Ps.setFromBufferAttribute(a),this.morphTargetsRelative)Ge.addVectors(fn.min,Ps.min),fn.expandByPoint(Ge),Ge.addVectors(fn.max,Ps.max),fn.expandByPoint(Ge);else fn.expandByPoint(Ps.min),fn.expandByPoint(Ps.max)}fn.getCenter(n);let i=0;for(let s=0,r=t.count;s<r;s++)Ge.fromBufferAttribute(t,s),i=Math.max(i,n.distanceToSquared(Ge));if(e)for(let s=0,r=e.length;s<r;s++){let a=e[s],o=this.morphTargetsRelative;for(let l=0,c=a.count;l<c;l++){if(Ge.fromBufferAttribute(a,l),o)os.fromBufferAttribute(t,l),Ge.add(os);i=Math.max(i,n.distanceToSquared(Ge))}}if(this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius))Ht('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){Ht("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let{position:n,normal:i,uv:s}=e,r=this.getAttribute("tangent");if(r===void 0||r.count!==n.count)r=new Mn(new Float32Array(4*n.count),4),this.setAttribute("tangent",r);let a=[],o=[];for(let E=0;E<n.count;E++)a[E]=new O,o[E]=new O;let l=new O,c=new O,u=new O,d=new qt,h=new qt,p=new qt,v=new O,T=new O;function m(E,g,M){l.fromBufferAttribute(n,E),c.fromBufferAttribute(n,g),u.fromBufferAttribute(n,M),d.fromBufferAttribute(s,E),h.fromBufferAttribute(s,g),p.fromBufferAttribute(s,M),c.sub(l),u.sub(l),h.sub(d),p.sub(d);let G=1/(h.x*p.y-p.x*h.y);if(!isFinite(G))return;v.copy(c).multiplyScalar(p.y).addScaledVector(u,-h.y).multiplyScalar(G),T.copy(u).multiplyScalar(h.x).addScaledVector(c,-p.x).multiplyScalar(G),a[E].add(v),a[g].add(v),a[M].add(v),o[E].add(T),o[g].add(T),o[M].add(T)}let f=this.groups;if(f.length===0)f=[{start:0,count:t.count}];for(let E=0,g=f.length;E<g;++E){let M=f[E],{start:G,count:N}=M;for(let F=G,X=G+N;F<X;F+=3)m(t.getX(F+0),t.getX(F+1),t.getX(F+2))}let w=new O,C=new O,y=new O,b=new O;function A(E){y.fromBufferAttribute(i,E),b.copy(y);let g=a[E];w.copy(g),w.sub(y.multiplyScalar(y.dot(g))).normalize(),C.crossVectors(b,g);let G=C.dot(o[E])<0?-1:1;r.setXYZW(E,w.x,w.y,w.z,G)}for(let E=0,g=f.length;E<g;++E){let M=f[E],{start:G,count:N}=M;for(let F=G,X=G+N;F<X;F+=3)A(t.getX(F+0)),A(t.getX(F+1)),A(t.getX(F+2))}this._transformed=!0}computeVertexNormals(){let t=this.index,e=this.getAttribute("position");if(e!==void 0){let n=this.getAttribute("normal");if(n===void 0||n.count!==e.count)n=new Mn(new Float32Array(e.count*3),3),this.setAttribute("normal",n);else for(let d=0,h=n.count;d<h;d++)n.setXYZ(d,0,0,0);let i=new O,s=new O,r=new O,a=new O,o=new O,l=new O,c=new O,u=new O;if(t)for(let d=0,h=t.count;d<h;d+=3){let p=t.getX(d+0),v=t.getX(d+1),T=t.getX(d+2);i.fromBufferAttribute(e,p),s.fromBufferAttribute(e,v),r.fromBufferAttribute(e,T),c.subVectors(r,s),u.subVectors(i,s),c.cross(u),a.fromBufferAttribute(n,p),o.fromBufferAttribute(n,v),l.fromBufferAttribute(n,T),a.add(c),o.add(c),l.add(c),n.setXYZ(p,a.x,a.y,a.z),n.setXYZ(v,o.x,o.y,o.z),n.setXYZ(T,l.x,l.y,l.z)}else for(let d=0,h=e.count;d<h;d+=3)i.fromBufferAttribute(e,d+0),s.fromBufferAttribute(e,d+1),r.fromBufferAttribute(e,d+2),c.subVectors(r,s),u.subVectors(i,s),c.cross(u),n.setXYZ(d+0,c.x,c.y,c.z),n.setXYZ(d+1,c.x,c.y,c.z),n.setXYZ(d+2,c.x,c.y,c.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let t=this.attributes.normal;for(let e=0,n=t.count;e<n;e++)Ge.fromBufferAttribute(t,e),Ge.normalize(),t.setXYZ(e,Ge.x,Ge.y,Ge.z)}toNonIndexed(){function t(a,o){let{array:l,itemSize:c,normalized:u}=a,d=new l.constructor(o.length*c),h=0,p=0;for(let v=0,T=o.length;v<T;v++){if(a.isInterleavedBufferAttribute)h=o[v]*a.data.stride+a.offset;else h=o[v]*c;for(let m=0;m<c;m++)d[p++]=l[h++]}return new Mn(d,c,u)}if(this.index===null)return Vt("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let e=new _n,n=this.index.array,i=this.attributes;for(let a in i){let o=i[a],l=t(o,n);e.setAttribute(a,l)}let s=this.morphAttributes;for(let a in s){let o=[],l=s[a];for(let c=0,u=l.length;c<u;c++){let d=l[c],h=t(d,n);o.push(h)}e.morphAttributes[a]=o}e.morphTargetsRelative=this.morphTargetsRelative;let r=this.groups;for(let a=0,o=r.length;a<o;a++){let l=r[a];e.addGroup(l.start,l.count,l.materialIndex)}return e}toJSON(){let t={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,t.name=this.name,Object.keys(this.userData).length>0)t.userData=this.userData;if(this.parameters!==void 0&&this._transformed!==!0){let o=this.parameters;for(let l in o)if(o[l]!==void 0)t[l]=o[l];return t}t.data={attributes:{}};let e=this.index;if(e!==null)t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)};let n=this.attributes;for(let o in n){let l=n[o];t.data.attributes[o]=l.toJSON(t.data)}let i={},s=!1;for(let o in this.morphAttributes){let l=this.morphAttributes[o],c=[];for(let u=0,d=l.length;u<d;u++){let h=l[u];c.push(h.toJSON(t.data))}if(c.length>0)i[o]=c,s=!0}if(s)t.data.morphAttributes=i,t.data.morphTargetsRelative=this.morphTargetsRelative;let r=this.groups;if(r.length>0)t.data.groups=JSON.parse(JSON.stringify(r));let a=this.boundingSphere;if(a!==null)t.data.boundingSphere=a.toJSON();return t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let e={};this.name=t.name;let n=t.index;if(n!==null)this.setIndex(n.clone());let i=t.attributes;for(let l in i){let c=i[l];this.setAttribute(l,c.clone(e))}let s=t.morphAttributes;for(let l in s){let c=[],u=s[l];for(let d=0,h=u.length;d<h;d++)c.push(u[d].clone(e));this.morphAttributes[l]=c}this.morphTargetsRelative=t.morphTargetsRelative;let r=t.groups;for(let l=0,c=r.length;l<c;l++){let u=r[l];this.addGroup(u.start,u.count,u.materialIndex)}let a=t.boundingBox;if(a!==null)this.boundingBox=a.clone();let o=t.boundingSphere;if(o!==null)this.boundingSphere=o.clone();return this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this._transformed=t._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}class el{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=35044,this.updateRanges=[],this.version=0,this.uuid=di()}onUploadCallback(){}set needsUpdate(t){if(t===!0)this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,n){t*=this.stride,n*=e.stride;for(let i=0,s=this.stride;i<s;i++)this.array[t+i]=e.array[n+i];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){if(t.arrayBuffers===void 0)t.arrayBuffers={};if(this.array.buffer._uuid===void 0)this.array.buffer._uuid=di();if(t.arrayBuffers[this.array.buffer._uuid]===void 0)t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer;let e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(e,this.stride);return n.setUsage(this.usage),n}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){if(t.arrayBuffers===void 0)t.arrayBuffers={};if(this.array.buffer._uuid===void 0)this.array.buffer._uuid=di();if(t.arrayBuffers[this.array.buffer._uuid]===void 0)t.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer));let e={uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride};return e.usage=this.usage,e}}var en=new O;class Hs{constructor(t,e,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,n=this.data.count;e<n;e++)en.fromBufferAttribute(this,e),en.applyMatrix4(t),this.setXYZ(e,en.x,en.y,en.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)en.fromBufferAttribute(this,e),en.applyNormalMatrix(t),this.setXYZ(e,en.x,en.y,en.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)en.fromBufferAttribute(this,e),en.transformDirection(t),this.setXYZ(e,en.x,en.y,en.z);return this}getComponent(t,e){let n=this.array[t*this.data.stride+this.offset+e];if(this.normalized)n=Fn(n,this.array);return n}setComponent(t,e,n){if(this.normalized)n=xe(n,this.array);return this.data.array[t*this.data.stride+this.offset+e]=n,this}setX(t,e){if(this.normalized)e=xe(e,this.array);return this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){if(this.normalized)e=xe(e,this.array);return this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){if(this.normalized)e=xe(e,this.array);return this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){if(this.normalized)e=xe(e,this.array);return this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];if(this.normalized)e=Fn(e,this.array);return e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];if(this.normalized)e=Fn(e,this.array);return e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];if(this.normalized)e=Fn(e,this.array);return e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];if(this.normalized)e=Fn(e,this.array);return e}setXY(t,e,n){if(t=t*this.data.stride+this.offset,this.normalized)e=xe(e,this.array),n=xe(n,this.array);return this.data.array[t+0]=e,this.data.array[t+1]=n,this}setXYZ(t,e,n,i){if(t=t*this.data.stride+this.offset,this.normalized)e=xe(e,this.array),n=xe(n,this.array),i=xe(i,this.array);return this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this}setXYZW(t,e,n,i,s){if(t=t*this.data.stride+this.offset,this.normalized)e=xe(e,this.array),n=xe(n,this.array),i=xe(i,this.array),s=xe(s,this.array);return this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this.data.array[t+3]=s,this}clone(t){if(t===void 0){ks("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let e=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[i+s])}return new Mn(new this.array.constructor(e),this.itemSize,this.normalized)}else{if(t.interleavedBuffers===void 0)t.interleavedBuffers={};if(t.interleavedBuffers[this.data.uuid]===void 0)t.interleavedBuffers[this.data.uuid]=this.data.clone(t);return new Hs(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}}toJSON(t){if(t===void 0){ks("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let e=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[i+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else{if(t.interleavedBuffers===void 0)t.interleavedBuffers={};if(t.interleavedBuffers[this.data.uuid]===void 0)t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t);return{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}}var Va=new O,Ju=new O,$u=new Yt;class Un{constructor(t=new O(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,n,i){return this.normal.set(t,e,n),this.constant=i,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){let i=Va.subVectors(n,e).cross(Ju.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(i,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){let t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e,n=!0){let i=t.delta(Va),s=this.normal.dot(i);if(s===0){if(this.distanceToPoint(t.start)===0)return e.copy(t.start);return null}let r=-(t.start.dot(this.normal)+this.constant)/s;if(n===!0&&(r<0||r>1))return null;return e.copy(t.start).addScaledVector(i,r)}intersectsLine(t){let e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){let n=e||$u.getNormalMatrix(t),i=this.coplanarPoint(Va).applyMatrix4(t),s=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(s),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}toJSON(){return{normal:this.normal.toArray(),constant:this.constant}}fromJSON(t){return this.normal.fromArray(t.normal),this.constant=t.constant,this}}var Ku=0;class _i extends ti{constructor(){super();this.isMaterial=!0,Object.defineProperty(this,"id",{value:Ku++}),this.uuid=di(),this.name="",this.type="Material",this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Kt(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=7680,this.stencilZFail=7680,this.stencilZPass=7680,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){if(this._alphaTest>0!==t>0)this.version++;this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t===void 0)return;for(let e in t){let n=t[e];if(n===void 0){Vt(`Material: parameter '${e}' has value of undefined.`);continue}let i=this[e];if(i===void 0){Vt(`Material: '${e}' is not a property of THREE.${this.type}.`);continue}if(i&&i.isColor)i.set(n);else if(i&&i.isVector2&&(n&&n.isVector2)||i&&i.isEuler&&(n&&n.isEuler)||i&&i.isVector3&&(n&&n.isVector3))i.copy(n);else this[e]=n}}toJSON(t){let e=t===void 0||typeof t==="string";if(e)t={textures:{},images:{}};let n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};if(n.uuid=this.uuid,n.type=this.type,n.blending=this.blending,n.side=this.side,n.shadowSide=this.shadowSide,n.vertexColors=this.vertexColors,n.opacity=this.opacity,n.transparent=this.transparent,n.blendSrc=this.blendSrc,n.blendDst=this.blendDst,n.blendEquation=this.blendEquation,n.blendSrcAlpha=this.blendSrcAlpha,n.blendDstAlpha=this.blendDstAlpha,n.blendEquationAlpha=this.blendEquationAlpha,n.blendColor=this.blendColor.getHex(),n.blendAlpha=this.blendAlpha,n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.clipIntersection=this.clipIntersection,n.clipShadows=this.clipShadows,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,n.stencilWrite=this.stencilWrite,n.polygonOffset=this.polygonOffset,n.polygonOffsetFactor=this.polygonOffsetFactor,n.polygonOffsetUnits=this.polygonOffsetUnits,n.dithering=this.dithering,n.alphaTest=this.alphaTest,n.alphaHash=this.alphaHash,n.alphaToCoverage=this.alphaToCoverage,n.premultipliedAlpha=this.premultipliedAlpha,n.forceSinglePass=this.forceSinglePass,n.allowOverride=this.allowOverride,n.visible=this.visible,n.toneMapped=this.toneMapped,n.name=this.name,this.color&&this.color.isColor)n.color=this.color.getHex();if(this.roughness!==void 0)n.roughness=this.roughness;if(this.metalness!==void 0)n.metalness=this.metalness;if(this.sheen!==void 0)n.sheen=this.sheen;if(this.sheenColor&&this.sheenColor.isColor)n.sheenColor=this.sheenColor.getHex();if(this.sheenRoughness!==void 0)n.sheenRoughness=this.sheenRoughness;if(this.emissive&&this.emissive.isColor)n.emissive=this.emissive.getHex();if(this.emissiveIntensity!==void 0)n.emissiveIntensity=this.emissiveIntensity;if(this.specular&&this.specular.isColor)n.specular=this.specular.getHex();if(this.specularIntensity!==void 0)n.specularIntensity=this.specularIntensity;if(this.specularColor&&this.specularColor.isColor)n.specularColor=this.specularColor.getHex();if(this.shininess!==void 0)n.shininess=this.shininess;if(this.clearcoat!==void 0)n.clearcoat=this.clearcoat;if(this.clearcoatRoughness!==void 0)n.clearcoatRoughness=this.clearcoatRoughness;if(this.clearcoatMap&&this.clearcoatMap.isTexture)n.clearcoatMap=this.clearcoatMap.toJSON(t).uuid;if(this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture)n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid;if(this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture)n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray();if(this.sheenColorMap&&this.sheenColorMap.isTexture)n.sheenColorMap=this.sheenColorMap.toJSON(t).uuid;if(this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture)n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(t).uuid;if(this.dispersion!==void 0)n.dispersion=this.dispersion;if(this.retroreflectivity!==void 0)n.retroreflectivity=this.retroreflectivity;if(this.iridescence!==void 0)n.iridescence=this.iridescence;if(this.iridescenceIOR!==void 0)n.iridescenceIOR=this.iridescenceIOR;if(this.iridescenceThicknessRange!==void 0)n.iridescenceThicknessRange=this.iridescenceThicknessRange;if(this.iridescenceMap&&this.iridescenceMap.isTexture)n.iridescenceMap=this.iridescenceMap.toJSON(t).uuid;if(this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture)n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid;if(this.anisotropy!==void 0)n.anisotropy=this.anisotropy;if(this.anisotropyRotation!==void 0)n.anisotropyRotation=this.anisotropyRotation;if(this.anisotropyMap&&this.anisotropyMap.isTexture)n.anisotropyMap=this.anisotropyMap.toJSON(t).uuid;if(this.map&&this.map.isTexture)n.map=this.map.toJSON(t).uuid;if(this.matcap&&this.matcap.isTexture)n.matcap=this.matcap.toJSON(t).uuid;if(this.alphaMap&&this.alphaMap.isTexture)n.alphaMap=this.alphaMap.toJSON(t).uuid;if(this.lightMap&&this.lightMap.isTexture)n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity;if(this.aoMap&&this.aoMap.isTexture)n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity;if(this.bumpMap&&this.bumpMap.isTexture)n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale;if(this.normalMap&&this.normalMap.isTexture)n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray();if(this.displacementMap&&this.displacementMap.isTexture)n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias;if(this.roughnessMap&&this.roughnessMap.isTexture)n.roughnessMap=this.roughnessMap.toJSON(t).uuid;if(this.metalnessMap&&this.metalnessMap.isTexture)n.metalnessMap=this.metalnessMap.toJSON(t).uuid;if(this.emissiveMap&&this.emissiveMap.isTexture)n.emissiveMap=this.emissiveMap.toJSON(t).uuid;if(this.specularMap&&this.specularMap.isTexture)n.specularMap=this.specularMap.toJSON(t).uuid;if(this.specularIntensityMap&&this.specularIntensityMap.isTexture)n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid;if(this.specularColorMap&&this.specularColorMap.isTexture)n.specularColorMap=this.specularColorMap.toJSON(t).uuid;if(this.envMap&&this.envMap.isTexture){if(n.envMap=this.envMap.toJSON(t).uuid,this.combine!==void 0)n.combine=this.combine}if(this.envMapRotation!==void 0)n.envMapRotation=this.envMapRotation.toArray();if(this.envMapIntensity!==void 0)n.envMapIntensity=this.envMapIntensity;if(this.reflectivity!==void 0)n.reflectivity=this.reflectivity;if(this.refractionRatio!==void 0)n.refractionRatio=this.refractionRatio;if(this.gradientMap&&this.gradientMap.isTexture)n.gradientMap=this.gradientMap.toJSON(t).uuid;if(this.transmission!==void 0)n.transmission=this.transmission;if(this.transmissionMap&&this.transmissionMap.isTexture)n.transmissionMap=this.transmissionMap.toJSON(t).uuid;if(this.thickness!==void 0)n.thickness=this.thickness;if(this.thicknessMap&&this.thicknessMap.isTexture)n.thicknessMap=this.thicknessMap.toJSON(t).uuid;if(this.attenuationDistance!==void 0)n.attenuationDistance=this.attenuationDistance;if(this.attenuationColor!==void 0)n.attenuationColor=this.attenuationColor.getHex();if(this.size!==void 0)n.size=this.size;if(this.sizeAttenuation!==void 0)n.sizeAttenuation=this.sizeAttenuation;if(Array.isArray(this.clippingPlanes)&&this.clippingPlanes.length>0)n.clippingPlanes=this.clippingPlanes.map((s)=>s.toJSON());if(this.rotation!==void 0)n.rotation=this.rotation;if(this.depthPacking!==void 0)n.depthPacking=this.depthPacking;if(this.linewidth!==void 0)n.linewidth=this.linewidth;if(this.linecap!==void 0)n.linecap=this.linecap;if(this.linejoin!==void 0)n.linejoin=this.linejoin;if(this.dashSize!==void 0)n.dashSize=this.dashSize;if(this.gapSize!==void 0)n.gapSize=this.gapSize;if(this.scale!==void 0)n.scale=this.scale;if(this.wireframe!==void 0)n.wireframe=this.wireframe;if(this.wireframeLinewidth!==void 0)n.wireframeLinewidth=this.wireframeLinewidth;if(this.wireframeLinecap!==void 0)n.wireframeLinecap=this.wireframeLinecap;if(this.wireframeLinejoin!==void 0)n.wireframeLinejoin=this.wireframeLinejoin;if(this.flatShading!==void 0)n.flatShading=this.flatShading;if(this.fog!==void 0)n.fog=this.fog;if(Object.keys(this.userData).length>0)n.userData=this.userData;function i(s){let r=[];for(let a in s){let o=s[a];delete o.metadata,r.push(o)}return r}if(e){let s=i(t.textures),r=i(t.images);if(s.length>0)n.textures=s;if(r.length>0)n.images=r}return n}fromJSON(t,e){if(t.uuid!==void 0)this.uuid=t.uuid;if(t.name!==void 0)this.name=t.name;if(t.color!==void 0&&this.color!==void 0)this.color.setHex(t.color);if(t.roughness!==void 0)this.roughness=t.roughness;if(t.metalness!==void 0)this.metalness=t.metalness;if(t.sheen!==void 0)this.sheen=t.sheen;if(t.sheenColor!==void 0)this.sheenColor=new Kt().setHex(t.sheenColor);if(t.sheenRoughness!==void 0)this.sheenRoughness=t.sheenRoughness;if(t.emissive!==void 0&&this.emissive!==void 0)this.emissive.setHex(t.emissive);if(t.specular!==void 0&&this.specular!==void 0)this.specular.setHex(t.specular);if(t.specularIntensity!==void 0)this.specularIntensity=t.specularIntensity;if(t.specularColor!==void 0&&this.specularColor!==void 0)this.specularColor.setHex(t.specularColor);if(t.shininess!==void 0)this.shininess=t.shininess;if(t.clearcoat!==void 0)this.clearcoat=t.clearcoat;if(t.clearcoatRoughness!==void 0)this.clearcoatRoughness=t.clearcoatRoughness;if(t.dispersion!==void 0)this.dispersion=t.dispersion;if(t.retroreflectivity!==void 0)this.retroreflectivity=t.retroreflectivity;if(t.iridescence!==void 0)this.iridescence=t.iridescence;if(t.iridescenceIOR!==void 0)this.iridescenceIOR=t.iridescenceIOR;if(t.iridescenceThicknessRange!==void 0)this.iridescenceThicknessRange=t.iridescenceThicknessRange;if(t.transmission!==void 0)this.transmission=t.transmission;if(t.thickness!==void 0)this.thickness=t.thickness;if(t.attenuationDistance!==void 0)this.attenuationDistance=t.attenuationDistance;if(t.attenuationColor!==void 0&&this.attenuationColor!==void 0)this.attenuationColor.setHex(t.attenuationColor);if(t.anisotropy!==void 0)this.anisotropy=t.anisotropy;if(t.anisotropyRotation!==void 0)this.anisotropyRotation=t.anisotropyRotation;if(t.fog!==void 0)this.fog=t.fog;if(t.flatShading!==void 0)this.flatShading=t.flatShading;if(t.blending!==void 0)this.blending=t.blending;if(t.combine!==void 0)this.combine=t.combine;if(t.side!==void 0)this.side=t.side;if(t.shadowSide!==void 0)this.shadowSide=t.shadowSide;if(t.opacity!==void 0)this.opacity=t.opacity;if(t.transparent!==void 0)this.transparent=t.transparent;if(t.alphaTest!==void 0)this.alphaTest=t.alphaTest;if(t.alphaHash!==void 0)this.alphaHash=t.alphaHash;if(t.depthFunc!==void 0)this.depthFunc=t.depthFunc;if(t.depthTest!==void 0)this.depthTest=t.depthTest;if(t.depthWrite!==void 0)this.depthWrite=t.depthWrite;if(t.colorWrite!==void 0)this.colorWrite=t.colorWrite;if(t.clippingPlanes!==void 0)this.clippingPlanes=t.clippingPlanes.map((n)=>new Un().fromJSON(n));if(t.clipIntersection!==void 0)this.clipIntersection=t.clipIntersection;if(t.clipShadows!==void 0)this.clipShadows=t.clipShadows;if(t.depthPacking!==void 0)this.depthPacking=t.depthPacking;if(t.blendSrc!==void 0)this.blendSrc=t.blendSrc;if(t.blendDst!==void 0)this.blendDst=t.blendDst;if(t.blendEquation!==void 0)this.blendEquation=t.blendEquation;if(t.blendSrcAlpha!==void 0)this.blendSrcAlpha=t.blendSrcAlpha;if(t.blendDstAlpha!==void 0)this.blendDstAlpha=t.blendDstAlpha;if(t.blendEquationAlpha!==void 0)this.blendEquationAlpha=t.blendEquationAlpha;if(t.blendColor!==void 0&&this.blendColor!==void 0)this.blendColor.setHex(t.blendColor);if(t.blendAlpha!==void 0)this.blendAlpha=t.blendAlpha;if(t.stencilWriteMask!==void 0)this.stencilWriteMask=t.stencilWriteMask;if(t.stencilFunc!==void 0)this.stencilFunc=t.stencilFunc;if(t.stencilRef!==void 0)this.stencilRef=t.stencilRef;if(t.stencilFuncMask!==void 0)this.stencilFuncMask=t.stencilFuncMask;if(t.stencilFail!==void 0)this.stencilFail=t.stencilFail;if(t.stencilZFail!==void 0)this.stencilZFail=t.stencilZFail;if(t.stencilZPass!==void 0)this.stencilZPass=t.stencilZPass;if(t.stencilWrite!==void 0)this.stencilWrite=t.stencilWrite;if(t.wireframe!==void 0)this.wireframe=t.wireframe;if(t.wireframeLinewidth!==void 0)this.wireframeLinewidth=t.wireframeLinewidth;if(t.wireframeLinecap!==void 0)this.wireframeLinecap=t.wireframeLinecap;if(t.wireframeLinejoin!==void 0)this.wireframeLinejoin=t.wireframeLinejoin;if(t.rotation!==void 0)this.rotation=t.rotation;if(t.linewidth!==void 0)this.linewidth=t.linewidth;if(t.linecap!==void 0)this.linecap=t.linecap;if(t.linejoin!==void 0)this.linejoin=t.linejoin;if(t.dashSize!==void 0)this.dashSize=t.dashSize;if(t.gapSize!==void 0)this.gapSize=t.gapSize;if(t.scale!==void 0)this.scale=t.scale;if(t.polygonOffset!==void 0)this.polygonOffset=t.polygonOffset;if(t.polygonOffsetFactor!==void 0)this.polygonOffsetFactor=t.polygonOffsetFactor;if(t.polygonOffsetUnits!==void 0)this.polygonOffsetUnits=t.polygonOffsetUnits;if(t.dithering!==void 0)this.dithering=t.dithering;if(t.alphaToCoverage!==void 0)this.alphaToCoverage=t.alphaToCoverage;if(t.premultipliedAlpha!==void 0)this.premultipliedAlpha=t.premultipliedAlpha;if(t.forceSinglePass!==void 0)this.forceSinglePass=t.forceSinglePass;if(t.allowOverride!==void 0)this.allowOverride=t.allowOverride;if(t.visible!==void 0)this.visible=t.visible;if(t.toneMapped!==void 0)this.toneMapped=t.toneMapped;if(t.userData!==void 0)this.userData=t.userData;if(t.vertexColors!==void 0)if(typeof t.vertexColors==="number")this.vertexColors=t.vertexColors>0;else this.vertexColors=t.vertexColors;if(t.size!==void 0)this.size=t.size;if(t.sizeAttenuation!==void 0)this.sizeAttenuation=t.sizeAttenuation;if(t.map!==void 0)this.map=e[t.map]||null;if(t.matcap!==void 0)this.matcap=e[t.matcap]||null;if(t.alphaMap!==void 0)this.alphaMap=e[t.alphaMap]||null;if(t.bumpMap!==void 0)this.bumpMap=e[t.bumpMap]||null;if(t.bumpScale!==void 0)this.bumpScale=t.bumpScale;if(t.normalMap!==void 0)this.normalMap=e[t.normalMap]||null;if(t.normalMapType!==void 0)this.normalMapType=t.normalMapType;if(t.normalScale!==void 0){let n=t.normalScale;if(Array.isArray(n)===!1)n=[n,n];this.normalScale=new qt().fromArray(n)}if(t.displacementMap!==void 0)this.displacementMap=e[t.displacementMap]||null;if(t.displacementScale!==void 0)this.displacementScale=t.displacementScale;if(t.displacementBias!==void 0)this.displacementBias=t.displacementBias;if(t.roughnessMap!==void 0)this.roughnessMap=e[t.roughnessMap]||null;if(t.metalnessMap!==void 0)this.metalnessMap=e[t.metalnessMap]||null;if(t.emissiveMap!==void 0)this.emissiveMap=e[t.emissiveMap]||null;if(t.emissiveIntensity!==void 0)this.emissiveIntensity=t.emissiveIntensity;if(t.specularMap!==void 0)this.specularMap=e[t.specularMap]||null;if(t.specularIntensityMap!==void 0)this.specularIntensityMap=e[t.specularIntensityMap]||null;if(t.specularColorMap!==void 0)this.specularColorMap=e[t.specularColorMap]||null;if(t.envMap!==void 0)this.envMap=e[t.envMap]||null;if(t.envMapRotation!==void 0)this.envMapRotation.fromArray(t.envMapRotation);if(t.envMapIntensity!==void 0)this.envMapIntensity=t.envMapIntensity;if(t.reflectivity!==void 0)this.reflectivity=t.reflectivity;if(t.refractionRatio!==void 0)this.refractionRatio=t.refractionRatio;if(t.lightMap!==void 0)this.lightMap=e[t.lightMap]||null;if(t.lightMapIntensity!==void 0)this.lightMapIntensity=t.lightMapIntensity;if(t.aoMap!==void 0)this.aoMap=e[t.aoMap]||null;if(t.aoMapIntensity!==void 0)this.aoMapIntensity=t.aoMapIntensity;if(t.gradientMap!==void 0)this.gradientMap=e[t.gradientMap]||null;if(t.clearcoatMap!==void 0)this.clearcoatMap=e[t.clearcoatMap]||null;if(t.clearcoatRoughnessMap!==void 0)this.clearcoatRoughnessMap=e[t.clearcoatRoughnessMap]||null;if(t.clearcoatNormalMap!==void 0)this.clearcoatNormalMap=e[t.clearcoatNormalMap]||null;if(t.clearcoatNormalScale!==void 0)this.clearcoatNormalScale=new qt().fromArray(t.clearcoatNormalScale);if(t.iridescenceMap!==void 0)this.iridescenceMap=e[t.iridescenceMap]||null;if(t.iridescenceThicknessMap!==void 0)this.iridescenceThicknessMap=e[t.iridescenceThicknessMap]||null;if(t.transmissionMap!==void 0)this.transmissionMap=e[t.transmissionMap]||null;if(t.thicknessMap!==void 0)this.thicknessMap=e[t.thicknessMap]||null;if(t.anisotropyMap!==void 0)this.anisotropyMap=e[t.anisotropyMap]||null;if(t.sheenColorMap!==void 0)this.sheenColorMap=e[t.sheenColorMap]||null;if(t.sheenRoughnessMap!==void 0)this.sheenRoughnessMap=e[t.sheenRoughnessMap]||null;return this}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;let e=t.clippingPlanes,n=null;if(e!==null){let i=e.length;n=Array(i);for(let s=0;s!==i;++s)n[s]=e[s].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.allowOverride=t.allowOverride,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){if(t===!0)this.version++}}class Ms extends _i{constructor(t){super();this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Kt(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.rotation=t.rotation,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}}var ls,Ls=new O,cs=new O,hs=new O,us=new qt,Ns=new qt,yh=new we,wr=new O,Os=new O,Er=new O,oc=new qt,Wa=new qt,lc=new qt;class sr extends He{constructor(t=new Ms){super();if(this.isSprite=!0,this.type="Sprite",ls===void 0){ls=new _n;let e=new Float32Array([-0.5,-0.5,0,0,0,0.5,-0.5,0,1,0,0.5,0.5,0,1,1,-0.5,0.5,0,0,1]),n=new el(e,5);ls.setIndex([0,1,2,0,2,3]),ls.setAttribute("position",new Hs(n,3,0,!1)),ls.setAttribute("uv",new Hs(n,2,3,!1))}this.geometry=ls,this.material=t,this.center=new qt(0.5,0.5),this.count=1}intersectsFrustum(t){return t.intersectsSprite(this)}raycast(t,e){if(t.camera===null)Ht('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.');if(cs.setFromMatrixScale(this.matrixWorld),yh.copy(t.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(t.camera.matrixWorldInverse,this.matrixWorld),hs.setFromMatrixPosition(this.modelViewMatrix),t.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1)cs.multiplyScalar(-hs.z);let n=this.material.rotation,i,s;if(n!==0)s=Math.cos(n),i=Math.sin(n);let r=this.center;Ar(wr.set(-0.5,-0.5,0),hs,r,cs,i,s),Ar(Os.set(0.5,-0.5,0),hs,r,cs,i,s),Ar(Er.set(0.5,0.5,0),hs,r,cs,i,s),oc.set(0,0),Wa.set(1,0),lc.set(1,1);let a=t.ray.intersectTriangle(wr,Os,Er,!1,Ls);if(a===null){if(Ar(Os.set(-0.5,0.5,0),hs,r,cs,i,s),Wa.set(0,1),a=t.ray.intersectTriangle(wr,Er,Os,!1,Ls),a===null)return}let o=t.ray.origin.distanceTo(Ls);if(o<t.near||o>t.far)return;e.push({distance:o,point:Ls.clone(),uv:pn.getInterpolation(Ls,wr,Os,Er,oc,Wa,lc,new qt),face:null,object:this})}copy(t,e){if(super.copy(t,e),t.center!==void 0)this.center.copy(t.center);return this.material=t.material,this}}function Ar(t,e,n,i,s,r){if(us.subVectors(t,n).addScalar(0.5).multiply(i),s!==void 0)Ns.x=r*us.x-s*us.y,Ns.y=s*us.x+r*us.y;else Ns.copy(us);t.copy(e),t.x+=Ns.x,t.y+=Ns.y,t.applyMatrix4(yh)}var Jn=new O,Xa=new O,Rr=new O,Ir=new O;class ra{constructor(t=new O,e=new O(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,Jn)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);let n=e.dot(this.direction);if(n<0)return e.copy(this.origin);return e.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){let e=Jn.subVectors(t,this.origin).dot(this.direction);if(e<0)return this.origin.distanceToSquared(t);return Jn.copy(this.origin).addScaledVector(this.direction,e),Jn.distanceToSquared(t)}distanceSqToSegment(t,e,n,i){Xa.copy(t).add(e).multiplyScalar(0.5),Rr.copy(e).sub(t).normalize(),Ir.copy(this.origin).sub(Xa);let s=t.distanceTo(e)*0.5,r=-this.direction.dot(Rr),a=Ir.dot(this.direction),o=-Ir.dot(Rr),l=Ir.lengthSq(),c=Math.abs(1-r*r),u,d,h,p;if(c>0)if(u=r*o-a,d=r*a-o,p=s*c,u>=0)if(d>=-p)if(d<=p){let v=1/c;u*=v,d*=v,h=u*(u+r*d+2*a)+d*(r*u+d+2*o)+l}else d=s,u=Math.max(0,-(r*d+a)),h=-u*u+d*(d+2*o)+l;else d=-s,u=Math.max(0,-(r*d+a)),h=-u*u+d*(d+2*o)+l;else if(d<=-p)u=Math.max(0,-(-r*s+a)),d=u>0?-s:Math.min(Math.max(-s,-o),s),h=-u*u+d*(d+2*o)+l;else if(d<=p)u=0,d=Math.min(Math.max(-s,-o),s),h=d*(d+2*o)+l;else u=Math.max(0,-(r*s+a)),d=u>0?s:Math.min(Math.max(-s,-o),s),h=-u*u+d*(d+2*o)+l;else d=r>0?-s:s,u=Math.max(0,-(r*d+a)),h=-u*u+d*(d+2*o)+l;if(n)n.copy(this.origin).addScaledVector(this.direction,u);if(i)i.copy(Xa).addScaledVector(Rr,d);return h}intersectSphere(t,e){if(t.radius<0)return null;Jn.subVectors(t.center,this.origin);let n=Jn.dot(this.direction),i=Jn.dot(Jn)-n*n,s=t.radius*t.radius;if(i>s)return null;let r=Math.sqrt(s-i),a=n-r,o=n+r;if(o<0)return null;if(a<0)return this.at(o,e);return this.at(a,e)}intersectsSphere(t){if(t.radius<0)return!1;return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){let e=t.normal.dot(this.direction);if(e===0){if(t.distanceToPoint(this.origin)===0)return 0;return null}let n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){let n=this.distanceToPlane(t);if(n===null)return null;return this.at(n,e)}intersectsPlane(t){let e=t.distanceToPoint(this.origin);if(e===0)return!0;if(t.normal.dot(this.direction)*e<0)return!0;return!1}intersectBox(t,e){let n,i,s,r,a,o,l=1/this.direction.x,c=1/this.direction.y,u=1/this.direction.z,d=this.origin;if(l>=0)n=(t.min.x-d.x)*l,i=(t.max.x-d.x)*l;else n=(t.max.x-d.x)*l,i=(t.min.x-d.x)*l;if(c>=0)s=(t.min.y-d.y)*c,r=(t.max.y-d.y)*c;else s=(t.max.y-d.y)*c,r=(t.min.y-d.y)*c;if(n>r||s>i)return null;if(s>n||isNaN(n))n=s;if(r<i||isNaN(i))i=r;if(u>=0)a=(t.min.z-d.z)*u,o=(t.max.z-d.z)*u;else a=(t.max.z-d.z)*u,o=(t.min.z-d.z)*u;if(n>o||a>i)return null;if(a>n||n!==n)n=a;if(o<i||i!==i)i=o;if(i<0)return null;return this.at(n>=0?n:i,e)}intersectsBox(t){return this.intersectBox(t,Jn)!==null}intersectTriangle(t,e,n,i,s){let r=this.origin,a=this.direction,{x:o,y:l,z:c}=a,u=t.x-r.x,d=t.y-r.y,h=t.z-r.z,p=e.x-r.x,v=e.y-r.y,T=e.z-r.z,m=n.x-r.x,f=n.y-r.y,w=n.z-r.z,C=Math.abs(o),y=Math.abs(l),b=Math.abs(c),A,E,g,M,G,N,F,X,R,k,Z,H;if(C>=y&&C>=b)if(g=o,N=u,R=p,H=m,o>=0)A=l,E=c,M=d,G=h,F=v,X=T,k=f,Z=w;else A=c,E=l,M=h,G=d,F=T,X=v,k=w,Z=f;else if(y>=b)if(g=l,N=d,R=v,H=f,l>=0)A=c,E=o,M=h,G=u,F=T,X=p,k=w,Z=m;else A=o,E=c,M=u,G=h,F=p,X=T,k=m,Z=w;else if(g=c,N=h,R=T,H=w,c>=0)A=o,E=l,M=u,G=d,F=p,X=v,k=m,Z=f;else A=l,E=o,M=d,G=u,F=v,X=p,k=f,Z=m;if(g===0)return null;let at=A/g,K=E/g,et=1/g,tt=M-at*N,dt=G-K*N,At=F-at*R,te=X-K*R,Bt=k-at*H,Y=Z-K*H,rt=Bt*te-Y*At,lt=tt*Y-dt*Bt,It=At*dt-te*tt;if(i){if(rt<0||lt<0||It<0)return null}else if((rt<0||lt<0||It<0)&&(rt>0||lt>0||It>0))return null;let Ft=rt+lt+It;if(Ft===0)return null;let Ut=et*(rt*N+lt*R+It*H);if(Ft>0?Ut<0:Ut>0)return null;return this.at(Ut/Ft,s)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Be extends _i{constructor(t){super();this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Kt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new fi,this.combine=0,this.reflectivity=1,this.refractionRatio=0.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}var cc=new we,Ti=new ra,Pr=new ir,hc=new O,Lr=new O,Nr=new O,Dr=new O,qa=new O,Ur=new O,uc=new O,Fr=new O;class Jt extends He{constructor(t=new _n,e=new Be){super();this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(t,e){if(super.copy(t,e),t.morphTargetInfluences!==void 0)this.morphTargetInfluences=t.morphTargetInfluences.slice();if(t.morphTargetDictionary!==void 0)this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary);return this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){let e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){let i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,r=i.length;s<r;s++){let a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}getVertexPosition(t,e){let n=this.geometry,i=n.attributes.position,s=n.morphAttributes.position,r=n.morphTargetsRelative;e.fromBufferAttribute(i,t);let a=this.morphTargetInfluences;if(s&&a){Ur.set(0,0,0);for(let o=0,l=s.length;o<l;o++){let c=a[o],u=s[o];if(c===0)continue;if(qa.fromBufferAttribute(u,t),r)Ur.addScaledVector(qa,c);else Ur.addScaledVector(qa.sub(e),c)}e.add(Ur)}return e}intersectsFrustum(t){return t.intersectsObject(this)}raycast(t,e){let n=this.geometry,i=this.material,s=this.matrixWorld;if(i===void 0)return;if(n.boundingSphere===null)n.computeBoundingSphere();if(Pr.copy(n.boundingSphere),Pr.applyMatrix4(s),Ti.copy(t.ray).recast(t.near),Pr.containsPoint(Ti.origin)===!1){if(Ti.intersectSphere(Pr,hc)===null)return;if(Ti.origin.distanceToSquared(hc)>(t.far-t.near)**2)return}if(cc.copy(s).invert(),Ti.copy(t.ray).applyMatrix4(cc),n.boundingBox!==null){if(Ti.intersectsBox(n.boundingBox)===!1)return}this._computeIntersections(t,e,Ti)}_computeIntersections(t,e,n){let i,s=this.geometry,r=this.material,a=s.index,o=s.attributes.position,l=s.attributes.uv,c=s.attributes.uv1,u=s.attributes.normal,{groups:d,drawRange:h}=s;if(a!==null)if(Array.isArray(r))for(let p=0,v=d.length;p<v;p++){let T=d[p],m=r[T.materialIndex],f=Math.max(T.start,h.start),w=Math.min(a.count,Math.min(T.start+T.count,h.start+h.count));for(let C=f,y=w;C<y;C+=3){let b=a.getX(C),A=a.getX(C+1),E=a.getX(C+2);if(i=Or(this,m,t,n,l,c,u,b,A,E),i)i.faceIndex=Math.floor(C/3),i.face.materialIndex=T.materialIndex,e.push(i)}}else{let p=Math.max(0,h.start),v=Math.min(a.count,h.start+h.count);for(let T=p,m=v;T<m;T+=3){let f=a.getX(T),w=a.getX(T+1),C=a.getX(T+2);if(i=Or(this,r,t,n,l,c,u,f,w,C),i)i.faceIndex=Math.floor(T/3),e.push(i)}}else if(o!==void 0)if(Array.isArray(r))for(let p=0,v=d.length;p<v;p++){let T=d[p],m=r[T.materialIndex],f=Math.max(T.start,h.start),w=Math.min(o.count,Math.min(T.start+T.count,h.start+h.count));for(let C=f,y=w;C<y;C+=3){let b=C,A=C+1,E=C+2;if(i=Or(this,m,t,n,l,c,u,b,A,E),i)i.faceIndex=Math.floor(C/3),i.face.materialIndex=T.materialIndex,e.push(i)}}else{let p=Math.max(0,h.start),v=Math.min(o.count,h.start+h.count);for(let T=p,m=v;T<m;T+=3){let f=T,w=T+1,C=T+2;if(i=Or(this,r,t,n,l,c,u,f,w,C),i)i.faceIndex=Math.floor(T/3),e.push(i)}}}}function Qu(t,e,n,i,s,r,a,o){let l;if(e.side===1)l=i.intersectTriangle(a,r,s,!0,o);else l=i.intersectTriangle(s,r,a,e.side===0,o);if(l===null)return null;Fr.copy(o),Fr.applyMatrix4(t.matrixWorld);let c=n.ray.origin.distanceTo(Fr);if(c<n.near||c>n.far)return null;return{distance:c,point:Fr.clone(),object:t}}function Or(t,e,n,i,s,r,a,o,l,c){t.getVertexPosition(o,Lr),t.getVertexPosition(l,Nr),t.getVertexPosition(c,Dr);let u=Qu(t,e,n,i,Lr,Nr,Dr,uc);if(u){let d=new O;if(pn.getBarycoord(uc,Lr,Nr,Dr,d),s)u.uv=pn.getInterpolatedAttribute(s,o,l,c,d,new qt);if(r)u.uv1=pn.getInterpolatedAttribute(r,o,l,c,d,new qt);if(a){if(u.normal=pn.getInterpolatedAttribute(a,o,l,c,d,new O),u.normal.dot(i.direction)>0)u.normal.multiplyScalar(-1)}let h={a:o,b:l,c,normal:new O,materialIndex:0};pn.getNormal(Lr,Nr,Dr,h.normal),u.face=h,u.barycoord=d}return u}class rr extends qe{constructor(t=null,e=1,n=1,i,s,r,a,o,l=1003,c=1003,u,d){super(null,r,a,o,l,c,i,s,u,d);this.isDataTexture=!0,this.image={data:t,width:e,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}var wi=new ir,ju=new qt(0.5,0.5),Br=new O;class ar{constructor(t=new Un,e=new Un,n=new Un,i=new Un,s=new Un,r=new Un){this.planes=[t,e,n,i,s,r]}set(t,e,n,i,s,r){let a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(n),a[3].copy(i),a[4].copy(s),a[5].copy(r),this}copy(t){let e=this.planes;for(let n=0;n<6;n++)e[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t,e=2000,n=!1){let i=this.planes,s=t.elements,r=s[0],a=s[1],o=s[2],l=s[3],c=s[4],u=s[5],d=s[6],h=s[7],p=s[8],v=s[9],T=s[10],m=s[11],f=s[12],w=s[13],C=s[14],y=s[15];if(i[0].setComponents(l-r,h-c,m-p,y-f).normalize(),i[1].setComponents(l+r,h+c,m+p,y+f).normalize(),i[2].setComponents(l+a,h+u,m+v,y+w).normalize(),i[3].setComponents(l-a,h-u,m-v,y-w).normalize(),n)i[4].setComponents(o,d,T,C).normalize(),i[5].setComponents(l-o,h-d,m-T,y-C).normalize();else if(i[4].setComponents(l-o,h-d,m-T,y-C).normalize(),e===2000)i[5].setComponents(l+o,h+d,m+T,y+C).normalize();else if(e===2001)i[5].setComponents(o,d,T,C).normalize();else throw Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);return this}intersectsObject(t){if(t.boundingSphere!==void 0){if(t.boundingSphere===null)t.computeBoundingSphere();wi.copy(t.boundingSphere).applyMatrix4(t.matrixWorld)}else{let e=t.geometry;if(e.boundingSphere===null)e.computeBoundingSphere();wi.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(wi)}intersectsSprite(t){wi.center.set(0,0,0);let e=ju.distanceTo(t.center);return wi.radius=0.7071067811865476+e,wi.applyMatrix4(t.matrixWorld),this.intersectsSphere(wi)}intersectsSphere(t){let e=this.planes,n=t.center,i=-t.radius;for(let s=0;s<6;s++)if(e[s].distanceToPoint(n)<i)return!1;return!0}intersectsBox(t){let e=this.planes;for(let n=0;n<6;n++){let i=e[n];if(Br.x=i.normal.x>0?t.max.x:t.min.x,Br.y=i.normal.y>0?t.max.y:t.min.y,Br.z=i.normal.z>0?t.max.z:t.min.z,i.distanceToPoint(Br)<0)return!1}return!0}containsPoint(t){let e=this.planes;for(let n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class aa extends qe{constructor(t=[],e=301,n,i,s,r,a,o,l,c){super(t,e,n,i,s,r,a,o,l,c);this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}class xi extends qe{constructor(t,e,n,i,s,r,a,o,l){super(t,e,n,i,s,r,a,o,l);this.isCanvasTexture=!0,this.needsUpdate=!0}}class Ui extends qe{constructor(t,e,n=1014,i,s,r,a=1003,o=1003,l,c=1026,u=1){if(c!==1026&&c!==1027)throw Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let d={width:t,height:e,depth:u};super(d,i,s,r,a,o,c,n,l);this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.source=new js(Object.assign({},t.image)),this.compareFunction=t.compareFunction,this}toJSON(t){let e=super.toJSON(t);return e.compareFunction=this.compareFunction,e}}class nl extends Ui{constructor(t,e=1014,n=301,i,s,r=1003,a=1003,o,l=1026){let c={width:t,height:t,depth:1},u=[c,c,c,c,c,c];super(t,t,e,n,i,s,r,a,o,l);this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(t){this.image=t}}class oa extends qe{constructor(t=null){super();this.sourceTexture=t,this.isExternalTexture=!0}copy(t){return super.copy(t),this.sourceTexture=t.sourceTexture,this}}class Hn extends _n{constructor(t=1,e=1,n=1,i=1,s=1,r=1){super();this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:i,heightSegments:s,depthSegments:r};let a=this;i=Math.floor(i),s=Math.floor(s),r=Math.floor(r);let o=[],l=[],c=[],u=[],d=0,h=0;p("z","y","x",-1,-1,n,e,t,r,s,0),p("z","y","x",1,-1,n,e,-t,r,s,1),p("x","z","y",1,1,t,n,e,i,r,2),p("x","z","y",1,-1,t,n,-e,i,r,3),p("x","y","z",1,-1,t,e,n,i,s,4),p("x","y","z",-1,-1,t,e,-n,i,s,5),this.setIndex(o),this.setAttribute("position",new Ye(l,3)),this.setAttribute("normal",new Ye(c,3)),this.setAttribute("uv",new Ye(u,2));function p(v,T,m,f,w,C,y,b,A,E,g){let M=C/A,G=y/E,N=C/2,F=y/2,X=b/2,R=A+1,k=E+1,Z=0,H=0,at=new O;for(let K=0;K<k;K++){let et=K*G-F;for(let tt=0;tt<R;tt++){let dt=tt*M-N;at[v]=dt*f,at[T]=et*w,at[m]=X,l.push(at.x,at.y,at.z),at[v]=0,at[T]=0,at[m]=b>0?1:-1,c.push(at.x,at.y,at.z),u.push(tt/A),u.push(1-K/E),Z+=1}}for(let K=0;K<E;K++)for(let et=0;et<A;et++){let tt=d+et+R*K,dt=d+et+R*(K+1),At=d+(et+1)+R*(K+1),te=d+(et+1)+R*K;o.push(tt,dt,te),o.push(dt,At,te),H+=6}a.addGroup(h,H,g),h+=H,d+=Z}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Hn(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}class bs extends _n{constructor(t=1,e=32,n=0,i=Math.PI*2){super();this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:n,thetaLength:i},e=Math.max(3,e);let s=[],r=[],a=[],o=[],l=new O,c=new qt;r.push(0,0,0),a.push(0,0,1),o.push(0.5,0.5);for(let u=0,d=3;u<=e;u++,d+=3){let h=n+u/e*i;l.x=t*Math.cos(h),l.y=t*Math.sin(h),r.push(l.x,l.y,l.z),a.push(0,0,1),c.x=(r[d]/t+1)/2,c.y=(r[d+1]/t+1)/2,o.push(c.x,c.y)}for(let u=1;u<=e;u++)s.push(u,u+1,0);this.setIndex(s),this.setAttribute("position",new Ye(r,3)),this.setAttribute("normal",new Ye(a,3)),this.setAttribute("uv",new Ye(o,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new bs(t.radius,t.segments,t.thetaStart,t.thetaLength)}}class xn extends _n{constructor(t=1,e=1,n=1,i=32,s=1,r=!1,a=0,o=Math.PI*2){super();this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:n,radialSegments:i,heightSegments:s,openEnded:r,thetaStart:a,thetaLength:o};let l=this;i=Math.floor(i),s=Math.floor(s);let c=[],u=[],d=[],h=[],p=0,v=[],T=n/2,m=0;if(f(),r===!1){if(t>0)w(!0);if(e>0)w(!1)}this.setIndex(c),this.setAttribute("position",new Ye(u,3)),this.setAttribute("normal",new Ye(d,3)),this.setAttribute("uv",new Ye(h,2));function f(){let C=new O,y=new O,b=0,A=(e-t)/n;for(let E=0;E<=s;E++){let g=[],M=E/s,G=M*(e-t)+t;for(let N=0;N<=i;N++){let F=N/i,X=F*o+a,R=Math.sin(X),k=Math.cos(X);y.x=G*R,y.y=-M*n+T,y.z=G*k,u.push(y.x,y.y,y.z),C.set(R,A,k).normalize(),d.push(C.x,C.y,C.z),h.push(F,1-M),g.push(p++)}v.push(g)}for(let E=0;E<i;E++)for(let g=0;g<s;g++){let M=v[g][E],G=v[g+1][E],N=v[g+1][E+1],F=v[g][E+1];if(t>0||g!==0)c.push(M,G,F),b+=3;if(e>0||g!==s-1)c.push(G,N,F),b+=3}l.addGroup(m,b,0),m+=b}function w(C){let y=p,b=new qt,A=new O,E=0,g=C===!0?t:e,M=C===!0?1:-1;for(let N=1;N<=i;N++)u.push(0,T*M,0),d.push(0,M,0),h.push(0.5,0.5),p++;let G=p;for(let N=0;N<=i;N++){let X=N/i*o+a,R=Math.cos(X),k=Math.sin(X);A.x=g*k,A.y=T*M,A.z=g*R,u.push(A.x,A.y,A.z),d.push(0,M,0),b.x=R*0.5+0.5,b.y=k*0.5*M+0.5,h.push(b.x,b.y),p++}for(let N=0;N<i;N++){let F=y+N,X=G+N;if(C===!0)c.push(X,X+1,F);else c.push(X+1,X,F);E+=3}l.addGroup(m,E,C===!0?1:2),m+=E}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new xn(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class Ie extends _n{constructor(t=1,e=1,n=1,i=1){super();this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:n,heightSegments:i};let s=t/2,r=e/2,a=Math.floor(n),o=Math.floor(i),l=a+1,c=o+1,u=t/a,d=e/o,h=[],p=[],v=[],T=[];for(let m=0;m<c;m++){let f=m*d-r;for(let w=0;w<l;w++){let C=w*u-s;p.push(C,-f,0),v.push(0,0,1),T.push(w/a),T.push(1-m/o)}}for(let m=0;m<o;m++)for(let f=0;f<a;f++){let w=f+l*m,C=f+l*(m+1),y=f+1+l*(m+1),b=f+1+l*m;h.push(w,C,b),h.push(C,y,b)}this.setIndex(h),this.setAttribute("position",new Ye(p,3)),this.setAttribute("normal",new Ye(v,3)),this.setAttribute("uv",new Ye(T,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Ie(t.width,t.height,t.widthSegments,t.heightSegments)}}function Fi(t){let e={};for(let n in t){e[n]={};for(let i in t[n]){let s=t[n][i];if(dc(s))if(s.isRenderTargetTexture)Vt("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[n][i]=null;else e[n][i]=s.clone();else if(Array.isArray(s))if(dc(s[0])){let r=[];for(let a=0,o=s.length;a<o;a++)r[a]=s[a].clone();e[n][i]=r}else e[n][i]=s.slice();else e[n][i]=s}}return e}function je(t){let e={};for(let n=0;n<t.length;n++){let i=Fi(t[n]);for(let s in i)e[s]=i[s]}return e}function dc(t){return t&&(t.isColor||t.isMatrix3||t.isMatrix4||t.isVector2||t.isVector3||t.isVector4||t.isTexture||t.isQuaternion)}function td(t){let e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function il(t){let e=t.getRenderTarget();if(e===null)return t.outputColorSpace;if(e.isXRRenderTarget===!0)return e.texture.colorSpace;return re.workingColorSpace}var Sh={clone:Fi,merge:je},ed=`void main() {
2
2
  gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
3
- }`,ed=`void main() {
3
+ }`,nd=`void main() {
4
4
  gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
5
- }`;class bn extends _i{constructor(t){super();if(this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=td,this.fragmentShader=ed,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,t!==void 0)this.setValues(t)}copy(t){return super.copy(t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=Oi(t.uniforms),this.uniformsGroups=ju(t.uniformsGroups),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.fog=t.fog,this.lights=t.lights,this.clipping=t.clipping,this.extensions=Object.assign({},t.extensions),this.glslVersion=t.glslVersion,this.defaultAttributeValues=Object.assign({},t.defaultAttributeValues),this.index0AttributeName=t.index0AttributeName,this.uniformsNeedUpdate=t.uniformsNeedUpdate,this}toJSON(t){let e=super.toJSON(t);e.glslVersion=this.glslVersion,e.uniforms={};for(let i in this.uniforms){let r=this.uniforms[i].value;if(r&&r.isTexture)e.uniforms[i]={type:"t",value:r.toJSON(t).uuid};else if(r&&r.isColor)e.uniforms[i]={type:"c",value:r.getHex()};else if(r&&r.isVector2)e.uniforms[i]={type:"v2",value:r.toArray()};else if(r&&r.isVector3)e.uniforms[i]={type:"v3",value:r.toArray()};else if(r&&r.isVector4)e.uniforms[i]={type:"v4",value:r.toArray()};else if(r&&r.isMatrix3)e.uniforms[i]={type:"m3",value:r.toArray()};else if(r&&r.isMatrix4)e.uniforms[i]={type:"m4",value:r.toArray()};else e.uniforms[i]={value:r}}if(Object.keys(this.defines).length>0)e.defines=this.defines;e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;let n={};for(let i in this.extensions)if(this.extensions[i]===!0)n[i]=!0;if(Object.keys(n).length>0)e.extensions=n;return e}fromJSON(t,e){if(super.fromJSON(t,e),t.uniforms!==void 0)for(let n in t.uniforms){let i=t.uniforms[n];switch(this.uniforms[n]={},i.type){case"t":this.uniforms[n].value=e[i.value]||null;break;case"c":this.uniforms[n].value=new Kt().setHex(i.value);break;case"v2":this.uniforms[n].value=new Xt().fromArray(i.value);break;case"v3":this.uniforms[n].value=new O().fromArray(i.value);break;case"v4":this.uniforms[n].value=new Ae().fromArray(i.value);break;case"m3":this.uniforms[n].value=new qt().fromArray(i.value);break;case"m4":this.uniforms[n].value=new we().fromArray(i.value);break;default:this.uniforms[n].value=i.value}}if(t.defines!==void 0)this.defines=t.defines;if(t.vertexShader!==void 0)this.vertexShader=t.vertexShader;if(t.fragmentShader!==void 0)this.fragmentShader=t.fragmentShader;if(t.glslVersion!==void 0)this.glslVersion=t.glslVersion;if(t.extensions!==void 0)for(let n in t.extensions)this.extensions[n]=t.extensions[n];if(t.lights!==void 0)this.lights=t.lights;if(t.clipping!==void 0)this.clipping=t.clipping;return this}}class il extends bn{constructor(t){super(t);this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class ni extends _i{constructor(t){super();this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Kt(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Kt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Xt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.gradientMap=t.gradientMap,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}class sl extends _i{constructor(t){super();this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=3200,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}}class rl extends _i{constructor(t){super();this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}}function os(t,e){if(!t||t.constructor===e)return t;if(typeof e.BYTES_PER_ELEMENT==="number")return new e(t);return Array.prototype.slice.call(t)}function Ga(t){return t!==void 0&&t.inTangents!==void 0&&t.outTangents!==void 0}class Bi{constructor(t,e,n,i){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new e.constructor(n),this.sampleValues=e,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(t){let e=this.parameterPositions,n=this._cachedIndex,i=e[n],s=e[n-1];n:{t:{let r;e:{i:if(!(t<i)){for(let a=n+2;;){if(i===void 0){if(t<s)break i;return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(s=i,i=e[++n],t<i)break t}r=e.length;break e}if(!(t>=s)){let a=e[1];if(t<a)n=2,s=a;for(let o=n-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===o)break;if(i=s,s=e[--n-1],t>=s)break t}r=n,n=0;break e}break n}while(n<r){let a=n+r>>>1;if(t<e[a])r=a;else n=a+1}if(i=e[n],s=e[n-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,s,i)}return this.interpolate_(n,s,t,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){let e=this.resultBuffer,n=this.sampleValues,i=this.valueSize,s=t*i;for(let r=0;r!==i;++r)e[r]=n[s+r];return e}interpolate_(){throw Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}}class al extends Bi{constructor(t,e,n,i){super(t,e,n,i);this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:2400,endingEnd:2400}}intervalChanged_(t,e,n){let i=this.parameterPositions,s=t-2,r=t+1,a=i[s],o=i[r];if(a===void 0)switch(this.getSettings_().endingStart){case 2401:s=t,a=2*e-n;break;case 2402:s=i.length-2,a=e+i[s]-i[s+1];break;default:s=t,a=n}if(o===void 0)switch(this.getSettings_().endingEnd){case 2401:r=t,o=2*n-e;break;case 2402:r=1,o=n+i[1]-i[0];break;default:r=t-1,o=e}let l=(n-e)*0.5,c=this.valueSize;this._weightPrev=l/(e-a),this._weightNext=l/(o-n),this._offsetPrev=s*c,this._offsetNext=r*c}interpolate_(t,e,n,i){let s=this.resultBuffer,r=this.sampleValues,a=this.valueSize,o=t*a,l=o-a,c=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,h=this._weightNext,p=(n-e)/(i-e),v=p*p,T=v*p,m=-d*T+2*d*v-d*p,f=(1+d)*T+(-1.5-2*d)*v+(-0.5+d)*p+1,w=(-1-h)*T+(1.5+h)*v+0.5*p,C=h*T-h*v;for(let y=0;y!==a;++y)s[y]=m*r[c+y]+f*r[l+y]+w*r[o+y]+C*r[u+y];return s}}class ol extends Bi{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){let s=this.resultBuffer,r=this.sampleValues,a=this.valueSize,o=t*a,l=o-a,c=(n-e)/(i-e),u=1-c;for(let d=0;d!==a;++d)s[d]=r[l+d]*u+r[o+d]*c;return s}}class ll extends Bi{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t){return this.copySampleValue_(t-1)}}class cl extends Bi{interpolate_(t,e,n,i){let s=this.resultBuffer,r=this.sampleValues,a=this.valueSize,o=t*a,l=o-a,c=this.inTangents,u=this.outTangents;if(!c||!u){let p=(n-e)/(i-e),v=1-p;for(let T=0;T!==a;++T)s[T]=r[l+T]*v+r[o+T]*p;return s}let d=a*2,h=t-1;for(let p=0;p!==a;++p){let v=r[l+p],T=r[o+p],m=h*d+p*2,f=u[m],w=u[m+1],C=t*d+p*2,y=c[C],b=c[C+1],A=id(n,e,f,y,i);s[p]=Sh(A,v,w,b,T)}return s}}function Sh(t,e,n,i,s){let r=1-t;return r*r*r*e+3*r*r*t*n+3*r*t*t*i+t*t*t*s}function nd(t,e,n,i,s){let r=1-t;return 3*r*r*(n-e)+6*r*t*(i-n)+3*t*t*(s-i)}function id(t,e,n,i,s){let r=(t-e)/(s-e);for(let a=0;a<8;a++){let o=Sh(r,e,n,i,s)-t;if(Math.abs(o)<0.0000000001)break;let l=nd(r,e,n,i,s);if(Math.abs(l)<0.0000000001)break;r=Math.max(0,Math.min(1,r-o/l))}return r}class wn{constructor(t,e,n,i){if(t===void 0)throw Error("THREE.KeyframeTrack: track name is undefined");if(e===void 0||e.length===0)throw Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=os(e,this.TimeBufferType),this.values=os(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(t){let e=t.constructor,n;if(e.toJSON!==this.toJSON)n=e.toJSON(t);else{n={name:t.name,times:os(t.times,Array),values:os(t.values,Array)};let i=t.getInterpolation();if(i!==t.DefaultInterpolation)n.interpolation=i;if(Ga(t.settings))n.settings={inTangents:os(t.settings.inTangents,Array),outTangents:os(t.settings.outTangents,Array)}}return n.type=t.ValueTypeName,n}InterpolantFactoryMethodDiscrete(t){return new ll(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new ol(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new al(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodBezier(t){let e=new cl(this.times,this.values,this.getValueSize(),t);if(this.settings)e.inTangents=this.settings.inTangents,e.outTangents=this.settings.outTangents;return e}setInterpolation(t){let e;switch(t){case 2300:e=this.InterpolantFactoryMethodDiscrete;break;case 2301:e=this.InterpolantFactoryMethodLinear;break;case 2302:e=this.InterpolantFactoryMethodSmooth;break;case 2303:e=this.InterpolantFactoryMethodBezier;break}if(e===void 0){let n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(t!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw Error(n);return Ht("KeyframeTrack:",n),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return 2300;case this.InterpolantFactoryMethodLinear:return 2301;case this.InterpolantFactoryMethodSmooth:return 2302;case this.InterpolantFactoryMethodBezier:return 2303}}getValueSize(){return this.values.length/this.times.length}shift(t){if(t!==0){let e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]+=t}return this}scale(t){if(t!==1){let e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]*=t;if(Ga(this.settings))dc(this.settings.inTangents,t),dc(this.settings.outTangents,t)}return this}trim(t,e){let n=this.times,i=n.length,s=0,r=i-1;while(s!==i&&n[s]<t)++s;while(r!==-1&&n[r]>e)--r;if(++r,s!==0||r!==i){if(s>=r)r=Math.max(r,1),s=r-1;let a=this.getValueSize();this.times=n.slice(s,r),this.values=this.values.slice(s*a,r*a)}return this}validate(){let t=!0,e=this.getValueSize();if(e-Math.floor(e)!==0)Gt("KeyframeTrack: Invalid value size in track.",this),t=!1;let n=this.times,i=this.values,s=n.length;if(s===0)Gt("KeyframeTrack: Track is empty.",this),t=!1;let r=null;for(let a=0;a!==s;a++){let o=n[a];if(typeof o==="number"&&isNaN(o)){Gt("KeyframeTrack: Time is not a valid number.",this,a,o),t=!1;break}if(r!==null&&r>o){Gt("KeyframeTrack: Out of order keys.",this,a,o,r),t=!1;break}r=o}if(i!==void 0){if(Nu(i))for(let a=0,o=i.length;a!==o;++a){let l=i[a];if(isNaN(l)){Gt("KeyframeTrack: Value is not a valid number.",this,a,l),t=!1;break}}}return t}optimize(){let t=this.times.slice(),e=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===2302,s=t.length-1,r=1;for(let a=1;a<s;++a){let o=!1,l=t[a],c=t[a+1];if(l!==c&&(a!==1||l!==t[0]))if(!i){let u=a*n,d=u-n,h=u+n;for(let p=0;p!==n;++p){let v=e[u+p];if(v!==e[d+p]||v!==e[h+p]){o=!0;break}}}else o=!0;if(o){if(a!==r){t[r]=t[a];let u=a*n,d=r*n;for(let h=0;h!==n;++h)e[d+h]=e[u+h]}++r}}if(s>0){t[r]=t[s];for(let a=s*n,o=r*n,l=0;l!==n;++l)e[o+l]=e[a+l];++r}if(r!==t.length)this.times=t.slice(0,r),this.values=e.slice(0,r*n);else this.times=t,this.values=e;return this}clone(){let t=this.times.slice(),e=this.values.slice(),i=new this.constructor(this.name,t,e);if(i.createInterpolant=this.createInterpolant,Ga(this.settings))i.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()};return i}}function dc(t,e){for(let n=0,i=t.length;n!==i;n+=2)t[n]*=e}wn.prototype.ValueTypeName="";wn.prototype.TimeBufferType=Float32Array;wn.prototype.ValueBufferType=Float32Array;wn.prototype.DefaultInterpolation=2301;class zi extends wn{constructor(t,e,n){super(t,e,n)}}zi.prototype.ValueTypeName="bool";zi.prototype.ValueBufferType=Array;zi.prototype.DefaultInterpolation=2300;zi.prototype.InterpolantFactoryMethodLinear=void 0;zi.prototype.InterpolantFactoryMethodSmooth=void 0;class hl extends wn{constructor(t,e,n,i){super(t,e,n,i)}}hl.prototype.ValueTypeName="color";class ul extends wn{constructor(t,e,n,i){super(t,e,n,i)}}ul.prototype.ValueTypeName="number";class dl extends Bi{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){let s=this.resultBuffer,r=this.sampleValues,a=this.valueSize,o=(n-e)/(i-e),l=t*a;for(let c=l+a;l!==c;l+=4)ei.slerpFlat(s,0,r,l-a,r,l,o);return s}}class na extends wn{constructor(t,e,n,i){super(t,e,n,i)}InterpolantFactoryMethodLinear(t){return new dl(this.times,this.values,this.getValueSize(),t)}}na.prototype.ValueTypeName="quaternion";na.prototype.InterpolantFactoryMethodSmooth=void 0;class ki extends wn{constructor(t,e,n){super(t,e,n)}}ki.prototype.ValueTypeName="string";ki.prototype.ValueBufferType=Array;ki.prototype.DefaultInterpolation=2300;ki.prototype.InterpolantFactoryMethodLinear=void 0;ki.prototype.InterpolantFactoryMethodSmooth=void 0;class fl extends wn{constructor(t,e,n,i){super(t,e,n,i)}}fl.prototype.ValueTypeName="vector";class pl{constructor(t,e,n){let i=this,s=!1,r=0,a=0,o=void 0,l=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this._abortController=null,this.itemStart=function(c){if(a++,s===!1){if(i.onStart!==void 0)i.onStart(c,r,a)}s=!0},this.itemEnd=function(c){if(r++,i.onProgress!==void 0)i.onProgress(c,r,a);if(r===a){if(s=!1,i.onLoad!==void 0)i.onLoad()}},this.itemError=function(c){if(i.onError!==void 0)i.onError(c)},this.resolveURL=function(c){if(c=c.normalize("NFC"),o)return o(c);return c},this.setURLModifier=function(c){return o=c,this},this.addHandler=function(c,u){return l.push(c,u),this},this.removeHandler=function(c){let u=l.indexOf(c);if(u!==-1)l.splice(u,2);return this},this.getHandler=function(c){for(let u=0,d=l.length;u<d;u+=2){let h=l[u],p=l[u+1];if(h.global)h.lastIndex=0;if(h.test(c))return p}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){if(!this._abortController)this._abortController=new AbortController;return this._abortController}}var Mh=new pl;class ml{constructor(t){if(this.manager=t!==void 0?t:Mh,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(t,e){let n=this;return new Promise(function(i,s){n.load(t,i,e,s)})}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}abort(){return this}}ml.DEFAULT_MATERIAL_NAME="__DEFAULT";class ia extends He{constructor(t,e=1){super();this.isLight=!0,this.type="Light",this.color=new Kt(t),this.intensity=e}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){let e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,e}}var Ha=new we,fc=new O,pc=new O;class gl{constructor(t){this.camera=t,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Xt(512,512),this.mapType=1009,this.map=null,this.mapPass=null,this.matrix=new we,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new tr,this._frameExtents=new Xt(1,1),this._viewportCount=1,this._viewports=[new Ae(0,0,1,1)]}getViewportCount(){return this._viewportCount}getCamera(){return this.camera}getFrustum(){return this._frustum}updateMatrices(t){let e=this.camera;fc.setFromMatrixPosition(t.matrixWorld),e.position.copy(fc),pc.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(pc),e.updateMatrixWorld(),this._updateMatrix(e,this.matrix,this._frustum)}_updateMatrix(t,e,n,i){Ha.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),n.setFromProjectionMatrix(Ha,t.coordinateSystem,t.reversedDepth);let s=this._frameExtents,r=i?i.z/s.x:1,a=i?i.w/s.y:1,o=i?i.x/s.x:0,l=i?i.y/s.y:0;if(t.coordinateSystem===2001||t.reversedDepth)e.set(0.5*r,0,0,0.5*r+o,0,0.5*a,0,0.5*a+l,0,0,1,0,0,0,0,1);else e.set(0.5*r,0,0,0.5*r+o,0,0.5*a,0,0.5*a+l,0,0,0.5,0.5,0,0,0,1);e.multiply(Ha)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){if(this.map)this.map.dispose();if(this.mapPass)this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.intensity=t.intensity,this.bias=t.bias,this.radius=t.radius,this.autoUpdate=t.autoUpdate,this.needsUpdate=t.needsUpdate,this.normalBias=t.normalBias,this.blurSamples=t.blurSamples,this.mapSize.copy(t.mapSize),this.biasNode=t.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){let t={};return t.intensity=this.intensity,t.bias=this.bias,t.normalBias=this.normalBias,t.radius=this.radius,t.blurSamples=this.blurSamples,t.mapSize=this.mapSize.toArray(),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}var Nr=new O,Dr=new ei,Un=new O;class sa extends He{constructor(){super();this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new we,this.projectionMatrix=new we,this.projectionMatrixInverse=new we,this.coordinateSystem=2000,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){return super.getWorldDirection(t).negate()}updateMatrixWorld(t){if(super.updateMatrixWorld(t),this.matrixWorld.decompose(Nr,Dr,Un),Un.x===1&&Un.y===1&&Un.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(Nr,Dr,Un.set(1,1,1)).invert()}updateWorldMatrix(t,e,n=!1){if(super.updateWorldMatrix(t,e,n),this.matrixWorld.decompose(Nr,Dr,Un),Un.x===1&&Un.y===1&&Un.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(Nr,Dr,Un.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}var ui=new O,mc=new Xt,gc=new Xt;class sn extends sa{constructor(t=50,e=1,n=0.1,i=2000){super();this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=t.view===null?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){let e=0.5*this.getFilmHeight()/t;this.fov=Ur*2*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){let t=Math.tan(va*0.5*this.fov);return 0.5*this.getFilmHeight()/t}getEffectiveFOV(){return Ur*2*Math.atan(Math.tan(va*0.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(t,e,n){ui.set(-1,-1,0.5).applyMatrix4(this.projectionMatrixInverse),e.set(ui.x,ui.y).multiplyScalar(-t/ui.z),ui.set(1,1,0.5).applyMatrix4(this.projectionMatrixInverse),n.set(ui.x,ui.y).multiplyScalar(-t/ui.z)}getViewSize(t,e){return this.getViewBounds(t,mc,gc),e.subVectors(gc,mc)}setViewOffset(t,e,n,i,s,r){if(this.aspect=t/e,this.view===null)this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1};this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=s,this.view.height=r,this.updateProjectionMatrix()}clearViewOffset(){if(this.view!==null)this.view.enabled=!1;this.updateProjectionMatrix()}updateProjectionMatrix(){let t=this.near,e=t*Math.tan(va*0.5*this.fov)/this.zoom,n=2*e,i=this.aspect*n,s=-0.5*i,r=this.view;if(this.view!==null&&this.view.enabled){let{fullWidth:o,fullHeight:l}=r;s+=r.offsetX*i/o,e-=r.offsetY*n/l,i*=r.width/o,n*=r.height/l}let a=this.filmOffset;if(a!==0)s+=t*a/this.getFilmWidth();this.projectionMatrix.makePerspective(s,s+i,e,e-n,t,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){let e=super.toJSON(t);if(e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,this.view!==null)e.object.view=Object.assign({},this.view);return e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}class er extends sa{constructor(t=-1,e=1,n=1,i=-1,s=0.1,r=2000){super();this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=n,this.bottom=i,this.near=s,this.far=r,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=t.view===null?null:Object.assign({},t.view),this}setViewOffset(t,e,n,i,s,r){if(this.view===null)this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1};this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=s,this.view.height=r,this.updateProjectionMatrix()}clearViewOffset(){if(this.view!==null)this.view.enabled=!1;this.updateProjectionMatrix()}updateProjectionMatrix(){let t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2,s=n-t,r=n+t,a=i+e,o=i-e;if(this.view!==null&&this.view.enabled){let l=(this.right-this.left)/this.view.fullWidth/this.zoom,c=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=l*this.view.offsetX,r=s+l*this.view.width,a-=c*this.view.offsetY,o=a-c*this.view.height}this.projectionMatrix.makeOrthographic(s,r,a,o,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){let e=super.toJSON(t);if(e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,this.view!==null)e.object.view=Object.assign({},this.view);return e}}class bh extends gl{constructor(){super(new er(-5,5,5,-5,0.5,500));this.isDirectionalLightShadow=!0}}class ra extends ia{constructor(t,e){super(t,e);this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(He.DEFAULT_UP),this.updateMatrix(),this.target=new He,this.shadow=new bh}dispose(){super.dispose(),this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}toJSON(t){let e=super.toJSON(t);return e.object.shadow=this.shadow.toJSON(),e.object.target=this.target.uuid,e}}class aa extends ia{constructor(t,e){super(t,e);this.isAmbientLight=!0,this.type="AmbientLight"}}var ls=-90,cs=1;class _l extends He{constructor(t,e,n){super();this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let i=new sn(ls,cs,t,e);i.layers=this.layers,this.add(i);let s=new sn(ls,cs,t,e);s.layers=this.layers,this.add(s);let r=new sn(ls,cs,t,e);r.layers=this.layers,this.add(r);let a=new sn(ls,cs,t,e);a.layers=this.layers,this.add(a);let o=new sn(ls,cs,t,e);o.layers=this.layers,this.add(o);let l=new sn(ls,cs,t,e);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){let t=this.coordinateSystem,e=this.children.concat(),[n,i,s,r,a,o]=e;for(let l of e)this.remove(l);if(t===2000)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),r.up.set(0,0,1),r.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),o.up.set(0,1,0),o.lookAt(0,0,-1);else if(t===2001)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),r.up.set(0,0,-1),r.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),o.up.set(0,-1,0),o.lookAt(0,0,-1);else throw Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);for(let l of e)this.add(l),l.updateMatrixWorld()}update(t,e){if(this.parent===null)this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:i}=this;if(this.coordinateSystem!==t.coordinateSystem)this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem();let[s,r,a,o,l,c]=this.children,u=t.getRenderTarget(),d=t.getActiveCubeFace(),h=t.getActiveMipmapLevel(),p=t.xr.enabled;t.xr.enabled=!1;let v=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let T=!1;if(t.isWebGLRenderer===!0)T=t.state.buffers.depth.getReversed();else T=t.reversedDepthBuffer;if(t.setRenderTarget(n,0,i),T&&t.autoClear===!1)t.clearDepth();if(t.render(e,s),t.setRenderTarget(n,1,i),T&&t.autoClear===!1)t.clearDepth();if(t.render(e,r),t.setRenderTarget(n,2,i),T&&t.autoClear===!1)t.clearDepth();if(t.render(e,a),t.setRenderTarget(n,3,i),T&&t.autoClear===!1)t.clearDepth();if(t.render(e,o),t.setRenderTarget(n,4,i),T&&t.autoClear===!1)t.clearDepth();if(t.render(e,l),n.texture.generateMipmaps=v,t.setRenderTarget(n,5,i),T&&t.autoClear===!1)t.clearDepth();t.render(e,c),t.setRenderTarget(u,d,h),t.xr.enabled=p,n.texture.needsPMREMUpdate=!0}}class xl extends sn{constructor(t=[]){super();this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=t}}var vl="\\[\\]\\.:\\/",sd=new RegExp("["+vl+"]","g"),yl="[^"+vl+"]",rd="[^"+vl.replace("\\.","")+"]",ad=/((?:WC+[\/:])*)/.source.replace("WC",yl),od=/(WCOD+)?/.source.replace("WCOD",rd),ld=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",yl),cd=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",yl),hd=new RegExp("^"+ad+od+ld+cd+"$"),ud=["material","materials","bones","map"];class Th{constructor(t,e,n){let i=n||pe.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,i)}getValue(t,e){this.bind();let n=this._targetGroup.nCachedObjects_,i=this._bindings[n];if(i!==void 0)i.getValue(t,e)}setValue(t,e){let n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=n.length;i!==s;++i)n[i].setValue(t,e)}bind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].bind()}unbind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].unbind()}}class pe{constructor(t,e,n){this.path=e,this.parsedPath=n||pe.parseTrackName(e),this.node=pe.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,n){if(!(t&&t.isAnimationObjectGroup))return new pe(t,e,n);else return new pe.Composite(t,e,n)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(sd,"")}static parseTrackName(t){let e=hd.exec(t);if(e===null)throw Error("THREE.PropertyBinding: Cannot parse trackName: "+t);let n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){let s=n.nodeName.substring(i+1);if(ud.indexOf(s)!==-1)n.nodeName=n.nodeName.substring(0,i),n.objectName=s}if(n.propertyName===null||n.propertyName.length===0)throw Error("THREE.PropertyBinding: can not parse propertyName from trackName: "+t);return n}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){let n=t.skeleton.getBoneByName(e);if(n!==void 0)return n}if(t.children){let n=function(s){for(let r=0;r<s.length;r++){let a=s[r];if(a.name===e||a.uuid===e)return a;let o=n(a.children);if(o)return o}return null},i=n(t.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)t[e++]=n[i]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=t[e++]}_setValue_array_setNeedsUpdate(t,e){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node,e=this.parsedPath,{objectName:n,propertyName:i,propertyIndex:s}=e;if(!t)t=pe.findNode(this.rootNode,e.nodeName),this.node=t;if(this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){Ht("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let l=e.objectIndex;switch(n){case"materials":if(!t.material){Gt("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.materials){Gt("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}t=t.material.materials;break;case"bones":if(!t.skeleton){Gt("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}t=t.skeleton.bones;for(let c=0;c<t.length;c++)if(t[c].name===l){l=c;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material){Gt("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.map){Gt("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}t=t.material.map;break;default:if(t[n]===void 0){Gt("PropertyBinding: Can not bind to objectName of node undefined.",this);return}t=t[n]}if(l!==void 0){if(t[l]===void 0){Gt("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);return}t=t[l]}}let r=t[i];if(r===void 0){let l=e.nodeName;Gt("PropertyBinding: Trying to update property for track: "+l+"."+i+" but it wasn't found.",t);return}let a=this.Versioning.None;if(this.targetObject=t,t.isMaterial===!0)a=this.Versioning.NeedsUpdate;else if(t.isObject3D===!0)a=this.Versioning.MatrixWorldNeedsUpdate;let o=this.BindingType.Direct;if(s!==void 0){if(i==="morphTargetInfluences"){if(!t.geometry){Gt("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!t.geometry.morphAttributes){Gt("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}if(t.morphTargetDictionary[s]!==void 0)s=t.morphTargetDictionary[s]}o=this.BindingType.ArrayElement,this.resolvedProperty=r,this.propertyIndex=s}else if(r.fromArray!==void 0&&r.toArray!==void 0)o=this.BindingType.HasFromToArray,this.resolvedProperty=r;else if(Array.isArray(r))o=this.BindingType.EntireArray,this.resolvedProperty=r;else this.propertyName=i;this.getValue=this.GetterByBindingType[o],this.setValue=this.SetterByBindingTypeAndVersioning[o][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}pe.Composite=Th;pe.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};pe.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};pe.prototype.GetterByBindingType=[pe.prototype._getValue_direct,pe.prototype._getValue_array,pe.prototype._getValue_arrayElement,pe.prototype._getValue_toArray];pe.prototype.SetterByBindingTypeAndVersioning=[[pe.prototype._setValue_direct,pe.prototype._setValue_direct_setNeedsUpdate,pe.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[pe.prototype._setValue_array,pe.prototype._setValue_array_setNeedsUpdate,pe.prototype._setValue_array_setMatrixWorldNeedsUpdate],[pe.prototype._setValue_arrayElement,pe.prototype._setValue_arrayElement_setNeedsUpdate,pe.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[pe.prototype._setValue_fromArray,pe.prototype._setValue_fromArray_setNeedsUpdate,pe.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var T0=new Float32Array(1);var _c=new we;class oa{constructor(t,e,n=0,i=1/0){this.ray=new jr(t,e),this.near=n,this.far=i,this.camera=null,this.layers=new qs,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){if(e.isPerspectiveCamera)this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,0.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e;else if(e.isOrthographicCamera)this.ray.origin.set(t.x,t.y,e.projectionMatrix.elements[14]).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e;else Gt("Raycaster: Unsupported camera type: "+e.type)}setFromXRController(t){return _c.identity().extractRotation(t.matrixWorld),this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(_c),this}intersectObject(t,e=!0,n=[]){return Va(t,this,n,e),n.sort(xc),n}intersectObjects(t,e=!0,n=[]){for(let i=0,s=t.length;i<s;i++)Va(t[i],this,n,e);return n.sort(xc),n}}function xc(t,e){return t.distance-e.distance}function Va(t,e,n,i){let s=!0;if(t.layers.test(e.layers)){if(t.raycast(e,n)===!1)s=!1}if(s===!0&&i===!0){let r=t.children;for(let a=0,o=r.length;a<o;a++)Va(r[a],e,n,!0)}}class Sl{static{Sl.prototype.isMatrix2=!0}constructor(t,e,n,i){if(this.elements=[1,0,0,1],t!==void 0)this.set(t,e,n,i)}identity(){return this.set(1,0,0,1),this}fromArray(t,e=0){for(let n=0;n<4;n++)this.elements[n]=t[n+e];return this}set(t,e,n,i){let s=this.elements;return s[0]=t,s[2]=e,s[1]=n,s[3]=i,this}}function Ml(t,e,n,i){let s=dd(i);switch(n){case 1021:return t*e;case 1028:return t*e/s.components*s.byteLength;case 1029:return t*e/s.components*s.byteLength;case 1030:return t*e*2/s.components*s.byteLength;case 1031:return t*e*2/s.components*s.byteLength;case 1022:return t*e*3/s.components*s.byteLength;case 1023:return t*e*4/s.components*s.byteLength;case 1033:return t*e*4/s.components*s.byteLength;case 33776:case 33777:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case 33778:case 33779:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case 35841:case 35843:return Math.max(t,16)*Math.max(e,8)/4;case 35840:case 35842:return Math.max(t,8)*Math.max(e,8)/2;case 36196:case 37492:case 37488:case 37489:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case 37496:case 37490:case 37491:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case 37808:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case 37809:return Math.floor((t+4)/5)*Math.floor((e+3)/4)*16;case 37810:return Math.floor((t+4)/5)*Math.floor((e+4)/5)*16;case 37811:return Math.floor((t+5)/6)*Math.floor((e+4)/5)*16;case 37812:return Math.floor((t+5)/6)*Math.floor((e+5)/6)*16;case 37813:return Math.floor((t+7)/8)*Math.floor((e+4)/5)*16;case 37814:return Math.floor((t+7)/8)*Math.floor((e+5)/6)*16;case 37815:return Math.floor((t+7)/8)*Math.floor((e+7)/8)*16;case 37816:return Math.floor((t+9)/10)*Math.floor((e+4)/5)*16;case 37817:return Math.floor((t+9)/10)*Math.floor((e+5)/6)*16;case 37818:return Math.floor((t+9)/10)*Math.floor((e+7)/8)*16;case 37819:return Math.floor((t+9)/10)*Math.floor((e+9)/10)*16;case 37820:return Math.floor((t+11)/12)*Math.floor((e+9)/10)*16;case 37821:return Math.floor((t+11)/12)*Math.floor((e+11)/12)*16;case 36492:case 36494:case 36495:return Math.ceil(t/4)*Math.ceil(e/4)*16;case 36283:case 36284:return Math.ceil(t/4)*Math.ceil(e/4)*8;case 36285:case 36286:return Math.ceil(t/4)*Math.ceil(e/4)*16}throw Error(`Unable to determine texture byte length for ${n} format.`)}function dd(t){switch(t){case 1009:case 1010:return{byteLength:1,components:1};case 1012:case 1011:case 1016:return{byteLength:2,components:1};case 1017:case 1018:return{byteLength:2,components:4};case 1014:case 1013:case 1015:return{byteLength:4,components:1};case 35902:case 35899:return{byteLength:4,components:3}}throw Error(`THREE.TextureUtils: Unknown texture type ${t}.`)}if(typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"186"}}));if(typeof window<"u")if(window.__THREE__)Ht("WARNING: Multiple instances of Three.js being imported.");else window.__THREE__="186";function qh(){let t=null,e=!1,n=null,i=null;function s(r,a){i=t.requestAnimationFrame(s),n(r,a)}return{start:function(){if(e===!0)return;if(n===null)return;if(t===null)return;i=t.requestAnimationFrame(s),e=!0},stop:function(){if(t!==null)t.cancelAnimationFrame(i);e=!1},setAnimationLoop:function(r){n=r},setContext:function(r){t=r}}}function fd(t){let e=new WeakMap;function n(o,l){let{array:c,usage:u}=o,d=c.byteLength,h=t.createBuffer();t.bindBuffer(l,h),t.bufferData(l,c,u),o.onUploadCallback();let p;if(c instanceof Float32Array)p=t.FLOAT;else if(typeof Float16Array<"u"&&c instanceof Float16Array)p=t.HALF_FLOAT;else if(c instanceof Uint16Array)if(o.isFloat16BufferAttribute)p=t.HALF_FLOAT;else p=t.UNSIGNED_SHORT;else if(c instanceof Int16Array)p=t.SHORT;else if(c instanceof Uint32Array)p=t.UNSIGNED_INT;else if(c instanceof Int32Array)p=t.INT;else if(c instanceof Int8Array)p=t.BYTE;else if(c instanceof Uint8Array)p=t.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)p=t.UNSIGNED_BYTE;else throw Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:h,type:p,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:d}}function i(o,l,c){let{array:u,updateRanges:d}=l;if(t.bindBuffer(c,o),d.length===0)t.bufferSubData(c,0,u);else{d.sort((p,v)=>p.start-v.start);let h=0;for(let p=1;p<d.length;p++){let v=d[h],T=d[p];if(T.start<=v.start+v.count+1)v.count=Math.max(v.count,T.start+T.count-v.start);else++h,d[h]=T}d.length=h+1;for(let p=0,v=d.length;p<v;p++){let T=d[p];t.bufferSubData(c,T.start*u.BYTES_PER_ELEMENT,u,T.start,T.count)}l.clearUpdateRanges()}l.onUploadCallback()}function s(o){if(o.isInterleavedBufferAttribute)o=o.data;return e.get(o)}function r(o){if(o.isInterleavedBufferAttribute)o=o.data;let l=e.get(o);if(l)t.deleteBuffer(l.buffer),e.delete(o)}function a(o,l){if(o.isInterleavedBufferAttribute)o=o.data;if(o.isGLBufferAttribute){let u=e.get(o);if(!u||u.version<o.version)e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}let c=e.get(o);if(c===void 0)e.set(o,n(o,l));else if(c.version<o.version){if(c.size!==o.array.byteLength)throw Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");i(c.buffer,o,l),c.version=o.version}}return{get:s,remove:r,update:a}}var pd=`#ifdef USE_ALPHAHASH
5
+ }`;class bn extends _i{constructor(t){super();if(this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=ed,this.fragmentShader=nd,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,t!==void 0)this.setValues(t)}copy(t){return super.copy(t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=Fi(t.uniforms),this.uniformsGroups=td(t.uniformsGroups),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.fog=t.fog,this.lights=t.lights,this.clipping=t.clipping,this.extensions=Object.assign({},t.extensions),this.glslVersion=t.glslVersion,this.defaultAttributeValues=Object.assign({},t.defaultAttributeValues),this.index0AttributeName=t.index0AttributeName,this.uniformsNeedUpdate=t.uniformsNeedUpdate,this}toJSON(t){let e=super.toJSON(t);e.glslVersion=this.glslVersion,e.uniforms={};for(let i in this.uniforms){let r=this.uniforms[i].value;if(r&&r.isTexture)e.uniforms[i]={type:"t",value:r.toJSON(t).uuid};else if(r&&r.isColor)e.uniforms[i]={type:"c",value:r.getHex()};else if(r&&r.isVector2)e.uniforms[i]={type:"v2",value:r.toArray()};else if(r&&r.isVector3)e.uniforms[i]={type:"v3",value:r.toArray()};else if(r&&r.isVector4)e.uniforms[i]={type:"v4",value:r.toArray()};else if(r&&r.isMatrix3)e.uniforms[i]={type:"m3",value:r.toArray()};else if(r&&r.isMatrix4)e.uniforms[i]={type:"m4",value:r.toArray()};else e.uniforms[i]={value:r}}if(Object.keys(this.defines).length>0)e.defines=this.defines;e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;let n={};for(let i in this.extensions)if(this.extensions[i]===!0)n[i]=!0;if(Object.keys(n).length>0)e.extensions=n;return e}fromJSON(t,e){if(super.fromJSON(t,e),t.uniforms!==void 0)for(let n in t.uniforms){let i=t.uniforms[n];switch(this.uniforms[n]={},i.type){case"t":this.uniforms[n].value=e[i.value]||null;break;case"c":this.uniforms[n].value=new Kt().setHex(i.value);break;case"v2":this.uniforms[n].value=new qt().fromArray(i.value);break;case"v3":this.uniforms[n].value=new O().fromArray(i.value);break;case"v4":this.uniforms[n].value=new Ae().fromArray(i.value);break;case"m3":this.uniforms[n].value=new Yt().fromArray(i.value);break;case"m4":this.uniforms[n].value=new we().fromArray(i.value);break;default:this.uniforms[n].value=i.value}}if(t.defines!==void 0)this.defines=t.defines;if(t.vertexShader!==void 0)this.vertexShader=t.vertexShader;if(t.fragmentShader!==void 0)this.fragmentShader=t.fragmentShader;if(t.glslVersion!==void 0)this.glslVersion=t.glslVersion;if(t.extensions!==void 0)for(let n in t.extensions)this.extensions[n]=t.extensions[n];if(t.lights!==void 0)this.lights=t.lights;if(t.clipping!==void 0)this.clipping=t.clipping;return this}}class sl extends bn{constructor(t){super(t);this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class ni extends _i{constructor(t){super();this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Kt(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Kt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new qt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.gradientMap=t.gradientMap,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}class rl extends _i{constructor(t){super();this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=3200,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}}class al extends _i{constructor(t){super();this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}}function ds(t,e){if(!t||t.constructor===e)return t;if(typeof e.BYTES_PER_ELEMENT==="number")return new e(t);return Array.prototype.slice.call(t)}function Ya(t){return t!==void 0&&t.inTangents!==void 0&&t.outTangents!==void 0}class Oi{constructor(t,e,n,i){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new e.constructor(n),this.sampleValues=e,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(t){let e=this.parameterPositions,n=this._cachedIndex,i=e[n],s=e[n-1];n:{t:{let r;e:{i:if(!(t<i)){for(let a=n+2;;){if(i===void 0){if(t<s)break i;return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(s=i,i=e[++n],t<i)break t}r=e.length;break e}if(!(t>=s)){let a=e[1];if(t<a)n=2,s=a;for(let o=n-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===o)break;if(i=s,s=e[--n-1],t>=s)break t}r=n,n=0;break e}break n}while(n<r){let a=n+r>>>1;if(t<e[a])r=a;else n=a+1}if(i=e[n],s=e[n-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,s,i)}return this.interpolate_(n,s,t,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){let e=this.resultBuffer,n=this.sampleValues,i=this.valueSize,s=t*i;for(let r=0;r!==i;++r)e[r]=n[s+r];return e}interpolate_(){throw Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}}class ol extends Oi{constructor(t,e,n,i){super(t,e,n,i);this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:2400,endingEnd:2400}}intervalChanged_(t,e,n){let i=this.parameterPositions,s=t-2,r=t+1,a=i[s],o=i[r];if(a===void 0)switch(this.getSettings_().endingStart){case 2401:s=t,a=2*e-n;break;case 2402:s=i.length-2,a=e+i[s]-i[s+1];break;default:s=t,a=n}if(o===void 0)switch(this.getSettings_().endingEnd){case 2401:r=t,o=2*n-e;break;case 2402:r=1,o=n+i[1]-i[0];break;default:r=t-1,o=e}let l=(n-e)*0.5,c=this.valueSize;this._weightPrev=l/(e-a),this._weightNext=l/(o-n),this._offsetPrev=s*c,this._offsetNext=r*c}interpolate_(t,e,n,i){let s=this.resultBuffer,r=this.sampleValues,a=this.valueSize,o=t*a,l=o-a,c=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,h=this._weightNext,p=(n-e)/(i-e),v=p*p,T=v*p,m=-d*T+2*d*v-d*p,f=(1+d)*T+(-1.5-2*d)*v+(-0.5+d)*p+1,w=(-1-h)*T+(1.5+h)*v+0.5*p,C=h*T-h*v;for(let y=0;y!==a;++y)s[y]=m*r[c+y]+f*r[l+y]+w*r[o+y]+C*r[u+y];return s}}class ll extends Oi{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){let s=this.resultBuffer,r=this.sampleValues,a=this.valueSize,o=t*a,l=o-a,c=(n-e)/(i-e),u=1-c;for(let d=0;d!==a;++d)s[d]=r[l+d]*u+r[o+d]*c;return s}}class cl extends Oi{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t){return this.copySampleValue_(t-1)}}class hl extends Oi{interpolate_(t,e,n,i){let s=this.resultBuffer,r=this.sampleValues,a=this.valueSize,o=t*a,l=o-a,c=this.inTangents,u=this.outTangents;if(!c||!u){let p=(n-e)/(i-e),v=1-p;for(let T=0;T!==a;++T)s[T]=r[l+T]*v+r[o+T]*p;return s}let d=a*2,h=t-1;for(let p=0;p!==a;++p){let v=r[l+p],T=r[o+p],m=h*d+p*2,f=u[m],w=u[m+1],C=t*d+p*2,y=c[C],b=c[C+1],A=sd(n,e,f,y,i);s[p]=Mh(A,v,w,b,T)}return s}}function Mh(t,e,n,i,s){let r=1-t;return r*r*r*e+3*r*r*t*n+3*r*t*t*i+t*t*t*s}function id(t,e,n,i,s){let r=1-t;return 3*r*r*(n-e)+6*r*t*(i-n)+3*t*t*(s-i)}function sd(t,e,n,i,s){let r=(t-e)/(s-e);for(let a=0;a<8;a++){let o=Mh(r,e,n,i,s)-t;if(Math.abs(o)<0.0000000001)break;let l=id(r,e,n,i,s);if(Math.abs(l)<0.0000000001)break;r=Math.max(0,Math.min(1,r-o/l))}return r}class Tn{constructor(t,e,n,i){if(t===void 0)throw Error("THREE.KeyframeTrack: track name is undefined");if(e===void 0||e.length===0)throw Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=ds(e,this.TimeBufferType),this.values=ds(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(t){let e=t.constructor,n;if(e.toJSON!==this.toJSON)n=e.toJSON(t);else{n={name:t.name,times:ds(t.times,Array),values:ds(t.values,Array)};let i=t.getInterpolation();if(i!==t.DefaultInterpolation)n.interpolation=i;if(Ya(t.settings))n.settings={inTangents:ds(t.settings.inTangents,Array),outTangents:ds(t.settings.outTangents,Array)}}return n.type=t.ValueTypeName,n}InterpolantFactoryMethodDiscrete(t){return new cl(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new ll(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new ol(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodBezier(t){let e=new hl(this.times,this.values,this.getValueSize(),t);if(this.settings)e.inTangents=this.settings.inTangents,e.outTangents=this.settings.outTangents;return e}setInterpolation(t){let e;switch(t){case 2300:e=this.InterpolantFactoryMethodDiscrete;break;case 2301:e=this.InterpolantFactoryMethodLinear;break;case 2302:e=this.InterpolantFactoryMethodSmooth;break;case 2303:e=this.InterpolantFactoryMethodBezier;break}if(e===void 0){let n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(t!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw Error(n);return Vt("KeyframeTrack:",n),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return 2300;case this.InterpolantFactoryMethodLinear:return 2301;case this.InterpolantFactoryMethodSmooth:return 2302;case this.InterpolantFactoryMethodBezier:return 2303}}getValueSize(){return this.values.length/this.times.length}shift(t){if(t!==0){let e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]+=t}return this}scale(t){if(t!==1){let e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]*=t;if(Ya(this.settings))fc(this.settings.inTangents,t),fc(this.settings.outTangents,t)}return this}trim(t,e){let n=this.times,i=n.length,s=0,r=i-1;while(s!==i&&n[s]<t)++s;while(r!==-1&&n[r]>e)--r;if(++r,s!==0||r!==i){if(s>=r)r=Math.max(r,1),s=r-1;let a=this.getValueSize();this.times=n.slice(s,r),this.values=this.values.slice(s*a,r*a)}return this}validate(){let t=!0,e=this.getValueSize();if(e-Math.floor(e)!==0)Ht("KeyframeTrack: Invalid value size in track.",this),t=!1;let n=this.times,i=this.values,s=n.length;if(s===0)Ht("KeyframeTrack: Track is empty.",this),t=!1;let r=null;for(let a=0;a!==s;a++){let o=n[a];if(typeof o==="number"&&isNaN(o)){Ht("KeyframeTrack: Time is not a valid number.",this,a,o),t=!1;break}if(r!==null&&r>o){Ht("KeyframeTrack: Out of order keys.",this,a,o,r),t=!1;break}r=o}if(i!==void 0){if(Du(i))for(let a=0,o=i.length;a!==o;++a){let l=i[a];if(isNaN(l)){Ht("KeyframeTrack: Value is not a valid number.",this,a,l),t=!1;break}}}return t}optimize(){let t=this.times.slice(),e=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===2302,s=t.length-1,r=1;for(let a=1;a<s;++a){let o=!1,l=t[a],c=t[a+1];if(l!==c&&(a!==1||l!==t[0]))if(!i){let u=a*n,d=u-n,h=u+n;for(let p=0;p!==n;++p){let v=e[u+p];if(v!==e[d+p]||v!==e[h+p]){o=!0;break}}}else o=!0;if(o){if(a!==r){t[r]=t[a];let u=a*n,d=r*n;for(let h=0;h!==n;++h)e[d+h]=e[u+h]}++r}}if(s>0){t[r]=t[s];for(let a=s*n,o=r*n,l=0;l!==n;++l)e[o+l]=e[a+l];++r}if(r!==t.length)this.times=t.slice(0,r),this.values=e.slice(0,r*n);else this.times=t,this.values=e;return this}clone(){let t=this.times.slice(),e=this.values.slice(),i=new this.constructor(this.name,t,e);if(i.createInterpolant=this.createInterpolant,Ya(this.settings))i.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()};return i}}function fc(t,e){for(let n=0,i=t.length;n!==i;n+=2)t[n]*=e}Tn.prototype.ValueTypeName="";Tn.prototype.TimeBufferType=Float32Array;Tn.prototype.ValueBufferType=Float32Array;Tn.prototype.DefaultInterpolation=2301;class Bi extends Tn{constructor(t,e,n){super(t,e,n)}}Bi.prototype.ValueTypeName="bool";Bi.prototype.ValueBufferType=Array;Bi.prototype.DefaultInterpolation=2300;Bi.prototype.InterpolantFactoryMethodLinear=void 0;Bi.prototype.InterpolantFactoryMethodSmooth=void 0;class ul extends Tn{constructor(t,e,n,i){super(t,e,n,i)}}ul.prototype.ValueTypeName="color";class dl extends Tn{constructor(t,e,n,i){super(t,e,n,i)}}dl.prototype.ValueTypeName="number";class fl extends Oi{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){let s=this.resultBuffer,r=this.sampleValues,a=this.valueSize,o=(n-e)/(i-e),l=t*a;for(let c=l+a;l!==c;l+=4)ei.slerpFlat(s,0,r,l-a,r,l,o);return s}}class la extends Tn{constructor(t,e,n,i){super(t,e,n,i)}InterpolantFactoryMethodLinear(t){return new fl(this.times,this.values,this.getValueSize(),t)}}la.prototype.ValueTypeName="quaternion";la.prototype.InterpolantFactoryMethodSmooth=void 0;class zi extends Tn{constructor(t,e,n){super(t,e,n)}}zi.prototype.ValueTypeName="string";zi.prototype.ValueBufferType=Array;zi.prototype.DefaultInterpolation=2300;zi.prototype.InterpolantFactoryMethodLinear=void 0;zi.prototype.InterpolantFactoryMethodSmooth=void 0;class pl extends Tn{constructor(t,e,n,i){super(t,e,n,i)}}pl.prototype.ValueTypeName="vector";class ml{constructor(t,e,n){let i=this,s=!1,r=0,a=0,o=void 0,l=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this._abortController=null,this.itemStart=function(c){if(a++,s===!1){if(i.onStart!==void 0)i.onStart(c,r,a)}s=!0},this.itemEnd=function(c){if(r++,i.onProgress!==void 0)i.onProgress(c,r,a);if(r===a){if(s=!1,i.onLoad!==void 0)i.onLoad()}},this.itemError=function(c){if(i.onError!==void 0)i.onError(c)},this.resolveURL=function(c){if(c=c.normalize("NFC"),o)return o(c);return c},this.setURLModifier=function(c){return o=c,this},this.addHandler=function(c,u){return l.push(c,u),this},this.removeHandler=function(c){let u=l.indexOf(c);if(u!==-1)l.splice(u,2);return this},this.getHandler=function(c){for(let u=0,d=l.length;u<d;u+=2){let h=l[u],p=l[u+1];if(h.global)h.lastIndex=0;if(h.test(c))return p}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){if(!this._abortController)this._abortController=new AbortController;return this._abortController}}var bh=new ml;class gl{constructor(t){if(this.manager=t!==void 0?t:bh,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(t,e){let n=this;return new Promise(function(i,s){n.load(t,i,e,s)})}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}abort(){return this}}gl.DEFAULT_MATERIAL_NAME="__DEFAULT";class ca extends He{constructor(t,e=1){super();this.isLight=!0,this.type="Light",this.color=new Kt(t),this.intensity=e}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){let e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,e}}var Za=new we,pc=new O,mc=new O;class _l{constructor(t){this.camera=t,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new qt(512,512),this.mapType=1009,this.map=null,this.mapPass=null,this.matrix=new we,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new ar,this._frameExtents=new qt(1,1),this._viewportCount=1,this._viewports=[new Ae(0,0,1,1)]}getViewportCount(){return this._viewportCount}getCamera(){return this.camera}getFrustum(){return this._frustum}updateMatrices(t){let e=this.camera;pc.setFromMatrixPosition(t.matrixWorld),e.position.copy(pc),mc.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(mc),e.updateMatrixWorld(),this._updateMatrix(e,this.matrix,this._frustum)}_updateMatrix(t,e,n,i){Za.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),n.setFromProjectionMatrix(Za,t.coordinateSystem,t.reversedDepth);let s=this._frameExtents,r=i?i.z/s.x:1,a=i?i.w/s.y:1,o=i?i.x/s.x:0,l=i?i.y/s.y:0;if(t.coordinateSystem===2001||t.reversedDepth)e.set(0.5*r,0,0,0.5*r+o,0,0.5*a,0,0.5*a+l,0,0,1,0,0,0,0,1);else e.set(0.5*r,0,0,0.5*r+o,0,0.5*a,0,0.5*a+l,0,0,0.5,0.5,0,0,0,1);e.multiply(Za)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){if(this.map)this.map.dispose();if(this.mapPass)this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.intensity=t.intensity,this.bias=t.bias,this.radius=t.radius,this.autoUpdate=t.autoUpdate,this.needsUpdate=t.needsUpdate,this.normalBias=t.normalBias,this.blurSamples=t.blurSamples,this.mapSize.copy(t.mapSize),this.biasNode=t.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){let t={};return t.intensity=this.intensity,t.bias=this.bias,t.normalBias=this.normalBias,t.radius=this.radius,t.blurSamples=this.blurSamples,t.mapSize=this.mapSize.toArray(),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}var zr=new O,kr=new ei,Dn=new O;class ha extends He{constructor(){super();this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new we,this.projectionMatrix=new we,this.projectionMatrixInverse=new we,this.coordinateSystem=2000,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){return super.getWorldDirection(t).negate()}updateMatrixWorld(t){if(super.updateMatrixWorld(t),this.matrixWorld.decompose(zr,kr,Dn),Dn.x===1&&Dn.y===1&&Dn.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(zr,kr,Dn.set(1,1,1)).invert()}updateWorldMatrix(t,e,n=!1){if(super.updateWorldMatrix(t,e,n),this.matrixWorld.decompose(zr,kr,Dn),Dn.x===1&&Dn.y===1&&Dn.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(zr,kr,Dn.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}var ui=new O,gc=new qt,_c=new qt;class nn extends ha{constructor(t=50,e=1,n=0.1,i=2000){super();this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=t.view===null?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){let e=0.5*this.getFilmHeight()/t;this.fov=Gr*2*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){let t=Math.tan(wa*0.5*this.fov);return 0.5*this.getFilmHeight()/t}getEffectiveFOV(){return Gr*2*Math.atan(Math.tan(wa*0.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(t,e,n){ui.set(-1,-1,0.5).applyMatrix4(this.projectionMatrixInverse),e.set(ui.x,ui.y).multiplyScalar(-t/ui.z),ui.set(1,1,0.5).applyMatrix4(this.projectionMatrixInverse),n.set(ui.x,ui.y).multiplyScalar(-t/ui.z)}getViewSize(t,e){return this.getViewBounds(t,gc,_c),e.subVectors(_c,gc)}setViewOffset(t,e,n,i,s,r){if(this.aspect=t/e,this.view===null)this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1};this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=s,this.view.height=r,this.updateProjectionMatrix()}clearViewOffset(){if(this.view!==null)this.view.enabled=!1;this.updateProjectionMatrix()}updateProjectionMatrix(){let t=this.near,e=t*Math.tan(wa*0.5*this.fov)/this.zoom,n=2*e,i=this.aspect*n,s=-0.5*i,r=this.view;if(this.view!==null&&this.view.enabled){let{fullWidth:o,fullHeight:l}=r;s+=r.offsetX*i/o,e-=r.offsetY*n/l,i*=r.width/o,n*=r.height/l}let a=this.filmOffset;if(a!==0)s+=t*a/this.getFilmWidth();this.projectionMatrix.makePerspective(s,s+i,e,e-n,t,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){let e=super.toJSON(t);if(e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,this.view!==null)e.object.view=Object.assign({},this.view);return e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}class or extends ha{constructor(t=-1,e=1,n=1,i=-1,s=0.1,r=2000){super();this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=n,this.bottom=i,this.near=s,this.far=r,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=t.view===null?null:Object.assign({},t.view),this}setViewOffset(t,e,n,i,s,r){if(this.view===null)this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1};this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=s,this.view.height=r,this.updateProjectionMatrix()}clearViewOffset(){if(this.view!==null)this.view.enabled=!1;this.updateProjectionMatrix()}updateProjectionMatrix(){let t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2,s=n-t,r=n+t,a=i+e,o=i-e;if(this.view!==null&&this.view.enabled){let l=(this.right-this.left)/this.view.fullWidth/this.zoom,c=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=l*this.view.offsetX,r=s+l*this.view.width,a-=c*this.view.offsetY,o=a-c*this.view.height}this.projectionMatrix.makeOrthographic(s,r,a,o,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){let e=super.toJSON(t);if(e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,this.view!==null)e.object.view=Object.assign({},this.view);return e}}class Th extends _l{constructor(){super(new or(-5,5,5,-5,0.5,500));this.isDirectionalLightShadow=!0}}class ua extends ca{constructor(t,e){super(t,e);this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(He.DEFAULT_UP),this.updateMatrix(),this.target=new He,this.shadow=new Th}dispose(){super.dispose(),this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}toJSON(t){let e=super.toJSON(t);return e.object.shadow=this.shadow.toJSON(),e.object.target=this.target.uuid,e}}class da extends ca{constructor(t,e){super(t,e);this.isAmbientLight=!0,this.type="AmbientLight"}}var fs=-90,ps=1;class xl extends He{constructor(t,e,n){super();this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let i=new nn(fs,ps,t,e);i.layers=this.layers,this.add(i);let s=new nn(fs,ps,t,e);s.layers=this.layers,this.add(s);let r=new nn(fs,ps,t,e);r.layers=this.layers,this.add(r);let a=new nn(fs,ps,t,e);a.layers=this.layers,this.add(a);let o=new nn(fs,ps,t,e);o.layers=this.layers,this.add(o);let l=new nn(fs,ps,t,e);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){let t=this.coordinateSystem,e=this.children.concat(),[n,i,s,r,a,o]=e;for(let l of e)this.remove(l);if(t===2000)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),r.up.set(0,0,1),r.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),o.up.set(0,1,0),o.lookAt(0,0,-1);else if(t===2001)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),r.up.set(0,0,-1),r.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),o.up.set(0,-1,0),o.lookAt(0,0,-1);else throw Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);for(let l of e)this.add(l),l.updateMatrixWorld()}update(t,e){if(this.parent===null)this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:i}=this;if(this.coordinateSystem!==t.coordinateSystem)this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem();let[s,r,a,o,l,c]=this.children,u=t.getRenderTarget(),d=t.getActiveCubeFace(),h=t.getActiveMipmapLevel(),p=t.xr.enabled;t.xr.enabled=!1;let v=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let T=!1;if(t.isWebGLRenderer===!0)T=t.state.buffers.depth.getReversed();else T=t.reversedDepthBuffer;if(t.setRenderTarget(n,0,i),T&&t.autoClear===!1)t.clearDepth();if(t.render(e,s),t.setRenderTarget(n,1,i),T&&t.autoClear===!1)t.clearDepth();if(t.render(e,r),t.setRenderTarget(n,2,i),T&&t.autoClear===!1)t.clearDepth();if(t.render(e,a),t.setRenderTarget(n,3,i),T&&t.autoClear===!1)t.clearDepth();if(t.render(e,o),t.setRenderTarget(n,4,i),T&&t.autoClear===!1)t.clearDepth();if(t.render(e,l),n.texture.generateMipmaps=v,t.setRenderTarget(n,5,i),T&&t.autoClear===!1)t.clearDepth();t.render(e,c),t.setRenderTarget(u,d,h),t.xr.enabled=p,n.texture.needsPMREMUpdate=!0}}class vl extends nn{constructor(t=[]){super();this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=t}}var yl="\\[\\]\\.:\\/",rd=new RegExp("["+yl+"]","g"),Sl="[^"+yl+"]",ad="[^"+yl.replace("\\.","")+"]",od=/((?:WC+[\/:])*)/.source.replace("WC",Sl),ld=/(WCOD+)?/.source.replace("WCOD",ad),cd=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Sl),hd=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Sl),ud=new RegExp("^"+od+ld+cd+hd+"$"),dd=["material","materials","bones","map"];class wh{constructor(t,e,n){let i=n||pe.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,i)}getValue(t,e){this.bind();let n=this._targetGroup.nCachedObjects_,i=this._bindings[n];if(i!==void 0)i.getValue(t,e)}setValue(t,e){let n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=n.length;i!==s;++i)n[i].setValue(t,e)}bind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].bind()}unbind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].unbind()}}class pe{constructor(t,e,n){this.path=e,this.parsedPath=n||pe.parseTrackName(e),this.node=pe.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,n){if(!(t&&t.isAnimationObjectGroup))return new pe(t,e,n);else return new pe.Composite(t,e,n)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(rd,"")}static parseTrackName(t){let e=ud.exec(t);if(e===null)throw Error("THREE.PropertyBinding: Cannot parse trackName: "+t);let n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){let s=n.nodeName.substring(i+1);if(dd.indexOf(s)!==-1)n.nodeName=n.nodeName.substring(0,i),n.objectName=s}if(n.propertyName===null||n.propertyName.length===0)throw Error("THREE.PropertyBinding: can not parse propertyName from trackName: "+t);return n}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){let n=t.skeleton.getBoneByName(e);if(n!==void 0)return n}if(t.children){let n=function(s){for(let r=0;r<s.length;r++){let a=s[r];if(a.name===e||a.uuid===e)return a;let o=n(a.children);if(o)return o}return null},i=n(t.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)t[e++]=n[i]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=t[e++]}_setValue_array_setNeedsUpdate(t,e){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node,e=this.parsedPath,{objectName:n,propertyName:i,propertyIndex:s}=e;if(!t)t=pe.findNode(this.rootNode,e.nodeName),this.node=t;if(this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){Vt("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let l=e.objectIndex;switch(n){case"materials":if(!t.material){Ht("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.materials){Ht("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}t=t.material.materials;break;case"bones":if(!t.skeleton){Ht("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}t=t.skeleton.bones;for(let c=0;c<t.length;c++)if(t[c].name===l){l=c;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material){Ht("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.map){Ht("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}t=t.material.map;break;default:if(t[n]===void 0){Ht("PropertyBinding: Can not bind to objectName of node undefined.",this);return}t=t[n]}if(l!==void 0){if(t[l]===void 0){Ht("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);return}t=t[l]}}let r=t[i];if(r===void 0){let l=e.nodeName;Ht("PropertyBinding: Trying to update property for track: "+l+"."+i+" but it wasn't found.",t);return}let a=this.Versioning.None;if(this.targetObject=t,t.isMaterial===!0)a=this.Versioning.NeedsUpdate;else if(t.isObject3D===!0)a=this.Versioning.MatrixWorldNeedsUpdate;let o=this.BindingType.Direct;if(s!==void 0){if(i==="morphTargetInfluences"){if(!t.geometry){Ht("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!t.geometry.morphAttributes){Ht("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}if(t.morphTargetDictionary[s]!==void 0)s=t.morphTargetDictionary[s]}o=this.BindingType.ArrayElement,this.resolvedProperty=r,this.propertyIndex=s}else if(r.fromArray!==void 0&&r.toArray!==void 0)o=this.BindingType.HasFromToArray,this.resolvedProperty=r;else if(Array.isArray(r))o=this.BindingType.EntireArray,this.resolvedProperty=r;else this.propertyName=i;this.getValue=this.GetterByBindingType[o],this.setValue=this.SetterByBindingTypeAndVersioning[o][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}pe.Composite=wh;pe.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};pe.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};pe.prototype.GetterByBindingType=[pe.prototype._getValue_direct,pe.prototype._getValue_array,pe.prototype._getValue_arrayElement,pe.prototype._getValue_toArray];pe.prototype.SetterByBindingTypeAndVersioning=[[pe.prototype._setValue_direct,pe.prototype._setValue_direct_setNeedsUpdate,pe.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[pe.prototype._setValue_array,pe.prototype._setValue_array_setNeedsUpdate,pe.prototype._setValue_array_setMatrixWorldNeedsUpdate],[pe.prototype._setValue_arrayElement,pe.prototype._setValue_arrayElement_setNeedsUpdate,pe.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[pe.prototype._setValue_fromArray,pe.prototype._setValue_fromArray_setNeedsUpdate,pe.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var w0=new Float32Array(1);var xc=new we;class fa{constructor(t,e,n=0,i=1/0){this.ray=new ra(t,e),this.near=n,this.far=i,this.camera=null,this.layers=new tr,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){if(e.isPerspectiveCamera)this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,0.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e;else if(e.isOrthographicCamera)this.ray.origin.set(t.x,t.y,e.projectionMatrix.elements[14]).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e;else Ht("Raycaster: Unsupported camera type: "+e.type)}setFromXRController(t){return xc.identity().extractRotation(t.matrixWorld),this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(xc),this}intersectObject(t,e=!0,n=[]){return Ja(t,this,n,e),n.sort(vc),n}intersectObjects(t,e=!0,n=[]){for(let i=0,s=t.length;i<s;i++)Ja(t[i],this,n,e);return n.sort(vc),n}}function vc(t,e){return t.distance-e.distance}function Ja(t,e,n,i){let s=!0;if(t.layers.test(e.layers)){if(t.raycast(e,n)===!1)s=!1}if(s===!0&&i===!0){let r=t.children;for(let a=0,o=r.length;a<o;a++)Ja(r[a],e,n,!0)}}class Ml{static{Ml.prototype.isMatrix2=!0}constructor(t,e,n,i){if(this.elements=[1,0,0,1],t!==void 0)this.set(t,e,n,i)}identity(){return this.set(1,0,0,1),this}fromArray(t,e=0){for(let n=0;n<4;n++)this.elements[n]=t[n+e];return this}set(t,e,n,i){let s=this.elements;return s[0]=t,s[2]=e,s[1]=n,s[3]=i,this}}function bl(t,e,n,i){let s=fd(i);switch(n){case 1021:return t*e;case 1028:return t*e/s.components*s.byteLength;case 1029:return t*e/s.components*s.byteLength;case 1030:return t*e*2/s.components*s.byteLength;case 1031:return t*e*2/s.components*s.byteLength;case 1022:return t*e*3/s.components*s.byteLength;case 1023:return t*e*4/s.components*s.byteLength;case 1033:return t*e*4/s.components*s.byteLength;case 33776:case 33777:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case 33778:case 33779:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case 35841:case 35843:return Math.max(t,16)*Math.max(e,8)/4;case 35840:case 35842:return Math.max(t,8)*Math.max(e,8)/2;case 36196:case 37492:case 37488:case 37489:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case 37496:case 37490:case 37491:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case 37808:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case 37809:return Math.floor((t+4)/5)*Math.floor((e+3)/4)*16;case 37810:return Math.floor((t+4)/5)*Math.floor((e+4)/5)*16;case 37811:return Math.floor((t+5)/6)*Math.floor((e+4)/5)*16;case 37812:return Math.floor((t+5)/6)*Math.floor((e+5)/6)*16;case 37813:return Math.floor((t+7)/8)*Math.floor((e+4)/5)*16;case 37814:return Math.floor((t+7)/8)*Math.floor((e+5)/6)*16;case 37815:return Math.floor((t+7)/8)*Math.floor((e+7)/8)*16;case 37816:return Math.floor((t+9)/10)*Math.floor((e+4)/5)*16;case 37817:return Math.floor((t+9)/10)*Math.floor((e+5)/6)*16;case 37818:return Math.floor((t+9)/10)*Math.floor((e+7)/8)*16;case 37819:return Math.floor((t+9)/10)*Math.floor((e+9)/10)*16;case 37820:return Math.floor((t+11)/12)*Math.floor((e+9)/10)*16;case 37821:return Math.floor((t+11)/12)*Math.floor((e+11)/12)*16;case 36492:case 36494:case 36495:return Math.ceil(t/4)*Math.ceil(e/4)*16;case 36283:case 36284:return Math.ceil(t/4)*Math.ceil(e/4)*8;case 36285:case 36286:return Math.ceil(t/4)*Math.ceil(e/4)*16}throw Error(`Unable to determine texture byte length for ${n} format.`)}function fd(t){switch(t){case 1009:case 1010:return{byteLength:1,components:1};case 1012:case 1011:case 1016:return{byteLength:2,components:1};case 1017:case 1018:return{byteLength:2,components:4};case 1014:case 1013:case 1015:return{byteLength:4,components:1};case 35902:case 35899:return{byteLength:4,components:3}}throw Error(`THREE.TextureUtils: Unknown texture type ${t}.`)}if(typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"186"}}));if(typeof window<"u")if(window.__THREE__)Vt("WARNING: Multiple instances of Three.js being imported.");else window.__THREE__="186";function Yh(){let t=null,e=!1,n=null,i=null;function s(r,a){i=t.requestAnimationFrame(s),n(r,a)}return{start:function(){if(e===!0)return;if(n===null)return;if(t===null)return;i=t.requestAnimationFrame(s),e=!0},stop:function(){if(t!==null)t.cancelAnimationFrame(i);e=!1},setAnimationLoop:function(r){n=r},setContext:function(r){t=r}}}function pd(t){let e=new WeakMap;function n(o,l){let{array:c,usage:u}=o,d=c.byteLength,h=t.createBuffer();t.bindBuffer(l,h),t.bufferData(l,c,u),o.onUploadCallback();let p;if(c instanceof Float32Array)p=t.FLOAT;else if(typeof Float16Array<"u"&&c instanceof Float16Array)p=t.HALF_FLOAT;else if(c instanceof Uint16Array)if(o.isFloat16BufferAttribute)p=t.HALF_FLOAT;else p=t.UNSIGNED_SHORT;else if(c instanceof Int16Array)p=t.SHORT;else if(c instanceof Uint32Array)p=t.UNSIGNED_INT;else if(c instanceof Int32Array)p=t.INT;else if(c instanceof Int8Array)p=t.BYTE;else if(c instanceof Uint8Array)p=t.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)p=t.UNSIGNED_BYTE;else throw Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:h,type:p,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:d}}function i(o,l,c){let{array:u,updateRanges:d}=l;if(t.bindBuffer(c,o),d.length===0)t.bufferSubData(c,0,u);else{d.sort((p,v)=>p.start-v.start);let h=0;for(let p=1;p<d.length;p++){let v=d[h],T=d[p];if(T.start<=v.start+v.count+1)v.count=Math.max(v.count,T.start+T.count-v.start);else++h,d[h]=T}d.length=h+1;for(let p=0,v=d.length;p<v;p++){let T=d[p];t.bufferSubData(c,T.start*u.BYTES_PER_ELEMENT,u,T.start,T.count)}l.clearUpdateRanges()}l.onUploadCallback()}function s(o){if(o.isInterleavedBufferAttribute)o=o.data;return e.get(o)}function r(o){if(o.isInterleavedBufferAttribute)o=o.data;let l=e.get(o);if(l)t.deleteBuffer(l.buffer),e.delete(o)}function a(o,l){if(o.isInterleavedBufferAttribute)o=o.data;if(o.isGLBufferAttribute){let u=e.get(o);if(!u||u.version<o.version)e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}let c=e.get(o);if(c===void 0)e.set(o,n(o,l));else if(c.version<o.version){if(c.size!==o.array.byteLength)throw Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");i(c.buffer,o,l),c.version=o.version}}return{get:s,remove:r,update:a}}var md=`#ifdef USE_ALPHAHASH
6
6
  if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
7
- #endif`,md=`#ifdef USE_ALPHAHASH
7
+ #endif`,gd=`#ifdef USE_ALPHAHASH
8
8
  const float ALPHA_HASH_SCALE = 0.05;
9
9
  float hash2D( vec2 value ) {
10
10
  return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
@@ -39,20 +39,20 @@ import{zr}from"./chunk-index-cn49mawx.js";import{nn,Tn,cr,rn,Lt,oo,Ts,yt,Ps,Zn,Q
39
39
  : cases.z;
40
40
  return clamp( threshold , 1.0e-6, 1.0 );
41
41
  }
42
- #endif`,gd=`#ifdef USE_ALPHAMAP
43
- diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
44
42
  #endif`,_d=`#ifdef USE_ALPHAMAP
43
+ diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
44
+ #endif`,xd=`#ifdef USE_ALPHAMAP
45
45
  uniform sampler2D alphaMap;
46
- #endif`,xd=`#ifdef USE_ALPHATEST
46
+ #endif`,vd=`#ifdef USE_ALPHATEST
47
47
  #ifdef ALPHA_TO_COVERAGE
48
48
  diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
49
49
  if ( diffuseColor.a == 0.0 ) discard;
50
50
  #else
51
51
  if ( diffuseColor.a < alphaTest ) discard;
52
52
  #endif
53
- #endif`,vd=`#ifdef USE_ALPHATEST
53
+ #endif`,yd=`#ifdef USE_ALPHATEST
54
54
  uniform float alphaTest;
55
- #endif`,yd=`#ifdef USE_AOMAP
55
+ #endif`,Sd=`#ifdef USE_AOMAP
56
56
  float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
57
57
  reflectedLight.indirectDiffuse *= ambientOcclusion;
58
58
  #if defined( USE_CLEARCOAT )
@@ -65,10 +65,10 @@ import{zr}from"./chunk-index-cn49mawx.js";import{nn,Tn,cr,rn,Lt,oo,Ts,yt,Ps,Zn,Q
65
65
  float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
66
66
  reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
67
67
  #endif
68
- #endif`,Sd=`#ifdef USE_AOMAP
68
+ #endif`,Md=`#ifdef USE_AOMAP
69
69
  uniform sampler2D aoMap;
70
70
  uniform float aoMapIntensity;
71
- #endif`,Md=`#ifdef USE_BATCHING
71
+ #endif`,bd=`#ifdef USE_BATCHING
72
72
  #if ! defined( GL_ANGLE_multi_draw )
73
73
  #define gl_DrawID _gl_DrawID
74
74
  uniform int _gl_DrawID;
@@ -102,15 +102,15 @@ import{zr}from"./chunk-index-cn49mawx.js";import{nn,Tn,cr,rn,Lt,oo,Ts,yt,Ps,Zn,Q
102
102
  int y = j / size;
103
103
  return texelFetch( batchingColorTexture, ivec2( x, y ), 0 );
104
104
  }
105
- #endif`,bd=`#ifdef USE_BATCHING
105
+ #endif`,Td=`#ifdef USE_BATCHING
106
106
  mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
107
- #endif`,Td=`vec3 transformed = vec3( position );
107
+ #endif`,wd=`vec3 transformed = vec3( position );
108
108
  #ifdef USE_ALPHAHASH
109
109
  vPosition = vec3( position );
110
- #endif`,wd=`vec3 objectNormal = vec3( normal );
110
+ #endif`,Ed=`vec3 objectNormal = vec3( normal );
111
111
  #ifdef USE_TANGENT
112
112
  vec3 objectTangent = vec3( tangent.xyz );
113
- #endif`,Ed=`float G_BlinnPhong_Implicit( ) {
113
+ #endif`,Ad=`float G_BlinnPhong_Implicit( ) {
114
114
  return 0.25;
115
115
  }
116
116
  float D_BlinnPhong( const in float shininess, const in float dotNH ) {
@@ -124,7 +124,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
124
124
  float G = G_BlinnPhong_Implicit( );
125
125
  float D = D_BlinnPhong( shininess, dotNH );
126
126
  return F * ( G * D );
127
- } // validated`,Ad=`#ifdef USE_IRIDESCENCE
127
+ } // validated`,Cd=`#ifdef USE_IRIDESCENCE
128
128
  const mat3 XYZ_TO_REC709 = mat3(
129
129
  3.2404542, -0.9692660, 0.0556434,
130
130
  -1.5371385, 1.8760108, -0.2040259,
@@ -187,7 +187,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
187
187
  }
188
188
  return max( I, vec3( 0.0 ) );
189
189
  }
190
- #endif`,Cd=`#ifdef USE_BUMPMAP
190
+ #endif`,Rd=`#ifdef USE_BUMPMAP
191
191
  uniform sampler2D bumpMap;
192
192
  uniform float bumpScale;
193
193
  vec2 dHdxy_fwd() {
@@ -208,7 +208,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
208
208
  vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
209
209
  return normalize( abs( fDet ) * surf_norm - vGrad );
210
210
  }
211
- #endif`,Rd=`#if NUM_CLIPPING_PLANES > 0
211
+ #endif`,Id=`#if NUM_CLIPPING_PLANES > 0
212
212
  vec4 plane;
213
213
  #ifdef ALPHA_TO_COVERAGE
214
214
  float distanceToPlane, distanceGradient;
@@ -254,20 +254,20 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
254
254
  if ( clipped ) discard;
255
255
  #endif
256
256
  #endif
257
- #endif`,Id=`#if NUM_CLIPPING_PLANES > 0
258
- varying vec3 vClipPosition;
259
- uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
260
257
  #endif`,Pd=`#if NUM_CLIPPING_PLANES > 0
261
258
  varying vec3 vClipPosition;
259
+ uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
262
260
  #endif`,Ld=`#if NUM_CLIPPING_PLANES > 0
261
+ varying vec3 vClipPosition;
262
+ #endif`,Nd=`#if NUM_CLIPPING_PLANES > 0
263
263
  vClipPosition = - mvPosition.xyz;
264
- #endif`,Nd=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
265
- diffuseColor *= vColor;
266
264
  #endif`,Dd=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
267
- varying vec4 vColor;
268
- #endif`,Ud=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
265
+ diffuseColor *= vColor;
266
+ #endif`,Ud=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
269
267
  varying vec4 vColor;
270
268
  #endif`,Fd=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
269
+ varying vec4 vColor;
270
+ #endif`,Od=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
271
271
  vColor = vec4( 1.0 );
272
272
  #endif
273
273
  #ifdef USE_COLOR_ALPHA
@@ -280,7 +280,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
280
280
  #endif
281
281
  #ifdef USE_BATCHING_COLOR
282
282
  vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) );
283
- #endif`,Od=`#define PI 3.141592653589793
283
+ #endif`,Bd=`#define PI 3.141592653589793
284
284
  #define PI2 6.283185307179586
285
285
  #define PI_HALF 1.5707963267948966
286
286
  #define RECIPROCAL_PI 0.3183098861837907
@@ -351,7 +351,7 @@ vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
351
351
  float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
352
352
  float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
353
353
  return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
354
- } // validated`,Bd=`#ifdef ENVMAP_TYPE_CUBE_UV
354
+ } // validated`,zd=`#ifdef ENVMAP_TYPE_CUBE_UV
355
355
  #define cubeUV_minMipLevel 4.0
356
356
  #define cubeUV_minTileSize 16.0
357
357
  float getFace( vec3 direction ) {
@@ -444,7 +444,7 @@ float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
444
444
  return vec4( mix( color0, color1, mipF ), 1.0 );
445
445
  }
446
446
  }
447
- #endif`,zd=`vec3 transformedNormal = objectNormal;
447
+ #endif`,kd=`vec3 transformedNormal = objectNormal;
448
448
  #ifdef USE_TANGENT
449
449
  vec3 transformedTangent = objectTangent;
450
450
  #endif
@@ -470,21 +470,21 @@ transformedNormal = normalMatrix * transformedNormal;
470
470
  #endif
471
471
  #ifdef USE_TANGENT
472
472
  transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
473
- #endif`,kd=`#ifdef USE_DISPLACEMENTMAP
473
+ #endif`,Gd=`#ifdef USE_DISPLACEMENTMAP
474
474
  uniform sampler2D displacementMap;
475
475
  uniform float displacementScale;
476
476
  uniform float displacementBias;
477
- #endif`,Gd=`#ifdef USE_DISPLACEMENTMAP
477
+ #endif`,Hd=`#ifdef USE_DISPLACEMENTMAP
478
478
  transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
479
- #endif`,Hd=`#ifdef USE_EMISSIVEMAP
479
+ #endif`,Vd=`#ifdef USE_EMISSIVEMAP
480
480
  vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
481
481
  #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
482
482
  emissiveColor = sRGBTransferEOTF( emissiveColor );
483
483
  #endif
484
484
  totalEmissiveRadiance *= emissiveColor.rgb;
485
- #endif`,Vd=`#ifdef USE_EMISSIVEMAP
485
+ #endif`,Wd=`#ifdef USE_EMISSIVEMAP
486
486
  uniform sampler2D emissiveMap;
487
- #endif`,Wd="gl_FragColor = linearToOutputTexel( gl_FragColor );",Xd=`vec4 LinearTransferOETF( in vec4 value ) {
487
+ #endif`,Xd="gl_FragColor = linearToOutputTexel( gl_FragColor );",qd=`vec4 LinearTransferOETF( in vec4 value ) {
488
488
  return value;
489
489
  }
490
490
  vec4 sRGBTransferEOTF( in vec4 value ) {
@@ -492,7 +492,7 @@ vec4 sRGBTransferEOTF( in vec4 value ) {
492
492
  }
493
493
  vec4 sRGBTransferOETF( in vec4 value ) {
494
494
  return 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 );
495
- }`,qd=`#ifdef USE_ENVMAP
495
+ }`,Yd=`#ifdef USE_ENVMAP
496
496
  #ifdef ENV_WORLDPOS
497
497
  vec3 cameraToFrag;
498
498
  if ( isOrthographic ) {
@@ -519,7 +519,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
519
519
  outgoingLight += envColor.xyz * specularStrength * reflectivity;
520
520
  #endif
521
521
  #endif
522
- #endif`,Yd=`#ifdef USE_ENVMAP
522
+ #endif`,Zd=`#ifdef USE_ENVMAP
523
523
  uniform float envMapIntensity;
524
524
  uniform mat3 envMapRotation;
525
525
  #ifdef ENVMAP_TYPE_CUBE
@@ -527,7 +527,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
527
527
  #else
528
528
  uniform sampler2D envMap;
529
529
  #endif
530
- #endif`,Zd=`#ifdef USE_ENVMAP
530
+ #endif`,Jd=`#ifdef USE_ENVMAP
531
531
  uniform float reflectivity;
532
532
  #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
533
533
  #define ENV_WORLDPOS
@@ -538,7 +538,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
538
538
  #else
539
539
  varying vec3 vReflect;
540
540
  #endif
541
- #endif`,Jd=`#ifdef USE_ENVMAP
541
+ #endif`,$d=`#ifdef USE_ENVMAP
542
542
  #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
543
543
  #define ENV_WORLDPOS
544
544
  #endif
@@ -549,7 +549,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
549
549
  varying vec3 vReflect;
550
550
  uniform float refractionRatio;
551
551
  #endif
552
- #endif`,$d=`#ifdef USE_ENVMAP
552
+ #endif`,Kd=`#ifdef USE_ENVMAP
553
553
  #ifdef ENV_WORLDPOS
554
554
  vWorldPosition = worldPosition.xyz;
555
555
  #else
@@ -566,18 +566,18 @@ vec4 sRGBTransferOETF( in vec4 value ) {
566
566
  vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
567
567
  #endif
568
568
  #endif
569
- #endif`,Kd=`#ifdef USE_FOG
570
- vFogDepth = - mvPosition.z;
571
569
  #endif`,Qd=`#ifdef USE_FOG
572
- varying float vFogDepth;
570
+ vFogDepth = - mvPosition.z;
573
571
  #endif`,jd=`#ifdef USE_FOG
572
+ varying float vFogDepth;
573
+ #endif`,tf=`#ifdef USE_FOG
574
574
  #ifdef FOG_EXP2
575
575
  float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
576
576
  #else
577
577
  float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
578
578
  #endif
579
579
  gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
580
- #endif`,tf=`#ifdef USE_FOG
580
+ #endif`,ef=`#ifdef USE_FOG
581
581
  uniform vec3 fogColor;
582
582
  varying float vFogDepth;
583
583
  #ifdef FOG_EXP2
@@ -586,7 +586,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
586
586
  uniform float fogNear;
587
587
  uniform float fogFar;
588
588
  #endif
589
- #endif`,ef=`#ifdef USE_GRADIENTMAP
589
+ #endif`,nf=`#ifdef USE_GRADIENTMAP
590
590
  uniform sampler2D gradientMap;
591
591
  #endif
592
592
  vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
@@ -598,12 +598,12 @@ vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
598
598
  vec2 fw = fwidth( coord ) * 0.5;
599
599
  return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
600
600
  #endif
601
- }`,nf=`#ifdef USE_LIGHTMAP
601
+ }`,sf=`#ifdef USE_LIGHTMAP
602
602
  uniform sampler2D lightMap;
603
603
  uniform float lightMapIntensity;
604
- #endif`,sf=`LambertMaterial material;
604
+ #endif`,rf=`LambertMaterial material;
605
605
  material.diffuseColor = diffuseColor.rgb;
606
- material.specularStrength = specularStrength;`,rf=`varying vec3 vViewPosition;
606
+ material.specularStrength = specularStrength;`,af=`varying vec3 vViewPosition;
607
607
  struct LambertMaterial {
608
608
  vec3 diffuseColor;
609
609
  float specularStrength;
@@ -617,7 +617,7 @@ void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometr
617
617
  reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
618
618
  }
619
619
  #define RE_Direct RE_Direct_Lambert
620
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,af=`uniform bool receiveShadow;
620
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,of=`uniform bool receiveShadow;
621
621
  uniform vec3 ambientLightColor;
622
622
  #if defined( USE_LIGHT_PROBES )
623
623
  uniform vec3 lightProbe[ 9 ];
@@ -746,7 +746,7 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
746
746
  return irradiance;
747
747
  }
748
748
  #endif
749
- #include <lightprobes_pars_fragment>`,of=`#ifdef USE_ENVMAP
749
+ #include <lightprobes_pars_fragment>`,lf=`#ifdef USE_ENVMAP
750
750
  vec3 getIBLIrradiance( const in vec3 normal ) {
751
751
  #ifdef ENVMAP_TYPE_CUBE_UV
752
752
  vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );
@@ -803,8 +803,8 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
803
803
  }
804
804
  #endif
805
805
  #endif
806
- #endif`,lf=`ToonMaterial material;
807
- material.diffuseColor = diffuseColor.rgb;`,cf=`varying vec3 vViewPosition;
806
+ #endif`,cf=`ToonMaterial material;
807
+ material.diffuseColor = diffuseColor.rgb;`,hf=`varying vec3 vViewPosition;
808
808
  struct ToonMaterial {
809
809
  vec3 diffuseColor;
810
810
  };
@@ -816,11 +816,11 @@ void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPo
816
816
  reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
817
817
  }
818
818
  #define RE_Direct RE_Direct_Toon
819
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,hf=`BlinnPhongMaterial material;
819
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,uf=`BlinnPhongMaterial material;
820
820
  material.diffuseColor = diffuseColor.rgb;
821
821
  material.specularColor = specular;
822
822
  material.specularShininess = shininess;
823
- material.specularStrength = specularStrength;`,uf=`varying vec3 vViewPosition;
823
+ material.specularStrength = specularStrength;`,df=`varying vec3 vViewPosition;
824
824
  struct BlinnPhongMaterial {
825
825
  vec3 diffuseColor;
826
826
  vec3 specularColor;
@@ -837,7 +837,7 @@ void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geom
837
837
  reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
838
838
  }
839
839
  #define RE_Direct RE_Direct_BlinnPhong
840
- #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,df=`PhysicalMaterial material;
840
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,ff=`PhysicalMaterial material;
841
841
  material.diffuseColor = diffuseColor.rgb;
842
842
  material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );
843
843
  material.metalness = metalnessFactor;
@@ -930,7 +930,7 @@ material.roughness = min( material.roughness, 1.0 );
930
930
  material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
931
931
  material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
932
932
  material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
933
- #endif`,ff=`uniform sampler2D dfgLUT;
933
+ #endif`,pf=`uniform sampler2D dfgLUT;
934
934
  struct PhysicalMaterial {
935
935
  vec3 diffuseColor;
936
936
  vec3 diffuseContribution;
@@ -1297,7 +1297,7 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia
1297
1297
  #define RE_IndirectSpecular RE_IndirectSpecular_Physical
1298
1298
  float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
1299
1299
  return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
1300
- }`,pf=`
1300
+ }`,mf=`
1301
1301
  vec3 geometryPosition = - vViewPosition;
1302
1302
  vec3 geometryNormal = normal;
1303
1303
  vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
@@ -1445,7 +1445,7 @@ IncidentLight directLight;
1445
1445
  #if defined( RE_IndirectSpecular )
1446
1446
  vec3 radiance = vec3( 0.0 );
1447
1447
  vec3 clearcoatRadiance = vec3( 0.0 );
1448
- #endif`,mf=`#if defined( RE_IndirectDiffuse )
1448
+ #endif`,gf=`#if defined( RE_IndirectDiffuse )
1449
1449
  #ifdef USE_LIGHTMAP
1450
1450
  vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
1451
1451
  vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
@@ -1475,7 +1475,7 @@ IncidentLight directLight;
1475
1475
  #ifdef USE_CLEARCOAT
1476
1476
  clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
1477
1477
  #endif
1478
- #endif`,gf=`#if defined( RE_IndirectDiffuse )
1478
+ #endif`,_f=`#if defined( RE_IndirectDiffuse )
1479
1479
  #if defined( LAMBERT ) || defined( PHONG )
1480
1480
  irradiance += iblIrradiance;
1481
1481
  #endif
@@ -1483,7 +1483,7 @@ IncidentLight directLight;
1483
1483
  #endif
1484
1484
  #if defined( RE_IndirectSpecular )
1485
1485
  RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1486
- #endif`,_f=`#ifdef USE_LIGHT_PROBES_GRID
1486
+ #endif`,xf=`#ifdef USE_LIGHT_PROBES_GRID
1487
1487
  uniform highp sampler3D probesSH;
1488
1488
  uniform vec3 probesMin;
1489
1489
  uniform vec3 probesMax;
@@ -1528,27 +1528,27 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
1528
1528
  result += c8 * 0.429043 * ( x * x - y * y );
1529
1529
  return max( result, vec3( 0.0 ) );
1530
1530
  }
1531
- #endif`,xf=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1532
- gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
1533
1531
  #endif`,vf=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1532
+ gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
1533
+ #endif`,yf=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1534
1534
  uniform float logDepthBufFC;
1535
1535
  varying float vFragDepth;
1536
1536
  varying float vIsPerspective;
1537
- #endif`,yf=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1537
+ #endif`,Sf=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1538
1538
  varying float vFragDepth;
1539
1539
  varying float vIsPerspective;
1540
- #endif`,Sf=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1540
+ #endif`,Mf=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1541
1541
  vFragDepth = 1.0 + gl_Position.w;
1542
1542
  vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
1543
- #endif`,Mf=`#ifdef USE_MAP
1543
+ #endif`,bf=`#ifdef USE_MAP
1544
1544
  vec4 sampledDiffuseColor = texture2D( map, vMapUv );
1545
1545
  #ifdef DECODE_VIDEO_TEXTURE
1546
1546
  sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
1547
1547
  #endif
1548
1548
  diffuseColor *= sampledDiffuseColor;
1549
- #endif`,bf=`#ifdef USE_MAP
1549
+ #endif`,Tf=`#ifdef USE_MAP
1550
1550
  uniform sampler2D map;
1551
- #endif`,Tf=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1551
+ #endif`,wf=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1552
1552
  #if defined( USE_POINTS_UV )
1553
1553
  vec2 uv = vUv;
1554
1554
  #else
@@ -1560,7 +1560,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
1560
1560
  #endif
1561
1561
  #ifdef USE_ALPHAMAP
1562
1562
  diffuseColor.a *= texture2D( alphaMap, uv ).g;
1563
- #endif`,wf=`#if defined( USE_POINTS_UV )
1563
+ #endif`,Ef=`#if defined( USE_POINTS_UV )
1564
1564
  varying vec2 vUv;
1565
1565
  #else
1566
1566
  #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
@@ -1572,19 +1572,19 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
1572
1572
  #endif
1573
1573
  #ifdef USE_ALPHAMAP
1574
1574
  uniform sampler2D alphaMap;
1575
- #endif`,Ef=`float metalnessFactor = metalness;
1575
+ #endif`,Af=`float metalnessFactor = metalness;
1576
1576
  #ifdef USE_METALNESSMAP
1577
1577
  vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
1578
1578
  metalnessFactor *= texelMetalness.b;
1579
- #endif`,Af=`#ifdef USE_METALNESSMAP
1579
+ #endif`,Cf=`#ifdef USE_METALNESSMAP
1580
1580
  uniform sampler2D metalnessMap;
1581
- #endif`,Cf=`#ifdef USE_INSTANCING_MORPH
1581
+ #endif`,Rf=`#ifdef USE_INSTANCING_MORPH
1582
1582
  float morphTargetInfluences[ MORPHTARGETS_COUNT ];
1583
1583
  float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
1584
1584
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1585
1585
  morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
1586
1586
  }
1587
- #endif`,Rf=`#if defined( USE_MORPHCOLORS )
1587
+ #endif`,If=`#if defined( USE_MORPHCOLORS )
1588
1588
  vColor *= morphTargetBaseInfluence;
1589
1589
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1590
1590
  #if defined( USE_COLOR_ALPHA )
@@ -1593,12 +1593,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
1593
1593
  if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
1594
1594
  #endif
1595
1595
  }
1596
- #endif`,If=`#ifdef USE_MORPHNORMALS
1596
+ #endif`,Pf=`#ifdef USE_MORPHNORMALS
1597
1597
  objectNormal *= morphTargetBaseInfluence;
1598
1598
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1599
1599
  if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
1600
1600
  }
1601
- #endif`,Pf=`#ifdef USE_MORPHTARGETS
1601
+ #endif`,Lf=`#ifdef USE_MORPHTARGETS
1602
1602
  #ifndef USE_INSTANCING_MORPH
1603
1603
  uniform float morphTargetBaseInfluence;
1604
1604
  uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
@@ -1612,12 +1612,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
1612
1612
  ivec3 morphUV = ivec3( x, y, morphTargetIndex );
1613
1613
  return texelFetch( morphTargetsTexture, morphUV, 0 );
1614
1614
  }
1615
- #endif`,Lf=`#ifdef USE_MORPHTARGETS
1615
+ #endif`,Nf=`#ifdef USE_MORPHTARGETS
1616
1616
  transformed *= morphTargetBaseInfluence;
1617
1617
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1618
1618
  if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
1619
1619
  }
1620
- #endif`,Nf=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
1620
+ #endif`,Df=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
1621
1621
  #ifdef FLAT_SHADED
1622
1622
  vec3 fdx = dFdx( vViewPosition );
1623
1623
  vec3 fdy = dFdy( vViewPosition );
@@ -1658,7 +1658,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
1658
1658
  tbn2[1] *= faceDirection;
1659
1659
  #endif
1660
1660
  #endif
1661
- vec3 nonPerturbedNormal = normal;`,Df=`#ifdef USE_NORMALMAP_OBJECTSPACE
1661
+ vec3 nonPerturbedNormal = normal;`,Uf=`#ifdef USE_NORMALMAP_OBJECTSPACE
1662
1662
  normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
1663
1663
  #ifdef FLIP_SIDED
1664
1664
  normal = - normal;
@@ -1676,19 +1676,19 @@ vec3 nonPerturbedNormal = normal;`,Df=`#ifdef USE_NORMALMAP_OBJECTSPACE
1676
1676
  normal = normalize( tbn * mapN );
1677
1677
  #elif defined( USE_BUMPMAP )
1678
1678
  normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
1679
- #endif`,Uf=`#ifndef FLAT_SHADED
1679
+ #endif`,Ff=`#ifndef FLAT_SHADED
1680
1680
  varying vec3 vNormal;
1681
1681
  #ifdef USE_TANGENT
1682
1682
  varying vec3 vTangent;
1683
1683
  varying vec3 vBitangent;
1684
1684
  #endif
1685
- #endif`,Ff=`#ifndef FLAT_SHADED
1685
+ #endif`,Of=`#ifndef FLAT_SHADED
1686
1686
  varying vec3 vNormal;
1687
1687
  #ifdef USE_TANGENT
1688
1688
  varying vec3 vTangent;
1689
1689
  varying vec3 vBitangent;
1690
1690
  #endif
1691
- #endif`,Of=`#ifndef FLAT_SHADED
1691
+ #endif`,Bf=`#ifndef FLAT_SHADED
1692
1692
  vNormal = normalize( transformedNormal );
1693
1693
  #ifdef USE_TANGENT
1694
1694
  vTangent = normalize( transformedTangent );
@@ -1697,7 +1697,7 @@ vec3 nonPerturbedNormal = normal;`,Df=`#ifdef USE_NORMALMAP_OBJECTSPACE
1697
1697
  vBitangent = - vBitangent;
1698
1698
  #endif
1699
1699
  #endif
1700
- #endif`,Bf=`#ifdef USE_NORMALMAP
1700
+ #endif`,zf=`#ifdef USE_NORMALMAP
1701
1701
  uniform sampler2D normalMap;
1702
1702
  uniform vec2 normalScale;
1703
1703
  #endif
@@ -1719,13 +1719,13 @@ vec3 nonPerturbedNormal = normal;`,Df=`#ifdef USE_NORMALMAP_OBJECTSPACE
1719
1719
  float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
1720
1720
  return mat3( T * scale, B * scale, N );
1721
1721
  }
1722
- #endif`,zf=`#ifdef USE_CLEARCOAT
1722
+ #endif`,kf=`#ifdef USE_CLEARCOAT
1723
1723
  vec3 clearcoatNormal = nonPerturbedNormal;
1724
- #endif`,kf=`#ifdef USE_CLEARCOAT_NORMALMAP
1724
+ #endif`,Gf=`#ifdef USE_CLEARCOAT_NORMALMAP
1725
1725
  vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
1726
1726
  clearcoatMapN.xy *= clearcoatNormalScale;
1727
1727
  clearcoatNormal = normalize( tbn2 * clearcoatMapN );
1728
- #endif`,Gf=`#ifdef USE_CLEARCOATMAP
1728
+ #endif`,Hf=`#ifdef USE_CLEARCOATMAP
1729
1729
  uniform sampler2D clearcoatMap;
1730
1730
  #endif
1731
1731
  #ifdef USE_CLEARCOAT_NORMALMAP
@@ -1734,18 +1734,18 @@ vec3 nonPerturbedNormal = normal;`,Df=`#ifdef USE_NORMALMAP_OBJECTSPACE
1734
1734
  #endif
1735
1735
  #ifdef USE_CLEARCOAT_ROUGHNESSMAP
1736
1736
  uniform sampler2D clearcoatRoughnessMap;
1737
- #endif`,Hf=`#ifdef USE_IRIDESCENCEMAP
1737
+ #endif`,Vf=`#ifdef USE_IRIDESCENCEMAP
1738
1738
  uniform sampler2D iridescenceMap;
1739
1739
  #endif
1740
1740
  #ifdef USE_IRIDESCENCE_THICKNESSMAP
1741
1741
  uniform sampler2D iridescenceThicknessMap;
1742
- #endif`,Vf=`#ifdef OPAQUE
1742
+ #endif`,Wf=`#ifdef OPAQUE
1743
1743
  diffuseColor.a = 1.0;
1744
1744
  #endif
1745
1745
  #ifdef USE_TRANSMISSION
1746
1746
  diffuseColor.a *= material.transmissionAlpha;
1747
1747
  #endif
1748
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Wf=`vec3 packNormalToRGB( const in vec3 normal ) {
1748
+ gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Xf=`vec3 packNormalToRGB( const in vec3 normal ) {
1749
1749
  return normalize( normal ) * 0.5 + 0.5;
1750
1750
  }
1751
1751
  vec3 unpackRGBToNormal( const in vec3 rgb ) {
@@ -1824,9 +1824,9 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
1824
1824
  #else
1825
1825
  return ( near * far ) / ( ( far - near ) * depth - far );
1826
1826
  #endif
1827
- }`,Xf=`#ifdef PREMULTIPLIED_ALPHA
1827
+ }`,qf=`#ifdef PREMULTIPLIED_ALPHA
1828
1828
  gl_FragColor.rgb *= gl_FragColor.a;
1829
- #endif`,qf=`vec4 mvPosition = vec4( transformed, 1.0 );
1829
+ #endif`,Yf=`vec4 mvPosition = vec4( transformed, 1.0 );
1830
1830
  #ifdef USE_BATCHING
1831
1831
  mvPosition = batchingMatrix * mvPosition;
1832
1832
  #endif
@@ -1834,22 +1834,22 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
1834
1834
  mvPosition = instanceMatrix * mvPosition;
1835
1835
  #endif
1836
1836
  mvPosition = modelViewMatrix * mvPosition;
1837
- gl_Position = projectionMatrix * mvPosition;`,Yf=`#ifdef DITHERING
1837
+ gl_Position = projectionMatrix * mvPosition;`,Zf=`#ifdef DITHERING
1838
1838
  gl_FragColor.rgb = dithering( gl_FragColor.rgb );
1839
- #endif`,Zf=`#ifdef DITHERING
1839
+ #endif`,Jf=`#ifdef DITHERING
1840
1840
  vec3 dithering( vec3 color ) {
1841
1841
  float grid_position = rand( gl_FragCoord.xy );
1842
1842
  vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
1843
1843
  dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
1844
1844
  return color + dither_shift_RGB;
1845
1845
  }
1846
- #endif`,Jf=`float roughnessFactor = roughness;
1846
+ #endif`,$f=`float roughnessFactor = roughness;
1847
1847
  #ifdef USE_ROUGHNESSMAP
1848
1848
  vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
1849
1849
  roughnessFactor *= texelRoughness.g;
1850
- #endif`,$f=`#ifdef USE_ROUGHNESSMAP
1850
+ #endif`,Kf=`#ifdef USE_ROUGHNESSMAP
1851
1851
  uniform sampler2D roughnessMap;
1852
- #endif`,Kf=`#if NUM_SPOT_LIGHT_COORDS > 0
1852
+ #endif`,Qf=`#if NUM_SPOT_LIGHT_COORDS > 0
1853
1853
  varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
1854
1854
  #endif
1855
1855
  #if NUM_SPOT_LIGHT_MAPS > 0
@@ -2100,7 +2100,7 @@ gl_Position = projectionMatrix * mvPosition;`,Yf=`#ifdef DITHERING
2100
2100
  }
2101
2101
  #endif
2102
2102
  #endif
2103
- #endif`,Qf=`#if NUM_SPOT_LIGHT_COORDS > 0
2103
+ #endif`,jf=`#if NUM_SPOT_LIGHT_COORDS > 0
2104
2104
  uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
2105
2105
  varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
2106
2106
  #endif
@@ -2145,7 +2145,7 @@ gl_Position = projectionMatrix * mvPosition;`,Yf=`#ifdef DITHERING
2145
2145
  };
2146
2146
  uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
2147
2147
  #endif
2148
- #endif`,jf=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SUN_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
2148
+ #endif`,tp=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SUN_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
2149
2149
  #ifdef HAS_NORMAL
2150
2150
  vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix );
2151
2151
  #else
@@ -2185,7 +2185,7 @@ gl_Position = projectionMatrix * mvPosition;`,Yf=`#ifdef DITHERING
2185
2185
  vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
2186
2186
  }
2187
2187
  #pragma unroll_loop_end
2188
- #endif`,tp=`float getShadowMask() {
2188
+ #endif`,ep=`float getShadowMask() {
2189
2189
  float shadow = 1.0;
2190
2190
  #ifdef USE_SHADOWMAP
2191
2191
  #if NUM_SUN_LIGHT_SHADOWS > 0
@@ -2226,12 +2226,12 @@ gl_Position = projectionMatrix * mvPosition;`,Yf=`#ifdef DITHERING
2226
2226
  #endif
2227
2227
  #endif
2228
2228
  return shadow;
2229
- }`,ep=`#ifdef USE_SKINNING
2229
+ }`,np=`#ifdef USE_SKINNING
2230
2230
  mat4 boneMatX = getBoneMatrix( skinIndex.x );
2231
2231
  mat4 boneMatY = getBoneMatrix( skinIndex.y );
2232
2232
  mat4 boneMatZ = getBoneMatrix( skinIndex.z );
2233
2233
  mat4 boneMatW = getBoneMatrix( skinIndex.w );
2234
- #endif`,np=`#ifdef USE_SKINNING
2234
+ #endif`,ip=`#ifdef USE_SKINNING
2235
2235
  uniform mat4 bindMatrix;
2236
2236
  uniform mat4 bindMatrixInverse;
2237
2237
  uniform highp sampler2D boneTexture;
@@ -2246,7 +2246,7 @@ gl_Position = projectionMatrix * mvPosition;`,Yf=`#ifdef DITHERING
2246
2246
  vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
2247
2247
  return mat4( v1, v2, v3, v4 );
2248
2248
  }
2249
- #endif`,ip=`#ifdef USE_SKINNING
2249
+ #endif`,sp=`#ifdef USE_SKINNING
2250
2250
  vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
2251
2251
  vec4 skinned = vec4( 0.0 );
2252
2252
  skinned += boneMatX * skinVertex * skinWeight.x;
@@ -2254,7 +2254,7 @@ gl_Position = projectionMatrix * mvPosition;`,Yf=`#ifdef DITHERING
2254
2254
  skinned += boneMatZ * skinVertex * skinWeight.z;
2255
2255
  skinned += boneMatW * skinVertex * skinWeight.w;
2256
2256
  transformed = ( bindMatrixInverse * skinned ).xyz;
2257
- #endif`,sp=`#ifdef USE_SKINNING
2257
+ #endif`,rp=`#ifdef USE_SKINNING
2258
2258
  mat4 skinMatrix = mat4( 0.0 );
2259
2259
  skinMatrix += skinWeight.x * boneMatX;
2260
2260
  skinMatrix += skinWeight.y * boneMatY;
@@ -2265,17 +2265,17 @@ gl_Position = projectionMatrix * mvPosition;`,Yf=`#ifdef DITHERING
2265
2265
  #ifdef USE_TANGENT
2266
2266
  objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
2267
2267
  #endif
2268
- #endif`,rp=`float specularStrength;
2268
+ #endif`,ap=`float specularStrength;
2269
2269
  #ifdef USE_SPECULARMAP
2270
2270
  vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
2271
2271
  specularStrength = texelSpecular.r;
2272
2272
  #else
2273
2273
  specularStrength = 1.0;
2274
- #endif`,ap=`#ifdef USE_SPECULARMAP
2274
+ #endif`,op=`#ifdef USE_SPECULARMAP
2275
2275
  uniform sampler2D specularMap;
2276
- #endif`,op=`#if defined( TONE_MAPPING )
2276
+ #endif`,lp=`#if defined( TONE_MAPPING )
2277
2277
  gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
2278
- #endif`,lp=`#ifndef saturate
2278
+ #endif`,cp=`#ifndef saturate
2279
2279
  #define saturate( a ) clamp( a, 0.0, 1.0 )
2280
2280
  #endif
2281
2281
  uniform float toneMappingExposure;
@@ -2372,7 +2372,7 @@ vec3 NeutralToneMapping( vec3 color ) {
2372
2372
  float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
2373
2373
  return mix( color, vec3( newPeak ), g );
2374
2374
  }
2375
- vec3 CustomToneMapping( vec3 color ) { return color; }`,cp=`#ifdef USE_TRANSMISSION
2375
+ vec3 CustomToneMapping( vec3 color ) { return color; }`,hp=`#ifdef USE_TRANSMISSION
2376
2376
  material.transmission = transmission;
2377
2377
  material.transmissionAlpha = 1.0;
2378
2378
  material.thickness = thickness;
@@ -2393,7 +2393,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,cp=`#ifdef USE_TRANSMISS
2393
2393
  material.attenuationColor, material.attenuationDistance );
2394
2394
  material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
2395
2395
  totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
2396
- #endif`,hp=`#ifdef USE_TRANSMISSION
2396
+ #endif`,up=`#ifdef USE_TRANSMISSION
2397
2397
  uniform float transmission;
2398
2398
  uniform float thickness;
2399
2399
  uniform float attenuationDistance;
@@ -2519,7 +2519,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,cp=`#ifdef USE_TRANSMISS
2519
2519
  float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
2520
2520
  return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
2521
2521
  }
2522
- #endif`,up=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2522
+ #endif`,dp=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2523
2523
  varying vec2 vUv;
2524
2524
  #endif
2525
2525
  #ifdef USE_MAP
@@ -2589,7 +2589,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,cp=`#ifdef USE_TRANSMISS
2589
2589
  #ifdef USE_THICKNESSMAP
2590
2590
  uniform mat3 thicknessMapTransform;
2591
2591
  varying vec2 vThicknessMapUv;
2592
- #endif`,dp=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2592
+ #endif`,fp=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2593
2593
  varying vec2 vUv;
2594
2594
  #endif
2595
2595
  #ifdef USE_MAP
@@ -2683,7 +2683,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,cp=`#ifdef USE_TRANSMISS
2683
2683
  #ifdef USE_THICKNESSMAP
2684
2684
  uniform mat3 thicknessMapTransform;
2685
2685
  varying vec2 vThicknessMapUv;
2686
- #endif`,fp=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2686
+ #endif`,pp=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2687
2687
  vUv = vec3( uv, 1 ).xy;
2688
2688
  #endif
2689
2689
  #ifdef USE_MAP
@@ -2754,7 +2754,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,cp=`#ifdef USE_TRANSMISS
2754
2754
  #endif
2755
2755
  #ifdef USE_THICKNESSMAP
2756
2756
  vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
2757
- #endif`;var pp=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
2757
+ #endif`;var mp=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
2758
2758
  vec4 worldPosition = vec4( transformed, 1.0 );
2759
2759
  #ifdef USE_BATCHING
2760
2760
  worldPosition = batchingMatrix * worldPosition;
@@ -2763,12 +2763,12 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,cp=`#ifdef USE_TRANSMISS
2763
2763
  worldPosition = instanceMatrix * worldPosition;
2764
2764
  #endif
2765
2765
  worldPosition = modelMatrix * worldPosition;
2766
- #endif`,mp=`varying vec2 vUv;
2766
+ #endif`,gp=`varying vec2 vUv;
2767
2767
  uniform mat3 uvTransform;
2768
2768
  void main() {
2769
2769
  vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
2770
2770
  gl_Position = vec4( position.xy, 1.0, 1.0 );
2771
- }`,gp=`uniform sampler2D t2D;
2771
+ }`,_p=`uniform sampler2D t2D;
2772
2772
  uniform float backgroundIntensity;
2773
2773
  varying vec2 vUv;
2774
2774
  void main() {
@@ -2780,14 +2780,14 @@ void main() {
2780
2780
  gl_FragColor = texColor;
2781
2781
  #include <tonemapping_fragment>
2782
2782
  #include <colorspace_fragment>
2783
- }`,_p=`varying vec3 vWorldDirection;
2783
+ }`,xp=`varying vec3 vWorldDirection;
2784
2784
  #include <common>
2785
2785
  void main() {
2786
2786
  vWorldDirection = transformDirection( position, modelMatrix );
2787
2787
  #include <begin_vertex>
2788
2788
  #include <project_vertex>
2789
2789
  gl_Position.z = gl_Position.w;
2790
- }`,xp=`#ifdef ENVMAP_TYPE_CUBE
2790
+ }`,vp=`#ifdef ENVMAP_TYPE_CUBE
2791
2791
  uniform samplerCube envMap;
2792
2792
  #elif defined( ENVMAP_TYPE_CUBE_UV )
2793
2793
  uniform sampler2D envMap;
@@ -2809,14 +2809,14 @@ void main() {
2809
2809
  gl_FragColor = texColor;
2810
2810
  #include <tonemapping_fragment>
2811
2811
  #include <colorspace_fragment>
2812
- }`,vp=`varying vec3 vWorldDirection;
2812
+ }`,yp=`varying vec3 vWorldDirection;
2813
2813
  #include <common>
2814
2814
  void main() {
2815
2815
  vWorldDirection = transformDirection( position, modelMatrix );
2816
2816
  #include <begin_vertex>
2817
2817
  #include <project_vertex>
2818
2818
  gl_Position.z = gl_Position.w;
2819
- }`,yp=`uniform samplerCube tCube;
2819
+ }`,Sp=`uniform samplerCube tCube;
2820
2820
  uniform float tFlip;
2821
2821
  uniform float opacity;
2822
2822
  varying vec3 vWorldDirection;
@@ -2826,7 +2826,7 @@ void main() {
2826
2826
  gl_FragColor.a *= opacity;
2827
2827
  #include <tonemapping_fragment>
2828
2828
  #include <colorspace_fragment>
2829
- }`,Sp=`#include <common>
2829
+ }`,Mp=`#include <common>
2830
2830
  #include <batching_pars_vertex>
2831
2831
  #include <uv_pars_vertex>
2832
2832
  #include <displacementmap_pars_vertex>
@@ -2853,7 +2853,7 @@ void main() {
2853
2853
  #include <logdepthbuf_vertex>
2854
2854
  #include <clipping_planes_vertex>
2855
2855
  vHighPrecisionZW = gl_Position.zw;
2856
- }`,Mp=`#if DEPTH_PACKING == 3200
2856
+ }`,bp=`#if DEPTH_PACKING == 3200
2857
2857
  uniform float opacity;
2858
2858
  #endif
2859
2859
  #include <common>
@@ -2891,7 +2891,7 @@ void main() {
2891
2891
  #elif DEPTH_PACKING == 3203
2892
2892
  gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
2893
2893
  #endif
2894
- }`,bp=`#define DISTANCE
2894
+ }`,Tp=`#define DISTANCE
2895
2895
  varying vec3 vWorldPosition;
2896
2896
  #include <common>
2897
2897
  #include <batching_pars_vertex>
@@ -2918,7 +2918,7 @@ void main() {
2918
2918
  #include <worldpos_vertex>
2919
2919
  #include <clipping_planes_vertex>
2920
2920
  vWorldPosition = worldPosition.xyz;
2921
- }`,Tp=`#define DISTANCE
2921
+ }`,wp=`#define DISTANCE
2922
2922
  uniform vec3 referencePosition;
2923
2923
  uniform float nearDistance;
2924
2924
  uniform float farDistance;
@@ -2941,13 +2941,13 @@ void main() {
2941
2941
  dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
2942
2942
  dist = saturate( dist );
2943
2943
  gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );
2944
- }`,wp=`varying vec3 vWorldDirection;
2944
+ }`,Ep=`varying vec3 vWorldDirection;
2945
2945
  #include <common>
2946
2946
  void main() {
2947
2947
  vWorldDirection = transformDirection( position, modelMatrix );
2948
2948
  #include <begin_vertex>
2949
2949
  #include <project_vertex>
2950
- }`,Ep=`uniform sampler2D tEquirect;
2950
+ }`,Ap=`uniform sampler2D tEquirect;
2951
2951
  varying vec3 vWorldDirection;
2952
2952
  #include <common>
2953
2953
  void main() {
@@ -2956,7 +2956,7 @@ void main() {
2956
2956
  gl_FragColor = texture2D( tEquirect, sampleUV );
2957
2957
  #include <tonemapping_fragment>
2958
2958
  #include <colorspace_fragment>
2959
- }`,Ap=`uniform float scale;
2959
+ }`,Cp=`uniform float scale;
2960
2960
  attribute float lineDistance;
2961
2961
  varying float vLineDistance;
2962
2962
  #include <common>
@@ -2978,7 +2978,7 @@ void main() {
2978
2978
  #include <logdepthbuf_vertex>
2979
2979
  #include <clipping_planes_vertex>
2980
2980
  #include <fog_vertex>
2981
- }`,Cp=`uniform vec3 diffuse;
2981
+ }`,Rp=`uniform vec3 diffuse;
2982
2982
  uniform float opacity;
2983
2983
  uniform float dashSize;
2984
2984
  uniform float totalSize;
@@ -3006,7 +3006,7 @@ void main() {
3006
3006
  #include <colorspace_fragment>
3007
3007
  #include <fog_fragment>
3008
3008
  #include <premultiplied_alpha_fragment>
3009
- }`,Rp=`#include <common>
3009
+ }`,Ip=`#include <common>
3010
3010
  #include <batching_pars_vertex>
3011
3011
  #include <uv_pars_vertex>
3012
3012
  #include <envmap_pars_vertex>
@@ -3038,7 +3038,7 @@ void main() {
3038
3038
  #include <worldpos_vertex>
3039
3039
  #include <envmap_vertex>
3040
3040
  #include <fog_vertex>
3041
- }`,Ip=`uniform vec3 diffuse;
3041
+ }`,Pp=`uniform vec3 diffuse;
3042
3042
  uniform float opacity;
3043
3043
  #ifndef FLAT_SHADED
3044
3044
  varying vec3 vNormal;
@@ -3086,7 +3086,7 @@ void main() {
3086
3086
  #include <fog_fragment>
3087
3087
  #include <premultiplied_alpha_fragment>
3088
3088
  #include <dithering_fragment>
3089
- }`,Pp=`#define LAMBERT
3089
+ }`,Lp=`#define LAMBERT
3090
3090
  varying vec3 vViewPosition;
3091
3091
  #include <common>
3092
3092
  #include <batching_pars_vertex>
@@ -3125,7 +3125,7 @@ void main() {
3125
3125
  #include <envmap_vertex>
3126
3126
  #include <shadowmap_vertex>
3127
3127
  #include <fog_vertex>
3128
- }`,Lp=`#define LAMBERT
3128
+ }`,Np=`#define LAMBERT
3129
3129
  uniform vec3 diffuse;
3130
3130
  uniform vec3 emissive;
3131
3131
  uniform float opacity;
@@ -3183,7 +3183,7 @@ void main() {
3183
3183
  #include <fog_fragment>
3184
3184
  #include <premultiplied_alpha_fragment>
3185
3185
  #include <dithering_fragment>
3186
- }`,Np=`#define MATCAP
3186
+ }`,Dp=`#define MATCAP
3187
3187
  varying vec3 vViewPosition;
3188
3188
  #include <common>
3189
3189
  #include <batching_pars_vertex>
@@ -3217,7 +3217,7 @@ void main() {
3217
3217
  #include <clipping_planes_vertex>
3218
3218
  #include <fog_vertex>
3219
3219
  vViewPosition = - mvPosition.xyz;
3220
- }`,Dp=`#define MATCAP
3220
+ }`,Up=`#define MATCAP
3221
3221
  uniform vec3 diffuse;
3222
3222
  uniform float opacity;
3223
3223
  uniform sampler2D matcap;
@@ -3263,7 +3263,7 @@ void main() {
3263
3263
  #include <fog_fragment>
3264
3264
  #include <premultiplied_alpha_fragment>
3265
3265
  #include <dithering_fragment>
3266
- }`,Up=`#define NORMAL
3266
+ }`,Fp=`#define NORMAL
3267
3267
  #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3268
3268
  varying vec3 vViewPosition;
3269
3269
  #endif
@@ -3296,7 +3296,7 @@ void main() {
3296
3296
  #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3297
3297
  vViewPosition = - mvPosition.xyz;
3298
3298
  #endif
3299
- }`,Fp=`#define NORMAL
3299
+ }`,Op=`#define NORMAL
3300
3300
  uniform float opacity;
3301
3301
  #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3302
3302
  varying vec3 vViewPosition;
@@ -3317,7 +3317,7 @@ void main() {
3317
3317
  #ifdef OPAQUE
3318
3318
  gl_FragColor.a = 1.0;
3319
3319
  #endif
3320
- }`,Op=`#define PHONG
3320
+ }`,Bp=`#define PHONG
3321
3321
  varying vec3 vViewPosition;
3322
3322
  #include <common>
3323
3323
  #include <batching_pars_vertex>
@@ -3356,7 +3356,7 @@ void main() {
3356
3356
  #include <envmap_vertex>
3357
3357
  #include <shadowmap_vertex>
3358
3358
  #include <fog_vertex>
3359
- }`,Bp=`#define PHONG
3359
+ }`,zp=`#define PHONG
3360
3360
  uniform vec3 diffuse;
3361
3361
  uniform vec3 emissive;
3362
3362
  uniform vec3 specular;
@@ -3416,7 +3416,7 @@ void main() {
3416
3416
  #include <fog_fragment>
3417
3417
  #include <premultiplied_alpha_fragment>
3418
3418
  #include <dithering_fragment>
3419
- }`,zp=`#define STANDARD
3419
+ }`,kp=`#define STANDARD
3420
3420
  varying vec3 vViewPosition;
3421
3421
  #ifdef USE_TRANSMISSION
3422
3422
  varying vec3 vWorldPosition;
@@ -3459,7 +3459,7 @@ void main() {
3459
3459
  #ifdef USE_TRANSMISSION
3460
3460
  vWorldPosition = worldPosition.xyz;
3461
3461
  #endif
3462
- }`,kp=`#define STANDARD
3462
+ }`,Gp=`#define STANDARD
3463
3463
  #ifdef PHYSICAL
3464
3464
  #define IOR
3465
3465
  #define USE_SPECULAR
@@ -3587,7 +3587,7 @@ void main() {
3587
3587
  #include <fog_fragment>
3588
3588
  #include <premultiplied_alpha_fragment>
3589
3589
  #include <dithering_fragment>
3590
- }`,Gp=`#define TOON
3590
+ }`,Hp=`#define TOON
3591
3591
  varying vec3 vViewPosition;
3592
3592
  #include <common>
3593
3593
  #include <batching_pars_vertex>
@@ -3624,7 +3624,7 @@ void main() {
3624
3624
  #include <worldpos_vertex>
3625
3625
  #include <shadowmap_vertex>
3626
3626
  #include <fog_vertex>
3627
- }`,Hp=`#define TOON
3627
+ }`,Vp=`#define TOON
3628
3628
  uniform vec3 diffuse;
3629
3629
  uniform vec3 emissive;
3630
3630
  uniform float opacity;
@@ -3676,7 +3676,7 @@ void main() {
3676
3676
  #include <fog_fragment>
3677
3677
  #include <premultiplied_alpha_fragment>
3678
3678
  #include <dithering_fragment>
3679
- }`,Vp=`uniform float size;
3679
+ }`,Wp=`uniform float size;
3680
3680
  uniform float scale;
3681
3681
  #include <common>
3682
3682
  #include <color_pars_vertex>
@@ -3707,7 +3707,7 @@ void main() {
3707
3707
  #include <clipping_planes_vertex>
3708
3708
  #include <worldpos_vertex>
3709
3709
  #include <fog_vertex>
3710
- }`,Wp=`uniform vec3 diffuse;
3710
+ }`,Xp=`uniform vec3 diffuse;
3711
3711
  uniform float opacity;
3712
3712
  #include <common>
3713
3713
  #include <color_pars_fragment>
@@ -3732,7 +3732,7 @@ void main() {
3732
3732
  #include <colorspace_fragment>
3733
3733
  #include <fog_fragment>
3734
3734
  #include <premultiplied_alpha_fragment>
3735
- }`,Xp=`#include <common>
3735
+ }`,qp=`#include <common>
3736
3736
  #include <batching_pars_vertex>
3737
3737
  #include <fog_pars_vertex>
3738
3738
  #include <morphtarget_pars_vertex>
@@ -3755,7 +3755,7 @@ void main() {
3755
3755
  #include <worldpos_vertex>
3756
3756
  #include <shadowmap_vertex>
3757
3757
  #include <fog_vertex>
3758
- }`,qp=`uniform vec3 color;
3758
+ }`,Yp=`uniform vec3 color;
3759
3759
  uniform float opacity;
3760
3760
  #include <common>
3761
3761
  #include <fog_pars_fragment>
@@ -3771,7 +3771,7 @@ void main() {
3771
3771
  #include <colorspace_fragment>
3772
3772
  #include <fog_fragment>
3773
3773
  #include <premultiplied_alpha_fragment>
3774
- }`,Yp=`uniform float rotation;
3774
+ }`,Zp=`uniform float rotation;
3775
3775
  uniform vec2 center;
3776
3776
  #include <common>
3777
3777
  #include <uv_pars_vertex>
@@ -3795,7 +3795,7 @@ void main() {
3795
3795
  #include <logdepthbuf_vertex>
3796
3796
  #include <clipping_planes_vertex>
3797
3797
  #include <fog_vertex>
3798
- }`,Zp=`uniform vec3 diffuse;
3798
+ }`,Jp=`uniform vec3 diffuse;
3799
3799
  uniform float opacity;
3800
3800
  #include <common>
3801
3801
  #include <uv_pars_fragment>
@@ -3820,7 +3820,7 @@ void main() {
3820
3820
  #include <tonemapping_fragment>
3821
3821
  #include <colorspace_fragment>
3822
3822
  #include <fog_fragment>
3823
- }`,jt={alphahash_fragment:pd,alphahash_pars_fragment:md,alphamap_fragment:gd,alphamap_pars_fragment:_d,alphatest_fragment:xd,alphatest_pars_fragment:vd,aomap_fragment:yd,aomap_pars_fragment:Sd,batching_pars_vertex:Md,batching_vertex:bd,begin_vertex:Td,beginnormal_vertex:wd,bsdfs:Ed,iridescence_fragment:Ad,bumpmap_pars_fragment:Cd,clipping_planes_fragment:Rd,clipping_planes_pars_fragment:Id,clipping_planes_pars_vertex:Pd,clipping_planes_vertex:Ld,color_fragment:Nd,color_pars_fragment:Dd,color_pars_vertex:Ud,color_vertex:Fd,common:Od,cube_uv_reflection_fragment:Bd,defaultnormal_vertex:zd,displacementmap_pars_vertex:kd,displacementmap_vertex:Gd,emissivemap_fragment:Hd,emissivemap_pars_fragment:Vd,colorspace_fragment:Wd,colorspace_pars_fragment:Xd,envmap_fragment:qd,envmap_common_pars_fragment:Yd,envmap_pars_fragment:Zd,envmap_pars_vertex:Jd,envmap_physical_pars_fragment:of,envmap_vertex:$d,fog_vertex:Kd,fog_pars_vertex:Qd,fog_fragment:jd,fog_pars_fragment:tf,gradientmap_pars_fragment:ef,lightmap_pars_fragment:nf,lights_lambert_fragment:sf,lights_lambert_pars_fragment:rf,lights_pars_begin:af,lights_toon_fragment:lf,lights_toon_pars_fragment:cf,lights_phong_fragment:hf,lights_phong_pars_fragment:uf,lights_physical_fragment:df,lights_physical_pars_fragment:ff,lights_fragment_begin:pf,lights_fragment_maps:mf,lights_fragment_end:gf,lightprobes_pars_fragment:_f,logdepthbuf_fragment:xf,logdepthbuf_pars_fragment:vf,logdepthbuf_pars_vertex:yf,logdepthbuf_vertex:Sf,map_fragment:Mf,map_pars_fragment:bf,map_particle_fragment:Tf,map_particle_pars_fragment:wf,metalnessmap_fragment:Ef,metalnessmap_pars_fragment:Af,morphinstance_vertex:Cf,morphcolor_vertex:Rf,morphnormal_vertex:If,morphtarget_pars_vertex:Pf,morphtarget_vertex:Lf,normal_fragment_begin:Nf,normal_fragment_maps:Df,normal_pars_fragment:Uf,normal_pars_vertex:Ff,normal_vertex:Of,normalmap_pars_fragment:Bf,clearcoat_normal_fragment_begin:zf,clearcoat_normal_fragment_maps:kf,clearcoat_pars_fragment:Gf,iridescence_pars_fragment:Hf,opaque_fragment:Vf,packing:Wf,premultiplied_alpha_fragment:Xf,project_vertex:qf,dithering_fragment:Yf,dithering_pars_fragment:Zf,roughnessmap_fragment:Jf,roughnessmap_pars_fragment:$f,shadowmap_pars_fragment:Kf,shadowmap_pars_vertex:Qf,shadowmap_vertex:jf,shadowmask_pars_fragment:tp,skinbase_vertex:ep,skinning_pars_vertex:np,skinning_vertex:ip,skinnormal_vertex:sp,specularmap_fragment:rp,specularmap_pars_fragment:ap,tonemapping_fragment:op,tonemapping_pars_fragment:lp,transmission_fragment:cp,transmission_pars_fragment:hp,uv_pars_fragment:up,uv_pars_vertex:dp,uv_vertex:fp,worldpos_vertex:pp,background_vert:mp,background_frag:gp,backgroundCube_vert:_p,backgroundCube_frag:xp,cube_vert:vp,cube_frag:yp,depth_vert:Sp,depth_frag:Mp,distance_vert:bp,distance_frag:Tp,equirect_vert:wp,equirect_frag:Ep,linedashed_vert:Ap,linedashed_frag:Cp,meshbasic_vert:Rp,meshbasic_frag:Ip,meshlambert_vert:Pp,meshlambert_frag:Lp,meshmatcap_vert:Np,meshmatcap_frag:Dp,meshnormal_vert:Up,meshnormal_frag:Fp,meshphong_vert:Op,meshphong_frag:Bp,meshphysical_vert:zp,meshphysical_frag:kp,meshtoon_vert:Gp,meshtoon_frag:Hp,points_vert:Vp,points_frag:Wp,shadow_vert:Xp,shadow_frag:qp,sprite_vert:Yp,sprite_frag:Zp},gt={common:{diffuse:{value:new Kt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new qt},alphaMap:{value:null},alphaMapTransform:{value:new qt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new qt}},envmap:{envMap:{value:null},envMapRotation:{value:new qt},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:0.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new qt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new qt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new qt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new qt},normalScale:{value:new Xt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new qt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new qt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new qt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new qt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:0.00025},fogNear:{value:1},fogFar:{value:2000},fogColor:{value:new Kt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},sunLights:{value:[],properties:{direction:{},color:{}}},sunLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},sunShadowMatrix:{value:[]},sunShadowCascade:{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 O},probesMax:{value:new O},probesResolution:{value:new O}},points:{diffuse:{value:new Kt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new qt},alphaTest:{value:0},uvTransform:{value:new qt}},sprite:{diffuse:{value:new Kt(16777215)},opacity:{value:1},center:{value:new Xt(0.5,0.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new qt},alphaMap:{value:null},alphaMapTransform:{value:new qt},alphaTest:{value:0}}},Wn={basic:{uniforms:je([gt.common,gt.specularmap,gt.envmap,gt.aomap,gt.lightmap,gt.fog]),vertexShader:jt.meshbasic_vert,fragmentShader:jt.meshbasic_frag},lambert:{uniforms:je([gt.common,gt.specularmap,gt.envmap,gt.aomap,gt.lightmap,gt.emissivemap,gt.bumpmap,gt.normalmap,gt.displacementmap,gt.fog,gt.lights,{emissive:{value:new Kt(0)},envMapIntensity:{value:1}}]),vertexShader:jt.meshlambert_vert,fragmentShader:jt.meshlambert_frag},phong:{uniforms:je([gt.common,gt.specularmap,gt.envmap,gt.aomap,gt.lightmap,gt.emissivemap,gt.bumpmap,gt.normalmap,gt.displacementmap,gt.fog,gt.lights,{emissive:{value:new Kt(0)},specular:{value:new Kt(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:jt.meshphong_vert,fragmentShader:jt.meshphong_frag},standard:{uniforms:je([gt.common,gt.envmap,gt.aomap,gt.lightmap,gt.emissivemap,gt.bumpmap,gt.normalmap,gt.displacementmap,gt.roughnessmap,gt.metalnessmap,gt.fog,gt.lights,{emissive:{value:new Kt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:jt.meshphysical_vert,fragmentShader:jt.meshphysical_frag},toon:{uniforms:je([gt.common,gt.aomap,gt.lightmap,gt.emissivemap,gt.bumpmap,gt.normalmap,gt.displacementmap,gt.gradientmap,gt.fog,gt.lights,{emissive:{value:new Kt(0)}}]),vertexShader:jt.meshtoon_vert,fragmentShader:jt.meshtoon_frag},matcap:{uniforms:je([gt.common,gt.bumpmap,gt.normalmap,gt.displacementmap,gt.fog,{matcap:{value:null}}]),vertexShader:jt.meshmatcap_vert,fragmentShader:jt.meshmatcap_frag},points:{uniforms:je([gt.points,gt.fog]),vertexShader:jt.points_vert,fragmentShader:jt.points_frag},dashed:{uniforms:je([gt.common,gt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:jt.linedashed_vert,fragmentShader:jt.linedashed_frag},depth:{uniforms:je([gt.common,gt.displacementmap]),vertexShader:jt.depth_vert,fragmentShader:jt.depth_frag},normal:{uniforms:je([gt.common,gt.bumpmap,gt.normalmap,gt.displacementmap,{opacity:{value:1}}]),vertexShader:jt.meshnormal_vert,fragmentShader:jt.meshnormal_frag},sprite:{uniforms:je([gt.sprite,gt.fog]),vertexShader:jt.sprite_vert,fragmentShader:jt.sprite_frag},background:{uniforms:{uvTransform:{value:new qt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:jt.background_vert,fragmentShader:jt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new qt}},vertexShader:jt.backgroundCube_vert,fragmentShader:jt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:jt.cube_vert,fragmentShader:jt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:jt.equirect_vert,fragmentShader:jt.equirect_frag},distance:{uniforms:je([gt.common,gt.displacementmap,{referencePosition:{value:new O},nearDistance:{value:1},farDistance:{value:1000}}]),vertexShader:jt.distance_vert,fragmentShader:jt.distance_frag},shadow:{uniforms:je([gt.lights,gt.fog,{color:{value:new Kt(0)},opacity:{value:1}}]),vertexShader:jt.shadow_vert,fragmentShader:jt.shadow_frag}};Wn.physical={uniforms:je([Wn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new qt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new qt},clearcoatNormalScale:{value:new Xt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new qt},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new qt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new qt},sheen:{value:0},sheenColor:{value:new Kt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new qt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new qt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new qt},transmissionSamplerSize:{value:new Xt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new qt},attenuationDistance:{value:0},attenuationColor:{value:new Kt(0)},specularColor:{value:new Kt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new qt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new qt},anisotropyVector:{value:new Xt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new qt}}]),vertexShader:jt.meshphysical_vert,fragmentShader:jt.meshphysical_frag};var la={r:0,b:0,g:0},Jp=new we,Yh=new qt;Yh.set(-1,0,0,0,1,0,0,0,1);function $p(t,e,n,i,s,r){let a=new Kt(0),o=s===!0?0:1,l,c,u=null,d=0,h=null;function p(w){let C=w.isScene===!0?w.background:null;if(C&&C.isTexture){let y=w.backgroundBlurriness>0;C=e.get(C,y)}return C}function v(w){let C=!1,y=p(w);if(y===null)m(a,o);else if(y&&y.isColor)m(y,1),C=!0;let b=t.xr.getEnvironmentBlendMode();if(b==="additive")n.buffers.color.setClear(0,0,0,1,r);else if(b==="alpha-blend")n.buffers.color.setClear(0,0,0,0,r);if(t.autoClear||C)n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil)}function T(w,C){let y=p(C);if(y&&(y.isCubeTexture||y.mapping===Gs)){if(c===void 0)c=new Jt(new Hn(1,1,1),new bn({name:"BackgroundCubeMaterial",uniforms:Oi(Wn.backgroundCube.uniforms),vertexShader:Wn.backgroundCube.vertexShader,fragmentShader:Wn.backgroundCube.fragmentShader,side:Ve,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(b,A,E){this.matrixWorld.copyPosition(E.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(c);if(c.material.uniforms.envMap.value=y,c.material.uniforms.backgroundBlurriness.value=C.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=C.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(Jp.makeRotationFromEuler(C.backgroundRotation)).transpose(),y.isCubeTexture&&y.isRenderTargetTexture===!1)c.material.uniforms.backgroundRotation.value.premultiply(Yh);if(c.material.toneMapped=re.getTransfer(y.colorSpace)!==Me,u!==y||d!==y.version||h!==t.toneMapping)c.material.needsUpdate=!0,u=y,d=y.version,h=t.toneMapping;c.layers.enableAll(),w.unshift(c,c.geometry,c.material,0,0,null)}else if(y&&y.isTexture){if(l===void 0)l=new Jt(new Ie(2,2),new bn({name:"BackgroundMaterial",uniforms:Oi(Wn.background.uniforms),vertexShader:Wn.background.vertexShader,fragmentShader:Wn.background.fragmentShader,side:fs,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(l);if(l.material.uniforms.t2D.value=y,l.material.uniforms.backgroundIntensity.value=C.backgroundIntensity,l.material.toneMapped=re.getTransfer(y.colorSpace)!==Me,y.matrixAutoUpdate===!0)y.updateMatrix();if(l.material.uniforms.uvTransform.value.copy(y.matrix),u!==y||d!==y.version||h!==t.toneMapping)l.material.needsUpdate=!0,u=y,d=y.version,h=t.toneMapping;l.layers.enableAll(),w.unshift(l,l.geometry,l.material,0,0,null)}}function m(w,C){w.getRGB(la,nl(t)),n.buffers.color.setClear(la.r,la.g,la.b,C,r)}function f(){if(c!==void 0)c.geometry.dispose(),c.material.dispose(),c=void 0;if(l!==void 0)l.geometry.dispose(),l.material.dispose(),l=void 0}return{getClearColor:function(){return a},setClearColor:function(w,C=1){a.set(w),o=C,m(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(w){o=w,m(a,o)},render:v,addToRenderList:T,dispose:f}}function Kp(t,e){let n=t.getParameter(t.MAX_VERTEX_ATTRIBS),i={},s=h(null),r=s,a=!1;function o(N,F,X,R,k){let Z=!1,H=d(N,R,X,F);if(r!==H)r=H,c(r.object);if(Z=p(N,R,X,k),Z)v(N,R,X,k);if(k!==null)e.update(k,t.ELEMENT_ARRAY_BUFFER);if(Z||a){if(a=!1,y(N,F,X,R),k!==null)t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e.get(k).buffer)}}function l(){return t.createVertexArray()}function c(N){return t.bindVertexArray(N)}function u(N){return t.deleteVertexArray(N)}function d(N,F,X,R){let k=R.wireframe===!0,Z=i[F.id];if(Z===void 0)Z={},i[F.id]=Z;let H=N.isInstancedMesh===!0?N.id:0,at=Z[H];if(at===void 0)at={},Z[H]=at;let K=at[X.id];if(K===void 0)K={},at[X.id]=K;let et=K[k];if(et===void 0)et=h(l()),K[k]=et;return et}function h(N){let F=[],X=[],R=[];for(let k=0;k<n;k++)F[k]=0,X[k]=0,R[k]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:F,enabledAttributes:X,attributeDivisors:R,object:N,attributes:{},index:null}}function p(N,F,X,R){let k=r.attributes,Z=F.attributes,H=0,at=X.getAttributes();for(let K in at)if(at[K].location>=0){let tt=k[K],dt=Z[K];if(dt===void 0){if(K==="instanceMatrix"&&N.instanceMatrix)dt=N.instanceMatrix;if(K==="instanceColor"&&N.instanceColor)dt=N.instanceColor}if(tt===void 0)return!0;if(tt.attribute!==dt)return!0;if(dt&&tt.data!==dt.data)return!0;H++}if(r.attributesNum!==H)return!0;if(r.index!==R)return!0;return!1}function v(N,F,X,R){let k={},Z=F.attributes,H=0,at=X.getAttributes();for(let K in at)if(at[K].location>=0){let tt=Z[K];if(tt===void 0){if(K==="instanceMatrix"&&N.instanceMatrix)tt=N.instanceMatrix;if(K==="instanceColor"&&N.instanceColor)tt=N.instanceColor}let dt={};if(dt.attribute=tt,tt&&tt.data)dt.data=tt.data;k[K]=dt,H++}r.attributes=k,r.attributesNum=H,r.index=R}function T(){let N=r.newAttributes;for(let F=0,X=N.length;F<X;F++)N[F]=0}function m(N){f(N,0)}function f(N,F){let X=r.newAttributes,R=r.enabledAttributes,k=r.attributeDivisors;if(X[N]=1,R[N]===0)t.enableVertexAttribArray(N),R[N]=1;if(k[N]!==F)t.vertexAttribDivisor(N,F),k[N]=F}function w(){let N=r.newAttributes,F=r.enabledAttributes;for(let X=0,R=F.length;X<R;X++)if(F[X]!==N[X])t.disableVertexAttribArray(X),F[X]=0}function C(N,F,X,R,k,Z,H){if(H===!0)t.vertexAttribIPointer(N,F,X,k,Z);else t.vertexAttribPointer(N,F,X,R,k,Z)}function y(N,F,X,R){T();let k=R.attributes,Z=X.getAttributes(),H=F.defaultAttributeValues;for(let at in Z){let K=Z[at];if(K.location>=0){let et=k[at];if(et===void 0){if(at==="instanceMatrix"&&N.instanceMatrix)et=N.instanceMatrix;if(at==="instanceColor"&&N.instanceColor)et=N.instanceColor}if(et!==void 0){let tt=et.normalized,dt=et.itemSize,At=e.get(et);if(At===void 0)continue;let{buffer:te,type:zt,bytesPerElement:Y}=At,rt=zt===t.INT||zt===t.UNSIGNED_INT||et.gpuType===eo;if(et.isInterleavedBufferAttribute){let lt=et.data,It=lt.stride,Ot=et.offset;if(lt.isInstancedInterleavedBuffer){for(let Ft=0;Ft<K.locationSize;Ft++)f(K.location+Ft,lt.meshPerAttribute);if(N.isInstancedMesh!==!0&&R._maxInstanceCount===void 0)R._maxInstanceCount=lt.meshPerAttribute*lt.count}else for(let Ft=0;Ft<K.locationSize;Ft++)m(K.location+Ft);t.bindBuffer(t.ARRAY_BUFFER,te);for(let Ft=0;Ft<K.locationSize;Ft++)C(K.location+Ft,dt/K.locationSize,zt,tt,It*Y,(Ot+dt/K.locationSize*Ft)*Y,rt)}else{if(et.isInstancedBufferAttribute){for(let lt=0;lt<K.locationSize;lt++)f(K.location+lt,et.meshPerAttribute);if(N.isInstancedMesh!==!0&&R._maxInstanceCount===void 0)R._maxInstanceCount=et.meshPerAttribute*et.count}else for(let lt=0;lt<K.locationSize;lt++)m(K.location+lt);t.bindBuffer(t.ARRAY_BUFFER,te);for(let lt=0;lt<K.locationSize;lt++)C(K.location+lt,dt/K.locationSize,zt,tt,dt*Y,dt/K.locationSize*lt*Y,rt)}}else if(H!==void 0){let tt=H[at];if(tt!==void 0)switch(tt.length){case 2:t.vertexAttrib2fv(K.location,tt);break;case 3:t.vertexAttrib3fv(K.location,tt);break;case 4:t.vertexAttrib4fv(K.location,tt);break;default:t.vertexAttrib1fv(K.location,tt)}}}}w()}function b(){M();for(let N in i){let F=i[N];for(let X in F){let R=F[X];for(let k in R){let Z=R[k];for(let H in Z)u(Z[H].object),delete Z[H];delete R[k]}}delete i[N]}}function A(N){if(i[N.id]===void 0)return;let F=i[N.id];for(let X in F){let R=F[X];for(let k in R){let Z=R[k];for(let H in Z)u(Z[H].object),delete Z[H];delete R[k]}}delete i[N.id]}function E(N){for(let F in i){let X=i[F];for(let R in X){let k=X[R];if(k[N.id]===void 0)continue;let Z=k[N.id];for(let H in Z)u(Z[H].object),delete Z[H];delete k[N.id]}}}function g(N){for(let F in i){let X=i[F],R=N.isInstancedMesh===!0?N.id:0,k=X[R];if(k===void 0)continue;for(let Z in k){let H=k[Z];for(let at in H)u(H[at].object),delete H[at];delete k[Z]}if(delete X[R],Object.keys(X).length===0)delete i[F]}}function M(){if(G(),a=!0,r===s)return;r=s,c(r.object)}function G(){s.geometry=null,s.program=null,s.wireframe=!1}return{setup:o,reset:M,resetDefaultState:G,dispose:b,releaseStatesOfGeometry:A,releaseStatesOfObject:g,releaseStatesOfProgram:E,initAttributes:T,enableAttribute:m,disableUnusedAttributes:w}}function Qp(t,e,n){let i;function s(l){i=l}function r(l,c){t.drawArrays(i,l,c),n.update(c,i,1)}function a(l,c,u){if(u===0)return;t.drawArraysInstanced(i,l,c,u),n.update(c,i,u)}function o(l,c,u){if(u===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,l,0,c,0,u);let h=0;for(let p=0;p<u;p++)h+=c[p];n.update(h,i,1)}this.setMode=s,this.render=r,this.renderInstances=a,this.renderMultiDraw=o}function jp(t,e,n,i){let s;function r(){if(s!==void 0)return s;if(e.has("EXT_texture_filter_anisotropic")===!0){let E=e.get("EXT_texture_filter_anisotropic");s=t.getParameter(E.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else s=0;return s}function a(E){if(E!==Gn&&i.convert(E)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT))return!1;return!0}function o(E){let g=E===kn&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));if(E!==mn&&E!==jn&&!g&&i.convert(E)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE))return!1;return!0}function l(E){if(E==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";E="mediump"}if(E==="mediump"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0)return"mediump"}return"lowp"}let c=n.precision!==void 0?n.precision:"highp",u=l(c);if(u!==c)Ht("WebGLRenderer:",c,"not supported, using",u,"instead."),c=u;let d=n.logarithmicDepthBuffer===!0,h=n.reversedDepthBuffer===!0&&e.has("EXT_clip_control");if(n.reversedDepthBuffer===!0&&h===!1)Ht("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");let p=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),v=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),T=t.getParameter(t.MAX_TEXTURE_SIZE),m=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),f=t.getParameter(t.MAX_VERTEX_ATTRIBS),w=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),C=t.getParameter(t.MAX_VARYING_VECTORS),y=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),b=t.getParameter(t.MAX_SAMPLES),A=t.getParameter(t.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:d,reversedDepthBuffer:h,maxTextures:p,maxVertexTextures:v,maxTextureSize:T,maxCubemapSize:m,maxAttributes:f,maxVertexUniforms:w,maxVaryings:C,maxFragmentUniforms:y,maxSamples:b,samples:A}}function tm(t){let e=this,n=null,i=0,s=!1,r=!1,a=new Fn,o=new qt,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(d,h){let p=d.length!==0||h||i!==0||s;return s=h,i=d.length,p},this.beginShadows=function(){r=!0,u(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(d,h){n=u(d,h,0)},this.setState=function(d,h,p){let{clippingPlanes:v,clipIntersection:T,clipShadows:m}=d,f=t.get(d);if(!s||v===null||v.length===0||r&&!m)if(r)u(null);else c();else{let w=r?0:i,C=w*4,y=f.clippingState||null;l.value=y,y=u(v,h,C,p);for(let b=0;b!==C;++b)y[b]=n[b];f.clippingState=y,this.numIntersection=T?this.numPlanes:0,this.numPlanes+=w}};function c(){if(l.value!==n)l.value=n,l.needsUpdate=i>0;e.numPlanes=i,e.numIntersection=0}function u(d,h,p,v){let T=d!==null?d.length:0,m=null;if(T!==0){if(m=l.value,v!==!0||m===null){let f=p+T*4,w=h.matrixWorldInverse;if(o.getNormalMatrix(w),m===null||m.length<f)m=new Float32Array(f);for(let C=0,y=p;C!==T;++C,y+=4)a.copy(d[C]).applyMatrix4(w,o),a.normal.toArray(m,y),m[y+3]=a.constant}l.value=m,l.needsUpdate=!0}return e.numPlanes=T,e.numIntersection=0,m}}var ys=4,em=6,nm=20,im=256,nr=new er,wh=new Kt,bl=null,Tl=0,wl=0,El=!1,sm=new O,Gi=new O;class Rl{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(t,e=0,n=0.1,i=100,s={}){let{size:r=256,position:a=sm}=s;bl=this._renderer.getRenderTarget(),Tl=this._renderer.getActiveCubeFace(),wl=this._renderer.getActiveMipmapLevel(),El=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(r);let o=this._allocateTargets();if(o.depthBuffer=!0,this._sceneToCubeUV(t,n,i,o,a),e>0)this._blur(o,0,0,e);return this._applyPMREM(o),this._cleanup(o),o}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){if(this._cubemapMaterial===null)this._cubemapMaterial=Ch(),this._compileMaterial(this._cubemapMaterial)}compileEquirectangularShader(){if(this._equirectMaterial===null)this._equirectMaterial=Ah(),this._compileMaterial(this._equirectMaterial)}dispose(){if(this._dispose(),this._cubemapMaterial!==null)this._cubemapMaterial.dispose();if(this._equirectMaterial!==null)this._equirectMaterial.dispose();if(this._backgroundBox!==null)this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose()}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){if(this._blurMaterial!==null)this._blurMaterial.dispose();if(this._ggxMaterial!==null)this._ggxMaterial.dispose();if(this._pingPongRenderTarget!==null)this._pingPongRenderTarget.dispose();for(let t=0;t<this._lodMeshes.length;t++)this._lodMeshes[t].geometry.dispose()}_cleanup(t){this._renderer.setRenderTarget(bl,Tl,wl),this._renderer.xr.enabled=El,t.scissorTest=!1,vs(t,0,0,t.width,t.height)}_fromTexture(t,e){if(t.mapping===ms||t.mapping===Ai)this._setSize(t.image.length===0?16:t.image[0].width||t.image[0].image.width);else this._setSize(t.image.width/4);bl=this._renderer.getRenderTarget(),Tl=this._renderer.getActiveCubeFace(),wl=this._renderer.getActiveMipmapLevel(),El=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;let n=e||this._allocateTargets();return this._textureToCubeUV(t,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){let t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,n={magFilter:Qe,minFilter:Qe,generateMipmaps:!1,type:kn,format:Gn,colorSpace:qo,depthBuffer:!1},i=Eh(t,e,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){if(this._pingPongRenderTarget!==null)this._dispose();this._pingPongRenderTarget=Eh(t,e,n);let{_lodMax:s}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods}=rm(s)),this._blurMaterial=om(s,t,e),this._ggxMaterial=am(s,t,e)}return i}_compileMaterial(t){let e=new Jt(new _n,t);this._renderer.compile(e,nr)}_sceneToCubeUV(t,e,n,i,s){let o=new sn(90,1,e,n),l=[1,-1,1,1,1,1],c=[1,1,1,-1,-1,-1],u=this._renderer,{autoClear:d,toneMapping:h}=u;if(u.getClearColor(wh),u.toneMapping=Ln,u.autoClear=!1,u.state.buffers.depth.getReversed())u.setRenderTarget(i),u.clearDepth(),u.setRenderTarget(null);if(this._backgroundBox===null)this._backgroundBox=new Jt(new Hn,new Be({name:"PMREM.Background",side:Ve,depthWrite:!1,depthTest:!1}));let v=this._backgroundBox,T=v.material,m=!1,f=t.background;if(f){if(f.isColor)T.color.copy(f),t.background=null,m=!0}else T.color.copy(wh),m=!0;for(let w=0;w<6;w++){let C=w%3;if(C===0)o.up.set(0,l[w],0),o.position.set(s.x,s.y,s.z),o.lookAt(s.x+c[w],s.y,s.z);else if(C===1)o.up.set(0,0,l[w]),o.position.set(s.x,s.y,s.z),o.lookAt(s.x,s.y+c[w],s.z);else o.up.set(0,l[w],0),o.position.set(s.x,s.y,s.z),o.lookAt(s.x,s.y,s.z+c[w]);let y=this._cubeSize;if(vs(i,C*y,w>2?y:0,y,y),u.setRenderTarget(i),m)u.render(v,o);u.render(t,o)}u.toneMapping=h,u.autoClear=d,t.background=f}_textureToCubeUV(t,e){let n=this._renderer,i=t.mapping===ms||t.mapping===Ai;if(i){if(this._cubemapMaterial===null)this._cubemapMaterial=Ch();this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1}else if(this._equirectMaterial===null)this._equirectMaterial=Ah();let s=i?this._cubemapMaterial:this._equirectMaterial,r=this._lodMeshes[0];r.material=s;let a=s.uniforms;a.envMap.value=t;let o=this._cubeSize;vs(e,0,0,3*o,2*o),n.setRenderTarget(e),n.render(r,nr)}_applyPMREM(t){let e=this._renderer,n=e.autoClear;e.autoClear=!1;let i=this._lodMeshes.length;for(let s=1;s<i;s++)this._applyGGXFilter(t,s-1,s);e.autoClear=n}_applyGGXFilter(t,e,n){let i=this._renderer,s=this._pingPongRenderTarget,r=this._ggxMaterial,a=this._lodMeshes[n];a.material=r;let o=r.uniforms,l=n/(this._lodMeshes.length-1),c=e/(this._lodMeshes.length-1),u=Math.sqrt(l*l-c*c),d=l*1.25,h=u*d,{_lodMax:p}=this,v=this._sizeLods[n],T=3*v*(n>p-ys?n-p+ys:0),m=4*(this._cubeSize-v);o.envMap.value=t.texture,o.roughness.value=h,o.mipInt.value=p-e,vs(s,T,m,3*v,2*v),i.setRenderTarget(s),i.render(a,nr),o.envMap.value=s.texture,o.roughness.value=0,o.mipInt.value=p-n,vs(t,T,m,3*v,2*v),i.setRenderTarget(t),i.render(a,nr)}_blur(t,e,n,i){let s=this._pingPongRenderTarget,r=Math.min(i,Math.PI)/Math.SQRT2;this._blurPass(t,s,e,n,r),this._blurPass(s,t,n,n,r)}_blurPass(t,e,n,i,s){let r=this._renderer,a=this._blurMaterial,o=this._lodMeshes[i];o.material=a;let l=a.uniforms;l.envMap.value=t.texture,l.sigma.value=s,l.mipInt.value=this._lodMax-n;let c=this._sizeLods[i],u=3*c*(i>this._lodMax-ys?i-this._lodMax+ys:0),d=4*(this._cubeSize-c);vs(e,u,d,3*c,2*c),r.setRenderTarget(e),r.render(o,nr)}}function rm(t){let e=[],n=[],i=t,s=t-ys+1+em;for(let r=0;r<s;r++){let a=Math.pow(2,i);e.push(a);let o=1/(a-2),l=-o,c=1+o,u=[l,l,c,l,c,c,l,l,c,c,l,c],d=6,h=6,p=3,v=new Float32Array(p*h*d),T=new Float32Array(p*h*d);for(let f=0;f<d;f++){let w=f%3*2/3-1,C=f>2?0:-1,y=[w,C,0,w+0.6666666666666666,C,0,w+0.6666666666666666,C+1,0,w,C,0,w+0.6666666666666666,C+1,0,w,C+1,0];v.set(y,p*h*f);for(let b=0;b<h;b++){let A=u[b*2]*2-1,E=u[b*2+1]*2-1;if(f===0)Gi.set(1,E,A);else if(f===1)Gi.set(-A,1,-E);else if(f===2)Gi.set(-A,E,1);else if(f===3)Gi.set(-1,E,-A);else if(f===4)Gi.set(-A,-1,E);else Gi.set(A,E,-1);Gi.toArray(T,(f*h+b)*p)}}let m=new _n;if(m.setAttribute("position",new Mn(v,p)),m.setAttribute("outputDirection",new Mn(T,p)),n.push(new Jt(m,null)),i>ys)i--}return{lodMeshes:n,sizeLods:e}}function Eh(t,e,n){let i=new gn(t,e,n);return i.texture.mapping=Gs,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function vs(t,e,n,i,s){t.viewport.set(e,n,i,s),t.scissor.set(e,n,i,s)}function am(t,e,n){return new bn({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:im,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${t}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:ha(),fragmentShader:`
3823
+ }`,jt={alphahash_fragment:md,alphahash_pars_fragment:gd,alphamap_fragment:_d,alphamap_pars_fragment:xd,alphatest_fragment:vd,alphatest_pars_fragment:yd,aomap_fragment:Sd,aomap_pars_fragment:Md,batching_pars_vertex:bd,batching_vertex:Td,begin_vertex:wd,beginnormal_vertex:Ed,bsdfs:Ad,iridescence_fragment:Cd,bumpmap_pars_fragment:Rd,clipping_planes_fragment:Id,clipping_planes_pars_fragment:Pd,clipping_planes_pars_vertex:Ld,clipping_planes_vertex:Nd,color_fragment:Dd,color_pars_fragment:Ud,color_pars_vertex:Fd,color_vertex:Od,common:Bd,cube_uv_reflection_fragment:zd,defaultnormal_vertex:kd,displacementmap_pars_vertex:Gd,displacementmap_vertex:Hd,emissivemap_fragment:Vd,emissivemap_pars_fragment:Wd,colorspace_fragment:Xd,colorspace_pars_fragment:qd,envmap_fragment:Yd,envmap_common_pars_fragment:Zd,envmap_pars_fragment:Jd,envmap_pars_vertex:$d,envmap_physical_pars_fragment:lf,envmap_vertex:Kd,fog_vertex:Qd,fog_pars_vertex:jd,fog_fragment:tf,fog_pars_fragment:ef,gradientmap_pars_fragment:nf,lightmap_pars_fragment:sf,lights_lambert_fragment:rf,lights_lambert_pars_fragment:af,lights_pars_begin:of,lights_toon_fragment:cf,lights_toon_pars_fragment:hf,lights_phong_fragment:uf,lights_phong_pars_fragment:df,lights_physical_fragment:ff,lights_physical_pars_fragment:pf,lights_fragment_begin:mf,lights_fragment_maps:gf,lights_fragment_end:_f,lightprobes_pars_fragment:xf,logdepthbuf_fragment:vf,logdepthbuf_pars_fragment:yf,logdepthbuf_pars_vertex:Sf,logdepthbuf_vertex:Mf,map_fragment:bf,map_pars_fragment:Tf,map_particle_fragment:wf,map_particle_pars_fragment:Ef,metalnessmap_fragment:Af,metalnessmap_pars_fragment:Cf,morphinstance_vertex:Rf,morphcolor_vertex:If,morphnormal_vertex:Pf,morphtarget_pars_vertex:Lf,morphtarget_vertex:Nf,normal_fragment_begin:Df,normal_fragment_maps:Uf,normal_pars_fragment:Ff,normal_pars_vertex:Of,normal_vertex:Bf,normalmap_pars_fragment:zf,clearcoat_normal_fragment_begin:kf,clearcoat_normal_fragment_maps:Gf,clearcoat_pars_fragment:Hf,iridescence_pars_fragment:Vf,opaque_fragment:Wf,packing:Xf,premultiplied_alpha_fragment:qf,project_vertex:Yf,dithering_fragment:Zf,dithering_pars_fragment:Jf,roughnessmap_fragment:$f,roughnessmap_pars_fragment:Kf,shadowmap_pars_fragment:Qf,shadowmap_pars_vertex:jf,shadowmap_vertex:tp,shadowmask_pars_fragment:ep,skinbase_vertex:np,skinning_pars_vertex:ip,skinning_vertex:sp,skinnormal_vertex:rp,specularmap_fragment:ap,specularmap_pars_fragment:op,tonemapping_fragment:lp,tonemapping_pars_fragment:cp,transmission_fragment:hp,transmission_pars_fragment:up,uv_pars_fragment:dp,uv_pars_vertex:fp,uv_vertex:pp,worldpos_vertex:mp,background_vert:gp,background_frag:_p,backgroundCube_vert:xp,backgroundCube_frag:vp,cube_vert:yp,cube_frag:Sp,depth_vert:Mp,depth_frag:bp,distance_vert:Tp,distance_frag:wp,equirect_vert:Ep,equirect_frag:Ap,linedashed_vert:Cp,linedashed_frag:Rp,meshbasic_vert:Ip,meshbasic_frag:Pp,meshlambert_vert:Lp,meshlambert_frag:Np,meshmatcap_vert:Dp,meshmatcap_frag:Up,meshnormal_vert:Fp,meshnormal_frag:Op,meshphong_vert:Bp,meshphong_frag:zp,meshphysical_vert:kp,meshphysical_frag:Gp,meshtoon_vert:Hp,meshtoon_frag:Vp,points_vert:Wp,points_frag:Xp,shadow_vert:qp,shadow_frag:Yp,sprite_vert:Zp,sprite_frag:Jp},gt={common:{diffuse:{value:new Kt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Yt},alphaMap:{value:null},alphaMapTransform:{value:new Yt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Yt}},envmap:{envMap:{value:null},envMapRotation:{value:new Yt},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:0.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Yt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Yt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Yt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Yt},normalScale:{value:new qt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Yt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Yt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Yt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Yt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:0.00025},fogNear:{value:1},fogFar:{value:2000},fogColor:{value:new Kt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},sunLights:{value:[],properties:{direction:{},color:{}}},sunLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},sunShadowMatrix:{value:[]},sunShadowCascade:{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 O},probesMax:{value:new O},probesResolution:{value:new O}},points:{diffuse:{value:new Kt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Yt},alphaTest:{value:0},uvTransform:{value:new Yt}},sprite:{diffuse:{value:new Kt(16777215)},opacity:{value:1},center:{value:new qt(0.5,0.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Yt},alphaMap:{value:null},alphaMapTransform:{value:new Yt},alphaTest:{value:0}}},Wn={basic:{uniforms:je([gt.common,gt.specularmap,gt.envmap,gt.aomap,gt.lightmap,gt.fog]),vertexShader:jt.meshbasic_vert,fragmentShader:jt.meshbasic_frag},lambert:{uniforms:je([gt.common,gt.specularmap,gt.envmap,gt.aomap,gt.lightmap,gt.emissivemap,gt.bumpmap,gt.normalmap,gt.displacementmap,gt.fog,gt.lights,{emissive:{value:new Kt(0)},envMapIntensity:{value:1}}]),vertexShader:jt.meshlambert_vert,fragmentShader:jt.meshlambert_frag},phong:{uniforms:je([gt.common,gt.specularmap,gt.envmap,gt.aomap,gt.lightmap,gt.emissivemap,gt.bumpmap,gt.normalmap,gt.displacementmap,gt.fog,gt.lights,{emissive:{value:new Kt(0)},specular:{value:new Kt(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:jt.meshphong_vert,fragmentShader:jt.meshphong_frag},standard:{uniforms:je([gt.common,gt.envmap,gt.aomap,gt.lightmap,gt.emissivemap,gt.bumpmap,gt.normalmap,gt.displacementmap,gt.roughnessmap,gt.metalnessmap,gt.fog,gt.lights,{emissive:{value:new Kt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:jt.meshphysical_vert,fragmentShader:jt.meshphysical_frag},toon:{uniforms:je([gt.common,gt.aomap,gt.lightmap,gt.emissivemap,gt.bumpmap,gt.normalmap,gt.displacementmap,gt.gradientmap,gt.fog,gt.lights,{emissive:{value:new Kt(0)}}]),vertexShader:jt.meshtoon_vert,fragmentShader:jt.meshtoon_frag},matcap:{uniforms:je([gt.common,gt.bumpmap,gt.normalmap,gt.displacementmap,gt.fog,{matcap:{value:null}}]),vertexShader:jt.meshmatcap_vert,fragmentShader:jt.meshmatcap_frag},points:{uniforms:je([gt.points,gt.fog]),vertexShader:jt.points_vert,fragmentShader:jt.points_frag},dashed:{uniforms:je([gt.common,gt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:jt.linedashed_vert,fragmentShader:jt.linedashed_frag},depth:{uniforms:je([gt.common,gt.displacementmap]),vertexShader:jt.depth_vert,fragmentShader:jt.depth_frag},normal:{uniforms:je([gt.common,gt.bumpmap,gt.normalmap,gt.displacementmap,{opacity:{value:1}}]),vertexShader:jt.meshnormal_vert,fragmentShader:jt.meshnormal_frag},sprite:{uniforms:je([gt.sprite,gt.fog]),vertexShader:jt.sprite_vert,fragmentShader:jt.sprite_frag},background:{uniforms:{uvTransform:{value:new Yt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:jt.background_vert,fragmentShader:jt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Yt}},vertexShader:jt.backgroundCube_vert,fragmentShader:jt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:jt.cube_vert,fragmentShader:jt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:jt.equirect_vert,fragmentShader:jt.equirect_frag},distance:{uniforms:je([gt.common,gt.displacementmap,{referencePosition:{value:new O},nearDistance:{value:1},farDistance:{value:1000}}]),vertexShader:jt.distance_vert,fragmentShader:jt.distance_frag},shadow:{uniforms:je([gt.lights,gt.fog,{color:{value:new Kt(0)},opacity:{value:1}}]),vertexShader:jt.shadow_vert,fragmentShader:jt.shadow_frag}};Wn.physical={uniforms:je([Wn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Yt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Yt},clearcoatNormalScale:{value:new qt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Yt},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Yt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Yt},sheen:{value:0},sheenColor:{value:new Kt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Yt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Yt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Yt},transmissionSamplerSize:{value:new qt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Yt},attenuationDistance:{value:0},attenuationColor:{value:new Kt(0)},specularColor:{value:new Kt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Yt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Yt},anisotropyVector:{value:new qt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Yt}}]),vertexShader:jt.meshphysical_vert,fragmentShader:jt.meshphysical_frag};var pa={r:0,b:0,g:0},$p=new we,Zh=new Yt;Zh.set(-1,0,0,0,1,0,0,0,1);function Kp(t,e,n,i,s,r){let a=new Kt(0),o=s===!0?0:1,l,c,u=null,d=0,h=null;function p(w){let C=w.isScene===!0?w.background:null;if(C&&C.isTexture){let y=w.backgroundBlurriness>0;C=e.get(C,y)}return C}function v(w){let C=!1,y=p(w);if(y===null)m(a,o);else if(y&&y.isColor)m(y,1),C=!0;let b=t.xr.getEnvironmentBlendMode();if(b==="additive")n.buffers.color.setClear(0,0,0,1,r);else if(b==="alpha-blend")n.buffers.color.setClear(0,0,0,0,r);if(t.autoClear||C)n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil)}function T(w,C){let y=p(C);if(y&&(y.isCubeTexture||y.mapping===Js)){if(c===void 0)c=new Jt(new Hn(1,1,1),new bn({name:"BackgroundCubeMaterial",uniforms:Fi(Wn.backgroundCube.uniforms),vertexShader:Wn.backgroundCube.vertexShader,fragmentShader:Wn.backgroundCube.fragmentShader,side:Ve,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(b,A,E){this.matrixWorld.copyPosition(E.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(c);if(c.material.uniforms.envMap.value=y,c.material.uniforms.backgroundBlurriness.value=C.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=C.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4($p.makeRotationFromEuler(C.backgroundRotation)).transpose(),y.isCubeTexture&&y.isRenderTargetTexture===!1)c.material.uniforms.backgroundRotation.value.premultiply(Zh);if(c.material.toneMapped=re.getTransfer(y.colorSpace)!==Me,u!==y||d!==y.version||h!==t.toneMapping)c.material.needsUpdate=!0,u=y,d=y.version,h=t.toneMapping;c.layers.enableAll(),w.unshift(c,c.geometry,c.material,0,0,null)}else if(y&&y.isTexture){if(l===void 0)l=new Jt(new Ie(2,2),new bn({name:"BackgroundMaterial",uniforms:Fi(Wn.background.uniforms),vertexShader:Wn.background.vertexShader,fragmentShader:Wn.background.fragmentShader,side:xs,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(l);if(l.material.uniforms.t2D.value=y,l.material.uniforms.backgroundIntensity.value=C.backgroundIntensity,l.material.toneMapped=re.getTransfer(y.colorSpace)!==Me,y.matrixAutoUpdate===!0)y.updateMatrix();if(l.material.uniforms.uvTransform.value.copy(y.matrix),u!==y||d!==y.version||h!==t.toneMapping)l.material.needsUpdate=!0,u=y,d=y.version,h=t.toneMapping;l.layers.enableAll(),w.unshift(l,l.geometry,l.material,0,0,null)}}function m(w,C){w.getRGB(pa,il(t)),n.buffers.color.setClear(pa.r,pa.g,pa.b,C,r)}function f(){if(c!==void 0)c.geometry.dispose(),c.material.dispose(),c=void 0;if(l!==void 0)l.geometry.dispose(),l.material.dispose(),l=void 0}return{getClearColor:function(){return a},setClearColor:function(w,C=1){a.set(w),o=C,m(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(w){o=w,m(a,o)},render:v,addToRenderList:T,dispose:f}}function Qp(t,e){let n=t.getParameter(t.MAX_VERTEX_ATTRIBS),i={},s=h(null),r=s,a=!1;function o(N,F,X,R,k){let Z=!1,H=d(N,R,X,F);if(r!==H)r=H,c(r.object);if(Z=p(N,R,X,k),Z)v(N,R,X,k);if(k!==null)e.update(k,t.ELEMENT_ARRAY_BUFFER);if(Z||a){if(a=!1,y(N,F,X,R),k!==null)t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e.get(k).buffer)}}function l(){return t.createVertexArray()}function c(N){return t.bindVertexArray(N)}function u(N){return t.deleteVertexArray(N)}function d(N,F,X,R){let k=R.wireframe===!0,Z=i[F.id];if(Z===void 0)Z={},i[F.id]=Z;let H=N.isInstancedMesh===!0?N.id:0,at=Z[H];if(at===void 0)at={},Z[H]=at;let K=at[X.id];if(K===void 0)K={},at[X.id]=K;let et=K[k];if(et===void 0)et=h(l()),K[k]=et;return et}function h(N){let F=[],X=[],R=[];for(let k=0;k<n;k++)F[k]=0,X[k]=0,R[k]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:F,enabledAttributes:X,attributeDivisors:R,object:N,attributes:{},index:null}}function p(N,F,X,R){let k=r.attributes,Z=F.attributes,H=0,at=X.getAttributes();for(let K in at)if(at[K].location>=0){let tt=k[K],dt=Z[K];if(dt===void 0){if(K==="instanceMatrix"&&N.instanceMatrix)dt=N.instanceMatrix;if(K==="instanceColor"&&N.instanceColor)dt=N.instanceColor}if(tt===void 0)return!0;if(tt.attribute!==dt)return!0;if(dt&&tt.data!==dt.data)return!0;H++}if(r.attributesNum!==H)return!0;if(r.index!==R)return!0;return!1}function v(N,F,X,R){let k={},Z=F.attributes,H=0,at=X.getAttributes();for(let K in at)if(at[K].location>=0){let tt=Z[K];if(tt===void 0){if(K==="instanceMatrix"&&N.instanceMatrix)tt=N.instanceMatrix;if(K==="instanceColor"&&N.instanceColor)tt=N.instanceColor}let dt={};if(dt.attribute=tt,tt&&tt.data)dt.data=tt.data;k[K]=dt,H++}r.attributes=k,r.attributesNum=H,r.index=R}function T(){let N=r.newAttributes;for(let F=0,X=N.length;F<X;F++)N[F]=0}function m(N){f(N,0)}function f(N,F){let X=r.newAttributes,R=r.enabledAttributes,k=r.attributeDivisors;if(X[N]=1,R[N]===0)t.enableVertexAttribArray(N),R[N]=1;if(k[N]!==F)t.vertexAttribDivisor(N,F),k[N]=F}function w(){let N=r.newAttributes,F=r.enabledAttributes;for(let X=0,R=F.length;X<R;X++)if(F[X]!==N[X])t.disableVertexAttribArray(X),F[X]=0}function C(N,F,X,R,k,Z,H){if(H===!0)t.vertexAttribIPointer(N,F,X,k,Z);else t.vertexAttribPointer(N,F,X,R,k,Z)}function y(N,F,X,R){T();let k=R.attributes,Z=X.getAttributes(),H=F.defaultAttributeValues;for(let at in Z){let K=Z[at];if(K.location>=0){let et=k[at];if(et===void 0){if(at==="instanceMatrix"&&N.instanceMatrix)et=N.instanceMatrix;if(at==="instanceColor"&&N.instanceColor)et=N.instanceColor}if(et!==void 0){let tt=et.normalized,dt=et.itemSize,At=e.get(et);if(At===void 0)continue;let{buffer:te,type:Bt,bytesPerElement:Y}=At,rt=Bt===t.INT||Bt===t.UNSIGNED_INT||et.gpuType===oo;if(et.isInterleavedBufferAttribute){let lt=et.data,It=lt.stride,Ft=et.offset;if(lt.isInstancedInterleavedBuffer){for(let Ut=0;Ut<K.locationSize;Ut++)f(K.location+Ut,lt.meshPerAttribute);if(N.isInstancedMesh!==!0&&R._maxInstanceCount===void 0)R._maxInstanceCount=lt.meshPerAttribute*lt.count}else for(let Ut=0;Ut<K.locationSize;Ut++)m(K.location+Ut);t.bindBuffer(t.ARRAY_BUFFER,te);for(let Ut=0;Ut<K.locationSize;Ut++)C(K.location+Ut,dt/K.locationSize,Bt,tt,It*Y,(Ft+dt/K.locationSize*Ut)*Y,rt)}else{if(et.isInstancedBufferAttribute){for(let lt=0;lt<K.locationSize;lt++)f(K.location+lt,et.meshPerAttribute);if(N.isInstancedMesh!==!0&&R._maxInstanceCount===void 0)R._maxInstanceCount=et.meshPerAttribute*et.count}else for(let lt=0;lt<K.locationSize;lt++)m(K.location+lt);t.bindBuffer(t.ARRAY_BUFFER,te);for(let lt=0;lt<K.locationSize;lt++)C(K.location+lt,dt/K.locationSize,Bt,tt,dt*Y,dt/K.locationSize*lt*Y,rt)}}else if(H!==void 0){let tt=H[at];if(tt!==void 0)switch(tt.length){case 2:t.vertexAttrib2fv(K.location,tt);break;case 3:t.vertexAttrib3fv(K.location,tt);break;case 4:t.vertexAttrib4fv(K.location,tt);break;default:t.vertexAttrib1fv(K.location,tt)}}}}w()}function b(){M();for(let N in i){let F=i[N];for(let X in F){let R=F[X];for(let k in R){let Z=R[k];for(let H in Z)u(Z[H].object),delete Z[H];delete R[k]}}delete i[N]}}function A(N){if(i[N.id]===void 0)return;let F=i[N.id];for(let X in F){let R=F[X];for(let k in R){let Z=R[k];for(let H in Z)u(Z[H].object),delete Z[H];delete R[k]}}delete i[N.id]}function E(N){for(let F in i){let X=i[F];for(let R in X){let k=X[R];if(k[N.id]===void 0)continue;let Z=k[N.id];for(let H in Z)u(Z[H].object),delete Z[H];delete k[N.id]}}}function g(N){for(let F in i){let X=i[F],R=N.isInstancedMesh===!0?N.id:0,k=X[R];if(k===void 0)continue;for(let Z in k){let H=k[Z];for(let at in H)u(H[at].object),delete H[at];delete k[Z]}if(delete X[R],Object.keys(X).length===0)delete i[F]}}function M(){if(G(),a=!0,r===s)return;r=s,c(r.object)}function G(){s.geometry=null,s.program=null,s.wireframe=!1}return{setup:o,reset:M,resetDefaultState:G,dispose:b,releaseStatesOfGeometry:A,releaseStatesOfObject:g,releaseStatesOfProgram:E,initAttributes:T,enableAttribute:m,disableUnusedAttributes:w}}function jp(t,e,n){let i;function s(l){i=l}function r(l,c){t.drawArrays(i,l,c),n.update(c,i,1)}function a(l,c,u){if(u===0)return;t.drawArraysInstanced(i,l,c,u),n.update(c,i,u)}function o(l,c,u){if(u===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,l,0,c,0,u);let h=0;for(let p=0;p<u;p++)h+=c[p];n.update(h,i,1)}this.setMode=s,this.render=r,this.renderInstances=a,this.renderMultiDraw=o}function tm(t,e,n,i){let s;function r(){if(s!==void 0)return s;if(e.has("EXT_texture_filter_anisotropic")===!0){let E=e.get("EXT_texture_filter_anisotropic");s=t.getParameter(E.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else s=0;return s}function a(E){if(E!==Gn&&i.convert(E)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT))return!1;return!0}function o(E){let g=E===kn&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));if(E!==mn&&E!==jn&&!g&&i.convert(E)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE))return!1;return!0}function l(E){if(E==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";E="mediump"}if(E==="mediump"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0)return"mediump"}return"lowp"}let c=n.precision!==void 0?n.precision:"highp",u=l(c);if(u!==c)Vt("WebGLRenderer:",c,"not supported, using",u,"instead."),c=u;let d=n.logarithmicDepthBuffer===!0,h=n.reversedDepthBuffer===!0&&e.has("EXT_clip_control");if(n.reversedDepthBuffer===!0&&h===!1)Vt("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");let p=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),v=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),T=t.getParameter(t.MAX_TEXTURE_SIZE),m=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),f=t.getParameter(t.MAX_VERTEX_ATTRIBS),w=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),C=t.getParameter(t.MAX_VARYING_VECTORS),y=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),b=t.getParameter(t.MAX_SAMPLES),A=t.getParameter(t.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:d,reversedDepthBuffer:h,maxTextures:p,maxVertexTextures:v,maxTextureSize:T,maxCubemapSize:m,maxAttributes:f,maxVertexUniforms:w,maxVaryings:C,maxFragmentUniforms:y,maxSamples:b,samples:A}}function em(t){let e=this,n=null,i=0,s=!1,r=!1,a=new Un,o=new Yt,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(d,h){let p=d.length!==0||h||i!==0||s;return s=h,i=d.length,p},this.beginShadows=function(){r=!0,u(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(d,h){n=u(d,h,0)},this.setState=function(d,h,p){let{clippingPlanes:v,clipIntersection:T,clipShadows:m}=d,f=t.get(d);if(!s||v===null||v.length===0||r&&!m)if(r)u(null);else c();else{let w=r?0:i,C=w*4,y=f.clippingState||null;l.value=y,y=u(v,h,C,p);for(let b=0;b!==C;++b)y[b]=n[b];f.clippingState=y,this.numIntersection=T?this.numPlanes:0,this.numPlanes+=w}};function c(){if(l.value!==n)l.value=n,l.needsUpdate=i>0;e.numPlanes=i,e.numIntersection=0}function u(d,h,p,v){let T=d!==null?d.length:0,m=null;if(T!==0){if(m=l.value,v!==!0||m===null){let f=p+T*4,w=h.matrixWorldInverse;if(o.getNormalMatrix(w),m===null||m.length<f)m=new Float32Array(f);for(let C=0,y=p;C!==T;++C,y+=4)a.copy(d[C]).applyMatrix4(w,o),a.normal.toArray(m,y),m[y+3]=a.constant}l.value=m,l.needsUpdate=!0}return e.numPlanes=T,e.numIntersection=0,m}}var ws=4,nm=6,im=20,sm=256,lr=new or,Eh=new Kt,Tl=null,wl=0,El=0,Al=!1,rm=new O,ki=new O;class Il{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(t,e=0,n=0.1,i=100,s={}){let{size:r=256,position:a=rm}=s;Tl=this._renderer.getRenderTarget(),wl=this._renderer.getActiveCubeFace(),El=this._renderer.getActiveMipmapLevel(),Al=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(r);let o=this._allocateTargets();if(o.depthBuffer=!0,this._sceneToCubeUV(t,n,i,o,a),e>0)this._blur(o,0,0,e);return this._applyPMREM(o),this._cleanup(o),o}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){if(this._cubemapMaterial===null)this._cubemapMaterial=Rh(),this._compileMaterial(this._cubemapMaterial)}compileEquirectangularShader(){if(this._equirectMaterial===null)this._equirectMaterial=Ch(),this._compileMaterial(this._equirectMaterial)}dispose(){if(this._dispose(),this._cubemapMaterial!==null)this._cubemapMaterial.dispose();if(this._equirectMaterial!==null)this._equirectMaterial.dispose();if(this._backgroundBox!==null)this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose()}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){if(this._blurMaterial!==null)this._blurMaterial.dispose();if(this._ggxMaterial!==null)this._ggxMaterial.dispose();if(this._pingPongRenderTarget!==null)this._pingPongRenderTarget.dispose();for(let t=0;t<this._lodMeshes.length;t++)this._lodMeshes[t].geometry.dispose()}_cleanup(t){this._renderer.setRenderTarget(Tl,wl,El),this._renderer.xr.enabled=Al,t.scissorTest=!1,Ts(t,0,0,t.width,t.height)}_fromTexture(t,e){if(t.mapping===ys||t.mapping===Ai)this._setSize(t.image.length===0?16:t.image[0].width||t.image[0].image.width);else this._setSize(t.image.width/4);Tl=this._renderer.getRenderTarget(),wl=this._renderer.getActiveCubeFace(),El=this._renderer.getActiveMipmapLevel(),Al=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;let n=e||this._allocateTargets();return this._textureToCubeUV(t,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){let t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,n={magFilter:Qe,minFilter:Qe,generateMipmaps:!1,type:kn,format:Gn,colorSpace:Zo,depthBuffer:!1},i=Ah(t,e,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){if(this._pingPongRenderTarget!==null)this._dispose();this._pingPongRenderTarget=Ah(t,e,n);let{_lodMax:s}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods}=am(s)),this._blurMaterial=lm(s,t,e),this._ggxMaterial=om(s,t,e)}return i}_compileMaterial(t){let e=new Jt(new _n,t);this._renderer.compile(e,lr)}_sceneToCubeUV(t,e,n,i,s){let o=new nn(90,1,e,n),l=[1,-1,1,1,1,1],c=[1,1,1,-1,-1,-1],u=this._renderer,{autoClear:d,toneMapping:h}=u;if(u.getClearColor(Eh),u.toneMapping=Pn,u.autoClear=!1,u.state.buffers.depth.getReversed())u.setRenderTarget(i),u.clearDepth(),u.setRenderTarget(null);if(this._backgroundBox===null)this._backgroundBox=new Jt(new Hn,new Be({name:"PMREM.Background",side:Ve,depthWrite:!1,depthTest:!1}));let v=this._backgroundBox,T=v.material,m=!1,f=t.background;if(f){if(f.isColor)T.color.copy(f),t.background=null,m=!0}else T.color.copy(Eh),m=!0;for(let w=0;w<6;w++){let C=w%3;if(C===0)o.up.set(0,l[w],0),o.position.set(s.x,s.y,s.z),o.lookAt(s.x+c[w],s.y,s.z);else if(C===1)o.up.set(0,0,l[w]),o.position.set(s.x,s.y,s.z),o.lookAt(s.x,s.y+c[w],s.z);else o.up.set(0,l[w],0),o.position.set(s.x,s.y,s.z),o.lookAt(s.x,s.y,s.z+c[w]);let y=this._cubeSize;if(Ts(i,C*y,w>2?y:0,y,y),u.setRenderTarget(i),m)u.render(v,o);u.render(t,o)}u.toneMapping=h,u.autoClear=d,t.background=f}_textureToCubeUV(t,e){let n=this._renderer,i=t.mapping===ys||t.mapping===Ai;if(i){if(this._cubemapMaterial===null)this._cubemapMaterial=Rh();this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1}else if(this._equirectMaterial===null)this._equirectMaterial=Ch();let s=i?this._cubemapMaterial:this._equirectMaterial,r=this._lodMeshes[0];r.material=s;let a=s.uniforms;a.envMap.value=t;let o=this._cubeSize;Ts(e,0,0,3*o,2*o),n.setRenderTarget(e),n.render(r,lr)}_applyPMREM(t){let e=this._renderer,n=e.autoClear;e.autoClear=!1;let i=this._lodMeshes.length;for(let s=1;s<i;s++)this._applyGGXFilter(t,s-1,s);e.autoClear=n}_applyGGXFilter(t,e,n){let i=this._renderer,s=this._pingPongRenderTarget,r=this._ggxMaterial,a=this._lodMeshes[n];a.material=r;let o=r.uniforms,l=n/(this._lodMeshes.length-1),c=e/(this._lodMeshes.length-1),u=Math.sqrt(l*l-c*c),d=l*1.25,h=u*d,{_lodMax:p}=this,v=this._sizeLods[n],T=3*v*(n>p-ws?n-p+ws:0),m=4*(this._cubeSize-v);o.envMap.value=t.texture,o.roughness.value=h,o.mipInt.value=p-e,Ts(s,T,m,3*v,2*v),i.setRenderTarget(s),i.render(a,lr),o.envMap.value=s.texture,o.roughness.value=0,o.mipInt.value=p-n,Ts(t,T,m,3*v,2*v),i.setRenderTarget(t),i.render(a,lr)}_blur(t,e,n,i){let s=this._pingPongRenderTarget,r=Math.min(i,Math.PI)/Math.SQRT2;this._blurPass(t,s,e,n,r),this._blurPass(s,t,n,n,r)}_blurPass(t,e,n,i,s){let r=this._renderer,a=this._blurMaterial,o=this._lodMeshes[i];o.material=a;let l=a.uniforms;l.envMap.value=t.texture,l.sigma.value=s,l.mipInt.value=this._lodMax-n;let c=this._sizeLods[i],u=3*c*(i>this._lodMax-ws?i-this._lodMax+ws:0),d=4*(this._cubeSize-c);Ts(e,u,d,3*c,2*c),r.setRenderTarget(e),r.render(o,lr)}}function am(t){let e=[],n=[],i=t,s=t-ws+1+nm;for(let r=0;r<s;r++){let a=Math.pow(2,i);e.push(a);let o=1/(a-2),l=-o,c=1+o,u=[l,l,c,l,c,c,l,l,c,c,l,c],d=6,h=6,p=3,v=new Float32Array(p*h*d),T=new Float32Array(p*h*d);for(let f=0;f<d;f++){let w=f%3*2/3-1,C=f>2?0:-1,y=[w,C,0,w+0.6666666666666666,C,0,w+0.6666666666666666,C+1,0,w,C,0,w+0.6666666666666666,C+1,0,w,C+1,0];v.set(y,p*h*f);for(let b=0;b<h;b++){let A=u[b*2]*2-1,E=u[b*2+1]*2-1;if(f===0)ki.set(1,E,A);else if(f===1)ki.set(-A,1,-E);else if(f===2)ki.set(-A,E,1);else if(f===3)ki.set(-1,E,-A);else if(f===4)ki.set(-A,-1,E);else ki.set(A,E,-1);ki.toArray(T,(f*h+b)*p)}}let m=new _n;if(m.setAttribute("position",new Mn(v,p)),m.setAttribute("outputDirection",new Mn(T,p)),n.push(new Jt(m,null)),i>ws)i--}return{lodMeshes:n,sizeLods:e}}function Ah(t,e,n){let i=new gn(t,e,n);return i.texture.mapping=Js,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Ts(t,e,n,i,s){t.viewport.set(e,n,i,s),t.scissor.set(e,n,i,s)}function om(t,e,n){return new bn({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:sm,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${t}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:ga(),fragmentShader:`
3824
3824
 
3825
3825
  precision highp float;
3826
3826
  precision highp int;
@@ -3924,7 +3924,7 @@ void main() {
3924
3924
 
3925
3925
  gl_FragColor = vec4(prefilteredColor, 1.0);
3926
3926
  }
3927
- `,blending:Bn,depthTest:!1,depthWrite:!1})}function om(t,e,n){return new bn({name:"SphericalGaussianBlur",defines:{SAMPLES:nm,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${t}.0`},uniforms:{envMap:{value:null},sigma:{value:0},mipInt:{value:0}},vertexShader:ha(),fragmentShader:`
3927
+ `,blending:On,depthTest:!1,depthWrite:!1})}function lm(t,e,n){return new bn({name:"SphericalGaussianBlur",defines:{SAMPLES:im,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${t}.0`},uniforms:{envMap:{value:null},sigma:{value:0},mipInt:{value:0}},vertexShader:ga(),fragmentShader:`
3928
3928
 
3929
3929
  precision highp float;
3930
3930
  precision highp int;
@@ -3984,7 +3984,7 @@ void main() {
3984
3984
  gl_FragColor = vec4( accumColor / accumWeight, 1.0 );
3985
3985
 
3986
3986
  }
3987
- `,blending:Bn,depthTest:!1,depthWrite:!1})}function Ah(){return new bn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:ha(),fragmentShader:`
3987
+ `,blending:On,depthTest:!1,depthWrite:!1})}function Ch(){return new bn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:ga(),fragmentShader:`
3988
3988
 
3989
3989
  precision mediump float;
3990
3990
  precision mediump int;
@@ -4003,7 +4003,7 @@ void main() {
4003
4003
  gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
4004
4004
 
4005
4005
  }
4006
- `,blending:Bn,depthTest:!1,depthWrite:!1})}function Ch(){return new bn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:ha(),fragmentShader:`
4006
+ `,blending:On,depthTest:!1,depthWrite:!1})}function Rh(){return new bn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:ga(),fragmentShader:`
4007
4007
 
4008
4008
  precision mediump float;
4009
4009
  precision mediump int;
@@ -4019,7 +4019,7 @@ void main() {
4019
4019
  gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
4020
4020
 
4021
4021
  }
4022
- `,blending:Bn,depthTest:!1,depthWrite:!1})}function ha(){return`
4022
+ `,blending:On,depthTest:!1,depthWrite:!1})}function ga(){return`
4023
4023
 
4024
4024
  precision mediump float;
4025
4025
  precision mediump int;
@@ -4034,7 +4034,7 @@ void main() {
4034
4034
  gl_Position = vec4( position, 1.0 );
4035
4035
 
4036
4036
  }
4037
- `}class Ll extends gn{constructor(t=1,e={}){super(t,t,e);this.isWebGLCubeRenderTarget=!0;let n={width:t,height:t,depth:1},i=[n,n,n,n,n,n];this.texture=new ta(i),this._setTextureOptions(e),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.colorSpace=e.colorSpace,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;let n={uniforms:{tEquirect:{value:null}},vertexShader:`
4037
+ `}class Nl extends gn{constructor(t=1,e={}){super(t,t,e);this.isWebGLCubeRenderTarget=!0;let n={width:t,height:t,depth:1},i=[n,n,n,n,n,n];this.texture=new aa(i),this._setTextureOptions(e),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.colorSpace=e.colorSpace,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;let n={uniforms:{tEquirect:{value:null}},vertexShader:`
4038
4038
 
4039
4039
  varying vec3 vWorldDirection;
4040
4040
 
@@ -4069,7 +4069,7 @@ void main() {
4069
4069
  gl_FragColor = texture2D( tEquirect, sampleUV );
4070
4070
 
4071
4071
  }
4072
- `},i=new Hn(5,5,5),s=new bn({name:"CubemapFromEquirect",uniforms:Oi(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Ve,blending:Bn});s.uniforms.tEquirect.value=e;let r=new Jt(i,s),a=e.minFilter;if(e.minFilter===Ci)e.minFilter=Qe;return new _l(1,10,this).update(t,r),e.minFilter=a,r.geometry.dispose(),r.material.dispose(),this}clear(t,e=!0,n=!0,i=!0){let s=t.getRenderTarget();for(let r=0;r<6;r++)t.setRenderTarget(this,r),t.clear(e,n,i);t.setRenderTarget(s)}}function lm(t){let e=new WeakMap,n=new WeakMap,i=null;function s(h,p=!1){if(h===null||h===void 0)return null;if(p)return a(h);return r(h)}function r(h){if(h&&h.isTexture){let p=h.mapping;if(p===Fr||p===Or)if(e.has(h)){let v=e.get(h).texture;return o(v,h.mapping)}else{let v=h.image;if(v&&v.height>0){let T=new Ll(v.height);return T.fromEquirectangularTexture(t,h),e.set(h,T),h.addEventListener("dispose",c),o(T.texture,h.mapping)}else return null}}return h}function a(h){if(h&&h.isTexture){let p=h.mapping,v=p===Fr||p===Or,T=p===ms||p===Ai;if(v||T){let m=n.get(h),f=m!==void 0?m.texture.pmremVersion:0;if(h.isRenderTargetTexture&&h.pmremVersion!==f){if(i===null)i=new Rl(t);return m=v?i.fromEquirectangular(h,m):i.fromCubemap(h,m),m.texture.pmremVersion=h.pmremVersion,n.set(h,m),m.texture}else if(m!==void 0)return m.texture;else{let w=h.image;if(v&&w&&w.height>0||T&&w&&l(w)){if(i===null)i=new Rl(t);return m=v?i.fromEquirectangular(h):i.fromCubemap(h),m.texture.pmremVersion=h.pmremVersion,n.set(h,m),h.addEventListener("dispose",u),m.texture}else return null}}}return h}function o(h,p){if(p===Fr)h.mapping=ms;else if(p===Or)h.mapping=Ai;return h}function l(h){let p=0,v=6;for(let T=0;T<v;T++)if(h[T]!==void 0)p++;return p===v}function c(h){let p=h.target;p.removeEventListener("dispose",c);let v=e.get(p);if(v!==void 0)e.delete(p),v.dispose()}function u(h){let p=h.target;p.removeEventListener("dispose",u);let v=n.get(p);if(v!==void 0)n.delete(p),v.dispose()}function d(){if(e=new WeakMap,n=new WeakMap,i!==null)i.dispose(),i=null}return{get:s,dispose:d}}function cm(t){let e={};function n(i){if(e[i]!==void 0)return e[i];let s=t.getExtension(i);return e[i]=s,s}return{has:function(i){return n(i)!==null},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(i){let s=n(i);if(s===null)Ei("WebGLRenderer: "+i+" extension not supported.");return s}}}function hm(t,e,n,i){let s={},r=new WeakMap;function a(d){let h=d.target;if(h.index!==null)e.remove(h.index);for(let v in h.attributes)e.remove(h.attributes[v]);h.removeEventListener("dispose",a),delete s[h.id];let p=r.get(h);if(p)e.remove(p),r.delete(h);if(i.releaseStatesOfGeometry(h),h.isInstancedBufferGeometry===!0)delete h._maxInstanceCount;n.memory.geometries--}function o(d,h){if(s[h.id]===!0)return h;return h.addEventListener("dispose",a),s[h.id]=!0,n.memory.geometries++,h}function l(d){let h=d.attributes;for(let p in h)e.update(h[p],t.ARRAY_BUFFER)}function c(d){let h=[],p=d.index,v=d.attributes.position,T=0;if(v===void 0)return;if(p!==null){let w=p.array;T=p.version;for(let C=0,y=w.length;C<y;C+=3){let b=w[C+0],A=w[C+1],E=w[C+2];h.push(b,A,A,E,E,b)}}else{let w=v.array;T=v.version;for(let C=0,y=w.length/3-1;C<y;C+=3){let b=C+0,A=C+1,E=C+2;h.push(b,A,A,E,E,b)}}let m=new(v.count>=65535?Qr:Kr)(h,1);m.version=T;let f=r.get(d);if(f)e.remove(f);r.set(d,m)}function u(d){let h=r.get(d);if(h){let p=d.index;if(p!==null){if(h.version<p.version)c(d)}}else c(d);return r.get(d)}return{get:o,update:l,getWireframeAttribute:u}}function um(t,e,n){let i;function s(d){i=d}let r,a;function o(d){r=d.type,a=d.bytesPerElement}function l(d,h){t.drawElements(i,h,r,d*a),n.update(h,i,1)}function c(d,h,p){if(p===0)return;t.drawElementsInstanced(i,h,r,d*a,p),n.update(h,i,p)}function u(d,h,p){if(p===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,h,0,r,d,0,p);let T=0;for(let m=0;m<p;m++)T+=h[m];n.update(T,i,1)}this.setMode=s,this.setIndex=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=u}function dm(t){let e={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function i(r,a,o){switch(n.calls++,a){case t.TRIANGLES:n.triangles+=o*(r/3);break;case t.LINES:n.lines+=o*(r/2);break;case t.LINE_STRIP:n.lines+=o*(r-1);break;case t.LINE_LOOP:n.lines+=o*r;break;case t.POINTS:n.points+=o*r;break;default:Gt("WebGLInfo: Unknown draw mode:",a);break}}function s(){n.calls=0,n.triangles=0,n.points=0,n.lines=0}return{memory:e,render:n,programs:null,autoReset:!0,reset:s,update:i}}function fm(t,e,n){let i=new WeakMap,s=new Ae;function r(a,o,l){let c=a.morphTargetInfluences,u=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,d=u!==void 0?u.length:0,h=i.get(o);if(h===void 0||h.count!==d){let M=function(){E.dispose(),i.delete(o),o.removeEventListener("dispose",M)};if(h!==void 0)h.texture.dispose();let p=o.morphAttributes.position!==void 0,v=o.morphAttributes.normal!==void 0,T=o.morphAttributes.color!==void 0,m=o.morphAttributes.position||[],f=o.morphAttributes.normal||[],w=o.morphAttributes.color||[],C=0;if(p===!0)C=1;if(v===!0)C=2;if(T===!0)C=3;let y=o.attributes.position.count*C,b=1;if(y>e.maxTextureSize)b=Math.ceil(y/e.maxTextureSize),y=e.maxTextureSize;let A=new Float32Array(y*b*4*d),E=new Jr(A,y,b,d);E.type=jn,E.needsUpdate=!0;let g=C*4;for(let G=0;G<d;G++){let N=m[G],F=f[G],X=w[G],R=y*b*4*G;for(let k=0;k<N.count;k++){let Z=k*g;if(p===!0)s.fromBufferAttribute(N,k),A[R+Z+0]=s.x,A[R+Z+1]=s.y,A[R+Z+2]=s.z,A[R+Z+3]=0;if(v===!0)s.fromBufferAttribute(F,k),A[R+Z+4]=s.x,A[R+Z+5]=s.y,A[R+Z+6]=s.z,A[R+Z+7]=0;if(T===!0)s.fromBufferAttribute(X,k),A[R+Z+8]=s.x,A[R+Z+9]=s.y,A[R+Z+10]=s.z,A[R+Z+11]=X.itemSize===4?s.w:1}}h={count:d,texture:E,size:new Xt(y,b)},i.set(o,h),o.addEventListener("dispose",M)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)l.getUniforms().setValue(t,"morphTexture",a.morphTexture,n);else{let p=0;for(let T=0;T<c.length;T++)p+=c[T];let v=o.morphTargetsRelative?1:1-p;l.getUniforms().setValue(t,"morphTargetBaseInfluence",v),l.getUniforms().setValue(t,"morphTargetInfluences",c)}l.getUniforms().setValue(t,"morphTargetsTexture",h.texture,n),l.getUniforms().setValue(t,"morphTargetsTextureSize",h.size)}return{update:r}}function pm(t,e,n,i,s){let r=new WeakMap;function a(c){let u=s.render.frame,d=c.geometry,h=e.get(c,d);if(r.get(h)!==u)e.update(h),r.set(h,u);if(c.isInstancedMesh){if(c.hasEventListener("dispose",l)===!1)c.addEventListener("dispose",l);if(r.get(c)!==u){if(n.update(c.instanceMatrix,t.ARRAY_BUFFER),c.instanceColor!==null)n.update(c.instanceColor,t.ARRAY_BUFFER);r.set(c,u)}}if(c.isSkinnedMesh){let p=c.skeleton;if(r.get(p)!==u)p.update(),r.set(p,u)}return h}function o(){r=new WeakMap}function l(c){let u=c.target;if(u.removeEventListener("dispose",l),i.releaseStatesOfObject(u),n.remove(u.instanceMatrix),u.instanceColor!==null)n.remove(u.instanceColor)}return{update:a,dispose:o}}var mm={[Za]:"LINEAR_TONE_MAPPING",[Ja]:"REINHARD_TONE_MAPPING",[$a]:"CINEON_TONE_MAPPING",[Ka]:"ACES_FILMIC_TONE_MAPPING",[ja]:"AGX_TONE_MAPPING",[to]:"NEUTRAL_TONE_MAPPING",[Qa]:"CUSTOM_TONE_MAPPING"};function gm(t,e,n,i,s,r){let a=new gn(e,n,{type:t,depthBuffer:s,stencilBuffer:r,samples:i?4:0,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,resolveDepthBuffer:!1,resolveStencilBuffer:!1}),o=null,l=null,c=new _n;c.setAttribute("position",new Ye([-1,3,0,-1,-1,0,3,-1,0],3)),c.setAttribute("uv",new Ye([0,2,0,0,2,0],2));let u=new il({uniforms:{tDiffuse:{value:null}},vertexShader:`
4072
+ `},i=new Hn(5,5,5),s=new bn({name:"CubemapFromEquirect",uniforms:Fi(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Ve,blending:On});s.uniforms.tEquirect.value=e;let r=new Jt(i,s),a=e.minFilter;if(e.minFilter===Ci)e.minFilter=Qe;return new xl(1,10,this).update(t,r),e.minFilter=a,r.geometry.dispose(),r.material.dispose(),this}clear(t,e=!0,n=!0,i=!0){let s=t.getRenderTarget();for(let r=0;r<6;r++)t.setRenderTarget(this,r),t.clear(e,n,i);t.setRenderTarget(s)}}function cm(t){let e=new WeakMap,n=new WeakMap,i=null;function s(h,p=!1){if(h===null||h===void 0)return null;if(p)return a(h);return r(h)}function r(h){if(h&&h.isTexture){let p=h.mapping;if(p===Hr||p===Vr)if(e.has(h)){let v=e.get(h).texture;return o(v,h.mapping)}else{let v=h.image;if(v&&v.height>0){let T=new Nl(v.height);return T.fromEquirectangularTexture(t,h),e.set(h,T),h.addEventListener("dispose",c),o(T.texture,h.mapping)}else return null}}return h}function a(h){if(h&&h.isTexture){let p=h.mapping,v=p===Hr||p===Vr,T=p===ys||p===Ai;if(v||T){let m=n.get(h),f=m!==void 0?m.texture.pmremVersion:0;if(h.isRenderTargetTexture&&h.pmremVersion!==f){if(i===null)i=new Il(t);return m=v?i.fromEquirectangular(h,m):i.fromCubemap(h,m),m.texture.pmremVersion=h.pmremVersion,n.set(h,m),m.texture}else if(m!==void 0)return m.texture;else{let w=h.image;if(v&&w&&w.height>0||T&&w&&l(w)){if(i===null)i=new Il(t);return m=v?i.fromEquirectangular(h):i.fromCubemap(h),m.texture.pmremVersion=h.pmremVersion,n.set(h,m),h.addEventListener("dispose",u),m.texture}else return null}}}return h}function o(h,p){if(p===Hr)h.mapping=ys;else if(p===Vr)h.mapping=Ai;return h}function l(h){let p=0,v=6;for(let T=0;T<v;T++)if(h[T]!==void 0)p++;return p===v}function c(h){let p=h.target;p.removeEventListener("dispose",c);let v=e.get(p);if(v!==void 0)e.delete(p),v.dispose()}function u(h){let p=h.target;p.removeEventListener("dispose",u);let v=n.get(p);if(v!==void 0)n.delete(p),v.dispose()}function d(){if(e=new WeakMap,n=new WeakMap,i!==null)i.dispose(),i=null}return{get:s,dispose:d}}function hm(t){let e={};function n(i){if(e[i]!==void 0)return e[i];let s=t.getExtension(i);return e[i]=s,s}return{has:function(i){return n(i)!==null},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(i){let s=n(i);if(s===null)Ei("WebGLRenderer: "+i+" extension not supported.");return s}}}function um(t,e,n,i){let s={},r=new WeakMap;function a(d){let h=d.target;if(h.index!==null)e.remove(h.index);for(let v in h.attributes)e.remove(h.attributes[v]);h.removeEventListener("dispose",a),delete s[h.id];let p=r.get(h);if(p)e.remove(p),r.delete(h);if(i.releaseStatesOfGeometry(h),h.isInstancedBufferGeometry===!0)delete h._maxInstanceCount;n.memory.geometries--}function o(d,h){if(s[h.id]===!0)return h;return h.addEventListener("dispose",a),s[h.id]=!0,n.memory.geometries++,h}function l(d){let h=d.attributes;for(let p in h)e.update(h[p],t.ARRAY_BUFFER)}function c(d){let h=[],p=d.index,v=d.attributes.position,T=0;if(v===void 0)return;if(p!==null){let w=p.array;T=p.version;for(let C=0,y=w.length;C<y;C+=3){let b=w[C+0],A=w[C+1],E=w[C+2];h.push(b,A,A,E,E,b)}}else{let w=v.array;T=v.version;for(let C=0,y=w.length/3-1;C<y;C+=3){let b=C+0,A=C+1,E=C+2;h.push(b,A,A,E,E,b)}}let m=new(v.count>=65535?sa:ia)(h,1);m.version=T;let f=r.get(d);if(f)e.remove(f);r.set(d,m)}function u(d){let h=r.get(d);if(h){let p=d.index;if(p!==null){if(h.version<p.version)c(d)}}else c(d);return r.get(d)}return{get:o,update:l,getWireframeAttribute:u}}function dm(t,e,n){let i;function s(d){i=d}let r,a;function o(d){r=d.type,a=d.bytesPerElement}function l(d,h){t.drawElements(i,h,r,d*a),n.update(h,i,1)}function c(d,h,p){if(p===0)return;t.drawElementsInstanced(i,h,r,d*a,p),n.update(h,i,p)}function u(d,h,p){if(p===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,h,0,r,d,0,p);let T=0;for(let m=0;m<p;m++)T+=h[m];n.update(T,i,1)}this.setMode=s,this.setIndex=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=u}function fm(t){let e={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function i(r,a,o){switch(n.calls++,a){case t.TRIANGLES:n.triangles+=o*(r/3);break;case t.LINES:n.lines+=o*(r/2);break;case t.LINE_STRIP:n.lines+=o*(r-1);break;case t.LINE_LOOP:n.lines+=o*r;break;case t.POINTS:n.points+=o*r;break;default:Ht("WebGLInfo: Unknown draw mode:",a);break}}function s(){n.calls=0,n.triangles=0,n.points=0,n.lines=0}return{memory:e,render:n,programs:null,autoReset:!0,reset:s,update:i}}function pm(t,e,n){let i=new WeakMap,s=new Ae;function r(a,o,l){let c=a.morphTargetInfluences,u=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,d=u!==void 0?u.length:0,h=i.get(o);if(h===void 0||h.count!==d){let M=function(){E.dispose(),i.delete(o),o.removeEventListener("dispose",M)};if(h!==void 0)h.texture.dispose();let p=o.morphAttributes.position!==void 0,v=o.morphAttributes.normal!==void 0,T=o.morphAttributes.color!==void 0,m=o.morphAttributes.position||[],f=o.morphAttributes.normal||[],w=o.morphAttributes.color||[],C=0;if(p===!0)C=1;if(v===!0)C=2;if(T===!0)C=3;let y=o.attributes.position.count*C,b=1;if(y>e.maxTextureSize)b=Math.ceil(y/e.maxTextureSize),y=e.maxTextureSize;let A=new Float32Array(y*b*4*d),E=new ea(A,y,b,d);E.type=jn,E.needsUpdate=!0;let g=C*4;for(let G=0;G<d;G++){let N=m[G],F=f[G],X=w[G],R=y*b*4*G;for(let k=0;k<N.count;k++){let Z=k*g;if(p===!0)s.fromBufferAttribute(N,k),A[R+Z+0]=s.x,A[R+Z+1]=s.y,A[R+Z+2]=s.z,A[R+Z+3]=0;if(v===!0)s.fromBufferAttribute(F,k),A[R+Z+4]=s.x,A[R+Z+5]=s.y,A[R+Z+6]=s.z,A[R+Z+7]=0;if(T===!0)s.fromBufferAttribute(X,k),A[R+Z+8]=s.x,A[R+Z+9]=s.y,A[R+Z+10]=s.z,A[R+Z+11]=X.itemSize===4?s.w:1}}h={count:d,texture:E,size:new qt(y,b)},i.set(o,h),o.addEventListener("dispose",M)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)l.getUniforms().setValue(t,"morphTexture",a.morphTexture,n);else{let p=0;for(let T=0;T<c.length;T++)p+=c[T];let v=o.morphTargetsRelative?1:1-p;l.getUniforms().setValue(t,"morphTargetBaseInfluence",v),l.getUniforms().setValue(t,"morphTargetInfluences",c)}l.getUniforms().setValue(t,"morphTargetsTexture",h.texture,n),l.getUniforms().setValue(t,"morphTargetsTextureSize",h.size)}return{update:r}}function mm(t,e,n,i,s){let r=new WeakMap;function a(c){let u=s.render.frame,d=c.geometry,h=e.get(c,d);if(r.get(h)!==u)e.update(h),r.set(h,u);if(c.isInstancedMesh){if(c.hasEventListener("dispose",l)===!1)c.addEventListener("dispose",l);if(r.get(c)!==u){if(n.update(c.instanceMatrix,t.ARRAY_BUFFER),c.instanceColor!==null)n.update(c.instanceColor,t.ARRAY_BUFFER);r.set(c,u)}}if(c.isSkinnedMesh){let p=c.skeleton;if(r.get(p)!==u)p.update(),r.set(p,u)}return h}function o(){r=new WeakMap}function l(c){let u=c.target;if(u.removeEventListener("dispose",l),i.releaseStatesOfObject(u),n.remove(u.instanceMatrix),u.instanceColor!==null)n.remove(u.instanceColor)}return{update:a,dispose:o}}var gm={[to]:"LINEAR_TONE_MAPPING",[eo]:"REINHARD_TONE_MAPPING",[no]:"CINEON_TONE_MAPPING",[io]:"ACES_FILMIC_TONE_MAPPING",[ro]:"AGX_TONE_MAPPING",[ao]:"NEUTRAL_TONE_MAPPING",[so]:"CUSTOM_TONE_MAPPING"};function _m(t,e,n,i,s,r){let a=new gn(e,n,{type:t,depthBuffer:s,stencilBuffer:r,samples:i?4:0,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,resolveDepthBuffer:!1,resolveStencilBuffer:!1}),o=null,l=null,c=new _n;c.setAttribute("position",new Ye([-1,3,0,-1,-1,0,3,-1,0],3)),c.setAttribute("uv",new Ye([0,2,0,0,2,0],2));let u=new sl({uniforms:{tDiffuse:{value:null}},vertexShader:`
4073
4073
  precision highp float;
4074
4074
 
4075
4075
  uniform mat4 modelViewMatrix;
@@ -4115,17 +4115,17 @@ void main() {
4115
4115
  #ifdef SRGB_TRANSFER
4116
4116
  gl_FragColor = sRGBTransferOETF( gl_FragColor );
4117
4117
  #endif
4118
- }`,depthTest:!1,depthWrite:!1}),d=new Jt(c,u),h=new er(-1,1,1,-1,0,1),p=null,v=null,T=!1,m,f=null,w=[],C=!1;this.setSize=function(y,b){if(a.setSize(y,b),o!==null)o.setSize(y,b);if(l!==null)l.setSize(y,b);for(let A=0;A<w.length;A++){let E=w[A];if(E.setSize)E.setSize(y,b)}},this.setEffects=function(y){w=y,C=w.length>0&&w[0].isRenderPass===!0;let{width:b,height:A}=a;if(w.length>0&&o===null)o=new gn(b,A,{type:kn,depthBuffer:!1,stencilBuffer:!1}),l=new gn(b,A,{type:kn,depthBuffer:!1,stencilBuffer:!1});for(let E=0;E<w.length;E++){let g=w[E];if(g.setSize)g.setSize(b,A)}},this.begin=function(y,b){if(T)return!1;if(y.toneMapping===Ln&&w.length===0)return!1;if(f=b,b!==null){let{width:A,height:E}=b;if(a.width!==A||a.height!==E)this.setSize(A,E)}if(C===!1)y.setRenderTarget(a);return m=y.toneMapping,y.toneMapping=Ln,!0},this.hasRenderPass=function(){return C},this.end=function(y,b){y.toneMapping=m,T=!0;let A=a,E=o;for(let g=0;g<w.length;g++){let M=w[g];if(M.enabled===!1)continue;if(M.render(y,E,A,b),M.needsSwap!==!1)A=E,E=E===o?l:o}if(p!==y.outputColorSpace||v!==y.toneMapping){if(p=y.outputColorSpace,v=y.toneMapping,u.defines={},re.getTransfer(p)===Me)u.defines.SRGB_TRANSFER="";let g=mm[v];if(g)u.defines[g]="";u.needsUpdate=!0}u.uniforms.tDiffuse.value=A.texture,y.setRenderTarget(f),y.render(d,h),f=null,T=!1},this.isCompositing=function(){return T},this.dispose=function(){if(a.dispose(),o!==null)o.dispose();if(l!==null)l.dispose();c.dispose(),u.dispose()}}var Zh=new qe,Il=new Fi(1,1),Jh=new Jr,$h=new jo,Kh=new ta,Rh=[],Ih=[],Ph=new Float32Array(16),Lh=new Float32Array(9),Nh=new Float32Array(4);function Ss(t,e,n){let i=t[0];if(i<=0||i>0)return t;let s=e*n,r=Rh[s];if(r===void 0)r=new Float32Array(s),Rh[s]=r;if(e!==0){i.toArray(r,0);for(let a=1,o=0;a!==e;++a)o+=n,t[a].toArray(r,o)}return r}function ze(t,e){if(t.length!==e.length)return!1;for(let n=0,i=t.length;n<i;n++)if(t[n]!==e[n])return!1;return!0}function ke(t,e){for(let n=0,i=e.length;n<i;n++)t[n]=e[n]}function ua(t,e){let n=Ih[e];if(n===void 0)n=new Int32Array(e),Ih[e]=n;for(let i=0;i!==e;++i)n[i]=t.allocateTextureUnit();return n}function _m(t,e){let n=this.cache;if(n[0]===e)return;t.uniform1f(this.addr,e),n[0]=e}function xm(t,e){let n=this.cache;if(e.x!==void 0){if(n[0]!==e.x||n[1]!==e.y)t.uniform2f(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y}else{if(ze(n,e))return;t.uniform2fv(this.addr,e),ke(n,e)}}function vm(t,e){let n=this.cache;if(e.x!==void 0){if(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)t.uniform3f(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z}else if(e.r!==void 0){if(n[0]!==e.r||n[1]!==e.g||n[2]!==e.b)t.uniform3f(this.addr,e.r,e.g,e.b),n[0]=e.r,n[1]=e.g,n[2]=e.b}else{if(ze(n,e))return;t.uniform3fv(this.addr,e),ke(n,e)}}function ym(t,e){let n=this.cache;if(e.x!==void 0){if(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)t.uniform4f(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w}else{if(ze(n,e))return;t.uniform4fv(this.addr,e),ke(n,e)}}function Sm(t,e){let n=this.cache,i=e.elements;if(i===void 0){if(ze(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),ke(n,e)}else{if(ze(n,i))return;Nh.set(i),t.uniformMatrix2fv(this.addr,!1,Nh),ke(n,i)}}function Mm(t,e){let n=this.cache,i=e.elements;if(i===void 0){if(ze(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),ke(n,e)}else{if(ze(n,i))return;Lh.set(i),t.uniformMatrix3fv(this.addr,!1,Lh),ke(n,i)}}function bm(t,e){let n=this.cache,i=e.elements;if(i===void 0){if(ze(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),ke(n,e)}else{if(ze(n,i))return;Ph.set(i),t.uniformMatrix4fv(this.addr,!1,Ph),ke(n,i)}}function Tm(t,e){let n=this.cache;if(n[0]===e)return;t.uniform1i(this.addr,e),n[0]=e}function wm(t,e){let n=this.cache;if(e.x!==void 0){if(n[0]!==e.x||n[1]!==e.y)t.uniform2i(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y}else{if(ze(n,e))return;t.uniform2iv(this.addr,e),ke(n,e)}}function Em(t,e){let n=this.cache;if(e.x!==void 0){if(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)t.uniform3i(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z}else{if(ze(n,e))return;t.uniform3iv(this.addr,e),ke(n,e)}}function Am(t,e){let n=this.cache;if(e.x!==void 0){if(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)t.uniform4i(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w}else{if(ze(n,e))return;t.uniform4iv(this.addr,e),ke(n,e)}}function Cm(t,e){let n=this.cache;if(n[0]===e)return;t.uniform1ui(this.addr,e),n[0]=e}function Rm(t,e){let n=this.cache;if(e.x!==void 0){if(n[0]!==e.x||n[1]!==e.y)t.uniform2ui(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y}else{if(ze(n,e))return;t.uniform2uiv(this.addr,e),ke(n,e)}}function Im(t,e){let n=this.cache;if(e.x!==void 0){if(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)t.uniform3ui(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z}else{if(ze(n,e))return;t.uniform3uiv(this.addr,e),ke(n,e)}}function Pm(t,e){let n=this.cache;if(e.x!==void 0){if(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)t.uniform4ui(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w}else{if(ze(n,e))return;t.uniform4uiv(this.addr,e),ke(n,e)}}function Lm(t,e,n){let i=this.cache,s=n.allocateTextureUnit();if(i[0]!==s)t.uniform1i(this.addr,s),i[0]=s;let r;if(this.type===t.SAMPLER_2D_SHADOW)Il.compareFunction=n.isReversedDepthBuffer()?Zr:Yr,r=Il;else r=Zh;n.setTexture2D(e||r,s)}function Nm(t,e,n){let i=this.cache,s=n.allocateTextureUnit();if(i[0]!==s)t.uniform1i(this.addr,s),i[0]=s;n.setTexture3D(e||$h,s)}function Dm(t,e,n){let i=this.cache,s=n.allocateTextureUnit();if(i[0]!==s)t.uniform1i(this.addr,s),i[0]=s;n.setTextureCube(e||Kh,s)}function Um(t,e,n){let i=this.cache,s=n.allocateTextureUnit();if(i[0]!==s)t.uniform1i(this.addr,s),i[0]=s;n.setTexture2DArray(e||Jh,s)}function Fm(t){switch(t){case 5126:return _m;case 35664:return xm;case 35665:return vm;case 35666:return ym;case 35674:return Sm;case 35675:return Mm;case 35676:return bm;case 5124:case 35670:return Tm;case 35667:case 35671:return wm;case 35668:case 35672:return Em;case 35669:case 35673:return Am;case 5125:return Cm;case 36294:return Rm;case 36295:return Im;case 36296:return Pm;case 35678:case 36198:case 36298:case 36306:case 35682:return Lm;case 35679:case 36299:case 36307:return Nm;case 35680:case 36300:case 36308:case 36293:return Dm;case 36289:case 36303:case 36311:case 36292:return Um}}function Om(t,e){t.uniform1fv(this.addr,e)}function Bm(t,e){let n=Ss(e,this.size,2);t.uniform2fv(this.addr,n)}function zm(t,e){let n=Ss(e,this.size,3);t.uniform3fv(this.addr,n)}function km(t,e){let n=Ss(e,this.size,4);t.uniform4fv(this.addr,n)}function Gm(t,e){let n=Ss(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function Hm(t,e){let n=Ss(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function Vm(t,e){let n=Ss(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function Wm(t,e){t.uniform1iv(this.addr,e)}function Xm(t,e){t.uniform2iv(this.addr,e)}function qm(t,e){t.uniform3iv(this.addr,e)}function Ym(t,e){t.uniform4iv(this.addr,e)}function Zm(t,e){t.uniform1uiv(this.addr,e)}function Jm(t,e){t.uniform2uiv(this.addr,e)}function $m(t,e){t.uniform3uiv(this.addr,e)}function Km(t,e){t.uniform4uiv(this.addr,e)}function Qm(t,e,n){let i=this.cache,s=e.length,r=ua(n,s);if(!ze(i,r))t.uniform1iv(this.addr,r),ke(i,r);let a;if(this.type===t.SAMPLER_2D_SHADOW)a=Il;else a=Zh;for(let o=0;o!==s;++o)n.setTexture2D(e[o]||a,r[o])}function jm(t,e,n){let i=this.cache,s=e.length,r=ua(n,s);if(!ze(i,r))t.uniform1iv(this.addr,r),ke(i,r);for(let a=0;a!==s;++a)n.setTexture3D(e[a]||$h,r[a])}function tg(t,e,n){let i=this.cache,s=e.length,r=ua(n,s);if(!ze(i,r))t.uniform1iv(this.addr,r),ke(i,r);for(let a=0;a!==s;++a)n.setTextureCube(e[a]||Kh,r[a])}function eg(t,e,n){let i=this.cache,s=e.length,r=ua(n,s);if(!ze(i,r))t.uniform1iv(this.addr,r),ke(i,r);for(let a=0;a!==s;++a)n.setTexture2DArray(e[a]||Jh,r[a])}function ng(t){switch(t){case 5126:return Om;case 35664:return Bm;case 35665:return zm;case 35666:return km;case 35674:return Gm;case 35675:return Hm;case 35676:return Vm;case 5124:case 35670:return Wm;case 35667:case 35671:return Xm;case 35668:case 35672:return qm;case 35669:case 35673:return Ym;case 5125:return Zm;case 36294:return Jm;case 36295:return $m;case 36296:return Km;case 35678:case 36198:case 36298:case 36306:case 35682:return Qm;case 35679:case 36299:case 36307:return jm;case 35680:case 36300:case 36308:case 36293:return tg;case 36289:case 36303:case 36311:case 36292:return eg}}class Qh{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.setValue=Fm(e.type)}}class jh{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.size=e.size,this.setValue=ng(e.type)}}class tu{constructor(t){this.id=t,this.seq=[],this.map={}}setValue(t,e,n){let i=this.seq;for(let s=0,r=i.length;s!==r;++s){let a=i[s];a.setValue(t,e[a.id],n)}}}var Al=/(\w+)(\])?(\[|\.)?/g;function Dh(t,e){t.seq.push(e),t.map[e.id]=e}function ig(t,e,n){let i=t.name,s=i.length;Al.lastIndex=0;while(!0){let r=Al.exec(i),a=Al.lastIndex,o=r[1],l=r[2]==="]",c=r[3];if(l)o=o|0;if(c===void 0||c==="["&&a+2===s){Dh(n,c===void 0?new Qh(o,t,e):new jh(o,t,e));break}else{let d=n.map[o];if(d===void 0)d=new tu(o),Dh(n,d);n=d}}}class rr{constructor(t,e){this.seq=[],this.map={};let n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let r=0;r<n;++r){let a=t.getActiveUniform(e,r),o=t.getUniformLocation(e,a.name);ig(a,o,this)}let i=[],s=[];for(let r of this.seq)if(r.type===t.SAMPLER_2D_SHADOW||r.type===t.SAMPLER_CUBE_SHADOW||r.type===t.SAMPLER_2D_ARRAY_SHADOW)i.push(r);else s.push(r);if(i.length>0)this.seq=i.concat(s)}setValue(t,e,n,i){let s=this.map[e];if(s!==void 0)s.setValue(t,n,i)}setOptional(t,e,n){let i=e[n];if(i!==void 0)this.setValue(t,n,i)}static upload(t,e,n,i){for(let s=0,r=e.length;s!==r;++s){let a=e[s],o=n[a.id];if(o.needsUpdate!==!1)a.setValue(t,o.value,i)}}static seqWithValue(t,e){let n=[];for(let i=0,s=t.length;i!==s;++i){let r=t[i];if(r.id in e)n.push(r)}return n}}function Uh(t,e,n){let i=t.createShader(e);return t.shaderSource(i,n),t.compileShader(i),i}var sg=37297,rg=0;function ag(t,e){let n=t.split(`
4118
+ }`,depthTest:!1,depthWrite:!1}),d=new Jt(c,u),h=new or(-1,1,1,-1,0,1),p=null,v=null,T=!1,m,f=null,w=[],C=!1;this.setSize=function(y,b){if(a.setSize(y,b),o!==null)o.setSize(y,b);if(l!==null)l.setSize(y,b);for(let A=0;A<w.length;A++){let E=w[A];if(E.setSize)E.setSize(y,b)}},this.setEffects=function(y){w=y,C=w.length>0&&w[0].isRenderPass===!0;let{width:b,height:A}=a;if(w.length>0&&o===null)o=new gn(b,A,{type:kn,depthBuffer:!1,stencilBuffer:!1}),l=new gn(b,A,{type:kn,depthBuffer:!1,stencilBuffer:!1});for(let E=0;E<w.length;E++){let g=w[E];if(g.setSize)g.setSize(b,A)}},this.begin=function(y,b){if(T)return!1;if(y.toneMapping===Pn&&w.length===0)return!1;if(f=b,b!==null){let{width:A,height:E}=b;if(a.width!==A||a.height!==E)this.setSize(A,E)}if(C===!1)y.setRenderTarget(a);return m=y.toneMapping,y.toneMapping=Pn,!0},this.hasRenderPass=function(){return C},this.end=function(y,b){y.toneMapping=m,T=!0;let A=a,E=o;for(let g=0;g<w.length;g++){let M=w[g];if(M.enabled===!1)continue;if(M.render(y,E,A,b),M.needsSwap!==!1)A=E,E=E===o?l:o}if(p!==y.outputColorSpace||v!==y.toneMapping){if(p=y.outputColorSpace,v=y.toneMapping,u.defines={},re.getTransfer(p)===Me)u.defines.SRGB_TRANSFER="";let g=gm[v];if(g)u.defines[g]="";u.needsUpdate=!0}u.uniforms.tDiffuse.value=A.texture,y.setRenderTarget(f),y.render(d,h),f=null,T=!1},this.isCompositing=function(){return T},this.dispose=function(){if(a.dispose(),o!==null)o.dispose();if(l!==null)l.dispose();c.dispose(),u.dispose()}}var Jh=new qe,Pl=new Ui(1,1),$h=new ea,Kh=new tl,Qh=new aa,Ih=[],Ph=[],Lh=new Float32Array(16),Nh=new Float32Array(9),Dh=new Float32Array(4);function Es(t,e,n){let i=t[0];if(i<=0||i>0)return t;let s=e*n,r=Ih[s];if(r===void 0)r=new Float32Array(s),Ih[s]=r;if(e!==0){i.toArray(r,0);for(let a=1,o=0;a!==e;++a)o+=n,t[a].toArray(r,o)}return r}function ze(t,e){if(t.length!==e.length)return!1;for(let n=0,i=t.length;n<i;n++)if(t[n]!==e[n])return!1;return!0}function ke(t,e){for(let n=0,i=e.length;n<i;n++)t[n]=e[n]}function _a(t,e){let n=Ph[e];if(n===void 0)n=new Int32Array(e),Ph[e]=n;for(let i=0;i!==e;++i)n[i]=t.allocateTextureUnit();return n}function xm(t,e){let n=this.cache;if(n[0]===e)return;t.uniform1f(this.addr,e),n[0]=e}function vm(t,e){let n=this.cache;if(e.x!==void 0){if(n[0]!==e.x||n[1]!==e.y)t.uniform2f(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y}else{if(ze(n,e))return;t.uniform2fv(this.addr,e),ke(n,e)}}function ym(t,e){let n=this.cache;if(e.x!==void 0){if(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)t.uniform3f(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z}else if(e.r!==void 0){if(n[0]!==e.r||n[1]!==e.g||n[2]!==e.b)t.uniform3f(this.addr,e.r,e.g,e.b),n[0]=e.r,n[1]=e.g,n[2]=e.b}else{if(ze(n,e))return;t.uniform3fv(this.addr,e),ke(n,e)}}function Sm(t,e){let n=this.cache;if(e.x!==void 0){if(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)t.uniform4f(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w}else{if(ze(n,e))return;t.uniform4fv(this.addr,e),ke(n,e)}}function Mm(t,e){let n=this.cache,i=e.elements;if(i===void 0){if(ze(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),ke(n,e)}else{if(ze(n,i))return;Dh.set(i),t.uniformMatrix2fv(this.addr,!1,Dh),ke(n,i)}}function bm(t,e){let n=this.cache,i=e.elements;if(i===void 0){if(ze(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),ke(n,e)}else{if(ze(n,i))return;Nh.set(i),t.uniformMatrix3fv(this.addr,!1,Nh),ke(n,i)}}function Tm(t,e){let n=this.cache,i=e.elements;if(i===void 0){if(ze(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),ke(n,e)}else{if(ze(n,i))return;Lh.set(i),t.uniformMatrix4fv(this.addr,!1,Lh),ke(n,i)}}function wm(t,e){let n=this.cache;if(n[0]===e)return;t.uniform1i(this.addr,e),n[0]=e}function Em(t,e){let n=this.cache;if(e.x!==void 0){if(n[0]!==e.x||n[1]!==e.y)t.uniform2i(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y}else{if(ze(n,e))return;t.uniform2iv(this.addr,e),ke(n,e)}}function Am(t,e){let n=this.cache;if(e.x!==void 0){if(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)t.uniform3i(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z}else{if(ze(n,e))return;t.uniform3iv(this.addr,e),ke(n,e)}}function Cm(t,e){let n=this.cache;if(e.x!==void 0){if(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)t.uniform4i(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w}else{if(ze(n,e))return;t.uniform4iv(this.addr,e),ke(n,e)}}function Rm(t,e){let n=this.cache;if(n[0]===e)return;t.uniform1ui(this.addr,e),n[0]=e}function Im(t,e){let n=this.cache;if(e.x!==void 0){if(n[0]!==e.x||n[1]!==e.y)t.uniform2ui(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y}else{if(ze(n,e))return;t.uniform2uiv(this.addr,e),ke(n,e)}}function Pm(t,e){let n=this.cache;if(e.x!==void 0){if(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)t.uniform3ui(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z}else{if(ze(n,e))return;t.uniform3uiv(this.addr,e),ke(n,e)}}function Lm(t,e){let n=this.cache;if(e.x!==void 0){if(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)t.uniform4ui(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w}else{if(ze(n,e))return;t.uniform4uiv(this.addr,e),ke(n,e)}}function Nm(t,e,n){let i=this.cache,s=n.allocateTextureUnit();if(i[0]!==s)t.uniform1i(this.addr,s),i[0]=s;let r;if(this.type===t.SAMPLER_2D_SHADOW)Pl.compareFunction=n.isReversedDepthBuffer()?ta:jr,r=Pl;else r=Jh;n.setTexture2D(e||r,s)}function Dm(t,e,n){let i=this.cache,s=n.allocateTextureUnit();if(i[0]!==s)t.uniform1i(this.addr,s),i[0]=s;n.setTexture3D(e||Kh,s)}function Um(t,e,n){let i=this.cache,s=n.allocateTextureUnit();if(i[0]!==s)t.uniform1i(this.addr,s),i[0]=s;n.setTextureCube(e||Qh,s)}function Fm(t,e,n){let i=this.cache,s=n.allocateTextureUnit();if(i[0]!==s)t.uniform1i(this.addr,s),i[0]=s;n.setTexture2DArray(e||$h,s)}function Om(t){switch(t){case 5126:return xm;case 35664:return vm;case 35665:return ym;case 35666:return Sm;case 35674:return Mm;case 35675:return bm;case 35676:return Tm;case 5124:case 35670:return wm;case 35667:case 35671:return Em;case 35668:case 35672:return Am;case 35669:case 35673:return Cm;case 5125:return Rm;case 36294:return Im;case 36295:return Pm;case 36296:return Lm;case 35678:case 36198:case 36298:case 36306:case 35682:return Nm;case 35679:case 36299:case 36307:return Dm;case 35680:case 36300:case 36308:case 36293:return Um;case 36289:case 36303:case 36311:case 36292:return Fm}}function Bm(t,e){t.uniform1fv(this.addr,e)}function zm(t,e){let n=Es(e,this.size,2);t.uniform2fv(this.addr,n)}function km(t,e){let n=Es(e,this.size,3);t.uniform3fv(this.addr,n)}function Gm(t,e){let n=Es(e,this.size,4);t.uniform4fv(this.addr,n)}function Hm(t,e){let n=Es(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function Vm(t,e){let n=Es(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function Wm(t,e){let n=Es(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function Xm(t,e){t.uniform1iv(this.addr,e)}function qm(t,e){t.uniform2iv(this.addr,e)}function Ym(t,e){t.uniform3iv(this.addr,e)}function Zm(t,e){t.uniform4iv(this.addr,e)}function Jm(t,e){t.uniform1uiv(this.addr,e)}function $m(t,e){t.uniform2uiv(this.addr,e)}function Km(t,e){t.uniform3uiv(this.addr,e)}function Qm(t,e){t.uniform4uiv(this.addr,e)}function jm(t,e,n){let i=this.cache,s=e.length,r=_a(n,s);if(!ze(i,r))t.uniform1iv(this.addr,r),ke(i,r);let a;if(this.type===t.SAMPLER_2D_SHADOW)a=Pl;else a=Jh;for(let o=0;o!==s;++o)n.setTexture2D(e[o]||a,r[o])}function tg(t,e,n){let i=this.cache,s=e.length,r=_a(n,s);if(!ze(i,r))t.uniform1iv(this.addr,r),ke(i,r);for(let a=0;a!==s;++a)n.setTexture3D(e[a]||Kh,r[a])}function eg(t,e,n){let i=this.cache,s=e.length,r=_a(n,s);if(!ze(i,r))t.uniform1iv(this.addr,r),ke(i,r);for(let a=0;a!==s;++a)n.setTextureCube(e[a]||Qh,r[a])}function ng(t,e,n){let i=this.cache,s=e.length,r=_a(n,s);if(!ze(i,r))t.uniform1iv(this.addr,r),ke(i,r);for(let a=0;a!==s;++a)n.setTexture2DArray(e[a]||$h,r[a])}function ig(t){switch(t){case 5126:return Bm;case 35664:return zm;case 35665:return km;case 35666:return Gm;case 35674:return Hm;case 35675:return Vm;case 35676:return Wm;case 5124:case 35670:return Xm;case 35667:case 35671:return qm;case 35668:case 35672:return Ym;case 35669:case 35673:return Zm;case 5125:return Jm;case 36294:return $m;case 36295:return Km;case 36296:return Qm;case 35678:case 36198:case 36298:case 36306:case 35682:return jm;case 35679:case 36299:case 36307:return tg;case 35680:case 36300:case 36308:case 36293:return eg;case 36289:case 36303:case 36311:case 36292:return ng}}class jh{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.setValue=Om(e.type)}}class tu{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.size=e.size,this.setValue=ig(e.type)}}class eu{constructor(t){this.id=t,this.seq=[],this.map={}}setValue(t,e,n){let i=this.seq;for(let s=0,r=i.length;s!==r;++s){let a=i[s];a.setValue(t,e[a.id],n)}}}var Cl=/(\w+)(\])?(\[|\.)?/g;function Uh(t,e){t.seq.push(e),t.map[e.id]=e}function sg(t,e,n){let i=t.name,s=i.length;Cl.lastIndex=0;while(!0){let r=Cl.exec(i),a=Cl.lastIndex,o=r[1],l=r[2]==="]",c=r[3];if(l)o=o|0;if(c===void 0||c==="["&&a+2===s){Uh(n,c===void 0?new jh(o,t,e):new tu(o,t,e));break}else{let d=n.map[o];if(d===void 0)d=new eu(o),Uh(n,d);n=d}}}class ur{constructor(t,e){this.seq=[],this.map={};let n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let r=0;r<n;++r){let a=t.getActiveUniform(e,r),o=t.getUniformLocation(e,a.name);sg(a,o,this)}let i=[],s=[];for(let r of this.seq)if(r.type===t.SAMPLER_2D_SHADOW||r.type===t.SAMPLER_CUBE_SHADOW||r.type===t.SAMPLER_2D_ARRAY_SHADOW)i.push(r);else s.push(r);if(i.length>0)this.seq=i.concat(s)}setValue(t,e,n,i){let s=this.map[e];if(s!==void 0)s.setValue(t,n,i)}setOptional(t,e,n){let i=e[n];if(i!==void 0)this.setValue(t,n,i)}static upload(t,e,n,i){for(let s=0,r=e.length;s!==r;++s){let a=e[s],o=n[a.id];if(o.needsUpdate!==!1)a.setValue(t,o.value,i)}}static seqWithValue(t,e){let n=[];for(let i=0,s=t.length;i!==s;++i){let r=t[i];if(r.id in e)n.push(r)}return n}}function Fh(t,e,n){let i=t.createShader(e);return t.shaderSource(i,n),t.compileShader(i),i}var rg=37297,ag=0;function og(t,e){let n=t.split(`
4119
4119
  `),i=[],s=Math.max(e-6,0),r=Math.min(e+6,n.length);for(let a=s;a<r;a++){let o=a+1;i.push(`${o===e?">":" "} ${o}: ${n[a]}`)}return i.join(`
4120
- `)}var Fh=new qt;function og(t){re._getMatrix(Fh,re.workingColorSpace,t);let e=`mat3( ${Fh.elements.map((n)=>n.toFixed(4))} )`;switch(re.getTransfer(t)){case Yo:return[e,"LinearTransferOETF"];case Me:return[e,"sRGBTransferOETF"];default:return Ht("WebGLProgram: Unsupported color space: ",t),[e,"LinearTransferOETF"]}}function Oh(t,e,n){let i=t.getShaderParameter(e,t.COMPILE_STATUS),r=(t.getShaderInfoLog(e)||"").trim();if(i&&r==="")return"";let a=/ERROR: 0:(\d+)/.exec(r);if(a){let o=parseInt(a[1]);return n.toUpperCase()+`
4120
+ `)}var Oh=new Yt;function lg(t){re._getMatrix(Oh,re.workingColorSpace,t);let e=`mat3( ${Oh.elements.map((n)=>n.toFixed(4))} )`;switch(re.getTransfer(t)){case Jo:return[e,"LinearTransferOETF"];case Me:return[e,"sRGBTransferOETF"];default:return Vt("WebGLProgram: Unsupported color space: ",t),[e,"LinearTransferOETF"]}}function Bh(t,e,n){let i=t.getShaderParameter(e,t.COMPILE_STATUS),r=(t.getShaderInfoLog(e)||"").trim();if(i&&r==="")return"";let a=/ERROR: 0:(\d+)/.exec(r);if(a){let o=parseInt(a[1]);return n.toUpperCase()+`
4121
4121
 
4122
4122
  `+r+`
4123
4123
 
4124
- `+ag(t.getShaderSource(e),o)}else return r}function lg(t,e){let n=og(e);return[`vec4 ${t}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
4125
- `)}var cg={[Za]:"Linear",[Ja]:"Reinhard",[$a]:"Cineon",[Ka]:"ACESFilmic",[ja]:"AgX",[to]:"Neutral",[Qa]:"Custom"};function hg(t,e){let n=cg[e];if(n===void 0)return Ht("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+t+"( vec3 color ) { return LinearToneMapping( color ); }";return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}var ca=new O;function ug(){re.getLuminanceCoefficients(ca);let t=ca.x.toFixed(4),e=ca.y.toFixed(4),n=ca.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${t}, ${e}, ${n} );`,"\treturn dot( weights, rgb );","}"].join(`
4126
- `)}function dg(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",t.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(sr).join(`
4127
- `)}function fg(t){let e=[];for(let n in t){let i=t[n];if(i===!1)continue;e.push("#define "+n+" "+i)}return e.join(`
4128
- `)}function pg(t,e){let n={},i=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let s=0;s<i;s++){let r=t.getActiveAttrib(e,s),a=r.name,o=1;if(r.type===t.FLOAT_MAT2)o=2;if(r.type===t.FLOAT_MAT3)o=3;if(r.type===t.FLOAT_MAT4)o=4;n[a]={type:r.type,location:t.getAttribLocation(e,a),locationSize:o}}return n}function sr(t){return t!==""}function Bh(t,e){let n=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return t.replace(/NUM_SUN_LIGHTS/g,e.numSunLights).replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_SUN_LIGHT_SHADOWS/g,e.numSunLightShadows).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function zh(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}var mg=/^[ \t]*#include +<([\w\d./]+)>/gm;function Pl(t){return t.replace(mg,_g)}var gg=new Map;function _g(t,e){let n=jt[e];if(n===void 0){let i=gg.get(e);if(i!==void 0)n=jt[i],Ht('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i);else throw Error("THREE.WebGLProgram: Can not resolve #include <"+e+">")}return Pl(n)}var xg=/#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 kh(t){return t.replace(xg,vg)}function vg(t,e,n,i){let s="";for(let r=parseInt(e);r<parseInt(n);r++)s+=i.replace(/\[\s*i\s*\]/g,"[ "+r+" ]").replace(/UNROLLED_LOOP_INDEX/g,r);return s}function Gh(t){let e=`precision ${t.precision} float;
4124
+ `+og(t.getShaderSource(e),o)}else return r}function cg(t,e){let n=lg(e);return[`vec4 ${t}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
4125
+ `)}var hg={[to]:"Linear",[eo]:"Reinhard",[no]:"Cineon",[io]:"ACESFilmic",[ro]:"AgX",[ao]:"Neutral",[so]:"Custom"};function ug(t,e){let n=hg[e];if(n===void 0)return Vt("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+t+"( vec3 color ) { return LinearToneMapping( color ); }";return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}var ma=new O;function dg(){re.getLuminanceCoefficients(ma);let t=ma.x.toFixed(4),e=ma.y.toFixed(4),n=ma.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${t}, ${e}, ${n} );`,"\treturn dot( weights, rgb );","}"].join(`
4126
+ `)}function fg(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",t.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(hr).join(`
4127
+ `)}function pg(t){let e=[];for(let n in t){let i=t[n];if(i===!1)continue;e.push("#define "+n+" "+i)}return e.join(`
4128
+ `)}function mg(t,e){let n={},i=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let s=0;s<i;s++){let r=t.getActiveAttrib(e,s),a=r.name,o=1;if(r.type===t.FLOAT_MAT2)o=2;if(r.type===t.FLOAT_MAT3)o=3;if(r.type===t.FLOAT_MAT4)o=4;n[a]={type:r.type,location:t.getAttribLocation(e,a),locationSize:o}}return n}function hr(t){return t!==""}function zh(t,e){let n=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return t.replace(/NUM_SUN_LIGHTS/g,e.numSunLights).replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_SUN_LIGHT_SHADOWS/g,e.numSunLightShadows).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function kh(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}var gg=/^[ \t]*#include +<([\w\d./]+)>/gm;function Ll(t){return t.replace(gg,xg)}var _g=new Map;function xg(t,e){let n=jt[e];if(n===void 0){let i=_g.get(e);if(i!==void 0)n=jt[i],Vt('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i);else throw Error("THREE.WebGLProgram: Can not resolve #include <"+e+">")}return Ll(n)}var vg=/#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 Gh(t){return t.replace(vg,yg)}function yg(t,e,n,i){let s="";for(let r=parseInt(e);r<parseInt(n);r++)s+=i.replace(/\[\s*i\s*\]/g,"[ "+r+" ]").replace(/UNROLLED_LOOP_INDEX/g,r);return s}function Hh(t){let e=`precision ${t.precision} float;
4129
4129
  precision ${t.precision} int;
4130
4130
  precision ${t.precision} sampler2D;
4131
4131
  precision ${t.precision} samplerCube;
@@ -4145,30 +4145,30 @@ void main() {
4145
4145
  `;if(t.precision==="highp")e+=`
4146
4146
  #define HIGH_PRECISION`;else if(t.precision==="mediump")e+=`
4147
4147
  #define MEDIUM_PRECISION`;else if(t.precision==="lowp")e+=`
4148
- #define LOW_PRECISION`;return e}var yg={[ks]:"SHADOWMAP_TYPE_PCF",[ds]:"SHADOWMAP_TYPE_VSM"};function Sg(t){return yg[t.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}var Mg={[ms]:"ENVMAP_TYPE_CUBE",[Ai]:"ENVMAP_TYPE_CUBE",[Gs]:"ENVMAP_TYPE_CUBE_UV"};function bg(t){if(t.envMap===!1)return"ENVMAP_TYPE_CUBE";return Mg[t.envMapMode]||"ENVMAP_TYPE_CUBE"}var Tg={[Ai]:"ENVMAP_MODE_REFRACTION"};function wg(t){if(t.envMap===!1)return"ENVMAP_MODE_REFLECTION";return Tg[t.envMapMode]||"ENVMAP_MODE_REFLECTION"}var Eg={[$c]:"ENVMAP_BLENDING_MULTIPLY",[Kc]:"ENVMAP_BLENDING_MIX",[Qc]:"ENVMAP_BLENDING_ADD"};function Ag(t){if(t.envMap===!1)return"ENVMAP_BLENDING_NONE";return Eg[t.combine]||"ENVMAP_BLENDING_NONE"}function Cg(t){let e=t.envMapCubeUVHeight;if(e===null)return null;let n=Math.log2(e)-2,i=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,n),112)),texelHeight:i,maxMip:n}}function Rg(t,e,n,i){let s=t.getContext(),{defines:r,vertexShader:a,fragmentShader:o}=n,l=Sg(n),c=bg(n),u=wg(n),d=Ag(n),h=Cg(n),p=dg(n),v=fg(r),T=s.createProgram(),m,f,w=n.glslVersion?"#version "+n.glslVersion+`
4149
- `:"";if(n.isRawShaderMaterial){if(m=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,v].filter(sr).join(`
4148
+ #define LOW_PRECISION`;return e}var Sg={[Xs]:"SHADOWMAP_TYPE_PCF",[_s]:"SHADOWMAP_TYPE_VSM"};function Mg(t){return Sg[t.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}var bg={[ys]:"ENVMAP_TYPE_CUBE",[Ai]:"ENVMAP_TYPE_CUBE",[Js]:"ENVMAP_TYPE_CUBE_UV"};function Tg(t){if(t.envMap===!1)return"ENVMAP_TYPE_CUBE";return bg[t.envMapMode]||"ENVMAP_TYPE_CUBE"}var wg={[Ai]:"ENVMAP_MODE_REFRACTION"};function Eg(t){if(t.envMap===!1)return"ENVMAP_MODE_REFLECTION";return wg[t.envMapMode]||"ENVMAP_MODE_REFLECTION"}var Ag={[Kc]:"ENVMAP_BLENDING_MULTIPLY",[Qc]:"ENVMAP_BLENDING_MIX",[jc]:"ENVMAP_BLENDING_ADD"};function Cg(t){if(t.envMap===!1)return"ENVMAP_BLENDING_NONE";return Ag[t.combine]||"ENVMAP_BLENDING_NONE"}function Rg(t){let e=t.envMapCubeUVHeight;if(e===null)return null;let n=Math.log2(e)-2,i=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,n),112)),texelHeight:i,maxMip:n}}function Ig(t,e,n,i){let s=t.getContext(),{defines:r,vertexShader:a,fragmentShader:o}=n,l=Mg(n),c=Tg(n),u=Eg(n),d=Cg(n),h=Rg(n),p=fg(n),v=pg(r),T=s.createProgram(),m,f,w=n.glslVersion?"#version "+n.glslVersion+`
4149
+ `:"";if(n.isRawShaderMaterial){if(m=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,v].filter(hr).join(`
4150
4150
  `),m.length>0)m+=`
4151
- `;if(f=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,v].filter(sr).join(`
4151
+ `;if(f=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,v].filter(hr).join(`
4152
4152
  `),f.length>0)f+=`
4153
- `}else m=[Gh(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 "+u:"",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&&n.flatShading===!1?"#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&&n.flatShading===!1?"#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 "+l:"",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",`
4154
- `].filter(sr).join(`
4155
- `),f=[Gh(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 "+c:"",n.envMap?"#define "+u:"",n.envMap?"#define "+d:"",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.retroreflection?"#define USE_RETROREFLECTION":"",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&&n.flatShading===!1?"#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 "+l:"",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!==Ln?"#define TONE_MAPPING":"",n.toneMapping!==Ln?jt.tonemapping_pars_fragment:"",n.toneMapping!==Ln?hg("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",jt.colorspace_pars_fragment,lg("linearToOutputTexel",n.outputColorSpace),ug(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
4156
- `].filter(sr).join(`
4157
- `);if(a=Pl(a),a=Bh(a,n),a=zh(a,n),o=Pl(o),o=Bh(o,n),o=zh(o,n),a=kh(a),o=kh(o),n.isRawShaderMaterial!==!0)w=`#version 300 es
4153
+ `}else m=[Hh(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 "+u:"",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&&n.flatShading===!1?"#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&&n.flatShading===!1?"#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 "+l:"",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",`
4154
+ `].filter(hr).join(`
4155
+ `),f=[Hh(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 "+c:"",n.envMap?"#define "+u:"",n.envMap?"#define "+d:"",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.retroreflection?"#define USE_RETROREFLECTION":"",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&&n.flatShading===!1?"#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 "+l:"",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!==Pn?"#define TONE_MAPPING":"",n.toneMapping!==Pn?jt.tonemapping_pars_fragment:"",n.toneMapping!==Pn?ug("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",jt.colorspace_pars_fragment,cg("linearToOutputTexel",n.outputColorSpace),dg(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
4156
+ `].filter(hr).join(`
4157
+ `);if(a=Ll(a),a=zh(a,n),a=kh(a,n),o=Ll(o),o=zh(o,n),o=kh(o,n),a=Gh(a),o=Gh(o),n.isRawShaderMaterial!==!0)w=`#version 300 es
4158
4158
  `,m=[p,"#define attribute in","#define varying out","#define texture2D texture"].join(`
4159
4159
  `)+`
4160
- `+m,f=["#define varying in",n.glslVersion===Jo?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===Jo?"":"#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(`
4160
+ `+m,f=["#define varying in",n.glslVersion===$o?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===$o?"":"#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(`
4161
4161
  `)+`
4162
- `+f;let C=w+m+a,y=w+f+o,b=Uh(s,s.VERTEX_SHADER,C),A=Uh(s,s.FRAGMENT_SHADER,y);if(s.attachShader(T,b),s.attachShader(T,A),n.index0AttributeName!==void 0)s.bindAttribLocation(T,0,n.index0AttributeName);else if(n.hasPositionAttribute===!0)s.bindAttribLocation(T,0,"position");s.linkProgram(T);function E(N){if(t.debug.checkShaderErrors){let F=s.getProgramInfoLog(T)||"",X=s.getShaderInfoLog(b)||"",R=s.getShaderInfoLog(A)||"",k=F.trim(),Z=X.trim(),H=R.trim(),at=!0,K=!0;if(s.getProgramParameter(T,s.LINK_STATUS)===!1)if(at=!1,typeof t.debug.onShaderError==="function")t.debug.onShaderError(s,T,b,A);else{let et=Oh(s,b,"vertex"),tt=Oh(s,A,"fragment");Gt("WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(T,s.VALIDATE_STATUS)+`
4162
+ `+f;let C=w+m+a,y=w+f+o,b=Fh(s,s.VERTEX_SHADER,C),A=Fh(s,s.FRAGMENT_SHADER,y);if(s.attachShader(T,b),s.attachShader(T,A),n.index0AttributeName!==void 0)s.bindAttribLocation(T,0,n.index0AttributeName);else if(n.hasPositionAttribute===!0)s.bindAttribLocation(T,0,"position");s.linkProgram(T);function E(N){if(t.debug.checkShaderErrors){let F=s.getProgramInfoLog(T)||"",X=s.getShaderInfoLog(b)||"",R=s.getShaderInfoLog(A)||"",k=F.trim(),Z=X.trim(),H=R.trim(),at=!0,K=!0;if(s.getProgramParameter(T,s.LINK_STATUS)===!1)if(at=!1,typeof t.debug.onShaderError==="function")t.debug.onShaderError(s,T,b,A);else{let et=Bh(s,b,"vertex"),tt=Bh(s,A,"fragment");Ht("WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(T,s.VALIDATE_STATUS)+`
4163
4163
 
4164
4164
  Material Name: `+N.name+`
4165
4165
  Material Type: `+N.type+`
4166
4166
 
4167
4167
  Program Info Log: `+k+`
4168
4168
  `+et+`
4169
- `+tt)}else if(k!=="")Ht("WebGLProgram: Program Info Log:",k);else if(Z===""||H==="")K=!1;if(K)N.diagnostics={runnable:at,programLog:k,vertexShader:{log:Z,prefix:m},fragmentShader:{log:H,prefix:f}}}s.deleteShader(b),s.deleteShader(A),g=new rr(s,T),M=pg(s,T)}let g;this.getUniforms=function(){if(g===void 0)E(this);return g};let M;this.getAttributes=function(){if(M===void 0)E(this);return M};let G=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){if(G===!1)G=s.getProgramParameter(T,sg);return G},this.destroy=function(){i.releaseStatesOfProgram(this),s.deleteProgram(T),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=rg++,this.cacheKey=e,this.usedTimes=1,this.program=T,this.vertexShader=b,this.fragmentShader=A,this}var Ig=0;class eu{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t,e,n){let i=this._getShaderCacheForMaterial(t);if(i.has(e)===!1)i.add(e),e.usedTimes++;if(i.has(n)===!1)i.add(n),n.usedTimes++;return this}remove(t){let e=this.materialCache.get(t);for(let n of e)if(n.usedTimes--,n.usedTimes===0)this.shaderCache.delete(n.code);return this.materialCache.delete(t),this}getVertexShaderStage(t){return this._getShaderStage(t.vertexShader)}getFragmentShaderStage(t){return this._getShaderStage(t.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){let e=this.materialCache,n=e.get(t);if(n===void 0)n=new Set,e.set(t,n);return n}_getShaderStage(t){let e=this.shaderCache,n=e.get(t);if(n===void 0)n=new nu(t),e.set(t,n);return n}}class nu{constructor(t){this.id=Ig++,this.code=t,this.usedTimes=0}}function Pg(t){return t===Li||t===Xr||t===qr}function Lg(t,e,n,i,s,r){let a=new qs,o=new eu,l=new Set,c=[],u=new Map,{logarithmicDepthBuffer:d,precision:h}=i,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 v(g){if(l.add(g),g===0)return"uv";return`uv${g}`}function T(g,M,G,N,F,X){let R=N.fog,k=F.geometry,Z=g.isMeshStandardMaterial||g.isMeshLambertMaterial||g.isMeshPhongMaterial?N.environment:null,H=g.isMeshStandardMaterial||g.isMeshLambertMaterial&&!g.envMap||g.isMeshPhongMaterial&&!g.envMap,at=e.get(g.envMap||Z,H),K=!!at&&at.mapping===Gs?at.image.height:null,et=p[g.type];if(g.precision!==null){if(h=i.getMaxPrecision(g.precision),h!==g.precision)Ht("WebGLProgram.getParameters:",g.precision,"not supported, using",h,"instead.")}let tt=k.morphAttributes.position||k.morphAttributes.normal||k.morphAttributes.color,dt=tt!==void 0?tt.length:0,At=0;if(k.morphAttributes.position!==void 0)At=1;if(k.morphAttributes.normal!==void 0)At=2;if(k.morphAttributes.color!==void 0)At=3;let te,zt,Y,rt;if(et){let fe=Wn[et];te=fe.vertexShader,zt=fe.fragmentShader}else{te=g.vertexShader,zt=g.fragmentShader;let fe=o.getVertexShaderStage(g),ce=o.getFragmentShaderStage(g);o.update(g,fe,ce),Y=fe.id,rt=ce.id}let lt=t.getRenderTarget(),It=t.state.buffers.depth.getReversed(),Ot=F.isInstancedMesh===!0,Ft=F.isBatchedMesh===!0,Ce=!!g.map,$t=!!g.matcap,ee=!!at,ue=!!g.aoMap,ne=!!g.lightMap,Le=!!g.bumpMap&&g.wireframe===!1,me=!!g.normalMap,Ze=!!g.displacementMap,Ne=!!g.emissiveMap,Re=!!g.metalnessMap,P=!!g.roughnessMap,Ue=g.anisotropy>0,ae=g.clearcoat>0,be=g.dispersion>0,S=g.retroreflectivity>0,_=g.iridescence>0,L=g.sheen>0,V=g.transmission>0,it=Ue&&!!g.anisotropyMap,st=ae&&!!g.clearcoatMap,ft=ae&&!!g.clearcoatNormalMap,J=ae&&!!g.clearcoatRoughnessMap,j=_&&!!g.iridescenceMap,_t=_&&!!g.iridescenceThicknessMap,Dt=L&&!!g.sheenColorMap,pt=L&&!!g.sheenRoughnessMap,ot=!!g.specularMap,Bt=!!g.specularColorMap,kt=!!g.specularIntensityMap,se=V&&!!g.transmissionMap,I=V&&!!g.thicknessMap,ct=!!g.gradientMap,Q=!!g.alphaMap,ut=g.alphaTest>0,Tt=!!g.alphaHash,nt=!!g.extensions,mt=Ln;if(g.toneMapped){if(lt===null||lt.isXRRenderTarget===!0)mt=t.toneMapping}let Vt={shaderID:et,shaderType:g.type,shaderName:g.name,vertexShader:te,fragmentShader:zt,defines:g.defines,customVertexShaderID:Y,customFragmentShaderID:rt,isRawShaderMaterial:g.isRawShaderMaterial===!0,glslVersion:g.glslVersion,precision:h,batching:Ft,batchingColor:Ft&&F._colorsTexture!==null,instancing:Ot,instancingColor:Ot&&F.instanceColor!==null,instancingMorph:Ot&&F.morphTexture!==null,outputColorSpace:lt===null?t.outputColorSpace:lt.isXRRenderTarget===!0?lt.texture.colorSpace:re.workingColorSpace,alphaToCoverage:!!g.alphaToCoverage,map:Ce,matcap:$t,envMap:ee,envMapMode:ee&&at.mapping,envMapCubeUVHeight:K,aoMap:ue,lightMap:ne,bumpMap:Le,normalMap:me,displacementMap:Ze,emissiveMap:Ne,normalMapObjectSpace:me&&g.normalMapType===oh,normalMapTangentSpace:me&&g.normalMapType===Xo,packedNormalMap:me&&g.normalMapType===Xo&&Pg(g.normalMap.format),metalnessMap:Re,roughnessMap:P,anisotropy:Ue,anisotropyMap:it,clearcoat:ae,clearcoatMap:st,clearcoatNormalMap:ft,clearcoatRoughnessMap:J,dispersion:be,retroreflection:S,iridescence:_,iridescenceMap:j,iridescenceThicknessMap:_t,sheen:L,sheenColorMap:Dt,sheenRoughnessMap:pt,specularMap:ot,specularColorMap:Bt,specularIntensityMap:kt,transmission:V,transmissionMap:se,thicknessMap:I,gradientMap:ct,opaque:g.transparent===!1&&g.blending===Pn&&g.alphaToCoverage===!1,alphaMap:Q,alphaTest:ut,alphaHash:Tt,combine:g.combine,mapUv:Ce&&v(g.map.channel),aoMapUv:ue&&v(g.aoMap.channel),lightMapUv:ne&&v(g.lightMap.channel),bumpMapUv:Le&&v(g.bumpMap.channel),normalMapUv:me&&v(g.normalMap.channel),displacementMapUv:Ze&&v(g.displacementMap.channel),emissiveMapUv:Ne&&v(g.emissiveMap.channel),metalnessMapUv:Re&&v(g.metalnessMap.channel),roughnessMapUv:P&&v(g.roughnessMap.channel),anisotropyMapUv:it&&v(g.anisotropyMap.channel),clearcoatMapUv:st&&v(g.clearcoatMap.channel),clearcoatNormalMapUv:ft&&v(g.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:J&&v(g.clearcoatRoughnessMap.channel),iridescenceMapUv:j&&v(g.iridescenceMap.channel),iridescenceThicknessMapUv:_t&&v(g.iridescenceThicknessMap.channel),sheenColorMapUv:Dt&&v(g.sheenColorMap.channel),sheenRoughnessMapUv:pt&&v(g.sheenRoughnessMap.channel),specularMapUv:ot&&v(g.specularMap.channel),specularColorMapUv:Bt&&v(g.specularColorMap.channel),specularIntensityMapUv:kt&&v(g.specularIntensityMap.channel),transmissionMapUv:se&&v(g.transmissionMap.channel),thicknessMapUv:I&&v(g.thicknessMap.channel),alphaMapUv:Q&&v(g.alphaMap.channel),vertexTangents:!!k.attributes.tangent&&(me||Ue),vertexNormals:!!k.attributes.normal,vertexColors:g.vertexColors,vertexAlphas:g.vertexColors===!0&&!!k.attributes.color&&k.attributes.color.itemSize===4,pointsUvs:F.isPoints===!0&&!!k.attributes.uv&&(Ce||Q),fog:!!R,useFog:g.fog===!0,fogExp2:!!R&&R.isFogExp2,flatShading:g.wireframe===!1&&(g.flatShading===!0||k.attributes.normal===void 0&&me===!1&&(g.isMeshLambertMaterial||g.isMeshPhongMaterial||g.isMeshStandardMaterial||g.isMeshPhysicalMaterial)),sizeAttenuation:g.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:It,skinning:F.isSkinnedMesh===!0,hasPositionAttribute:k.attributes.position!==void 0,morphTargets:k.morphAttributes.position!==void 0,morphNormals:k.morphAttributes.normal!==void 0,morphColors:k.morphAttributes.color!==void 0,morphTargetsCount:dt,morphTextureStride:At,numSunLights:M.sun.length,numDirLights:M.directional.length,numPointLights:M.point.length,numSpotLights:M.spot.length,numSpotLightMaps:M.spotLightMap.length,numRectAreaLights:M.rectArea.length,numHemiLights:M.hemi.length,numSunLightShadows:M.sunShadowMap.length,numDirLightShadows:M.directionalShadowMap.length,numPointLightShadows:M.pointShadowMap.length,numSpotLightShadows:M.spotShadowMap.length,numSpotLightShadowsWithMaps:M.numSpotLightShadowsWithMaps,numLightProbes:M.numLightProbes,numLightProbeGrids:X.length,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:g.dithering,shadowMapEnabled:t.shadowMap.enabled&&G.length>0,shadowMapType:t.shadowMap.type,toneMapping:mt,decodeVideoTexture:Ce&&g.map.isVideoTexture===!0&&re.getTransfer(g.map.colorSpace)===Me,decodeVideoTextureEmissive:Ne&&g.emissiveMap.isVideoTexture===!0&&re.getTransfer(g.emissiveMap.colorSpace)===Me,premultipliedAlpha:g.premultipliedAlpha,doubleSided:g.side===on,flipSided:g.side===Ve,useDepthPacking:g.depthPacking>=0,depthPacking:g.depthPacking||0,index0AttributeName:g.index0AttributeName,extensionClipCullDistance:nt&&g.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(nt&&g.extensions.multiDraw===!0||Ft)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:g.customProgramCacheKey()};return Vt.vertexUv1s=l.has(1),Vt.vertexUv2s=l.has(2),Vt.vertexUv3s=l.has(3),l.clear(),Vt}function m(g){let M=[];if(g.shaderID)M.push(g.shaderID);else M.push(g.customVertexShaderID),M.push(g.customFragmentShaderID);if(g.defines!==void 0)for(let G in g.defines)M.push(G),M.push(g.defines[G]);if(g.isRawShaderMaterial===!1)f(M,g),w(M,g),M.push(t.outputColorSpace);return M.push(g.customProgramCacheKey),M.join()}function f(g,M){g.push(M.precision),g.push(M.outputColorSpace),g.push(M.envMapMode),g.push(M.envMapCubeUVHeight),g.push(M.mapUv),g.push(M.alphaMapUv),g.push(M.lightMapUv),g.push(M.aoMapUv),g.push(M.bumpMapUv),g.push(M.normalMapUv),g.push(M.displacementMapUv),g.push(M.emissiveMapUv),g.push(M.metalnessMapUv),g.push(M.roughnessMapUv),g.push(M.anisotropyMapUv),g.push(M.clearcoatMapUv),g.push(M.clearcoatNormalMapUv),g.push(M.clearcoatRoughnessMapUv),g.push(M.iridescenceMapUv),g.push(M.iridescenceThicknessMapUv),g.push(M.sheenColorMapUv),g.push(M.sheenRoughnessMapUv),g.push(M.specularMapUv),g.push(M.specularColorMapUv),g.push(M.specularIntensityMapUv),g.push(M.transmissionMapUv),g.push(M.thicknessMapUv),g.push(M.combine),g.push(M.fogExp2),g.push(M.sizeAttenuation),g.push(M.morphTargetsCount),g.push(M.morphAttributeCount),g.push(M.numSunLights),g.push(M.numDirLights),g.push(M.numPointLights),g.push(M.numSpotLights),g.push(M.numSpotLightMaps),g.push(M.numHemiLights),g.push(M.numRectAreaLights),g.push(M.numSunLightShadows),g.push(M.numDirLightShadows),g.push(M.numPointLightShadows),g.push(M.numSpotLightShadows),g.push(M.numSpotLightShadowsWithMaps),g.push(M.numLightProbes),g.push(M.shadowMapType),g.push(M.toneMapping),g.push(M.numClippingPlanes),g.push(M.numClipIntersection),g.push(M.depthPacking)}function w(g,M){if(a.disableAll(),M.instancing)a.enable(0);if(M.instancingColor)a.enable(1);if(M.instancingMorph)a.enable(2);if(M.matcap)a.enable(3);if(M.envMap)a.enable(4);if(M.normalMapObjectSpace)a.enable(5);if(M.normalMapTangentSpace)a.enable(6);if(M.clearcoat)a.enable(7);if(M.iridescence)a.enable(8);if(M.alphaTest)a.enable(9);if(M.vertexColors)a.enable(10);if(M.vertexAlphas)a.enable(11);if(M.vertexUv1s)a.enable(12);if(M.vertexUv2s)a.enable(13);if(M.vertexUv3s)a.enable(14);if(M.vertexTangents)a.enable(15);if(M.anisotropy)a.enable(16);if(M.alphaHash)a.enable(17);if(M.batching)a.enable(18);if(M.dispersion)a.enable(19);if(M.retroreflection)a.enable(24);if(M.batchingColor)a.enable(20);if(M.gradientMap)a.enable(21);if(M.packedNormalMap)a.enable(22);if(M.vertexNormals)a.enable(23);if(g.push(a.mask),a.disableAll(),M.fog)a.enable(0);if(M.useFog)a.enable(1);if(M.flatShading)a.enable(2);if(M.logarithmicDepthBuffer)a.enable(3);if(M.reversedDepthBuffer)a.enable(4);if(M.skinning)a.enable(5);if(M.morphTargets)a.enable(6);if(M.morphNormals)a.enable(7);if(M.morphColors)a.enable(8);if(M.premultipliedAlpha)a.enable(9);if(M.shadowMapEnabled)a.enable(10);if(M.doubleSided)a.enable(11);if(M.flipSided)a.enable(12);if(M.useDepthPacking)a.enable(13);if(M.dithering)a.enable(14);if(M.transmission)a.enable(15);if(M.sheen)a.enable(16);if(M.opaque)a.enable(17);if(M.pointsUvs)a.enable(18);if(M.decodeVideoTexture)a.enable(19);if(M.decodeVideoTextureEmissive)a.enable(20);if(M.alphaToCoverage)a.enable(21);if(M.numLightProbeGrids>0)a.enable(22);if(M.hasPositionAttribute)a.enable(23);g.push(a.mask)}function C(g){let M=p[g.type],G;if(M){let N=Wn[M];G=yh.clone(N.uniforms)}else G=g.uniforms;return G}function y(g,M){let G=u.get(M);if(G!==void 0)++G.usedTimes;else G=new Rg(t,M,g,s),c.push(G),u.set(M,G);return G}function b(g){if(--g.usedTimes===0){let M=c.indexOf(g);c[M]=c[c.length-1],c.pop(),u.delete(g.cacheKey),g.destroy()}}function A(g){o.remove(g)}function E(){o.dispose()}return{getParameters:T,getProgramCacheKey:m,getUniforms:C,acquireProgram:y,releaseProgram:b,releaseShaderCache:A,programs:c,dispose:E}}function Ng(){let t=new WeakMap;function e(a){return t.has(a)}function n(a){let o=t.get(a);if(o===void 0)o={},t.set(a,o);return o}function i(a){t.delete(a)}function s(a,o,l){t.get(a)[o]=l}function r(){t=new WeakMap}return{has:e,get:n,remove:i,update:s,dispose:r}}function Dg(t,e){if(t.groupOrder!==e.groupOrder)return t.groupOrder-e.groupOrder;else if(t.renderOrder!==e.renderOrder)return t.renderOrder-e.renderOrder;else if(t.material.id!==e.material.id)return t.material.id-e.material.id;else if(t.materialVariant!==e.materialVariant)return t.materialVariant-e.materialVariant;else if(t.z!==e.z)return t.z-e.z;else return t.id-e.id}function Hh(t,e){if(t.groupOrder!==e.groupOrder)return t.groupOrder-e.groupOrder;else if(t.renderOrder!==e.renderOrder)return t.renderOrder-e.renderOrder;else if(t.z!==e.z)return e.z-t.z;else return t.id-e.id}function Vh(){let t=[],e=0,n=[],i=[],s=[];function r(){e=0,n.length=0,i.length=0,s.length=0}function a(h){let p=0;if(h.isInstancedMesh)p+=2;if(h.isSkinnedMesh)p+=1;return p}function o(h,p,v,T,m,f){let w=t[e];if(w===void 0)w={id:h.id,object:h,geometry:p,material:v,materialVariant:a(h),groupOrder:T,renderOrder:h.renderOrder,z:m,group:f},t[e]=w;else w.id=h.id,w.object=h,w.geometry=p,w.material=v,w.materialVariant=a(h),w.groupOrder=T,w.renderOrder=h.renderOrder,w.z=m,w.group=f;return e++,w}function l(h,p,v,T,m,f,w){if(w.reversedDepth===!0)m=-m;let C=o(h,p,v,T,m,f);if(v.transmission>0)i.push(C);else if(v.transparent===!0)s.push(C);else n.push(C)}function c(h,p,v,T,m,f){let w=o(h,p,v,T,m,f);if(v.transmission>0)i.unshift(w);else if(v.transparent===!0)s.unshift(w);else n.unshift(w)}function u(h,p){if(n.length>1)n.sort(h||Dg);if(i.length>1)i.sort(p||Hh);if(s.length>1)s.sort(p||Hh)}function d(){for(let h=e,p=t.length;h<p;h++){let v=t[h];if(v.id===null)break;v.id=null,v.object=null,v.geometry=null,v.material=null,v.group=null}}return{opaque:n,transmissive:i,transparent:s,init:r,push:l,unshift:c,finish:d,sort:u}}function Ug(){let t=new WeakMap;function e(i,s){let r=t.get(i),a;if(r===void 0)a=new Vh,t.set(i,[a]);else if(s>=r.length)a=new Vh,r.push(a);else a=r[s];return a}function n(){t=new WeakMap}return{get:e,dispose:n}}function Fg(){let t={};return{get:function(e){if(t[e.id]!==void 0)return t[e.id];let n;switch(e.type){case"SunLight":case"DirectionalLight":n={direction:new O,color:new Kt};break;case"SpotLight":n={position:new O,direction:new O,color:new Kt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new O,color:new Kt,distance:0,decay:0};break;case"HemisphereLight":n={direction:new O,skyColor:new Kt,groundColor:new Kt};break;case"RectAreaLight":n={color:new Kt,position:new O,halfWidth:new O,halfHeight:new O};break}return t[e.id]=n,n}}}function Og(){let t={};return{get:function(e){if(t[e.id]!==void 0)return t[e.id];let n;switch(e.type){case"SunLight":case"DirectionalLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Xt};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Xt};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Xt,shadowCameraNear:1,shadowCameraFar:1000};break}return t[e.id]=n,n}}}var Bg=0;function zg(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function kg(t){let e=new Fg,n=Og(),i={version:0,hash:{sunLength:-1,directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numSunShadows:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],sun:[],sunShadow:[],sunShadowMap:[],sunShadowMatrix:[],sunShadowCascade:[],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 c=0;c<9;c++)i.probe.push(new O);let s=new O,r=new we,a=new we;function o(c){let u=0,d=0,h=0;for(let F=0;F<9;F++)i.probe[F].set(0,0,0);let p=0,v=0,T=0,m=0,f=0,w=0,C=0,y=0,b=0,A=0,E=0,g=0,M=0,G=0;c.sort(zg);for(let F=0,X=c.length;F<X;F++){let R=c[F],{color:k,intensity:Z,distance:H}=R,at=null;if(R.shadow&&R.shadow.map)if(R.shadow.map.texture.format===Li)at=R.shadow.map.texture;else at=R.shadow.map.depthTexture||R.shadow.map.texture;if(R.isAmbientLight)u+=k.r*Z,d+=k.g*Z,h+=k.b*Z;else if(R.isLightProbe){for(let K=0;K<9;K++)i.probe[K].addScaledVector(R.sh.coefficients[K],Z);G++}else if(R.isSunLight){let K=e.get(R);if(K.color.copy(R.color).multiplyScalar(R.intensity),R.castShadow){let et=R.shadow,tt=n.get(R);tt.shadowIntensity=et.intensity,tt.shadowBias=et.bias,tt.shadowNormalBias=et.normalBias,tt.shadowRadius=et.radius,tt.shadowMapSize.copy(et.mapSize).multiply(et.getFrameExtents()),i.sunShadow[v]=tt,i.sunShadowMap[v]=at;let dt=et.getViewportCount();for(let At=0;At<dt;At++)i.sunShadowMatrix[T+At]=et.getMatrix(At),i.sunShadowCascade[T+At]=et._cascadeData[At];T+=dt,v++}i.sun[p]=K,p++}else if(R.isDirectionalLight){let K=e.get(R);if(K.color.copy(R.color).multiplyScalar(R.intensity),R.castShadow){let et=R.shadow,tt=n.get(R);tt.shadowIntensity=et.intensity,tt.shadowBias=et.bias,tt.shadowNormalBias=et.normalBias,tt.shadowRadius=et.radius,tt.shadowMapSize=et.mapSize,i.directionalShadow[m]=tt,i.directionalShadowMap[m]=at,i.directionalShadowMatrix[m]=R.shadow.matrix,b++}i.directional[m]=K,m++}else if(R.isSpotLight){let K=e.get(R);K.position.setFromMatrixPosition(R.matrixWorld),K.color.copy(k).multiplyScalar(Z),K.distance=H,K.coneCos=Math.cos(R.angle),K.penumbraCos=Math.cos(R.angle*(1-R.penumbra)),K.decay=R.decay,i.spot[w]=K;let et=R.shadow;if(R.map){if(i.spotLightMap[g]=R.map,g++,et.updateMatrices(R),R.castShadow)M++}if(i.spotLightMatrix[w]=et.matrix,R.castShadow){let tt=n.get(R);tt.shadowIntensity=et.intensity,tt.shadowBias=et.bias,tt.shadowNormalBias=et.normalBias,tt.shadowRadius=et.radius,tt.shadowMapSize=et.mapSize,i.spotShadow[w]=tt,i.spotShadowMap[w]=at,E++}w++}else if(R.isRectAreaLight){let K=e.get(R);K.color.copy(k).multiplyScalar(Z),K.halfWidth.set(R.width*0.5,0,0),K.halfHeight.set(0,R.height*0.5,0),i.rectArea[C]=K,C++}else if(R.isPointLight){let K=e.get(R);if(K.color.copy(R.color).multiplyScalar(R.intensity),K.distance=R.distance,K.decay=R.decay,R.castShadow){let et=R.shadow,tt=n.get(R);tt.shadowIntensity=et.intensity,tt.shadowBias=et.bias,tt.shadowNormalBias=et.normalBias,tt.shadowRadius=et.radius,tt.shadowMapSize=et.mapSize,tt.shadowCameraNear=et.camera.near,tt.shadowCameraFar=et.camera.far,i.pointShadow[f]=tt,i.pointShadowMap[f]=at,i.pointShadowMatrix[f]=R.shadow.matrix,A++}i.point[f]=K,f++}else if(R.isHemisphereLight){let K=e.get(R);K.skyColor.copy(R.color).multiplyScalar(Z),K.groundColor.copy(R.groundColor).multiplyScalar(Z),i.hemi[y]=K,y++}}if(C>0)if(t.has("OES_texture_float_linear")===!0)i.rectAreaLTC1=gt.LTC_FLOAT_1,i.rectAreaLTC2=gt.LTC_FLOAT_2;else i.rectAreaLTC1=gt.LTC_HALF_1,i.rectAreaLTC2=gt.LTC_HALF_2;i.ambient[0]=u,i.ambient[1]=d,i.ambient[2]=h;let N=i.hash;if(N.sunLength!==p||N.directionalLength!==m||N.pointLength!==f||N.spotLength!==w||N.rectAreaLength!==C||N.hemiLength!==y||N.numSunShadows!==v||N.numDirectionalShadows!==b||N.numPointShadows!==A||N.numSpotShadows!==E||N.numSpotMaps!==g||N.numLightProbes!==G)i.sun.length=p,i.directional.length=m,i.spot.length=w,i.rectArea.length=C,i.point.length=f,i.hemi.length=y,i.sunShadow.length=v,i.sunShadowMap.length=v,i.sunShadowMatrix.length=T,i.sunShadowCascade.length=T,i.directionalShadow.length=b,i.directionalShadowMap.length=b,i.directionalShadowMatrix.length=b,i.pointShadow.length=A,i.pointShadowMap.length=A,i.pointShadowMatrix.length=A,i.spotShadow.length=E,i.spotShadowMap.length=E,i.spotLightMatrix.length=E+g-M,i.spotLightMap.length=g,i.numSpotLightShadowsWithMaps=M,i.numLightProbes=G,N.sunLength=p,N.directionalLength=m,N.pointLength=f,N.spotLength=w,N.rectAreaLength=C,N.hemiLength=y,N.numSunShadows=v,N.numDirectionalShadows=b,N.numPointShadows=A,N.numSpotShadows=E,N.numSpotMaps=g,N.numLightProbes=G,i.version=Bg++}function l(c,u){let d=0,h=0,p=0,v=0,T=0,m=0,f=u.matrixWorldInverse;for(let w=0,C=c.length;w<C;w++){let y=c[w];if(y.isSunLight){let b=i.sun[d];b.direction.setFromMatrixPosition(y.matrixWorld),b.direction.transformDirection(f),d++}else if(y.isDirectionalLight){let b=i.directional[h];b.direction.setFromMatrixPosition(y.matrixWorld),s.setFromMatrixPosition(y.target.matrixWorld),b.direction.sub(s),b.direction.transformDirection(f),h++}else if(y.isSpotLight){let b=i.spot[v];b.position.setFromMatrixPosition(y.matrixWorld),b.position.applyMatrix4(f),b.direction.setFromMatrixPosition(y.matrixWorld),s.setFromMatrixPosition(y.target.matrixWorld),b.direction.sub(s),b.direction.transformDirection(f),v++}else if(y.isRectAreaLight){let b=i.rectArea[T];b.position.setFromMatrixPosition(y.matrixWorld),b.position.applyMatrix4(f),a.identity(),r.copy(y.matrixWorld),r.premultiply(f),a.extractRotation(r),b.halfWidth.set(y.width*0.5,0,0),b.halfHeight.set(0,y.height*0.5,0),b.halfWidth.applyMatrix4(a),b.halfHeight.applyMatrix4(a),T++}else if(y.isPointLight){let b=i.point[p];b.position.setFromMatrixPosition(y.matrixWorld),b.position.applyMatrix4(f),p++}else if(y.isHemisphereLight){let b=i.hemi[m];b.direction.setFromMatrixPosition(y.matrixWorld),b.direction.transformDirection(f),m++}}}return{setup:o,setupView:l,state:i}}function Wh(t){let e=new kg(t),n=[],i=[],s=[];function r(h){d.camera=h,n.length=0,i.length=0,s.length=0}function a(h){n.push(h)}function o(h){i.push(h)}function l(h){s.push(h)}function c(){e.setup(n)}function u(h){e.setupView(n,h)}let d={lightsArray:n,shadowsArray:i,lightProbeGridArray:s,camera:null,lights:e,transmissionRenderTarget:{},textureUnits:0};return{init:r,state:d,setupLights:c,setupLightsView:u,pushLight:a,pushShadow:o,pushLightProbeGrid:l}}function Gg(t){let e=new WeakMap;function n(s,r=0){let a=e.get(s),o;if(a===void 0)o=new Wh(t),e.set(s,[o]);else if(r>=a.length)o=new Wh(t),a.push(o);else o=a[r];return o}function i(){e=new WeakMap}return{get:n,dispose:i}}var Hg=`void main() {
4169
+ `+tt)}else if(k!=="")Vt("WebGLProgram: Program Info Log:",k);else if(Z===""||H==="")K=!1;if(K)N.diagnostics={runnable:at,programLog:k,vertexShader:{log:Z,prefix:m},fragmentShader:{log:H,prefix:f}}}s.deleteShader(b),s.deleteShader(A),g=new ur(s,T),M=mg(s,T)}let g;this.getUniforms=function(){if(g===void 0)E(this);return g};let M;this.getAttributes=function(){if(M===void 0)E(this);return M};let G=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){if(G===!1)G=s.getProgramParameter(T,rg);return G},this.destroy=function(){i.releaseStatesOfProgram(this),s.deleteProgram(T),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=ag++,this.cacheKey=e,this.usedTimes=1,this.program=T,this.vertexShader=b,this.fragmentShader=A,this}var Pg=0;class nu{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t,e,n){let i=this._getShaderCacheForMaterial(t);if(i.has(e)===!1)i.add(e),e.usedTimes++;if(i.has(n)===!1)i.add(n),n.usedTimes++;return this}remove(t){let e=this.materialCache.get(t);for(let n of e)if(n.usedTimes--,n.usedTimes===0)this.shaderCache.delete(n.code);return this.materialCache.delete(t),this}getVertexShaderStage(t){return this._getShaderStage(t.vertexShader)}getFragmentShaderStage(t){return this._getShaderStage(t.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){let e=this.materialCache,n=e.get(t);if(n===void 0)n=new Set,e.set(t,n);return n}_getShaderStage(t){let e=this.shaderCache,n=e.get(t);if(n===void 0)n=new iu(t),e.set(t,n);return n}}class iu{constructor(t){this.id=Pg++,this.code=t,this.usedTimes=0}}function Lg(t){return t===Pi||t===Kr||t===Qr}function Ng(t,e,n,i,s,r){let a=new tr,o=new nu,l=new Set,c=[],u=new Map,{logarithmicDepthBuffer:d,precision:h}=i,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 v(g){if(l.add(g),g===0)return"uv";return`uv${g}`}function T(g,M,G,N,F,X){let R=N.fog,k=F.geometry,Z=g.isMeshStandardMaterial||g.isMeshLambertMaterial||g.isMeshPhongMaterial?N.environment:null,H=g.isMeshStandardMaterial||g.isMeshLambertMaterial&&!g.envMap||g.isMeshPhongMaterial&&!g.envMap,at=e.get(g.envMap||Z,H),K=!!at&&at.mapping===Js?at.image.height:null,et=p[g.type];if(g.precision!==null){if(h=i.getMaxPrecision(g.precision),h!==g.precision)Vt("WebGLProgram.getParameters:",g.precision,"not supported, using",h,"instead.")}let tt=k.morphAttributes.position||k.morphAttributes.normal||k.morphAttributes.color,dt=tt!==void 0?tt.length:0,At=0;if(k.morphAttributes.position!==void 0)At=1;if(k.morphAttributes.normal!==void 0)At=2;if(k.morphAttributes.color!==void 0)At=3;let te,Bt,Y,rt;if(et){let fe=Wn[et];te=fe.vertexShader,Bt=fe.fragmentShader}else{te=g.vertexShader,Bt=g.fragmentShader;let fe=o.getVertexShaderStage(g),ce=o.getFragmentShaderStage(g);o.update(g,fe,ce),Y=fe.id,rt=ce.id}let lt=t.getRenderTarget(),It=t.state.buffers.depth.getReversed(),Ft=F.isInstancedMesh===!0,Ut=F.isBatchedMesh===!0,Ce=!!g.map,$t=!!g.matcap,ee=!!at,ue=!!g.aoMap,ne=!!g.lightMap,Le=!!g.bumpMap&&g.wireframe===!1,me=!!g.normalMap,Ze=!!g.displacementMap,Ne=!!g.emissiveMap,Re=!!g.metalnessMap,P=!!g.roughnessMap,Ue=g.anisotropy>0,ae=g.clearcoat>0,be=g.dispersion>0,S=g.retroreflectivity>0,_=g.iridescence>0,L=g.sheen>0,V=g.transmission>0,it=Ue&&!!g.anisotropyMap,st=ae&&!!g.clearcoatMap,ft=ae&&!!g.clearcoatNormalMap,J=ae&&!!g.clearcoatRoughnessMap,j=_&&!!g.iridescenceMap,_t=_&&!!g.iridescenceThicknessMap,Nt=L&&!!g.sheenColorMap,pt=L&&!!g.sheenRoughnessMap,ot=!!g.specularMap,Ot=!!g.specularColorMap,kt=!!g.specularIntensityMap,se=V&&!!g.transmissionMap,I=V&&!!g.thicknessMap,ct=!!g.gradientMap,Q=!!g.alphaMap,ut=g.alphaTest>0,Tt=!!g.alphaHash,nt=!!g.extensions,mt=Pn;if(g.toneMapped){if(lt===null||lt.isXRRenderTarget===!0)mt=t.toneMapping}let Wt={shaderID:et,shaderType:g.type,shaderName:g.name,vertexShader:te,fragmentShader:Bt,defines:g.defines,customVertexShaderID:Y,customFragmentShaderID:rt,isRawShaderMaterial:g.isRawShaderMaterial===!0,glslVersion:g.glslVersion,precision:h,batching:Ut,batchingColor:Ut&&F._colorsTexture!==null,instancing:Ft,instancingColor:Ft&&F.instanceColor!==null,instancingMorph:Ft&&F.morphTexture!==null,outputColorSpace:lt===null?t.outputColorSpace:lt.isXRRenderTarget===!0?lt.texture.colorSpace:re.workingColorSpace,alphaToCoverage:!!g.alphaToCoverage,map:Ce,matcap:$t,envMap:ee,envMapMode:ee&&at.mapping,envMapCubeUVHeight:K,aoMap:ue,lightMap:ne,bumpMap:Le,normalMap:me,displacementMap:Ze,emissiveMap:Ne,normalMapObjectSpace:me&&g.normalMapType===lh,normalMapTangentSpace:me&&g.normalMapType===Yo,packedNormalMap:me&&g.normalMapType===Yo&&Lg(g.normalMap.format),metalnessMap:Re,roughnessMap:P,anisotropy:Ue,anisotropyMap:it,clearcoat:ae,clearcoatMap:st,clearcoatNormalMap:ft,clearcoatRoughnessMap:J,dispersion:be,retroreflection:S,iridescence:_,iridescenceMap:j,iridescenceThicknessMap:_t,sheen:L,sheenColorMap:Nt,sheenRoughnessMap:pt,specularMap:ot,specularColorMap:Ot,specularIntensityMap:kt,transmission:V,transmissionMap:se,thicknessMap:I,gradientMap:ct,opaque:g.transparent===!1&&g.blending===In&&g.alphaToCoverage===!1,alphaMap:Q,alphaTest:ut,alphaHash:Tt,combine:g.combine,mapUv:Ce&&v(g.map.channel),aoMapUv:ue&&v(g.aoMap.channel),lightMapUv:ne&&v(g.lightMap.channel),bumpMapUv:Le&&v(g.bumpMap.channel),normalMapUv:me&&v(g.normalMap.channel),displacementMapUv:Ze&&v(g.displacementMap.channel),emissiveMapUv:Ne&&v(g.emissiveMap.channel),metalnessMapUv:Re&&v(g.metalnessMap.channel),roughnessMapUv:P&&v(g.roughnessMap.channel),anisotropyMapUv:it&&v(g.anisotropyMap.channel),clearcoatMapUv:st&&v(g.clearcoatMap.channel),clearcoatNormalMapUv:ft&&v(g.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:J&&v(g.clearcoatRoughnessMap.channel),iridescenceMapUv:j&&v(g.iridescenceMap.channel),iridescenceThicknessMapUv:_t&&v(g.iridescenceThicknessMap.channel),sheenColorMapUv:Nt&&v(g.sheenColorMap.channel),sheenRoughnessMapUv:pt&&v(g.sheenRoughnessMap.channel),specularMapUv:ot&&v(g.specularMap.channel),specularColorMapUv:Ot&&v(g.specularColorMap.channel),specularIntensityMapUv:kt&&v(g.specularIntensityMap.channel),transmissionMapUv:se&&v(g.transmissionMap.channel),thicknessMapUv:I&&v(g.thicknessMap.channel),alphaMapUv:Q&&v(g.alphaMap.channel),vertexTangents:!!k.attributes.tangent&&(me||Ue),vertexNormals:!!k.attributes.normal,vertexColors:g.vertexColors,vertexAlphas:g.vertexColors===!0&&!!k.attributes.color&&k.attributes.color.itemSize===4,pointsUvs:F.isPoints===!0&&!!k.attributes.uv&&(Ce||Q),fog:!!R,useFog:g.fog===!0,fogExp2:!!R&&R.isFogExp2,flatShading:g.wireframe===!1&&(g.flatShading===!0||k.attributes.normal===void 0&&me===!1&&(g.isMeshLambertMaterial||g.isMeshPhongMaterial||g.isMeshStandardMaterial||g.isMeshPhysicalMaterial)),sizeAttenuation:g.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:It,skinning:F.isSkinnedMesh===!0,hasPositionAttribute:k.attributes.position!==void 0,morphTargets:k.morphAttributes.position!==void 0,morphNormals:k.morphAttributes.normal!==void 0,morphColors:k.morphAttributes.color!==void 0,morphTargetsCount:dt,morphTextureStride:At,numSunLights:M.sun.length,numDirLights:M.directional.length,numPointLights:M.point.length,numSpotLights:M.spot.length,numSpotLightMaps:M.spotLightMap.length,numRectAreaLights:M.rectArea.length,numHemiLights:M.hemi.length,numSunLightShadows:M.sunShadowMap.length,numDirLightShadows:M.directionalShadowMap.length,numPointLightShadows:M.pointShadowMap.length,numSpotLightShadows:M.spotShadowMap.length,numSpotLightShadowsWithMaps:M.numSpotLightShadowsWithMaps,numLightProbes:M.numLightProbes,numLightProbeGrids:X.length,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:g.dithering,shadowMapEnabled:t.shadowMap.enabled&&G.length>0,shadowMapType:t.shadowMap.type,toneMapping:mt,decodeVideoTexture:Ce&&g.map.isVideoTexture===!0&&re.getTransfer(g.map.colorSpace)===Me,decodeVideoTextureEmissive:Ne&&g.emissiveMap.isVideoTexture===!0&&re.getTransfer(g.emissiveMap.colorSpace)===Me,premultipliedAlpha:g.premultipliedAlpha,doubleSided:g.side===sn,flipSided:g.side===Ve,useDepthPacking:g.depthPacking>=0,depthPacking:g.depthPacking||0,index0AttributeName:g.index0AttributeName,extensionClipCullDistance:nt&&g.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(nt&&g.extensions.multiDraw===!0||Ut)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:g.customProgramCacheKey()};return Wt.vertexUv1s=l.has(1),Wt.vertexUv2s=l.has(2),Wt.vertexUv3s=l.has(3),l.clear(),Wt}function m(g){let M=[];if(g.shaderID)M.push(g.shaderID);else M.push(g.customVertexShaderID),M.push(g.customFragmentShaderID);if(g.defines!==void 0)for(let G in g.defines)M.push(G),M.push(g.defines[G]);if(g.isRawShaderMaterial===!1)f(M,g),w(M,g),M.push(t.outputColorSpace);return M.push(g.customProgramCacheKey),M.join()}function f(g,M){g.push(M.precision),g.push(M.outputColorSpace),g.push(M.envMapMode),g.push(M.envMapCubeUVHeight),g.push(M.mapUv),g.push(M.alphaMapUv),g.push(M.lightMapUv),g.push(M.aoMapUv),g.push(M.bumpMapUv),g.push(M.normalMapUv),g.push(M.displacementMapUv),g.push(M.emissiveMapUv),g.push(M.metalnessMapUv),g.push(M.roughnessMapUv),g.push(M.anisotropyMapUv),g.push(M.clearcoatMapUv),g.push(M.clearcoatNormalMapUv),g.push(M.clearcoatRoughnessMapUv),g.push(M.iridescenceMapUv),g.push(M.iridescenceThicknessMapUv),g.push(M.sheenColorMapUv),g.push(M.sheenRoughnessMapUv),g.push(M.specularMapUv),g.push(M.specularColorMapUv),g.push(M.specularIntensityMapUv),g.push(M.transmissionMapUv),g.push(M.thicknessMapUv),g.push(M.combine),g.push(M.fogExp2),g.push(M.sizeAttenuation),g.push(M.morphTargetsCount),g.push(M.morphAttributeCount),g.push(M.numSunLights),g.push(M.numDirLights),g.push(M.numPointLights),g.push(M.numSpotLights),g.push(M.numSpotLightMaps),g.push(M.numHemiLights),g.push(M.numRectAreaLights),g.push(M.numSunLightShadows),g.push(M.numDirLightShadows),g.push(M.numPointLightShadows),g.push(M.numSpotLightShadows),g.push(M.numSpotLightShadowsWithMaps),g.push(M.numLightProbes),g.push(M.shadowMapType),g.push(M.toneMapping),g.push(M.numClippingPlanes),g.push(M.numClipIntersection),g.push(M.depthPacking)}function w(g,M){if(a.disableAll(),M.instancing)a.enable(0);if(M.instancingColor)a.enable(1);if(M.instancingMorph)a.enable(2);if(M.matcap)a.enable(3);if(M.envMap)a.enable(4);if(M.normalMapObjectSpace)a.enable(5);if(M.normalMapTangentSpace)a.enable(6);if(M.clearcoat)a.enable(7);if(M.iridescence)a.enable(8);if(M.alphaTest)a.enable(9);if(M.vertexColors)a.enable(10);if(M.vertexAlphas)a.enable(11);if(M.vertexUv1s)a.enable(12);if(M.vertexUv2s)a.enable(13);if(M.vertexUv3s)a.enable(14);if(M.vertexTangents)a.enable(15);if(M.anisotropy)a.enable(16);if(M.alphaHash)a.enable(17);if(M.batching)a.enable(18);if(M.dispersion)a.enable(19);if(M.retroreflection)a.enable(24);if(M.batchingColor)a.enable(20);if(M.gradientMap)a.enable(21);if(M.packedNormalMap)a.enable(22);if(M.vertexNormals)a.enable(23);if(g.push(a.mask),a.disableAll(),M.fog)a.enable(0);if(M.useFog)a.enable(1);if(M.flatShading)a.enable(2);if(M.logarithmicDepthBuffer)a.enable(3);if(M.reversedDepthBuffer)a.enable(4);if(M.skinning)a.enable(5);if(M.morphTargets)a.enable(6);if(M.morphNormals)a.enable(7);if(M.morphColors)a.enable(8);if(M.premultipliedAlpha)a.enable(9);if(M.shadowMapEnabled)a.enable(10);if(M.doubleSided)a.enable(11);if(M.flipSided)a.enable(12);if(M.useDepthPacking)a.enable(13);if(M.dithering)a.enable(14);if(M.transmission)a.enable(15);if(M.sheen)a.enable(16);if(M.opaque)a.enable(17);if(M.pointsUvs)a.enable(18);if(M.decodeVideoTexture)a.enable(19);if(M.decodeVideoTextureEmissive)a.enable(20);if(M.alphaToCoverage)a.enable(21);if(M.numLightProbeGrids>0)a.enable(22);if(M.hasPositionAttribute)a.enable(23);g.push(a.mask)}function C(g){let M=p[g.type],G;if(M){let N=Wn[M];G=Sh.clone(N.uniforms)}else G=g.uniforms;return G}function y(g,M){let G=u.get(M);if(G!==void 0)++G.usedTimes;else G=new Ig(t,M,g,s),c.push(G),u.set(M,G);return G}function b(g){if(--g.usedTimes===0){let M=c.indexOf(g);c[M]=c[c.length-1],c.pop(),u.delete(g.cacheKey),g.destroy()}}function A(g){o.remove(g)}function E(){o.dispose()}return{getParameters:T,getProgramCacheKey:m,getUniforms:C,acquireProgram:y,releaseProgram:b,releaseShaderCache:A,programs:c,dispose:E}}function Dg(){let t=new WeakMap;function e(a){return t.has(a)}function n(a){let o=t.get(a);if(o===void 0)o={},t.set(a,o);return o}function i(a){t.delete(a)}function s(a,o,l){t.get(a)[o]=l}function r(){t=new WeakMap}return{has:e,get:n,remove:i,update:s,dispose:r}}function Ug(t,e){if(t.groupOrder!==e.groupOrder)return t.groupOrder-e.groupOrder;else if(t.renderOrder!==e.renderOrder)return t.renderOrder-e.renderOrder;else if(t.material.id!==e.material.id)return t.material.id-e.material.id;else if(t.materialVariant!==e.materialVariant)return t.materialVariant-e.materialVariant;else if(t.z!==e.z)return t.z-e.z;else return t.id-e.id}function Vh(t,e){if(t.groupOrder!==e.groupOrder)return t.groupOrder-e.groupOrder;else if(t.renderOrder!==e.renderOrder)return t.renderOrder-e.renderOrder;else if(t.z!==e.z)return e.z-t.z;else return t.id-e.id}function Wh(){let t=[],e=0,n=[],i=[],s=[];function r(){e=0,n.length=0,i.length=0,s.length=0}function a(h){let p=0;if(h.isInstancedMesh)p+=2;if(h.isSkinnedMesh)p+=1;return p}function o(h,p,v,T,m,f){let w=t[e];if(w===void 0)w={id:h.id,object:h,geometry:p,material:v,materialVariant:a(h),groupOrder:T,renderOrder:h.renderOrder,z:m,group:f},t[e]=w;else w.id=h.id,w.object=h,w.geometry=p,w.material=v,w.materialVariant=a(h),w.groupOrder=T,w.renderOrder=h.renderOrder,w.z=m,w.group=f;return e++,w}function l(h,p,v,T,m,f,w){if(w.reversedDepth===!0)m=-m;let C=o(h,p,v,T,m,f);if(v.transmission>0)i.push(C);else if(v.transparent===!0)s.push(C);else n.push(C)}function c(h,p,v,T,m,f){let w=o(h,p,v,T,m,f);if(v.transmission>0)i.unshift(w);else if(v.transparent===!0)s.unshift(w);else n.unshift(w)}function u(h,p){if(n.length>1)n.sort(h||Ug);if(i.length>1)i.sort(p||Vh);if(s.length>1)s.sort(p||Vh)}function d(){for(let h=e,p=t.length;h<p;h++){let v=t[h];if(v.id===null)break;v.id=null,v.object=null,v.geometry=null,v.material=null,v.group=null}}return{opaque:n,transmissive:i,transparent:s,init:r,push:l,unshift:c,finish:d,sort:u}}function Fg(){let t=new WeakMap;function e(i,s){let r=t.get(i),a;if(r===void 0)a=new Wh,t.set(i,[a]);else if(s>=r.length)a=new Wh,r.push(a);else a=r[s];return a}function n(){t=new WeakMap}return{get:e,dispose:n}}function Og(){let t={};return{get:function(e){if(t[e.id]!==void 0)return t[e.id];let n;switch(e.type){case"SunLight":case"DirectionalLight":n={direction:new O,color:new Kt};break;case"SpotLight":n={position:new O,direction:new O,color:new Kt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new O,color:new Kt,distance:0,decay:0};break;case"HemisphereLight":n={direction:new O,skyColor:new Kt,groundColor:new Kt};break;case"RectAreaLight":n={color:new Kt,position:new O,halfWidth:new O,halfHeight:new O};break}return t[e.id]=n,n}}}function Bg(){let t={};return{get:function(e){if(t[e.id]!==void 0)return t[e.id];let n;switch(e.type){case"SunLight":case"DirectionalLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new qt};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new qt};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new qt,shadowCameraNear:1,shadowCameraFar:1000};break}return t[e.id]=n,n}}}var zg=0;function kg(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function Gg(t){let e=new Og,n=Bg(),i={version:0,hash:{sunLength:-1,directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numSunShadows:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],sun:[],sunShadow:[],sunShadowMap:[],sunShadowMatrix:[],sunShadowCascade:[],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 c=0;c<9;c++)i.probe.push(new O);let s=new O,r=new we,a=new we;function o(c){let u=0,d=0,h=0;for(let F=0;F<9;F++)i.probe[F].set(0,0,0);let p=0,v=0,T=0,m=0,f=0,w=0,C=0,y=0,b=0,A=0,E=0,g=0,M=0,G=0;c.sort(kg);for(let F=0,X=c.length;F<X;F++){let R=c[F],{color:k,intensity:Z,distance:H}=R,at=null;if(R.shadow&&R.shadow.map)if(R.shadow.map.texture.format===Pi)at=R.shadow.map.texture;else at=R.shadow.map.depthTexture||R.shadow.map.texture;if(R.isAmbientLight)u+=k.r*Z,d+=k.g*Z,h+=k.b*Z;else if(R.isLightProbe){for(let K=0;K<9;K++)i.probe[K].addScaledVector(R.sh.coefficients[K],Z);G++}else if(R.isSunLight){let K=e.get(R);if(K.color.copy(R.color).multiplyScalar(R.intensity),R.castShadow){let et=R.shadow,tt=n.get(R);tt.shadowIntensity=et.intensity,tt.shadowBias=et.bias,tt.shadowNormalBias=et.normalBias,tt.shadowRadius=et.radius,tt.shadowMapSize.copy(et.mapSize).multiply(et.getFrameExtents()),i.sunShadow[v]=tt,i.sunShadowMap[v]=at;let dt=et.getViewportCount();for(let At=0;At<dt;At++)i.sunShadowMatrix[T+At]=et.getMatrix(At),i.sunShadowCascade[T+At]=et._cascadeData[At];T+=dt,v++}i.sun[p]=K,p++}else if(R.isDirectionalLight){let K=e.get(R);if(K.color.copy(R.color).multiplyScalar(R.intensity),R.castShadow){let et=R.shadow,tt=n.get(R);tt.shadowIntensity=et.intensity,tt.shadowBias=et.bias,tt.shadowNormalBias=et.normalBias,tt.shadowRadius=et.radius,tt.shadowMapSize=et.mapSize,i.directionalShadow[m]=tt,i.directionalShadowMap[m]=at,i.directionalShadowMatrix[m]=R.shadow.matrix,b++}i.directional[m]=K,m++}else if(R.isSpotLight){let K=e.get(R);K.position.setFromMatrixPosition(R.matrixWorld),K.color.copy(k).multiplyScalar(Z),K.distance=H,K.coneCos=Math.cos(R.angle),K.penumbraCos=Math.cos(R.angle*(1-R.penumbra)),K.decay=R.decay,i.spot[w]=K;let et=R.shadow;if(R.map){if(i.spotLightMap[g]=R.map,g++,et.updateMatrices(R),R.castShadow)M++}if(i.spotLightMatrix[w]=et.matrix,R.castShadow){let tt=n.get(R);tt.shadowIntensity=et.intensity,tt.shadowBias=et.bias,tt.shadowNormalBias=et.normalBias,tt.shadowRadius=et.radius,tt.shadowMapSize=et.mapSize,i.spotShadow[w]=tt,i.spotShadowMap[w]=at,E++}w++}else if(R.isRectAreaLight){let K=e.get(R);K.color.copy(k).multiplyScalar(Z),K.halfWidth.set(R.width*0.5,0,0),K.halfHeight.set(0,R.height*0.5,0),i.rectArea[C]=K,C++}else if(R.isPointLight){let K=e.get(R);if(K.color.copy(R.color).multiplyScalar(R.intensity),K.distance=R.distance,K.decay=R.decay,R.castShadow){let et=R.shadow,tt=n.get(R);tt.shadowIntensity=et.intensity,tt.shadowBias=et.bias,tt.shadowNormalBias=et.normalBias,tt.shadowRadius=et.radius,tt.shadowMapSize=et.mapSize,tt.shadowCameraNear=et.camera.near,tt.shadowCameraFar=et.camera.far,i.pointShadow[f]=tt,i.pointShadowMap[f]=at,i.pointShadowMatrix[f]=R.shadow.matrix,A++}i.point[f]=K,f++}else if(R.isHemisphereLight){let K=e.get(R);K.skyColor.copy(R.color).multiplyScalar(Z),K.groundColor.copy(R.groundColor).multiplyScalar(Z),i.hemi[y]=K,y++}}if(C>0)if(t.has("OES_texture_float_linear")===!0)i.rectAreaLTC1=gt.LTC_FLOAT_1,i.rectAreaLTC2=gt.LTC_FLOAT_2;else i.rectAreaLTC1=gt.LTC_HALF_1,i.rectAreaLTC2=gt.LTC_HALF_2;i.ambient[0]=u,i.ambient[1]=d,i.ambient[2]=h;let N=i.hash;if(N.sunLength!==p||N.directionalLength!==m||N.pointLength!==f||N.spotLength!==w||N.rectAreaLength!==C||N.hemiLength!==y||N.numSunShadows!==v||N.numDirectionalShadows!==b||N.numPointShadows!==A||N.numSpotShadows!==E||N.numSpotMaps!==g||N.numLightProbes!==G)i.sun.length=p,i.directional.length=m,i.spot.length=w,i.rectArea.length=C,i.point.length=f,i.hemi.length=y,i.sunShadow.length=v,i.sunShadowMap.length=v,i.sunShadowMatrix.length=T,i.sunShadowCascade.length=T,i.directionalShadow.length=b,i.directionalShadowMap.length=b,i.directionalShadowMatrix.length=b,i.pointShadow.length=A,i.pointShadowMap.length=A,i.pointShadowMatrix.length=A,i.spotShadow.length=E,i.spotShadowMap.length=E,i.spotLightMatrix.length=E+g-M,i.spotLightMap.length=g,i.numSpotLightShadowsWithMaps=M,i.numLightProbes=G,N.sunLength=p,N.directionalLength=m,N.pointLength=f,N.spotLength=w,N.rectAreaLength=C,N.hemiLength=y,N.numSunShadows=v,N.numDirectionalShadows=b,N.numPointShadows=A,N.numSpotShadows=E,N.numSpotMaps=g,N.numLightProbes=G,i.version=zg++}function l(c,u){let d=0,h=0,p=0,v=0,T=0,m=0,f=u.matrixWorldInverse;for(let w=0,C=c.length;w<C;w++){let y=c[w];if(y.isSunLight){let b=i.sun[d];b.direction.setFromMatrixPosition(y.matrixWorld),b.direction.transformDirection(f),d++}else if(y.isDirectionalLight){let b=i.directional[h];b.direction.setFromMatrixPosition(y.matrixWorld),s.setFromMatrixPosition(y.target.matrixWorld),b.direction.sub(s),b.direction.transformDirection(f),h++}else if(y.isSpotLight){let b=i.spot[v];b.position.setFromMatrixPosition(y.matrixWorld),b.position.applyMatrix4(f),b.direction.setFromMatrixPosition(y.matrixWorld),s.setFromMatrixPosition(y.target.matrixWorld),b.direction.sub(s),b.direction.transformDirection(f),v++}else if(y.isRectAreaLight){let b=i.rectArea[T];b.position.setFromMatrixPosition(y.matrixWorld),b.position.applyMatrix4(f),a.identity(),r.copy(y.matrixWorld),r.premultiply(f),a.extractRotation(r),b.halfWidth.set(y.width*0.5,0,0),b.halfHeight.set(0,y.height*0.5,0),b.halfWidth.applyMatrix4(a),b.halfHeight.applyMatrix4(a),T++}else if(y.isPointLight){let b=i.point[p];b.position.setFromMatrixPosition(y.matrixWorld),b.position.applyMatrix4(f),p++}else if(y.isHemisphereLight){let b=i.hemi[m];b.direction.setFromMatrixPosition(y.matrixWorld),b.direction.transformDirection(f),m++}}}return{setup:o,setupView:l,state:i}}function Xh(t){let e=new Gg(t),n=[],i=[],s=[];function r(h){d.camera=h,n.length=0,i.length=0,s.length=0}function a(h){n.push(h)}function o(h){i.push(h)}function l(h){s.push(h)}function c(){e.setup(n)}function u(h){e.setupView(n,h)}let d={lightsArray:n,shadowsArray:i,lightProbeGridArray:s,camera:null,lights:e,transmissionRenderTarget:{},textureUnits:0};return{init:r,state:d,setupLights:c,setupLightsView:u,pushLight:a,pushShadow:o,pushLightProbeGrid:l}}function Hg(t){let e=new WeakMap;function n(s,r=0){let a=e.get(s),o;if(a===void 0)o=new Xh(t),e.set(s,[o]);else if(r>=a.length)o=new Xh(t),a.push(o);else o=a[r];return o}function i(){e=new WeakMap}return{get:n,dispose:i}}var Vg=`void main() {
4170
4170
  gl_Position = vec4( position, 1.0 );
4171
- }`,Vg=`uniform sampler2D shadow_pass;
4171
+ }`,Wg=`uniform sampler2D shadow_pass;
4172
4172
  uniform vec2 resolution;
4173
4173
  uniform float radius;
4174
4174
  void main() {
@@ -4193,12 +4193,12 @@ void main() {
4193
4193
  squared_mean = squared_mean / samples;
4194
4194
  float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );
4195
4195
  gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );
4196
- }`,Wg=[new O(1,0,0),new O(-1,0,0),new O(0,1,0),new O(0,-1,0),new O(0,0,1),new O(0,0,-1)],Xg=[new O(0,-1,0),new O(0,-1,0),new O(0,0,1),new O(0,0,-1),new O(0,-1,0),new O(0,-1,0)],Xh=new we,ir=new O,Cl=new O;function qg(t,e,n){let i=new tr,s=new Xt,r=new Xt,a=new Ae,o=new sl,l=new rl,c={},u=n.maxTextureSize,d={[fs]:Ve,[Ve]:fs,[on]:on},h=new bn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Xt},radius:{value:4}},vertexShader:Hg,fragmentShader:Vg}),p=h.clone();p.defines.HORIZONTAL_PASS=1;let v=new _n;v.setAttribute("position",new Mn(new Float32Array([-1,-1,0.5,3,-1,0.5,-1,3,0.5]),3));let T=new Jt(v,h),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=ks;let f=this.type;this.render=function(A,E,g){if(m.enabled===!1)return;if(m.autoUpdate===!1&&m.needsUpdate===!1)return;if(A.length===0)return;if(this.type===Mc)Ht("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=ks;let M=t.getRenderTarget(),G=t.getActiveCubeFace(),N=t.getActiveMipmapLevel(),F=t.state;if(F.setBlending(Bn),F.buffers.depth.getReversed()===!0)F.buffers.color.setClear(0,0,0,0);else F.buffers.color.setClear(1,1,1,1);F.buffers.depth.setTest(!0),F.setScissorTest(!1);let X=f!==this.type;if(X)E.traverse(function(R){if(R.material)if(Array.isArray(R.material))R.material.forEach((k)=>k.needsUpdate=!0);else R.material.needsUpdate=!0});for(let R=0,k=A.length;R<k;R++){let Z=A[R],H=Z.shadow;if(H===void 0){Ht("WebGLShadowMap:",Z,"has no shadow.");continue}if(H.autoUpdate===!1&&H.needsUpdate===!1)continue;s.copy(H.mapSize);let at=H.getFrameExtents();if(s.multiply(at),r.copy(H.mapSize),s.x>u||s.y>u){if(s.x>u)r.x=Math.floor(u/at.x),s.x=r.x*at.x,H.mapSize.x=r.x;if(s.y>u)r.y=Math.floor(u/at.y),s.y=r.y*at.y,H.mapSize.y=r.y}let K=t.state.buffers.depth.getReversed();if(H.camera._reversedDepth=K,H.map===null||X===!0){if(H.map!==null){if(H.map.depthTexture!==null)H.map.depthTexture.dispose(),H.map.depthTexture=null;H.map.dispose()}if(this.type===ds){if(Z.isPointLight){Ht("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}H.map=new gn(s.x,s.y,{format:Li,type:kn,minFilter:Qe,magFilter:Qe,generateMipmaps:!1}),H.map.texture.name=Z.name+".shadowMap",H.map.depthTexture=new Fi(s.x,s.y,jn),H.map.depthTexture.name=Z.name+".shadowMapDepth",H.map.depthTexture.format=Ri,H.map.depthTexture.compareFunction=null,H.map.depthTexture.minFilter=Nn,H.map.depthTexture.magFilter=Nn}else{if(Z.isPointLight)H.map=new Ll(s.x),H.map.depthTexture=new el(s.x,mi);else H.map=new gn(s.x,s.y),H.map.depthTexture=new Fi(s.x,s.y,mi);if(H.map.depthTexture.name=Z.name+".shadowMap",H.map.depthTexture.format=Ri,this.type===ks)H.map.depthTexture.compareFunction=K?Zr:Yr,H.map.depthTexture.minFilter=Qe,H.map.depthTexture.magFilter=Qe;else H.map.depthTexture.compareFunction=null,H.map.depthTexture.minFilter=Nn,H.map.depthTexture.magFilter=Nn}H.camera.updateProjectionMatrix()}if(H.map.isWebGLCubeRenderTarget!==!0&&(H.map.width!==s.x||H.map.height!==s.y))H.map.setSize(s.x,s.y);let et=H.map.isWebGLCubeRenderTarget?6:H.getViewportCount();if(Z.isPointLight!==!0)H.updateMatrices(Z,g);for(let tt=0;tt<et;tt++){let dt=H.getCamera(tt);if(Z.isPointLight){let{camera:At,matrix:te}=H,zt=Z.distance||At.far;if(zt!==At.far)At.far=zt,At.updateProjectionMatrix();ir.setFromMatrixPosition(Z.matrixWorld),At.position.copy(ir),Cl.copy(At.position),Cl.add(Wg[tt]),At.up.copy(Xg[tt]),At.lookAt(Cl),At.updateMatrixWorld(),te.makeTranslation(-ir.x,-ir.y,-ir.z),Xh.multiplyMatrices(At.projectionMatrix,At.matrixWorldInverse),H._frustum.setFromProjectionMatrix(Xh,At.coordinateSystem,At.reversedDepth)}if(H.map.isWebGLCubeRenderTarget)t.setRenderTarget(H.map,tt),t.clear();else{if(tt===0)t.setRenderTarget(H.map),t.clear();let At=H.getViewport(tt);a.set(r.x*At.x,r.y*At.y,r.x*At.z,r.y*At.w),F.viewport(a)}i=H.getFrustum(tt),y(E,g,dt,Z,this.type)}if(H.isPointLightShadow!==!0&&this.type===ds)w(H,g);H.needsUpdate=!1}f=this.type,m.needsUpdate=!1,t.setRenderTarget(M,G,N)};function w(A,E){let g=e.update(T);if(h.defines.VSM_SAMPLES!==A.blurSamples)h.defines.VSM_SAMPLES=A.blurSamples,p.defines.VSM_SAMPLES=A.blurSamples,h.needsUpdate=!0,p.needsUpdate=!0;if(A.mapPass===null)A.mapPass=new gn(s.x,s.y,{format:Li,type:kn});else if(A.mapPass.width!==A.map.width||A.mapPass.height!==A.map.height)A.mapPass.setSize(A.map.width,A.map.height);h.uniforms.shadow_pass.value=A.map.depthTexture,h.uniforms.resolution.value.set(A.map.width,A.map.height),h.uniforms.radius.value=A.radius,t.setRenderTarget(A.mapPass),t.clear(),t.renderBufferDirect(E,null,g,h,T,null),p.uniforms.shadow_pass.value=A.mapPass.texture,p.uniforms.resolution.value.set(A.map.width,A.map.height),p.uniforms.radius.value=A.radius,t.setRenderTarget(A.map),t.clear(),t.renderBufferDirect(E,null,g,p,T,null)}function C(A,E,g,M){let G=null,N=g.isPointLight===!0?A.customDistanceMaterial:A.customDepthMaterial;if(N!==void 0)G=N;else if(G=g.isPointLight===!0?l:o,t.localClippingEnabled&&E.clipShadows===!0&&Array.isArray(E.clippingPlanes)&&E.clippingPlanes.length!==0||E.displacementMap&&E.displacementScale!==0||E.alphaMap&&E.alphaTest>0||E.map&&E.alphaTest>0||E.alphaToCoverage===!0){let F=G.uuid,X=E.uuid,R=c[F];if(R===void 0)R={},c[F]=R;let k=R[X];if(k===void 0)k=G.clone(),R[X]=k,E.addEventListener("dispose",b);G=k}if(G.visible=E.visible,G.wireframe=E.wireframe,M===ds)G.side=E.shadowSide!==null?E.shadowSide:E.side;else G.side=E.shadowSide!==null?E.shadowSide:d[E.side];if(G.alphaMap=E.alphaMap,G.alphaTest=E.alphaToCoverage===!0?0.5:E.alphaTest,G.map=E.map,G.clipShadows=E.clipShadows,G.clippingPlanes=E.clippingPlanes,G.clipIntersection=E.clipIntersection,G.displacementMap=E.displacementMap,G.displacementScale=E.displacementScale,G.displacementBias=E.displacementBias,G.wireframeLinewidth=E.wireframeLinewidth,G.linewidth=E.linewidth,g.isPointLight===!0&&G.isMeshDistanceMaterial===!0){let F=t.properties.get(G);F.light=g}return G}function y(A,E,g,M,G){if(A.visible===!1)return;if(A.layers.test(E.layers)&&(A.isMesh||A.isLine||A.isPoints)){if((A.castShadow||A.receiveShadow&&G===ds)&&(!A.frustumCulled||A.intersectsFrustum(i))){A.modelViewMatrix.multiplyMatrices(g.matrixWorldInverse,A.matrixWorld);let X=e.update(A),R=A.material;if(Array.isArray(R)){let k=X.groups;for(let Z=0,H=k.length;Z<H;Z++){let at=k[Z],K=R[at.materialIndex];if(K&&K.visible){let et=C(A,K,M,G);A.onBeforeShadow(t,A,E,g,X,et,at),t.renderBufferDirect(g,null,X,et,A,at),A.onAfterShadow(t,A,E,g,X,et,at)}}}else if(R.visible){let k=C(A,R,M,G);A.onBeforeShadow(t,A,E,g,X,k,null),t.renderBufferDirect(g,null,X,k,A,null),A.onAfterShadow(t,A,E,g,X,k,null)}}}let F=A.children;for(let X=0,R=F.length;X<R;X++)y(F[X],E,g,M,G)}function b(A){A.target.removeEventListener("dispose",b);for(let g in c){let M=c[g],G=A.target.uuid;if(G in M)M[G].dispose(),delete M[G]}}}function Yg(t,e){function n(){let I=!1,ct=new Ae,Q=null,ut=new Ae(0,0,0,0);return{setMask:function(Tt){if(Q!==Tt&&!I)t.colorMask(Tt,Tt,Tt,Tt),Q=Tt},setLocked:function(Tt){I=Tt},setClear:function(Tt,nt,mt,Vt,fe){if(fe===!0)Tt*=Vt,nt*=Vt,mt*=Vt;if(ct.set(Tt,nt,mt,Vt),ut.equals(ct)===!1)t.clearColor(Tt,nt,mt,Vt),ut.copy(ct)},reset:function(){I=!1,Q=null,ut.set(-1,0,0,0)}}}function i(){let I=!1,ct=!1,Q=null,ut=null,Tt=null;return{setReversed:function(nt){if(ct!==nt){let mt=e.get("EXT_clip_control");if(nt)mt.clipControlEXT(mt.LOWER_LEFT_EXT,mt.ZERO_TO_ONE_EXT);else mt.clipControlEXT(mt.LOWER_LEFT_EXT,mt.NEGATIVE_ONE_TO_ONE_EXT);ct=nt;let Vt=Tt;Tt=null,this.setClear(Vt)}},getReversed:function(){return ct},setTest:function(nt){if(nt)lt(t.DEPTH_TEST);else It(t.DEPTH_TEST)},setMask:function(nt){if(Q!==nt&&!I)t.depthMask(nt),Q=nt},setFunc:function(nt){if(ct)nt=_h[nt];if(ut!==nt){switch(nt){case Vc:t.depthFunc(t.NEVER);break;case Wc:t.depthFunc(t.ALWAYS);break;case Xc:t.depthFunc(t.LESS);break;case Ya:t.depthFunc(t.LEQUAL);break;case qc:t.depthFunc(t.EQUAL);break;case Yc:t.depthFunc(t.GEQUAL);break;case Zc:t.depthFunc(t.GREATER);break;case Jc:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}ut=nt}},setLocked:function(nt){I=nt},setClear:function(nt){if(Tt!==nt){if(Tt=nt,ct)nt=1-nt;t.clearDepth(nt)}},reset:function(){I=!1,Q=null,ut=null,Tt=null,ct=!1}}}function s(){let I=!1,ct=null,Q=null,ut=null,Tt=null,nt=null,mt=null,Vt=null,fe=null;return{setTest:function(ce){if(!I)if(ce)lt(t.STENCIL_TEST);else It(t.STENCIL_TEST)},setMask:function(ce){if(ct!==ce&&!I)t.stencilMask(ce),ct=ce},setFunc:function(ce,un,vn){if(Q!==ce||ut!==un||Tt!==vn)t.stencilFunc(ce,un,vn),Q=ce,ut=un,Tt=vn},setOp:function(ce,un,vn){if(nt!==ce||mt!==un||Vt!==vn)t.stencilOp(ce,un,vn),nt=ce,mt=un,Vt=vn},setLocked:function(ce){I=ce},setClear:function(ce){if(fe!==ce)t.clearStencil(ce),fe=ce},reset:function(){I=!1,ct=null,Q=null,ut=null,Tt=null,nt=null,mt=null,Vt=null,fe=null}}}let r=new n,a=new i,o=new s,l=new WeakMap,c=new WeakMap,u={},d={},h={},p=new WeakMap,v=[],T=null,m=!1,f=null,w=null,C=null,y=null,b=null,A=null,E=null,g=new Kt(0,0,0),M=0,G=!1,N=null,F=null,X=null,R=null,k=null,Z=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS),H=!1,at=0,K=t.getParameter(t.VERSION);if(K.indexOf("WebGL")!==-1)at=parseFloat(/^WebGL (\d)/.exec(K)[1]),H=at>=1;else if(K.indexOf("OpenGL ES")!==-1)at=parseFloat(/^OpenGL ES (\d)/.exec(K)[1]),H=at>=2;let et=null,tt={},dt=t.getParameter(t.SCISSOR_BOX),At=t.getParameter(t.VIEWPORT),te=new Ae().fromArray(dt),zt=new Ae().fromArray(At);function Y(I,ct,Q,ut){let Tt=new Uint8Array(4),nt=t.createTexture();t.bindTexture(I,nt),t.texParameteri(I,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(I,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let mt=0;mt<Q;mt++)if(I===t.TEXTURE_3D||I===t.TEXTURE_2D_ARRAY)t.texImage3D(ct,0,t.RGBA,1,1,ut,0,t.RGBA,t.UNSIGNED_BYTE,Tt);else t.texImage2D(ct+mt,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,Tt);return nt}let rt={};rt[t.TEXTURE_2D]=Y(t.TEXTURE_2D,t.TEXTURE_2D,1),rt[t.TEXTURE_CUBE_MAP]=Y(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),rt[t.TEXTURE_2D_ARRAY]=Y(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),rt[t.TEXTURE_3D]=Y(t.TEXTURE_3D,t.TEXTURE_3D,1,1),r.setClear(0,0,0,1),a.setClear(1),o.setClear(0),lt(t.DEPTH_TEST),a.setFunc(Ya),Le(!1),me(Wa),lt(t.CULL_FACE),ue(Bn);function lt(I){if(u[I]!==!0)t.enable(I),u[I]=!0}function It(I){if(u[I]!==!1)t.disable(I),u[I]=!1}function Ot(I,ct){if(h[I]!==ct){if(t.bindFramebuffer(I,ct),h[I]=ct,I===t.DRAW_FRAMEBUFFER)h[t.FRAMEBUFFER]=ct;if(I===t.FRAMEBUFFER)h[t.DRAW_FRAMEBUFFER]=ct;return!0}return!1}function Ft(I,ct){let Q=v,ut=!1;if(I){if(Q=p.get(ct),Q===void 0)Q=[],p.set(ct,Q);let Tt=I.textures;if(Q.length!==Tt.length||Q[0]!==t.COLOR_ATTACHMENT0){for(let nt=0,mt=Tt.length;nt<mt;nt++)Q[nt]=t.COLOR_ATTACHMENT0+nt;Q.length=Tt.length,ut=!0}}else if(Q[0]!==t.BACK)Q[0]=t.BACK,ut=!0;if(ut)t.drawBuffers(Q)}function Ce(I){if(T!==I)return t.useProgram(I),T=I,!0;return!1}let $t={[ps]:t.FUNC_ADD,[Tc]:t.FUNC_SUBTRACT,[wc]:t.FUNC_REVERSE_SUBTRACT};$t[Ec]=t.MIN,$t[Ac]=t.MAX;let ee={[Cc]:t.ZERO,[Rc]:t.ONE,[Ic]:t.SRC_COLOR,[Lc]:t.SRC_ALPHA,[Bc]:t.SRC_ALPHA_SATURATE,[Fc]:t.DST_COLOR,[Dc]:t.DST_ALPHA,[Pc]:t.ONE_MINUS_SRC_COLOR,[Nc]:t.ONE_MINUS_SRC_ALPHA,[Oc]:t.ONE_MINUS_DST_COLOR,[Uc]:t.ONE_MINUS_DST_ALPHA,[zc]:t.CONSTANT_COLOR,[kc]:t.ONE_MINUS_CONSTANT_COLOR,[Gc]:t.CONSTANT_ALPHA,[Hc]:t.ONE_MINUS_CONSTANT_ALPHA};function ue(I,ct,Q,ut,Tt,nt,mt,Vt,fe,ce){if(I===Bn){if(m===!0)It(t.BLEND),m=!1;return}if(m===!1)lt(t.BLEND),m=!0;if(I!==bc){if(I!==f||ce!==G){if(w!==ps||b!==ps)t.blendEquation(t.FUNC_ADD),w=ps,b=ps;if(ce)switch(I){case Pn:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case Qn:t.blendFunc(t.ONE,t.ONE);break;case Xa:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case qa:t.blendFuncSeparate(t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA,t.ZERO,t.ONE);break;default:Gt("WebGLState: Invalid blending: ",I);break}else switch(I){case Pn:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case Qn:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE);break;case Xa:Gt("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case qa:Gt("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Gt("WebGLState: Invalid blending: ",I);break}C=null,y=null,A=null,E=null,g.set(0,0,0),M=0,f=I,G=ce}return}if(Tt=Tt||ct,nt=nt||Q,mt=mt||ut,ct!==w||Tt!==b)t.blendEquationSeparate($t[ct],$t[Tt]),w=ct,b=Tt;if(Q!==C||ut!==y||nt!==A||mt!==E)t.blendFuncSeparate(ee[Q],ee[ut],ee[nt],ee[mt]),C=Q,y=ut,A=nt,E=mt;if(Vt.equals(g)===!1||fe!==M)t.blendColor(Vt.r,Vt.g,Vt.b,fe),g.copy(Vt),M=fe;f=I,G=!1}function ne(I,ct){I.side===on?It(t.CULL_FACE):lt(t.CULL_FACE);let Q=I.side===Ve;if(ct)Q=!Q;Le(Q),I.blending===Pn&&I.transparent===!1?ue(Bn):ue(I.blending,I.blendEquation,I.blendSrc,I.blendDst,I.blendEquationAlpha,I.blendSrcAlpha,I.blendDstAlpha,I.blendColor,I.blendAlpha,I.premultipliedAlpha),a.setFunc(I.depthFunc),a.setTest(I.depthTest),a.setMask(I.depthWrite),r.setMask(I.colorWrite);let ut=I.stencilWrite;if(o.setTest(ut),ut)o.setMask(I.stencilWriteMask),o.setFunc(I.stencilFunc,I.stencilRef,I.stencilFuncMask),o.setOp(I.stencilFail,I.stencilZFail,I.stencilZPass);Ne(I.polygonOffset,I.polygonOffsetFactor,I.polygonOffsetUnits),I.alphaToCoverage===!0?lt(t.SAMPLE_ALPHA_TO_COVERAGE):It(t.SAMPLE_ALPHA_TO_COVERAGE)}function Le(I){if(N!==I){if(I)t.frontFace(t.CW);else t.frontFace(t.CCW);N=I}}function me(I){if(I!==yc){if(lt(t.CULL_FACE),I!==F)if(I===Wa)t.cullFace(t.BACK);else if(I===Sc)t.cullFace(t.FRONT);else t.cullFace(t.FRONT_AND_BACK)}else It(t.CULL_FACE);F=I}function Ze(I){if(I!==X){if(H)t.lineWidth(I);X=I}}function Ne(I,ct,Q){if(I){if(lt(t.POLYGON_OFFSET_FILL),R!==ct||k!==Q){if(R=ct,k=Q,a.getReversed())ct=-ct;t.polygonOffset(ct,Q)}}else It(t.POLYGON_OFFSET_FILL)}function Re(I){if(I)lt(t.SCISSOR_TEST);else It(t.SCISSOR_TEST)}function P(I){if(I===void 0)I=t.TEXTURE0+Z-1;if(et!==I)t.activeTexture(I),et=I}function Ue(I,ct,Q){if(Q===void 0)if(et===null)Q=t.TEXTURE0+Z-1;else Q=et;let ut=tt[Q];if(ut===void 0)ut={type:void 0,texture:void 0},tt[Q]=ut;if(ut.type!==I||ut.texture!==ct){if(et!==Q)t.activeTexture(Q),et=Q;t.bindTexture(I,ct||rt[I]),ut.type=I,ut.texture=ct}}function ae(){let I=tt[et];if(I!==void 0&&I.type!==void 0)t.bindTexture(I.type,null),I.type=void 0,I.texture=void 0}function be(){try{t.compressedTexImage2D(...arguments)}catch(I){Gt("WebGLState:",I)}}function S(){try{t.compressedTexImage3D(...arguments)}catch(I){Gt("WebGLState:",I)}}function _(){try{t.texSubImage2D(...arguments)}catch(I){Gt("WebGLState:",I)}}function L(){try{t.texSubImage3D(...arguments)}catch(I){Gt("WebGLState:",I)}}function V(){try{t.compressedTexSubImage2D(...arguments)}catch(I){Gt("WebGLState:",I)}}function it(){try{t.compressedTexSubImage3D(...arguments)}catch(I){Gt("WebGLState:",I)}}function st(){try{t.texStorage2D(...arguments)}catch(I){Gt("WebGLState:",I)}}function ft(){try{t.texStorage3D(...arguments)}catch(I){Gt("WebGLState:",I)}}function J(){try{t.texImage2D(...arguments)}catch(I){Gt("WebGLState:",I)}}function j(){try{t.texImage3D(...arguments)}catch(I){Gt("WebGLState:",I)}}function _t(I){if(d[I]!==void 0)return d[I];else return t.getParameter(I)}function Dt(I,ct){if(d[I]!==ct)t.pixelStorei(I,ct),d[I]=ct}function pt(I){if(te.equals(I)===!1)t.scissor(I.x,I.y,I.z,I.w),te.copy(I)}function ot(I){if(zt.equals(I)===!1)t.viewport(I.x,I.y,I.z,I.w),zt.copy(I)}function Bt(I,ct){let Q=c.get(ct);if(Q===void 0)Q=new WeakMap,c.set(ct,Q);let ut=Q.get(I);if(ut===void 0)ut=t.getUniformBlockIndex(ct,I.name),Q.set(I,ut)}function kt(I,ct){let ut=c.get(ct).get(I);if(l.get(ct)!==ut)t.uniformBlockBinding(ct,ut,I.__bindingPointIndex),l.set(ct,ut)}function se(){t.disable(t.BLEND),t.disable(t.CULL_FACE),t.disable(t.DEPTH_TEST),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SCISSOR_TEST),t.disable(t.STENCIL_TEST),t.disable(t.SAMPLE_ALPHA_TO_COVERAGE),t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ZERO),t.blendFuncSeparate(t.ONE,t.ZERO,t.ONE,t.ZERO),t.blendColor(0,0,0,0),t.colorMask(!0,!0,!0,!0),t.clearColor(0,0,0,0),t.depthMask(!0),t.depthFunc(t.LESS),a.setReversed(!1),t.clearDepth(1),t.stencilMask(4294967295),t.stencilFunc(t.ALWAYS,0,4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP),t.clearStencil(0),t.cullFace(t.BACK),t.frontFace(t.CCW),t.polygonOffset(0,0),t.activeTexture(t.TEXTURE0),t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),t.bindFramebuffer(t.READ_FRAMEBUFFER,null),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.canvas.height),t.pixelStorei(t.PACK_ALIGNMENT,4),t.pixelStorei(t.UNPACK_ALIGNMENT,4),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,!1),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,t.BROWSER_DEFAULT_WEBGL),t.pixelStorei(t.PACK_ROW_LENGTH,0),t.pixelStorei(t.PACK_SKIP_PIXELS,0),t.pixelStorei(t.PACK_SKIP_ROWS,0),t.pixelStorei(t.UNPACK_ROW_LENGTH,0),t.pixelStorei(t.UNPACK_IMAGE_HEIGHT,0),t.pixelStorei(t.UNPACK_SKIP_PIXELS,0),t.pixelStorei(t.UNPACK_SKIP_ROWS,0),t.pixelStorei(t.UNPACK_SKIP_IMAGES,0),u={},d={},et=null,tt={},h={},p=new WeakMap,v=[],T=null,m=!1,f=null,w=null,C=null,y=null,b=null,A=null,E=null,g=new Kt(0,0,0),M=0,G=!1,N=null,F=null,X=null,R=null,k=null,te.set(0,0,t.canvas.width,t.canvas.height),zt.set(0,0,t.canvas.width,t.canvas.height),r.reset(),a.reset(),o.reset()}return{buffers:{color:r,depth:a,stencil:o},enable:lt,disable:It,bindFramebuffer:Ot,drawBuffers:Ft,useProgram:Ce,setBlending:ue,setMaterial:ne,setFlipSided:Le,setCullFace:me,setLineWidth:Ze,setPolygonOffset:Ne,setScissorTest:Re,activeTexture:P,bindTexture:Ue,unbindTexture:ae,compressedTexImage2D:be,compressedTexImage3D:S,texImage2D:J,texImage3D:j,pixelStorei:Dt,getParameter:_t,updateUBOMapping:Bt,uniformBlockBinding:kt,texStorage2D:st,texStorage3D:ft,texSubImage2D:_,texSubImage3D:L,compressedTexSubImage2D:V,compressedTexSubImage3D:it,scissor:pt,viewport:ot,reset:se}}function Zg(t,e,n,i,s,r,a){let o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new Xt,u=new WeakMap,d=new Set,h,p=new WeakMap,v=!1;try{v=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch(S){}function T(S,_){return v?new OffscreenCanvas(S,_):Os("canvas")}function m(S,_,L){let V=1,it=be(S);if(it.width>L||it.height>L)V=L/Math.max(it.width,it.height);if(V<1)if(typeof HTMLImageElement<"u"&&S instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&S instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&S instanceof ImageBitmap||typeof VideoFrame<"u"&&S instanceof VideoFrame){let st=Math.floor(V*it.width),ft=Math.floor(V*it.height);if(h===void 0)h=T(st,ft);let J=_?T(st,ft):h;return J.width=st,J.height=ft,J.getContext("2d").drawImage(S,0,0,st,ft),Ht("WebGLRenderer: Texture has been resized from ("+it.width+"x"+it.height+") to ("+st+"x"+ft+")."),J}else{if("data"in S)Ht("WebGLRenderer: Image in DataTexture is too big ("+it.width+"x"+it.height+").");return S}return S}function f(S){return S.generateMipmaps}function w(S){t.generateMipmap(S)}function C(S){if(S.isWebGLCubeRenderTarget)return t.TEXTURE_CUBE_MAP;if(S.isWebGL3DRenderTarget)return t.TEXTURE_3D;if(S.isWebGLArrayRenderTarget||S.isCompressedArrayTexture)return t.TEXTURE_2D_ARRAY;return t.TEXTURE_2D}function y(S,_,L,V,it,st=!1){if(S!==null){if(t[S]!==void 0)return t[S];Ht("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+S+"'")}let ft;if(V){if(ft=e.get("EXT_texture_norm16"),!ft)Ht("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension")}let J=_;if(_===t.RED){if(L===t.FLOAT)J=t.R32F;if(L===t.HALF_FLOAT)J=t.R16F;if(L===t.UNSIGNED_BYTE)J=t.R8;if(L===t.UNSIGNED_SHORT&&ft)J=ft.R16_EXT;if(L===t.SHORT&&ft)J=ft.R16_SNORM_EXT}if(_===t.RED_INTEGER){if(L===t.UNSIGNED_BYTE)J=t.R8UI;if(L===t.UNSIGNED_SHORT)J=t.R16UI;if(L===t.UNSIGNED_INT)J=t.R32UI;if(L===t.BYTE)J=t.R8I;if(L===t.SHORT)J=t.R16I;if(L===t.INT)J=t.R32I}if(_===t.RG){if(L===t.FLOAT)J=t.RG32F;if(L===t.HALF_FLOAT)J=t.RG16F;if(L===t.UNSIGNED_BYTE)J=t.RG8;if(L===t.UNSIGNED_SHORT&&ft)J=ft.RG16_EXT;if(L===t.SHORT&&ft)J=ft.RG16_SNORM_EXT}if(_===t.RG_INTEGER){if(L===t.UNSIGNED_BYTE)J=t.RG8UI;if(L===t.UNSIGNED_SHORT)J=t.RG16UI;if(L===t.UNSIGNED_INT)J=t.RG32UI;if(L===t.BYTE)J=t.RG8I;if(L===t.SHORT)J=t.RG16I;if(L===t.INT)J=t.RG32I}if(_===t.RGB_INTEGER){if(L===t.UNSIGNED_BYTE)J=t.RGB8UI;if(L===t.UNSIGNED_SHORT)J=t.RGB16UI;if(L===t.UNSIGNED_INT)J=t.RGB32UI;if(L===t.BYTE)J=t.RGB8I;if(L===t.SHORT)J=t.RGB16I;if(L===t.INT)J=t.RGB32I}if(_===t.RGBA_INTEGER){if(L===t.UNSIGNED_BYTE)J=t.RGBA8UI;if(L===t.UNSIGNED_SHORT)J=t.RGBA16UI;if(L===t.UNSIGNED_INT)J=t.RGBA32UI;if(L===t.BYTE)J=t.RGBA8I;if(L===t.SHORT)J=t.RGBA16I;if(L===t.INT)J=t.RGBA32I}if(_===t.RGB){if(L===t.UNSIGNED_SHORT&&ft)J=ft.RGB16_EXT;if(L===t.SHORT&&ft)J=ft.RGB16_SNORM_EXT;if(L===t.UNSIGNED_INT_5_9_9_9_REV)J=t.RGB9_E5;if(L===t.UNSIGNED_INT_10F_11F_11F_REV)J=t.R11F_G11F_B10F}if(_===t.RGBA){let j=st?Yo:re.getTransfer(it);if(L===t.FLOAT)J=t.RGBA32F;if(L===t.HALF_FLOAT)J=t.RGBA16F;if(L===t.UNSIGNED_BYTE)J=j===Me?t.SRGB8_ALPHA8:t.RGBA8;if(L===t.UNSIGNED_SHORT&&ft)J=ft.RGBA16_EXT;if(L===t.SHORT&&ft)J=ft.RGBA16_SNORM_EXT;if(L===t.UNSIGNED_SHORT_4_4_4_4)J=t.RGBA4;if(L===t.UNSIGNED_SHORT_5_5_5_1)J=t.RGB5_A1}if(J===t.R16F||J===t.R32F||J===t.RG16F||J===t.RG32F||J===t.RGBA16F||J===t.RGBA32F)e.get("EXT_color_buffer_float");return J}function b(S,_){let L;if(S){if(_===null||_===mi||_===gs)L=t.DEPTH24_STENCIL8;else if(_===jn)L=t.DEPTH32F_STENCIL8;else if(_===Ws)L=t.DEPTH24_STENCIL8,Ht("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")}else if(_===null||_===mi||_===gs)L=t.DEPTH_COMPONENT24;else if(_===jn)L=t.DEPTH_COMPONENT32F;else if(_===Ws)L=t.DEPTH_COMPONENT16;return L}function A(S,_){if(f(S)===!0||S.isFramebufferTexture&&S.minFilter!==Nn&&S.minFilter!==Qe)return Math.log2(Math.max(_.width,_.height))+1;else if(S.mipmaps!==void 0&&S.mipmaps.length>0)return S.mipmaps.length;else if(S.isCompressedTexture&&Array.isArray(S.image))return _.mipmaps.length;else return 1}function E(S){let _=S.target;if(_.removeEventListener("dispose",E),M(_),_.isVideoTexture)u.delete(_);if(_.isHTMLTexture)d.delete(_)}function g(S){let _=S.target;_.removeEventListener("dispose",g),N(_)}function M(S){let _=i.get(S);if(_.__webglInit===void 0)return;let L=S.source,V=p.get(L);if(V){let it=V[_.__cacheKey];if(it.usedTimes--,it.usedTimes===0)G(S);if(Object.keys(V).length===0)p.delete(L)}i.remove(S)}function G(S){let _=i.get(S);t.deleteTexture(_.__webglTexture);let L=S.source,V=p.get(L);delete V[_.__cacheKey],a.memory.textures--}function N(S){let _=i.get(S);if(S.depthTexture)S.depthTexture.dispose(),i.remove(S.depthTexture);if(S.isWebGLCubeRenderTarget)for(let V=0;V<6;V++){if(Array.isArray(_.__webglFramebuffer[V]))for(let it=0;it<_.__webglFramebuffer[V].length;it++)t.deleteFramebuffer(_.__webglFramebuffer[V][it]);else t.deleteFramebuffer(_.__webglFramebuffer[V]);if(_.__webglDepthbuffer)t.deleteRenderbuffer(_.__webglDepthbuffer[V])}else{if(Array.isArray(_.__webglFramebuffer))for(let V=0;V<_.__webglFramebuffer.length;V++)t.deleteFramebuffer(_.__webglFramebuffer[V]);else t.deleteFramebuffer(_.__webglFramebuffer);if(_.__webglDepthbuffer)t.deleteRenderbuffer(_.__webglDepthbuffer);if(_.__webglMultisampledFramebuffer)t.deleteFramebuffer(_.__webglMultisampledFramebuffer);if(_.__webglColorRenderbuffer){for(let V=0;V<_.__webglColorRenderbuffer.length;V++)if(_.__webglColorRenderbuffer[V])t.deleteRenderbuffer(_.__webglColorRenderbuffer[V])}if(_.__webglDepthRenderbuffer)t.deleteRenderbuffer(_.__webglDepthRenderbuffer)}let L=S.textures;for(let V=0,it=L.length;V<it;V++){let st=i.get(L[V]);if(st.__webglTexture)t.deleteTexture(st.__webglTexture),a.memory.textures--;i.remove(L[V])}i.remove(S)}let F=0;function X(){F=0}function R(){return F}function k(S){F=S}function Z(){let S=F;if(S>=s.maxTextures)Ht("WebGLTextures: Trying to use "+(S+1)+" texture units while this GPU supports only "+s.maxTextures);return F+=1,S}function H(S){let _=[];return _.push(S.wrapS),_.push(S.wrapT),_.push(S.wrapR||0),_.push(S.magFilter),_.push(S.minFilter),_.push(S.anisotropy),_.push(S.internalFormat),_.push(S.format),_.push(S.type),_.push(S.generateMipmaps),_.push(S.premultiplyAlpha),_.push(S.flipY),_.push(S.unpackAlignment),_.push(S.colorSpace),_.join()}function at(S,_){let L=i.get(S);if(S.isVideoTexture)Ue(S);if(S.isRenderTargetTexture===!1&&S.isExternalTexture!==!0&&S.version>0&&L.__version!==S.version){let V=S.image;if(V===null)Ht("WebGLRenderer: Texture marked for update but no image data found.");else if(V.complete===!1)Ht("WebGLRenderer: Texture marked for update but image is incomplete");else{It(L,S,_);return}}else if(S.isExternalTexture)L.__webglTexture=S.sourceTexture?S.sourceTexture:null;n.bindTexture(t.TEXTURE_2D,L.__webglTexture,t.TEXTURE0+_)}function K(S,_){let L=i.get(S);if(S.isRenderTargetTexture===!1&&S.version>0&&L.__version!==S.version){It(L,S,_);return}else if(S.isExternalTexture)L.__webglTexture=S.sourceTexture?S.sourceTexture:null;n.bindTexture(t.TEXTURE_2D_ARRAY,L.__webglTexture,t.TEXTURE0+_)}function et(S,_){let L=i.get(S);if(S.isRenderTargetTexture===!1&&S.version>0&&L.__version!==S.version){It(L,S,_);return}n.bindTexture(t.TEXTURE_3D,L.__webglTexture,t.TEXTURE0+_)}function tt(S,_){let L=i.get(S);if(S.isCubeDepthTexture!==!0&&S.version>0&&L.__version!==S.version){Ot(L,S,_);return}n.bindTexture(t.TEXTURE_CUBE_MAP,L.__webglTexture,t.TEXTURE0+_)}let dt={[Hs]:t.REPEAT,[zn]:t.CLAMP_TO_EDGE,[jc]:t.MIRRORED_REPEAT},At={[Nn]:t.NEAREST,[th]:t.NEAREST_MIPMAP_NEAREST,[Vs]:t.NEAREST_MIPMAP_LINEAR,[Qe]:t.LINEAR,[Br]:t.LINEAR_MIPMAP_NEAREST,[Ci]:t.LINEAR_MIPMAP_LINEAR},te={[lh]:t.NEVER,[fh]:t.ALWAYS,[ch]:t.LESS,[Yr]:t.LEQUAL,[hh]:t.EQUAL,[Zr]:t.GEQUAL,[uh]:t.GREATER,[dh]:t.NOTEQUAL};function zt(S,_){if(_.type===jn&&e.has("OES_texture_float_linear")===!1&&(_.magFilter===Qe||_.magFilter===Br||_.magFilter===Vs||_.magFilter===Ci||_.minFilter===Qe||_.minFilter===Br||_.minFilter===Vs||_.minFilter===Ci))Ht("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device.");if(t.texParameteri(S,t.TEXTURE_WRAP_S,dt[_.wrapS]),t.texParameteri(S,t.TEXTURE_WRAP_T,dt[_.wrapT]),S===t.TEXTURE_3D||S===t.TEXTURE_2D_ARRAY)t.texParameteri(S,t.TEXTURE_WRAP_R,dt[_.wrapR]);if(t.texParameteri(S,t.TEXTURE_MAG_FILTER,At[_.magFilter]),t.texParameteri(S,t.TEXTURE_MIN_FILTER,At[_.minFilter]),_.compareFunction)t.texParameteri(S,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(S,t.TEXTURE_COMPARE_FUNC,te[_.compareFunction]);if(e.has("EXT_texture_filter_anisotropic")===!0){if(_.magFilter===Nn)return;if(_.minFilter!==Vs&&_.minFilter!==Ci)return;if(_.type===jn&&e.has("OES_texture_float_linear")===!1)return;if(_.anisotropy>1||i.get(_).__currentAnisotropy){let L=e.get("EXT_texture_filter_anisotropic");t.texParameterf(S,L.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(_.anisotropy,s.getMaxAnisotropy())),i.get(_).__currentAnisotropy=_.anisotropy}}}function Y(S,_){let L=!1;if(S.__webglInit===void 0)S.__webglInit=!0,_.addEventListener("dispose",E);let V=_.source,it=p.get(V);if(it===void 0)it={},p.set(V,it);let st=H(_);if(st!==S.__cacheKey){if(it[st]===void 0)it[st]={texture:t.createTexture(),usedTimes:0},a.memory.textures++,L=!0;it[st].usedTimes++;let ft=it[S.__cacheKey];if(ft!==void 0){if(it[S.__cacheKey].usedTimes--,ft.usedTimes===0)G(_)}S.__cacheKey=st,S.__webglTexture=it[st].texture}return L}function rt(S,_,L){return Math.floor(Math.floor(S/L)/_)}function lt(S,_,L,V){let st=S.updateRanges;if(st.length===0)n.texSubImage2D(t.TEXTURE_2D,0,0,0,_.width,_.height,L,V,_.data);else{st.sort((Dt,pt)=>Dt.start-pt.start);let ft=0;for(let Dt=1;Dt<st.length;Dt++){let pt=st[ft],ot=st[Dt],Bt=pt.start+pt.count,kt=rt(ot.start,_.width,4),se=rt(pt.start,_.width,4);if(ot.start<=Bt+1&&kt===se&&rt(ot.start+ot.count-1,_.width,4)===kt)pt.count=Math.max(pt.count,ot.start+ot.count-pt.start);else++ft,st[ft]=ot}st.length=ft+1;let J=n.getParameter(t.UNPACK_ROW_LENGTH),j=n.getParameter(t.UNPACK_SKIP_PIXELS),_t=n.getParameter(t.UNPACK_SKIP_ROWS);n.pixelStorei(t.UNPACK_ROW_LENGTH,_.width);for(let Dt=0,pt=st.length;Dt<pt;Dt++){let ot=st[Dt],Bt=Math.floor(ot.start/4),kt=Math.ceil(ot.count/4),se=Bt%_.width,I=Math.floor(Bt/_.width),ct=kt,Q=1;n.pixelStorei(t.UNPACK_SKIP_PIXELS,se),n.pixelStorei(t.UNPACK_SKIP_ROWS,I),n.texSubImage2D(t.TEXTURE_2D,0,se,I,ct,1,L,V,_.data)}S.clearUpdateRanges(),n.pixelStorei(t.UNPACK_ROW_LENGTH,J),n.pixelStorei(t.UNPACK_SKIP_PIXELS,j),n.pixelStorei(t.UNPACK_SKIP_ROWS,_t)}}function It(S,_,L){let V=t.TEXTURE_2D;if(_.isDataArrayTexture||_.isCompressedArrayTexture)V=t.TEXTURE_2D_ARRAY;if(_.isData3DTexture)V=t.TEXTURE_3D;let it=Y(S,_),st=_.source;n.bindTexture(V,S.__webglTexture,t.TEXTURE0+L);let ft=i.get(st);if(st.version!==ft.__version||it===!0){if(n.activeTexture(t.TEXTURE0+L),(typeof ImageBitmap<"u"&&_.image instanceof ImageBitmap)===!1){let Q=re.getPrimaries(re.workingColorSpace),ut=_.colorSpace===Ni?null:re.getPrimaries(_.colorSpace),Tt=_.colorSpace===Ni||Q===ut?t.NONE:t.BROWSER_DEFAULT_WEBGL;n.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,_.flipY),n.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,_.premultiplyAlpha),n.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,Tt)}n.pixelStorei(t.UNPACK_ALIGNMENT,_.unpackAlignment);let j=m(_.image,!1,s.maxTextureSize);j=ae(_,j);let _t=r.convert(_.format,_.colorSpace),Dt=r.convert(_.type),pt=y(_.internalFormat,_t,Dt,_.normalized,_.colorSpace,_.isVideoTexture);zt(V,_);let ot,Bt=_.mipmaps,kt=_.isVideoTexture!==!0,se=ft.__version===void 0||it===!0,I=st.dataReady,ct=A(_,j);if(_.isDepthTexture){if(pt=b(_.format===Pi,_.type),se)if(kt)n.texStorage2D(t.TEXTURE_2D,1,pt,j.width,j.height);else n.texImage2D(t.TEXTURE_2D,0,pt,j.width,j.height,0,_t,Dt,null)}else if(_.isDataTexture)if(Bt.length>0){if(kt&&se)n.texStorage2D(t.TEXTURE_2D,ct,pt,Bt[0].width,Bt[0].height);for(let Q=0,ut=Bt.length;Q<ut;Q++)if(ot=Bt[Q],kt){if(I)n.texSubImage2D(t.TEXTURE_2D,Q,0,0,ot.width,ot.height,_t,Dt,ot.data)}else n.texImage2D(t.TEXTURE_2D,Q,pt,ot.width,ot.height,0,_t,Dt,ot.data);_.generateMipmaps=!1}else if(kt){if(se)n.texStorage2D(t.TEXTURE_2D,ct,pt,j.width,j.height);if(I)lt(_,j,_t,Dt)}else n.texImage2D(t.TEXTURE_2D,0,pt,j.width,j.height,0,_t,Dt,j.data);else if(_.isCompressedTexture)if(_.isCompressedArrayTexture){if(kt&&se)n.texStorage3D(t.TEXTURE_2D_ARRAY,ct,pt,Bt[0].width,Bt[0].height,j.depth);for(let Q=0,ut=Bt.length;Q<ut;Q++)if(ot=Bt[Q],_.format!==Gn)if(_t!==null)if(kt){if(I)if(_.layerUpdates.size>0){let Tt=Ml(ot.width,ot.height,_.format,_.type);for(let nt of _.layerUpdates){let mt=ot.data.subarray(nt*Tt/ot.data.BYTES_PER_ELEMENT,(nt+1)*Tt/ot.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Q,0,0,nt,ot.width,ot.height,1,_t,mt)}}else n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Q,0,0,0,ot.width,ot.height,j.depth,_t,ot.data)}else n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,Q,pt,ot.width,ot.height,j.depth,0,ot.data,0,0);else Ht("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(kt){if(I)n.texSubImage3D(t.TEXTURE_2D_ARRAY,Q,0,0,0,ot.width,ot.height,j.depth,_t,Dt,ot.data)}else n.texImage3D(t.TEXTURE_2D_ARRAY,Q,pt,ot.width,ot.height,j.depth,0,_t,Dt,ot.data);if(_.layerUpdates.size>0)_.clearLayerUpdates()}else{if(kt&&se)n.texStorage2D(t.TEXTURE_2D,ct,pt,Bt[0].width,Bt[0].height);for(let Q=0,ut=Bt.length;Q<ut;Q++)if(ot=Bt[Q],_.format!==Gn)if(_t!==null)if(kt){if(I)n.compressedTexSubImage2D(t.TEXTURE_2D,Q,0,0,ot.width,ot.height,_t,ot.data)}else n.compressedTexImage2D(t.TEXTURE_2D,Q,pt,ot.width,ot.height,0,ot.data);else Ht("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(kt){if(I)n.texSubImage2D(t.TEXTURE_2D,Q,0,0,ot.width,ot.height,_t,Dt,ot.data)}else n.texImage2D(t.TEXTURE_2D,Q,pt,ot.width,ot.height,0,_t,Dt,ot.data)}else if(_.isDataArrayTexture)if(kt){if(se)n.texStorage3D(t.TEXTURE_2D_ARRAY,ct,pt,j.width,j.height,j.depth);if(I)if(_.layerUpdates.size>0){let Q=Ml(j.width,j.height,_.format,_.type);for(let ut of _.layerUpdates){let Tt=j.data.subarray(ut*Q/j.data.BYTES_PER_ELEMENT,(ut+1)*Q/j.data.BYTES_PER_ELEMENT);n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,ut,j.width,j.height,1,_t,Dt,Tt)}_.clearLayerUpdates()}else n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,j.width,j.height,j.depth,_t,Dt,j.data)}else n.texImage3D(t.TEXTURE_2D_ARRAY,0,pt,j.width,j.height,j.depth,0,_t,Dt,j.data);else if(_.isData3DTexture)if(kt){if(se)n.texStorage3D(t.TEXTURE_3D,ct,pt,j.width,j.height,j.depth);if(I)n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,j.width,j.height,j.depth,_t,Dt,j.data)}else n.texImage3D(t.TEXTURE_3D,0,pt,j.width,j.height,j.depth,0,_t,Dt,j.data);else if(_.isFramebufferTexture){if(se)if(kt)n.texStorage2D(t.TEXTURE_2D,ct,pt,j.width,j.height);else{let Q=j.width,ut=j.height;for(let Tt=0;Tt<ct;Tt++)n.texImage2D(t.TEXTURE_2D,Tt,pt,Q,ut,0,_t,Dt,null),Q>>=1,ut>>=1}}else if(_.isHTMLTexture){if("texElementImage2D"in t){let Q=t.canvas;if(!Q.hasAttribute("layoutsubtree"))Q.setAttribute("layoutsubtree","true");if(j.parentNode!==Q){Q.appendChild(j),d.add(_),Q.onpaint=(ut)=>{let Tt=ut.changedElements;for(let nt of d)if(Tt.includes(nt.image))nt.needsUpdate=!0},Q.requestPaint();return}if(t.texElementImage2D.length===3)t.texElementImage2D(t.TEXTURE_2D,t.RGBA8,j);else{let{RGBA:Tt,RGBA:nt,UNSIGNED_BYTE:mt}=t;t.texElementImage2D(t.TEXTURE_2D,0,Tt,nt,mt,j)}t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE)}}else if(Bt.length>0){if(kt&&se){let Q=be(Bt[0]);n.texStorage2D(t.TEXTURE_2D,ct,pt,Q.width,Q.height)}for(let Q=0,ut=Bt.length;Q<ut;Q++)if(ot=Bt[Q],kt){if(I)n.texSubImage2D(t.TEXTURE_2D,Q,0,0,_t,Dt,ot)}else n.texImage2D(t.TEXTURE_2D,Q,pt,_t,Dt,ot);_.generateMipmaps=!1}else if(kt){if(se){let Q=be(j);n.texStorage2D(t.TEXTURE_2D,ct,pt,Q.width,Q.height)}if(I)n.texSubImage2D(t.TEXTURE_2D,0,0,0,_t,Dt,j)}else n.texImage2D(t.TEXTURE_2D,0,pt,_t,Dt,j);if(f(_))w(V);if(ft.__version=st.version,_.onUpdate)_.onUpdate(_)}S.__version=_.version}function Ot(S,_,L){if(_.image.length!==6)return;let V=Y(S,_),it=_.source;n.bindTexture(t.TEXTURE_CUBE_MAP,S.__webglTexture,t.TEXTURE0+L);let st=i.get(it);if(it.version!==st.__version||V===!0){n.activeTexture(t.TEXTURE0+L);let ft=re.getPrimaries(re.workingColorSpace),J=_.colorSpace===Ni?null:re.getPrimaries(_.colorSpace),j=_.colorSpace===Ni||ft===J?t.NONE:t.BROWSER_DEFAULT_WEBGL;n.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,_.flipY),n.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,_.premultiplyAlpha),n.pixelStorei(t.UNPACK_ALIGNMENT,_.unpackAlignment),n.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,j);let _t=_.isCompressedTexture||_.image[0].isCompressedTexture,Dt=_.image[0]&&_.image[0].isDataTexture,pt=[];for(let nt=0;nt<6;nt++){if(!_t&&!Dt)pt[nt]=m(_.image[nt],!0,s.maxCubemapSize);else pt[nt]=Dt?_.image[nt].image:_.image[nt];pt[nt]=ae(_,pt[nt])}let ot=pt[0],Bt=r.convert(_.format,_.colorSpace),kt=r.convert(_.type),se=y(_.internalFormat,Bt,kt,_.normalized,_.colorSpace),I=_.isVideoTexture!==!0,ct=st.__version===void 0||V===!0,Q=it.dataReady,ut=A(_,ot);zt(t.TEXTURE_CUBE_MAP,_);let Tt;if(_t){if(I&&ct)n.texStorage2D(t.TEXTURE_CUBE_MAP,ut,se,ot.width,ot.height);for(let nt=0;nt<6;nt++){Tt=pt[nt].mipmaps;for(let mt=0;mt<Tt.length;mt++){let Vt=Tt[mt];if(_.format!==Gn)if(Bt!==null)if(I){if(Q)n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+nt,mt,0,0,Vt.width,Vt.height,Bt,Vt.data)}else n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+nt,mt,se,Vt.width,Vt.height,0,Vt.data);else Ht("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()");else if(I){if(Q)n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+nt,mt,0,0,Vt.width,Vt.height,Bt,kt,Vt.data)}else n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+nt,mt,se,Vt.width,Vt.height,0,Bt,kt,Vt.data)}}}else{if(Tt=_.mipmaps,I&&ct){if(Tt.length>0)ut++;let nt=be(pt[0]);n.texStorage2D(t.TEXTURE_CUBE_MAP,ut,se,nt.width,nt.height)}for(let nt=0;nt<6;nt++)if(Dt){if(I){if(Q)n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+nt,0,0,0,pt[nt].width,pt[nt].height,Bt,kt,pt[nt].data)}else n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+nt,0,se,pt[nt].width,pt[nt].height,0,Bt,kt,pt[nt].data);for(let mt=0;mt<Tt.length;mt++){let fe=Tt[mt].image[nt].image;if(I){if(Q)n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+nt,mt+1,0,0,fe.width,fe.height,Bt,kt,fe.data)}else n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+nt,mt+1,se,fe.width,fe.height,0,Bt,kt,fe.data)}}else{if(I){if(Q)n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+nt,0,0,0,Bt,kt,pt[nt])}else n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+nt,0,se,Bt,kt,pt[nt]);for(let mt=0;mt<Tt.length;mt++){let Vt=Tt[mt];if(I){if(Q)n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+nt,mt+1,0,0,Bt,kt,Vt.image[nt])}else n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+nt,mt+1,se,Bt,kt,Vt.image[nt])}}}if(f(_))w(t.TEXTURE_CUBE_MAP);if(st.__version=it.version,_.onUpdate)_.onUpdate(_)}S.__version=_.version}function Ft(S,_,L,V,it,st){let ft=r.convert(L.format,L.colorSpace),J=r.convert(L.type),j=y(L.internalFormat,ft,J,L.normalized,L.colorSpace),_t=i.get(_),Dt=i.get(L);if(Dt.__renderTarget=_,!_t.__hasExternalTextures){let pt=Math.max(1,_.width>>st),ot=Math.max(1,_.height>>st);if(it===t.TEXTURE_3D||it===t.TEXTURE_2D_ARRAY)n.texImage3D(it,st,j,pt,ot,_.depth,0,ft,J,null);else n.texImage2D(it,st,j,pt,ot,0,ft,J,null)}if(n.bindFramebuffer(t.FRAMEBUFFER,S),P(_))o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,V,it,Dt.__webglTexture,0,Re(_));else if(it===t.TEXTURE_2D||it>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&it<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)t.framebufferTexture2D(t.FRAMEBUFFER,V,it,Dt.__webglTexture,st);n.bindFramebuffer(t.FRAMEBUFFER,null)}function Ce(S,_,L){if(t.bindRenderbuffer(t.RENDERBUFFER,S),_.depthBuffer){let V=_.depthTexture,it=V&&V.isDepthTexture?V.type:null,st=b(_.stencilBuffer,it),ft=_.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;if(P(_))o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Re(_),st,_.width,_.height);else if(L)t.renderbufferStorageMultisample(t.RENDERBUFFER,Re(_),st,_.width,_.height);else t.renderbufferStorage(t.RENDERBUFFER,st,_.width,_.height);t.framebufferRenderbuffer(t.FRAMEBUFFER,ft,t.RENDERBUFFER,S)}else{let V=_.textures;for(let it=0;it<V.length;it++){let st=V[it],ft=r.convert(st.format,st.colorSpace),J=r.convert(st.type),j=y(st.internalFormat,ft,J,st.normalized,st.colorSpace);if(P(_))o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Re(_),j,_.width,_.height);else if(L)t.renderbufferStorageMultisample(t.RENDERBUFFER,Re(_),j,_.width,_.height);else t.renderbufferStorage(t.RENDERBUFFER,j,_.width,_.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function $t(S,_,L){let V=_.isWebGLCubeRenderTarget===!0;if(n.bindFramebuffer(t.FRAMEBUFFER,S),!(_.depthTexture&&_.depthTexture.isDepthTexture))throw Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");let it=i.get(_.depthTexture);if(it.__renderTarget=_,!it.__webglTexture||_.depthTexture.image.width!==_.width||_.depthTexture.image.height!==_.height)_.depthTexture.image.width=_.width,_.depthTexture.image.height=_.height,_.depthTexture.needsUpdate=!0;if(V){if(it.__webglInit===void 0)it.__webglInit=!0,_.depthTexture.addEventListener("dispose",E);if(it.__webglTexture===void 0){it.__webglTexture=t.createTexture(),n.bindTexture(t.TEXTURE_CUBE_MAP,it.__webglTexture),zt(t.TEXTURE_CUBE_MAP,_.depthTexture);let _t=r.convert(_.depthTexture.format),Dt=r.convert(_.depthTexture.type),pt;if(_.depthTexture.format===Ri)pt=t.DEPTH_COMPONENT24;else if(_.depthTexture.format===Pi)pt=t.DEPTH24_STENCIL8;for(let ot=0;ot<6;ot++)t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ot,0,pt,_.width,_.height,0,_t,Dt,null)}}else at(_.depthTexture,0);let st=it.__webglTexture,ft=Re(_),J=V?t.TEXTURE_CUBE_MAP_POSITIVE_X+L:t.TEXTURE_2D,j=_.depthTexture.format===Pi?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;if(_.depthTexture.format===Ri)if(P(_))o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,j,J,st,0,ft);else t.framebufferTexture2D(t.FRAMEBUFFER,j,J,st,0);else if(_.depthTexture.format===Pi)if(P(_))o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,j,J,st,0,ft);else t.framebufferTexture2D(t.FRAMEBUFFER,j,J,st,0);else throw Error("THREE.WebGLTextures: Unknown depthTexture format.")}function ee(S){let _=i.get(S),L=S.isWebGLCubeRenderTarget===!0;if(_.__boundDepthTexture!==S.depthTexture){let V=S.depthTexture;if(_.__depthDisposeCallback)_.__depthDisposeCallback();if(V){let it=()=>{delete _.__boundDepthTexture,delete _.__depthDisposeCallback,V.removeEventListener("dispose",it)};V.addEventListener("dispose",it),_.__depthDisposeCallback=it}_.__boundDepthTexture=V}if(S.depthTexture&&!_.__autoAllocateDepthBuffer)if(L)for(let V=0;V<6;V++)$t(_.__webglFramebuffer[V],S,V);else{let V=S.texture.mipmaps;if(V&&V.length>0)$t(_.__webglFramebuffer[0],S,0);else $t(_.__webglFramebuffer,S,0)}else if(L){_.__webglDepthbuffer=[];for(let V=0;V<6;V++)if(n.bindFramebuffer(t.FRAMEBUFFER,_.__webglFramebuffer[V]),_.__webglDepthbuffer[V]===void 0)_.__webglDepthbuffer[V]=t.createRenderbuffer(),Ce(_.__webglDepthbuffer[V],S,!1);else{let it=S.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,st=_.__webglDepthbuffer[V];t.bindRenderbuffer(t.RENDERBUFFER,st),t.framebufferRenderbuffer(t.FRAMEBUFFER,it,t.RENDERBUFFER,st)}}else{let V=S.texture.mipmaps;if(V&&V.length>0)n.bindFramebuffer(t.FRAMEBUFFER,_.__webglFramebuffer[0]);else n.bindFramebuffer(t.FRAMEBUFFER,_.__webglFramebuffer);if(_.__webglDepthbuffer===void 0)_.__webglDepthbuffer=t.createRenderbuffer(),Ce(_.__webglDepthbuffer,S,!1);else{let it=S.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,st=_.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,st),t.framebufferRenderbuffer(t.FRAMEBUFFER,it,t.RENDERBUFFER,st)}}n.bindFramebuffer(t.FRAMEBUFFER,null)}function ue(S,_,L){let V=i.get(S);if(_!==void 0)Ft(V.__webglFramebuffer,S,S.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0);if(L!==void 0)ee(S)}function ne(S){let _=S.texture,L=i.get(S),V=i.get(_);S.addEventListener("dispose",g);let it=S.textures,st=S.isWebGLCubeRenderTarget===!0,ft=it.length>1;if(!ft){if(V.__webglTexture===void 0)V.__webglTexture=t.createTexture();V.__version=_.version,a.memory.textures++}if(st){L.__webglFramebuffer=[];for(let J=0;J<6;J++)if(_.mipmaps&&_.mipmaps.length>0){L.__webglFramebuffer[J]=[];for(let j=0;j<_.mipmaps.length;j++)L.__webglFramebuffer[J][j]=t.createFramebuffer()}else L.__webglFramebuffer[J]=t.createFramebuffer()}else{if(_.mipmaps&&_.mipmaps.length>0){L.__webglFramebuffer=[];for(let J=0;J<_.mipmaps.length;J++)L.__webglFramebuffer[J]=t.createFramebuffer()}else L.__webglFramebuffer=t.createFramebuffer();if(ft)for(let J=0,j=it.length;J<j;J++){let _t=i.get(it[J]);if(_t.__webglTexture===void 0)_t.__webglTexture=t.createTexture(),a.memory.textures++}if(S.samples>0&&P(S)===!1){L.__webglMultisampledFramebuffer=t.createFramebuffer(),L.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,L.__webglMultisampledFramebuffer);for(let J=0;J<it.length;J++){let j=it[J];L.__webglColorRenderbuffer[J]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,L.__webglColorRenderbuffer[J]);let _t=r.convert(j.format,j.colorSpace),Dt=r.convert(j.type),pt=y(j.internalFormat,_t,Dt,j.normalized,j.colorSpace,S.isXRRenderTarget===!0),ot=Re(S);t.renderbufferStorageMultisample(t.RENDERBUFFER,ot,pt,S.width,S.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+J,t.RENDERBUFFER,L.__webglColorRenderbuffer[J])}if(t.bindRenderbuffer(t.RENDERBUFFER,null),S.depthBuffer)L.__webglDepthRenderbuffer=t.createRenderbuffer(),Ce(L.__webglDepthRenderbuffer,S,!0);n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(st){n.bindTexture(t.TEXTURE_CUBE_MAP,V.__webglTexture),zt(t.TEXTURE_CUBE_MAP,_);for(let J=0;J<6;J++)if(_.mipmaps&&_.mipmaps.length>0)for(let j=0;j<_.mipmaps.length;j++)Ft(L.__webglFramebuffer[J][j],S,_,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+J,j);else Ft(L.__webglFramebuffer[J],S,_,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+J,0);if(f(_))w(t.TEXTURE_CUBE_MAP);n.unbindTexture()}else if(ft){for(let J=0,j=it.length;J<j;J++){let _t=it[J],Dt=i.get(_t),pt=t.TEXTURE_2D;if(S.isWebGL3DRenderTarget||S.isWebGLArrayRenderTarget)pt=S.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY;if(n.bindTexture(pt,Dt.__webglTexture),zt(pt,_t),Ft(L.__webglFramebuffer,S,_t,t.COLOR_ATTACHMENT0+J,pt,0),f(_t))w(pt)}n.unbindTexture()}else{let J=t.TEXTURE_2D;if(S.isWebGL3DRenderTarget||S.isWebGLArrayRenderTarget)J=S.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY;if(n.bindTexture(J,V.__webglTexture),zt(J,_),_.mipmaps&&_.mipmaps.length>0)for(let j=0;j<_.mipmaps.length;j++)Ft(L.__webglFramebuffer[j],S,_,t.COLOR_ATTACHMENT0,J,j);else Ft(L.__webglFramebuffer,S,_,t.COLOR_ATTACHMENT0,J,0);if(f(_))w(J);n.unbindTexture()}if(S.depthBuffer)ee(S)}function Le(S){let _=S.textures;for(let L=0,V=_.length;L<V;L++){let it=_[L];if(f(it)){let st=C(S),ft=i.get(it).__webglTexture;n.bindTexture(st,ft),w(st),n.unbindTexture()}}}let me=[],Ze=[];function Ne(S){if(S.samples>0){if(P(S)===!1){let{textures:_,width:L,height:V}=S,it=t.COLOR_BUFFER_BIT,st=S.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,ft=i.get(S),J=_.length>1;if(J)for(let _t=0;_t<_.length;_t++)n.bindFramebuffer(t.FRAMEBUFFER,ft.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+_t,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,ft.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+_t,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,ft.__webglMultisampledFramebuffer);let j=S.texture.mipmaps;if(j&&j.length>0)n.bindFramebuffer(t.DRAW_FRAMEBUFFER,ft.__webglFramebuffer[0]);else n.bindFramebuffer(t.DRAW_FRAMEBUFFER,ft.__webglFramebuffer);for(let _t=0;_t<_.length;_t++){if(S.resolveDepthBuffer){if(S.depthBuffer)it|=t.DEPTH_BUFFER_BIT;if(S.stencilBuffer&&S.resolveStencilBuffer)it|=t.STENCIL_BUFFER_BIT}if(J){t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,ft.__webglColorRenderbuffer[_t]);let Dt=i.get(_[_t]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,Dt,0)}if(t.blitFramebuffer(0,0,L,V,0,0,L,V,it,t.NEAREST),l===!0){if(me.length=0,Ze.length=0,me.push(t.COLOR_ATTACHMENT0+_t),S.depthBuffer&&S.storeMultisampledDepthBuffer===!1)me.push(st),Ze.push(st),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,Ze);t.invalidateFramebuffer(t.READ_FRAMEBUFFER,me)}}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),J)for(let _t=0;_t<_.length;_t++){n.bindFramebuffer(t.FRAMEBUFFER,ft.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+_t,t.RENDERBUFFER,ft.__webglColorRenderbuffer[_t]);let Dt=i.get(_[_t]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,ft.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+_t,t.TEXTURE_2D,Dt,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,ft.__webglMultisampledFramebuffer)}else if(S.depthBuffer&&S.storeMultisampledDepthBuffer===!1&&l){let _=S.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[_])}}}function Re(S){return Math.min(s.maxSamples,S.samples)}function P(S){let _=i.get(S);return S.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&_.__useRenderToTexture!==!1}function Ue(S){let _=a.render.frame;if(u.get(S)!==_)u.set(S,_),S.update()}function ae(S,_){let{colorSpace:L,format:V,type:it}=S;if(S.isCompressedTexture===!0||S.isVideoTexture===!0)return _;if(L!==qo&&L!==Ni)if(re.getTransfer(L)===Me){if(V!==Gn||it!==mn)Ht("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.")}else Gt("WebGLTextures: Unsupported texture color space:",L);return _}function be(S){if(typeof HTMLImageElement<"u"&&S instanceof HTMLImageElement)c.width=S.naturalWidth||S.width,c.height=S.naturalHeight||S.height;else if(typeof VideoFrame<"u"&&S instanceof VideoFrame)c.width=S.displayWidth,c.height=S.displayHeight;else c.width=S.width,c.height=S.height;return c}this.allocateTextureUnit=Z,this.resetTextureUnits=X,this.getTextureUnits=R,this.setTextureUnits=k,this.setTexture2D=at,this.setTexture2DArray=K,this.setTexture3D=et,this.setTextureCube=tt,this.rebindTextures=ue,this.setupRenderTarget=ne,this.updateRenderTargetMipmap=Le,this.updateMultisampleRenderTarget=Ne,this.setupDepthRenderbuffer=ee,this.setupFrameBufferTexture=Ft,this.useMultisampledRTT=P,this.isReversedDepthBuffer=function(){return n.buffers.depth.getReversed()}}function Jg(t,e){function n(i,s=Ni){let r,a=re.getTransfer(s);if(i===mn)return t.UNSIGNED_BYTE;if(i===no)return t.UNSIGNED_SHORT_4_4_4_4;if(i===io)return t.UNSIGNED_SHORT_5_5_5_1;if(i===ih)return t.UNSIGNED_INT_5_9_9_9_REV;if(i===sh)return t.UNSIGNED_INT_10F_11F_11F_REV;if(i===eh)return t.BYTE;if(i===nh)return t.SHORT;if(i===Ws)return t.UNSIGNED_SHORT;if(i===eo)return t.INT;if(i===mi)return t.UNSIGNED_INT;if(i===jn)return t.FLOAT;if(i===kn)return t.HALF_FLOAT;if(i===rh)return t.ALPHA;if(i===ah)return t.RGB;if(i===Gn)return t.RGBA;if(i===Ri)return t.DEPTH_COMPONENT;if(i===Pi)return t.DEPTH_STENCIL;if(i===kr)return t.RED;if(i===ro)return t.RED_INTEGER;if(i===Li)return t.RG;if(i===lo)return t.RG_INTEGER;if(i===co)return t.RGBA_INTEGER;if(i===Gr||i===Hr||i===Vr||i===Wr)if(a===Me)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(i===Gr)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Hr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Vr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===Wr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(i===Gr)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Hr)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Vr)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Wr)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===ho||i===uo||i===fo||i===po)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(i===ho)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===uo)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===fo)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===po)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===mo||i===go||i===_o||i===xo||i===vo||i===Xr||i===yo)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(i===mo||i===go)return a===Me?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(i===_o)return a===Me?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(i===xo)return r.COMPRESSED_R11_EAC;if(i===vo)return r.COMPRESSED_SIGNED_R11_EAC;if(i===Xr)return r.COMPRESSED_RG11_EAC;if(i===yo)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===So||i===Mo||i===bo||i===To||i===wo||i===Eo||i===Ao||i===Co||i===Ro||i===Io||i===Po||i===Lo||i===No||i===Do)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(i===So)return a===Me?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Mo)return a===Me?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===bo)return a===Me?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===To)return a===Me?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===wo)return a===Me?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===Eo)return a===Me?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Ao)return a===Me?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===Co)return a===Me?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Ro)return a===Me?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===Io)return a===Me?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===Po)return a===Me?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===Lo)return a===Me?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===No)return a===Me?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===Do)return a===Me?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===Uo||i===Oo||i===zo)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(i===Uo)return a===Me?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===Oo)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===zo)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===ko||i===Ho||i===qr||i===Vo)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(i===ko)return r.COMPRESSED_RED_RGTC1_EXT;if(i===Ho)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===qr)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===Vo)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;if(i===gs)return t.UNSIGNED_INT_24_8;return t[i]!==void 0?t[i]:null}return{convert:n}}var $g=`
4196
+ }`,Xg=[new O(1,0,0),new O(-1,0,0),new O(0,1,0),new O(0,-1,0),new O(0,0,1),new O(0,0,-1)],qg=[new O(0,-1,0),new O(0,-1,0),new O(0,0,1),new O(0,0,-1),new O(0,-1,0),new O(0,-1,0)],qh=new we,cr=new O,Rl=new O;function Yg(t,e,n){let i=new ar,s=new qt,r=new qt,a=new Ae,o=new rl,l=new al,c={},u=n.maxTextureSize,d={[xs]:Ve,[Ve]:xs,[sn]:sn},h=new bn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new qt},radius:{value:4}},vertexShader:Vg,fragmentShader:Wg}),p=h.clone();p.defines.HORIZONTAL_PASS=1;let v=new _n;v.setAttribute("position",new Mn(new Float32Array([-1,-1,0.5,3,-1,0.5,-1,3,0.5]),3));let T=new Jt(v,h),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Xs;let f=this.type;this.render=function(A,E,g){if(m.enabled===!1)return;if(m.autoUpdate===!1&&m.needsUpdate===!1)return;if(A.length===0)return;if(this.type===bc)Vt("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=Xs;let M=t.getRenderTarget(),G=t.getActiveCubeFace(),N=t.getActiveMipmapLevel(),F=t.state;if(F.setBlending(On),F.buffers.depth.getReversed()===!0)F.buffers.color.setClear(0,0,0,0);else F.buffers.color.setClear(1,1,1,1);F.buffers.depth.setTest(!0),F.setScissorTest(!1);let X=f!==this.type;if(X)E.traverse(function(R){if(R.material)if(Array.isArray(R.material))R.material.forEach((k)=>k.needsUpdate=!0);else R.material.needsUpdate=!0});for(let R=0,k=A.length;R<k;R++){let Z=A[R],H=Z.shadow;if(H===void 0){Vt("WebGLShadowMap:",Z,"has no shadow.");continue}if(H.autoUpdate===!1&&H.needsUpdate===!1)continue;s.copy(H.mapSize);let at=H.getFrameExtents();if(s.multiply(at),r.copy(H.mapSize),s.x>u||s.y>u){if(s.x>u)r.x=Math.floor(u/at.x),s.x=r.x*at.x,H.mapSize.x=r.x;if(s.y>u)r.y=Math.floor(u/at.y),s.y=r.y*at.y,H.mapSize.y=r.y}let K=t.state.buffers.depth.getReversed();if(H.camera._reversedDepth=K,H.map===null||X===!0){if(H.map!==null){if(H.map.depthTexture!==null)H.map.depthTexture.dispose(),H.map.depthTexture=null;H.map.dispose()}if(this.type===_s){if(Z.isPointLight){Vt("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}H.map=new gn(s.x,s.y,{format:Pi,type:kn,minFilter:Qe,magFilter:Qe,generateMipmaps:!1}),H.map.texture.name=Z.name+".shadowMap",H.map.depthTexture=new Ui(s.x,s.y,jn),H.map.depthTexture.name=Z.name+".shadowMapDepth",H.map.depthTexture.format=Ri,H.map.depthTexture.compareFunction=null,H.map.depthTexture.minFilter=Ln,H.map.depthTexture.magFilter=Ln}else{if(Z.isPointLight)H.map=new Nl(s.x),H.map.depthTexture=new nl(s.x,mi);else H.map=new gn(s.x,s.y),H.map.depthTexture=new Ui(s.x,s.y,mi);if(H.map.depthTexture.name=Z.name+".shadowMap",H.map.depthTexture.format=Ri,this.type===Xs)H.map.depthTexture.compareFunction=K?ta:jr,H.map.depthTexture.minFilter=Qe,H.map.depthTexture.magFilter=Qe;else H.map.depthTexture.compareFunction=null,H.map.depthTexture.minFilter=Ln,H.map.depthTexture.magFilter=Ln}H.camera.updateProjectionMatrix()}if(H.map.isWebGLCubeRenderTarget!==!0&&(H.map.width!==s.x||H.map.height!==s.y))H.map.setSize(s.x,s.y);let et=H.map.isWebGLCubeRenderTarget?6:H.getViewportCount();if(Z.isPointLight!==!0)H.updateMatrices(Z,g);for(let tt=0;tt<et;tt++){let dt=H.getCamera(tt);if(Z.isPointLight){let{camera:At,matrix:te}=H,Bt=Z.distance||At.far;if(Bt!==At.far)At.far=Bt,At.updateProjectionMatrix();cr.setFromMatrixPosition(Z.matrixWorld),At.position.copy(cr),Rl.copy(At.position),Rl.add(Xg[tt]),At.up.copy(qg[tt]),At.lookAt(Rl),At.updateMatrixWorld(),te.makeTranslation(-cr.x,-cr.y,-cr.z),qh.multiplyMatrices(At.projectionMatrix,At.matrixWorldInverse),H._frustum.setFromProjectionMatrix(qh,At.coordinateSystem,At.reversedDepth)}if(H.map.isWebGLCubeRenderTarget)t.setRenderTarget(H.map,tt),t.clear();else{if(tt===0)t.setRenderTarget(H.map),t.clear();let At=H.getViewport(tt);a.set(r.x*At.x,r.y*At.y,r.x*At.z,r.y*At.w),F.viewport(a)}i=H.getFrustum(tt),y(E,g,dt,Z,this.type)}if(H.isPointLightShadow!==!0&&this.type===_s)w(H,g);H.needsUpdate=!1}f=this.type,m.needsUpdate=!1,t.setRenderTarget(M,G,N)};function w(A,E){let g=e.update(T);if(h.defines.VSM_SAMPLES!==A.blurSamples)h.defines.VSM_SAMPLES=A.blurSamples,p.defines.VSM_SAMPLES=A.blurSamples,h.needsUpdate=!0,p.needsUpdate=!0;if(A.mapPass===null)A.mapPass=new gn(s.x,s.y,{format:Pi,type:kn});else if(A.mapPass.width!==A.map.width||A.mapPass.height!==A.map.height)A.mapPass.setSize(A.map.width,A.map.height);h.uniforms.shadow_pass.value=A.map.depthTexture,h.uniforms.resolution.value.set(A.map.width,A.map.height),h.uniforms.radius.value=A.radius,t.setRenderTarget(A.mapPass),t.clear(),t.renderBufferDirect(E,null,g,h,T,null),p.uniforms.shadow_pass.value=A.mapPass.texture,p.uniforms.resolution.value.set(A.map.width,A.map.height),p.uniforms.radius.value=A.radius,t.setRenderTarget(A.map),t.clear(),t.renderBufferDirect(E,null,g,p,T,null)}function C(A,E,g,M){let G=null,N=g.isPointLight===!0?A.customDistanceMaterial:A.customDepthMaterial;if(N!==void 0)G=N;else if(G=g.isPointLight===!0?l:o,t.localClippingEnabled&&E.clipShadows===!0&&Array.isArray(E.clippingPlanes)&&E.clippingPlanes.length!==0||E.displacementMap&&E.displacementScale!==0||E.alphaMap&&E.alphaTest>0||E.map&&E.alphaTest>0||E.alphaToCoverage===!0){let F=G.uuid,X=E.uuid,R=c[F];if(R===void 0)R={},c[F]=R;let k=R[X];if(k===void 0)k=G.clone(),R[X]=k,E.addEventListener("dispose",b);G=k}if(G.visible=E.visible,G.wireframe=E.wireframe,M===_s)G.side=E.shadowSide!==null?E.shadowSide:E.side;else G.side=E.shadowSide!==null?E.shadowSide:d[E.side];if(G.alphaMap=E.alphaMap,G.alphaTest=E.alphaToCoverage===!0?0.5:E.alphaTest,G.map=E.map,G.clipShadows=E.clipShadows,G.clippingPlanes=E.clippingPlanes,G.clipIntersection=E.clipIntersection,G.displacementMap=E.displacementMap,G.displacementScale=E.displacementScale,G.displacementBias=E.displacementBias,G.wireframeLinewidth=E.wireframeLinewidth,G.linewidth=E.linewidth,g.isPointLight===!0&&G.isMeshDistanceMaterial===!0){let F=t.properties.get(G);F.light=g}return G}function y(A,E,g,M,G){if(A.visible===!1)return;if(A.layers.test(E.layers)&&(A.isMesh||A.isLine||A.isPoints)){if((A.castShadow||A.receiveShadow&&G===_s)&&(!A.frustumCulled||A.intersectsFrustum(i))){A.modelViewMatrix.multiplyMatrices(g.matrixWorldInverse,A.matrixWorld);let X=e.update(A),R=A.material;if(Array.isArray(R)){let k=X.groups;for(let Z=0,H=k.length;Z<H;Z++){let at=k[Z],K=R[at.materialIndex];if(K&&K.visible){let et=C(A,K,M,G);A.onBeforeShadow(t,A,E,g,X,et,at),t.renderBufferDirect(g,null,X,et,A,at),A.onAfterShadow(t,A,E,g,X,et,at)}}}else if(R.visible){let k=C(A,R,M,G);A.onBeforeShadow(t,A,E,g,X,k,null),t.renderBufferDirect(g,null,X,k,A,null),A.onAfterShadow(t,A,E,g,X,k,null)}}}let F=A.children;for(let X=0,R=F.length;X<R;X++)y(F[X],E,g,M,G)}function b(A){A.target.removeEventListener("dispose",b);for(let g in c){let M=c[g],G=A.target.uuid;if(G in M)M[G].dispose(),delete M[G]}}}function Zg(t,e){function n(){let I=!1,ct=new Ae,Q=null,ut=new Ae(0,0,0,0);return{setMask:function(Tt){if(Q!==Tt&&!I)t.colorMask(Tt,Tt,Tt,Tt),Q=Tt},setLocked:function(Tt){I=Tt},setClear:function(Tt,nt,mt,Wt,fe){if(fe===!0)Tt*=Wt,nt*=Wt,mt*=Wt;if(ct.set(Tt,nt,mt,Wt),ut.equals(ct)===!1)t.clearColor(Tt,nt,mt,Wt),ut.copy(ct)},reset:function(){I=!1,Q=null,ut.set(-1,0,0,0)}}}function i(){let I=!1,ct=!1,Q=null,ut=null,Tt=null;return{setReversed:function(nt){if(ct!==nt){let mt=e.get("EXT_clip_control");if(nt)mt.clipControlEXT(mt.LOWER_LEFT_EXT,mt.ZERO_TO_ONE_EXT);else mt.clipControlEXT(mt.LOWER_LEFT_EXT,mt.NEGATIVE_ONE_TO_ONE_EXT);ct=nt;let Wt=Tt;Tt=null,this.setClear(Wt)}},getReversed:function(){return ct},setTest:function(nt){if(nt)lt(t.DEPTH_TEST);else It(t.DEPTH_TEST)},setMask:function(nt){if(Q!==nt&&!I)t.depthMask(nt),Q=nt},setFunc:function(nt){if(ct)nt=xh[nt];if(ut!==nt){switch(nt){case Wc:t.depthFunc(t.NEVER);break;case Xc:t.depthFunc(t.ALWAYS);break;case qc:t.depthFunc(t.LESS);break;case ja:t.depthFunc(t.LEQUAL);break;case Yc:t.depthFunc(t.EQUAL);break;case Zc:t.depthFunc(t.GEQUAL);break;case Jc:t.depthFunc(t.GREATER);break;case $c:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}ut=nt}},setLocked:function(nt){I=nt},setClear:function(nt){if(Tt!==nt){if(Tt=nt,ct)nt=1-nt;t.clearDepth(nt)}},reset:function(){I=!1,Q=null,ut=null,Tt=null,ct=!1}}}function s(){let I=!1,ct=null,Q=null,ut=null,Tt=null,nt=null,mt=null,Wt=null,fe=null;return{setTest:function(ce){if(!I)if(ce)lt(t.STENCIL_TEST);else It(t.STENCIL_TEST)},setMask:function(ce){if(ct!==ce&&!I)t.stencilMask(ce),ct=ce},setFunc:function(ce,cn,vn){if(Q!==ce||ut!==cn||Tt!==vn)t.stencilFunc(ce,cn,vn),Q=ce,ut=cn,Tt=vn},setOp:function(ce,cn,vn){if(nt!==ce||mt!==cn||Wt!==vn)t.stencilOp(ce,cn,vn),nt=ce,mt=cn,Wt=vn},setLocked:function(ce){I=ce},setClear:function(ce){if(fe!==ce)t.clearStencil(ce),fe=ce},reset:function(){I=!1,ct=null,Q=null,ut=null,Tt=null,nt=null,mt=null,Wt=null,fe=null}}}let r=new n,a=new i,o=new s,l=new WeakMap,c=new WeakMap,u={},d={},h={},p=new WeakMap,v=[],T=null,m=!1,f=null,w=null,C=null,y=null,b=null,A=null,E=null,g=new Kt(0,0,0),M=0,G=!1,N=null,F=null,X=null,R=null,k=null,Z=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS),H=!1,at=0,K=t.getParameter(t.VERSION);if(K.indexOf("WebGL")!==-1)at=parseFloat(/^WebGL (\d)/.exec(K)[1]),H=at>=1;else if(K.indexOf("OpenGL ES")!==-1)at=parseFloat(/^OpenGL ES (\d)/.exec(K)[1]),H=at>=2;let et=null,tt={},dt=t.getParameter(t.SCISSOR_BOX),At=t.getParameter(t.VIEWPORT),te=new Ae().fromArray(dt),Bt=new Ae().fromArray(At);function Y(I,ct,Q,ut){let Tt=new Uint8Array(4),nt=t.createTexture();t.bindTexture(I,nt),t.texParameteri(I,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(I,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let mt=0;mt<Q;mt++)if(I===t.TEXTURE_3D||I===t.TEXTURE_2D_ARRAY)t.texImage3D(ct,0,t.RGBA,1,1,ut,0,t.RGBA,t.UNSIGNED_BYTE,Tt);else t.texImage2D(ct+mt,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,Tt);return nt}let rt={};rt[t.TEXTURE_2D]=Y(t.TEXTURE_2D,t.TEXTURE_2D,1),rt[t.TEXTURE_CUBE_MAP]=Y(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),rt[t.TEXTURE_2D_ARRAY]=Y(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),rt[t.TEXTURE_3D]=Y(t.TEXTURE_3D,t.TEXTURE_3D,1,1),r.setClear(0,0,0,1),a.setClear(1),o.setClear(0),lt(t.DEPTH_TEST),a.setFunc(ja),Le(!1),me($a),lt(t.CULL_FACE),ue(On);function lt(I){if(u[I]!==!0)t.enable(I),u[I]=!0}function It(I){if(u[I]!==!1)t.disable(I),u[I]=!1}function Ft(I,ct){if(h[I]!==ct){if(t.bindFramebuffer(I,ct),h[I]=ct,I===t.DRAW_FRAMEBUFFER)h[t.FRAMEBUFFER]=ct;if(I===t.FRAMEBUFFER)h[t.DRAW_FRAMEBUFFER]=ct;return!0}return!1}function Ut(I,ct){let Q=v,ut=!1;if(I){if(Q=p.get(ct),Q===void 0)Q=[],p.set(ct,Q);let Tt=I.textures;if(Q.length!==Tt.length||Q[0]!==t.COLOR_ATTACHMENT0){for(let nt=0,mt=Tt.length;nt<mt;nt++)Q[nt]=t.COLOR_ATTACHMENT0+nt;Q.length=Tt.length,ut=!0}}else if(Q[0]!==t.BACK)Q[0]=t.BACK,ut=!0;if(ut)t.drawBuffers(Q)}function Ce(I){if(T!==I)return t.useProgram(I),T=I,!0;return!1}let $t={[vs]:t.FUNC_ADD,[wc]:t.FUNC_SUBTRACT,[Ec]:t.FUNC_REVERSE_SUBTRACT};$t[Ac]=t.MIN,$t[Cc]=t.MAX;let ee={[Rc]:t.ZERO,[Ic]:t.ONE,[Pc]:t.SRC_COLOR,[Nc]:t.SRC_ALPHA,[zc]:t.SRC_ALPHA_SATURATE,[Oc]:t.DST_COLOR,[Uc]:t.DST_ALPHA,[Lc]:t.ONE_MINUS_SRC_COLOR,[Dc]:t.ONE_MINUS_SRC_ALPHA,[Bc]:t.ONE_MINUS_DST_COLOR,[Fc]:t.ONE_MINUS_DST_ALPHA,[kc]:t.CONSTANT_COLOR,[Gc]:t.ONE_MINUS_CONSTANT_COLOR,[Hc]:t.CONSTANT_ALPHA,[Vc]:t.ONE_MINUS_CONSTANT_ALPHA};function ue(I,ct,Q,ut,Tt,nt,mt,Wt,fe,ce){if(I===On){if(m===!0)It(t.BLEND),m=!1;return}if(m===!1)lt(t.BLEND),m=!0;if(I!==Tc){if(I!==f||ce!==G){if(w!==vs||b!==vs)t.blendEquation(t.FUNC_ADD),w=vs,b=vs;if(ce)switch(I){case In:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case Qn:t.blendFunc(t.ONE,t.ONE);break;case Ka:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case Qa:t.blendFuncSeparate(t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA,t.ZERO,t.ONE);break;default:Ht("WebGLState: Invalid blending: ",I);break}else switch(I){case In:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case Qn:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE);break;case Ka:Ht("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Qa:Ht("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Ht("WebGLState: Invalid blending: ",I);break}C=null,y=null,A=null,E=null,g.set(0,0,0),M=0,f=I,G=ce}return}if(Tt=Tt||ct,nt=nt||Q,mt=mt||ut,ct!==w||Tt!==b)t.blendEquationSeparate($t[ct],$t[Tt]),w=ct,b=Tt;if(Q!==C||ut!==y||nt!==A||mt!==E)t.blendFuncSeparate(ee[Q],ee[ut],ee[nt],ee[mt]),C=Q,y=ut,A=nt,E=mt;if(Wt.equals(g)===!1||fe!==M)t.blendColor(Wt.r,Wt.g,Wt.b,fe),g.copy(Wt),M=fe;f=I,G=!1}function ne(I,ct){I.side===sn?It(t.CULL_FACE):lt(t.CULL_FACE);let Q=I.side===Ve;if(ct)Q=!Q;Le(Q),I.blending===In&&I.transparent===!1?ue(On):ue(I.blending,I.blendEquation,I.blendSrc,I.blendDst,I.blendEquationAlpha,I.blendSrcAlpha,I.blendDstAlpha,I.blendColor,I.blendAlpha,I.premultipliedAlpha),a.setFunc(I.depthFunc),a.setTest(I.depthTest),a.setMask(I.depthWrite),r.setMask(I.colorWrite);let ut=I.stencilWrite;if(o.setTest(ut),ut)o.setMask(I.stencilWriteMask),o.setFunc(I.stencilFunc,I.stencilRef,I.stencilFuncMask),o.setOp(I.stencilFail,I.stencilZFail,I.stencilZPass);Ne(I.polygonOffset,I.polygonOffsetFactor,I.polygonOffsetUnits),I.alphaToCoverage===!0?lt(t.SAMPLE_ALPHA_TO_COVERAGE):It(t.SAMPLE_ALPHA_TO_COVERAGE)}function Le(I){if(N!==I){if(I)t.frontFace(t.CW);else t.frontFace(t.CCW);N=I}}function me(I){if(I!==Sc){if(lt(t.CULL_FACE),I!==F)if(I===$a)t.cullFace(t.BACK);else if(I===Mc)t.cullFace(t.FRONT);else t.cullFace(t.FRONT_AND_BACK)}else It(t.CULL_FACE);F=I}function Ze(I){if(I!==X){if(H)t.lineWidth(I);X=I}}function Ne(I,ct,Q){if(I){if(lt(t.POLYGON_OFFSET_FILL),R!==ct||k!==Q){if(R=ct,k=Q,a.getReversed())ct=-ct;t.polygonOffset(ct,Q)}}else It(t.POLYGON_OFFSET_FILL)}function Re(I){if(I)lt(t.SCISSOR_TEST);else It(t.SCISSOR_TEST)}function P(I){if(I===void 0)I=t.TEXTURE0+Z-1;if(et!==I)t.activeTexture(I),et=I}function Ue(I,ct,Q){if(Q===void 0)if(et===null)Q=t.TEXTURE0+Z-1;else Q=et;let ut=tt[Q];if(ut===void 0)ut={type:void 0,texture:void 0},tt[Q]=ut;if(ut.type!==I||ut.texture!==ct){if(et!==Q)t.activeTexture(Q),et=Q;t.bindTexture(I,ct||rt[I]),ut.type=I,ut.texture=ct}}function ae(){let I=tt[et];if(I!==void 0&&I.type!==void 0)t.bindTexture(I.type,null),I.type=void 0,I.texture=void 0}function be(){try{t.compressedTexImage2D(...arguments)}catch(I){Ht("WebGLState:",I)}}function S(){try{t.compressedTexImage3D(...arguments)}catch(I){Ht("WebGLState:",I)}}function _(){try{t.texSubImage2D(...arguments)}catch(I){Ht("WebGLState:",I)}}function L(){try{t.texSubImage3D(...arguments)}catch(I){Ht("WebGLState:",I)}}function V(){try{t.compressedTexSubImage2D(...arguments)}catch(I){Ht("WebGLState:",I)}}function it(){try{t.compressedTexSubImage3D(...arguments)}catch(I){Ht("WebGLState:",I)}}function st(){try{t.texStorage2D(...arguments)}catch(I){Ht("WebGLState:",I)}}function ft(){try{t.texStorage3D(...arguments)}catch(I){Ht("WebGLState:",I)}}function J(){try{t.texImage2D(...arguments)}catch(I){Ht("WebGLState:",I)}}function j(){try{t.texImage3D(...arguments)}catch(I){Ht("WebGLState:",I)}}function _t(I){if(d[I]!==void 0)return d[I];else return t.getParameter(I)}function Nt(I,ct){if(d[I]!==ct)t.pixelStorei(I,ct),d[I]=ct}function pt(I){if(te.equals(I)===!1)t.scissor(I.x,I.y,I.z,I.w),te.copy(I)}function ot(I){if(Bt.equals(I)===!1)t.viewport(I.x,I.y,I.z,I.w),Bt.copy(I)}function Ot(I,ct){let Q=c.get(ct);if(Q===void 0)Q=new WeakMap,c.set(ct,Q);let ut=Q.get(I);if(ut===void 0)ut=t.getUniformBlockIndex(ct,I.name),Q.set(I,ut)}function kt(I,ct){let ut=c.get(ct).get(I);if(l.get(ct)!==ut)t.uniformBlockBinding(ct,ut,I.__bindingPointIndex),l.set(ct,ut)}function se(){t.disable(t.BLEND),t.disable(t.CULL_FACE),t.disable(t.DEPTH_TEST),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SCISSOR_TEST),t.disable(t.STENCIL_TEST),t.disable(t.SAMPLE_ALPHA_TO_COVERAGE),t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ZERO),t.blendFuncSeparate(t.ONE,t.ZERO,t.ONE,t.ZERO),t.blendColor(0,0,0,0),t.colorMask(!0,!0,!0,!0),t.clearColor(0,0,0,0),t.depthMask(!0),t.depthFunc(t.LESS),a.setReversed(!1),t.clearDepth(1),t.stencilMask(4294967295),t.stencilFunc(t.ALWAYS,0,4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP),t.clearStencil(0),t.cullFace(t.BACK),t.frontFace(t.CCW),t.polygonOffset(0,0),t.activeTexture(t.TEXTURE0),t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),t.bindFramebuffer(t.READ_FRAMEBUFFER,null),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.canvas.height),t.pixelStorei(t.PACK_ALIGNMENT,4),t.pixelStorei(t.UNPACK_ALIGNMENT,4),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,!1),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,t.BROWSER_DEFAULT_WEBGL),t.pixelStorei(t.PACK_ROW_LENGTH,0),t.pixelStorei(t.PACK_SKIP_PIXELS,0),t.pixelStorei(t.PACK_SKIP_ROWS,0),t.pixelStorei(t.UNPACK_ROW_LENGTH,0),t.pixelStorei(t.UNPACK_IMAGE_HEIGHT,0),t.pixelStorei(t.UNPACK_SKIP_PIXELS,0),t.pixelStorei(t.UNPACK_SKIP_ROWS,0),t.pixelStorei(t.UNPACK_SKIP_IMAGES,0),u={},d={},et=null,tt={},h={},p=new WeakMap,v=[],T=null,m=!1,f=null,w=null,C=null,y=null,b=null,A=null,E=null,g=new Kt(0,0,0),M=0,G=!1,N=null,F=null,X=null,R=null,k=null,te.set(0,0,t.canvas.width,t.canvas.height),Bt.set(0,0,t.canvas.width,t.canvas.height),r.reset(),a.reset(),o.reset()}return{buffers:{color:r,depth:a,stencil:o},enable:lt,disable:It,bindFramebuffer:Ft,drawBuffers:Ut,useProgram:Ce,setBlending:ue,setMaterial:ne,setFlipSided:Le,setCullFace:me,setLineWidth:Ze,setPolygonOffset:Ne,setScissorTest:Re,activeTexture:P,bindTexture:Ue,unbindTexture:ae,compressedTexImage2D:be,compressedTexImage3D:S,texImage2D:J,texImage3D:j,pixelStorei:Nt,getParameter:_t,updateUBOMapping:Ot,uniformBlockBinding:kt,texStorage2D:st,texStorage3D:ft,texSubImage2D:_,texSubImage3D:L,compressedTexSubImage2D:V,compressedTexSubImage3D:it,scissor:pt,viewport:ot,reset:se}}function Jg(t,e,n,i,s,r,a){let o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new qt,u=new WeakMap,d=new Set,h,p=new WeakMap,v=!1;try{v=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch(S){}function T(S,_){return v?new OffscreenCanvas(S,_):zs("canvas")}function m(S,_,L){let V=1,it=be(S);if(it.width>L||it.height>L)V=L/Math.max(it.width,it.height);if(V<1)if(typeof HTMLImageElement<"u"&&S instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&S instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&S instanceof ImageBitmap||typeof VideoFrame<"u"&&S instanceof VideoFrame){let st=Math.floor(V*it.width),ft=Math.floor(V*it.height);if(h===void 0)h=T(st,ft);let J=_?T(st,ft):h;return J.width=st,J.height=ft,J.getContext("2d").drawImage(S,0,0,st,ft),Vt("WebGLRenderer: Texture has been resized from ("+it.width+"x"+it.height+") to ("+st+"x"+ft+")."),J}else{if("data"in S)Vt("WebGLRenderer: Image in DataTexture is too big ("+it.width+"x"+it.height+").");return S}return S}function f(S){return S.generateMipmaps}function w(S){t.generateMipmap(S)}function C(S){if(S.isWebGLCubeRenderTarget)return t.TEXTURE_CUBE_MAP;if(S.isWebGL3DRenderTarget)return t.TEXTURE_3D;if(S.isWebGLArrayRenderTarget||S.isCompressedArrayTexture)return t.TEXTURE_2D_ARRAY;return t.TEXTURE_2D}function y(S,_,L,V,it,st=!1){if(S!==null){if(t[S]!==void 0)return t[S];Vt("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+S+"'")}let ft;if(V){if(ft=e.get("EXT_texture_norm16"),!ft)Vt("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension")}let J=_;if(_===t.RED){if(L===t.FLOAT)J=t.R32F;if(L===t.HALF_FLOAT)J=t.R16F;if(L===t.UNSIGNED_BYTE)J=t.R8;if(L===t.UNSIGNED_SHORT&&ft)J=ft.R16_EXT;if(L===t.SHORT&&ft)J=ft.R16_SNORM_EXT}if(_===t.RED_INTEGER){if(L===t.UNSIGNED_BYTE)J=t.R8UI;if(L===t.UNSIGNED_SHORT)J=t.R16UI;if(L===t.UNSIGNED_INT)J=t.R32UI;if(L===t.BYTE)J=t.R8I;if(L===t.SHORT)J=t.R16I;if(L===t.INT)J=t.R32I}if(_===t.RG){if(L===t.FLOAT)J=t.RG32F;if(L===t.HALF_FLOAT)J=t.RG16F;if(L===t.UNSIGNED_BYTE)J=t.RG8;if(L===t.UNSIGNED_SHORT&&ft)J=ft.RG16_EXT;if(L===t.SHORT&&ft)J=ft.RG16_SNORM_EXT}if(_===t.RG_INTEGER){if(L===t.UNSIGNED_BYTE)J=t.RG8UI;if(L===t.UNSIGNED_SHORT)J=t.RG16UI;if(L===t.UNSIGNED_INT)J=t.RG32UI;if(L===t.BYTE)J=t.RG8I;if(L===t.SHORT)J=t.RG16I;if(L===t.INT)J=t.RG32I}if(_===t.RGB_INTEGER){if(L===t.UNSIGNED_BYTE)J=t.RGB8UI;if(L===t.UNSIGNED_SHORT)J=t.RGB16UI;if(L===t.UNSIGNED_INT)J=t.RGB32UI;if(L===t.BYTE)J=t.RGB8I;if(L===t.SHORT)J=t.RGB16I;if(L===t.INT)J=t.RGB32I}if(_===t.RGBA_INTEGER){if(L===t.UNSIGNED_BYTE)J=t.RGBA8UI;if(L===t.UNSIGNED_SHORT)J=t.RGBA16UI;if(L===t.UNSIGNED_INT)J=t.RGBA32UI;if(L===t.BYTE)J=t.RGBA8I;if(L===t.SHORT)J=t.RGBA16I;if(L===t.INT)J=t.RGBA32I}if(_===t.RGB){if(L===t.UNSIGNED_SHORT&&ft)J=ft.RGB16_EXT;if(L===t.SHORT&&ft)J=ft.RGB16_SNORM_EXT;if(L===t.UNSIGNED_INT_5_9_9_9_REV)J=t.RGB9_E5;if(L===t.UNSIGNED_INT_10F_11F_11F_REV)J=t.R11F_G11F_B10F}if(_===t.RGBA){let j=st?Jo:re.getTransfer(it);if(L===t.FLOAT)J=t.RGBA32F;if(L===t.HALF_FLOAT)J=t.RGBA16F;if(L===t.UNSIGNED_BYTE)J=j===Me?t.SRGB8_ALPHA8:t.RGBA8;if(L===t.UNSIGNED_SHORT&&ft)J=ft.RGBA16_EXT;if(L===t.SHORT&&ft)J=ft.RGBA16_SNORM_EXT;if(L===t.UNSIGNED_SHORT_4_4_4_4)J=t.RGBA4;if(L===t.UNSIGNED_SHORT_5_5_5_1)J=t.RGB5_A1}if(J===t.R16F||J===t.R32F||J===t.RG16F||J===t.RG32F||J===t.RGBA16F||J===t.RGBA32F)e.get("EXT_color_buffer_float");return J}function b(S,_){let L;if(S){if(_===null||_===mi||_===Ss)L=t.DEPTH24_STENCIL8;else if(_===jn)L=t.DEPTH32F_STENCIL8;else if(_===Qs)L=t.DEPTH24_STENCIL8,Vt("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")}else if(_===null||_===mi||_===Ss)L=t.DEPTH_COMPONENT24;else if(_===jn)L=t.DEPTH_COMPONENT32F;else if(_===Qs)L=t.DEPTH_COMPONENT16;return L}function A(S,_){if(f(S)===!0||S.isFramebufferTexture&&S.minFilter!==Ln&&S.minFilter!==Qe)return Math.log2(Math.max(_.width,_.height))+1;else if(S.mipmaps!==void 0&&S.mipmaps.length>0)return S.mipmaps.length;else if(S.isCompressedTexture&&Array.isArray(S.image))return _.mipmaps.length;else return 1}function E(S){let _=S.target;if(_.removeEventListener("dispose",E),M(_),_.isVideoTexture)u.delete(_);if(_.isHTMLTexture)d.delete(_)}function g(S){let _=S.target;_.removeEventListener("dispose",g),N(_)}function M(S){let _=i.get(S);if(_.__webglInit===void 0)return;let L=S.source,V=p.get(L);if(V){let it=V[_.__cacheKey];if(it.usedTimes--,it.usedTimes===0)G(S);if(Object.keys(V).length===0)p.delete(L)}i.remove(S)}function G(S){let _=i.get(S);t.deleteTexture(_.__webglTexture);let L=S.source,V=p.get(L);delete V[_.__cacheKey],a.memory.textures--}function N(S){let _=i.get(S);if(S.depthTexture)S.depthTexture.dispose(),i.remove(S.depthTexture);if(S.isWebGLCubeRenderTarget)for(let V=0;V<6;V++){if(Array.isArray(_.__webglFramebuffer[V]))for(let it=0;it<_.__webglFramebuffer[V].length;it++)t.deleteFramebuffer(_.__webglFramebuffer[V][it]);else t.deleteFramebuffer(_.__webglFramebuffer[V]);if(_.__webglDepthbuffer)t.deleteRenderbuffer(_.__webglDepthbuffer[V])}else{if(Array.isArray(_.__webglFramebuffer))for(let V=0;V<_.__webglFramebuffer.length;V++)t.deleteFramebuffer(_.__webglFramebuffer[V]);else t.deleteFramebuffer(_.__webglFramebuffer);if(_.__webglDepthbuffer)t.deleteRenderbuffer(_.__webglDepthbuffer);if(_.__webglMultisampledFramebuffer)t.deleteFramebuffer(_.__webglMultisampledFramebuffer);if(_.__webglColorRenderbuffer){for(let V=0;V<_.__webglColorRenderbuffer.length;V++)if(_.__webglColorRenderbuffer[V])t.deleteRenderbuffer(_.__webglColorRenderbuffer[V])}if(_.__webglDepthRenderbuffer)t.deleteRenderbuffer(_.__webglDepthRenderbuffer)}let L=S.textures;for(let V=0,it=L.length;V<it;V++){let st=i.get(L[V]);if(st.__webglTexture)t.deleteTexture(st.__webglTexture),a.memory.textures--;i.remove(L[V])}i.remove(S)}let F=0;function X(){F=0}function R(){return F}function k(S){F=S}function Z(){let S=F;if(S>=s.maxTextures)Vt("WebGLTextures: Trying to use "+(S+1)+" texture units while this GPU supports only "+s.maxTextures);return F+=1,S}function H(S){let _=[];return _.push(S.wrapS),_.push(S.wrapT),_.push(S.wrapR||0),_.push(S.magFilter),_.push(S.minFilter),_.push(S.anisotropy),_.push(S.internalFormat),_.push(S.format),_.push(S.type),_.push(S.generateMipmaps),_.push(S.premultiplyAlpha),_.push(S.flipY),_.push(S.unpackAlignment),_.push(S.colorSpace),_.join()}function at(S,_){let L=i.get(S);if(S.isVideoTexture)Ue(S);if(S.isRenderTargetTexture===!1&&S.isExternalTexture!==!0&&S.version>0&&L.__version!==S.version){let V=S.image;if(V===null)Vt("WebGLRenderer: Texture marked for update but no image data found.");else if(V.complete===!1)Vt("WebGLRenderer: Texture marked for update but image is incomplete");else{It(L,S,_);return}}else if(S.isExternalTexture)L.__webglTexture=S.sourceTexture?S.sourceTexture:null;n.bindTexture(t.TEXTURE_2D,L.__webglTexture,t.TEXTURE0+_)}function K(S,_){let L=i.get(S);if(S.isRenderTargetTexture===!1&&S.version>0&&L.__version!==S.version){It(L,S,_);return}else if(S.isExternalTexture)L.__webglTexture=S.sourceTexture?S.sourceTexture:null;n.bindTexture(t.TEXTURE_2D_ARRAY,L.__webglTexture,t.TEXTURE0+_)}function et(S,_){let L=i.get(S);if(S.isRenderTargetTexture===!1&&S.version>0&&L.__version!==S.version){It(L,S,_);return}n.bindTexture(t.TEXTURE_3D,L.__webglTexture,t.TEXTURE0+_)}function tt(S,_){let L=i.get(S);if(S.isCubeDepthTexture!==!0&&S.version>0&&L.__version!==S.version){Ft(L,S,_);return}n.bindTexture(t.TEXTURE_CUBE_MAP,L.__webglTexture,t.TEXTURE0+_)}let dt={[$s]:t.REPEAT,[Bn]:t.CLAMP_TO_EDGE,[th]:t.MIRRORED_REPEAT},At={[Ln]:t.NEAREST,[eh]:t.NEAREST_MIPMAP_NEAREST,[Ks]:t.NEAREST_MIPMAP_LINEAR,[Qe]:t.LINEAR,[Xr]:t.LINEAR_MIPMAP_NEAREST,[Ci]:t.LINEAR_MIPMAP_LINEAR},te={[ch]:t.NEVER,[ph]:t.ALWAYS,[hh]:t.LESS,[jr]:t.LEQUAL,[uh]:t.EQUAL,[ta]:t.GEQUAL,[dh]:t.GREATER,[fh]:t.NOTEQUAL};function Bt(S,_){if(_.type===jn&&e.has("OES_texture_float_linear")===!1&&(_.magFilter===Qe||_.magFilter===Xr||_.magFilter===Ks||_.magFilter===Ci||_.minFilter===Qe||_.minFilter===Xr||_.minFilter===Ks||_.minFilter===Ci))Vt("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device.");if(t.texParameteri(S,t.TEXTURE_WRAP_S,dt[_.wrapS]),t.texParameteri(S,t.TEXTURE_WRAP_T,dt[_.wrapT]),S===t.TEXTURE_3D||S===t.TEXTURE_2D_ARRAY)t.texParameteri(S,t.TEXTURE_WRAP_R,dt[_.wrapR]);if(t.texParameteri(S,t.TEXTURE_MAG_FILTER,At[_.magFilter]),t.texParameteri(S,t.TEXTURE_MIN_FILTER,At[_.minFilter]),_.compareFunction)t.texParameteri(S,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(S,t.TEXTURE_COMPARE_FUNC,te[_.compareFunction]);if(e.has("EXT_texture_filter_anisotropic")===!0){if(_.magFilter===Ln)return;if(_.minFilter!==Ks&&_.minFilter!==Ci)return;if(_.type===jn&&e.has("OES_texture_float_linear")===!1)return;if(_.anisotropy>1||i.get(_).__currentAnisotropy){let L=e.get("EXT_texture_filter_anisotropic");t.texParameterf(S,L.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(_.anisotropy,s.getMaxAnisotropy())),i.get(_).__currentAnisotropy=_.anisotropy}}}function Y(S,_){let L=!1;if(S.__webglInit===void 0)S.__webglInit=!0,_.addEventListener("dispose",E);let V=_.source,it=p.get(V);if(it===void 0)it={},p.set(V,it);let st=H(_);if(st!==S.__cacheKey){if(it[st]===void 0)it[st]={texture:t.createTexture(),usedTimes:0},a.memory.textures++,L=!0;it[st].usedTimes++;let ft=it[S.__cacheKey];if(ft!==void 0){if(it[S.__cacheKey].usedTimes--,ft.usedTimes===0)G(_)}S.__cacheKey=st,S.__webglTexture=it[st].texture}return L}function rt(S,_,L){return Math.floor(Math.floor(S/L)/_)}function lt(S,_,L,V){let st=S.updateRanges;if(st.length===0)n.texSubImage2D(t.TEXTURE_2D,0,0,0,_.width,_.height,L,V,_.data);else{st.sort((Nt,pt)=>Nt.start-pt.start);let ft=0;for(let Nt=1;Nt<st.length;Nt++){let pt=st[ft],ot=st[Nt],Ot=pt.start+pt.count,kt=rt(ot.start,_.width,4),se=rt(pt.start,_.width,4);if(ot.start<=Ot+1&&kt===se&&rt(ot.start+ot.count-1,_.width,4)===kt)pt.count=Math.max(pt.count,ot.start+ot.count-pt.start);else++ft,st[ft]=ot}st.length=ft+1;let J=n.getParameter(t.UNPACK_ROW_LENGTH),j=n.getParameter(t.UNPACK_SKIP_PIXELS),_t=n.getParameter(t.UNPACK_SKIP_ROWS);n.pixelStorei(t.UNPACK_ROW_LENGTH,_.width);for(let Nt=0,pt=st.length;Nt<pt;Nt++){let ot=st[Nt],Ot=Math.floor(ot.start/4),kt=Math.ceil(ot.count/4),se=Ot%_.width,I=Math.floor(Ot/_.width),ct=kt,Q=1;n.pixelStorei(t.UNPACK_SKIP_PIXELS,se),n.pixelStorei(t.UNPACK_SKIP_ROWS,I),n.texSubImage2D(t.TEXTURE_2D,0,se,I,ct,1,L,V,_.data)}S.clearUpdateRanges(),n.pixelStorei(t.UNPACK_ROW_LENGTH,J),n.pixelStorei(t.UNPACK_SKIP_PIXELS,j),n.pixelStorei(t.UNPACK_SKIP_ROWS,_t)}}function It(S,_,L){let V=t.TEXTURE_2D;if(_.isDataArrayTexture||_.isCompressedArrayTexture)V=t.TEXTURE_2D_ARRAY;if(_.isData3DTexture)V=t.TEXTURE_3D;let it=Y(S,_),st=_.source;n.bindTexture(V,S.__webglTexture,t.TEXTURE0+L);let ft=i.get(st);if(st.version!==ft.__version||it===!0){if(n.activeTexture(t.TEXTURE0+L),(typeof ImageBitmap<"u"&&_.image instanceof ImageBitmap)===!1){let Q=re.getPrimaries(re.workingColorSpace),ut=_.colorSpace===Li?null:re.getPrimaries(_.colorSpace),Tt=_.colorSpace===Li||Q===ut?t.NONE:t.BROWSER_DEFAULT_WEBGL;n.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,_.flipY),n.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,_.premultiplyAlpha),n.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,Tt)}n.pixelStorei(t.UNPACK_ALIGNMENT,_.unpackAlignment);let j=m(_.image,!1,s.maxTextureSize);j=ae(_,j);let _t=r.convert(_.format,_.colorSpace),Nt=r.convert(_.type),pt=y(_.internalFormat,_t,Nt,_.normalized,_.colorSpace,_.isVideoTexture);Bt(V,_);let ot,Ot=_.mipmaps,kt=_.isVideoTexture!==!0,se=ft.__version===void 0||it===!0,I=st.dataReady,ct=A(_,j);if(_.isDepthTexture){if(pt=b(_.format===Ii,_.type),se)if(kt)n.texStorage2D(t.TEXTURE_2D,1,pt,j.width,j.height);else n.texImage2D(t.TEXTURE_2D,0,pt,j.width,j.height,0,_t,Nt,null)}else if(_.isDataTexture)if(Ot.length>0){if(kt&&se)n.texStorage2D(t.TEXTURE_2D,ct,pt,Ot[0].width,Ot[0].height);for(let Q=0,ut=Ot.length;Q<ut;Q++)if(ot=Ot[Q],kt){if(I)n.texSubImage2D(t.TEXTURE_2D,Q,0,0,ot.width,ot.height,_t,Nt,ot.data)}else n.texImage2D(t.TEXTURE_2D,Q,pt,ot.width,ot.height,0,_t,Nt,ot.data);_.generateMipmaps=!1}else if(kt){if(se)n.texStorage2D(t.TEXTURE_2D,ct,pt,j.width,j.height);if(I)lt(_,j,_t,Nt)}else n.texImage2D(t.TEXTURE_2D,0,pt,j.width,j.height,0,_t,Nt,j.data);else if(_.isCompressedTexture)if(_.isCompressedArrayTexture){if(kt&&se)n.texStorage3D(t.TEXTURE_2D_ARRAY,ct,pt,Ot[0].width,Ot[0].height,j.depth);for(let Q=0,ut=Ot.length;Q<ut;Q++)if(ot=Ot[Q],_.format!==Gn)if(_t!==null)if(kt){if(I)if(_.layerUpdates.size>0){let Tt=bl(ot.width,ot.height,_.format,_.type);for(let nt of _.layerUpdates){let mt=ot.data.subarray(nt*Tt/ot.data.BYTES_PER_ELEMENT,(nt+1)*Tt/ot.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Q,0,0,nt,ot.width,ot.height,1,_t,mt)}}else n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Q,0,0,0,ot.width,ot.height,j.depth,_t,ot.data)}else n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,Q,pt,ot.width,ot.height,j.depth,0,ot.data,0,0);else Vt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(kt){if(I)n.texSubImage3D(t.TEXTURE_2D_ARRAY,Q,0,0,0,ot.width,ot.height,j.depth,_t,Nt,ot.data)}else n.texImage3D(t.TEXTURE_2D_ARRAY,Q,pt,ot.width,ot.height,j.depth,0,_t,Nt,ot.data);if(_.layerUpdates.size>0)_.clearLayerUpdates()}else{if(kt&&se)n.texStorage2D(t.TEXTURE_2D,ct,pt,Ot[0].width,Ot[0].height);for(let Q=0,ut=Ot.length;Q<ut;Q++)if(ot=Ot[Q],_.format!==Gn)if(_t!==null)if(kt){if(I)n.compressedTexSubImage2D(t.TEXTURE_2D,Q,0,0,ot.width,ot.height,_t,ot.data)}else n.compressedTexImage2D(t.TEXTURE_2D,Q,pt,ot.width,ot.height,0,ot.data);else Vt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(kt){if(I)n.texSubImage2D(t.TEXTURE_2D,Q,0,0,ot.width,ot.height,_t,Nt,ot.data)}else n.texImage2D(t.TEXTURE_2D,Q,pt,ot.width,ot.height,0,_t,Nt,ot.data)}else if(_.isDataArrayTexture)if(kt){if(se)n.texStorage3D(t.TEXTURE_2D_ARRAY,ct,pt,j.width,j.height,j.depth);if(I)if(_.layerUpdates.size>0){let Q=bl(j.width,j.height,_.format,_.type);for(let ut of _.layerUpdates){let Tt=j.data.subarray(ut*Q/j.data.BYTES_PER_ELEMENT,(ut+1)*Q/j.data.BYTES_PER_ELEMENT);n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,ut,j.width,j.height,1,_t,Nt,Tt)}_.clearLayerUpdates()}else n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,j.width,j.height,j.depth,_t,Nt,j.data)}else n.texImage3D(t.TEXTURE_2D_ARRAY,0,pt,j.width,j.height,j.depth,0,_t,Nt,j.data);else if(_.isData3DTexture)if(kt){if(se)n.texStorage3D(t.TEXTURE_3D,ct,pt,j.width,j.height,j.depth);if(I)n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,j.width,j.height,j.depth,_t,Nt,j.data)}else n.texImage3D(t.TEXTURE_3D,0,pt,j.width,j.height,j.depth,0,_t,Nt,j.data);else if(_.isFramebufferTexture){if(se)if(kt)n.texStorage2D(t.TEXTURE_2D,ct,pt,j.width,j.height);else{let Q=j.width,ut=j.height;for(let Tt=0;Tt<ct;Tt++)n.texImage2D(t.TEXTURE_2D,Tt,pt,Q,ut,0,_t,Nt,null),Q>>=1,ut>>=1}}else if(_.isHTMLTexture){if("texElementImage2D"in t){let Q=t.canvas;if(!Q.hasAttribute("layoutsubtree"))Q.setAttribute("layoutsubtree","true");if(j.parentNode!==Q){Q.appendChild(j),d.add(_),Q.onpaint=(ut)=>{let Tt=ut.changedElements;for(let nt of d)if(Tt.includes(nt.image))nt.needsUpdate=!0},Q.requestPaint();return}if(t.texElementImage2D.length===3)t.texElementImage2D(t.TEXTURE_2D,t.RGBA8,j);else{let{RGBA:Tt,RGBA:nt,UNSIGNED_BYTE:mt}=t;t.texElementImage2D(t.TEXTURE_2D,0,Tt,nt,mt,j)}t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE)}}else if(Ot.length>0){if(kt&&se){let Q=be(Ot[0]);n.texStorage2D(t.TEXTURE_2D,ct,pt,Q.width,Q.height)}for(let Q=0,ut=Ot.length;Q<ut;Q++)if(ot=Ot[Q],kt){if(I)n.texSubImage2D(t.TEXTURE_2D,Q,0,0,_t,Nt,ot)}else n.texImage2D(t.TEXTURE_2D,Q,pt,_t,Nt,ot);_.generateMipmaps=!1}else if(kt){if(se){let Q=be(j);n.texStorage2D(t.TEXTURE_2D,ct,pt,Q.width,Q.height)}if(I)n.texSubImage2D(t.TEXTURE_2D,0,0,0,_t,Nt,j)}else n.texImage2D(t.TEXTURE_2D,0,pt,_t,Nt,j);if(f(_))w(V);if(ft.__version=st.version,_.onUpdate)_.onUpdate(_)}S.__version=_.version}function Ft(S,_,L){if(_.image.length!==6)return;let V=Y(S,_),it=_.source;n.bindTexture(t.TEXTURE_CUBE_MAP,S.__webglTexture,t.TEXTURE0+L);let st=i.get(it);if(it.version!==st.__version||V===!0){n.activeTexture(t.TEXTURE0+L);let ft=re.getPrimaries(re.workingColorSpace),J=_.colorSpace===Li?null:re.getPrimaries(_.colorSpace),j=_.colorSpace===Li||ft===J?t.NONE:t.BROWSER_DEFAULT_WEBGL;n.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,_.flipY),n.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,_.premultiplyAlpha),n.pixelStorei(t.UNPACK_ALIGNMENT,_.unpackAlignment),n.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,j);let _t=_.isCompressedTexture||_.image[0].isCompressedTexture,Nt=_.image[0]&&_.image[0].isDataTexture,pt=[];for(let nt=0;nt<6;nt++){if(!_t&&!Nt)pt[nt]=m(_.image[nt],!0,s.maxCubemapSize);else pt[nt]=Nt?_.image[nt].image:_.image[nt];pt[nt]=ae(_,pt[nt])}let ot=pt[0],Ot=r.convert(_.format,_.colorSpace),kt=r.convert(_.type),se=y(_.internalFormat,Ot,kt,_.normalized,_.colorSpace),I=_.isVideoTexture!==!0,ct=st.__version===void 0||V===!0,Q=it.dataReady,ut=A(_,ot);Bt(t.TEXTURE_CUBE_MAP,_);let Tt;if(_t){if(I&&ct)n.texStorage2D(t.TEXTURE_CUBE_MAP,ut,se,ot.width,ot.height);for(let nt=0;nt<6;nt++){Tt=pt[nt].mipmaps;for(let mt=0;mt<Tt.length;mt++){let Wt=Tt[mt];if(_.format!==Gn)if(Ot!==null)if(I){if(Q)n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+nt,mt,0,0,Wt.width,Wt.height,Ot,Wt.data)}else n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+nt,mt,se,Wt.width,Wt.height,0,Wt.data);else Vt("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()");else if(I){if(Q)n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+nt,mt,0,0,Wt.width,Wt.height,Ot,kt,Wt.data)}else n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+nt,mt,se,Wt.width,Wt.height,0,Ot,kt,Wt.data)}}}else{if(Tt=_.mipmaps,I&&ct){if(Tt.length>0)ut++;let nt=be(pt[0]);n.texStorage2D(t.TEXTURE_CUBE_MAP,ut,se,nt.width,nt.height)}for(let nt=0;nt<6;nt++)if(Nt){if(I){if(Q)n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+nt,0,0,0,pt[nt].width,pt[nt].height,Ot,kt,pt[nt].data)}else n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+nt,0,se,pt[nt].width,pt[nt].height,0,Ot,kt,pt[nt].data);for(let mt=0;mt<Tt.length;mt++){let fe=Tt[mt].image[nt].image;if(I){if(Q)n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+nt,mt+1,0,0,fe.width,fe.height,Ot,kt,fe.data)}else n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+nt,mt+1,se,fe.width,fe.height,0,Ot,kt,fe.data)}}else{if(I){if(Q)n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+nt,0,0,0,Ot,kt,pt[nt])}else n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+nt,0,se,Ot,kt,pt[nt]);for(let mt=0;mt<Tt.length;mt++){let Wt=Tt[mt];if(I){if(Q)n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+nt,mt+1,0,0,Ot,kt,Wt.image[nt])}else n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+nt,mt+1,se,Ot,kt,Wt.image[nt])}}}if(f(_))w(t.TEXTURE_CUBE_MAP);if(st.__version=it.version,_.onUpdate)_.onUpdate(_)}S.__version=_.version}function Ut(S,_,L,V,it,st){let ft=r.convert(L.format,L.colorSpace),J=r.convert(L.type),j=y(L.internalFormat,ft,J,L.normalized,L.colorSpace),_t=i.get(_),Nt=i.get(L);if(Nt.__renderTarget=_,!_t.__hasExternalTextures){let pt=Math.max(1,_.width>>st),ot=Math.max(1,_.height>>st);if(it===t.TEXTURE_3D||it===t.TEXTURE_2D_ARRAY)n.texImage3D(it,st,j,pt,ot,_.depth,0,ft,J,null);else n.texImage2D(it,st,j,pt,ot,0,ft,J,null)}if(n.bindFramebuffer(t.FRAMEBUFFER,S),P(_))o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,V,it,Nt.__webglTexture,0,Re(_));else if(it===t.TEXTURE_2D||it>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&it<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)t.framebufferTexture2D(t.FRAMEBUFFER,V,it,Nt.__webglTexture,st);n.bindFramebuffer(t.FRAMEBUFFER,null)}function Ce(S,_,L){if(t.bindRenderbuffer(t.RENDERBUFFER,S),_.depthBuffer){let V=_.depthTexture,it=V&&V.isDepthTexture?V.type:null,st=b(_.stencilBuffer,it),ft=_.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;if(P(_))o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Re(_),st,_.width,_.height);else if(L)t.renderbufferStorageMultisample(t.RENDERBUFFER,Re(_),st,_.width,_.height);else t.renderbufferStorage(t.RENDERBUFFER,st,_.width,_.height);t.framebufferRenderbuffer(t.FRAMEBUFFER,ft,t.RENDERBUFFER,S)}else{let V=_.textures;for(let it=0;it<V.length;it++){let st=V[it],ft=r.convert(st.format,st.colorSpace),J=r.convert(st.type),j=y(st.internalFormat,ft,J,st.normalized,st.colorSpace);if(P(_))o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Re(_),j,_.width,_.height);else if(L)t.renderbufferStorageMultisample(t.RENDERBUFFER,Re(_),j,_.width,_.height);else t.renderbufferStorage(t.RENDERBUFFER,j,_.width,_.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function $t(S,_,L){let V=_.isWebGLCubeRenderTarget===!0;if(n.bindFramebuffer(t.FRAMEBUFFER,S),!(_.depthTexture&&_.depthTexture.isDepthTexture))throw Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");let it=i.get(_.depthTexture);if(it.__renderTarget=_,!it.__webglTexture||_.depthTexture.image.width!==_.width||_.depthTexture.image.height!==_.height)_.depthTexture.image.width=_.width,_.depthTexture.image.height=_.height,_.depthTexture.needsUpdate=!0;if(V){if(it.__webglInit===void 0)it.__webglInit=!0,_.depthTexture.addEventListener("dispose",E);if(it.__webglTexture===void 0){it.__webglTexture=t.createTexture(),n.bindTexture(t.TEXTURE_CUBE_MAP,it.__webglTexture),Bt(t.TEXTURE_CUBE_MAP,_.depthTexture);let _t=r.convert(_.depthTexture.format),Nt=r.convert(_.depthTexture.type),pt;if(_.depthTexture.format===Ri)pt=t.DEPTH_COMPONENT24;else if(_.depthTexture.format===Ii)pt=t.DEPTH24_STENCIL8;for(let ot=0;ot<6;ot++)t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ot,0,pt,_.width,_.height,0,_t,Nt,null)}}else at(_.depthTexture,0);let st=it.__webglTexture,ft=Re(_),J=V?t.TEXTURE_CUBE_MAP_POSITIVE_X+L:t.TEXTURE_2D,j=_.depthTexture.format===Ii?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;if(_.depthTexture.format===Ri)if(P(_))o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,j,J,st,0,ft);else t.framebufferTexture2D(t.FRAMEBUFFER,j,J,st,0);else if(_.depthTexture.format===Ii)if(P(_))o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,j,J,st,0,ft);else t.framebufferTexture2D(t.FRAMEBUFFER,j,J,st,0);else throw Error("THREE.WebGLTextures: Unknown depthTexture format.")}function ee(S){let _=i.get(S),L=S.isWebGLCubeRenderTarget===!0;if(_.__boundDepthTexture!==S.depthTexture){let V=S.depthTexture;if(_.__depthDisposeCallback)_.__depthDisposeCallback();if(V){let it=()=>{delete _.__boundDepthTexture,delete _.__depthDisposeCallback,V.removeEventListener("dispose",it)};V.addEventListener("dispose",it),_.__depthDisposeCallback=it}_.__boundDepthTexture=V}if(S.depthTexture&&!_.__autoAllocateDepthBuffer)if(L)for(let V=0;V<6;V++)$t(_.__webglFramebuffer[V],S,V);else{let V=S.texture.mipmaps;if(V&&V.length>0)$t(_.__webglFramebuffer[0],S,0);else $t(_.__webglFramebuffer,S,0)}else if(L){_.__webglDepthbuffer=[];for(let V=0;V<6;V++)if(n.bindFramebuffer(t.FRAMEBUFFER,_.__webglFramebuffer[V]),_.__webglDepthbuffer[V]===void 0)_.__webglDepthbuffer[V]=t.createRenderbuffer(),Ce(_.__webglDepthbuffer[V],S,!1);else{let it=S.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,st=_.__webglDepthbuffer[V];t.bindRenderbuffer(t.RENDERBUFFER,st),t.framebufferRenderbuffer(t.FRAMEBUFFER,it,t.RENDERBUFFER,st)}}else{let V=S.texture.mipmaps;if(V&&V.length>0)n.bindFramebuffer(t.FRAMEBUFFER,_.__webglFramebuffer[0]);else n.bindFramebuffer(t.FRAMEBUFFER,_.__webglFramebuffer);if(_.__webglDepthbuffer===void 0)_.__webglDepthbuffer=t.createRenderbuffer(),Ce(_.__webglDepthbuffer,S,!1);else{let it=S.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,st=_.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,st),t.framebufferRenderbuffer(t.FRAMEBUFFER,it,t.RENDERBUFFER,st)}}n.bindFramebuffer(t.FRAMEBUFFER,null)}function ue(S,_,L){let V=i.get(S);if(_!==void 0)Ut(V.__webglFramebuffer,S,S.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0);if(L!==void 0)ee(S)}function ne(S){let _=S.texture,L=i.get(S),V=i.get(_);S.addEventListener("dispose",g);let it=S.textures,st=S.isWebGLCubeRenderTarget===!0,ft=it.length>1;if(!ft){if(V.__webglTexture===void 0)V.__webglTexture=t.createTexture();V.__version=_.version,a.memory.textures++}if(st){L.__webglFramebuffer=[];for(let J=0;J<6;J++)if(_.mipmaps&&_.mipmaps.length>0){L.__webglFramebuffer[J]=[];for(let j=0;j<_.mipmaps.length;j++)L.__webglFramebuffer[J][j]=t.createFramebuffer()}else L.__webglFramebuffer[J]=t.createFramebuffer()}else{if(_.mipmaps&&_.mipmaps.length>0){L.__webglFramebuffer=[];for(let J=0;J<_.mipmaps.length;J++)L.__webglFramebuffer[J]=t.createFramebuffer()}else L.__webglFramebuffer=t.createFramebuffer();if(ft)for(let J=0,j=it.length;J<j;J++){let _t=i.get(it[J]);if(_t.__webglTexture===void 0)_t.__webglTexture=t.createTexture(),a.memory.textures++}if(S.samples>0&&P(S)===!1){L.__webglMultisampledFramebuffer=t.createFramebuffer(),L.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,L.__webglMultisampledFramebuffer);for(let J=0;J<it.length;J++){let j=it[J];L.__webglColorRenderbuffer[J]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,L.__webglColorRenderbuffer[J]);let _t=r.convert(j.format,j.colorSpace),Nt=r.convert(j.type),pt=y(j.internalFormat,_t,Nt,j.normalized,j.colorSpace,S.isXRRenderTarget===!0),ot=Re(S);t.renderbufferStorageMultisample(t.RENDERBUFFER,ot,pt,S.width,S.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+J,t.RENDERBUFFER,L.__webglColorRenderbuffer[J])}if(t.bindRenderbuffer(t.RENDERBUFFER,null),S.depthBuffer)L.__webglDepthRenderbuffer=t.createRenderbuffer(),Ce(L.__webglDepthRenderbuffer,S,!0);n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(st){n.bindTexture(t.TEXTURE_CUBE_MAP,V.__webglTexture),Bt(t.TEXTURE_CUBE_MAP,_);for(let J=0;J<6;J++)if(_.mipmaps&&_.mipmaps.length>0)for(let j=0;j<_.mipmaps.length;j++)Ut(L.__webglFramebuffer[J][j],S,_,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+J,j);else Ut(L.__webglFramebuffer[J],S,_,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+J,0);if(f(_))w(t.TEXTURE_CUBE_MAP);n.unbindTexture()}else if(ft){for(let J=0,j=it.length;J<j;J++){let _t=it[J],Nt=i.get(_t),pt=t.TEXTURE_2D;if(S.isWebGL3DRenderTarget||S.isWebGLArrayRenderTarget)pt=S.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY;if(n.bindTexture(pt,Nt.__webglTexture),Bt(pt,_t),Ut(L.__webglFramebuffer,S,_t,t.COLOR_ATTACHMENT0+J,pt,0),f(_t))w(pt)}n.unbindTexture()}else{let J=t.TEXTURE_2D;if(S.isWebGL3DRenderTarget||S.isWebGLArrayRenderTarget)J=S.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY;if(n.bindTexture(J,V.__webglTexture),Bt(J,_),_.mipmaps&&_.mipmaps.length>0)for(let j=0;j<_.mipmaps.length;j++)Ut(L.__webglFramebuffer[j],S,_,t.COLOR_ATTACHMENT0,J,j);else Ut(L.__webglFramebuffer,S,_,t.COLOR_ATTACHMENT0,J,0);if(f(_))w(J);n.unbindTexture()}if(S.depthBuffer)ee(S)}function Le(S){let _=S.textures;for(let L=0,V=_.length;L<V;L++){let it=_[L];if(f(it)){let st=C(S),ft=i.get(it).__webglTexture;n.bindTexture(st,ft),w(st),n.unbindTexture()}}}let me=[],Ze=[];function Ne(S){if(S.samples>0){if(P(S)===!1){let{textures:_,width:L,height:V}=S,it=t.COLOR_BUFFER_BIT,st=S.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,ft=i.get(S),J=_.length>1;if(J)for(let _t=0;_t<_.length;_t++)n.bindFramebuffer(t.FRAMEBUFFER,ft.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+_t,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,ft.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+_t,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,ft.__webglMultisampledFramebuffer);let j=S.texture.mipmaps;if(j&&j.length>0)n.bindFramebuffer(t.DRAW_FRAMEBUFFER,ft.__webglFramebuffer[0]);else n.bindFramebuffer(t.DRAW_FRAMEBUFFER,ft.__webglFramebuffer);for(let _t=0;_t<_.length;_t++){if(S.resolveDepthBuffer){if(S.depthBuffer)it|=t.DEPTH_BUFFER_BIT;if(S.stencilBuffer&&S.resolveStencilBuffer)it|=t.STENCIL_BUFFER_BIT}if(J){t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,ft.__webglColorRenderbuffer[_t]);let Nt=i.get(_[_t]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,Nt,0)}if(t.blitFramebuffer(0,0,L,V,0,0,L,V,it,t.NEAREST),l===!0){if(me.length=0,Ze.length=0,me.push(t.COLOR_ATTACHMENT0+_t),S.depthBuffer&&S.storeMultisampledDepthBuffer===!1)me.push(st),Ze.push(st),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,Ze);t.invalidateFramebuffer(t.READ_FRAMEBUFFER,me)}}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),J)for(let _t=0;_t<_.length;_t++){n.bindFramebuffer(t.FRAMEBUFFER,ft.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+_t,t.RENDERBUFFER,ft.__webglColorRenderbuffer[_t]);let Nt=i.get(_[_t]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,ft.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+_t,t.TEXTURE_2D,Nt,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,ft.__webglMultisampledFramebuffer)}else if(S.depthBuffer&&S.storeMultisampledDepthBuffer===!1&&l){let _=S.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[_])}}}function Re(S){return Math.min(s.maxSamples,S.samples)}function P(S){let _=i.get(S);return S.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&_.__useRenderToTexture!==!1}function Ue(S){let _=a.render.frame;if(u.get(S)!==_)u.set(S,_),S.update()}function ae(S,_){let{colorSpace:L,format:V,type:it}=S;if(S.isCompressedTexture===!0||S.isVideoTexture===!0)return _;if(L!==Zo&&L!==Li)if(re.getTransfer(L)===Me){if(V!==Gn||it!==mn)Vt("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.")}else Ht("WebGLTextures: Unsupported texture color space:",L);return _}function be(S){if(typeof HTMLImageElement<"u"&&S instanceof HTMLImageElement)c.width=S.naturalWidth||S.width,c.height=S.naturalHeight||S.height;else if(typeof VideoFrame<"u"&&S instanceof VideoFrame)c.width=S.displayWidth,c.height=S.displayHeight;else c.width=S.width,c.height=S.height;return c}this.allocateTextureUnit=Z,this.resetTextureUnits=X,this.getTextureUnits=R,this.setTextureUnits=k,this.setTexture2D=at,this.setTexture2DArray=K,this.setTexture3D=et,this.setTextureCube=tt,this.rebindTextures=ue,this.setupRenderTarget=ne,this.updateRenderTargetMipmap=Le,this.updateMultisampleRenderTarget=Ne,this.setupDepthRenderbuffer=ee,this.setupFrameBufferTexture=Ut,this.useMultisampledRTT=P,this.isReversedDepthBuffer=function(){return n.buffers.depth.getReversed()}}function $g(t,e){function n(i,s=Li){let r,a=re.getTransfer(s);if(i===mn)return t.UNSIGNED_BYTE;if(i===lo)return t.UNSIGNED_SHORT_4_4_4_4;if(i===co)return t.UNSIGNED_SHORT_5_5_5_1;if(i===sh)return t.UNSIGNED_INT_5_9_9_9_REV;if(i===rh)return t.UNSIGNED_INT_10F_11F_11F_REV;if(i===nh)return t.BYTE;if(i===ih)return t.SHORT;if(i===Qs)return t.UNSIGNED_SHORT;if(i===oo)return t.INT;if(i===mi)return t.UNSIGNED_INT;if(i===jn)return t.FLOAT;if(i===kn)return t.HALF_FLOAT;if(i===ah)return t.ALPHA;if(i===oh)return t.RGB;if(i===Gn)return t.RGBA;if(i===Ri)return t.DEPTH_COMPONENT;if(i===Ii)return t.DEPTH_STENCIL;if(i===qr)return t.RED;if(i===ho)return t.RED_INTEGER;if(i===Pi)return t.RG;if(i===uo)return t.RG_INTEGER;if(i===fo)return t.RGBA_INTEGER;if(i===Yr||i===Zr||i===Jr||i===$r)if(a===Me)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(i===Yr)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Zr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Jr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===$r)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(i===Yr)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Zr)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Jr)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===$r)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===po||i===mo||i===go||i===_o)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(i===po)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===mo)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===go)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===_o)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===xo||i===vo||i===So||i===Mo||i===To||i===Kr||i===wo)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(i===xo||i===vo)return a===Me?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(i===So)return a===Me?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(i===Mo)return r.COMPRESSED_R11_EAC;if(i===To)return r.COMPRESSED_SIGNED_R11_EAC;if(i===Kr)return r.COMPRESSED_RG11_EAC;if(i===wo)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===Eo||i===Ao||i===Co||i===Ro||i===Io||i===Po||i===Lo||i===No||i===Do||i===Uo||i===Fo||i===Bo||i===zo||i===ko)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(i===Eo)return a===Me?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Ao)return a===Me?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Co)return a===Me?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Ro)return a===Me?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Io)return a===Me?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===Po)return a===Me?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Lo)return a===Me?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===No)return a===Me?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Do)return a===Me?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===Uo)return a===Me?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===Fo)return a===Me?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===Bo)return a===Me?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===zo)return a===Me?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===ko)return a===Me?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===Go||i===Ho||i===Vo)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(i===Go)return a===Me?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===Ho)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===Vo)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===Wo||i===Xo||i===Qr||i===qo)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(i===Wo)return r.COMPRESSED_RED_RGTC1_EXT;if(i===Xo)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===Qr)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===qo)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;if(i===Ss)return t.UNSIGNED_INT_24_8;return t[i]!==void 0?t[i]:null}return{convert:n}}var Kg=`
4197
4197
  void main() {
4198
4198
 
4199
4199
  gl_Position = vec4( position, 1.0 );
4200
4200
 
4201
- }`,Kg=`
4201
+ }`,Qg=`
4202
4202
  uniform sampler2DArray depthColor;
4203
4203
  uniform float depthWidth;
4204
4204
  uniform float depthHeight;
@@ -4217,4 +4217,4 @@ void main() {
4217
4217
 
4218
4218
  }
4219
4219
 
4220
- }`;class iu{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e){if(this.texture===null){let n=new ea(t.texture);if(t.depthNear!==e.depthNear||t.depthFar!==e.depthFar)this.depthNear=t.depthNear,this.depthFar=t.depthFar;this.texture=n}}getMesh(t){if(this.texture!==null){if(this.mesh===null){let e=t.cameras[0].viewport,n=new bn({vertexShader:$g,fragmentShader:Kg,uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new Jt(new Ie(20,20),n)}}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class su extends ti{constructor(t,e){super();let n=this,i=null,s=1,r=null,a="local-floor",o=1,l=null,c=null,u=null,d=null,h=null,p=null,v=typeof XRWebGLBinding<"u",T=new iu,m={},f=e.getContextAttributes(),w=null,C=null,y=[],b=[],A=new Xt,E=null,g=null,M=new sn;M.viewport=new Ae;let G=new sn;G.viewport=new Ae;let N=[M,G],F=new xl,X=null,R=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Y){let rt=y[Y];if(rt===void 0)rt=new Ys,y[Y]=rt;return rt.getTargetRaySpace()},this.getControllerGrip=function(Y){let rt=y[Y];if(rt===void 0)rt=new Ys,y[Y]=rt;return rt.getGripSpace()},this.getHand=function(Y){let rt=y[Y];if(rt===void 0)rt=new Ys,y[Y]=rt;return rt.getHandSpace()};function k(Y){let rt=b.indexOf(Y.inputSource);if(rt===-1)return;let lt=y[rt];if(lt!==void 0)lt.update(Y.inputSource,Y.frame,l||r),lt.dispatchEvent({type:Y.type,data:Y.inputSource})}function Z(){i.removeEventListener("select",k),i.removeEventListener("selectstart",k),i.removeEventListener("selectend",k),i.removeEventListener("squeeze",k),i.removeEventListener("squeezestart",k),i.removeEventListener("squeezeend",k),i.removeEventListener("end",Z),i.removeEventListener("inputsourceschange",H);for(let Y=0;Y<y.length;Y++){let rt=b[Y];if(rt===null)continue;b[Y]=null,y[Y].disconnect(rt)}X=null,R=null,T.reset();for(let Y in m)delete m[Y];if(t.setRenderTarget(w),h=null,d=null,u=null,i=null,C=null,zt.stop(),n.isPresenting=!1,t.setPixelRatio(E),t.setSize(A.width,A.height,!1),g!==null){let Y=g.camera;Y.fov=g.fov,Y.zoom=g.zoom,Y.updateProjectionMatrix(),g=null}n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Y){if(s=Y,n.isPresenting===!0)Ht("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Y){if(a=Y,n.isPresenting===!0)Ht("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||r},this.setReferenceSpace=function(Y){l=Y},this.getBaseLayer=function(){return d!==null?d:h},this.getBinding=function(){if(u===null&&v)u=new XRWebGLBinding(i,e);return u},this.getFrame=function(){return p},this.getSession=function(){return i},this.setSession=async function(Y){if(i=Y,i!==null){if(w=t.getRenderTarget(),i.addEventListener("select",k),i.addEventListener("selectstart",k),i.addEventListener("selectend",k),i.addEventListener("squeeze",k),i.addEventListener("squeezestart",k),i.addEventListener("squeezeend",k),i.addEventListener("end",Z),i.addEventListener("inputsourceschange",H),f.xrCompatible!==!0)await e.makeXRCompatible();if(E=t.getPixelRatio(),t.getSize(A),!(v&&("createProjectionLayer"in XRWebGLBinding.prototype))){let lt={antialias:f.antialias,alpha:!0,depth:f.depth,stencil:f.stencil,framebufferScaleFactor:s};h=new XRWebGLLayer(i,e,lt),i.updateRenderState({baseLayer:h}),t.setPixelRatio(1),t.setSize(h.framebufferWidth,h.framebufferHeight,!1),C=new gn(h.framebufferWidth,h.framebufferHeight,{format:Gn,type:mn,colorSpace:t.outputColorSpace,stencilBuffer:f.stencil,resolveDepthBuffer:h.ignoreDepthValues===!1,resolveStencilBuffer:h.ignoreDepthValues===!1,storeMultisampledDepthBuffer:h.ignoreDepthValues===!1,storeMultisampledStencilBuffer:h.ignoreDepthValues===!1})}else{let lt=null,It=null,Ot=null;if(f.depth)Ot=f.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,lt=f.stencil?Pi:Ri,It=f.stencil?gs:mi;let Ft={colorFormat:e.RGBA8,depthFormat:Ot,scaleFactor:s};u=this.getBinding(),d=u.createProjectionLayer(Ft),i.updateRenderState({layers:[d]}),t.setPixelRatio(1),t.setSize(d.textureWidth,d.textureHeight,!1),C=new gn(d.textureWidth,d.textureHeight,{format:Gn,type:mn,depthTexture:new Fi(d.textureWidth,d.textureHeight,It,void 0,void 0,void 0,void 0,void 0,void 0,lt),stencilBuffer:f.stencil,colorSpace:t.outputColorSpace,samples:f.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1,storeMultisampledDepthBuffer:d.ignoreDepthValues===!1,storeMultisampledStencilBuffer:d.ignoreDepthValues===!1})}C.isXRRenderTarget=!0,this.setFoveation(o),l=null,r=await i.requestReferenceSpace(a),zt.setContext(i),zt.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return T.getDepthTexture()};function H(Y){for(let rt=0;rt<Y.removed.length;rt++){let lt=Y.removed[rt],It=b.indexOf(lt);if(It>=0)b[It]=null,y[It].disconnect(lt)}for(let rt=0;rt<Y.added.length;rt++){let lt=Y.added[rt],It=b.indexOf(lt);if(It===-1){for(let Ft=0;Ft<y.length;Ft++)if(Ft>=b.length){b.push(lt),It=Ft;break}else if(b[Ft]===null){b[Ft]=lt,It=Ft;break}if(It===-1)break}let Ot=y[It];if(Ot)Ot.connect(lt)}}let at=new O,K=new O;function et(Y,rt,lt){at.setFromMatrixPosition(rt.matrixWorld),K.setFromMatrixPosition(lt.matrixWorld);let It=at.distanceTo(K),Ot=rt.projectionMatrix.elements,Ft=lt.projectionMatrix.elements,Ce=Ot[14]/(Ot[10]-1),$t=Ot[14]/(Ot[10]+1),ee=(Ot[9]+1)/Ot[5],ue=(Ot[9]-1)/Ot[5],ne=(Ot[8]-1)/Ot[0],Le=(Ft[8]+1)/Ft[0],me=Ce*ne,Ze=Ce*Le,Ne=It/(-ne+Le),Re=Ne*-ne;if(rt.matrixWorld.decompose(Y.position,Y.quaternion,Y.scale),Y.translateX(Re),Y.translateZ(Ne),Y.matrixWorld.compose(Y.position,Y.quaternion,Y.scale),Y.matrixWorldInverse.copy(Y.matrixWorld).invert(),Ot[10]===-1)Y.projectionMatrix.copy(rt.projectionMatrix),Y.projectionMatrixInverse.copy(rt.projectionMatrixInverse);else{let P=Ce+Ne,Ue=$t+Ne,ae=me-Re,be=Ze+(It-Re),S=ee*$t/Ue*P,_=ue*$t/Ue*P;Y.projectionMatrix.makePerspective(ae,be,S,_,P,Ue),Y.projectionMatrixInverse.copy(Y.projectionMatrix).invert()}}function tt(Y,rt){if(rt===null)Y.matrixWorld.copy(Y.matrix);else Y.matrixWorld.multiplyMatrices(rt.matrixWorld,Y.matrix);Y.matrixWorldInverse.copy(Y.matrixWorld).invert()}this.updateCamera=function(Y){if(i===null)return;let{near:rt,far:lt}=Y;if(T.texture!==null){if(T.depthNear>0)rt=T.depthNear;if(T.depthFar>0)lt=T.depthFar}if(F.near=G.near=M.near=rt,F.far=G.far=M.far=lt,X!==F.near||R!==F.far)i.updateRenderState({depthNear:F.near,depthFar:F.far}),X=F.near,R=F.far;F.layers.mask=Y.layers.mask|6,M.layers.mask=F.layers.mask&-5,G.layers.mask=F.layers.mask&-3;let It=Y.parent,Ot=F.cameras;tt(F,It);for(let Ft=0;Ft<Ot.length;Ft++)tt(Ot[Ft],It);if(Ot.length===2)et(F,M,G);else F.projectionMatrix.copy(M.projectionMatrix);if(g===null&&Y.isPerspectiveCamera)g={camera:Y,fov:Y.fov,zoom:Y.zoom};dt(Y,F,It)};function dt(Y,rt,lt){if(lt===null)Y.matrix.copy(rt.matrixWorld);else Y.matrix.copy(lt.matrixWorld),Y.matrix.invert(),Y.matrix.multiply(rt.matrixWorld);if(Y.matrix.decompose(Y.position,Y.quaternion,Y.scale),Y.updateMatrixWorld(!0),Y.projectionMatrix.copy(rt.projectionMatrix),Y.projectionMatrixInverse.copy(rt.projectionMatrixInverse),Y.isPerspectiveCamera)Y.fov=Ur*2*Math.atan(1/Y.projectionMatrix.elements[5]),Y.zoom=1}this.getCamera=function(){return F},this.getFoveation=function(){if(d===null&&h===null)return;return o},this.setFoveation=function(Y){if(o=Y,d!==null)d.fixedFoveation=Y;if(h!==null&&h.fixedFoveation!==void 0)h.fixedFoveation=Y},this.hasDepthSensing=function(){return T.texture!==null},this.getDepthSensingMesh=function(){return T.getMesh(F)},this.getCameraTexture=function(Y){return m[Y]};let At=null;function te(Y,rt){if(c=rt.getViewerPose(l||r),p=rt,c!==null){let lt=c.views;if(h!==null)t.setRenderTargetFramebuffer(C,h.framebuffer),t.setRenderTarget(C);let It=!1;if(lt.length!==F.cameras.length)F.cameras.length=0,It=!0;for(let $t=0;$t<lt.length;$t++){let ee=lt[$t],ue=null;if(h!==null)ue=h.getViewport(ee);else{let Le=u.getViewSubImage(d,ee);if(ue=Le.viewport,$t===0)t.setRenderTargetTextures(C,Le.colorTexture,Le.depthStencilTexture),t.setRenderTarget(C)}let ne=N[$t];if(ne===void 0)ne=new sn,ne.layers.enable($t),ne.viewport=new Ae,N[$t]=ne;if(ne.matrix.fromArray(ee.transform.matrix),ne.matrix.decompose(ne.position,ne.quaternion,ne.scale),ne.projectionMatrix.fromArray(ee.projectionMatrix),ne.projectionMatrixInverse.copy(ne.projectionMatrix).invert(),ne.viewport.set(ue.x,ue.y,ue.width,ue.height),$t===0)F.matrix.copy(ne.matrix),F.matrix.decompose(F.position,F.quaternion,F.scale);if(It===!0)F.cameras.push(ne)}let Ot=i.enabledFeatures;if(Ot&&Ot.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&v){u=n.getBinding();let $t=u.getDepthInformation(lt[0]);if($t&&$t.isValid&&$t.texture)T.init($t,i.renderState)}if(Ot&&Ot.includes("camera-access")&&v){t.state.unbindTexture(),u=n.getBinding();for(let $t=0;$t<lt.length;$t++){let ee=lt[$t].camera;if(ee){let ue=m[ee];if(!ue)ue=new ea,m[ee]=ue;let ne=u.getCameraImage(ee);ue.sourceTexture=ne}}}}for(let lt=0;lt<y.length;lt++){let It=b[lt],Ot=y[lt];if(It!==null&&Ot!==void 0)Ot.update(It,rt,l||r)}if(At)At(Y,rt);if(rt.detectedPlanes)n.dispatchEvent({type:"planesdetected",data:rt});p=null}let zt=new qh;zt.setAnimationLoop(te),this.setAnimationLoop=function(Y){At=Y},this.dispose=function(){}}}var Qg=new we,ru=new qt;ru.set(-1,0,0,0,1,0,0,0,1);function jg(t,e){function n(m,f){if(m.matrixAutoUpdate===!0)m.updateMatrix();f.value.copy(m.matrix)}function i(m,f){if(f.color.getRGB(m.fogColor.value,nl(t)),f.isFog)m.fogNear.value=f.near,m.fogFar.value=f.far;else if(f.isFogExp2)m.fogDensity.value=f.density}function s(m,f,w,C,y){if(f.isNodeMaterial)f.uniformsNeedUpdate=!1;else if(f.isMeshBasicMaterial)r(m,f);else if(f.isMeshLambertMaterial){if(r(m,f),f.envMap)m.envMapIntensity.value=f.envMapIntensity}else if(f.isMeshToonMaterial)r(m,f),d(m,f);else if(f.isMeshPhongMaterial){if(r(m,f),u(m,f),f.envMap)m.envMapIntensity.value=f.envMapIntensity}else if(f.isMeshStandardMaterial){if(r(m,f),h(m,f),f.isMeshPhysicalMaterial)p(m,f,y)}else if(f.isMeshMatcapMaterial)r(m,f),v(m,f);else if(f.isMeshDepthMaterial)r(m,f);else if(f.isMeshDistanceMaterial)r(m,f),T(m,f);else if(f.isMeshNormalMaterial)r(m,f);else if(f.isLineBasicMaterial){if(a(m,f),f.isLineDashedMaterial)o(m,f)}else if(f.isPointsMaterial)l(m,f,w,C);else if(f.isSpriteMaterial)c(m,f);else if(f.isShadowMaterial)m.color.value.copy(f.color),m.opacity.value=f.opacity;else if(f.isShaderMaterial)f.uniformsNeedUpdate=!1}function r(m,f){if(m.opacity.value=f.opacity,f.color)m.diffuse.value.copy(f.color);if(f.emissive)m.emissive.value.copy(f.emissive).multiplyScalar(f.emissiveIntensity);if(f.map)m.map.value=f.map,n(f.map,m.mapTransform);if(f.alphaMap)m.alphaMap.value=f.alphaMap,n(f.alphaMap,m.alphaMapTransform);if(f.bumpMap){if(m.bumpMap.value=f.bumpMap,n(f.bumpMap,m.bumpMapTransform),m.bumpScale.value=f.bumpScale,f.side===Ve)m.bumpScale.value*=-1}if(f.normalMap){if(m.normalMap.value=f.normalMap,n(f.normalMap,m.normalMapTransform),m.normalScale.value.copy(f.normalScale),f.side===Ve)m.normalScale.value.negate()}if(f.displacementMap)m.displacementMap.value=f.displacementMap,n(f.displacementMap,m.displacementMapTransform),m.displacementScale.value=f.displacementScale,m.displacementBias.value=f.displacementBias;if(f.emissiveMap)m.emissiveMap.value=f.emissiveMap,n(f.emissiveMap,m.emissiveMapTransform);if(f.specularMap)m.specularMap.value=f.specularMap,n(f.specularMap,m.specularMapTransform);if(f.alphaTest>0)m.alphaTest.value=f.alphaTest;let w=e.get(f),{envMap:C,envMapRotation:y}=w;if(C){if(m.envMap.value=C,m.envMapRotation.value.setFromMatrix4(Qg.makeRotationFromEuler(y)).transpose(),C.isCubeTexture&&C.isRenderTargetTexture===!1)m.envMapRotation.value.premultiply(ru);m.reflectivity.value=f.reflectivity,m.ior.value=f.ior,m.refractionRatio.value=f.refractionRatio}if(f.lightMap)m.lightMap.value=f.lightMap,m.lightMapIntensity.value=f.lightMapIntensity,n(f.lightMap,m.lightMapTransform);if(f.aoMap)m.aoMap.value=f.aoMap,m.aoMapIntensity.value=f.aoMapIntensity,n(f.aoMap,m.aoMapTransform)}function a(m,f){if(m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,f.map)m.map.value=f.map,n(f.map,m.mapTransform)}function o(m,f){m.dashSize.value=f.dashSize,m.totalSize.value=f.dashSize+f.gapSize,m.scale.value=f.scale}function l(m,f,w,C){if(m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,m.size.value=f.size*w,m.scale.value=C*0.5,f.map)m.map.value=f.map,n(f.map,m.uvTransform);if(f.alphaMap)m.alphaMap.value=f.alphaMap,n(f.alphaMap,m.alphaMapTransform);if(f.alphaTest>0)m.alphaTest.value=f.alphaTest}function c(m,f){if(m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,m.rotation.value=f.rotation,f.map)m.map.value=f.map,n(f.map,m.mapTransform);if(f.alphaMap)m.alphaMap.value=f.alphaMap,n(f.alphaMap,m.alphaMapTransform);if(f.alphaTest>0)m.alphaTest.value=f.alphaTest}function u(m,f){m.specular.value.copy(f.specular),m.shininess.value=Math.max(f.shininess,0.0001)}function d(m,f){if(f.gradientMap)m.gradientMap.value=f.gradientMap}function h(m,f){if(m.metalness.value=f.metalness,f.metalnessMap)m.metalnessMap.value=f.metalnessMap,n(f.metalnessMap,m.metalnessMapTransform);if(m.roughness.value=f.roughness,f.roughnessMap)m.roughnessMap.value=f.roughnessMap,n(f.roughnessMap,m.roughnessMapTransform);if(f.envMap)m.envMapIntensity.value=f.envMapIntensity}function p(m,f,w){if(m.ior.value=f.ior,f.sheen>0){if(m.sheenColor.value.copy(f.sheenColor).multiplyScalar(f.sheen),m.sheenRoughness.value=f.sheenRoughness,f.sheenColorMap)m.sheenColorMap.value=f.sheenColorMap,n(f.sheenColorMap,m.sheenColorMapTransform);if(f.sheenRoughnessMap)m.sheenRoughnessMap.value=f.sheenRoughnessMap,n(f.sheenRoughnessMap,m.sheenRoughnessMapTransform)}if(f.clearcoat>0){if(m.clearcoat.value=f.clearcoat,m.clearcoatRoughness.value=f.clearcoatRoughness,f.clearcoatMap)m.clearcoatMap.value=f.clearcoatMap,n(f.clearcoatMap,m.clearcoatMapTransform);if(f.clearcoatRoughnessMap)m.clearcoatRoughnessMap.value=f.clearcoatRoughnessMap,n(f.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform);if(f.clearcoatNormalMap){if(m.clearcoatNormalMap.value=f.clearcoatNormalMap,n(f.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(f.clearcoatNormalScale),f.side===Ve)m.clearcoatNormalScale.value.negate()}}if(f.dispersion>0)m.dispersion.value=f.dispersion;if(f.retroreflectivity>0)m.retroreflectivity.value=f.retroreflectivity;if(f.iridescence>0){if(m.iridescence.value=f.iridescence,m.iridescenceIOR.value=f.iridescenceIOR,m.iridescenceThicknessMinimum.value=f.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=f.iridescenceThicknessRange[1],f.iridescenceMap)m.iridescenceMap.value=f.iridescenceMap,n(f.iridescenceMap,m.iridescenceMapTransform);if(f.iridescenceThicknessMap)m.iridescenceThicknessMap.value=f.iridescenceThicknessMap,n(f.iridescenceThicknessMap,m.iridescenceThicknessMapTransform)}if(f.transmission>0){if(m.transmission.value=f.transmission,m.transmissionSamplerMap.value=w.texture,m.transmissionSamplerSize.value.set(w.width,w.height),f.transmissionMap)m.transmissionMap.value=f.transmissionMap,n(f.transmissionMap,m.transmissionMapTransform);if(m.thickness.value=f.thickness,f.thicknessMap)m.thicknessMap.value=f.thicknessMap,n(f.thicknessMap,m.thicknessMapTransform);m.attenuationDistance.value=f.attenuationDistance,m.attenuationColor.value.copy(f.attenuationColor)}if(f.anisotropy>0){if(m.anisotropyVector.value.set(f.anisotropy*Math.cos(f.anisotropyRotation),f.anisotropy*Math.sin(f.anisotropyRotation)),f.anisotropyMap)m.anisotropyMap.value=f.anisotropyMap,n(f.anisotropyMap,m.anisotropyMapTransform)}if(m.specularIntensity.value=f.specularIntensity,m.specularColor.value.copy(f.specularColor),f.specularColorMap)m.specularColorMap.value=f.specularColorMap,n(f.specularColorMap,m.specularColorMapTransform);if(f.specularIntensityMap)m.specularIntensityMap.value=f.specularIntensityMap,n(f.specularIntensityMap,m.specularIntensityMapTransform)}function v(m,f){if(f.matcap)m.matcap.value=f.matcap}function T(m,f){let w=e.get(f).light;m.referencePosition.value.setFromMatrixPosition(w.matrixWorld),m.nearDistance.value=w.shadow.camera.near,m.farDistance.value=w.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:s}}function t0(t,e,n,i){let s={},r={},a=[],o=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS);function l(y,b){let A=b.program;i.uniformBlockBinding(y,A)}function c(y,b){let A=s[y.id];if(A===void 0)m(y),A=u(y),s[y.id]=A,y.addEventListener("dispose",w);let E=b.program;i.updateUBOMapping(y,E);let g=e.render.frame;if(r[y.id]!==g)h(y),r[y.id]=g}function u(y){let b=d();y.__bindingPointIndex=b;let A=t.createBuffer(),{__size:E,usage:g}=y;return t.bindBuffer(t.UNIFORM_BUFFER,A),t.bufferData(t.UNIFORM_BUFFER,E,g),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,b,A),A}function d(){for(let y=0;y<o;y++)if(a.indexOf(y)===-1)return a.push(y),y;return Gt("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function h(y){let b=s[y.id],{uniforms:A,__cache:E}=y;t.bindBuffer(t.UNIFORM_BUFFER,b);for(let g=0,M=A.length;g<M;g++){let G=A[g];if(Array.isArray(G))for(let N=0,F=G.length;N<F;N++)p(G[N],g,N,E);else p(G,g,0,E)}t.bindBuffer(t.UNIFORM_BUFFER,null)}function p(y,b,A,E){if(T(y,b,A,E)===!0){let{__offset:g,value:M}=y;if(Array.isArray(M)){let G=0;for(let N=0;N<M.length;N++){let F=M[N],X=f(F);if(v(F,y.__data,G),typeof F!=="number"&&typeof F!=="boolean"&&!F.isMatrix3&&!ArrayBuffer.isView(F))G+=X.storage/Float32Array.BYTES_PER_ELEMENT}}else v(M,y.__data,0);t.bufferSubData(t.UNIFORM_BUFFER,g,y.__data)}}function v(y,b,A){if(typeof y==="number"||typeof y==="boolean")b[0]=y;else if(y.isMatrix3)b[0]=y.elements[0],b[1]=y.elements[1],b[2]=y.elements[2],b[3]=0,b[4]=y.elements[3],b[5]=y.elements[4],b[6]=y.elements[5],b[7]=0,b[8]=y.elements[6],b[9]=y.elements[7],b[10]=y.elements[8],b[11]=0;else if(ArrayBuffer.isView(y))b.set(new y.constructor(y.buffer,y.byteOffset,b.length));else y.toArray(b,A)}function T(y,b,A,E){let g=y.value,M=b+"_"+A;if(E[M]===void 0){if(typeof g==="number"||typeof g==="boolean")E[M]=g;else if(ArrayBuffer.isView(g))E[M]=g.slice();else E[M]=g.clone();return!0}else{let G=E[M];if(typeof g==="number"||typeof g==="boolean"){if(G!==g)return E[M]=g,!0}else if(ArrayBuffer.isView(g))return!0;else if(G.equals(g)===!1)return G.copy(g),!0}return!1}function m(y){let b=y.uniforms,A=0,E=16;for(let M=0,G=b.length;M<G;M++){let N=Array.isArray(b[M])?b[M]:[b[M]];for(let F=0,X=N.length;F<X;F++){let R=N[F],k=Array.isArray(R.value)?R.value:[R.value];for(let Z=0,H=k.length;Z<H;Z++){let at=k[Z],K=f(at),et=A%E,tt=et%K.boundary,dt=et+tt;if(A+=tt,dt!==0&&E-dt<K.storage)A+=E-dt;R.__data=new Float32Array(K.storage/Float32Array.BYTES_PER_ELEMENT),R.__offset=A,A+=K.storage}}}let g=A%E;if(g>0)A+=E-g;return y.__size=A,y.__cache={},this}function f(y){let b={boundary:0,storage:0};if(typeof y==="number"||typeof y==="boolean")b.boundary=4,b.storage=4;else if(y.isVector2)b.boundary=8,b.storage=8;else if(y.isVector3||y.isColor)b.boundary=16,b.storage=12;else if(y.isVector4)b.boundary=16,b.storage=16;else if(y.isMatrix3)b.boundary=48,b.storage=48;else if(y.isMatrix4)b.boundary=64,b.storage=64;else if(y.isTexture)Ht("WebGLRenderer: Texture samplers can not be part of an uniforms group.");else if(ArrayBuffer.isView(y))b.boundary=16,b.storage=y.byteLength;else Ht("WebGLRenderer: Unsupported uniform value type.",y);return b}function w(y){let b=y.target;b.removeEventListener("dispose",w);let A=a.indexOf(b.__bindingPointIndex);a.splice(A,1),t.deleteBuffer(s[b.id]),delete s[b.id],delete r[b.id]}function C(){for(let y in s)t.deleteBuffer(s[y]);a=[],s={},r={}}return{bind:l,update:c,dispose:C}}var e0=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]),Vn=null;function n0(){if(Vn===null)Vn=new js(e0,16,16,Li,kn),Vn.name="DFG_LUT",Vn.minFilter=Qe,Vn.magFilter=Qe,Vn.wrapS=zn,Vn.wrapT=zn,Vn.generateMipmaps=!1,Vn.needsUpdate=!0;return Vn}class Nl{constructor(t={}){let{canvas:e=ph(),context:n=null,depth:i=!0,stencil:s=!1,alpha:r=!1,antialias:a=!1,premultipliedAlpha:o=!0,preserveDrawingBuffer:l=!1,powerPreference:c="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1,outputBufferType:h=mn}=t;this.isWebGLRenderer=!0;let p;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=n.getContextAttributes().alpha}else p=r;let v=h,T=new Set([co,lo,ro]),m=new Set([mn,mi,Ws,gs,no,io]),f=new Uint32Array(4),w=new Int32Array(4),C=new O,y=null,b=null,A=[],E=[],g=null;this.domElement=e,this.debug={checkShaderErrors:!0,diagnostics:{keywords:!1},onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=Ln,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let M=this,G=!1,N=null,F=null,X=null,R=null;this._outputColorSpace=gi;let k=0,Z=0,H=null,at=-1,K=null,et=new Ae,tt=new Ae,dt=null,At=new Kt(0),te=0,{width:zt,height:Y}=e,rt=1,lt=null,It=null,Ot=new Ae(0,0,zt,Y),Ft=new Ae(0,0,zt,Y),Ce=!1,$t=new tr,ee=!1,ue=!1,ne=new we,Le=new O,me=new Ae,Ze={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},Ne=!1;function Re(){return H===null?rt:1}let P=n;function Ue(x,D){return e.getContext(x,D)}let ae,be,S,_,L,V,it,st,ft,J,j,_t,Dt,pt,ot,Bt,kt,se,I,ct,Q,ut,Tt;try{let x={alpha:!0,depth:i,stencil:s,antialias:a,premultipliedAlpha:o,preserveDrawingBuffer:l,powerPreference:c,failIfMajorPerformanceCaveat:u};if("setAttribute"in e)e.setAttribute("data-engine",`three.js r${vc}`);if(e.addEventListener("webglcontextlost",Vt,!1),e.addEventListener("webglcontextrestored",fe,!1),e.addEventListener("webglcontextcreationerror",ce,!1),P===null){if(P=Ue("webgl2",x),P===null)if(Ue("webgl2"))throw Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes.");else throw Error("THREE.WebGLRenderer: Error creating WebGL context.")}nt()}catch(x){throw e.removeEventListener("webglcontextlost",Vt,!1),e.removeEventListener("webglcontextrestored",fe,!1),e.removeEventListener("webglcontextcreationerror",ce,!1),Gt("WebGLRenderer: "+x.message),x}function nt(){if(ae=new cm(P),ae.init(),Q=new Jg(P,ae),be=new jp(P,ae,t,Q),S=new Yg(P,ae),be.reversedDepthBuffer&&d)S.buffers.depth.setReversed(!0);F=P.createFramebuffer(),X=P.createFramebuffer(),R=P.createFramebuffer(),_=new dm(P),L=new Ng,V=new Zg(P,ae,S,L,be,Q,_),it=new lm(M),st=new fd(P),ut=new Kp(P,st),ft=new hm(P,st,_,ut),J=new pm(P,ft,st,ut,_),se=new fm(P,be,V),ot=new tm(L),j=new Lg(M,it,ae,be,ut,ot),_t=new jg(M,L),Dt=new Ug,pt=new Gg(ae),kt=new $p(M,it,S,J,p,o),Bt=new qg(M,J,be),Tt=new t0(P,_,be,S),I=new Qp(P,ae,_),ct=new um(P,ae,_),_.programs=j.programs,M.capabilities=be,M.extensions=ae,M.properties=L,M.renderLists=Dt,M.shadowMap=Bt,M.state=S,M.info=_}if(v!==mn)g=new gm(v,e.width,e.height,a,i,s);let mt=new su(M,P);this.xr=mt,this.getContext=function(){return P},this.getContextAttributes=function(){return P.getContextAttributes()},this.forceContextLoss=function(){let x=ae.get("WEBGL_lose_context");if(x)x.loseContext()},this.forceContextRestore=function(){let x=ae.get("WEBGL_lose_context");if(x)x.restoreContext()},this.getPixelRatio=function(){return rt},this.setPixelRatio=function(x){if(x===void 0)return;rt=x,this.setSize(zt,Y,!1)},this.getSize=function(x){return x.set(zt,Y)},this.setSize=function(x,D,W=!0){if(mt.isPresenting){Ht("WebGLRenderer: Can't change size while VR device is presenting.");return}if(zt=x,Y=D,e.width=Math.floor(x*rt),e.height=Math.floor(D*rt),W===!0)e.style.width=x+"px",e.style.height=D+"px";if(g!==null)g.setSize(e.width,e.height);this.setViewport(0,0,x,D)},this.getDrawingBufferSize=function(x){return x.set(zt*rt,Y*rt).floor()},this.setDrawingBufferSize=function(x,D,W){zt=x,Y=D,rt=W,e.width=Math.floor(x*W),e.height=Math.floor(D*W),this.setViewport(0,0,x,D)},this.setEffects=function(x){if(v===mn){Gt("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(x){for(let D=0;D<x.length;D++)if(x[D].isOutputPass===!0){Ht("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}g.setEffects(x||[])},this.getCurrentViewport=function(x){return x.copy(et)},this.getViewport=function(x){return x.copy(Ot)},this.setViewport=function(x,D,W,B){if(x.isVector4)Ot.set(x.x,x.y,x.z,x.w);else Ot.set(x,D,W,B);S.viewport(et.copy(Ot).multiplyScalar(rt).round())},this.getScissor=function(x){return x.copy(Ft)},this.setScissor=function(x,D,W,B){if(x.isVector4)Ft.set(x.x,x.y,x.z,x.w);else Ft.set(x,D,W,B);S.scissor(tt.copy(Ft).multiplyScalar(rt).round())},this.getScissorTest=function(){return Ce},this.setScissorTest=function(x){S.setScissorTest(Ce=x)},this.setOpaqueSort=function(x){lt=x},this.setTransparentSort=function(x){It=x},this.getClearColor=function(x){return x.copy(kt.getClearColor())},this.setClearColor=function(){kt.setClearColor(...arguments)},this.getClearAlpha=function(){return kt.getClearAlpha()},this.setClearAlpha=function(){kt.setClearAlpha(...arguments)},this.clear=function(x=!0,D=!0,W=!0){let B=0;if(x){let z=!1;if(H!==null){let vt=H.texture.format;z=T.has(vt)}if(z){let vt=H.texture.type,Et=m.has(vt),xt=kt.getClearColor(),Pt=kt.getClearAlpha(),{r:Ut,g:Qt,b:ie}=xt;if(Et)f[0]=Ut,f[1]=Qt,f[2]=ie,f[3]=Pt,P.clearBufferuiv(P.COLOR,0,f);else w[0]=Ut,w[1]=Qt,w[2]=ie,w[3]=Pt,P.clearBufferiv(P.COLOR,0,w)}else B|=P.COLOR_BUFFER_BIT}if(D)B|=P.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0);if(W)B|=P.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295);if(B!==0)P.clear(B)},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(x){x.setRenderer(this),N=x},this.dispose=function(){e.removeEventListener("webglcontextlost",Vt,!1),e.removeEventListener("webglcontextrestored",fe,!1),e.removeEventListener("webglcontextcreationerror",ce,!1),kt.dispose(),Dt.dispose(),pt.dispose(),L.dispose(),it.dispose(),J.dispose(),ut.dispose(),Tt.dispose(),j.dispose(),mt.dispose(),mt.removeEventListener("sessionstart",ht),mt.removeEventListener("sessionend",St),bt.stop()};function Vt(x){x.preventDefault(),Bs("WebGLRenderer: Context Lost."),G=!0}function fe(){Bs("WebGLRenderer: Context Restored."),G=!1;let x=_.autoReset,D=Bt.enabled,W=Bt.autoUpdate,B=Bt.needsUpdate,z=Bt.type;nt(),_.autoReset=x,Bt.enabled=D,Bt.autoUpdate=W,Bt.needsUpdate=B,Bt.type=z}function ce(x){Gt("WebGLRenderer: A WebGL context could not be created. Reason: ",x.statusMessage)}function un(x){let D=x.target;D.removeEventListener("dispose",un),vn(D)}function vn(x){hr(x),L.remove(x)}function hr(x){let D=L.get(x).programs;if(D!==void 0){if(D.forEach(function(W){j.releaseProgram(W)}),x.isShaderMaterial)j.releaseShaderCache(x)}}this.renderBufferDirect=function(x,D,W,B,z,vt){if(D===null)D=Ze;let Et=z.isMesh&&z.matrixWorld.determinantAffine()<0,xt=En(x,D,W,B,z);S.setMaterial(B,Et);let Pt=W.index,Ut=1;if(B.wireframe===!0){if(Pt=ft.getWireframeAttribute(W),Pt===void 0)return;Ut=2}let Qt=W.drawRange,ie=W.attributes.position,Nt=Qt.start*Ut,de=(Qt.start+Qt.count)*Ut;if(vt!==null)Nt=Math.max(Nt,vt.start*Ut),de=Math.min(de,(vt.start+vt.count)*Ut);if(Pt!==null)Nt=Math.max(Nt,0),de=Math.min(de,Pt.count);else if(ie!==void 0&&ie!==null)Nt=Math.max(Nt,0),de=Math.min(de,ie.count);let Fe=de-Nt;if(Fe<0||Fe===1/0)return;ut.setup(z,B,xt,W,Pt);let Ee,Se=I;if(Pt!==null)Ee=st.get(Pt),Se=ct,Se.setIndex(Ee);if(z.isMesh)if(B.wireframe===!0)S.setLineWidth(B.wireframeLinewidth*Re()),Se.setMode(P.LINES);else Se.setMode(P.TRIANGLES);else if(z.isLine){let Je=B.linewidth;if(Je===void 0)Je=1;if(S.setLineWidth(Je*Re()),z.isLineSegments)Se.setMode(P.LINES);else if(z.isLineLoop)Se.setMode(P.LINE_LOOP);else Se.setMode(P.LINE_STRIP)}else if(z.isPoints)Se.setMode(P.POINTS);else if(z.isSprite)Se.setMode(P.TRIANGLES);if(z.isBatchedMesh)if(!ae.get("WEBGL_multi_draw")){let{_multiDrawStarts:Je,_multiDrawCounts:wt,_multiDrawCount:tn}=z,le=Pt?st.get(Pt).bytesPerElement:1,yn=L.get(B).currentProgram.getUniforms();for(let Dn=0;Dn<tn;Dn++)yn.setValue(P,"_gl_DrawID",Dn),Se.render(Je[Dn]/le,wt[Dn])}else Se.renderMultiDraw(z._multiDrawStarts,z._multiDrawCounts,z._multiDrawCount);else if(z.isInstancedMesh)Se.renderInstances(Nt,Fe,z.count);else if(W.isInstancedBufferGeometry){let Je=W._maxInstanceCount!==void 0?W._maxInstanceCount:1/0,wt=Math.min(W.instanceCount,Je);Se.renderInstances(Nt,Fe,wt)}else Se.render(Nt,Fe)};function ur(x,D,W,B){if(N!==null&&x.isNodeMaterial)N.setObject(B,x);if(ee===!0)ot.setState(x,W,!1);if(x.transparent===!0&&x.side===on&&x.forceSinglePass===!1)x.side=Ve,x.needsUpdate=!0,hn(x,D,B),x.side=fs,x.needsUpdate=!0,hn(x,D,B),x.side=on;else hn(x,D,B)}this.compile=function(x,D,W=null){if(W===null)W=x;if(N!==null)N.renderStart(x,D,W);if(b=pt.get(W),b.init(D),E.push(b),W.traverseVisible(function(z){if(z.isLight&&z.layers.test(D.layers)){if(b.pushLight(z),z.castShadow)b.pushShadow(z)}}),x!==W)x.traverseVisible(function(z){if(z.isLight&&z.layers.test(D.layers)){if(b.pushLight(z),z.castShadow)b.pushShadow(z)}});if(b.setupLights(),N!==null)N.updateLights(b.state.lightsArray);if(ue=this.localClippingEnabled,ee=ot.init(this.clippingPlanes,ue),ee===!0)ot.setGlobalState(this.clippingPlanes,D);if(N!==null)Bt.render(b.state.shadowsArray,W,D);let B=new Set;if(x.traverse(function(z){if(!(z.isMesh||z.isPoints||z.isLine||z.isSprite))return;let vt=z.material;if(vt)if(Array.isArray(vt))for(let Et=0;Et<vt.length;Et++){let xt=vt[Et];ur(xt,W,D,z),B.add(xt)}else ur(vt,W,D,z),B.add(vt)}),b=E.pop(),N!==null)N.renderEnd();return B},this.compileAsync=function(x,D,W=null){let B=this.compile(x,D,W);return new Promise((z)=>{function vt(){if(B.forEach(function(Et){let Pt=L.get(Et).currentProgram;if(Pt===void 0||Pt.isReady())B.delete(Et)}),B.size===0){z(x);return}setTimeout(vt,10)}if(ae.get("KHR_parallel_shader_compile")!==null)vt();else setTimeout(vt,10)})};let U=null;function q(x){if(U)U(x)}function ht(){bt.stop()}function St(){bt.start()}let bt=new qh;if(bt.setAnimationLoop(q),typeof self<"u")bt.setContext(self);this.setAnimationLoop=function(x){U=x,mt.setAnimationLoop(x),x===null?bt.stop():bt.start()},mt.addEventListener("sessionstart",ht),mt.addEventListener("sessionend",St),this.render=function(x,D){if(D!==void 0&&D.isCamera!==!0){Gt("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(G===!0)return;if(N!==null)N.renderStart(x,D);let W=mt.enabled===!0&&mt.isPresenting===!0,B=g!==null&&(H===null||W)&&g.begin(M,H);if(x.matrixWorldAutoUpdate===!0)x.updateMatrixWorld();if(D.parent===null&&D.matrixWorldAutoUpdate===!0)D.updateMatrixWorld();if(mt.enabled===!0&&mt.isPresenting===!0&&(g===null||g.isCompositing()===!1)){if(mt.cameraAutoUpdate===!0)mt.updateCamera(D);D=mt.getCamera()}if(x.isScene===!0)x.onBeforeRender(M,x,D,H);if(b=pt.get(x,E.length),b.init(D),b.state.textureUnits=V.getTextureUnits(),E.push(b),ne.multiplyMatrices(D.projectionMatrix,D.matrixWorldInverse),$t.setFromProjectionMatrix(ne,$o,D.reversedDepth),ue=this.localClippingEnabled,ee=ot.init(this.clippingPlanes,ue),y=Dt.get(x,A.length),y.init(),A.push(y),mt.enabled===!0&&mt.isPresenting===!0){let Et=M.xr.getDepthSensingMesh();if(Et!==null)Yt(Et,D,-1/0,M.sortObjects)}if(Yt(x,D,0,M.sortObjects),y.finish(),N!==null)N.updateLights(b.state.lightsArray);if(M.sortObjects===!0)y.sort(lt,It);if(Ne=mt.enabled===!1||mt.isPresenting===!1||mt.hasDepthSensing()===!1,Ne)kt.addToRenderList(y,x);if(this.info.render.frame++,this.info.autoReset===!0)this.info.reset();if(ee===!0)ot.beginShadows();let z=b.state.shadowsArray;if(Bt.render(z,x,D),ee===!0)ot.endShadows();if((B&&g.hasRenderPass())===!1){let Et=y.opaque,xt=y.transmissive;if(b.setupLights(),D.isArrayCamera){let Pt=D.cameras;if(xt.length>0)for(let Ut=0,Qt=Pt.length;Ut<Qt;Ut++){let ie=Pt[Ut];ve(Et,xt,x,ie)}if(Ne)kt.render(x);for(let Ut=0,Qt=Pt.length;Ut<Qt;Ut++){let ie=Pt[Ut];he(y,x,ie,ie.viewport)}}else{if(xt.length>0)ve(Et,xt,x,D);if(Ne)kt.render(x);he(y,x,D)}}if(H!==null&&Z===0)V.updateMultisampleRenderTarget(H),V.updateRenderTargetMipmap(H);if(B)g.end(M);if(x.isScene===!0)x.onAfterRender(M,x,D);if(ut.resetDefaultState(),at=-1,K=null,E.pop(),E.length>0){if(b=E[E.length-1],V.setTextureUnits(b.state.textureUnits),ee===!0)ot.setGlobalState(M.clippingPlanes,b.state.camera)}else b=null;if(A.pop(),A.length>0)y=A[A.length-1];else y=null;if(N!==null)N.renderEnd()};function Yt(x,D,W,B){if(x.visible===!1)return;if(x.layers.test(D.layers)){if(x.isGroup)W=x.renderOrder;else if(x.isLOD){if(x.autoUpdate===!0)x.update(D)}else if(x.isLightProbeGrid)b.pushLightProbeGrid(x);else if(x.isLight){if(b.pushLight(x),x.castShadow)b.pushShadow(x)}else if(x.isSprite){if(!x.frustumCulled||x.intersectsFrustum($t)){if(B)me.setFromMatrixPosition(x.matrixWorld).applyMatrix4(ne);let Et=J.update(x),xt=x.material;if(xt.visible)y.push(x,Et,xt,W,me.z,null,D)}}else if(x.isMesh||x.isLine||x.isPoints){if(!x.frustumCulled||x.intersectsFrustum($t)){let Et=J.update(x),xt=x.material;if(B){if(x.boundingSphere!==void 0){if(x.boundingSphere===null)x.computeBoundingSphere();me.copy(x.boundingSphere.center)}else{if(Et.boundingSphere===null)Et.computeBoundingSphere();me.copy(Et.boundingSphere.center)}me.applyMatrix4(x.matrixWorld).applyMatrix4(ne)}if(Array.isArray(xt)){let Pt=Et.groups;for(let Ut=0,Qt=Pt.length;Ut<Qt;Ut++){let ie=Pt[Ut],Nt=xt[ie.materialIndex];if(Nt&&Nt.visible)y.push(x,Et,Nt,W,me.z,ie,D)}}else if(xt.visible)y.push(x,Et,xt,W,me.z,null,D)}}}let vt=x.children;for(let Et=0,xt=vt.length;Et<xt;Et++)Yt(vt[Et],D,W,B)}function he(x,D,W,B){let{opaque:z,transmissive:vt,transparent:Et}=x;if(b.setupLightsView(W),ee===!0)ot.setGlobalState(M.clippingPlanes,W);if(B)S.viewport(et.copy(B));if(z.length>0)Wt(z,D,W);if(vt.length>0)Wt(vt,D,W);if(Et.length>0)Wt(Et,D,W);S.buffers.depth.setTest(!0),S.buffers.depth.setMask(!0),S.buffers.color.setMask(!0),S.setPolygonOffset(!1)}function ve(x,D,W,B){if((W.isScene===!0?W.overrideMaterial:null)!==null)return;if(b.state.transmissionRenderTarget[B.id]===void 0){let Nt=ae.has("EXT_color_buffer_half_float")||ae.has("EXT_color_buffer_float");b.state.transmissionRenderTarget[B.id]=new gn(1,1,{generateMipmaps:!0,type:Nt?kn:mn,minFilter:Ci,samples:Math.max(4,be.samples),stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:re.workingColorSpace})}let vt=b.state.transmissionRenderTarget[B.id],Et=B.viewport||et;vt.setSize(Et.z*M.transmissionResolutionScale,Et.w*M.transmissionResolutionScale);let xt=M.getRenderTarget(),Pt=M.getActiveCubeFace(),Ut=M.getActiveMipmapLevel();if(M.setRenderTarget(vt),M.getClearColor(At),te=M.getClearAlpha(),te<1)M.setClearColor(16777215,0.5);if(M.clear(),Ne)kt.render(W);let Qt=M.toneMapping;M.toneMapping=Ln;let ie=B.viewport;if(B.viewport!==void 0)B.viewport=void 0;if(b.setupLightsView(B),ee===!0)ot.setGlobalState(M.clippingPlanes,B);if(Wt(x,W,B),V.updateMultisampleRenderTarget(vt),V.updateRenderTargetMipmap(vt),ae.has("WEBGL_multisampled_render_to_texture")===!1){let Nt=!1;for(let de=0,Fe=D.length;de<Fe;de++){let Ee=D[de],{object:Se,geometry:Je,material:wt,group:tn}=Ee;if(wt.side===on&&Se.layers.test(B.layers)){let le=wt.side;wt.side=Ve,wt.needsUpdate=!0,cn(Se,W,B,Je,wt,tn),wt.side=le,wt.needsUpdate=!0,Nt=!0}}if(Nt===!0)V.updateMultisampleRenderTarget(vt),V.updateRenderTargetMipmap(vt)}if(M.setRenderTarget(xt,Pt,Ut),M.setClearColor(At,te),ie!==void 0)B.viewport=ie;M.toneMapping=Qt}function Wt(x,D,W){let B=D.isScene===!0?D.overrideMaterial:null;for(let z=0,vt=x.length;z<vt;z++){let Et=x[z],{object:xt,geometry:Pt,group:Ut}=Et,Qt=Et.material;if(Qt.allowOverride===!0&&B!==null)Qt=B;if(xt.layers.test(W.layers))cn(xt,D,W,Pt,Qt,Ut)}}function cn(x,D,W,B,z,vt){if(N!==null&&z.isNodeMaterial)N.setObject(x,z);if(x.onBeforeRender(M,D,W,B,z,vt),x.modelViewMatrix.multiplyMatrices(W.matrixWorldInverse,x.matrixWorld),x.normalMatrix.getNormalMatrix(x.modelViewMatrix),z.onBeforeRender(M,D,W,B,x,vt),z.transparent===!0&&z.side===on&&z.forceSinglePass===!1)z.side=Ve,z.needsUpdate=!0,M.renderBufferDirect(W,D,B,z,x,vt),z.side=fs,z.needsUpdate=!0,M.renderBufferDirect(W,D,B,z,x,vt),z.side=on;else M.renderBufferDirect(W,D,B,z,x,vt);x.onAfterRender(M,D,W,B,z,vt)}function hn(x,D,W){if(D.isScene!==!0)D=Ze;let B=L.get(x),z=b.state.lights,vt=b.state.shadowsArray,Et=z.state.version,xt=j.getParameters(x,z.state,vt,D,W,b.state.lightProbeGridArray),Pt=j.getProgramCacheKey(xt),Ut=B.programs;B.environment=x.isMeshStandardMaterial||x.isMeshLambertMaterial||x.isMeshPhongMaterial?D.environment:null,B.fog=D.fog;let Qt=x.isMeshStandardMaterial||x.isMeshLambertMaterial&&!x.envMap||x.isMeshPhongMaterial&&!x.envMap;if(B.envMap=it.get(x.envMap||B.environment,Qt),B.envMapRotation=B.environment!==null&&x.envMap===null?D.environmentRotation:x.envMapRotation,Ut===void 0)x.addEventListener("dispose",un),Ut=new Map,B.programs=Ut;let ie=Ut.get(Pt);if(ie!==void 0){if(B.currentProgram===ie&&B.lightsStateVersion===Et)return ge(x,xt),ie}else{if(xt.uniforms=j.getUniforms(x),N!==null&&x.isNodeMaterial)N.build(x,W,xt);x.onBeforeCompile(xt,M),ie=j.acquireProgram(xt,Pt),Ut.set(Pt,ie),B.uniforms=xt.uniforms}let Nt=B.uniforms;if(!x.isShaderMaterial&&!x.isRawShaderMaterial||x.clipping===!0)Nt.clippingPlanes=ot.uniform;if(ge(x,xt),B.needsLights=ii(x),B.lightsStateVersion=Et,B.needsLights)Nt.ambientLightColor.value=z.state.ambient,Nt.lightProbe.value=z.state.probe,Nt.sunLights.value=z.state.sun,Nt.sunLightShadows.value=z.state.sunShadow,Nt.directionalLights.value=z.state.directional,Nt.directionalLightShadows.value=z.state.directionalShadow,Nt.spotLights.value=z.state.spot,Nt.spotLightShadows.value=z.state.spotShadow,Nt.rectAreaLights.value=z.state.rectArea,Nt.ltc_1.value=z.state.rectAreaLTC1,Nt.ltc_2.value=z.state.rectAreaLTC2,Nt.pointLights.value=z.state.point,Nt.pointLightShadows.value=z.state.pointShadow,Nt.hemisphereLights.value=z.state.hemi,Nt.sunShadowMatrix.value=z.state.sunShadowMatrix,Nt.sunShadowCascade.value=z.state.sunShadowCascade,Nt.directionalShadowMatrix.value=z.state.directionalShadowMatrix,Nt.spotLightMatrix.value=z.state.spotLightMatrix,Nt.spotLightMap.value=z.state.spotLightMap,Nt.pointShadowMatrix.value=z.state.pointShadowMatrix;return B.lightProbeGrid=b.state.lightProbeGridArray.length>0,B.currentProgram=ie,B.uniformsList=null,ie}function Si(x){if(x.uniformsList===null){let D=x.currentProgram.getUniforms();x.uniformsList=rr.seqWithValue(D.seq,x.uniforms)}return x.uniformsList}function ge(x,D){let W=L.get(x);W.outputColorSpace=D.outputColorSpace,W.batching=D.batching,W.batchingColor=D.batchingColor,W.instancing=D.instancing,W.instancingColor=D.instancingColor,W.instancingMorph=D.instancingMorph,W.skinning=D.skinning,W.morphTargets=D.morphTargets,W.morphNormals=D.morphNormals,W.morphColors=D.morphColors,W.morphTargetsCount=D.morphTargetsCount,W.numClippingPlanes=D.numClippingPlanes,W.numIntersection=D.numClipIntersection,W.vertexAlphas=D.vertexAlphas,W.vertexTangents=D.vertexTangents,W.toneMapping=D.toneMapping}function ye(x,D){if(x.length===0)return null;if(x.length===1)return x[0].texture!==null?x[0]:null;C.setFromMatrixPosition(D.matrixWorld);for(let W=0,B=x.length;W<B;W++){let z=x[W];if(z.texture!==null&&z.boundingBox.containsPoint(C))return z}return null}function En(x,D,W,B,z){if(D.isScene!==!0)D=Ze;V.resetTextureUnits();let vt=D.fog,Et=B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial?D.environment:null,xt=H===null?M.outputColorSpace:H.isXRRenderTarget===!0?H.texture.colorSpace:re.workingColorSpace,Pt=B.isMeshStandardMaterial||B.isMeshLambertMaterial&&!B.envMap||B.isMeshPhongMaterial&&!B.envMap,Ut=it.get(B.envMap||Et,Pt),Qt=B.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,ie=!!W.attributes.tangent&&(!!B.normalMap||B.anisotropy>0),Nt=!!W.morphAttributes.position,de=!!W.morphAttributes.normal,Fe=!!W.morphAttributes.color,Ee=Ln;if(B.toneMapped){if(H===null||H.isXRRenderTarget===!0)Ee=M.toneMapping}let Se=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,Je=Se!==void 0?Se.length:0,wt=L.get(B),tn=b.state.lights;if(ee===!0){if(ue===!0||x!==K){let Te=x===K&&B.id===at;ot.setState(B,x,Te)}}let le=!1;if(B.version===wt.__version){if(wt.needsLights&&wt.lightsStateVersion!==tn.state.version)le=!0;else if(wt.outputColorSpace!==xt)le=!0;else if(z.isBatchedMesh&&wt.batching===!1)le=!0;else if(!z.isBatchedMesh&&wt.batching===!0)le=!0;else if(z.isBatchedMesh&&wt.batchingColor===!0&&z._colorsTexture===null)le=!0;else if(z.isBatchedMesh&&wt.batchingColor===!1&&z._colorsTexture!==null)le=!0;else if(z.isInstancedMesh&&wt.instancing===!1)le=!0;else if(!z.isInstancedMesh&&wt.instancing===!0)le=!0;else if(z.isSkinnedMesh&&wt.skinning===!1)le=!0;else if(!z.isSkinnedMesh&&wt.skinning===!0)le=!0;else if(z.isInstancedMesh&&wt.instancingColor===!0&&z.instanceColor===null)le=!0;else if(z.isInstancedMesh&&wt.instancingColor===!1&&z.instanceColor!==null)le=!0;else if(z.isInstancedMesh&&wt.instancingMorph===!0&&z.morphTexture===null)le=!0;else if(z.isInstancedMesh&&wt.instancingMorph===!1&&z.morphTexture!==null)le=!0;else if(wt.envMap!==Ut)le=!0;else if(B.fog===!0&&wt.fog!==vt)le=!0;else if(wt.numClippingPlanes!==void 0&&(wt.numClippingPlanes!==ot.numPlanes||wt.numIntersection!==ot.numIntersection))le=!0;else if(wt.vertexAlphas!==Qt)le=!0;else if(wt.vertexTangents!==ie)le=!0;else if(wt.morphTargets!==Nt)le=!0;else if(wt.morphNormals!==de)le=!0;else if(wt.morphColors!==Fe)le=!0;else if(wt.toneMapping!==Ee)le=!0;else if(wt.morphTargetsCount!==Je)le=!0;else if(!!wt.lightProbeGrid!==b.state.lightProbeGridArray.length>0)le=!0}else le=!0,wt.__version=B.version;let yn=wt.currentProgram;if(le===!0){if(yn=hn(B,D,z),N&&B.isNodeMaterial)N.onUpdateProgram(B,yn,wt)}let Dn=!1,si=!1,Wi=!1,_e=yn.getUniforms(),De=wt.uniforms;if(S.useProgram(yn.program))Dn=!0,si=!0,Wi=!0;if(B.id!==at)at=B.id,si=!0;if(wt.needsLights){let Te=ye(b.state.lightProbeGridArray,z);if(wt.lightProbeGrid!==Te)wt.lightProbeGrid=Te,si=!0}if(Dn||K!==x){if(S.buffers.depth.getReversed()&&x.reversedDepth!==!0)x._reversedDepth=!0,x.updateProjectionMatrix();_e.setValue(P,"projectionMatrix",x.projectionMatrix),_e.setValue(P,"viewMatrix",x.matrixWorldInverse);let ai=_e.map.cameraPosition;if(ai!==void 0)ai.setValue(P,Le.setFromMatrixPosition(x.matrixWorld));if(be.logarithmicDepthBuffer)_e.setValue(P,"logDepthBufFC",2/(Math.log(x.far+1)/Math.LN2));if(B.isMeshPhongMaterial||B.isMeshToonMaterial||B.isMeshLambertMaterial||B.isMeshBasicMaterial||B.isMeshStandardMaterial||B.isShaderMaterial)_e.setValue(P,"isOrthographic",x.isOrthographicCamera===!0);if(K!==x)K=x,si=!0,Wi=!0}if(wt.needsLights){if(tn.state.sunShadowMap.length>0)_e.setValue(P,"sunShadowMap",tn.state.sunShadowMap,V);if(tn.state.directionalShadowMap.length>0)_e.setValue(P,"directionalShadowMap",tn.state.directionalShadowMap,V);if(tn.state.spotShadowMap.length>0)_e.setValue(P,"spotShadowMap",tn.state.spotShadowMap,V);if(tn.state.pointShadowMap.length>0)_e.setValue(P,"pointShadowMap",tn.state.pointShadowMap,V)}if(z.isSkinnedMesh){_e.setOptional(P,z,"bindMatrix"),_e.setOptional(P,z,"bindMatrixInverse");let Te=z.skeleton;if(Te){if(Te.boneTexture===null)Te.computeBoneTexture();_e.setValue(P,"boneTexture",Te.boneTexture,V)}}if(z.isBatchedMesh){if(_e.setOptional(P,z,"batchingTexture"),_e.setValue(P,"batchingTexture",z._matricesTexture,V),_e.setOptional(P,z,"batchingIdTexture"),_e.setValue(P,"batchingIdTexture",z._indirectTexture,V),_e.setOptional(P,z,"batchingColorTexture"),z._colorsTexture!==null)_e.setValue(P,"batchingColorTexture",z._colorsTexture,V)}let ri=W.morphAttributes;if(ri.position!==void 0||ri.normal!==void 0||ri.color!==void 0)se.update(z,W,yn);if(si||wt.receiveShadow!==z.receiveShadow)wt.receiveShadow=z.receiveShadow,_e.setValue(P,"receiveShadow",z.receiveShadow);if((B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial)&&B.envMap===null&&D.environment!==null)De.envMapIntensity.value=D.environmentIntensity;if(De.dfgLUT!==void 0)De.dfgLUT.value=n0();if(si){if(_e.setValue(P,"toneMappingExposure",M.toneMappingExposure),wt.needsLights)We(De,Wi);if(vt&&B.fog===!0)_t.refreshFogUniforms(De,vt);if(_t.refreshMaterialUniforms(De,B,rt,Y,b.state.transmissionRenderTarget[x.id]),wt.needsLights&&wt.lightProbeGrid){let Te=wt.lightProbeGrid;De.probesSH.value=Te.texture,De.probesMin.value.copy(Te.boundingBox.min),De.probesMax.value.copy(Te.boundingBox.max),De.probesResolution.value.copy(Te.resolution)}rr.upload(P,Si(wt),De,V)}if(B.isShaderMaterial&&B.uniformsNeedUpdate===!0)rr.upload(P,Si(wt),De,V),B.uniformsNeedUpdate=!1;if(B.isSpriteMaterial)_e.setValue(P,"center",z.center);if(_e.setValue(P,"modelViewMatrix",z.modelViewMatrix),_e.setValue(P,"normalMatrix",z.normalMatrix),_e.setValue(P,"modelMatrix",z.matrixWorld),B.uniformsGroups!==void 0){let Te=B.uniformsGroups;for(let ai=0,Xi=Te.length;ai<Xi;ai++){let Yl=Te[ai];Tt.update(Yl,yn),Tt.bind(Yl,yn)}}return yn}function We(x,D){x.ambientLightColor.needsUpdate=D,x.lightProbe.needsUpdate=D,x.sunLights.needsUpdate=D,x.sunLightShadows.needsUpdate=D,x.directionalLights.needsUpdate=D,x.directionalLightShadows.needsUpdate=D,x.pointLights.needsUpdate=D,x.pointLightShadows.needsUpdate=D,x.spotLights.needsUpdate=D,x.spotLightShadows.needsUpdate=D,x.rectAreaLights.needsUpdate=D,x.hemisphereLights.needsUpdate=D}function ii(x){return x.isMeshLambertMaterial||x.isMeshToonMaterial||x.isMeshPhongMaterial||x.isMeshStandardMaterial||x.isShadowMaterial||x.isShaderMaterial&&x.lights===!0}this.getActiveCubeFace=function(){return k},this.getActiveMipmapLevel=function(){return Z},this.getRenderTarget=function(){return H},this.setRenderTargetTextures=function(x,D,W){let B=L.get(x);if(B.__autoAllocateDepthBuffer=x.resolveDepthBuffer===!1,B.__autoAllocateDepthBuffer===!1)B.__useRenderToTexture=!1;L.get(x.texture).__webglTexture=D,L.get(x.depthTexture).__webglTexture=B.__autoAllocateDepthBuffer?void 0:W,B.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(x,D){let W=L.get(x);W.__webglFramebuffer=D,W.__useDefaultFramebuffer=D===void 0},this.setRenderTarget=function(x,D=0,W=0){H=x,k=D,Z=W;let B=null,z=!1,vt=!1;if(x){let xt=L.get(x);if(xt.__useDefaultFramebuffer!==void 0){S.bindFramebuffer(P.FRAMEBUFFER,xt.__webglFramebuffer),et.copy(x.viewport),tt.copy(x.scissor),dt=x.scissorTest,S.viewport(et),S.scissor(tt),S.setScissorTest(dt),at=-1;return}else if(xt.__webglFramebuffer===void 0)V.setupRenderTarget(x);else if(xt.__hasExternalTextures)V.rebindTextures(x,L.get(x.texture).__webglTexture,L.get(x.depthTexture).__webglTexture);else if(x.depthBuffer){let Qt=x.depthTexture;if(xt.__boundDepthTexture!==Qt){if(Qt!==null&&L.has(Qt)&&(x.width!==Qt.image.width||x.height!==Qt.image.height))throw Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");V.setupDepthRenderbuffer(x)}}let Pt=x.texture;if(Pt.isData3DTexture||Pt.isDataArrayTexture||Pt.isCompressedArrayTexture)vt=!0;let Ut=L.get(x).__webglFramebuffer;if(x.isWebGLCubeRenderTarget){if(Array.isArray(Ut[D]))B=Ut[D][W];else B=Ut[D];z=!0}else if(x.samples>0&&V.useMultisampledRTT(x)===!1)B=L.get(x).__webglMultisampledFramebuffer;else if(Array.isArray(Ut))B=Ut[W];else B=Ut;et.copy(x.viewport),tt.copy(x.scissor),dt=x.scissorTest}else et.copy(Ot).multiplyScalar(rt).floor(),tt.copy(Ft).multiplyScalar(rt).floor(),dt=Ce;if(W!==0)B=F;if(S.bindFramebuffer(P.FRAMEBUFFER,B))S.drawBuffers(x,B);if(S.viewport(et),S.scissor(tt),S.setScissorTest(dt),z){let xt=L.get(x.texture);P.framebufferTexture2D(P.FRAMEBUFFER,P.COLOR_ATTACHMENT0,P.TEXTURE_CUBE_MAP_POSITIVE_X+D,xt.__webglTexture,W)}else if(vt){let xt=D;for(let Pt=0;Pt<x.textures.length;Pt++){let Ut=L.get(x.textures[Pt]);P.framebufferTextureLayer(P.FRAMEBUFFER,P.COLOR_ATTACHMENT0+Pt,Ut.__webglTexture,W,xt)}}else if(x!==null&&W!==0){let xt=L.get(x.texture);P.framebufferTexture2D(P.FRAMEBUFFER,P.COLOR_ATTACHMENT0,P.TEXTURE_2D,xt.__webglTexture,W)}at=-1};function ql(x){let D=L.get(x);if(D.__readFormat!==x.format||D.__readType!==x.type)D.__readFormat=x.format,D.__readType=x.type,D.__formatReadable=be.textureFormatReadable(x.format),D.__typeReadable=be.textureTypeReadable(x.type);return D}if(this.readRenderTargetPixels=function(x,D,W,B,z,vt,Et,xt=0){if(!(x&&x.isWebGLRenderTarget)){Gt("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Pt=L.get(x).__webglFramebuffer;if(x.isWebGLCubeRenderTarget&&Et!==void 0)Pt=Pt[Et];if(Pt){S.bindFramebuffer(P.FRAMEBUFFER,Pt);try{let Ut=x.textures[xt],{format:Qt,type:ie}=Ut;if(x.textures.length>1)P.readBuffer(P.COLOR_ATTACHMENT0+xt);let Nt=ql(Ut);if(Nt.__formatReadable===!1){Gt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(Nt.__typeReadable===!1){Gt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}if(D>=0&&D<=x.width-B&&(W>=0&&W<=x.height-z))P.readPixels(D,W,B,z,Q.convert(Qt),Q.convert(ie),vt)}finally{let Ut=H!==null?L.get(H).__webglFramebuffer:null;S.bindFramebuffer(P.FRAMEBUFFER,Ut)}}},this.readRenderTargetPixelsAsync=async function(x,D,W,B,z,vt,Et,xt=0){if(!(x&&x.isWebGLRenderTarget))throw Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Pt=L.get(x).__webglFramebuffer;if(x.isWebGLCubeRenderTarget&&Et!==void 0)Pt=Pt[Et];if(Pt)if(D>=0&&D<=x.width-B&&(W>=0&&W<=x.height-z)){S.bindFramebuffer(P.FRAMEBUFFER,Pt);let Ut=x.textures[xt],{format:Qt,type:ie}=Ut;if(x.textures.length>1)P.readBuffer(P.COLOR_ATTACHMENT0+xt);let Nt=ql(Ut);if(Nt.__formatReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(Nt.__typeReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let de=P.createBuffer();P.bindBuffer(P.PIXEL_PACK_BUFFER,de),P.bufferData(P.PIXEL_PACK_BUFFER,vt.byteLength,P.STREAM_READ),P.readPixels(D,W,B,z,Q.convert(Qt),Q.convert(ie),0),P.bindBuffer(P.PIXEL_PACK_BUFFER,null);let Fe=H!==null?L.get(H).__webglFramebuffer:null;S.bindFramebuffer(P.FRAMEBUFFER,Fe);let Ee=P.fenceSync(P.SYNC_GPU_COMMANDS_COMPLETE,0);return P.flush(),await gh(P,Ee,4),P.bindBuffer(P.PIXEL_PACK_BUFFER,de),P.getBufferSubData(P.PIXEL_PACK_BUFFER,0,vt),P.bindBuffer(P.PIXEL_PACK_BUFFER,null),P.deleteBuffer(de),P.deleteSync(Ee),vt}else throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(x,D=null,W=0){let B=Math.pow(2,-W),z=Math.floor(x.image.width*B),vt=Math.floor(x.image.height*B),Et=D!==null?D.x:0,xt=D!==null?D.y:0;V.setTexture2D(x,0),P.copyTexSubImage2D(P.TEXTURE_2D,W,0,0,Et,xt,z,vt),S.unbindTexture()},this.copyTextureToTexture=function(x,D,W=null,B=null,z=0,vt=0){let Et,xt,Pt,Ut,Qt,ie,Nt,de,Fe,Ee=x.isCompressedTexture?x.mipmaps[vt]:x.image;if(W!==null)Et=W.max.x-W.min.x,xt=W.max.y-W.min.y,Pt=W.isBox3?W.max.z-W.min.z:1,Ut=W.min.x,Qt=W.min.y,ie=W.isBox3?W.min.z:0;else{let De=Math.pow(2,-z);if(Et=Math.floor(Ee.width*De),xt=Math.floor(Ee.height*De),x.isDataArrayTexture)Pt=Ee.depth;else if(x.isData3DTexture)Pt=Math.floor(Ee.depth*De);else Pt=1;Ut=0,Qt=0,ie=0}if(B!==null)Nt=B.x,de=B.y,Fe=B.z;else Nt=0,de=0,Fe=0;let Se=Q.convert(D.format),Je=Q.convert(D.type),wt;if(D.isData3DTexture)V.setTexture3D(D,0),wt=P.TEXTURE_3D;else if(D.isDataArrayTexture||D.isCompressedArrayTexture)V.setTexture2DArray(D,0),wt=P.TEXTURE_2D_ARRAY;else V.setTexture2D(D,0),wt=P.TEXTURE_2D;S.activeTexture(P.TEXTURE0),S.pixelStorei(P.UNPACK_FLIP_Y_WEBGL,D.flipY),S.pixelStorei(P.UNPACK_PREMULTIPLY_ALPHA_WEBGL,D.premultiplyAlpha),S.pixelStorei(P.UNPACK_ALIGNMENT,D.unpackAlignment);let tn=S.getParameter(P.UNPACK_ROW_LENGTH),le=S.getParameter(P.UNPACK_IMAGE_HEIGHT),yn=S.getParameter(P.UNPACK_SKIP_PIXELS),Dn=S.getParameter(P.UNPACK_SKIP_ROWS),si=S.getParameter(P.UNPACK_SKIP_IMAGES);S.pixelStorei(P.UNPACK_ROW_LENGTH,Ee.width),S.pixelStorei(P.UNPACK_IMAGE_HEIGHT,Ee.height),S.pixelStorei(P.UNPACK_SKIP_PIXELS,Ut),S.pixelStorei(P.UNPACK_SKIP_ROWS,Qt),S.pixelStorei(P.UNPACK_SKIP_IMAGES,ie);let Wi=x.isDataArrayTexture||x.isData3DTexture,_e=D.isDataArrayTexture||D.isData3DTexture;if(x.isDepthTexture){let De=L.get(x),ri=L.get(D),Te=L.get(De.__renderTarget),ai=L.get(ri.__renderTarget);S.bindFramebuffer(P.READ_FRAMEBUFFER,Te.__webglFramebuffer),S.bindFramebuffer(P.DRAW_FRAMEBUFFER,ai.__webglFramebuffer);for(let Xi=0;Xi<Pt;Xi++){if(Wi)P.framebufferTextureLayer(P.READ_FRAMEBUFFER,P.COLOR_ATTACHMENT0,L.get(x).__webglTexture,z,ie+Xi),P.framebufferTextureLayer(P.DRAW_FRAMEBUFFER,P.COLOR_ATTACHMENT0,L.get(D).__webglTexture,vt,Fe+Xi);P.blitFramebuffer(Ut,Qt,Et,xt,Nt,de,Et,xt,P.DEPTH_BUFFER_BIT,P.NEAREST)}S.bindFramebuffer(P.READ_FRAMEBUFFER,null),S.bindFramebuffer(P.DRAW_FRAMEBUFFER,null)}else if(z!==0||x.isRenderTargetTexture||L.has(x)){let De=L.get(x),ri=L.get(D);S.bindFramebuffer(P.READ_FRAMEBUFFER,X),S.bindFramebuffer(P.DRAW_FRAMEBUFFER,R);for(let Te=0;Te<Pt;Te++){if(Wi)P.framebufferTextureLayer(P.READ_FRAMEBUFFER,P.COLOR_ATTACHMENT0,De.__webglTexture,z,ie+Te);else P.framebufferTexture2D(P.READ_FRAMEBUFFER,P.COLOR_ATTACHMENT0,P.TEXTURE_2D,De.__webglTexture,z);if(_e)P.framebufferTextureLayer(P.DRAW_FRAMEBUFFER,P.COLOR_ATTACHMENT0,ri.__webglTexture,vt,Fe+Te);else P.framebufferTexture2D(P.DRAW_FRAMEBUFFER,P.COLOR_ATTACHMENT0,P.TEXTURE_2D,ri.__webglTexture,vt);if(z!==0)P.blitFramebuffer(Ut,Qt,Et,xt,Nt,de,Et,xt,P.COLOR_BUFFER_BIT,P.NEAREST);else if(_e)P.copyTexSubImage3D(wt,vt,Nt,de,Fe+Te,Ut,Qt,Et,xt);else P.copyTexSubImage2D(wt,vt,Nt,de,Ut,Qt,Et,xt)}S.bindFramebuffer(P.READ_FRAMEBUFFER,null),S.bindFramebuffer(P.DRAW_FRAMEBUFFER,null)}else if(_e)if(x.isDataTexture||x.isData3DTexture)P.texSubImage3D(wt,vt,Nt,de,Fe,Et,xt,Pt,Se,Je,Ee.data);else if(D.isCompressedArrayTexture)P.compressedTexSubImage3D(wt,vt,Nt,de,Fe,Et,xt,Pt,Se,Ee.data);else P.texSubImage3D(wt,vt,Nt,de,Fe,Et,xt,Pt,Se,Je,Ee);else if(x.isDataTexture)P.texSubImage2D(P.TEXTURE_2D,vt,Nt,de,Et,xt,Se,Je,Ee.data);else if(x.isCompressedTexture)P.compressedTexSubImage2D(P.TEXTURE_2D,vt,Nt,de,Ee.width,Ee.height,Se,Ee.data);else P.texSubImage2D(P.TEXTURE_2D,vt,Nt,de,Et,xt,Se,Je,Ee);if(S.pixelStorei(P.UNPACK_ROW_LENGTH,tn),S.pixelStorei(P.UNPACK_IMAGE_HEIGHT,le),S.pixelStorei(P.UNPACK_SKIP_PIXELS,yn),S.pixelStorei(P.UNPACK_SKIP_ROWS,Dn),S.pixelStorei(P.UNPACK_SKIP_IMAGES,si),vt===0&&D.generateMipmaps)P.generateMipmap(wt);S.unbindTexture()},this.initRenderTarget=function(x){if(L.get(x).__webglFramebuffer===void 0)V.setupRenderTarget(x)},this.initTexture=function(x){if(x.isCubeTexture)V.setTextureCube(x,0);else if(x.isData3DTexture)V.setTexture3D(x,0);else if(x.isDataArrayTexture||x.isCompressedArrayTexture)V.setTexture2DArray(x,0);else V.setTexture2D(x,0);S.unbindTexture()},this.resetState=function(){k=0,Z=0,H=null,S.reset(),ut.reset()},typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return $o}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;let e=this.getContext();e.drawingBufferColorSpace=re._getDrawingBufferColorSpace(t),e.unpackColorSpace=re._getUnpackColorSpace()}}function Pe(t,e){let n=document.createElement("canvas");n.width=t,n.height=e;let i=n.getContext("2d");if(!i)throw Error("a canvas has no 2D context");return[n,i]}var Dl=(t)=>{let e=t;return()=>{e+=1831565813;let n=Math.imul(e^e>>>15,e|1);return n^=n+Math.imul(n^n>>>7,n|61),((n^n>>>14)>>>0)/4294967296}},au=(t,e)=>e>0.7?t.glassLight:e<0.3?t.glassDark:t.glass,Hi=(t,e,n)=>{t.strokeStyle=e,t.lineWidth=n,t.lineJoin="round",t.lineCap="round",t.stroke()};function ou(t,e,n,i,s){let r=n+i*0.9;t.beginPath(),t.moveTo(e,n+s),t.lineTo(e,r),t.bezierCurveTo(e,n+i*0.35,e+i*0.38,n+i*0.12,e+i/2,n),t.bezierCurveTo(e+i*0.62,n+i*0.12,e+i,n+i*0.35,e+i,r),t.lineTo(e+i,n+s),t.closePath()}function vi(t,e,n,i,s=0.32){t.beginPath();for(let r=0;r<8;r+=1){let a=Math.PI/4*r-Math.PI/2,o=r%2===0?i:i*s;t.lineTo(e+Math.cos(a)*o,n+Math.sin(a)*o)}t.closePath()}function lu(t){let[e,n]=Pe(512,512),i=Dl(11);n.fillStyle=t.floor,n.fillRect(0,0,512,512);let s=4,r=512/s;for(let a=0;a<s;a+=1)for(let o=0;o<s;o+=1)if((a+o)%2===0||i()>0.7)n.fillStyle=t.stoneShade,n.globalAlpha=0.28,n.fillRect(o*r,a*r,r,r),n.globalAlpha=1;n.strokeStyle=t.floorJoint,n.lineWidth=6;for(let a=0;a<=s;a+=1)n.beginPath(),n.moveTo(a*r,0),n.lineTo(a*r,512),n.moveTo(0,a*r),n.lineTo(512,a*r),n.stroke();return e}function cu(t){let[e,n]=Pe(512,512),i=Dl(23);n.fillStyle=t.stone,n.fillRect(0,0,512,512);let s=8,r=512/s;for(let a=0;a<s;a+=1){let o=a%2===0?4:5,l=512/(a%2===0?4:4),c=a%2===0?0:-l/2;for(let u=0;u<=o;u+=1){let d=c+u*l;if(i()>0.55)n.fillStyle=t.stoneShade,n.globalAlpha=0.45,n.fillRect(d,a*r,l,r),n.globalAlpha=1;n.fillStyle=t.stoneJoint,n.fillRect(d-3,a*r,6,r)}n.fillStyle=t.stoneJoint,n.fillRect(0,a*r-3,512,6)}return e}function da(t){let[n,i]=Pe(1024,1024),s=512;i.translate(512,512),i.strokeStyle=t.rune,i.fillStyle=t.rune,i.lineCap="round",i.lineJoin="round",i.shadowColor=t.rune,i.shadowBlur=26;let r=(a,o)=>{i.lineWidth=o,i.beginPath(),i.arc(0,0,a,0,Math.PI*2),i.stroke()};r(480,14),r(452,4),r(330,10),r(300,4),r(150,8);for(let a=0;a<16;a+=1){if(i.save(),i.rotate(Math.PI*2*a/16),i.translate(0,-391),a%2===0)vi(i,0,0,34,0.3),i.fill();else i.beginPath(),i.arc(0,0,22,0.55*Math.PI,2.45*Math.PI),i.arc(9,-2,18,2.45*Math.PI,0.55*Math.PI,!0),i.closePath(),i.fill();i.restore()}i.lineWidth=7;for(let a=0;a<8;a+=1)i.save(),i.rotate(Math.PI*2*a/8),i.beginPath(),i.moveTo(0,-150),i.lineTo(0,-300),i.stroke(),i.restore();return vi(i,0,0,142,0.2),i.fill(),i.shadowBlur=0,i.fillStyle=t.bg,i.globalAlpha=0.55,vi(i,0,0,52,0.4),i.fill(),n}function Ul(t,e){let n=Dl(e==="rose"?5:9);if(e==="lancet"){let[l,c]=Pe(256,512);ou(c,14,10,228,492),c.save(),c.clip(),c.fillStyle=t.glass,c.fillRect(0,0,256,512);let u=3,d=8,h=228/u,p=492/d;for(let v=0;v<d;v+=1)for(let T=0;T<u;T+=1)c.fillStyle=au(t,n()),c.fillRect(14+T*h,10+v*p,h,p);if(t.night){c.fillStyle=t.sky;for(let v=0;v<6;v+=1)vi(c,40+n()*176,60+n()*380,5+n()*4,0.3),c.fill()}c.restore(),c.strokeStyle=t.stoneJoint,c.lineWidth=9;for(let v=1;v<u;v+=1)c.beginPath(),c.moveTo(14+v*h,10),c.lineTo(14+v*h,502),c.stroke();for(let v=1;v<d;v+=1)c.beginPath(),c.moveTo(14,10+v*p),c.lineTo(242,10+v*p),c.stroke();return ou(c,14,10,228,492),Hi(c,t.ink,12),l}let i=512,[s,r]=Pe(i,i),a=i/2;r.beginPath(),r.arc(a,a,236,0,Math.PI*2),r.save(),r.clip(),r.fillStyle=t.glass,r.fillRect(0,0,i,i);let o=i/8;for(let l=0;l<8;l+=1)for(let c=0;c<8;c+=1)r.fillStyle=au(t,n()),r.fillRect(c*o,l*o,o,o);if(r.fillStyle=t.sky,r.beginPath(),r.arc(a,a-8,98,0,Math.PI*2),r.fill(),t.night){r.fillStyle=t.glass,r.beginPath(),r.arc(a+52,a-34,88,0,Math.PI*2),r.fill(),r.fillStyle=t.sky;for(let[l,c,u]of[[150,120,12],[380,150,9],[120,340,8],[400,360,12],[310,90,7]])vi(r,l,c,u,0.3),r.fill()}else{r.strokeStyle=t.sky,r.lineWidth=12;for(let l=0;l<12;l+=1){let c=Math.PI*2*l/12;r.beginPath(),r.moveTo(a+Math.cos(c)*120,a-8+Math.sin(c)*120),r.lineTo(a+Math.cos(c)*190,a-8+Math.sin(c)*190),r.stroke()}}r.restore(),r.strokeStyle=t.stoneJoint,r.lineWidth=12;for(let l=1;l<8;l+=1)r.beginPath(),r.moveTo(l*o,0),r.lineTo(l*o,i),r.moveTo(0,l*o),r.lineTo(i,l*o),r.stroke();return r.beginPath(),r.arc(a,a,236,0,Math.PI*2),Hi(r,t.ink,16),r.beginPath(),r.arc(a,a,246,0,Math.PI*2),Hi(r,t.stoneShade,14),s}function hu(t,e){let[n,i]=Pe(256,512),s=()=>{i.beginPath(),i.moveTo(24,10),i.lineTo(232,10),i.lineTo(232,470),i.lineTo(128,400),i.lineTo(24,470),i.closePath()};if(s(),i.fillStyle=t.banner,i.fill(),i.save(),s(),i.clip(),i.fillStyle=t.ink,i.globalAlpha=0.18,i.fillRect(128,0,128,512),i.restore(),s(),Hi(i,t.bannerEdge,14),s(),Hi(i,t.ink,5),i.strokeStyle=t.bannerEdge,i.fillStyle=t.bannerEdge,i.lineWidth=9,i.lineCap="round",i.beginPath(),i.moveTo(40,56),i.lineTo(216,56),i.stroke(),e==="star")vi(i,128,220,84,0.22),i.fill(),i.beginPath(),i.arc(128,220,14,0,Math.PI*2),i.fillStyle=t.banner,i.fill();else if(e==="moon")i.beginPath(),i.arc(128,215,74,0,Math.PI*2),i.fill(),i.fillStyle=t.banner,i.beginPath(),i.arc(158,196,66,0,Math.PI*2),i.fill(),i.fillStyle=t.bannerEdge,vi(i,170,266,24,0.3),i.fill();else i.beginPath(),i.moveTo(128,120),i.lineTo(190,215),i.lineTo(128,320),i.lineTo(66,215),i.closePath(),i.lineWidth=11,i.stroke(),vi(i,128,215,34,0.3),i.fill();return n}function uu(t){let[e,n]=Pe(256,320);return n.fillStyle=t.woodDark,n.fillRect(8,8,240,304),n.fillStyle=t.woodLight,n.fillRect(24,24,208,272),n.fillStyle=t.wood,n.beginPath(),n.moveTo(24,296),n.lineTo(232,296),n.lineTo(232,24),n.lineTo(212,44),n.lineTo(212,276),n.lineTo(44,276),n.closePath(),n.fill(),n.fillStyle=t.woodDark,n.fillRect(44,44,168,232),n.strokeStyle=t.goldDark,n.lineWidth=8,n.strokeRect(44,44,168,232),n.strokeStyle=t.gold,n.lineWidth=4,n.strokeRect(56,56,144,208),n.fillStyle=t.gold,n.beginPath(),n.moveTo(128,84),n.lineTo(172,160),n.lineTo(128,238),n.lineTo(84,160),n.closePath(),n.fill(),n.fillStyle=t.woodDark,n.beginPath(),n.moveTo(128,122),n.lineTo(148,160),n.lineTo(128,202),n.lineTo(108,160),n.closePath(),n.fill(),n.strokeStyle=t.ink,n.lineWidth=5,n.strokeRect(8,8,240,304),e}function du(t){let[e,n]=Pe(128,192),i=(s,r,a,o)=>{n.beginPath(),n.moveTo(s,r),n.bezierCurveTo(s+o*0.2,r+(a-r)*0.3,s+o,r+(a-r)*0.5,s+o,a-o*0.9),n.arc(s,a-o*0.9,o,0,Math.PI,!1),n.bezierCurveTo(s-o,r+(a-r)*0.5,s-o*0.2,r+(a-r)*0.3,s,r),n.closePath()};return i(64,10,182,44),n.fillStyle=t.flame,n.fill(),Hi(n,t.ink,7),i(64,74,176,24),n.fillStyle=t.flameCore,n.fill(),e}function fu(t){let[e,n]=Pe(512,128),i=(s,r)=>{n.beginPath(),n.arc(s*128+64,64,54,0,Math.PI*2),n.fillStyle=r,n.fill(),Hi(n,t.ink,8)};i(0,t.paper),n.fillStyle=t.ink;for(let s of[-26,0,26])n.beginPath(),n.arc(64+s,70,9,0,Math.PI*2),n.fill();return i(1,t.gold),n.fillStyle=t.ink,n.beginPath(),n.moveTo(180,26),n.lineTo(204,26),n.lineTo(199,74),n.lineTo(185,74),n.closePath(),n.fill(),n.beginPath(),n.arc(192,94,8,0,Math.PI*2),n.fill(),i(2,"#58c878"),n.strokeStyle=t.paper,n.lineWidth=14,n.lineCap="round",n.lineJoin="round",n.beginPath(),n.moveTo(294,66),n.lineTo(312,84),n.lineTo(348,44),n.stroke(),i(3,"#ee4b4b"),n.strokeStyle=t.paper,n.beginPath(),n.moveTo(428,44),n.lineTo(468,84),n.moveTo(468,44),n.lineTo(428,84),n.stroke(),e}function fa(){let[t,e]=Pe(128,128),n=e.createRadialGradient(64,64,0,64,64,64);return n.addColorStop(0,"rgba(255,255,255,1)"),n.addColorStop(0.35,"rgba(255,255,255,.55)"),n.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=n,e.fillRect(0,0,128,128),t}function pu(){let[t,e]=Pe(256,512),n=[[20,60,0.55],[96,40,0.8],[150,70,0.45],[220,30,0.7]];for(let[i,s,r]of n)e.fillStyle=`rgba(255,255,255,${r})`,e.beginPath(),e.moveTo(i,0),e.lineTo(i+s,0),e.lineTo(i+s+90,512),e.lineTo(i+90,512),e.closePath(),e.fill();return t}function mu(t){let[e,n]=Pe(256,256);n.lineCap="round";let i=[[Math.PI*1.1,78,128],[Math.PI*1.32,84,138],[Math.PI*1.54,76,124]],s=196,r=204;for(let[a,o]of[[t.ink,34],[t.gold,20]]){n.strokeStyle=a,n.lineWidth=o;for(let[l,c,u]of i)n.beginPath(),n.moveTo(s+Math.cos(l)*c,r+Math.sin(l)*c),n.lineTo(s+Math.cos(l)*u,r+Math.sin(l)*u),n.stroke()}return e}var pa=0.034,Fl=0.02,Ol=0.024,i0=(t)=>{let e=new Image;return e.decoding="async",e.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`,e.decode().then(()=>e)};function Bl(t,e,n,i){let[s,r]=Pe(e,n);return r.drawImage(t,0,0,e,n),r.globalCompositeOperation="source-in",r.fillStyle=i,r.fillRect(0,0,e,n),s}function zl(t,e=48){return Array.from({length:e},(n,i)=>{let s=Math.PI*2*i/e;return[Math.cos(s)*t,Math.sin(s)*t]})}async function kl(t,e,n){let{rim:i,ink:s,edge:r}=n,a=await i0(t),o=(a.naturalHeight||a.height||e)/(a.naturalWidth||a.width||e),l=Math.round(e),c=Math.round(e*o),u=Math.ceil(e*(pa+Fl+Ol))+2,[d,h]=Pe(l+u*2,c+u*2),p=Bl(a,l,c,s),v=Bl(a,l,c,i),T=Bl(a,l,c,r);for(let[m,f]of zl(e*(pa+Fl)))h.drawImage(T,u+m+e*Ol*0.5,u+f+e*Ol);for(let[m,f]of zl(e*(pa+Fl)))h.drawImage(p,u+m,u+f);for(let[m,f]of zl(e*pa))h.drawImage(v,u+m,u+f);return h.drawImage(a,u,u,l,c),{canvas:d,pad:u/l}}function ma(t,e,n){let i=(r,a)=>Number.parseInt(r.slice(1+a*2,3+a*2),16),s=(r)=>Math.round(i(t,r)+(i(e,r)-i(t,r))*n).toString(16).padStart(2,"0");return`#${s(0)}${s(1)}${s(2)}`}var ar=Math.PI*2,ga=(t,e=0,n=1)=>Math.min(n,Math.max(e,t));function s0(t){let[e,n]=Pe(128,128),i=[[64,74,30],[36,80,22],[92,80,23],[48,54,24],[80,56,22]],s=t.paper,r=ma(t.paper,t.ink,t.night?0.42:0.28);n.fillStyle=t.ink;for(let[a,o,l]of i)n.beginPath(),n.arc(a,o,l+5,0,ar),n.fill();n.save(),n.beginPath();for(let[a,o,l]of i)n.moveTo(a+l,o),n.arc(a,o,l,0,ar);n.clip(),n.fillStyle=r,n.fillRect(0,0,128,128),n.fillStyle=s;for(let[a,o,l]of i)n.beginPath(),n.arc(a-7,o-8,l,0,ar),n.fill();return n.restore(),e}function r0(t){let[e,n]=Pe(64,64);n.translate(32,32),n.beginPath();for(let i=0;i<8;i+=1){let s=Math.PI/4*i-Math.PI/2,r=i%2===0?27:8;n.lineTo(Math.cos(s)*r,Math.sin(s)*r)}return n.closePath(),n.lineJoin="round",n.lineWidth=7,n.strokeStyle=t.ink,n.stroke(),n.fillStyle=t.gold,n.fill(),e}function a0(){let[t,e]=Pe(64,256),n=e.createLinearGradient(0,0,64,0);n.addColorStop(0,"rgba(255,255,255,0)"),n.addColorStop(0.5,"rgba(255,255,255,1)"),n.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=n,e.fillRect(0,0,64,256),e.globalCompositeOperation="destination-in";let i=e.createLinearGradient(0,256,0,0);return i.addColorStop(0,"rgba(255,255,255,1)"),i.addColorStop(0.55,"rgba(255,255,255,.45)"),i.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=i,e.fillRect(0,0,64,256),t}class Gl{hall;group=new Xe;runs=[];textures=new Map;planes=new Map;constructor(t){this.hall=t}texture(t,e){let n=this.textures.get(t);if(n)return n;let i=new xi(e());return i.colorSpace=gi,this.textures.set(t,i),i}plane(t,e,n){let i=this.planes.get(t);if(i)return i;let s=new Ie(e,n);return this.planes.set(t,s),s}get glow(){return this.hall.additive?Qn:Pn}puff(t,e){let n=this.hall,i=this.texture("cloud",()=>s0(n)),s=this.texture("sparkle",()=>r0(n)),r=Array.from({length:7},(o,l)=>{let c=ar*l/7+l%2*0.4,u=new Ks(new _s({map:i,transparent:!0,depthWrite:!1,fog:!1}));return u.renderOrder=8,this.group.add(u),{sprite:u,angle:c,reach:0.55+l%3*0.22,size:1.5+l*5%4*0.28,lift:-0.9+l%4*0.75,turn:(l%2?1:-1)*(0.25+l%3*0.1)}}),a=Array.from({length:4},(o,l)=>{let c=new Ks(new _s({map:s,transparent:!0,depthWrite:!1,depthTest:!1,fog:!1}));return c.renderOrder=9,this.group.add(c),{sprite:c,angle:ar*l/4+0.7}});this.runs.push({start:e,update:(o)=>{let l=ga(o/an),c=Ii(l/0.35),u=1-(1-l)**2,d=1-ga((l-0.55)/0.45);for(let h of r)h.sprite.position.set(t.x+Math.cos(h.angle)*h.reach*(0.5+u*1.3),t.y+h.lift*(0.6+u*0.5)+l*1.2,t.z+Math.sin(h.angle)*h.reach*(0.5+u*1.3)),h.sprite.scale.setScalar(Math.max(h.size*c,0.01)),h.sprite.material.rotation=h.angle*0.3+h.turn*l,h.sprite.material.opacity=d;for(let h of a){let p=0.9+u*1.6;h.sprite.position.set(t.x+Math.cos(h.angle)*p,t.y+0.5+u*1.4,t.z+Math.sin(h.angle)*p),h.sprite.scale.setScalar(0.5*Ii(ga((l-0.1)/0.3))),h.sprite.material.rotation=l*2.5,h.sprite.material.opacity=1-ga((l-0.5)/0.4)}return l<1},end:()=>{for(let o of r)this.group.remove(o.sprite),o.sprite.material.dispose();for(let o of a)this.group.remove(o.sprite),o.sprite.material.dispose()}})}circle(t,e){let n=this.hall,i=this.texture("rune",()=>{let[d,h]=Pe(256,256);return h.drawImage(da(n),0,0,256,256),d}),s=this.texture("column",a0),r=this.plane("disc",3.4,3.4),a=this.plane("column",2.2,5),o=new Xe;o.position.set(t.x,t.y+0.03,t.z);let l=new Jt(r,new Be({map:i,transparent:!0,depthWrite:!1,blending:this.glow,opacity:0,fog:!1}));l.rotation.x=-Math.PI/2,l.renderOrder=4,o.add(l);let c=new Xe;c.position.set(t.x,t.y+0.1,t.z);let u=new Be({map:s,color:n.rune,transparent:!0,depthWrite:!1,blending:this.glow,side:on,opacity:0,fog:!1});for(let d of[0,Math.PI/2]){let h=new Jt(a,u);h.position.y=2.5,h.rotation.y=d,h.renderOrder=6,c.add(h)}this.group.add(o,c),this.runs.push({start:e,update:(d)=>{let h=Di(d);return l.material.opacity=h.circle*(n.night?1:0.9),o.rotation.y=h.spin,u.opacity=h.light*0.75,c.scale.set(1,0.4+h.light*0.6,1),d<ln},end:()=>{this.group.remove(o,c),l.material.dispose(),u.dispose()}})}step(t){for(let e=this.runs.length-1;e>=0;e-=1){let n=this.runs[e];if(!n)continue;let i=t-n.start;if(i<0)continue;if(!n.update(i))n.end(),this.runs.splice(e,1)}return this.runs.length>0}dispose(){for(let t of this.runs)t.end();this.runs.length=0;for(let t of this.textures.values())t.dispose();for(let t of this.planes.values())t.dispose();this.textures.clear(),this.planes.clear(),this.group.removeFromParent()}}function gu(t,e=0.0001){e=Math.max(e,Number.EPSILON);let n={},i=t.getIndex(),s=t.getAttribute("position"),r=i?i.count:s.count,a=0,o=Object.keys(t.attributes),l={},c={},u=[],d=["getX","getY","getZ","getW"],h=["setX","setY","setZ","setW"];for(let w=0,C=o.length;w<C;w++){let y=o[w],b=t.attributes[y];l[y]=new b.constructor(new b.array.constructor(b.count*b.itemSize),b.itemSize,b.normalized);let A=t.morphAttributes[y];if(A){if(!c[y])c[y]=[];A.forEach((E,g)=>{let M=new E.array.constructor(E.count*E.itemSize);c[y][g]=new E.constructor(M,E.itemSize,E.normalized)})}}let p=e*0.5,v=Math.log10(1/e),T=Math.pow(10,v),m=p*T;for(let w=0;w<r;w++){let C=i?i.getX(w):w,y="";for(let b=0,A=o.length;b<A;b++){let E=o[b],g=t.getAttribute(E),M=g.itemSize;for(let G=0;G<M;G++)y+=`${Math.trunc(g[d[G]](C)*T+m)},`}if(y in n)u.push(n[y]);else{for(let b=0,A=o.length;b<A;b++){let E=o[b],g=t.getAttribute(E),M=t.morphAttributes[E],G=g.itemSize,N=l[E],F=c[E];for(let X=0;X<G;X++){let R=d[X],k=h[X];if(N[k](a,g[R](C)),M)for(let Z=0,H=M.length;Z<H;Z++)F[Z][k](a,M[Z][R](C))}}n[y]=a,u.push(a),a++}}let f=t.clone();for(let w in t.attributes){let C=l[w];if(f.setAttribute(w,new C.constructor(C.array.slice(0,a*C.itemSize),C.itemSize,C.normalized)),!(w in c))continue;for(let y=0;y<c[w].length;y++){let b=c[w][y];f.morphAttributes[w][y]=new b.constructor(b.array.slice(0,a*b.itemSize),b.itemSize,b.normalized)}}return f.setIndex(u),f}function o0(){let t=new Uint8Array([125,195,255]),e=new js(t,3,1,kr,mn);return e.minFilter=Nn,e.magFilter=Nn,e.generateMipmaps=!1,e.needsUpdate=!0,e}class Hl{steps=o0();lit=new Map;flat=new Map;ink=new Kt("#000000");hullMaterial=new Be({color:this.ink,side:Ve,fog:!1});toon(t,e){let n=this.lit.get(t);if(!n)n=new ni({color:e,gradientMap:this.steps}),this.lit.set(t,n);else n.color.set(e);return n}basic(t,e){let n=this.flat.get(t);if(!n)n=new Be({color:e,fog:!1}),this.flat.set(t,n);else n.color.set(e);return n}setInk(t){this.ink.set(t),this.hullMaterial.color.copy(this.ink)}dispose(){this.steps.dispose(),this.hullMaterial.dispose();for(let t of this.lit.values())t.dispose();for(let t of this.flat.values())t.dispose()}}function l0(t,e){let n=t.clone();n.deleteAttribute("uv"),n.deleteAttribute("normal");let i=gu(n,0.0001);i.computeVertexNormals();let s=i.getAttribute("position"),r=i.getAttribute("normal"),a=new O;for(let o=0;o<s.count;o+=1)a.fromBufferAttribute(r,o).multiplyScalar(e),s.setXYZ(o,s.getX(o)+a.x,s.getY(o)+a.y,s.getZ(o)+a.z);return s.needsUpdate=!0,i}function yi(t,e,n,i){let s=i.get(t.geometry);if(!s)s=l0(t.geometry,n),i.set(t.geometry,s);let r=new Jt(s,e.hullMaterial);return r.renderOrder=t.renderOrder,r.userData.hull=!0,t.add(r),t}var Vi=12,or=12,c0=["moon","star","crest"];class _u{textures=[];geometries=[];materials=[];texture(t,e){let n=new xi(t);if(n.colorSpace=gi,e)n.wrapS=Hs,n.wrapT=Hs,n.repeat.set(e[0],e[1]);else n.wrapS=zn,n.wrapT=zn;return n.anisotropy=4,this.textures.push(n),n}geometry(t){return this.geometries.push(t),t}material(t){return this.materials.push(t),t}dispose(){for(let t of this.textures)t.dispose();for(let t of this.geometries)t.dispose();for(let t of this.materials)t.dispose()}}function xu(t,e,n){let i=new _u,s=new Xe,r=new Map,a=Lt(e),o=a+9.5,l=(tt,dt={})=>i.material(new Be({map:tt,transparent:!0,depthWrite:!1,fog:!1,...dt})),c=t.additive?Qn:Pn,u=i.texture(lu(t),[o/2.2,o/2.2]),d=new Jt(i.geometry(new xs(o+1,72)),i.material(new ni({color:"#ffffff",map:u,gradientMap:n.steps})));d.rotation.x=-Math.PI/2,s.add(d);let h=new Jt(i.geometry(new xn(a+1.9,a+2.15,0.2,72)),n.toon("dais",t.stoneShade));h.position.y=0.1,yi(h,n,0.07,r),s.add(h);let p=new Jt(i.geometry(new Ie((a-0.7)*2,(a-0.7)*2)),l(i.texture(da(t)),{blending:c,opacity:t.night?t.runeGlow:1}));p.rotation.x=-Math.PI/2,p.position.y=0.215,s.add(p);let v=i.material(new ni({color:"#ffffff",map:i.texture(cu(t),[o*nn/7,Vi/5]),gradientMap:n.steps,side:Ve})),T=new Jt(i.geometry(new xn(o,o,Vi,72,1,!0)),v);T.position.y=Vi/2,s.add(T);let m=new Jt(i.geometry(new xs(o+1,48)),i.material(new Be({color:t.bg,side:on})));m.rotation.x=Math.PI/2,m.position.y=Vi,s.add(m);let f=i.geometry(new xn(0.6,0.66,Vi,14)),w=i.geometry(new xn(0.88,0.7,0.5,14)),C=i.geometry(new xn(0.78,0.9,0.6,14)),y=i.geometry(new Ie(2.2,4.4)),b=i.geometry(new xn(0.34,0.2,0.36,10)),A=i.geometry(new xn(0.06,0.06,0.7,6)),E=i.geometry(new Ie(0.62,0.93)),g=i.geometry(new Ie(2.6,2.6)),M=l(i.texture(du(t)),{transparent:!0,alphaTest:0.35,depthWrite:!0}),G=l(i.texture(fa()),{color:t.flame,blending:c,opacity:t.night?0.55:0.28}),N=c0.map((tt)=>i.material(new Be({map:i.texture(hu(t,tt)),transparent:!0,alphaTest:0.4,fog:!1}))),F=[],X=(tt,dt,At,te)=>(te.position.set(Math.sin(tt)*dt,At,Math.cos(tt)*dt),te.rotation.y=tt+Math.PI,s.add(te),te);for(let tt=0;tt<or;tt+=1){let dt=nn*(tt+0.5)/or,At=new Jt(f,n.toon("pillar",t.stone));X(dt,o-0.7,Vi/2,At),yi(At,n,0.06,r);let te=new Jt(w,n.toon("pillar",t.stone));X(dt,o-0.7,Vi-0.55,te);let zt=new Jt(C,n.toon("pillar",t.stone));X(dt,o-0.7,0.3,zt);let Y=new Jt(y,N[tt%N.length]??N[0]);X(dt,o-1.34,6.8,Y);let rt=new Jt(A,n.toon("iron",t.woodDark));X(dt,o-1.4,2.8,rt),rt.rotation.x=Math.PI/2;let lt=new Jt(b,n.toon("iron",t.woodDark));X(dt,o-1.75,2.95,lt),yi(lt,n,0.04,r);let It=new Jt(E,M);It.position.set(Math.sin(dt)*(o-1.75),3.5,Math.cos(dt)*(o-1.75)),It.renderOrder=3,s.add(It);let Ot=new Jt(g,G);Ot.position.copy(It.position),Ot.renderOrder=2,s.add(Ot),F.push({body:It,halo:Ot,phase:tt*1.7,base:1})}let R=i.geometry(new Ie(2.6,5.2)),k=i.geometry(new Ie(4.6,4.6)),Z=l(i.texture(Ul(t,"lancet")),{alphaTest:0.3,depthWrite:!0,transparent:!1}),H=l(i.texture(Ul(t,"rose")),{alphaTest:0.3,depthWrite:!0,transparent:!1}),at=i.geometry(new Ie(3.4,10)),K=l(i.texture(pu()),{color:t.beam,opacity:t.beamAlpha,blending:c,side:on}),et=[];for(let tt=0;tt<or;tt+=1){let dt=nn*tt/or,At=tt===or/2,te=new Jt(At?k:R,At?H:Z);X(dt,o-0.12,At?7.1:6.2,te);let zt=new Jt(at,K),Y=o-4.4;zt.position.set(Math.sin(dt)*Y,4.4,Math.cos(dt)*Y),zt.rotation.set(0,dt+Math.PI,0),zt.rotateX(-0.62),zt.renderOrder=1,s.add(zt),et.push(zt)}return{group:s,flames:F,beams:et,wallRadius:o,dispose(){for(let tt of r.values())tt.dispose();i.dispose()}}}function vu(t,e,n){for(let i of t){let s=n?1:1+0.09*Math.sin(e*9+i.phase)+0.05*Math.sin(e*17+i.phase*2);i.body.scale.set(s*0.96,s*(1.02+(n?0:0.06*Math.sin(e*11+i.phase))),1),i.halo.scale.setScalar(n?1:0.95+0.1*Math.sin(e*7+i.phase))}}function yu(t){let e=()=>{let p=t.idleMs??80;return typeof p==="function"?p():p},{host:n}=t,i=!0,s,r=0,a=!1,o=Number.NEGATIVE_INFINITY,l=!1,c=()=>l||!i||n.hidden(),u=()=>{if(s===void 0)return;n.cancel(s),s=void 0},d=(p)=>{if(s=void 0,c())return;if(a||p-o>=e()){let v=r===0?16:Math.min(p-r,100);r=p,o=p,a=t.frame(p,v)}if(a||e()>0)s=n.request(d)},h=()=>{if(s!==void 0||c())return;r=0,s=n.request(d)};return{get state(){if(c())return"paused";return a?"live":"idle"},wake(){a=!0,h()},setVisible(p){if(i=p,c())u();else h()},sync(){if(c())u();else h()},dispose(){l=!0,u()}}}var Mu=2;var bu=(t,e)=>Math.abs(t.x-e.x)<(t.w+e.w)/2+2&&Math.abs(t.y-e.y)<(t.h+e.h)/2+2,h0=(t,e,n)=>n<e?(e+n)/2:Math.min(n,Math.max(e,t));function Su(t,e,n,i){let s=t.w/2+2,r=i.width-t.w/2-2,a=t.h/2,o=i.height-t.h/2,l=[...e,...n],c=[t.x,...t.above?[t.above.x]:[],...l.flatMap((p)=>[p.x-(p.w+t.w)/2-2,p.x+(p.w+t.w)/2+2])].map((p)=>h0(p,s,r)),u=[t.y,...t.above?[t.above.y]:[],...l.flatMap((p)=>[p.y-(p.h+t.h)/2-2,p.y+(p.h+t.h)/2+2])].filter((p)=>p>=a&&p<=o),d,h=Number.POSITIVE_INFINITY;for(let p of c)for(let v of u){let T=t.above,m=Math.min(Math.hypot(p-t.x,(v-t.y)*1.5),T?Math.hypot(p-T.x,(v-T.y)*1.5)+40:Number.POSITIVE_INFINITY);if(m>=h)continue;let f={x:p,y:v,w:t.w,h:t.h};if(l.some((w)=>bu(f,w)))continue;d=f,h=m}return d}function Tu(t,e,n=[]){let i=t.map(({x:l,y:c})=>({x:l,y:c})),s=[],r=!0,a=0,o=t.map((l,c)=>c).sort((l,c)=>(t[c]?.y??0)-(t[l]?.y??0)||(t[l]?.x??0)-(t[c]?.x??0)||l-c);for(let l of o){let c=t[l];if(!c)continue;let u=Su(c,s,n,e);if(!u){if(u=Su(c,s,[],e),u&&n.some((h)=>bu(u,h)))a+=1}if(!u)r=!1;let d=u??c;s.push(d),i[l]={x:d.x,y:d.y}}return{spots:i,clear:r,covering:a}}var u0=1.06,d0=0.68,wu=12,f0=16;class Vl{labels;click;root=document.createElement("div");items=new Map;point=new O;local=new O;constructor(t,e,n){this.labels=e;this.click=n;this.root.className="rt-names",t.appendChild(this.root)}paint(t){let e=this.root.style;e.setProperty("--rt-gold",t.gold),e.setProperty("--rt-gold-dark",t.goldDark),e.setProperty("--rt-plate-ink",t.plateInk),e.setProperty("--rt-ink",t.ink),e.setProperty("--rt-font",Mt)}set(t,e){for(let n of this.items.values())n.el.remove();this.items.clear();for(let n of t){if(n.init.kind==="owner")continue;let i=document.createElement("button");if(i.type="button",i.className="rt-name",i.textContent=n.init.name,i.setAttribute("aria-label",n.init.kind==="agent"?this.labels.seat(n.init.name,e(n)):n.init.name),n.init.id)i.dataset.seat=n.init.id;i.addEventListener("click",(s)=>this.click(n,Ct(s,i))),this.root.appendChild(i),this.items.set(n,{el:i,x:0,y:0,shown:!1})}}mark(t,e){let n=this.items.get(t);if(n)n.el.textContent=e?`${e} ${t.init.name}`:t.init.name}relabel(t,e){let n=this.items.get(t);if(n&&t.init.kind==="agent")n.el.setAttribute("aria-label",this.labels.seat(t.init.name,e))}size(t){this.root.style.setProperty("--rt-name-size",`${Math.max(wu,Math.min(f0,t*0.0125)).toFixed(1)}px`)}place(t,e,n,i,s){t.updateMatrixWorld();let r=[];for(let[l,c]of this.items){this.local.copy(e),l.group.worldToLocal(this.local);let u=this.local.z>=0?1:-1;this.point.set(0,u0,u*d0),l.group.localToWorld(this.point),this.point.project(t);let d=(this.point.x*0.5+0.5)*n,h=(-this.point.y*0.5+0.5)*i,v=this.point.z<1&&d>-n*0.05&&d<n*1.05&&h>-i*0.05&&h<i*1.05&&l!==s&&l.group.visible&&!l.labelHidden;if(v!==c.shown)c.shown=v,c.el.style.visibility=v?"visible":"hidden";if(!v)continue;r.push({item:c,podium:l,x:d,y:h,w:c.el.offsetWidth,h:c.el.offsetHeight||wu*1.8})}let a=this.faces(t,e,n,i);for(let l of r){let c=a.get(l.podium);if(c)l.above={x:c.x,y:c.y-c.h/2-l.h/2-Mu}}let o=Tu(r,{width:n,height:i},[...a.values()]);return r.forEach(({item:l},c)=>{let u=o.spots[c];if(!u)return;if(Math.abs(u.x-l.x)>0.25||Math.abs(u.y-l.y)>0.25)l.x=u.x,l.y=u.y,l.el.style.transform=`translate(${u.x.toFixed(1)}px, ${u.y.toFixed(1)}px) translate(-50%, -50%)`}),o.clear}faces(t,e,n,i){let s=new Map,r=[e.x,e.y,e.z];for(let a of this.items.keys()){if(a.init.kind!=="agent")continue;if(!a.group.visible||!a.board.visible)continue;a.board.getWorldPosition(this.point);let o=[this.point.x,this.point.y,this.point.z],{POSITIVE_INFINITY:l,NEGATIVE_INFINITY:c,POSITIVE_INFINITY:u,NEGATIVE_INFINITY:d}=Number,h=!1;for(let[p,v,T]of Ps(o,a.board.scale.y,r)){if(this.point.set(p,v,T).project(t),this.point.z>=1)h=!0;let m=(this.point.x*0.5+0.5)*n,f=(-this.point.y*0.5+0.5)*i;l=Math.min(l,m),c=Math.max(c,m),u=Math.min(u,f),d=Math.max(d,f)}if(h)continue;s.set(a,{x:(l+c)/2,y:(u+d)/2,w:c-l,h:d-u})}return s}dispose(){this.root.remove(),this.items.clear()}}var Eu=0.62;function p0(t,e){let n=Math.atan2(t,e),i=(s)=>Math.max(-Eu,Math.min(Eu,s));if(Math.abs(n)<=Math.PI/2)return i(n);return Math.PI+i(Tn(n-Math.PI))}var lr=1.3,m0=1.24,g0=0.31,_0=[512,128],_a={waiting:0,alert:1,done:2,error:3};function Au(t){switch(t){case"thinking":case"working":return"waiting";case"waiting":return"alert";case"done":return"done";case"error":return"error";default:return null}}class Wl{hall;geometries=[];textures=[];hulls=new Map;plinth=this.own(new Hn(1.84,0.2,1.4));body;slab=this.own(new Hn(1.98,0.14,1.5));trim=this.own(new Hn(2.01,0.04,1.53));panelPlane=this.own(new Ie(0.84,1.05));platePlane=this.own(new Ie(m0,g0));glowPlane=this.own(new Ie(4.8,4.8));badgePlanes;panelTexture;glowTexture;badgeTexture;marksTexture;marksPlane=this.own(new Ie(1.25,1.25));constructor(t){this.hall=t;let e=new xn(0.82*Math.SQRT2,0.72*Math.SQRT2,1,4,1);e.rotateY(Math.PI/4),this.body=this.own(e),this.panelTexture=this.texture(uu(t)),this.glowTexture=this.texture(fa()),this.badgeTexture=this.texture(fu(t)),this.marksTexture=this.texture(mu(t));let n=(i)=>{let s=new Ie(0.56,0.56),r=s.getAttribute("uv");for(let a=0;a<r.count;a+=1)r.setX(a,(i+r.getX(a))/4);return this.own(s)};this.badgePlanes={waiting:n(_a.waiting),alert:n(_a.alert),done:n(_a.done),error:n(_a.error)}}own(t){return this.geometries.push(t),t}texture(t){let e=new xi(t);return e.colorSpace=gi,e.wrapS=zn,e.wrapT=zn,e.anisotropy=4,e.minFilter=Qe,this.textures.push(e),e}dispose(){for(let t of this.geometries)t.dispose();for(let t of this.hulls.values())t.dispose();for(let t of this.textures)t.dispose()}}class xa{init;kit;group=new Xe;rig=new Xe;board;boardMaterial;glow;glowMaterial;badge;badgeMaterial;marks;marksMaterial;marksSince=0;marksOn=!1;hits=[];plateTexture;plateMaterial;panelMaterial;shown=null;closedMap;talkMap;plateText={text:"",px:0};speak=0;bob=0;boardY=0;labelHidden=!1;phase=Math.random()*6;constructor(t,e,n){this.init=t;this.kit=e;let{hall:i}=e,s=(w)=>(w.userData.seat=t.id??null,w.userData.kind=t.kind,this.hits.push(w),w),r=new Jt(e.plinth,n.toon("woodDark",i.woodDark));r.position.y=0.1,yi(r,n,0.045,e.hulls);let a=new Jt(e.body,n.toon("wood",i.wood));a.scale.set(1,1,0.756);let o=t.kind==="owner";a.scale.y=o?0.3:1,a.position.y=o?0.35:0.7,yi(a,n,0.045,e.hulls);let l=new Jt(e.slab,n.toon("woodLight",i.woodLight));l.position.y=o?0.58:1.27,yi(l,n,0.045,e.hulls);let c=new Jt(e.trim,n.toon("gold",i.gold));c.position.y=o?0.51:1.2,this.group.add(r,s(a),s(l),c),this.panelMaterial=new ni({map:e.panelTexture,transparent:!0,gradientMap:n.steps});let u=new Jt(e.panelPlane,this.panelMaterial);u.position.set(0,0.68,0.64),u.visible=!o,this.group.add(u);let[d,h]=_0,[p,v]=Pe(d,h);this.plateTexture=e.texture(p),this.plateText=Bo(v,t.name,d,h,i),this.plateMaterial=new Be({map:this.plateTexture,fog:!1});let T=new Jt(e.platePlane,this.plateMaterial);T.position.set(0,o?0.36:1.06,0.68),T.rotation.x=-0.16;let m=new Jt(e.platePlane,this.plateMaterial);m.position.set(0,o?0.36:1.06,-0.68),m.rotation.y=Math.PI,m.rotation.x=-0.16,this.group.add(s(T),s(m));let f=new Be({transparent:!0,alphaTest:0.4,fog:!1});if(this.boardMaterial=f,this.board=new Jt(new Ie(yt,yt),f),this.board.visible=!1,this.board.position.y=lr+yt/2,s(this.board),this.glowMaterial=new Be({map:e.glowTexture,color:t.accent,transparent:!0,opacity:0,depthWrite:!1,fog:!1,blending:i.additive?Qn:Pn}),this.glow=new Jt(e.glowPlane,this.glowMaterial),this.glow.position.set(0,lr+yt/2,-0.5),this.glow.visible=!1,this.badgeMaterial=new Be({map:e.badgeTexture,transparent:!0,alphaTest:0.2,fog:!1}),this.badge=new Jt(e.badgePlanes.waiting,this.badgeMaterial),this.badge.position.set(1.05,lr+yt,0.05),this.badge.visible=!1,this.badge.renderOrder=5,this.marksMaterial=new Be({map:e.marksTexture,transparent:!0,alphaTest:0.2,depthTest:!1,depthWrite:!1,fog:!1}),this.marks=new Jt(e.marksPlane,this.marksMaterial),this.marks.position.set(-1,lr+yt*0.76,0.2),this.marks.visible=!1,this.marks.renderOrder=5,t.kind==="agent")this.rig.position.set(0,0,-0.08),this.rig.add(this.glow,this.board,this.badge,this.marks),this.group.add(this.rig)}setSticker(t){let e=this.closedMap,n=this.kit.texture(t);this.closedMap=n,this.boardMaterial.map=n,this.boardMaterial.needsUpdate=!0;let i=t.height/t.width;this.board.scale.set(1,i,1),this.boardY=lr+yt*i/2,this.board.position.y=this.boardY,this.glow.position.y=this.boardY,this.badge.position.y=this.board.position.y+yt*i/2+0.02,this.board.visible=!0,e?.dispose()}setTalk(t){let e=this.talkMap;if(this.talkMap=t?this.kit.texture(t):void 0,this.boardMaterial.map===e)this.boardMaterial.map=this.closedMap??null;e?.dispose()}mouth(t){let e=t&&this.talkMap?this.talkMap:this.closedMap;if(e&&this.boardMaterial.map!==e)this.boardMaterial.map=e;return this.talkMap!==void 0}markFrame(t,e,n){let i=t&&!n;if(i&&!this.marksOn)this.marksSince=e;if(this.marksOn=i,!i)return this.marks.visible=!1,!1;let s=Math.min((e-this.marksSince)/0.4,1),r=1.70158,a=1+(r+1)*(s-1)**3+r*(s-1)**2;return this.marks.visible=!0,this.marks.scale.setScalar(Math.max(a,0.01)),s<1}setBadge(t){if(t===this.shown)return;if(this.shown=t,this.badge.visible=t!==null,t)this.badge.geometry=this.kit.badgePlanes[t]}setDim(t){this.boardMaterial.color.set(t?"#7a7f8f":"#ffffff")}face(t){let e=this.group.worldToLocal(t.clone());this.rig.rotation.y=p0(e.x,e.z)}dispose(){this.plateTexture.dispose(),this.plateMaterial.dispose(),this.panelMaterial.dispose(),this.closedMap?.dispose(),this.talkMap?.dispose(),this.boardMaterial.dispose(),this.board.geometry.dispose(),this.glowMaterial.dispose(),this.badgeMaterial.dispose(),this.marksMaterial.dispose()}}function Cu(t,e){let n=document.createElement("div");n.className="rt-speed",n.setAttribute("aria-hidden","true"),n.style.cssText="position:absolute;inset:0;pointer-events:none;opacity:0;background:repeating-conic-gradient(from 3deg at 50% 52%,rgba(255,255,255,.85) 0 .55deg,transparent .55deg 5.2deg);-webkit-mask-image:radial-gradient(ellipse at 50% 52%,transparent 34%,#000 74%);mask-image:radial-gradient(ellipse at 50% 52%,transparent 34%,#000 74%);",t.appendChild(n);let i;return{play(){if(e())return!1;if(n.dataset.playing="",typeof n.animate==="function")n.animate([{opacity:0,transform:"scale(1.18)"},{opacity:0.9,transform:"scale(1.04)",offset:0.3},{opacity:0,transform:"scale(1)"}],{duration:400,easing:"ease-out"});else n.style.opacity="0.9";if(i!==void 0)clearTimeout(i);return i=setTimeout(()=>{delete n.dataset.playing,n.style.opacity="0"},400),!0},dispose(){if(i!==void 0)clearTimeout(i);n.remove()}}}var x0=2,v0=1.5,y0=60,Ru=8,S0=1.22,M0=0.82,Iu=(t,e,n,i)=>t+(e-t)*(1-Math.exp(-n*i)),Xl=0.2,b0=2,Pu=(t)=>t.init.id??t.init.kind;function lS(t,e,n){let i=window.matchMedia("(prefers-reduced-motion: reduce)"),s=e.reducedMotion==="auto"||e.reducedMotion===void 0?i.matches:e.reducedMotion,r=window.matchMedia("(pointer: coarse)").matches,a=e.lowPower==="auto"||e.lowPower===void 0?r||Math.min(t.clientWidth||innerWidth,innerWidth)<700||(navigator.hardwareConcurrency||8)<=4:e.lowPower,o=a?v0:x0,l=new Nl({antialias:!a,alpha:!1,powerPreference:a?"default":"high-performance"});l.setPixelRatio(Math.min(window.devicePixelRatio||1,o));let c=l.domElement;if(c.style.cssText="display:block;width:100%;height:100%;touch-action:none;outline:none;cursor:grab",c.setAttribute("aria-hidden","true"),getComputedStyle(t).position==="static")t.style.position="relative";t.appendChild(c);let u=e.labels??Zt,d=new Vl(t,u,(U,q)=>{if(U.init.kind==="agent"&&U.init.id)e.onSeatClick({id:U.init.id,name:U.init.name,at:q})}),h=Cu(t,()=>s),p=new $r,v=new sn(42,1,0.1,90),T=new aa,m=new ra;m.position.set(-6,12,7),p.add(T,m);let{theme:f,scheme:w}=e,C=[],y=new Map,b=new Map,A=new Map,E=new Map,g,M=0,G=new Map,N=(U)=>{let q=G.get(U);return q&&q.svg===A.get(U)&&q.talk===E.get(U)&&q.tone===F()?q:void 0},F=()=>`${f}/${w}`,X,R=null,k=0,Z=Zn(0,1),H=Z,at=Z,K=0,et=0,tt=!1,dt,At=!1,te=()=>g?.slots??cr(C.length),zt=()=>te().count,Y=(U)=>{let q=g?.slotOf.get(U);return q===void 0?void 0:rn(q,zt())},rt=()=>{let U=R?Y(R):void 0;return U===void 0?Zn(k,zt(),v.aspect,c.clientWidth||void 0):Qs(U,zt())},lt=()=>{let{position:U,target:q}=so(Z);v.position.set(...U),v.lookAt(q[0],q[1],q[2]),v.rotateZ(Z.roll);let ht=ao(Z.fov,v.aspect);if(Math.abs(v.fov-ht)>0.001)v.fov=ht,v.updateProjectionMatrix()},It=(U,q,ht=!1)=>{let St=Cs(Z,U,s||q,ht);if(tt=St.dive===!0,St.cut)Z=U,et=0;else H=Z,at=U,K=performance.now(),et=St.ms;return st.wake(),St},Ot=()=>{if(!g)return;p.remove(g.group);for(let U of g.podiums)U.dispose();g.kit.dispose(),g.built.dispose(),g.toon.dispose(),g=void 0},Ft=async(U,q)=>{let ht=A.get(U),St=g;if(!ht||!St)return;let bt=St.slotOf.get(U),Yt=bt===void 0?void 0:St.podiums[bt];if(Yt?.init.kind!=="agent")return;let he=E.get(U),ve={rim:St.hall.paper,ink:St.hall.ink,edge:ma(C.find((Wt)=>Wt.id===U)?.color??St.hall.gold,St.hall.ink,0.35)};try{let[Wt,cn]=await Promise.all([kl(ht,320,ve),he?kl(he,320,ve):void 0]);if(q!==M||g!==St)return;G.set(U,{svg:ht,talk:he,tone:F(),canvas:Wt.canvas,talkCanvas:cn?.canvas}),Yt.setSticker(Wt.canvas),Yt.setTalk(cn?.canvas),st.wake()}catch{}},Ce=(U,q)=>{U.setBadge(Au(q))},$t=(U)=>{let q=++M;Ot();let ht=An(f,w),St=cr(C.length),bt=new Hl;bt.setInk(ht.ink);let Yt=new Wl(ht),he=xu(ht,St.count,bt),ve=new Xe;ve.add(he.group);let Wt=new Map,cn=[],hn=[],Si=(ge,ye,En=0)=>{let We=Es(ge,St.count),ii=1+En/Lt(St.count);ye.group.position.set(We.x*ii,0.2,We.z*ii),ye.group.rotation.y=We.yaw,hn[ge]=ye,ve.add(ye.group)};if(Si(0,new xa({id:void 0,name:e.ownerName??"You",kind:"owner",accent:ht.gold},Yt,bt),1.2),C.slice(0,St.seated).forEach((ge,ye)=>{let En=ye+1;Wt.set(ge.id,En),cn.push(ge.id);let We=new xa({id:ge.id,name:ge.name,kind:"agent",accent:ge.color},Yt,bt);We.setDim(ge.dim===!0),Ce(We,y.get(ge.id)??ge.state??"idle"),Si(En,We);let ii=N(ge.id);if(ii)We.setSticker(ii.canvas),We.setTalk(ii.talkCanvas)}),g={hall:ht,toon:bt,kit:Yt,built:he,group:ve,slots:St,podiums:hn,slotOf:Wt,order:cn},U&&X){let ge=new Set;for(let ye of hn){let En={x:ye.group.position.x,z:ye.group.position.z,yaw:ye.group.rotation.y},We=U.from.get(Pu(ye));if(We)X.slides.push({podium:ye,from:We,to:En}),ye.group.position.x=We.x,ye.group.position.z=We.z,ye.group.rotation.y=We.yaw;if(ye.init.id&&U.joining.has(ye.init.id))ye.group.visible=!1,ye.labelHidden=!0,ge.add(ye)}X.risers=[...ge]}p.add(ve),ve.updateMatrixWorld(!0),p.background=new Kt(ht.bg),p.fog=new Zs(ht.bg,17,46),T.color.set(ht.ambient),T.intensity=ht.ambientI,m.color.set(ht.key),m.intensity=ht.keyI;for(let ge of C.slice(0,St.seated)){if(N(ge.id))continue;Ft(ge.id,q)}if(R&&!Wt.has(R))R=null;It(rt(),U===void 0),d.paint(ht),d.set(hn,(ge)=>y.get(ge.init.id??"")??"idle");for(let ge of hn){let ye=b.get(ge.init.id??"");if(ye)d.mark(ge,ye)}st.wake()},ee=(U)=>U.slice(0,cr(U.length).seated).map((q)=>q.id),ue=()=>{let U=new Map;for(let q of g?.podiums??[])U.set(Pu(q),{x:q.group.position.x,z:q.group.position.z,yaw:q.group.rotation.y});return U},ne=(U)=>{U.swapped=!0;let q=ue();C=U.next,U.slides=[],$t({from:q,joining:new Set(U.plan.joining)});for(let ht of U.risers)U.fx?.circle({x:ht.group.position.x,y:Xl,z:ht.group.position.z},U.plan.riseAt)},Le=(U)=>{for(let q of U.timers)clearTimeout(q);for(let q of U.slides)q.podium.group.position.x=q.to.x,q.podium.group.position.z=q.to.z,q.podium.group.rotation.y=q.to.yaw;for(let q of U.risers)q.group.visible=!0,q.group.position.y=Xl,q.labelHidden=!1;if(U.fx?.dispose(),c.style.transition="",c.style.opacity="",d.root.style.transition="",d.root.style.opacity="",X===U)X=void 0;st.wake()},me=()=>{let U=X;if(!U)return;if(!U.swapped)U.swapped=!0,C=U.next,$t();Le(U)},Ze=(U,q)=>{let ht={plan:q,start:performance.now(),next:U,leavers:[],swapped:!1,fx:void 0,slides:[],risers:[],timers:[]};if(X=ht,q.mode==="fade"){for(let Yt of[c,d.root])Yt.style.transition=`opacity ${Rt}ms linear`,Yt.style.opacity="0";ht.timers.push(setTimeout(()=>{ht.swapped=!0,C=U,$t();for(let Yt of[c,d.root])Yt.style.opacity="1"},Rt),setTimeout(()=>Le(ht),Rt*2));return}let St=g;if(!St)return;let bt=new Gl(St.hall);ht.fx=bt,p.add(bt.group);for(let Yt of q.leaving){let he=St.slotOf.get(Yt),ve=he===void 0?void 0:St.podiums[he];if(!ve)continue;ht.leavers.push(ve),bt.puff({x:ve.group.position.x,y:b0,z:ve.group.position.z},0)}if(q.swapAt===0)ne(ht);st.wake()},Ne=(U)=>{let q=X;if(!q||q.plan.mode!=="play")return q!==void 0;let ht=Math.max(0,U-q.start);if(!q.swapped){let bt=Go(ht);for(let Yt of q.leavers)if(Yt.group.scale.set(bt.scaleX,bt.scaleY,bt.scaleX),bt.gone)Yt.group.visible=!1;if(ht>=q.plan.swapAt)ne(q)}if(q.swapped){let bt=Zo(ht-q.plan.swapAt);for(let{podium:he,from:ve,to:Wt}of q.slides)he.group.position.x=ve.x+(Wt.x-ve.x)*bt,he.group.position.z=ve.z+(Wt.z-ve.z)*bt,he.group.rotation.y=Wo(ve.yaw,Wt.yaw,bt);let Yt=Di(ht-q.plan.riseAt);for(let he of q.risers)he.group.visible=Yt.shown,he.group.position.y=Xl-Yt.depth*Fo,he.labelHidden=!Yt.named}let St=q.fx?.step(ht)??!1;if(ht>=q.plan.total&&!St)return Le(q),!1;return!0},Re,P=new O,Ue=0,ae=0,be=0,S=0,_=0,L=0,V=performance.now(),st=yu({frame:(U,q)=>{let ht=performance.now();Ue+=q/1000;let St=!1;if(Ne(U))St=!0;if(et>0){let he=(U-K)/et;if(he>=1)Z=at,et=0;else Z=Ms(H,at,tt?Rs(he):Qi(he)),St=!0}else if(dt)St=!0;lt(),v.getWorldPosition(P);let bt=g;if(bt){let he=R===null?void 0:bt.slotOf.get(R);for(let Wt of bt.podiums)Wt.group.updateMatrixWorld(!0);let ve=d.place(v,P,t.clientWidth,t.clientHeight,he===void 0?void 0:bt.podiums[he]);if(R===null&&ve!==Re)Re=ve,e.onNames?.(ve);vu(bt.built.flames,Ue,s);for(let Wt of bt.built.flames)Wt.body.lookAt(P.x,Wt.body.position.y,P.z);for(let Wt of bt.podiums){if(Wt.init.kind!=="agent")continue;let cn=y.get(Wt.init.id??"")??"idle",hn=cn==="speaking"?1:0,Si=cn==="thinking"||cn==="working"?1:0,ge=Wt.speak;Wt.speak=s?hn:Iu(Wt.speak,hn,7,q/1000),Wt.bob=s?0:Iu(Wt.bob,Si,5,q/1000);let ye=Wt.speak>0.02;if(Wt.glow.visible=ye&&Wt.board.visible,Wt.glowMaterial.opacity=0.85*Wt.speak,Wt.board.position.y=Wt.boardY+Math.sin(Ue*3.1+Wt.phase)*0.035*Wt.bob,Wt.face(P),Wt.markFrame(cn==="speaking",Ue,s))St=!0;let En=cn==="speaking"&&!s;if(Wt.mouth(En&&Pr(Ue,Wt.phase))&&En)St=!0;if(Math.abs(Wt.speak-hn)>0.01||Math.abs(ge-Wt.speak)>0.001||Wt.bob>0.02)St=!0}}l.render(p,v),be+=1,ae+=1;let Yt=performance.now()-ht;if(S+=Yt,_=Math.max(_,Yt),U-V>=1000)L=ae*1000/(U-V),ft={...ft,fps:L,frameMs:S/Math.max(ae,1),frameMsMax:_},ae=0,S=0,_=0,V=U;return St},host:{request:(U)=>requestAnimationFrame(U),cancel:(U)=>cancelAnimationFrame(U),hidden:()=>document.hidden},idleMs:()=>s?0:a?140:90}),ft={kind:"webgl",fps:0,frameMs:0,frameMsMax:0,drawCalls:0,triangles:0,textures:0,geometries:0,dpr:l.getPixelRatio(),lowPower:a,reduced:s,loop:"idle",seats:0,renders:0},J=()=>{let{clientWidth:U,clientHeight:q}=t;if(U<=0||q<=0)return;if(l.setSize(U,q,!1),v.aspect=U/q,v.updateProjectionMatrix(),R===null&&!dt&&g)if(et===0)Z=rt();else at=rt();d.size(U),st.wake()},j=new ResizeObserver(J);j.observe(t);let _t=new IntersectionObserver((U)=>{for(let q of U)st.setVisible(q.isIntersecting)});_t.observe(t);let Dt=()=>st.sync();document.addEventListener("visibilitychange",Dt);let pt=(U)=>{U.preventDefault(),n?.()};c.addEventListener("webglcontextlost",pt);let ot=(U,q,ht)=>{let St=U!==null&&g?.slotOf.has(U)?U:null;if(St===R)return;let bt=St!==null&&R===null;R=St;let Yt=It(rt(),q,bt);if(St!==null&&At&&!Yt.cut)h.play();if(ht)e.onFocus?.(St)},Bt=new Xt,kt=new oa,se=(U,q)=>{let ht=g;if(!ht)return;let St=c.getBoundingClientRect();return Bt.set((U-St.left)/St.width*2-1,-((q-St.top)/St.height)*2+1),kt.setFromCamera(Bt,v),kt.intersectObjects(ht.podiums.filter((Yt)=>Yt.group.visible).flatMap((Yt)=>Yt.hits).filter((Yt)=>Yt.visible),!1)[0]?.object.userData},I=new Map,ct,Q=0,ut=!1,Tt=()=>{let[U,q]=[...I.values()];return U&&q?Math.hypot(U.x-q.x,U.y-q.y):0},nt=(U)=>{if(I.set(U.pointerId,{x:U.clientX,y:U.clientY}),I.size===2){Q=Tt(),ut=!1,ct=void 0,dt=void 0;return}let q=c.getBoundingClientRect(),ht=!$s(U.clientX,U.clientY,q,{width:innerWidth,height:innerHeight});if(ct={x:U.clientX,y:U.clientY,az:k,ok:ht,at:performance.now(),hold:U.pointerType!=="mouse"&&e.onSeatMenu!==void 0},ht)c.setPointerCapture?.(U.pointerId);c.style.cursor="grabbing"},mt=(U)=>{if(I.has(U.pointerId))I.set(U.pointerId,{x:U.clientX,y:U.clientY});if(I.size===2&&Q>0&&!ut){let St=Tt()/Q,bt=St>S0?"in":St<M0?"out":"none";if(bt!=="none")ut=!0,un(bt==="in"?-1:1);return}if(!ct){if(U.buttons===0)c.style.cursor=se(U.clientX,U.clientY)?"pointer":"grab";return}if(!ct.ok||R!==null)return;let q=U.clientX-ct.x;if(Math.abs(q)<Ru&&!dt)return;let ht=ct.az+As(q,c.clientWidth);dt={az:ht},Z=Zn(ht,zt(),v.aspect,c.clientWidth||void 0),et=0,st.wake()},Vt=(U)=>{if(I.delete(U.pointerId),I.size<2)Q=0;c.style.cursor="grab";let q=ct;if(ct=void 0,!q||ut){if(I.size===0)ut=!1;return}let ht=U.clientX-q.x,St=U.clientY-q.y;if(dt){k=oo(dt.az,zt()),dt=void 0,It(Zn(k,zt(),v.aspect,c.clientWidth||void 0),!1);return}if(Math.hypot(ht,St)<Ru){if(q.hold&&performance.now()-q.at>=zr)return;let bt=se(U.clientX,U.clientY);if(!bt)return;if(bt.kind==="agent"&&bt.seat){let Yt=C.find((he)=>he.id===bt.seat);if(Yt)e.onSeatClick({id:Yt.id,name:Yt.name,at:{x:U.clientX,y:U.clientY}})}else if(bt.kind==="owner"&&R!==null)ot(null,!1,!0);return}if(q.ok&&R!==null&&Math.abs(ht)>=y0&&Math.abs(ht)>Math.abs(St))ce(ht<0?1:-1)},fe=(U)=>{if(I.delete(U.pointerId),ct=void 0,dt)k=oo(dt.az,zt()),dt=void 0,It(Zn(k,zt(),v.aspect,c.clientWidth||void 0),!1);c.style.cursor="grab"},ce=(U)=>{let q=g;if(!q||R===null||q.order.length<2)return;let ht=q.order.indexOf(R),St=q.order[(ht+U+q.order.length)%q.order.length];if(St)ot(St,!1,!0)},un=(U)=>{let q=g;if(!q)return;let ht=Ns(U,R!==null);if(ht==="in"){let St=Ts(k,q.slots),bt=St===void 0?void 0:q.order[St-1];if(bt)ot(bt,!1,!0)}else if(ht==="out")ot(null,!1,!0)},vn=0,hr=(U)=>{U.preventDefault();let q=performance.now();if(q-vn<450||Math.abs(U.deltaY)<4)return;vn=q,un(U.deltaY)};c.addEventListener("pointerdown",nt),c.addEventListener("pointermove",mt),c.addEventListener("pointerup",Vt),c.addEventListener("pointercancel",fe),c.addEventListener("wheel",hr,{passive:!1});let ur=(U)=>U.length===C.length&&U.every((q,ht)=>q.id===C[ht]?.id&&q.name===C[ht]?.name&&q.color===C[ht]?.color);C=e.seats.map((U)=>({...U}));for(let U of C){if(U.state)y.set(U.id,U.state);if(U.avatarSvg)A.set(U.id,U.avatarSvg);if(U.talkSvg)E.set(U.id,U.talkSvg)}if(e.focus&&C.some((U)=>U.id===e.focus))R=e.focus;return $t(),Z=rt(),J(),At=!0,{kind:"webgl",setTheme(U,q){if(U===f&&q===w)return;me(),f=U,w=q,$t()},setSeats(U){me();let q=!ur(U),ht=U.map((bt)=>({...bt})),St=q&&At&&g?di(ee(C),ee(ht),s):void 0;for(let bt of ht){if(bt.state)y.set(bt.id,bt.state);if(bt.avatarSvg&&bt.avatarSvg!==A.get(bt.id))A.set(bt.id,bt.avatarSvg);if(bt.avatarSvg)if(bt.talkSvg)E.set(bt.id,bt.talkSvg);else E.delete(bt.id)}if(St&&St.mode!=="cut"){Ze(ht,St);return}if(C=ht,q)$t();else{let bt=g;for(let Yt of C){let he=bt?.slotOf.get(Yt.id);(he===void 0?void 0:bt?.podiums[he])?.setDim(Yt.dim===!0),Ft(Yt.id,M)}}st.wake()},setState(U,q){y.set(U,q);let ht=g?.slotOf.get(U),St=ht===void 0?void 0:g?.podiums[ht];if(St)Ce(St,q),d.relabel(St,q);st.wake()},setMark(U,q){if(q===null)b.delete(U);else b.set(U,q);let ht=g?.slotOf.get(U),St=ht===void 0?void 0:g?.podiums[ht];if(St)d.mark(St,q);st.wake()},async setAvatar(U,q,ht){if(A.set(U,q),ht)E.set(U,ht);else E.delete(U);await Ft(U,M)},setReducedMotion(U){if(s=U,ft.reduced=U,U)It(rt(),!0);st.wake()},resetCamera(){k=0,ot(null,!1,!0),It(rt(),!1)},focus(U,q){ot(U,q?.cut===!0,!1)},focused:()=>R,seatAt(U,q){let ht=se(U,q);return ht?.kind==="agent"?ht.seat:null},getStats(){let U=l.info;return{...ft,drawCalls:U.render.calls,triangles:U.render.triangles,textures:U.memory.textures,geometries:U.memory.geometries,loop:st.state,seats:C.length,renders:be,reduced:s}},dispose(){if(X){for(let U of X.timers)clearTimeout(U);X.fx?.dispose(),X=void 0}st.dispose(),j.disconnect(),_t.disconnect(),document.removeEventListener("visibilitychange",Dt),c.removeEventListener("webglcontextlost",pt),c.removeEventListener("pointerdown",nt),c.removeEventListener("pointermove",mt),c.removeEventListener("pointerup",Vt),c.removeEventListener("pointercancel",fe),c.removeEventListener("wheel",hr),h.dispose(),d.dispose(),Ot(),l.dispose(),l.forceContextLoss(),c.remove()}}}export{lS as createTable3D};
4220
+ }`;class su{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e){if(this.texture===null){let n=new oa(t.texture);if(t.depthNear!==e.depthNear||t.depthFar!==e.depthFar)this.depthNear=t.depthNear,this.depthFar=t.depthFar;this.texture=n}}getMesh(t){if(this.texture!==null){if(this.mesh===null){let e=t.cameras[0].viewport,n=new bn({vertexShader:Kg,fragmentShader:Qg,uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new Jt(new Ie(20,20),n)}}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class ru extends ti{constructor(t,e){super();let n=this,i=null,s=1,r=null,a="local-floor",o=1,l=null,c=null,u=null,d=null,h=null,p=null,v=typeof XRWebGLBinding<"u",T=new su,m={},f=e.getContextAttributes(),w=null,C=null,y=[],b=[],A=new qt,E=null,g=null,M=new nn;M.viewport=new Ae;let G=new nn;G.viewport=new Ae;let N=[M,G],F=new vl,X=null,R=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Y){let rt=y[Y];if(rt===void 0)rt=new er,y[Y]=rt;return rt.getTargetRaySpace()},this.getControllerGrip=function(Y){let rt=y[Y];if(rt===void 0)rt=new er,y[Y]=rt;return rt.getGripSpace()},this.getHand=function(Y){let rt=y[Y];if(rt===void 0)rt=new er,y[Y]=rt;return rt.getHandSpace()};function k(Y){let rt=b.indexOf(Y.inputSource);if(rt===-1)return;let lt=y[rt];if(lt!==void 0)lt.update(Y.inputSource,Y.frame,l||r),lt.dispatchEvent({type:Y.type,data:Y.inputSource})}function Z(){i.removeEventListener("select",k),i.removeEventListener("selectstart",k),i.removeEventListener("selectend",k),i.removeEventListener("squeeze",k),i.removeEventListener("squeezestart",k),i.removeEventListener("squeezeend",k),i.removeEventListener("end",Z),i.removeEventListener("inputsourceschange",H);for(let Y=0;Y<y.length;Y++){let rt=b[Y];if(rt===null)continue;b[Y]=null,y[Y].disconnect(rt)}X=null,R=null,T.reset();for(let Y in m)delete m[Y];if(t.setRenderTarget(w),h=null,d=null,u=null,i=null,C=null,Bt.stop(),n.isPresenting=!1,t.setPixelRatio(E),t.setSize(A.width,A.height,!1),g!==null){let Y=g.camera;Y.fov=g.fov,Y.zoom=g.zoom,Y.updateProjectionMatrix(),g=null}n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Y){if(s=Y,n.isPresenting===!0)Vt("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Y){if(a=Y,n.isPresenting===!0)Vt("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||r},this.setReferenceSpace=function(Y){l=Y},this.getBaseLayer=function(){return d!==null?d:h},this.getBinding=function(){if(u===null&&v)u=new XRWebGLBinding(i,e);return u},this.getFrame=function(){return p},this.getSession=function(){return i},this.setSession=async function(Y){if(i=Y,i!==null){if(w=t.getRenderTarget(),i.addEventListener("select",k),i.addEventListener("selectstart",k),i.addEventListener("selectend",k),i.addEventListener("squeeze",k),i.addEventListener("squeezestart",k),i.addEventListener("squeezeend",k),i.addEventListener("end",Z),i.addEventListener("inputsourceschange",H),f.xrCompatible!==!0)await e.makeXRCompatible();if(E=t.getPixelRatio(),t.getSize(A),!(v&&("createProjectionLayer"in XRWebGLBinding.prototype))){let lt={antialias:f.antialias,alpha:!0,depth:f.depth,stencil:f.stencil,framebufferScaleFactor:s};h=new XRWebGLLayer(i,e,lt),i.updateRenderState({baseLayer:h}),t.setPixelRatio(1),t.setSize(h.framebufferWidth,h.framebufferHeight,!1),C=new gn(h.framebufferWidth,h.framebufferHeight,{format:Gn,type:mn,colorSpace:t.outputColorSpace,stencilBuffer:f.stencil,resolveDepthBuffer:h.ignoreDepthValues===!1,resolveStencilBuffer:h.ignoreDepthValues===!1,storeMultisampledDepthBuffer:h.ignoreDepthValues===!1,storeMultisampledStencilBuffer:h.ignoreDepthValues===!1})}else{let lt=null,It=null,Ft=null;if(f.depth)Ft=f.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,lt=f.stencil?Ii:Ri,It=f.stencil?Ss:mi;let Ut={colorFormat:e.RGBA8,depthFormat:Ft,scaleFactor:s};u=this.getBinding(),d=u.createProjectionLayer(Ut),i.updateRenderState({layers:[d]}),t.setPixelRatio(1),t.setSize(d.textureWidth,d.textureHeight,!1),C=new gn(d.textureWidth,d.textureHeight,{format:Gn,type:mn,depthTexture:new Ui(d.textureWidth,d.textureHeight,It,void 0,void 0,void 0,void 0,void 0,void 0,lt),stencilBuffer:f.stencil,colorSpace:t.outputColorSpace,samples:f.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1,storeMultisampledDepthBuffer:d.ignoreDepthValues===!1,storeMultisampledStencilBuffer:d.ignoreDepthValues===!1})}C.isXRRenderTarget=!0,this.setFoveation(o),l=null,r=await i.requestReferenceSpace(a),Bt.setContext(i),Bt.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return T.getDepthTexture()};function H(Y){for(let rt=0;rt<Y.removed.length;rt++){let lt=Y.removed[rt],It=b.indexOf(lt);if(It>=0)b[It]=null,y[It].disconnect(lt)}for(let rt=0;rt<Y.added.length;rt++){let lt=Y.added[rt],It=b.indexOf(lt);if(It===-1){for(let Ut=0;Ut<y.length;Ut++)if(Ut>=b.length){b.push(lt),It=Ut;break}else if(b[Ut]===null){b[Ut]=lt,It=Ut;break}if(It===-1)break}let Ft=y[It];if(Ft)Ft.connect(lt)}}let at=new O,K=new O;function et(Y,rt,lt){at.setFromMatrixPosition(rt.matrixWorld),K.setFromMatrixPosition(lt.matrixWorld);let It=at.distanceTo(K),Ft=rt.projectionMatrix.elements,Ut=lt.projectionMatrix.elements,Ce=Ft[14]/(Ft[10]-1),$t=Ft[14]/(Ft[10]+1),ee=(Ft[9]+1)/Ft[5],ue=(Ft[9]-1)/Ft[5],ne=(Ft[8]-1)/Ft[0],Le=(Ut[8]+1)/Ut[0],me=Ce*ne,Ze=Ce*Le,Ne=It/(-ne+Le),Re=Ne*-ne;if(rt.matrixWorld.decompose(Y.position,Y.quaternion,Y.scale),Y.translateX(Re),Y.translateZ(Ne),Y.matrixWorld.compose(Y.position,Y.quaternion,Y.scale),Y.matrixWorldInverse.copy(Y.matrixWorld).invert(),Ft[10]===-1)Y.projectionMatrix.copy(rt.projectionMatrix),Y.projectionMatrixInverse.copy(rt.projectionMatrixInverse);else{let P=Ce+Ne,Ue=$t+Ne,ae=me-Re,be=Ze+(It-Re),S=ee*$t/Ue*P,_=ue*$t/Ue*P;Y.projectionMatrix.makePerspective(ae,be,S,_,P,Ue),Y.projectionMatrixInverse.copy(Y.projectionMatrix).invert()}}function tt(Y,rt){if(rt===null)Y.matrixWorld.copy(Y.matrix);else Y.matrixWorld.multiplyMatrices(rt.matrixWorld,Y.matrix);Y.matrixWorldInverse.copy(Y.matrixWorld).invert()}this.updateCamera=function(Y){if(i===null)return;let{near:rt,far:lt}=Y;if(T.texture!==null){if(T.depthNear>0)rt=T.depthNear;if(T.depthFar>0)lt=T.depthFar}if(F.near=G.near=M.near=rt,F.far=G.far=M.far=lt,X!==F.near||R!==F.far)i.updateRenderState({depthNear:F.near,depthFar:F.far}),X=F.near,R=F.far;F.layers.mask=Y.layers.mask|6,M.layers.mask=F.layers.mask&-5,G.layers.mask=F.layers.mask&-3;let It=Y.parent,Ft=F.cameras;tt(F,It);for(let Ut=0;Ut<Ft.length;Ut++)tt(Ft[Ut],It);if(Ft.length===2)et(F,M,G);else F.projectionMatrix.copy(M.projectionMatrix);if(g===null&&Y.isPerspectiveCamera)g={camera:Y,fov:Y.fov,zoom:Y.zoom};dt(Y,F,It)};function dt(Y,rt,lt){if(lt===null)Y.matrix.copy(rt.matrixWorld);else Y.matrix.copy(lt.matrixWorld),Y.matrix.invert(),Y.matrix.multiply(rt.matrixWorld);if(Y.matrix.decompose(Y.position,Y.quaternion,Y.scale),Y.updateMatrixWorld(!0),Y.projectionMatrix.copy(rt.projectionMatrix),Y.projectionMatrixInverse.copy(rt.projectionMatrixInverse),Y.isPerspectiveCamera)Y.fov=Gr*2*Math.atan(1/Y.projectionMatrix.elements[5]),Y.zoom=1}this.getCamera=function(){return F},this.getFoveation=function(){if(d===null&&h===null)return;return o},this.setFoveation=function(Y){if(o=Y,d!==null)d.fixedFoveation=Y;if(h!==null&&h.fixedFoveation!==void 0)h.fixedFoveation=Y},this.hasDepthSensing=function(){return T.texture!==null},this.getDepthSensingMesh=function(){return T.getMesh(F)},this.getCameraTexture=function(Y){return m[Y]};let At=null;function te(Y,rt){if(c=rt.getViewerPose(l||r),p=rt,c!==null){let lt=c.views;if(h!==null)t.setRenderTargetFramebuffer(C,h.framebuffer),t.setRenderTarget(C);let It=!1;if(lt.length!==F.cameras.length)F.cameras.length=0,It=!0;for(let $t=0;$t<lt.length;$t++){let ee=lt[$t],ue=null;if(h!==null)ue=h.getViewport(ee);else{let Le=u.getViewSubImage(d,ee);if(ue=Le.viewport,$t===0)t.setRenderTargetTextures(C,Le.colorTexture,Le.depthStencilTexture),t.setRenderTarget(C)}let ne=N[$t];if(ne===void 0)ne=new nn,ne.layers.enable($t),ne.viewport=new Ae,N[$t]=ne;if(ne.matrix.fromArray(ee.transform.matrix),ne.matrix.decompose(ne.position,ne.quaternion,ne.scale),ne.projectionMatrix.fromArray(ee.projectionMatrix),ne.projectionMatrixInverse.copy(ne.projectionMatrix).invert(),ne.viewport.set(ue.x,ue.y,ue.width,ue.height),$t===0)F.matrix.copy(ne.matrix),F.matrix.decompose(F.position,F.quaternion,F.scale);if(It===!0)F.cameras.push(ne)}let Ft=i.enabledFeatures;if(Ft&&Ft.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&v){u=n.getBinding();let $t=u.getDepthInformation(lt[0]);if($t&&$t.isValid&&$t.texture)T.init($t,i.renderState)}if(Ft&&Ft.includes("camera-access")&&v){t.state.unbindTexture(),u=n.getBinding();for(let $t=0;$t<lt.length;$t++){let ee=lt[$t].camera;if(ee){let ue=m[ee];if(!ue)ue=new oa,m[ee]=ue;let ne=u.getCameraImage(ee);ue.sourceTexture=ne}}}}for(let lt=0;lt<y.length;lt++){let It=b[lt],Ft=y[lt];if(It!==null&&Ft!==void 0)Ft.update(It,rt,l||r)}if(At)At(Y,rt);if(rt.detectedPlanes)n.dispatchEvent({type:"planesdetected",data:rt});p=null}let Bt=new Yh;Bt.setAnimationLoop(te),this.setAnimationLoop=function(Y){At=Y},this.dispose=function(){}}}var jg=new we,au=new Yt;au.set(-1,0,0,0,1,0,0,0,1);function t0(t,e){function n(m,f){if(m.matrixAutoUpdate===!0)m.updateMatrix();f.value.copy(m.matrix)}function i(m,f){if(f.color.getRGB(m.fogColor.value,il(t)),f.isFog)m.fogNear.value=f.near,m.fogFar.value=f.far;else if(f.isFogExp2)m.fogDensity.value=f.density}function s(m,f,w,C,y){if(f.isNodeMaterial)f.uniformsNeedUpdate=!1;else if(f.isMeshBasicMaterial)r(m,f);else if(f.isMeshLambertMaterial){if(r(m,f),f.envMap)m.envMapIntensity.value=f.envMapIntensity}else if(f.isMeshToonMaterial)r(m,f),d(m,f);else if(f.isMeshPhongMaterial){if(r(m,f),u(m,f),f.envMap)m.envMapIntensity.value=f.envMapIntensity}else if(f.isMeshStandardMaterial){if(r(m,f),h(m,f),f.isMeshPhysicalMaterial)p(m,f,y)}else if(f.isMeshMatcapMaterial)r(m,f),v(m,f);else if(f.isMeshDepthMaterial)r(m,f);else if(f.isMeshDistanceMaterial)r(m,f),T(m,f);else if(f.isMeshNormalMaterial)r(m,f);else if(f.isLineBasicMaterial){if(a(m,f),f.isLineDashedMaterial)o(m,f)}else if(f.isPointsMaterial)l(m,f,w,C);else if(f.isSpriteMaterial)c(m,f);else if(f.isShadowMaterial)m.color.value.copy(f.color),m.opacity.value=f.opacity;else if(f.isShaderMaterial)f.uniformsNeedUpdate=!1}function r(m,f){if(m.opacity.value=f.opacity,f.color)m.diffuse.value.copy(f.color);if(f.emissive)m.emissive.value.copy(f.emissive).multiplyScalar(f.emissiveIntensity);if(f.map)m.map.value=f.map,n(f.map,m.mapTransform);if(f.alphaMap)m.alphaMap.value=f.alphaMap,n(f.alphaMap,m.alphaMapTransform);if(f.bumpMap){if(m.bumpMap.value=f.bumpMap,n(f.bumpMap,m.bumpMapTransform),m.bumpScale.value=f.bumpScale,f.side===Ve)m.bumpScale.value*=-1}if(f.normalMap){if(m.normalMap.value=f.normalMap,n(f.normalMap,m.normalMapTransform),m.normalScale.value.copy(f.normalScale),f.side===Ve)m.normalScale.value.negate()}if(f.displacementMap)m.displacementMap.value=f.displacementMap,n(f.displacementMap,m.displacementMapTransform),m.displacementScale.value=f.displacementScale,m.displacementBias.value=f.displacementBias;if(f.emissiveMap)m.emissiveMap.value=f.emissiveMap,n(f.emissiveMap,m.emissiveMapTransform);if(f.specularMap)m.specularMap.value=f.specularMap,n(f.specularMap,m.specularMapTransform);if(f.alphaTest>0)m.alphaTest.value=f.alphaTest;let w=e.get(f),{envMap:C,envMapRotation:y}=w;if(C){if(m.envMap.value=C,m.envMapRotation.value.setFromMatrix4(jg.makeRotationFromEuler(y)).transpose(),C.isCubeTexture&&C.isRenderTargetTexture===!1)m.envMapRotation.value.premultiply(au);m.reflectivity.value=f.reflectivity,m.ior.value=f.ior,m.refractionRatio.value=f.refractionRatio}if(f.lightMap)m.lightMap.value=f.lightMap,m.lightMapIntensity.value=f.lightMapIntensity,n(f.lightMap,m.lightMapTransform);if(f.aoMap)m.aoMap.value=f.aoMap,m.aoMapIntensity.value=f.aoMapIntensity,n(f.aoMap,m.aoMapTransform)}function a(m,f){if(m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,f.map)m.map.value=f.map,n(f.map,m.mapTransform)}function o(m,f){m.dashSize.value=f.dashSize,m.totalSize.value=f.dashSize+f.gapSize,m.scale.value=f.scale}function l(m,f,w,C){if(m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,m.size.value=f.size*w,m.scale.value=C*0.5,f.map)m.map.value=f.map,n(f.map,m.uvTransform);if(f.alphaMap)m.alphaMap.value=f.alphaMap,n(f.alphaMap,m.alphaMapTransform);if(f.alphaTest>0)m.alphaTest.value=f.alphaTest}function c(m,f){if(m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,m.rotation.value=f.rotation,f.map)m.map.value=f.map,n(f.map,m.mapTransform);if(f.alphaMap)m.alphaMap.value=f.alphaMap,n(f.alphaMap,m.alphaMapTransform);if(f.alphaTest>0)m.alphaTest.value=f.alphaTest}function u(m,f){m.specular.value.copy(f.specular),m.shininess.value=Math.max(f.shininess,0.0001)}function d(m,f){if(f.gradientMap)m.gradientMap.value=f.gradientMap}function h(m,f){if(m.metalness.value=f.metalness,f.metalnessMap)m.metalnessMap.value=f.metalnessMap,n(f.metalnessMap,m.metalnessMapTransform);if(m.roughness.value=f.roughness,f.roughnessMap)m.roughnessMap.value=f.roughnessMap,n(f.roughnessMap,m.roughnessMapTransform);if(f.envMap)m.envMapIntensity.value=f.envMapIntensity}function p(m,f,w){if(m.ior.value=f.ior,f.sheen>0){if(m.sheenColor.value.copy(f.sheenColor).multiplyScalar(f.sheen),m.sheenRoughness.value=f.sheenRoughness,f.sheenColorMap)m.sheenColorMap.value=f.sheenColorMap,n(f.sheenColorMap,m.sheenColorMapTransform);if(f.sheenRoughnessMap)m.sheenRoughnessMap.value=f.sheenRoughnessMap,n(f.sheenRoughnessMap,m.sheenRoughnessMapTransform)}if(f.clearcoat>0){if(m.clearcoat.value=f.clearcoat,m.clearcoatRoughness.value=f.clearcoatRoughness,f.clearcoatMap)m.clearcoatMap.value=f.clearcoatMap,n(f.clearcoatMap,m.clearcoatMapTransform);if(f.clearcoatRoughnessMap)m.clearcoatRoughnessMap.value=f.clearcoatRoughnessMap,n(f.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform);if(f.clearcoatNormalMap){if(m.clearcoatNormalMap.value=f.clearcoatNormalMap,n(f.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(f.clearcoatNormalScale),f.side===Ve)m.clearcoatNormalScale.value.negate()}}if(f.dispersion>0)m.dispersion.value=f.dispersion;if(f.retroreflectivity>0)m.retroreflectivity.value=f.retroreflectivity;if(f.iridescence>0){if(m.iridescence.value=f.iridescence,m.iridescenceIOR.value=f.iridescenceIOR,m.iridescenceThicknessMinimum.value=f.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=f.iridescenceThicknessRange[1],f.iridescenceMap)m.iridescenceMap.value=f.iridescenceMap,n(f.iridescenceMap,m.iridescenceMapTransform);if(f.iridescenceThicknessMap)m.iridescenceThicknessMap.value=f.iridescenceThicknessMap,n(f.iridescenceThicknessMap,m.iridescenceThicknessMapTransform)}if(f.transmission>0){if(m.transmission.value=f.transmission,m.transmissionSamplerMap.value=w.texture,m.transmissionSamplerSize.value.set(w.width,w.height),f.transmissionMap)m.transmissionMap.value=f.transmissionMap,n(f.transmissionMap,m.transmissionMapTransform);if(m.thickness.value=f.thickness,f.thicknessMap)m.thicknessMap.value=f.thicknessMap,n(f.thicknessMap,m.thicknessMapTransform);m.attenuationDistance.value=f.attenuationDistance,m.attenuationColor.value.copy(f.attenuationColor)}if(f.anisotropy>0){if(m.anisotropyVector.value.set(f.anisotropy*Math.cos(f.anisotropyRotation),f.anisotropy*Math.sin(f.anisotropyRotation)),f.anisotropyMap)m.anisotropyMap.value=f.anisotropyMap,n(f.anisotropyMap,m.anisotropyMapTransform)}if(m.specularIntensity.value=f.specularIntensity,m.specularColor.value.copy(f.specularColor),f.specularColorMap)m.specularColorMap.value=f.specularColorMap,n(f.specularColorMap,m.specularColorMapTransform);if(f.specularIntensityMap)m.specularIntensityMap.value=f.specularIntensityMap,n(f.specularIntensityMap,m.specularIntensityMapTransform)}function v(m,f){if(f.matcap)m.matcap.value=f.matcap}function T(m,f){let w=e.get(f).light;m.referencePosition.value.setFromMatrixPosition(w.matrixWorld),m.nearDistance.value=w.shadow.camera.near,m.farDistance.value=w.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:s}}function e0(t,e,n,i){let s={},r={},a=[],o=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS);function l(y,b){let A=b.program;i.uniformBlockBinding(y,A)}function c(y,b){let A=s[y.id];if(A===void 0)m(y),A=u(y),s[y.id]=A,y.addEventListener("dispose",w);let E=b.program;i.updateUBOMapping(y,E);let g=e.render.frame;if(r[y.id]!==g)h(y),r[y.id]=g}function u(y){let b=d();y.__bindingPointIndex=b;let A=t.createBuffer(),{__size:E,usage:g}=y;return t.bindBuffer(t.UNIFORM_BUFFER,A),t.bufferData(t.UNIFORM_BUFFER,E,g),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,b,A),A}function d(){for(let y=0;y<o;y++)if(a.indexOf(y)===-1)return a.push(y),y;return Ht("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function h(y){let b=s[y.id],{uniforms:A,__cache:E}=y;t.bindBuffer(t.UNIFORM_BUFFER,b);for(let g=0,M=A.length;g<M;g++){let G=A[g];if(Array.isArray(G))for(let N=0,F=G.length;N<F;N++)p(G[N],g,N,E);else p(G,g,0,E)}t.bindBuffer(t.UNIFORM_BUFFER,null)}function p(y,b,A,E){if(T(y,b,A,E)===!0){let{__offset:g,value:M}=y;if(Array.isArray(M)){let G=0;for(let N=0;N<M.length;N++){let F=M[N],X=f(F);if(v(F,y.__data,G),typeof F!=="number"&&typeof F!=="boolean"&&!F.isMatrix3&&!ArrayBuffer.isView(F))G+=X.storage/Float32Array.BYTES_PER_ELEMENT}}else v(M,y.__data,0);t.bufferSubData(t.UNIFORM_BUFFER,g,y.__data)}}function v(y,b,A){if(typeof y==="number"||typeof y==="boolean")b[0]=y;else if(y.isMatrix3)b[0]=y.elements[0],b[1]=y.elements[1],b[2]=y.elements[2],b[3]=0,b[4]=y.elements[3],b[5]=y.elements[4],b[6]=y.elements[5],b[7]=0,b[8]=y.elements[6],b[9]=y.elements[7],b[10]=y.elements[8],b[11]=0;else if(ArrayBuffer.isView(y))b.set(new y.constructor(y.buffer,y.byteOffset,b.length));else y.toArray(b,A)}function T(y,b,A,E){let g=y.value,M=b+"_"+A;if(E[M]===void 0){if(typeof g==="number"||typeof g==="boolean")E[M]=g;else if(ArrayBuffer.isView(g))E[M]=g.slice();else E[M]=g.clone();return!0}else{let G=E[M];if(typeof g==="number"||typeof g==="boolean"){if(G!==g)return E[M]=g,!0}else if(ArrayBuffer.isView(g))return!0;else if(G.equals(g)===!1)return G.copy(g),!0}return!1}function m(y){let b=y.uniforms,A=0,E=16;for(let M=0,G=b.length;M<G;M++){let N=Array.isArray(b[M])?b[M]:[b[M]];for(let F=0,X=N.length;F<X;F++){let R=N[F],k=Array.isArray(R.value)?R.value:[R.value];for(let Z=0,H=k.length;Z<H;Z++){let at=k[Z],K=f(at),et=A%E,tt=et%K.boundary,dt=et+tt;if(A+=tt,dt!==0&&E-dt<K.storage)A+=E-dt;R.__data=new Float32Array(K.storage/Float32Array.BYTES_PER_ELEMENT),R.__offset=A,A+=K.storage}}}let g=A%E;if(g>0)A+=E-g;return y.__size=A,y.__cache={},this}function f(y){let b={boundary:0,storage:0};if(typeof y==="number"||typeof y==="boolean")b.boundary=4,b.storage=4;else if(y.isVector2)b.boundary=8,b.storage=8;else if(y.isVector3||y.isColor)b.boundary=16,b.storage=12;else if(y.isVector4)b.boundary=16,b.storage=16;else if(y.isMatrix3)b.boundary=48,b.storage=48;else if(y.isMatrix4)b.boundary=64,b.storage=64;else if(y.isTexture)Vt("WebGLRenderer: Texture samplers can not be part of an uniforms group.");else if(ArrayBuffer.isView(y))b.boundary=16,b.storage=y.byteLength;else Vt("WebGLRenderer: Unsupported uniform value type.",y);return b}function w(y){let b=y.target;b.removeEventListener("dispose",w);let A=a.indexOf(b.__bindingPointIndex);a.splice(A,1),t.deleteBuffer(s[b.id]),delete s[b.id],delete r[b.id]}function C(){for(let y in s)t.deleteBuffer(s[y]);a=[],s={},r={}}return{bind:l,update:c,dispose:C}}var n0=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]),Vn=null;function i0(){if(Vn===null)Vn=new rr(n0,16,16,Pi,kn),Vn.name="DFG_LUT",Vn.minFilter=Qe,Vn.magFilter=Qe,Vn.wrapS=Bn,Vn.wrapT=Bn,Vn.generateMipmaps=!1,Vn.needsUpdate=!0;return Vn}class Dl{constructor(t={}){let{canvas:e=mh(),context:n=null,depth:i=!0,stencil:s=!1,alpha:r=!1,antialias:a=!1,premultipliedAlpha:o=!0,preserveDrawingBuffer:l=!1,powerPreference:c="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1,outputBufferType:h=mn}=t;this.isWebGLRenderer=!0;let p;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=n.getContextAttributes().alpha}else p=r;let v=h,T=new Set([fo,uo,ho]),m=new Set([mn,mi,Qs,Ss,lo,co]),f=new Uint32Array(4),w=new Int32Array(4),C=new O,y=null,b=null,A=[],E=[],g=null;this.domElement=e,this.debug={checkShaderErrors:!0,diagnostics:{keywords:!1},onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=Pn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let M=this,G=!1,N=null,F=null,X=null,R=null;this._outputColorSpace=gi;let k=0,Z=0,H=null,at=-1,K=null,et=new Ae,tt=new Ae,dt=null,At=new Kt(0),te=0,{width:Bt,height:Y}=e,rt=1,lt=null,It=null,Ft=new Ae(0,0,Bt,Y),Ut=new Ae(0,0,Bt,Y),Ce=!1,$t=new ar,ee=!1,ue=!1,ne=new we,Le=new O,me=new Ae,Ze={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},Ne=!1;function Re(){return H===null?rt:1}let P=n;function Ue(x,D){return e.getContext(x,D)}let ae,be,S,_,L,V,it,st,ft,J,j,_t,Nt,pt,ot,Ot,kt,se,I,ct,Q,ut,Tt;try{let x={alpha:!0,depth:i,stencil:s,antialias:a,premultipliedAlpha:o,preserveDrawingBuffer:l,powerPreference:c,failIfMajorPerformanceCaveat:u};if("setAttribute"in e)e.setAttribute("data-engine",`three.js r${yc}`);if(e.addEventListener("webglcontextlost",Wt,!1),e.addEventListener("webglcontextrestored",fe,!1),e.addEventListener("webglcontextcreationerror",ce,!1),P===null){if(P=Ue("webgl2",x),P===null)if(Ue("webgl2"))throw Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes.");else throw Error("THREE.WebGLRenderer: Error creating WebGL context.")}nt()}catch(x){throw e.removeEventListener("webglcontextlost",Wt,!1),e.removeEventListener("webglcontextrestored",fe,!1),e.removeEventListener("webglcontextcreationerror",ce,!1),Ht("WebGLRenderer: "+x.message),x}function nt(){if(ae=new hm(P),ae.init(),Q=new $g(P,ae),be=new tm(P,ae,t,Q),S=new Zg(P,ae),be.reversedDepthBuffer&&d)S.buffers.depth.setReversed(!0);F=P.createFramebuffer(),X=P.createFramebuffer(),R=P.createFramebuffer(),_=new fm(P),L=new Dg,V=new Jg(P,ae,S,L,be,Q,_),it=new cm(M),st=new pd(P),ut=new Qp(P,st),ft=new um(P,st,_,ut),J=new mm(P,ft,st,ut,_),se=new pm(P,be,V),ot=new em(L),j=new Ng(M,it,ae,be,ut,ot),_t=new t0(M,L),Nt=new Fg,pt=new Hg(ae),kt=new Kp(M,it,S,J,p,o),Ot=new Yg(M,J,be),Tt=new e0(P,_,be,S),I=new jp(P,ae,_),ct=new dm(P,ae,_),_.programs=j.programs,M.capabilities=be,M.extensions=ae,M.properties=L,M.renderLists=Nt,M.shadowMap=Ot,M.state=S,M.info=_}if(v!==mn)g=new _m(v,e.width,e.height,a,i,s);let mt=new ru(M,P);this.xr=mt,this.getContext=function(){return P},this.getContextAttributes=function(){return P.getContextAttributes()},this.forceContextLoss=function(){let x=ae.get("WEBGL_lose_context");if(x)x.loseContext()},this.forceContextRestore=function(){let x=ae.get("WEBGL_lose_context");if(x)x.restoreContext()},this.getPixelRatio=function(){return rt},this.setPixelRatio=function(x){if(x===void 0)return;rt=x,this.setSize(Bt,Y,!1)},this.getSize=function(x){return x.set(Bt,Y)},this.setSize=function(x,D,W=!0){if(mt.isPresenting){Vt("WebGLRenderer: Can't change size while VR device is presenting.");return}if(Bt=x,Y=D,e.width=Math.floor(x*rt),e.height=Math.floor(D*rt),W===!0)e.style.width=x+"px",e.style.height=D+"px";if(g!==null)g.setSize(e.width,e.height);this.setViewport(0,0,x,D)},this.getDrawingBufferSize=function(x){return x.set(Bt*rt,Y*rt).floor()},this.setDrawingBufferSize=function(x,D,W){Bt=x,Y=D,rt=W,e.width=Math.floor(x*W),e.height=Math.floor(D*W),this.setViewport(0,0,x,D)},this.setEffects=function(x){if(v===mn){Ht("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(x){for(let D=0;D<x.length;D++)if(x[D].isOutputPass===!0){Vt("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}g.setEffects(x||[])},this.getCurrentViewport=function(x){return x.copy(et)},this.getViewport=function(x){return x.copy(Ft)},this.setViewport=function(x,D,W,B){if(x.isVector4)Ft.set(x.x,x.y,x.z,x.w);else Ft.set(x,D,W,B);S.viewport(et.copy(Ft).multiplyScalar(rt).round())},this.getScissor=function(x){return x.copy(Ut)},this.setScissor=function(x,D,W,B){if(x.isVector4)Ut.set(x.x,x.y,x.z,x.w);else Ut.set(x,D,W,B);S.scissor(tt.copy(Ut).multiplyScalar(rt).round())},this.getScissorTest=function(){return Ce},this.setScissorTest=function(x){S.setScissorTest(Ce=x)},this.setOpaqueSort=function(x){lt=x},this.setTransparentSort=function(x){It=x},this.getClearColor=function(x){return x.copy(kt.getClearColor())},this.setClearColor=function(){kt.setClearColor(...arguments)},this.getClearAlpha=function(){return kt.getClearAlpha()},this.setClearAlpha=function(){kt.setClearAlpha(...arguments)},this.clear=function(x=!0,D=!0,W=!0){let B=0;if(x){let z=!1;if(H!==null){let vt=H.texture.format;z=T.has(vt)}if(z){let vt=H.texture.type,Et=m.has(vt),xt=kt.getClearColor(),Pt=kt.getClearAlpha(),{r:Dt,g:Qt,b:ie}=xt;if(Et)f[0]=Dt,f[1]=Qt,f[2]=ie,f[3]=Pt,P.clearBufferuiv(P.COLOR,0,f);else w[0]=Dt,w[1]=Qt,w[2]=ie,w[3]=Pt,P.clearBufferiv(P.COLOR,0,w)}else B|=P.COLOR_BUFFER_BIT}if(D)B|=P.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0);if(W)B|=P.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295);if(B!==0)P.clear(B)},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(x){x.setRenderer(this),N=x},this.dispose=function(){e.removeEventListener("webglcontextlost",Wt,!1),e.removeEventListener("webglcontextrestored",fe,!1),e.removeEventListener("webglcontextcreationerror",ce,!1),kt.dispose(),Nt.dispose(),pt.dispose(),L.dispose(),it.dispose(),J.dispose(),ut.dispose(),Tt.dispose(),j.dispose(),mt.dispose(),mt.removeEventListener("sessionstart",ht),mt.removeEventListener("sessionend",St),bt.stop()};function Wt(x){x.preventDefault(),ks("WebGLRenderer: Context Lost."),G=!0}function fe(){ks("WebGLRenderer: Context Restored."),G=!1;let x=_.autoReset,D=Ot.enabled,W=Ot.autoUpdate,B=Ot.needsUpdate,z=Ot.type;nt(),_.autoReset=x,Ot.enabled=D,Ot.autoUpdate=W,Ot.needsUpdate=B,Ot.type=z}function ce(x){Ht("WebGLRenderer: A WebGL context could not be created. Reason: ",x.statusMessage)}function cn(x){let D=x.target;D.removeEventListener("dispose",cn),vn(D)}function vn(x){mr(x),L.remove(x)}function mr(x){let D=L.get(x).programs;if(D!==void 0){if(D.forEach(function(W){j.releaseProgram(W)}),x.isShaderMaterial)j.releaseShaderCache(x)}}this.renderBufferDirect=function(x,D,W,B,z,vt){if(D===null)D=Ze;let Et=z.isMesh&&z.matrixWorld.determinantAffine()<0,xt=wn(x,D,W,B,z);S.setMaterial(B,Et);let Pt=W.index,Dt=1;if(B.wireframe===!0){if(Pt=ft.getWireframeAttribute(W),Pt===void 0)return;Dt=2}let Qt=W.drawRange,ie=W.attributes.position,Lt=Qt.start*Dt,de=(Qt.start+Qt.count)*Dt;if(vt!==null)Lt=Math.max(Lt,vt.start*Dt),de=Math.min(de,(vt.start+vt.count)*Dt);if(Pt!==null)Lt=Math.max(Lt,0),de=Math.min(de,Pt.count);else if(ie!==void 0&&ie!==null)Lt=Math.max(Lt,0),de=Math.min(de,ie.count);let Fe=de-Lt;if(Fe<0||Fe===1/0)return;ut.setup(z,B,xt,W,Pt);let Ee,Se=I;if(Pt!==null)Ee=st.get(Pt),Se=ct,Se.setIndex(Ee);if(z.isMesh)if(B.wireframe===!0)S.setLineWidth(B.wireframeLinewidth*Re()),Se.setMode(P.LINES);else Se.setMode(P.TRIANGLES);else if(z.isLine){let Je=B.linewidth;if(Je===void 0)Je=1;if(S.setLineWidth(Je*Re()),z.isLineSegments)Se.setMode(P.LINES);else if(z.isLineLoop)Se.setMode(P.LINE_LOOP);else Se.setMode(P.LINE_STRIP)}else if(z.isPoints)Se.setMode(P.POINTS);else if(z.isSprite)Se.setMode(P.TRIANGLES);if(z.isBatchedMesh)if(!ae.get("WEBGL_multi_draw")){let{_multiDrawStarts:Je,_multiDrawCounts:wt,_multiDrawCount:tn}=z,le=Pt?st.get(Pt).bytesPerElement:1,yn=L.get(B).currentProgram.getUniforms();for(let Nn=0;Nn<tn;Nn++)yn.setValue(P,"_gl_DrawID",Nn),Se.render(Je[Nn]/le,wt[Nn])}else Se.renderMultiDraw(z._multiDrawStarts,z._multiDrawCounts,z._multiDrawCount);else if(z.isInstancedMesh)Se.renderInstances(Lt,Fe,z.count);else if(W.isInstancedBufferGeometry){let Je=W._maxInstanceCount!==void 0?W._maxInstanceCount:1/0,wt=Math.min(W.instanceCount,Je);Se.renderInstances(Lt,Fe,wt)}else Se.render(Lt,Fe)};function gr(x,D,W,B){if(N!==null&&x.isNodeMaterial)N.setObject(B,x);if(ee===!0)ot.setState(x,W,!1);if(x.transparent===!0&&x.side===sn&&x.forceSinglePass===!1)x.side=Ve,x.needsUpdate=!0,ln(x,D,B),x.side=xs,x.needsUpdate=!0,ln(x,D,B),x.side=sn;else ln(x,D,B)}this.compile=function(x,D,W=null){if(W===null)W=x;if(N!==null)N.renderStart(x,D,W);if(b=pt.get(W),b.init(D),E.push(b),W.traverseVisible(function(z){if(z.isLight&&z.layers.test(D.layers)){if(b.pushLight(z),z.castShadow)b.pushShadow(z)}}),x!==W)x.traverseVisible(function(z){if(z.isLight&&z.layers.test(D.layers)){if(b.pushLight(z),z.castShadow)b.pushShadow(z)}});if(b.setupLights(),N!==null)N.updateLights(b.state.lightsArray);if(ue=this.localClippingEnabled,ee=ot.init(this.clippingPlanes,ue),ee===!0)ot.setGlobalState(this.clippingPlanes,D);if(N!==null)Ot.render(b.state.shadowsArray,W,D);let B=new Set;if(x.traverse(function(z){if(!(z.isMesh||z.isPoints||z.isLine||z.isSprite))return;let vt=z.material;if(vt)if(Array.isArray(vt))for(let Et=0;Et<vt.length;Et++){let xt=vt[Et];gr(xt,W,D,z),B.add(xt)}else gr(vt,W,D,z),B.add(vt)}),b=E.pop(),N!==null)N.renderEnd();return B},this.compileAsync=function(x,D,W=null){let B=this.compile(x,D,W);return new Promise((z)=>{function vt(){if(B.forEach(function(Et){let Pt=L.get(Et).currentProgram;if(Pt===void 0||Pt.isReady())B.delete(Et)}),B.size===0){z(x);return}setTimeout(vt,10)}if(ae.get("KHR_parallel_shader_compile")!==null)vt();else setTimeout(vt,10)})};let U=null;function q(x){if(U)U(x)}function ht(){bt.stop()}function St(){bt.start()}let bt=new Yh;if(bt.setAnimationLoop(q),typeof self<"u")bt.setContext(self);this.setAnimationLoop=function(x){U=x,mt.setAnimationLoop(x),x===null?bt.stop():bt.start()},mt.addEventListener("sessionstart",ht),mt.addEventListener("sessionend",St),this.render=function(x,D){if(D!==void 0&&D.isCamera!==!0){Ht("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(G===!0)return;if(N!==null)N.renderStart(x,D);let W=mt.enabled===!0&&mt.isPresenting===!0,B=g!==null&&(H===null||W)&&g.begin(M,H);if(x.matrixWorldAutoUpdate===!0)x.updateMatrixWorld();if(D.parent===null&&D.matrixWorldAutoUpdate===!0)D.updateMatrixWorld();if(mt.enabled===!0&&mt.isPresenting===!0&&(g===null||g.isCompositing()===!1)){if(mt.cameraAutoUpdate===!0)mt.updateCamera(D);D=mt.getCamera()}if(x.isScene===!0)x.onBeforeRender(M,x,D,H);if(b=pt.get(x,E.length),b.init(D),b.state.textureUnits=V.getTextureUnits(),E.push(b),ne.multiplyMatrices(D.projectionMatrix,D.matrixWorldInverse),$t.setFromProjectionMatrix(ne,Ko,D.reversedDepth),ue=this.localClippingEnabled,ee=ot.init(this.clippingPlanes,ue),y=Nt.get(x,A.length),y.init(),A.push(y),mt.enabled===!0&&mt.isPresenting===!0){let Et=M.xr.getDepthSensingMesh();if(Et!==null)Zt(Et,D,-1/0,M.sortObjects)}if(Zt(x,D,0,M.sortObjects),y.finish(),N!==null)N.updateLights(b.state.lightsArray);if(M.sortObjects===!0)y.sort(lt,It);if(Ne=mt.enabled===!1||mt.isPresenting===!1||mt.hasDepthSensing()===!1,Ne)kt.addToRenderList(y,x);if(this.info.render.frame++,this.info.autoReset===!0)this.info.reset();if(ee===!0)ot.beginShadows();let z=b.state.shadowsArray;if(Ot.render(z,x,D),ee===!0)ot.endShadows();if((B&&g.hasRenderPass())===!1){let Et=y.opaque,xt=y.transmissive;if(b.setupLights(),D.isArrayCamera){let Pt=D.cameras;if(xt.length>0)for(let Dt=0,Qt=Pt.length;Dt<Qt;Dt++){let ie=Pt[Dt];ve(Et,xt,x,ie)}if(Ne)kt.render(x);for(let Dt=0,Qt=Pt.length;Dt<Qt;Dt++){let ie=Pt[Dt];he(y,x,ie,ie.viewport)}}else{if(xt.length>0)ve(Et,xt,x,D);if(Ne)kt.render(x);he(y,x,D)}}if(H!==null&&Z===0)V.updateMultisampleRenderTarget(H),V.updateRenderTargetMipmap(H);if(B)g.end(M);if(x.isScene===!0)x.onAfterRender(M,x,D);if(ut.resetDefaultState(),at=-1,K=null,E.pop(),E.length>0){if(b=E[E.length-1],V.setTextureUnits(b.state.textureUnits),ee===!0)ot.setGlobalState(M.clippingPlanes,b.state.camera)}else b=null;if(A.pop(),A.length>0)y=A[A.length-1];else y=null;if(N!==null)N.renderEnd()};function Zt(x,D,W,B){if(x.visible===!1)return;if(x.layers.test(D.layers)){if(x.isGroup)W=x.renderOrder;else if(x.isLOD){if(x.autoUpdate===!0)x.update(D)}else if(x.isLightProbeGrid)b.pushLightProbeGrid(x);else if(x.isLight){if(b.pushLight(x),x.castShadow)b.pushShadow(x)}else if(x.isSprite){if(!x.frustumCulled||x.intersectsFrustum($t)){if(B)me.setFromMatrixPosition(x.matrixWorld).applyMatrix4(ne);let Et=J.update(x),xt=x.material;if(xt.visible)y.push(x,Et,xt,W,me.z,null,D)}}else if(x.isMesh||x.isLine||x.isPoints){if(!x.frustumCulled||x.intersectsFrustum($t)){let Et=J.update(x),xt=x.material;if(B){if(x.boundingSphere!==void 0){if(x.boundingSphere===null)x.computeBoundingSphere();me.copy(x.boundingSphere.center)}else{if(Et.boundingSphere===null)Et.computeBoundingSphere();me.copy(Et.boundingSphere.center)}me.applyMatrix4(x.matrixWorld).applyMatrix4(ne)}if(Array.isArray(xt)){let Pt=Et.groups;for(let Dt=0,Qt=Pt.length;Dt<Qt;Dt++){let ie=Pt[Dt],Lt=xt[ie.materialIndex];if(Lt&&Lt.visible)y.push(x,Et,Lt,W,me.z,ie,D)}}else if(xt.visible)y.push(x,Et,xt,W,me.z,null,D)}}}let vt=x.children;for(let Et=0,xt=vt.length;Et<xt;Et++)Zt(vt[Et],D,W,B)}function he(x,D,W,B){let{opaque:z,transmissive:vt,transparent:Et}=x;if(b.setupLightsView(W),ee===!0)ot.setGlobalState(M.clippingPlanes,W);if(B)S.viewport(et.copy(B));if(z.length>0)Xt(z,D,W);if(vt.length>0)Xt(vt,D,W);if(Et.length>0)Xt(Et,D,W);S.buffers.depth.setTest(!0),S.buffers.depth.setMask(!0),S.buffers.color.setMask(!0),S.setPolygonOffset(!1)}function ve(x,D,W,B){if((W.isScene===!0?W.overrideMaterial:null)!==null)return;if(b.state.transmissionRenderTarget[B.id]===void 0){let Lt=ae.has("EXT_color_buffer_half_float")||ae.has("EXT_color_buffer_float");b.state.transmissionRenderTarget[B.id]=new gn(1,1,{generateMipmaps:!0,type:Lt?kn:mn,minFilter:Ci,samples:Math.max(4,be.samples),stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:re.workingColorSpace})}let vt=b.state.transmissionRenderTarget[B.id],Et=B.viewport||et;vt.setSize(Et.z*M.transmissionResolutionScale,Et.w*M.transmissionResolutionScale);let xt=M.getRenderTarget(),Pt=M.getActiveCubeFace(),Dt=M.getActiveMipmapLevel();if(M.setRenderTarget(vt),M.getClearColor(At),te=M.getClearAlpha(),te<1)M.setClearColor(16777215,0.5);if(M.clear(),Ne)kt.render(W);let Qt=M.toneMapping;M.toneMapping=Pn;let ie=B.viewport;if(B.viewport!==void 0)B.viewport=void 0;if(b.setupLightsView(B),ee===!0)ot.setGlobalState(M.clippingPlanes,B);if(Xt(x,W,B),V.updateMultisampleRenderTarget(vt),V.updateRenderTargetMipmap(vt),ae.has("WEBGL_multisampled_render_to_texture")===!1){let Lt=!1;for(let de=0,Fe=D.length;de<Fe;de++){let Ee=D[de],{object:Se,geometry:Je,material:wt,group:tn}=Ee;if(wt.side===sn&&Se.layers.test(B.layers)){let le=wt.side;wt.side=Ve,wt.needsUpdate=!0,an(Se,W,B,Je,wt,tn),wt.side=le,wt.needsUpdate=!0,Lt=!0}}if(Lt===!0)V.updateMultisampleRenderTarget(vt),V.updateRenderTargetMipmap(vt)}if(M.setRenderTarget(xt,Pt,Dt),M.setClearColor(At,te),ie!==void 0)B.viewport=ie;M.toneMapping=Qt}function Xt(x,D,W){let B=D.isScene===!0?D.overrideMaterial:null;for(let z=0,vt=x.length;z<vt;z++){let Et=x[z],{object:xt,geometry:Pt,group:Dt}=Et,Qt=Et.material;if(Qt.allowOverride===!0&&B!==null)Qt=B;if(xt.layers.test(W.layers))an(xt,D,W,Pt,Qt,Dt)}}function an(x,D,W,B,z,vt){if(N!==null&&z.isNodeMaterial)N.setObject(x,z);if(x.onBeforeRender(M,D,W,B,z,vt),x.modelViewMatrix.multiplyMatrices(W.matrixWorldInverse,x.matrixWorld),x.normalMatrix.getNormalMatrix(x.modelViewMatrix),z.onBeforeRender(M,D,W,B,x,vt),z.transparent===!0&&z.side===sn&&z.forceSinglePass===!1)z.side=Ve,z.needsUpdate=!0,M.renderBufferDirect(W,D,B,z,x,vt),z.side=xs,z.needsUpdate=!0,M.renderBufferDirect(W,D,B,z,x,vt),z.side=sn;else M.renderBufferDirect(W,D,B,z,x,vt);x.onAfterRender(M,D,W,B,z,vt)}function ln(x,D,W){if(D.isScene!==!0)D=Ze;let B=L.get(x),z=b.state.lights,vt=b.state.shadowsArray,Et=z.state.version,xt=j.getParameters(x,z.state,vt,D,W,b.state.lightProbeGridArray),Pt=j.getProgramCacheKey(xt),Dt=B.programs;B.environment=x.isMeshStandardMaterial||x.isMeshLambertMaterial||x.isMeshPhongMaterial?D.environment:null,B.fog=D.fog;let Qt=x.isMeshStandardMaterial||x.isMeshLambertMaterial&&!x.envMap||x.isMeshPhongMaterial&&!x.envMap;if(B.envMap=it.get(x.envMap||B.environment,Qt),B.envMapRotation=B.environment!==null&&x.envMap===null?D.environmentRotation:x.envMapRotation,Dt===void 0)x.addEventListener("dispose",cn),Dt=new Map,B.programs=Dt;let ie=Dt.get(Pt);if(ie!==void 0){if(B.currentProgram===ie&&B.lightsStateVersion===Et)return ge(x,xt),ie}else{if(xt.uniforms=j.getUniforms(x),N!==null&&x.isNodeMaterial)N.build(x,W,xt);x.onBeforeCompile(xt,M),ie=j.acquireProgram(xt,Pt),Dt.set(Pt,ie),B.uniforms=xt.uniforms}let Lt=B.uniforms;if(!x.isShaderMaterial&&!x.isRawShaderMaterial||x.clipping===!0)Lt.clippingPlanes=ot.uniform;if(ge(x,xt),B.needsLights=ii(x),B.lightsStateVersion=Et,B.needsLights)Lt.ambientLightColor.value=z.state.ambient,Lt.lightProbe.value=z.state.probe,Lt.sunLights.value=z.state.sun,Lt.sunLightShadows.value=z.state.sunShadow,Lt.directionalLights.value=z.state.directional,Lt.directionalLightShadows.value=z.state.directionalShadow,Lt.spotLights.value=z.state.spot,Lt.spotLightShadows.value=z.state.spotShadow,Lt.rectAreaLights.value=z.state.rectArea,Lt.ltc_1.value=z.state.rectAreaLTC1,Lt.ltc_2.value=z.state.rectAreaLTC2,Lt.pointLights.value=z.state.point,Lt.pointLightShadows.value=z.state.pointShadow,Lt.hemisphereLights.value=z.state.hemi,Lt.sunShadowMatrix.value=z.state.sunShadowMatrix,Lt.sunShadowCascade.value=z.state.sunShadowCascade,Lt.directionalShadowMatrix.value=z.state.directionalShadowMatrix,Lt.spotLightMatrix.value=z.state.spotLightMatrix,Lt.spotLightMap.value=z.state.spotLightMap,Lt.pointShadowMatrix.value=z.state.pointShadowMatrix;return B.lightProbeGrid=b.state.lightProbeGridArray.length>0,B.currentProgram=ie,B.uniformsList=null,ie}function Si(x){if(x.uniformsList===null){let D=x.currentProgram.getUniforms();x.uniformsList=ur.seqWithValue(D.seq,x.uniforms)}return x.uniformsList}function ge(x,D){let W=L.get(x);W.outputColorSpace=D.outputColorSpace,W.batching=D.batching,W.batchingColor=D.batchingColor,W.instancing=D.instancing,W.instancingColor=D.instancingColor,W.instancingMorph=D.instancingMorph,W.skinning=D.skinning,W.morphTargets=D.morphTargets,W.morphNormals=D.morphNormals,W.morphColors=D.morphColors,W.morphTargetsCount=D.morphTargetsCount,W.numClippingPlanes=D.numClippingPlanes,W.numIntersection=D.numClipIntersection,W.vertexAlphas=D.vertexAlphas,W.vertexTangents=D.vertexTangents,W.toneMapping=D.toneMapping}function ye(x,D){if(x.length===0)return null;if(x.length===1)return x[0].texture!==null?x[0]:null;C.setFromMatrixPosition(D.matrixWorld);for(let W=0,B=x.length;W<B;W++){let z=x[W];if(z.texture!==null&&z.boundingBox.containsPoint(C))return z}return null}function wn(x,D,W,B,z){if(D.isScene!==!0)D=Ze;V.resetTextureUnits();let vt=D.fog,Et=B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial?D.environment:null,xt=H===null?M.outputColorSpace:H.isXRRenderTarget===!0?H.texture.colorSpace:re.workingColorSpace,Pt=B.isMeshStandardMaterial||B.isMeshLambertMaterial&&!B.envMap||B.isMeshPhongMaterial&&!B.envMap,Dt=it.get(B.envMap||Et,Pt),Qt=B.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,ie=!!W.attributes.tangent&&(!!B.normalMap||B.anisotropy>0),Lt=!!W.morphAttributes.position,de=!!W.morphAttributes.normal,Fe=!!W.morphAttributes.color,Ee=Pn;if(B.toneMapped){if(H===null||H.isXRRenderTarget===!0)Ee=M.toneMapping}let Se=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,Je=Se!==void 0?Se.length:0,wt=L.get(B),tn=b.state.lights;if(ee===!0){if(ue===!0||x!==K){let Te=x===K&&B.id===at;ot.setState(B,x,Te)}}let le=!1;if(B.version===wt.__version){if(wt.needsLights&&wt.lightsStateVersion!==tn.state.version)le=!0;else if(wt.outputColorSpace!==xt)le=!0;else if(z.isBatchedMesh&&wt.batching===!1)le=!0;else if(!z.isBatchedMesh&&wt.batching===!0)le=!0;else if(z.isBatchedMesh&&wt.batchingColor===!0&&z._colorsTexture===null)le=!0;else if(z.isBatchedMesh&&wt.batchingColor===!1&&z._colorsTexture!==null)le=!0;else if(z.isInstancedMesh&&wt.instancing===!1)le=!0;else if(!z.isInstancedMesh&&wt.instancing===!0)le=!0;else if(z.isSkinnedMesh&&wt.skinning===!1)le=!0;else if(!z.isSkinnedMesh&&wt.skinning===!0)le=!0;else if(z.isInstancedMesh&&wt.instancingColor===!0&&z.instanceColor===null)le=!0;else if(z.isInstancedMesh&&wt.instancingColor===!1&&z.instanceColor!==null)le=!0;else if(z.isInstancedMesh&&wt.instancingMorph===!0&&z.morphTexture===null)le=!0;else if(z.isInstancedMesh&&wt.instancingMorph===!1&&z.morphTexture!==null)le=!0;else if(wt.envMap!==Dt)le=!0;else if(B.fog===!0&&wt.fog!==vt)le=!0;else if(wt.numClippingPlanes!==void 0&&(wt.numClippingPlanes!==ot.numPlanes||wt.numIntersection!==ot.numIntersection))le=!0;else if(wt.vertexAlphas!==Qt)le=!0;else if(wt.vertexTangents!==ie)le=!0;else if(wt.morphTargets!==Lt)le=!0;else if(wt.morphNormals!==de)le=!0;else if(wt.morphColors!==Fe)le=!0;else if(wt.toneMapping!==Ee)le=!0;else if(wt.morphTargetsCount!==Je)le=!0;else if(!!wt.lightProbeGrid!==b.state.lightProbeGridArray.length>0)le=!0}else le=!0,wt.__version=B.version;let yn=wt.currentProgram;if(le===!0){if(yn=ln(B,D,z),N&&B.isNodeMaterial)N.onUpdateProgram(B,yn,wt)}let Nn=!1,si=!1,Vi=!1,_e=yn.getUniforms(),De=wt.uniforms;if(S.useProgram(yn.program))Nn=!0,si=!0,Vi=!0;if(B.id!==at)at=B.id,si=!0;if(wt.needsLights){let Te=ye(b.state.lightProbeGridArray,z);if(wt.lightProbeGrid!==Te)wt.lightProbeGrid=Te,si=!0}if(Nn||K!==x){if(S.buffers.depth.getReversed()&&x.reversedDepth!==!0)x._reversedDepth=!0,x.updateProjectionMatrix();_e.setValue(P,"projectionMatrix",x.projectionMatrix),_e.setValue(P,"viewMatrix",x.matrixWorldInverse);let ai=_e.map.cameraPosition;if(ai!==void 0)ai.setValue(P,Le.setFromMatrixPosition(x.matrixWorld));if(be.logarithmicDepthBuffer)_e.setValue(P,"logDepthBufFC",2/(Math.log(x.far+1)/Math.LN2));if(B.isMeshPhongMaterial||B.isMeshToonMaterial||B.isMeshLambertMaterial||B.isMeshBasicMaterial||B.isMeshStandardMaterial||B.isShaderMaterial)_e.setValue(P,"isOrthographic",x.isOrthographicCamera===!0);if(K!==x)K=x,si=!0,Vi=!0}if(wt.needsLights){if(tn.state.sunShadowMap.length>0)_e.setValue(P,"sunShadowMap",tn.state.sunShadowMap,V);if(tn.state.directionalShadowMap.length>0)_e.setValue(P,"directionalShadowMap",tn.state.directionalShadowMap,V);if(tn.state.spotShadowMap.length>0)_e.setValue(P,"spotShadowMap",tn.state.spotShadowMap,V);if(tn.state.pointShadowMap.length>0)_e.setValue(P,"pointShadowMap",tn.state.pointShadowMap,V)}if(z.isSkinnedMesh){_e.setOptional(P,z,"bindMatrix"),_e.setOptional(P,z,"bindMatrixInverse");let Te=z.skeleton;if(Te){if(Te.boneTexture===null)Te.computeBoneTexture();_e.setValue(P,"boneTexture",Te.boneTexture,V)}}if(z.isBatchedMesh){if(_e.setOptional(P,z,"batchingTexture"),_e.setValue(P,"batchingTexture",z._matricesTexture,V),_e.setOptional(P,z,"batchingIdTexture"),_e.setValue(P,"batchingIdTexture",z._indirectTexture,V),_e.setOptional(P,z,"batchingColorTexture"),z._colorsTexture!==null)_e.setValue(P,"batchingColorTexture",z._colorsTexture,V)}let ri=W.morphAttributes;if(ri.position!==void 0||ri.normal!==void 0||ri.color!==void 0)se.update(z,W,yn);if(si||wt.receiveShadow!==z.receiveShadow)wt.receiveShadow=z.receiveShadow,_e.setValue(P,"receiveShadow",z.receiveShadow);if((B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial)&&B.envMap===null&&D.environment!==null)De.envMapIntensity.value=D.environmentIntensity;if(De.dfgLUT!==void 0)De.dfgLUT.value=i0();if(si){if(_e.setValue(P,"toneMappingExposure",M.toneMappingExposure),wt.needsLights)We(De,Vi);if(vt&&B.fog===!0)_t.refreshFogUniforms(De,vt);if(_t.refreshMaterialUniforms(De,B,rt,Y,b.state.transmissionRenderTarget[x.id]),wt.needsLights&&wt.lightProbeGrid){let Te=wt.lightProbeGrid;De.probesSH.value=Te.texture,De.probesMin.value.copy(Te.boundingBox.min),De.probesMax.value.copy(Te.boundingBox.max),De.probesResolution.value.copy(Te.resolution)}ur.upload(P,Si(wt),De,V)}if(B.isShaderMaterial&&B.uniformsNeedUpdate===!0)ur.upload(P,Si(wt),De,V),B.uniformsNeedUpdate=!1;if(B.isSpriteMaterial)_e.setValue(P,"center",z.center);if(_e.setValue(P,"modelViewMatrix",z.modelViewMatrix),_e.setValue(P,"normalMatrix",z.normalMatrix),_e.setValue(P,"modelMatrix",z.matrixWorld),B.uniformsGroups!==void 0){let Te=B.uniformsGroups;for(let ai=0,Xi=Te.length;ai<Xi;ai++){let Zl=Te[ai];Tt.update(Zl,yn),Tt.bind(Zl,yn)}}return yn}function We(x,D){x.ambientLightColor.needsUpdate=D,x.lightProbe.needsUpdate=D,x.sunLights.needsUpdate=D,x.sunLightShadows.needsUpdate=D,x.directionalLights.needsUpdate=D,x.directionalLightShadows.needsUpdate=D,x.pointLights.needsUpdate=D,x.pointLightShadows.needsUpdate=D,x.spotLights.needsUpdate=D,x.spotLightShadows.needsUpdate=D,x.rectAreaLights.needsUpdate=D,x.hemisphereLights.needsUpdate=D}function ii(x){return x.isMeshLambertMaterial||x.isMeshToonMaterial||x.isMeshPhongMaterial||x.isMeshStandardMaterial||x.isShadowMaterial||x.isShaderMaterial&&x.lights===!0}this.getActiveCubeFace=function(){return k},this.getActiveMipmapLevel=function(){return Z},this.getRenderTarget=function(){return H},this.setRenderTargetTextures=function(x,D,W){let B=L.get(x);if(B.__autoAllocateDepthBuffer=x.resolveDepthBuffer===!1,B.__autoAllocateDepthBuffer===!1)B.__useRenderToTexture=!1;L.get(x.texture).__webglTexture=D,L.get(x.depthTexture).__webglTexture=B.__autoAllocateDepthBuffer?void 0:W,B.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(x,D){let W=L.get(x);W.__webglFramebuffer=D,W.__useDefaultFramebuffer=D===void 0},this.setRenderTarget=function(x,D=0,W=0){H=x,k=D,Z=W;let B=null,z=!1,vt=!1;if(x){let xt=L.get(x);if(xt.__useDefaultFramebuffer!==void 0){S.bindFramebuffer(P.FRAMEBUFFER,xt.__webglFramebuffer),et.copy(x.viewport),tt.copy(x.scissor),dt=x.scissorTest,S.viewport(et),S.scissor(tt),S.setScissorTest(dt),at=-1;return}else if(xt.__webglFramebuffer===void 0)V.setupRenderTarget(x);else if(xt.__hasExternalTextures)V.rebindTextures(x,L.get(x.texture).__webglTexture,L.get(x.depthTexture).__webglTexture);else if(x.depthBuffer){let Qt=x.depthTexture;if(xt.__boundDepthTexture!==Qt){if(Qt!==null&&L.has(Qt)&&(x.width!==Qt.image.width||x.height!==Qt.image.height))throw Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");V.setupDepthRenderbuffer(x)}}let Pt=x.texture;if(Pt.isData3DTexture||Pt.isDataArrayTexture||Pt.isCompressedArrayTexture)vt=!0;let Dt=L.get(x).__webglFramebuffer;if(x.isWebGLCubeRenderTarget){if(Array.isArray(Dt[D]))B=Dt[D][W];else B=Dt[D];z=!0}else if(x.samples>0&&V.useMultisampledRTT(x)===!1)B=L.get(x).__webglMultisampledFramebuffer;else if(Array.isArray(Dt))B=Dt[W];else B=Dt;et.copy(x.viewport),tt.copy(x.scissor),dt=x.scissorTest}else et.copy(Ft).multiplyScalar(rt).floor(),tt.copy(Ut).multiplyScalar(rt).floor(),dt=Ce;if(W!==0)B=F;if(S.bindFramebuffer(P.FRAMEBUFFER,B))S.drawBuffers(x,B);if(S.viewport(et),S.scissor(tt),S.setScissorTest(dt),z){let xt=L.get(x.texture);P.framebufferTexture2D(P.FRAMEBUFFER,P.COLOR_ATTACHMENT0,P.TEXTURE_CUBE_MAP_POSITIVE_X+D,xt.__webglTexture,W)}else if(vt){let xt=D;for(let Pt=0;Pt<x.textures.length;Pt++){let Dt=L.get(x.textures[Pt]);P.framebufferTextureLayer(P.FRAMEBUFFER,P.COLOR_ATTACHMENT0+Pt,Dt.__webglTexture,W,xt)}}else if(x!==null&&W!==0){let xt=L.get(x.texture);P.framebufferTexture2D(P.FRAMEBUFFER,P.COLOR_ATTACHMENT0,P.TEXTURE_2D,xt.__webglTexture,W)}at=-1};function Yl(x){let D=L.get(x);if(D.__readFormat!==x.format||D.__readType!==x.type)D.__readFormat=x.format,D.__readType=x.type,D.__formatReadable=be.textureFormatReadable(x.format),D.__typeReadable=be.textureTypeReadable(x.type);return D}if(this.readRenderTargetPixels=function(x,D,W,B,z,vt,Et,xt=0){if(!(x&&x.isWebGLRenderTarget)){Ht("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Pt=L.get(x).__webglFramebuffer;if(x.isWebGLCubeRenderTarget&&Et!==void 0)Pt=Pt[Et];if(Pt){S.bindFramebuffer(P.FRAMEBUFFER,Pt);try{let Dt=x.textures[xt],{format:Qt,type:ie}=Dt;if(x.textures.length>1)P.readBuffer(P.COLOR_ATTACHMENT0+xt);let Lt=Yl(Dt);if(Lt.__formatReadable===!1){Ht("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(Lt.__typeReadable===!1){Ht("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}if(D>=0&&D<=x.width-B&&(W>=0&&W<=x.height-z))P.readPixels(D,W,B,z,Q.convert(Qt),Q.convert(ie),vt)}finally{let Dt=H!==null?L.get(H).__webglFramebuffer:null;S.bindFramebuffer(P.FRAMEBUFFER,Dt)}}},this.readRenderTargetPixelsAsync=async function(x,D,W,B,z,vt,Et,xt=0){if(!(x&&x.isWebGLRenderTarget))throw Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Pt=L.get(x).__webglFramebuffer;if(x.isWebGLCubeRenderTarget&&Et!==void 0)Pt=Pt[Et];if(Pt)if(D>=0&&D<=x.width-B&&(W>=0&&W<=x.height-z)){S.bindFramebuffer(P.FRAMEBUFFER,Pt);let Dt=x.textures[xt],{format:Qt,type:ie}=Dt;if(x.textures.length>1)P.readBuffer(P.COLOR_ATTACHMENT0+xt);let Lt=Yl(Dt);if(Lt.__formatReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(Lt.__typeReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let de=P.createBuffer();P.bindBuffer(P.PIXEL_PACK_BUFFER,de),P.bufferData(P.PIXEL_PACK_BUFFER,vt.byteLength,P.STREAM_READ),P.readPixels(D,W,B,z,Q.convert(Qt),Q.convert(ie),0),P.bindBuffer(P.PIXEL_PACK_BUFFER,null);let Fe=H!==null?L.get(H).__webglFramebuffer:null;S.bindFramebuffer(P.FRAMEBUFFER,Fe);let Ee=P.fenceSync(P.SYNC_GPU_COMMANDS_COMPLETE,0);return P.flush(),await _h(P,Ee,4),P.bindBuffer(P.PIXEL_PACK_BUFFER,de),P.getBufferSubData(P.PIXEL_PACK_BUFFER,0,vt),P.bindBuffer(P.PIXEL_PACK_BUFFER,null),P.deleteBuffer(de),P.deleteSync(Ee),vt}else throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(x,D=null,W=0){let B=Math.pow(2,-W),z=Math.floor(x.image.width*B),vt=Math.floor(x.image.height*B),Et=D!==null?D.x:0,xt=D!==null?D.y:0;V.setTexture2D(x,0),P.copyTexSubImage2D(P.TEXTURE_2D,W,0,0,Et,xt,z,vt),S.unbindTexture()},this.copyTextureToTexture=function(x,D,W=null,B=null,z=0,vt=0){let Et,xt,Pt,Dt,Qt,ie,Lt,de,Fe,Ee=x.isCompressedTexture?x.mipmaps[vt]:x.image;if(W!==null)Et=W.max.x-W.min.x,xt=W.max.y-W.min.y,Pt=W.isBox3?W.max.z-W.min.z:1,Dt=W.min.x,Qt=W.min.y,ie=W.isBox3?W.min.z:0;else{let De=Math.pow(2,-z);if(Et=Math.floor(Ee.width*De),xt=Math.floor(Ee.height*De),x.isDataArrayTexture)Pt=Ee.depth;else if(x.isData3DTexture)Pt=Math.floor(Ee.depth*De);else Pt=1;Dt=0,Qt=0,ie=0}if(B!==null)Lt=B.x,de=B.y,Fe=B.z;else Lt=0,de=0,Fe=0;let Se=Q.convert(D.format),Je=Q.convert(D.type),wt;if(D.isData3DTexture)V.setTexture3D(D,0),wt=P.TEXTURE_3D;else if(D.isDataArrayTexture||D.isCompressedArrayTexture)V.setTexture2DArray(D,0),wt=P.TEXTURE_2D_ARRAY;else V.setTexture2D(D,0),wt=P.TEXTURE_2D;S.activeTexture(P.TEXTURE0),S.pixelStorei(P.UNPACK_FLIP_Y_WEBGL,D.flipY),S.pixelStorei(P.UNPACK_PREMULTIPLY_ALPHA_WEBGL,D.premultiplyAlpha),S.pixelStorei(P.UNPACK_ALIGNMENT,D.unpackAlignment);let tn=S.getParameter(P.UNPACK_ROW_LENGTH),le=S.getParameter(P.UNPACK_IMAGE_HEIGHT),yn=S.getParameter(P.UNPACK_SKIP_PIXELS),Nn=S.getParameter(P.UNPACK_SKIP_ROWS),si=S.getParameter(P.UNPACK_SKIP_IMAGES);S.pixelStorei(P.UNPACK_ROW_LENGTH,Ee.width),S.pixelStorei(P.UNPACK_IMAGE_HEIGHT,Ee.height),S.pixelStorei(P.UNPACK_SKIP_PIXELS,Dt),S.pixelStorei(P.UNPACK_SKIP_ROWS,Qt),S.pixelStorei(P.UNPACK_SKIP_IMAGES,ie);let Vi=x.isDataArrayTexture||x.isData3DTexture,_e=D.isDataArrayTexture||D.isData3DTexture;if(x.isDepthTexture){let De=L.get(x),ri=L.get(D),Te=L.get(De.__renderTarget),ai=L.get(ri.__renderTarget);S.bindFramebuffer(P.READ_FRAMEBUFFER,Te.__webglFramebuffer),S.bindFramebuffer(P.DRAW_FRAMEBUFFER,ai.__webglFramebuffer);for(let Xi=0;Xi<Pt;Xi++){if(Vi)P.framebufferTextureLayer(P.READ_FRAMEBUFFER,P.COLOR_ATTACHMENT0,L.get(x).__webglTexture,z,ie+Xi),P.framebufferTextureLayer(P.DRAW_FRAMEBUFFER,P.COLOR_ATTACHMENT0,L.get(D).__webglTexture,vt,Fe+Xi);P.blitFramebuffer(Dt,Qt,Et,xt,Lt,de,Et,xt,P.DEPTH_BUFFER_BIT,P.NEAREST)}S.bindFramebuffer(P.READ_FRAMEBUFFER,null),S.bindFramebuffer(P.DRAW_FRAMEBUFFER,null)}else if(z!==0||x.isRenderTargetTexture||L.has(x)){let De=L.get(x),ri=L.get(D);S.bindFramebuffer(P.READ_FRAMEBUFFER,X),S.bindFramebuffer(P.DRAW_FRAMEBUFFER,R);for(let Te=0;Te<Pt;Te++){if(Vi)P.framebufferTextureLayer(P.READ_FRAMEBUFFER,P.COLOR_ATTACHMENT0,De.__webglTexture,z,ie+Te);else P.framebufferTexture2D(P.READ_FRAMEBUFFER,P.COLOR_ATTACHMENT0,P.TEXTURE_2D,De.__webglTexture,z);if(_e)P.framebufferTextureLayer(P.DRAW_FRAMEBUFFER,P.COLOR_ATTACHMENT0,ri.__webglTexture,vt,Fe+Te);else P.framebufferTexture2D(P.DRAW_FRAMEBUFFER,P.COLOR_ATTACHMENT0,P.TEXTURE_2D,ri.__webglTexture,vt);if(z!==0)P.blitFramebuffer(Dt,Qt,Et,xt,Lt,de,Et,xt,P.COLOR_BUFFER_BIT,P.NEAREST);else if(_e)P.copyTexSubImage3D(wt,vt,Lt,de,Fe+Te,Dt,Qt,Et,xt);else P.copyTexSubImage2D(wt,vt,Lt,de,Dt,Qt,Et,xt)}S.bindFramebuffer(P.READ_FRAMEBUFFER,null),S.bindFramebuffer(P.DRAW_FRAMEBUFFER,null)}else if(_e)if(x.isDataTexture||x.isData3DTexture)P.texSubImage3D(wt,vt,Lt,de,Fe,Et,xt,Pt,Se,Je,Ee.data);else if(D.isCompressedArrayTexture)P.compressedTexSubImage3D(wt,vt,Lt,de,Fe,Et,xt,Pt,Se,Ee.data);else P.texSubImage3D(wt,vt,Lt,de,Fe,Et,xt,Pt,Se,Je,Ee);else if(x.isDataTexture)P.texSubImage2D(P.TEXTURE_2D,vt,Lt,de,Et,xt,Se,Je,Ee.data);else if(x.isCompressedTexture)P.compressedTexSubImage2D(P.TEXTURE_2D,vt,Lt,de,Ee.width,Ee.height,Se,Ee.data);else P.texSubImage2D(P.TEXTURE_2D,vt,Lt,de,Et,xt,Se,Je,Ee);if(S.pixelStorei(P.UNPACK_ROW_LENGTH,tn),S.pixelStorei(P.UNPACK_IMAGE_HEIGHT,le),S.pixelStorei(P.UNPACK_SKIP_PIXELS,yn),S.pixelStorei(P.UNPACK_SKIP_ROWS,Nn),S.pixelStorei(P.UNPACK_SKIP_IMAGES,si),vt===0&&D.generateMipmaps)P.generateMipmap(wt);S.unbindTexture()},this.initRenderTarget=function(x){if(L.get(x).__webglFramebuffer===void 0)V.setupRenderTarget(x)},this.initTexture=function(x){if(x.isCubeTexture)V.setTextureCube(x,0);else if(x.isData3DTexture)V.setTexture3D(x,0);else if(x.isDataArrayTexture||x.isCompressedArrayTexture)V.setTexture2DArray(x,0);else V.setTexture2D(x,0);S.unbindTexture()},this.resetState=function(){k=0,Z=0,H=null,S.reset(),ut.reset()},typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Ko}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;let e=this.getContext();e.drawingBufferColorSpace=re._getDrawingBufferColorSpace(t),e.unpackColorSpace=re._getUnpackColorSpace()}}function Pe(t,e){let n=document.createElement("canvas");n.width=t,n.height=e;let i=n.getContext("2d");if(!i)throw Error("a canvas has no 2D context");return[n,i]}var Ul=(t)=>{let e=t;return()=>{e+=1831565813;let n=Math.imul(e^e>>>15,e|1);return n^=n+Math.imul(n^n>>>7,n|61),((n^n>>>14)>>>0)/4294967296}},ou=(t,e)=>e>0.7?t.glassLight:e<0.3?t.glassDark:t.glass,Gi=(t,e,n)=>{t.strokeStyle=e,t.lineWidth=n,t.lineJoin="round",t.lineCap="round",t.stroke()};function lu(t,e,n,i,s){let r=n+i*0.9;t.beginPath(),t.moveTo(e,n+s),t.lineTo(e,r),t.bezierCurveTo(e,n+i*0.35,e+i*0.38,n+i*0.12,e+i/2,n),t.bezierCurveTo(e+i*0.62,n+i*0.12,e+i,n+i*0.35,e+i,r),t.lineTo(e+i,n+s),t.closePath()}function vi(t,e,n,i,s=0.32){t.beginPath();for(let r=0;r<8;r+=1){let a=Math.PI/4*r-Math.PI/2,o=r%2===0?i:i*s;t.lineTo(e+Math.cos(a)*o,n+Math.sin(a)*o)}t.closePath()}function cu(t){let[e,n]=Pe(512,512),i=Ul(11);n.fillStyle=t.floor,n.fillRect(0,0,512,512);let s=4,r=512/s;for(let a=0;a<s;a+=1)for(let o=0;o<s;o+=1)if((a+o)%2===0||i()>0.7)n.fillStyle=t.stoneShade,n.globalAlpha=0.28,n.fillRect(o*r,a*r,r,r),n.globalAlpha=1;n.strokeStyle=t.floorJoint,n.lineWidth=6;for(let a=0;a<=s;a+=1)n.beginPath(),n.moveTo(a*r,0),n.lineTo(a*r,512),n.moveTo(0,a*r),n.lineTo(512,a*r),n.stroke();return e}function hu(t){let[e,n]=Pe(512,512),i=Ul(23);n.fillStyle=t.stone,n.fillRect(0,0,512,512);let s=8,r=512/s;for(let a=0;a<s;a+=1){let o=a%2===0?4:5,l=512/(a%2===0?4:4),c=a%2===0?0:-l/2;for(let u=0;u<=o;u+=1){let d=c+u*l;if(i()>0.55)n.fillStyle=t.stoneShade,n.globalAlpha=0.45,n.fillRect(d,a*r,l,r),n.globalAlpha=1;n.fillStyle=t.stoneJoint,n.fillRect(d-3,a*r,6,r)}n.fillStyle=t.stoneJoint,n.fillRect(0,a*r-3,512,6)}return e}function xa(t){let[n,i]=Pe(1024,1024),s=512;i.translate(512,512),i.strokeStyle=t.rune,i.fillStyle=t.rune,i.lineCap="round",i.lineJoin="round",i.shadowColor=t.rune,i.shadowBlur=26;let r=(a,o)=>{i.lineWidth=o,i.beginPath(),i.arc(0,0,a,0,Math.PI*2),i.stroke()};r(480,14),r(452,4),r(330,10),r(300,4),r(150,8);for(let a=0;a<16;a+=1){if(i.save(),i.rotate(Math.PI*2*a/16),i.translate(0,-391),a%2===0)vi(i,0,0,34,0.3),i.fill();else i.beginPath(),i.arc(0,0,22,0.55*Math.PI,2.45*Math.PI),i.arc(9,-2,18,2.45*Math.PI,0.55*Math.PI,!0),i.closePath(),i.fill();i.restore()}i.lineWidth=7;for(let a=0;a<8;a+=1)i.save(),i.rotate(Math.PI*2*a/8),i.beginPath(),i.moveTo(0,-150),i.lineTo(0,-300),i.stroke(),i.restore();return vi(i,0,0,142,0.2),i.fill(),i.shadowBlur=0,i.fillStyle=t.bg,i.globalAlpha=0.55,vi(i,0,0,52,0.4),i.fill(),n}function Fl(t,e){let n=Ul(e==="rose"?5:9);if(e==="lancet"){let[l,c]=Pe(256,512);lu(c,14,10,228,492),c.save(),c.clip(),c.fillStyle=t.glass,c.fillRect(0,0,256,512);let u=3,d=8,h=228/u,p=492/d;for(let v=0;v<d;v+=1)for(let T=0;T<u;T+=1)c.fillStyle=ou(t,n()),c.fillRect(14+T*h,10+v*p,h,p);if(t.night){c.fillStyle=t.sky;for(let v=0;v<6;v+=1)vi(c,40+n()*176,60+n()*380,5+n()*4,0.3),c.fill()}c.restore(),c.strokeStyle=t.stoneJoint,c.lineWidth=9;for(let v=1;v<u;v+=1)c.beginPath(),c.moveTo(14+v*h,10),c.lineTo(14+v*h,502),c.stroke();for(let v=1;v<d;v+=1)c.beginPath(),c.moveTo(14,10+v*p),c.lineTo(242,10+v*p),c.stroke();return lu(c,14,10,228,492),Gi(c,t.ink,12),l}let i=512,[s,r]=Pe(i,i),a=i/2;r.beginPath(),r.arc(a,a,236,0,Math.PI*2),r.save(),r.clip(),r.fillStyle=t.glass,r.fillRect(0,0,i,i);let o=i/8;for(let l=0;l<8;l+=1)for(let c=0;c<8;c+=1)r.fillStyle=ou(t,n()),r.fillRect(c*o,l*o,o,o);if(r.fillStyle=t.sky,r.beginPath(),r.arc(a,a-8,98,0,Math.PI*2),r.fill(),t.night){r.fillStyle=t.glass,r.beginPath(),r.arc(a+52,a-34,88,0,Math.PI*2),r.fill(),r.fillStyle=t.sky;for(let[l,c,u]of[[150,120,12],[380,150,9],[120,340,8],[400,360,12],[310,90,7]])vi(r,l,c,u,0.3),r.fill()}else{r.strokeStyle=t.sky,r.lineWidth=12;for(let l=0;l<12;l+=1){let c=Math.PI*2*l/12;r.beginPath(),r.moveTo(a+Math.cos(c)*120,a-8+Math.sin(c)*120),r.lineTo(a+Math.cos(c)*190,a-8+Math.sin(c)*190),r.stroke()}}r.restore(),r.strokeStyle=t.stoneJoint,r.lineWidth=12;for(let l=1;l<8;l+=1)r.beginPath(),r.moveTo(l*o,0),r.lineTo(l*o,i),r.moveTo(0,l*o),r.lineTo(i,l*o),r.stroke();return r.beginPath(),r.arc(a,a,236,0,Math.PI*2),Gi(r,t.ink,16),r.beginPath(),r.arc(a,a,246,0,Math.PI*2),Gi(r,t.stoneShade,14),s}function uu(t,e){let[n,i]=Pe(256,512),s=()=>{i.beginPath(),i.moveTo(24,10),i.lineTo(232,10),i.lineTo(232,470),i.lineTo(128,400),i.lineTo(24,470),i.closePath()};if(s(),i.fillStyle=t.banner,i.fill(),i.save(),s(),i.clip(),i.fillStyle=t.ink,i.globalAlpha=0.18,i.fillRect(128,0,128,512),i.restore(),s(),Gi(i,t.bannerEdge,14),s(),Gi(i,t.ink,5),i.strokeStyle=t.bannerEdge,i.fillStyle=t.bannerEdge,i.lineWidth=9,i.lineCap="round",i.beginPath(),i.moveTo(40,56),i.lineTo(216,56),i.stroke(),e==="star")vi(i,128,220,84,0.22),i.fill(),i.beginPath(),i.arc(128,220,14,0,Math.PI*2),i.fillStyle=t.banner,i.fill();else if(e==="moon")i.beginPath(),i.arc(128,215,74,0,Math.PI*2),i.fill(),i.fillStyle=t.banner,i.beginPath(),i.arc(158,196,66,0,Math.PI*2),i.fill(),i.fillStyle=t.bannerEdge,vi(i,170,266,24,0.3),i.fill();else i.beginPath(),i.moveTo(128,120),i.lineTo(190,215),i.lineTo(128,320),i.lineTo(66,215),i.closePath(),i.lineWidth=11,i.stroke(),vi(i,128,215,34,0.3),i.fill();return n}function du(t){let[e,n]=Pe(256,320);return n.fillStyle=t.woodDark,n.fillRect(8,8,240,304),n.fillStyle=t.woodLight,n.fillRect(24,24,208,272),n.fillStyle=t.wood,n.beginPath(),n.moveTo(24,296),n.lineTo(232,296),n.lineTo(232,24),n.lineTo(212,44),n.lineTo(212,276),n.lineTo(44,276),n.closePath(),n.fill(),n.fillStyle=t.woodDark,n.fillRect(44,44,168,232),n.strokeStyle=t.goldDark,n.lineWidth=8,n.strokeRect(44,44,168,232),n.strokeStyle=t.gold,n.lineWidth=4,n.strokeRect(56,56,144,208),n.fillStyle=t.gold,n.beginPath(),n.moveTo(128,84),n.lineTo(172,160),n.lineTo(128,238),n.lineTo(84,160),n.closePath(),n.fill(),n.fillStyle=t.woodDark,n.beginPath(),n.moveTo(128,122),n.lineTo(148,160),n.lineTo(128,202),n.lineTo(108,160),n.closePath(),n.fill(),n.strokeStyle=t.ink,n.lineWidth=5,n.strokeRect(8,8,240,304),e}function fu(t){let[e,n]=Pe(128,192),i=(s,r,a,o)=>{n.beginPath(),n.moveTo(s,r),n.bezierCurveTo(s+o*0.2,r+(a-r)*0.3,s+o,r+(a-r)*0.5,s+o,a-o*0.9),n.arc(s,a-o*0.9,o,0,Math.PI,!1),n.bezierCurveTo(s-o,r+(a-r)*0.5,s-o*0.2,r+(a-r)*0.3,s,r),n.closePath()};return i(64,10,182,44),n.fillStyle=t.flame,n.fill(),Gi(n,t.ink,7),i(64,74,176,24),n.fillStyle=t.flameCore,n.fill(),e}function pu(t){let[e,n]=Pe(512,128),i=(s,r)=>{n.beginPath(),n.arc(s*128+64,64,54,0,Math.PI*2),n.fillStyle=r,n.fill(),Gi(n,t.ink,8)};i(0,t.paper),n.fillStyle=t.ink;for(let s of[-26,0,26])n.beginPath(),n.arc(64+s,70,9,0,Math.PI*2),n.fill();return i(1,t.gold),n.fillStyle=t.ink,n.beginPath(),n.moveTo(180,26),n.lineTo(204,26),n.lineTo(199,74),n.lineTo(185,74),n.closePath(),n.fill(),n.beginPath(),n.arc(192,94,8,0,Math.PI*2),n.fill(),i(2,"#58c878"),n.strokeStyle=t.paper,n.lineWidth=14,n.lineCap="round",n.lineJoin="round",n.beginPath(),n.moveTo(294,66),n.lineTo(312,84),n.lineTo(348,44),n.stroke(),i(3,"#ee4b4b"),n.strokeStyle=t.paper,n.beginPath(),n.moveTo(428,44),n.lineTo(468,84),n.moveTo(468,44),n.lineTo(428,84),n.stroke(),e}function va(){let[t,e]=Pe(128,128),n=e.createRadialGradient(64,64,0,64,64,64);return n.addColorStop(0,"rgba(255,255,255,1)"),n.addColorStop(0.35,"rgba(255,255,255,.55)"),n.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=n,e.fillRect(0,0,128,128),t}function mu(){let[t,e]=Pe(256,512),n=[[20,60,0.55],[96,40,0.8],[150,70,0.45],[220,30,0.7]];for(let[i,s,r]of n)e.fillStyle=`rgba(255,255,255,${r})`,e.beginPath(),e.moveTo(i,0),e.lineTo(i+s,0),e.lineTo(i+s+90,512),e.lineTo(i+90,512),e.closePath(),e.fill();return t}function gu(t){let[e,n]=Pe(256,256);n.lineCap="round";let i=[[Math.PI*1.1,78,128],[Math.PI*1.32,84,138],[Math.PI*1.54,76,124]],s=196,r=204;for(let[a,o]of[[t.ink,34],[t.gold,20]]){n.strokeStyle=a,n.lineWidth=o;for(let[l,c,u]of i)n.beginPath(),n.moveTo(s+Math.cos(l)*c,r+Math.sin(l)*c),n.lineTo(s+Math.cos(l)*u,r+Math.sin(l)*u),n.stroke()}return e}var ya=0.034,Ol=0.02,Bl=0.024,s0=(t)=>{let e=new Image;return e.decoding="async",e.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`,e.decode().then(()=>e)};function zl(t,e,n,i){let[s,r]=Pe(e,n);return r.drawImage(t,0,0,e,n),r.globalCompositeOperation="source-in",r.fillStyle=i,r.fillRect(0,0,e,n),s}function kl(t,e=48){return Array.from({length:e},(n,i)=>{let s=Math.PI*2*i/e;return[Math.cos(s)*t,Math.sin(s)*t]})}async function Gl(t,e,n){let{rim:i,ink:s,edge:r}=n,a=await s0(t),o=(a.naturalHeight||a.height||e)/(a.naturalWidth||a.width||e),l=Math.round(e),c=Math.round(e*o),u=Math.ceil(e*(ya+Ol+Bl))+2,[d,h]=Pe(l+u*2,c+u*2),p=zl(a,l,c,s),v=zl(a,l,c,i),T=zl(a,l,c,r);for(let[m,f]of kl(e*(ya+Ol)))h.drawImage(T,u+m+e*Bl*0.5,u+f+e*Bl);for(let[m,f]of kl(e*(ya+Ol)))h.drawImage(p,u+m,u+f);for(let[m,f]of kl(e*ya))h.drawImage(v,u+m,u+f);return h.drawImage(a,u,u,l,c),{canvas:d,pad:u/l}}function Sa(t,e,n){let i=(r,a)=>Number.parseInt(r.slice(1+a*2,3+a*2),16),s=(r)=>Math.round(i(t,r)+(i(e,r)-i(t,r))*n).toString(16).padStart(2,"0");return`#${s(0)}${s(1)}${s(2)}`}var dr=Math.PI*2,Ma=(t,e=0,n=1)=>Math.min(n,Math.max(e,t));function r0(t){let[e,n]=Pe(128,128),i=[[64,74,30],[36,80,22],[92,80,23],[48,54,24],[80,56,22]],s=t.paper,r=Sa(t.paper,t.ink,t.night?0.42:0.28);n.fillStyle=t.ink;for(let[a,o,l]of i)n.beginPath(),n.arc(a,o,l+5,0,dr),n.fill();n.save(),n.beginPath();for(let[a,o,l]of i)n.moveTo(a+l,o),n.arc(a,o,l,0,dr);n.clip(),n.fillStyle=r,n.fillRect(0,0,128,128),n.fillStyle=s;for(let[a,o,l]of i)n.beginPath(),n.arc(a-7,o-8,l,0,dr),n.fill();return n.restore(),e}function a0(t){let[e,n]=Pe(64,64);n.translate(32,32),n.beginPath();for(let i=0;i<8;i+=1){let s=Math.PI/4*i-Math.PI/2,r=i%2===0?27:8;n.lineTo(Math.cos(s)*r,Math.sin(s)*r)}return n.closePath(),n.lineJoin="round",n.lineWidth=7,n.strokeStyle=t.ink,n.stroke(),n.fillStyle=t.gold,n.fill(),e}function o0(){let[t,e]=Pe(64,256),n=e.createLinearGradient(0,0,64,0);n.addColorStop(0,"rgba(255,255,255,0)"),n.addColorStop(0.5,"rgba(255,255,255,1)"),n.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=n,e.fillRect(0,0,64,256),e.globalCompositeOperation="destination-in";let i=e.createLinearGradient(0,256,0,0);return i.addColorStop(0,"rgba(255,255,255,1)"),i.addColorStop(0.55,"rgba(255,255,255,.45)"),i.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=i,e.fillRect(0,0,64,256),t}class Hl{hall;group=new Xe;runs=[];textures=new Map;planes=new Map;constructor(t){this.hall=t}texture(t,e){let n=this.textures.get(t);if(n)return n;let i=new xi(e());return i.colorSpace=gi,this.textures.set(t,i),i}plane(t,e,n){let i=this.planes.get(t);if(i)return i;let s=new Ie(e,n);return this.planes.set(t,s),s}get glow(){return this.hall.additive?Qn:In}puff(t,e){let n=this.hall,i=this.texture("cloud",()=>r0(n)),s=this.texture("sparkle",()=>a0(n)),r=Array.from({length:7},(o,l)=>{let c=dr*l/7+l%2*0.4,u=new sr(new Ms({map:i,transparent:!0,depthWrite:!1,fog:!1}));return u.renderOrder=8,this.group.add(u),{sprite:u,angle:c,reach:0.55+l%3*0.22,size:1.5+l*5%4*0.28,lift:-0.9+l%4*0.75,turn:(l%2?1:-1)*(0.25+l%3*0.1)}}),a=Array.from({length:4},(o,l)=>{let c=new sr(new Ms({map:s,transparent:!0,depthWrite:!1,depthTest:!1,fog:!1}));return c.renderOrder=9,this.group.add(c),{sprite:c,angle:dr*l/4+0.7}});this.runs.push({start:e,update:(o)=>{let l=Ma(o/un),c=Zi(l/0.35),u=1-(1-l)**2,d=1-Ma((l-0.55)/0.45);for(let h of r)h.sprite.position.set(t.x+Math.cos(h.angle)*h.reach*(0.5+u*1.3),t.y+h.lift*(0.6+u*0.5)+l*1.2,t.z+Math.sin(h.angle)*h.reach*(0.5+u*1.3)),h.sprite.scale.setScalar(Math.max(h.size*c,0.01)),h.sprite.material.rotation=h.angle*0.3+h.turn*l,h.sprite.material.opacity=d;for(let h of a){let p=0.9+u*1.6;h.sprite.position.set(t.x+Math.cos(h.angle)*p,t.y+0.5+u*1.4,t.z+Math.sin(h.angle)*p),h.sprite.scale.setScalar(0.5*Zi(Ma((l-0.1)/0.3))),h.sprite.material.rotation=l*2.5,h.sprite.material.opacity=1-Ma((l-0.5)/0.4)}return l<1},end:()=>{for(let o of r)this.group.remove(o.sprite),o.sprite.material.dispose();for(let o of a)this.group.remove(o.sprite),o.sprite.material.dispose()}})}circle(t,e){let n=this.hall,i=this.texture("rune",()=>{let[d,h]=Pe(256,256);return h.drawImage(xa(n),0,0,256,256),d}),s=this.texture("column",o0),r=this.plane("disc",3.4,3.4),a=this.plane("column",2.2,5),o=new Xe;o.position.set(t.x,t.y+0.03,t.z);let l=new Jt(r,new Be({map:i,transparent:!0,depthWrite:!1,blending:this.glow,opacity:0,fog:!1}));l.rotation.x=-Math.PI/2,l.renderOrder=4,o.add(l);let c=new Xe;c.position.set(t.x,t.y+0.1,t.z);let u=new Be({map:s,color:n.rune,transparent:!0,depthWrite:!1,blending:this.glow,side:sn,opacity:0,fog:!1});for(let d of[0,Math.PI/2]){let h=new Jt(a,u);h.position.y=2.5,h.rotation.y=d,h.renderOrder=6,c.add(h)}this.group.add(o,c),this.runs.push({start:e,update:(d)=>{let h=Wi(d);return l.material.opacity=h.circle*(n.night?1:0.9),o.rotation.y=h.spin,u.opacity=h.light*0.75,c.scale.set(1,0.4+h.light*0.6,1),d<dn},end:()=>{this.group.remove(o,c),l.material.dispose(),u.dispose()}})}step(t){for(let e=this.runs.length-1;e>=0;e-=1){let n=this.runs[e];if(!n)continue;let i=t-n.start;if(i<0)continue;if(!n.update(i))n.end(),this.runs.splice(e,1)}return this.runs.length>0}dispose(){for(let t of this.runs)t.end();this.runs.length=0;for(let t of this.textures.values())t.dispose();for(let t of this.planes.values())t.dispose();this.textures.clear(),this.planes.clear(),this.group.removeFromParent()}}function _u(t,e=0.0001){e=Math.max(e,Number.EPSILON);let n={},i=t.getIndex(),s=t.getAttribute("position"),r=i?i.count:s.count,a=0,o=Object.keys(t.attributes),l={},c={},u=[],d=["getX","getY","getZ","getW"],h=["setX","setY","setZ","setW"];for(let w=0,C=o.length;w<C;w++){let y=o[w],b=t.attributes[y];l[y]=new b.constructor(new b.array.constructor(b.count*b.itemSize),b.itemSize,b.normalized);let A=t.morphAttributes[y];if(A){if(!c[y])c[y]=[];A.forEach((E,g)=>{let M=new E.array.constructor(E.count*E.itemSize);c[y][g]=new E.constructor(M,E.itemSize,E.normalized)})}}let p=e*0.5,v=Math.log10(1/e),T=Math.pow(10,v),m=p*T;for(let w=0;w<r;w++){let C=i?i.getX(w):w,y="";for(let b=0,A=o.length;b<A;b++){let E=o[b],g=t.getAttribute(E),M=g.itemSize;for(let G=0;G<M;G++)y+=`${Math.trunc(g[d[G]](C)*T+m)},`}if(y in n)u.push(n[y]);else{for(let b=0,A=o.length;b<A;b++){let E=o[b],g=t.getAttribute(E),M=t.morphAttributes[E],G=g.itemSize,N=l[E],F=c[E];for(let X=0;X<G;X++){let R=d[X],k=h[X];if(N[k](a,g[R](C)),M)for(let Z=0,H=M.length;Z<H;Z++)F[Z][k](a,M[Z][R](C))}}n[y]=a,u.push(a),a++}}let f=t.clone();for(let w in t.attributes){let C=l[w];if(f.setAttribute(w,new C.constructor(C.array.slice(0,a*C.itemSize),C.itemSize,C.normalized)),!(w in c))continue;for(let y=0;y<c[w].length;y++){let b=c[w][y];f.morphAttributes[w][y]=new b.constructor(b.array.slice(0,a*b.itemSize),b.itemSize,b.normalized)}}return f.setIndex(u),f}function l0(){let t=new Uint8Array([125,195,255]),e=new rr(t,3,1,qr,mn);return e.minFilter=Ln,e.magFilter=Ln,e.generateMipmaps=!1,e.needsUpdate=!0,e}class Vl{steps=l0();lit=new Map;flat=new Map;ink=new Kt("#000000");hullMaterial=new Be({color:this.ink,side:Ve,fog:!1});toon(t,e){let n=this.lit.get(t);if(!n)n=new ni({color:e,gradientMap:this.steps}),this.lit.set(t,n);else n.color.set(e);return n}basic(t,e){let n=this.flat.get(t);if(!n)n=new Be({color:e,fog:!1}),this.flat.set(t,n);else n.color.set(e);return n}setInk(t){this.ink.set(t),this.hullMaterial.color.copy(this.ink)}dispose(){this.steps.dispose(),this.hullMaterial.dispose();for(let t of this.lit.values())t.dispose();for(let t of this.flat.values())t.dispose()}}function c0(t,e){let n=t.clone();n.deleteAttribute("uv"),n.deleteAttribute("normal");let i=_u(n,0.0001);i.computeVertexNormals();let s=i.getAttribute("position"),r=i.getAttribute("normal"),a=new O;for(let o=0;o<s.count;o+=1)a.fromBufferAttribute(r,o).multiplyScalar(e),s.setXYZ(o,s.getX(o)+a.x,s.getY(o)+a.y,s.getZ(o)+a.z);return s.needsUpdate=!0,i}function yi(t,e,n,i){let s=i.get(t.geometry);if(!s)s=c0(t.geometry,n),i.set(t.geometry,s);let r=new Jt(s,e.hullMaterial);return r.renderOrder=t.renderOrder,r.userData.hull=!0,t.add(r),t}var Hi=12,fr=12,h0=["moon","star","crest"];class xu{textures=[];geometries=[];materials=[];texture(t,e){let n=new xi(t);if(n.colorSpace=gi,e)n.wrapS=$s,n.wrapT=$s,n.repeat.set(e[0],e[1]);else n.wrapS=Bn,n.wrapT=Bn;return n.anisotropy=4,this.textures.push(n),n}geometry(t){return this.geometries.push(t),t}material(t){return this.materials.push(t),t}dispose(){for(let t of this.textures)t.dispose();for(let t of this.geometries)t.dispose();for(let t of this.materials)t.dispose()}}function vu(t,e,n){let i=new xu,s=new Xe,r=new Map,a=zt(e),o=a+9.5,l=(tt,dt={})=>i.material(new Be({map:tt,transparent:!0,depthWrite:!1,fog:!1,...dt})),c=t.additive?Qn:In,u=i.texture(cu(t),[o/2.2,o/2.2]),d=new Jt(i.geometry(new bs(o+1,72)),i.material(new ni({color:"#ffffff",map:u,gradientMap:n.steps})));d.rotation.x=-Math.PI/2,s.add(d);let h=new Jt(i.geometry(new xn(a+1.9,a+2.15,0.2,72)),n.toon("dais",t.stoneShade));h.position.y=0.1,yi(h,n,0.07,r),s.add(h);let p=new Jt(i.geometry(new Ie((a-0.7)*2,(a-0.7)*2)),l(i.texture(xa(t)),{blending:c,opacity:t.night?t.runeGlow:1}));p.rotation.x=-Math.PI/2,p.position.y=0.215,s.add(p);let v=i.material(new ni({color:"#ffffff",map:i.texture(hu(t),[o*rn/7,Hi/5]),gradientMap:n.steps,side:Ve})),T=new Jt(i.geometry(new xn(o,o,Hi,72,1,!0)),v);T.position.y=Hi/2,s.add(T);let m=new Jt(i.geometry(new bs(o+1,48)),i.material(new Be({color:t.bg,side:sn})));m.rotation.x=Math.PI/2,m.position.y=Hi,s.add(m);let f=i.geometry(new xn(0.6,0.66,Hi,14)),w=i.geometry(new xn(0.88,0.7,0.5,14)),C=i.geometry(new xn(0.78,0.9,0.6,14)),y=i.geometry(new Ie(2.2,4.4)),b=i.geometry(new xn(0.34,0.2,0.36,10)),A=i.geometry(new xn(0.06,0.06,0.7,6)),E=i.geometry(new Ie(0.62,0.93)),g=i.geometry(new Ie(2.6,2.6)),M=l(i.texture(fu(t)),{transparent:!0,alphaTest:0.35,depthWrite:!0}),G=l(i.texture(va()),{color:t.flame,blending:c,opacity:t.night?0.55:0.28}),N=h0.map((tt)=>i.material(new Be({map:i.texture(uu(t,tt)),transparent:!0,alphaTest:0.4,fog:!1}))),F=[],X=(tt,dt,At,te)=>(te.position.set(Math.sin(tt)*dt,At,Math.cos(tt)*dt),te.rotation.y=tt+Math.PI,s.add(te),te);for(let tt=0;tt<fr;tt+=1){let dt=rn*(tt+0.5)/fr,At=new Jt(f,n.toon("pillar",t.stone));X(dt,o-0.7,Hi/2,At),yi(At,n,0.06,r);let te=new Jt(w,n.toon("pillar",t.stone));X(dt,o-0.7,Hi-0.55,te);let Bt=new Jt(C,n.toon("pillar",t.stone));X(dt,o-0.7,0.3,Bt);let Y=new Jt(y,N[tt%N.length]??N[0]);X(dt,o-1.34,6.8,Y);let rt=new Jt(A,n.toon("iron",t.woodDark));X(dt,o-1.4,2.8,rt),rt.rotation.x=Math.PI/2;let lt=new Jt(b,n.toon("iron",t.woodDark));X(dt,o-1.75,2.95,lt),yi(lt,n,0.04,r);let It=new Jt(E,M);It.position.set(Math.sin(dt)*(o-1.75),3.5,Math.cos(dt)*(o-1.75)),It.renderOrder=3,s.add(It);let Ft=new Jt(g,G);Ft.position.copy(It.position),Ft.renderOrder=2,s.add(Ft),F.push({body:It,halo:Ft,phase:tt*1.7,base:1})}let R=i.geometry(new Ie(2.6,5.2)),k=i.geometry(new Ie(4.6,4.6)),Z=l(i.texture(Fl(t,"lancet")),{alphaTest:0.3,depthWrite:!0,transparent:!1}),H=l(i.texture(Fl(t,"rose")),{alphaTest:0.3,depthWrite:!0,transparent:!1}),at=i.geometry(new Ie(3.4,10)),K=l(i.texture(mu()),{color:t.beam,opacity:t.beamAlpha,blending:c,side:sn}),et=[];for(let tt=0;tt<fr;tt+=1){let dt=rn*tt/fr,At=tt===fr/2,te=new Jt(At?k:R,At?H:Z);X(dt,o-0.12,At?7.1:6.2,te);let Bt=new Jt(at,K),Y=o-4.4;Bt.position.set(Math.sin(dt)*Y,4.4,Math.cos(dt)*Y),Bt.rotation.set(0,dt+Math.PI,0),Bt.rotateX(-0.62),Bt.renderOrder=1,s.add(Bt),et.push(Bt)}return{group:s,flames:F,beams:et,wallRadius:o,dispose(){for(let tt of r.values())tt.dispose();i.dispose()}}}function yu(t,e,n){for(let i of t){let s=n?1:1+0.09*Math.sin(e*9+i.phase)+0.05*Math.sin(e*17+i.phase*2);i.body.scale.set(s*0.96,s*(1.02+(n?0:0.06*Math.sin(e*11+i.phase))),1),i.halo.scale.setScalar(n?1:0.95+0.1*Math.sin(e*7+i.phase))}}function Su(t){let e=()=>{let p=t.idleMs??80;return typeof p==="function"?p():p},{host:n}=t,i=!0,s,r=0,a=!1,o=Number.NEGATIVE_INFINITY,l=!1,c=()=>l||!i||n.hidden(),u=()=>{if(s===void 0)return;n.cancel(s),s=void 0},d=(p)=>{if(s=void 0,c())return;if(a||p-o>=e()){let v=r===0?16:Math.min(p-r,100);r=p,o=p,a=t.frame(p,v)}if(a||e()>0)s=n.request(d)},h=()=>{if(s!==void 0||c())return;r=0,s=n.request(d)};return{get state(){if(c())return"paused";return a?"live":"idle"},wake(){a=!0,h()},setVisible(p){if(i=p,c())u();else h()},sync(){if(c())u();else h()},dispose(){l=!0,u()}}}var bu=2;var Tu=(t,e)=>Math.abs(t.x-e.x)<(t.w+e.w)/2+2&&Math.abs(t.y-e.y)<(t.h+e.h)/2+2,u0=(t,e,n)=>n<e?(e+n)/2:Math.min(n,Math.max(e,t));function Mu(t,e,n,i){let s=t.w/2+2,r=i.width-t.w/2-2,a=t.h/2,o=i.height-t.h/2,l=[...e,...n],c=[t.x,...t.above?[t.above.x]:[],...l.flatMap((p)=>[p.x-(p.w+t.w)/2-2,p.x+(p.w+t.w)/2+2])].map((p)=>u0(p,s,r)),u=[t.y,...t.above?[t.above.y]:[],...l.flatMap((p)=>[p.y-(p.h+t.h)/2-2,p.y+(p.h+t.h)/2+2])].filter((p)=>p>=a&&p<=o),d,h=Number.POSITIVE_INFINITY;for(let p of c)for(let v of u){let T=t.above,m=Math.min(Math.hypot(p-t.x,(v-t.y)*1.5),T?Math.hypot(p-T.x,(v-T.y)*1.5)+40:Number.POSITIVE_INFINITY);if(m>=h)continue;let f={x:p,y:v,w:t.w,h:t.h};if(l.some((w)=>Tu(f,w)))continue;d=f,h=m}return d}function wu(t,e,n=[]){let i=t.map(({x:l,y:c})=>({x:l,y:c})),s=[],r=!0,a=0,o=t.map((l,c)=>c).sort((l,c)=>(t[c]?.y??0)-(t[l]?.y??0)||(t[l]?.x??0)-(t[c]?.x??0)||l-c);for(let l of o){let c=t[l];if(!c)continue;let u=Mu(c,s,n,e);if(!u){if(u=Mu(c,s,[],e),u&&n.some((h)=>Tu(u,h)))a+=1}if(!u)r=!1;let d=u??c;s.push(d),i[l]={x:d.x,y:d.y}}return{spots:i,clear:r,covering:a}}var d0=1.06,f0=0.68,Eu=12,p0=16;class Wl{labels;click;root=document.createElement("div");items=new Map;point=new O;local=new O;constructor(t,e,n){this.labels=e;this.click=n;this.root.className="rt-names",t.appendChild(this.root)}paint(t){let e=this.root.style;e.setProperty("--rt-gold",t.gold),e.setProperty("--rt-gold-dark",t.goldDark),e.setProperty("--rt-plate-ink",t.plateInk),e.setProperty("--rt-ink",t.ink),e.setProperty("--rt-font",Mt)}set(t,e){for(let n of this.items.values())n.el.remove();this.items.clear();for(let n of t){if(n.init.kind==="owner")continue;let i=document.createElement("button");if(i.type="button",i.className="rt-name",i.textContent=n.init.name,i.setAttribute("aria-label",n.init.kind==="agent"?this.labels.seat(n.init.name,e(n)):n.init.name),n.init.id)i.dataset.seat=n.init.id;i.addEventListener("click",(s)=>this.click(n,Ct(s,i))),this.root.appendChild(i),this.items.set(n,{el:i,x:0,y:0,shown:!1})}}mark(t,e){let n=this.items.get(t);if(n)n.el.textContent=e?`${e} ${t.init.name}`:t.init.name}relabel(t,e){let n=this.items.get(t);if(n&&t.init.kind==="agent")n.el.setAttribute("aria-label",this.labels.seat(t.init.name,e))}size(t){this.root.style.setProperty("--rt-name-size",`${Math.max(Eu,Math.min(p0,t*0.0125)).toFixed(1)}px`)}place(t,e,n,i,s){t.updateMatrixWorld();let r=[];for(let[l,c]of this.items){this.local.copy(e),l.group.worldToLocal(this.local);let u=this.local.z>=0?1:-1;this.point.set(0,d0,u*f0),l.group.localToWorld(this.point),this.point.project(t);let d=(this.point.x*0.5+0.5)*n,h=(-this.point.y*0.5+0.5)*i,v=this.point.z<1&&d>-n*0.05&&d<n*1.05&&h>-i*0.05&&h<i*1.05&&l!==s&&l.group.visible&&!l.labelHidden;if(v!==c.shown)c.shown=v,c.el.style.visibility=v?"visible":"hidden";if(!v)continue;r.push({item:c,podium:l,x:d,y:h,w:c.el.offsetWidth,h:c.el.offsetHeight||Eu*1.8})}let a=this.faces(t,e,n,i);for(let l of r){let c=a.get(l.podium);if(c)l.above={x:c.x,y:c.y-c.h/2-l.h/2-bu}}let o=wu(r,{width:n,height:i},[...a.values()]);return r.forEach(({item:l},c)=>{let u=o.spots[c];if(!u)return;if(Math.abs(u.x-l.x)>0.25||Math.abs(u.y-l.y)>0.25)l.x=u.x,l.y=u.y,l.el.style.transform=`translate(${u.x.toFixed(1)}px, ${u.y.toFixed(1)}px) translate(-50%, -50%)`}),o.clear}faces(t,e,n,i){let s=new Map,r=[e.x,e.y,e.z];for(let a of this.items.keys()){if(a.init.kind!=="agent")continue;if(!a.group.visible||!a.board.visible)continue;a.board.getWorldPosition(this.point);let o=[this.point.x,this.point.y,this.point.z],{POSITIVE_INFINITY:l,NEGATIVE_INFINITY:c,POSITIVE_INFINITY:u,NEGATIVE_INFINITY:d}=Number,h=!1;for(let[p,v,T]of Ds(o,a.board.scale.y,r)){if(this.point.set(p,v,T).project(t),this.point.z>=1)h=!0;let m=(this.point.x*0.5+0.5)*n,f=(-this.point.y*0.5+0.5)*i;l=Math.min(l,m),c=Math.max(c,m),u=Math.min(u,f),d=Math.max(d,f)}if(h)continue;s.set(a,{x:(l+c)/2,y:(u+d)/2,w:c-l,h:d-u})}return s}dispose(){this.root.remove(),this.items.clear()}}var Au=0.62;function m0(t,e){let n=Math.atan2(t,e),i=(s)=>Math.max(-Au,Math.min(Au,s));if(Math.abs(n)<=Math.PI/2)return i(n);return Math.PI+i(Rn(n-Math.PI))}var pr=1.3,g0=1.24,_0=0.31,x0=[512,128],ba={waiting:0,alert:1,done:2,error:3};function Cu(t){switch(t){case"thinking":case"working":return"waiting";case"waiting":return"alert";case"done":return"done";case"error":return"error";default:return null}}class Xl{hall;geometries=[];textures=[];hulls=new Map;plinth=this.own(new Hn(1.84,0.2,1.4));body;slab=this.own(new Hn(1.98,0.14,1.5));trim=this.own(new Hn(2.01,0.04,1.53));panelPlane=this.own(new Ie(0.84,1.05));platePlane=this.own(new Ie(g0,_0));glowPlane=this.own(new Ie(4.8,4.8));badgePlanes;panelTexture;glowTexture;badgeTexture;marksTexture;marksPlane=this.own(new Ie(1.25,1.25));constructor(t){this.hall=t;let e=new xn(0.82*Math.SQRT2,0.72*Math.SQRT2,1,4,1);e.rotateY(Math.PI/4),this.body=this.own(e),this.panelTexture=this.texture(du(t)),this.glowTexture=this.texture(va()),this.badgeTexture=this.texture(pu(t)),this.marksTexture=this.texture(gu(t));let n=(i)=>{let s=new Ie(0.56,0.56),r=s.getAttribute("uv");for(let a=0;a<r.count;a+=1)r.setX(a,(i+r.getX(a))/4);return this.own(s)};this.badgePlanes={waiting:n(ba.waiting),alert:n(ba.alert),done:n(ba.done),error:n(ba.error)}}own(t){return this.geometries.push(t),t}texture(t){let e=new xi(t);return e.colorSpace=gi,e.wrapS=Bn,e.wrapT=Bn,e.anisotropy=4,e.minFilter=Qe,this.textures.push(e),e}dispose(){for(let t of this.geometries)t.dispose();for(let t of this.hulls.values())t.dispose();for(let t of this.textures)t.dispose()}}class Ta{init;kit;group=new Xe;rig=new Xe;board;boardMaterial;glow;glowMaterial;badge;badgeMaterial;marks;marksMaterial;marksSince=0;marksOn=!1;hits=[];plateTexture;plateMaterial;panelMaterial;shown=null;closedMap;talkMap;plateText={text:"",px:0};speak=0;bob=0;boardY=0;labelHidden=!1;phase=Math.random()*6;constructor(t,e,n){this.init=t;this.kit=e;let{hall:i}=e,s=(w)=>(w.userData.seat=t.id??null,w.userData.kind=t.kind,this.hits.push(w),w),r=new Jt(e.plinth,n.toon("woodDark",i.woodDark));r.position.y=0.1,yi(r,n,0.045,e.hulls);let a=new Jt(e.body,n.toon("wood",i.wood));a.scale.set(1,1,0.756);let o=t.kind==="owner";a.scale.y=o?0.3:1,a.position.y=o?0.35:0.7,yi(a,n,0.045,e.hulls);let l=new Jt(e.slab,n.toon("woodLight",i.woodLight));l.position.y=o?0.58:1.27,yi(l,n,0.045,e.hulls);let c=new Jt(e.trim,n.toon("gold",i.gold));c.position.y=o?0.51:1.2,this.group.add(r,s(a),s(l),c),this.panelMaterial=new ni({map:e.panelTexture,transparent:!0,gradientMap:n.steps});let u=new Jt(e.panelPlane,this.panelMaterial);u.position.set(0,0.68,0.64),u.visible=!o,this.group.add(u);let[d,h]=x0,[p,v]=Pe(d,h);this.plateTexture=e.texture(p),this.plateText=es(v,t.name,d,h,i),this.plateMaterial=new Be({map:this.plateTexture,fog:!1});let T=new Jt(e.platePlane,this.plateMaterial);T.position.set(0,o?0.36:1.06,0.68),T.rotation.x=-0.16;let m=new Jt(e.platePlane,this.plateMaterial);m.position.set(0,o?0.36:1.06,-0.68),m.rotation.y=Math.PI,m.rotation.x=-0.16,this.group.add(s(T),s(m));let f=new Be({transparent:!0,alphaTest:0.4,fog:!1});if(this.boardMaterial=f,this.board=new Jt(new Ie(yt,yt),f),this.board.visible=!1,this.board.position.y=pr+yt/2,s(this.board),this.glowMaterial=new Be({map:e.glowTexture,color:t.accent,transparent:!0,opacity:0,depthWrite:!1,fog:!1,blending:i.additive?Qn:In}),this.glow=new Jt(e.glowPlane,this.glowMaterial),this.glow.position.set(0,pr+yt/2,-0.5),this.glow.visible=!1,this.badgeMaterial=new Be({map:e.badgeTexture,transparent:!0,alphaTest:0.2,fog:!1}),this.badge=new Jt(e.badgePlanes.waiting,this.badgeMaterial),this.badge.position.set(1.05,pr+yt,0.05),this.badge.visible=!1,this.badge.renderOrder=5,this.marksMaterial=new Be({map:e.marksTexture,transparent:!0,alphaTest:0.2,depthTest:!1,depthWrite:!1,fog:!1}),this.marks=new Jt(e.marksPlane,this.marksMaterial),this.marks.position.set(-1,pr+yt*0.76,0.2),this.marks.visible=!1,this.marks.renderOrder=5,t.kind==="agent")this.rig.position.set(0,0,-0.08),this.rig.add(this.glow,this.board,this.badge,this.marks),this.group.add(this.rig)}setSticker(t){let e=this.closedMap,n=this.kit.texture(t);this.closedMap=n,this.boardMaterial.map=n,this.boardMaterial.needsUpdate=!0;let i=t.height/t.width;this.board.scale.set(1,i,1),this.boardY=pr+yt*i/2,this.board.position.y=this.boardY,this.glow.position.y=this.boardY,this.badge.position.y=this.board.position.y+yt*i/2+0.02,this.board.visible=!0,e?.dispose()}setTalk(t){let e=this.talkMap;if(this.talkMap=t?this.kit.texture(t):void 0,this.boardMaterial.map===e)this.boardMaterial.map=this.closedMap??null;e?.dispose()}mouth(t){let e=t&&this.talkMap?this.talkMap:this.closedMap;if(e&&this.boardMaterial.map!==e)this.boardMaterial.map=e;return this.talkMap!==void 0}markFrame(t,e,n){let i=t&&!n;if(i&&!this.marksOn)this.marksSince=e;if(this.marksOn=i,!i)return this.marks.visible=!1,!1;let s=Math.min((e-this.marksSince)/0.4,1),r=1.70158,a=1+(r+1)*(s-1)**3+r*(s-1)**2;return this.marks.visible=!0,this.marks.scale.setScalar(Math.max(a,0.01)),s<1}setBadge(t){if(t===this.shown)return;if(this.shown=t,this.badge.visible=t!==null,t)this.badge.geometry=this.kit.badgePlanes[t]}setDim(t){this.boardMaterial.color.set(t?"#7a7f8f":"#ffffff")}face(t){let e=this.group.worldToLocal(t.clone());this.rig.rotation.y=m0(e.x,e.z)}dispose(){this.plateTexture.dispose(),this.plateMaterial.dispose(),this.panelMaterial.dispose(),this.closedMap?.dispose(),this.talkMap?.dispose(),this.boardMaterial.dispose(),this.board.geometry.dispose(),this.glowMaterial.dispose(),this.badgeMaterial.dispose(),this.marksMaterial.dispose()}}function Ru(t,e){let n=document.createElement("div");n.className="rt-speed",n.setAttribute("aria-hidden","true"),n.style.cssText="position:absolute;inset:0;pointer-events:none;opacity:0;background:repeating-conic-gradient(from 3deg at 50% 52%,rgba(255,255,255,.85) 0 .55deg,transparent .55deg 5.2deg);-webkit-mask-image:radial-gradient(ellipse at 50% 52%,transparent 34%,#000 74%);mask-image:radial-gradient(ellipse at 50% 52%,transparent 34%,#000 74%);",t.appendChild(n);let i;return{play(){if(e())return!1;if(n.dataset.playing="",typeof n.animate==="function")n.animate([{opacity:0,transform:"scale(1.18)"},{opacity:0.9,transform:"scale(1.04)",offset:0.3},{opacity:0,transform:"scale(1)"}],{duration:400,easing:"ease-out"});else n.style.opacity="0.9";if(i!==void 0)clearTimeout(i);return i=setTimeout(()=>{delete n.dataset.playing,n.style.opacity="0"},400),!0},dispose(){if(i!==void 0)clearTimeout(i);n.remove()}}}var v0=2,y0=1.5,S0=60,Iu=8,M0=1.22,b0=0.82,Pu=(t,e,n,i)=>t+(e-t)*(1-Math.exp(-n*i)),ql=0.2,T0=2,Lu=(t)=>t.init.id??t.init.kind;function cS(t,e,n){let i=window.matchMedia("(prefers-reduced-motion: reduce)"),s=e.reducedMotion==="auto"||e.reducedMotion===void 0?i.matches:e.reducedMotion,r=window.matchMedia("(pointer: coarse)").matches,a=e.lowPower==="auto"||e.lowPower===void 0?r||Math.min(t.clientWidth||innerWidth,innerWidth)<700||(navigator.hardwareConcurrency||8)<=4:e.lowPower,o=a?y0:v0,l=new Dl({antialias:!a,alpha:!1,powerPreference:a?"default":"high-performance"});l.setPixelRatio(Math.min(window.devicePixelRatio||1,o));let c=l.domElement;if(c.style.cssText="display:block;width:100%;height:100%;touch-action:none;outline:none;cursor:grab",c.setAttribute("aria-hidden","true"),getComputedStyle(t).position==="static")t.style.position="relative";t.appendChild(c);let u=e.labels??Gt,d=new Wl(t,u,(U,q)=>{if(U.init.kind==="agent"&&U.init.id)e.onSeatClick({id:U.init.id,name:U.init.name,at:q})}),h=Ru(t,()=>s),p=new na,v=new nn(42,1,0.1,90),T=new da,m=new ua;m.position.set(-6,12,7),p.add(T,m);let{theme:f,scheme:w}=e,C=[],y=new Map,b=new Map,A=new Map,E=new Map,g,M=0,G=new Map,N=(U)=>{let q=G.get(U);return q&&q.svg===A.get(U)&&q.talk===E.get(U)&&q.tone===F()?q:void 0},F=()=>`${f}/${w}`,X,R=null,k=0,Z=Kn(0,1),H=Z,at=Z,K=0,et=0,tt=!1,dt,At=!1,te=()=>g?.slots??vr(C.length),Bt=()=>te().count,Y=(U)=>{let q=g?.slotOf.get(U);return q===void 0?void 0:on(q,Bt())},rt=()=>{let U=R?Y(R):void 0;return U===void 0?Kn(k,Bt(),v.aspect,c.clientWidth||void 0):Us(U,Bt())},lt=()=>{let{position:U,target:q}=yo(Z);v.position.set(...U),v.lookAt(q[0],q[1],q[2]),v.rotateZ(Z.roll);let ht=bo(Z.fov,v.aspect);if(Math.abs(v.fov-ht)>0.001)v.fov=ht,v.updateProjectionMatrix()},It=(U,q,ht=!1)=>{let St=Bs(Z,U,s||q,ht);if(tt=St.dive===!0,St.cut)Z=U,et=0;else H=Z,at=U,K=performance.now(),et=St.ms;return st.wake(),St},Ft=()=>{if(!g)return;p.remove(g.group);for(let U of g.podiums)U.dispose();g.kit.dispose(),g.built.dispose(),g.toon.dispose(),g=void 0},Ut=async(U,q)=>{let ht=A.get(U),St=g;if(!ht||!St)return;let bt=St.slotOf.get(U),Zt=bt===void 0?void 0:St.podiums[bt];if(Zt?.init.kind!=="agent")return;let he=E.get(U),ve={rim:St.hall.paper,ink:St.hall.ink,edge:Sa(C.find((Xt)=>Xt.id===U)?.color??St.hall.gold,St.hall.ink,0.35)};try{let[Xt,an]=await Promise.all([Gl(ht,320,ve),he?Gl(he,320,ve):void 0]);if(q!==M||g!==St)return;G.set(U,{svg:ht,talk:he,tone:F(),canvas:Xt.canvas,talkCanvas:an?.canvas}),Zt.setSticker(Xt.canvas),Zt.setTalk(an?.canvas),st.wake()}catch{}},Ce=(U,q)=>{U.setBadge(Cu(q))},$t=(U)=>{let q=++M;Ft();let ht=zn(f,w),St=vr(C.length),bt=new Vl;bt.setInk(ht.ink);let Zt=new Xl(ht),he=vu(ht,St.count,bt),ve=new Xe;ve.add(he.group);let Xt=new Map,an=[],ln=[],Si=(ge,ye,wn=0)=>{let We=Fs(ge,St.count),ii=1+wn/zt(St.count);ye.group.position.set(We.x*ii,0.2,We.z*ii),ye.group.rotation.y=We.yaw,ln[ge]=ye,ve.add(ye.group)};if(Si(0,new Ta({id:void 0,name:e.ownerName??"You",kind:"owner",accent:ht.gold},Zt,bt),1.2),C.slice(0,St.seated).forEach((ge,ye)=>{let wn=ye+1;Xt.set(ge.id,wn),an.push(ge.id);let We=new Ta({id:ge.id,name:ge.name,kind:"agent",accent:ge.color},Zt,bt);We.setDim(ge.dim===!0),Ce(We,y.get(ge.id)??ge.state??"idle"),Si(wn,We);let ii=N(ge.id);if(ii)We.setSticker(ii.canvas),We.setTalk(ii.talkCanvas)}),g={hall:ht,toon:bt,kit:Zt,built:he,group:ve,slots:St,podiums:ln,slotOf:Xt,order:an},U&&X){let ge=new Set;for(let ye of ln){let wn={x:ye.group.position.x,z:ye.group.position.z,yaw:ye.group.rotation.y},We=U.from.get(Lu(ye));if(We)X.slides.push({podium:ye,from:We,to:wn}),ye.group.position.x=We.x,ye.group.position.z=We.z,ye.group.rotation.y=We.yaw;if(ye.init.id&&U.joining.has(ye.init.id))ye.group.visible=!1,ye.labelHidden=!0,ge.add(ye)}X.risers=[...ge]}p.add(ve),ve.updateMatrixWorld(!0),p.background=new Kt(ht.bg),p.fog=new nr(ht.bg,17,46),T.color.set(ht.ambient),T.intensity=ht.ambientI,m.color.set(ht.key),m.intensity=ht.keyI;for(let ge of C.slice(0,St.seated)){if(N(ge.id))continue;Ut(ge.id,q)}if(R&&!Xt.has(R))R=null;It(rt(),U===void 0),d.paint(ht),d.set(ln,(ge)=>y.get(ge.init.id??"")??"idle");for(let ge of ln){let ye=b.get(ge.init.id??"");if(ye)d.mark(ge,ye)}st.wake()},ee=(U)=>U.slice(0,vr(U.length).seated).map((q)=>q.id),ue=()=>{let U=new Map;for(let q of g?.podiums??[])U.set(Lu(q),{x:q.group.position.x,z:q.group.position.z,yaw:q.group.rotation.y});return U},ne=(U)=>{U.swapped=!0;let q=ue();C=U.next,U.slides=[],$t({from:q,joining:new Set(U.plan.joining)});for(let ht of U.risers)U.fx?.circle({x:ht.group.position.x,y:ql,z:ht.group.position.z},U.plan.riseAt)},Le=(U)=>{for(let q of U.timers)clearTimeout(q);for(let q of U.slides)q.podium.group.position.x=q.to.x,q.podium.group.position.z=q.to.z,q.podium.group.rotation.y=q.to.yaw;for(let q of U.risers)q.group.visible=!0,q.group.position.y=ql,q.labelHidden=!1;if(U.fx?.dispose(),c.style.transition="",c.style.opacity="",d.root.style.transition="",d.root.style.opacity="",X===U)X=void 0;st.wake()},me=()=>{let U=X;if(!U)return;if(!U.swapped)U.swapped=!0,C=U.next,$t();Le(U)},Ze=(U,q)=>{let ht={plan:q,start:performance.now(),next:U,leavers:[],swapped:!1,fx:void 0,slides:[],risers:[],timers:[]};if(X=ht,q.mode==="fade"){for(let Zt of[c,d.root])Zt.style.transition=`opacity ${Rt}ms linear`,Zt.style.opacity="0";ht.timers.push(setTimeout(()=>{ht.swapped=!0,C=U,$t();for(let Zt of[c,d.root])Zt.style.opacity="1"},Rt),setTimeout(()=>Le(ht),Rt*2));return}let St=g;if(!St)return;let bt=new Hl(St.hall);ht.fx=bt,p.add(bt.group);for(let Zt of q.leaving){let he=St.slotOf.get(Zt),ve=he===void 0?void 0:St.podiums[he];if(!ve)continue;ht.leavers.push(ve),bt.puff({x:ve.group.position.x,y:T0,z:ve.group.position.z},0)}if(q.swapAt===0)ne(ht);st.wake()},Ne=(U)=>{let q=X;if(!q||q.plan.mode!=="play")return q!==void 0;let ht=Math.max(0,U-q.start);if(!q.swapped){let bt=ns(ht);for(let Zt of q.leavers)if(Zt.group.scale.set(bt.scaleX,bt.scaleY,bt.scaleX),bt.gone)Zt.group.visible=!1;if(ht>=q.plan.swapAt)ne(q)}if(q.swapped){let bt=is(ht-q.plan.swapAt);for(let{podium:he,from:ve,to:Xt}of q.slides)he.group.position.x=ve.x+(Xt.x-ve.x)*bt,he.group.position.z=ve.z+(Xt.z-ve.z)*bt,he.group.rotation.y=rs(ve.yaw,Xt.yaw,bt);let Zt=Wi(ht-q.plan.riseAt);for(let he of q.risers)he.group.visible=Zt.shown,he.group.position.y=ql-Zt.depth*ts,he.labelHidden=!Zt.named}let St=q.fx?.step(ht)??!1;if(ht>=q.plan.total&&!St)return Le(q),!1;return!0},Re,P=new O,Ue=0,ae=0,be=0,S=0,_=0,L=0,V=performance.now(),st=Su({frame:(U,q)=>{let ht=performance.now();Ue+=q/1000;let St=!1;if(Ne(U))St=!0;if(et>0){let he=(U-K)/et;if(he>=1)Z=at,et=0;else Z=Vs(H,at,tt?qs(he):Ni(he)),St=!0}else if(dt)St=!0;lt(),v.getWorldPosition(P);let bt=g;if(bt){let he=R===null?void 0:bt.slotOf.get(R);for(let Xt of bt.podiums)Xt.group.updateMatrixWorld(!0);let ve=d.place(v,P,t.clientWidth,t.clientHeight,he===void 0?void 0:bt.podiums[he]);if(R===null&&ve!==Re)Re=ve,e.onNames?.(ve);yu(bt.built.flames,Ue,s);for(let Xt of bt.built.flames)Xt.body.lookAt(P.x,Xt.body.position.y,P.z);for(let Xt of bt.podiums){if(Xt.init.kind!=="agent")continue;let an=y.get(Xt.init.id??"")??"idle",ln=an==="speaking"?1:0,Si=an==="thinking"||an==="working"?1:0,ge=Xt.speak;Xt.speak=s?ln:Pu(Xt.speak,ln,7,q/1000),Xt.bob=s?0:Pu(Xt.bob,Si,5,q/1000);let ye=Xt.speak>0.02;if(Xt.glow.visible=ye&&Xt.board.visible,Xt.glowMaterial.opacity=0.85*Xt.speak,Xt.board.position.y=Xt.boardY+Math.sin(Ue*3.1+Xt.phase)*0.035*Xt.bob,Xt.face(P),Xt.markFrame(an==="speaking",Ue,s))St=!0;let wn=an==="speaking"&&!s;if(Xt.mouth(wn&&Cr(Ue,Xt.phase))&&wn)St=!0;if(Math.abs(Xt.speak-ln)>0.01||Math.abs(ge-Xt.speak)>0.001||Xt.bob>0.02)St=!0}}l.render(p,v),be+=1,ae+=1;let Zt=performance.now()-ht;if(S+=Zt,_=Math.max(_,Zt),U-V>=1000)L=ae*1000/(U-V),ft={...ft,fps:L,frameMs:S/Math.max(ae,1),frameMsMax:_},ae=0,S=0,_=0,V=U;return St},host:{request:(U)=>requestAnimationFrame(U),cancel:(U)=>cancelAnimationFrame(U),hidden:()=>document.hidden},idleMs:()=>s?0:a?140:90}),ft={kind:"webgl",fps:0,frameMs:0,frameMsMax:0,drawCalls:0,triangles:0,textures:0,geometries:0,dpr:l.getPixelRatio(),lowPower:a,reduced:s,loop:"idle",seats:0,renders:0},J=()=>{let{clientWidth:U,clientHeight:q}=t;if(U<=0||q<=0)return;if(l.setSize(U,q,!1),v.aspect=U/q,v.updateProjectionMatrix(),R===null&&!dt&&g)if(et===0)Z=rt();else at=rt();d.size(U),st.wake()},j=new ResizeObserver(J);j.observe(t);let _t=new IntersectionObserver((U)=>{for(let q of U)st.setVisible(q.isIntersecting)});_t.observe(t);let Nt=()=>st.sync();document.addEventListener("visibilitychange",Nt);let pt=(U)=>{U.preventDefault(),n?.()};c.addEventListener("webglcontextlost",pt);let ot=(U,q,ht)=>{let St=U!==null&&g?.slotOf.has(U)?U:null;if(St===R)return;let bt=St!==null&&R===null;R=St;let Zt=It(rt(),q,bt);if(St!==null&&At&&!Zt.cut)h.play();if(ht)e.onFocus?.(St)},Ot=new qt,kt=new fa,se=(U,q)=>{let ht=g;if(!ht)return;let St=c.getBoundingClientRect();return Ot.set((U-St.left)/St.width*2-1,-((q-St.top)/St.height)*2+1),kt.setFromCamera(Ot,v),kt.intersectObjects(ht.podiums.filter((Zt)=>Zt.group.visible).flatMap((Zt)=>Zt.hits).filter((Zt)=>Zt.visible),!1)[0]?.object.userData},I=new Map,ct,Q=0,ut=!1,Tt=()=>{let[U,q]=[...I.values()];return U&&q?Math.hypot(U.x-q.x,U.y-q.y):0},nt=(U)=>{if(I.set(U.pointerId,{x:U.clientX,y:U.clientY}),I.size===2){Q=Tt(),ut=!1,ct=void 0,dt=void 0;return}let q=c.getBoundingClientRect(),ht=!Ws(U.clientX,U.clientY,q,{width:innerWidth,height:innerHeight});if(ct={x:U.clientX,y:U.clientY,az:k,ok:ht,at:performance.now(),hold:U.pointerType!=="mouse"&&e.onSeatMenu!==void 0},ht)c.setPointerCapture?.(U.pointerId);c.style.cursor="grabbing"},mt=(U)=>{if(I.has(U.pointerId))I.set(U.pointerId,{x:U.clientX,y:U.clientY});if(I.size===2&&Q>0&&!ut){let St=Tt()/Q,bt=St>M0?"in":St<b0?"out":"none";if(bt!=="none")ut=!0,cn(bt==="in"?-1:1);return}if(!ct){if(U.buttons===0)c.style.cursor=se(U.clientX,U.clientY)?"pointer":"grab";return}if(!ct.ok||R!==null)return;let q=U.clientX-ct.x;if(Math.abs(q)<Iu&&!dt)return;let ht=ct.az+Gs(q,c.clientWidth);dt={az:ht},Z=Kn(ht,Bt(),v.aspect,c.clientWidth||void 0),et=0,st.wake()},Wt=(U)=>{if(I.delete(U.pointerId),I.size<2)Q=0;c.style.cursor="grab";let q=ct;if(ct=void 0,!q||ut){if(I.size===0)ut=!1;return}let ht=U.clientX-q.x,St=U.clientY-q.y;if(dt){k=Oo(dt.az,Bt()),dt=void 0,It(Kn(k,Bt(),v.aspect,c.clientWidth||void 0),!1);return}if(Math.hypot(ht,St)<Iu){if(q.hold&&performance.now()-q.at>=Wr)return;let bt=se(U.clientX,U.clientY);if(!bt)return;if(bt.kind==="agent"&&bt.seat){let Zt=C.find((he)=>he.id===bt.seat);if(Zt)e.onSeatClick({id:Zt.id,name:Zt.name,at:{x:U.clientX,y:U.clientY}})}else if(bt.kind==="owner"&&R!==null)ot(null,!1,!0);return}if(q.ok&&R!==null&&Math.abs(ht)>=S0&&Math.abs(ht)>Math.abs(St))ce(Zs(ht))},fe=(U)=>{if(I.delete(U.pointerId),ct=void 0,dt)k=Oo(dt.az,Bt()),dt=void 0,It(Kn(k,Bt(),v.aspect,c.clientWidth||void 0),!1);c.style.cursor="grab"},ce=(U)=>{let q=g;if(!q||R===null||q.order.length<2)return;let ht=q.order.indexOf(R),St=q.order[(ht+U+q.order.length)%q.order.length];if(St)ot(St,!1,!0)},cn=(U)=>{let q=g;if(!q)return;let ht=Ys(U,R!==null);if(ht==="in"){let St=Is(k,q.slots),bt=St===void 0?void 0:q.order[St-1];if(bt)ot(bt,!1,!0)}else if(ht==="out")ot(null,!1,!0)},vn=0,mr=(U)=>{U.preventDefault();let q=performance.now();if(q-vn<450||Math.abs(U.deltaY)<4)return;vn=q,cn(U.deltaY)};c.addEventListener("pointerdown",nt),c.addEventListener("pointermove",mt),c.addEventListener("pointerup",Wt),c.addEventListener("pointercancel",fe),c.addEventListener("wheel",mr,{passive:!1});let gr=(U)=>U.length===C.length&&U.every((q,ht)=>q.id===C[ht]?.id&&q.name===C[ht]?.name&&q.color===C[ht]?.color);C=e.seats.map((U)=>({...U}));for(let U of C){if(U.state)y.set(U.id,U.state);if(U.avatarSvg)A.set(U.id,U.avatarSvg);if(U.talkSvg)E.set(U.id,U.talkSvg)}if(e.focus&&C.some((U)=>U.id===e.focus))R=e.focus;return $t(),Z=rt(),J(),At=!0,{kind:"webgl",setTheme(U,q){if(U===f&&q===w)return;me(),f=U,w=q,$t()},setSeats(U){me();let q=!gr(U),ht=U.map((bt)=>({...bt})),St=q&&At&&g?pi(ee(C),ee(ht),s):void 0;for(let bt of ht){if(bt.state)y.set(bt.id,bt.state);if(bt.avatarSvg&&bt.avatarSvg!==A.get(bt.id))A.set(bt.id,bt.avatarSvg);if(bt.avatarSvg)if(bt.talkSvg)E.set(bt.id,bt.talkSvg);else E.delete(bt.id)}if(St&&St.mode!=="cut"){Ze(ht,St);return}if(C=ht,q)$t();else{let bt=g;for(let Zt of C){let he=bt?.slotOf.get(Zt.id);(he===void 0?void 0:bt?.podiums[he])?.setDim(Zt.dim===!0),Ut(Zt.id,M)}}st.wake()},setState(U,q){y.set(U,q);let ht=g?.slotOf.get(U),St=ht===void 0?void 0:g?.podiums[ht];if(St)Ce(St,q),d.relabel(St,q);st.wake()},setMark(U,q){if(q===null)b.delete(U);else b.set(U,q);let ht=g?.slotOf.get(U),St=ht===void 0?void 0:g?.podiums[ht];if(St)d.mark(St,q);st.wake()},async setAvatar(U,q,ht){if(A.set(U,q),ht)E.set(U,ht);else E.delete(U);await Ut(U,M)},setReducedMotion(U){if(s=U,ft.reduced=U,U)It(rt(),!0);st.wake()},resetCamera(){k=0,ot(null,!1,!0),It(rt(),!1)},focus(U,q){ot(U,q?.cut===!0,!1)},focused:()=>R,seatAt(U,q){let ht=se(U,q);return ht?.kind==="agent"?ht.seat:null},getStats(){let U=l.info;return{...ft,drawCalls:U.render.calls,triangles:U.render.triangles,textures:U.memory.textures,geometries:U.memory.geometries,loop:st.state,seats:C.length,renders:be,reduced:s}},dispose(){if(X){for(let U of X.timers)clearTimeout(U);X.fx?.dispose(),X=void 0}st.dispose(),j.disconnect(),_t.disconnect(),document.removeEventListener("visibilitychange",Nt),c.removeEventListener("webglcontextlost",pt),c.removeEventListener("pointerdown",nt),c.removeEventListener("pointermove",mt),c.removeEventListener("pointerup",Wt),c.removeEventListener("pointercancel",fe),c.removeEventListener("wheel",mr),h.dispose(),d.dispose(),Ft(),l.dispose(),l.forceContextLoss(),c.remove()}}}export{cS as createTable3D};