UNPKG

three-virtual-geometry

Version:

Virtual geometry for three.js WebGPU: automatic cluster LOD and GPU-driven culling for billions of triangles. Independent implementation, not affiliated with Epic Games.

586 lines • 1.42 MB
/**
 * three-virtual-geometry 0.1.3 | MIT License | https://github.com/elad12390/three-virtual-geometry
 * Independent open-source implementation of virtual geometry; not affiliated with or endorsed by Epic Games.
 * Includes meshoptimizer (MIT, Arseny Kapoulkine) and three.js (MIT, three.js authors). Parts derived from nanite-webgpu (MIT, Marcin Matuszczyk).
 */
var AP=Object.defineProperty;var CE=(r,e)=>{for(var t in e)AP(r,t,{get:e[t],enumerable:!0})};var $b=(function(){var r="b9H79Tebbbe9ok9Geueu9Geub9Gbb9Gruuuuuuueu9Gvuuuuueu9Gduueu9Gluuuueu9Gvuuuuub9Gouuuuuub9Gluuuub9GiuuueuiE8AdilveoveovrrwrrrDDoDrbqqbelve9Weiiviebeoweuecj:Gdkr:PlCo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8F9TW79O9V9Wt9FW9U9J9V9KW9wWVtW949c919M9MWV9mW4W2be8A9TW79O9V9Wt9FW9U9J9V9KW9wWVtW949c919M9MWVbd8F9TW79O9V9Wt9FW9U9J9V9KW9wWVtW949c919M9MWV9c9V919U9KbiE9TW79O9V9Wt9FW9U9J9V9KW9wWVtW949wWV79P9V9UblY9TW79O9V9Wt9FW9U9J9V9KW69U9KW949c919M9MWVbv8E9TW79O9V9Wt9FW9U9J9V9KW69U9KW949c919M9MWV9c9V919U9Kbo8A9TW79O9V9Wt9FW9U9J9V9KW69U9KW949wWV79P9V9UbrE9TW79O9V9Wt9FW9U9J9V9KW69U9KW949tWG91W9U9JWbwa9TW79O9V9Wt9FW9U9J9V9KW69U9KW949tWG91W9U9JW9c9V919U9KbDL9TW79O9V9Wt9FW9U9J9V9KWS9P2tWV9p9JtbqK9TW79O9V9Wt9FW9U9J9V9KWS9P2tWV9r919HtbkL9TW79O9V9Wt9FW9U9J9V9KWS9P2tWVT949WbxY9TW79O9V9Wt9FW9U9J9V9KWS9P2tWVJ9V29VVbmE9TW79O9V9Wt9F9V9Wt9P9T9P96W9wWVtW94J9H9J9OWbza9TW79O9V9Wt9F9V9Wt9P9T9P96W9wWVtW94J9H9J9OW9ttV9P9WbHa9TW79O9V9Wt9F9V9Wt9P9T9P96W9wWVtW94SWt9J9O9sW9T9H9WbOK9TW79O9V9Wt9F79W9Ht9P9H29t9VVt9sW9T9H9WbAl79IV9RbXDwebcekdKYq:Nf8Adbk;wadhud9:8Jjjjjbc;qw9Rgr8KjjjjbcbhwdnaeTmbabcbyd;i:I:cjbaoaocb9iEgDc:GeV86bbarc;adfcbcjdz:xjjjb8AdnaiTmbarc;adfadalz:wjjjb8Akarc;abfalfcbcbcjdal9RalcFe0Ez:xjjjb8Aarc;abfarc;adfalz:wjjjb8Aar9cb83iUar9cb83i8War9cb83iyar9cb83iaar9cb83iKar9cb83izar9cb83iwar9cb83ibcj;abal9Uc;WFbGcjdalca0Ehqdnaicd6mbavcd9imbaDTmbadcefhkaqci2gxal2hmarc;alfclfhParc;qlfceVhsarc;qofclVhzcbhHincdhOcbhAdnavci6mbar9cb83i;Ooar9cb83i;Goar9cb83i;yoar9cb83i;qoadaHfgoybbhCcbhXincbhwcbhQdninaoalfhLaoybbgKaC7aQVhQawcP0meaLhoaKhCawcefgwaXfai6mbkkcbhCarc;qofhwincwhYcwh8AdnaQaC93gocFeGgEcs0mbclh8AaEci0mbcdcbaEEh8Akdnaocw4cFeGgEcs0mbclhYaEci0mbcdcbaEEhYkaYa8AfhEawydbh3cwhYcwh8Adnaocz4cFeGg5cs0mbclh8Aa5ci0mbcdcba5Eh8AkaEa3fhEdnaocFFFFb0mbclhYaocFFF8F0mbcbcdaocjjjw6EhYkawaEa8AfaYfBdbawclfhwaCcefgCcw9hmbkaLhoaKhCaXczfgXai6mbkcbhocehwazhQinawaoaQydbarc;qofaocdtfydb6EhoaQclfhQawcefgwcw9hmbkaoclthAcihOkcbhEarc;qlfcbcjdz:xjjjb8AarcbBd;ilar9cb83i;aladh8Eaqh8Fakh3inarc;qlfadaEaEcb9h9Ral2falz:wjjjb8Aaia8Faia8F6EhadnaqaiaE9RaEaqfai6EgKcsfc9WGgoaK9nmbarc;qofaKfcbaoaK9Rz:xjjjb8AkadaEal2fhhcbhginagaAVcl4hXarc;alfagcdtfh8JaHh8Kcbh8Lina8LaHfhwdndndndndndndnagPlbedibkaKTmvahawfhoarc;qlfawfRbbhQarc;qofhwaahCinawaoRbbgYaQ9RgQcetaQcKtc8F91786bbawcefhwaoalfhoaYhQaEaCcufgC9hmbxvkkaKTmla8Kc9:Ghoa8LcitcwGh8Aarc;qlfawceVfRbbcwtarc;qlfawc9:GfRbbVhQarc;qofhwaahCinawa3aofRbbcwta8EaofRbbVgYaQ9RgQcetaQcztc8F917cFFiGa8A486bbaoalfhoawcefhwaYhQaEaCcufgC9hmbxlkkasa8Kc98GgQfhoa3aQfhYarc;qlfawc98GgQfRbbhCcwhwinaoRbbawtaCVhCaocefhoawcwfgwca9hmbxdkkaKTmdxekaKTmea8Lcith5ahaQfh8AcbhLina8ARbbhQcwhoaYhwinawRbbaotaQVhQawcefhwaocwfgoca9hmbkarc;qofaLfaQaC7aX93a5486bbaYalfhYa8Aalfh8AaQhCaLcefgLaK9hmbkka8Jydbh8AcbhLarc;qofhoincdhQcbhwinaQaoawfRbbcb9hfhQawcefgwcz9hmbkclhCcbhwinaCaoawfRbbcd0fhCawcefgwcz9hmbkcwhYcbhwinaYaoawfRbbcP0fhYawcefgwcz9hmbkaQaCaQaC6EgwaYawaY6Egwczawcz6Ea8Afh8AaoczfhoaLczfgLaK6mbka8Ja8ABdbka8Kcefh8Ka8Lcefg8Lcl9hmbkagcefggaO9hmbka8Eamfh8Ea8Faxfh8Fa3amfh3aEaxfgEai6mbkcbhocehwaPhQinawaoaQydbarc;alfaocdtfydb6EhoaQclfhQaOawcefgw9hmbkaraHcd4faAcdVaoaocdSE86bbaHclfgHal6mbkkabaefhgabcefhoalcd4g8McbaDEhkadcefh8Narc;abfceVhecbhmdndninaiam9nmearc;qofcbcjdz:xjjjb8Aagao9Rak6mdadamal2gwfhxcbhHa8Nawfhzaocbakz:xjjjbg8Fakfh3aqaiam9Ramaqfai6Egscsfgocl4cifcd4hOaoc9WGg8JThPindndndndndndndndndndnaDTmbaraHcd4fRbbgQciGPlbedlbkasTmdaxaHfhoarc;abfaHfRbbhQarc;qofhwashCinawaoRbbgYaQ9RgQcetaQcKtc8F91786bbawcefhwaoalfhoaYhQaCcufgCmbxikkasTmiaHcitcwGh8Aarc;abfaHceVfRbbcwtarc;abfaHc9:GgofRbbVhQaxaofhoarc;qofhwashCinawao8VbbgYaQ9RgQcetaQcztc8F917cFFiGa8A486bbawcefhwaoalfhoaYhQaCcufgCmbxikkaeaHc98Gg8Afhoaza8AfhYarc;abfa8AfRbbhCcwhwinaoRbbawtaCVhCaocefhoawcwfgwca9hmbkasTmdaQcl4hKaHcitcKGhEaxa8Afh8AcbhLina8ARbbhQcwhoaYhwinawRbbaotaQVhQawcefhwaocwfgoca9hmbkarc;qofaLfaQaC7aK93aE486bbaYalfhYa8Aalfh8AaQhCaLcefgLas9hmbkkaDmbcbhoxlka8JTmbcbhodninarc;qofaofgwcwf8Pibaw8Pib:e9qTmeaoczfgoa8J9pmdxbkkdnavmbcehoxikcbh8AaOhLaOhKinarc;qofa8Afgocwf8Pibhyao8Pibh8PcdhQcbhwinaQaoawfRbbcb9hfhQawcefgwcz9hmbkclhCcbhwinaCaoawfRbbcd0fhCawcefgwcz9hmbkcwhYcbhwinaYaoawfRbbcP0fhYawcefgwcz9hmbkaQaCaQaC6EgoaYaoaY6Egoczaocz6EaKfhKaocucbaya8P:e9cb9sEgwaoaw6EaLfhLa8Aczfg8Aa8J9pmdxbkka8FaHcd4fgoaoRbbcdaHcetcoGtV86bbxikdnaLas6mbaKas6mba8FaHcd4fgoaoRbbciaHcetcoGtV86bbaga39Ras6mra3arc;qofasz:wjjjbasfh3xikaLaK9phoka8FaHcd4fgwawRbbaoaHcetcoGtV86bbkaga39RaO6mla3cbaOz:xjjjbgaaOfhKdndna8JmbaPhoxekdnagaK9RcK9pmbaPhoxekaocdtc:q:G:cjbfcj:G:cjbaDEg3ydxghcetc;:FFFeGhAcuhEcuahtcu7cFeGh8Ecbh8Karc;qofhQinarc;qofa8KfhXczh8AdndndnahPDbeeeeeeedekcucbaXcwf8PibaX8Pib:e9cb9sEh8AxekcbhoaAh8Aina8Aa8EaQaofRbb9nfh8Aaocefgocz9hmbkkcih5cbhYinczhwdndndna3aYcdtfydbgLPDbeeeeeeedekcucbaXcwf8PibaX8Pib:e9cb9sEhwxekaLcetc;:FFFeGhwcuaLtcu7cFeGhCcbhoinawaCaQaofRbb9nfhwaocefgocz9hmbkkdndnawa8A6mbaLaE9hmeawa8A9hmea3a5cdtfydbcwSmekaYh5awh8AkaYcefgYci9hmbkaaa8Kco4fgoaoRbba5a8Kci4coGtV86bbdndndna3a5cdtfydbgEPDdbbbbbbbebkdncwaE9Tg5TmbcuaEtcu7hwdndnaEceSmbcbh8LaQhXinaXhoa5hYcbhCinaoRbbg8AawcFeGgLa8AaL6EaCaEtVhCaocefhoaYcufgYmbkaKaC86bbaXa5fhXaKcefhKa8La5fg8Lcz6mbxdkkcbh8LaQhXinaXhoa5hYcbhCinaoRbbg8AawcFeGgLa8AaL6EaCcetVhCaocefhoaYcufgYmbkaKaC:T9cFe:d9c:c:qj:bw9:9c:q;c1:I1e:d9c:b:c:e1z9:9ca188bbaXa5fhXaKcefhKa8La5fg8Lcz6mbkkcbhoinaKaQaofRbbgC86bbaKaCawcFeG9pfhKaocefgocz9hmbxikkdnaEceSmbinaKcb86bbaKcefhKxbkkinaKcb86bbaKcefhKxbkkaKaX8Pbw83bwaKaX8Pbb83bbaKczfhKka8Kczfg8Ka8J9pgomeaQczfhQagaK9RcK9pmbkkaoTmlaKh3aKTmlkaHcefgHal9hmbkarc;abfaxascufal2falz:wjjjb8Aasamfhma3hoa3mbkcbhwxdkdnagao9RakalfgwcKcaaDEgQawaQ0EgC9pmbcbhwxdkdnawaQ9pmbaocbaCaw9Rgwz:xjjjbawfhokaoarc;adfalz:wjjjbalfhodnaDTmbaoara8Mz:wjjjba8Mfhokaoab9Rhwxekcbhwkarc;qwf8Kjjjjbawk5babaeadaialcdcbyd;i:I:cjbz:bjjjbk9reduaecd4gdaefgicaaica0Ecj;abae9Uc;WFbGcjdaeca0Egicl4cifcd4aifae2adfabaifcufai9U2fcefkmbcbabBd;i:I:cjbk;HPeLu8Jjjjjbc;ae9Rgl8Kjjjjbcbhvdnaeaici9UgocHf6mbabcbyd;m:I:cjbgrc;GeV86bbalc;abfcFecjez:xjjjb8Aal9cu83iUal9cu83i8Wal9cu83iyal9cu83iaal9cu83iKal9cu83izal9cu83iwal9cu83ibabaefc9WfhwabcefgDaofhednaiTmbcmcsarcb9kgqEhkcbhxcbhmcbhPcbhscbhzindnaeaw9nmbcbhvxikazcufhvadaPcdtfgHydbhOaHcwfydbhAaHclfydbhCcbhXdndndninalc;abfavcsGcitfgoydlhQdndndnaoydbgoaO9hmbaQaCSmekdnaoaC9hmbaQaA9hmbaXcefhXxekaoaA9hmeaQaO9hmeaXcdfhXkaXc870mdascufhvaHaXcdtgAcxGgoyd:4:G:cjbcdtfydbhQaHaoyd:0:G:cjbcdtfydbhCaHaoyd:W:G:cjbcdtfydbhOcbhodnindnalavcsGcdtfydbaQ9hmbaohXxdkcuhXavcufhvaocefgocz9hmbkkaxaQaxSgvaXce9iaXak9oVgoGfhxdndndncbcsavEaXaoEgvcs9hmbarce9imbaQaQamaQcefamSgvEgmcefSmecmcsavEhvkaDavaAc;WeGV86bbavcs9hmeaQam9Rgvcetavc8F917hvinaecbcjeavcje6EavcFbGV86bbaecefheavcr4gvmbkaQhmxvkcPhvaDaAcPV86bbaQhmkavTmiavak9omicdhocehXazhAxlkavcufhvaXclfgXc;ab9hmbkkdnaHcecdcbaAaxSEaCaxSEcdtgvyd:W:G:cjbcdtfydbgOTaHavyd:0:G:cjbcdtfydbgCceSGaHavyd:4:G:cjbcdtfydbgQcdSGaxcb9hGaqGgLce9hmbal9cu83iUal9cu83i8Wal9cu83iyal9cu83iaal9cu83iKal9cu83izal9cu83iwal9cu83ibcbhxkcbhXascufgvhodnindnalaocsGcdtfydbaC9hmbaXhAxdkcuhAaocufhoaXcefgXcz9hmbkkcbhodnindnalavcsGcdtfydbaQ9hmbaohXxdkcuhXavcufhvaocefgocz9hmbkkaxaOaxSgKfhHdndnaAcm0mbaAcefhAxekcbcsaCaHSgvEhAaHavfhHkdndnaXcm0mbaXcefhXxekcbcsaQaHSgvEhXaHavfhHkc9:cuaKEhYcbhvaXaAcltVg8AcFeGhodndndninavc;q:G:cjbfRbbaoSmeavcefgvcz9hmbxdkkaLaOax9havcm0VVmbaDavc;WeV86bbxekaDaY86bbaea8A86bbaecefhekdnaKmbaOam9Rgvcetavc8F917hvinaecbcjeavcje6EavcFbGV86bbaecefheavcr4gvmbkaOhmkdnaAcs9hmbaCam9Rgvcetavc8F917hvinaecbcjeavcje6EavcFbGV86bbaecefheavcr4gvmbkaChmkdnaXcs9hmbaQam9Rgvcetavc8F917hvinaecbcjeavcje6EavcFbGV86bbaecefheavcr4gvmbkaQhmkalascdtfaOBdbascefcsGhvdndnaAPzbeeeeeeeeeeeeeebekalavcdtfaCBdbascdfcsGhvkdndnaXPzbeeeeeeeeeeeeeebekalavcdtfaQBdbavcefcsGhvkcihoalc;abfazcitfgXaOBdlaXaCBdbazcefcsGhAcdhXavhsaHhxxekcdhoalascdtfaQBdbcehXascefcsGhsazhAkalc;abfaAcitfgvaCBdlavaQBdbalc;abfazaXfcsGcitfgvaQBdlavaOBdbaDcefhDazaofcsGhzaPcifgPai6mbkkdnaeaw9nmbcbhvxekcbhvinaeavfavc;q:G:cjbfRbb86bbavcefgvcz9hmbkaeab9Ravfhvkalc;aef8KjjjjbavkZeeucbhddninadcefgdc8F0meaeceadt0mbkkadcrfcFeGcr9Uci2cdfabci9U2cHfkmbcbabBd;m:I:cjbk:zderu8Jjjjjbcz9Rhlcbhvdnaeaicvf6mbabcbRb;m:I:cjbc;qeV86bbal9cb83iwabcefhvabaefc98fhodnaiTmbcbhecbhrcbhwindnavao6mbcbskadawcdtfydbgDalcwfaraDae9Rgeaec8F91ge7ae9Rc507grcdtfgqydb9Rgec8E91c9:Gaecdt7arVheinavcbcjeaecje6EaecFbGV86bbavcefhvaecr4gembkaqaDBdbaDheawcefgwai9hmbkkdnavao9nmbcbskavcbBbbavab9RclfhvkavkBeeucbhddninadcefgdc8F0meaeceadt0mbkkabadcwfcFeGcr9U2cvfk:dvli99dui99ludnaeTmbcuadcetcuftcu7:Zhvdndncuaicuftcu7:ZgoJbbbZMgr:lJbbb9p9DTmbar:Ohwxekcjjjj94hwkcbhicbhDinalclfIdbgrJbbbbJbbjZalIdbgq:lar:lMalcwfIdbgk:lMgr:varJbbbb9BEgrNhxaqarNhralcxfIdbhqdndnakJbbbb9GTmbaxhkxekJbbjZar:l:tgkak:maxJbbbb9GEhkJbbjZax:l:tgxax:marJbbbb9GEhrkdndnaqJbbj:;aqJbbj:;9GEgxJbbjZaxJbbjZ9FEavNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohmxekcjjjj94hmkdndnakJbbj:;akJbbj:;9GEgqJbbjZaqJbbjZ9FEaoNJbbbZJbbb:;akJbbbb9GEMgq:lJbbb9p9DTmbaq:OhPxekcjjjj94hPkdndnarJbbj:;arJbbj:;9GEgqJbbjZaqJbbjZ9FEaoNJbbbZJbbb:;arJbbbb9GEMgr:lJbbb9p9DTmbar:Ohsxekcjjjj94hskdndnadcl9hmbabaDfgzas86bbazcifam86bbazcdfaw86bbazcefaP86bbxekabaifgzas87ebazcofam87ebazclfaw87ebazcdfaP87ebkaicwfhiaDclfhDalczfhlaecufgembkkk;hlld99eud99eudnaeTmbdndncuaicuftcu7:ZgvJbbbZMgo:lJbbb9p9DTmbao:Ohixekcjjjj94hikaic;8FiGhrinabcofcicdalclfIdb:lalIdb:l9EgialcwfIdb:lalaicdtfIdb:l9EEgialcxfIdb:lalaicdtfIdb:l9EEgiarV87ebdndnJbbj:;JbbjZalaicdtfIdbJbbbb9DEgoalaicd7cdtfIdbJ;Zl:1ZNNgwJbbj:;awJbbj:;9GEgDJbbjZaDJbbjZ9FEavNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohqxekcjjjj94hqkabcdfaq87ebdndnalaicefciGcdtfIdbJ;Zl:1ZNaoNgwJbbj:;awJbbj:;9GEgDJbbjZaDJbbjZ9FEavNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohqxekcjjjj94hqkabaq87ebdndnaoalaicufciGcdtfIdbJ;Zl:1ZNNgoJbbj:;aoJbbj:;9GEgwJbbjZawJbbjZ9FEavNJbbbZJbbb:;aoJbbbb9GEMgo:lJbbb9p9DTmbao:Ohixekcjjjj94hikabclfai87ebabcwfhbalczfhlaecufgembkkk;uvdDue998Jjjjjbcjd9Rgo8Kjjjjbdndndnadcd4grTmbc:CucbavEhwaohdarhDinadawBdbadclfhdaDcufgDmbkavcd9hmbaeTmbarcdthqcbhkalhxinaohdaxhDarhwinadadydbgmaDydbcL4cFeGc:cufgPamaP9kEBdbaDclfhDadclfhdawcufgwmbkaxaqfhxakcefgkae9hmbxdkkaeTmekarcdthxavce9hhqcbhkindndndnaqmbarTmdc:CuhwalhdarhDinawadydbcL4cFeGc:cufgmawam9kEhwadclfhdaDcufgDmbxdkkdndndndnavPleddbdkarTmlaohdalhDarhwinadcbaDydbcL4cFeGgmc:cufgPaPam0EBdbadclfhdaDclfhDawcufgwmbxikkarTmicbhdarhDindnaladfIdbgsJbbbb9Bmbaoadfas:8cL4cFeGgwc8Aawc8A0Ec:cufBdbkadclfhdaDcufgDmbxdkkarTmdkc:CuhwkcbhdarhminawhDdnavceSmbaoadfydbhDkdndnaladfIdbgscjjj;8iaDai9RcefgPcLt9R::NJbbbZJbbb:;asJbbbb9GEMgs:lJbbb9p9DTmbas:OhDxekcjjjj94hDkabadfaDcFFFiaDcFFFi9iEcFFFrGaPcKtVBdbadclfhdamcufgmmbkkabaxfhbalaxfhlakcefgkae9hmbkkaocjdf8Kjjjjbk:Olveue99iue99iudnaeTmbceaicufthvcuaitcu7:Zhocbhradcl9hhwcbhDindndnalcwfIdbgqJbbbbaqJbbbb9GEgqJbbjZaqJbbjZ9FEaoNJbbbZMgq:lJbbb9p9DTmbaq:Ohixekcjjjj94hikdndnalIdbgqJbbbbaqJbbbb9GEgqJbbjZaqJbbjZ9FEaoNJbbbZMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkadai9Rcd9TgkaifhidndnalclfIdbgqJbbbbaqJbbbb9GEgqJbbjZaqJbbjZ9FEaoNJbbbZMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkadai9Rcd9ThddndnalcxfIdbgqJbbbbaqJbbbb9GEgqJbbjZaqJbbjZ9FEaoNJbbbZMgq:lJbbb9p9DTmbaq:Ohxxekcjjjj94hxkadaifhiaxce91avVhxdndnawmbabaDfgmai86bbamcifax86bbamcdfad86bbamcefak86bbxekabarfgmai87ebamcofax87ebamclfad87ebamcdfak87ebkarcwfhraDclfhDalczfhlaecufgembkkk;mqdQui998Jjjjjbc:qd9Rgv8Kjjjjbavc:Sefcbc;Kbz:xjjjb8AdnadTmbaiTmbdndnabaeSmbaehoxekavcuadcdtgradcFFFFi0Ecbyd;q:I:cjbHjjjjbbgoBd:SeavceBd:mdaoaearz:wjjjb8AkavcbBd:Oeav9cb83i:Geavc:Gefaoadaiavc:Sefz:pjjjbavyd:Gehwadci9UgDcbyd;q:I:cjbHjjjjbbheavc:Sefavyd:mdgqcdtfaeBdbavaqcefgrBd:mdaecbaDz:xjjjbhkavc:SefarcdtfcuaicdtaicFFFFi0Ecbyd;q:I:cjbHjjjjbbgxBdbavaqcdfgmBd:mdalc;ebfhPawheaxhrinaralIdbaPaeydbgscwascw6EcdtfIdbMUdbaeclfhearclfhraicufgimbkavc:SefamcdtfcuaDcdtadcFFFF970Ecbyd;q:I:cjbHjjjjbbgmBdbdnadci6mbaoheamhraDhiinaraxaeydbcdtfIdbaxaeclfydbcdtfIdbMaxaecwfydbcdtfIdbMUdbaecxfhearclfhraicufgimbkkaqcifhzalc;ebfhHavc;qbfhOavheavyd:KehAavyd:OehCcbhscbhrcbhXcehQinaehLaoarcx2fgKydbhPaKclfydbhdabaXcx2fgecwfaKcwfydbgYBdbaeclfadBdbaeaPBdbakarfce86bbaOaYBdwaOadBdlaOaPBdbamarcdtfcbBdbcih8AdnasTmbaLhiinaOa8AcdtfaiydbgeBdba8AaeaY9haeaP9haead9hGGfh8AaiclfhiascufgsmbkkaXcefhXcbhsinaCaAaKascdtfydbcdtgifydbcdtfgYheawaifgdydbgPhidnaPTmbdninaeydbarSmeaeclfheaicufgiTmdxbkkaeaYaPcdtfc98fydbBdbadadydbcufBdbkascefgsci9hmbkdndndna8ATmbcuhrJbbbbhEcbhdavyd:KehYavyd:OehKindnawaOadcdtfydbcdtgsfydbgeTmbaxasfgiIdbh3aialcuadadcs0EcdtfclfIdbaHaecwaecw6EcdtfIdbMg5Udba5a3:th5aecdthiaKaYasfydbcdtfheinamaeydbgscdtfgPa5aPIdbMg3Udba3aEaEa39DgPEhEasaraPEhraeclfheaic98fgimbkkadcefgda8A9hmbkarcu9hmekaQaD9pmeindnakaQfRbbmbaQhrxdkaDaQcefgQ9hmbxdkka8Acza8Acz6EhsaOheaLhOarcu9hmekkazTmbaqcdtavc:Seffcwfheinaeydbcbyd;u:I:cjbH:bjjjbbaec98fheazcufgzmbkkavc:qdf8Kjjjjbk:0leoucuaicdtgvaicFFFFi0Egocbyd;q:I:cjbHjjjjbbhralalyd9GgwcdtfarBdbalawcefBd9GabarBdbaocbyd;q:I:cjbHjjjjbbhralalyd9GgocdtfarBdbalaocefBd9GabarBdlcuadcdtadcFFFFi0Ecbyd;q:I:cjbHjjjjbbhralalyd9GgocdtfarBdbalaocefBd9GabarBdwabydbcbavz:xjjjb8AabydbhraehladhvinaralydbcdtfgoaoydbcefBdbalclfhlavcufgvmbkcbhvabydlglhoarhwaihDinaoavBdbaoclfhoawydbavfhvawclfhwaDcufgDmbkadci9Uhqdnadcd9nmbabydwhocbhvinaecwfydbhwaeclfydbhDalaeydbcdtfgbabydbgbcefBdbaoabcdtfavBdbalaDcdtfgDaDydbgDcefBdbaoaDcdtfavBdbalawcdtfgwawydbgwcefBdbaoawcdtfavBdbaecxfheaqavcefgv9hmbkkinalalydbarydb9RBdbarclfhralclfhlaicufgimbkkQbabaeadaic;G:G:cjbz:ojjjbkQbabaeadaic;i:H:cjbz:ojjjbk9DeeuabcFeaicdtz:xjjjbhlcbhbdnadTmbindnalaeydbcdtfgiydbcu9hmbaiabBdbabcefhbkaeclfheadcufgdmbkkabk:3vioud9:du8Jjjjjbc;Wa9Rgl8Kjjjjbcbhvalcxfcbc;Kbz:xjjjb8AalcuadcitgoadcFFFFe0Ecbyd;q:I:cjbHjjjjbbgrBdxalceBd2araeadaicezNjjjbalcuaoadcjjjjoGEcbyd;q:I:cjbHjjjjbbgwBdzadcdthednadTmbabhiinaiavBdbaiclfhiadavcefgv9hmbkkawaefhDalabBdwalawBdl9cbhqindnadTmbaq9cq9:hkarhvaDhiadheinaiav8Pibak1:NcFrG87ebavcwfhvaicdfhiaecufgembkkalclfaq:NceGcdtfydbhxalclfaq9ce98gq:NceGcdtfydbhmalc;Wbfcbcjaz:xjjjb8AaDhvadhidnadTmbinalc;Wbfav8VebcdtfgeaeydbcefBdbavcdfhvaicufgimbkkcbhvcbhiinalc;WbfavfgeydbhoaeaiBdbaoaifhiavclfgvcja9hmbkadhvdndnadTmbinalc;WbfaDamydbgicetf8VebcdtfgeaeydbgecefBdbaxaecdtfaiBdbamclfhmavcufgvmbkaq9cv9smdcbhvinabawydbcdtfavBdbawclfhwadavcefgv9hmbxdkkaq9cv9smekkcwhvcbhiinalcxfavfc98fydbcbyd;u:I:cjbH:bjjjbbaiceGheclhvcehiaeTmbkalc;Waf8Kjjjjbk:Awliuo99iud9:cbhv8Jjjjjbca9Rgocbyd:4:I:cjbBdKaocb8Pd:W:I:cjb83izaocbyd;e:I:cjbBdwaocb8Pd:8:I:cjb83ibaicd4hrdndnadmbJFFuFhwJFFuuhDJFFuuhqJFFuFhkJFFuuhxJFFuFhmxekarcdthPaehsincbhiinaoczfaifgzasaifIdbgwazIdbgDaDaw9EEUdbaoaifgzawazIdbgDaDaw9DEUdbaiclfgicx9hmbkasaPfhsavcefgvad9hmbkaoIdKhDaoIdwhwaoIdChqaoIdlhkaoIdzhxaoIdbhmkdnadTmbJbbbbJbFu9hJbbbbamax:tgmamJbbbb9DEgmakaq:tgkakam9DEgkawaD:tgwawak9DEgw:vawJbbbb9BEhwdnalmbarcdthoindndnaeclfIdbaq:tawNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikai:S9cC:ghHdndnaeIdbax:tawNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikaHai:S:ehHdndnaecwfIdbaD:tawNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikabaHai:T9cy:g:e83ibaeaofheabcwfhbadcufgdmbxdkkarcdthoindndnaeIdbax:tawNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikai:SgH9ca:gaH9cz:g9cjjj;4s:d:eaH9cFe:d:e9cF:bj;4:pj;ar:d9c:bd9:9c:p;G:d;4j:E;ar:d9cH9:9c;d;H:W:y:m:g;d;Hb:d9cv9:9c;j:KM;j:KM;j:Kd:dhOdndnaeclfIdbaq:tawNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikai:SgH9ca:gaH9cz:g9cjjj;4s:d:eaH9cFe:d:e9cF:bj;4:pj;ar:d9c:bd9:9c:p;G:d;4j:E;ar:d9cH9:9c;d;H:W:y:m:g;d;Hb:d9cq9:9cM;j:KM;j:KM;jl:daO:ehOdndnaecwfIdbaD:tawNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikabaOai:SgH9ca:gaH9cz:g9cjjj;4s:d:eaH9cFe:d:e9cF:bj;4:pj;ar:d9c:bd9:9c:p;G:d;4j:E;ar:d9cH9:9c;d;H:W:y:m:g;d;Hb:d9cC9:9c:KM;j:KM;j:KMD:d:e83ibaeaofheabcwfhbadcufgdmbkkk9teiucbcbyd;y:I:cjbgeabcifc98GfgbBd;y:I:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaeczfheaiczfhiadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabk9teiucbcbyd;y:I:cjbgeabcrfc94GfgbBd;y:I:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikTeeucbabcbyd;y:I:cjbge9Rcifc98GaefgbBd;y:I:cjbdnabZbcztge9nmbabae9RcFFifcz4nb8Akkk;Sddbcj:Gdk;idbbbbdbbblbbbwbbbbbbbebbbdbbblbbbwbbbbbbbbbbbbbbbbbbbebbbdbbbbbbbebbbbbbbbbbbbbbbb4:h9w9N94:P:gW:j9O:ye9Pbbbbbb:l29hZ;69:9kZ;N;76Z;rg97Z;z;o9xZ8J;B85Z;:;u9yZ;b;k9HZ:2;Z9DZ9e:l9mZ59A8KZ:r;T3Z:A:zYZ79OHZ;j4::8::Y:D9V8:bbbb9s:49:Z8R:hBZ9M9M;M8:L;z;o8:;8:PG89q;x:J878R:hQ8::M:B;e87bbbbbbjZbbjZbbjZ:E;V;N8::Y:DsZ9i;H;68:xd;R8:;h0838:;W:NoZbbbb:WV9O8:uf888:9i;H;68:9c9G;L89;n;m9m89;D8Ko8:bbbbf:8tZ9m836ZS:2AZL;zPZZ818EZ9e:lxZ;U98F8:819E;68:FFuuFFuuFFuuFFuFFFuFFFuFbc;i:IdkCebbbebbbebbbdbbb9G:rbb",e=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if(typeof WebAssembly!="object")return{supported:!1};var t,s=WebAssembly.instantiate(n(r),{}).then(function(f){t=f.instance,t.exports.__wasm_call_ctors(),t.exports.meshopt_encodeVertexVersion(1),t.exports.meshopt_encodeIndexVersion(1)});function n(f){for(var p=new Uint8Array(f.length),m=0;m<f.length;++m){var b=f.charCodeAt(m);p[m]=b>96?b-97:b>64?b-39:b+4}for(var g=0,m=0;m<f.length;++m)p[g++]=p[m]<60?e[p[m]]:(p[m]-60)*64+p[++m];return p.buffer.slice(0,g)}function a(f){if(!f)throw new Error("Assertion failed")}function i(f){return new Uint8Array(f.buffer,f.byteOffset,f.byteLength)}function o(f,p,m,b){var g=t.exports.sbrk,x=g(p.length*4),T=g(m*4),y=new Uint8Array(t.exports.memory.buffer),v=i(p);y.set(v,x),b&&b(x,x,p.length,m);var _=f(T,x,p.length,m);y=new Uint8Array(t.exports.memory.buffer);var A=new Uint32Array(m);new Uint8Array(A.buffer).set(y.subarray(T,T+m*4)),v.set(y.subarray(x,x+p.length*4)),g(x-g(0));for(var M=0;M<p.length;++M)p[M]=A[p[M]];return[A,_]}function c(f,p,m,b){var g=t.exports.sbrk,x=g(m*4),T=g(m*b),y=new Uint8Array(t.exports.memory.buffer);y.set(i(p),T),f(x,T,m,b),y=new Uint8Array(t.exports.memory.buffer);var v=new Uint32Array(m);return new Uint8Array(v.buffer).set(y.subarray(x,x+m*4)),g(x-g(0)),v}function l(f,p,m,b,g,x,T){var y=t.exports.sbrk,v=y(p),_=y(b*g),A=new Uint8Array(t.exports.memory.buffer);A.set(i(m),_);var M=f(v,p,_,b,g,x,T),N=new Uint8Array(M);return N.set(A.subarray(v,v+M)),y(v-y(0)),N}function h(f){for(var p=0,m=0;m<f.length;++m){var b=f[m];p=p<b?b:p}return p}function u(f,p){if(a(p==2||p==4),p==4)return new Uint32Array(f.buffer,f.byteOffset,f.byteLength/4);var m=new Uint16Array(f.buffer,f.byteOffset,f.byteLength/2);return new Uint32Array(m)}function d(f,p,m,b,g,x,T){var y=t.exports.sbrk,v=y(m*b),_=y(m*x),A=new Uint8Array(t.exports.memory.buffer);A.set(i(p),_),f(v,m,b,g,_,T);var M=new Uint8Array(m*b);return M.set(A.subarray(v,v+m*b)),y(v-y(0)),M}return{ready:s,supported:!0,reorderMesh:function(f,p,m){a(f instanceof Uint32Array||f instanceof Int32Array),a(!p||f.length%3==0);var b=p?m?t.exports.meshopt_optimizeVertexCacheStrip:t.exports.meshopt_optimizeVertexCache:void 0;return o(t.exports.meshopt_optimizeVertexFetchRemap,f,h(f)+1,b)},reorderPoints:function(f,p){return a(f instanceof Float32Array),a(f.length%p==0),a(p>=3),c(t.exports.meshopt_spatialSortRemap,f,f.length/p,p*4)},encodeVertexBuffer:function(f,p,m){a(m>0&&m<=256),a(m%4==0);var b=t.exports.meshopt_encodeVertexBufferBound(p,m);return l(t.exports.meshopt_encodeVertexBuffer,b,f,p,m)},encodeVertexBufferLevel:function(f,p,m,b,g){a(m>0&&m<=256),a(m%4==0),a(b>=0&&b<=3),a(g===void 0||g==0||g==1);var x=t.exports.meshopt_encodeVertexBufferBound(p,m);return l(t.exports.meshopt_encodeVertexBufferLevel,x,f,p,m,b,g===void 0?-1:g)},encodeIndexBuffer:function(f,p,m){a(m==2||m==4),a(p%3==0);var b=u(f,m),g=t.exports.meshopt_encodeIndexBufferBound(p,h(b)+1);return l(t.exports.meshopt_encodeIndexBuffer,g,b,p,4)},encodeIndexSequence:function(f,p,m){a(m==2||m==4);var b=u(f,m),g=t.exports.meshopt_encodeIndexSequenceBound(p,h(b)+1);return l(t.exports.meshopt_encodeIndexSequence,g,b,p,4)},encodeGltfBuffer:function(f,p,m,b,g){var x={ATTRIBUTES:this.encodeVertexBufferLevel,TRIANGLES:this.encodeIndexBuffer,INDICES:this.encodeIndexSequence};return a(x[b]),x[b](f,p,m,2,g===void 0?0:g)},encodeFilterOct:function(f,p,m,b){return a(m==4||m==8),a(b>=2&&b<=16),d(t.exports.meshopt_encodeFilterOct,f,p,m,b,16)},encodeFilterQuat:function(f,p,m,b){return a(m==8),a(b>=4&&b<=16),d(t.exports.meshopt_encodeFilterQuat,f,p,m,b,16)},encodeFilterExp:function(f,p,m,b,g){a(m>0&&m%4==0),a(b>=1&&b<=24);var x={Separate:0,SharedVector:1,SharedComponent:2,Clamped:3};return a(!g||g in x),d(t.exports.meshopt_encodeFilterExp,f,p,m,b,m,g?x[g]:1)},encodeFilterColor:function(f,p,m,b){return a(m==4||m==8),a(b>=2&&b<=16),d(t.exports.meshopt_encodeFilterColor,f,p,m,b,16)}}})();var mf=(function(){var r="b9H79Tebbbe8Fv9Gbb9Gvuuuuueu9Giuuub9Geueu9Giuuueuixkbeeeddddillviebeoweuecj:Gdkr;Neqo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbeY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVbdE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbiL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtblK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949WboY9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVJ9V29VVbrl79IV9Rbwq;X8:kdbk:kYi5ud9:du8Jjjjjbcjq9Rgv8Kjjjjbc9:hodnalTmbcuhoaiRbbgrc;WeGc:Ge9hmbarcsGgwce0mbc9:hoalcufadcd4cbawEgDadfgrcKcaawEgqaraq0Egk6mbaicefhxcj;abad9Uc;WFbGcjdadca0EhmaialfgPar9Rgoadfhsavaoadz:jjjjbgzceVhHcbhOdndninaeaO9nmeaPax9RaD6mdamaeaO9RaOamfgoae6EgAcsfglc9WGhCaAcethXaxaDfhiaOaeaoaeao6E9RhQalcl4cifcd4hLazcjdfaAfhKcbhYabaOad2fg8AhEaHh3incbh5dnawTmbaxaYcd4fRbbh5kcbh8Eazcjdfhqinaih8Fdndndndna5a8Ecet4ciGgoc9:fPdebdkaPa8F9RaA6mrazcjdfa8EaA2fa8FaAz:jjjjb8Aa8FaAfhixdkazcjdfa8EaA2fcbaAz:kjjjb8Aa8FhixekaPa8F9RaL6mva8FaLfhidnaCTmbaPai9RcK6mbaocdtc:q:G:cjbfcj:G:cjbawEhaczhrcbhlinargoc9Wfghaqfhrdndndndndndnaaa8Fahco4fRbbalcoG4ciGcdtfydbPDbedvivvvlvkar9cb83bwar9cb83bbxlkarcbaiRbdai8Xbb9c:c:qj:bw9:9c:q;c1:I1e:d9c:b:c:e1z9:gg9cjjjjjz:dg8J9qE86bbaqaofgrcGfcbaicdfa8J9c8N1:NfghRbbag9cjjjjjw:dg8J9qE86bbarcVfcbaha8J9c8M1:NfghRbbag9cjjjjjl:dg8J9qE86bbarc7fcbaha8J9c8L1:NfghRbbag9cjjjjjd:dg8J9qE86bbarctfcbaha8J9c8K1:NfghRbbag9cjjjjje:dg8J9qE86bbarc91fcbaha8J9c8J1:NfghRbbag9cjjjj;ab:dg8J9qE86bbarc4fcbaha8J9cg1:NfghRbbag9cjjjja:dg8J9qE86bbarc93fcbaha8J9ch1:NfghRbbag9cjjjjz:dgg9qE86bbarc94fcbahag9ca1:NfghRbbai8Xbe9c:c:qj:bw9:9c:q;c1:I1e:d9c:b:c:e1z9:gg9cjjjjjz:dg8J9qE86bbarc95fcbaha8J9c8N1:NfgiRbbag9cjjjjjw:dg8J9qE86bbarc96fcbaia8J9c8M1:NfgiRbbag9cjjjjjl:dg8J9qE86bbarc97fcbaia8J9c8L1:NfgiRbbag9cjjjjjd:dg8J9qE86bbarc98fcbaia8J9c8K1:NfgiRbbag9cjjjjje:dg8J9qE86bbarc99fcbaia8J9c8J1:NfgiRbbag9cjjjj;ab:dg8J9qE86bbarc9:fcbaia8J9cg1:NfgiRbbag9cjjjja:dg8J9qE86bbarcufcbaia8J9ch1:NfgiRbbag9cjjjjz:dgg9qE86bbaiag9ca1:NfhixikaraiRblaiRbbghco4g8Ka8KciSg8KE86bbaqaofgrcGfaiclfa8Kfg8KRbbahcl4ciGg8La8LciSg8LE86bbarcVfa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc7fa8Ka8Lfg8KRbbahciGghahciSghE86bbarctfa8Kahfg8KRbbaiRbeghco4g8La8LciSg8LE86bbarc91fa8Ka8Lfg8KRbbahcl4ciGg8La8LciSg8LE86bbarc4fa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc93fa8Ka8Lfg8KRbbahciGghahciSghE86bbarc94fa8Kahfg8KRbbaiRbdghco4g8La8LciSg8LE86bbarc95fa8Ka8Lfg8KRbbahcl4ciGg8La8LciSg8LE86bbarc96fa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc97fa8Ka8Lfg8KRbbahciGghahciSghE86bbarc98fa8KahfghRbbaiRbigico4g8Ka8KciSg8KE86bbarc99faha8KfghRbbaicl4ciGg8Ka8KciSg8KE86bbarc9:faha8KfghRbbaicd4ciGg8Ka8KciSg8KE86bbarcufaha8KfgrRbbaiciGgiaiciSgiE86bbaraifhixdkaraiRbwaiRbbghcl4g8Ka8KcsSg8KE86bbaqaofgrcGfaicwfa8Kfg8KRbbahcsGghahcsSghE86bbarcVfa8KahfghRbbaiRbeg8Kcl4g8La8LcsSg8LE86bbarc7faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarctfaha8KfghRbbaiRbdg8Kcl4g8La8LcsSg8LE86bbarc91faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc4faha8KfghRbbaiRbig8Kcl4g8La8LcsSg8LE86bbarc93faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc94faha8KfghRbbaiRblg8Kcl4g8La8LcsSg8LE86bbarc95faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc96faha8KfghRbbaiRbvg8Kcl4g8La8LcsSg8LE86bbarc97faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc98faha8KfghRbbaiRbog8Kcl4g8La8LcsSg8LE86bbarc99faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc9:faha8KfghRbbaiRbrgicl4g8Ka8KcsSg8KE86bbarcufaha8KfgrRbbaicsGgiaicsSgiE86bbaraifhixekarai8Pbw83bwarai8Pbb83bbaiczfhikdnaoaC9pmbalcdfhlaoczfhraPai9RcL0mekkaoaC6moaimexokaCmva8FTmvkaqaAfhqa8Ecefg8Ecl9hmbkdndndndnawTmbasaYcd4fRbbgociGPlbedrbkaATmdazaYfh8Fazcjdfhhcbh8EaEhaina8FRbbhraahocbhlinaoahalfRbbgqce4cbaqceG9R7arfgr86bbaoadfhoaAalcefgl9hmbkaacefhaa8Fcefh8FahaAfhha8Ecefg8Ecl9hmbxikkaATmeazaYfhaazcjdfhhcbhoceh8EaKh8FinaEaofhlaa8Vbbhrcbhoinala8FaofRbbcwtahaofRbbgqVc;:FiGce4cbaqceG9R7arfgr87bbaladfhlaQaocefgofmbka8FaXfh8FcdhoaacdfhaahaXfhha8EceGhlcbh8EalmbxdkkaATmbaocl4h8EazaYfRbbhqcwhoa3hlinalRbbaotaqVhqalcefhlaocwfgoca9hmbkcbhhaEh8FaKhainazcjdfahfRbbhrcwhoaahlinalRbbaotarVhralaAfhlaocwfgoca9hmbkara8E94aq7hqcbhoa8Fhlinalaqao486bbalcefhlaocwfgoca9hmbka8Fadfh8FaacefhaahcefghaA9hmbkkaEclfhEa3clfh3aYclfgYad6mbkaza8AaAcufad2fadz:jjjjb8AaAaOfhOaihxaimbkc9:hoxdkcbc99aPax9RakSEhoxekc9:hokavcjqf8Kjjjjbaok:bsesu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnalaeci9UgrcHf6mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgwce0mbavc;abfcFecjez:kjjjb8Aav9cu83iUav9cu83i8Wav9cu83iyav9cu83iaav9cu83iKav9cu83izav9cu83iwav9cu83ibaialfc9WfhDaicefgiarfhqdndnaeci9pmbaqhexekcmcsawceSEhkcbhxcbhmaqhecbhlcbhoindndnaiRbbgrc;Ve0mbavc;abfaoarcu7gPcl4fcsGcitfgwydlhsawydbhzdndnarcsGgwak9pmbavalaPfcsGcdtfydbaxawEhraxawTgHfhxxekdnaeaD9nmbc9:hoxokdndnawcsSmbcehHamawcetfcWfhrxekaecefhrae8SbbgwcFeGhPdndnawcu9mmbarhexekaecvfheaPcFbGhPcrhwdninar8SbbgHcFbGawtaPVhPaHcu9kmearcefhrawcrfgwc8J9hmbxdkkarcefhekcehHaPce4cbaPceG9R7amfhrkarhmkavc;abfaocitfgwarBdbawasBdlavalcdtfarBdbavc;abfaocefcsGcitfgwazBdbawarBdlaocdfhoaHalfhldnadcd9hmbabar87elabas87edabaz87ebabcofhbxdkabarBdwabasBdlabazBdbabcxfhbxekdnarcpe0mbavalaDarcsGfRbbgwcl4gP9RcsGcdtfydbaxcefgsaPEhravalaw9RcsGcdtfydbasaPTgzfgsawcsGgPEhwaPThPdndnadcd9hmbabaw87elabar87edabax87ebcohHxekabawBdwabarBdlabaxBdbcxhHkavalcdtfaxBdbavc;abfaocitfgOarBdbaOaxBdlavalcefglcsGcdtfarBdbavc;abfaocefcsGcitfgOawBdbaOarBdlavalazfglcsGcdtfawBdbavc;abfaocdfcsGcitfgraxBdbarawBdlaocifhoabaHfhbalaPfhlasaPfhxxekdnaeaD9nmbc9:hoxlkaxcbaeRbbgwEgHarc;:eSgrfhsawcsGhOdndnawcl4gAmbascefhzxekashzavalaA9RcsGcdtfydbhskdndnaOmbazcefhxxekazhxavalaw9RcsGcdtfydbhzkdndnarTmbaecefhrxekaecdfhrae8SbegPcFeGhwdnaPcu9kmbaecofhHawcFbGhwcrhedninar8SbbgPcFbGaetawVhwaPcu9kmearcefhraecrfgec8J9hmbkaHhrxekarcefhrkawce4cbawceG9R7amfgmhHkdndnaAcsSmbarhwxekarcefhwar8SbbgecFeGhPdnaecu9kmbarcvfhsaPcFbGhPcrhedninaw8SbbgrcFbGaetaPVhParcu9kmeawcefhwaecrfgec8J9hmbkashwxekawcefhwkaPce4cbaPceG9R7amfgmhskdndnaOcsSmbawhexekawcefheaw8SbbgrcFeGhPdnarcu9kmbawcvfhzaPcFbGhPcrhrdninae8SbbgwcFbGartaPVhPawcu9kmeaecefhearcrfgrc8J9hmbkazhexekaecefhekaPce4cbaPceG9R7amfgmhzkdndnadcd9hmbabaz87elabas87edabaH87ebcohrxekabazBdwabasBdlabaHBdbcxhrkavc;abfaocitfgwasBdbawaHBdlavalcdtfaHBdbavc;abfaocefcsGcitfgwazBdbawasBdlavalcefglcsGcdtfasBdbavc;abfaocdfcsGcitfgwaHBdbawazBdlavalaATaAcsSVfglcsGcdtfazBdbalaOTaOcsSVfhlaocifhoabarfhbkaocsGhoalcsGhlaicefgiaq6mbkkcbc99aeaDSEhokavc;aef8Kjjjjbaok:clevu8Jjjjjbcz9Rhvdnalaecvf9pmbc9:skdnaiRbbc;:eGc;qeSmbcuskav9cb83iwaicefhoaialfc98fhrdnaeTmbdnadcdSmbcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcdtfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgiBdbalaiBdbawcefgwae9hmbxdkkcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcetfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgi87ebalaiBdbawcefgwae9hmbkkcbc99aoarSEk:Lvoeue99dud99eud99dndnadcl9hmbaeTmeindndnabcdfgd8Sbb:Yab8Sbbgi:Ygl:l:tabcefgv8Sbbgo:Ygr:l:tgwJbb;:9cawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai86bbdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad86bbdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad86bbabclfhbaecufgembxdkkaeTmbindndnabclfgd8Ueb:Yab8Uebgi:Ygl:l:tabcdfgv8Uebgo:Ygr:l:tgwJb;:FSawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai87ebdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad87ebdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad87ebabcwfhbaecufgembkkk:4ioiue99dud99dud99dnaeTmbcbhiabhlindndnal8Uebgv:YgoJ:ji:1Salcof8UebgrciVgw:Y:vgDNJbbbZJbbb:;avcu9kEMgq:lJbbb9p9DTmbaq:Ohkxekcjjjj94hkkalclf8Uebhvalcdf8UebhxalarcefciGcetfak87ebdndnax:YgqaDNJbbbZJbbb:;axcu9kEMgm:lJbbb9p9DTmbam:Ohxxekcjjjj94hxkabaiarciGgkfcd7cetfax87ebdndnav:YgmaDNJbbbZJbbb:;avcu9kEMgP:lJbbb9p9DTmbaP:Ohvxekcjjjj94hvkalarcufciGcetfav87ebdndnawaw2:ZgPaPMaoaoN:taqaqN:tamamN:tgoJbbbbaoJbbbb9GE:raDNJbbbZMgD:lJbbb9p9DTmbaD:Ohrxekcjjjj94hrkalakcetfar87ebalcwfhlaiclfhiaecufgembkkk9mbdnadcd4ae2gdTmbinababydbgecwtcw91:Yaece91cjjj98Gcjjj;8if::NUdbabclfhbadcufgdmbkkk:Tvirud99eudndnadcl9hmbaeTmeindndnabRbbgiabcefgl8Sbbgvabcdfgo8Sbbgrf9R:YJbbuJabcifgwRbbgdce4adVgDcd4aDVgDcl4aDVgD:Z:vgqNJbbbZMgk:lJbbb9p9DTmbak:Ohxxekcjjjj94hxkaoax86bbdndnaraif:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohoxekcjjjj94hokalao86bbdndnavaifar9R:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikabai86bbdndnaDadcetGadceGV:ZaqNJbbbZMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkawad86bbabclfhbaecufgembxdkkaeTmbindndnab8Vebgiabcdfgl8Uebgvabclfgo8Uebgrf9R:YJbFu9habcofgw8Vebgdce4adVgDcd4aDVgDcl4aDVgDcw4aDVgD:Z:vgqNJbbbZMgk:lJbbb9p9DTmbak:Ohxxekcjjjj94hxkaoax87ebdndnaraif:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohoxekcjjjj94hokalao87ebdndnavaifar9R:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikabai87ebdndnaDadcetGadceGV:ZaqNJbbbZMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkawad87ebabcwfhbaecufgembkkk9teiucbcbyd:K:G:cjbgeabcifc98GfgbBd:K:G:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaeczfheaiczfhiadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabkk83dbcj:Gdk8Kbbbbdbbblbbbwbbbbbbbebbbdbbblbbbwbbbbc:K:Gdkl8W:qbb",e="b9H79TebbbeKl9Gbb9Gvuuuuueu9Giuuub9Geueuixkbbebeeddddilve9Weeeviebeoweuecj:Gdkr;Neqo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbdY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVblE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtboK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbrL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949WbwY9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVJ9V29VVbDl79IV9Rbqq:I9Dklbzik94evu8Jjjjjbcz9Rhbcbheincbhdcbhiinabcwfadfaicjuaead4ceGglE86bbaialfhiadcefgdcw9hmbkaeai86b:q:W:cjbaecitab8Piw83i:q:G:cjbaecefgecjd9hmbkk:SBlEud97dur978Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnalTmbcuhoaiRbbgrc;WeGc:Ge9hmbarcsGgwce0mbc9:hoalcufadcd4cbawEgDadfgrcKcaawEgqaraq0Egk6mbaialfgxar9RhodnadTgmmbavaoad;8qbbkaicefhPcj;abad9Uc;WFbGcjdadca0EhsdndndnadTmbaoadfhzcbhHinaeaH9nmdaxaP9RaD6miabaHad2fgOavcjdfasaeaH9RaHasfae6EgAaAcsfgoc9WGgCSEhXaPaDfhQaocl4cifcd4hLavcj;cbfaCcetfhKavcj;cbfaCci2fhYavcj;cbfaCfh8AcbhEaoc;ab6h3incbh5dnawTmbaPaEcd4fRbbh5kcbh8Eavcj;cbfh8Findndndndna5a8Ecet4ciGgoc9:fPdebdkaxaQ9RaC6mwdnaCTmbavcj;cbfa8EaC2faQaC;8qbbkaQaAfhQxdkaCTmeavcj;cbfa8EaC2fcbaC;8kbxekaxaQ9RaL6moaoclVcbawEhraQaLfhocbhidna3mbaxao9Rc;Gb6mbcbhlina8FalfhidndndndndndnaQalco4fRbbgqciGarfPDbedibledibkaipxbbbbbbbbbbbbbbbbpklbxlkaiaopbblaopbbbgaclp:meaapmbzeHdOiAlCvXoQrLgacdp:meaapmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9oghpxiiiiiiiiiiiiiiiip8Jgap5b9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbagRb:q:W:cjbggpsaap5e9cjF;8;4;W;G;ab9:9cU1:Ng8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPahaap9spklbagaoclffa8JRb:q:W:cjbfhoxikaiaopbbwaopbbbgaclp:meaapmbzeHdOiAlCvXoQrLpxssssssssssssssssp9oghpxssssssssssssssssp8Jgap5b9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbagRb:q:W:cjbggpsaap5e9cjF;8;4;W;G;ab9:9cU1:Ng8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPahaap9spklbagaocwffa8JRb:q:W:cjbfhoxdkaiaopbbbpklbaoczfhoxekaiaopbbdaoRbbggcitpbi:q:G:cjbagRb:q:W:cjbggpsaoRbeg8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbagaocdffa8JRb:q:W:cjbfhokdndndndndndnaqcd4ciGarfPDbedibledibkaiczfpxbbbbbbbbbbbbbbbbpklbxlkaiczfaopbblaopbbbgaclp:meaapmbzeHdOiAlCvXoQrLgacdp:meaapmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9oghpxiiiiiiiiiiiiiiiip8Jgap5b9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbagRb:q:W:cjbggpsaap5e9cjF;8;4;W;G;ab9:9cU1:Ng8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPahaap9spklbagaoclffa8JRb:q:W:cjbfhoxikaiczfaopbbwaopbbbgaclp:meaapmbzeHdOiAlCvXoQrLpxssssssssssssssssp9oghpxssssssssssssssssp8Jgap5b9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbagRb:q:W:cjbggpsaap5e9cjF;8;4;W;G;ab9:9cU1:Ng8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPahaap9spklbagaocwffa8JRb:q:W:cjbfhoxdkaiczfaopbbbpklbaoczfhoxekaiczfaopbbdaoRbbggcitpbi:q:G:cjbagRb:q:W:cjbggpsaoRbeg8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbagaocdffa8JRb:q:W:cjbfhokdndndndndndnaqcl4ciGarfPDbedibledibkaicafpxbbbbbbbbbbbbbbbbpklbxlkaicafaopbblaopbbbgaclp:meaapmbzeHdOiAlCvXoQrLgacdp:meaapmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9oghpxiiiiiiiiiiiiiiiip8Jgap5b9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbagRb:q:W:cjbggpsaap5e9cjF;8;4;W;G;ab9:9cU1:Ng8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPahaap9spklbagaoclffa8JRb:q:W:cjbfhoxikaicafaopbbwaopbbbgaclp:meaapmbzeHdOiAlCvXoQrLpxssssssssssssssssp9oghpxssssssssssssssssp8Jgap5b9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbagRb:q:W:cjbggpsaap5e9cjF;8;4;W;G;ab9:9cU1:Ng8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPahaap9spklbagaocwffa8JRb:q:W:cjbfhoxdkaicafaopbbbpklbaoczfhoxekaicafaopbbdaoRbbggcitpbi:q:G:cjbagRb:q:W:cjbggpsaoRbeg8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbagaocdffa8JRb:q:W:cjbfhokdndndndndndnaqco4arfPDbedibledibkaic8Wfpxbbbbbbbbbbbbbbbbpklbxlkaic8Wfaopbblaopbbbgaclp:meaapmbzeHdOiAlCvXoQrLgacdp:meaapmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9oghpxiiiiiiiiiiiiiiiip8Jgap5b9cjF;8;4;W;G;ab9:9cU1:Ngicitpbi:q:G:cjbaiRb:q:W:cjbgipsaap5e9cjF;8;4;W;G;ab9:9cU1:Ngqcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPahaap9spklbaiaoclffaqRb:q:W:cjbfhoxikaic8Wfaopbbwaopbbbgaclp:meaapmbzeHdOiAlCvXoQrLpxssssssssssssssssp9oghpxssssssssssssssssp8Jgap5b9cjF;8;4;W;G;ab9:9cU1:Ngicitpbi:q:G:cjbaiRb:q:W:cjbgipsaap5e9cjF;8;4;W;G;ab9:9cU1:Ngqcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPahaap9spklbaiaocwffaqRb:q:W:cjbfhoxdkaic8Wfaopbbbpklbaoczfhoxekaic8WfaopbbdaoRbbgicitpbi:q:G:cjbaiRb:q:W:cjbgipsaoRbegqcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbaiaocdffaqRb:q:W:cjbfhokalc;abfhialcjefaC0meaihlaxao9Rc;Fb0mbkkdnaiaC9pmbaici4hlinaxao9RcK6mwa8FaifhqdndndndndndnaQaico4fRbbalcoG4ciGarfPDbedibledibkaqpxbbbbbbbbbbbbbbbbpkbbxlkaqaopbblaopbbbgaclp:meaapmbzeHdOiAlCvXoQrLgacdp:meaapmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9oghpxiiiiiiiiiiiiiiiip8Jgap5b9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbagRb:q:W:cjbggpsaap5e9cjF;8;4;W;G;ab9:9cU1:Ng8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPahaap9spkbbagaoclffa8JRb:q:W:cjbfhoxikaqaopbbwaopbbbgaclp:meaapmbzeHdOiAlCvXoQrLpxssssssssssssssssp9oghpxssssssssssssssssp8Jgap5b9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbagRb:q:W:cjbggpsaap5e9cjF;8;4;W;G;ab9:9cU1:Ng8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPahaap9spkbbagaocwffa8JRb:q:W:cjbfhoxdkaqaopbbbpkbbaoczfhoxekaqaopbbdaoRbbggcitpbi:q:G:cjbagRb:q:W:cjbggpsaoRbeg8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpkbbagaocdffa8JRb:q:W:cjbfhokalcdfhlaiczfgiaC6mbkkaohQaoTmoka8FaCfh8Fa8Ecefg8Ecl9hmbkdndndndnawTmbazaEcd4fRbbglciGPlbedwbkaCTmdaXaEfhlavaEfpbdbh8Kcbhoinalavcj;cbfaofpblbg8La8Aaofpblbg8MpmbzeHdOiAlCvXoQrLg8NaKaofpblbgyaYaofpblbg8PpmbzeHdOiAlCvXoQrLgIpmbezHdiOAlvCXorQLgacep9Taapxeeeeeeeeeeeeeeeeghp9op9Hp9rgaa8Kp9Ug8Kp9Abbbaladfgla8Kaaaapmlvorlvorlvorlvorp9Ug8Kp9Abbbaladfgla8KaaaapmwDqkwDqkwDqkwDqkp9Ug8Kp9Abbbaladfgla8KaaaapmxmPsxmPsxmPsxmPsp9Ug8Kp9Abbbaladfgla8Ka8NaIpmwDKYqk8AExm35Ps8E8Fgacep9Taaahp9op9Hp9rgap9Ug8Kp9Abbbaladfgla8Kaaaapmlvorlvorlvorlvorp9Ug8Kp9Abbbaladfgla8KaaaapmwDqkwDqkwDqkwDqkp9Ug8Kp9Abbbaladfgla8KaaaapmxmPsxmPsxmPsxmPsp9Ug8Kp9Abbbaladfgla8Ka8La8MpmwKDYq8AkEx3m5P8Es8Fg8Laya8PpmwKDYq8AkEx3m5P8Es8Fg8MpmbezHdiOAlvCXorQLgacep9Taaahp9op9Hp9rgap9Ug8Kp9Abbbaladfgla8Kaaaapmlvorlvorlvorlvorp9Ug8Kp9Abbbaladfgla8KaaaapmwDqkwDqkwDqkwDqkp9Ug8Kp9Abbbaladfgla8KaaaapmxmPsxmPsxmPsxmPsp9Ug8Kp9Abbbaladfgla8Ka8La8MpmwDKYqk8AExm35Ps8E8Fgacep9Taaahp9op9Hp9rgap9Ughp9Abbbaladfglahaaaapmlvorlvorlvorlvorp9Ughp9AbbbaladfglahaaaapmwDqkwDqkwDqkwDqkp9Ughp9AbbbaladfglahaaaapmxmPsxmPsxmPsxmPsp9Ug8Kp9AbbbaladfhlaoczfgoaC6mbxikkaCTmeaXaEfhlavaEfpbdbh8Kcbhoinalavcj;cbfaofpblbg8La8Aaofpblbg8MpmbzeHdOiAlCvXoQrLg8NaKaofpblbgyaYaofpblbg8PpmbzeHdOiAlCvXoQrLgIpmbezHdiOAlvCXorQLgacep:neaapxebebebebebebebebghp9op:bep9rgaa8Kp:oeg8Kp9Abbbaladfgla8Kaaaapmlvorlvorlvorlvorp:oeg8Kp9Abbbaladfgla8KaaaapmwDqkwDqkwDqkwDqkp:oeg8Kp9Abbbaladfgla8KaaaapmxmPsxmPsxmPsxmPsp:oeg8Kp9Abbbaladfgla8Ka8NaIpmwDKYqk8AExm35Ps8E8Fgacep:neaaahp9op:bep9rgap:oeg8Kp9Abbbaladfgla8Kaaaapmlvorlvorlvorlvorp:oeg8Kp9Abbbaladfgla8KaaaapmwDqkwDqkwDqkwDqkp:oeg8Kp9Abbbaladfgla8KaaaapmxmPsxmPsxmPsxmPsp:oeg8Kp9Abbbaladfgla8Ka8La8MpmwKDYq8AkEx3m5P8Es8Fg8Laya8PpmwKDYq8AkEx3m5P8Es8Fg8MpmbezHdiOAlvCXorQLgacep:neaaahp9op:bep9rgap:oeg8Kp9Abbbaladfgla8Kaaaapmlvorlvorlvorlvorp:oeg8Kp9Abbbaladfgla8KaaaapmwDqkwDqkwDqkwDqkp:oeg8Kp9Abbbaladfgla8KaaaapmxmPsxmPsxmPsxmPsp:oeg8Kp9Abbbaladfgla8Ka8La8MpmwDKYqk8AExm35Ps8E8Fgacep:neaaahp9op:bep9rgap:oeghp9Abbbaladfglahaaaapmlvorlvorlvorlvorp:oeghp9AbbbaladfglahaaaapmwDqkwDqkwDqkwDqkp:oeghp9AbbbaladfglahaaaapmxmPsxmPsxmPsxmPsp:oeg8Kp9AbbbaladfhlaoczfgoaC6mbxdkkaCTmbaXaEfhrcbhocbalcl4gl9Rc8FGhiavaEfpbdbhhinaravcj;cbfaofpblbg8Ka8Aaofpblbg8LpmbzeHdOiAlCvXoQrLg8MaKaofpblbg8NaYaofpblbgypmbzeHdOiAlCvXoQrLg8PpmbezHdiOAlvCXorQLgaaip:Reaaalp:Tep9qgaahp9rghp9Abbbaradfgrahaaaapmlvorlvorlvorlvorp9rghp9AbbbaradfgrahaaaapmwDqkwDqkwDqkwDqkp9rghp9AbbbaradfgrahaaaapmxmPsxmPsxmPsxmPsp9rghp9Abbbaradfgraha8Ma8PpmwDKYqk8AExm35Ps8E8Fgaaip:Reaaalp:Tep9qgap9rghp9Abbbaradfgrahaaaapmlvorlvorlvorlvorp9rghp9AbbbaradfgrahaaaapmwDqkwDqkwDqkwDqkp9rghp9AbbbaradfgrahaaaapmxmPsxmPsxmPsxmPsp9rghp9Abbbaradfgraha8Ka8LpmwKDYq8AkEx3m5P8Es8Fg8Ka8NaypmwKDYq8AkEx3m5P8Es8Fg8LpmbezHdiOAlvCXorQLgaaip:Reaaalp:Tep9qgap9rghp9Abbbaradfgrahaaaapmlvorlvorlvorlvorp9rghp9AbbbaradfgrahaaaapmwDqkwDqkwDqkwDqkp9rghp9AbbbaradfgrahaaaapmxmPsxmPsxmPsxmPsp9rghp9Abbbaradfgraha8Ka8LpmwDKYqk8AExm35Ps8E8Fgaaip:Reaaalp:Tep9qgap9rghp9Abbbaradfgrahaaaapmlvorlvorlvorlvorp9rghp9AbbbaradfgrahaaaapmwDqkwDqkwDqkwDqkp9rghp9AbbbaradfgrahaaaapmxmPsxmPsxmPsxmPsp9rghp9AbbbaradfhraoczfgoaC6mbkkaEclfgEad6mbkdnaXavcjdf9hmbaAad2goTmbaOavcjdfao;8qbbkdnammbavaXaAcufad2fad;8qbbkaAaHfhHc9:hoaQhPaQmbxlkkaeTmbaDalfhrcbhocuhlinaralaD9RglfaD6mdasaeao9Raoasfae6Eaofgoae6mbkaial9RhPkcbc99axaP9RakSEhoxekc9:hokavcj;kbf8Kjjjjbaokwbz:bjjjbkpPesu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnalaeci9UgrcHf6mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgwce0mbavc;abfcFecje;8kbav9cu83iUav9cu83i8Wav9cu83iyav9cu83iaav9cu83iKav9cu83izav9cu83iwav9cu83ibaialfc9WfhDaicefgiarfhqdndnaeci9pmbaqhexekcmcsawceSEhkcbhxcbhmaqhecbhlcbhoindndnaiRbbgrc;Ve0mbavc;abfaoarcu7gPcl4fcsGcitfgwydlhsawydbhzdndnarcsGgwak9pmbavalaPfcsGcdtfydbaxawEhraxawTgHfhxxekdnaeaD9nmbc9:hoxokdndnawcsSmbcehHamawcetfcWfhrxekaecefhrae8SbbgwcFeGhPdndnawcu9mmbarhexekaecvfheaPcFbGhPcrhwdninar8SbbgHcFbGawtaPVhPaHcu9kmearcefhrawcrfgwc8J9hmbxdkkarcefhekcehHaPce4cbaPceG9R7amfhrkarhmkavc;abfaocitfgwarBdbawasBdlavalcdtfarBdbavc;abfaocefcsGcitfgwazBdbawarBdlaocdfhoaHalfhldnadcd9hmbabar87elabas87edabaz87ebabcofhbxdkabarBdwabasBdlabazBdbabcxfhbxekdnarcpe0mbavalaDarcsGfRbbgwcl4gP9RcsGcdtfydbaxcefgsaPEhravalaw9RcsGcdtfydbasaPTgzfgsawcsGgPEhwaPThPdndnadcd9hmbabaw87elabar87edabax87ebcohHxekabawBdwabarBdlabaxBdbcxhHkavalcdtfaxBdbavc;abfaocitfgOarBdbaOaxBdlavalcefglcsGcdtfarBdbavc;abfaocefcsGcitfgOawBdbaOarBdlavalazfglcsGcdtfawBdbavc;abfaocdfcsGcitfgraxBdbarawBdlaocifhoabaHfhbalaPfhlasaPfhxxekdnaeaD9nmbc9:hoxlkaxcbaeRbbgwEgHarc;:eSgrfhsawcsGhOdndnawcl4gAmbascefhzxekashzavalaA9RcsGcdtfydbhskdndnaOmbazcefhxxekazhxavalaw9RcsGcdtfydbhzkdndnarTmbaecefhrxekaecdfhrae8SbegPcFeGhwdnaPcu9kmbaecofhHawcFbGhwcrhedninar8SbbgPcFbGaetawVhwaPcu9kmearcefhraecrfgec8J9hmbkaHhrxekarcefhrkawce4cbawceG9R7amfgmhHkdndnaAcsSmbarhwxekarcefhwar8SbbgecFeGhPdnaecu9kmbarcvfhsaPcFbGhPcrhedninaw8SbbgrcFbGaetaPVhParcu9kmeawcefhwaecrfgec8J9hmbkashwxekawcefhwkaPce4cbaPceG9R7amfgmhskdndnaOcsSmbawhexekawcefheaw8SbbgrcFeGhPdnarcu9kmbawcvfhzaPcFbGhPcrhrdninae8SbbgwcFbGartaPVhPawcu9kmeaecefhearcrfgrc8J9hmbkazhexekaecefhekaPce4cbaPceG9R7amfgmhzkdndnadcd9hmbabaz87elabas87edabaH87ebcohrxekabazBdwabasBdlabaHBdbcxhrkavc;abfaocitfgwasBdbawaHBdlavalcdtfaHBdbavc;abfaocefcsGcitfgwazBdbawasBdlavalcefglcsGcdtfasBdbavc;abfaocdfcsGcitfgwaHBdbawazBdlavalaATaAcsSVfglcsGcdtfazBdbalaOTaOcsSVfhlaocifhoabarfhbkaocsGhoalcsGhlaicefgiaq6mbkkcbc99aeaDSEhokavc;aef8Kjjjjbaok:clevu8Jjjjjbcz9Rhvdnalaecvf9pmbc9:skdnaiRbbc;:eGc;qeSmbcuskav9cb83iwaicefhoaialfc98fhrdnaeTmbdnadcdSmbcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcdtfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgiBdbalaiBdbawcefgwae9hmbxdkkcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcetfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgi87ebalaiBdbawcefgwae9hmbkkcbc99aoarSEk;Toio97eue97aec98Ghedndnadcl9hmbaeTmecbhdinababpbbbgicKp:RecKp:Sep;6eglaicwp:RecKp:Sep;6ealp;Geaiczp:RecKp:Sep;6egvp;Gep;Kep;Legopxbbbbbbbbbbbbbbbbp:2egralpxbbbjbbbjbbbjbbbjgwp9op9rp;Keglpxbb;:9cbb;:9cbb;:9cbb;:9calalp;Meaoaop;Meavaravawp9op9rp;Keglalp;Mep;Kep;Kep;Jep;Negvp;Mepxbbn0bbn0bbn0bbn0grp;KepxFbbbFbbbFbbbFbbbp9oaipxbbbFbbbFbbbFbbbFp9op9qalavp;Mearp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaoavp;Mearp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpkbbabczfhbadclfgdae6mbxdkkaeTmbcbhdinabczfgDaDpbbbgipxbbbbbbFFbbbbbbFFgwp9oabpbbbgoaipmbediwDqkzHOAKY8AEgvczp:Reczp:Sep;6eglaoaipmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eavczp:Sep;6egvp;Gealp;Gep;Kep;Legipxbbbbbbbbbbbbbbbbp:2egralpxbbbjbbbjbbbjbbbjgqp9op9rp;Keglpxb;:FSb;:FSb;:FSb;:FSalalp;Meaiaip;Meavaravaqp9op9rp;Keglalp;Mep;Kep;Kep;Jep;Negvp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbp9oaiavp;Mearp;Keczp:Rep9qgialavp;Mearp;KepxFFbbFFbbFFbbFFbbp9oglpmwDKYqk8AExm35Ps8E8Fp9qpkbbabaoawp9oaialpmbezHdiOAlvCXorQLp9qpkbbabcafhbadclfgdae6mbkkk;2ileue97euo97dnaec98GgiTmbcbheinabcKfpx:ji:1S:ji:1S:ji:1S:ji:1SabpbbbglabczfgvpbbbgopmlvorxmPsCXQL358E8Fgrczp:Segwpxibbbibbbibbbibbbp9qp;6egDp;NegqaDaDp;MegDaDp;KealaopmbediwDqkzHOAKY8AEgDczp:Reczp:Sep;6eglalp;MeaDczp:Sep;6egoaop;Mearczp:Reczp:Sep;6egrarp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jep;Mepxbbn0bbn0bbn0bbn0gDp;KepxFFbbFFbbFFbbFFbbgkp9oaqaop;MeaDp;Keczp:Rep9qgoaqalp;MeaDp;Keakp9oaqarp;MeaDp;Keczp:Rep9qgDpmwDKYqk8AExm35Ps8E8Fglp5eawclp:RegqpEi:T:j83ibavalp5baqpEd:T:j83ibabcwfaoaDpmbezHdiOAlvCXorQLgDp5eaqpEe:T:j83ibabaDp5baqpEb:T:j83ibabcafhbaeclfgeai6mbkkkuee97dnadcd4ae2c98GgeTmbcbhdinababpbbbgicwp:Recwp:Sep;6eaicep:SepxbbjFbbjFbbjFbbjFp9opxbbjZbbjZbbjZbbjZp:Uep;Mepkbbabczfhbadclfgdae6mbkkk:Sodw97euaec98Ghedndnadcl9hmbaeTmecbhdinabpxbbuJbbuJbbuJbbuJabpbbbgicKp:TeglaicYp:Tep9qgvcdp:Teavp9qgvclp:Teavp9qgop;6ep;Negvaicwp:RecKp:SegraipxFbbbFbbbFbbbFbbbgwp9ogDp:Uep;6ep;Mepxbbn0bbn0bbn0bbn0gqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9oavaDarp:Xeaiczp:RecKp:Segip:Uep;6ep;Meaqp;Keawp9op9qavaDaraip:Uep:Xep;6ep;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qavaoalcep:Rep9oalpxebbbebbbebbbebbbp9op9qp;6ep;Meaqp;KecKp:Rep9qpkbbabczfhbadclfgdae6mbxdkkaeTmbcbhdinabczfgkpxbFu9hbFu9hbFu9hbFu9habpbbbglakpbbbgrpmlvorxmPsCXQL358E8Fgvczp:TegqavcHp:Tep9qgicdp:Teaip9qgiclp:Teaip9qgicwp:Teaip9qgop;6ep;NegialarpmbediwDqkzHOAKY8AEgDpxFFbbFFbbFFbbFFbbglp9ograDczp:Segwp:Ueavczp:Reczp:SegDp:Xep;6ep;Mepxbbn0bbn0bbn0bbn0gvp;Kealp9oaiarawaDp:Uep:Xep;6ep;Meavp;Keczp:Rep9qgwaiaoaqcep:Rep9oaqpxebbbebbbebbbebbbp9op9qp;6ep;Meavp;Keczp:ReaiaDarp:Uep;6ep;Meavp;Kealp9op9qgipmwDKYqk8AExm35Ps8E8FpkbbabawaipmbezHdiOAlvCXorQLpkbbabcafhbadclfgdae6mbkkk9teiucbcbydj:G:cjbgeabcifc98GfgbBdj:G:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikkxebcj:Gdklz:zbb",t=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),s=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if(typeof WebAssembly!="object")return{supported:!1};var n=WebAssembly.validate(t)?o(e):o(r),a,i=WebAssembly.instantiate(n,{}).then(function(g){a=g.instance,a.exports.__wasm_call_ctors()});function o(g){for(var x=new Uint8Array(g.length),T=0;T<g.length;++T){var y=g.charCodeAt(T);x[T]=y>96?y-97:y>64?y-39:y+4}for(var v=0,T=0;T<g.length;++T)x[v++]=x[T]<60?s[x[T]]:(x[T]-60)*64+x[++T];return x.buffer.slice(0,v)}function c(g,x,T,y,v,_,A){var M=g.exports.sbrk,N=y+3&-4,R=M(N*v),I=M(_.length),D=new Uint8Array(g.exports.memory.buffer);D.set(_,I);var O=x(R,y,v,I,_.length);if(O==0&&A&&A(R,N,v),T.set(D.subarray(R,R+y*v)),M(R-M(0)),O!=0)throw new Error("Malformed buffer data: "+O)}var l={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp",COLOR:"meshopt_decodeFilterColor"},h={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"},u=[],d=0;function f(g){var x={object:new Worker(g),pending:0,requests:{}};return x.object.onmessage=function(T){var y=T.data;x.pending-=y.count,x.requests[y.id][y.action](y.value),delete x.requests[y.id]},x}function p(g){for(var x="self.ready = WebAssembly.instantiate(new Uint8Array(["+new Uint8Array(n)+"]), {}).then(function(result) { result.instance.exports.__wasm_call_ctors(); return result.instance; });self.onmessage = "+b.name+";"+c.toString()+b.toString(),T=new Blob([x],{type:"text/javascript"}),y=URL.createObjectURL(T),v=u.length;v<g;++v)u[v]=f(y);for(var v=g;v<u.length;++v)u[v].object.postMessage({});u.length=g,URL.revokeObjectURL(y)}function m(g,x,T,y,v){for(var _=u[0],A=1;A<u.length;++A)u[A].pending<_.pending&&(_=u[A]);return new Promise(function(M,N){var R=new Uint8Array(T),I=++d;_.pending+=g,_.requests[I]={resolve:M,reject:N},_.object.postMessage({id:I,count:g,size:x,source:R,mode:y,filter:v},[R.buffer])})}function b(g){var x=g.data;self.ready.then(function(T){if(!x.id)return self.close();try{var y=new Uint8Array(x.count*x.size);c(T,T.exports[x.mode],y,x.count,x.size,x.source,T.exports[x.filter]),self.postMessage({id:x.id,count:x.count,action:"resolve",value:y},[y.buffer])}catch(v){self.postMessage({id:x.id,count:x.count,action:"reject",value:v})}})}return{ready:i,supported:!0,useWorkers:function(g){p(g)},decodeVertexBuffer:function(g,x,T,y,v){c(a,a.exports.meshopt_decodeVertexBuffer,g,x,T,y,a.exports[l[v]])},decodeIndexBuffer:function(g,x,T,y){c(a,a.exports.meshopt_decodeIndexBuffer,g,x,T,y)},decodeIndexSequence:function(g,x,T,y){c(a,a.exports.meshopt_decodeIndexSequence,g,x,T,y)},decodeGltfBuffer:function(g,x,T,y,v,_){c(a,a.exports[h[v]],g,x,T,y,a.exports[l[_]])},decodeGltfBufferAsync:function(g,x,T,y,v){return u.length>0?m(g,x,T,h[y],l[v]):i.then(function(){var _=new Uint8Array(g*x);return c(a,a.exports[h[y]],_,g,x,T,a.exports[l[v]]),_})}}})();var $a=(function(){var r="b9H79Tebbbe;veC9Geueu9Geub9Gbb9Gsuuuuuuuuuuuu99uueu9Gvuuuuub9Gruuuuuuub9Gouuuuuue999Gvuuuuueu9Gzuuuuuuuuuuu99uuuub9Gquuuuuuu99uueu9GPuuuuuuuuuuu99uueu9Gquuuuuuuu99ueu9Gruuuuuu99eu9Gwuuuuuu99ueu9Giuuue999GDuuuuuuuuueu9Gkuuuuuuuu99uub9Gluuuueu9Gluuuub9Giuuueui3EdilvorlwDiqkrxmPszdHObAAbeAlve9Weiiviebeoweuecj:Gdkr:Sdmo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bbz9TW79O9V9Wt9F79P9T9W29P9M95bw8E9TW79O9V9Wt9F79P9T9W29P9M959x9Pt9OcttV9P9I91tW7bD8A9TW79O9V9Wt9F79P9T9W29P9M959x9Pt9O9v9W9K9HtWbqQ9TW79O9V9Wt9F79P9T9W29P9M959t29V9W9W95bkX9TW79O9V9Wt9F79P9T9W29P9M959qV919UWbmQ9TW79O9V9Wt9F79P9T9W29P9M959q9V9P9Ut7bPX9TW79O9V9Wt9F79P9T9W29P9M959t9J9H2WbsP9TW79O9V9Wt9FVW9TW79Obza9TW79O9V9Wt9F9V9Wt9P9T9P96W9wWVtW94SWt9J9O9sW9T9H9WbA59TW79O9V9Wt9F9NW9UWV9HtW9q9V79Pt9P9V9U9sW9T9H9WbCl79IV9RbXDwebcekdKYq:p:1dElbzOk:Q:tekYue99iuQ99eui99Due99xue9:w998Jjjjjbcj;sb9Rgs8Kjjjjbcbhzasc:Cefcbc;Kbz:xjjjb8AdnabaeSmbabaeadcdtz:wjjjb8AkdnamcdGTmbalcrfci4cbyd;y:L:cjbHjjjjbbhHasc:Cefasyd;8egecdtfaHBdbasaecefBd;8ecbhlcbhednadTmbabheadhOinaHaeydbci4fcb86bbaeclfheaOcufgOmbkcbhlabheadhOinaHaeydbgAci4fgCaCRbbgCceaAcrGgAtV86bbaCcu7aA4ceGalfhlaeclfheaOcufgOmbkcualcdtalcFFFFi0Ehekaecbyd;y:L:cjbHjjjjbbhzasc:Cefasyd;8egecdtfazBdbasaecefBd;8ealcd4alfhOcehHinaHgecethHaeaO6mbkcbhXcuaecdtgOaecFFFFi0Ecbyd;y:L:cjbHjjjjbbhHasc:Cefasyd;8egAcdtfaHBdbasaAcefBd;8eaHcFeaOz:xjjjbhQdnadTmbaecufhLcbhKindndnaQabaKcdtfgYydbgAc:v;t;h;Ev2aLGgOcdtfgCydbgHcuSmbceheinazaHcdtfydbaASmdaOaefhHaecefheaQaHaLGgOcdtfgCydbgHcu9hmbkkazaXcdtfaABdbaCaXBdbaXhHaXcefhXkaYaHBdbaKcefgKad9hmbkkaQcbyd;C:L:cjbH:bjjjbbasasyd;8ecufBd;8ekcbh8AcualcefgecdtaecFFFFi0Ecbyd;y:L:cjbHjjjjbbhKasc:Cefasyd;8egecdtfaKBdbasaKBdNeasaecefBd;8ecuadcitadcFFFFe0Ecbyd;y:L:cjbHjjjjbbhEasc:Cefasyd;8egecdtfaEBdbasaEBd:yeasaecefBd;8eascNefabadalcbz:cjjjbcualcdtgealcFFFFi0Eg3cbyd;y:L:cjbHjjjjbbhHasc:Cefasyd;8egOcdtfaHBdbasaOcefBd;8ea3cbyd;y:L:cjbHjjjjbbhXasc:Cefasyd;8egOcdtfaXBdbasaOcefBd;8eaHaXaialavazasc:Cefz:djjjbalcbyd;y:L:cjbHjjjjbbh5asc:Cefasyd;8egOcdtfa5BdbasaOcefBd;8ea3cbyd;y:L:cjbHjjjjbbhOasc:Cefasyd;8egAcdtfaOBdbasaAcefBd;8ea3cbyd;y:L:cjbHjjjjbbhAasc:Cefasyd;8egCcdtfaABdbasaCcefBd;8eaOcFeaez:xjjjbh8EaAcFeaez:xjjjbh8FdnalTmbindnaKa8AgAcefg8AcdtfydbgCaKaAcdtgefydbgOSmbaCaO9RhYaEaOcitfhaa8Faefhha8EaefhLcbhCindndnaaaCcitfydbgQaA9hmbaLaABdbahaABdbxekdnaKaQcdtggfgeclfydbgOaeydbgeSmbaOae9RhOaEaecitfheinaeydbaASmdaecwfheaOcufgOmbkka8FagfgeaAaQaeydbcuSEBdbaLaQaAaLydbcuSEBdbkaCcefgCaY9hmbkka8Aal9hmbkaHhOaXhAa8EhQa8FhCcbheindndnaeaOydbgL9hmbdnaeaAydbgL9hmbaQydbhLdnaCydbgYcu9hmbaLcu9hmba5aefcb86bbxikdnaYcuSmbaLcuSmbaeaYSmbaHaYcdtfydbaHaLcdtfydb9hmba5aefcd86bbxika5aefhadnaeaYSmbaeaLSmbaace86bbxikaacv86bbxdkdnaeaXaLcdtgYfydb9hmbdnaCydbgacuSmbaeaaSmbaQydbggcuSmbaeagSmba8FaYfydbghcuSmbahaLSmba8EaYfydbgYcuSmbaYaLSmbaHaacdtfydbgLaHaYcdtfydb9hmbaLaHagcdtfydbgYSmbaYaHahcdtfydb9hmba5aefcd86bbxika5aefcv86bbxdka5aefcv86bbxeka5aefa5aLfRbb86bbkaOclfhOaAclfhAaQclfhQaCclfhCalaecefge9hmbkdnamcaGTmbcbh8Jindndna5a8Jfg8KRbbg8Lc9:fPlbeebekdndndnaHa8Jcdtfydbgea8J9hmbcbhYcbh8MaqTmednazTmbcbh8Ma8JheinaqazaecdtgefydbfRbbce4a8MVceGh8MaXaefydbgea8J9hmbxikkcbh8Ma8JheinaqaefRbbce4a8MVceGh8MaXaecdtfydbgea8J9hmbxdkka5aefRbbhexeka8JheindnaKaecdtg8AfgeclfydbgOaeydbgeSmbaOae9RhgaEaecitfhhaHa8AfhacbhLinahaLcitfydbgQhednindnaKaecdtgCfgeclfydbgOaeydbgeSmbaOae9RhOaEaecitfheaaydbhAdninaHaeydbcdtfydbaASmeaecwfheaOcufgOTmdxbkkcbhexdkaXaCfydbgeaQ9hmbkcehekaYaeVhYaLcefgLag9hmbkkaXa8Afydbgea8J9hmbka8LclciaYceGEa8MEheka8Kae86bbka8Jcefg8Jal9hmbkkdnaqTmbdndnazTmbazheaHhOalhAindnaqaeydbfRbbceGTmba5aOydbfcv86bbkaeclfheaOclfhOaAcufgAmbxdkkaqheaHhOalhAindnaeRbbceGTmba5aOydbfcv86bbkaecefheaOclfhOaAcufgAmbkkaHhealhAa5hOindna5aeydbfRbbcv9hmbaOcv86bbkaeclfheaOcefhOaAcufgAmbkkamceGTmba5healhOindndnaeRbbcufPlbeebekaecv86bbkaecefheaOcufgOmbkkcbh8Ncualcx2alc;v:Q;v:Qe0Ecbyd;y:L:cjbHjjjjbbh8Kasc:Cefasyd;8egecdtfa8KBdbasaecefBd;8eascbBd:qeas9cb83i1ea8Kaialavazasc1efz:ejjjbhydndnaDmbcbh8PcbhaxekcbhaawhecbhOindnaeIdbJbbbb9ETmbasaacdtfaOBdbaacefhakaeclfheaDaOcefgO9hmbkcuaaal2gecdtaecFFFFi0Ecbyd;y:L:cjbHjjjjbbh8Pasc:Cefasyd;8egecdtfa8PBdbasaecefBd;8ealTmbdnaambcbhaxekarcd4hgdnazTmbaacdthhcbhLa8PhYinaoazaLcdtfydbag2cdtfhQasheaYhOaahAinaOaQaeydbcdtgCfIdbawaCfIdbNUdbaeclfheaOclfhOaAcufgAmbkaYahfhYaLcefgLal9hmbxdkkaacdthhcbhLa8PhYinaoaLag2cdtfhQasheaYhOaahAinaOaQaeydbcdtgCfIdbawaCfIdbNUdbaeclfheaOclfhOaAcufgAmbkaYahfhYaLcefgLal9hmbkkcualc8S2gOalc;D;O;f8U0EgCcbyd;y:L:cjbHjjjjbbheasc:Cefasyd;8egAcdtfaeBdbasaAcefBd;8eaecbaOz:xjjjbhIcbh8RcbhgdnaaTmbcbh8NaCcbyd;y:L:cjbHjjjjbbhgasc:Cefasyd;8egecdtfagBdbasaecefBd;8eagcbaOz:xjjjb8Acuaaal2gecltgOaecFFFFb0Ecbyd;y:L:cjbHjjjjbbh8Rasc:Cefasyd;8egecdtfa8RBdbasaecefBd;8ea8RcbaOz:xjjjb8AamcjjjjdGTmbcualcltgealcFFFFb0Ecbyd;y:L:cjbHjjjjbbh8Nasc:Cefasyd;8egOcdtfa8NBdbasaOcefBd;8ea8Ncbaez:xjjjb8AkdnadTmbcbhQabhOina8KaOclfydbgLcx2fgeIdba8KaOydbgYcx2fgAIdbg8S:tgRa8KaOcwfydbghcx2fgCIdlaAIdlg8U:tg8VNaeIdla8U:tg8WaCIdba8S:tg8XN:tg8Ya8YNa8WaCIdwaAIdwg8Z:tg80NaeIdwa8Z:tg8Wa8VN:tg81a81Na8Wa8XNaRa80N:tg80a80NMMg8V:rhBa8Yh8Xa80h8Wa81hRdna8VJbbbb9EgATmba8YaB:vh8Xa80aB:vh8Wa81aB:vhRkaIaHaYcdtfydbgCc8S2fgeaRaB:rg8VaRNNg83aeIdbMUdbaea8Wa8Va8WNgUNg85aeIdlMUdlaea8Xa8Va8XNg86Ng87aeIdwMUdwaeaRaUNgUaeIdxMUdxaea86aRNg88aeIdzMUdzaea8Wa86Ng89aeIdCMUdCaeaRa8Va8Xa8ZNaRa8SNa8Ua8WNMM:mg8:Ng86NgRaeIdKMUdKaea8Wa86Ng8WaeId3MUd3aea8Xa86Ng8XaeIdaMUdaaea86a8:Ng86aeId8KMUd8Kaea8VaeIdyMUdyaIaHaLcdtfydbgLc8S2fgea83aeIdbMUdbaea85aeIdlMUdlaea87aeIdwMUdwaeaUaeIdxMUdxaea88aeIdzMUdzaea89aeIdCMUdCaeaRaeIdKMUdKaea8WaeId3MUd3aea8XaeIdaMUdaaea86aeId8KMUd8Kaea8VaeIdyMUdyaIaHahcdtfydbgYc8S2fgea83aeIdbMUdbaea85aeIdlMUdlaea87aeIdwMUdwaeaUaeIdxMUdxaea88aeIdzMUdzaea89aeIdCMUdCaeaRaeIdKMUdKaea8WaeId3MUd3aea8XaeIdaMUdaaea86aeId8KMUd8Kaea8VaeIdyMUdydna8NTmbdnaATmba8YaB:vh8Ya80aB:vh80a81aB:vh81ka8NaCcltfgeaBJbbbZNgRa80Ng8VaeIdlMUdlaeaRa8YNg8WaeIdwMUdwaeaRa81Ng8XaeIdbMUdbaeaRa8S:ma81Na8Ua80N:ta8Za8YN:tNgRaeIdxMUdxa8NaLcltfgea8VaeIdlMUdlaea8WaeIdwMUdwaea8XaeIdbMUdbaeaRaeIdxMUdxa8NaYcltfgea8VaeIdlMUdlaea8WaeIdwMUdwaea8XaeIdbMUdbaeaRaeIdxMUdxkaOcxfhOaQcifgQad6mbkkdnalTmbJq;x8J88J;n;m;m89J:v:;;w8ZamczGEamc;abGEh80cbhOaHhCazhQaIhea8KhAindnaOaCydb9hmbaOhLdnazTmbaQydbhLka80hRdnaqTmbJbbjZa80aqaLfRbbclGEhRkaecxfgLaLIdbJbbbbMUdbaeczfgLaLIdbJbbbbMUdbaecCfgLaLIdbJbbbbMUdbaeaRaecyfgLIdbg8YNgRaeIdbMUdbaeclfgYaRaYIdbMUdbaecwfgYaRaYIdbMUdbaecKfgYaYIdbaAIdbg8WaRN:tUdbaAcwfIdbh8Vaec3fgYaYIdbaRaAclfIdbg8XN:tUdbaecafgYaYIdbaRa8VN:tUdbaec8KfgYIdbh81aLa8YaRMUdbaYa81aRa8Va8VNa8Wa8WNa8Xa8XNMMNMUdbkaCclfhCaQclfhQaec8SfheaAcxfhAalaOcefgO9hmbkkdnadTmbcbh8AabhLinaba8AcdtfhYcbheindna5aLaefydbgCfRbbgOTmba5aYaec:G:G:cjbfydbcdtfydbgQfRbbcFeGgATmbdnaOclSghmbaOci6mbaAclSmbaAcd0mekdnaOcd0mba8EaCcdtfydbaQ9hmekdnaAcd0mba8FaQcdtfydbaC9hmekdndnahmbaAcl9hmekaOciSmeaAciSmekJbbbZJbbbZJbbacaAcdSEaOcdSEhUdna8KaYaec:K:G:cjbfydbcdtfydbcx2fgOIdwa8KaCcx2fgAIdwg86:tg8Sa8KaQcx2fghIdwa86:tg8Xa8XNahIdbaAIdbg8U:tg80a80NahIdlaAIdlg8Z:tg8Va8VNMMg81Na8Xa8Sa8XNaOIdba8U:tg83a80Na8VaOIdla8Z:tg85NMMg8WN:tg8Ya8YNa83a81Na80a8WN:tgRaRNa85a81Na8Va8WN:tg8Wa8WNMMgBJbbbb9ETmba8YaB:rgB:vh8Ya8WaB:vh8WaRaB:vhRkaUa81:rNgBa8Ya86NaRa8UNa8Za8WNMM:mg81Ng87a81Nh88a80a85Na8Va83N:tg81a81Na8Va8SNa8Xa85N:tg8Va8VNa8Xa83Na80a8SN:tg8Xa8XNMMg83:rh80a8Ya87Nh85a8Wa87Nh89aRa87Nh87a8WaBa8YNg8SNh8:a8SaRNhZaRaBa8WNgnNhca8Ya8SNh8Ya8WanNh8WaRaBaRNNh8Sdna83Jbbbb9ETmba81a80:vh81a8Xa80:vh8Xa8Va80:vh8VkaIaHaCcdtfydbc8S2fgOaOIdba8Sa8VaUa80:rNgRa8VNNMg80MUdbaOa8Wa8XaRa8XNg8SNMg83aOIdlMUdlaOa8Ya81aRa81Ng8WNMg8YaOIdwMUdwaOaca8Va8SNMg8SaOIdxMUdxaOaZa8Wa8VNMgUaOIdzMUdzaOa8:a8Xa8WNMg8WaOIdCMUdCaOa87a8VaRa81a86Na8Va8UNa8Za8XNMMg86:mNgRNMg8VaOIdKMUdKaOa89a8XaRNMg8XaOId3MUd3aOa85a81aRNMg81aOIdaMUdaaOa88a86aRN:tgRaOId8KMUd8KaOaBaOIdyMUdyaIaHaQcdtfydbc8S2fgOa80aOIdbMUdbaOa83aOIdlMUdlaOa8YaOIdwMUdwaOa8SaOIdxMUdxaOaUaOIdzMUdzaOa8WaOIdCMUdCaOa8VaOIdKMUdKaOa8XaOId3MUd3aOa81aOIdaMUdaaOaRaOId8KMUd8KaOaBaOIdyMUdykaeclfgecx9hmbkaLcxfhLa8Acifg8Aad6mbkkdnamcjeGTmbalTmbcbh9cindnaKa9cgecdtgOfydbghaKaecefg9ccdtfydbg8M9pmba8Kaecx2fhDaIaHaOfydbgCc8S2fh8AindnaHaEahcitfgeydbgLcdtfydbg8JaC0mbaeydlh8LcuhAaLheindnaKaecdtgYfgeclfydbgOaeydbgeSmbaOae9RhOaEaecitfheindnaHaeydbcdtfydbaC9hmbaAcu9hhQaLhAaQmbaeclfydbhAkaecwfheaOcufgOmbkkaXaYfydbgeaL9hmbkaAaLSmbaAcuSmba8KaLcx2fgeIdbaDIdbg81:tgRa8Ka8Lcx2fgOIdlaDIdlg80:tg8XNaeIdla80:tg8VaOIdba81:tg8YN:tg86a8KaAcx2fgAIdba81:tg8Za8VNaAIdla80:tg83aRN:tg8SNa8VaOIdwaDIdwgB:tg8UNaeIdwaB:tg8Wa8XN:tg85a83a8WNaAIdwaB:tg87a8VN:tgUNa8Wa8YNaRa8UN:tg88a87aRNa8Za8WN:tg89NMMa86a86Na85a85Na88a88NMM:rJ:A:z9z:;Na8Sa8SNaUaUNa89a89NMM:rN9Gmbdna8Ua8Wa8WNaRaRNa8Va8VNMMg8SNa8Wa8Ua8WNa8YaRNa8Va8XNMMg86N:tg8Ua8UNa8Ya8SNaRa86N:tg8Ya8YNa8Xa8SNa8Va86N:tg86a86NMMg8XJbbbb9ETmba8Ua8X:rg8X:vh8Ua86a8X:vh86a8Ya8X:vh8Yka8S:rg8Xa8UaBNa8Ya81Na80a86NMM:mgUNg85aUNhUa8Ua85Nh88a86a85Nh89a8Ya85Nh8:a86a8Xa8UNg85NhZa85a8YNhna8Ya8Xa86NgcNhJa8Ua85Nh8Ua86acNh86a8Ya8Xa8YNNh85dna87a8SNa8Wa87a8WNa8ZaRNa8Va83NMMg8YN:tg8Wa8WNa8Za8SNaRa8YN:tgRaRNa83a8SNa8Va8YN:tg8Va8VNMMg8YJbbbb9ETmba8Wa8Y:rg8Y:vh8Wa8Va8Y:vh8VaRa8Y:vhRka8Aa8AIdba85aRa8XaRNNMg8SMUdba8Aa86a8Va8Xa8VNg8ZNMg86a8AIdlMUdla8Aa8Ua8Wa8Xa8WNg8YNMg8Ua8AIdwMUdwa8AaJaRa8ZNMg8Za8AIdxMUdxa8Aana8YaRNMg83a8AIdzMUdza8AaZa8Va8YNMg85a8AIdCMUdCa8Aa8:aRa8Xa8WaBNaRa81Na80a8VNMMg81:mNg8YNMgRa8AIdKMUdKa8Aa89a8Va8YNMg8Va8AId3MUd3a8Aa88a8Wa8YNMg8Wa8AIdaMUdaa8AaUa81a8YN:tg8Ya8AId8KMUd8Ka8Aa8Xa8XMg8Xa8AIdyMUdyaIa8Jc8S2fgea8SaeIdbMUdbaea86aeIdlMUdlaea8UaeIdwMUdwaea8ZaeIdxMUdxaea83aeIdzMUdzaea85aeIdCMUdCaeaRaeIdKMUdKaea8VaeId3MUd3aea8WaeIdaMUdaaea8YaeId8KMUd8Kaea8XaeIdyMUdykahcefgha8M9hmbkka9cal9hmbkkdnadTmbaaTmbcbhYinJbbbbh80a8KabaYcdtfgeclfydbgLcx2fgOIdwa8Kaeydbghcx2fgAIdwg8Z:tg8Va8VNaOIdbaAIdbg83:tg8Wa8WNaOIdlaAIdlg85:tg8Xa8XNMMg8Sa8Kaecwfydbg8Acx2fgeIdwa8Z:tg8YNa8Va8YNa8WaeIdba83:tg81Na8XaeIdla85:tgBNMMgRa8VN:tJbbbbJbbjZa8Sa8Ya8YNa81a81NaBaBNMMg8UNaRaRN:tg86:va86Jbbbb9BEg86Nh88a8Ua8VNaRa8YN:ta86Nh89a8SaBNaRa8XN:ta86Nh8:a8Ua8XNaRaBN:ta86NhZa8Sa81NaRa8WN:ta86Nhna8Ua8WNaRa81N:ta86Nhca8WaBNa8Xa81N:tgRaRNa8Xa8YNa8VaBN:tgRaRNa8Va81Na8Wa8YN:tgRaRNMM:rJbbbZNhRa8Pahaa2g8JcdtfhOa8Pa8Aaa2g8McdtfhAa8PaLaa2gDcdtfhCa8Z:mhJa85:mh9ea83:mhTascjdfheaahQJbbbbhBJbbbbh86Jbbbbh8SJbbbbh8UJbbbbh8ZJbbbbh83Jbbbbh85Jbbbbh87JbbbbhUinaecwfaRa89aCIdbaOIdbg8Y:tg8XNa88aAIdba8Y:tg81NMg8VNUdbaeclfaRaZa8XNa8:a81NMg8WNUdbaeaRaca8XNana81NMg8XNUdbaecxfaRaJa8VNa9ea8WNa8YaTa8XNMMMg8YNUdbaRa8Va8WNNa8ZMh8ZaRa8Va8XNNa8UMh8UaRa8Wa8XNNa8SMh8SaRa8Ya8YNNaUMhUaRa8Va8YNNa87Mh87aRa8Wa8YNNa85Mh85aRa8Xa8YNNa83Mh83aRa8Va8VNNa86Mh86aRa8Wa8WNNaBMhBaRa8Xa8XNNa80Mh80aOclfhOaCclfhCaAclfhAaeczfheaQcufgQmbkagahc8S2fgea80aeIdbMUdbaeaBaeIdlMUdlaea86aeIdwMUdwaea8SaeIdxMUdxaea8UaeIdzMUdzaea8ZaeIdCMUdCaea83aeIdKMUdKaea85aeId3MUd3aea87aeIdaMUdaaeaUaeId8KMUd8KaeaRaeIdyMUdyagaLc8S2fgea80aeIdbMUdbaeaBaeIdlMUdlaea86aeIdwMUdwaea8SaeIdxMUdxaea8UaeIdzMUdzaea8ZaeIdCMUdCaea83aeIdKMUdKaea85aeId3MUd3aea87aeIdaMUdaaeaUaeId8KMUd8KaeaRaeIdyMUdyaga8Ac8S2fgea80aeIdbMUdbaeaBaeIdlMUdlaea86aeIdwMUdwaea8SaeIdxMUdxaea8UaeIdzMUdzaea8ZaeIdCMUdCaea83aeIdKMUdKaea85aeId3MUd3aea87aeIdaMUdaaeaUaeId8KMUd8KaeaRaeIdyMUdya8Ra8JcltfhLcbhOaahCinaLaOfgeascjdfaOfgAIdbaeIdbMUdbaeclfgQaAclfIdbaQIdbMUdbaecwfgQaAcwfIdbaQIdbMUdbaecxfgeaAcxfIdbaeIdbMUdbaOczfhOaCcufgCmbka8RaDcltfhLcbhOaahCinaLaOfgeascjdfaOfgAIdbaeIdbMUdbaeclfgQaAclfIdbaQIdbMUdbaecwfgQaAcwfIdbaQIdbMUdbaecxfgeaAcxfIdbaeIdbMUdbaOczfhOaCcufgCmbka8Ra8McltfhLcbhOaahCinaLaOfgeascjdfaOfgAIdbaeIdbMUdbaeclfgQaAclfIdbaQIdbMUdbaecwfgQaAcwfIdbaQIdbMUdbaecxfgeaAcxfIdbaeIdbMUdbaOczfhOaCcufgCmbkaYcifgYad6mbkkcbhAdndnamcwGgSmbJbbbbh86cbh9hcbh9icbh6xekcbh9ha3cbyd;y:L:cjbHjjjjbbh6asc:Cefasyd;8egecdtfa6BdbasaecefBd;8ecua6alabadaHz:fjjjbgCcltaCcjjjjiGEcbyd;y:L:cjbHjjjjbbh9iasc:Cefasyd;8egecdtfa9iBdbasaecefBd;8ea9iaCa6a8Kalz:gjjjbJFFuuh86aCTmba9iheaChOinaeIdbgRa86a86aR9EEh86aeclfheaOcufgOmbkaCh9hkdnalTmbaKclfheaKydbhCa5hOalhQcbhAincbaeydbgLaC9RaORbbcpeGEaAfhAaOcefhOaeclfheaLhCaQcufgQmbkaAce4hAkcuadaA9Rcifg9kcx2a9kc;v:Q;v:Qe0Ecbyd;y:L:cjbHjjjjbbh0asc:Cefasyd;8egecdtfa0BdbasaecefBd;8ecua9kcdta9kcFFFFi0Ecbyd;y:L:cjbHjjjjbbh9masc:Cefasyd;8egecdtfa9mBdbasaecefBd;8ea3cbyd;y:L:cjbHjjjjbbh9nasc:Cefasyd;8egecdtfa9nBdbasaecefBd;8ealcbyd;y:L:cjbHjjjjbbh9oasc:Cefasyd;8egecdtfa9oBdbasaecefBd;8eaxaxNayJbbjZamclGEg9pa9pN:vh87JbbbbhUdnadak9nmbdna9kci6mbamcjdGh9qaaclth9ra0cwfh9sJbbbbh85JbbbbhUinascNefabadalaHz:cjjjbabh8Acbh3cbh9tinaba9tcdtfh8McbheindnaHa8AaefydbgAcdtghfydbgCaHa8Maec:W:G:cjbfydbcdtfydbgOcdtg8JfydbgQSmba5aOfRbbgYco2a5aAfRbbgLfRb;a:G:cjbg8LaLco2aYfgDRb;a:G:cjbg9cVcFeGTmbdnaQaC9nmbaDRb;W:G:cjbcFeGmekdnaLcufcFeGce0mbaYTmba8EahfydbaO9hmekdnaLTmbaYcufcFeGce0mba8Fa8JfydbaA9hmeka0a3cx2fgCaOaAa9ccFeGgQEBdlaCaAaOaQEBdbaCaQa8LGcb9hBdwa3cefh3kaeclfgecx9hmbkdna9tcifg9tad9pmba8Acxfh8Aa3cifa9k9nmekka3TmdcbhDinaIaHa0aDcx2fghydbgLcdtgCfydbg8Jc8S2fgeIdwa8KahydlgYcx2fgOIdwg8WNaeIdzaOIdbg8XNaeIdaMgRaRMMa8WNaeIdlaOIdlg8YNaeIdCa8WNaeId3MgRaRMMa8YNaeIdba8XNaeIdxa8YNaeIdKMgRaRMMa8XNaeId8KMMM:lhRJbbbbJbbjZaeIdyg8V:va8VJbbbb9BEh8Vdndnahydwg8MmbJFFuuhBxekJbbbbJbbjZaIaHaYcdtfydbc8S2fgeIdyg81:va81Jbbbb9BEaeIdwa8KaLcx2fgOIdwg81NaeIdzaOIdbg80NaeIdaMgBaBMMa81NaeIdlaOIdlgBNaeIdCa81NaeId3Mg81a81MMaBNaeIdba80NaeIdxaBNaeIdKMg81a81MMa80NaeId8KMMM:lNhBka8VaRNh80dnaaTmbagaLc8S2fgAIdwa8WNaAIdza8XNaAIdaMgRaRMMa8WNaAIdla8YNaAIdCa8WNaAId3MgRaRMMa8YNaAIdba8XNaAIdxa8YNaAIdKMgRaRMMa8XNaAId8KMMMhRa8PaYaa2gQcdtfhOa8RaLaa2g8AcltfheaAIdyh81aahAinaOIdbg8Va8Va81NaecxfIdba8WaecwfIdbNa8XaeIdbNa8YaeclfIdbNMMMg8Va8VM:tNaRMhRaOclfhOaeczfheaAcufgAmbkaR:lgRa81aRa819DEaRa9qEh8Sdndna8MmbJbbbbhRxekagaYc8S2fgAIdwa8KaLcx2fgeIdwg8WNaAIdzaeIdbg8XNaAIdaMgRaRMMa8WNaAIdlaeIdlg8YNaAIdCa8WNaAId3MgRaRMMa8YNaAIdba8XNaAIdxa8YNaAIdKMgRaRMMa8XNaAId8KMMMhRa8Pa8AcdtfhOa8RaQcltfheaAIdyh81aahAinaOIdbg8Va8Va81NaecxfIdba8WaecwfIdbNa8XaeIdbNa8YaeclfIdbNMMMg8Va8VM:tNaRMhRaOclfhOaeczfheaAcufgAmbkaR:lgRa81aRa819DEaRa9qEhRka80a8SMh80aBaRMhBdndndna5aLfRbbc9:fPibeedkdna8Fa8Ea8EaCfydbaYSEaXaCfydbgQcdtfydbgCcu9hmbaXaYcdtfydbhCkagaQc8S2fgAIdwa8KaCcx2fgeIdwg8WNaAIdzaeIdbg8XNaAIdaMgRaRMMa8WNaAIdlaeIdlg8YNaAIdCa8WNaAId3MgRaRMMa8YNaAIdba8XNaAIdxa8YNaAIdKMgRaRMMa8XNaAId8KMMMhRa8PaCaa2g8AcdtfhOa8RaQaa2g8JcltfheaAIdyh81aahAinaOIdbg8Va8Va81NaecxfIdba8WaecwfIdbNa8XaeIdbNa8YaeclfIdbNMMMg8Va8VM:tNaRMhRaOclfhOaeczfheaAcufgAmbkaR:lgRa81aRa819DEaRa9qEh8Sdndna8MmbJbbbbhRxekagaCc8S2fgAIdwa8KaQcx2fgeIdwg8WNaAIdzaeIdbg8XNaAIdaMgRaRMMa8WNaAIdlaeIdlg8YNaAIdCa8WNaAId3MgRaRMMa8YNaAIdba8XNaAIdxa8YNaAIdKMgRaRMMa8XNaAId8KMMMhRa8Pa8JcdtfhOa8Ra8AcltfheaAIdyh81aahAinaOIdbg8Va8Va81NaecxfIdba8WaecwfIdbNa8XaeIdbNa8YaeclfIdbNMMMg8Va8VM:tNaRMhRaOclfhOaeczfheaAcufgAmbkaR:lgRa81aRa819DEaRa9qEhRka80a8SMh80aBaRMhBxdkaXaCfydbgCaLSmbaHaYcdtfydbh8Aindndna8EaCcdtgQfydbgecuSmbaHaecdtfydba8ASmekdna8FaQfydbgecuSmbaHaecdtfydba8ASmekaYhekagaCc8S2fgAIdwa8Kaecx2fgOIdwg8WNaAIdzaOIdbg8XNaAIdaMgRaRMMa8WNaAIdlaOIdlg8YNaAIdCa8WNaAId3MgRaRMMa8YNaAIdba8XNaAIdxa8YNaAIdKMgRaRMMa8XNaAId8KMMMhRa8Paeaa2cdtfhOa8RaCaa2cltfheaAIdyh81aahAinaOIdbg8Va8Va81NaecxfIdba8WaecwfIdbNa8XaeIdbNa8YaeclfIdbNMMMg8Va8VM:tNaRMhRaOclfhOaeczfheaAcufgAmbka80aR:lgRa81aRa819DEaRa9qEMh80aXaQfydbgCaL9hmbkkdna5aYfRbbgeciSmbaecl9hmeka8MTmbaXaYcdtfydbgCaYSmbindndna8EaCcdtgQfydbgecuSmbaHaecdtfydba8JSmekdna8FaQfydbgecuSmbaHaecdtfydba8JSmekaLhekagaCc8S2fgAIdwa8Kaecx2fgOIdwg8WNaAIdzaOIdbg8XNaAIdaMgRaRMMa8WNaAIdlaOIdlg8YNaAIdCa8WNaAId3MgRaRMMa8YNaAIdba8XNaAIdxa8YNaAIdKMgRaRMMa8XNaAId8KMMMhRa8Paeaa2cdtfhOa8RaCaa2cltfheaAIdyh81aahAinaOIdbg8Va8Va81NaecxfIdba8WaecwfIdbNa8XaeIdbNa8YaeclfIdbNMMMg8Va8VM:tNaRMhRaOclfhOaeczfheaAcufgAmbkaBaR:lgRa81aRa819DEaRa9qEMhBaXaQfydbgCaY9hmbkkahaBa80aBa809DgeEUdwahaLaYaea8Mcb9hGgeEBdlahaYaLaeEBdbaDcefgDa39hmbkascjdfcbcj;qbz:xjjjb8Aa9shea3hOinascjdfaeydbcA4cF8FGgAcFAaAcFA6EcdtfgAaAydbcefBdbaecxfheaOcufgOmbkcbhecbhOinascjdfaefgAydbhCaAaOBdbaCaOfhOaeclfgecj;qb9hmbkcbhea9shOinascjdfaOydbcA4cF8FGgAcFAaAcFA6EcdtfgAaAydbgAcefBdba9maAcdtfaeBdbaOcxfhOa3aecefge9hmbkadak9RgAci9Uh9udnalTmbcbhea9nhOinaOaeBdbaOclfhOalaecefge9hmbkkcbh9va9ocbalz:xjjjbh9caAcO9Uh9wa9uce4h9tcbh8Lcbh8Mdnina0a9ma8Mcdtfydbcx2fg8JIdwgRa879Emea8La9u9pmeJFFuuh8Vdna9ta39pmba0a9ma9tcdtfydbcx2fIdwJbb;aZNh8VkdnaRa8V9ETmbaRaU9ETmba8La9w0mdkdna9caHa8JydlgDcdtg9xfg8AydbgAfg9yRbba9caHa8Jydbghcdtg9zfydbgefg9ARbbVmba5ahfRbbh9BdndnaKaecdtfgOclfydbgCaOydbgOSmbaCaO9RhCa8KaAcx2fhLa8Kaecx2fhYaEaOcitfheindna9naeydbcdtfydbgOaASmba9naeclfydbcdtfydbgQaASmbaOaQSmba8KaQcx2fgQIdba8KaOcx2fgOIdbg8W:tgRaYIdlaOIdlg8X:tg80NaQIdla8X:tg8VaYIdba8W:tgBN:tg8YaRaLIdla8X:tg8SNa8VaLIdba8W:tg8UN:tg8XNa8VaYIdwaOIdwg81:tg8ZNaQIdwa81:tg8Wa80N:tg80a8VaLIdwa81:tg83Na8Wa8SN:tg8VNa8WaBNaRa8ZN:tg81a8Wa8UNaRa83N:tgRNMMa8Ya8YNa80a80Na81a81NMMa8Xa8XNa8Va8VNaRaRNMMN:rJbbj8:N9FmikaecwfheaCcufgCmbkkdndna9Bc99fcFeGce0mba9na9zfaDBdbaXa9zfydbgeahSmeina8AydbhAdndna8EaecdtgOfydbgecuSmbaHaecdtfydbaASmekdna8FaOfydbgecuSmbaHaecdtfydbaASmekaDheka9naOfaeBdbaXaOfydbgeah9hmbxdkkdndna9BcFeGcdSmbaDhexekdna8Fa8Ea8Ea9zfydbaDSEaXa9zfydbghcdtfydbgecu9hmbaXa9xfydbheka9na9zfaDBdbka9nahcdtfaeBdbka9Ace86bba9yce86bba8JIdwgRaUaUaR9DEhUa9vcefh9vcecda9BcFeGceSEa8Lfh8Lxeka9tcefh9tka8Mcefg8Ma39hmbkka9vTmddnalTmbcbhLcbhhindna9nahcdtgefydbgAahSmbaHaAcdtfydbh8AdnahaHaefydb9hg8JmbaIa8Ac8S2fgeaIahc8S2fgOIdbaeIdbMUdbaeaOIdlaeIdlMUdlaeaOIdwaeIdwMUdwaeaOIdxaeIdxMUdxaeaOIdzaeIdzMUdzaeaOIdCaeIdCMUdCaeaOIdKaeIdKMUdKaeaOId3aeId3MUd3aeaOIdaaeIdaMUdaaeaOId8KaeId8KMUd8KaeaOIdyaeIdyMUdya8NTmba8Na8Acltfgea8NahcltfgOIdbaeIdbMUdbaeaOIdlaeIdlMUdlaeaOIdwaeIdwMUdwaeaOIdxaeIdxMUdxkaaTmbagaAc8S2fgeagahc8S2g8MfgOIdbaeIdbMUdbaeaOIdlaeIdlMUdlaeaOIdwaeIdwMUdwaeaOIdxaeIdxMUdxaeaOIdzaeIdzMUdzaeaOIdCaeIdCMUdCaeaOIdKaeIdKMUdKaeaOId3aeId3MUd3aeaOIdaaeIdaMUdaaeaOId8KaeId8KMUd8KaeaOIdyaeIdyMUdya9raA2hYa8RhOaahCinaOaYfgeaOaLfgAIdbaeIdbMUdbaeclfgQaAclfIdbaQIdbMUdbaecwfgQaAcwfIdbaQIdbMUdbaecxfgeaAcxfIdbaeIdbMUdbaOczfhOaCcufgCmbka8JmbJbbbbJbbjZaIa8MfgeIdygR:vaRJbbbb9BEaeIdwa8Ka8Acx2fgOIdwgRNaeIdzaOIdbg8VNaeIdaMg8Wa8WMMaRNaeIdlaOIdlg8WNaeIdCaRNaeId3MgRaRMMa8WNaeIdba8VNaeIdxa8WNaeIdKMgRaRMMa8VNaeId8KMMM:lNgRa85a85aR9DEh85kaLa9rfhLahcefghal9hmbkcbhOa8EheindnaeydbgAcuSmbdnaOa9naAcdtgCfydbgA9hmbcuhAa8EaCfydbgCcuSmba9naCcdtfydbhAkaeaABdbkaeclfhealaOcefgO9hmbkcbhOa8FheindnaeydbgAcuSmbdnaOa9naAcdtgCfydbgA9hmbcuhAa8FaCfydbgCcuSmba9naCcdtfydbhAkaeaABdbkaeclfhealaOcefgO9hmbkka85aUaaEh85cbhOabhecbhAindnaHa9naeydbcdtfydbgLcdtfydbgCaHa9naeclfydbcdtfydbgYcdtfydbgQSmbaCaHa9naecwfydbcdtfydbg8AcdtfydbghSmbaQahSmbabaOcdtfgCaLBdbaCcwfa8ABdbaCclfaYBdbaOcifhOkaecxfheaAcifgAad6mbkdndnaSmbaOhdxekdnaOak0mbaOhdxekdna86a859FmbaOhdxekJFFuuh86cbhdabhecbhAindna9ia6aeydbgCcdtfydbcdtfIdbgRa859ETmbaeclf8Pdbh9CabadcdtfgQaCBdbaQclfa9C83dbaRa86a86aR9EEh86adcifhdkaecxfheaAcifgAaO6mbkkadak0mbxdkkascNefabadalaHz:cjjjbkdndnadak0mbadhYxekdnaSmbadhYxekdna86a879FmbadhYxekcehQina86Jbb;aZNgRa87aRa879DEh8WJbbbbhRdna9hTmba9ihea9hhOinaeIdbg8VaRa8Va8W9FEaRa8VaR9EEhRaeclfheaOcufgOmbkkJFFuuh86cbhYabhecbhOindna9ia6aeydbgAcdtfydbcdtfIdbg8Va8W9ETmbaeclf8Pdbh9CabaYcdtfgCaABdbaCclfa9C83dba8Va86a86a8V9EEh86aYcifhYkaecxfheaOcifgOad6mbkdnaQaYad9hVceGmbadhYxdkaRaUaUaR9DEhUaYak9nmecbhQaYhda86a879FmbkkdnamcjjjjdGTmba9ocbalz:xjjjbh8AdnaYTmbabheaYhOina8AaeydbgAfce86bba8AaHaAcdtfydbfce86bbaeclfheaOcufgOmbkkascNefabaYalaHz:cjjjbdndnalTmbcbhCindna8AaCfRbbTmbdna5aCfRbbPlbeebekdnaHaCcdtgLfydbgeaCSmba8KaCcx2fgOa8Kaecx2fgeydwBdwaOae8Pdb83dbxekaIaCc8S2fgQIdygnanJL:3;rUNgRMh87aQIdwgxaRMh8SaQIdlg9DaRMh8UaQIdbg9EaRMh81aQIdag9FaRa8KaCcx2fg8JIdwg88N:th8ZaQId3g9GaRa8JIdlg89N:th83aQIdKg9Ha8JIdbg8:aRN:th80JbbbbhZaQIdCg9IJbbbbMh85aQIdzg9JJbbbbMhBaQIdxg9KJbbbbMh86dndnaaTmbaChAinJbbbba87agaAc8S2fgOIdygR:vaRJbbbb9BEhRa8RaAaa2cltfheaOIdaa87Na8ZMh8ZaOId3a87Na83Mh83aOIdKa87Na80Mh80aOIdCa87Na85Mh85aOIdza87NaBMhBaOIdxa87Na86Mh86aOIdwa87Na8SMh8SaOIdla87Na8UMh8UaOIdba87Na81Mh81aahOina8ZaecwfIdbg8VaecxfIdbg8YNaRN:th8Za83aeclfIdbg8Wa8YNaRN:th83a85a8Wa8VNaRN:th85a81aeIdbg8Xa8XNaRN:th81a80a8Xa8YNaRN:th80aBa8Xa8VNaRN:thBa86a8Xa8WNaRN:th86a8Sa8Va8VNaRN:th8Sa8Ua8Wa8WNaRN:th8UaeczfheaOcufgOmbkaXaAcdtfydbgAaC9hmbka8NTmba8NaCcltfgeIdxhTaeIdwhcaeIdlhJaeIdbhRxekJbbbbhTJbbbbhcJbbbbhJJbbbbhRkaBa81:vg8Wa80Na8Z:ta85aBa86a81:vg8VN:tg8Za8Ua86a8VN:tg8Y:vg8Xa8Va80Na83:tg8UN:th83acaRa8WN:taJaRa8VN:tg86a8XN:tg85a8SaBa8WN:ta8Za8XN:tgB:vg8S:mh8Za86a8Y:vgc:mhJdnJbbbbaRaRa81:vg9eN:ta86acN:ta85a8SN:tg86:la87J:983:g81NgR9ETmba8Za83NaJa8UNa9ea80NaT:tMMa86:vhZka81:laR9ETmba8Y:laR9ETmbaB:laR9ETmba9e:maZNa8W:ma8ZaZNa83aB:vMgBNa8V:maJaZNa8X:maBNa8Ua8Y:vMMg85Na80:ma81:vMMMh87aKaLfgeclfydbgOaeydbge9RhhaEaecitfhLJbbbbhRdnaOaeSg8MmbJbbbbhRaLheahhAina8Kaeclfydbcx2fgOIdwa88:tg8Va8VNaOIdba8::tg8Va8VNaOIdla89:tg8Va8VNMMg8Va8Kaeydbcx2fgOIdwa88:tg8Wa8WNaOIdba8::tg8Wa8WNaOIdla89:tg8Wa8WNMMg8WaRaRa8W9DEgRaRa8V9DEhRaecwfheaAcufgAmbkaR:rgRaRNhRkaBa88:tg8Va8VNa87a8::tg8Va8VNa85a89:tg8Va8VNMMaR9EmbaQId8KhZdna8Mmbina8KaLclfydbcx2fgeIdba8KaLydbcx2fgOIdbg8W:tgRa89aOIdlg8X:tg80NaeIdla8X:tg8Va8:a8W:tg86N:tg8YaRa85a8X:tg8SNa8Va87a8W:tg8UN:tg8XNa8Va88aOIdwg81:tg8ZNaeIdwa81:tg8Wa80N:tg80a8VaBa81:tg83Na8Wa8SN:tg8VNa8Wa86NaRa8ZN:tg81a8Wa8UNaRa83N:tgRNMMa8Ya8YNa80a80Na81a81NMMa8Xa8XNa8Va8VNaRaRNMMN:rJbbj8:N9FmdaLcwfhLahcufghmbkkJbbbbJbbjZan:vanJbbbb9BEgRaxaBNa9Ja87Na9FMg8Va8VMMaBNa9Da85Na9IaBNa9GMg8Va8VMMa85Na9Ea87Na9Ka85Na9HMg8Va8VMMa87NaZMMM:lNaRaxa88Na9Ja8:Na9FMg8Va8VMMa88Na9Da89Na9Ia88Na9GMg8Va8VMMa89Na9Ea8:Na9Ka89Na9HMg8Va8VMMa8:NaZMMM:lNJbb;aZNJ:983:g81M9Emba8JaBUdwa8Ja85Udla8Ja87UdbkaCcefgCal9hmbkdnaambcbhaxdkcbhQindna8AaQfRbbTmbaHaQcdtgefydbaQ9hmba5aQfhhaXaefh8Ja8KaQcx2fhAa8PaQaa2cdtfh8McbhEincuhCdnahRbbc99fcFeGce0mbaQhCa8JydbgeaQSmba8PaEcdtgOfhLa8MaOfIdbhRaQhCinaChOcuhCdnaLaeaa2cdtfIdbaR9CmbaOcuSmbaOhCagaec8S2fIdyagaOc8S2fIdy9ETmbaehCkaXaecdtfydbgeaQ9hmbkka8PaEcdtfhLa8RaEcltfhKaQheinaLaeaa2cdtfJbbbbJbbjZagaeaCaCcuSEgOc8S2fIdygR:vaRJbbbb9BEaKaOaa2cltfgOIdwaAIdwNaOIdbaAIdbNaOIdlaAIdlNMMaOIdxMNUdbaXaecdtfydbgeaQ9hmbkaEcefgEaa9hmbkkaQcefgQal9hmbxdkkaambcbhakaiavaoarawaaala8Ka8Pazasayasc1efa5a8Aaqz:hjjjbkdnamcjjjjlGTmbazmbaYTmbabhecbhLina5aeydbgAfRbbc3thQaecwfgXydbhHcjjjj94hCdna8EaAcdtgEfydbaeclfgKydbgOSmbcjjjj94cba8FaOcdtfydbaASEhCkaeaQaCVaAVBdba5aOfRbbc3thacjjjj94hCcjjjj94hQdna8EaOcdtfydbaHSmbcjjjj94cba8FaHcdtfydbaOSEhQkaKaaaQVaOVBdba5aHfRbbc3thOdna8EaHcdtfydbaASmbcjjjj94cba8FaEfydbaHSEhCkaXaOaCVaHVBdbaecxfheaLcifgLaY6mbkkdnazTmbaYTmbaYheinabazabydbcdtfydbBdbabclfhbaecufgembkkdnaPTmbaPa9paU:rNUdbkdnasyd;8egHTmbaHcdtasc:Ceffc98fheinaeydbcbyd;C:L:cjbH:bjjjbbaec98fheaHcufgHmbkkascj;sbf8KjjjjbaYk;Yieouabydlhvabydbclfcbaicdtz:xjjjbhoadci9UhrdnadTmbdnalTmbaehwadhDinaoalawydbcdtfydbcdtfgqaqydbcefBdbawclfhwaDcufgDmbxdkkaehwadhDinaoawydbcdtfgqaqydbcefBdbawclfhwaDcufgDmbkkdnaiTmbcbhDaohwinawydbhqawaDBdbawclfhwaqaDfhDaicufgimbkkdnadci6mbinaecwfydbhwaeclfydbhDaeydbhidnalTmbalawcdtfydbhwalaDcdtfydbhDalaicdtfydbhikavaoaicdtfgqydbcitfaDBdbavaqydbcitfawBdlaqaqydbcefBdbavaoaDcdtfgqydbcitfawBdbavaqydbcitfaiBdlaqaqydbcefBdbavaoawcdtfgwydbcitfaiBdbavawydbcitfaDBdlawawydbcefBdbaecxfhearcufgrmbkkabydbcbBdbk:todDue99aicd4aifhrcehwinawgDcethwaDar6mbkcuaDcdtgraDcFFFFi0Ecbyd;y:L:cjbHjjjjbbhwaoaoyd9GgqcefBd9GaoaqcdtfawBdbawcFearz:xjjjbhkdnaiTmbalcd4hlaDcufhxcbhminamhDdnavTmbavamcdtfydbhDkcbadaDal2cdtfgDydlgwawcjjjj94SEgwcH4aw7c:F:b:DD2cbaDydbgwawcjjjj94SEgwcH4aw7c;D;O:B8J27cbaDydwgDaDcjjjj94SEgDcH4aD7c:3F;N8N27axGhwamcdthPdndndnavTmbakawcdtfgrydbgDcuSmeadavaPfydbal2cdtfgsIdbhzcehqinaqhrdnadavaDcdtfydbal2cdtfgqIdbaz9CmbaqIdlasIdl9CmbaqIdwasIdw9BmlkarcefhqakawarfaxGgwcdtfgrydbgDcu9hmbxdkkakawcdtfgrydbgDcuSmbadamal2cdtfgsIdbhzcehqinaqhrdnadaDal2cdtfgqIdbaz9CmbaqIdlasIdl9CmbaqIdwasIdw9BmikarcefhqakawarfaxGgwcdtfgrydbgDcu9hmbkkaramBdbamhDkabaPfaDBdbamcefgmai9hmbkkakcbyd;C:L:cjbH:bjjjbbaoaoyd9GcufBd9GdnaeTmbaiTmbcbhDaehwinawaDBdbawclfhwaiaDcefgD9hmbkcbhDaehwindnaDabydbgrSmbawaearcdtfgrydbBdbaraDBdbkabclfhbawclfhwaiaDcefgD9hmbkkk;:odvuv998Jjjjjbca9Rgocbyd1:G:cjbBdKaocb8Pdj:G:cjb83izaocbydN:G:cjbBdwaocb8Pd:m:G:cjb83ibdnadTmbaicd4hrdnabmbdnalTmbcbhwinaealawcdtfydbar2cdtfhDcbhiinaoczfaifgqaDaifIdbgkaqIdbgxaxak9EEUdbaoaifgqakaqIdbgxaxak9DEUdbaiclfgicx9hmbkawcefgwad9hmbxikkarcdthwcbhDincbhiinaoczfaifgqaeaifIdbgkaqIdbgxaxak9EEUdbaoaifgqakaqIdbgxaxak9DEUdbaiclfgicx9hmbkaeawfheaDcefgDad9hmbxdkkdnalTmbcbhwinabawcx2fgiaealawcdtfydbar2cdtfgDIdbUdbaiaDIdlUdlaiaDIdwUdwcbhiinaoczfaifgqaDaifIdbgkaqIdbgxaxak9EEUdbaoaifgqakaqIdbgxaxak9DEUdbaiclfgicx9hmbkawcefgwad9hmbxdkkarcdthlcbhwaehDinabawcx2fgiaeawar2cdtfgqIdbUdbaiaqIdlUdlaiaqIdwUdwcbhiinaoczfaifgqaDaifIdbgkaqIdbgxaxak9EEUdbaoaifgqakaqIdbgxaxak9DEUdbaiclfgicx9hmbkaDalfhDawcefgwad9hmbkkJbbbbaoIdbaoIdzgx:tgkakJbbbb9DEgkaoIdlaoIdCgm:tgPaPak9DEgkaoIdwaoIdKgP:tgsasak9DEhsdnabTmbadTmbJbbbbJbbjZas:vasJbbbb9BEhkinabakabIdbax:tNUdbabclfgoakaoIdbam:tNUdbabcwfgoakaoIdbaP:tNUdbabcxfhbadcufgdmbkkdnavTmbavaPUdwavamUdlavaxUdbkask:WlewudnaeTmbcbhvabhoinaoavBdbaoclfhoaeavcefgv9hmbkkdnaiTmbcbhrinadarcdtfhwcbhDinalawaDcdtgvyd:G:G:cjbcdtfydbcdtfydbhodnalawavfydbcdtfydbgqabaqcdtfgkydbgvSmbinakabavgqcdtfgxydbgvBdbaxhkaqav9hmbkkdnaoabaocdtfgkydbgvSmbinakabavgocdtfgxydbgvBdbaxhkaoav9hmbkkdnaqaoSmbabaqaoaqao0Ecdtfaqaoaqao6EBdbkaDcefgDci9hmbkarcifgrai6mbkkdnaembcbskcbhxindnalaxcdtgvfydbax9hmbaxhodnaxabavfgDydbgvSmbaDhqinaqabavgocdtfgkydbgvBdbakhqaoav9hmbkkaDaoBdbkaxcefgxae9hmbkcbhkabhvcbhoindndnaoalydbgq9hmbdnaoavydbgq9hmbavakBdbakcefhkxdkavabaqcdtfydbBdbxekavabaqcdtfydbBdbkalclfhlavclfhvaeaocefgo9hmbkakk;jiilud99euabcbaecltz:xjjjbhvdnalTmbadhoaihralhwinarcwfIdbhDarclfIdbhqavaoydbcltfgkarIdbakIdbMUdbakaqakIdlMUdlakaDakIdwMUdwakakIdxJbbjZMUdxaoclfhoarcxfhrawcufgwmbkkdnaeTmbavhkaehrinakcxfgoIdbhDaocbBdbakakIdbJbbbbJbbjZaD:vaDJbbbb9BEgDNUdbakclfgoaDaoIdbNUdbakcwfgoaDaoIdbNUdbakczfhkarcufgrmbkkdnalTmbinavadydbcltfgkaicwfIdbakIdw:tgDaDNaiIdbakIdb:tgDaDNaiclfIdbakIdl:tgDaDNMMgDakIdxgqaqaD9DEUdxadclfhdaicxfhialcufglmbkkdnaeTmbavcxfhkinabakIdbUdbakczfhkabclfhbaecufgembkkk:moerudnaoTmbaecd4hzdnavTmbaicd4hHavcdthOcbhAindnaPaAfRbbTmbaAhednaDTmbaDaAcdtfydbhekdnasTmbasaefRbbceGmekdnamaAfRbbcvSmbabaeaz2cdtfgiaraAcx2fgCIdbakNaxIdbMUdbaiaCIdlakNaxIdlMUdlaiaCIdwakNaxIdwMUdwkadaeaH2cdtfhXaqheawhiavhCinaXaeydbcdtgQfaiIdbalaQfIdb:vUdbaeclfheaiclfhiaCcufgCmbkkawaOfhwaAcefgAao9hmbxdkkdnasmbcbheaDhiindnaPaefRbbTmbaehCdnaDTmbaiydbhCkamaefRbbcvSmbabaCaz2cdtfgCarIdbakNaxIdbMUdbaCarclfIdbakNaxIdlMUdlaCarcwfIdbakNaxIdwMUdwkaiclfhiarcxfhraoaecefge9hmbxdkkdnaDTmbindnaPRbbTmbasaDydbgefRbbceGmbamRbbcvSmbabaeaz2cdtfgearIdbakNaxIdbMUdbaearclfIdbakNaxIdlMUdlaearcwfIdbakNaxIdwMUdwkaPcefhPaDclfhDamcefhmarcxfhraocufgombxdkkazcdthicbheindnaPaefRbbTmbasaefRbbceGmbamaefRbbcvSmbabarIdbakNaxIdbMUdbabclfarclfIdbakNaxIdlMUdbabcwfarcwfIdbakNaxIdwMUdbkarcxfhrabaifhbaoaecefge9hmbkkk8MbabaeadaialavcbcbcbcbcbaoarawaDz:bjjjbk8MbabaeadaialavaoarawaDaqakaxamaPz:bjjjbkRbababaeadaialavaoarawaDaqakaxcjjjjdVamz:bjjjbk:vgoque99due99duq998Jjjjjbc;Wb9Rgq8Kjjjjbcbhkaqcxfcbc;Kbz:xjjjb8Aaqcualcx2alc;v:Q;v:Qe0Ecbyd;y:L:cjbHjjjjbbgxBdxaqceBd2axaialavcbcbz:ejjjb8AaqcualcdtalcFFFFi0Egmcbyd;y:L:cjbHjjjjbbgiBdzaqcdBd2dndnJFF959eJbbjZawJbbjZawJbbjZ9DE:vawJ9VO:d869DEgw:lJbbb9p9DTmbaw:OhPxekcjjjj94hPkadci9Uhsarco9UhzdndnaombaPcd9imekdnalTmbaPcuf:YhwdnaoTmbcbhvaihHaxhOindndnaoavfRbbceGTmbavcjjjjlVhAxekdndnaOclfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhAxekcjjjj94hAkaAcqthAdndnaOcwfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaAaXVhAdndnaOIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaAaXcCtVhAkaHaABdbaHclfhHaOcxfhOalavcefgv9hmbxdkkaxhvaihOalhHindndnavIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhAxekcjjjj94hAkaAcCthAdndnavclfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaXcqtaAVhAdndnavcwfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaOaAaXVBdbavcxfhvaOclfhOaHcufgHmbkkadTmbcbhkaehvcbhOinakaiavclfydbcdtfydbgHaiavcwfydbcdtfydbgA9haiavydbcdtfydbgXaH9haXaA9hGGfhkavcxfhvaOcifgOad6mbkkarci9UhQdndnaz:Z:rJbbbZMgw:lJbbb9p9DTmbaw:Ohvxekcjjjj94hvkaQ:ZhLcbhKc:bwhzdninakaQ9pmeazaP9Rcd9imeavazcufgOavaO9iEaPcefavaP9kEhYdnalTmbaYcuf:YhwdnaoTmbcbhOaihHaxhvindndnaoaOfRbbceGTmbaOcjjjjlVhAxekdndnavclfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhAxekcjjjj94hAkaAcqthAdndnavcwfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaAaXVhAdndnavIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaAaXcCtVhAkaHaABdbaHclfhHavcxfhvalaOcefgO9hmbxdkkaxhvaihOalhHindndnavIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhAxekcjjjj94hAkaAcCthAdndnavclfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaXcqtaAVhAdndnavcwfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaOaAaXVBdbavcxfhvaOclfhOaHcufgHmbkkcbhOdnadTmbaehvcbhHinaOaiavclfydbcdtfydbgAaiavcwfydbcdtfydbgX9haiavydbcdtfydbgraA9haraX9hGGfhOavcxfhvaHcifgHad6mbkkdnas:ZgCaL:taY:Ygwaz:Y:tg8ANak:ZgEaO:Zg3:tNaEaL:tawaP:Y:tg5Na3aC:tNMg8EJbbbb9BmbaCaE:ta5a8Aa3aL:tNNNa8E:vawMhwkdndnaOaQ0mbaOhkaYhPxekaOhsaYhzkdndnaKcl0mbdnawJbbbZMgw:lJbbb9p9DTmbaw:Ohvxdkcjjjj94hvxekaPazfcd9ThvkaKcefgKcs9hmbkkdndndnakmbJbbjZhwcbhOcdhvaDmexdkalcd4alfhHcehOinaOgvcethOavaH6mbkaqcuavcdtavcFFFFi0Ecbyd;y:L:cjbHjjjjbbgYBdCaqciBd2aqamcbyd;y:L:cjbHjjjjbbgzBdKaqclBd2dnalTmbaPcuf:YhwdnaoTmbcbhOaihAaxhHindndnaoaOfRbbceGTmbaOcjjjjlVhXxekdndnaHclfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaXcqthXdndnaHcwfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:Ohrxekcjjjj94hrkaXarVhXdndnaHIdbawNJbbbZMgC:lJbbb9p9DTmbaC:Ohrxekcjjjj94hrkaXarcCtVhXkaAaXBdbaAclfhAaHcxfhHalaOcefgO9hmbxdkkaxhOaihHalhAindndnaOIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaXcCthXdndnaOclfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:Ohrxekcjjjj94hrkarcqtaXVhXdndnaOcwfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:Ohrxekcjjjj94hrkaHaXarVBdbaOcxfhOaHclfhHaAcufgAmbkkaqcuaYavazaialz:mjjjbgXc8S2gvaXc;D;O;f8U0Ecbyd;y:L:cjbHjjjjbbgiBd3aqcvBd2aicbavz:xjjjbhOdnadTmbcbhraehiinaxaiclfydbgocx2fgvIdbaxaiydbgPcx2fgHIdbg3:tgCaxaicwfydbgYcx2fgAIdlaHIdlg8A:tgwNavIdla8A:tgEaAIdba3:tg8EN:tgLaLNaEaAIdwaHIdwg5:tg8FNavIdwa5:tgEawN:tgwawNaEa8ENaCa8FN:tgCaCNMMg8E:rhEJbbnnJbbjZazaPcdtfydbgvazaocdtfydbgASavazaYcdtfydbgoSGgHEh8Fdna8EJbbbb9ETmbaLaE:vhLaCaE:vhCawaE:vhwkaOavc8S2fgvavIdbawa8FaE:rNgEawNNg8FMUdbavaCaEaCNgaNghavIdlMUdlavaLaEaLNg8ENggavIdwMUdwavawaaNgaavIdxMUdxava8EawNg8JavIdzMUdzavaCa8ENg8EavIdCMUdCavawaEaLa5Nawa3Na8AaCNMM:mg8ANg3NgwavIdKMUdKavaCa3NgCavId3MUd3avaLa3NgLavIdaMUdaava3a8ANg3avId8KMUd8KavaEavIdyMUdydnaHmbaOaAc8S2fgva8FavIdbMUdbavahavIdlMUdlavagavIdwMUdwavaaavIdxMUdxava8JavIdzMUdzava8EavIdCMUdCavawavIdKMUdKavaCavId3MUd3avaLavIdaMUdaava3avId8KMUd8KavaEavIdyMUdyaOaoc8S2fgva8FavIdbMUdbavahavIdlMUdlavagavIdwMUdwavaaavIdxMUdxava8JavIdzMUdzava8EavIdCMUdCavawavIdKMUdKavaCavId3MUd3avaLavIdaMUdaava3avId8KMUd8KavaEavIdyMUdykaicxfhiarcifgrad6mbkkcbhAaqcuaXcdtgvaXcFFFFi0Egicbyd;y:L:cjbHjjjjbbgHBdaaqcoBd2aqaicbyd;y:L:cjbHjjjjbbgiBd8KaqcrBd2aHcFeavz:xjjjbhPdnalTmbazhHinJbbbbJbbjZaOaHydbgrc8S2fgvIdygw:vawJbbbb9BEavIdwaxcwfIdbgwNavIdzaxIdbgCNavIdaMgLaLMMawNavIdlaxclfIdbgLNavIdCawNavId3MgwawMMaLNavIdbaCNavIdxaLNavIdKMgwawMMaCNavId8KMMM:lNhwdndnaParcdtgvfgrydbcuSmbaiavfIdbaw9ETmekaraABdbaiavfawUdbkaHclfhHaxcxfhxalaAcefgA9hmbkkdndnaXmbJbbbbhwxekJbbbbhwinaiIdbgCawawaC9DEhwaiclfhiaXcufgXmbkaw:rhwkakcd4akfhOcehiinaigvcethiavaO6mbkcbhOaqcuavcdtgiavcFFFFi0Ecbyd;y:L:cjbHjjjjbbgHBdyaHcFeaiz:xjjjbhXdnadTmbavcufhrcbhkcbhxindnazaeaxcdtfgvydbcdtfydbgiazavclfydbcdtfydbgOSmbaiazavcwfydbcdtfydbgvSmbaOavSmbaPavcdtfydbhAdndnaPaOcdtfydbgvaPaicdtfydbgi9pmbavaA9pmbaAhlaihoavhAxekdnaAai9pmbaAav9pmbaihlavhoxekavhlaAhoaihAkabakcx2fgvaABdbavcwfaoBdbavclfalBdbdnaXaoc:3F;N8N2alc:F:b:DD27aAc;D;O:B8J27arGgOcdtfgvydbgicuSmbcehHinaHhvdnabaicx2fgiydbaA9hmbaiydlal9hmbaiydwaoSmikavcefhHaXaOavfarGgOcdtfgvydbgicu9hmbkkavakBdbakcefhkkaxcifgxad6mbkakci2hOkcwhvaDTmekaDawUdbkavcdthvaqcxfc98fhiinaiavfydbcbyd;C:L:cjbH:bjjjbbavc98fgvmbkaqc;Wbf8KjjjjbaOk:0iewuabcFeaecdtz:xjjjbhbdnalmbcbskaecufhvdndnaiTmbcbhocbhrindndndnabaiarcdtgwfydbgDcm4aD7c:v;t;h;Ev2gecs4ae7avGgqcdtfgkydbgxcuSmbceheinaiaxcdtgxfydbaDSmdaqaefhxaecefheabaxavGgqcdtfgkydbgxcu9hmbkkakarBdbaoheaocefhoxekadaxfydbhekadawfaeBdbarcefgral9hmbxdkkcbhocbhDindnabaDcm4aD7c:v;t;h;Ev2gecs4ae7avGgqcdtfgkydbgxcuSmbaxaDSmbceheinabaqaefavGgqcdtfgkydbgxcuSmeaecefheaxaD9hmbkkdndnaxcu9hmbakaDBdbaoheaocefhoxekadaxcdtfydbhekadaDcdtfaeBdbaDcefgDal9hmbkkaok:3ldrue9:8Jjjjjbc;Wb9Rgr8Kjjjjbcbhwarcxfcbc;Kbz:xjjjb8AdnabaeSmbabaeadcdtz:wjjjb8AkarcualcdtalcFFFFi0EgDcbyd;y:L:cjbHjjjjbbgqBdxarceBd2aqcbaialavcbarcxfz:djjjbcualcx2alc;v:Q;v:Qe0Ecbyd;y:L:cjbHjjjjbbhkarcxfaryd2gxcdtfakBdbaraxcefgmBd2akaialavcbcbz:ejjjb8AarcxfamcdtfaDcbyd;y:L:cjbHjjjjbbgiBdbaraxcdfgvBd2arcxfavcdtfcuaialaeadaqz:fjjjbgecltaecjjjjiGEcbyd;y:L:cjbHjjjjbbgqBdbaqaeaiakalz:gjjjbaxcifhkdnadTmbaoaoNhocbhwabhlcbheindnaqaialydbgvcdtfydbcdtfIdbao9ETmbalclf8PdbhPabawcdtfgDavBdbaDclfaP83dbawcifhwkalcxfhlaecifgead6mbkkdnakTmbaxcdtarcxffcwfhlinalydbcbyd;C:L:cjbH:bjjjbbalc98fhlakcufgkmbkkarc;Wbf8Kjjjjbawk;lOoDud99oue99vuv998Jjjjjbc;Wb9Rgw8KjjjjbdndnarmbcbhDxekawcxfcbc;Kbz:xjjjb8Aawcuadcx2adc;v:Q;v:Qe0Ecbyd;y:L:cjbHjjjjbbgqBdxawceBd2aqaeadaicbcbz:ejjjb8AawcuadcdtadcFFFFi0Egkcbyd;y:L:cjbHjjjjbbgxBdzawcdBd2adcd4adfhecehiinaigmcethiamae6mbkcbhPawcuamcdtgsamcFFFFi0Ecbyd;y:L:cjbHjjjjbbgzBdCawciBd2dndnar:ZgH:rJbbbZMgO:lJbbb9p9DTmbaO:Ohixekcjjjj94hikamcufhAc:bwhCcbhXadhQcbhLinaiaCcufgeaiae9iEaPcefaiaP9kEhDdndnadTmbaDcuf:YhOaqhiaxheadhKindndnaiIdbaONJbbbZMgY:lJbbb9p9DTmbaY:Oh8Axekcjjjj94h8Aka8AcCth8AdndnaiclfIdbaONJbbbZMgY:lJbbb9p9DTmbaY:OhExekcjjjj94hEkaEcqta8AVh8AdndnaicwfIdbaONJbbbZMgY:lJbbb9p9DTmbaY:OhExekcjjjj94hEkaea8AaEVBdbaicxfhiaeclfheaKcufgKmbkazcFeasz:xjjjbh3cbh5cbh8Eindna3axa8Ecdtfydbg8Acm4a8A7c:v;t;h;Ev2gics4ai7aAGgKcdtfgEydbgecuSmbaea8ASmbcehiina3aKaifaAGgKcdtfgEydbgecuSmeaicefhiaea8A9hmbkkaEa8ABdba5aecuSfh5a8Ecefg8Ead9hmbxdkkazcFeasz:xjjjb8Acbh5kdnaQ:ZgYaH:taD:YgOaC:Y:tg8FNaX:Zgaa5:Zgh:tNaaaH:taOaP:Y:tggNahaY:tNMg8JJbbbb9BmbaYaa:taga8FahaH:tNNNa8J:vaOMhOkaPaDa5ar0geEhPaXa5aeEhXdna5arSmbaDaCaeEgCaP9Rcd9imbdndnaLcl0mbdnaOJbbbZMgO:lJbbb9p9DTmbaO:Ohixdkcjjjj94hixekaPaCfcd9Thika5aQaeEhQaLcefgLcs9hmekkdndnaXmbcihicbhDxekawakcbyd;y:L:cjbHjjjjbbg8ABdKawclBd2aPcuf:YhYdnadTmbaqhiaxheadhKindndnaiIdbaYNJbbbZMgO:lJbbb9p9DTmbaO:OhExekcjjjj94hEkaEcCthEdndnaiclfIdbaYNJbbbZMgO:lJbbb9p9DTmbaO:Oh3xekcjjjj94h3ka3cqtaEVhEdndnaicwfIdbaYNJbbbZMgO:lJbbb9p9DTmbaO:Oh3xekcjjjj94h3kaeaEa3VBdbaicxfhiaeclfheaKcufgKmbkkawcuazama8Aaxadz:mjjjbgDc32giaDc;j:KM;jb0Ecbyd;y:L:cjbHjjjjbbgeBd3awcvBd2aecbaiz:xjjjbh3avcd4hxdnadTmbdnalTmbaxcdth8Ea8AhEaqhealhKadhAina3aEydbc32fgiaeIdbaiIdbMUdbaiaeclfIdbaiIdlMUdlaiaecwfIdbaiIdwMUdwaiaKIdbaiIdxMUdxaiaKclfIdbaiIdzMUdzaiaKcwfIdbaiIdCMUdCaiaiIdKJbbjZMUdKaEclfhEaecxfheaKa8EfhKaAcufgAmbxdkka8AhKaqheadhEina3aKydbc32fgiaeIdbaiIdbMUdbaiaeclfIdbaiIdlMUdlaiaecwfIdbaiIdwMUdwaiaiIdxJbbbbMUdxaiaiIdzJbbbbMUdzaiaiIdCJbbbbMUdCaiaiIdKJbbjZMUdKaKclfhKaecxfheaEcufgEmbkkdnaDTmba3hiaDheinaiaiIdbJbbbbJbbjZaicKfIdbgO:vaOJbbbb9BEgONUdbaiclfgKaOaKIdbNUdbaicwfgKaOaKIdbNUdbaicxfgKaOaKIdbNUdbaiczfgKaOaKIdbNUdbaicCfgKaOaKIdbNUdbaic3fhiaecufgembkkcbhEawcuaDcdtgCaDcFFFFi0Egicbyd;y:L:cjbHjjjjbbgeBdaawcoBd2awaicbyd;y:L:cjbHjjjjbbg8EBd8KaecFeaCz:xjjjbh5dnadTmbaoJbbjZJbbjZaY:vaPceSENgOaONhYaxcdthxalheinaYaecN:H:cjbalEgKIdwa3a8AydbgAc32fgiIdC:tgOaONaKIdbaiIdx:tgOaONaKIdlaiIdz:tgOaONMMNaqcwfIdbaiIdw:tgOaONaqIdbaiIdb:tgOaONaqclfIdbaiIdl:tgOaONMMMhOdndna5aAcdtgifgKydbcuSmba8EaifIdbaO9ETmekaKaEBdba8EaifaOUdbka8Aclfh8AaqcxfhqaeaxfheadaEcefgE9hmbkkaba5aCz:wjjjb8Acrhikaicdthiawcxfc98fheinaeaifydbcbyd;C:L:cjbH:bjjjbbaic98fgimbkkawc;Wbf8KjjjjbaDk:Pdidui99ducbhi8Jjjjjbca9Rglcbyd1:G:cjbBdKalcb8Pdj:G:cjb83izalcbydN:G:cjbBdwalcb8Pd:m:G:cjb83ibdndnaembJbbjFhvJbbjFhoJbbjFhrxekadcd4cdthwincbhdinalczfadfgDabadfIdbgvaDIdbgoaoav9EEUdbaladfgDavaDIdbgoaoav9DEUdbadclfgdcx9hmbkabawfhbaicefgiae9hmbkalIdwalIdK:thralIdlalIdC:thoalIdbalIdz:thvkJbbbbavavJbbbb9DEgvaoaoav9DEgvararav9DEk:H8Modui99lud99Aus998Jjjjjbcji9RgD8KjjjjbcbhqaDcxfcbc;Kbz:xjjjb8AaDcbBdwaD9cb83ibaDcbyd;i:L:cjbBd1eaDcb8Pd;a:L:cjb83ijeaDcbyd;u:L:cjbBd94aDcb8Pd;m:L:cjb83i9WdndnavmbJbbjFhkJbbjFhxJbbjFhmxekaocd4cdthPalhsincbhzinaDcjefazfgHasazfIdbgkaHIdbgxaxak9EEUdbaDc;WbfazfgHakaHIdbgxaxak9DEUdbazclfgzcx9hmbkasaPfhsaqcefgqav9hmbkaDId94aDId1e:thmaDIdtaDId:ee:thxaDId9WaDIdje:thkkJbbbbhOdnar:YgAJq;x8J88MaA:vJbbbbakakJbbbb9DEgkaxaxak9DEgkamamak9DENgxJbbbb9Bmbarc9:f:Yax:vhOkaDcCfhCaDcxfcxfhXcbhzinaDazfaDcjefazfIdbgkaxaDc;WbfazfIdbak:t:tJbbb:;NMUdbazclfgzcx9hmbkcbhQaDarar2gLar2gzcbyd;y:L:cjbHjjjjbbgHBdxaDceBd2aHcbazz:xjjjbgKcbcbadaialaoaraOaDawz:rjjjbcdhYaDcuaLcdtaLcFFFFi0Eg8Acbyd;y:L:cjbHjjjjbbgEBdzaDcdBd2aDcjefcbarz:xjjjb8Acbh3dnaLTmbdnarcb9kmbaKhzaEhHaLhsincbh3aHcbcuazaDcjefarz:AjjjbEBdbazarfhzaHclfhHascufgsmbxdkkaKhPcbh3cbhvindndnaKavar2faDcjefarz:AjjjbTmbcbhHaPhzarhsinazaHazRbbgqfgHcbaqE86bbazcefhzascufgsmbkaEavcdtfa3BdbaHa3fh3xekaEavcdtfcuBdbkaParfhPavcefgvaL9hmbkkdnabTmbaDcua3cotgza3cFFF8F0Ecbyd;y:L:cjbHjjjjbbgQBdCcihYaDciBd2aQcbazz:xjjjb8AaXhCkdnawceGmbaCa8Acbyd;y:L:cjbHjjjjbbg5BdbaDaYcefgzBd2aDcxfazcdtfaLcbyd;y:L:cjbHjjjjbbgzBdbaDaYcdfgYBd2azcbaLz:xjjjbh8EarcufhXdnarci9imbarc9:fhCararcef2aKfcefh8Aceh8Fina8Far2hPa8AhvcehqindnaEaqaPfcdtfydbcuSmbavhzaChHinazazRbbgscuasE86bbazcefhzaHcufgHmbkkavarfhvaqcefgqaX9hmbka8AaLfh8Aa8Fcefg8FaX9hmbkkarce9imbcbh8Acbhqcbhvina8EaqfhscbhzindnasazfgHRbbmbaHce86bba5a8AcdtfaqazfBdba8Acefh8Akarazcefgz9hmbkaqarfhqavcefgvar9hmbka8ATmbaKcefhaaKc9:fhharc9:fhgarci9ih8Jina8Ea5a8Acufg8Acdtfydbgvfcb86bbavar2hPdna8JmbaEavcdtfydbcuSmbaKaPfhHaghqindnaHcefgzRbbgscFe9hmbaHRbbmbcbhskazas86bbazhHaqcufgqmbkaharavcef2fhzaXhsindnazRbbgHcFe9hmbazcefRbbmbcbhHkazaH86bbazcufhzascufgsce9kmbkkaaaPfh8Kavavar9Ug8Lar29Rh8FcbhCindnaCceScuaCEa8Ffgzce9imbazaX9ombcuaCciSaCcdSEa8LfgHce9imbaHaX9ombaEaHar2azfg8McdtfydbcuSmba8Jmbaaa8Mar2fhzcbhqa8KhsaghvinazazRbbgHcbaHaHcFeSEasRbbEgP86bbascefhsazcefhzaPaH7aqVhqavcufgvmbkaqcFeGTmba8Ea8MfgzRbbmbazce86bba5a8Acdtfa8MBdba8Acefh8AkaCcefgCcl9hmbka8AmbkkdnaQTmbaKaEaQadaialaoaraOaDawz:rjjjba3TmbJbbjZaO:vhkawcjjjjlGhPdnawcdGTmbJbbnnaOaON:vh8NakJbbbZNhyaQhzinazczfgsIdbg8PazcCfIdbgx:vhmazcxfgqIdbgIax:vhAazcwfgvIdbg8Rax:vh8SakazydbgHcFrG:ZNhRakaHcq4cFrG:ZNh8UakaHcC4cFrG:ZNh8VdnaxJ:p;c;188Ng8WazcKfIdbMg8X:laxJ:983:g81Ngx9ETmba8Wazc3fIdbMazc8KfIdbg8Ya8Ya8X:vg8YN:tg8Z:lax9ETmba8WazcafIdbMazcyfIdbg8Wa8Wa8X:vg80N:tazc8SfIdba8Wa8YN:tg8Wa8Wa8Z:vg8WN:tg81:lax9ETmba8PJ:p;c;188NazcUfIdb:ta80a8RJ:p;c;188Nazc8WfIdb:tg8PN:ta8WaIJ:p;c;188Nazc80fIdb:ta8Ya8PN:tgIN:ta81:vgxam:tg8Ra8RNa8Pa8X:va8YaIa8Z:va8WaxN:tg8XN:ta80axN:tg8Wa8S:tg8Ya8YNa8XaA:tg8Ya8YNMMa8N9DTmbaxaRaxaR9EEgxakaRMgmaxam9DEhma8Xa8Ua8Xa8U9EEgxaka8UMgAaxaA9DEhAa8Wa8Va8Wa8V9EEgxaka8VMg8Saxa8S9DEh8SkdnaPTmbayaRMhmaya8UMhAaya8VMh8SkasamUdbaqaAUdbava8SUdbazc;abfhza3cufg3mbxdkkdnaPTmbakJbbbZNhxaQhzinazczfaxakazydbgHcFrG:ZNMUdbazcxfaxakaHcq4cFrG:ZNMUdbazcwfaxakaHcC4cFrG:ZNMUdbazc;abfhza3cufg3mbxdkkaQcCfhzinazc98fgHaHIdbazIdbgk:vUdbazc94fgHaHIdbak:vUdbazctfgHaHIdbak:vUdbazc;abfhza3cufg3mbkkcbhsdndnarcd9imbarcufh3aEarcdtfhadnabmbaKcefg8Mararcefgz2fh8JaKazfhba8MaLfh8Ecbhscbh8Kina8Kar2h8La8Mheabh8Aa8Eh8Fa8Jh5cbhXindnaEaXa8LfgqcdtgzfgHclfydbaHydbGaaazfgzydbGazclfydbGcuSmbclcbaKaqar2fgzarfRbbEazRbbcb9hVczcbazaLfgzRbbEVc;abcbazarfRbbEVhPaehza8AhHa8Fhqa5hva3hQindnaPclcbaHRbbEazRbbcb9hVczcbaqRbbEVc;abcbavRbbEVgPcetVgCTmbaCcFeSmbasaCRb;W;p:cjbfhskazcefhzaHcefhHaqcefhqavcefhvaQcufgQmbkkaearfhea8Aarfh8Aa8Farfh8Fa5arfh5aXcefgXa39hmbka8MaLfh8MabaLfhba8EaLfh8Ea8JaLfh8Ja8Kcefg8Ka39hmbxdkkJbbjZaO:vgkakJk;x8J88NNh8RawcdGh8EaDIdwhkaDIdlhxaDIdbhmcbhscbhPinaPar2h8KcbhvindnaEava8KfgqcdtgzfgHclfydbaHydbGaaazfgzydbGazclfydbGcuSmbcbh8AclcbaKaqar2fgYarfRbbEaYRbbcb9hVczcbaYaLfg8JRbbEVc;abcba8JarfRbbEVh8Lindna8LclcbaYa8Ag8Mcefg8AfgzarfRbbEazRbbcb9hVczcba8Ja8AfgzRbbEVc;abcbazarfRbbEVg8LcetVgCTmbaCcFeSmbcbhqdndndnaCRb;W;n:cjbcufPdebdka8ETmeaCcC2gz8Ve;W:L:cjbcltaz8Ve;Y:L:cjbcsGVh8FaKa8Mfh5cxhzaDcjefhHinaHaQaEa8Faz4gqce4ceGavfaqcd4ceGaPfar2fgXcdtfydbcotfa5aqceGfaXar2fRbbcotfcnfBdbaHclfhHazc98fgzc989hmbkaDydjegzIdyaDyd:megHIdyMaDyd:eegqIdyaDyd1egXIdyMMg8XaqIdwaXIdwMJbbbZNgANazIdUaHIdUMaqIdUaXIdUMMg8WMg8Sa8SMazIdaaHIdaMaqIdaaXIdaMMg8YaqIdzaXIdzMJbbbZNg8SNMa8SNazId8SaHId8SMaqId8SaXId8SMMgRa8SNazId80aHId80MaqId80aXId80MMg8UMg8Sa8SMazId3aHId3MaqId3aXId3MMg8VaqIdxaXIdxMJbbbZNg8SNMa8SNazId8KaHId8KMaqId8KaXId8KMMg8Za8SNazId8WaHId8WMaqId8WaXId8WMMg80Mg8Sa8SMazIdKaHIdKMaqIdKaXIdKMMgyaANMaANazId88aHId88MaqId88aXId88MMg8PMMM:lgIa8RazIdCaHIdCMaqIdCaXIdCMMN9Ea8XazIdwaHIdwMJbbbZNgANa8WMg8Sa8SMa8YazIdzaHIdzMJbbbZNg8SNMa8SNaRa8SNa8UMg8Sa8SMa8VazIdxaHIdxMJbbbZNg8SNMa8SNa8Za8SNa80Mg8Sa8SMayaANMaANa8PMMM:laIJ;d;1UZN9DGhqxekaKa8Mfh8FcbhzcrhHindnaCaz4ceGTmba8FazceGfazce4ceGavfazcd4aPfar2fgqar2fRbbgXcFeSmbaQaEaqcdtfydbcotfaXcotfc9efRbbaH4ceGTmbcbhqxdkaHcufhHcehqazcefgzcw9hmbkkaCcC2aqcq2fgH8Ve;W:L:cjbgzTmbaHc;Y:L:cjbfhqaKa8MfhCabasc8K2fhHindnasae9pmbaHaQaEazcD4ceGavfazcq4ceGaPfar2fgXcdtfydbcotfaCazcw4ceGfaXar2fRbbcotfgXc9ifIdbamMUdbaHclfaXc9mfIdbaxMUdbaHcwfaXc9qfIdbakMUdbaHcxfamaQaEazcv4ceGavfazco4ceGaPfar2fgXcdtfydbcotfaCazcl4ceGfaXar2fRbbcotfgXc9ifIdbMUdbaHczfaxaXc9mfIdbMUdbaHcCfakaXc9qfIdbMUdbaHcKfamaQaEazce4ceGavfazcd4ceGaPfar2fgXcdtfydbcotfaCazceGfaXar2fRbbcotfgzc9ifIdbMUdbaHc3faxazc9mfIdbMUdbaHcafakazc9qfIdbMUdbkaHc8KfhHascefhsaq8Vebhzaqcdfhqazmbkka8Aa39hmbkkavcefgva39hmbkaPcefgPa39hmbkaDyd2gYTmekaYcdtaDcxffc98fhzinazydbcbyd;C:L:cjbH:bjjjbbazc98fhzaYcufgYmbkkaDcjif8Kjjjjbask;Kxmiue99due99euz99eui99eud99dud99oudnalTmbaocd4hkaqcdGhxarc99fhqarcethmawawMhPcbhsindndnawavaiascdtfgoclfydbak2cdtfgzIdwgHavaoydbak2cdtfgOIdwgA:tgCaCNazIdbgXaOIdbgQ:tgLaLNazIdlgKaOIdlgY:tg8Aa8ANMMgEavaocwfydbak2cdtfgoIdwg3aA:tg5a5NaoIdbg8EaQ:tg8Fa8FNaoIdlgaaY:tghahNMMggaEag9EEgEa3aH:tgHaHNa8EaX:tgHaHNaaaK:tgHaHNMMgHaEaH9EE:rNgHaHMgH:lJbbb9p9DTmbaH:Ohoxekcjjjj94hokdnaLahNa8Aa8FN:tgHaHNa8Aa5NaCahN:tgXaXNaCa8FNaLa5N:tgKaKNMMg3Jbbbb9BmbJbbjZhEdnaoceaoce9kEgoamaoam9iEg8Jcd9imbJbbjZa8J:Z:vhEkarcb9imbaAaDIdw:th8KaYaDIdl:th8LaQaDIdb:th8Ma8Jcba8Jcb9kEh8NdnadTmbaHJbbjZa3:rgA:vgQNg3aAa8Jcefa8Jcdf2:Y:vgANh8EaKaQNgKaANhyaXaQNgXaXaANNh8PcbhIina8Jcba8Jcb9kEcefh8RaEaI:ZNgQaCNa8KMhgaQa8ANa8LMh8SaQaLNa8MMhRcbhzindndnaPaEaz:ZNgQahNa8SMgYNgH:lJbbb9p9DTmbaH:OhOxekcjjjj94hOkaOce91goaqaoaq6Eh8UdndnaPaQa5NagMgHNga:lJbbb9p9DTmbaa:Oh8Vxekcjjjj94h8Vka8Ua8Vce91goaqaoaq6Eg8Wcefar2fcefgoar2h8XdndnaPaQa8FNaRMgQNga:lJbbb9p9DTmbaa:Oh8Yxekcjjjj94h8Ykadaeaocdtfydbcotfaba8Yce91goaqaoaq6Eg8Zfa8XfcefRbbcotfgocnfa8Ucqta8ZcCtVa8WVBdbaoc9efg8Ua8URbbcea8YceGaOcetcdGVa8VcdtclGVtV86bbaoc9ifgOaQaANaOIdbMUdbaoc9mfgOaYaANaOIdbMUdbaoc9qfgOaHaANaOIdbMUdbaoc9ufgOaAaOIdbMUdbdnaxTmbaoc9yfgOa8PaOIdbMUdbaoc9CfgOaKayNaOIdbMUdbaoc9GfgOa3a8ENaOIdbMUdbaoc9KfgOaXayNaOIdbMUdbaoc9OfgOaXa8ENaOIdbMUdbaoc2fgOaKa8ENaOIdbMUdbaoc9WfgOaXaAa3aHNaXaQNaKaYNMMgY:mNgQNaOIdbMUdbaoctfgOaKaQNaOIdbMUdbaoc94fgOa3aQNaOIdbMUdbaoc98fgoaoIdbaYaQN:tUdbka8Razcefgz9hmbka8Jcufh8JaIa8NShoaIcefhIaoTmbxdkkcbh8Vina8Jcba8Jcb9kEcefh8UaEa8V:ZNgAaCNa8KMhYaAa8ANa8LMhHaAaLNa8MMhXcbhoindndnaPaEao:ZNgAahNaHMNgQ:lJbbb9p9DTmbaQ:Ohzxekcjjjj94hzkazce91gzaqazaq6EhzdndnaPaAa5NaYMNgQ:lJbbb9p9DTmbaQ:OhOxekcjjjj94hOkazaOce91gOaqaOaq6Ecefar2fcefar2hzdndnaPaAa8FNaXMNgA:lJbbb9p9DTmbaA:OhOxekcjjjj94hOkabaOce91gOaqaOaq6Efazfcefce86bba8Uaocefgo9hmbka8Jcufh8Ja8Va8NShoa8Vcefh8VaoTmbkkascifgsal6mbkkk:Nvezu8Jjjjjbcjd9Rgb8Kjjjjbcbheabcbcjdz:xjjjbhdc:W:H:cjbhbinabRbbgicC2glabcqf8Veb87e;4:L:cjbalabcdfgv8Peb83e;W:L:cjbaiabcefRbb86b;W;n:cjbadaifce86bbalavabcxfceaetc:F:d;avGEgi8Peb83e;6:L:cjbalai8Vew87e:c:M:cjbabcQfhbaecefgecK9hmbkcbhoinc;Y:L:cjbhrcbhvindnadavfgwRbbce9hmbavcC2c;W:L:cjbfhDcbhbcehqavc;W;n:cjbfhkinabcitc:G:H:cjbfhlcbhbcbheinaeavab4ceGalabfRbbtVheabcefgbcw9hmbkdnadaecFeGgxfgmRbbmbaxcC2c;W:L:cjbfhPcbhbcehsindnaDabcq2gif8VebgbTmbaraifheaPaifhiinaialabcl4csGfRbbcltalabcw4csGfRbbcwtValabcsGfRbbV87ebaicdfhiae8VebhbaecdfheabmbkkcehbasceGhecbhsaembkamce86bbaxakRbb86b;W;n:cjbkcehbaqceGhlcbhqalmbkawcd86bbkarcCfhravcefgvcjd9hmbkaocefgoci9hmbkcbhic;W:L:cjbhvincuhlavhbinalcefhlab8Vebheabcdfhbaembkaial86b;W;p:cjbavcCfhvaicefgicjd9hmbkadcjdf8Kjjjjbk9DeeuabcFeaicdtz:xjjjbhlcbhbdnadTmbindnalaeydbcdtfgiydbcu9hmbaiabBdbabcefhbkaeclfheadcufgdmbkkabk;Bidqui998Jjjjjbc;Wb9Rgl8Kjjjjbalcxfcbc;Kbz:xjjjb8Aadcd4adfhvcehoinaogrcethoarav6mbkalcuarcdtgoarcFFFFi0Ecbyd;y:L:cjbHjjjjbbgvBdxavcFeaoz:xjjjbhwdnadTmbaicd4hDarcufhqcbhkindndnawcbaeakaD2cdtfgrydlgiaicjjjj94SEgocH4ao7c:F:b:DD2cbarydbgxaxcjjjj94SEgocH4ao7c;D;O:B8J27cbarydwgmamcjjjj94SEgrcH4ar7c:3F;N8N27aqGgvcdtfgrydbgocuSmbam::hPai::hsax::hzcehiinaihrdnaeaoaD2cdtfgiIdbaz9CmbaiIdlas9CmbaiIdwaP9BmikarcefhiawavarfaqGgvcdtfgrydbgocu9hmbkkarakBdbakhokabakcdtfaoBdbakcefgkad9hmbkkalydxcbyd;C:L:cjbH:bjjjbbalc;Wbf8Kjjjjbk9teiucbcbyd;G:L:cjbgeabcifc98GfgbBd;G:L:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaeczfheaiczfhiadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabk9teiucbcbyd;G:L:cjbgeabcrfc94GfgbBd;G:L:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikTeeucbabcbyd;G:L:cjbge9Rcifc98GaefgbBd;G:L:cjbdnabZbcztge9nmbabae9RcFFifcz4nb8Akk6eiucbhidnadTmbdninabRbbglaeRbbgv9hmeaecefheabcefhbadcufgdmbxdkkalav9Rhikaikk;0vdbcj:Gdk;yvFFuuFFuuFFuuFFuFFFuFFFuFbbbbbbbbebbbdbbbbbbbebbbebbbdbbbbbbbbbbbeeeeeebebbeebbebbebbbeeebbbbebbbbbbbbbbbbbbbbbbbeeeeeeebebbbeeebbeebbbbbebbbbbebebbbbbbbbbbbbbbbdiorbelvlbodveribbbbbbbbbbbbbbbbbbbbbbebbbbbbbbbbbbbbbbbbbbbibbbbbbbbbbbbbbbbbbbbbobbbbbbbbbbbbbbbbbbbbbrbaebbbbbbbbbbbbbbbbbbsd8We8YbbbbbbbhiaebbbbbbQe8Ke9cebbbbbbbbbbbbbbbbLb8KebbbbbbbbbbbbbbbbbbKbbbbbbbbbbbbbbbbbbbbbYeJbilbbbbbbbbbbbbbbbbEe80e8WlbbbbbbzlAbbbbbbb5eJdnibbbbbbai8Kbbbbbbb8Ee9ce8Ylcibbbb8Yebbbbbbbb8FdOlAdbbbbbb80e8Ylbbbbbb88eTi8KiJv8Jlbbbbbbbbbbbb89e9td8Kv9qibbbbndlvaibbbbZd8Li8KvbbbbbbJdTibbbbbb9Pe81b9GvoiBvbbbbbbbbbbbb9Re9JbvoWibbbbvibbbbbbbb9VeWi9Gvbbbbbb8WvBbbbbbbb9:b9ceBvbbbbbbbbbbbbbbbbubWibbbbbbbbbbbbbbbbbb;Wd9hvSrbbbbbbWl9NvbbbbbbFbbbbbbbbbbbbbbbbbbbbbFFuuFFuuFFuuFFuFFFuFFFuFbc;y:Ldkxebbbdbbb;W:Obb",e=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if(typeof WebAssembly!="object")return{supported:!1};var t,s=WebAssembly.instantiate(n(r),{}).then(function(y){t=y.instance,t.exports.__wasm_call_ctors()});function n(y){for(var v=new Uint8Array(y.length),_=0;_<y.length;++_){var A=y.charCodeAt(_);v[_]=A>96?A-97:A>64?A-39:A+4}for(var M=0,_=0;_<y.length;++_)v[M++]=v[_]<60?e[v[_]]:(v[_]-60)*64+v[++_];return v.buffer.slice(0,M)}function a(y){if(!y)throw new Error("Assertion failed")}function i(y){return new Uint8Array(y.buffer,y.byteOffset,y.byteLength)}function o(y,v,_,A){var M=t.exports.sbrk,N=M(_*4),R=M(_*A*4),I=new Uint8Array(t.exports.memory.buffer);I.set(i(v),R),y(N,R,_,A*4),I=new Uint8Array(t.exports.memory.buffer);var D=new Uint32Array(_);return new Uint8Array(D.buffer).set(I.subarray(N,N+_*4)),M(N-M(0)),D}function c(y,v,_){var A=t.exports.sbrk,M=A(v.length*4),N=A(_*4),R=new Uint8Array(t.exports.memory.buffer),I=i(v);R.set(I,M);var D=y(N,M,v.length,_);R=new Uint8Array(t.exports.memory.buffer);var O=new Uint32Array(_);new Uint8Array(O.buffer).set(R.subarray(N,N+_*4)),A(M-A(0));for(var P=0;P<v.length;++P)v[P]=O[v[P]];return[O,D]}function l(y){for(var v=0,_=0;_<y.length;++_){var A=y[_];v=v<A?A:v}return v}function h(y,v,_,A,M,N,R,I,D){var O=t.exports.sbrk,P=O(4),U=O(_*4),j=O(M*N),z=O(_*4),H=new Uint8Array(t.exports.memory.buffer);H.set(i(A),j),H.set(i(v),z);var J=y(U,z,_,j,M,N,R,I,D,P);H=new Uint8Array(t.exports.memory.buffer);var ee=new Uint32Array(J);i(ee).set(H.subarray(U,U+J*4));var se=new Float32Array(1);return i(se).set(H.subarray(P,P+4)),O(P-O(0)),[ee,se[0]]}function u(y,v,_,A,M,N,R,I,D,O,P,U,j){var z=t.exports.sbrk,H=z(4),J=z(_*4),ee=z(M*N),se=z(M*I),_e=z(D.length*4),Ae=z(_*4),Se=O?z(M):0,Fe=new Uint8Array(t.exports.memory.buffer);Fe.set(i(A),ee),Fe.set(i(R),se),Fe.set(i(D),_e),Fe.set(i(v),Ae),O&&Fe.set(i(O),Se);var ft=y(J,Ae,_,ee,M,N,se,I,_e,D.length,Se,P,U,j,H);Fe=new Uint8Array(t.exports.memory.buffer);var te=new Uint32Array(ft);i(te).set(Fe.subarray(J,J+ft*4));var re=new Float32Array(1);return i(re).set(Fe.subarray(H,H+4)),z(H-z(0)),[te,re[0]]}function d(y,v,_,A,M,N,R,I,D,O,P,U,j){var z=t.exports.sbrk,H=z(4),J=z(M*N),ee=z(M*I),se=z(D.length*4),_e=z(_*4),Ae=O?z(M):0,Se=new Uint8Array(t.exports.memory.buffer);Se.set(i(A),J),Se.set(i(R),ee),Se.set(i(D),se),Se.set(i(v),_e),O&&Se.set(i(O),Ae);var Fe=y(_e,_,J,M,N,ee,I,se,D.length,Ae,P,U,j,H);Se=new Uint8Array(t.exports.memory.buffer),i(v).set(Se.subarray(_e,_e+Fe*4)),i(A).set(Se.subarray(J,J+M*N)),i(R).set(Se.subarray(ee,ee+M*I));var ft=new Float32Array(1);return i(ft).set(Se.subarray(H,H+4)),z(H-z(0)),[Fe,ft[0]]}function f(y,v,_,A){var M=t.exports.sbrk,N=M(_*A),R=new Uint8Array(t.exports.memory.buffer);R.set(i(v),N);var I=y(N,_,A);return M(N-M(0)),I}function p(y,v,_,A,M,N,R,I){var D=t.exports.sbrk,O=D(I*4),P=D(_*A),U=M?D(_*N):0,j=new Uint8Array(t.exports.memory.buffer);j.set(i(v),P),M&&j.set(i(M),U);var z=y(O,P,_,A,U,N,R,I);j=new Uint8Array(t.exports.memory.buffer);var H=new Uint32Array(z);return i(H).set(j.subarray(O,O+z*4)),D(O-D(0)),H}function m(y,v,_,A,M,N,R,I,D){var O=t.exports.sbrk,P=O(4),U=O(_*4),j=O(M*N),z=O(_*4),H=R?O(M):0,J=new Uint8Array(t.exports.memory.buffer);J.set(i(A),j),J.set(i(v),z),R&&J.set(i(R),H);var ee=y(U,z,_,j,M,N,H,I,D,P);J=new Uint8Array(t.exports.memory.buffer);var se=new Uint32Array(ee);i(se).set(J.subarray(U,U+ee*4));var _e=new Float32Array(1);return i(_e).set(J.subarray(P,P+4)),O(P-O(0)),[se,_e[0]]}function b(y,v,_,A,M,N,R){var I=t.exports.sbrk,D=I(_*4),O=I(M*N),P=I(_*4),U=new Uint8Array(t.exports.memory.buffer);U.set(i(A),O),U.set(i(v),P);var j=y(D,P,_,O,M,N,R);U=new Uint8Array(t.exports.memory.buffer);var z=new Uint32Array(j);return i(z).set(U.subarray(D,D+j*4)),I(D-I(0)),z}function g(y,v,_,A,M,N){var R=t.exports.sbrk,I=R(_.byteLength),D=R(v.byteLength),O=new Uint8Array(t.exports.memory.buffer);O.set(i(_),I),O.set(i(v),D);var P=_.byteLength/A,U=y(0,0,D,v.length,I,P,A,M,N),j=R(U*9*4),z=y(j,U,D,v.length,I,P,A,M,N);a(z<=U),O=new Uint8Array(t.exports.memory.buffer);var H=new Float32Array(z*9);return i(H).set(O.subarray(j,j+H.byteLength)),R(I-R(0)),H}var x={LockBorder:1,Sparse:2,ErrorAbsolute:4,Prune:8,Regularize:16,Permissive:32,RegularizeLight:64,PreserveFolds:128,ErrorClamped:256,_InternalDebug:1<<30},T={Shell:1,Solve:2,Thicken:0,_InternalDebug:1<<30};return{ready:s,supported:!0,compactMesh:function(y){a(y instanceof Uint32Array||y instanceof Int32Array||y instanceof Uint16Array||y instanceof Int16Array),a(y.length%3==0);var v=y.BYTES_PER_ELEMENT==4?y:new Uint32Array(y),_=c(t.exports.meshopt_optimizeVertexFetchRemap,v,l(y)+1);if(y!==v)for(var A=0;A<v.length;++A)y[A]=v[A];return _},generatePositionRemap:function(y,v){return a(y instanceof Float32Array),a(y.length%v==0),a(v>=3),o(t.exports.meshopt_generatePositionRemap,y,y.length/v,v)},simplify:function(y,v,_,A,M,N){a(y instanceof Uint32Array||y instanceof Int32Array||y instanceof Uint16Array||y instanceof Int16Array),a(y.length%3==0),a(v instanceof Float32Array),a(v.length%_==0),a(_>=3),a(A>=0&&A<=y.length),a(A%3==0),a(M>=0);for(var R=0,I=0;I<(N?N.length:0);++I)a(N[I]in x),R|=x[N[I]];var D=y.BYTES_PER_ELEMENT==4?y:new Uint32Array(y),O=h(t.exports.meshopt_simplify,D,y.length,v,v.length/_,_*4,A,M,R);return O[0]=y instanceof Uint32Array?O[0]:new y.constructor(O[0]),O},simplifyWithAttributes:function(y,v,_,A,M,N,R,I,D,O){a(y instanceof Uint32Array||y instanceof Int32Array||y instanceof Uint16Array||y instanceof Int16Array),a(y.length%3==0),a(v instanceof Float32Array),a(v.length%_==0),a(_>=3),a(A instanceof Float32Array),a(A.length==M*(v.length/_)),a(M>=0),a(R==null||R instanceof Uint8Array),a(R==null||R.length==v.length/_),a(I>=0&&I<=y.length),a(I%3==0),a(D>=0),a(Array.isArray(N)),a(M>=N.length),a(N.length<=32);for(var P=0;P<N.length;++P)a(N[P]>=0);for(var U=0,P=0;P<(O?O.length:0);++P)a(O[P]in x),U|=x[O[P]];var j=y.BYTES_PER_ELEMENT==4?y:new Uint32Array(y),z=u(t.exports.meshopt_simplifyWithAttributes,j,y.length,v,v.length/_,_*4,A,M*4,new Float32Array(N),R,I,D,U);return z[0]=y instanceof Uint32Array?z[0]:new y.constructor(z[0]),z},simplifyWithUpdate:function(y,v,_,A,M,N,R,I,D,O){a(y instanceof Uint32Array||y instanceof Int32Array||y instanceof Uint16Array||y instanceof Int16Array),a(y.length%3==0),a(v instanceof Float32Array),a(v.length%_==0),a(_>=3),a(A instanceof Float32Array),a(A.length==M*(v.length/_)),a(M>=0),a(R==null||R instanceof Uint8Array),a(R==null||R.length==v.length/_),a(I>=0&&I<=y.length),a(I%3==0),a(D>=0),a(Array.isArray(N)),a(M>=N.length),a(N.length<=32);for(var P=0;P<N.length;++P)a(N[P]>=0);for(var U=0,P=0;P<(O?O.length:0);++P)a(O[P]in x),U|=x[O[P]];var j=y.BYTES_PER_ELEMENT==4?y:new Uint32Array(y),z=d(t.exports.meshopt_simplifyWithUpdate,j,y.length,v,v.length/_,_*4,A,M*4,new Float32Array(N),R,I,D,U);if(y!==j)for(var P=0;P<z[0];++P)y[P]=j[P];return z},getScale:function(y,v){return a(y instanceof Float32Array),a(y.length%v==0),a(v>=3),f(t.exports.meshopt_simplifyScale,y,y.length/v,v*4)},simplifyPoints:function(y,v,_,A,M,N){return a(y instanceof Float32Array),a(y.length%v==0),a(v>=3),a(_>=0&&_<=y.length/v),A?(a(A instanceof Float32Array),a(A.length%M==0),a(M>=3),a(y.length/v==A.length/M),p(t.exports.meshopt_simplifyPoints,y,y.length/v,v*4,A,M*4,N||0,_)):p(t.exports.meshopt_simplifyPoints,y,y.length/v,v*4,void 0,0,0,_)},simplifySloppy:function(y,v,_,A,M,N){a(y instanceof Uint32Array||y instanceof Int32Array||y instanceof Uint16Array||y instanceof Int16Array),a(y.length%3==0),a(v instanceof Float32Array),a(v.length%_==0),a(_>=3),a(A==null||A instanceof Uint8Array),a(A==null||A.length==v.length/_),a(M>=0&&M<=y.length),a(M%3==0),a(N>=0);var R=y.BYTES_PER_ELEMENT==4?y:new Uint32Array(y),I=m(t.exports.meshopt_simplifySloppy,R,y.length,v,v.length/_,_*4,A,M,N);return I[0]=y instanceof Uint32Array?I[0]:new y.constructor(I[0]),I},simplifyPrune:function(y,v,_,A){a(y instanceof Uint32Array||y instanceof Int32Array||y instanceof Uint16Array||y instanceof Int16Array),a(y.length%3==0),a(v instanceof Float32Array),a(v.length%_==0),a(_>=3),a(A>=0);var M=y.BYTES_PER_ELEMENT==4?y:new Uint32Array(y),N=b(t.exports.meshopt_simplifyPrune,M,y.length,v,v.length/_,_*4,A);return N=y instanceof Uint32Array?N:new y.constructor(N),N},remesh:function(y,v,_,A,M){a(y instanceof Uint32Array||y instanceof Int32Array||y instanceof Uint16Array||y instanceof Int16Array),a(y.length%3==0),a(v instanceof Float32Array),a(v.length%_==0),a(_>=3),a(A>=4&&A<=256);for(var N=0,R=0;R<(M?M.length:0);++R)a(M[R]in T),N|=T[M[R]];var I=y.BYTES_PER_ELEMENT==4?y:new Uint32Array(y);return g(t.exports.meshopt_remesh,I,v,_*4,A,N)}}})();var Yb=(function(){var r="b9H79Tebbbe:neP9Geueu9Geub9Gbb9Giuuueu9Gmuuuuuuuuuuu9999eu9Gouuuuuueu9Gruuuuuuub9Gxuuuuuuuuuuuueu9Gxuuuuuuuuuuu99eu9GPuuuuuuuuuuuuu99b9Gouuuuuub9Gwuuuuuuuub9Gvuuuuub9GluuuubiQXdilvorwDqokoqxmbiibeilve9Weiiviebeoweuecj:Gdkr;Zeqo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9I919P29K9nW79O2Wt79c9V919U9KbeY9TW79O9V9Wt9F9I919P29K9nW79O2Wt7S2W94bd39TW79O9V9Wt9F9I919P29K9nW79O2Wt79t9W9Ht9P9H2bo39TW79O9V9Wt9F9J9V9T9W91tWJ2917tWV9c9V919U9K7bw39TW79O9V9Wt9F9J9V9T9W91tW9nW79O2Wt9c9V919U9K7bkE9TW79O9V9Wt9F9J9V9T9W91tW9t9W9OWVW9c9V919U9K7bxL9TW79O9V9Wt9F9V9Wt9P9T9P96W9nW79O2WtbPl79IV9RbsDwebcekdOAq;W:leXdbkIbabaec9:fgefcufae9Ugeabci9Uadfcufad9Ugbaeab0Ek:88JDPue99eux99due99euo99iu8Jjjjjbc:WD9Rgm8KjjjjbdndnalmbcbhPxekamc:Cwfcbc;Kbz:rjjjb8AcuaocdtgsaocFFFFi0Ehzcbyd;0:G:cjbhHdndnalcb9imbaoal9nmbamazaHHjjjjbbgHBd:CwamceBd;8wamazcbyd;0:G:cjbHjjjjbbgOBd:GwamcdBd;8wamcualcdtalcFFFFi0Ecbyd;0:G:cjbHjjjjbbgABd:KwamciBd;8waihzalhsinaHazydbcdtfcbBdbazclfhzascufgsmbkaihzalhsinaHazydbcdtfgCaCydbcefBdbazclfhzascufgsmbkaihzalhCcbhXindnaHazydbcdtgQfgsydbcb9imbaOaQfaXBdbasasydbgQcjjjj94VBdbaQaXfhXkazclfhzaCcufgCmbkalci9UhLdnalci6mbcbhzaihsinascwfydbhCasclfydbhXaOasydbcdtfgQaQydbgQcefBdbaAaQcdtfazBdbaOaXcdtfgXaXydbgXcefBdbaAaXcdtfazBdbaOaCcdtfgCaCydbgCcefBdbaAaCcdtfazBdbascxfhsaLazcefgz9hmbkkaihzalhsindnaHazydbcdtgCfgXydbgQcu9kmbaXaQcFFFFrGgQBdbaOaCfgCaCydbaQ9RBdbkazclfhzascufgsmbxdkkamazaHHjjjjbbgHBd:CwamceBd;8wamazcbyd;0:G:cjbHjjjjbbgOBd:GwamcdBd;8wamcualcdtalcFFFFi0Ecbyd;0:G:cjbHjjjjbbgABd:KwamciBd;8waHcbasz:rjjjbhXaihzalhsinaXazydbcdtfgCaCydbcefBdbazclfhzascufgsmbkalci9UhLdnaoTmbcbhzaOhsaXhCaohQinasazBdbasclfhsaCydbazfhzaCclfhCaQcufgQmbkkdnalci6mbcbhzaihsinascwfydbhCasclfydbhQaOasydbcdtfgKaKydbgKcefBdbaAaKcdtfazBdbaOaQcdtfgQaQydbgQcefBdbaAaQcdtfazBdbaOaCcdtfgCaCydbgCcefBdbaAaCcdtfazBdbascxfhsaLazcefgz9hmbkkaoTmbcbhzaohsinaOazfgCaCydbaXazfydb9RBdbazclfhzascufgsmbkkamaLcbyd;0:G:cjbHjjjjbbgzBd:OwamclBd;8wazcbaLz:rjjjbhYamcuaLcK2alcjjjjd0Ecbyd;0:G:cjbHjjjjbbg8ABd:SwamcvBd;8wJbbbbhEdnalci6g3mbarcd4hKaihsa8AhzaLhrJbbbbh5inavasclfydbaK2cdtfgCIdlh8EavasydbaK2cdtfgXIdlhEavascwfydbaK2cdtfgQIdlh8FaCIdwhaaXIdwhhaQIdwhgazaCIdbg8JaXIdbg8KMaQIdbg8LMJbbnn:vUdbazclfaXIdlaCIdlMaQIdlMJbbnn:vUdbaQIdwh8MaCIdwh8NaXIdwhyazcxfa8EaE:tg8Eagah:tggNaaah:tgaa8FaE:tghN:tgEJbbbbJbbjZa8Ja8K:tg8FahNa8Ea8La8K:tg8KN:tghahNaEaENaaa8KNa8FagN:tgEaENMMg8K:rg8E:va8KJbbbb9BEg8KNUdbazczfaEa8KNUdbazcCfaha8KNUdbazcwfa8Maya8NMMJbbnn:vUdba5a8EMh5ascxfhsazcKfhzarcufgrmbka5aL:Z:vJbbbZNhEkamcuaLcdtalcFFFF970Ecbyd;0:G:cjbHjjjjbbgCBd:WwamcoBd;8waq:Zhhdna3mbcbhzaChsinasazBdbasclfhsaLazcefgz9hmbkkaEahNhhamcuaLcltalcFFFFd0Ecbyd;0:G:cjbHjjjjbbg8PBd:0wamcrBd;8wcba8Pa8AaCaLcbz:djjjb8AJFFuuh8MJFFuuh8NJFFuuhydnalci6mbJFFuuhya8AhzaLhsJFFuuh8NJFFuuh8MinazcwfIdbgEa8Ma8MaE9EEh8MazclfIdbgEa8Na8NaE9EEh8NazIdbgEayayaE9EEhyazcKfhzascufgsmbkkah:rhEamaocetgzcuaocu9kEcbyd;0:G:cjbHjjjjbbgCBd:4wdndnaoal9nmbaihzalhsinaCazydbcetfcFFi87ebazclfhzascufgsmbxdkkaCcFeazz:rjjjb8AkaEJbbbZNh8JcuhIdnalci6mbcbhsJFFuuhEa8AhzcuhIinazcwfIdba8M:tghahNazIdbay:tghahNazclfIdba8N:tghahNMM:rghaEaIcuSahaE9DVgXEhEasaIaXEhIazcKfhzaLascefgs9hmbkkamczfcbcjwz:rjjjb8Aam9cb83iwam9cb83ibaxa8JNh8RJbbjZak:th8Lcbh8SJbbbbhRJbbbbh8UJbbbbh8VJbbbbh8WJbbbbh8XJbbbbh8Ycbh8ZcbhPinJbbbbhEdna8STmbJbbjZa8S:Z:vhEkJbbbbhhdna8Ya8YNa8Wa8WNa8Xa8XNMMg8KJbbbb9BmbJbbjZa8K:r:vhhka8VaENh8Ka8UaENh5aRaENh8EaIhLdndndndndna8SaPVTmbamydwg80Tmea8YahNh8Fa8XahNhaa8WahNhgaeamydbcdtfh81cbh3JFFuuhEcvhQcuhLindnaHa81a3cdtfydbcdtgzfydbgvTmbaAaOazfydbcdtfhsindndnaCaiasydbgKcx2fgzclfydbgrcetf8Vebcs4aCazydbgXcetf8Vebcs4faCazcwfydbglcetf8Vebcs4fgombcbhzxekcehzaHaXcdtfydbgXceSmbcehzaHarcdtfydbgrceSmbcehzaHalcdtfydbglceSmbdnarcdSaXcdSfalcdSfcd6mbaocefhzxekaocdfhzkdnazaQ9kmba8AaKcK2fgXIdwa8K:tghahNaXIdba8E:tghahNaXIdla5:tghahNMM:ra8J:va8LNJbbjZMJ9VO:d86JbbjZaXIdCa8FNaXIdxagNaaaXIdzNMMakN:tghahJ9VO:d869DENghaEazaQ6ahaE9DVgXEhEaKaLaXEhLazaQaXEhQkasclfhsavcufgvmbkka3cefg3a809hmbkkaLcu9hmekama8KUd:ODama5Ud:KDama8EUd:GDamcuBd:qDamcFFF;7rBdjDa8Pcba8AaYamc:GDfamc:qDfamcjDfz:ejjjbamyd:qDhLdndnaxJbbbb9ETmba8SaD6mbaLcuSmeceh3amIdjDa8R9EmixdkaLcu9hmekdna8STmbabaPcltfgHam8Piw83dwaHam8Pib83dbaPcefhPkc3hHinamc:CwfaHfydbcbyd;4:G:cjbH:bjjjbbaHc98fgHc989hmbxvkkcbh3a8Saq9pmbamydwaCaiaLcx2fgzydbcetf8Vebcs4aCazcwfydbcetf8Vebcs4faCazclfydbcetf8Vebcs4ffaw9nmekcbhzcbhsdna8ZTmbcbhsamczfhXinamczfascdtfaXydbgQBdbaXclfhXasaYaQfRbbTfhsa8Zcufg8ZmbkkamydwhlamydbhXam9cu83i:GDam9cu83i:ODam9cu83i:qDam9cu83i:yDinamcjDfazfcFFF;7rBdbazclfgzcz9hmbkasc;8easclfc:bd6Eg8Zcdth80dnalTmbaeaXcdtfhocbhrindnaHaoarcdtfydbcdtgzfydbgvTmbaAaOazfydbcdtfhscuhQcuhzinaHaiasydbgKcx2fgXclfydbcdtfydbaHaXydbcdtfydbfaHaXcwfydbcdtfydbfgXazaXaz6gXEhzaKaQaXEhQasclfhsavcufgvmbkaQcuSmba8AaQcK2fgsIdwa8M:tgEaENasIdbay:tgEaENasIdla8N:tgEaENMM:rhEcbhsindndnazamc:qDfasfgvydbgX6mbazaX9hmeaEamcjDfasfIdb9FTmekavazBdbamc:GDfasfaQBdbamcjDfasfaEUdbxdkasclfgscz9hmbkkarcefgral9hmbkkamczfa80fhQcbhzcbhsindnamc:GDfazfydbgXcuSmbaQascdtfaXBdbascefhskazclfgzcz9hmbkasa8Zfg8ZTmbJFFuuhhcuhKamczfhza8ZhvcuhQina8AazydbgXcK2fgsIdwa8M:tgEaENasIdbay:tgEaENasIdla8N:tgEaENMM:rhEdndnaHaiaXcx2fgsclfydbcdtfydbaHasydbcdtfydbfaHascwfydbcdtfydbfgsaQ6mbasaQ9hmeaEah9DTmekaEhhashQaXhKkazclfhzavcufgvmbkaKcuSmbaKhLkdnamaiaLcx2fgrydbarclfydbarcwfydbaCabaeadaPawaqa3z:fjjjbTmbaPcefhPJbbbbhRJbbbbh8UJbbbbh8VJbbbbh8WJbbbbh8XJbbbbh8YkcbhXinaAaOaraXcdtfydbcdtgsfydbcdtfgKhzaHasfgvydbgQhsdnaQTmbdninazydbaLSmeazclfhzascufgsTmdxbkkazaKaQcdtfc98fydbBdbavavydbcufBdbkaXcefgXci9hmbka8AaLcK2fgzIdbhEazIdlhhazIdwh8KazIdxh5azIdzh8EazIdCh8FaYaLfce86bba8Ya8FMh8Ya8Xa8EMh8Xa8Wa5Mh8Wa8Va8KMh8Va8UahMh8UaRaEMhRamydxh8Sxbkkamc:WDf8KjjjjbaPkjoivuv99lu8Jjjjjbca9Rgo8Kjjjjbdndnalcw0mbaiydbhraeabcitfgwalcdtciVBdlawarBdbdnalcd6mbaiclfhralcufhDawcxfhwinarydbhqawcuBdbawc98faqBdbawcwfhwarclfhraDcufgDmbkkalabfhwxekcbhqaocbBdKao9cb83izaocbBdwao9cb83ibJbbjZhkJbbjZhxinadaiaqcdtfydbcK2fhDcbhwinaoczfawfgraDawfIdbgmarIdbgP:tgsaxNaPMgPUdbaoawfgrasamaP:tNarIdbMUdbawclfgwcx9hmbkJbbjZakJbbjZMgk:vhxaqcefgqal9hmbkcbhradcbcecdaoIdlgmaoIdwgP9GEgwaoIdbgsaP9GEawasam9GEgzcdtgwfhHaoczfawfIdbhmaihwalhDinaiarcdtfgqydbhOaqawydbgABdbawaOBdbawclfhwaraHaAcK2fIdbam9DfhraDcufgDmbkdndnarcv6mbavc8X9kmbaralc98f6mekaiydbhraeabcitfgwalcdtciVBdlawarBdbaiclfhralcufhDawcxfhwinarydbhqawcuBdbawc98faqBdbawcwfhwarclfhraDcufgDmbkalabfhwxekaeabcitfgwamUdbawawydlc98GazVBdlabcefaeadaiaravcefgqz:djjjbhDawawydlciGaDabcu7fcdtVBdlaDaeadaiarcdtfalar9Raqz:djjjbhwkaocaf8Kjjjjbawk;Oddvue99dninabaecitfgrydlgwcd4gDTmednawciGgqci9hmbcihqdnawcl6mbabaecitfhbcbheawhqcehkindnaiabydbgDfRbbmbcbhkadaDcK2fgwIdwalIdw:tgxaxNawIdbalIdb:tgxaxNawIdlalIdl:tgxaxNMM:rgxaoIdb9DTmbaoaxUdbavaDBdbarydlhqkabcwfhbaecefgeaqcd46mbkakceGTmikaraqciGBdlskdnabcbaDalaqcdtfIdbarIdb:tgxJbbbb9FEgwaD7aecefgDfgecitfydlabawaDfgDcitfydlVci0mbaraqBdlkabaDadaialavaoz:ejjjbax:laoIdb9Fmbkkkjlevudndnabydwgxaladcetfgm8Vebcs4alaecetfgP8Vebgscs4falaicetfgz8Vebcs4ffaD0mbakmbcbhDabydxaq6mekavawcltfgxab8Pdw83dwaxab8Pdb83dbabydbhDdnabydwgwTmbaoaDcdtfhxawhsinalaxydbcetfcFFi87ebaxclfhxascufgsmbkkabaDawfBdbabydxhxab9cb83dwababydlaxci2fBdlaP8VebhscehDcbhxkdnascztcz91cu9kmbabaxcefBdwaPax87ebaoabydbcdtfaxcdtfaeBdbkdnam8Uebcu9kmbababydwgxcefBdwamax87ebaoabydbcdtfaxcdtfadBdbkdnaz8Uebcu9kmbababydwgxcefBdwazax87ebaoabydbcdtfaxcdtfaiBdbkarabydlfabydxci2faPRbb86bbarabydlfabydxci2fcefamRbb86bbarabydlfabydxci2fcdfazRbb86bbababydxcefBdxaDk:mPrHue99eue99eue99iu8Jjjjjbc;W;Gb9Rgx8KjjjjbdndnalmbcbhmxekcbhPaxc:m;Gbfcbc;Kbz:rjjjb8Aaxcualci9UgscltascjjjjiGEcbyd;0:G:cjbHjjjjbbgzBd:m9GaxceBd;S9GaxcuascK2gHcKfalcpFFFe0Ecbyd;0:G:cjbHjjjjbbgOBd:q9GaxcdBd;S9Gdnalci6gAmbarcd4hCascdthXaOhQazhLinavaiaPcx2fgrydwaC2cdtfhKavarydlaC2cdtfhYavarydbaC2cdtfh8AcbhraLhEinaQarfgma8Aarfg3Idbg5aYarfg8EIdbg8Fa5a8F9DEg5UdbamaKarfgaIdbg8Fa5a8Fa59DEg8FUdbamcxfgma3Idbg5a8EIdbgha5ah9EEg5UdbamaaIdbgha5aha59EEg5UdbaEa8Fa5MJbbbZNUdbaEaXfhEarclfgrcx9hmbkaQcKfhQaLclfhLaPcefgPas9hmbkkaOaHfgr9cb83dbar9cb83dzar9cb83dwaxcuascx2gralc:bjjjl0Ecbyd;0:G:cjbHjjjjbbgHBdN9GaxciBd;S9GascdthgazarfhvaxcwVhPaxclVhCaHh8Jazh8KcbhLinaxcbcj;Gbz:rjjjbhEaLas2cdthadnaAmba8Khrash3inaEarydbgmc8F91cjjjj94Vam7gmcQ4cx2fg8Ea8EydwcefBdwaEamcd4cFrGcx2fg8Ea8EydbcefBdbaEamcx4cFrGcx2fgmamydlcefBdlarclfhra3cufg3mbkkazaafh8AaHaafhXcbhmcbh3cbh8EcbhainaEamfgrydbhQara3BdbarcwfgKydbhYaKaaBdbarclfgrydbhKara8EBdbaQa3fh3aYaafhaaKa8Efh8Eamcxfgmcj;Gb9hmbkdnaAmbcbhravhminamarBdbamclfhmasarcefgr9hmbkavhrashminaEa8Aarydbg3cdtfydbg8Ec8F91a8E7cd4cFrGcx2fg8Ea8Eydbg8EcefBdbaXa8Ecdtfa3Bdbarclfhramcufgmmbka8JhrashminaCa8Aarydbg3cdtfydbg8Ec8F91a8E7cx4cFrGcx2fg8Ea8Eydbg8EcefBdbava8Ecdtfa3BdbarclfhramcufgmmbkavhrashminaPa8Aarydbg3cdtfydbg8Ec8F91cjjjj94Va8E7cQ4cx2fg8Ea8Eydbg8EcefBdbaXa8Ecdtfa3Bdbarclfhramcufgmmbkka8Jagfh8Ja8Kagfh8KaLcefgLci9hmbkaEaocetgrcuaocu9kEcbyd;0:G:cjbHjjjjbbgKBd:y9GaEclBd;S9Gdndnaoal9nmbaihralhminaKarydbcetfcFFi87ebarclfhramcufgmmbxdkkaKcFearz:rjjjb8Akcbh8EaEascbyd;0:G:cjbHjjjjbbg8ABd:C9GaOaHaHascdtfaHascitfa8AascbazaKaiawaDaqakz:hjjjbdndnalci6mba8Ahrashmina8EarRbbfh8EarcefhramcufgmmbkaE9cb83iwaE9cb83ibalawc9:fgrfcufar9UgrasaDfcufaD9Ugmaram0EhYcbhmcbhra8Ehaincbh3dnarTmba8AarfRbbceSh3kamaEaiaHydbcx2fgQydbaQclfydbaQcwfydbaKabaeadamawaqa3a3ce7a8EaY9nVaaamfaY6VGz:fjjjbfhmaHclfhHaaa8AarfRbb9Rhaasarcefgr9hmbkaEydxTmeabamcltfgraE8Piw83dwaraE8Pib83dbamcefhmxekaE9cb83iwaE9cb83ibcbhmkczhrinaEc:m;Gbfarfydbcbyd;4:G:cjbH:bjjjbbarc98fgrc989hmbkkaxc;W;Gbf8Kjjjjbamk:wKDQue99iue99iul9:euw99iu8Jjjjjbc;qb9RgP8Kjjjjbaxhsaxhzdndnavax0gHmbdnavTmbcbhOaehzavhAinawaDazydbcx2fgCcwfydbcetfgX8VebhQawaCclfydbcetfgL8VebhKawaCydbcetfgC8VebhYaXce87ebaLce87ebaCce87ebaOaKcs4aYcs4faQcs4ffhOazclfhzaAcufgAmbkaehzavhAinawaDazydbcx2fgCcwfydbcetfcFFi87ebawaCclfydbcetfcFFi87ebawaCydbcetfcFFi87ebazclfhzaAcufgAmbkcehzaqhsaOaq0mekalce86bbalcefcbavcufz:rjjjb8AxekaPaiBdxaPadBdwaPaeBdlavakaqci9Ug8Aaka8Aak6EaHEgK9RhEaxaK9Rh3aKcufh5aKceth8EaKcdtgCc98fh8FavcitgOaC9Rarfc98fhaascufhhavcufhgaraOfh8JJbbjZas:Y:vh8KcbazceakaxSEg8Lcdtg8M9Rh8NJFFuuhycuh8PcbhIcbh8RinaPclfa8RcdtfydbhQaPcb8Pd:y:G:cjbg8S83i9iaPcb8Pd:q:G:cjbgR83inaPcb8Pd1:G:cjbg8U83iUaPcb8Pdj:G:cjbg8V83i8WaPa8S83iyaPaR83iaaPa8U83iKaPa8V83izaQavcdtgYfh8WcbhXinabaQaXcdtgLfydbcK2fhAcbhzinaPc8WfazfgCaAazfgOIdbg8XaCIdbg8Ya8Xa8Y9DEUdbaCczfgCaOcxfIdbg8XaCIdbg8Ya8Xa8Y9EEUdbazclfgzcx9hmbkaba8WaXcu7cdtfydbcK2fhAcbhzaPIdUh8ZaPId9ih80aPId80h81aPId9ehBaPId8Wh83aPIdnhUinaPczfazfgCaAazfgOIdbg8XaCIdbg8Ya8Xa8Y9DEUdbaCczfgCaOcxfIdbg8XaCIdbg8Ya8Xa8Y9EEUdbazclfgzcx9hmbkaraLfgza80a8Z:tg8XaUa83:tg8YNa8YaBa81:tg8ZNa8Za8XNMMUdbazaYfaPIdyaPIdK:tg8XaPIdaaPIdz:tg8YNa8YaPId8KaPIdC:tg8ZNa8Za8XNMMUdbaXcefgXav9hmbkcbh85dnaHmbcbhAaQhza8JhCavhXinawaDazydbcx2fgOcwfydbcetfgL8Vebh8WawaOclfydbcetfg858Vebh86awaOydbcetfgO8Vebh87aLce87eba85ce87ebaOce87ebaCaAa86cs4a87cs4fa8Wcs4ffgABdbazclfhzaCclfhCaXcufgXmbkavhCinawaDaQydbcx2fgzcwfydbcetfcFFi87ebawazclfydbcetfcFFi87ebawazydbcetfcFFi87ebaQclfhQaCcufgCmbka8Jh85kdndndndndndndndndndndnava8E6mba8Eax9nmeavavaK9UgzaK29Raza320mda5aE9pmqa85Th87ceh8WaEhQxwka5ag9pmDa8Eax9nmixokavaK6mea5aE9pmwcehQaEhXa85Tmixlka5ag6mlxrka5ag9pmokcbhQaghXa85mekJFFuuh8XcbhLa5hzindnazcefgCaK6mbaQavaC9RgOaK6GmbarazcdtfIdbg8YaC:YNaravaz9RcdtfaYfc94fIdbg8ZaO:YNMg80a8X9Embdndna8KaOahf:YNg81:lJbbb9p9DTmba81:OhAxekcjjjj94hAka8ZasaA2aO9R:YNh8Zdndna8Kazasf:YNg81:lJbbb9p9DTmba81:OhOxekcjjjj94hOkamasaO2aC9R:Ya8YNa8ZMNa80Mg8Ya8Xa8Ya8X9DgOEh8XaCaLaOEhLkaza8LfgzaX6mbxlkkJFFuuh8XcbhLaEhCaahAa8FhOaKhzindnazaK6mbaQaCaK6GmbaraOfIdbg8Yaz:YNaAIdbg8ZaC:YNMg80a8X9Embdndna8Ka85aOfydbgYahf:YNg81:lJbbb9p9DTmba81:Oh8Wxekcjjjj94h8Wkamasa8W2aY9R:Yg81a8YNa8Za81NMNa80Mg8Ya8Xa8Ya8X9DgYEh8XazaLaYEhLkaCa8L9RhCaAa8NfhAaOa8MfhOaza8LfgzcufaX6mbxikka85Th87cbh8WaghQkJFFuuh8XcbhLaEhCaahAa8FhOaKhzindnazazaK9UgXaK29RaXa320mbdna8WTmbaCaCaK9UgXaK29RaXa320mekaraOfIdbg8Yaz:YNaAIdbg8ZaC:YNMg80a8X9EmbazhXaChYdna87mba85aOfydbgXhYkdndna8KaYahf:YNg81:lJbbb9p9DTmba81:Oh86xekcjjjj94h86ka8Zasa862aY9R:YNh8Zdndna8KaXahf:YNg81:lJbbb9p9DTmba81:OhYxekcjjjj94hYkamasaY2aX9R:Ya8YNa8ZMNa80Mg8Ya8Xa8Ya8X9DgXEh8XazaLaXEhLkaCa8L9RhCaAa8NfhAaOa8MfhOaza8LfgzcufaQ6mbkkaLTmba8Xay9DTmba8XhyaLhIa8Rh8Pka8Rcefg8Rci9hmbkdndnaoc8X9kmba8Pcb9omeka8Acufh85cbhYindndndnavaY9RaxaYaxfav0Eg8WTmbcbhAaeaYcdtfgzhCa8WhXinawaDaCydbcx2fgOcwfydbcetfgQ8VebhbawaOclfydbcetfgL8VebhrawaOydbcetfgO8VebhKaQce87ebaLce87ebaOce87ebaAarcs4aKcs4fabcs4ffhAaCclfhCaXcufgXmbka8WhOinawaDazydbcx2fgCcwfydbcetfcFFi87ebawaCclfydbcetfcFFi87ebawaCydbcetfcFFi87ebazclfhzaOcufgOmbkaAaq0mekalaYfgzce86bbazcefcba8Wcufz:rjjjb8AxekalaYfgzce86bbazcefcba85z:rjjjb8Aa8Ah8Wka8WaYfgYav9pmdxbkkaravcdtg8WfhLdnaITmbaPclfa8PcdtfydbhzaIhCinaLazydbfcb86bbazclfhzaCcufgCmbkkdnavaI9nmbaPclfa8PcdtfydbaIcdtfhzavaI9RhCinaLazydbfce86bbazclfhzaCcufgCmbkkcbhYindnaYa8PSmbcbhzaraPclfaYcdtfydbgKa8Wz:qjjjbhCavhXaIhOinaKaOazaLaCydbgQfRbbgAEcdtfaQBdbaCclfhCaOaAfhOazaA9RcefhzaXcufgXmbkkaYcefgYci9hmbkabaeadaialaIaocefgCarawaDaqakaxamz:hjjjbabaeaIcdtgzfadazfaiazfalaIfavaI9RaCarawaDaqakaxamz:hjjjbkaPc;qbf8Kjjjjbk:Seeru8Jjjjjbc:q;ab9Rgo8Kjjjjbaoc:q8WfcFecjzz:rjjjb8AcbhrdnadTmbaehwadhDinaoarcdtfawydbgqBdbaoc:q8WfaqcFiGcdtfgkydbhxakaqBdbawclfhwaraxaq9hfhraDcufgDmbkkabaeadaoaraiavz:jjjjbaoc:q;abf8Kjjjjbk;Sqloud99euD998Jjjjjbc:W;ab9Rgr8KjjjjbdndnadTmbaocd4hwcbhDcbhqindnavaeclfydbaw2cdtfgkIdbavaeydbaw2cdtfgxIdbgm:tgPavaecwfydbaw2cdtfgsIdlaxIdlgz:tgHNakIdlaz:tgOasIdbam:tgAN:tgCaCNaOasIdwaxIdwgX:tgQNakIdwaX:tgOaHN:tgHaHNaOaANaPaQN:tgPaPNMMgOJbbbb9Bmbarc8WfaDcltfgkaCaO:rgO:vgCUdwakaPaO:vgPUdlakaHaO:vgHUdbakaCaXNaHamNazaPNMM:mUdxaDcefhDkaecxfheaqcifgqad6mbkab9cb83dyab9cb83daab9cb83dKab9cb83dzab9cb83dwab9cb83dbaDTmearcbBd8Sar9cb83iKar9cb83izarczfavalaoarc8Sfcbcraiz:kjjjbarIdKhQarIdChLarIdzhKar9cb83iwar9cb83ibararc8WfaDczarc8Sfcbcicbz:kjjjbJbbbbhmdnarIdwgzazNarIdbgHaHNarIdlgXaXNMMgCJbbbb9BmbJbbjZaC:r:vhmkazamNhCaXamNhXaHamNhHJbbjZhmarc8WfheaDhvinaecwfIdbaCNaeIdbaHNaXaeclfIdbNMMgzamazam9DEhmaeczfheavcufgvmbkabaQUdwabaLUdlabaKUdbabarId3UdxdndnamJ;n;m;m899FmbJbbbbhzarc8WfheinaecxfIdbaQaecwfIdbgPNaKaeIdbgONaLaeclfIdbgANMMMaCaPNaHaONaXaANMM:vgPazaPaz9EEhzaeczfheaDcufgDmbkabaCUd8KabaXUdaabaHUd3abaQaCazN:tUdKabaLaXazN:tUdCabaKaHazN:tUdzabJbbjZamamN:t:rgmUdydndnaCJbbj:;aCJbbj:;9GEgzJbbjZazJbbjZ9FEJbb;:9cNJbbbZJbbb:;aCJbbbb9GEMgz:lJbbb9p9DTmbaz:Ohexekcjjjj94hekabae86b8UdndnaXJbbj:;aXJbbj:;9GEgzJbbjZazJbbjZ9FEJbb;:9cNJbbbZJbbb:;aXJbbbb9GEMgz:lJbbb9p9DTmbaz:Ohvxekcjjjj94hvkabav86bRdndnaHJbbj:;aHJbbj:;9GEgzJbbjZazJbbjZ9FEJbb;:9cNJbbbZJbbb:;aHJbbbb9GEMgz:lJbbb9p9DTmbaz:Ohwxekcjjjj94hwkabaw86b8SdndnaecKtcK91:YJbb;:9c:vaC:t:lavcKtcK91:YJbb;:9c:vaX:t:lawcKtcK91:YJbb;:9c:vaH:t:lamMMMJbb;:9cNJbbjZMgm:lJbbb9p9DTmbam:Ohexekcjjjj94hekaecFbaecFb9iEhexekabcjjj;8iBdycFbhekabae86b8Vxekab9cb83dyab9cb83daab9cb83dKab9cb83dzab9cb83dwab9cb83dbkarc:W;abf8Kjjjjbk;7woDuo99eue99euv998Jjjjjbcje9Rgw8Kjjjjbawc;abfcbaocdtgDz:rjjjb8Aawc;GbfcbaDz:rjjjb8AawcafhDawhqaohkinaqcFFF97BdbaDcFFF;7rBdbaqclfhqaDclfhDakcufgkmbkavcd4hxaicd4hmdnadTmbaocx2hPcbhsinashzdnarTmbarascdtfydbhzkaeazam2cdtfgDIdwhHaDIdlhOaDIdbhAalazax2cdtfIdbhCcbhDawcafhqawc;Gbfhvawhkawc;abfhiinaCaDc:O:G:cjbfIdbaHNaDc:G:G:cjbfIdbaANaDc:K:G:cjbfIdbaONMMgXMhQazhLdnaXaC:tgXaqIdbgK9DgYmbavydbhLkavaLBdbazhLdnaQakIdbg8A9EmbaiydbhLa8AhQkaiaLBdbakaQUdbaqaXaKaYEUdbaiclfhiakclfhkavclfhvaqclfhqaPaDcxfgD9hmbkascefgsad9hmbkkJbbbbhQcbhLawc;GbfhDawc;abfhqcbhkinalaqydbgvax2cdtfIdbalaDydbgiax2cdtfIdbaeavam2cdtfgvIdwaeaiam2cdtfgiIdw:tgCaCNavIdbaiIdb:tgCaCNavIdlaiIdl:tgCaCNMM:rMMgCaQaCaQ9EgvEhQakaLavEhLaqclfhqaDclfhDaoakcefgk9hmbkJbbbbhCdnaeawc;abfaLcdtgqfydbgkam2cdtfgDIdwaeawc;Gbfaqfydbgvam2cdtfgqIdwgH:tgXaXNaDIdbaqIdbgA:tg8Aa8ANaDIdlaqIdlgE:tgOaONMMgKJbbbb9ETmbaK:rgCalakax2cdtfIdbMalavax2cdtfIdb:taCaCM:vhCkaQJbbbZNhKaXaCNaHMhHaOaCNaEMhOa8AaCNaAMhAdnadTmbcbhqarhkinaqhDdnarTmbakydbhDkdnalaDax2cdtfIdbg3aeaDam2cdtfgDIdwaH:tgQaQNaDIdbaA:tgCaCNaDIdlaO:tgXaXNMMg5:rgEMg8EaK9ETmbJbbbbh8Adna5Jbbbb9ETmba8EaK:taEaEM:vh8Aka8AaQNaHMhHa8AaXNaOMhOa8AaCNaAMhAa3aKaEMMJbbbZNhKkakclfhkadaqcefgq9hmbkkabaKUdxabaHUdwabaOUdlabaAUdbawcjef8Kjjjjbk:reevu8Jjjjjbcj8W9Rgr8Kjjjjbaici2hwcbhDdnaiTmbarhiawhqinaiaeadRbbgkcdtfydbBdbaDakcefgkaDak0EhDaiclfhiadcefhdaqcufgqmbkkabarawaeaDalaoz:jjjjbarcj8Wf8Kjjjjbk:Eeeeu8Jjjjjbca9Rgo8Kjjjjbab9cb83dyab9cb83daab9cb83dKab9cb83dzab9cb83dwab9cb83dbdnadTmbaocbBd3ao9cb83iwao9cb83ibaoaeadaialaoc3falEavcbalEcrcbz:kjjjbabao8Pib83dbabao8Piw83dwkaocaf8Kjjjjbk::meQu8Jjjjjbcjz9Rgv8KjjjjbcbhoavcjPfcbaez:rjjjb8Aavcjxfcbaez:rjjjb8AdnaiTmbadhoaihrinavcjxfaoRbbfgwawRbbcef86bbavcjxfaocefRbbfgwawRbbcef86bbavcjxfaocdfRbbfgwawRbbcef86bbaocifhoarcufgrmbkcbhDcjehoadhqcehkindndnalTmbcbhxcuhmaqhrakhwcuhPinawcufamaoavcjPfarcefRbbgsfRbb9RcFeGgzci6aoavcjPfarRbbgHfRbb9RcFeGgOci6faoavcjPfarcdfRbbgAfRbb9RcFeGgCci6fgXcOtaOcFr7azaCf9RcwtVavcjxfaAfRbbgzavcjxfaHfRbbgHavcjxfasfRbbgsaHas6Egsazas6EcFe7VgsaP9kgzEhmaXcd6gHaxcefgOal9iVce9hmdasaPazEhPaxaOaHEhxarcifhrawai6hsawcefhwasmbxdkkcuhmaqhrakhwcuhxinawcufamaoavcjPfarcefRbbfRbb9RcFeGci6aoavcjPfarRbbfRbb9RcFeGci6faoavcjPfarcdfRbbfRbb9RcFeGci6fgPax9kgsEhmaPce0meaPaxasEhxarcifhrawai6hPawcefhwaPmbkkadamci2fgrcdfRbbhwarcefRbbhxarRbbhPadaDci2fgrcifaramaD9Rci2zNjjjb8AaPavcjPffaocefgo86bbaPavcjxffgmamRbbcuf86bbaxavcjPffao86bbaxavcjxffgmamRbbcuf86bbarcdfaw86bbarcefax86bbaraP86bbawavcjPffao86bbawavcjxffgrarRbbcuf86bbaqcifhqakcefhkaDcefgDai9hmbkcbhzdnalcb9mmbcbhsavcjPfcbaez:rjjjb8Aadcvfhlinadasci2fgxcefgDRbbhoaxcdfgqRbbhrdndnavcjPfaxRbbgmfRbbmbavcjPfarfRbbhwdndndnavcjPfaofRbbTmbawcFeGTmexikawcFeGmdascefgAai9pmdasc980mdascifhQcbhLarcFeGhCamcFeGhXalhwcbhKcbhYinawcufRbbhPawRbbhOcehkdndnawc9:fRbbgHao9hmbaPcFeGamSmekdnaPcFeGao9hmbaOcFeGamSmekaHamSaOcFeGaoSGhkkceh8AaYceGhYdndnaHar9hmbaPcFeGaoSmekdnaPcFeGar9hmbaOcFeGaoSmekaHaoSaOcFeGarSGh8AkakaYVhYaLaHcFeGgHaXSaPcFeGgPaCSGaPaXSaOcFeGgPaCSGVaHaCSaPaXSGVVhLa8AaKceGVhKdnaAcefgPai9pmbawcifhwaAaQ6hHaPhAaHmekkaYTmeaKmekarhwaohPaohHarhOamhrxdkdnaYTaLVceGTmbaYaKTVaLVceGmekamhwarhParhHamhOaohrxekaohwamhPamhHaohOkavcjPfarfce86bbavcjPfawfce86bbaxaH86bbaqar86bbaDaO86bbavcjPfaPfce86bbalcifhlascefgsai9hmbkkavcFeaecetz:rjjjbhwaici2hrindnawadRbbgmcetfgx8Uebgocu9kmbaxaz87ebawcjlfazcdtfabamcdtfydbBdbazhoazcefhzkadao86bbadcefhdarcufgrmbkazcdthokabavcjlfaoz:qjjjb8Aavcjzf8KjjjjbkObabaiaeadcbz:njjjbk9teiucbcbyd;8:G:cjbgeabcifc98GfgbBd;8:G:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaeczfheaiczfhiadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabk9teiucbcbyd;8:G:cjbgeabcrfc94GfgbBd;8:G:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikTeeucbabcbyd;8:G:cjbge9Rcifc98GaefgbBd;8:G:cjbdnabZbcztge9nmbabae9RcFFifcz4nb8Akk:3qeludndnadch6mbadTmeabaead;8qbbabskabaeSmbdnaeadabfgi9Rcbadcet9R0mbadTmeabaead;8qbbabskaeab7ciGhldndndnabae9pmbdnalTmbadhvabhixikdnabciGmbadhvabhixdkadTmiabaeRbb86bbadcufhvdnabcefgiciGmbaecefhexdkavTmiabaeRbe86beadc9:fhvdnabcdfgiciGmbaecdfhexdkavTmiabaeRbd86bdadc99fhvdnabcifgiciGmbaecifhexdkavTmiabaeRbi86biabclfhiaeclfheadc98fhvxekdnalmbdnaiciGTmbadTmlabadcufgifglaeaifRbb86bbdnalciGmbaihdxekaiTmlabadc9:fgifglaeaifRbb86bbdnalciGmbaihdxekaiTmlabadc99fgifglaeaifRbb86bbdnalciGmbaihdxekaiTmlabadc98fgdfaeadfRbb86bbkadcl6mbdnadc98fgocxGcxSmbaocd4cefciGhiaec98fhlabc98fhvinavadfaladfydbBdbadc98fhdaicufgimbkkaocx6mbaec9Wfhvabc9WfhoinaoadfgicxfavadfglcxfydbBdbaicwfalcwfydbBdbaiclfalclfydbBdbaialydbBdbadc9Wfgdci0mbkkadTmdadhidnadciGglTmbaecufhvabcufhoadhiinaoaifavaifRbb86bbaicufhialcufglmbkkadcl6mdaec98fhlabc98fhvinavaifgecifalaifgdcifRbb86bbaecdfadcdfRbb86bbaecefadcefRbb86bbaeadRbb86bbaic98fgimbxikkavcl6mbdnavc98fglc3Gc3Smbavalcd4cefcrGgdcdt9RhvinaiaeydbBdbaeclfheaiclfhiadcufgdmbkkalc36mbinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaiczfaeczfydbBdbaicCfaecCfydbBdbaicKfaecKfydbBdbaic3faec3fydbBdbaecafheaicafhiavc9Gfgvci0mbkkavTmbdndnavcrGgdmbavhlxekavc94GhlinaiaeRbb86bbaicefhiaecefheadcufgdmbkkavcw6mbinaiaeRbb86bbaicefaecefRbb86bbaicdfaecdfRbb86bbaicifaecifRbb86bbaiclfaeclfRbb86bbaicvfaecvfRbb86bbaicofaecofRbb86bbaicrfaecrfRbb86bbaicwfhiaecwfhealc94fglmbkkabkk:pedbcj:GdktFFuuFFuuFFuubbbbFFuFFFuFFFuFbbbbbbjZbbbbbbbbbbbbbbjZbbbbbbbbbbbbbbjZ86;nAZ86;nAZ86;nAZ86;nA:;86;nAZ86;nAZ86;nAZ86;nA:;86;nAZ86;nAZ86;nAZ86;nA:;bc;0:Gdkxebbbdbbbj:qbb",e=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if(typeof WebAssembly!="object")return{supported:!1};var t,s=WebAssembly.instantiate(n(r),{}).then(function(m){t=m.instance,t.exports.__wasm_call_ctors()});function n(m){for(var b=new Uint8Array(m.length),g=0;g<m.length;++g){var x=m.charCodeAt(g);b[g]=x>96?x-97:x>64?x-39:x+4}for(var T=0,g=0;g<m.length;++g)b[T++]=b[g]<60?e[b[g]]:(b[g]-60)*64+b[++g];return b.buffer.slice(0,T)}function a(m){if(!m)throw new Error("Assertion failed")}function i(m){return new Uint8Array(m.buffer,m.byteOffset,m.byteLength)}var o=48,c=16;function l(m,b){var g=m.meshlets[b*4+0],x=m.meshlets[b*4+1],T=m.meshlets[b*4+2],y=m.meshlets[b*4+3];return{vertices:m.vertices.subarray(g,g+T),triangles:m.triangles.subarray(x,x+y*3)}}function h(m,b,g,x,T,y,v,_,A,M){var N=t.exports.sbrk,R=t.exports.meshopt_buildMeshletsBound(b.length,y,v),I=N(R*c),D=N(b.length*4),O=N(b.length),P=N(b.byteLength),U=N(g.byteLength),j=new Uint8Array(t.exports.memory.buffer);j.set(i(b),P),j.set(i(g),U);var z=m(I,D,O,P,b.length,U,x,T,y,v,_,A,M);j=new Uint8Array(t.exports.memory.buffer);for(var H=j.subarray(I,I+z*c),J=new Uint32Array(H.buffer,H.byteOffset,H.byteLength/4).slice(),ee=0;ee<z;++ee){var se=J[ee*4+0],_e=J[ee*4+1],x=J[ee*4+2],Ae=J[ee*4+3];t.exports.meshopt_optimizeMeshlet(D+se*4,O+_e,Ae,x)}var Se=z?J[(z-1)*4+0]+J[(z-1)*4+2]:0,Fe=z?J[(z-1)*4+1]+J[(z-1)*4+3]*3:0,ft={meshlets:J,vertices:new Uint32Array(j.buffer,D,Se).slice(),triangles:new Uint8Array(j.buffer,O,Fe).slice(),meshletCount:z};return N(I-N(0)),ft}function u(m){var b=new Float32Array(t.exports.memory.buffer,m,o/4);return{centerX:b[0],centerY:b[1],centerZ:b[2],radius:b[3],coneApexX:b[4],coneApexY:b[5],coneApexZ:b[6],coneAxisX:b[7],coneAxisY:b[8],coneAxisZ:b[9],coneCutoff:b[10]}}function d(m,b,g,x){var T=t.exports.sbrk,y=[],v=T(b.byteLength),_=T(m.vertices.byteLength),A=T(m.triangles.byteLength),M=T(o),N=new Uint8Array(t.exports.memory.buffer);N.set(i(b),v),N.set(i(m.vertices),_),N.set(i(m.triangles),A);for(var R=0;R<m.meshletCount;++R){var I=m.meshlets[R*4+0],D=m.meshlets[R*4+1],O=m.meshlets[R*4+3];t.exports.meshopt_computeMeshletBounds(M,_+I*4,A+D,O,v,g,x),y.push(u(M))}return T(v-T(0)),y}function f(m,b,g,x){var T=t.exports.sbrk,y=T(o),v=T(m.byteLength),_=T(b.byteLength),A=new Uint8Array(t.exports.memory.buffer);A.set(i(m),v),A.set(i(b),_),t.exports.meshopt_computeClusterBounds(y,v,m.length,_,g,x);var M=u(y);return T(y-T(0)),M}function p(m,b,g,x,T){var y=t.exports.sbrk,v=y(o),_=y(m.byteLength),A=x?y(x.byteLength):0,M=new Uint8Array(t.exports.memory.buffer);M.set(i(m),_),x&&M.set(i(x),A),t.exports.meshopt_computeSphereBounds(v,_,b,g,A,x?T:0);var N=u(v);return y(v-y(0)),N}return{ready:s,supported:!0,buildMeshlets:function(m,b,g,x,T,y){a(m.length%3==0),a(b instanceof Float32Array),a(b.length%g==0),a(g>=3),a(x>=3&&x<=256),a(T>=1&&T<=512),y=y||0;var v=m.BYTES_PER_ELEMENT==4?m:new Uint32Array(m);return h(t.exports.meshopt_buildMeshletsFlex,v,b,b.length/g,g*4,x,T,T,y,0)},buildMeshletsFlex:function(m,b,g,x,T,y,v,_){a(m.length%3==0),a(b instanceof Float32Array),a(b.length%g==0),a(g>=3),a(x>=3&&x<=256),a(T>=1&&y<=512),a(T<=y),v=v||0,_=_||0;var A=m.BYTES_PER_ELEMENT==4?m:new Uint32Array(m);return h(t.exports.meshopt_buildMeshletsFlex,A,b,b.length/g,g*4,x,T,y,v,_)},buildMeshletsSpatial:function(m,b,g,x,T,y,v){a(m.length%3==0),a(b instanceof Float32Array),a(b.length%g==0),a(g>=3),a(x>=3&&x<=256),a(T>=1&&y<=512),a(T<=y),v=v||0;var _=m.BYTES_PER_ELEMENT==4?m:new Uint32Array(m);return h(t.exports.meshopt_buildMeshletsSpatial,_,b,b.length/g,g*4,x,T,y,v)},extractMeshlet:function(m,b){return a(b>=0&&b<m.meshletCount),l(m,b)},computeClusterBounds:function(m,b,g){a(m.length%3==0),a(m.length/3<=512),a(b instanceof Float32Array),a(b.length%g==0),a(g>=3);var x=m.BYTES_PER_ELEMENT==4?m:new Uint32Array(m);return f(x,b,b.length/g,g*4)},computeMeshletBounds:function(m,b,g){return a(b instanceof Float32Array),a(b.length%g==0),a(g>=3),d(m,b,b.length/g,g*4)},computeSphereBounds:function(m,b,g,x){return a(m instanceof Float32Array),a(m.length%b==0),a(b>=3),a(!g||g instanceof Float32Array),a(!g||g.length%x==0),a(!g||x>=1),a(!g||m.length/b==g.length/x),x=x||0,p(m,m.length/b,b*4,g,x*4)}}})();var pee=(function(){var r="b9H79Tebbbe9vx9Geueu9Geub9Gbb9Gkuuuuuuuuuuub9Gouuuuuub9Gwuuuuuu9999b9Giuuueu9Ge98e999Gvuuuuueu9Gd99ueu9Ge99e999Gd98ue98isPdilvboberrwDqklve9Weiiviebeoweuecj:Gdkr9Avo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bbK9TW79O9V9Wt9F9NW9UWV9HtW9u9H9U9NW9Ut7beL9TW79O9V9Wt9F9NW9UWV9HtW9o9VV9T9H27bil79IV9RblDwebcekdorq;X9PPdbk;e8EvHuw99euv99wu8Jjjjjbc;Wb9Rgk8Kjjjjbakcxfcbc;Kbz:fjjjb8AakcualcdtalcFFFFi0Ecbyd:W:2:cjbHjjjjbbgxBdxakceBd2adci9Uhmalcd4alfhPcehsinasgzcethsazaP6mbkakcuazcdtgsazcFFFFi0Ecbyd:W:2:cjbHjjjjbbgPBdzakcdBd2aPcFeasz:fjjjbhHaDcd4hOarcd4hAavcd4hCdnalTmbazcufhrcbhvindndnaHcbaiavaC2cdtfgzydlgDaDcjjjj94SEgPcH4cbaoavaA2cdtfgsydlgXcs4aXcjjjj94SE7aP7c:F:b:DD2cbazydbgQaQcjjjj94SEgPcH4cbasydbgLcs4aLcjjjj94SE7aP7c;D;O:B8J27cbazydwgKaKcjjjj94SEgzcH4cbasydwgYcs4aYcjjjj94SE7az7c:3F;N8N27awavaO2cdtfgzydlg8AazydbgE7cFFFFrGgzcm4az7c:fjjK27arGgPcdtfgzydbgscuSmba8A::h3aE::h5aY::h8EaX::h8FaL::haaK::hhaD::hgaQ::h8JcehDinaDhzdnaiasaC2cdtfgDIdba8J9CmbaDIdlag9CmbaDIdwah9CmbaoasaA2cdtfgDIdbaa9CmbaDIdla8F9CmbaDIdwa8E9CmbawasaO2cdtfgDIdba59CmbaDIdla39BmikazcefhDaHaPazfarGgPcdtfgzydbgscu9hmbkkazavBdbavhskaxavcdtfasBdbavcefgval9hmbkkcbhPaHcbyd:0:2:cjbH:bjjjbbakceBd2ak9cb83ibakaeadaxalakcxfz:cjjjbcuamcltadcFFFFd0Ecbyd:W:2:cjbHjjjjbbh8Kakcxfakyd2gKcdtfa8KBdbakaKcefgYBd2dnadci6mbaehsa8KhzamhvindndnaeTmbascwfydbhDasclfydbhHasydbhrxekaPcdfhDaPcefhHaPhrkJbbbbh8JJbbbbJbbbbJbbbbJbbbbJbbjZJbbj:;awaHaO2cdtfgXIdbawaraO2cdtfgQIdbga:tawaDaO2cdtfgLIdlaQIdlgh:tggNaXIdlah:tghaLIdbaa:tN:tgaJbbbb9EEaaJbbbb9BEg5aiaraC2cdtfgrIdwgaaiaHaC2cdtfgHIdwg39BEa5arIdlg8FaHIdlg8L9BEa5arIdbg8EaHIdbg8M9BEg5aaaiaDaC2cdtfgDIdwg8N9BEa5a8FaDIdlgy9BEa5a8EaDIdbg8P9BEg5a3a8N9BEa5a8Lay9BEa5a8Ma8P9BEh5dnaga3aa:tNaha8Naa:tN:tgaaaNaga8Ma8E:tNaha8Pa8E:tN:tg8Ea8ENaga8La8F:tNahaya8F:tN:tggagNMMghJbbbb9Bmba5ah:r:vh8Jkazcxfa5Udbazcwfaaa8JNUdbazclfaga8JNUdbaza8Ea8JNUdbascxfhsazczfhzaPcifhPavcufgvmbkkcbhzakcxfaYcdtfcuadcdtadcFFFFi0Ecbyd:W:2:cjbHjjjjbbgDBdbakaKcdfgPBd2dnadTmbaDhsinasazBdbasclfhsadazcefgz9hmbkkakcxfaPcdtfcuamcdtadcFFFF970Ecbyd:W:2:cjbHjjjjbbgvBdbakaKcifgzBd2akcxfazcdtfamcbyd:W:2:cjbHjjjjbbgYBdbakaKclfBd2dnadci6mba8KcxfhsavhPcbhzinaPazBdbaYazfcdcbasIdbg8JJbbbb9DEa8JJbbbb9EV86bbaPclfhPasczfhsamazcefgz9hmbkkdnalTmbcbhIakydlh8Rakydbh8SinaIcdthzdna8SaIcefgIcdtfydbgsa8SazfydbgzSmbasaz9RhQa8RazcdtfhLcbhRinaLaRcdtfg8Uydbgzcd4g8Vci2g8WazciGcdtgsyd:e:G:cjbfhza8Wasydj:G:cjbfhsdnaeTmbaeazcdtfydbhzaeascdtfydbhskdnaRcefgRaQ9pmbaxazcdtfydbhKaxascdtfydbhEaYa8Vfh8Aava8Vcdtfh8XaRhwinaLawcdtfgXydbgzcd4gsci2gOazciGcdtgzyd:e:G:cjbfhPaOazydj:G:cjbfhzdnaeTmbaeaPcdtfydbhPaeazcdtfydbhzkdndnaxazcdtfydbaKSmbaxaPcdtfydbaE9hmekaYasfRbbgza8ARbbgPVciSmbdnazaPGmba8VhPdna8Va8XydbgzSmba8XhHinaHavazgPcdtfgrydbgzBdbarhHaPaz9hmbkkdnasavascdtfgHydbgzSmbinaHavazgscdtfgrydbgzBdbarhHasaz9hmbkkaPasSmbaYasfgHRbbaYaPfgzRbbVciSmeavascdtfaPBdbazazRbbaHRbbV86bbkdna8UydbciGa8WfgsaDascdtfgPydbgzSmbinaPaDazgscdtfgHydbgzBdbaHhPasaz9hmbkkdnaXydbciGaOfgPaDaPcdtfgHydbgzSmbinaHaDazgPcdtfgrydbgzBdbarhHaPaz9hmbkkasaPSmbaDaPcdtfasBdbkawcefgwaQ9hmbkkaRaQ9hmbkkaIal9hmbkkdnadTmbcbhrinarhsdnaraDarcdtfgwydbgzSmbawhPinaPaDazgscdtfgHydbgzBdbaHhPasaz9hmbkkawasBdbarcefgrad9hmbkcbh8Vabcbadcltz:fjjjbhQdnadci6mbaqceGhKaDhLaeh8Acbh8Windna8Ka8WcltfgPIdxJbbbb9Bmbaea8Wci2gEcdtfhXcbhsa8VhwinaQaLasfydbcltfhzdndnaeTmba8AasfydbhHaXasc:e:G:cjbfydbcdtfydbhOaXascj:G:cjbfydbcdtfydbhxxekasc:e:G:cjbfydbaEfhOascj:G:cjbfydbaEfhxawhHkazaPIdbghaoaHaA2cdtfgrIdbg8JaPIdwg8EarIdwggNaha8JNaPIdlg5arIdlghNMMgaN:tg8FJbbbbJbbjZa8EagaaN:tg8Ea8ENa8Fa8FNa5ahaaN:tgaaaNMMg8F:r:va8FJbbbb9BEJ;As6nJbbjZaiaxaC2cdtfgrIdwaiaHaC2cdtfgHIdwg3:tg8Faga8FagNarIdbaHIdbg8L:tg8Ma8JNaharIdlaHIdlg8N:tgyNMMg8FN:tg5aiaOaC2cdtfgHIdwa3:tg3aga3agNaHIdba8L:tg8Pa8JNahaHIdla8N:tg8NNMMg3N:tggNa8Ma8Ja8FN:tg8La8Pa8Ja3N:tg8JNayaha8FN:tg8Fa8Naha3N:tghNMMJbbbbJbbjZa5a5Na8La8LNa8Fa8FNMMagagNa8Ja8JNahahNMMNg8J:rgg:va8JJbbbb9BENgh:lg8Ja8JJbbjZ9EEg8Ja8JJ7;A9s89NJ:L9t9s::MNJ;ob;jZMJbbjZa8J:t:rNg8J:ta8JahJbbbb9DENg8Jaga8JNaKEg8JNazIdbMUdbazaaa8JNazIdlMUdlaza8Ea8JNazIdwMUdwawcefhwasclfgscx9hmbkkaLcxfhLa8Acxfh8Aa8Vcifh8Va8Wcefg8Wam9hmbkcbhrinarhsdnaravarcdtfgPydbgzSmbinaPavazgscdtfgHydbgzBdbaHhPasaz9hmbkkaQarc8W2fgzc3fJbbjZJbbj:;aYasfRbbceGEg8JUdbazc8Sfa8JUdbaza8JUdxarcefgram9hmbkkaqcdGhvcbhsaDhPaQhzindnasaPydb9hmbdndnazcwfgHIdbg8Ja8JNazIdbggagNazclfgrIdbghahNMMgaJbbbb9BmbaHa8JJbbjZaa:r:vgaNUdbarahaaNUdbazagaaNg8JUdbxekaHa8JJbbbbNUdbarahJbbbbNUdbazagJbbbbNg8JUdba8JJbbjZavEh8Jkaza8JUdbkaPclfhPazczfhzadascefgs9hmbkcbhzaQhsindnazaDydbgPSmbasaQaPcltfgPydwBdwasaP8Pdb83dbkaDclfhDasczfhsadazcefgz9hmbkkdnakyd2gsTmbascdtakcxffc98fhzinazydbcbyd:0:2:cjbH:bjjjbbazc98fhzascufgsmbkkakc;Wbf8Kjjjjbk;:levucualcefgocdtaocFFFFi0Ecbyd:W:2:cjbHjjjjbbhoavavyd9GgrcdtfaoBdbavarcefBd9GabaoBdbcuadcdtadcFFFFi0Ecbyd:W:2:cjbHjjjjbbhoavavyd9GgrcdtfaoBdbavarcefBd9GabaoBdlabydbclfcbalcdtz:fjjjbhoadci9UhwdnadTmbdnaeTmbaehvadhrinaoaiavydbcdtfydbcdtfgDaDydbcefBdbavclfhvarcufgrmbxdkkadhraihvinaoavydbcdtfgDaDydbcefBdbavclfhvarcufgrmbkkdnalTmbcbhraohvinavydbhDavarBdbavclfhvaDarfhralcufglmbkkdnadci6mbabydlhrcbhlcdhvindndnaeTmbaiaealfgqydbcdtfhDaiaqcwfydbcdtfhdaiaqclfydbcdtfhqxekaialfgDcwfhdaDclfhqkadydbhdaqydbhqaoaDydbcdtfgDaDydbgDcefBdbaraDcdtfavc9:fBdbaoaqcdtfgDaDydbgDcefBdbaraDcdtfavcufBdbaoadcdtfgDaDydbgDcefBdbaraDcdtfavBdbalcxfhlavclfhvawcufgwmbkkabydbcbBdbk:SEvxui99duv99xu8Jjjjjbc;Wb9Rgw8Kjjjjbawcxfcbc;Kbz:fjjjb8AawcualcdtalcFFFFi0Ecbyd:W:2:cjbHjjjjbbgDBdxawceBd2adci9Uhqalcd4alfhkaoz:mjjjbhocehxinaxgmcethxamak6mbkawcuamcdtgxamcFFFFi0Ecbyd:W:2:cjbHjjjjbbgkBdzawcdBd2akcFeaxz:fjjjbhPavcd4hsdnalTmbamcufhzcbhHindndnaPcbaiaHas2cdtfgmydlgvavcjjjj94SEgxcH4ax7c:F:b:DD2cbamydbgOaOcjjjj94SEgxcH4ax7c;D;O:B8J27cbamydwgAaAcjjjj94SEgmcH4am7c:3F;N8N27azGgkcdtfgmydbgxcuSmbaA::hCav::hXaO::hQcehvinavhmdnaiaxas2cdtfgvIdbaQ9CmbavIdlaX9CmbavIdwaC9BmikamcefhvaPakamfazGgkcdtfgmydbgxcu9hmbkkamaHBdbaHhxkaDaHcdtfaxBdbaHcefgHal9hmbkkcbhkaPcbyd:0:2:cjbH:bjjjbbawceBd2aw9cb83ibawaeadaDalawcxfz:cjjjbcuaqcltadcFFFFd0Ecbyd:W:2:cjbHjjjjbbhLawcxfawyd2gKcdtfaLBdbawaKcefgOBd2dnadci6mbaehxaLhmaqhHindndnaeTmbaxcwfydbhzaxclfydbhvaxydbhPxekakcdfhzakcefhvakhPkJbbbbhQdnaiavas2cdtfgvIdbaiaPas2cdtfgPIdbgX:tgYaiazas2cdtfgzIdlaPIdlgC:tg8ANavIdlaC:tgCazIdbaX:tgEN:tgXaXNaCazIdwaPIdwg3:tg5NavIdwa3:tg3a8AN:tgCaCNa3aENaYa5N:tgYaYNMMg8AJbbbb9BmbJbbjZa8A:r:vhQkamcxfa8AJbbbb9CBdbamcwfaXaQNUdbamclfaYaQNUdbamaCaQNUdbaxcxfhxamczfhmakcifhkaHcufgHmbkkcbhmawcxfaOcdtfcuadcdtg8EadcFFFFi0Ecbyd:W:2:cjbHjjjjbbgvBdbawaKcdfg8FBd2dnadTmbavhxinaxamBdbaxclfhxadamcefgm9hmbkkdnalTmbcbhaawydlhhawydbhginaacdthmdnagaacefgacdtfydbgxagamfydbgmSmbaxam9RhAahamcdtfh8Jcbh8Kina8Ja8Kcdtfg8Lydbgmcd4gkci2g8MamciGcdtgxyd:e:G:cjbfhma8Maxydj:G:cjbfhxdnaeTmbaeamcdtfydbhmaeaxcdtfydbhxkdna8Kcefg8KaA9pmbaLakcltfhOaDamcdtfydbh8NaDaxcdtfydbhya8KhHina8JaHcdtfg8Pydbgmcd4gkci2gzamciGgPcdtgmyd:e:G:cjbfhxazamydj:G:cjbfhmdnaeTmbaeaxcdtfydbhxaeamcdtfydbhmkdndnaDamcdtfydba8NSmbaDaxcdtfydbay9hmekaOIdwaLakcltfgmIdwNaOIdbamIdbNaOIdlamIdlNMMao9ETmbaOydxamydx9hmbdna8LydbciGa8MfgxavaxcdtfgkydbgmSmbinakavamgxcdtfgPydbgmBdbaPhkaxam9hmbka8PydbciGhPkdnaPazfgkavakcdtfgPydbgmSmbinaPavamgkcdtfgzydbgmBdbazhPakam9hmbkkaxakSmbavakcdtfaxBdbkaHcefgHaA9hmbkka8KaA9hmbkkaaal9hmbkkdndndnadTmbcbhzinazhxdnazavazcdtfgHydbgmSmbaHhkinakavamgxcdtfgPydbgmBdbaPhkaxam9hmbkkaHaxBdbazcefgzad9hmbkcbh8Mabcbadcx2z:fjjjbh8Padcd9nmeavhAaeh8NcbhyinaLaycltfhkaeayci2g8JcdtfhDcbhxa8MhHina8PaAaxfydbcx2fhmdndnaeTmba8NaxfydbhzaDaxc:e:G:cjbfydbcdtfydbhOaDaxcj:G:cjbfydbcdtfydbhPxekaxc:e:G:cjbfydba8JfhOaxcj:G:cjbfydba8JfhPaHhzkamakIdbaiaPas2cdtfgPIdwaiazas2cdtfgzIdwgC:tgoaoNaPIdbazIdbgY:tgQaQNaPIdlazIdlg8A:tgXaXNMMaiaOas2cdtfgPIdwaC:tgCaCNaPIdbaY:tgYaYNaPIdla8A:tg8Aa8ANMMNgE:rg3J;As6nJbbjZaoaCNaQaYNaXa8ANMMJbbbbJbbjZa3:vaEJbbbb9BENgQ:lgoaoJbbjZ9EEgoaoJ7;A9s89NJ:L9t9s::MNJ;ob;jZMJbbjZao:t:rNgo:taoaQJbbbb9DENgoNamIdbMUdbamakIdlaoNamIdlMUdlamakIdwaoNamIdwMUdwaHcefhHaxclfgxcx9hmbkaAcxfhAa8Ncxfh8Na8Mcifh8MaycefgyaqSmdxbkkabcbadcx2z:fjjjb8Axekcbhxavhka8Phmindnaxakydb9hmbJbbbbhodnamcwfgPIdbgQaQNamIdbgXaXNamclfgzIdbgCaCNMMgYJbbbb9BmbJbbjZaY:r:vhokaPaQaoNUdbazaCaoNUdbamaXaoNUdbkakclfhkamcxfhmadaxcefgx9hmbkkdnarJbbbb9ETmbawcxfa8Fcdtfcuadcltg8Pa8EcFFFFi0Ecbyd:W:2:cjbHjjjjbbg8JBdbdndnar:ngo:lJbbb9p9DTmbao:Ohmxekcjjjj94hmkaKcifh8Famce9imbamcqamcq9iEh8Nadci6hLcbhAina8Jcba8Pz:fjjjbhPdnaLmbcbhDavhOinavaDcx2fhecbhxinabaOaxfydbgzcx2fgmIdwhoabaeaxcj:G:cjbfydbcdtfydbgHcx2fgkIdwhQamIdbhXakIdbhCamIdlhYakIdlh8AaPazcltfgmamIdxJbbjZMUdxamamIdbaCaX:taoaQNaXaCNaYa8ANMMgXaXNJbbbbaXJbbbb9EEgXNgCMUdbamamIdla8AaY:taXNgYMUdlamaQao:taXNgoamIdwMUdwaPaHcltfgmamIdxJbbjZMUdxamamIdbaC:tUdbamamIdlaY:tUdlamamIdwao:tUdwaxclfgxcx9hmbkaOcxfhOaDcefgDaq9hmbkkdnadTmbaraA:Z:tgoJbbjZaoJbbjZ9DEJbbbZNh8AcbhxavhkabhzaPhmindnaxakydb9hmbamcxfIdbgQJbbbb9ETmbJbbbbhodnamcwfIdba8AaQ:vgQNazcwfgPIdbMgXaXNamIdbaQNazIdbMgCaCNamclfIdbaQNazclfgHIdbMgQaQNMMgYJbbbb9BmbJbbjZaY:r:vhokaPaXaoNUdbaHaQaoNUdbazaCaoNUdbkakclfhkazcxfhzamczfhmadaxcefgx9hmbkkaAcefgAa8N9hmbkkdnadTmbcbhmabhxindnamavydbgkSmbaxabakcx2fgkydwBdwaxak8Pdb83dbkavclfhvaxcxfhxadamcefgm9hmbkkdna8FTmba8Fcdtawcxffc98fhminamydbcbyd:0:2:cjbH:bjjjbbamc98fhma8Fcufg8Fmbkkawc;Wbf8Kjjjjbk9teiucbcbyd:4:2:cjbgeabcifc98GfgbBd:4:2:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabk9teiucbcbyd:4:2:cjbgeabcrfc94GfgbBd:4:2:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikTeeucbabcbyd:4:2:cjbge9Rcifc98GaefgbBd:4:2:cjbdnabZbcztge9nmbabae9RcFFifcz4nb8Akk9pee98abab:Igbabab:Ige:Iab9e9P9q;U;G9c:t;58::I9e8N8Es;O:h;a9w:;:G:Iae9e9c86v;H9t9v:LZ:Iab9e:b9ExpFF;F:;:I9ebbbbbb;WZ:G:G:G:2k0ed98ababab:Ige:Igdaeae:I:Iae9e:NS87:m:h;n;g8::I9et;N;k;I;5bI:;:G:Iadae9e:Y;79U:jzH:bZ:I9e93:S;l9u9v9v;f:;:G:Iab:G:G:2k:K8Flqud98zul988Jjjjjbc:Wl9Rgv8Kjjjjbcbhoadc99fcK9Tgrcbarcb9kEgwc9O2adfhDdnalcdtc:q:G:cjbfydbgqaicufgkfgdcb9imbawak9RhxdnadTmbaqaifgdceGhmawcdtaicdt9Rc:O:G:cjbfhradc9:GhPavc;adfhdcbhoin9ebbbbbbbbhs9ebbbbbbbbhzdnaxaofgHcb9imbarc98fydb:3hzkadaz85ibdnaHcu9imbarydb:3hskadcwfas85ibadczfhdarcwfhraPaocdfgo9hmbkamTmeaxaofhxkdndnaxcb9omb9ebbbbbbbbhzxekaxcdtyd:G:G:cjb:3hzkavc;adfaocitfaz85ibkaDc9OfhOcbhdaqcbaqcb9kEhmaic;:FFFrGhHaiceGhAaicitavc;adffc9WfhPinadhxdndnaice9omb9ebbbbbbbbhzxekcbhr9ebbbbbbbbhzdnakTmbaPhdabhoinaocwf8Ribad8Rib:Iao8Ribadcwf8Rib:Iaz:G:Ghzadc9WfhdaoczfhoaHarcdfgr9hmbkaATmekabarcitf8Ribavc;adfaxakfar9Rcitf8Rib:Iaz:Ghzkavaxcitfaz85ibaPcwfhPaxcefhdaxam9hmbkaic;:FFFrGhHaiceGhCc8VaD9RhXc8WaD9RhQavc;Gifc98fgLaqcdtfhKawcdtc:G:G:cjbfhwavc;adfc94fhYavc;Gifc9Wfh8Aavc9WfhEaDc9Nfh3aqhxdninavaxcitgdf8Ribhzdnaxce9imbcbhrdndnaxce9hmbaxhdxekaxceGhmaxc;:FFFrGhPaEadfhdcbhravc;Gifhoinaoaz9ebbbbbb9W8::I;8d:3gs9ebbbbbb9W;b:Iaz:G;8dBdbaoclfadcwf8Ribas:Ggz9ebbbbbb9W8::I;8d:3gs9ebbbbbb9W;b:Iaz:G;8dBdbad8Ribas:Ghzaocwfhoadc9WfhdaParcdfgr9hmbkamTmeaxar9Rhdkavc;Gifarcdtfaz9ebbbbbb9W8::I;8d:3gs9ebbbbbb9W;b:Iaz:G;8dBdbavadcitfc94f8Ribas:GhzkazaOz:njjjbgz9ebbbbbb;aZ:I:C9ebbbbbba;a:Iaz:Ggzaz;8dg5:3:HhzdndndndndnaOce9ig8Embavc;Gifaxcdtfc98fgdadydbgdadaQ91gdaQt9RgoBdbaoaX91h8Fada5fh5xekaOmeavc;Gifaxcdtfc98fydbcL91h8Fka8Fce9imdxekcdh8Faz9ebbbbbb;GZ9Mmbcbh8Fxekcehodnaxce9imbcbhrcbhPdnaxceSmbaxceGhaaxc;:FFFrGhAcbhravc;GifhdcbhPinadydbhodndndndnaPTmbcFFFrhPxekaoTmecjjjwhPkadaPao9RBdbcbhPxekcehPkadclfgmydbhodndndndnaPmbcFFFrhPxekaoTmecjjjwhPkamaPao9RBdbcehPcbhoxekcbhPcehokadcwfhdaAarcdfgr9hmbkaaTmekavc;GifarcdtfgrydbhddndnaPTmbcFFFrhoxekcehoadTmecjjjwhokaraoad9RBdbcbhokdna8EmbcFFFihddndna3PdebdkcFFFehdkavc;Gifaxcdtfc98fgrarydbadGBdbka5cefh5a8Fcd9hmb9ebbbbbb;WZaz:Hhzcdh8Faombaz9ebbbbbb;WZaOz:njjjb:Hhzkdnaz9ebbbbbbbb9Imbdnaxaq9mmbaxaq9RgdciGhrcbhoaxhPdndnaqax9Rc980mbadc98Ghma8AaxcdtfhdcbhoaxhPinadydbadclfydbadcwfydbadcxfydbaoVVVVhoadc9WfhdaPc98fhPamc98fgmmbkarTmekaLaPcdtfhdinadydbaoVhoadc98fhdarcufgrmbkkaoTmbavc;Gifaxcdtfc98fhdinaxcufhxaOc9OfhOadydbhoadc98fhdaoTmbxlkkaKhdaxhPinaPcefhPadydbhoadc98fhdaoTmbkaYaiaxfcitfhminavc;adfaxaifgAcitfawaxcefgxcdtfydb:385ibdndnaice9omb9ebbbbbbbbhzxekcbhr9ebbbbbbbbhzdnakTmbamhdabhoinaocwf8Ribad8Rib:Iao8Ribadcwf8Rib:Iaz:G:Ghzadc9WfhdaoczfhoaHarcdfgr9hmbkaCTmekabarcitf8Ribavc;adfaAar9Rcitf8Rib:Iaz:Ghzkavaxcitfaz85ibamcwfhmaxaP9imbkaPhxxekkdndnazcKaD9Rz:njjjbgz9ebbbbbb9Wc9MTmbavc;Gifaxcdtfaz9ebbbbbb9W8::I;8dgd:39ebbbbbb9W;b:Iaz:G;8dBdbaxcefhxaDhOxekaz;8dhdkavc;GifaxcdtfadBdbkdnaxcb9imb9ebbbbbb;WZaOz:njjjbhzdndnaxceGTmbaxhoxekavaxcitfazavc;Gifaxcdtfydb:3:I85ibaxcufhoaz9ebbbbbb9W8::IhzkdnaxTmbaocefhraocdtavc;Giffc98fhdaocitavfc94fhoinaoaz9ebbbbbb9W8::Igsadydb:3:I85ibaocwfazadclfydb:3:I85ibadc94fhdaoc9Wfhoas9ebbbbbb9W8::Ihzarc9:fgrmbkkavaxcitfhHaxhdindndnaqaxadgi9RgAaqaA9iEgdcb9omb9ebbbbbbbbhzxekadcefgociGhrdndnadci9pmbcbhd9ebbbbbbbbhzxekcbhPcbaoc98G9Rhm9ebbbbbbbbhzcbhdinadc1:2:cjbf8RibaHadfgocKf8Rib:Iadcj:2:cjbf8Ribaoczf8Rib:Iadc;4:1:cjbf8Ribaocwf8Rib:Iadc;W:1:cjbf8Ribao8Rib:Iaz:G:G:G:GhzadcafhdamaPc98fgP9hmbkarTmecbaP9Rhdkadcithdinadc;W:1:cjbf8RibaHadf8Rib:Iaz:Ghzadcwfhdarcufgrmbkkavc:GefaAcitfaz85ibaHc94fhHaicufhdaicb9kmbkkdndndndndnalPleddblk9ebbbbbbbbhhdnaxce9imbaxhddnaxceGTmbavc:Gefaxcitfgdc94fgoao8Ribgzad8Ribgs:Ggg85ibadasazag:H:G85ibaxcufhdkaxceSmbadcdfhoadcitavc:Geffc9Wfhdinadad8Ribgsadcwfgr8RibggadczfgH8Ribg8J:Ggz:Gg8K85ibaHa8Jagaz:H:G85ibarazasa8K:H:G85ibadc9Wfhdaoc9:fgocd9kmbkaxceSmbaxcefhoaxcitavc:Geffc94fhdinadad8Ribgzadcwfgr8Ribgs:Ggg85ibarasazag:H:G85ibadc94fhdaocufgocd0mbkaxcefhoavc:Gefaxcitfhd9ebbbbbbbbhhinahad8Rib:Ghhadc94fhdaocufgocd0mbkkav8Ri:Gehza8Fmdaeaz85ibaeah85izaeav8Ri:Oe85iwxikdndnaxcb9omb9ebbbbbbbbhzxekdndnaxciGci9hmb9ebbbbbbbbhzaxhoxekaxcefciGhravc:Gefaxcitfhd9ebbbbbbbbhzaxhoinaocufhoazad8Rib:Ghzadc94fhdarcufgrmbkkaxci6mbaocefhraocitavc:Geffc9OfhdinazadcKf8Rib:Gadczf8Rib:Gadcwf8Rib:Gad8Rib:Ghzadc9Gfhdarc98fgrmbkkaeaz:Aaza8FE85ibxdkdndnaxcb9omb9ebbbbbbbbhzxekdndnaxciGci9hmb9ebbbbbbbbhzaxhoxekaxcefciGhravc:Gefaxcitfhd9ebbbbbbbbhzaxhoinaocufhoazad8Rib:Ghzadc94fhdarcufgrmbkkaxci6mbaocefhraocitavc:Geffc9OfhdinazadcKf8Rib:Gadczf8Rib:Gadcwf8Rib:Gad8Rib:Ghzadc9Gfhdarc98fgrmbkkaeaz:Aaza8FE85ibav8Ri:Geaz:Hhzcehddnaxce9imbaxciGhodnaxcufci6mbaxc;8FFFrGhHavc:Gefcafhdcbhrinazadc9Of8Rib:Gadc9Wf8Rib:Gadc94f8Rib:Gad8Rib:GhzadcafhdaHarclfgr9hmbkaoTmearcefhdkavc:Gefadcitfhdinazad8Rib:Ghzadcwfhdaocufgombkkaeaz:Aaza8FE85iwxekaeaz:A85ibaeah:A85izaeav8Ri:Oe:A85iwkavc:Wlf8Kjjjjba5crGk:ediiue98eu8Jjjjjbcz9Rgd8Kjjjjbdndnab:8gicFFFFrGglc;A:F:K;Ul0mbaeab:7gvav9e:d;i;j9T8W9F;KZ:I9ebbbbbbUJ:G9ebbbbbbU;d:Ggv9ebbb9q;7h;5:;:I:Gav9e9J9I8A9H:0z9r:::I:G85ibav;8dhlxekdnalcjjj;8r6mbaeabab:t:785ibcbhlxekadalalcL4c;Q9:fgocLt9R:::785iwadcwfadaocecbz:kjjjbhlad8Ribhvdnaicu9kmbaeav:A85ibcbal9Rhlxekaeav85ibkadczf8Kjjjjbalk;piiiue99e988Jjjjjbcz9Rge8Kjjjjbdndnab:8gdcFFFFrGgic;A:F:K;6i0mbJbbjZhlaicjjj;mi6meab:7z1jjjbhlxekdnaic;r:N;T:dl0mbdnaic;K:x;Bjl6mb9eKR9e9u;7hDn9eKR9e9u;7hD;aadcb9iEab:7:Gz1jjjb:mhlxdkab:7hvdnadcu9kmbav9eKR9e9u;7h;5Z:Gz:jjjjbhlxdk9eKR9e9u;7h;5Zav:Hz:jjjjbhlxekdnaic;v;J1:hl0mbdnaic;G;B:;:fl6mb9eKR9e9u;7hYn9eKR9e9u;7hY;aadcb9iEab:7:Gz1jjjbhlxdkdnadcu9kmb9e;sh8Zu98;zO;aab:7:Hz:jjjjbhlxdkab:79e;sh8Zu98;zO;a:Gz:jjjjbhlxekdnaicjjj;8r6mbabab:thlxekabaecwfz:ljjjbhiae8RiwhvdndndndnaiciGPlbedibkavz1jjjbhlxikav:Az:jjjjbhlxdkavz1jjjb:mhlxekavz:jjjjbhlkaeczf8Kjjjjbalk:Uebdndnaecjw9imbab9ebbbbbb;Gu:IhbdnaecFs9pmbaec:b94fhexdkab9ebbbbbb;Gu:IhbaecpLaecpL6Ec:c9Wfhexekaec:b949kmbab9ebbbbbb9Gi:Ihbdnaec:49W9nmbaec;jrfhexekab9ebbbbbb9Gi:Ihbaec;W9Oaec;W9O0EcMsfhekabaecFrf:T9c80:g:;:Ikk;mQdbcj:Gdk:WQebbbdbbbbbbbebbbibbblbbblbbbobbb:d;5:Ib9e9o9Ub;88PXb;r9x8Nb;D80;1b9I;B;ab88:z:vbc:qJb9J9r;:b:7;E:Rb:39H;fb869U8Kb;s9n9cb6o;GbD;Q8Ub3M;rb;R5;:b8P:X3b;O8::Nb;181:cb9e:78Ub:C;P:eb:08M9Wbc9:9Fb;w:r85b9t:d85b:C;085b:l9F:eby;5:9b;48F87b;EF:xbs:yvbH8V;Vbq9A:lb9T8F9Tb;p9:BbD;l8NbS9p:3b:E9MZbR;Q9Fb:68N91b;L;R;hb8997;Xb;385rbM9s:kb;79R;Qb8F:X9Fbw9D:nb8Wi9wb97;8Sb;W:R9Rba:8;pbB;0:Ab;J:P5b9E9H:rbwE;Mb:f:zWb:GC9Fb:nn9Obj;yFb8N79nboo8Xb;k9wXb;j:O7b97;I9Gb9R:m;abY;e9hb;n9N;dbD;O;Cb9z:dIb:l4;eb:M3:wb9e:V;DbY9x;rb:L8:vbvrFb8Z9:Zb;c8Y;Ob:y9p;Eb:7998Yb8M89;db8E9R;Vb:F;49Eb818F86bu;Y;kb;X:h5b98:qhbf8K98b;v9U;6b8WR93bX87Jb:1C;gb;dY:Db:T;e;cb8S9ncbxb9Db:g99Sb;JGRb:B;g:Ab8Z9Ibb:0;s98b:0:N:xb839v;vb;x8:;2b:JzKb9n4;8b9K:DIb9W;x:Rb9J98;4b96:W9xbLX;Nb;a69wb87;w;zb:N:eUb8K8J;lb;w:k93b9A9u8Jbb8F:5b;XqEbY;o;Fb:F8XFb9M8Efb:z9x9Hb:S;79hb9:u;ybgW:3b8Y;O:jb;M:;9Gb;V;e;nb2BDb9DZ;ubQ;E;xb9y87;Eb;E:BMb;sgyby:g;Ob;I9y9nb;g;k8Ybw;JQb;G99;lbL;a9qb;Z5:NbK;G9Bb8UA80b:dO9Ib:d9ieb;1:o9Bb:T:Wub8E;P;Yb9i9kJbz9N;tb:Q;D;yb:U9F9cbf9H;obqy:Kb;t:z:0bo:M;Yb9C93ub:J;c:db9H881b:k794b:V:m9Ab9V;x:9bR:M9Jb;0:;;lb:n:b;Vb8M;b9Nb9v;kTb;k;zBby:O;sb;c9H:nbO;j93bl8MCbOS:Bb;e9z;eb;i;f9eb9n:Y:rbbL;Zb;uJ:Tb8P6;Lbp;vzbb::;8b8EN;mb9W;o;UbA8:;1b;S;Xjb:Z;N;db;h;4yb:tvNb;bG8:b8UD:ZbkT;Zb1O:Cb:Ra97b8U:1:Fb9hM;cb978Y8Vbx9v9TbV:N:qb9R;N8Fb8X;l:wb95Q9kbc95;Ib;0;F:jb;ON:xb;I;M:eb:z8X:xb1;T9Rb9F9FBb:7pPb9i:A:0b9N:K2bGV9cb:n9D8Yb:FX:4b:8;LDb:n8X8Lb;3t85b8Wv3bmxeb0w9Ob8S;U9yb9h:Q:qbt;Ndb:9;w8Kb;399:Mb9U9iVb:FQ;Vb:oN:Mb:0:r;2b;r9t9rb;pq;Yba:y8Zb;109:b:Y9J9Ob;D8:9Fbn9Dib:f:jub9v9s8Pb839K;ab9T;yzb8Y9i8Yb9B9m91b9oG;ubT9u9UbkD;bbI;19PbC9M;vb8Nr:Db9Dl9qb:087;Bb;Q4;fb:h;5Lb69R99b58N:6b:w9P8Pb;g;m:Sb:TC9ub:q;Ifb1;z:jb8SV9qbl:K::b93rNb;Z8W9Wbb;88Nb;QG:Ob9M;c6b9K;G89b:x;D:db:JZ:xbJNpbm:g:mb8Xc;EbM85:Db;D9W:mbL:3;Nbw;F87bX838Rb9Cj:Gb9Aj:tbzHMbs;O;yb2j:Vb;BF0bU:qsb9zK4b9I:LXb9H;l:7b;h:j:5bzn:9b;s;Ylb6918Nb;R:2;2b;Bg:7bqC:Qb:j8M8Vb9K:d4bD878ZbPN8Ab9r86:Qb5:J;cb:V;T:Ub9C8MOb9T;c9nbR96:Cb;a9w:xbiZ:dbD;W;2b8Rn:mb9T8X:zb85:0rbxaXb;y;d9Bb;1M;eb;g:T0b9o;k:Lb:N83;nb;M:PBb:RMNb;D9c9ObY9J;Eb4:m;Vb9O:l9sb;8;B83b:U:H:Rb;FX8Xbb:U:Hbx;7;Ab9K9n9Mb;Tv:3b8PW8Wb9x9w:;b9hF86bf;5:5b91::;Zby:t;Fb:Rj8Wb9M:m;2bl;lXb;6gob;z;K5b89:Z:Kb9xE:pbB;nDb9o9c;PbA:::Kb8Z8J:1b;W:Q8Ab9pW:Ob;s;b:LbkZsb9B94;nb8J;54b97:llb:jLVb;g:M9tb9V9U;Ib;V;Rbb:B9k9yb;e;A:3b:Q9M:6b4;p;pb;rd5b:X;XRb:m:z;bb;d:T93b:g9i;Ab;39D:Gb;gj;0b:S;W8Vb;D;S:AbZ9C:8b;q;E9Tb:q;h8FbI;B:2b:J8L86bb:V:Ab:T9t:tb:29xlb8PR:0b0j9:b;Ar:Nb4:QPb979z:HbQOIb;C:3Rb;6;Lpb:j;B;:b:j::pb;K42bo:P;8b8:j9Wb:f9UXbp:hFby8:rb9H9N8ZbIK:gb9n:9;Qb:Z;N:Vb:p9T9Ub:v9N85b8X:;9Bb:e;x9ib8W;FQb;hRJb8L9H81b;j9W;ob8W;l:4b:;2pb:Kb:Ibv2;Kb9A;D:Gbh9V9hb9IO;sb:59C:eb9W9H6b9R9w;Gb:z9seb9q9v83b8E;v:3b8Z;X;ebA9U9Fb9D8W;Kb:f8U:Pb5:Y;db:H8YBbw:3:Kb;Q:X;ubQ;3hb:p9P;Kb8NF93bxijb:nnRb9p;n:Gba:L:zb:Z:I;tb8V9Dqb:0;59cbH;A;lb99::;qb:B;B;bb:RL:9b;k:I:bbwf9Cb8U9vLb8Nb9vbuC;Wb;Hr:gbCk9Kb:wc:nb:h::;Eb;ApIb9R8L:2b97:j80bv;Z;:b:5:;:Eb9Of9pb9kI:Ob9p;e9AbR;4:8b;x9A:yb;0;h:vbm9n:nba86:Mb:K9x9FbCZ:XbjU:vb;maebG;D:gb;j;E:2b:;9G;1b9nWHber9Rb:m:W:Sb:Y;a;qb9r9v9ib8E;7Pb:vV;db:Jo87b;an81bo;C97b;GT;mb9o8P;6b;w;k;ib;O;Zcb989K;Eb:B9K;yb;z::8Xb:K:x;db939y;ub9P;J;fb;W;AAb:68688bSKSb9v919Fb;s:9;1b9UM;gb:S8U9DbP9e;Tb38:9cb9H;e:hb8Pp;Pb;N;w;Zbg98;kb9V:r81bw;G;fbF;x:nb9Uf;Ib:Wp;gb:tw;bb989Dtb9R:T:Yb;n9U:Db8:V97b;gHfb;3;p:Pb8P7;Fb:1;j:6b:3b9rb;I:Ymbt:68Kb;L999Gbt;y:kbmX8Sb:bKxb9:9MNbe8PQb:F964bpp::b9wT;Vb;z9:Bb;S;zAb:l:6:5b;e:x;8b8X:O8Nb;X9U;dbN;fBb;y:O9wb:0:O:1b;p;mPbO:jRb9V9x80b8S9w:jb:z;o;Jb;wa:5b9R9E:Qb8:I:CbH9F;mbpk9kb;H;0;7b:o879Tb;I:g8Sb;P;u:eb;8:0:Pb;V;U;rb8U81;jb8V859HbUh9ebE;z;ib:b;8qb;79kfb8V3;yb9t:0:eb9o:z:mb9ug;mbI9v;Cb;a;g;wbkY:wb8A9W:4b9P:v9Kb8M9A9GbZ9s;UbuHsb;0:1Hb;8;l;1b80:8Rb80:8;Ub;O9D;mb;D9E9Gb9N:o:BbM8Z;Vb;jL:4b9H9y:Bb;H9x:8b9r:d;gb;y8:zb;DG9ibR3;Db:VK:Hbh8SSb9z;Z;xb;z96:yb:E9u;ab9p:g;6b9wo;8b;L95:Ub:jgBbU:Tgb9N:t;Cb9v;O:Qb:c8MUb;k;N:Bb9rm:Kb:z8Z:Xb:P;xPb9Pv9ibW:Y;Wbu1:Nb19m:xb;5;rBbhM:Zb97:c9kb:y;phbn:F;Cb;C9h9vb;Ht86b9N;R9cb;::D;Fb9E;u9Fb979N:Kb:6:S96b9v;2:Ib8R18Jbc:69vb9z9UwbhI:gb859h:db:j;J;Mb;L:E;ub6;7nbF9w;Pb3s;kb;f9z:kbN;68Rb;t;b;fbs;f;pb;B9A:Ub9h;f:gb:fJ9Ibh:g87b8S95Nbz9H:hbI9m97bj8S8AbJ:;Ob18M:qb9488:jb:O;e;Kb;L;B97b;e86;cb8M;0;Qb;39N:kbmM:;bW:J8Rb89:t:Xb:998kb:K9r;Cb8N;D9Jb9P;H;Db:ANYb:O8P:vb9O;oybD;T:0b9e:Fab9o:y;kb9W:c9Jb9:988Jbs:58Yb:N;1:obC9w;Nbh;Xwb:1:DIb9V9:9nb:LY9rb:1;5:Rb:c;F;wb:w;D9HbQBdb;e86:Fb:d:I:HbV;T9Tb85:n96b:c:4:Pb9R8Y9CbS8N9Bbb80;Tb;sb93b;8;09vbe9z9nb;GGjbbbbbbbbbbbbn;7h;5ZbbbbR9et8:bbbj:yS;488bbb9G9r;m9487bbbj:dE;W85bbbna8L96Ubbbjg:c;JBbbbb5;Z9P81bc:W:2dkxebbbdbbbn:Bbb",e=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if(typeof WebAssembly!="object")return{supported:!1};var t,s=WebAssembly.instantiate(n(r),{}).then(function(h){t=h.instance,t.exports.__wasm_call_ctors()});function n(h){for(var u=new Uint8Array(h.length),d=0;d<h.length;++d){var f=h.charCodeAt(d);u[d]=f>96?f-97:f>64?f-39:f+4}for(var p=0,d=0;d<h.length;++d)u[p++]=u[d]<60?e[u[d]]:(u[d]-60)*64+u[++d];return u.buffer.slice(0,p)}function a(h){if(!h)throw new Error("Assertion failed")}function i(h){return new Uint8Array(h.buffer,h.byteOffset,h.byteLength)}function o(h,u,d,f,p,m,b,g,x,T){var y=t.exports.sbrk,v=y(u*16),_=h?y(h.byteLength):0,A=y(d.byteLength),M=y(m.byteLength),N=y(g.byteLength),R=new Uint8Array(t.exports.memory.buffer);h&&R.set(i(h),_),R.set(i(d),A),R.set(i(m),M),R.set(i(g),N),t.exports.meshopt_generateTangents(v,_,u,A,f,p*4,M,b*4,N,x*4,T),R=new Uint8Array(t.exports.memory.buffer);var I=new Float32Array(R.buffer,v,u*4).slice();return y(v-y(0)),I}function c(h,u,d,f,p,m,b){var g=t.exports.sbrk,x=g(u*12),T=h?g(h.byteLength):0,y=g(d.byteLength),v=new Uint8Array(t.exports.memory.buffer);h&&v.set(i(h),T),v.set(i(d),y),t.exports.meshopt_generateNormals(x,T,u,y,f,p*4,m,b),v=new Uint8Array(t.exports.memory.buffer);var _=new Float32Array(v.buffer,x,u*3).slice();return g(x-g(0)),_}var l={Compatible:1,ZeroFallback:2};return{ready:s,supported:!0,generateTangents:function(h,u,d,f,p,m,b,g){a(h===null||h instanceof Uint32Array||h instanceof Int32Array||h instanceof Uint16Array||h instanceof Int16Array),a(h===null||h.length%3==0),a(u instanceof Float32Array),a(u.length%d==0),a(d>=3),a(f instanceof Float32Array),a(f.length%p==0),a(p>=3),a(m instanceof Float32Array),a(m.length%b==0),a(b>=2),a(u.length/d==f.length/p),a(u.length/d==m.length/b),a(h!==null||u.length/d%3==0);for(var x=0,T=0;T<(g?g.length:0);++T)a(g[T]in l),x|=l[g[T]];var y=u.length/d,v=h?h.length:y,_=h===null||h.BYTES_PER_ELEMENT==4?h:new Uint32Array(h);return o(_,v,u,y,d,f,p,m,b,x)},generateNormals:function(h,u,d,f,p){a(h===null||h instanceof Uint32Array||h instanceof Int32Array||h instanceof Uint16Array||h instanceof Int16Array),a(h===null||h.length%3==0),a(u instanceof Float32Array),a(u.length%d==0),a(d>=3),a(h!==null||u.length/d%3==0),a(f>=0&&f<=Math.PI),p=p||0;var m=u.length/d,b=h?h.length:m,g=h===null||h.BYTES_PER_ELEMENT==4?h:new Uint32Array(h);return c(g,b,u,m,d,f,p)}}})();var kE=128,Rv=128;var bf={shaded:0,meshlets:1,lodLevel:2,instances:3};function Cv(r,e){let t=r.length;if(t<=e)return[r.map((u,d)=>d)];let s=new Map;for(let u=0;u<t;u++)for(let d of r[u].boundaryEdges){let f=s.get(d);f?f[f.length-1]!==u&&f.push(u):s.set(d,[u])}let n=Array.from({length:t},()=>new Map);for(let u of s.values())for(let d=0;d<u.length;d++)for(let f=d+1;f<u.length;f++){let p=u[d],m=u[f];n[p].set(m,(n[p].get(m)||0)+1),n[m].set(p,(n[m].get(p)||0)+1)}let a=SP(r.map(u=>u.center)),i=new Uint8Array(t),o=[];for(let u of a){if(i[u])continue;let d=[u];i[u]=1;let f=new Map,p=m=>{for(let[b,g]of n[m])i[b]||f.set(b,(f.get(b)||0)+g)};for(p(u);d.length<e&&f.size>0;){let m=-1,b=-1,g=1/0;for(let[x,T]of f){if(i[x])continue;let y=MP(r[x].center,r[u].center);(T>b||T===b&&y<g)&&(m=x,b=T,g=y)}if(m<0)break;f.delete(m),i[m]=1,d.push(m),p(m)}o.push(d)}let c=[],l=[],h=Math.max(2,Math.floor(e/2));for(let u of o){if(u.length>=h){c.push(u);continue}l.length+u.length>e&&(c.push(l),l=[]),l.push(...u)}return l.length>0&&c.push(l),c}function MP(r,e){let t=r[0]-e[0],s=r[1]-e[1],n=r[2]-e[2];return t*t+s*s+n*n}function SP(r){let e=[1/0,1/0,1/0],t=[-1/0,-1/0,-1/0];for(let a of r)for(let i=0;i<3;i++)e[i]=Math.min(e[i],a[i]),t[i]=Math.max(t[i],a[i]);let s=Math.max(t[0]-e[0],t[1]-e[1],t[2]-e[2])||1,n=r.map(a=>{let i=o=>Math.min(1023,Math.max(0,Math.floor((a[o]-e[o])/s*1023)));return Ev(i(0))|Ev(i(1))<<1|Ev(i(2))<<2});return r.map((a,i)=>i).sort((a,i)=>n[a]-n[i])}function Ev(r){return r&=1023,r=(r|r<<16)&50331903,r=(r|r<<8)&50393103,r=(r|r<<4)&51130563,r=(r|r<<2)&153391689,r}function BE(r,e,t,s,n){if(t.length===0)return null;let a=[1/0,1/0,1/0],i=[-1/0,-1/0,-1/0];for(let te=0;te<t.length;te++){let re=t[te]*3;for(let Q=0;Q<3;Q++)a[Q]=Math.min(a[Q],r[re+Q]),i[Q]=Math.max(i[Q],r[re+Q])}let o=Math.max(i[0]-a[0],i[1]-a[1],i[2]-a[2]);if(!(o>0))return null;let c=o/s,l=3,h=[0,1,2].map(te=>Math.ceil((i[te]-a[te])/c)+1+l*2),u=[0,1,2].map(te=>a[te]-l*c),[d,f,p]=h,m=1,b=d,g=d*f,x=d*f*p,T=new Uint8Array(x),y=e?new Float32Array(x*3):null,v=e?new Uint32Array(x):null,_=n?new Float32Array(x*2).fill(NaN):null,A=0,M=0,N=(te,re,Q,Ee,Oe,Ce)=>{let Je=Math.floor((te-u[0])/c)*m+Math.floor((re-u[1])/c)*b+Math.floor((Q-u[2])/c)*g;T[Je]=1,_&&Number.isNaN(_[Je*2])&&(_[Je*2]=A,_[Je*2+1]=M),y&&(y[Je*3]+=Ee,y[Je*3+1]+=Oe,y[Je*3+2]+=Ce,v[Je]++)};for(let te=0;te<t.length;te+=3){let re=t[te]*3,Q=t[te+1]*3,Ee=t[te+2]*3,Oe=Math.max(kv(r,re,Q),kv(r,Q,Ee),kv(r,Ee,re)),Ce=Math.max(1,Math.ceil(Oe/(c*.5)));for(let Je=0;Je<=Ce;Je++)for(let ne=0;ne<=Ce-Je;ne++){let ae=Je/Ce,oe=ne/Ce,me=1-ae-oe,ve=r[re]*me+r[Q]*ae+r[Ee]*oe,Pe=r[re+1]*me+r[Q+1]*ae+r[Ee+1]*oe,ue=r[re+2]*me+r[Q+2]*ae+r[Ee+2]*oe;if(n){let Ue=t[te]*2,De=t[te+1]*2,$e=t[te+2]*2;A=n[Ue]*me+n[De]*ae+n[$e]*oe,M=n[Ue+1]*me+n[De+1]*ae+n[$e+1]*oe}e?N(ve,Pe,ue,e[re]*me+e[Q]*ae+e[Ee]*oe,e[re+1]*me+e[Q+1]*ae+e[Ee+1]*oe,e[re+2]*me+e[Q+2]*ae+e[Ee+2]*oe):N(ve,Pe,ue,0,0,0)}}let R=RP(NP(T,h),h),I=new Float32Array(x);for(let te=0;te<x;te++)I[te]=R[te];Iv(I,h,m,d),Iv(I,h,b,f),Iv(I,h,g,p);let D=.5,O=d-1,P=f-1,U=p-1,j=new Int32Array(O*P*U).fill(-1),z=[],H=[],J=[],ee=[],se=new Float32Array(8);for(let te=0;te<U;te++)for(let re=0;re<P;re++)for(let Q=0;Q<O;Q++){let Ee=Q*m+re*b+te*g,Oe=0;for(let ue=0;ue<8;ue++)se[ue]=I[Ee+(ue&1)*m+(ue>>1&1)*b+(ue>>2&1)*g],se[ue]>=D&&Oe++;if(Oe===0||Oe===8)continue;let Ce=0,Je=0,ne=0,ae=0;for(let ue=0;ue<8;ue++)for(let Ue of[1,2,4]){if(ue&Ue)continue;let De=ue|Ue,$e=se[ue],At=se[De];if($e>=D==At>=D)continue;let ps=(D-$e)/(At-$e);Ce+=(ue&1)+(Ue===1?ps:0),Je+=(ue>>1&1)+(Ue===2?ps:0),ne+=(ue>>2&1)+(Ue===4?ps:0),ae++}j[Q+re*O+te*O*P]=z.length/3,z.push(u[0]+(Q+.5+Ce/ae)*c,u[1]+(re+.5+Je/ae)*c,u[2]+(te+.5+ne/ae)*c);let oe=se[1]+se[3]+se[5]+se[7]-se[0]-se[2]-se[4]-se[6],me=se[2]+se[3]+se[6]+se[7]-se[0]-se[1]-se[4]-se[5],ve=se[4]+se[5]+se[6]+se[7]-se[0]-se[1]-se[2]-se[3],Pe=Math.hypot(oe,me,ve)||1;if(H.push(-oe/Pe,-me/Pe,-ve/Pe),y){let ue=0,Ue=0,De=0,$e=0;for(let At=0;At<8;At++){let ps=Ee+(At&1)*m+(At>>1&1)*b+(At>>2&1)*g;v[ps]&&(ue+=y[ps*3],Ue+=y[ps*3+1],De+=y[ps*3+2],$e+=v[ps])}$e?J.push(ue/$e,Ue/$e,De/$e):J.push(NaN,NaN,NaN)}if(_){let ue=NaN,Ue=NaN;for(let De=0;De<8&&Number.isNaN(ue);De++){let $e=Ee+(De&1)*m+(De>>1&1)*b+(De>>2&1)*g;ue=_[$e*2],Ue=_[$e*2+1]}ee.push(ue,Ue)}}let _e=[],Ae=(te,re,Q)=>j[te+re*O+Q*O*P],Se=(te,re,Q,Ee,Oe,Ce,Je)=>{let ne=z[Q*3]-z[te*3],ae=z[Q*3+1]-z[te*3+1],oe=z[Q*3+2]-z[te*3+2],me=z[Ee*3]-z[re*3],ve=z[Ee*3+1]-z[re*3+1],Pe=z[Ee*3+2]-z[re*3+2],ue=ae*Pe-oe*ve,Ue=oe*me-ne*Pe,De=ne*ve-ae*me;ue*Oe+Ue*Ce+De*Je>=0?_e.push(te,re,Q,te,Q,Ee):_e.push(te,Q,re,te,Ee,Q)};for(let te=1;te<p-1;te++)for(let re=1;re<f-1;re++)for(let Q=1;Q<d-1;Q++){let Ee=Q*m+re*b+te*g,Oe=I[Ee]>=D;if(Oe!==I[Ee+m]>=D){let Ce=Oe?1:-1;Se(Ae(Q,re-1,te-1),Ae(Q,re,te-1),Ae(Q,re,te),Ae(Q,re-1,te),Ce,0,0)}if(Oe!==I[Ee+b]>=D){let Ce=Oe?1:-1;Se(Ae(Q-1,re,te-1),Ae(Q,re,te-1),Ae(Q,re,te),Ae(Q-1,re,te),0,Ce,0)}if(Oe!==I[Ee+g]>=D){let Ce=Oe?1:-1;Se(Ae(Q-1,re-1,te),Ae(Q,re-1,te),Ae(Q,re,te),Ae(Q-1,re,te),0,0,Ce)}}if(_e.length===0)return null;let Fe=null;y&&(Fe=Float32Array.from(J),IE(Fe,_e,3));let ft=null;return _&&(ft=Float32Array.from(ee),IE(ft,_e,2)),{positions:Float32Array.from(z),normals:Float32Array.from(H),colors:Fe,uvs:ft,indices:Uint32Array.from(_e),cellSize:c}}function kv(r,e,t){return Math.hypot(r[e]-r[t],r[e+1]-r[t+1],r[e+2]-r[t+2])}function NP(r,e){let t=r;for(let s=0;s<3;s++)t=FE(t,e,s,1);return t}function RP(r,e){let t=r;for(let s=0;s<3;s++)t=FE(t,e,s,0);return t}function FE(r,e,t,s){let[n,a,i]=e,o=t===0?1:t===1?n:n*a,c=e[t],l=new Uint8Array(r.length);for(let h=0;h<i;h++)for(let u=0;u<a;u++)for(let d=0;d<n;d++){let f=d+u*n+h*n*a,p=t===0?d:t===1?u:h,m=p>0?r[f-o]:0,b=p<c-1?r[f+o]:0;l[f]=s?r[f]|m|b:r[f]&m&b}return l}function Iv(r,e,t,s){let[n,a,i]=e,o=new Float32Array(s),c=n*a*i/s;for(let l=0;l<c;l++){let h;t===1?h=l*n:t===n?h=l%n+Math.floor(l/n)*n*a:h=l;for(let u=0;u<s;u++)o[u]=r[h+u*t];for(let u=0;u<s;u++){let d=u>0?o[u-1]:0,f=u<s-1?o[u+1]:0;r[h+u*t]=(d+o[u]+f)/3}}}function IE(r,e,t){let s=r.length/t;for(let n=0;n<8;n++){let a=0,i=new Float32Array(s*t),o=new Uint32Array(s);for(let c=0;c<e.length;c+=3)for(let l=0;l<3;l++){let h=e[c+l];if(Number.isNaN(r[h*t]))for(let u=1;u<3;u++){let d=e[c+(l+u)%3];if(!Number.isNaN(r[d*t])){for(let f=0;f<t;f++)i[h*t+f]+=r[d*t+f];o[h]++}}}for(let c=0;c<s;c++)if(Number.isNaN(r[c*t]))if(o[c])for(let l=0;l<t;l++)r[c*t+l]=i[c*t+l]/o[c];else a++;if(!a)return}for(let n=0;n<r.length;n++)Number.isNaN(r[n])&&(r[n]=.5)}var Bv=24;function DE(r,e,t,s,n,a){let i=r.length/3,o=new Map,c=m=>{let b=m;for(;o.get(b)!==b;)b=o.get(b);for(;o.get(m)!==b;){let g=o.get(m);o.set(m,b),m=g}return b};for(let m=0;m<r.length;m++){let b=t[r[m]];o.has(b)||o.set(b,b)}for(let m=0;m<r.length;m+=3){let b=c(t[r[m]]);for(let g=1;g<3;g++){let x=c(t[r[m+g]]);b!==x&&o.set(x,b)}}let l=new Map;for(let m=0;m<i;m++){let b=c(t[r[m*3]]),g=l.get(b);g||l.set(b,g=[]),g.push(m)}if(l.size<2)return null;let h=[];for(let m of l.values()){let b=new Uint32Array(m.length*3),g=!0;m.forEach((x,T)=>{for(let y=0;y<3;y++){let v=r[x*3+y];b[T*3+y]=v,s[t[v]]!==n&&(g=!1)}}),h.push({indices:b,free:g})}let u=[p(!0),p(!1)].filter(m=>m!==null),d=u.filter(m=>m.indices.length/3<=a*1.25),f=d.length?d:u;return f.sort((m,b)=>d.length?m.error-b.error:m.indices.length-b.indices.length),f[0]??null;function p(m){let b=0,g=h.map(N=>({...N})),x=a/i,T=0;for(let N of g){let R=Math.max(6,Math.floor(N.indices.length*x/3)*3);if(m&&N.free&&N.indices.length>R){let I=IP(N.indices,e),[D,O]=$a.simplify(I.indices,I.positions,3,R,1e10,["ErrorAbsolute"]);D.length>0&&D.length<N.indices.length&&(N.indices=D.map(P=>I.toGlobal[P]),b=Math.max(b,O))}T+=N.indices.length/3}let y=[],v=[],_=e.length/3;if(T>a){let N=g.map((H,J)=>({p:H,i:J})).filter(({p:H})=>H.free),R=new Map;for(let{p:H,i:J}of N)R.set(J,CP(H.indices,e));let I=N.map(({i:H})=>H),D=BP(I.map(H=>R.get(H).center)),O=Math.max(D[3]-D[0],D[4]-D[1],D[5]-D[2],1e-9),P=H=>FP([(H[0]-D[0])/O,(H[1]-D[1])/O,(H[2]-D[2])/O]);I.sort((H,J)=>P(R.get(H).center)-P(R.get(J).center));let U=I.map((H,J)=>{let ee=1/0;for(let se=Math.max(0,J-Bv);se<Math.min(I.length,J+1+Bv);se++)se!==J&&(ee=Math.min(ee,PE(R.get(H).center,R.get(I[se]).center)));return ee}),j=[...U].sort((H,J)=>H-J)[Math.floor(U.length/2)],z=new Set;for(let H=0;H<I.length&&T>a;H++){let J=I[H];if(z.has(J))continue;let ee=-1,se=j*2;for(let Oe=H+1;Oe<Math.min(I.length,H+1+Bv);Oe++){let Ce=I[Oe];if(z.has(Ce))continue;let Je=PE(R.get(J).center,R.get(Ce).center);Je<=se&&(se=Je,ee=Ce)}if(ee<0)continue;z.add(J),z.add(ee);let[_e,Ae]=R.get(J).area>=R.get(ee).area?[J,ee]:[ee,J],Se=R.get(_e),Fe=R.get(Ae),ft=Math.max(Se.area+Fe.area,1e-12),te=ft/Math.max(Se.area,1e-12),re=Fe.area/ft,Q=[0,1,2].map(Oe=>(Fe.center[Oe]-Se.center[Oe])*re),Ee=EP(g[_e].indices,e,Se,te,Q,_+v.length,y,v);b=Math.max(b,se*Math.max(re,1-re),Ee.growth),T-=g[Ae].indices.length/3,g[_e].indices=Ee.indices,g[Ae].indices=new Uint32Array(0)}}let A=new Uint32Array(g.reduce((N,R)=>N+R.indices.length,0)),M=0;for(let N of g)A.set(N.indices,M),M+=N.indices.length;return A.length>=r.length?null:{indices:A,error:b,newPositions:Float32Array.from(y),newSources:Uint32Array.from(v),firstNewVertex:_}}}function EP(r,e,t,s,n,a,i,o){let l=t.extent[0]>t.extent[1]*2?[1,s]:[Math.sqrt(s),Math.sqrt(s)],h=Math.max((l[0]-1)*t.extent[0],(l[1]-1)*t.extent[1])/2,u=new Map,d=new Uint32Array(r.length),f=t.center;for(let p=0;p<r.length;p++){let m=r[p],b=u.get(m);if(b===void 0){b=a+u.size,u.set(m,b);let g=[e[m*3]-f[0],e[m*3+1]-f[1],e[m*3+2]-f[2]],x=[e[m*3]+n[0],e[m*3+1]+n[1],e[m*3+2]+n[2]];for(let T=0;T<2;T++){let y=t.axes[T],v=g[0]*y[0]+g[1]*y[1]+g[2]*y[2];for(let _=0;_<3;_++)x[_]+=(l[T]-1)*v*y[_]}i.push(x[0],x[1],x[2]),o.push(m)}d[p]=b}return{indices:d,growth:h}}function CP(r,e){let t=[...new Set(r)],s=[0,0,0];for(let c of t)for(let l=0;l<3;l++)s[l]+=e[c*3+l]/t.length;let n=[0,0,0,0,0,0,0,0,0];for(let c of t){let l=[e[c*3]-s[0],e[c*3+1]-s[1],e[c*3+2]-s[2]];for(let h=0;h<3;h++)for(let u=0;u<3;u++)n[h*3+u]+=l[h]*l[u]}let a=kP(n),i=[0,0,0];for(let c=0;c<3;c++){let l=1/0,h=-1/0;for(let u of t){let d=(e[u*3]-s[0])*a[c][0]+(e[u*3+1]-s[1])*a[c][1]+(e[u*3+2]-s[2])*a[c][2];l=Math.min(l,d),h=Math.max(h,d)}i[c]=h-l}let o=0;for(let c=0;c<r.length;c+=3){let l=r[c]*3,h=r[c+1]*3,u=r[c+2]*3,d=[e[h]-e[l],e[h+1]-e[l+1],e[h+2]-e[l+2]],f=[e[u]-e[l],e[u+1]-e[l+1],e[u+2]-e[l+2]];o+=.5*Math.hypot(d[1]*f[2]-d[2]*f[1],d[2]*f[0]-d[0]*f[2],d[0]*f[1]-d[1]*f[0])}return{area:o,center:s,axes:a,extent:i}}function kP(r){let e=[...r],t=[1,0,0,0,1,0,0,0,1];for(let n=0;n<24&&!(Math.abs(e[1])+Math.abs(e[2])+Math.abs(e[5])<1e-12*(Math.abs(e[0])+Math.abs(e[4])+Math.abs(e[8])+1e-30));n++)for(let[i,o]of[[0,1],[0,2],[1,2]]){let c=e[i*3+o];if(Math.abs(c)<1e-30)continue;let l=(e[o*3+o]-e[i*3+i])/(2*c),h=Math.sign(l||1)/(Math.abs(l)+Math.sqrt(l*l+1)),u=1/Math.sqrt(h*h+1),d=h*u;for(let f=0;f<3;f++){let p=e[f*3+i],m=e[f*3+o];e[f*3+i]=u*p-d*m,e[f*3+o]=d*p+u*m}for(let f=0;f<3;f++){let p=e[i*3+f],m=e[o*3+f];e[i*3+f]=u*p-d*m,e[o*3+f]=d*p+u*m}for(let f=0;f<3;f++){let p=t[f*3+i],m=t[f*3+o];t[f*3+i]=u*p-d*m,t[f*3+o]=d*p+u*m}}return[0,1,2].sort((n,a)=>e[a*3+a]-e[n*3+n]).map(n=>{let a=t[n],i=t[3+n],o=t[6+n],c=Math.hypot(a,i,o)||1;return[a/c,i/c,o/c]})}function IP(r,e){let t=new Map,s=[],n=new Uint32Array(r.length);for(let i=0;i<r.length;i++){let o=t.get(r[i]);o===void 0&&(o=s.length,t.set(r[i],o),s.push(r[i])),n[i]=o}let a=new Float32Array(s.length*3);return s.forEach((i,o)=>a.set(e.subarray(i*3,i*3+3),o*3)),{indices:n,positions:a,toGlobal:s}}function BP(r){let e=[1/0,1/0,1/0,-1/0,-1/0,-1/0];for(let t of r)for(let s=0;s<3;s++)e[s]=Math.min(e[s],t[s]),e[s+3]=Math.max(e[s+3],t[s]);return e}var PE=(r,e)=>Math.hypot(r[0]-e[0],r[1]-e[1],r[2]-e[2]);function FP(r){let e=t=>{let s=Math.min(1023,Math.max(0,Math.floor(t*1024)))&1023;return s=(s|s<<16)&50331903,s=(s|s<<8)&50393103,s=(s|s<<4)&51130563,s=(s|s<<2)&153391689,s};return(e(r[0])|e(r[1])<<1|e(r[2])<<2)>>>0}var PP={groupSize:12,maxLodLevels:24,maxGroupKeepRatio:.9,simplifyRatio:.5,minLevelReduction:.03,prune:!1,tailSimplify:!0,minRootTriangles:4,voxelLods:!0,voxelResolution:64,aggregateLods:!0},DP=1024,UE=r=>{let e=[];for(let t=Math.max(4,Math.round(r));t>=4;t=Math.floor(t/2))e.push(t);return e},OP=()=>new Promise(r=>setTimeout(r,0));async function Tf(r,e={}){let t={...PP,...e},s=performance.now();await Yb.ready,await $a.ready;let n=r.positions,a=r.normals,i=r.colors??null,o=r.uvs??null,c=$a.generatePositionRemap(n,3),l=0,h=0,u=["LockBorder","ErrorAbsolute"];t.prune&&u.push("Prune");let d=[],f=new Map,p=N(r.indices,0,null,0),m=p,b=zE(m),g=1,x=Math.max(1,p.length*2);for(let R=1;R<=t.maxLodLevels&&m.length>1&&!(t.tailSimplify&&b<=DP||t.tailSimplify&&t.voxelLods&&h>0&&y(m,b));R++){let I=Cv(m,t.groupSize),D=[],O=t.aggregateLods?v(I,m):null,P=NaN;for(let[j,z]of I.entries()){let H=z.map(Q=>m[Q]),J=LE(H),ee=Zb(J,n),se=Math.max(3,Math.floor(J.length*t.simplifyRatio/3)*3),[_e,Ae]=$a.simplify(ee.indices,ee.positions,3,se,1e10,u),Se=new Uint32Array(_e.length);for(let Q=0;Q<_e.length;Q++)Se[Q]=ee.toGlobal[_e[Q]];let Fe=Math.max(Ae,Fv(ee.indices,_e,ee.positions));if(O&&_e.length>se*1.25){let Q=DE(J,n,c,O,j,se/3);Q&&Number.isNaN(P)&&(P=t.tailSimplify&&t.voxelLods?T(b):1/0);let Ee=Math.max(...H.map(Oe=>Oe.error));if(Q&&Q.indices.length<_e.length&&Ee+Q.error<P){let Oe=Q.newSources;if(Oe.length>0){let Ce=(Je,ne)=>{let ae=new Float32Array(Oe.length*ne);return Oe.forEach((oe,me)=>ae.set(Je.subarray(oe*ne,oe*ne+ne),me*ne)),ae};_(Q.newPositions,Ce(a,3),i?Ce(i,3):null,o?Ce(o,2):null)}Se=Q.indices,Fe=Math.max(Q.error,Fv(J,Se,n)),h++}}if(Se.length>J.length*t.maxGroupKeepRatio)continue;let ft=xf(H.map(Q=>Q.lodSphere)),re=Math.max(...H.map(Q=>Q.error))+Math.max(Fe,1e-7);for(let Q of H)Q.parentSphere=ft,Q.parentError=re;if(Se.length>0){let Q=N(Se,R,ft,re);D.push(...Q);for(let Ee of H)Ee.replacements=Q}}if(await t.onProgress?.(Math.min(.99,d.length/x)),await OP(),D.length===0)break;g=R+1,m=D;let U=zE(m);if(U>b*(1-t.minLevelReduction))break;b=U}return t.tailSimplify&&(g=M(d.filter(R=>R.parentError>=1e30),g)),await t.onProgress?.(1),UP({positions:n,normals:a,colors:i??void 0,uvs:o??void 0,indices:r.indices},d,g,l,performance.now()-s,h);function T(R){let I=Math.max(3,Math.floor(R/2)*3),D=1/0;for(let O of UE(t.voxelResolution)){let P=A(O);if(!P)continue;let[U,j]=$a.simplify(P.indices,P.positions,3,Math.min(I,P.indices.length),1e10,["ErrorAbsolute"]);U.length>0&&U.length<=I&&(D=Math.min(D,2*P.cellSize+j))}return D}function y(R,I){let D=0;for(let O of R)D=Math.max(D,O.error);return T(I)<=D}function v(R,I){let D=new Int32Array(c.length).fill(-1);return R.forEach((O,P)=>{for(let U of O){let j=I[U].indices;for(let z=0;z<j.length;z++){let H=c[j[z]];D[H]===-1?D[H]=P:D[H]!==P&&(D[H]=-2)}}}),D}function _(R,I,D,O){let P=n.length/3,U=R.length/3,j=(H,J)=>{let ee=new Float32Array(H.length+J.length);return ee.set(H),ee.set(J,H.length),ee};n=j(n,R),a=j(a,I),i&&(i=j(i,D??new Float32Array(U*3).fill(1))),o&&(o=j(o,O??new Float32Array(U*2)));let z=new Uint32Array(c.length+U);z.set(c);for(let H=0;H<U;H++)z[c.length+H]=P+H;return c=z,P}function A(R){return f.has(R)||f.set(R,BE(r.positions,r.colors,r.indices,R,r.uvs)),f.get(R)}function M(R,I){if(R.length===0)return I;let D=["ErrorAbsolute"];t.prune&&D.push("Prune");let O=R,P=I;for(;P<I+t.maxLodLevels;P++){let U=LE(O);if(U.length/3<=t.minRootTriangles)break;let j=Zb(U,n),z=Math.max(3,Math.floor(U.length/2/3)*3),H=U.length*t.maxGroupKeepRatio,J=Math.max(...O.map(te=>te.error)),[ee,se]=$a.simplify(j.indices,j.positions,3,z,1e10,D);if(ee.length>H){let[te,re]=$a.simplifySloppy(j.indices,j.positions,3,null,z,1);te.length<ee.length&&(ee=te,se=re*$a.getScale(j.positions,3))}let _e=null,Ae=1/0;if(ee.length<=H){Ae=J+Math.max(Math.max(se,Fv(j.indices,ee,j.positions)),1e-7),_e=new Uint32Array(ee.length);for(let te=0;te<ee.length;te++)_e[te]=j.toGlobal[ee[te]]}let Se=null;if(t.voxelLods)for(let te of UE(t.voxelResolution)){let re=A(te);if(!re)continue;let Q=Math.min(z,re.indices.length),[Ee,Oe]=$a.simplify(re.indices,re.positions,3,Q,1e10,["ErrorAbsolute"]);if(Ee.length===0||Ee.length>H)continue;let Ce=Math.max(J*(1+1e-5)+1e-7,2*re.cellSize+Oe);Ce<Ae&&(Ae=Ce,Se={proxy:re,indices:Ee})}if(!Number.isFinite(Ae))break;if(Se){let te=Zb(Se.indices,Se.proxy.positions),re=(Oe,Ce=3)=>{let Je=new Float32Array(te.toGlobal.length*Ce);return te.toGlobal.forEach((ne,ae)=>Je.set(Oe.subarray(ne*Ce,ne*Ce+Ce),ae*Ce)),Je},{proxy:Q}=Se,Ee=_(te.positions,re(Q.normals),Q.colors?re(Q.colors):null,Q.uvs?re(Q.uvs,2):null);_e=te.indices.map(Oe=>Oe+Ee),l++}let Fe=xf(O.map(te=>te.lodSphere));for(let te of O)te.parentSphere=Fe,te.parentError=Ae;if(_e.length===0)return P+1;let ft=N(_e,P,Fe,Ae);for(let te of O)te.replacements=ft;O=ft}return P}function N(R,I,D,O){let P=Zb(R,n),U=Yb.buildMeshlets(P.indices,P.positions,3,128,128,0),j=[];for(let z=0;z<U.meshletCount;z++){let H=U.meshlets[z*4+0],J=U.meshlets[z*4+1],ee=U.meshlets[z*4+2],se=U.meshlets[z*4+3],_e=new Uint32Array(ee);for(let te=0;te<ee;te++)_e[te]=P.toGlobal[U.vertices[H+te]];let Ae=U.triangles.slice(J,J+se*3),Se=new Uint32Array(se*3);for(let te=0;te<se*3;te++)Se[te]=_e[Ae[te]];let Fe=VP(Se,n),ft={indices:Se,lodLevel:I,lodSphere:D??Fe,error:O,parentSphere:[0,0,0,0],parentError:1e30,cullSphere:Fe,boundaryEdges:LP(Se,c),center:[Fe[0],Fe[1],Fe[2]],replacements:[],vertices:_e,localTriangles:Ae};j.push(ft),d.push(ft)}return j}}function UP(r,e,t,s,n,a){let i=[...e].sort((P,U)=>P.lodLevel-U.lodLevel),o=i.length,c=new Uint32Array(i.reduce((P,U)=>P+U.indices.length,0)),l=new Float32Array(o*16),h=new Uint32Array(o*4),u=new Map;i.forEach((P,U)=>u.set(P,U));let d=new Int32Array(o).fill(-1),f=new Map,p=[0],m=0;i.forEach((P,U)=>{if(P.replacements.length===0)return;let j=f.get(P.replacements);j===void 0&&(j=f.size,f.set(P.replacements,j),m+=P.replacements.length,p.push(m)),d[U]=j});let b=Uint32Array.from(p),g=new Uint32Array(m);for(let[P,U]of f)P.forEach((j,z)=>g[b[U]+z]=u.get(j));let x=new Uint32Array(i.reduce((P,U)=>P+U.vertices.length,0)),T=new Uint32Array(c.length/3),y=0,v=0,_={leafTriangles:0,leafMeshlets:0,rootTriangles:0,rootMeshlets:0,lodLevels:t,voxelLevels:s,aggregateGroups:a,buildMs:n};i.forEach((P,U)=>{c.set(P.indices,y),x.set(P.vertices,v);let j=P.localTriangles;for(let ee=0,se=y/3;ee<j.length;ee+=3,se++)T[se]=j[ee]|j[ee+1]<<8|j[ee+2]<<16;let z=U*16;l.set(P.lodSphere,z),l.set(P.parentSphere,z+4),l[z+8]=P.error,l[z+9]=P.parentError,l.set(P.cullSphere,z+12);let H=P.indices.length/3,J=U*4;h[J+0]=H,h[J+1]=y,h[J+2]=P.lodLevel,h[J+3]=v,y+=P.indices.length,v+=P.vertices.length,P.lodLevel===0&&(_.leafTriangles+=H,_.leafMeshlets+=1),P.parentError>=1e30&&(_.rootTriangles+=H,_.rootMeshlets+=1)});let A=xf(i.filter(P=>P.lodLevel===0).map(P=>P.cullSphere)),M=i.length?i[i.length-1].lodLevel+1:0,N=new Uint32Array(M*2),R=new Float32Array(M*2),I=new Float32Array(M*2);for(let P=0;P<M;P++)R[P*2]=1/0,R[P*2+1]=0,I[P*2]=0,I[P*2+1]=1/0;i.forEach((P,U)=>{let j=P.lodLevel;N[j*2+1]===0&&(N[j*2]=U),N[j*2+1]++,R[j*2]=Math.min(R[j*2],P.error),R[j*2+1]=Math.max(R[j*2+1],P.parentError),I[j*2]=Math.max(I[j*2],P.error),I[j*2+1]=Math.min(I[j*2+1],P.parentError)});let D=xf([...i.map(P=>P.lodSphere),...i.filter(P=>P.parentError<1e30).map(P=>P.parentSphere)]),O=xf(i.map(P=>P.cullSphere));return{positions:r.positions,normals:r.normals,colors:r.colors??null,uvs:r.uvs??null,indices:c,meshletCount:o,meshletBounds:l,meshletInfo:h,replacementGroup:d,replacementStart:b,replacementIndices:g,meshletVertices:x,meshletTriangles:T,levelRanges:N,levelErrors:R,levelGuardErrors:I,lodBoundsSphere:D,cullBoundsSphere:O,boundingSphere:A,stats:_}}function Fv(r,e,t){let s=o=>{let c=[1/0,1/0,1/0],l=[-1/0,-1/0,-1/0];for(let h=0;h<o.length;h++){let u=o[h]*3;for(let d=0;d<3;d++){let f=t[u+d];f<c[d]&&(c[d]=f),f>l[d]&&(l[d]=f)}}return{min:c,max:l}},n=s(r);if(e.length===0)return Math.max(n.max[0]-n.min[0],n.max[1]-n.min[1],n.max[2]-n.min[2])/2;let a=s(e),i=0;for(let o=0;o<3;o++)i=Math.max(i,a.min[o]-n.min[o],n.max[o]-a.max[o]);return i}var gf=new Int32Array(0);function Zb(r,e){let t=e.length/3;gf.length<t&&(gf=new Int32Array(t).fill(-1));let s=new Uint32Array(r.length),n=new Uint32Array(r.length),a=0;for(let c=0;c<r.length;c++){let l=r[c],h=gf[l];h<0&&(h=a++,gf[l]=h,s[h]=l),n[c]=h}let i=s.subarray(0,a),o=new Float32Array(a*3);for(let c=0;c<a;c++){let l=i[c];gf[l]=-1,o[c*3+0]=e[l*3+0],o[c*3+1]=e[l*3+1],o[c*3+2]=e[l*3+2]}return{indices:n,positions:o,toGlobal:i}}var yf=new Float64Array(1024),Mc=new Uint8Array(1024),Pv=new Int32Array(512);function LP(r,e){let t=r.length,s=yf.length;if(s<t*2){for(;s<t*2;)s<<=1;yf=new Float64Array(s),Mc=new Uint8Array(s),Pv=new Int32Array(s/2)}let n=s-1,a=0;for(let o=0;o<r.length;o+=3)for(let c=0;c<3;c++){let l=e[r[o+c]],h=e[r[o+(c+1)%3]],u=zP(l,h),d=(Math.imul(l<h?l:h,2654435761)^Math.imul(l<h?h:l,2246822507))&n;for(;Mc[d]!==0&&yf[d]!==u;)d=d+1&n;Mc[d]===0&&(yf[d]=u,Pv[a++]=d),Mc[d]<255&&Mc[d]++}let i=[];for(let o=0;o<a;o++){let c=Pv[o];Mc[c]===1&&i.push(yf[c]),Mc[c]=0}return i}var zP=(r,e)=>r<e?r*67108864+e:e*67108864+r;function LE(r){let e=new Uint32Array(r.reduce((s,n)=>s+n.indices.length,0)),t=0;for(let s of r)e.set(s.indices,t),t+=s.indices.length;return e}var zE=r=>r.reduce((e,t)=>e+t.indices.length/3,0);function VP(r,e){let t=[1/0,1/0,1/0],s=[-1/0,-1/0,-1/0];for(let c=0;c<r.length;c++){let l=r[c]*3;for(let h=0;h<3;h++){let u=e[l+h];u<t[h]&&(t[h]=u),u>s[h]&&(s[h]=u)}}let n=(t[0]+s[0])/2,a=(t[1]+s[1])/2,i=(t[2]+s[2])/2,o=0;for(let c=0;c<r.length;c++){let l=r[c]*3,h=e[l]-n,u=e[l+1]-a,d=e[l+2]-i;o=Math.max(o,h*h+u*u+d*d)}return[n,a,i,Math.sqrt(o)]}function xf(r){if(r.length===1)return[...r[0]];let e=new Float32Array(r.length*3),t=new Float32Array(r.length);r.forEach((a,i)=>{e.set([a[0],a[1],a[2]],i*3),t[i]=a[3]});let s=Yb.computeSphereBounds(e,3,t,1),n=s.radius;for(let a of r){let i=Math.hypot(a[0]-s.centerX,a[1]-s.centerY,a[2]-s.centerZ)+a[3];n=Math.max(n,i)}return[s.centerX,s.centerY,s.centerZ,n*1.0001]}var ch=1,jE=1329940310,Ya=16,Dv={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array},jP={positions:{strides:[12]},normals:{strides:[12]},colors:{strides:[12]},uvs:{strides:[8]},tangents:{strides:[16]},meshletBounds:{strides:[64],deflateRaw:!0},meshletInfo:{strides:[16]}},Gt=class extends Error{constructor(e){super(`three-virtual-geometry: ${e}`),this.name="VirtualMeshFormatError"}};async function Ov(r,e={}){let t=e.compress??!0;t&&await $b.ready;let s=r,n=Object.keys(s).filter(m=>s[m]!==void 0&&typeof s[m]!="function"),a=[],i=[],o={},c=0;for(let m of n){let b=s[m];if(!ArrayBuffer.isView(b)){o[m]=b;continue}let g=b.constructor.name;if(!(g in Dv))throw new Gt(`cannot serialize field "${m}" of type ${g}`);let x=b,T,y;m==="indices"&&!e.keepIndices&&qP(r)?(y={name:m,type:g,length:x.length,encoding:"meshlet-indices"},T=new Uint8Array(0)):t?{entry:y,blob:T}=await HP(m,g,x,r,e.deflate??!0):(y={name:m,type:g,length:x.length,encoding:"raw"},T=wr(x)),a.push({...y,offset:c,byteLength:T.length}),i.push(T),c+=lh(T.length)}let l={generator:"three-virtual-geometry",keys:n,fields:a,values:o},h=new TextEncoder().encode(JSON.stringify(l,$P)),u=lh(h.length),d=new Uint8Array(Ya+u+c);d.set(h,Ya),d.fill(32,Ya+h.length,Ya+u);let f=Ya+u;a.forEach((m,b)=>d.set(i[b],f+m.offset));let p=new DataView(d.buffer);return p.setUint32(0,jE,!0),p.setUint32(4,ch,!0),p.setUint32(8,h.length,!0),p.setUint32(12,qE(d,Ya),!0),d}async function vf(r){let e=ArrayBuffer.isView(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):new Uint8Array(r);e.byteOffset%4!==0&&(e=e.slice());let t=new DataView(e.buffer,e.byteOffset,e.byteLength);if(e.length<Ya||t.getUint32(0,!0)!==jE)throw new Gt("not a three-virtual-geometry geometry file (bad magic bytes)");let s=t.getUint32(4,!0);if(s!==ch)throw new Gt(`unsupported geometry format version ${s} (this build reads version ${ch}); re-bake the file`);let n=t.getUint32(8,!0),a=Ya+lh(n);if(a>e.length||e.length%4!==0)throw new Gt("geometry file is truncated");let i;try{i=JSON.parse(new TextDecoder().decode(e.subarray(Ya,Ya+n)),YP)}catch{throw new Gt("geometry file is corrupt or truncated (unreadable header)")}if(!i||!Array.isArray(i.fields)||!Array.isArray(i.keys)||typeof i.values!="object")throw new Gt("geometry file is corrupt (malformed header)");let o=e.subarray(a),c={},l=[...i.fields].sort((f,p)=>VE(f.encoding)-VE(p.encoding));l.some(f=>f.encoding!=="raw")&&await mf.ready;for(let f of l){if(!Dv[f.type]||!Number.isInteger(f.length)||f.length<0)throw new Gt(`geometry file is corrupt (field "${f.name}")`);if(f.offset%4!==0||f.offset+f.byteLength>o.length)throw new Gt(`geometry file is truncated (field "${f.name}")`)}if(qE(e,Ya)!==t.getUint32(12,!0))throw new Gt("geometry file is corrupt (checksum mismatch)");let h=(f,p)=>p instanceof Gt?p:new Gt(`geometry file is corrupt (field "${f.name}": ${p.message})`),u=await Promise.all(l.map(f=>{let p=o.subarray(f.offset,f.offset+f.byteLength);return f.deflate?XE(p).catch(m=>Promise.reject(h(f,m))):p}));for(let f=0;f<l.length;f++)try{c[l[f].name]=await GE({...l[f],deflate:!1},u[f],c)}catch(p){throw h(l[f],p)}let d={};for(let f of i.keys)d[f]=f in c?c[f]:i.values[f];return d}async function GP(r,e){if(typeof r!="string"&&!(r instanceof URL))return vf(r);let t=await fetch(r,e);if(!t.ok)throw new Error(`three-virtual-geometry: failed to load ${r} (HTTP ${t.status})`);return vf(await t.arrayBuffer())}async function HP(r,e,t,s,n){let a=wr(t),i={name:r,type:e,length:t.length},o=jP[r]??{},c={entry:{...i,encoding:"raw"},blob:a},l=[c],h=r==="meshletTriangles"&&t instanceof Uint32Array?WP(t,s.meshletInfo):null;if(h)l.push({entry:{...i,encoding:"meshlet-triangles"},blob:h});else if(a.length%4===0&&a.length>0){let u=(o.strides??[Math.max(4,t.BYTES_PER_ELEMENT)]).filter(d=>d%4===0&&d<=256&&a.length%d===0);for(let d of u){let f=$b.encodeVertexBufferLevel(a,a.length/d,d,2,1);l.push({entry:{...i,encoding:"meshopt-vertex",stride:d},blob:f})}}if(l.sort((u,d)=>u.blob.length-d.blob.length),n&&KP()&&a.length>=64){let u=o.deflateRaw&&l[0]!==c?[l[0],c]:[l[0]];for(let d of u)l.push({entry:{...d.entry,deflate:!0},blob:await JP(d.blob)});l.sort((d,f)=>d.blob.length-f.blob.length)}for(let u of l){let d=await GE({...u.entry,offset:0,byteLength:u.blob.length},u.blob,{meshletInfo:s.meshletInfo});if(WE(wr(d),a))return u}return c}function WP(r,e){if(!(e instanceof Uint32Array))return null;let t=new Uint32Array(r.length*3),s=new Uint8Array(r.length);for(let c=0;c<e.length;c+=4){let l=e[c],h=e[c+1]/3,u=e[c+3];if(h+l>r.length)return null;for(let d=h;d<h+l;d++){let f=r[d];if(s[d]||f>>>24)return null;s[d]=1,t[d*3]=u+(f&255),t[d*3+1]=u+(f>>8&255),t[d*3+2]=u+(f>>16&255)}}if(!s.every(c=>c===1))return null;let n=$b.encodeIndexBuffer(wr(t),t.length,4),a=new Uint32Array(t.length);mf.decodeIndexBuffer(wr(a),t.length,4,n);let i=new Uint8Array(Math.ceil(r.length/4));for(let c=0;c<r.length;c++){let l=t[c*3],h=t[c*3+1],u=t[c*3+2],d=a[c*3],f=a[c*3+1],p=a[c*3+2],m;if(l===d&&h===f&&u===p)m=0;else if(l===f&&h===p&&u===d)m=1;else if(l===p&&h===d&&u===f)m=2;else return null;i[c>>2]|=m<<(c&3)*2}let o=new Uint8Array(4+lh(n.length)+i.length);return new DataView(o.buffer).setUint32(0,n.length,!0),o.set(n,4),o.set(i,4+lh(n.length)),o}function qP(r){let{indices:e,meshletInfo:t,meshletVertices:s,meshletTriangles:n}=r;if(!(e instanceof Uint32Array&&t instanceof Uint32Array&&s instanceof Uint32Array&&n instanceof Uint32Array))return!1;try{return WE(wr(HE(e.length,t,s,n)),wr(e))}catch{return!1}}var VE=r=>r==="meshlet-triangles"?1:r==="meshlet-indices"?2:0;async function GE(r,e,t){let s=Dv[r.type],n=new s(r.length),a=wr(n),i=r.deflate?await XE(e):e;switch(r.encoding){case"raw":if(i.length!==a.length)throw new Gt(`geometry file is corrupt (field "${r.name}" has the wrong size)`);a.set(i);break;case"meshopt-vertex":{let o=r.stride??0;if(o<=0||o%4!==0||a.length%o!==0)throw new Gt(`geometry file is corrupt (field "${r.name}" stride)`);mf.decodeVertexBuffer(a,a.length/o,o,i);break}case"meshlet-triangles":XP(n,i,eg(t,"meshletInfo",r.name));break;case"meshlet-indices":n.set(HE(r.length,eg(t,"meshletInfo",r.name),eg(t,"meshletVertices",r.name),eg(t,"meshletTriangles",r.name)));break;default:throw new Gt(`unknown encoding "${r.encoding}" for field "${r.name}"`)}return n}function eg(r,e,t){let s=r[e];if(!(s instanceof Uint32Array))throw new Gt(`geometry file is corrupt ("${t}" needs "${e}")`);return s}function XP(r,e,t){let s=new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(0,!0),n=4+lh(s);if(n+Math.ceil(r.length/4)>e.length)throw new Error("truncated triangle data");let a=new Uint32Array(r.length*3);mf.decodeIndexBuffer(wr(a),a.length,4,e.subarray(4,4+s));let i=e.subarray(n);for(let o=0;o<t.length;o+=4){let c=t[o],l=t[o+1]/3,h=t[o+3];if(l+c>r.length)throw new Error("meshlet range out of bounds");for(let u=l;u<l+c;u++){let d=i[u>>2]>>(u&3)*2&3,f=a[u*3]-h,p=a[u*3+1]-h,m=a[u*3+2]-h,[b,g,x]=d===0?[f,p,m]:d===1?[p,m,f]:[m,f,p];if((b|g|x)>>>8)throw new Error("meshlet-local vertex id out of range");r[u]=b|g<<8|x<<16}}}function HE(r,e,t,s){let n=new Uint32Array(r);for(let a=0;a<e.length;a+=4){let i=e[a],o=e[a+1],c=e[a+3];if(o+i*3>r||o/3+i>s.length)throw new Gt("geometry file is corrupt (meshlet range out of bounds)");for(let l=0;l<i;l++){let h=s[o/3+l];for(let u=0;u<3;u++){let d=c+(h>>8*u&255);if(d>=t.length)throw new Gt("geometry file is corrupt (meshlet vertex out of bounds)");n[o+l*3+u]=t[d]}}}return n}var lh=r=>r+3&-4;function wr(r){return new Uint8Array(r.buffer,r.byteOffset,r.byteLength)}function WE(r,e){if(r.length!==e.length)return!1;if(r.byteOffset%4===0&&e.byteOffset%4===0&&r.length%4===0){let t=new Uint32Array(r.buffer,r.byteOffset,r.length/4),s=new Uint32Array(e.buffer,e.byteOffset,e.length/4);for(let n=0;n<t.length;n++)if(t[n]!==s[n])return!1;return!0}for(let t=0;t<r.length;t++)if(r[t]!==e[t])return!1;return!0}function qE(r,e){let t=new Uint32Array(r.buffer,r.byteOffset+e,r.length-e>>2),s=2166136261^t.length;for(let n=0;n<t.length;n++)s=Math.imul(s^t[n],16777619),s^=s>>>15;return s>>>0}var KP=()=>typeof CompressionStream<"u"&&typeof DecompressionStream<"u";async function JP(r){let e=new Blob([r]).stream().pipeThrough(new CompressionStream("deflate-raw"));return new Uint8Array(await new Response(e).arrayBuffer())}async function XE(r){if(typeof DecompressionStream>"u")throw new Gt("this environment cannot decompress the geometry file (no DecompressionStream)");let e=new Blob([r]).stream().pipeThrough(new DecompressionStream("deflate-raw"));return new Uint8Array(await new Response(e).arrayBuffer())}function $P(r,e){if(typeof e=="number"&&!Number.isFinite(e))return{$number:String(e)};if(ArrayBuffer.isView(e))throw new Gt(`typed array nested inside field "${r}" cannot be serialized; store it as a top-level field`);return e}function YP(r,e){if(e&&typeof e=="object"&&!Array.isArray(e)){let t=Object.keys(e);if(t.length===1&&t[0]==="$number")return Number(e.$number)}return e}var KE=8,ZP="three-virtual-geometry-cache",va="meshes",_a="meta",QP=512*1024*1024,e3=3e3;async function Lv(r,e={}){let{cache:t,...s}=e;if(t?.store===!1||!$E())return Tf(r,s);let n=performance.now(),a=await JE(r,s,t?.key).catch(()=>null),i=a?await YE():null;if(!i||!a)return Tf(r,s);let o=await s3(i,a);if(o)try{let l=await vf(o);return l.stats&&(l.stats.buildMs=performance.now()-n),a3(i,a),await s.onProgress?.(1),l}catch{i3(i,a)}let c=await Tf(r,s);try{let l=await Ov(c,{deflate:!1});n3(i,a,l,t?.maxBytes)}catch{}return c}async function t3(){if(!$E())return;let r=await YE();r&&await new Promise(e=>{try{let t=r.transaction([va,_a],"readwrite");t.objectStore(va).clear(),t.objectStore(_a).clear(),t.oncomplete=t.onerror=t.onabort=()=>e()}catch{e()}})}async function JE(r,e={},t){let s=`v${KE}.${ch}`;if(t!==void 0)return`${s}:key:${t}`;let n=globalThis.crypto?.subtle;if(!n)throw new Error("crypto.subtle unavailable");let a=r,i=Object.keys(a).filter(p=>a[p]!==void 0&&a[p]!==null).sort(),o=[],c=[];for(let p of i){let m=a[p];ArrayBuffer.isView(m)?(o.push([p,m.constructor.name,m.byteLength]),c.push(n.digest("SHA-256",m))):o.push([p,m])}let l=Object.entries(e).filter(([,p])=>p!==void 0&&typeof p!="function").sort(([p],[m])=>p<m?-1:1),h=new TextEncoder().encode(JSON.stringify({versions:s,source:o,options:l})),u=await Promise.all(c),d=new Uint8Array(h.length+u.length*32);d.set(h),u.forEach((p,m)=>d.set(new Uint8Array(p),h.length+m*32));let f=new Uint8Array(await n.digest("SHA-256",d));return`${s}:sha256:${Array.from(f,p=>p.toString(16).padStart(2,"0")).join("")}`}function $E(){try{return typeof indexedDB<"u"&&indexedDB!==null}catch{return!1}}var Uv=null;function YE(){return Uv??=new Promise(r=>{let e=setTimeout(()=>r(null),e3),t=s=>{clearTimeout(e),r(s)};try{let s=indexedDB.open(ZP,1);s.onupgradeneeded=()=>{let n=s.result;n.objectStoreNames.contains(va)||n.createObjectStore(va),n.objectStoreNames.contains(_a)||n.createObjectStore(_a)},s.onsuccess=()=>{let n=s.result;n.onversionchange=()=>{n.close(),Uv=Promise.resolve(null)},t(n)},s.onerror=s.onblocked=()=>t(null)}catch{t(null)}}),Uv}function s3(r,e){return new Promise(t=>{try{let s=r.transaction(va,"readonly").objectStore(va).get(e);s.onsuccess=()=>{let n=s.result;t(n instanceof ArrayBuffer?new Uint8Array(n):n instanceof Uint8Array?n:null)},s.onerror=()=>t(null)}catch{t(null)}})}function n3(r,e,t,s=QP){return new Promise(n=>{try{let a=r.transaction([va,_a],"readwrite");a.objectStore(va).put(t.buffer.byteLength===t.length?t.buffer:t.slice().buffer,e),a.objectStore(_a).put({size:t.length,lastUsed:Date.now()},e),a.oncomplete=()=>n(),a.onerror=a.onabort=()=>n()}catch{n()}}).then(()=>r3(r,e,s))}function a3(r,e){try{let s=r.transaction(_a,"readwrite").objectStore(_a),n=s.get(e);n.onsuccess=()=>{let a=n.result;a&&s.put({...a,lastUsed:Date.now()},e)}}catch{}}function i3(r,e){try{let t=r.transaction([va,_a],"readwrite");t.objectStore(va).delete(e),t.objectStore(_a).delete(e)}catch{}}function r3(r,e,t){return new Promise(s=>{try{let n=r.transaction([va,_a],"readwrite"),a=n.objectStore(_a),i=a.getAllKeys(),o=a.getAll();o.onsuccess=()=>{let c=i.result,l=o.result.map((u,d)=>({key:c[d],...u})),h=l.reduce((u,d)=>u+d.size,0);l.sort((u,d)=>u.lastUsed-d.lastUsed);for(let u of l){if(h<=t)break;u.key!==e&&(n.objectStore(va).delete(u.key),a.delete(u.key),h-=u.size)}},n.oncomplete=n.onerror=n.onabort=()=>s()}catch{s()}})}var O2={};CE(O2,{BRDF_GGX:()=>UH,BRDF_Lambert:()=>LH,BRDF_Sheen:()=>zH,BasicPointShadowFilter:()=>VH,BasicShadowFilter:()=>jH,Break:()=>GH,Const:()=>HH,Continue:()=>WH,DFGLUT:()=>qH,D_GGX:()=>XH,D_GGX_Anisotropic:()=>KH,Discard:()=>JH,EPSILON:()=>$H,EnvironmentBRDF:()=>YH,F_Schlick:()=>ZH,Fn:()=>Zs,HALF_PI:()=>QH,INFINITY:()=>eW,If:()=>Tt,LTC_Evaluate:()=>tW,LTC_Evaluate_Volume:()=>sW,LTC_Uv:()=>nW,Loop:()=>co,NodeAccess:()=>aW,NodeShaderStage:()=>iW,NodeType:()=>rW,NodeUpdateType:()=>oW,OnAfterObjectUpdate:()=>cW,OnAfterRenderPipeline:()=>lW,OnBeforeFrameUpdate:()=>hW,OnBeforeMaterialUpdate:()=>uW,OnBeforeObjectUpdate:()=>dW,OnBeforeRenderPipeline:()=>fW,OnFrameUpdate:()=>pW,OnMaterialUpdate:()=>mW,OnObjectUpdate:()=>bW,PCFShadowFilter:()=>gW,PI:()=>yW,PI2:()=>xW,PointShadowFilter:()=>wW,Return:()=>xa,Schlick_to_F0:()=>TW,ShaderNode:()=>vW,Stack:()=>_W,Switch:()=>AW,TBNViewMatrix:()=>MW,TWO_PI:()=>SW,VSMShadowFilter:()=>NW,V_GGX_SmithCorrelated:()=>RW,V_GGX_SmithCorrelated_Anisotropic:()=>EW,Var:()=>CW,VarIntent:()=>kW,abs:()=>IW,acesFilmicToneMapping:()=>BW,acos:()=>FW,acosh:()=>PW,add:()=>DW,addMethodChaining:()=>OW,addNodeElement:()=>UW,agxToneMapping:()=>LW,all:()=>zW,alphaT:()=>VW,ambientOcclusion:()=>jW,and:()=>GW,anisotropy:()=>HW,anisotropyB:()=>WW,anisotropyT:()=>qW,any:()=>XW,array:()=>KW,asin:()=>JW,asinh:()=>$W,assign:()=>YW,atan:()=>ZW,atanh:()=>QW,atomicAdd:()=>mr,atomicAnd:()=>e6,atomicFunc:()=>t6,atomicLoad:()=>qn,atomicMax:()=>s6,atomicMin:()=>n6,atomicOr:()=>a6,atomicStore:()=>Ha,atomicSub:()=>i6,atomicXor:()=>r6,attenuationColor:()=>o6,attenuationDistance:()=>c6,attribute:()=>l6,attributeArray:()=>h6,backgroundBlurriness:()=>u6,backgroundIntensity:()=>d6,backgroundRotation:()=>f6,batch:()=>p6,batchColor:()=>m6,batchIndirectIndex:()=>b6,bentNormalView:()=>g6,billboarding:()=>y6,bitAnd:()=>x6,bitNot:()=>w6,bitOr:()=>T6,bitXor:()=>v6,bitangentGeometry:()=>_6,bitangentLocal:()=>A6,bitangentView:()=>M6,bitangentViewFrame:()=>S6,bitangentWorld:()=>N6,bitcast:()=>iv,blendBurn:()=>R6,blendColor:()=>E6,blendDodge:()=>C6,blendOverlay:()=>k6,blendScreen:()=>I6,bool:()=>eh,buffer:()=>B6,bufferAttribute:()=>F6,builtin:()=>P6,builtinAOContext:()=>D6,builtinGIContext:()=>O6,builtinShadowContext:()=>U6,bumpMap:()=>ZN,bvec2:()=>L6,bvec3:()=>z6,bvec4:()=>V6,bypass:()=>j6,cache:()=>G6,call:()=>H6,cameraFar:()=>W6,cameraIndex:()=>q6,cameraNear:()=>X6,cameraNormalMatrix:()=>K6,cameraPosition:()=>J6,cameraProjectionMatrix:()=>$6,cameraProjectionMatrixInverse:()=>Y6,cameraViewMatrix:()=>Sb,cameraViewport:()=>Z6,cameraWorldMatrix:()=>Q6,cbrt:()=>eq,cdl:()=>tq,ceil:()=>QN,checker:()=>sq,cineonToneMapping:()=>nq,clamp:()=>yc,clearcoat:()=>aq,clearcoatNormalView:()=>iq,clearcoatRoughness:()=>rq,clipSpace:()=>oq,clipping:()=>cq,clippingAlpha:()=>lq,code:()=>hq,color:()=>uq,colorSpaceToWorking:()=>dq,colorToDirection:()=>fq,compute:()=>pq,computeKernel:()=>mq,computeSkinning:()=>bq,context:()=>rv,convert:()=>gq,convertColorSpace:()=>yq,convertToTexture:()=>xq,cos:()=>wq,cosh:()=>Tq,countLeadingZeros:()=>vq,countOneBits:()=>_q,countTrailingZeros:()=>Aq,cross:()=>Mq,cubeTexture:()=>Sq,cubeTextureBase:()=>Nq,dFdx:()=>Rq,dFdy:()=>Eq,dashSize:()=>Cq,debug:()=>kq,decrement:()=>Iq,decrementBefore:()=>Bq,defaultBuildStages:()=>Fq,defaultShaderStages:()=>Pq,defined:()=>Dq,degrees:()=>Oq,deltaTime:()=>Uq,densityFogFactor:()=>Lq,depth:()=>zq,depthPass:()=>Vq,determinant:()=>jq,difference:()=>Gq,diffuseColor:()=>Hq,diffuseContribution:()=>Wq,directPointLight:()=>qq,directionToColor:()=>Xq,directionToFaceDirection:()=>Kq,dispersion:()=>Jq,distance:()=>$q,div:()=>Yq,dot:()=>ov,dot4I8Packed:()=>Zq,dot4U8Packed:()=>Qq,drawIndex:()=>e5,dynamicBufferAttribute:()=>t5,element:()=>s5,emissive:()=>n5,equal:()=>a5,equirectDirection:()=>i5,equirectUV:()=>r5,exp:()=>o5,exp2:()=>eR,exponentialHeightFogFactor:()=>c5,expression:()=>l5,faceDirection:()=>tR,faceForward:()=>h5,faceforward:()=>u5,float:()=>ht,floatBitsToInt:()=>d5,floatBitsToUint:()=>f5,floor:()=>br,fog:()=>p5,fract:()=>cv,frameGroup:()=>m5,frameId:()=>b5,frontFacing:()=>g5,fwidth:()=>y5,gain:()=>x5,gapSize:()=>w5,getConstNodeType:()=>T5,getCurrentStack:()=>v5,getDistanceAttenuation:()=>_5,getGeometryRoughness:()=>A5,getNormalFromDepth:()=>M5,getParallaxCorrectNormal:()=>S5,getRoughness:()=>N5,getScreenPosition:()=>R5,getScreenPositionFromClip:()=>E5,getShIrradianceAt:()=>C5,getTextureIndex:()=>k5,getViewPosition:()=>I5,globalId:()=>B5,glsl:()=>F5,glslFn:()=>P5,grayscale:()=>D5,greaterThan:()=>O5,greaterThanEqual:()=>U5,hardwareClipping:()=>L5,hash:()=>Nb,highpModelNormalViewMatrix:()=>z5,highpModelViewMatrix:()=>V5,hue:()=>j5,increment:()=>G5,incrementBefore:()=>H5,inspect:()=>W5,instance:()=>q5,instanceColor:()=>X5,instanceIndex:()=>xc,instancedArray:()=>K5,instancedBufferAttribute:()=>J5,instancedDynamicBufferAttribute:()=>$5,instancedMesh:()=>Y5,int:()=>lv,intBitsToFloat:()=>Z5,interleavedGradientNoise:()=>Q5,inverse:()=>eX,inverseSqrt:()=>tX,inversesqrt:()=>sX,invocationLocalIndex:()=>nX,invocationSubgroupIndex:()=>aX,ior:()=>iX,iridescence:()=>rX,iridescenceIOR:()=>oX,iridescenceThickness:()=>cX,isolate:()=>lX,ivec2:()=>sR,ivec3:()=>hX,ivec4:()=>uX,js:()=>dX,label:()=>fX,length:()=>gr,lengthSq:()=>pX,lessThan:()=>mX,lessThanEqual:()=>bX,lightPosition:()=>gX,lightProjectionUV:()=>yX,lightShadowMatrix:()=>xX,lightTargetDirection:()=>wX,lightTargetPosition:()=>TX,lightViewPosition:()=>vX,lightingContext:()=>_X,lights:()=>AX,linearDepth:()=>MX,linearToneMapping:()=>SX,localId:()=>Qd,log:()=>nR,log2:()=>aR,logarithmicDepthToViewZ:()=>NX,luminance:()=>RX,mat2:()=>EX,mat3:()=>iR,mat4:()=>rR,matcapUV:()=>CX,materialAO:()=>kX,materialAlphaTest:()=>IX,materialAnisotropy:()=>BX,materialAnisotropyVector:()=>FX,materialAttenuationColor:()=>PX,materialAttenuationDistance:()=>DX,materialClearcoat:()=>OX,materialClearcoatNormal:()=>UX,materialClearcoatRoughness:()=>LX,materialColor:()=>ef,materialDispersion:()=>zX,materialEmissive:()=>VX,materialEnvIntensity:()=>jX,materialEnvRotation:()=>GX,materialIOR:()=>HX,materialIridescence:()=>WX,materialIridescenceIOR:()=>qX,materialIridescenceThickness:()=>XX,materialLightMap:()=>KX,materialLineDashOffset:()=>JX,materialLineDashSize:()=>$X,materialLineGapSize:()=>YX,materialLineScale:()=>ZX,materialLineWidth:()=>QX,materialMetalness:()=>eK,materialNormal:()=>tK,materialOpacity:()=>sK,materialPointSize:()=>nK,materialReference:()=>Rb,materialReflectivity:()=>aK,materialRefractionRatio:()=>iK,materialRetroreflectivity:()=>rK,materialRotation:()=>oK,materialRoughness:()=>cK,materialSheen:()=>lK,materialSheenRoughness:()=>hK,materialShininess:()=>uK,materialSpecular:()=>dK,materialSpecularColor:()=>fK,materialSpecularIntensity:()=>pK,materialSpecularStrength:()=>mK,materialThickness:()=>bK,materialTransmission:()=>gK,max:()=>Xn,maxMipLevel:()=>yK,mediumpModelViewMatrix:()=>xK,metalness:()=>wK,min:()=>tf,mix:()=>TK,mixElement:()=>vK,mod:()=>_K,modelDirection:()=>AK,modelNormalMatrix:()=>MK,modelPosition:()=>SK,modelRadius:()=>NK,modelScale:()=>RK,modelViewMatrix:()=>EK,modelViewPosition:()=>CK,modelViewProjection:()=>kK,modelWorldMatrix:()=>oR,modelWorldMatrixInverse:()=>IK,morphReference:()=>BK,mrt:()=>cR,mul:()=>FK,mx_aastep:()=>PK,mx_add:()=>DK,mx_atan2:()=>OK,mx_cell_noise_float:()=>UK,mx_cell_noise_vec3:()=>LK,mx_contrast:()=>zK,mx_divide:()=>VK,mx_fractal_noise_float:()=>jK,mx_fractal_noise_float_2d:()=>GK,mx_fractal_noise_vec2:()=>HK,mx_fractal_noise_vec3:()=>WK,mx_fractal_noise_vec4:()=>qK,mx_frame:()=>XK,mx_heighttonormal:()=>KK,mx_hsvtorgb:()=>JK,mx_ifequal:()=>$K,mx_ifgreater:()=>YK,mx_ifgreatereq:()=>ZK,mx_invert:()=>QK,mx_modulo:()=>eJ,mx_multiply:()=>tJ,mx_noise_float:()=>sJ,mx_noise_vec3:()=>nJ,mx_noise_vec4:()=>aJ,mx_place2d:()=>iJ,mx_power:()=>rJ,mx_ramp4:()=>oJ,mx_ramplr:()=>cJ,mx_ramptb:()=>lJ,mx_rgbtohsv:()=>hJ,mx_rotate2d:()=>uJ,mx_rotate3d:()=>dJ,mx_safepower:()=>fJ,mx_separate:()=>pJ,mx_smoothstep:()=>mJ,mx_splitlr:()=>bJ,mx_splittb:()=>gJ,mx_srgb_texture_to_lin_rec709:()=>yJ,mx_subtract:()=>xJ,mx_timer:()=>wJ,mx_transform_uv:()=>TJ,mx_unifiednoise2d:()=>vJ,mx_unifiednoise3d:()=>_J,mx_worley_noise_float:()=>AJ,mx_worley_noise_float_2d:()=>MJ,mx_worley_noise_float_3d:()=>SJ,mx_worley_noise_vec2:()=>NJ,mx_worley_noise_vec3:()=>RJ,mx_worley_noise_vec3_style:()=>EJ,negate:()=>CJ,negateOnBackSide:()=>hv,neutralToneMapping:()=>kJ,nodeArray:()=>IJ,nodeImmutable:()=>BJ,nodeObject:()=>FJ,nodeObjectIntent:()=>PJ,nodeObjects:()=>DJ,nodeProxy:()=>OJ,nodeProxyConstructor:()=>UJ,nodeProxyIntent:()=>LJ,normalFlat:()=>zJ,normalGeometry:()=>VJ,normalLocal:()=>lR,normalMap:()=>jJ,normalView:()=>hR,normalViewGeometry:()=>GJ,normalWorld:()=>HJ,normalWorldGeometry:()=>WJ,normalize:()=>sf,not:()=>qJ,notEqual:()=>XJ,numWorkgroups:()=>Eb,objectDirection:()=>KJ,objectGroup:()=>JJ,objectPosition:()=>$J,objectRadius:()=>YJ,objectScale:()=>ZJ,objectViewPosition:()=>QJ,objectWorldMatrix:()=>e$,oneMinus:()=>t$,or:()=>s$,orthographicDepthToViewZ:()=>n$,oscSawtooth:()=>a$,oscSine:()=>i$,oscSquare:()=>r$,oscTriangle:()=>o$,output:()=>c$,outputStruct:()=>l$,overloadingFn:()=>h$,overrideNode:()=>u$,overrideNodes:()=>d$,pack4xI8:()=>f$,pack4xI8Clamp:()=>p$,pack4xU8:()=>m$,pack4xU8Clamp:()=>b$,packHalf2x16:()=>g$,packNormalToRGB:()=>y$,packSnorm2x16:()=>x$,packSnorm4x8:()=>w$,packUnorm2x16:()=>T$,packUnorm4x8:()=>v$,parabola:()=>_$,parallaxDirection:()=>A$,parallaxUV:()=>M$,parameter:()=>S$,pass:()=>N$,passTexture:()=>R$,pcurve:()=>E$,perspectiveDepthToViewZ:()=>C$,pmremTexture:()=>k$,pointShadow:()=>I$,pointUV:()=>B$,pointWidth:()=>F$,positionGeometry:()=>P$,positionLocal:()=>uR,positionPrevious:()=>D$,positionView:()=>uv,positionViewDirection:()=>O$,positionWorld:()=>U$,positionWorldDirection:()=>L$,posterize:()=>z$,pow:()=>V$,pow2:()=>j$,pow3:()=>G$,pow4:()=>H$,premultiplyAlpha:()=>W$,property:()=>q$,quadBroadcast:()=>X$,quadSwapDiagonal:()=>K$,quadSwapX:()=>J$,quadSwapY:()=>$$,radians:()=>Y$,rand:()=>Z$,range:()=>Q$,rangeFogFactor:()=>eY,reciprocal:()=>tY,reference:()=>sY,referenceBuffer:()=>nY,reflect:()=>aY,reflectVector:()=>iY,reflectView:()=>rY,reflector:()=>oY,refract:()=>cY,refractVector:()=>lY,refractView:()=>hY,reinhardToneMapping:()=>uY,remap:()=>dY,remapClamp:()=>fY,renderGroup:()=>pY,renderOutput:()=>mY,rendererReference:()=>bY,replaceDefaultUV:()=>gY,retroreflectivity:()=>yY,rotate:()=>xY,rotateUV:()=>wY,roughness:()=>TY,round:()=>vY,rtt:()=>_Y,sRGBTransferEOTF:()=>AY,sRGBTransferOETF:()=>MY,sample:()=>SY,sampler:()=>NY,samplerComparison:()=>RY,saturate:()=>EY,saturation:()=>CY,screenCoordinate:()=>dR,screenDPR:()=>kY,screenSize:()=>IY,screenUV:()=>BY,select:()=>os,setCurrentStack:()=>FY,setName:()=>PY,shaderStages:()=>DY,shadow:()=>OY,shadowPositionWorld:()=>UY,shapeCircle:()=>LY,sharedUniformGroup:()=>zY,sheen:()=>VY,sheenRoughness:()=>jY,shiftLeft:()=>GY,shiftRight:()=>HY,shininess:()=>WY,sign:()=>qY,sin:()=>XY,sinc:()=>KY,sinh:()=>JY,skinning:()=>$Y,smoothstep:()=>fR,smoothstepElement:()=>YY,specularColor:()=>ZY,specularColorBlended:()=>QY,specularF90:()=>e7,spherizeUV:()=>t7,split:()=>s7,spritesheetUV:()=>n7,sqrt:()=>nf,stack:()=>a7,step:()=>i7,stepElement:()=>r7,storage:()=>Rs,storageBarrier:()=>o7,storageElement:()=>c7,storageTexture:()=>l7,storageTexture3D:()=>h7,struct:()=>u7,sub:()=>d7,subBuild:()=>f7,subgroupAdd:()=>p7,subgroupAll:()=>m7,subgroupAnd:()=>b7,subgroupAny:()=>g7,subgroupBallot:()=>y7,subgroupBroadcast:()=>x7,subgroupBroadcastFirst:()=>w7,subgroupElect:()=>T7,subgroupExclusiveAdd:()=>v7,subgroupExclusiveMul:()=>_7,subgroupInclusiveAdd:()=>A7,subgroupInclusiveMul:()=>M7,subgroupIndex:()=>S7,subgroupMax:()=>N7,subgroupMin:()=>R7,subgroupMul:()=>E7,subgroupOr:()=>C7,subgroupShuffle:()=>k7,subgroupShuffleDown:()=>I7,subgroupShuffleUp:()=>B7,subgroupShuffleXor:()=>F7,subgroupSize:()=>P7,subgroupXor:()=>D7,tan:()=>O7,tangentGeometry:()=>U7,tangentLocal:()=>L7,tangentView:()=>z7,tangentViewFrame:()=>V7,tangentWorld:()=>j7,tanh:()=>G7,texture:()=>Cb,texture3D:()=>H7,texture3DLevel:()=>W7,texture3DLoad:()=>q7,textureBarrier:()=>X7,textureBicubic:()=>K7,textureBicubicLevel:()=>J7,textureLevel:()=>$7,textureLoad:()=>Y7,textureSize:()=>Z7,textureStore:()=>Q7,thickness:()=>eZ,time:()=>tZ,toneMapping:()=>sZ,toneMappingExposure:()=>nZ,toonOutlinePass:()=>aZ,transformDirection:()=>iZ,transformNormal:()=>rZ,transformNormalByInverseViewMatrix:()=>oZ,transformNormalByViewMatrix:()=>cZ,transformNormalToView:()=>pR,transformedClearcoatNormalView:()=>lZ,transformedNormalView:()=>hZ,transformedNormalWorld:()=>uZ,transmission:()=>dZ,transpose:()=>fZ,triNoise3D:()=>pZ,triplanarTexture:()=>mZ,triplanarTextures:()=>bZ,trunc:()=>gZ,uint:()=>de,uintBitsToFloat:()=>yZ,uniform:()=>kt,uniformArray:()=>xZ,uniformCubeTexture:()=>wZ,uniformFlow:()=>TZ,uniformGroup:()=>vZ,uniformTexture:()=>_Z,unpack4xI8:()=>AZ,unpack4xU8:()=>MZ,unpackHalf2x16:()=>SZ,unpackNormal:()=>NZ,unpackRGBToNormal:()=>RZ,unpackSnorm2x16:()=>EZ,unpackSnorm4x8:()=>CZ,unpackUnorm2x16:()=>mR,unpackUnorm4x8:()=>kZ,unpremultiplyAlpha:()=>IZ,userData:()=>BZ,uv:()=>FZ,uvec2:()=>PZ,uvec3:()=>DZ,uvec4:()=>af,varying:()=>OZ,varyingProperty:()=>Wa,vec2:()=>bR,vec3:()=>wc,vec4:()=>Lt,vectorComponents:()=>UZ,velocity:()=>kb,vertexColor:()=>LZ,vertexIndex:()=>dv,vertexStage:()=>zZ,vibrance:()=>VZ,viewZToLogarithmicDepth:()=>jZ,viewZToOrthographicDepth:()=>GZ,viewZToPerspectiveDepth:()=>HZ,viewZToReversedOrthographicDepth:()=>WZ,viewZToReversedPerspectiveDepth:()=>qZ,viewport:()=>XZ,viewportCoordinate:()=>KZ,viewportDepthTexture:()=>JZ,viewportLinearDepth:()=>$Z,viewportMipTexture:()=>YZ,viewportOpaqueMipTexture:()=>ZZ,viewportSafeUV:()=>QZ,viewportSharedTexture:()=>eQ,viewportSize:()=>tQ,viewportTexture:()=>sQ,viewportUV:()=>nQ,vogelDiskSample:()=>aQ,wgsl:()=>iQ,wgslFn:()=>rQ,workgroupArray:()=>gR,workgroupBarrier:()=>yR,workgroupId:()=>Tc,workingToColorSpace:()=>oQ,xor:()=>cQ});var Ri={};CE(Ri,{ACESFilmicToneMapping:()=>dx,AONode:()=>iw,AddEquation:()=>sa,AddOperation:()=>L_,AdditiveAnimationBlendMode:()=>mx,AdditiveBlending:()=>ko,AgXToneMapping:()=>fx,AlphaFormat:()=>Su,AlwaysCompare:()=>vx,AlwaysDepth:()=>Fh,AlwaysStencilFunc:()=>yx,AmbientLight:()=>sl,AmbientLightNode:()=>ab,AnalyticLightNode:()=>ur,AnimationAction:()=>Pp,AnimationClip:()=>Vi,AnimationLoader:()=>dy,AnimationMixer:()=>vy,AnimationObjectGroup:()=>Ty,AnimationUtils:()=>uy,ArcCurve:()=>sp,ArrayCamera:()=>kp,ArrayElementNode:()=>no,ArrayNode:()=>Pm,ArrowHelper:()=>jy,AssignNode:()=>R0,AtomicFunctionNode:()=>ga,AttachedBindMode:()=>Hg,AttributeNode:()=>Lm,Audio:()=>Bp,AudioAnalyser:()=>wy,AudioContext:()=>pu,AudioListener:()=>yy,AudioLoader:()=>by,AxesHelper:()=>Gy,BackSide:()=>Xt,Backend:()=>pb,BarrierNode:()=>Gw,BasicDepthPacking:()=>W_,BasicEnvironmentNode:()=>Pd,BasicLightMapNode:()=>dw,BasicNodeLibrary:()=>o1,BasicShadowMap:()=>O_,BatchedMesh:()=>Jf,BezierInterpolant:()=>Mp,BitcastNode:()=>lc,BitcountNode:()=>io,BlendMode:()=>Km,Bone:()=>_o,BooleanKeyframeTrack:()=>Oi,Box2:()=>Op,Box3:()=>ss,Box3Helper:()=>zy,BoxGeometry:()=>kr,BoxHelper:()=>Ly,BufferAttribute:()=>Xe,BufferAttributeNode:()=>xi,BufferGeometry:()=>ke,BufferGeometryLoader:()=>Rp,BufferNode:()=>Cd,BuiltinNode:()=>W0,BumpMapNode:()=>Y0,BundleGroup:()=>QS,BypassNode:()=>U0,ByteType:()=>Ur,Cache:()=>ni,Camera:()=>tl,CameraHelper:()=>Uy,CanvasTarget:()=>iT,CanvasTexture:()=>oy,CapsuleGeometry:()=>Zf,CatmullRomCurve3:()=>np,CineonToneMapping:()=>ux,CircleGeometry:()=>Qf,ClampToEdgeWrapping:()=>hs,ClippingGroup:()=>c1,ClippingNode:()=>Si,Clock:()=>Ry,CodeNode:()=>mt,Color:()=>be,ColorKeyframeTrack:()=>cu,ColorManagement:()=>qe,ColorSpaceNode:()=>Ed,Compatibility:()=>Hr,CompressedArrayTexture:()=>iy,CompressedCubeTexture:()=>ry,CompressedTexture:()=>Xc,CompressedTextureLoader:()=>fy,ComputeBuiltinNode:()=>jw,ComputeNode:()=>D0,ConditionalNode:()=>C0,ConeGeometry:()=>$h,ConstNode:()=>fa,ConstantAlphaFactor:()=>ox,ConstantColorFactor:()=>ix,ContextNode:()=>Rd,Controls:()=>bu,ConvertNode:()=>Em,CubeCamera:()=>Cp,CubeDepthTexture:()=>Yf,CubeMapNode:()=>uw,CubeReflectionMapping:()=>Wi,CubeRefractionMapping:()=>ol,CubeRenderTarget:()=>jm,CubeTexture:()=>Pi,CubeTextureLoader:()=>py,CubeTextureNode:()=>K0,CubeUVReflectionMapping:()=>cl,CubicBezierCurve:()=>Yh,CubicBezierCurve3:()=>ap,CubicInterpolant:()=>_p,CullFaceBack:()=>P_,CullFaceFront:()=>D_,CullFaceFrontBack:()=>lC,CullFaceNone:()=>F_,Curve:()=>On,CurvePath:()=>rp,CustomBlending:()=>Or,CustomToneMapping:()=>hC,CylinderGeometry:()=>Kc,Cylindrical:()=>Ey,Data3DTexture:()=>Hh,DataArrayTexture:()=>Gh,DataTexture:()=>Is,DataTextureLoader:()=>my,DataUtils:()=>$g,DebugNode:()=>z0,DecrementStencilOp:()=>$_,DecrementWrapStencilOp:()=>Z_,DefaultLoadingManager:()=>uA,DepthFormat:()=>vn,DepthStencilFormat:()=>na,DepthTexture:()=>Ds,DetachedBindMode:()=>z_,DirectRenderPipeline:()=>e1,DirectionalLight:()=>Fr,DirectionalLightHelper:()=>Oy,DirectionalLightNode:()=>ib,DiscreteInterpolant:()=>Ap,DodecahedronGeometry:()=>ep,DoubleSide:()=>rn,DstAlphaFactor:()=>ex,DstColorFactor:()=>sx,DynamicCopyUsage:()=>vC,DynamicDrawUsage:()=>Gr,DynamicReadUsage:()=>xC,EdgesGeometry:()=>tp,EllipseCurve:()=>Jc,EnvironmentNode:()=>gw,EqualCompare:()=>wx,EqualDepth:()=>Dh,EqualStencilFunc:()=>sA,EquirectangularReflectionMapping:()=>vu,EquirectangularRefractionMapping:()=>_u,Euler:()=>Na,EventDispatcher:()=>Bs,EventNode:()=>Zt,ExpressionNode:()=>Dl,ExternalTexture:()=>ly,ExtrudeGeometry:()=>hp,FileLoader:()=>an,FlipNode:()=>x0,Float16BufferAttribute:()=>Kh,Float32BufferAttribute:()=>ge,FloatType:()=>Mt,Fog:()=>qf,FogExp2:()=>Wf,FramebufferTexture:()=>qc,FrontFacingNode:()=>q0,FrontSide:()=>ea,Frustum:()=>ci,FrustumArray:()=>Jh,FunctionCallNode:()=>E0,FunctionNode:()=>$m,FunctionOverloadingNode:()=>Sw,GLBufferAttribute:()=>Sy,GLSL1:()=>AC,GLSL3:()=>MC,GLSLNodeBuilder:()=>pT,GLSLNodeParser:()=>sT,GreaterCompare:()=>td,GreaterDepth:()=>Uh,GreaterEqualCompare:()=>Oo,GreaterEqualDepth:()=>Oh,GreaterEqualStencilFunc:()=>rA,GreaterStencilFunc:()=>aA,GridHelper:()=>Py,Group:()=>qs,HTMLTexture:()=>cy,HalfFloatType:()=>ds,HemisphereLight:()=>Qc,HemisphereLightHelper:()=>Fy,HemisphereLightNode:()=>rb,IESSpotLight:()=>gb,IESSpotLightNode:()=>ob,IcosahedronGeometry:()=>up,ImageBitmapLoader:()=>fu,ImageLoader:()=>Co,ImageUtils:()=>Gf,IncrementStencilOp:()=>J_,IncrementWrapStencilOp:()=>Y_,IndexNode:()=>rs,IndirectStorageBufferAttribute:()=>Jd,InputNode:()=>Md,InspectorBase:()=>Um,InspectorNode:()=>V0,InstancedBufferAttribute:()=>ys,InstancedBufferGeometry:()=>Np,InstancedInterleavedBuffer:()=>Dp,InstancedMesh:()=>Er,Int16BufferAttribute:()=>ey,Int32BufferAttribute:()=>ty,Int8BufferAttribute:()=>Yg,IntType:()=>Ts,InterleavedBuffer:()=>ri,InterleavedBufferAttribute:()=>Ra,Interpolant:()=>li,InterpolateBezier:()=>Wg,InterpolateDiscrete:()=>wo,InterpolateLinear:()=>To,InterpolateSmooth:()=>Of,InterpolationSamplingMode:()=>NC,InterpolationSamplingType:()=>SC,InvertStencilOp:()=>Q_,IrradianceNode:()=>Vm,IsolateNode:()=>O0,JoinNode:()=>g0,KeepStencilOp:()=>kh,KeyframeTrack:()=>Mn,LOD:()=>Kf,LatheGeometry:()=>dp,Layers:()=>Wh,LessCompare:()=>$p,LessDepth:()=>Ph,LessEqualCompare:()=>ml,LessEqualDepth:()=>Lc,LessEqualStencilFunc:()=>nA,LessStencilFunc:()=>tA,Light:()=>hi,LightProbe:()=>al,LightProbeNode:()=>cb,LightShadow:()=>el,Lighting:()=>aT,LightingContextNode:()=>rw,LightingModel:()=>oc,LightingNode:()=>ao,LightsNode:()=>Gd,Line:()=>Qn,Line2NodeMaterial:()=>dM,Line3:()=>Cy,LineBasicMaterial:()=>ns,LineBasicNodeMaterial:()=>lw,LineCurve:()=>Zh,LineCurve3:()=>ip,LineDashedMaterial:()=>Zc,LineDashedNodeMaterial:()=>hw,LineLoop:()=>Hc,LineSegments:()=>_n,LinearFilter:()=>Ye,LinearInterpolant:()=>ou,LinearMipMapLinearFilter:()=>V_,LinearMipMapNearestFilter:()=>fC,LinearMipmapLinearFilter:()=>on,LinearMipmapNearestFilter:()=>Fo,LinearSRGBColorSpace:()=>nn,LinearToneMapping:()=>lx,LinearTransfer:()=>Vh,Loader:()=>us,LoaderUtils:()=>Ea,LoadingManager:()=>lu,LoopNode:()=>aw,LoopOnce:()=>j_,LoopPingPong:()=>H_,LoopRepeat:()=>G_,MOUSE:()=>Pr,MRTNode:()=>Mw,Material:()=>Rt,MaterialBlending:()=>Lp,MaterialLoader:()=>du,MaterialNode:()=>$,MaterialReferenceNode:()=>J0,MathNode:()=>L,MathUtils:()=>Lo,Matrix2:()=>mu,Matrix3:()=>Fs,Matrix4:()=>le,MaxEquation:()=>$y,MaxMipLevelNode:()=>G0,MemberNode:()=>w0,Mesh:()=>at,MeshBasicMaterial:()=>Bt,MeshBasicNodeMaterial:()=>cc,MeshDepthMaterial:()=>Tp,MeshDistanceMaterial:()=>vp,MeshLambertMaterial:()=>Di,MeshLambertNodeMaterial:()=>Dd,MeshMatcapMaterial:()=>Eo,MeshMatcapNodeMaterial:()=>Vd,MeshNormalMaterial:()=>Ro,MeshNormalNodeMaterial:()=>Fd,MeshPhongMaterial:()=>So,MeshPhongNodeMaterial:()=>Od,MeshPhysicalMaterial:()=>xs,MeshPhysicalNodeMaterial:()=>ql,MeshSSSNodeMaterial:()=>wM,MeshStandardMaterial:()=>An,MeshStandardNodeMaterial:()=>Wl,MeshToonMaterial:()=>No,MeshToonNodeMaterial:()=>zd,MinEquation:()=>Jy,MirroredRepeatWrapping:()=>ai,MixOperation:()=>U_,ModelNode:()=>kn,MultiplyBlending:()=>Bo,MultiplyOperation:()=>wu,NearestFilter:()=>pt,NearestMipMapLinearFilter:()=>dC,NearestMipMapNearestFilter:()=>uC,NearestMipmapLinearFilter:()=>fi,NearestMipmapNearestFilter:()=>ll,NeutralToneMapping:()=>px,NeverCompare:()=>xx,NeverDepth:()=>Bh,NeverStencilFunc:()=>eA,NoBlending:()=>Ca,NoColorSpace:()=>qi,NoNormalPacking:()=>Jp,NoToneMapping:()=>Hi,Node:()=>we,NodeAccess:()=>As,NodeAttribute:()=>eb,NodeBuilder:()=>sb,NodeCache:()=>Ad,NodeCode:()=>eT,NodeError:()=>zm,NodeFrame:()=>nb,NodeFunctionInput:()=>Wd,NodeLoader:()=>RT,NodeMaterial:()=>wt,NodeMaterialLoader:()=>ET,NodeMaterialObserver:()=>b0,NodeObjectLoader:()=>r1,NodeShaderStage:()=>Ml,NodeType:()=>bI,NodeUniform:()=>Zw,NodeUpdateType:()=>Me,NodeUtils:()=>cO,NodeVar:()=>tb,NodeVarying:()=>Qw,NormalAnimationBlendMode:()=>Xp,NormalBlending:()=>ta,NormalGAPacking:()=>q_,NormalMapNode:()=>$0,NormalRGPacking:()=>gx,NotEqualCompare:()=>Tx,NotEqualDepth:()=>Lh,NotEqualStencilFunc:()=>iA,NumberKeyframeTrack:()=>Ui,Object3D:()=>Ze,Object3DNode:()=>Yt,ObjectLoader:()=>Ep,ObjectSpaceNormalMap:()=>Kp,OctahedronGeometry:()=>nu,OneFactor:()=>Yy,OneMinusConstantAlphaFactor:()=>cx,OneMinusConstantColorFactor:()=>rx,OneMinusDstAlphaFactor:()=>tx,OneMinusDstColorFactor:()=>nx,OneMinusSrcAlphaFactor:()=>xu,OneMinusSrcColorFactor:()=>Qy,OperatorNode:()=>Ut,OrthographicCamera:()=>ji,OutputStructNode:()=>Xm,OverrideContextNode:()=>Wm,PCFShadowMap:()=>gu,PCFSoftShadowMap:()=>qy,PMREMGenerator:()=>mw,PMREMNode:()=>bw,PackFloatNode:()=>hc,Packed4x8IntegerNode:()=>Ns,ParameterNode:()=>qm,PassNode:()=>ro,Path:()=>Ao,PerspectiveCamera:()=>qt,PhongLightingModel:()=>Gm,PhysicalLightingModel:()=>Ud,Plane:()=>wn,PlaneGeometry:()=>au,PlaneHelper:()=>Vy,PointLight:()=>di,PointLightHelper:()=>By,PointLightNode:()=>Zm,PointShadowNode:()=>Xw,PointUVNode:()=>Iw,Points:()=>Wc,PointsMaterial:()=>Cr,PointsNodeMaterial:()=>xw,PolarGridHelper:()=>Dy,PolyhedronGeometry:()=>Ir,PositionalAudio:()=>xy,PostProcessing:()=>t1,ProjectorLight:()=>yb,ProjectorLightNode:()=>lb,PropertyBinding:()=>dt,PropertyMixer:()=>Fp,PropertyNode:()=>st,QuadMesh:()=>Xl,QuadraticBezierCurve:()=>Qh,QuadraticBezierCurve3:()=>eu,Quaternion:()=>It,QuaternionKeyframeTrack:()=>Li,QuaternionLinearInterpolant:()=>Sp,R11_EAC_Format:()=>ku,RED_GREEN_RGTC2_Format:()=>jr,RED_RGTC1_Format:()=>Yu,REVISION:()=>Up,RG11_EAC_Format:()=>Vr,RGBADepthPacking:()=>pC,RGBAFormat:()=>gs,RGBAIntegerFormat:()=>Nu,RGBA_ASTC_10x10_Format:()=>Wu,RGBA_ASTC_10x5_Format:()=>ju,RGBA_ASTC_10x6_Format:()=>Gu,RGBA_ASTC_10x8_Format:()=>Hu,RGBA_ASTC_12x10_Format:()=>qu,RGBA_ASTC_12x12_Format:()=>Xu,RGBA_ASTC_4x4_Format:()=>Fu,RGBA_ASTC_5x4_Format:()=>Pu,RGBA_ASTC_5x5_Format:()=>Du,RGBA_ASTC_6x5_Format:()=>Ou,RGBA_ASTC_6x6_Format:()=>Uu,RGBA_ASTC_8x5_Format:()=>Lu,RGBA_ASTC_8x6_Format:()=>zu,RGBA_ASTC_8x8_Format:()=>Vu,RGBA_BPTC_Format:()=>Ku,RGBA_ETC2_EAC_Format:()=>Cu,RGBA_PVRTC_2BPPV1_Format:()=>qp,RGBA_PVRTC_4BPPV1_Format:()=>Wp,RGBA_S3TC_DXT1_Format:()=>ul,RGBA_S3TC_DXT3_Format:()=>dl,RGBA_S3TC_DXT5_Format:()=>fl,RGBDepthPacking:()=>mC,RGBFormat:()=>Po,RGBIntegerFormat:()=>jp,RGB_BPTC_SIGNED_Format:()=>Ju,RGB_BPTC_UNSIGNED_Format:()=>$u,RGB_ETC1_Format:()=>Ru,RGB_ETC2_Format:()=>Eu,RGB_PVRTC_2BPPV1_Format:()=>Hp,RGB_PVRTC_4BPPV1_Format:()=>Gp,RGB_S3TC_DXT1_Format:()=>hl,RGDepthPacking:()=>bC,RGFormat:()=>cn,RGIntegerFormat:()=>Do,RTTNode:()=>Ew,RangeNode:()=>Vw,RawShaderMaterial:()=>wp,Ray:()=>oi,Raycaster:()=>Ny,ReadbackBuffer:()=>s1,RectAreaLight:()=>nl,RectAreaLightNode:()=>hb,RedFormat:()=>Lr,RedIntegerFormat:()=>zr,ReferenceBaseNode:()=>Om,ReferenceElementNode:()=>Dm,ReferenceNode:()=>jl,ReflectorNode:()=>Rw,ReinhardToneMapping:()=>hx,RenderObjectRefreshType:()=>bi,RenderOutputNode:()=>L0,RenderPipeline:()=>xb,RenderTarget:()=>Ps,RenderTarget3D:()=>_y,Renderer:()=>rT,RendererReferenceNode:()=>B0,RendererUtils:()=>uV,RepeatWrapping:()=>Zn,ReplaceStencilOp:()=>K_,ReverseSubtractEquation:()=>Ky,RingGeometry:()=>fp,RotateNode:()=>yw,SIGNED_R11_EAC_Format:()=>Iu,SIGNED_RED_GREEN_RGTC2_Format:()=>Qu,SIGNED_RED_RGTC1_Format:()=>Zu,SIGNED_RG11_EAC_Format:()=>Bu,SRGBColorSpace:()=>Wt,SRGBTransfer:()=>Ie,SampleNode:()=>Cw,Scene:()=>ii,ScreenNode:()=>Cn,SetNode:()=>y0,ShaderMaterial:()=>ru,ShadowBaseNode:()=>qw,ShadowMaterial:()=>iu,ShadowNode:()=>Ym,ShadowNodeMaterial:()=>ww,Shape:()=>Mo,ShapeGeometry:()=>pp,ShapePath:()=>Hy,ShapeUtils:()=>Sa,ShortType:()=>pi,Skeleton:()=>Gc,SkeletonHelper:()=>Iy,SkinnedMesh:()=>jc,Source:()=>Xg,Sphere:()=>jt,SphereGeometry:()=>Yc,Spherical:()=>il,SphericalHarmonics3:()=>uu,SplineCurve:()=>tu,SplitNode:()=>Cm,SpotLight:()=>ui,SpotLightHelper:()=>ky,SpotLightNode:()=>Kl,Sprite:()=>Xf,SpriteMaterial:()=>Vc,SpriteNodeMaterial:()=>Hm,SrcAlphaFactor:()=>yu,SrcAlphaSaturateFactor:()=>ax,SrcColorFactor:()=>Zy,StackNode:()=>vw,StackTrace:()=>is,StandardNodeLibrary:()=>NT,StaticCopyUsage:()=>TC,StaticDrawUsage:()=>Uo,StaticReadUsage:()=>yC,StereoCamera:()=>gy,Storage3DTexture:()=>a1,StorageArrayElementNode:()=>Q0,StorageArrayTexture:()=>i1,StorageBufferAttribute:()=>mn,StorageBufferNode:()=>ew,StorageInstancedBufferAttribute:()=>kw,StorageTexture:()=>n1,StorageTexture3DNode:()=>Bw,StorageTextureNode:()=>Jm,StreamCopyUsage:()=>_C,StreamDrawUsage:()=>gC,StreamReadUsage:()=>wC,StringKeyframeTrack:()=>zi,StructNode:()=>Aw,StructTypeNode:()=>_w,SubBuildNode:()=>k0,SubgroupFunctionNode:()=>Re,SubtractEquation:()=>Xy,SubtractiveBlending:()=>Io,TOUCH:()=>Dr,TSL:()=>w,TangentSpaceNormalMap:()=>aa,TempNode:()=>xt,TetrahedronGeometry:()=>mp,Texture:()=>gt,Texture3DNode:()=>Fw,TextureLoader:()=>hu,TextureNode:()=>ba,TextureSizeNode:()=>j0,TextureSource:()=>Ma,TextureUtils:()=>Wy,Timer:()=>Ip,TimestampQuery:()=>Ia,ToneMappingNode:()=>F0,ToonOutlinePassNode:()=>zw,TorusGeometry:()=>bp,TorusKnotGeometry:()=>gp,Triangle:()=>si,TriangleFanDrawMode:()=>pl,TriangleStripDrawMode:()=>ed,TrianglesDrawMode:()=>bx,TubeGeometry:()=>yp,UVMapping:()=>Tu,Uint16BufferAttribute:()=>qh,Uint32BufferAttribute:()=>Xh,Uint8BufferAttribute:()=>Zg,Uint8ClampedBufferAttribute:()=>Qg,Uniform:()=>Ay,UniformArrayNode:()=>H0,UniformGroupNode:()=>Fm,UniformNode:()=>ac,UniformsGroup:()=>My,UnpackFloatNode:()=>uc,UnsignedByteType:()=>ws,UnsignedInt101111Type:()=>Mu,UnsignedInt248Type:()=>mi,UnsignedInt5999Type:()=>Au,UnsignedIntType:()=>St,UnsignedShort4444Type:()=>zp,UnsignedShort5551Type:()=>Vp,UnsignedShortType:()=>ka,UserDataNode:()=>Pw,VSMShadowMap:()=>rl,VarNode:()=>Fl,VaryingNode:()=>I0,Vector2:()=>q,Vector3:()=>E,Vector4:()=>Ge,VectorKeyframeTrack:()=>Br,VelocityNode:()=>Dw,VertexColorNode:()=>cw,VideoFrameTexture:()=>ay,VideoTexture:()=>$f,ViewportDepthNode:()=>Ga,ViewportDepthTextureNode:()=>ow,ViewportSharedTextureNode:()=>Ow,ViewportTextureNode:()=>Gl,VolumeNodeMaterial:()=>AM,WGSLNodeBuilder:()=>AT,WebGL3DRenderTarget:()=>Jg,WebGLArrayRenderTarget:()=>Kg,WebGLBackend:()=>mb,WebGLCapabilities:()=>mT,WebGLCoordinateSystem:()=>sn,WebGLRenderTarget:()=>jh,WebGPUBackend:()=>ST,WebGPUCoordinateSystem:()=>Xs,WebGPURenderer:()=>ZS,WebXRController:()=>Hf,WireframeGeometry:()=>xp,WorkgroupInfoNode:()=>Hw,WrapAroundEnding:()=>zh,ZeroCurvatureEnding:()=>yo,ZeroFactor:()=>Gi,ZeroSlopeEnding:()=>xo,ZeroStencilOp:()=>X_,createCanvasElement:()=>oA,defaultBuildStages:()=>xm,defaultShaderStages:()=>f1,error:()=>W,getConsoleFunction:()=>EC,log:()=>jf,setConsoleFunction:()=>RC,shaderStages:()=>wm,vectorComponents:()=>pc,warn:()=>K,warnOnce:()=>je});var Up="186",Pr={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Dr={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},F_=0,P_=1,D_=2,lC=3,O_=0,gu=1,qy=2,rl=3,ea=0,Xt=1,rn=2,Ca=0,ta=1,ko=2,Io=3,Bo=4,Or=5,Lp=6,sa=100,Xy=101,Ky=102,Jy=103,$y=104,Gi=200,Yy=201,Zy=202,Qy=203,yu=204,xu=205,ex=206,tx=207,sx=208,nx=209,ax=210,ix=211,rx=212,ox=213,cx=214,Bh=0,Fh=1,Ph=2,Lc=3,Dh=4,Oh=5,Uh=6,Lh=7,wu=0,U_=1,L_=2,Hi=0,lx=1,hx=2,ux=3,dx=4,hC=5,fx=6,px=7,Hg="attached",z_="detached",Tu=300,Wi=301,ol=302,vu=303,_u=304,cl=306,Zn=1e3,hs=1001,ai=1002,pt=1003,ll=1004,uC=1004,fi=1005,dC=1005,Ye=1006,Fo=1007,fC=1007,on=1008,V_=1008,ws=1009,Ur=1010,pi=1011,ka=1012,Ts=1013,St=1014,Mt=1015,ds=1016,zp=1017,Vp=1018,mi=1020,Au=35902,Mu=35899,Su=1021,Po=1022,gs=1023,vn=1026,na=1027,Lr=1028,zr=1029,cn=1030,Do=1031,jp=1032,Nu=1033,hl=33776,ul=33777,dl=33778,fl=33779,Gp=35840,Hp=35841,Wp=35842,qp=35843,Ru=36196,Eu=37492,Cu=37496,ku=37488,Iu=37489,Vr=37490,Bu=37491,Fu=37808,Pu=37809,Du=37810,Ou=37811,Uu=37812,Lu=37813,zu=37814,Vu=37815,ju=37816,Gu=37817,Hu=37818,Wu=37819,qu=37820,Xu=37821,Ku=36492,Ju=36494,$u=36495,Yu=36283,Zu=36284,jr=36285,Qu=36286,j_=2200,G_=2201,H_=2202,wo=2300,To=2301,Of=2302,Wg=2303,yo=2400,xo=2401,zh=2402,Xp=2500,mx=2501,bx=0,ed=1,pl=2,W_=3200,pC=3201,mC=3202,bC=3203,aa=0,Kp=1,qi="",Wt="srgb",nn="srgb-linear",Vh="linear",Ie="srgb",Jp="",gx="rg",q_="ga",X_=0,kh=7680,K_=7681,J_=7682,$_=7683,Y_=34055,Z_=34056,Q_=5386,eA=512,tA=513,sA=514,nA=515,aA=516,iA=517,rA=518,yx=519,xx=512,$p=513,wx=514,ml=515,td=516,Tx=517,Oo=518,vx=519,Uo=35044,Gr=35048,gC=35040,yC=35045,xC=35049,wC=35041,TC=35046,vC=35050,_C=35042,AC="100",MC="300 es",sn=2e3,Xs=2001,Ia={COMPUTE:"compute",RENDER:"render"},SC={PERSPECTIVE:"perspective",LINEAR:"linear",FLAT:"flat"},NC={NORMAL:"normal",CENTROID:"centroid",SAMPLE:"sample",FIRST:"first",EITHER:"either"},Hr={TEXTURE_COMPARE:"depthTextureCompare"},bi={NONE:0,SHARED:1,FULL:2};function o3(r){for(let e=r.length-1;e>=0;--e)if(r[e]>=65535)return!0;return!1}var c3={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Ch(r,e){return new c3[r](e)}function bl(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}function qg(r){return document.createElementNS("http://www.w3.org/1999/xhtml",r)}function oA(){let r=qg("canvas");return r.style.display="block",r}var ZE={},vo=null;function RC(r){vo=r}function EC(){return vo}function jf(...r){let e="THREE."+r.shift();vo?vo("log",e,...r):console.log(e,...r)}function CC(r){let e=r[0];if(typeof e=="string"&&e.startsWith("TSL:")){let t=r[1];t&&t.isStackTrace?r[0]+=" "+t.getLocation():r[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return r}function K(...r){r=CC(r);let e="THREE."+r.shift();if(vo)vo("warn",e,...r);else{let t=r[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...r)}}function W(...r){r=CC(r);let e="THREE."+r.shift();if(vo)vo("error",e,...r);else{let t=r[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...r)}}function je(...r){let e=r.join(" ");e in ZE||(ZE[e]=!0,K(...r))}function _x(){return typeof self<"u"&&typeof self.scheduler<"u"&&typeof self.scheduler.yield<"u"?self.scheduler.yield():new Promise(r=>{requestAnimationFrame(r)})}var cA={[Bh]:Fh,[Ph]:Uh,[Dh]:Lh,[Lc]:Oh,[Fh]:Bh,[Uh]:Ph,[Lh]:Dh,[Oh]:Lc},Bs=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let s=this._listeners;s[e]===void 0&&(s[e]=[]),s[e].indexOf(t)===-1&&s[e].push(t)}hasEventListener(e,t){let s=this._listeners;return s===void 0?!1:s[e]!==void 0&&s[e].indexOf(t)!==-1}removeEventListener(e,t){let s=this._listeners;if(s===void 0)return;let n=s[e];if(n!==void 0){let a=n.indexOf(t);a!==-1&&n.splice(a,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let s=t[e.type];if(s!==void 0){e.target=this;let n=s.slice(0);for(let a=0,i=n.length;a<i;a++)n[a].call(this,e);e.target=null}}},Qs=["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"],QE=1234567,Uc=Math.PI/180,zc=180/Math.PI;function Yn(){let r=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,s=Math.random()*4294967295|0;return(Qs[r&255]+Qs[r>>8&255]+Qs[r>>16&255]+Qs[r>>24&255]+"-"+Qs[e&255]+Qs[e>>8&255]+"-"+Qs[e>>16&15|64]+Qs[e>>24&255]+"-"+Qs[t&63|128]+Qs[t>>8&255]+"-"+Qs[t>>16&255]+Qs[t>>24&255]+Qs[s&255]+Qs[s>>8&255]+Qs[s>>16&255]+Qs[s>>24&255]).toLowerCase()}function Be(r,e,t){return Math.max(e,Math.min(t,r))}function lA(r,e){return(r%e+e)%e}function l3(r,e,t,s,n){return s+(r-e)*(n-s)/(t-e)}function h3(r,e,t){return r!==e?(t-r)/(e-r):0}function Uf(r,e,t){return(1-t)*r+t*e}function u3(r,e,t,s){return Uf(r,e,1-Math.exp(-t*s))}function d3(r,e=1){return e-Math.abs(lA(r,e*2)-e)}function f3(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*(3-2*r))}function p3(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*r*(r*(r*6-15)+10))}function m3(r,e){return r+Math.floor(Math.random()*(e-r+1))}function b3(r,e){return r+Math.random()*(e-r)}function g3(r){return r*(.5-Math.random())}function y3(r){r!==void 0&&(QE=r);let e=QE+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function x3(r){return r*Uc}function w3(r){return r*zc}function T3(r){return r>0&&Number.isInteger(r)&&2**Math.round(Math.log2(r))===r}function v3(r){return Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))}function _3(r){return Math.pow(2,Math.floor(Math.log(r)/Math.LN2))}function A3(r,e,t,s,n){let a=Math.cos,i=Math.sin,o=a(t/2),c=i(t/2),l=a((e+s)/2),h=i((e+s)/2),u=a((e-s)/2),d=i((e-s)/2),f=a((s-e)/2),p=i((s-e)/2);switch(n){case"XYX":r.set(o*h,c*u,c*d,o*l);break;case"YZY":r.set(c*d,o*h,c*u,o*l);break;case"ZXZ":r.set(c*u,c*d,o*h,o*l);break;case"XZX":r.set(o*h,c*p,c*f,o*l);break;case"YXY":r.set(c*f,o*h,c*p,o*l);break;case"ZYZ":r.set(c*p,c*f,o*h,o*l);break;default:K("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+n)}}function Tn(r,e){switch(e.constructor){case Float32Array:return r;case Uint32Array:return r/4294967295;case Uint16Array:return r/65535;case Uint8Array:case Uint8ClampedArray:return r/255;case Int32Array:return Math.max(r/2147483647,-1);case Int16Array:return Math.max(r/32767,-1);case Int8Array:return Math.max(r/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function We(r,e){switch(e.constructor){case Float32Array:return r;case Uint32Array:return Math.round(r*4294967295);case Uint16Array:return Math.round(r*65535);case Uint8Array:case Uint8ClampedArray:return Math.round(r*255);case Int32Array:return Math.round(r*2147483647);case Int16Array:return Math.round(r*32767);case Int8Array:return Math.round(r*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}var Lo={DEG2RAD:Uc,RAD2DEG:zc,generateUUID:Yn,clamp:Be,euclideanModulo:lA,mapLinear:l3,inverseLerp:h3,lerp:Uf,damp:u3,pingpong:d3,smoothstep:f3,smootherstep:p3,randInt:m3,randFloat:b3,randFloatSpread:g3,seededRandom:y3,degToRad:x3,radToDeg:w3,isPowerOfTwo:T3,ceilPowerOfTwo:v3,floorPowerOfTwo:_3,setQuaternionFromProperEuler:A3,normalize:We,denormalize:Tn},q=class r{static{r.prototype.isVector2=!0}constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,s=this.y,n=e.elements;return this.x=n[0]*t+n[3]*s+n[6],this.y=n[1]*t+n[4]*s+n[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Be(this.x,e.x,t.x),this.y=Be(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Be(this.x,e,t),this.y=Be(this.y,e,t),this}clampLength(e,t){let s=this.length();return this.divideScalar(s||1).multiplyScalar(Be(s,e,t))}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(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.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(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let s=this.dot(e)/t;return Math.acos(Be(s,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,s=this.y-e.y;return t*t+s*s}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,s){return this.x=e.x+(t.x-e.x)*s,this.y=e.y+(t.y-e.y)*s,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let s=Math.cos(t),n=Math.sin(t),a=this.x-e.x,i=this.y-e.y;return this.x=a*s-i*n+e.x,this.y=a*n+i*s+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},It=class{constructor(e=0,t=0,s=0,n=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=s,this._w=n}static slerpFlat(e,t,s,n,a,i,o){let c=s[n+0],l=s[n+1],h=s[n+2],u=s[n+3],d=a[i+0],f=a[i+1],p=a[i+2],m=a[i+3];if(u!==m||c!==d||l!==f||h!==p){let b=c*d+l*f+h*p+u*m;b<0&&(d=-d,f=-f,p=-p,m=-m,b=-b);let g=1-o;if(b<.9995){let x=Math.acos(b),T=Math.sin(x);g=Math.sin(g*x)/T,o=Math.sin(o*x)/T,c=c*g+d*o,l=l*g+f*o,h=h*g+p*o,u=u*g+m*o}else{c=c*g+d*o,l=l*g+f*o,h=h*g+p*o,u=u*g+m*o;let x=1/Math.sqrt(c*c+l*l+h*h+u*u);c*=x,l*=x,h*=x,u*=x}}e[t]=c,e[t+1]=l,e[t+2]=h,e[t+3]=u}static multiplyQuaternionsFlat(e,t,s,n,a,i){let o=s[n],c=s[n+1],l=s[n+2],h=s[n+3],u=a[i],d=a[i+1],f=a[i+2],p=a[i+3];return e[t]=o*p+h*u+c*f-l*d,e[t+1]=c*p+h*d+l*u-o*f,e[t+2]=l*p+h*f+o*d-c*u,e[t+3]=h*p-o*u-c*d-l*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,s,n){return this._x=e,this._y=t,this._z=s,this._w=n,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let s=e._x,n=e._y,a=e._z,i=e._order,o=Math.cos,c=Math.sin,l=o(s/2),h=o(n/2),u=o(a/2),d=c(s/2),f=c(n/2),p=c(a/2);switch(i){case"XYZ":this._x=d*h*u+l*f*p,this._y=l*f*u-d*h*p,this._z=l*h*p+d*f*u,this._w=l*h*u-d*f*p;break;case"YXZ":this._x=d*h*u+l*f*p,this._y=l*f*u-d*h*p,this._z=l*h*p-d*f*u,this._w=l*h*u+d*f*p;break;case"ZXY":this._x=d*h*u-l*f*p,this._y=l*f*u+d*h*p,this._z=l*h*p+d*f*u,this._w=l*h*u-d*f*p;break;case"ZYX":this._x=d*h*u-l*f*p,this._y=l*f*u+d*h*p,this._z=l*h*p-d*f*u,this._w=l*h*u+d*f*p;break;case"YZX":this._x=d*h*u+l*f*p,this._y=l*f*u+d*h*p,this._z=l*h*p-d*f*u,this._w=l*h*u-d*f*p;break;case"XZY":this._x=d*h*u-l*f*p,this._y=l*f*u-d*h*p,this._z=l*h*p+d*f*u,this._w=l*h*u+d*f*p;break;default:K("Quaternion: .setFromEuler() encountered an unknown order: "+i)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let s=t/2,n=Math.sin(s);return this._x=e.x*n,this._y=e.y*n,this._z=e.z*n,this._w=Math.cos(s),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,s=t[0],n=t[4],a=t[8],i=t[1],o=t[5],c=t[9],l=t[2],h=t[6],u=t[10],d=s+o+u;if(d>0){let f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(h-c)*f,this._y=(a-l)*f,this._z=(i-n)*f}else if(s>o&&s>u){let f=2*Math.sqrt(1+s-o-u);this._w=(h-c)/f,this._x=.25*f,this._y=(n+i)/f,this._z=(a+l)/f}else if(o>u){let f=2*Math.sqrt(1+o-s-u);this._w=(a-l)/f,this._x=(n+i)/f,this._y=.25*f,this._z=(c+h)/f}else{let f=2*Math.sqrt(1+u-s-o);this._w=(i-n)/f,this._x=(a+l)/f,this._y=(c+h)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let s=e.dot(t)+1;return s<1e-8?(s=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=s):(this._x=0,this._y=-e.z,this._z=e.y,this._w=s)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=s),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Be(this.dot(e),-1,1)))}rotateTowards(e,t){let s=this.angleTo(e);if(s===0)return this;let n=Math.min(1,t/s);return this.slerp(e,n),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(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._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 e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let s=e._x,n=e._y,a=e._z,i=e._w,o=t._x,c=t._y,l=t._z,h=t._w;return this._x=s*h+i*o+n*l-a*c,this._y=n*h+i*c+a*o-s*l,this._z=a*h+i*l+s*c-n*o,this._w=i*h-s*o-n*c-a*l,this._onChangeCallback(),this}slerp(e,t){let s=e._x,n=e._y,a=e._z,i=e._w,o=this.dot(e);o<0&&(s=-s,n=-n,a=-a,i=-i,o=-o);let c=1-t;if(o<.9995){let l=Math.acos(o),h=Math.sin(l);c=Math.sin(c*l)/h,t=Math.sin(t*l)/h,this._x=this._x*c+s*t,this._y=this._y*c+n*t,this._z=this._z*c+a*t,this._w=this._w*c+i*t,this._onChangeCallback()}else this._x=this._x*c+s*t,this._y=this._y*c+n*t,this._z=this._z*c+a*t,this._w=this._w*c+i*t,this.normalize();return this}slerpQuaternions(e,t,s){return this.copy(e).slerp(t,s)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),s=Math.random(),n=Math.sqrt(1-s),a=Math.sqrt(s);return this.set(n*Math.sin(e),n*Math.cos(e),a*Math.sin(t),a*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},E=class r{static{r.prototype.isVector3=!0}constructor(e=0,t=0,s=0){this.x=e,this.y=t,this.z=s}set(e,t,s){return s===void 0&&(s=this.z),this.x=e,this.y=t,this.z=s,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("THREE.Vector3: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("THREE.Vector3: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(e8.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(e8.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,s=this.y,n=this.z,a=e.elements;return this.x=a[0]*t+a[3]*s+a[6]*n,this.y=a[1]*t+a[4]*s+a[7]*n,this.z=a[2]*t+a[5]*s+a[8]*n,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,s=this.y,n=this.z,a=e.elements,i=1/(a[3]*t+a[7]*s+a[11]*n+a[15]);return this.x=(a[0]*t+a[4]*s+a[8]*n+a[12])*i,this.y=(a[1]*t+a[5]*s+a[9]*n+a[13])*i,this.z=(a[2]*t+a[6]*s+a[10]*n+a[14])*i,this}applyQuaternion(e){let t=this.x,s=this.y,n=this.z,a=e.x,i=e.y,o=e.z,c=e.w,l=2*(i*n-o*s),h=2*(o*t-a*n),u=2*(a*s-i*t);return this.x=t+c*l+i*u-o*h,this.y=s+c*h+o*l-a*u,this.z=n+c*u+a*h-i*l,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,s=this.y,n=this.z,a=e.elements;return this.x=a[0]*t+a[4]*s+a[8]*n,this.y=a[1]*t+a[5]*s+a[9]*n,this.z=a[2]*t+a[6]*s+a[10]*n,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Be(this.x,e.x,t.x),this.y=Be(this.y,e.y,t.y),this.z=Be(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Be(this.x,e,t),this.y=Be(this.y,e,t),this.z=Be(this.z,e,t),this}clampLength(e,t){let s=this.length();return this.divideScalar(s||1).multiplyScalar(Be(s,e,t))}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(e){return this.x*e.x+this.y*e.y+this.z*e.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(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,s){return this.x=e.x+(t.x-e.x)*s,this.y=e.y+(t.y-e.y)*s,this.z=e.z+(t.z-e.z)*s,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let s=e.x,n=e.y,a=e.z,i=t.x,o=t.y,c=t.z;return this.x=n*c-a*o,this.y=a*i-s*c,this.z=s*o-n*i,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let s=e.dot(this)/t;return this.copy(e).multiplyScalar(s)}projectOnPlane(e){return zv.copy(this).projectOnVector(e),this.sub(zv)}reflect(e){return this.sub(zv.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let s=this.dot(e)/t;return Math.acos(Be(s,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,s=this.y-e.y,n=this.z-e.z;return t*t+s*s+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,s){let n=Math.sin(t)*e;return this.x=n*Math.sin(s),this.y=Math.cos(t)*e,this.z=n*Math.cos(s),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,s){return this.x=e*Math.sin(t),this.y=s,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),s=this.setFromMatrixColumn(e,1).length(),n=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=s,this.z=n,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,s=Math.sqrt(1-t*t);return this.x=s*Math.cos(e),this.y=t,this.z=s*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},zv=new E,e8=new It,Fs=class r{static{r.prototype.isMatrix3=!0}constructor(e,t,s,n,a,i,o,c,l){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,s,n,a,i,o,c,l)}set(e,t,s,n,a,i,o,c,l){let h=this.elements;return h[0]=e,h[1]=n,h[2]=o,h[3]=t,h[4]=a,h[5]=c,h[6]=s,h[7]=i,h[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,s=e.elements;return t[0]=s[0],t[1]=s[1],t[2]=s[2],t[3]=s[3],t[4]=s[4],t[5]=s[5],t[6]=s[6],t[7]=s[7],t[8]=s[8],this}extractBasis(e,t,s){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),s.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let s=e.elements,n=t.elements,a=this.elements,i=s[0],o=s[3],c=s[6],l=s[1],h=s[4],u=s[7],d=s[2],f=s[5],p=s[8],m=n[0],b=n[3],g=n[6],x=n[1],T=n[4],y=n[7],v=n[2],_=n[5],A=n[8];return a[0]=i*m+o*x+c*v,a[3]=i*b+o*T+c*_,a[6]=i*g+o*y+c*A,a[1]=l*m+h*x+u*v,a[4]=l*b+h*T+u*_,a[7]=l*g+h*y+u*A,a[2]=d*m+f*x+p*v,a[5]=d*b+f*T+p*_,a[8]=d*g+f*y+p*A,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],s=e[1],n=e[2],a=e[3],i=e[4],o=e[5],c=e[6],l=e[7],h=e[8];return t*i*h-t*o*l-s*a*h+s*o*c+n*a*l-n*i*c}invert(){let e=this.elements,t=e[0],s=e[1],n=e[2],a=e[3],i=e[4],o=e[5],c=e[6],l=e[7],h=e[8],u=h*i-o*l,d=o*c-h*a,f=l*a-i*c,p=t*u+s*d+n*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/p;return e[0]=u*m,e[1]=(n*l-h*s)*m,e[2]=(o*s-n*i)*m,e[3]=d*m,e[4]=(h*t-n*c)*m,e[5]=(n*a-o*t)*m,e[6]=f*m,e[7]=(s*c-l*t)*m,e[8]=(i*t-s*a)*m,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,s,n,a,i,o){let c=Math.cos(a),l=Math.sin(a);return this.set(s*c,s*l,-s*(c*i+l*o)+i+e,-n*l,n*c,-n*(-l*i+c*o)+o+t,0,0,1),this}scale(e,t){return je("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Vv.makeScale(e,t)),this}rotate(e){return je("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Vv.makeRotation(-e)),this}translate(e,t){return je("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Vv.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),s=Math.sin(e);return this.set(t,-s,0,s,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,s=e.elements;for(let n=0;n<9;n++)if(t[n]!==s[n])return!1;return!0}fromArray(e,t=0){for(let s=0;s<9;s++)this.elements[s]=e[s+t];return this}toArray(e=[],t=0){let s=this.elements;return e[t]=s[0],e[t+1]=s[1],e[t+2]=s[2],e[t+3]=s[3],e[t+4]=s[4],e[t+5]=s[5],e[t+6]=s[6],e[t+7]=s[7],e[t+8]=s[8],e}clone(){return new this.constructor().fromArray(this.elements)}},Vv=new Fs,t8=new Fs().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),s8=new Fs().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function M3(){let r={enabled:!0,workingColorSpace:nn,spaces:{},convert:function(n,a,i){return this.enabled===!1||a===i||!a||!i||(this.spaces[a].transfer===Ie&&(n.r=Rr(n.r),n.g=Rr(n.g),n.b=Rr(n.b)),this.spaces[a].primaries!==this.spaces[i].primaries&&(n.applyMatrix3(this.spaces[a].toXYZ),n.applyMatrix3(this.spaces[i].fromXYZ)),this.spaces[i].transfer===Ie&&(n.r=Ih(n.r),n.g=Ih(n.g),n.b=Ih(n.b))),n},workingToColorSpace:function(n,a){return this.convert(n,this.workingColorSpace,a)},colorSpaceToWorking:function(n,a){return this.convert(n,a,this.workingColorSpace)},getPrimaries:function(n){return this.spaces[n].primaries},getTransfer:function(n){return n===qi?Vh:this.spaces[n].transfer},getToneMappingMode:function(n){return this.spaces[n].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(n,a=this.workingColorSpace){return n.fromArray(this.spaces[a].luminanceCoefficients)},define:function(n){Object.assign(this.spaces,n)},_getMatrix:function(n,a,i){return n.copy(this.spaces[a].toXYZ).multiply(this.spaces[i].fromXYZ)},_getDrawingBufferColorSpace:function(n){return this.spaces[n].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(n=this.workingColorSpace){return this.spaces[n].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(n,a){return je("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),r.workingToColorSpace(n,a)},toWorkingColorSpace:function(n,a){return je("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),r.colorSpaceToWorking(n,a)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],s=[.3127,.329];return r.define({[nn]:{primaries:e,whitePoint:s,transfer:Vh,toXYZ:t8,fromXYZ:s8,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Wt},outputColorSpaceConfig:{drawingBufferColorSpace:Wt}},[Wt]:{primaries:e,whitePoint:s,transfer:Ie,toXYZ:t8,fromXYZ:s8,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Wt}}}),r}var qe=M3();function Rr(r){return r<.04045?r*.0773993808:Math.pow(r*.9478672986+.0521327014,2.4)}function Ih(r){return r<.0031308?r*12.92:1.055*Math.pow(r,.41666)-.055}var hh,Gf=class{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let s;if(e instanceof HTMLCanvasElement)s=e;else{hh===void 0&&(hh=qg("canvas")),hh.width=e.width,hh.height=e.height;let n=hh.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),s=hh}return s.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){let t=qg("canvas");t.width=e.width,t.height=e.height;let s=t.getContext("2d");s.drawImage(e,0,0,e.width,e.height);let n=s.getImageData(0,0,e.width,e.height),a=n.data;for(let i=0;i<a.length;i++)a[i]=Rr(a[i]/255)*255;return s.putImageData(n,0,0),t}else if(e.data){let t=e.data.slice(0);for(let s=0;s<t.length;s++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[s]=Math.floor(Rr(t[s]/255)*255):t[s]=Rr(t[s]);return{data:t,width:e.width,height:e.height}}else return K("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},S3=0,Ma=class{constructor(e=null){this.isTextureSource=!0,Object.defineProperty(this,"id",{value:S3++}),this.uuid=Yn(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;return typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame<"u"&&t instanceof VideoFrame?e.set(t.displayWidth,t.displayHeight,0):t!==null?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let s={uuid:this.uuid,url:""},n=this.data;if(n!==null){let a;if(Array.isArray(n)){a=[];for(let i=0,o=n.length;i<o;i++)n[i].isDataTexture?a.push(jv(n[i].image)):a.push(jv(n[i]))}else a=jv(n);s.url=a}return t||(e.images[this.uuid]=s),s}};function jv(r){return typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&r instanceof ImageBitmap?Gf.getDataURL(r):r.data?{data:Array.from(r.data),width:r.width,height:r.height,type:r.data.constructor.name}:(K("Texture: Unable to serialize Texture."),{})}var Xg=class extends Ma{constructor(e=null){je('Source: "Source" has been renamed to "TextureSource". Please update your code to use "THREE.TextureSource" instead.'),super(e),this.isSource=!0}},N3=0,Gv=new E,gt=class r extends Bs{constructor(e=r.DEFAULT_IMAGE,t=r.DEFAULT_MAPPING,s=hs,n=hs,a=Ye,i=on,o=gs,c=ws,l=r.DEFAULT_ANISOTROPY,h=qi){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:N3++}),this.uuid=Yn(),this.name="",this.source=new Ma(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=s,this.wrapT=n,this.magFilter=a,this.minFilter=i,this.anisotropy=l,this.format=o,this.internalFormat=null,this.type=c,this.offset=new q(0,0),this.repeat=new q(1,1),this.center=new q(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Fs,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(Gv).x}get height(){return this.source.getSize(Gv).y}get depth(){return this.source.getSize(Gv).z}get image(){return this.source.data}set image(e){this.source.data=e}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(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let s=e[t];if(s===void 0){K(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let n=this[t];if(n===void 0){K(`Texture.setValues(): property '${t}' does not exist.`);continue}n&&s&&n.isVector2&&s.isVector2||n&&s&&n.isVector3&&s.isVector3||n&&s&&n.isMatrix3&&s.isMatrix3?n.copy(s):this[t]=s}}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let s={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).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};return Object.keys(this.userData).length>0&&(s.userData=this.userData),t||(e.textures[this.uuid]=s),s}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Tu)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Zn:e.x=e.x-Math.floor(e.x);break;case hs:e.x=e.x<0?0:1;break;case ai:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Zn:e.y=e.y-Math.floor(e.y);break;case hs:e.y=e.y<0?0:1;break;case ai:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};gt.DEFAULT_IMAGE=null;gt.DEFAULT_MAPPING=Tu;gt.DEFAULT_ANISOTROPY=1;var Ge=class r{static{r.prototype.isVector4=!0}constructor(e=0,t=0,s=0,n=1){this.x=e,this.y=t,this.z=s,this.w=n}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,s,n){return this.x=e,this.y=t,this.z=s,this.w=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,s=this.y,n=this.z,a=this.w,i=e.elements;return this.x=i[0]*t+i[4]*s+i[8]*n+i[12]*a,this.y=i[1]*t+i[5]*s+i[9]*n+i[13]*a,this.z=i[2]*t+i[6]*s+i[10]*n+i[14]*a,this.w=i[3]*t+i[7]*s+i[11]*n+i[15]*a,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,s,n,a,c=e.elements,l=c[0],h=c[4],u=c[8],d=c[1],f=c[5],p=c[9],m=c[2],b=c[6],g=c[10];if(Math.abs(h-d)<.01&&Math.abs(u-m)<.01&&Math.abs(p-b)<.01){if(Math.abs(h+d)<.1&&Math.abs(u+m)<.1&&Math.abs(p+b)<.1&&Math.abs(l+f+g-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;let T=(l+1)/2,y=(f+1)/2,v=(g+1)/2,_=(h+d)/4,A=(u+m)/4,M=(p+b)/4;return T>y&&T>v?T<.01?(s=0,n=.707106781,a=.707106781):(s=Math.sqrt(T),n=_/s,a=A/s):y>v?y<.01?(s=.707106781,n=0,a=.707106781):(n=Math.sqrt(y),s=_/n,a=M/n):v<.01?(s=.707106781,n=.707106781,a=0):(a=Math.sqrt(v),s=A/a,n=M/a),this.set(s,n,a,t),this}let x=Math.sqrt((b-p)*(b-p)+(u-m)*(u-m)+(d-h)*(d-h));return Math.abs(x)<.001&&(x=1),this.x=(b-p)/x,this.y=(u-m)/x,this.z=(d-h)/x,this.w=Math.acos((l+f+g-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Be(this.x,e.x,t.x),this.y=Be(this.y,e.y,t.y),this.z=Be(this.z,e.z,t.z),this.w=Be(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Be(this.x,e,t),this.y=Be(this.y,e,t),this.z=Be(this.z,e,t),this.w=Be(this.w,e,t),this}clampLength(e,t){let s=this.length();return this.divideScalar(s||1).multiplyScalar(Be(s,e,t))}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(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.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(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,s){return this.x=e.x+(t.x-e.x)*s,this.y=e.y+(t.y-e.y)*s,this.z=e.z+(t.z-e.z)*s,this.w=e.w+(t.w-e.w)*s,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),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}},Ps=class extends Bs{constructor(e=1,t=1,s={}){super(),s=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Ye,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},s),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=s.depth,this.scissor=new Ge(0,0,e,t),this.scissorTest=!1,this.viewport=new Ge(0,0,e,t),this.textures=[];let n={width:e,height:t,depth:s.depth},a=new gt(n),i=s.count;for(let o=0;o<i;o++)this.textures[o]=a.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(s),this.depthBuffer=s.depthBuffer,this.stencilBuffer=s.stencilBuffer,this.resolveColorBuffer=s.resolveColorBuffer,this.resolveDepthBuffer=s.resolveDepthBuffer,this.resolveStencilBuffer=s.resolveStencilBuffer,this.storeMultisampledColorBuffer=s.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=s.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=s.storeMultisampledStencilBuffer,this._depthTexture=null,this.depthTexture=s.depthTexture,this.samples=s.samples,this.multiview=s.multiview,this.useArrayDepthTexture=s.useArrayDepthTexture}_setTextureOptions(e={}){let t={minFilter:Ye,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let s=0;s<this.textures.length;s++)this.textures[s].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&this._depthTexture.renderTarget===this&&(this._depthTexture.renderTarget=null),e!==null&&e.renderTarget===null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,s=1){if(this.width!==e||this.height!==t||this.depth!==s){this.width=e,this.height=t,this.depth=s;for(let n=0,a=this.textures.length;n<a;n++)this.textures[n].image.width=e,this.textures[n].image.height=t,this.textures[n].image.depth=s,this.textures[n].isData3DTexture!==!0&&(this.textures[n].isArrayTexture=this.textures[n].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,s=e.textures.length;t<s;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let n=Object.assign({},e.textures[t].image);this.textures[t].source=new Ma(n)}if(this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveColorBuffer=e.resolveColorBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,this.storeMultisampledColorBuffer=e.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=e.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=e.storeMultisampledStencilBuffer,e.depthTexture!==null)if(e.depthTexture.renderTarget===e){let t=e.depthTexture.clone();t.renderTarget=null,this.depthTexture=t}else this.depthTexture=e.depthTexture;return this.samples=e.samples,this.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}},jh=class extends Ps{constructor(e=1,t=1,s={}){super(e,t,s),this.isWebGLRenderTarget=!0}},Gh=class extends gt{constructor(e=null,t=1,s=1,n=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:s,depth:n},this.magFilter=pt,this.minFilter=pt,this.wrapR=hs,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},Kg=class extends jh{constructor(e=1,t=1,s=1,n={}){super(e,t,n),this.isWebGLArrayRenderTarget=!0,this.depth=s,this.texture=new Gh(null,e,t,s),this._setTextureOptions(n),this.texture.isRenderTargetTexture=!0}},Hh=class extends gt{constructor(e=null,t=1,s=1,n=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:s,depth:n},this.magFilter=pt,this.minFilter=pt,this.wrapR=hs,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}},Jg=class extends jh{constructor(e=1,t=1,s=1,n={}){super(e,t,n),this.isWebGL3DRenderTarget=!0,this.depth=s,this.texture=new Hh(null,e,t,s),this._setTextureOptions(n),this.texture.isRenderTargetTexture=!0}},le=class r{static{r.prototype.isMatrix4=!0}constructor(e,t,s,n,a,i,o,c,l,h,u,d,f,p,m,b){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,s,n,a,i,o,c,l,h,u,d,f,p,m,b)}set(e,t,s,n,a,i,o,c,l,h,u,d,f,p,m,b){let g=this.elements;return g[0]=e,g[4]=t,g[8]=s,g[12]=n,g[1]=a,g[5]=i,g[9]=o,g[13]=c,g[2]=l,g[6]=h,g[10]=u,g[14]=d,g[3]=f,g[7]=p,g[11]=m,g[15]=b,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 r().fromArray(this.elements)}copy(e){let t=this.elements,s=e.elements;return t[0]=s[0],t[1]=s[1],t[2]=s[2],t[3]=s[3],t[4]=s[4],t[5]=s[5],t[6]=s[6],t[7]=s[7],t[8]=s[8],t[9]=s[9],t[10]=s[10],t[11]=s[11],t[12]=s[12],t[13]=s[13],t[14]=s[14],t[15]=s[15],this}copyPosition(e){let t=this.elements,s=e.elements;return t[12]=s[12],t[13]=s[13],t[14]=s[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,s){return this.determinantAffine()===0?(e.set(1,0,0),t.set(0,1,0),s.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),s.setFromMatrixColumn(this,2),this)}makeBasis(e,t,s){return this.set(e.x,t.x,s.x,0,e.y,t.y,s.y,0,e.z,t.z,s.z,0,0,0,0,1),this}extractRotation(e){if(e.determinantAffine()===0)return this.identity();let t=this.elements,s=e.elements,n=1/uh.setFromMatrixColumn(e,0).length(),a=1/uh.setFromMatrixColumn(e,1).length(),i=1/uh.setFromMatrixColumn(e,2).length();return t[0]=s[0]*n,t[1]=s[1]*n,t[2]=s[2]*n,t[3]=0,t[4]=s[4]*a,t[5]=s[5]*a,t[6]=s[6]*a,t[7]=0,t[8]=s[8]*i,t[9]=s[9]*i,t[10]=s[10]*i,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,s=e.x,n=e.y,a=e.z,i=Math.cos(s),o=Math.sin(s),c=Math.cos(n),l=Math.sin(n),h=Math.cos(a),u=Math.sin(a);if(e.order==="XYZ"){let d=i*h,f=i*u,p=o*h,m=o*u;t[0]=c*h,t[4]=-c*u,t[8]=l,t[1]=f+p*l,t[5]=d-m*l,t[9]=-o*c,t[2]=m-d*l,t[6]=p+f*l,t[10]=i*c}else if(e.order==="YXZ"){let d=c*h,f=c*u,p=l*h,m=l*u;t[0]=d+m*o,t[4]=p*o-f,t[8]=i*l,t[1]=i*u,t[5]=i*h,t[9]=-o,t[2]=f*o-p,t[6]=m+d*o,t[10]=i*c}else if(e.order==="ZXY"){let d=c*h,f=c*u,p=l*h,m=l*u;t[0]=d-m*o,t[4]=-i*u,t[8]=p+f*o,t[1]=f+p*o,t[5]=i*h,t[9]=m-d*o,t[2]=-i*l,t[6]=o,t[10]=i*c}else if(e.order==="ZYX"){let d=i*h,f=i*u,p=o*h,m=o*u;t[0]=c*h,t[4]=p*l-f,t[8]=d*l+m,t[1]=c*u,t[5]=m*l+d,t[9]=f*l-p,t[2]=-l,t[6]=o*c,t[10]=i*c}else if(e.order==="YZX"){let d=i*c,f=i*l,p=o*c,m=o*l;t[0]=c*h,t[4]=m-d*u,t[8]=p*u+f,t[1]=u,t[5]=i*h,t[9]=-o*h,t[2]=-l*h,t[6]=f*u+p,t[10]=d-m*u}else if(e.order==="XZY"){let d=i*c,f=i*l,p=o*c,m=o*l;t[0]=c*h,t[4]=-u,t[8]=l*h,t[1]=d*u+m,t[5]=i*h,t[9]=f*u-p,t[2]=p*u-f,t[6]=o*h,t[10]=m*u+d}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(R3,e,E3)}lookAt(e,t,s){let n=this.elements;return Jn.subVectors(e,t),Jn.lengthSq()===0&&(Jn.z=1),Jn.normalize(),uo.crossVectors(s,Jn),uo.lengthSq()===0&&(Math.abs(s.z)===1?Jn.x+=1e-4:Jn.z+=1e-4,Jn.normalize(),uo.crossVectors(s,Jn)),uo.normalize(),tg.crossVectors(Jn,uo),n[0]=uo.x,n[4]=tg.x,n[8]=Jn.x,n[1]=uo.y,n[5]=tg.y,n[9]=Jn.y,n[2]=uo.z,n[6]=tg.z,n[10]=Jn.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let s=e.elements,n=t.elements,a=this.elements,i=s[0],o=s[4],c=s[8],l=s[12],h=s[1],u=s[5],d=s[9],f=s[13],p=s[2],m=s[6],b=s[10],g=s[14],x=s[3],T=s[7],y=s[11],v=s[15],_=n[0],A=n[4],M=n[8],N=n[12],R=n[1],I=n[5],D=n[9],O=n[13],P=n[2],U=n[6],j=n[10],z=n[14],H=n[3],J=n[7],ee=n[11],se=n[15];return a[0]=i*_+o*R+c*P+l*H,a[4]=i*A+o*I+c*U+l*J,a[8]=i*M+o*D+c*j+l*ee,a[12]=i*N+o*O+c*z+l*se,a[1]=h*_+u*R+d*P+f*H,a[5]=h*A+u*I+d*U+f*J,a[9]=h*M+u*D+d*j+f*ee,a[13]=h*N+u*O+d*z+f*se,a[2]=p*_+m*R+b*P+g*H,a[6]=p*A+m*I+b*U+g*J,a[10]=p*M+m*D+b*j+g*ee,a[14]=p*N+m*O+b*z+g*se,a[3]=x*_+T*R+y*P+v*H,a[7]=x*A+T*I+y*U+v*J,a[11]=x*M+T*D+y*j+v*ee,a[15]=x*N+T*O+y*z+v*se,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],s=e[4],n=e[8],a=e[12],i=e[1],o=e[5],c=e[9],l=e[13],h=e[2],u=e[6],d=e[10],f=e[14],p=e[3],m=e[7],b=e[11],g=e[15],x=c*f-l*d,T=o*f-l*u,y=o*d-c*u,v=i*f-l*h,_=i*d-c*h,A=i*u-o*h;return t*(m*x-b*T+g*y)-s*(p*x-b*v+g*_)+n*(p*T-m*v+g*A)-a*(p*y-m*_+b*A)}determinantAffine(){let e=this.elements,t=e[0],s=e[4],n=e[8],a=e[1],i=e[5],o=e[9],c=e[2],l=e[6],h=e[10];return t*(i*h-o*l)-s*(a*h-o*c)+n*(a*l-i*c)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,s){let n=this.elements;return e.isVector3?(n[12]=e.x,n[13]=e.y,n[14]=e.z):(n[12]=e,n[13]=t,n[14]=s),this}invert(){let e=this.elements,t=e[0],s=e[1],n=e[2],a=e[3],i=e[4],o=e[5],c=e[6],l=e[7],h=e[8],u=e[9],d=e[10],f=e[11],p=e[12],m=e[13],b=e[14],g=e[15],x=t*o-s*i,T=t*c-n*i,y=t*l-a*i,v=s*c-n*o,_=s*l-a*o,A=n*l-a*c,M=h*m-u*p,N=h*b-d*p,R=h*g-f*p,I=u*b-d*m,D=u*g-f*m,O=d*g-f*b,P=x*O-T*D+y*I+v*R-_*N+A*M;if(P===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let U=1/P;return e[0]=(o*O-c*D+l*I)*U,e[1]=(n*D-s*O-a*I)*U,e[2]=(m*A-b*_+g*v)*U,e[3]=(d*_-u*A-f*v)*U,e[4]=(c*R-i*O-l*N)*U,e[5]=(t*O-n*R+a*N)*U,e[6]=(b*y-p*A-g*T)*U,e[7]=(h*A-d*y+f*T)*U,e[8]=(i*D-o*R+l*M)*U,e[9]=(s*R-t*D-a*M)*U,e[10]=(p*_-m*y+g*x)*U,e[11]=(u*y-h*_-f*x)*U,e[12]=(o*N-i*I-c*M)*U,e[13]=(t*I-s*N+n*M)*U,e[14]=(m*T-p*v-b*x)*U,e[15]=(h*v-u*T+d*x)*U,this}scale(e){let t=this.elements,s=e.x,n=e.y,a=e.z;return t[0]*=s,t[4]*=n,t[8]*=a,t[1]*=s,t[5]*=n,t[9]*=a,t[2]*=s,t[6]*=n,t[10]*=a,t[3]*=s,t[7]*=n,t[11]*=a,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],s=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],n=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,s,n))}makeTranslation(e,t,s){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,s,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),s=Math.sin(e);return this.set(1,0,0,0,0,t,-s,0,0,s,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),s=Math.sin(e);return this.set(t,0,s,0,0,1,0,0,-s,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),s=Math.sin(e);return this.set(t,-s,0,0,s,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let s=Math.cos(t),n=Math.sin(t),a=1-s,i=e.x,o=e.y,c=e.z,l=a*i,h=a*o;return this.set(l*i+s,l*o-n*c,l*c+n*o,0,l*o+n*c,h*o+s,h*c-n*i,0,l*c-n*o,h*c+n*i,a*c*c+s,0,0,0,0,1),this}makeScale(e,t,s){return this.set(e,0,0,0,0,t,0,0,0,0,s,0,0,0,0,1),this}makeShear(e,t,s,n,a,i){return this.set(1,s,a,0,e,1,i,0,t,n,1,0,0,0,0,1),this}compose(e,t,s){let n=this.elements,a=t._x,i=t._y,o=t._z,c=t._w,l=a+a,h=i+i,u=o+o,d=a*l,f=a*h,p=a*u,m=i*h,b=i*u,g=o*u,x=c*l,T=c*h,y=c*u,v=s.x,_=s.y,A=s.z;return n[0]=(1-(m+g))*v,n[1]=(f+y)*v,n[2]=(p-T)*v,n[3]=0,n[4]=(f-y)*_,n[5]=(1-(d+g))*_,n[6]=(b+x)*_,n[7]=0,n[8]=(p+T)*A,n[9]=(b-x)*A,n[10]=(1-(d+m))*A,n[11]=0,n[12]=e.x,n[13]=e.y,n[14]=e.z,n[15]=1,this}decompose(e,t,s){let n=this.elements;e.x=n[12],e.y=n[13],e.z=n[14];let a=this.determinantAffine();if(a===0)return s.set(1,1,1),t.identity(),this;let i=uh.set(n[0],n[1],n[2]).length(),o=uh.set(n[4],n[5],n[6]).length(),c=uh.set(n[8],n[9],n[10]).length();a<0&&(i=-i),Za.copy(this);let l=1/i,h=1/o,u=1/c;return Za.elements[0]*=l,Za.elements[1]*=l,Za.elements[2]*=l,Za.elements[4]*=h,Za.elements[5]*=h,Za.elements[6]*=h,Za.elements[8]*=u,Za.elements[9]*=u,Za.elements[10]*=u,t.setFromRotationMatrix(Za),s.x=i,s.y=o,s.z=c,this}makePerspective(e,t,s,n,a,i,o=sn,c=!1){let l=this.elements,h=2*a/(t-e),u=2*a/(s-n),d=(t+e)/(t-e),f=(s+n)/(s-n),p,m;if(c)p=a/(i-a),m=i*a/(i-a);else if(o===sn)p=-(i+a)/(i-a),m=-2*i*a/(i-a);else if(o===Xs)p=-i/(i-a),m=-i*a/(i-a);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=d,l[12]=0,l[1]=0,l[5]=u,l[9]=f,l[13]=0,l[2]=0,l[6]=0,l[10]=p,l[14]=m,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,s,n,a,i,o=sn,c=!1){let l=this.elements,h=2/(t-e),u=2/(s-n),d=-(t+e)/(t-e),f=-(s+n)/(s-n),p,m;if(c)p=1/(i-a),m=i/(i-a);else if(o===sn)p=-2/(i-a),m=-(i+a)/(i-a);else if(o===Xs)p=-1/(i-a),m=-a/(i-a);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=0,l[12]=d,l[1]=0,l[5]=u,l[9]=0,l[13]=f,l[2]=0,l[6]=0,l[10]=p,l[14]=m,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){let t=this.elements,s=e.elements;for(let n=0;n<16;n++)if(t[n]!==s[n])return!1;return!0}fromArray(e,t=0){for(let s=0;s<16;s++)this.elements[s]=e[s+t];return this}toArray(e=[],t=0){let s=this.elements;return e[t]=s[0],e[t+1]=s[1],e[t+2]=s[2],e[t+3]=s[3],e[t+4]=s[4],e[t+5]=s[5],e[t+6]=s[6],e[t+7]=s[7],e[t+8]=s[8],e[t+9]=s[9],e[t+10]=s[10],e[t+11]=s[11],e[t+12]=s[12],e[t+13]=s[13],e[t+14]=s[14],e[t+15]=s[15],e}},uh=new E,Za=new le,R3=new E(0,0,0),E3=new E(1,1,1),uo=new E,tg=new E,Jn=new E,n8=new le,a8=new It,Na=class r{constructor(e=0,t=0,s=0,n=r.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=s,this._order=n}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,s,n=this._order){return this._x=e,this._y=t,this._z=s,this._order=n,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,s=!0){let n=e.elements,a=n[0],i=n[4],o=n[8],c=n[1],l=n[5],h=n[9],u=n[2],d=n[6],f=n[10];switch(t){case"XYZ":this._y=Math.asin(Be(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,f),this._z=Math.atan2(-i,a)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Be(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-u,a),this._z=0);break;case"ZXY":this._x=Math.asin(Be(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-i,l)):(this._y=0,this._z=Math.atan2(c,a));break;case"ZYX":this._y=Math.asin(-Be(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(c,a)):(this._x=0,this._z=Math.atan2(-i,l));break;case"YZX":this._z=Math.asin(Be(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-u,a)):(this._x=0,this._y=Math.atan2(o,f));break;case"XZY":this._z=Math.asin(-Be(i,-1,1)),Math.abs(i)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(o,a)):(this._x=Math.atan2(-h,f),this._y=0);break;default:K("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,s===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,s){return n8.makeRotationFromQuaternion(e),this.setFromRotationMatrix(n8,t,s)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return a8.setFromEuler(this),this.setFromQuaternion(a8,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};Na.DEFAULT_ORDER="XYZ";var Wh=class{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}},C3=0,i8=new E,dh=new It,Tr=new le,sg=new E,_f=new E,k3=new E,I3=new It,r8=new E(1,0,0),o8=new E(0,1,0),c8=new E(0,0,1),l8={type:"added"},B3={type:"removed"},fh={type:"childadded",child:null},Hv={type:"childremoved",child:null},Ze=class r extends Bs{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:C3++}),this.uuid=Yn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=r.DEFAULT_UP.clone();let e=new E,t=new Na,s=new It,n=new E(1,1,1);function a(){s.setFromEuler(t,!1)}function i(){t.setFromQuaternion(s,void 0,!1)}t._onChange(a),s._onChange(i),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:s},scale:{configurable:!0,enumerable:!0,value:n},modelViewMatrix:{value:new le},normalMatrix:{value:new Fs}}),this.matrix=new le,this.matrixWorld=new le,this.matrixAutoUpdate=r.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=r.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Wh,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(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return dh.setFromAxisAngle(e,t),this.quaternion.multiply(dh),this}rotateOnWorldAxis(e,t){return dh.setFromAxisAngle(e,t),this.quaternion.premultiply(dh),this}rotateX(e){return this.rotateOnAxis(r8,e)}rotateY(e){return this.rotateOnAxis(o8,e)}rotateZ(e){return this.rotateOnAxis(c8,e)}translateOnAxis(e,t){return i8.copy(e).applyQuaternion(this.quaternion),this.position.add(i8.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(r8,e)}translateY(e){return this.translateOnAxis(o8,e)}translateZ(e){return this.translateOnAxis(c8,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Tr.copy(this.matrixWorld).invert())}lookAt(e,t,s){e.isVector3?sg.copy(e):sg.set(e,t,s);let n=this.parent;this.updateWorldMatrix(!0,!1),_f.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Tr.lookAt(_f,sg,this.up):Tr.lookAt(sg,_f,this.up),this.quaternion.setFromRotationMatrix(Tr),n&&(Tr.extractRotation(n.matrixWorld),dh.setFromRotationMatrix(Tr),this.quaternion.premultiply(dh.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(W("Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(l8),fh.child=e,this.dispatchEvent(fh),fh.child=null):W("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let s=0;s<arguments.length;s++)this.remove(arguments[s]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(B3),Hv.child=e,this.dispatchEvent(Hv),Hv.child=null),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Tr.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Tr.multiply(e.parent.matrixWorld)),e.applyMatrix4(Tr),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(l8),fh.child=e,this.dispatchEvent(fh),fh.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let s=0,n=this.children.length;s<n;s++){let i=this.children[s].getObjectByProperty(e,t);if(i!==void 0)return i}}getObjectsByProperty(e,t,s=[]){this[e]===t&&s.push(this);let n=this.children;for(let a=0,i=n.length;a<i;a++)n[a].getObjectsByProperty(e,t,s);return s}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(_f,e,k3),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(_f,I3,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}intersectsFrustum(){}traverse(e){e(this);let t=this.children;for(let s=0,n=t.length;s<n;s++)t[s].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let s=0,n=t.length;s<n;s++)t[s].traverseVisible(e)}traverseAncestors(e){let t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let e=this.pivot;if(e!==null){let t=e.x,s=e.y,n=e.z,a=this.matrix.elements;a[12]+=t-a[0]*t-a[4]*s-a[8]*n,a[13]+=s-a[1]*t-a[5]*s-a[9]*n,a[14]+=n-a[2]*t-a[6]*s-a[10]*n}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);let t=this.children;for(let s=0,n=t.length;s<n;s++)t[s].updateMatrixWorld(e)}updateWorldMatrix(e,t,s=!1){let n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||s)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,s=!0),t===!0){let a=this.children;for(let i=0,o=a.length;i<o;i++)a[i].updateWorldMatrix(!1,!0,s)}}toJSON(e){let t=e===void 0||typeof e=="string",s={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},s.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});let n={};n.uuid=this.uuid,n.type=this.type,n.name=this.name,n.castShadow=this.castShadow,n.receiveShadow=this.receiveShadow,n.visible=this.visible,n.frustumCulled=this.frustumCulled,n.renderOrder=this.renderOrder,n.static=this.static,n.matrixAutoUpdate=this.matrixAutoUpdate,Object.keys(this.userData).length>0&&(n.userData=this.userData),n.layers=this.layers.mask,n.matrix=this.matrix.toArray(),n.up=this.up.toArray(),this.pivot!==null&&(n.pivot=this.pivot.toArray()),this.morphTargetDictionary!==void 0&&(n.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(n.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(n.type="InstancedMesh",n.count=this.count,n.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(n.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(n.type="BatchedMesh",n.perObjectFrustumCulled=this.perObjectFrustumCulled,n.sortObjects=this.sortObjects,n.drawRanges=this._drawRanges,n.reservedRanges=this._reservedRanges,n.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),n.instanceInfo=this._instanceInfo.map(o=>({...o})),n.availableInstanceIds=this._availableInstanceIds.slice(),n.availableGeometryIds=this._availableGeometryIds.slice(),n.nextIndexStart=this._nextIndexStart,n.nextVertexStart=this._nextVertexStart,n.geometryCount=this._geometryCount,n.maxInstanceCount=this._maxInstanceCount,n.maxVertexCount=this._maxVertexCount,n.maxIndexCount=this._maxIndexCount,n.geometryInitialized=this._geometryInitialized,n.matricesTexture=this._matricesTexture.toJSON(e),n.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(n.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(n.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(n.boundingBox=this.boundingBox.toJSON()));function a(o,c){return o[c.uuid]===void 0&&(o[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?n.background=this.background.toJSON():this.background.isTexture&&(n.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(n.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){n.geometry=a(e.geometries,this.geometry);let o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){let c=o.shapes;if(Array.isArray(c))for(let l=0,h=c.length;l<h;l++){let u=c[l];a(e.shapes,u)}else a(e.shapes,c)}}if(this.isSkinnedMesh&&(n.bindMode=this.bindMode,n.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(a(e.skeletons,this.skeleton),n.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let o=[];for(let c=0,l=this.material.length;c<l;c++)o.push(a(e.materials,this.material[c]));n.material=o}else n.material=a(e.materials,this.material);if(this.children.length>0){n.children=[];for(let o=0;o<this.children.length;o++)n.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){n.animations=[];for(let o=0;o<this.animations.length;o++){let c=this.animations[o];n.animations.push(a(e.animations,c))}}if(t){let o=i(e.geometries),c=i(e.materials),l=i(e.textures),h=i(e.images),u=i(e.shapes),d=i(e.skeletons),f=i(e.animations),p=i(e.nodes);o.length>0&&(s.geometries=o),c.length>0&&(s.materials=c),l.length>0&&(s.textures=l),h.length>0&&(s.images=h),u.length>0&&(s.shapes=u),d.length>0&&(s.skeletons=d),f.length>0&&(s.animations=f),p.length>0&&(s.nodes=p)}return s.object=n,s;function i(o){let c=[];for(let l in o){let h=o[l];delete h.metadata,c.push(h)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let s=0;s<e.children.length;s++){let n=e.children[s];this.add(n.clone())}return this}dispose(){this.dispatchEvent({type:"dispose"})}};Ze.DEFAULT_UP=new E(0,1,0);Ze.DEFAULT_MATRIX_AUTO_UPDATE=!0;Ze.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var qs=class extends Ze{constructor(){super(),this.isGroup=!0,this.type="Group"}},F3={type:"move"},Hf=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new qs,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new qs,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new E,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new E),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new qs,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new E,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new E,this._grip.eventsEnabled=!1),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let s of e.hand.values())this._getHandJoint(t,s)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,s){let n=null,a=null,i=null,o=this._targetRay,c=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){i=!0;for(let m of e.hand.values()){let b=t.getJointPose(m,s),g=this._getHandJoint(l,m);b!==null&&(g.matrix.fromArray(b.transform.matrix),g.matrix.decompose(g.position,g.rotation,g.scale),g.matrixWorldNeedsUpdate=!0,g.jointRadius=b.radius),g.visible=b!==null}let h=l.joints["index-finger-tip"],u=l.joints["thumb-tip"],d=h.position.distanceTo(u.position),f=.02,p=.005;l.inputState.pinching&&d>f+p?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&d<=f-p&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(a=t.getPose(e.gripSpace,s),a!==null&&(c.matrix.fromArray(a.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,a.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(a.linearVelocity)):c.hasLinearVelocity=!1,a.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(a.angularVelocity)):c.hasAngularVelocity=!1,c.eventsEnabled&&c.dispatchEvent({type:"gripUpdated",data:e,target:this})));o!==null&&(n=t.getPose(e.targetRaySpace,s),n===null&&a!==null&&(n=a),n!==null&&(o.matrix.fromArray(n.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,n.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(n.linearVelocity)):o.hasLinearVelocity=!1,n.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(n.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(F3)))}return o!==null&&(o.visible=n!==null),c!==null&&(c.visible=a!==null),l!==null&&(l.visible=i!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let s=new qs;s.matrixAutoUpdate=!1,s.visible=!1,e.joints[t.jointName]=s,e.add(s)}return e.joints[t.jointName]}},kC={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},fo={h:0,s:0,l:0},ng={h:0,s:0,l:0};function Wv(r,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?r+(e-r)*6*t:t<1/2?e:t<2/3?r+(e-r)*6*(2/3-t):r}var be=class{constructor(e,t,s){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,s)}set(e,t,s){if(t===void 0&&s===void 0){let n=e;n&&n.isColor?this.copy(n):typeof n=="number"?this.setHex(n):typeof n=="string"&&this.setStyle(n)}else this.setRGB(e,t,s);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Wt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,qe.colorSpaceToWorking(this,t),this}setRGB(e,t,s,n=qe.workingColorSpace){return this.r=e,this.g=t,this.b=s,qe.colorSpaceToWorking(this,n),this}setHSL(e,t,s,n=qe.workingColorSpace){if(e=lA(e,1),t=Be(t,0,1),s=Be(s,0,1),t===0)this.r=this.g=this.b=s;else{let a=s<=.5?s*(1+t):s+t-s*t,i=2*s-a;this.r=Wv(i,a,e+1/3),this.g=Wv(i,a,e),this.b=Wv(i,a,e-1/3)}return qe.colorSpaceToWorking(this,n),this}setStyle(e,t=Wt){function s(a){a!==void 0&&parseFloat(a)<1&&K("Color: Alpha component of "+e+" will be ignored.")}let n;if(n=/^(\w+)\(([^\)]*)\)/.exec(e)){let a,i=n[1],o=n[2];switch(i){case"rgb":case"rgba":if(a=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return s(a[4]),this.setRGB(Math.min(255,parseInt(a[1],10))/255,Math.min(255,parseInt(a[2],10))/255,Math.min(255,parseInt(a[3],10))/255,t);if(a=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return s(a[4]),this.setRGB(Math.min(100,parseInt(a[1],10))/100,Math.min(100,parseInt(a[2],10))/100,Math.min(100,parseInt(a[3],10))/100,t);break;case"hsl":case"hsla":if(a=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return s(a[4]),this.setHSL(parseFloat(a[1])/360,parseFloat(a[2])/100,parseFloat(a[3])/100,t);break;default:K("Color: Unknown color model "+e)}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(e)){let a=n[1],i=a.length;if(i===3)return this.setRGB(parseInt(a.charAt(0),16)/15,parseInt(a.charAt(1),16)/15,parseInt(a.charAt(2),16)/15,t);if(i===6)return this.setHex(parseInt(a,16),t);K("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Wt){let s=kC[e.toLowerCase()];return s!==void 0?this.setHex(s,t):K("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Rr(e.r),this.g=Rr(e.g),this.b=Rr(e.b),this}copyLinearToSRGB(e){return this.r=Ih(e.r),this.g=Ih(e.g),this.b=Ih(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Wt){return qe.workingToColorSpace(en.copy(this),e),Math.round(Be(en.r*255,0,255))*65536+Math.round(Be(en.g*255,0,255))*256+Math.round(Be(en.b*255,0,255))}getHexString(e=Wt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=qe.workingColorSpace){qe.workingToColorSpace(en.copy(this),t);let s=en.r,n=en.g,a=en.b,i=Math.max(s,n,a),o=Math.min(s,n,a),c,l,h=(o+i)/2;if(o===i)c=0,l=0;else{let u=i-o;switch(l=h<=.5?u/(i+o):u/(2-i-o),i){case s:c=(n-a)/u+(n<a?6:0);break;case n:c=(a-s)/u+2;break;case a:c=(s-n)/u+4;break}c/=6}return e.h=c,e.s=l,e.l=h,e}getRGB(e,t=qe.workingColorSpace){return qe.workingToColorSpace(en.copy(this),t),e.r=en.r,e.g=en.g,e.b=en.b,e}getStyle(e=Wt){qe.workingToColorSpace(en.copy(this),e);let t=en.r,s=en.g,n=en.b;return e!==Wt?`color(${e} ${t.toFixed(3)} ${s.toFixed(3)} ${n.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(s*255)},${Math.round(n*255)})`}offsetHSL(e,t,s){return this.getHSL(fo),this.setHSL(fo.h+e,fo.s+t,fo.l+s)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,s){return this.r=e.r+(t.r-e.r)*s,this.g=e.g+(t.g-e.g)*s,this.b=e.b+(t.b-e.b)*s,this}lerpHSL(e,t){this.getHSL(fo),e.getHSL(ng);let s=Uf(fo.h,ng.h,t),n=Uf(fo.s,ng.s,t),a=Uf(fo.l,ng.l,t);return this.setHSL(s,n,a),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,s=this.g,n=this.b,a=e.elements;return this.r=a[0]*t+a[3]*s+a[6]*n,this.g=a[1]*t+a[4]*s+a[7]*n,this.b=a[2]*t+a[5]*s+a[8]*n,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}},en=new be;be.NAMES=kC;var Wf=class r{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new be(e),this.density=t}clone(){return new r(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}},qf=class r{constructor(e,t=1,s=1e3){this.isFog=!0,this.name="",this.color=new be(e),this.near=t,this.far=s}clone(){return new r(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}},ii=class extends Ze{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Na,this.environmentIntensity=1,this.environmentRotation=new Na,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),t.object.backgroundBlurriness=this.backgroundBlurriness,t.object.backgroundIntensity=this.backgroundIntensity,t.object.backgroundRotation=this.backgroundRotation.toArray(),t.object.environmentIntensity=this.environmentIntensity,t.object.environmentRotation=this.environmentRotation.toArray(),t}},Qa=new E,vr=new E,qv=new E,_r=new E,ph=new E,mh=new E,h8=new E,Xv=new E,Kv=new E,Jv=new E,$v=new Ge,Yv=new Ge,Zv=new Ge,si=class r{constructor(e=new E,t=new E,s=new E){this.a=e,this.b=t,this.c=s}static getNormal(e,t,s,n){n.subVectors(s,t),Qa.subVectors(e,t),n.cross(Qa);let a=n.lengthSq();return a>0?n.multiplyScalar(1/Math.sqrt(a)):n.set(0,0,0)}static getBarycoord(e,t,s,n,a){Qa.subVectors(n,t),vr.subVectors(s,t),qv.subVectors(e,t);let i=Qa.dot(Qa),o=Qa.dot(vr),c=Qa.dot(qv),l=vr.dot(vr),h=vr.dot(qv),u=i*l-o*o;if(u===0)return a.set(0,0,0),null;let d=1/u,f=(l*c-o*h)*d,p=(i*h-o*c)*d;return a.set(1-f-p,p,f)}static containsPoint(e,t,s,n){return this.getBarycoord(e,t,s,n,_r)===null?!1:_r.x>=0&&_r.y>=0&&_r.x+_r.y<=1}static getInterpolation(e,t,s,n,a,i,o,c){return this.getBarycoord(e,t,s,n,_r)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(a,_r.x),c.addScaledVector(i,_r.y),c.addScaledVector(o,_r.z),c)}static getInterpolatedAttribute(e,t,s,n,a,i){return $v.setScalar(0),Yv.setScalar(0),Zv.setScalar(0),$v.fromBufferAttribute(e,t),Yv.fromBufferAttribute(e,s),Zv.fromBufferAttribute(e,n),i.setScalar(0),i.addScaledVector($v,a.x),i.addScaledVector(Yv,a.y),i.addScaledVector(Zv,a.z),i}static isFrontFacing(e,t,s,n){return Qa.subVectors(s,t),vr.subVectors(e,t),Qa.cross(vr).dot(n)<0}set(e,t,s){return this.a.copy(e),this.b.copy(t),this.c.copy(s),this}setFromPointsAndIndices(e,t,s,n){return this.a.copy(e[t]),this.b.copy(e[s]),this.c.copy(e[n]),this}setFromAttributeAndIndices(e,t,s,n){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,s),this.c.fromBufferAttribute(e,n),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Qa.subVectors(this.c,this.b),vr.subVectors(this.a,this.b),Qa.cross(vr).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return r.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return r.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,s,n,a){return r.getInterpolation(e,this.a,this.b,this.c,t,s,n,a)}containsPoint(e){return r.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return r.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let s=this.a,n=this.b,a=this.c,i,o;ph.subVectors(n,s),mh.subVectors(a,s),Xv.subVectors(e,s);let c=ph.dot(Xv),l=mh.dot(Xv);if(c<=0&&l<=0)return t.copy(s);Kv.subVectors(e,n);let h=ph.dot(Kv),u=mh.dot(Kv);if(h>=0&&u<=h)return t.copy(n);let d=c*u-h*l;if(d<=0&&c>=0&&h<=0)return i=c/(c-h),t.copy(s).addScaledVector(ph,i);Jv.subVectors(e,a);let f=ph.dot(Jv),p=mh.dot(Jv);if(p>=0&&f<=p)return t.copy(a);let m=f*l-c*p;if(m<=0&&l>=0&&p<=0)return o=l/(l-p),t.copy(s).addScaledVector(mh,o);let b=h*p-f*u;if(b<=0&&u-h>=0&&f-p>=0)return h8.subVectors(a,n),o=(u-h)/(u-h+(f-p)),t.copy(n).addScaledVector(h8,o);let g=1/(b+m+d);return i=m*g,o=d*g,t.copy(s).addScaledVector(ph,i).addScaledVector(mh,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},ss=class{constructor(e=new E(1/0,1/0,1/0),t=new E(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,s=e.length;t<s;t+=3)this.expandByPoint(ei.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,s=e.count;t<s;t++)this.expandByPoint(ei.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,s=e.length;t<s;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let s=ei.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(s),this.max.copy(e).add(s),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.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(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let s=e.geometry;if(s!==void 0){let a=s.getAttribute("position");if(t===!0&&a!==void 0&&e.isInstancedMesh!==!0)for(let i=0,o=a.count;i<o;i++)e.isMesh===!0?e.getVertexPosition(i,ei):ei.fromBufferAttribute(a,i),ei.applyMatrix4(e.matrixWorld),this.expandByPoint(ei);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),ag.copy(e.boundingBox)):(s.boundingBox===null&&s.computeBoundingBox(),ag.copy(s.boundingBox)),ag.applyMatrix4(e.matrixWorld),this.union(ag)}let n=e.children;for(let a=0,i=n.length;a<i;a++)this.expandByObject(n[a],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,ei),ei.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,s;return e.normal.x>0?(t=e.normal.x*this.min.x,s=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,s=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,s+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,s+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,s+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,s+=e.normal.z*this.min.z),t<=-e.constant&&s>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Af),ig.subVectors(this.max,Af),bh.subVectors(e.a,Af),gh.subVectors(e.b,Af),yh.subVectors(e.c,Af),po.subVectors(gh,bh),mo.subVectors(yh,gh),Sc.subVectors(bh,yh);let t=[0,-po.z,po.y,0,-mo.z,mo.y,0,-Sc.z,Sc.y,po.z,0,-po.x,mo.z,0,-mo.x,Sc.z,0,-Sc.x,-po.y,po.x,0,-mo.y,mo.x,0,-Sc.y,Sc.x,0];return!Qv(t,bh,gh,yh,ig)||(t=[1,0,0,0,1,0,0,0,1],!Qv(t,bh,gh,yh,ig))?!1:(rg.crossVectors(po,mo),t=[rg.x,rg.y,rg.z],Qv(t,bh,gh,yh,ig))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,ei).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(ei).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Ar[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Ar[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Ar[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Ar[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Ar[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Ar[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Ar[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Ar[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Ar),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}},Ar=[new E,new E,new E,new E,new E,new E,new E,new E],ei=new E,ag=new ss,bh=new E,gh=new E,yh=new E,po=new E,mo=new E,Sc=new E,Af=new E,ig=new E,rg=new E,Nc=new E;function Qv(r,e,t,s,n){for(let a=0,i=r.length-3;a<=i;a+=3){Nc.fromArray(r,a);let o=n.x*Math.abs(Nc.x)+n.y*Math.abs(Nc.y)+n.z*Math.abs(Nc.z),c=e.dot(Nc),l=t.dot(Nc),h=s.dot(Nc);if(Math.max(-Math.max(c,l,h),Math.min(c,l,h))>o)return!1}return!0}var Nr=P3();function P3(){let r=new ArrayBuffer(4),e=new Float32Array(r),t=new Uint32Array(r),s=new Uint32Array(512),n=new Uint32Array(512);for(let c=0;c<256;++c){let l=c-127;l<-27?(s[c]=0,s[c|256]=32768,n[c]=24,n[c|256]=24):l<-14?(s[c]=1024>>-l-14,s[c|256]=1024>>-l-14|32768,n[c]=-l-1,n[c|256]=-l-1):l<=15?(s[c]=l+15<<10,s[c|256]=l+15<<10|32768,n[c]=13,n[c|256]=13):l<128?(s[c]=31744,s[c|256]=64512,n[c]=24,n[c|256]=24):(s[c]=31744,s[c|256]=64512,n[c]=13,n[c|256]=13)}let a=new Uint32Array(2048),i=new Uint32Array(64),o=new Uint32Array(64);for(let c=1;c<1024;++c){let l=c<<13,h=0;for(;(l&8388608)===0;)l<<=1,h-=8388608;l&=-8388609,h+=947912704,a[c]=l|h}for(let c=1024;c<2048;++c)a[c]=939524096+(c-1024<<13);for(let c=1;c<31;++c)i[c]=c<<23;i[31]=1199570944,i[32]=2147483648;for(let c=33;c<63;++c)i[c]=2147483648+(c-32<<23);i[63]=3347054592;for(let c=1;c<64;++c)c!==32&&(o[c]=1024);return{floatView:e,uint32View:t,baseTable:s,shiftTable:n,mantissaTable:a,exponentTable:i,offsetTable:o}}function Dn(r){Math.abs(r)>65504&&K("DataUtils.toHalfFloat(): Value out of range."),r=Be(r,-65504,65504),Nr.floatView[0]=r;let e=Nr.uint32View[0],t=e>>23&511;return Nr.baseTable[t]+((e&8388607)>>Nr.shiftTable[t])}function Pf(r){let e=r>>10;return Nr.uint32View[0]=Nr.mantissaTable[Nr.offsetTable[e]+(r&1023)]+Nr.exponentTable[e],Nr.floatView[0]}var $g=class{static toHalfFloat(e){return Dn(e)}static fromHalfFloat(e){return Pf(e)}},ls=new E,og=new q,D3=0,Xe=class extends Bs{constructor(e,t,s=!1){if(super(),Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:D3++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=s,this.usage=Uo,this.updateRanges=[],this.gpuType=Mt,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,s){e*=this.itemSize,s*=t.itemSize;for(let n=0,a=this.itemSize;n<a;n++)this.array[e+n]=t.array[s+n];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,s=this.count;t<s;t++)og.fromBufferAttribute(this,t),og.applyMatrix3(e),this.setXY(t,og.x,og.y);else if(this.itemSize===3)for(let t=0,s=this.count;t<s;t++)ls.fromBufferAttribute(this,t),ls.applyMatrix3(e),this.setXYZ(t,ls.x,ls.y,ls.z);return this}applyMatrix4(e){for(let t=0,s=this.count;t<s;t++)ls.fromBufferAttribute(this,t),ls.applyMatrix4(e),this.setXYZ(t,ls.x,ls.y,ls.z);return this}applyNormalMatrix(e){for(let t=0,s=this.count;t<s;t++)ls.fromBufferAttribute(this,t),ls.applyNormalMatrix(e),this.setXYZ(t,ls.x,ls.y,ls.z);return this}transformDirection(e){for(let t=0,s=this.count;t<s;t++)ls.fromBufferAttribute(this,t),ls.transformDirection(e),this.setXYZ(t,ls.x,ls.y,ls.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let s=this.array[e*this.itemSize+t];return this.normalized&&(s=Tn(s,this.array)),s}setComponent(e,t,s){return this.normalized&&(s=We(s,this.array)),this.array[e*this.itemSize+t]=s,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Tn(t,this.array)),t}setX(e,t){return this.normalized&&(t=We(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Tn(t,this.array)),t}setY(e,t){return this.normalized&&(t=We(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=Tn(t,this.array)),t}setZ(e,t){return this.normalized&&(t=We(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=Tn(t,this.array)),t}setW(e,t){return this.normalized&&(t=We(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,s){return e*=this.itemSize,this.normalized&&(t=We(t,this.array),s=We(s,this.array)),this.array[e+0]=t,this.array[e+1]=s,this}setXYZ(e,t,s,n){return e*=this.itemSize,this.normalized&&(t=We(t,this.array),s=We(s,this.array),n=We(n,this.array)),this.array[e+0]=t,this.array[e+1]=s,this.array[e+2]=n,this}setXYZW(e,t,s,n,a){return e*=this.itemSize,this.normalized&&(t=We(t,this.array),s=We(s,this.array),n=We(n,this.array),a=We(a,this.array)),this.array[e+0]=t,this.array[e+1]=s,this.array[e+2]=n,this.array[e+3]=a,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return e.name=this.name,e.usage=this.usage,e.gpuType=this.gpuType,e}dispose(){this.dispatchEvent({type:"dispose"})}},Yg=class extends Xe{constructor(e,t,s){super(new Int8Array(e),t,s)}},Zg=class extends Xe{constructor(e,t,s){super(new Uint8Array(e),t,s)}},Qg=class extends Xe{constructor(e,t,s){super(new Uint8ClampedArray(e),t,s)}},ey=class extends Xe{constructor(e,t,s){super(new Int16Array(e),t,s)}},qh=class extends Xe{constructor(e,t,s){super(new Uint16Array(e),t,s)}},ty=class extends Xe{constructor(e,t,s){super(new Int32Array(e),t,s)}},Xh=class extends Xe{constructor(e,t,s){super(new Uint32Array(e),t,s)}},Kh=class extends Xe{constructor(e,t,s){super(new Uint16Array(e),t,s),this.isFloat16BufferAttribute=!0}getX(e){let t=Pf(this.array[e*this.itemSize]);return this.normalized&&(t=Tn(t,this.array)),t}setX(e,t){return this.normalized&&(t=We(t,this.array)),this.array[e*this.itemSize]=Dn(t),this}getY(e){let t=Pf(this.array[e*this.itemSize+1]);return this.normalized&&(t=Tn(t,this.array)),t}setY(e,t){return this.normalized&&(t=We(t,this.array)),this.array[e*this.itemSize+1]=Dn(t),this}getZ(e){let t=Pf(this.array[e*this.itemSize+2]);return this.normalized&&(t=Tn(t,this.array)),t}setZ(e,t){return this.normalized&&(t=We(t,this.array)),this.array[e*this.itemSize+2]=Dn(t),this}getW(e){let t=Pf(this.array[e*this.itemSize+3]);return this.normalized&&(t=Tn(t,this.array)),t}setW(e,t){return this.normalized&&(t=We(t,this.array)),this.array[e*this.itemSize+3]=Dn(t),this}setXY(e,t,s){return e*=this.itemSize,this.normalized&&(t=We(t,this.array),s=We(s,this.array)),this.array[e+0]=Dn(t),this.array[e+1]=Dn(s),this}setXYZ(e,t,s,n){return e*=this.itemSize,this.normalized&&(t=We(t,this.array),s=We(s,this.array),n=We(n,this.array)),this.array[e+0]=Dn(t),this.array[e+1]=Dn(s),this.array[e+2]=Dn(n),this}setXYZW(e,t,s,n,a){return e*=this.itemSize,this.normalized&&(t=We(t,this.array),s=We(s,this.array),n=We(n,this.array),a=We(a,this.array)),this.array[e+0]=Dn(t),this.array[e+1]=Dn(s),this.array[e+2]=Dn(n),this.array[e+3]=Dn(a),this}},ge=class extends Xe{constructor(e,t,s){super(new Float32Array(e),t,s)}},O3=new ss,Mf=new E,e_=new E,jt=class{constructor(e=new E,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let s=this.center;t!==void 0?s.copy(t):O3.setFromPoints(e).getCenter(s);let n=0;for(let a=0,i=e.length;a<i;a++)n=Math.max(n,s.distanceToSquared(e[a]));return this.radius=Math.sqrt(n),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let s=this.center.distanceToSquared(e);return t.copy(e),s>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Mf.subVectors(e,this.center);let t=Mf.lengthSq();if(t>this.radius*this.radius){let s=Math.sqrt(t),n=(s-this.radius)*.5;this.center.addScaledVector(Mf,n/s),this.radius+=n}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(e_.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Mf.copy(e.center).add(e_)),this.expandByPoint(Mf.copy(e.center).sub(e_))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}},U3=0,Aa=new le,t_=new Ze,xh=new E,$n=new ss,Sf=new ss,ks=new E,ke=class r extends Bs{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:U3++}),this.uuid=Yn(),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(e){return Array.isArray(e)?this.index=new(o3(e)?Xh:qh)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,s=0){this.groups.push({start:e,count:t,materialIndex:s})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let s=this.attributes.normal;if(s!==void 0){let a=new Fs().getNormalMatrix(e);s.applyNormalMatrix(a),s.needsUpdate=!0}let n=this.attributes.tangent;return n!==void 0&&(n.transformDirection(e),n.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return Aa.makeRotationFromQuaternion(e),this.applyMatrix4(Aa),this}rotateX(e){return Aa.makeRotationX(e),this.applyMatrix4(Aa),this}rotateY(e){return Aa.makeRotationY(e),this.applyMatrix4(Aa),this}rotateZ(e){return Aa.makeRotationZ(e),this.applyMatrix4(Aa),this}translate(e,t,s){return Aa.makeTranslation(e,t,s),this.applyMatrix4(Aa),this}scale(e,t,s){return Aa.makeScale(e,t,s),this.applyMatrix4(Aa),this}lookAt(e){return t_.lookAt(e),t_.updateMatrix(),this.applyMatrix4(t_.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(xh).negate(),this.translate(xh.x,xh.y,xh.z),this}setFromPoints(e){let t=this.getAttribute("position");if(t===void 0){let s=[];for(let n=0,a=e.length;n<a;n++){let i=e[n];s.push(i.x,i.y,i.z||0)}this.setAttribute("position",new ge(s,3))}else{let s=Math.min(e.length,t.count);for(let n=0;n<s;n++){let a=e[n];t.setXYZ(n,a.x,a.y,a.z||0)}e.length>t.count&&K("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ss);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){W("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new E(-1/0,-1/0,-1/0),new E(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let s=0,n=t.length;s<n;s++){let a=t[s];$n.setFromBufferAttribute(a),this.morphTargetsRelative?(ks.addVectors(this.boundingBox.min,$n.min),this.boundingBox.expandByPoint(ks),ks.addVectors(this.boundingBox.max,$n.max),this.boundingBox.expandByPoint(ks)):(this.boundingBox.expandByPoint($n.min),this.boundingBox.expandByPoint($n.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&W('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new jt);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){W("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new E,1/0);return}if(e){let s=this.boundingSphere.center;if($n.setFromBufferAttribute(e),t)for(let a=0,i=t.length;a<i;a++){let o=t[a];Sf.setFromBufferAttribute(o),this.morphTargetsRelative?(ks.addVectors($n.min,Sf.min),$n.expandByPoint(ks),ks.addVectors($n.max,Sf.max),$n.expandByPoint(ks)):($n.expandByPoint(Sf.min),$n.expandByPoint(Sf.max))}$n.getCenter(s);let n=0;for(let a=0,i=e.count;a<i;a++)ks.fromBufferAttribute(e,a),n=Math.max(n,s.distanceToSquared(ks));if(t)for(let a=0,i=t.length;a<i;a++){let o=t[a],c=this.morphTargetsRelative;for(let l=0,h=o.count;l<h;l++)ks.fromBufferAttribute(o,l),c&&(xh.fromBufferAttribute(e,l),ks.add(xh)),n=Math.max(n,s.distanceToSquared(ks))}this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)&&W('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){W("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let s=t.position,n=t.normal,a=t.uv,i=this.getAttribute("tangent");(i===void 0||i.count!==s.count)&&(i=new Xe(new Float32Array(4*s.count),4),this.setAttribute("tangent",i));let o=[],c=[];for(let M=0;M<s.count;M++)o[M]=new E,c[M]=new E;let l=new E,h=new E,u=new E,d=new q,f=new q,p=new q,m=new E,b=new E;function g(M,N,R){l.fromBufferAttribute(s,M),h.fromBufferAttribute(s,N),u.fromBufferAttribute(s,R),d.fromBufferAttribute(a,M),f.fromBufferAttribute(a,N),p.fromBufferAttribute(a,R),h.sub(l),u.sub(l),f.sub(d),p.sub(d);let I=1/(f.x*p.y-p.x*f.y);isFinite(I)&&(m.copy(h).multiplyScalar(p.y).addScaledVector(u,-f.y).multiplyScalar(I),b.copy(u).multiplyScalar(f.x).addScaledVector(h,-p.x).multiplyScalar(I),o[M].add(m),o[N].add(m),o[R].add(m),c[M].add(b),c[N].add(b),c[R].add(b))}let x=this.groups;x.length===0&&(x=[{start:0,count:e.count}]);for(let M=0,N=x.length;M<N;++M){let R=x[M],I=R.start,D=R.count;for(let O=I,P=I+D;O<P;O+=3)g(e.getX(O+0),e.getX(O+1),e.getX(O+2))}let T=new E,y=new E,v=new E,_=new E;function A(M){v.fromBufferAttribute(n,M),_.copy(v);let N=o[M];T.copy(N),T.sub(v.multiplyScalar(v.dot(N))).normalize(),y.crossVectors(_,N);let I=y.dot(c[M])<0?-1:1;i.setXYZW(M,T.x,T.y,T.z,I)}for(let M=0,N=x.length;M<N;++M){let R=x[M],I=R.start,D=R.count;for(let O=I,P=I+D;O<P;O+=3)A(e.getX(O+0)),A(e.getX(O+1)),A(e.getX(O+2))}this._transformed=!0}computeVertexNormals(){let e=this.index,t=this.getAttribute("position");if(t!==void 0){let s=this.getAttribute("normal");if(s===void 0||s.count!==t.count)s=new Xe(new Float32Array(t.count*3),3),this.setAttribute("normal",s);else for(let d=0,f=s.count;d<f;d++)s.setXYZ(d,0,0,0);let n=new E,a=new E,i=new E,o=new E,c=new E,l=new E,h=new E,u=new E;if(e)for(let d=0,f=e.count;d<f;d+=3){let p=e.getX(d+0),m=e.getX(d+1),b=e.getX(d+2);n.fromBufferAttribute(t,p),a.fromBufferAttribute(t,m),i.fromBufferAttribute(t,b),h.subVectors(i,a),u.subVectors(n,a),h.cross(u),o.fromBufferAttribute(s,p),c.fromBufferAttribute(s,m),l.fromBufferAttribute(s,b),o.add(h),c.add(h),l.add(h),s.setXYZ(p,o.x,o.y,o.z),s.setXYZ(m,c.x,c.y,c.z),s.setXYZ(b,l.x,l.y,l.z)}else for(let d=0,f=t.count;d<f;d+=3)n.fromBufferAttribute(t,d+0),a.fromBufferAttribute(t,d+1),i.fromBufferAttribute(t,d+2),h.subVectors(i,a),u.subVectors(n,a),h.cross(u),s.setXYZ(d+0,h.x,h.y,h.z),s.setXYZ(d+1,h.x,h.y,h.z),s.setXYZ(d+2,h.x,h.y,h.z);this.normalizeNormals(),s.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,s=e.count;t<s;t++)ks.fromBufferAttribute(e,t),ks.normalize(),e.setXYZ(t,ks.x,ks.y,ks.z)}toNonIndexed(){function e(o,c){let l=o.array,h=o.itemSize,u=o.normalized,d=new l.constructor(c.length*h),f=0,p=0;for(let m=0,b=c.length;m<b;m++){o.isInterleavedBufferAttribute?f=c[m]*o.data.stride+o.offset:f=c[m]*h;for(let g=0;g<h;g++)d[p++]=l[f++]}return new Xe(d,h,u)}if(this.index===null)return K("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new r,s=this.index.array,n=this.attributes;for(let o in n){let c=n[o],l=e(c,s);t.setAttribute(o,l)}let a=this.morphAttributes;for(let o in a){let c=[],l=a[o];for(let h=0,u=l.length;h<u;h++){let d=l[h],f=e(d,s);c.push(f)}t.morphAttributes[o]=c}t.morphTargetsRelative=this.morphTargetsRelative;let i=this.groups;for(let o=0,c=i.length;o<c;o++){let l=i[o];t.addGroup(l.start,l.count,l.materialIndex)}return t}toJSON(){let e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,e.name=this.name,Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){let c=this.parameters;for(let l in c)c[l]!==void 0&&(e[l]=c[l]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let s=this.attributes;for(let c in s){let l=s[c];e.data.attributes[c]=l.toJSON(e.data)}let n={},a=!1;for(let c in this.morphAttributes){let l=this.morphAttributes[c],h=[];for(let u=0,d=l.length;u<d;u++){let f=l[u];h.push(f.toJSON(e.data))}h.length>0&&(n[c]=h,a=!0)}a&&(e.data.morphAttributes=n,e.data.morphTargetsRelative=this.morphTargetsRelative);let i=this.groups;i.length>0&&(e.data.groups=JSON.parse(JSON.stringify(i)));let o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let s=e.index;s!==null&&this.setIndex(s.clone());let n=e.attributes;for(let l in n){let h=n[l];this.setAttribute(l,h.clone(t))}let a=e.morphAttributes;for(let l in a){let h=[],u=a[l];for(let d=0,f=u.length;d<f;d++)h.push(u[d].clone(t));this.morphAttributes[l]=h}this.morphTargetsRelative=e.morphTargetsRelative;let i=e.groups;for(let l=0,h=i.length;l<h;l++){let u=i[l];this.addGroup(u.start,u.count,u.materialIndex)}let o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());let c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}},ri=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Uo,this.updateRanges=[],this.version=0,this.uuid=Yn()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,s){e*=this.stride,s*=t.stride;for(let n=0,a=this.stride;n<a;n++)this.array[e+n]=t.array[s+n];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Yn()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),s=new this.constructor(t,this.stride);return s.setUsage(this.usage),s}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Yn()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer)));let t={uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride};return t.usage=this.usage,t}},xn=new E,Ra=class r{constructor(e,t,s,n=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=s,this.normalized=n}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,s=this.data.count;t<s;t++)xn.fromBufferAttribute(this,t),xn.applyMatrix4(e),this.setXYZ(t,xn.x,xn.y,xn.z);return this}applyNormalMatrix(e){for(let t=0,s=this.count;t<s;t++)xn.fromBufferAttribute(this,t),xn.applyNormalMatrix(e),this.setXYZ(t,xn.x,xn.y,xn.z);return this}transformDirection(e){for(let t=0,s=this.count;t<s;t++)xn.fromBufferAttribute(this,t),xn.transformDirection(e),this.setXYZ(t,xn.x,xn.y,xn.z);return this}getComponent(e,t){let s=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(s=Tn(s,this.array)),s}setComponent(e,t,s){return this.normalized&&(s=We(s,this.array)),this.data.array[e*this.data.stride+this.offset+t]=s,this}setX(e,t){return this.normalized&&(t=We(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=We(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=We(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=We(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=Tn(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Tn(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Tn(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Tn(t,this.array)),t}setXY(e,t,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=We(t,this.array),s=We(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=s,this}setXYZ(e,t,s,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=We(t,this.array),s=We(s,this.array),n=We(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=s,this.data.array[e+2]=n,this}setXYZW(e,t,s,n,a){return e=e*this.data.stride+this.offset,this.normalized&&(t=We(t,this.array),s=We(s,this.array),n=We(n,this.array),a=We(a,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=s,this.data.array[e+2]=n,this.data.array[e+3]=a,this}clone(e){if(e===void 0){jf("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let s=0;s<this.count;s++){let n=s*this.data.stride+this.offset;for(let a=0;a<this.itemSize;a++)t.push(this.data.array[n+a])}return new Xe(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new r(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){jf("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let s=0;s<this.count;s++){let n=s*this.data.stride+this.offset;for(let a=0;a<this.itemSize;a++)t.push(this.data.array[n+a])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},s_=new E,L3=new E,z3=new Fs,wn=class{constructor(e=new E(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,s,n){return this.normal.set(e,t,s),this.constant=n,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,s){let n=s_.subVectors(s,t).cross(L3.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(n,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,s=!0){let n=e.delta(s_),a=this.normal.dot(n);if(a===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let i=-(e.start.dot(this.normal)+this.constant)/a;return s===!0&&(i<0||i>1)?null:t.copy(e.start).addScaledVector(n,i)}intersectsLine(e){let t=this.distanceToPoint(e.start),s=this.distanceToPoint(e.end);return t<0&&s>0||s<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let s=t||z3.getNormalMatrix(e),n=this.coplanarPoint(s_).applyMatrix4(e),a=this.normal.applyMatrix3(s).normalize();return this.constant=-n.dot(a),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}toJSON(){return{normal:this.normal.toArray(),constant:this.constant}}fromJSON(e){return this.normal.fromArray(e.normal),this.constant=e.constant,this}},V3=0,Rt=class extends Bs{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:V3++}),this.uuid=Yn(),this.name="",this.type="Material",this.blending=ta,this.side=ea,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=yu,this.blendDst=xu,this.blendEquation=sa,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new be(0,0,0),this.blendAlpha=0,this.depthFunc=Lc,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=yx,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=kh,this.stencilZFail=kh,this.stencilZPass=kh,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(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let s=e[t];if(s===void 0){K(`Material: parameter '${t}' has value of undefined.`);continue}let n=this[t];if(n===void 0){K(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}n&&n.isColor?n.set(s):n&&n.isVector2&&s&&s.isVector2||n&&n.isEuler&&s&&s.isEuler||n&&n.isVector3&&s&&s.isVector3?n.copy(s):this[t]=s}}toJSON(e){let t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});let s={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};s.uuid=this.uuid,s.type=this.type,s.blending=this.blending,s.side=this.side,s.shadowSide=this.shadowSide,s.vertexColors=this.vertexColors,s.opacity=this.opacity,s.transparent=this.transparent,s.blendSrc=this.blendSrc,s.blendDst=this.blendDst,s.blendEquation=this.blendEquation,s.blendSrcAlpha=this.blendSrcAlpha,s.blendDstAlpha=this.blendDstAlpha,s.blendEquationAlpha=this.blendEquationAlpha,s.blendColor=this.blendColor.getHex(),s.blendAlpha=this.blendAlpha,s.depthFunc=this.depthFunc,s.depthTest=this.depthTest,s.depthWrite=this.depthWrite,s.colorWrite=this.colorWrite,s.clipIntersection=this.clipIntersection,s.clipShadows=this.clipShadows,s.stencilWriteMask=this.stencilWriteMask,s.stencilFunc=this.stencilFunc,s.stencilRef=this.stencilRef,s.stencilFuncMask=this.stencilFuncMask,s.stencilFail=this.stencilFail,s.stencilZFail=this.stencilZFail,s.stencilZPass=this.stencilZPass,s.stencilWrite=this.stencilWrite,s.polygonOffset=this.polygonOffset,s.polygonOffsetFactor=this.polygonOffsetFactor,s.polygonOffsetUnits=this.polygonOffsetUnits,s.dithering=this.dithering,s.alphaTest=this.alphaTest,s.alphaHash=this.alphaHash,s.alphaToCoverage=this.alphaToCoverage,s.premultipliedAlpha=this.premultipliedAlpha,s.forceSinglePass=this.forceSinglePass,s.allowOverride=this.allowOverride,s.visible=this.visible,s.toneMapped=this.toneMapped,s.name=this.name,this.color&&this.color.isColor&&(s.color=this.color.getHex()),this.roughness!==void 0&&(s.roughness=this.roughness),this.metalness!==void 0&&(s.metalness=this.metalness),this.sheen!==void 0&&(s.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(s.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(s.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(s.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&(s.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(s.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(s.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(s.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(s.shininess=this.shininess),this.clearcoat!==void 0&&(s.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(s.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(s.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(s.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(s.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,s.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(s.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(s.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(s.dispersion=this.dispersion),this.retroreflectivity!==void 0&&(s.retroreflectivity=this.retroreflectivity),this.iridescence!==void 0&&(s.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(s.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(s.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(s.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(s.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(s.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(s.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(s.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(s.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(s.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(s.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(s.lightMap=this.lightMap.toJSON(e).uuid,s.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(s.aoMap=this.aoMap.toJSON(e).uuid,s.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(s.bumpMap=this.bumpMap.toJSON(e).uuid,s.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(s.normalMap=this.normalMap.toJSON(e).uuid,s.normalMapType=this.normalMapType,s.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(s.displacementMap=this.displacementMap.toJSON(e).uuid,s.displacementScale=this.displacementScale,s.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(s.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(s.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(s.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(s.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(s.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(s.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(s.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(s.combine=this.combine)),this.envMapRotation!==void 0&&(s.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(s.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(s.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(s.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(s.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(s.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(s.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(s.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(s.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&(s.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(s.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(s.size=this.size),this.sizeAttenuation!==void 0&&(s.sizeAttenuation=this.sizeAttenuation),Array.isArray(this.clippingPlanes)&&this.clippingPlanes.length>0&&(s.clippingPlanes=this.clippingPlanes.map(a=>a.toJSON())),this.rotation!==void 0&&(s.rotation=this.rotation),this.depthPacking!==void 0&&(s.depthPacking=this.depthPacking),this.linewidth!==void 0&&(s.linewidth=this.linewidth),this.linecap!==void 0&&(s.linecap=this.linecap),this.linejoin!==void 0&&(s.linejoin=this.linejoin),this.dashSize!==void 0&&(s.dashSize=this.dashSize),this.gapSize!==void 0&&(s.gapSize=this.gapSize),this.scale!==void 0&&(s.scale=this.scale),this.wireframe!==void 0&&(s.wireframe=this.wireframe),this.wireframeLinewidth!==void 0&&(s.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!==void 0&&(s.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!==void 0&&(s.wireframeLinejoin=this.wireframeLinejoin),this.flatShading!==void 0&&(s.flatShading=this.flatShading),this.fog!==void 0&&(s.fog=this.fog),Object.keys(this.userData).length>0&&(s.userData=this.userData);function n(a){let i=[];for(let o in a){let c=a[o];delete c.metadata,i.push(c)}return i}if(t){let a=n(e.textures),i=n(e.images);a.length>0&&(s.textures=a),i.length>0&&(s.images=i)}return s}fromJSON(e,t){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new be().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.retroreflectivity!==void 0&&(this.retroreflectivity=e.retroreflectivity),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.clippingPlanes!==void 0&&(this.clippingPlanes=e.clippingPlanes.map(s=>new wn().fromJSON(s))),e.clipIntersection!==void 0&&(this.clipIntersection=e.clipIntersection),e.clipShadows!==void 0&&(this.clipShadows=e.clipShadows),e.depthPacking!==void 0&&(this.depthPacking=e.depthPacking),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.linecap!==void 0&&(this.linecap=e.linecap),e.linejoin!==void 0&&(this.linejoin=e.linejoin),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?this.vertexColors=e.vertexColors>0:this.vertexColors=e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=t[e.map]||null),e.matcap!==void 0&&(this.matcap=t[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=t[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=t[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=t[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let s=e.normalScale;Array.isArray(s)===!1&&(s=[s,s]),this.normalScale=new q().fromArray(s)}return e.displacementMap!==void 0&&(this.displacementMap=t[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=t[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=t[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=t[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=t[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=t[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=t[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=t[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=t[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=t[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=t[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=t[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new q().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(this.iridescenceMap=t[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=t[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=t[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=t[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=t[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,s=null;if(t!==null){let n=t.length;s=new Array(n);for(let a=0;a!==n;++a)s[a]=t[a].clone()}return this.clippingPlanes=s,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}},Vc=class extends Rt{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new be(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}},wh,Nf=new E,Th=new E,vh=new E,_h=new q,Rf=new q,IC=new le,cg=new E,Ef=new E,lg=new E,u8=new q,n_=new q,d8=new q,Xf=class extends Ze{constructor(e=new Vc){if(super(),this.isSprite=!0,this.type="Sprite",wh===void 0){wh=new ke;let t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),s=new ri(t,5);wh.setIndex([0,1,2,0,2,3]),wh.setAttribute("position",new Ra(s,3,0,!1)),wh.setAttribute("uv",new Ra(s,2,3,!1))}this.geometry=wh,this.material=e,this.center=new q(.5,.5),this.count=1}intersectsFrustum(e){return e.intersectsSprite(this)}raycast(e,t){e.camera===null&&W('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Th.setFromMatrixScale(this.matrixWorld),IC.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),vh.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Th.multiplyScalar(-vh.z);let s=this.material.rotation,n,a;s!==0&&(a=Math.cos(s),n=Math.sin(s));let i=this.center;hg(cg.set(-.5,-.5,0),vh,i,Th,n,a),hg(Ef.set(.5,-.5,0),vh,i,Th,n,a),hg(lg.set(.5,.5,0),vh,i,Th,n,a),u8.set(0,0),n_.set(1,0),d8.set(1,1);let o=e.ray.intersectTriangle(cg,Ef,lg,!1,Nf);if(o===null&&(hg(Ef.set(-.5,.5,0),vh,i,Th,n,a),n_.set(0,1),o=e.ray.intersectTriangle(cg,lg,Ef,!1,Nf),o===null))return;let c=e.ray.origin.distanceTo(Nf);c<e.near||c>e.far||t.push({distance:c,point:Nf.clone(),uv:si.getInterpolation(Nf,cg,Ef,lg,u8,n_,d8,new q),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}};function hg(r,e,t,s,n,a){_h.subVectors(r,t).addScalar(.5).multiply(s),n!==void 0?(Rf.x=a*_h.x-n*_h.y,Rf.y=n*_h.x+a*_h.y):Rf.copy(_h),r.copy(e),r.x+=Rf.x,r.y+=Rf.y,r.applyMatrix4(IC)}var ug=new E,f8=new E,Kf=class extends Ze{constructor(){super(),this.isLOD=!0,this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);let t=e.levels;for(let s=0,n=t.length;s<n;s++){let a=t[s];this.addLevel(a.object.clone(),a.distance,a.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,s=0){t=Math.abs(t);let n=this.levels,a;for(a=0;a<n.length&&!(t<n[a].distance);a++);return n.splice(a,0,{distance:t,hysteresis:s,object:e}),this.add(e),this}removeLevel(e){let t=this.levels;for(let s=0;s<t.length;s++)if(t[s].distance===e){let n=t.splice(s,1);return this.remove(n[0].object),!0}return!1}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){let t=this.levels;if(t.length>0){let s,n;for(s=1,n=t.length;s<n;s++){let a=t[s].distance;if(t[s].object.visible&&(a-=a*t[s].hysteresis),e<a)break}return t[s-1].object}return null}raycast(e,t){if(this.levels.length>0){ug.setFromMatrixPosition(this.matrixWorld);let n=e.ray.origin.distanceTo(ug);this.getObjectForDistance(n).raycast(e,t)}}update(e){let t=this.levels;if(t.length>1){ug.setFromMatrixPosition(e.matrixWorld),f8.setFromMatrixPosition(this.matrixWorld);let s=ug.distanceTo(f8)/e.zoom;t[0].object.visible=!0;let n,a;for(n=1,a=t.length;n<a;n++){let i=t[n].distance;if(t[n].object.visible&&(i-=i*t[n].hysteresis),s>=i)t[n-1].object.visible=!1,t[n].object.visible=!0;else break}for(this._currentLevel=n-1;n<a;n++)t[n].object.visible=!1}}toJSON(e){let t=super.toJSON(e);t.object.autoUpdate=this.autoUpdate,t.object.levels=[];let s=this.levels;for(let n=0,a=s.length;n<a;n++){let i=s[n];t.object.levels.push({object:i.object.uuid,distance:i.distance,hysteresis:i.hysteresis})}return t}},Mr=new E,a_=new E,dg=new E,fg=new E,oi=class{constructor(e=new E,t=new E(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Mr)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let s=t.dot(this.direction);return s<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,s)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=Mr.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Mr.copy(this.origin).addScaledVector(this.direction,t),Mr.distanceToSquared(e))}distanceSqToSegment(e,t,s,n){a_.copy(e).add(t).multiplyScalar(.5),dg.copy(t).sub(e).normalize(),fg.copy(this.origin).sub(a_);let a=e.distanceTo(t)*.5,i=-this.direction.dot(dg),o=fg.dot(this.direction),c=-fg.dot(dg),l=fg.lengthSq(),h=Math.abs(1-i*i),u,d,f,p;if(h>0)if(u=i*c-o,d=i*o-c,p=a*h,u>=0)if(d>=-p)if(d<=p){let m=1/h;u*=m,d*=m,f=u*(u+i*d+2*o)+d*(i*u+d+2*c)+l}else d=a,u=Math.max(0,-(i*d+o)),f=-u*u+d*(d+2*c)+l;else d=-a,u=Math.max(0,-(i*d+o)),f=-u*u+d*(d+2*c)+l;else d<=-p?(u=Math.max(0,-(-i*a+o)),d=u>0?-a:Math.min(Math.max(-a,-c),a),f=-u*u+d*(d+2*c)+l):d<=p?(u=0,d=Math.min(Math.max(-a,-c),a),f=d*(d+2*c)+l):(u=Math.max(0,-(i*a+o)),d=u>0?a:Math.min(Math.max(-a,-c),a),f=-u*u+d*(d+2*c)+l);else d=i>0?-a:a,u=Math.max(0,-(i*d+o)),f=-u*u+d*(d+2*c)+l;return s&&s.copy(this.origin).addScaledVector(this.direction,u),n&&n.copy(a_).addScaledVector(dg,d),f}intersectSphere(e,t){if(e.radius<0)return null;Mr.subVectors(e.center,this.origin);let s=Mr.dot(this.direction),n=Mr.dot(Mr)-s*s,a=e.radius*e.radius;if(n>a)return null;let i=Math.sqrt(a-n),o=s-i,c=s+i;return c<0?null:o<0?this.at(c,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let s=-(this.origin.dot(e.normal)+e.constant)/t;return s>=0?s:null}intersectPlane(e,t){let s=this.distanceToPlane(e);return s===null?null:this.at(s,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let s,n,a,i,o,c,l=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,d=this.origin;return l>=0?(s=(e.min.x-d.x)*l,n=(e.max.x-d.x)*l):(s=(e.max.x-d.x)*l,n=(e.min.x-d.x)*l),h>=0?(a=(e.min.y-d.y)*h,i=(e.max.y-d.y)*h):(a=(e.max.y-d.y)*h,i=(e.min.y-d.y)*h),s>i||a>n||((a>s||isNaN(s))&&(s=a),(i<n||isNaN(n))&&(n=i),u>=0?(o=(e.min.z-d.z)*u,c=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,c=(e.min.z-d.z)*u),s>c||o>n)||((o>s||s!==s)&&(s=o),(c<n||n!==n)&&(n=c),n<0)?null:this.at(s>=0?s:n,t)}intersectsBox(e){return this.intersectBox(e,Mr)!==null}intersectTriangle(e,t,s,n,a){let i=this.origin,o=this.direction,c=o.x,l=o.y,h=o.z,u=e.x-i.x,d=e.y-i.y,f=e.z-i.z,p=t.x-i.x,m=t.y-i.y,b=t.z-i.z,g=s.x-i.x,x=s.y-i.y,T=s.z-i.z,y=Math.abs(c),v=Math.abs(l),_=Math.abs(h),A,M,N,R,I,D,O,P,U,j,z,H;if(y>=v&&y>=_?(N=c,D=u,U=p,H=g,c>=0?(A=l,M=h,R=d,I=f,O=m,P=b,j=x,z=T):(A=h,M=l,R=f,I=d,O=b,P=m,j=T,z=x)):v>=_?(N=l,D=d,U=m,H=x,l>=0?(A=h,M=c,R=f,I=u,O=b,P=p,j=T,z=g):(A=c,M=h,R=u,I=f,O=p,P=b,j=g,z=T)):(N=h,D=f,U=b,H=T,h>=0?(A=c,M=l,R=u,I=d,O=p,P=m,j=g,z=x):(A=l,M=c,R=d,I=u,O=m,P=p,j=x,z=g)),N===0)return null;let J=A/N,ee=M/N,se=1/N,_e=R-J*D,Ae=I-ee*D,Se=O-J*U,Fe=P-ee*U,ft=j-J*H,te=z-ee*H,re=ft*Fe-te*Se,Q=_e*te-Ae*ft,Ee=Se*Ae-Fe*_e;if(n){if(re<0||Q<0||Ee<0)return null}else if((re<0||Q<0||Ee<0)&&(re>0||Q>0||Ee>0))return null;let Oe=re+Q+Ee;if(Oe===0)return null;let Ce=se*(re*D+Q*U+Ee*H);return(Oe>0?Ce<0:Ce>0)?null:this.at(Ce/Oe,a)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},Bt=class extends Rt{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new be(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 Na,this.combine=wu,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},p8=new le,Rc=new oi,pg=new jt,m8=new E,mg=new E,bg=new E,gg=new E,i_=new E,yg=new E,b8=new E,xg=new E,at=class extends Ze{constructor(e=new ke,t=new Bt){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let t=this.geometry.morphAttributes,s=Object.keys(t);if(s.length>0){let n=t[s[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,i=n.length;a<i;a++){let o=n[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=a}}}}getVertexPosition(e,t){let s=this.geometry,n=s.attributes.position,a=s.morphAttributes.position,i=s.morphTargetsRelative;t.fromBufferAttribute(n,e);let o=this.morphTargetInfluences;if(a&&o){yg.set(0,0,0);for(let c=0,l=a.length;c<l;c++){let h=o[c],u=a[c];h!==0&&(i_.fromBufferAttribute(u,e),i?yg.addScaledVector(i_,h):yg.addScaledVector(i_.sub(t),h))}t.add(yg)}return t}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let s=this.geometry,n=this.material,a=this.matrixWorld;n!==void 0&&(s.boundingSphere===null&&s.computeBoundingSphere(),pg.copy(s.boundingSphere),pg.applyMatrix4(a),Rc.copy(e.ray).recast(e.near),!(pg.containsPoint(Rc.origin)===!1&&(Rc.intersectSphere(pg,m8)===null||Rc.origin.distanceToSquared(m8)>(e.far-e.near)**2))&&(p8.copy(a).invert(),Rc.copy(e.ray).applyMatrix4(p8),!(s.boundingBox!==null&&Rc.intersectsBox(s.boundingBox)===!1)&&this._computeIntersections(e,t,Rc)))}_computeIntersections(e,t,s){let n,a=this.geometry,i=this.material,o=a.index,c=a.attributes.position,l=a.attributes.uv,h=a.attributes.uv1,u=a.attributes.normal,d=a.groups,f=a.drawRange;if(o!==null)if(Array.isArray(i))for(let p=0,m=d.length;p<m;p++){let b=d[p],g=i[b.materialIndex],x=Math.max(b.start,f.start),T=Math.min(o.count,Math.min(b.start+b.count,f.start+f.count));for(let y=x,v=T;y<v;y+=3){let _=o.getX(y),A=o.getX(y+1),M=o.getX(y+2);n=wg(this,g,e,s,l,h,u,_,A,M),n&&(n.faceIndex=Math.floor(y/3),n.face.materialIndex=b.materialIndex,t.push(n))}}else{let p=Math.max(0,f.start),m=Math.min(o.count,f.start+f.count);for(let b=p,g=m;b<g;b+=3){let x=o.getX(b),T=o.getX(b+1),y=o.getX(b+2);n=wg(this,i,e,s,l,h,u,x,T,y),n&&(n.faceIndex=Math.floor(b/3),t.push(n))}}else if(c!==void 0)if(Array.isArray(i))for(let p=0,m=d.length;p<m;p++){let b=d[p],g=i[b.materialIndex],x=Math.max(b.start,f.start),T=Math.min(c.count,Math.min(b.start+b.count,f.start+f.count));for(let y=x,v=T;y<v;y+=3){let _=y,A=y+1,M=y+2;n=wg(this,g,e,s,l,h,u,_,A,M),n&&(n.faceIndex=Math.floor(y/3),n.face.materialIndex=b.materialIndex,t.push(n))}}else{let p=Math.max(0,f.start),m=Math.min(c.count,f.start+f.count);for(let b=p,g=m;b<g;b+=3){let x=b,T=b+1,y=b+2;n=wg(this,i,e,s,l,h,u,x,T,y),n&&(n.faceIndex=Math.floor(b/3),t.push(n))}}}};function j3(r,e,t,s,n,a,i,o){let c;if(e.side===Xt?c=s.intersectTriangle(i,a,n,!0,o):c=s.intersectTriangle(n,a,i,e.side===ea,o),c===null)return null;xg.copy(o),xg.applyMatrix4(r.matrixWorld);let l=t.ray.origin.distanceTo(xg);return l<t.near||l>t.far?null:{distance:l,point:xg.clone(),object:r}}function wg(r,e,t,s,n,a,i,o,c,l){r.getVertexPosition(o,mg),r.getVertexPosition(c,bg),r.getVertexPosition(l,gg);let h=j3(r,e,t,s,mg,bg,gg,b8);if(h){let u=new E;si.getBarycoord(b8,mg,bg,gg,u),n&&(h.uv=si.getInterpolatedAttribute(n,o,c,l,u,new q)),a&&(h.uv1=si.getInterpolatedAttribute(a,o,c,l,u,new q)),i&&(h.normal=si.getInterpolatedAttribute(i,o,c,l,u,new E),h.normal.dot(s.direction)>0&&h.normal.multiplyScalar(-1));let d={a:o,b:c,c:l,normal:new E,materialIndex:0};si.getNormal(mg,bg,gg,d.normal),h.face=d,h.barycoord=u}return h}var Cf=new Ge,g8=new Ge,y8=new Ge,G3=new Ge,x8=new le,Tg=new E,r_=new jt,w8=new le,o_=new oi,jc=class extends at{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=Hg,this.bindMatrix=new le,this.bindMatrixInverse=new le,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;this.boundingBox===null&&(this.boundingBox=new ss),this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let s=0;s<t.count;s++)this.getVertexPosition(s,Tg),this.boundingBox.expandByPoint(Tg)}computeBoundingSphere(){let e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new jt),this.boundingSphere.makeEmpty();let t=e.getAttribute("position");for(let s=0;s<t.count;s++)this.getVertexPosition(s,Tg),this.boundingSphere.expandByPoint(Tg)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){let s=this.material,n=this.matrixWorld;s!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),r_.copy(this.boundingSphere),r_.applyMatrix4(n),e.ray.intersectsSphere(r_)!==!1&&(w8.copy(n).invert(),o_.copy(e.ray).applyMatrix4(w8),!(this.boundingBox!==null&&o_.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,o_)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){let e=new Ge,t=this.geometry.attributes.skinWeight;for(let s=0,n=t.count;s<n;s++){e.fromBufferAttribute(t,s);let a=1/e.manhattanLength();a!==1/0?e.multiplyScalar(a):e.set(1,0,0,0),t.setXYZW(s,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===Hg?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===z_?this.bindMatrixInverse.copy(this.bindMatrix).invert():K("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){let s=this.skeleton,n=this.geometry;g8.fromBufferAttribute(n.attributes.skinIndex,e),y8.fromBufferAttribute(n.attributes.skinWeight,e),t.isVector4?(Cf.copy(t),t.set(0,0,0,0)):(Cf.set(...t,1),t.set(0,0,0)),Cf.applyMatrix4(this.bindMatrix);for(let a=0;a<4;a++){let i=y8.getComponent(a);if(i!==0){let o=g8.getComponent(a);x8.multiplyMatrices(s.bones[o].matrixWorld,s.boneInverses[o]),t.addScaledVector(G3.copy(Cf).applyMatrix4(x8),i)}}return t.isVector4&&(t.w=Cf.w),t.applyMatrix4(this.bindMatrixInverse)}},_o=class extends Ze{constructor(){super(),this.isBone=!0,this.type="Bone"}},Is=class extends gt{constructor(e=null,t=1,s=1,n,a,i,o,c,l=pt,h=pt,u,d){super(null,i,o,c,l,h,n,a,u,d),this.isDataTexture=!0,this.image={data:e,width:t,height:s},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},T8=new le,H3=new le,Gc=class r{constructor(e=[],t=[]){this.uuid=Yn(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){K("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let s=0,n=this.bones.length;s<n;s++)this.boneInverses.push(new le)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let s=new le;this.bones[e]&&s.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(s)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let s=this.bones[e];s&&s.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let s=this.bones[e];s&&(s.parent&&s.parent.isBone?(s.matrix.copy(s.parent.matrixWorld).invert(),s.matrix.multiply(s.matrixWorld)):s.matrix.copy(s.matrixWorld),s.matrix.decompose(s.position,s.quaternion,s.scale))}}update(){let e=this.bones,t=this.boneInverses,s=this.boneMatrices,n=this.boneTexture;for(let a=0,i=e.length;a<i;a++){let o=e[a]?e[a].matrixWorld:H3;T8.multiplyMatrices(o,t[a]),T8.toArray(s,a*16)}n!==null&&(n.needsUpdate=!0)}clone(){return new r(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let s=new Is(t,e,e,gs,Mt);return s.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=s,this}getBoneByName(e){for(let t=0,s=this.bones.length;t<s;t++){let n=this.bones[t];if(n.name===e)return n}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let s=0,n=e.bones.length;s<n;s++){let a=e.bones[s],i=t[a];i===void 0&&(K("Skeleton: No bone found with UUID:",a),i=new _o),this.bones.push(i),this.boneInverses.push(new le().fromArray(e.boneInverses[s]))}return this.init(),this}toJSON(){let e={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,s=this.boneInverses;for(let n=0,a=t.length;n<a;n++){let i=t[n];e.bones.push(i.uuid);let o=s[n];e.boneInverses.push(o.toArray())}return e}},ys=class extends Xe{constructor(e,t,s,n=1){super(e,t,s),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}},Ah=new le,v8=new le,vg=[],_8=new ss,W3=new le,kf=new at,If=new jt,Er=class extends at{constructor(e,t,s){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new ys(new Float32Array(s*16),16),this.instanceColor=null,this.morphTexture=null,this.count=s,this.boundingBox=null,this.boundingSphere=null;for(let n=0;n<s;n++)this.setMatrixAt(n,W3)}computeBoundingBox(){let e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new ss),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let s=0;s<t;s++)this.getMatrixAt(s,Ah),_8.copy(e.boundingBox).applyMatrix4(Ah),this.boundingBox.union(_8)}computeBoundingSphere(){let e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new jt),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let s=0;s<t;s++)this.getMatrixAt(s,Ah),If.copy(e.boundingSphere).applyMatrix4(Ah),this.boundingSphere.union(If)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){return this.instanceColor===null?t.setRGB(1,1,1):t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){return t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){let s=t.morphTargetInfluences,n=this.morphTexture.source.data.data,a=s.length+1,i=e*a+1;for(let o=0;o<s.length;o++)s[o]=n[i+o]}raycast(e,t){let s=this.matrixWorld,n=this.count;if(kf.geometry=this.geometry,kf.material=this.material,kf.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),If.copy(this.boundingSphere),If.applyMatrix4(s),e.ray.intersectsSphere(If)!==!1))for(let a=0;a<n;a++){this.getMatrixAt(a,Ah),v8.multiplyMatrices(s,Ah),kf.matrixWorld=v8,kf.raycast(e,vg);for(let i=0,o=vg.length;i<o;i++){let c=vg[i];c.instanceId=a,c.object=this,t.push(c)}vg.length=0}}setColorAt(e,t){return this.instanceColor===null&&(this.instanceColor=new ys(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3),this}setMatrixAt(e,t){return t.toArray(this.instanceMatrix.array,e*16),this}setMorphAt(e,t){let s=t.morphTargetInfluences,n=s.length+1;this.morphTexture===null&&(this.morphTexture=new Is(new Float32Array(n*this.count),n,this.count,Lr,Mt));let a=this.morphTexture.source.data.data,i=0;for(let l=0;l<s.length;l++)i+=s[l];let o=this.geometry.morphTargetsRelative?1:1-i,c=n*e;return a[c]=o,a.set(s,c+1),this}updateMorphTargets(){}dispose(){super.dispose(),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}},Ec=new jt,q3=new q(.5,.5),_g=new E,ci=class{constructor(e=new wn,t=new wn,s=new wn,n=new wn,a=new wn,i=new wn){this.planes=[e,t,s,n,a,i]}set(e,t,s,n,a,i){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(s),o[3].copy(n),o[4].copy(a),o[5].copy(i),this}copy(e){let t=this.planes;for(let s=0;s<6;s++)t[s].copy(e.planes[s]);return this}setFromProjectionMatrix(e,t=sn,s=!1){let n=this.planes,a=e.elements,i=a[0],o=a[1],c=a[2],l=a[3],h=a[4],u=a[5],d=a[6],f=a[7],p=a[8],m=a[9],b=a[10],g=a[11],x=a[12],T=a[13],y=a[14],v=a[15];if(n[0].setComponents(l-i,f-h,g-p,v-x).normalize(),n[1].setComponents(l+i,f+h,g+p,v+x).normalize(),n[2].setComponents(l+o,f+u,g+m,v+T).normalize(),n[3].setComponents(l-o,f-u,g-m,v-T).normalize(),s)n[4].setComponents(c,d,b,y).normalize(),n[5].setComponents(l-c,f-d,g-b,v-y).normalize();else if(n[4].setComponents(l-c,f-d,g-b,v-y).normalize(),t===sn)n[5].setComponents(l+c,f+d,g+b,v+y).normalize();else if(t===Xs)n[5].setComponents(c,d,b,y).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Ec.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Ec.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Ec)}intersectsSprite(e){Ec.center.set(0,0,0);let t=q3.distanceTo(e.center);return Ec.radius=.7071067811865476+t,Ec.applyMatrix4(e.matrixWorld),this.intersectsSphere(Ec)}intersectsSphere(e){let t=this.planes,s=e.center,n=-e.radius;for(let a=0;a<6;a++)if(t[a].distanceToPoint(s)<n)return!1;return!0}intersectsBox(e){let t=this.planes;for(let s=0;s<6;s++){let n=t[s];if(_g.x=n.normal.x>0?e.max.x:e.min.x,_g.y=n.normal.y>0?e.max.y:e.min.y,_g.z=n.normal.z>0?e.max.z:e.min.z,n.distanceToPoint(_g)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let s=0;s<6;s++)if(t[s].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}},A8=new le,Jh=class r{constructor(){this.coordinateSystem=sn,this._frustums=[],this._count=0}setFromArrayCamera(e){let t=e.cameras,s=this._frustums;for(let n=0;n<t.length;n++){let a=t[n];A8.multiplyMatrices(a.projectionMatrix,a.matrixWorldInverse),s[n]===void 0&&(s[n]=new ci),s[n].setFromProjectionMatrix(A8,a.coordinateSystem,a.reversedDepth)}return this._count=t.length,this}intersectsObject(e){let t=this._frustums;for(let s=0;s<this._count;s++)if(t[s].intersectsObject(e))return!0;return!1}intersectsSprite(e){let t=this._frustums;for(let s=0;s<this._count;s++)if(t[s].intersectsSprite(e))return!0;return!1}intersectsSphere(e){let t=this._frustums;for(let s=0;s<this._count;s++)if(t[s].intersectsSphere(e))return!0;return!1}intersectsBox(e){let t=this._frustums;for(let s=0;s<this._count;s++)if(t[s].intersectsBox(e))return!0;return!1}containsPoint(e){let t=this._frustums;for(let s=0;s<this._count;s++)if(t[s].containsPoint(e))return!0;return!1}copy(e){this.coordinateSystem=e.coordinateSystem;let t=this._frustums,s=e._frustums;for(let n=0;n<e._count;n++)t[n]===void 0&&(t[n]=new ci),t[n].copy(s[n]);return this._count=e._count,this}clone(){return new r().copy(this)}};function c_(r,e){return r-e}function X3(r,e){return r.z-e.z}function K3(r,e){return e.z-r.z}var v_=class{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t,s,n){let a=this.pool,i=this.list;this.index>=a.length&&a.push({start:-1,count:-1,z:-1,index:-1});let o=a[this.index];i.push(o),this.index++,o.start=e,o.count=t,o.z=s,o.index=n}reset(){this.list.length=0,this.index=0}},Pn=new le,J3=new be(1,1,1),$3=new ci,Y3=new Jh,Ag=new ss,Cc=new jt,Bf=new E,M8=new E,Z3=new E,l_=new v_,tn=new at,Mg=[];function Q3(r,e,t=0){let s=e.itemSize;if(r.isInterleavedBufferAttribute||r.array.constructor!==e.array.constructor){let n=r.count;for(let a=0;a<n;a++)for(let i=0;i<s;i++)e.setComponent(a+t,i,r.getComponent(a,i))}else e.array.set(r.array,t*s);e.needsUpdate=!0}function kc(r,e){if(r.constructor!==e.constructor){let t=Math.min(r.length,e.length);for(let s=0;s<t;s++)e[s]=r[s]}else{let t=Math.min(r.length,e.length);e.set(new r.constructor(r.buffer,0,t))}}var Jf=class extends at{constructor(e,t,s=t*2,n){super(new ke,n),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._instanceInfo=[],this._geometryInfo=[],this._availableInstanceIds=[],this._availableGeometryIds=[],this._nextIndexStart=0,this._nextVertexStart=0,this._geometryCount=0,this._visibilityChanged=!0,this._geometryInitialized=!1,this._maxInstanceCount=e,this._maxVertexCount=t,this._maxIndexCount=s,this._multiDrawCounts=new Int32Array(e),this._multiDrawStarts=new Int32Array(e),this._multiDrawCount=0,this._multiDrawBytesPerElement=1,this._matricesTexture=null,this._indirectTexture=null,this._colorsTexture=null,this._initMatricesTexture(),this._initIndirectTexture()}get maxInstanceCount(){return this._maxInstanceCount}get instanceCount(){return this._instanceInfo.length-this._availableInstanceIds.length}get unusedVertexCount(){return this._maxVertexCount-this._nextVertexStart}get unusedIndexCount(){return this._maxIndexCount-this._nextIndexStart}_initMatricesTexture(){let e=Math.sqrt(this._maxInstanceCount*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);let t=new Float32Array(e*e*4),s=new Is(t,e,e,gs,Mt);this._matricesTexture=s}_initIndirectTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);let t=new Uint32Array(e*e),s=new Is(t,e,e,zr,St);this._indirectTexture=s}_initColorsTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);let t=new Float32Array(e*e*4).fill(1),s=new Is(t,e,e,gs,Mt);s.colorSpace=qe.workingColorSpace,this._colorsTexture=s}_initializeGeometry(e){let t=this.geometry,s=this._maxVertexCount,n=this._maxIndexCount;if(this._geometryInitialized===!1){for(let a in e.attributes){let i=e.getAttribute(a),{array:o,itemSize:c,normalized:l}=i,h=new o.constructor(s*c),u=new Xe(h,c,l);t.setAttribute(a,u)}if(e.getIndex()!==null){let a=s>65535?new Uint32Array(n):new Uint16Array(n);t.setIndex(new Xe(a,1))}this._geometryInitialized=!0}}_validateGeometry(e){let t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(let s in t.attributes){if(!e.hasAttribute(s))throw new Error(`THREE.BatchedMesh: Added geometry missing "${s}". All geometries must have consistent attributes.`);let n=e.getAttribute(s),a=t.getAttribute(s);if(n.itemSize!==a.itemSize||n.normalized!==a.normalized)throw new Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}validateInstanceId(e){let t=this._instanceInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid instanceId ${e}. Instance is either out of range or has been deleted.`)}validateGeometryId(e){let t=this._geometryInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid geometryId ${e}. Geometry is either out of range or has been deleted.`)}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ss);let e=this.boundingBox,t=this._instanceInfo;e.makeEmpty();for(let s=0,n=t.length;s<n;s++){if(t[s].active===!1)continue;let a=t[s].geometryIndex;this.getMatrixAt(s,Pn),this.getBoundingBoxAt(a,Ag).applyMatrix4(Pn),e.union(Ag)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new jt);let e=this.boundingSphere,t=this._instanceInfo;e.makeEmpty();for(let s=0,n=t.length;s<n;s++){if(t[s].active===!1)continue;let a=t[s].geometryIndex;this.getMatrixAt(s,Pn),this.getBoundingSphereAt(a,Cc).applyMatrix4(Pn),e.union(Cc)}}addInstance(e){if(this._instanceInfo.length>=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw new Error("THREE.BatchedMesh: Maximum item count reached.");let s={visible:!0,active:!0,geometryIndex:e},n=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(c_),n=this._availableInstanceIds.shift(),this._instanceInfo[n]=s):(n=this._instanceInfo.length,this._instanceInfo.push(s));let a=this._matricesTexture;Pn.identity().toArray(a.image.data,n*16),a.needsUpdate=!0;let i=this._colorsTexture;return i&&(J3.toArray(i.image.data,n*4),i.needsUpdate=!0),this._visibilityChanged=!0,n}addGeometry(e,t=-1,s=-1){this._initializeGeometry(e),this._validateGeometry(e);let n={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},a=this._geometryInfo;n.vertexStart=this._nextVertexStart,n.reservedVertexCount=t===-1?e.getAttribute("position").count:t;let i=e.getIndex();if(i!==null&&(n.indexStart=this._nextIndexStart,n.reservedIndexCount=s===-1?i.count:s),n.indexStart!==-1&&n.indexStart+n.reservedIndexCount>this._maxIndexCount||n.vertexStart+n.reservedVertexCount>this._maxVertexCount)throw new Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");let c;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(c_),c=this._availableGeometryIds.shift(),a[c]=n):(c=this._geometryCount,this._geometryCount++,a.push(n)),this.setGeometryAt(c,e),this._nextIndexStart=n.indexStart+n.reservedIndexCount,this._nextVertexStart=n.vertexStart+n.reservedVertexCount,c}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);let s=this.geometry,n=s.getIndex()!==null,a=s.getIndex(),i=t.getIndex(),o=this._geometryInfo[e];if(n&&i.count>o.reservedIndexCount||t.attributes.position.count>o.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");let c=o.vertexStart,l=o.reservedVertexCount;o.vertexCount=t.getAttribute("position").count;for(let h in s.attributes){let u=t.getAttribute(h),d=s.getAttribute(h);Q3(u,d,c);let f=u.itemSize;for(let p=u.count,m=l;p<m;p++){let b=c+p;for(let g=0;g<f;g++)d.setComponent(b,g,0)}d.needsUpdate=!0,d.addUpdateRange(c*f,l*f)}if(n){let h=o.indexStart,u=o.reservedIndexCount;o.indexCount=t.getIndex().count;for(let d=0;d<i.count;d++)a.setX(h+d,c+i.getX(d));for(let d=i.count,f=u;d<f;d++)a.setX(h+d,c);a.needsUpdate=!0,a.addUpdateRange(h,o.reservedIndexCount)}return o.start=n?o.indexStart:o.vertexStart,o.count=n?o.indexCount:o.vertexCount,o.boundingBox=null,t.boundingBox!==null&&(o.boundingBox=t.boundingBox.clone()),o.boundingSphere=null,t.boundingSphere!==null&&(o.boundingSphere=t.boundingSphere.clone()),this._visibilityChanged=!0,e}deleteGeometry(e){let t=this._geometryInfo;if(e>=t.length||t[e].active===!1)return this;let s=this._instanceInfo;for(let n=0,a=s.length;n<a;n++)s[n].active&&s[n].geometryIndex===e&&this.deleteInstance(n);return t[e].active=!1,this._availableGeometryIds.push(e),this._visibilityChanged=!0,this}deleteInstance(e){return this.validateInstanceId(e),this._instanceInfo[e].active=!1,this._availableInstanceIds.push(e),this._visibilityChanged=!0,this}optimize(){let e=0,t=0,s=this._geometryInfo,n=s.map((i,o)=>o).sort((i,o)=>s[i].vertexStart-s[o].vertexStart),a=this.geometry;for(let i=0,o=s.length;i<o;i++){let c=n[i],l=s[c];if(l.active!==!1){if(a.index!==null){if(l.indexStart!==t){let{indexStart:h,vertexStart:u,reservedIndexCount:d}=l,f=a.index,p=f.array,m=e-u;for(let b=h;b<h+d;b++)p[b]=p[b]+m;f.array.copyWithin(t,h,h+d),f.addUpdateRange(t,d),f.needsUpdate=!0,l.indexStart=t}t+=l.reservedIndexCount}if(l.vertexStart!==e){let{vertexStart:h,reservedVertexCount:u}=l,d=a.attributes;for(let f in d){let p=d[f],{array:m,itemSize:b}=p;m.copyWithin(e*b,h*b,(h+u)*b),p.addUpdateRange(e*b,u*b),p.needsUpdate=!0}l.vertexStart=e}e+=l.reservedVertexCount,l.start=a.index?l.indexStart:l.vertexStart}}return this._nextIndexStart=t,this._nextVertexStart=e,this._visibilityChanged=!0,this}getBoundingBoxAt(e,t){if(e>=this._geometryCount)return null;let s=this.geometry,n=this._geometryInfo[e];if(n.boundingBox===null){let a=new ss,i=s.index,o=s.attributes.position;for(let c=n.start,l=n.start+n.count;c<l;c++){let h=c;i&&(h=i.getX(h)),a.expandByPoint(Bf.fromBufferAttribute(o,h))}n.boundingBox=a}return t.copy(n.boundingBox),t}getBoundingSphereAt(e,t){if(e>=this._geometryCount)return null;let s=this.geometry,n=this._geometryInfo[e];if(n.boundingSphere===null){let a=new jt;this.getBoundingBoxAt(e,Ag),Ag.getCenter(a.center);let i=s.index,o=s.attributes.position,c=0;for(let l=n.start,h=n.start+n.count;l<h;l++){let u=l;i&&(u=i.getX(u)),Bf.fromBufferAttribute(o,u),c=Math.max(c,a.center.distanceToSquared(Bf))}a.radius=Math.sqrt(c),n.boundingSphere=a}return t.copy(n.boundingSphere),t}setMatrixAt(e,t){this.validateInstanceId(e);let s=this._matricesTexture,n=this._matricesTexture.image.data;return t.toArray(n,e*16),s.needsUpdate=!0,this}getMatrixAt(e,t){return this.validateInstanceId(e),t.fromArray(this._matricesTexture.image.data,e*16)}setColorAt(e,t){return this.validateInstanceId(e),this._colorsTexture===null&&this._initColorsTexture(),t.toArray(this._colorsTexture.image.data,e*4),this._colorsTexture.needsUpdate=!0,this}getColorAt(e,t){return this.validateInstanceId(e),this._colorsTexture===null?t.isVector4?t.set(1,1,1,1):t.setRGB(1,1,1):t.fromArray(this._colorsTexture.image.data,e*4)}setVisibleAt(e,t){return this.validateInstanceId(e),this._instanceInfo[e].visible===t?this:(this._instanceInfo[e].visible=t,this._visibilityChanged=!0,this)}getVisibleAt(e){return this.validateInstanceId(e),this._instanceInfo[e].visible}setGeometryIdAt(e,t){return this.validateInstanceId(e),this.validateGeometryId(t),this._instanceInfo[e].geometryIndex=t,this._visibilityChanged=!0,this}getGeometryIdAt(e){return this.validateInstanceId(e),this._instanceInfo[e].geometryIndex}getGeometryRangeAt(e,t={}){this.validateGeometryId(e);let s=this._geometryInfo[e];return t.vertexStart=s.vertexStart,t.vertexCount=s.vertexCount,t.reservedVertexCount=s.reservedVertexCount,t.indexStart=s.indexStart,t.indexCount=s.indexCount,t.reservedIndexCount=s.reservedIndexCount,t.start=s.start,t.count=s.count,t}setInstanceCount(e){let t=this._availableInstanceIds,s=this._instanceInfo;for(t.sort(c_);t[t.length-1]===s.length-1;)s.pop(),t.pop();if(e<s.length)throw new Error(`THREE.BatchedMesh: Instance ids outside the range ${e} are being used. Cannot shrink instance count.`);let n=new Int32Array(e),a=new Int32Array(e);kc(this._multiDrawCounts,n),kc(this._multiDrawStarts,a),this._multiDrawCounts=n,this._multiDrawStarts=a,this._maxInstanceCount=e;let i=this._indirectTexture,o=this._matricesTexture,c=this._colorsTexture;i.dispose(),this._initIndirectTexture(),kc(i.image.data,this._indirectTexture.image.data),o.dispose(),this._initMatricesTexture(),kc(o.image.data,this._matricesTexture.image.data),c&&(c.dispose(),this._initColorsTexture(),kc(c.image.data,this._colorsTexture.image.data))}setGeometrySize(e,t){let s=[...this._geometryInfo].filter(o=>o.active);if(Math.max(...s.map(o=>o.vertexStart+o.reservedVertexCount))>e)throw new Error(`THREE.BatchedMesh: Geometry vertex values are being used outside the range ${t}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...s.map(c=>c.indexStart+c.reservedIndexCount))>t)throw new Error(`THREE.BatchedMesh: Geometry index values are being used outside the range ${t}. Cannot shrink further.`);let a=this.geometry;a.dispose(),this._maxVertexCount=e,this._maxIndexCount=t,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new ke,this._initializeGeometry(a));let i=this.geometry;a.index&&kc(a.index.array,i.index.array);for(let o in a.attributes)kc(a.attributes[o].array,i.attributes[o].array)}raycast(e,t){let s=this._instanceInfo,n=this._geometryInfo,a=this.matrixWorld,i=this.geometry;tn.material=this.material,tn.geometry.index=i.index,tn.geometry.attributes=i.attributes,tn.geometry.boundingBox===null&&(tn.geometry.boundingBox=new ss),tn.geometry.boundingSphere===null&&(tn.geometry.boundingSphere=new jt);for(let o=0,c=s.length;o<c;o++){if(!s[o].visible||!s[o].active)continue;let l=s[o].geometryIndex,h=n[l];tn.geometry.setDrawRange(h.start,h.count),this.getMatrixAt(o,tn.matrixWorld).premultiply(a),this.getBoundingBoxAt(l,tn.geometry.boundingBox),this.getBoundingSphereAt(l,tn.geometry.boundingSphere),tn.raycast(e,Mg);for(let u=0,d=Mg.length;u<d;u++){let f=Mg[u];f.object=this,f.batchId=o,t.push(f)}Mg.length=0}tn.material=null,tn.geometry.index=null,tn.geometry.attributes={},tn.geometry.setDrawRange(0,1/0)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this._geometryInfo=e._geometryInfo.map(t=>({...t,boundingBox:t.boundingBox!==null?t.boundingBox.clone():null,boundingSphere:t.boundingSphere!==null?t.boundingSphere.clone():null})),this._instanceInfo=e._instanceInfo.map(t=>({...t})),this._availableInstanceIds=e._availableInstanceIds.slice(),this._availableGeometryIds=e._availableGeometryIds.slice(),this._nextIndexStart=e._nextIndexStart,this._nextVertexStart=e._nextVertexStart,this._geometryCount=e._geometryCount,this._maxInstanceCount=e._maxInstanceCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._multiDrawBytesPerElement=e._multiDrawBytesPerElement,this._indirectTexture=e._indirectTexture.clone(),this._indirectTexture.image.data=this._indirectTexture.image.data.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),this._colorsTexture!==null&&(this._colorsTexture=e._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){super.dispose(),this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null)}onBeforeRender(e,t,s,n,a){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;let i=n.getIndex(),o=i===null?1:i.array.BYTES_PER_ELEMENT,c=1;a.wireframe&&(c=2,o=n.attributes.position.count>65535?4:2);let l=this._instanceInfo,h=this._multiDrawStarts,u=this._multiDrawCounts,d=this._geometryInfo,f=this.perObjectFrustumCulled,p=this._indirectTexture,m=p.image.data,b=s.isArrayCamera?Y3:$3;f&&(s.isArrayCamera?b.setFromArrayCamera(s):(Pn.multiplyMatrices(s.projectionMatrix,s.matrixWorldInverse).multiply(this.matrixWorld),b.setFromProjectionMatrix(Pn,s.coordinateSystem,s.reversedDepth)));let g=0;if(this.sortObjects){Pn.copy(this.matrixWorld).invert(),Bf.setFromMatrixPosition(s.matrixWorld).applyMatrix4(Pn),M8.set(0,0,-1).transformDirection(s.matrixWorld).transformDirection(Pn);for(let y=0,v=l.length;y<v;y++)if(l[y].visible&&l[y].active){let _=l[y].geometryIndex;this.getMatrixAt(y,Pn),this.getBoundingSphereAt(_,Cc).applyMatrix4(Pn);let A=!1;if(f&&(A=!b.intersectsSphere(Cc)),!A){let M=d[_],N=Z3.subVectors(Cc.center,Bf).dot(M8);l_.push(M.start,M.count,N,y)}}let x=l_.list,T=this.customSort;T===null?x.sort(a.transparent?K3:X3):T.call(this,x,s);for(let y=0,v=x.length;y<v;y++){let _=x[y];h[g]=_.start*o*c,u[g]=_.count*c,m[g]=_.index,g++}l_.reset()}else for(let x=0,T=l.length;x<T;x++)if(l[x].visible&&l[x].active){let y=l[x].geometryIndex,v=!1;if(f&&(this.getMatrixAt(x,Pn),this.getBoundingSphereAt(y,Cc).applyMatrix4(Pn),v=!b.intersectsSphere(Cc)),!v){let _=d[y];h[g]=_.start*o*c,u[g]=_.count*c,m[g]=x,g++}}p.needsUpdate=!0,this._multiDrawCount=g,this._multiDrawBytesPerElement=o,this._visibilityChanged=!1}onBeforeShadow(e,t,s,n,a,i){this.onBeforeRender(e,null,n,a,i)}},ns=class extends Rt{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new be(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},sy=new E,ny=new E,S8=new le,Ff=new oi,Sg=new jt,h_=new E,N8=new E,Qn=class extends Ze{constructor(e=new ke,t=new ns){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,s=[0];for(let n=1,a=t.count;n<a;n++)sy.fromBufferAttribute(t,n-1),ny.fromBufferAttribute(t,n),s[n]=s[n-1],s[n]+=sy.distanceTo(ny);e.setAttribute("lineDistance",new ge(s,1))}else K("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let s=this.geometry,n=this.matrixWorld,a=e.params.Line.threshold,i=s.drawRange;if(s.boundingSphere===null&&s.computeBoundingSphere(),Sg.copy(s.boundingSphere),Sg.applyMatrix4(n),Sg.radius+=a,e.ray.intersectsSphere(Sg)===!1)return;S8.copy(n).invert(),Ff.copy(e.ray).applyMatrix4(S8);let o=a/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,l=this.isLineSegments?2:1,h=s.index,d=s.attributes.position;if(h!==null){let f=Math.max(0,i.start),p=Math.min(h.count,i.start+i.count);for(let m=f,b=p-1;m<b;m+=l){let g=h.getX(m),x=h.getX(m+1),T=Ng(this,e,Ff,c,g,x,m);T&&t.push(T)}if(this.isLineLoop){let m=h.getX(p-1),b=h.getX(f),g=Ng(this,e,Ff,c,m,b,p-1);g&&t.push(g)}}else{let f=Math.max(0,i.start),p=Math.min(d.count,i.start+i.count);for(let m=f,b=p-1;m<b;m+=l){let g=Ng(this,e,Ff,c,m,m+1,m);g&&t.push(g)}if(this.isLineLoop){let m=Ng(this,e,Ff,c,p-1,f,p-1);m&&t.push(m)}}}updateMorphTargets(){let t=this.geometry.morphAttributes,s=Object.keys(t);if(s.length>0){let n=t[s[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,i=n.length;a<i;a++){let o=n[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=a}}}}};function Ng(r,e,t,s,n,a,i){let o=r.geometry.attributes.position;if(sy.fromBufferAttribute(o,n),ny.fromBufferAttribute(o,a),t.distanceSqToSegment(sy,ny,h_,N8)>s)return;h_.applyMatrix4(r.matrixWorld);let l=e.ray.origin.distanceTo(h_);if(!(l<e.near||l>e.far))return{distance:l,point:N8.clone().applyMatrix4(r.matrixWorld),index:i,face:null,faceIndex:null,barycoord:null,object:r}}var R8=new E,E8=new E,_n=class extends Qn{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,s=[];for(let n=0,a=t.count;n<a;n+=2)R8.fromBufferAttribute(t,n),E8.fromBufferAttribute(t,n+1),s[n]=n===0?0:s[n-1],s[n+1]=s[n]+R8.distanceTo(E8);e.setAttribute("lineDistance",new ge(s,1))}else K("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},Hc=class extends Qn{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}},Cr=class extends Rt{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new be(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}},C8=new le,__=new oi,Rg=new jt,Eg=new E,Wc=class extends Ze{constructor(e=new ke,t=new Cr){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let s=this.geometry,n=this.matrixWorld,a=e.params.Points.threshold,i=s.drawRange;if(s.boundingSphere===null&&s.computeBoundingSphere(),Rg.copy(s.boundingSphere),Rg.applyMatrix4(n),Rg.radius+=a,e.ray.intersectsSphere(Rg)===!1)return;C8.copy(n).invert(),__.copy(e.ray).applyMatrix4(C8);let o=a/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,l=s.index,u=s.attributes.position;if(l!==null){let d=Math.max(0,i.start),f=Math.min(l.count,i.start+i.count);for(let p=d,m=f;p<m;p++){let b=l.getX(p);Eg.fromBufferAttribute(u,b),k8(Eg,b,c,n,e,t,this)}}else{let d=Math.max(0,i.start),f=Math.min(u.count,i.start+i.count);for(let p=d,m=f;p<m;p++)Eg.fromBufferAttribute(u,p),k8(Eg,p,c,n,e,t,this)}}updateMorphTargets(){let t=this.geometry.morphAttributes,s=Object.keys(t);if(s.length>0){let n=t[s[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,i=n.length;a<i;a++){let o=n[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=a}}}}};function k8(r,e,t,s,n,a,i){let o=__.distanceSqToPoint(r);if(o<t){let c=new E;__.closestPointToPoint(r,c),c.applyMatrix4(s);let l=n.ray.origin.distanceTo(c);if(l<n.near||l>n.far)return;a.push({distance:l,distanceToRay:Math.sqrt(o),point:c,index:e,face:null,faceIndex:null,barycoord:null,object:i})}}var $f=class extends gt{constructor(e,t,s,n,a=Ye,i=Ye,o,c,l){super(e,t,s,n,a,i,o,c,l),this.isVideoTexture=!0,this.generateMipmaps=!1,this._requestVideoFrameCallbackId=0;let h=this;function u(){h.needsUpdate=!0,h._requestVideoFrameCallbackId=e.requestVideoFrameCallback(u)}"requestVideoFrameCallback"in e&&(this._requestVideoFrameCallbackId=e.requestVideoFrameCallback(u))}clone(){return new this.constructor(this.image).copy(this)}update(){let e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}dispose(){this._requestVideoFrameCallbackId!==0&&(this.source.data.cancelVideoFrameCallback(this._requestVideoFrameCallbackId),this._requestVideoFrameCallbackId=0),super.dispose()}},ay=class extends $f{constructor(e,t,s,n,a,i,o,c){super({},e,t,s,n,a,i,o,c),this.isVideoFrameTexture=!0}update(){}clone(){return new this.constructor().copy(this)}setFrame(e){this.image=e,this.needsUpdate=!0}},qc=class extends gt{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=pt,this.minFilter=pt,this.generateMipmaps=!1,this.needsUpdate=!0}},Xc=class extends gt{constructor(e,t,s,n,a,i,o,c,l,h,u,d){super(null,i,o,c,l,h,n,a,u,d),this.isCompressedTexture=!0,this.image={width:t,height:s},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}},iy=class extends Xc{constructor(e,t,s,n,a,i){super(e,t,s,a,i),this.isCompressedArrayTexture=!0,this.image.depth=n,this.wrapR=hs,this.layerUpdates=new Set}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},ry=class extends Xc{constructor(e,t,s){super(void 0,e[0].width,e[0].height,t,s,Wi),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}},Pi=class extends gt{constructor(e=[],t=Wi,s,n,a,i,o,c,l,h){super(e,t,s,n,a,i,o,c,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},oy=class extends gt{constructor(e,t,s,n,a,i,o,c,l){super(e,t,s,n,a,i,o,c,l),this.isCanvasTexture=!0,this.needsUpdate=!0}},cy=class extends gt{constructor(e,t,s,n,a,i,o,c,l){super(e,t,s,n,a,i,o,c,l),this.isHTMLTexture=!0,this.generateMipmaps=!1,this.needsUpdate=!0;let h=e?e.parentNode:null;h!==null&&"requestPaint"in h&&(h.onpaint=()=>{this.needsUpdate=!0},h.requestPaint())}dispose(){let e=this.image?this.image.parentNode:null;e!==null&&"onpaint"in e&&(e.onpaint=null),super.dispose()}},Ds=class extends gt{constructor(e,t,s=St,n,a,i,o=pt,c=pt,l,h=vn,u=1){if(h!==vn&&h!==na)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let d={width:e,height:t,depth:u};super(d,n,a,i,o,c,h,s,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Ma(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return t.compareFunction=this.compareFunction,t}},Yf=class extends Ds{constructor(e,t=St,s=Wi,n,a,i=pt,o=pt,c,l=vn){let h={width:e,height:e,depth:1},u=[h,h,h,h,h,h];super(e,e,t,s,n,a,i,o,c,l),this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}},ly=class extends gt{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}},kr=class r extends ke{constructor(e=1,t=1,s=1,n=1,a=1,i=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:s,widthSegments:n,heightSegments:a,depthSegments:i};let o=this;n=Math.floor(n),a=Math.floor(a),i=Math.floor(i);let c=[],l=[],h=[],u=[],d=0,f=0;p("z","y","x",-1,-1,s,t,e,i,a,0),p("z","y","x",1,-1,s,t,-e,i,a,1),p("x","z","y",1,1,e,s,t,n,i,2),p("x","z","y",1,-1,e,s,-t,n,i,3),p("x","y","z",1,-1,e,t,s,n,a,4),p("x","y","z",-1,-1,e,t,-s,n,a,5),this.setIndex(c),this.setAttribute("position",new ge(l,3)),this.setAttribute("normal",new ge(h,3)),this.setAttribute("uv",new ge(u,2));function p(m,b,g,x,T,y,v,_,A,M,N){let R=y/A,I=v/M,D=y/2,O=v/2,P=_/2,U=A+1,j=M+1,z=0,H=0,J=new E;for(let ee=0;ee<j;ee++){let se=ee*I-O;for(let _e=0;_e<U;_e++){let Ae=_e*R-D;J[m]=Ae*x,J[b]=se*T,J[g]=P,l.push(J.x,J.y,J.z),J[m]=0,J[b]=0,J[g]=_>0?1:-1,h.push(J.x,J.y,J.z),u.push(_e/A),u.push(1-ee/M),z+=1}}for(let ee=0;ee<M;ee++)for(let se=0;se<A;se++){let _e=d+se+U*ee,Ae=d+se+U*(ee+1),Se=d+(se+1)+U*(ee+1),Fe=d+(se+1)+U*ee;c.push(_e,Ae,Fe),c.push(Ae,Se,Fe),H+=6}o.addGroup(f,H,N),f+=H,d+=z}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new r(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}},Zf=class r extends ke{constructor(e=1,t=1,s=4,n=8,a=1){super(),this.type="CapsuleGeometry",this.parameters={radius:e,height:t,capSegments:s,radialSegments:n,heightSegments:a},t=Math.max(0,t),s=Math.max(1,Math.floor(s)),n=Math.max(3,Math.floor(n)),a=Math.max(1,Math.floor(a));let i=[],o=[],c=[],l=[],h=t/2,u=Math.PI/2*e,d=t,f=2*u+d,p=s*2+a,m=n+1,b=new E,g=new E;for(let x=0;x<=p;x++){let T=0,y=0,v=0,_=0;if(x<=s){let N=x/s,R=N*Math.PI/2;y=-h-e*Math.cos(R),v=e*Math.sin(R),_=-e*Math.cos(R),T=N*u}else if(x<=s+a){let N=(x-s)/a;y=-h+N*t,v=e,_=0,T=u+N*d}else{let N=(x-s-a)/s,R=N*Math.PI/2;y=h+e*Math.sin(R),v=e*Math.cos(R),_=e*Math.sin(R),T=u+d+N*u}let A=Math.max(0,Math.min(1,T/f)),M=0;x===0?M=.5/n:x===p&&(M=-.5/n);for(let N=0;N<=n;N++){let R=N/n,I=R*Math.PI*2,D=Math.sin(I),O=Math.cos(I);g.x=-v*O,g.y=y,g.z=v*D,o.push(g.x,g.y,g.z),b.set(-v*O,_,v*D),b.normalize(),c.push(b.x,b.y,b.z),l.push(R+M,A)}if(x>0){let N=(x-1)*m;for(let R=0;R<n;R++){let I=N+R,D=N+R+1,O=x*m+R,P=x*m+R+1;i.push(I,D,O),i.push(D,P,O)}}}this.setIndex(i),this.setAttribute("position",new ge(o,3)),this.setAttribute("normal",new ge(c,3)),this.setAttribute("uv",new ge(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new r(e.radius,e.height,e.capSegments,e.radialSegments,e.heightSegments)}},Qf=class r extends ke{constructor(e=1,t=32,s=0,n=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:s,thetaLength:n},t=Math.max(3,t);let a=[],i=[],o=[],c=[],l=new E,h=new q;i.push(0,0,0),o.push(0,0,1),c.push(.5,.5);for(let u=0,d=3;u<=t;u++,d+=3){let f=s+u/t*n;l.x=e*Math.cos(f),l.y=e*Math.sin(f),i.push(l.x,l.y,l.z),o.push(0,0,1),h.x=(i[d]/e+1)/2,h.y=(i[d+1]/e+1)/2,c.push(h.x,h.y)}for(let u=1;u<=t;u++)a.push(u,u+1,0);this.setIndex(a),this.setAttribute("position",new ge(i,3)),this.setAttribute("normal",new ge(o,3)),this.setAttribute("uv",new ge(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new r(e.radius,e.segments,e.thetaStart,e.thetaLength)}},Kc=class r extends ke{constructor(e=1,t=1,s=1,n=32,a=1,i=!1,o=0,c=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:s,radialSegments:n,heightSegments:a,openEnded:i,thetaStart:o,thetaLength:c};let l=this;n=Math.floor(n),a=Math.floor(a);let h=[],u=[],d=[],f=[],p=0,m=[],b=s/2,g=0;x(),i===!1&&(e>0&&T(!0),t>0&&T(!1)),this.setIndex(h),this.setAttribute("position",new ge(u,3)),this.setAttribute("normal",new ge(d,3)),this.setAttribute("uv",new ge(f,2));function x(){let y=new E,v=new E,_=0,A=(t-e)/s;for(let M=0;M<=a;M++){let N=[],R=M/a,I=R*(t-e)+e;for(let D=0;D<=n;D++){let O=D/n,P=O*c+o,U=Math.sin(P),j=Math.cos(P);v.x=I*U,v.y=-R*s+b,v.z=I*j,u.push(v.x,v.y,v.z),y.set(U,A,j).normalize(),d.push(y.x,y.y,y.z),f.push(O,1-R),N.push(p++)}m.push(N)}for(let M=0;M<n;M++)for(let N=0;N<a;N++){let R=m[N][M],I=m[N+1][M],D=m[N+1][M+1],O=m[N][M+1];(e>0||N!==0)&&(h.push(R,I,O),_+=3),(t>0||N!==a-1)&&(h.push(I,D,O),_+=3)}l.addGroup(g,_,0),g+=_}function T(y){let v=p,_=new q,A=new E,M=0,N=y===!0?e:t,R=y===!0?1:-1;for(let D=1;D<=n;D++)u.push(0,b*R,0),d.push(0,R,0),f.push(.5,.5),p++;let I=p;for(let D=0;D<=n;D++){let P=D/n*c+o,U=Math.cos(P),j=Math.sin(P);A.x=N*j,A.y=b*R,A.z=N*U,u.push(A.x,A.y,A.z),d.push(0,R,0),_.x=U*.5+.5,_.y=j*.5*R+.5,f.push(_.x,_.y),p++}for(let D=0;D<n;D++){let O=v+D,P=I+D;y===!0?h.push(P,P+1,O):h.push(P+1,P,O),M+=3}l.addGroup(g,M,y===!0?1:2),g+=M}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new r(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},$h=class r extends Kc{constructor(e=1,t=1,s=32,n=1,a=!1,i=0,o=Math.PI*2){super(0,e,t,s,n,a,i,o),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:s,heightSegments:n,openEnded:a,thetaStart:i,thetaLength:o}}static fromJSON(e){return new r(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},Ir=class r extends ke{constructor(e=[],t=[],s=1,n=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:s,detail:n};let a=[],i=[];o(n),l(s),h(),this.setAttribute("position",new ge(a,3)),this.setAttribute("normal",new ge(a.slice(),3)),this.setAttribute("uv",new ge(i,2)),n===0?this.computeVertexNormals():this.normalizeNormals();function o(x){let T=new E,y=new E,v=new E;for(let _=0;_<t.length;_+=3)f(t[_+0],T),f(t[_+1],y),f(t[_+2],v),c(T,y,v,x)}function c(x,T,y,v){let _=v+1,A=[];for(let M=0;M<=_;M++){A[M]=[];let N=x.clone().lerp(y,M/_),R=T.clone().lerp(y,M/_),I=_-M;for(let D=0;D<=I;D++)D===0&&M===_?A[M][D]=N:A[M][D]=N.clone().lerp(R,D/I)}for(let M=0;M<_;M++)for(let N=0;N<2*(_-M)-1;N++){let R=Math.floor(N/2);N%2===0?(d(A[M][R+1]),d(A[M+1][R]),d(A[M][R])):(d(A[M][R+1]),d(A[M+1][R+1]),d(A[M+1][R]))}}function l(x){let T=new E;for(let y=0;y<a.length;y+=3)T.x=a[y+0],T.y=a[y+1],T.z=a[y+2],T.normalize().multiplyScalar(x),a[y+0]=T.x,a[y+1]=T.y,a[y+2]=T.z}function h(){let x=new E;for(let T=0;T<a.length;T+=3){x.x=a[T+0],x.y=a[T+1],x.z=a[T+2];let y=b(x)/2/Math.PI+.5,v=g(x)/Math.PI+.5;i.push(y,1-v)}p(),u()}function u(){for(let x=0;x<i.length;x+=6){let T=i[x+0],y=i[x+2],v=i[x+4],_=Math.max(T,y,v),A=Math.min(T,y,v);_>.9&&A<.1&&(T<.2&&(i[x+0]+=1),y<.2&&(i[x+2]+=1),v<.2&&(i[x+4]+=1))}}function d(x){a.push(x.x,x.y,x.z)}function f(x,T){let y=x*3;T.x=e[y+0],T.y=e[y+1],T.z=e[y+2]}function p(){let x=new E,T=new E,y=new E,v=new E,_=new q,A=new q,M=new q;for(let N=0,R=0;N<a.length;N+=9,R+=6){x.set(a[N+0],a[N+1],a[N+2]),T.set(a[N+3],a[N+4],a[N+5]),y.set(a[N+6],a[N+7],a[N+8]),_.set(i[R+0],i[R+1]),A.set(i[R+2],i[R+3]),M.set(i[R+4],i[R+5]),v.copy(x).add(T).add(y).divideScalar(3);let I=b(v);m(_,R+0,x,I),m(A,R+2,T,I),m(M,R+4,y,I)}}function m(x,T,y,v){v<0&&x.x===1&&(i[T]=x.x-1),y.x===0&&y.z===0&&(i[T]=v/2/Math.PI+.5)}function b(x){return Math.atan2(x.z,-x.x)}function g(x){return Math.atan2(-x.y,Math.sqrt(x.x*x.x+x.z*x.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new r(e.vertices,e.indices,e.radius,e.detail)}},ep=class r extends Ir{constructor(e=1,t=0){let s=(1+Math.sqrt(5))/2,n=1/s,a=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-n,-s,0,-n,s,0,n,-s,0,n,s,-n,-s,0,-n,s,0,n,-s,0,n,s,0,-s,0,-n,s,0,-n,-s,0,n,s,0,n],i=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(a,i,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new r(e.radius,e.detail)}},Cg=new E,kg=new E,u_=new E,Ig=new si,tp=class extends ke{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},e!==null){let n=Math.pow(10,4),a=Math.cos(Uc*t),i=e.getIndex(),o=e.getAttribute("position"),c=i?i.count:o.count,l=[0,0,0],h=["a","b","c"],u=new Array(3),d={},f=[];for(let p=0;p<c;p+=3){i?(l[0]=i.getX(p),l[1]=i.getX(p+1),l[2]=i.getX(p+2)):(l[0]=p,l[1]=p+1,l[2]=p+2);let{a:m,b,c:g}=Ig;if(m.fromBufferAttribute(o,l[0]),b.fromBufferAttribute(o,l[1]),g.fromBufferAttribute(o,l[2]),Ig.getNormal(u_),u[0]=`${Math.round(m.x*n)},${Math.round(m.y*n)},${Math.round(m.z*n)}`,u[1]=`${Math.round(b.x*n)},${Math.round(b.y*n)},${Math.round(b.z*n)}`,u[2]=`${Math.round(g.x*n)},${Math.round(g.y*n)},${Math.round(g.z*n)}`,!(u[0]===u[1]||u[1]===u[2]||u[2]===u[0]))for(let x=0;x<3;x++){let T=(x+1)%3,y=u[x],v=u[T],_=Ig[h[x]],A=Ig[h[T]],M=`${y}_${v}`,N=`${v}_${y}`;N in d&&d[N]?(u_.dot(d[N].normal)<=a&&(f.push(_.x,_.y,_.z),f.push(A.x,A.y,A.z)),d[N]=null):M in d||(d[M]={index0:l[x],index1:l[T],normal:u_.clone()})}}for(let p in d)if(d[p]){let{index0:m,index1:b}=d[p];Cg.fromBufferAttribute(o,m),kg.fromBufferAttribute(o,b),f.push(Cg.x,Cg.y,Cg.z),f.push(kg.x,kg.y,kg.z)}this.setAttribute("position",new ge(f,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}},On=class{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){K("Curve: .getPoint() not implemented.")}getPointAt(e,t){let s=this.getUtoTmapping(e);return this.getPoint(s,t)}getPoints(e=5){let t=[];for(let s=0;s<=e;s++)t.push(this.getPoint(s/e));return t}getSpacedPoints(e=5){let t=[];for(let s=0;s<=e;s++)t.push(this.getPointAt(s/e));return t}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let t=[],s,n=this.getPoint(0),a=0;t.push(0);for(let i=1;i<=e;i++)s=this.getPoint(i/e),a+=s.distanceTo(n),t.push(a),n=s;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t=null){let s=this.getLengths(),n=0,a=s.length,i;t?i=t:i=e*s[a-1];let o=0,c=a-1,l;for(;o<=c;)if(n=Math.floor(o+(c-o)/2),l=s[n]-i,l<0)o=n+1;else if(l>0)c=n-1;else{c=n;break}if(n=c,s[n]===i)return n/(a-1);let h=s[n],d=s[n+1]-h,f=(i-h)/d;return(n+f)/(a-1)}getTangent(e,t){let n=e-1e-4,a=e+1e-4;n<0&&(n=0),a>1&&(a=1);let i=this.getPoint(n),o=this.getPoint(a),c=t||(i.isVector2?new q:new E);return c.copy(o).sub(i).normalize(),c}getTangentAt(e,t){let s=this.getUtoTmapping(e);return this.getTangent(s,t)}computeFrenetFrames(e,t=!1){let s=new E,n=[],a=[],i=[],o=new E,c=new le;for(let f=0;f<=e;f++){let p=f/e;n[f]=this.getTangentAt(p,new E)}a[0]=new E,i[0]=new E;let l=Number.MAX_VALUE,h=Math.abs(n[0].x),u=Math.abs(n[0].y),d=Math.abs(n[0].z);h<=l&&(l=h,s.set(1,0,0)),u<=l&&(l=u,s.set(0,1,0)),d<=l&&s.set(0,0,1),o.crossVectors(n[0],s).normalize(),a[0].crossVectors(n[0],o),i[0].crossVectors(n[0],a[0]);for(let f=1;f<=e;f++){if(a[f]=a[f-1].clone(),i[f]=i[f-1].clone(),o.crossVectors(n[f-1],n[f]),o.length()>Number.EPSILON){o.normalize();let p=Math.acos(Be(n[f-1].dot(n[f]),-1,1));a[f].applyMatrix4(c.makeRotationAxis(o,p))}i[f].crossVectors(n[f],a[f])}if(t===!0){let f=Math.acos(Be(a[0].dot(a[e]),-1,1));f/=e,n[0].dot(o.crossVectors(a[0],a[e]))>0&&(f=-f);for(let p=1;p<=e;p++)a[p].applyMatrix4(c.makeRotationAxis(n[p],f*p)),i[p].crossVectors(n[p],a[p])}return{tangents:n,normals:a,binormals:i}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},Jc=class extends On{constructor(e=0,t=0,s=1,n=1,a=0,i=Math.PI*2,o=!1,c=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=s,this.yRadius=n,this.aStartAngle=a,this.aEndAngle=i,this.aClockwise=o,this.aRotation=c}getPoint(e,t=new q){let s=t,n=Math.PI*2,a=this.aEndAngle-this.aStartAngle,i=Math.abs(a)<Number.EPSILON;for(;a<0;)a+=n;for(;a>n;)a-=n;a<Number.EPSILON&&(i?a=0:a=n),this.aClockwise===!0&&!i&&(a===n?a=-n:a=a-n);let o=this.aStartAngle+e*a,c=this.aX+this.xRadius*Math.cos(o),l=this.aY+this.yRadius*Math.sin(o);if(this.aRotation!==0){let h=Math.cos(this.aRotation),u=Math.sin(this.aRotation),d=c-this.aX,f=l-this.aY;c=d*h-f*u+this.aX,l=d*u+f*h+this.aY}return s.set(c,l)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){let e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}},sp=class extends Jc{constructor(e,t,s,n,a,i){super(e,t,s,s,n,a,i),this.isArcCurve=!0,this.type="ArcCurve"}};function hA(){let r=0,e=0,t=0,s=0;function n(a,i,o,c){r=a,e=o,t=-3*a+3*i-2*o-c,s=2*a-2*i+o+c}return{initCatmullRom:function(a,i,o,c,l){n(i,o,l*(o-a),l*(c-i))},initNonuniformCatmullRom:function(a,i,o,c,l,h,u){let d=(i-a)/l-(o-a)/(l+h)+(o-i)/h,f=(o-i)/h-(c-i)/(h+u)+(c-o)/u;d*=h,f*=h,n(i,o,d,f)},calc:function(a){let i=a*a,o=i*a;return r+e*a+t*i+s*o}}}var I8=new E,B8=new E,d_=new hA,f_=new hA,p_=new hA,np=class extends On{constructor(e=[],t=!1,s="centripetal",n=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=s,this.tension=n}getPoint(e,t=new E){let s=t,n=this.points,a=n.length,i=(a-(this.closed?0:1))*e,o=Math.floor(i),c=i-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/a)+1)*a:c===0&&o===a-1&&(o=a-2,c=1);let l,h;this.closed||o>0?l=n[(o-1)%a]:(B8.subVectors(n[0],n[1]).add(n[0]),l=B8);let u=n[o%a],d=n[(o+1)%a];if(this.closed||o+2<a?h=n[(o+2)%a]:(I8.subVectors(n[a-1],n[a-2]).add(n[a-1]),h=I8),this.curveType==="centripetal"||this.curveType==="chordal"){let f=this.curveType==="chordal"?.5:.25,p=Math.pow(l.distanceToSquared(u),f),m=Math.pow(u.distanceToSquared(d),f),b=Math.pow(d.distanceToSquared(h),f);m<1e-4&&(m=1),p<1e-4&&(p=m),b<1e-4&&(b=m),d_.initNonuniformCatmullRom(l.x,u.x,d.x,h.x,p,m,b),f_.initNonuniformCatmullRom(l.y,u.y,d.y,h.y,p,m,b),p_.initNonuniformCatmullRom(l.z,u.z,d.z,h.z,p,m,b)}else this.curveType==="catmullrom"&&(d_.initCatmullRom(l.x,u.x,d.x,h.x,this.tension),f_.initCatmullRom(l.y,u.y,d.y,h.y,this.tension),p_.initCatmullRom(l.z,u.z,d.z,h.z,this.tension));return s.set(d_.calc(c),f_.calc(c),p_.calc(c)),s}copy(e){super.copy(e),this.points=[];for(let t=0,s=e.points.length;t<s;t++){let n=e.points[t];this.points.push(n.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,s=this.points.length;t<s;t++){let n=this.points[t];e.points.push(n.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,s=e.points.length;t<s;t++){let n=e.points[t];this.points.push(new E().fromArray(n))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};function F8(r,e,t,s,n){let a=(s-e)*.5,i=(n-t)*.5,o=r*r,c=r*o;return(2*t-2*s+a+i)*c+(-3*t+3*s-2*a-i)*o+a*r+t}function eD(r,e){let t=1-r;return t*t*e}function tD(r,e){return 2*(1-r)*r*e}function sD(r,e){return r*r*e}function Lf(r,e,t,s){return eD(r,e)+tD(r,t)+sD(r,s)}function nD(r,e){let t=1-r;return t*t*t*e}function aD(r,e){let t=1-r;return 3*t*t*r*e}function iD(r,e){return 3*(1-r)*r*r*e}function rD(r,e){return r*r*r*e}function zf(r,e,t,s,n){return nD(r,e)+aD(r,t)+iD(r,s)+rD(r,n)}var Yh=class extends On{constructor(e=new q,t=new q,s=new q,n=new q){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=s,this.v3=n}getPoint(e,t=new q){let s=t,n=this.v0,a=this.v1,i=this.v2,o=this.v3;return s.set(zf(e,n.x,a.x,i.x,o.x),zf(e,n.y,a.y,i.y,o.y)),s}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},ap=class extends On{constructor(e=new E,t=new E,s=new E,n=new E){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=s,this.v3=n}getPoint(e,t=new E){let s=t,n=this.v0,a=this.v1,i=this.v2,o=this.v3;return s.set(zf(e,n.x,a.x,i.x,o.x),zf(e,n.y,a.y,i.y,o.y),zf(e,n.z,a.z,i.z,o.z)),s}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},Zh=class extends On{constructor(e=new q,t=new q){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new q){let s=t;return e===1?s.copy(this.v2):(s.copy(this.v2).sub(this.v1),s.multiplyScalar(e).add(this.v1)),s}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new q){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},ip=class extends On{constructor(e=new E,t=new E){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new E){let s=t;return e===1?s.copy(this.v2):(s.copy(this.v2).sub(this.v1),s.multiplyScalar(e).add(this.v1)),s}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new E){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},Qh=class extends On{constructor(e=new q,t=new q,s=new q){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=s}getPoint(e,t=new q){let s=t,n=this.v0,a=this.v1,i=this.v2;return s.set(Lf(e,n.x,a.x,i.x),Lf(e,n.y,a.y,i.y)),s}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},eu=class extends On{constructor(e=new E,t=new E,s=new E){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=s}getPoint(e,t=new E){let s=t,n=this.v0,a=this.v1,i=this.v2;return s.set(Lf(e,n.x,a.x,i.x),Lf(e,n.y,a.y,i.y),Lf(e,n.z,a.z,i.z)),s}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},tu=class extends On{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new q){let s=t,n=this.points,a=(n.length-1)*e,i=Math.floor(a),o=a-i,c=n[i===0?i:i-1],l=n[i],h=n[i>n.length-2?n.length-1:i+1],u=n[i>n.length-3?n.length-1:i+2];return s.set(F8(o,c.x,l.x,h.x,u.x),F8(o,c.y,l.y,h.y,u.y)),s}copy(e){super.copy(e),this.points=[];for(let t=0,s=e.points.length;t<s;t++){let n=e.points[t];this.points.push(n.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,s=this.points.length;t<s;t++){let n=this.points[t];e.points.push(n.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,s=e.points.length;t<s;t++){let n=e.points[t];this.points.push(new q().fromArray(n))}return this}},hy=Object.freeze({__proto__:null,ArcCurve:sp,CatmullRomCurve3:np,CubicBezierCurve:Yh,CubicBezierCurve3:ap,EllipseCurve:Jc,LineCurve:Zh,LineCurve3:ip,QuadraticBezierCurve:Qh,QuadraticBezierCurve3:eu,SplineCurve:tu}),rp=class extends On{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){let e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){let s=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new hy[s](t,e))}return this}getPoint(e,t){let s=e*this.getLength(),n=this.getCurveLengths(),a=0;for(;a<n.length;){if(n[a]>=s){let i=n[a]-s,o=this.curves[a],c=o.getLength(),l=c===0?0:1-i/c;return o.getPointAt(l,t)}a++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let s=0,n=this.curves.length;s<n;s++)t+=this.curves[s].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){let t=[];for(let s=0;s<=e;s++)t.push(this.getPoint(s/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){let t=[],s;for(let n=0,a=this.curves;n<a.length;n++){let i=a[n],o=i.isEllipseCurve?e*2:i.isLineCurve||i.isLineCurve3?1:i.isSplineCurve?e*i.points.length:e,c=i.getPoints(o);for(let l=0;l<c.length;l++){let h=c[l];s&&s.equals(h)||(t.push(h),s=h)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,s=e.curves.length;t<s;t++){let n=e.curves[t];this.curves.push(n.clone())}return this.autoClose=e.autoClose,this}toJSON(){let e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,s=this.curves.length;t<s;t++){let n=this.curves[t];e.curves.push(n.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,s=e.curves.length;t<s;t++){let n=e.curves[t];this.curves.push(new hy[n.type]().fromJSON(n))}return this}},Ao=class extends rp{constructor(e){super(),this.type="Path",this.currentPoint=new q,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,s=e.length;t<s;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){let s=new Zh(this.currentPoint.clone(),new q(e,t));return this.curves.push(s),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,s,n){let a=new Qh(this.currentPoint.clone(),new q(e,t),new q(s,n));return this.curves.push(a),this.currentPoint.set(s,n),this}bezierCurveTo(e,t,s,n,a,i){let o=new Yh(this.currentPoint.clone(),new q(e,t),new q(s,n),new q(a,i));return this.curves.push(o),this.currentPoint.set(a,i),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),s=new tu(t);return this.curves.push(s),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,s,n,a,i){let o=this.currentPoint.x,c=this.currentPoint.y;return this.absarc(e+o,t+c,s,n,a,i),this}absarc(e,t,s,n,a,i){return this.absellipse(e,t,s,s,n,a,i),this}ellipse(e,t,s,n,a,i,o,c){let l=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(e+l,t+h,s,n,a,i,o,c),this}absellipse(e,t,s,n,a,i,o,c){let l=new Jc(e,t,s,n,a,i,o,c);if(this.curves.length>0){let u=l.getPoint(0);u.equals(this.currentPoint)||this.lineTo(u.x,u.y)}this.curves.push(l);let h=l.getPoint(1);return this.currentPoint.copy(h),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},Mo=class extends Ao{constructor(e){super(e),this.uuid=Yn(),this.type="Shape",this.holes=[]}getPointsHoles(e){let t=[];for(let s=0,n=this.holes.length;s<n;s++)t[s]=this.holes[s].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,s=e.holes.length;t<s;t++){let n=e.holes[t];this.holes.push(n.clone())}return this}toJSON(){let e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,s=this.holes.length;t<s;t++){let n=this.holes[t];e.holes.push(n.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,s=e.holes.length;t<s;t++){let n=e.holes[t];this.holes.push(new Ao().fromJSON(n))}return this}};function oD(r,e,t=2){let s=e&&e.length,n=s?e[0]*t:r.length,a=BC(r,0,n,t,!0),i=[];if(!a||a.next===a.prev)return i;let o,c,l;if(s&&(a=dD(r,e,a,t)),r.length>80*t){o=r[0],c=r[1];let h=o,u=c;for(let d=t;d<n;d+=t){let f=r[d],p=r[d+1];f<o&&(o=f),p<c&&(c=p),f>h&&(h=f),p>u&&(u=p)}l=Math.max(h-o,u-c),l=l!==0?32767/l:0}return op(a,i,t,o,c,l,0),i}function BC(r,e,t,s,n){let a;if(n===_D(r,e,t,s)>0)for(let i=e;i<t;i+=s)a=P8(i/s|0,r[i],r[i+1],a);else for(let i=t-s;i>=e;i-=s)a=P8(i/s|0,r[i],r[i+1],a);return a&&su(a,a.next)&&(lp(a),a=a.next),a}function $c(r,e){if(!r)return r;e||(e=r);let t=r,s;do if(s=!1,!t.steiner&&(su(t,t.next)||Vt(t.prev,t,t.next)===0)){if(lp(t),t=e=t.prev,t===t.next)break;s=!0}else t=t.next;while(s||t!==e);return e}function op(r,e,t,s,n,a,i){if(!r)return;!i&&a&&gD(r,s,n,a);let o=r;for(;r.prev!==r.next;){let c=r.prev,l=r.next;if(a?lD(r,s,n,a):cD(r)){e.push(c.i,r.i,l.i),lp(r),r=l.next,o=l.next;continue}if(r=l,r===o){i?i===1?(r=hD($c(r),e),op(r,e,t,s,n,a,2)):i===2&&uD(r,e,t,s,n,a):op($c(r),e,t,s,n,a,1);break}}}function cD(r){let e=r.prev,t=r,s=r.next;if(Vt(e,t,s)>=0)return!1;let n=e.x,a=t.x,i=s.x,o=e.y,c=t.y,l=s.y,h=Math.min(n,a,i),u=Math.min(o,c,l),d=Math.max(n,a,i),f=Math.max(o,c,l),p=s.next;for(;p!==e;){if(p.x>=h&&p.x<=d&&p.y>=u&&p.y<=f&&Df(n,o,a,c,i,l,p.x,p.y)&&Vt(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function lD(r,e,t,s){let n=r.prev,a=r,i=r.next;if(Vt(n,a,i)>=0)return!1;let o=n.x,c=a.x,l=i.x,h=n.y,u=a.y,d=i.y,f=Math.min(o,c,l),p=Math.min(h,u,d),m=Math.max(o,c,l),b=Math.max(h,u,d),g=A_(f,p,e,t,s),x=A_(m,b,e,t,s),T=r.prevZ,y=r.nextZ;for(;T&&T.z>=g&&y&&y.z<=x;){if(T.x>=f&&T.x<=m&&T.y>=p&&T.y<=b&&T!==n&&T!==i&&Df(o,h,c,u,l,d,T.x,T.y)&&Vt(T.prev,T,T.next)>=0||(T=T.prevZ,y.x>=f&&y.x<=m&&y.y>=p&&y.y<=b&&y!==n&&y!==i&&Df(o,h,c,u,l,d,y.x,y.y)&&Vt(y.prev,y,y.next)>=0))return!1;y=y.nextZ}for(;T&&T.z>=g;){if(T.x>=f&&T.x<=m&&T.y>=p&&T.y<=b&&T!==n&&T!==i&&Df(o,h,c,u,l,d,T.x,T.y)&&Vt(T.prev,T,T.next)>=0)return!1;T=T.prevZ}for(;y&&y.z<=x;){if(y.x>=f&&y.x<=m&&y.y>=p&&y.y<=b&&y!==n&&y!==i&&Df(o,h,c,u,l,d,y.x,y.y)&&Vt(y.prev,y,y.next)>=0)return!1;y=y.nextZ}return!0}function hD(r,e){let t=r;do{let s=t.prev,n=t.next.next;!su(s,n)&&PC(s,t,t.next,n)&&cp(s,n)&&cp(n,s)&&(e.push(s.i,t.i,n.i),lp(t),lp(t.next),t=r=n),t=t.next}while(t!==r);return $c(t)}function uD(r,e,t,s,n,a){let i=r;do{let o=i.next.next;for(;o!==i.prev;){if(i.i!==o.i&&wD(i,o)){let c=DC(i,o);i=$c(i,i.next),c=$c(c,c.next),op(i,e,t,s,n,a,0),op(c,e,t,s,n,a,0);return}o=o.next}i=i.next}while(i!==r)}function dD(r,e,t,s){let n=[];for(let a=0,i=e.length;a<i;a++){let o=e[a]*s,c=a<i-1?e[a+1]*s:r.length,l=BC(r,o,c,s,!1);l===l.next&&(l.steiner=!0),n.push(xD(l))}n.sort(fD);for(let a=0;a<n.length;a++)t=pD(n[a],t);return t}function fD(r,e){let t=r.x-e.x;if(t===0&&(t=r.y-e.y,t===0)){let s=(r.next.y-r.y)/(r.next.x-r.x),n=(e.next.y-e.y)/(e.next.x-e.x);t=s-n}return t}function pD(r,e){let t=mD(r,e);if(!t)return e;let s=DC(t,r);return $c(s,s.next),$c(t,t.next)}function mD(r,e){let t=e,s=r.x,n=r.y,a=-1/0,i;if(su(r,t))return t;do{if(su(r,t.next))return t.next;if(n<=t.y&&n>=t.next.y&&t.next.y!==t.y){let u=t.x+(n-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(u<=s&&u>a&&(a=u,i=t.x<t.next.x?t:t.next,u===s))return i}t=t.next}while(t!==e);if(!i)return null;let o=i,c=i.x,l=i.y,h=1/0;t=i;do{if(s>=t.x&&t.x>=c&&s!==t.x&&FC(n<l?s:a,n,c,l,n<l?a:s,n,t.x,t.y)){let u=Math.abs(n-t.y)/(s-t.x);cp(t,r)&&(u<h||u===h&&(t.x>i.x||t.x===i.x&&bD(i,t)))&&(i=t,h=u)}t=t.next}while(t!==o);return i}function bD(r,e){return Vt(r.prev,r,e.prev)<0&&Vt(e.next,r,r.next)<0}function gD(r,e,t,s){let n=r;do n.z===0&&(n.z=A_(n.x,n.y,e,t,s)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next;while(n!==r);n.prevZ.nextZ=null,n.prevZ=null,yD(n)}function yD(r){let e,t=1;do{let s=r,n;r=null;let a=null;for(e=0;s;){e++;let i=s,o=0;for(let l=0;l<t&&(o++,i=i.nextZ,!!i);l++);let c=t;for(;o>0||c>0&&i;)o!==0&&(c===0||!i||s.z<=i.z)?(n=s,s=s.nextZ,o--):(n=i,i=i.nextZ,c--),a?a.nextZ=n:r=n,n.prevZ=a,a=n;s=i}a.nextZ=null,t*=2}while(e>1);return r}function A_(r,e,t,s,n){return r=(r-t)*n|0,e=(e-s)*n|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,r|e<<1}function xD(r){let e=r,t=r;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==r);return t}function FC(r,e,t,s,n,a,i,o){return(n-i)*(e-o)>=(r-i)*(a-o)&&(r-i)*(s-o)>=(t-i)*(e-o)&&(t-i)*(a-o)>=(n-i)*(s-o)}function Df(r,e,t,s,n,a,i,o){return!(r===i&&e===o)&&FC(r,e,t,s,n,a,i,o)}function wD(r,e){return r.next.i!==e.i&&r.prev.i!==e.i&&!TD(r,e)&&(cp(r,e)&&cp(e,r)&&vD(r,e)&&(Vt(r.prev,r,e.prev)||Vt(r,e.prev,e))||su(r,e)&&Vt(r.prev,r,r.next)>0&&Vt(e.prev,e,e.next)>0)}function Vt(r,e,t){return(e.y-r.y)*(t.x-e.x)-(e.x-r.x)*(t.y-e.y)}function su(r,e){return r.x===e.x&&r.y===e.y}function PC(r,e,t,s){let n=Fg(Vt(r,e,t)),a=Fg(Vt(r,e,s)),i=Fg(Vt(t,s,r)),o=Fg(Vt(t,s,e));return!!(n!==a&&i!==o||n===0&&Bg(r,t,e)||a===0&&Bg(r,s,e)||i===0&&Bg(t,r,s)||o===0&&Bg(t,e,s))}function Bg(r,e,t){return e.x<=Math.max(r.x,t.x)&&e.x>=Math.min(r.x,t.x)&&e.y<=Math.max(r.y,t.y)&&e.y>=Math.min(r.y,t.y)}function Fg(r){return r>0?1:r<0?-1:0}function TD(r,e){let t=r;do{if(t.i!==r.i&&t.next.i!==r.i&&t.i!==e.i&&t.next.i!==e.i&&PC(t,t.next,r,e))return!0;t=t.next}while(t!==r);return!1}function cp(r,e){return Vt(r.prev,r,r.next)<0?Vt(r,e,r.next)>=0&&Vt(r,r.prev,e)>=0:Vt(r,e,r.prev)<0||Vt(r,r.next,e)<0}function vD(r,e){let t=r,s=!1,n=(r.x+e.x)/2,a=(r.y+e.y)/2;do t.y>a!=t.next.y>a&&t.next.y!==t.y&&n<(t.next.x-t.x)*(a-t.y)/(t.next.y-t.y)+t.x&&(s=!s),t=t.next;while(t!==r);return s}function DC(r,e){let t=M_(r.i,r.x,r.y),s=M_(e.i,e.x,e.y),n=r.next,a=e.prev;return r.next=e,e.prev=r,t.next=n,n.prev=t,s.next=t,t.prev=s,a.next=s,s.prev=a,s}function P8(r,e,t,s){let n=M_(r,e,t);return s?(n.next=s.next,n.prev=s,s.next.prev=n,s.next=n):(n.prev=n,n.next=n),n}function lp(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function M_(r,e,t){return{i:r,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function _D(r,e,t,s){let n=0;for(let a=e,i=t-s;a<t;a+=s)n+=(r[i]-r[a])*(r[a+1]+r[i+1]),i=a;return n}var S_=class{static triangulate(e,t,s=2){return oD(e,t,s)}},Sa=class r{static area(e){let t=e.length,s=0;for(let n=t-1,a=0;a<t;n=a++)s+=e[n].x*e[a].y-e[a].x*e[n].y;return s*.5}static isClockWise(e){return r.area(e)<0}static triangulateShape(e,t){let s=[],n=[],a=[];D8(e),O8(s,e);let i=e.length;t.forEach(D8);for(let c=0;c<t.length;c++)n.push(i),i+=t[c].length,O8(s,t[c]);let o=S_.triangulate(s,n);for(let c=0;c<o.length;c+=3)a.push(o.slice(c,c+3));return a}};function D8(r){let e=r.length;e>2&&r[e-1].equals(r[0])&&r.pop()}function O8(r,e){for(let t=0;t<e.length;t++)r.push(e[t].x),r.push(e[t].y)}var hp=class r extends ke{constructor(e=new Mo([new q(.5,.5),new q(-.5,.5),new q(-.5,-.5),new q(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];let s=this,n=[],a=[];for(let o=0,c=e.length;o<c;o++){let l=e[o];i(l)}this.setAttribute("position",new ge(n,3)),this.setAttribute("uv",new ge(a,2)),this.computeVertexNormals();function i(o){let c=[],l=t.curveSegments!==void 0?t.curveSegments:12,h=t.steps!==void 0?t.steps:1,u=t.depth!==void 0?t.depth:1,d=t.bevelEnabled!==void 0?t.bevelEnabled:!0,f=t.bevelThickness!==void 0?t.bevelThickness:.2,p=t.bevelSize!==void 0?t.bevelSize:f-.1,m=t.bevelOffset!==void 0?t.bevelOffset:0,b=t.bevelSegments!==void 0?t.bevelSegments:3,g=t.extrudePath,x=t.UVGenerator!==void 0?t.UVGenerator:AD,T,y=!1,v,_,A,M;if(g){T=g.getSpacedPoints(h),y=!0,d=!1;let ne=g.isCatmullRomCurve3?g.closed:!1;v=g.computeFrenetFrames(h,ne),_=new E,A=new E,M=new E}d||(b=0,f=0,p=0,m=0);let N=o.extractPoints(l),R=N.shape,I=N.holes;if(!Sa.isClockWise(R)){R=R.reverse();for(let ne=0,ae=I.length;ne<ae;ne++){let oe=I[ne];Sa.isClockWise(oe)&&(I[ne]=oe.reverse())}}function O(ne){let oe=10000000000000001e-36,me=ne[0];for(let ve=1;ve<=ne.length;ve++){let Pe=ve%ne.length,ue=ne[Pe],Ue=ue.x-me.x,De=ue.y-me.y,$e=Ue*Ue+De*De,At=Math.max(Math.abs(ue.x),Math.abs(ue.y),Math.abs(me.x),Math.abs(me.y)),ps=oe*At*At;if($e<=ps){ne.splice(Pe,1),ve--;continue}me=ue}}O(R),I.forEach(O);let P=I.length,U=R;for(let ne=0;ne<P;ne++){let ae=I[ne];R=R.concat(ae)}function j(ne,ae,oe){return ae||W("ExtrudeGeometry: vec does not exist"),ne.clone().addScaledVector(ae,oe)}let z=R.length;function H(ne,ae,oe){let me,ve,Pe,ue=ne.x-ae.x,Ue=ne.y-ae.y,De=oe.x-ne.x,$e=oe.y-ne.y,At=ue*ue+Ue*Ue,ps=ue*$e-Ue*De;if(Math.abs(ps)>Number.EPSILON){let bn=Math.sqrt(At),Wb=Math.sqrt(De*De+$e*$e),ah=ae.x-Ue/bn,uf=ae.y+ue/bn,qb=oe.x-$e/Wb,Xb=oe.y+De/Wb,df=((qb-ah)*$e-(Xb-uf)*De)/(ue*$e-Ue*De);me=ah+ue*df-ne.x,ve=uf+Ue*df-ne.y;let ff=me*me+ve*ve;if(ff<=2)return new q(me,ve);Pe=Math.sqrt(ff/2)}else{let bn=!1;ue>Number.EPSILON?De>Number.EPSILON&&(bn=!0):ue<-Number.EPSILON?De<-Number.EPSILON&&(bn=!0):Math.sign(Ue)===Math.sign($e)&&(bn=!0),bn?(me=-Ue,ve=ue,Pe=Math.sqrt(At)):(me=ue,ve=Ue,Pe=Math.sqrt(At/2))}return new q(me/Pe,ve/Pe)}let J=[];for(let ne=0,ae=U.length,oe=ae-1,me=ne+1;ne<ae;ne++,oe++,me++)oe===ae&&(oe=0),me===ae&&(me=0),J[ne]=H(U[ne],U[oe],U[me]);let ee=[],se,_e=J.concat();for(let ne=0,ae=P;ne<ae;ne++){let oe=I[ne];se=[];for(let me=0,ve=oe.length,Pe=ve-1,ue=me+1;me<ve;me++,Pe++,ue++)Pe===ve&&(Pe=0),ue===ve&&(ue=0),se[me]=H(oe[me],oe[Pe],oe[ue]);ee.push(se),_e=_e.concat(se)}let Ae;if(b===0)Ae=Sa.triangulateShape(U,I);else{let ne=[],ae=[];for(let oe=0;oe<b;oe++){let me=oe/b,ve=f*Math.cos(me*Math.PI/2),Pe=p*Math.sin(me*Math.PI/2)+m;for(let ue=0,Ue=U.length;ue<Ue;ue++){let De=j(U[ue],J[ue],Pe);Q(De.x,De.y,-ve),me===0&&ne.push(De)}for(let ue=0,Ue=P;ue<Ue;ue++){let De=I[ue];se=ee[ue];let $e=[];for(let At=0,ps=De.length;At<ps;At++){let bn=j(De[At],se[At],Pe);Q(bn.x,bn.y,-ve),me===0&&$e.push(bn)}me===0&&ae.push($e)}}Ae=Sa.triangulateShape(ne,ae)}let Se=Ae.length,Fe=p+m;for(let ne=0;ne<z;ne++){let ae=d?j(R[ne],_e[ne],Fe):R[ne];y?(A.copy(v.normals[0]).multiplyScalar(ae.x),_.copy(v.binormals[0]).multiplyScalar(ae.y),M.copy(T[0]).add(A).add(_),Q(M.x,M.y,M.z)):Q(ae.x,ae.y,0)}for(let ne=1;ne<=h;ne++)for(let ae=0;ae<z;ae++){let oe=d?j(R[ae],_e[ae],Fe):R[ae];y?(A.copy(v.normals[ne]).multiplyScalar(oe.x),_.copy(v.binormals[ne]).multiplyScalar(oe.y),M.copy(T[ne]).add(A).add(_),Q(M.x,M.y,M.z)):Q(oe.x,oe.y,u/h*ne)}for(let ne=b-1;ne>=0;ne--){let ae=ne/b,oe=f*Math.cos(ae*Math.PI/2),me=p*Math.sin(ae*Math.PI/2)+m;for(let ve=0,Pe=U.length;ve<Pe;ve++){let ue=j(U[ve],J[ve],me);Q(ue.x,ue.y,u+oe)}for(let ve=0,Pe=I.length;ve<Pe;ve++){let ue=I[ve];se=ee[ve];for(let Ue=0,De=ue.length;Ue<De;Ue++){let $e=j(ue[Ue],se[Ue],me);y?Q($e.x,$e.y+T[h-1].y,T[h-1].x+oe):Q($e.x,$e.y,u+oe)}}}ft(),te();function ft(){let ne=n.length/3;if(d){let ae=0,oe=z*ae;for(let me=0;me<Se;me++){let ve=Ae[me];Ee(ve[2]+oe,ve[1]+oe,ve[0]+oe)}ae=h+b*2,oe=z*ae;for(let me=0;me<Se;me++){let ve=Ae[me];Ee(ve[0]+oe,ve[1]+oe,ve[2]+oe)}}else{for(let ae=0;ae<Se;ae++){let oe=Ae[ae];Ee(oe[2],oe[1],oe[0])}for(let ae=0;ae<Se;ae++){let oe=Ae[ae];Ee(oe[0]+z*h,oe[1]+z*h,oe[2]+z*h)}}s.addGroup(ne,n.length/3-ne,0)}function te(){let ne=n.length/3,ae=0;re(U,ae),ae+=U.length;for(let oe=0,me=I.length;oe<me;oe++){let ve=I[oe];re(ve,ae),ae+=ve.length}s.addGroup(ne,n.length/3-ne,1)}function re(ne,ae){let oe=ne.length;for(;--oe>=0;){let me=oe,ve=oe-1;ve<0&&(ve=ne.length-1);for(let Pe=0,ue=h+b*2;Pe<ue;Pe++){let Ue=z*Pe,De=z*(Pe+1),$e=ae+me+Ue,At=ae+ve+Ue,ps=ae+ve+De,bn=ae+me+De;Oe($e,At,ps,bn)}}}function Q(ne,ae,oe){c.push(ne),c.push(ae),c.push(oe)}function Ee(ne,ae,oe){Ce(ne),Ce(ae),Ce(oe);let me=n.length/3,ve=x.generateTopUV(s,n,me-3,me-2,me-1);Je(ve[0]),Je(ve[1]),Je(ve[2])}function Oe(ne,ae,oe,me){Ce(ne),Ce(ae),Ce(me),Ce(ae),Ce(oe),Ce(me);let ve=n.length/3,Pe=x.generateSideWallUV(s,n,ve-6,ve-3,ve-2,ve-1);Je(Pe[0]),Je(Pe[1]),Je(Pe[3]),Je(Pe[1]),Je(Pe[2]),Je(Pe[3])}function Ce(ne){n.push(c[ne*3+0]),n.push(c[ne*3+1]),n.push(c[ne*3+2])}function Je(ne){a.push(ne.x),a.push(ne.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON(),t=this.parameters.shapes,s=this.parameters.options;return MD(t,s,e)}static fromJSON(e,t){let s=[];for(let a=0,i=e.shapes.length;a<i;a++){let o=t[e.shapes[a]];s.push(o)}let n=e.options.extrudePath;return n!==void 0&&(e.options.extrudePath=new hy[n.type]().fromJSON(n)),new r(s,e.options)}},AD={generateTopUV:function(r,e,t,s,n){let a=e[t*3],i=e[t*3+1],o=e[s*3],c=e[s*3+1],l=e[n*3],h=e[n*3+1];return[new q(a,i),new q(o,c),new q(l,h)]},generateSideWallUV:function(r,e,t,s,n,a){let i=e[t*3],o=e[t*3+1],c=e[t*3+2],l=e[s*3],h=e[s*3+1],u=e[s*3+2],d=e[n*3],f=e[n*3+1],p=e[n*3+2],m=e[a*3],b=e[a*3+1],g=e[a*3+2];return Math.abs(o-h)<Math.abs(i-l)?[new q(i,1-c),new q(l,1-u),new q(d,1-p),new q(m,1-g)]:[new q(o,1-c),new q(h,1-u),new q(f,1-p),new q(b,1-g)]}};function MD(r,e,t){if(t.shapes=[],Array.isArray(r))for(let s=0,n=r.length;s<n;s++){let a=r[s];t.shapes.push(a.uuid)}else t.shapes.push(r.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}var up=class r extends Ir{constructor(e=1,t=0){let s=(1+Math.sqrt(5))/2,n=[-1,s,0,1,s,0,-1,-s,0,1,-s,0,0,-1,s,0,1,s,0,-1,-s,0,1,-s,s,0,-1,s,0,1,-s,0,-1,-s,0,1],a=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(n,a,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new r(e.radius,e.detail)}},dp=class r extends ke{constructor(e=[new q(0,-.5),new q(.5,0),new q(0,.5)],t=12,s=0,n=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:s,phiLength:n},t=Math.floor(t),n=Be(n,0,Math.PI*2);let a=[],i=[],o=[],c=[],l=[],h=1/t,u=new E,d=new q,f=new E,p=new E,m=new E,b=0,g=0;for(let x=0;x<=e.length-1;x++)switch(x){case 0:b=e[x+1].x-e[x].x,g=e[x+1].y-e[x].y,f.x=g*1,f.y=-b,f.z=g*0,m.copy(f),f.normalize(),c.push(f.x,f.y,f.z);break;case e.length-1:c.push(m.x,m.y,m.z);break;default:b=e[x+1].x-e[x].x,g=e[x+1].y-e[x].y,f.x=g*1,f.y=-b,f.z=g*0,p.copy(f),f.x+=m.x,f.y+=m.y,f.z+=m.z,f.normalize(),c.push(f.x,f.y,f.z),m.copy(p)}for(let x=0;x<=t;x++){let T=s+x*h*n,y=Math.sin(T),v=Math.cos(T);for(let _=0;_<=e.length-1;_++){u.x=e[_].x*y,u.y=e[_].y,u.z=e[_].x*v,i.push(u.x,u.y,u.z),d.x=x/t,d.y=_/(e.length-1),o.push(d.x,d.y);let A=c[3*_+0]*y,M=c[3*_+1],N=c[3*_+0]*v;l.push(A,M,N)}}for(let x=0;x<t;x++)for(let T=0;T<e.length-1;T++){let y=T+x*e.length,v=y,_=y+e.length,A=y+e.length+1,M=y+1;a.push(v,_,M),a.push(A,M,_)}this.setIndex(a),this.setAttribute("position",new ge(i,3)),this.setAttribute("uv",new ge(o,2)),this.setAttribute("normal",new ge(l,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new r(e.points,e.segments,e.phiStart,e.phiLength)}},nu=class r extends Ir{constructor(e=1,t=0){let s=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],n=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];super(s,n,e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new r(e.radius,e.detail)}},au=class r extends ke{constructor(e=1,t=1,s=1,n=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:s,heightSegments:n};let a=e/2,i=t/2,o=Math.floor(s),c=Math.floor(n),l=o+1,h=c+1,u=e/o,d=t/c,f=[],p=[],m=[],b=[];for(let g=0;g<h;g++){let x=g*d-i;for(let T=0;T<l;T++){let y=T*u-a;p.push(y,-x,0),m.push(0,0,1),b.push(T/o),b.push(1-g/c)}}for(let g=0;g<c;g++)for(let x=0;x<o;x++){let T=x+l*g,y=x+l*(g+1),v=x+1+l*(g+1),_=x+1+l*g;f.push(T,y,_),f.push(y,v,_)}this.setIndex(f),this.setAttribute("position",new ge(p,3)),this.setAttribute("normal",new ge(m,3)),this.setAttribute("uv",new ge(b,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new r(e.width,e.height,e.widthSegments,e.heightSegments)}},fp=class r extends ke{constructor(e=.5,t=1,s=32,n=1,a=0,i=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:s,phiSegments:n,thetaStart:a,thetaLength:i},s=Math.max(3,s),n=Math.max(1,n);let o=[],c=[],l=[],h=[],u=e,d=(t-e)/n,f=new E,p=new q;for(let m=0;m<=n;m++){for(let b=0;b<=s;b++){let g=a+b/s*i;f.x=u*Math.cos(g),f.y=u*Math.sin(g),c.push(f.x,f.y,f.z),l.push(0,0,1),p.x=(f.x/t+1)/2,p.y=(f.y/t+1)/2,h.push(p.x,p.y)}u+=d}for(let m=0;m<n;m++){let b=m*(s+1);for(let g=0;g<s;g++){let x=g+b,T=x,y=x+s+1,v=x+s+2,_=x+1;o.push(T,y,_),o.push(y,v,_)}}this.setIndex(o),this.setAttribute("position",new ge(c,3)),this.setAttribute("normal",new ge(l,3)),this.setAttribute("uv",new ge(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new r(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}},pp=class r extends ke{constructor(e=new Mo([new q(0,.5),new q(-.5,-.5),new q(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};let s=[],n=[],a=[],i=[],o=0,c=0;if(Array.isArray(e)===!1)l(e);else for(let h=0;h<e.length;h++)l(e[h]),this.addGroup(o,c,h),o+=c,c=0;this.setIndex(s),this.setAttribute("position",new ge(n,3)),this.setAttribute("normal",new ge(a,3)),this.setAttribute("uv",new ge(i,2));function l(h){let u=n.length/3,d=h.extractPoints(t),f=d.shape,p=d.holes;Sa.isClockWise(f)===!1&&(f=f.reverse());for(let b=0,g=p.length;b<g;b++){let x=p[b];Sa.isClockWise(x)===!0&&(p[b]=x.reverse())}let m=Sa.triangulateShape(f,p);for(let b=0,g=p.length;b<g;b++){let x=p[b];f=f.concat(x)}for(let b=0,g=f.length;b<g;b++){let x=f[b];n.push(x.x,x.y,0),a.push(0,0,1),i.push(x.x,x.y)}for(let b=0,g=m.length;b<g;b++){let x=m[b],T=x[0]+u,y=x[1]+u,v=x[2]+u;s.push(T,y,v),c+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON(),t=this.parameters.shapes;return SD(t,e)}static fromJSON(e,t){let s=[];for(let n=0,a=e.shapes.length;n<a;n++){let i=t[e.shapes[n]];s.push(i)}return new r(s,e.curveSegments)}};function SD(r,e){if(e.shapes=[],Array.isArray(r))for(let t=0,s=r.length;t<s;t++){let n=r[t];e.shapes.push(n.uuid)}else e.shapes.push(r.uuid);return e}var Yc=class r extends ke{constructor(e=1,t=32,s=16,n=0,a=Math.PI*2,i=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:s,phiStart:n,phiLength:a,thetaStart:i,thetaLength:o},t=Math.max(3,Math.floor(t)),s=Math.max(2,Math.floor(s));let c=Math.min(i+o,Math.PI),l=0,h=[],u=new E,d=new E,f=[],p=[],m=[],b=[];for(let g=0;g<=s;g++){let x=[],T=g/s,y=i+T*o,v=e*Math.cos(y),_=Math.sqrt(e*e-v*v),A=0;g===0&&i===0?A=.5/t:g===s&&c===Math.PI&&(A=-.5/t);for(let M=0;M<=t;M++){let N=M/t,R=n+N*a;u.x=-_*Math.cos(R),u.y=v,u.z=_*Math.sin(R),p.push(u.x,u.y,u.z),d.copy(u).normalize(),m.push(d.x,d.y,d.z),b.push(N+A,1-T),x.push(l++)}h.push(x)}for(let g=0;g<s;g++)for(let x=0;x<t;x++){let T=h[g][x+1],y=h[g][x],v=h[g+1][x],_=h[g+1][x+1];(g!==0||i>0)&&f.push(T,y,_),(g!==s-1||c<Math.PI)&&f.push(y,v,_)}this.setIndex(f),this.setAttribute("position",new ge(p,3)),this.setAttribute("normal",new ge(m,3)),this.setAttribute("uv",new ge(b,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new r(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}},mp=class r extends Ir{constructor(e=1,t=0){let s=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],n=[2,1,0,0,3,2,1,3,0,2,3,1];super(s,n,e,t),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new r(e.radius,e.detail)}},bp=class r extends ke{constructor(e=1,t=.4,s=12,n=48,a=Math.PI*2,i=0,o=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:s,tubularSegments:n,arc:a,thetaStart:i,thetaLength:o},s=Math.floor(s),n=Math.floor(n);let c=[],l=[],h=[],u=[],d=new E,f=new E,p=new E;for(let m=0;m<=s;m++){let b=i+m/s*o;for(let g=0;g<=n;g++){let x=g/n*a;f.x=(e+t*Math.cos(b))*Math.cos(x),f.y=(e+t*Math.cos(b))*Math.sin(x),f.z=t*Math.sin(b),l.push(f.x,f.y,f.z),d.x=e*Math.cos(x),d.y=e*Math.sin(x),p.subVectors(f,d).normalize(),h.push(p.x,p.y,p.z),u.push(g/n),u.push(m/s)}}for(let m=1;m<=s;m++)for(let b=1;b<=n;b++){let g=(n+1)*m+b-1,x=(n+1)*(m-1)+b-1,T=(n+1)*(m-1)+b,y=(n+1)*m+b;c.push(g,x,y),c.push(x,T,y)}this.setIndex(c),this.setAttribute("position",new ge(l,3)),this.setAttribute("normal",new ge(h,3)),this.setAttribute("uv",new ge(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new r(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc,e.thetaStart,e.thetaLength)}},gp=class r extends ke{constructor(e=1,t=.4,s=64,n=8,a=2,i=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:s,radialSegments:n,p:a,q:i},s=Math.floor(s),n=Math.floor(n);let o=[],c=[],l=[],h=[],u=new E,d=new E,f=new E,p=new E,m=new E,b=new E,g=new E;for(let T=0;T<=s;++T){let y=T/s*a*Math.PI*2;x(y,a,i,e,f),x(y+.01,a,i,e,p),b.subVectors(p,f),g.addVectors(p,f),m.crossVectors(b,g),g.crossVectors(m,b),m.normalize(),g.normalize();for(let v=0;v<=n;++v){let _=v/n*Math.PI*2,A=-t*Math.cos(_),M=t*Math.sin(_);u.x=f.x+(A*g.x+M*m.x),u.y=f.y+(A*g.y+M*m.y),u.z=f.z+(A*g.z+M*m.z),c.push(u.x,u.y,u.z),d.subVectors(u,f).normalize(),l.push(d.x,d.y,d.z),h.push(T/s),h.push(v/n)}}for(let T=1;T<=s;T++)for(let y=1;y<=n;y++){let v=(n+1)*(T-1)+(y-1),_=(n+1)*T+(y-1),A=(n+1)*T+y,M=(n+1)*(T-1)+y;o.push(v,_,M),o.push(_,A,M)}this.setIndex(o),this.setAttribute("position",new ge(c,3)),this.setAttribute("normal",new ge(l,3)),this.setAttribute("uv",new ge(h,2));function x(T,y,v,_,A){let M=Math.cos(T),N=Math.sin(T),R=v/y*T,I=Math.cos(R);A.x=_*(2+I)*.5*M,A.y=_*(2+I)*N*.5,A.z=_*Math.sin(R)*.5}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new r(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}},yp=class r extends ke{constructor(e=new eu(new E(-1,-1,0),new E(-1,1,0),new E(1,1,0)),t=64,s=1,n=8,a=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:s,radialSegments:n,closed:a};let i=e.computeFrenetFrames(t,a);this.tangents=i.tangents,this.normals=i.normals,this.binormals=i.binormals;let o=new E,c=new E,l=new q,h=new E,u=[],d=[],f=[],p=[];m(),this.setIndex(p),this.setAttribute("position",new ge(u,3)),this.setAttribute("normal",new ge(d,3)),this.setAttribute("uv",new ge(f,2));function m(){for(let T=0;T<t;T++)b(T);b(a===!1?t:0),x(),g()}function b(T){h=e.getPointAt(T/t,h);let y=i.normals[T],v=i.binormals[T];for(let _=0;_<=n;_++){let A=_/n*Math.PI*2,M=Math.sin(A),N=-Math.cos(A);c.x=N*y.x+M*v.x,c.y=N*y.y+M*v.y,c.z=N*y.z+M*v.z,c.normalize(),d.push(c.x,c.y,c.z),o.x=h.x+s*c.x,o.y=h.y+s*c.y,o.z=h.z+s*c.z,u.push(o.x,o.y,o.z)}}function g(){for(let T=1;T<=t;T++)for(let y=1;y<=n;y++){let v=(n+1)*(T-1)+(y-1),_=(n+1)*T+(y-1),A=(n+1)*T+y,M=(n+1)*(T-1)+y;p.push(v,_,M),p.push(_,A,M)}}function x(){for(let T=0;T<=t;T++)for(let y=0;y<=n;y++)l.x=T/t,l.y=y/n,f.push(l.x,l.y)}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new r(new hy[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}},xp=class extends ke{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){let t=[],s=new Set,n=new E,a=new E;if(e.index!==null){let i=e.attributes.position,o=e.index,c=e.groups;c.length===0&&(c=[{start:0,count:o.count,materialIndex:0}]);for(let l=0,h=c.length;l<h;++l){let u=c[l],d=u.start,f=u.count;for(let p=d,m=d+f;p<m;p+=3)for(let b=0;b<3;b++){let g=o.getX(p+b),x=o.getX(p+(b+1)%3);n.fromBufferAttribute(i,g),a.fromBufferAttribute(i,x),U8(n,a,s)===!0&&(t.push(n.x,n.y,n.z),t.push(a.x,a.y,a.z))}}}else{let i=e.attributes.position;for(let o=0,c=i.count/3;o<c;o++)for(let l=0;l<3;l++){let h=3*o+l,u=3*o+(l+1)%3;n.fromBufferAttribute(i,h),a.fromBufferAttribute(i,u),U8(n,a,s)===!0&&(t.push(n.x,n.y,n.z),t.push(a.x,a.y,a.z))}}this.setAttribute("position",new ge(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}};function U8(r,e,t){let s=`${r.x},${r.y},${r.z}-${e.x},${e.y},${e.z}`,n=`${e.x},${e.y},${e.z}-${r.x},${r.y},${r.z}`;return t.has(s)===!0||t.has(n)===!0?!1:(t.add(s),t.add(n),!0)}var L8=Object.freeze({__proto__:null,BoxGeometry:kr,CapsuleGeometry:Zf,CircleGeometry:Qf,ConeGeometry:$h,CylinderGeometry:Kc,DodecahedronGeometry:ep,EdgesGeometry:tp,ExtrudeGeometry:hp,IcosahedronGeometry:up,LatheGeometry:dp,OctahedronGeometry:nu,PlaneGeometry:au,PolyhedronGeometry:Ir,RingGeometry:fp,ShapeGeometry:pp,SphereGeometry:Yc,TetrahedronGeometry:mp,TorusGeometry:bp,TorusKnotGeometry:gp,TubeGeometry:yp,WireframeGeometry:xp}),iu=class extends Rt{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new be(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}};function ND(r){let e={};for(let t in r){e[t]={};for(let s in r[t]){let n=r[t][s];if(z8(n))n.isRenderTargetTexture?(K("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][s]=null):e[t][s]=n.clone();else if(Array.isArray(n))if(z8(n[0])){let a=[];for(let i=0,o=n.length;i<o;i++)a[i]=n[i].clone();e[t][s]=a}else e[t][s]=n.slice();else e[t][s]=n}}return e}function z8(r){return r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)}function RD(r){let e=[];for(let t=0;t<r.length;t++)e.push(r[t].clone());return e}var ED=`void main() {
	gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,CD=`void main() {
	gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
}`,ru=class extends Rt{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=ED,this.fragmentShader=CD,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,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=ND(e.uniforms),this.uniformsGroups=RD(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let n in this.uniforms){let i=this.uniforms[n].value;i&&i.isTexture?t.uniforms[n]={type:"t",value:i.toJSON(e).uuid}:i&&i.isColor?t.uniforms[n]={type:"c",value:i.getHex()}:i&&i.isVector2?t.uniforms[n]={type:"v2",value:i.toArray()}:i&&i.isVector3?t.uniforms[n]={type:"v3",value:i.toArray()}:i&&i.isVector4?t.uniforms[n]={type:"v4",value:i.toArray()}:i&&i.isMatrix3?t.uniforms[n]={type:"m3",value:i.toArray()}:i&&i.isMatrix4?t.uniforms[n]={type:"m4",value:i.toArray()}:t.uniforms[n]={value:i}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let s={};for(let n in this.extensions)this.extensions[n]===!0&&(s[n]=!0);return Object.keys(s).length>0&&(t.extensions=s),t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(let s in e.uniforms){let n=e.uniforms[s];switch(this.uniforms[s]={},n.type){case"t":this.uniforms[s].value=t[n.value]||null;break;case"c":this.uniforms[s].value=new be().setHex(n.value);break;case"v2":this.uniforms[s].value=new q().fromArray(n.value);break;case"v3":this.uniforms[s].value=new E().fromArray(n.value);break;case"v4":this.uniforms[s].value=new Ge().fromArray(n.value);break;case"m3":this.uniforms[s].value=new Fs().fromArray(n.value);break;case"m4":this.uniforms[s].value=new le().fromArray(n.value);break;default:this.uniforms[s].value=n.value}}if(e.defines!==void 0&&(this.defines=e.defines),e.vertexShader!==void 0&&(this.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(this.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(this.glslVersion=e.glslVersion),e.extensions!==void 0)for(let s in e.extensions)this.extensions[s]=e.extensions[s];return e.lights!==void 0&&(this.lights=e.lights),e.clipping!==void 0&&(this.clipping=e.clipping),this}},wp=class extends ru{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}},An=class extends Rt{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new be(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new be(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=aa,this.normalScale=new q(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Na,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},xs=class extends An{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new q(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Be(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new be(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new be(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new be(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._retroreflectivity=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get retroreflectivity(){return this._retroreflectivity}set retroreflectivity(e){this._retroreflectivity>0!=e>0&&this.version++,this._retroreflectivity=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.retroreflectivity=e.retroreflectivity,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}},So=class extends Rt{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new be(16777215),this.specular=new be(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new be(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=aa,this.normalScale=new q(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Na,this.combine=wu,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},No=class extends Rt{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new be(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new be(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=aa,this.normalScale=new q(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(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},Ro=class extends Rt{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=aa,this.normalScale=new q(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}},Di=class extends Rt{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new be(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new be(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=aa,this.normalScale=new q(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Na,this.combine=wu,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},Tp=class extends Rt{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=W_,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}},vp=class extends Rt{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}},Eo=class extends Rt{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new be(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=aa,this.normalScale=new q(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this.fog=e.fog,this}},Zc=class extends ns{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}};function ti(r,e){return!r||r.constructor===e?r:typeof e.BYTES_PER_ELEMENT=="number"?new e(r):Array.prototype.slice.call(r)}function Vf(r){return r!==void 0&&r.inTangents!==void 0&&r.outTangents!==void 0}function OC(r){function e(n,a){return r[n]-r[a]}let t=r.length,s=new Array(t);for(let n=0;n!==t;++n)s[n]=n;return s.sort(e),s}function N_(r,e,t){let s=r.length,n=new r.constructor(s);for(let a=0,i=0;i!==s;++a){let o=t[a]*e;for(let c=0;c!==e;++c)n[i++]=r[o+c]}return n}function UC(r,e,t,s){let n=1,a=r[0];for(;a!==void 0&&a[s]===void 0;)a=r[n++];if(a===void 0)return;let i=a[s];if(i!==void 0)if(Array.isArray(i))do i=a[s],i!==void 0&&(e.push(a.time),t.push(...i)),a=r[n++];while(a!==void 0);else if(i.toArray!==void 0)do i=a[s],i!==void 0&&(e.push(a.time),i.toArray(t,t.length)),a=r[n++];while(a!==void 0);else do i=a[s],i!==void 0&&(e.push(a.time),t.push(i)),a=r[n++];while(a!==void 0)}function kD(r,e,t,s,n=30){let a=r.clone();a.name=e;let i=[];for(let c=0;c<a.tracks.length;++c){let l=a.tracks[c],h=l.getValueSize(),u=[],d=[];for(let f=0;f<l.times.length;++f){let p=l.times[f]*n;if(!(p<t||p>=s)){u.push(l.times[f]);for(let m=0;m<h;++m)d.push(l.values[f*h+m])}}u.length!==0&&(l.times=ti(u,l.times.constructor),l.values=ti(d,l.values.constructor),i.push(l))}a.tracks=i;let o=1/0;for(let c=0;c<a.tracks.length;++c)o>a.tracks[c].times[0]&&(o=a.tracks[c].times[0]);for(let c=0;c<a.tracks.length;++c)a.tracks[c].shift(-1*o);return a.resetDuration(),a}function ID(r,e=0,t=r,s=30){s<=0&&(s=30);let n=t.tracks.length,a=e/s;for(let i=0;i<n;++i){let o=t.tracks[i],c=o.ValueTypeName;if(c==="bool"||c==="string")continue;let l=r.tracks.find(function(g){return g.name===o.name&&g.ValueTypeName===c});if(l===void 0)continue;let h=0,u=o.getValueSize();o.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(h=u/3);let d=0,f=l.getValueSize();l.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(d=f/3);let p=o.times.length-1,m;if(a<=o.times[0]){let g=h,x=u-h;m=o.values.slice(g,x)}else if(a>=o.times[p]){let g=p*u+h,x=g+u-h;m=o.values.slice(g,x)}else{let g=o.createInterpolant(),x=h,T=u-h;g.evaluate(a),m=g.resultBuffer.slice(x,T)}c==="quaternion"&&new It().fromArray(m).normalize().conjugate().toArray(m);let b=l.times.length;for(let g=0;g<b;++g){let x=g*f+d;if(c==="quaternion")It.multiplyQuaternionsFlat(l.values,x,m,0,l.values,x);else{let T=f-d*2;for(let y=0;y<T;++y)l.values[x+y]-=m[y]}}}return r.blendMode=mx,r}var uy=class{static convertArray(e,t){return ti(e,t)}static isTypedArray(e){return bl(e)}static hasTangents(e){return Vf(e)}static getKeyframeOrder(e){return OC(e)}static sortedArray(e,t,s){return N_(e,t,s)}static flattenJSON(e,t,s,n){UC(e,t,s,n)}static subclip(e,t,s,n,a=30){return kD(e,t,s,n,a)}static makeClipAdditive(e,t=0,s=e,n=30){return ID(e,t,s,n)}},li=class{constructor(e,t,s,n){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=n!==void 0?n:new t.constructor(s),this.sampleValues=t,this.valueSize=s,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,s=this._cachedIndex,n=t[s],a=t[s-1];e:{t:{let i;s:{n:if(!(e<n)){for(let o=s+2;;){if(n===void 0){if(e<a)break n;return s=t.length,this._cachedIndex=s,this.copySampleValue_(s-1)}if(s===o)break;if(a=n,n=t[++s],e<n)break t}i=t.length;break s}if(!(e>=a)){let o=t[1];e<o&&(s=2,a=o);for(let c=s-2;;){if(a===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(s===c)break;if(n=a,a=t[--s-1],e>=a)break t}i=s,s=0;break s}break e}for(;s<i;){let o=s+i>>>1;e<t[o]?i=o:s=o+1}if(n=t[s],a=t[s-1],a===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===void 0)return s=t.length,this._cachedIndex=s,this.copySampleValue_(s-1)}this._cachedIndex=s,this.intervalChanged_(s,a,n)}return this.interpolate_(s,a,e,n)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,s=this.sampleValues,n=this.valueSize,a=e*n;for(let i=0;i!==n;++i)t[i]=s[a+i];return t}interpolate_(){throw new Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}},_p=class extends li{constructor(e,t,s,n){super(e,t,s,n),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:yo,endingEnd:yo}}intervalChanged_(e,t,s){let n=this.parameterPositions,a=e-2,i=e+1,o=n[a],c=n[i];if(o===void 0)switch(this.getSettings_().endingStart){case xo:a=e,o=2*t-s;break;case zh:a=n.length-2,o=t+n[a]-n[a+1];break;default:a=e,o=s}if(c===void 0)switch(this.getSettings_().endingEnd){case xo:i=e,c=2*s-t;break;case zh:i=1,c=s+n[1]-n[0];break;default:i=e-1,c=t}let l=(s-t)*.5,h=this.valueSize;this._weightPrev=l/(t-o),this._weightNext=l/(c-s),this._offsetPrev=a*h,this._offsetNext=i*h}interpolate_(e,t,s,n){let a=this.resultBuffer,i=this.sampleValues,o=this.valueSize,c=e*o,l=c-o,h=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,f=this._weightNext,p=(s-t)/(n-t),m=p*p,b=m*p,g=-d*b+2*d*m-d*p,x=(1+d)*b+(-1.5-2*d)*m+(-.5+d)*p+1,T=(-1-f)*b+(1.5+f)*m+.5*p,y=f*b-f*m;for(let v=0;v!==o;++v)a[v]=g*i[h+v]+x*i[l+v]+T*i[c+v]+y*i[u+v];return a}},ou=class extends li{constructor(e,t,s,n){super(e,t,s,n)}interpolate_(e,t,s,n){let a=this.resultBuffer,i=this.sampleValues,o=this.valueSize,c=e*o,l=c-o,h=(s-t)/(n-t),u=1-h;for(let d=0;d!==o;++d)a[d]=i[l+d]*u+i[c+d]*h;return a}},Ap=class extends li{constructor(e,t,s,n){super(e,t,s,n)}interpolate_(e){return this.copySampleValue_(e-1)}},Mp=class extends li{interpolate_(e,t,s,n){let a=this.resultBuffer,i=this.sampleValues,o=this.valueSize,c=e*o,l=c-o,h=this.inTangents,u=this.outTangents;if(!h||!u){let p=(s-t)/(n-t),m=1-p;for(let b=0;b!==o;++b)a[b]=i[l+b]*m+i[c+b]*p;return a}let d=o*2,f=e-1;for(let p=0;p!==o;++p){let m=i[l+p],b=i[c+p],g=f*d+p*2,x=u[g],T=u[g+1],y=e*d+p*2,v=h[y],_=h[y+1],A=FD(s,t,x,v,n);a[p]=LC(A,m,T,_,b)}return a}};function LC(r,e,t,s,n){let a=1-r;return a*a*a*e+3*a*a*r*t+3*a*r*r*s+r*r*r*n}function BD(r,e,t,s,n){let a=1-r;return 3*a*a*(t-e)+6*a*r*(s-t)+3*r*r*(n-s)}function FD(r,e,t,s,n){let a=(r-e)/(n-e);for(let i=0;i<8;i++){let o=LC(a,e,t,s,n)-r;if(Math.abs(o)<1e-10)break;let c=BD(a,e,t,s,n);if(Math.abs(c)<1e-10)break;a=Math.max(0,Math.min(1,a-o/c))}return a}var Mn=class{constructor(e,t,s,n){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=ti(t,this.TimeBufferType),this.values=ti(s,this.ValueBufferType),this.setInterpolation(n||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,s;if(t.toJSON!==this.toJSON)s=t.toJSON(e);else{s={name:e.name,times:ti(e.times,Array),values:ti(e.values,Array)};let n=e.getInterpolation();n!==e.DefaultInterpolation&&(s.interpolation=n),Vf(e.settings)&&(s.settings={inTangents:ti(e.settings.inTangents,Array),outTangents:ti(e.settings.outTangents,Array)})}return s.type=e.ValueTypeName,s}InterpolantFactoryMethodDiscrete(e){return new Ap(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new ou(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new _p(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){let t=new Mp(this.times,this.values,this.getValueSize(),e);return this.settings&&(t.inTangents=this.settings.inTangents,t.outTangents=this.settings.outTangents),t}setInterpolation(e){let t;switch(e){case wo:t=this.InterpolantFactoryMethodDiscrete;break;case To:t=this.InterpolantFactoryMethodLinear;break;case Of:t=this.InterpolantFactoryMethodSmooth;break;case Wg:t=this.InterpolantFactoryMethodBezier;break}if(t===void 0){let s="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(s);return K("KeyframeTrack:",s),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return wo;case this.InterpolantFactoryMethodLinear:return To;case this.InterpolantFactoryMethodSmooth:return Of;case this.InterpolantFactoryMethodBezier:return Wg}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let s=0,n=t.length;s!==n;++s)t[s]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let s=0,n=t.length;s!==n;++s)t[s]*=e;Vf(this.settings)&&(V8(this.settings.inTangents,e),V8(this.settings.outTangents,e))}return this}trim(e,t){let s=this.times,n=s.length,a=0,i=n-1;for(;a!==n&&s[a]<e;)++a;for(;i!==-1&&s[i]>t;)--i;if(++i,a!==0||i!==n){a>=i&&(i=Math.max(i,1),a=i-1);let o=this.getValueSize();this.times=s.slice(a,i),this.values=this.values.slice(a*o,i*o)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(W("KeyframeTrack: Invalid value size in track.",this),e=!1);let s=this.times,n=this.values,a=s.length;a===0&&(W("KeyframeTrack: Track is empty.",this),e=!1);let i=null;for(let o=0;o!==a;o++){let c=s[o];if(typeof c=="number"&&isNaN(c)){W("KeyframeTrack: Time is not a valid number.",this,o,c),e=!1;break}if(i!==null&&i>c){W("KeyframeTrack: Out of order keys.",this,o,c,i),e=!1;break}i=c}if(n!==void 0&&bl(n))for(let o=0,c=n.length;o!==c;++o){let l=n[o];if(isNaN(l)){W("KeyframeTrack: Value is not a valid number.",this,o,l),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),s=this.getValueSize(),n=this.getInterpolation()===Of,a=e.length-1,i=1;for(let o=1;o<a;++o){let c=!1,l=e[o],h=e[o+1];if(l!==h&&(o!==1||l!==e[0]))if(n)c=!0;else{let u=o*s,d=u-s,f=u+s;for(let p=0;p!==s;++p){let m=t[u+p];if(m!==t[d+p]||m!==t[f+p]){c=!0;break}}}if(c){if(o!==i){e[i]=e[o];let u=o*s,d=i*s;for(let f=0;f!==s;++f)t[d+f]=t[u+f]}++i}}if(a>0){e[i]=e[a];for(let o=a*s,c=i*s,l=0;l!==s;++l)t[c+l]=t[o+l];++i}return i!==e.length?(this.times=e.slice(0,i),this.values=t.slice(0,i*s)):(this.times=e,this.values=t),this}clone(){let e=this.times.slice(),t=this.values.slice(),s=this.constructor,n=new s(this.name,e,t);return n.createInterpolant=this.createInterpolant,Vf(this.settings)&&(n.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()}),n}};function V8(r,e){for(let t=0,s=r.length;t!==s;t+=2)r[t]*=e}Mn.prototype.ValueTypeName="";Mn.prototype.TimeBufferType=Float32Array;Mn.prototype.ValueBufferType=Float32Array;Mn.prototype.DefaultInterpolation=To;var Oi=class extends Mn{constructor(e,t,s){super(e,t,s)}};Oi.prototype.ValueTypeName="bool";Oi.prototype.ValueBufferType=Array;Oi.prototype.DefaultInterpolation=wo;Oi.prototype.InterpolantFactoryMethodLinear=void 0;Oi.prototype.InterpolantFactoryMethodSmooth=void 0;var cu=class extends Mn{constructor(e,t,s,n){super(e,t,s,n)}};cu.prototype.ValueTypeName="color";var Ui=class extends Mn{constructor(e,t,s,n){super(e,t,s,n)}};Ui.prototype.ValueTypeName="number";var Sp=class extends li{constructor(e,t,s,n){super(e,t,s,n)}interpolate_(e,t,s,n){let a=this.resultBuffer,i=this.sampleValues,o=this.valueSize,c=(s-t)/(n-t),l=e*o;for(let h=l+o;l!==h;l+=4)It.slerpFlat(a,0,i,l-o,i,l,c);return a}},Li=class extends Mn{constructor(e,t,s,n){super(e,t,s,n)}InterpolantFactoryMethodLinear(e){return new Sp(this.times,this.values,this.getValueSize(),e)}};Li.prototype.ValueTypeName="quaternion";Li.prototype.InterpolantFactoryMethodSmooth=void 0;var zi=class extends Mn{constructor(e,t,s){super(e,t,s)}};zi.prototype.ValueTypeName="string";zi.prototype.ValueBufferType=Array;zi.prototype.DefaultInterpolation=wo;zi.prototype.InterpolantFactoryMethodLinear=void 0;zi.prototype.InterpolantFactoryMethodSmooth=void 0;var Br=class extends Mn{constructor(e,t,s,n){super(e,t,s,n)}};Br.prototype.ValueTypeName="vector";var Vi=class{constructor(e="",t=-1,s=[],n=Xp){this.name=e,this.tracks=s,this.duration=t,this.blendMode=n,this.uuid=Yn(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){let t=[],s=e.tracks,n=1/(e.fps||1);for(let i=0,o=s.length;i!==o;++i)t.push(DD(s[i]).scale(n));let a=new this(e.name,e.duration,t,e.blendMode);return a.uuid=e.uuid,a.userData=JSON.parse(e.userData||"{}"),a}static toJSON(e){let t=[],s=e.tracks,n={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let a=0,i=s.length;a!==i;++a)t.push(Mn.toJSON(s[a]));return n}static CreateFromMorphTargetSequence(e,t,s,n){let a=t.length,i=[];for(let o=0;o<a;o++){let c=[],l=[];c.push((o+a-1)%a,o,(o+1)%a),l.push(0,1,0);let h=OC(c);c=N_(c,1,h),l=N_(l,1,h),!n&&c[0]===0&&(c.push(a),l.push(l[0])),i.push(new Ui(".morphTargetInfluences["+t[o].name+"]",c,l).scale(1/s))}return new this(e,-1,i)}static findByName(e,t){let s=e;if(!Array.isArray(e)){let n=e;s=n.geometry&&n.geometry.animations||n.animations}for(let n=0;n<s.length;n++)if(s[n].name===t)return s[n];return null}static CreateClipsFromMorphTargetSequences(e,t,s){let n={},a=/^([\w-]*?)([\d]+)$/;for(let o=0,c=e.length;o<c;o++){let l=e[o],h=l.name.match(a);if(h&&h.length>1){let u=h[1],d=n[u];d||(n[u]=d=[]),d.push(l)}}let i=[];for(let o in n)i.push(this.CreateFromMorphTargetSequence(o,n[o],t,s));return i}resetDuration(){let e=this.tracks,t=0;for(let s=0,n=e.length;s!==n;++s){let a=this.tracks[s];t=Math.max(t,a.times[a.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let s=0;s<this.tracks.length;s++)e.push(this.tracks[s].clone());let t=new this.constructor(this.name,this.duration,e,this.blendMode);return t.userData=JSON.parse(JSON.stringify(this.userData)),t}toJSON(){return this.constructor.toJSON(this)}};function PD(r){switch(r.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Ui;case"vector":case"vector2":case"vector3":case"vector4":return Br;case"color":return cu;case"quaternion":return Li;case"bool":case"boolean":return Oi;case"string":return zi}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+r)}function DD(r){if(r.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let e=PD(r.type);if(r.times===void 0){let s=[],n=[];UC(r.keys,s,n,"value"),r.times=s,r.values=n}let t;return e.parse!==void 0?t=e.parse(r):t=new e(r.name,r.times,r.values,r.interpolation),Vf(r.settings)&&(t.settings={inTangents:ti(r.settings.inTangents,Float32Array),outTangents:ti(r.settings.outTangents,Float32Array)}),t}var ni={enabled:!1,files:{},add:function(r,e){this.enabled!==!1&&(j8(r)||(this.files[r]=e))},get:function(r){if(this.enabled!==!1&&!j8(r))return this.files[r]},remove:function(r){delete this.files[r]},clear:function(){this.files={}}};function j8(r){try{let e=r.slice(r.indexOf(":")+1);return new URL(e).protocol==="blob:"}catch{return!1}}var lu=class{constructor(e,t,s){let n=this,a=!1,i=0,o=0,c,l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=s,this._abortController=null,this.itemStart=function(h){o++,a===!1&&n.onStart!==void 0&&n.onStart(h,i,o),a=!0},this.itemEnd=function(h){i++,n.onProgress!==void 0&&n.onProgress(h,i,o),i===o&&(a=!1,n.onLoad!==void 0&&n.onLoad())},this.itemError=function(h){n.onError!==void 0&&n.onError(h)},this.resolveURL=function(h){return h=h.normalize("NFC"),c?c(h):h},this.setURLModifier=function(h){return c=h,this},this.addHandler=function(h,u){return l.push(h,u),this},this.removeHandler=function(h){let u=l.indexOf(h);return u!==-1&&l.splice(u,2),this},this.getHandler=function(h){for(let u=0,d=l.length;u<d;u+=2){let f=l[u],p=l[u+1];if(f.global&&(f.lastIndex=0),f.test(h))return p}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}},uA=new lu,us=class{constructor(e){this.manager=e!==void 0?e:uA,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(e,t){let s=this;return new Promise(function(n,a){s.load(e,n,t,a)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}};us.DEFAULT_MATERIAL_NAME="__DEFAULT";var Sr={},R_=class extends Error{constructor(e,t){super(e),this.response=t}},an=class extends us{constructor(e){super(e),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,t,s,n){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let a=ni.get(`file:${e}`);if(a!==void 0){this.manager.itemStart(e),setTimeout(()=>{t&&t(a),this.manager.itemEnd(e)},0);return}if(Sr[e]!==void 0){Sr[e].push({onLoad:t,onProgress:s,onError:n});return}Sr[e]=[],Sr[e].push({onLoad:t,onProgress:s,onError:n});let i=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),o=this.mimeType,c=this.responseType;fetch(i).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&K("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;let h=Sr[e],u=l.body.getReader(),d=l.headers.get("X-File-Size")||l.headers.get("Content-Length"),f=d?parseInt(d):0,p=f!==0,m=0,b=new ReadableStream({start(g){x();function x(){u.read().then(({done:T,value:y})=>{if(T)g.close();else{m+=y.byteLength;let v=new ProgressEvent("progress",{lengthComputable:p,loaded:m,total:f});for(let _=0,A=h.length;_<A;_++){let M=h[_];M.onProgress&&M.onProgress(v)}g.enqueue(y),x()}},T=>{g.error(T)})}}});return new Response(b)}else throw new R_(`fetch for "${l.url}" responded with ${l.status}: ${l.statusText}`,l)}).then(l=>{switch(c){case"arraybuffer":return l.arrayBuffer();case"blob":return l.blob();case"document":return l.text().then(h=>new DOMParser().parseFromString(h,o));case"json":return l.json();default:if(o==="")return l.text();{let u=/charset="?([^;"\s]*)"?/i.exec(o),d=u&&u[1]?u[1].toLowerCase():void 0,f=new TextDecoder(d);return l.arrayBuffer().then(p=>f.decode(p))}}}).then(l=>{ni.add(`file:${e}`,l);let h=Sr[e];delete Sr[e];for(let u=0,d=h.length;u<d;u++){let f=h[u];f.onLoad&&f.onLoad(l)}}).catch(l=>{let h=Sr[e];if(h===void 0)throw this.manager.itemError(e),l;delete Sr[e];for(let u=0,d=h.length;u<d;u++){let f=h[u];f.onError&&f.onError(l)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}},dy=class extends us{constructor(e){super(e)}load(e,t,s,n){let a=this,i=new an(this.manager);i.setPath(this.path),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(e,function(o){try{t(a.parse(JSON.parse(o)))}catch(c){n?n(c):W(c),a.manager.itemError(e)}},s,n)}parse(e){let t=[];for(let s=0;s<e.length;s++){let n=Vi.parse(e[s]);t.push(n)}return t}},fy=class extends us{constructor(e){super(e)}load(e,t,s,n){let a=this,i=[],o=new Xc,c=new an(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(a.withCredentials);let l=0;function h(u){c.load(e[u],function(d){let f=a.parse(d,!0);i[u]={width:f.width,height:f.height,format:f.format,mipmaps:f.mipmaps},l+=1,l===6&&(f.mipmapCount===1&&(o.minFilter=Ye),o.image=i,o.format=f.format,o.needsUpdate=!0,t&&t(o))},s,n)}if(Array.isArray(e))for(let u=0,d=e.length;u<d;++u)h(u);else c.load(e,function(u){let d=a.parse(u,!0);if(d.isCubemap){let f=d.mipmaps.length/d.mipmapCount;for(let p=0;p<f;p++){i[p]={mipmaps:[]};for(let m=0;m<d.mipmapCount;m++)i[p].mipmaps.push(d.mipmaps[p*d.mipmapCount+m]),i[p].format=d.format,i[p].width=d.width,i[p].height=d.height}o.image=i}else o.image.width=d.width,o.image.height=d.height,o.mipmaps=d.mipmaps;d.mipmapCount===1&&(o.minFilter=Ye),o.format=d.format,o.needsUpdate=!0,t&&t(o)},s,n);return o}},Mh=new WeakMap,Co=class extends us{constructor(e){super(e)}load(e,t,s,n){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let a=this,i=ni.get(`image:${e}`);if(i!==void 0){if(i.complete===!0)a.manager.itemStart(e),setTimeout(function(){t&&t(i),a.manager.itemEnd(e)},0);else{let u=Mh.get(i);u===void 0&&(u=[],Mh.set(i,u)),u.push({onLoad:t,onError:n})}return i}let o=qg("img");function c(){h(),t&&t(this);let u=Mh.get(this)||[];for(let d=0;d<u.length;d++){let f=u[d];f.onLoad&&f.onLoad(this)}Mh.delete(this),a.manager.itemEnd(e)}function l(u){h(),n&&n(u),ni.remove(`image:${e}`);let d=Mh.get(this)||[];for(let f=0;f<d.length;f++){let p=d[f];p.onError&&p.onError(u)}Mh.delete(this),a.manager.itemError(e),a.manager.itemEnd(e)}function h(){o.removeEventListener("load",c,!1),o.removeEventListener("error",l,!1)}return o.addEventListener("load",c,!1),o.addEventListener("error",l,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),ni.add(`image:${e}`,o),a.manager.itemStart(e),o.src=e,o}},py=class extends us{constructor(e){super(e)}load(e,t,s,n){let a=new Pi;a.colorSpace=Wt;let i=new Co(this.manager);i.setCrossOrigin(this.crossOrigin),i.setPath(this.path);let o=0;function c(l){i.load(e[l],function(h){a.images[l]=h,o++,o===6&&(a.needsUpdate=!0,t&&t(a))},void 0,n)}for(let l=0;l<e.length;++l)c(l);return a}},my=class extends us{constructor(e){super(e)}load(e,t,s,n){let a=this,i=new Is,o=new an(this.manager);return o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setPath(this.path),o.setWithCredentials(a.withCredentials),o.load(e,function(c){let l;try{l=a.parse(c)}catch(h){n!==void 0?n(h):W(h);return}a._applyTexData(i,l),t&&t(i,l)},s,n),i}createDataTexture(e){let t=new Is;return this._applyTexData(t,this.parse(e)),t}_applyTexData(e,t){t.image!==void 0?e.image=t.image:t.data!==void 0&&(e.image.width=t.width,e.image.height=t.height,e.image.data=t.data),e.wrapS=t.wrapS!==void 0?t.wrapS:hs,e.wrapT=t.wrapT!==void 0?t.wrapT:hs,e.magFilter=t.magFilter!==void 0?t.magFilter:Ye,e.minFilter=t.minFilter!==void 0?t.minFilter:Ye,e.anisotropy=t.anisotropy!==void 0?t.anisotropy:1,t.colorSpace!==void 0&&(e.colorSpace=t.colorSpace),t.flipY!==void 0&&(e.flipY=t.flipY),t.format!==void 0&&(e.format=t.format),t.type!==void 0&&(e.type=t.type),t.mipmaps!==void 0&&(e.mipmaps=t.mipmaps,e.minFilter=on),t.mipmapCount===1&&(e.minFilter=Ye),t.generateMipmaps!==void 0&&(e.generateMipmaps=t.generateMipmaps),e.needsUpdate=!0}},hu=class extends us{constructor(e){super(e)}load(e,t,s,n){let a=new gt,i=new Co(this.manager);return i.setCrossOrigin(this.crossOrigin),i.setPath(this.path),i.load(e,function(o){a.image=o,a.needsUpdate=!0,t!==void 0&&t(a)},s,n),a}},hi=class extends Ze{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new be(e),this.intensity=t}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}},Qc=class extends hi{constructor(e,t,s){super(e,s),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Ze.DEFAULT_UP),this.updateMatrix(),this.groundColor=new be(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){let t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}},m_=new le,G8=new E,H8=new E,el=class{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new q(512,512),this.mapType=ws,this.map=null,this.mapPass=null,this.matrix=new le,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new ci,this._frameExtents=new q(1,1),this._viewportCount=1,this._viewports=[new Ge(0,0,1,1)]}getViewportCount(){return this._viewportCount}getCamera(){return this.camera}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera;G8.setFromMatrixPosition(e.matrixWorld),t.position.copy(G8),H8.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(H8),t.updateMatrixWorld(),this._updateMatrix(t,this.matrix,this._frustum)}_updateMatrix(e,t,s,n){m_.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),s.setFromProjectionMatrix(m_,e.coordinateSystem,e.reversedDepth);let a=this._frameExtents,i=n?n.z/a.x:1,o=n?n.w/a.y:1,c=n?n.x/a.x:0,l=n?n.y/a.y:0;e.coordinateSystem===Xs||e.reversedDepth?t.set(.5*i,0,0,.5*i+c,0,.5*o,0,.5*o+l,0,0,1,0,0,0,0,1):t.set(.5*i,0,0,.5*i+c,0,.5*o,0,.5*o+l,0,0,.5,.5,0,0,0,1),t.multiply(m_)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this.biasNode=e.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return e.intensity=this.intensity,e.bias=this.bias,e.normalBias=this.normalBias,e.radius=this.radius,e.blurSamples=this.blurSamples,e.mapSize=this.mapSize.toArray(),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}},Pg=new E,Dg=new It,Fi=new E,tl=class extends Ze{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new le,this.projectionMatrix=new le,this.projectionMatrixInverse=new le,this.coordinateSystem=sn,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorld.decompose(Pg,Dg,Fi),Fi.x===1&&Fi.y===1&&Fi.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Pg,Dg,Fi.set(1,1,1)).invert()}updateWorldMatrix(e,t,s=!1){super.updateWorldMatrix(e,t,s),this.matrixWorld.decompose(Pg,Dg,Fi),Fi.x===1&&Fi.y===1&&Fi.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Pg,Dg,Fi.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}},bo=new E,W8=new q,q8=new q,qt=class extends tl{constructor(e=50,t=1,s=.1,n=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=s,this.far=n,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=.5*this.getFilmHeight()/e;this.fov=zc*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(Uc*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return zc*2*Math.atan(Math.tan(Uc*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,s){bo.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(bo.x,bo.y).multiplyScalar(-e/bo.z),bo.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),s.set(bo.x,bo.y).multiplyScalar(-e/bo.z)}getViewSize(e,t){return this.getViewBounds(e,W8,q8),t.subVectors(q8,W8)}setViewOffset(e,t,s,n,a,i){this.aspect=e/t,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=e,this.view.fullHeight=t,this.view.offsetX=s,this.view.offsetY=n,this.view.width=a,this.view.height=i,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(Uc*.5*this.fov)/this.zoom,s=2*t,n=this.aspect*s,a=-.5*n,i=this.view;if(this.view!==null&&this.view.enabled){let c=i.fullWidth,l=i.fullHeight;a+=i.offsetX*n/c,t-=i.offsetY*s/l,n*=i.width/c,s*=i.height/l}let o=this.filmOffset;o!==0&&(a+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(a,a+n,t,t-s,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}},E_=class extends el{constructor(){super(new qt(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){let t=this.camera,s=zc*2*e.angle*this.focus,n=this.mapSize.width/this.mapSize.height*this.aspect,a=e.distance||t.far;(s!==t.fov||n!==t.aspect||a!==t.far)&&(t.fov=s,t.aspect=n,t.far=a,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this.aspect=e.aspect,this}toJSON(){let e=super.toJSON();return e.focus=this.focus,e.aspect=this.aspect,e}},ui=class extends hi{constructor(e,t,s=0,n=Math.PI/3,a=0,i=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Ze.DEFAULT_UP),this.updateMatrix(),this.target=new Ze,this.distance=s,this.angle=n,this.penumbra=a,this.decay=i,this.map=null,this.shadow=new E_}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.map=e.map,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.distance=this.distance,t.object.angle=this.angle,t.object.decay=this.decay,t.object.penumbra=this.penumbra,t.object.target=this.target.uuid,this.map&&this.map.isTexture&&(t.object.map=this.map.toJSON(e).uuid),t.object.shadow=this.shadow.toJSON(),t}},C_=class extends el{constructor(){super(new qt(90,1,.5,500)),this.isPointLightShadow=!0}},di=class extends hi{constructor(e,t,s=0,n=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=s,this.decay=n,this.shadow=new C_}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.distance=this.distance,t.object.decay=this.decay,t.object.shadow=this.shadow.toJSON(),t}},ji=class extends tl{constructor(e=-1,t=1,s=1,n=-1,a=.1,i=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=s,this.bottom=n,this.near=a,this.far=i,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,s,n,a,i){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=e,this.view.fullHeight=t,this.view.offsetX=s,this.view.offsetY=n,this.view.width=a,this.view.height=i,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),s=(this.right+this.left)/2,n=(this.top+this.bottom)/2,a=s-e,i=s+e,o=n+t,c=n-t;if(this.view!==null&&this.view.enabled){let l=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;a+=l*this.view.offsetX,i=a+l*this.view.width,o-=h*this.view.offsetY,c=o-h*this.view.height}this.projectionMatrix.makeOrthographic(a,i,o,c,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}},k_=class extends el{constructor(){super(new ji(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},Fr=class extends hi{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Ze.DEFAULT_UP),this.updateMatrix(),this.target=new Ze,this.shadow=new k_}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}},sl=class extends hi{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}},nl=class extends hi{constructor(e,t,s=10,n=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=s,this.height=n}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){let t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}},uu=class{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new E)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){let s=e.x,n=e.y,a=e.z,i=this.coefficients;return t.copy(i[0]).multiplyScalar(.282095),t.addScaledVector(i[1],.488603*n),t.addScaledVector(i[2],.488603*a),t.addScaledVector(i[3],.488603*s),t.addScaledVector(i[4],1.092548*(s*n)),t.addScaledVector(i[5],1.092548*(n*a)),t.addScaledVector(i[6],.315392*(3*a*a-1)),t.addScaledVector(i[7],1.092548*(s*a)),t.addScaledVector(i[8],.546274*(s*s-n*n)),t}getIrradianceAt(e,t){let s=e.x,n=e.y,a=e.z,i=this.coefficients;return t.copy(i[0]).multiplyScalar(.886227),t.addScaledVector(i[1],2*.511664*n),t.addScaledVector(i[2],2*.511664*a),t.addScaledVector(i[3],2*.511664*s),t.addScaledVector(i[4],2*.429043*s*n),t.addScaledVector(i[5],2*.429043*n*a),t.addScaledVector(i[6],.743125*a*a-.247708),t.addScaledVector(i[7],2*.429043*s*a),t.addScaledVector(i[8],.429043*(s*s-n*n)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let s=0;s<9;s++)this.coefficients[s].addScaledVector(e.coefficients[s],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let s=0;s<9;s++)this.coefficients[s].lerp(e.coefficients[s],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(e,t=0){let s=this.coefficients;for(let n=0;n<9;n++)s[n].fromArray(e,t+n*3);return this}toArray(e=[],t=0){let s=this.coefficients;for(let n=0;n<9;n++)s[n].toArray(e,t+n*3);return e}static getBasisAt(e,t){let s=e.x,n=e.y,a=e.z;t[0]=.282095,t[1]=.488603*n,t[2]=.488603*a,t[3]=.488603*s,t[4]=1.092548*s*n,t[5]=1.092548*n*a,t[6]=.315392*(3*a*a-1),t[7]=1.092548*s*a,t[8]=.546274*(s*s-n*n)}},al=class extends hi{constructor(e=new uu,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}toJSON(e){let t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}},X8={},du=class r extends us{constructor(e){super(e),this.textures={}}load(e,t,s,n){let a=this,i=new an(a.manager);i.setPath(a.path),i.setRequestHeader(a.requestHeader),i.setWithCredentials(a.withCredentials),i.load(e,function(o){try{t(a.parse(JSON.parse(o)))}catch(c){n?n(c):W(c),a.manager.itemError(e)}},s,n)}parse(e){let t=this.createMaterialFromType(e.type);return t.fromJSON(e,this.textures),t}setTextures(e){return this.textures=e,this}createMaterialFromType(e){return r.createMaterialFromType(e)}static createMaterialFromType(e){let s={ShadowMaterial:iu,SpriteMaterial:Vc,RawShaderMaterial:wp,ShaderMaterial:ru,PointsMaterial:Cr,MeshPhysicalMaterial:xs,MeshStandardMaterial:An,MeshPhongMaterial:So,MeshToonMaterial:No,MeshNormalMaterial:Ro,MeshLambertMaterial:Di,MeshDepthMaterial:Tp,MeshDistanceMaterial:vp,MeshBasicMaterial:Bt,MeshMatcapMaterial:Eo,LineDashedMaterial:Zc,LineBasicMaterial:ns,Material:Rt,...X8}[e],n;return s===void 0?(je(`MaterialLoader: Unknown material type "${e}". Use .registerMaterial() before starting the deserialization process.`),n=new Rt):n=new s,n}static registerMaterial(e,t){X8[e]=t}},Ea=class{static extractUrlBase(e){let t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}},Np=class extends ke{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){let e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}},Rp=class extends us{constructor(e){super(e)}load(e,t,s,n){let a=this,i=new an(a.manager);i.setPath(a.path),i.setRequestHeader(a.requestHeader),i.setWithCredentials(a.withCredentials),i.load(e,function(o){try{t(a.parse(JSON.parse(o)))}catch(c){n?n(c):W(c),a.manager.itemError(e)}},s,n)}parse(e){let t={},s={};function n(f,p){if(t[p]!==void 0)return t[p];let b=f.interleavedBuffers[p],g=a(f,b.buffer),x=Ch(b.type,g),T=new ri(x,b.stride);return T.uuid=b.uuid,b.usage!==void 0&&T.setUsage(b.usage),t[p]=T,T}function a(f,p){if(s[p]!==void 0)return s[p];let b=f.arrayBuffers[p],g=new Uint32Array(b).buffer;return s[p]=g,g}let i=e.isInstancedBufferGeometry?new Np:new ke,o=e.data.index;if(o!==void 0){let f=Ch(o.type,o.array);i.setIndex(new Xe(f,1))}let c=e.data.attributes;for(let f in c){let p=c[f],m;if(p.isInterleavedBufferAttribute){let b=n(e.data,p.data);m=new Ra(b,p.itemSize,p.offset,p.normalized)}else{let b=Ch(p.type,p.array),g=p.isInstancedBufferAttribute?ys:Xe;m=new g(b,p.itemSize,p.normalized)}p.name!==void 0&&(m.name=p.name),p.usage!==void 0&&m.setUsage(p.usage),p.gpuType!==void 0&&(m.gpuType=p.gpuType),i.setAttribute(f,m)}let l=e.data.morphAttributes;if(l)for(let f in l){let p=l[f],m=[];for(let b=0,g=p.length;b<g;b++){let x=p[b],T;if(x.isInterleavedBufferAttribute){let y=n(e.data,x.data);T=new Ra(y,x.itemSize,x.offset,x.normalized)}else{let y=Ch(x.type,x.array);T=new Xe(y,x.itemSize,x.normalized)}x.name!==void 0&&(T.name=x.name),x.usage!==void 0&&T.setUsage(x.usage),x.gpuType!==void 0&&(T.gpuType=x.gpuType),m.push(T)}i.morphAttributes[f]=m}e.data.morphTargetsRelative&&(i.morphTargetsRelative=!0);let u=e.data.groups||e.data.drawcalls||e.data.offsets;if(u!==void 0)for(let f=0,p=u.length;f!==p;++f){let m=u[f];i.addGroup(m.start,m.count,m.materialIndex)}let d=e.data.boundingSphere;return d!==void 0&&(i.boundingSphere=new jt().fromJSON(d)),e.name&&(i.name=e.name),e.userData&&(i.userData=e.userData),i}},b_={},Ep=class extends us{constructor(e){super(e)}load(e,t,s,n){let a=this,i=this.path===""?Ea.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||i;let o=new an(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(c){let l=null;try{l=JSON.parse(c)}catch(u){n!==void 0&&n(u),W("ObjectLoader: Can't parse "+e+".",u.message);return}let h=l.metadata;if(h===void 0||h.type===void 0||h.type.toLowerCase()==="geometry"){n!==void 0&&n(new Error("THREE.ObjectLoader: Can't load "+e)),W("ObjectLoader: Can't load "+e);return}a.parse(l,t)},s,n)}async loadAsync(e,t){let s=this,n=this.path===""?Ea.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||n;let a=new an(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials);let i=await a.loadAsync(e,t),o;try{o=JSON.parse(i)}catch(l){throw new Error("THREE.ObjectLoader: Can't parse "+e+". "+l.message)}let c=o.metadata;if(c===void 0||c.type===void 0||c.type.toLowerCase()==="geometry")throw new Error("THREE.ObjectLoader: Can't load "+e);return await s.parseAsync(o)}parse(e,t){let s=this.parseAnimations(e.animations),n=this.parseShapes(e.shapes),a=this.parseGeometries(e.geometries,n),i=this.parseImages(e.images,function(){t!==void 0&&t(l)}),o=this.parseTextures(e.textures,i),c=this.parseMaterials(e.materials,o),l=this.parseObject(e.object,a,c,o,s),h=this.parseSkeletons(e.skeletons,l);if(this.bindSkeletons(l,h),this.bindLightTargets(l),t!==void 0){let u=!1;for(let d in i)if(i[d].data instanceof HTMLImageElement){u=!0;break}u===!1&&t(l)}return l}async parseAsync(e){let t=this.parseAnimations(e.animations),s=this.parseShapes(e.shapes),n=this.parseGeometries(e.geometries,s),a=await this.parseImagesAsync(e.images),i=this.parseTextures(e.textures,a),o=this.parseMaterials(e.materials,i),c=this.parseObject(e.object,n,o,i,t),l=this.parseSkeletons(e.skeletons,c);return this.bindSkeletons(c,l),this.bindLightTargets(c),c}static registerGeometry(e,t){b_[e]=t}parseShapes(e){let t={};if(e!==void 0)for(let s=0,n=e.length;s<n;s++){let a=new Mo().fromJSON(e[s]);t[a.uuid]=a}return t}parseSkeletons(e,t){let s={},n={};if(t.traverse(function(a){a.isBone&&(n[a.uuid]=a)}),e!==void 0)for(let a=0,i=e.length;a<i;a++){let o=new Gc().fromJSON(e[a],n);s[o.uuid]=o}return s}parseGeometries(e,t){let s={};if(e!==void 0){let n=new Rp;for(let a=0,i=e.length;a<i;a++){let o,c=e[a];switch(c.type){case"BufferGeometry":case"InstancedBufferGeometry":o=n.parse(c);break;default:c.type in L8?o=L8[c.type].fromJSON(c,t):c.type in b_?o=b_[c.type].fromJSON(c,t):K(`ObjectLoader: Unknown geometry type "${c.type}". Use .registerGeometry() before starting the deserialization process.`)}o.uuid=c.uuid,c.name!==void 0&&(o.name=c.name),c.userData!==void 0&&(o.userData=c.userData),s[c.uuid]=o}}return s}parseMaterials(e,t){let s={},n={};if(e!==void 0){let a=new du;a.setTextures(t);for(let i=0,o=e.length;i<o;i++){let c=e[i];s[c.uuid]===void 0&&(s[c.uuid]=a.parse(c)),n[c.uuid]=s[c.uuid]}}return n}parseAnimations(e){let t={};if(e!==void 0)for(let s=0;s<e.length;s++){let n=e[s],a=Vi.parse(n);t[a.uuid]=a}return t}parseImages(e,t){let s=this,n={},a;function i(c){return c=s.manager.resolveURL(c),s.manager.itemStart(c),a.load(c,function(){s.manager.itemEnd(c)},void 0,function(){s.manager.itemError(c),s.manager.itemEnd(c)})}function o(c){if(typeof c=="string"){let l=c,h=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(l)?l:s.resourcePath+l;return i(h)}else return c.data?{data:Ch(c.type,c.data),width:c.width,height:c.height}:null}if(e!==void 0&&e.length>0){let c=new lu(t);a=new Co(c),a.setCrossOrigin(this.crossOrigin);for(let l=0,h=e.length;l<h;l++){let u=e[l],d=u.url;if(Array.isArray(d)){let f=[];for(let p=0,m=d.length;p<m;p++){let b=d[p],g=o(b);g!==null&&(g instanceof HTMLImageElement?f.push(g):f.push(new Is(g.data,g.width,g.height)))}n[u.uuid]=new Ma(f)}else{let f=o(u.url);n[u.uuid]=new Ma(f)}}}return n}async parseImagesAsync(e){let t=this,s={},n;async function a(i){if(typeof i=="string"){let o=i,c=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(o)?o:t.resourcePath+o;return await n.loadAsync(c)}else return i.data?{data:Ch(i.type,i.data),width:i.width,height:i.height}:null}if(e!==void 0&&e.length>0){n=new Co(this.manager),n.setCrossOrigin(this.crossOrigin);for(let i=0,o=e.length;i<o;i++){let c=e[i],l=c.url;if(Array.isArray(l)){let h=[];for(let u=0,d=l.length;u<d;u++){let f=l[u],p=await a(f);p!==null&&(p instanceof HTMLImageElement?h.push(p):h.push(new Is(p.data,p.width,p.height)))}s[c.uuid]=new Ma(h)}else{let h=await a(c.url);s[c.uuid]=new Ma(h)}}}return s}parseTextures(e,t){function s(a,i){return typeof a=="number"?a:(K("ObjectLoader.parseTexture: Constant should be in numeric form.",a),i[a])}let n={};if(e!==void 0)for(let a=0,i=e.length;a<i;a++){let o=e[a];o.image===void 0&&K('ObjectLoader: No "image" specified for',o.uuid),t[o.image]===void 0&&K("ObjectLoader: Undefined image",o.image);let c=t[o.image],l=c.data,h;Array.isArray(l)?(h=new Pi,l.length===6&&(h.needsUpdate=!0)):(l&&l.data?h=new Is:h=new gt,l&&(h.needsUpdate=!0)),h.source=c,h.uuid=o.uuid,o.name!==void 0&&(h.name=o.name),o.mapping!==void 0&&(h.mapping=s(o.mapping,OD)),o.channel!==void 0&&(h.channel=o.channel),o.offset!==void 0&&h.offset.fromArray(o.offset),o.repeat!==void 0&&h.repeat.fromArray(o.repeat),o.center!==void 0&&h.center.fromArray(o.center),o.rotation!==void 0&&(h.rotation=o.rotation),o.wrap!==void 0&&(h.wrapS=s(o.wrap[0],K8),h.wrapT=s(o.wrap[1],K8)),o.format!==void 0&&(h.format=o.format),o.internalFormat!==void 0&&(h.internalFormat=o.internalFormat),o.type!==void 0&&(h.type=o.type),o.colorSpace!==void 0&&(h.colorSpace=o.colorSpace),o.minFilter!==void 0&&(h.minFilter=s(o.minFilter,J8)),o.magFilter!==void 0&&(h.magFilter=s(o.magFilter,J8)),o.anisotropy!==void 0&&(h.anisotropy=o.anisotropy),o.flipY!==void 0&&(h.flipY=o.flipY),o.generateMipmaps!==void 0&&(h.generateMipmaps=o.generateMipmaps),o.premultiplyAlpha!==void 0&&(h.premultiplyAlpha=o.premultiplyAlpha),o.unpackAlignment!==void 0&&(h.unpackAlignment=o.unpackAlignment),o.compareFunction!==void 0&&(h.compareFunction=o.compareFunction),o.normalized!==void 0&&(h.normalized=o.normalized),o.userData!==void 0&&(h.userData=o.userData),n[o.uuid]=h}return n}parseObject(e,t,s,n,a){let i;function o(d){return t[d]===void 0&&K("ObjectLoader: Undefined geometry",d),t[d]}function c(d){if(d!==void 0){if(Array.isArray(d)){let f=[];for(let p=0,m=d.length;p<m;p++){let b=d[p];s[b]===void 0&&K("ObjectLoader: Undefined material",b),f.push(s[b])}return f}return s[d]===void 0&&K("ObjectLoader: Undefined material",d),s[d]}}function l(d){return n[d]===void 0&&K("ObjectLoader: Undefined texture",d),n[d]}let h,u;switch(e.type){case"Scene":i=new ii,e.background!==void 0&&(Number.isInteger(e.background)?i.background=new be(e.background):i.background=l(e.background)),e.environment!==void 0&&(i.environment=l(e.environment)),e.fog!==void 0&&(e.fog.type==="Fog"?i.fog=new qf(e.fog.color,e.fog.near,e.fog.far):e.fog.type==="FogExp2"&&(i.fog=new Wf(e.fog.color,e.fog.density)),e.fog.name!==""&&(i.fog.name=e.fog.name)),e.backgroundBlurriness!==void 0&&(i.backgroundBlurriness=e.backgroundBlurriness),e.backgroundIntensity!==void 0&&(i.backgroundIntensity=e.backgroundIntensity),e.backgroundRotation!==void 0&&i.backgroundRotation.fromArray(e.backgroundRotation),e.environmentIntensity!==void 0&&(i.environmentIntensity=e.environmentIntensity),e.environmentRotation!==void 0&&i.environmentRotation.fromArray(e.environmentRotation);break;case"PerspectiveCamera":i=new qt(e.fov,e.aspect,e.near,e.far),e.focus!==void 0&&(i.focus=e.focus),e.zoom!==void 0&&(i.zoom=e.zoom),e.filmGauge!==void 0&&(i.filmGauge=e.filmGauge),e.filmOffset!==void 0&&(i.filmOffset=e.filmOffset),e.view!==void 0&&(i.view=Object.assign({},e.view));break;case"OrthographicCamera":i=new ji(e.left,e.right,e.top,e.bottom,e.near,e.far),e.zoom!==void 0&&(i.zoom=e.zoom),e.view!==void 0&&(i.view=Object.assign({},e.view));break;case"AmbientLight":i=new sl(e.color,e.intensity);break;case"DirectionalLight":i=new Fr(e.color,e.intensity),i.target=e.target||"";break;case"PointLight":i=new di(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":i=new nl(e.color,e.intensity,e.width,e.height);break;case"SpotLight":i=new ui(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay),i.target=e.target||"";break;case"HemisphereLight":i=new Qc(e.color,e.groundColor,e.intensity);break;case"LightProbe":let d=new uu().fromArray(e.sh);i=new al(d,e.intensity);break;case"SkinnedMesh":h=o(e.geometry),u=c(e.material),i=new jc(h,u),e.bindMode!==void 0&&(i.bindMode=e.bindMode),e.bindMatrix!==void 0&&i.bindMatrix.fromArray(e.bindMatrix),e.skeleton!==void 0&&(i.skeleton=e.skeleton);break;case"Mesh":h=o(e.geometry),u=c(e.material),i=new at(h,u);break;case"InstancedMesh":h=o(e.geometry),u=c(e.material);let f=e.count,p=e.instanceMatrix,m=e.instanceColor;i=new Er(h,u,f),i.instanceMatrix=new ys(new Float32Array(p.array),16),m!==void 0&&(i.instanceColor=new ys(new Float32Array(m.array),m.itemSize));break;case"BatchedMesh":h=o(e.geometry),u=c(e.material),i=new Jf(e.maxInstanceCount,e.maxVertexCount,e.maxIndexCount,u),i.geometry=h,i.perObjectFrustumCulled=e.perObjectFrustumCulled,i.sortObjects=e.sortObjects,i._drawRanges=e.drawRanges,i._reservedRanges=e.reservedRanges,i._geometryInfo=e.geometryInfo.map(b=>{let g=null,x=null;return b.boundingBox!==void 0&&(g=new ss().fromJSON(b.boundingBox)),b.boundingSphere!==void 0&&(x=new jt().fromJSON(b.boundingSphere)),{...b,boundingBox:g,boundingSphere:x}}),i._instanceInfo=e.instanceInfo,i._availableInstanceIds=e._availableInstanceIds,i._availableGeometryIds=e._availableGeometryIds,i._nextIndexStart=e.nextIndexStart,i._nextVertexStart=e.nextVertexStart,i._geometryCount=e.geometryCount,i._maxInstanceCount=e.maxInstanceCount,i._maxVertexCount=e.maxVertexCount,i._maxIndexCount=e.maxIndexCount,i._geometryInitialized=e.geometryInitialized,i._matricesTexture=l(e.matricesTexture.uuid),i._indirectTexture=l(e.indirectTexture.uuid),e.colorsTexture!==void 0&&(i._colorsTexture=l(e.colorsTexture.uuid)),e.boundingSphere!==void 0&&(i.boundingSphere=new jt().fromJSON(e.boundingSphere)),e.boundingBox!==void 0&&(i.boundingBox=new ss().fromJSON(e.boundingBox));break;case"LOD":i=new Kf;break;case"Line":i=new Qn(o(e.geometry),c(e.material));break;case"LineLoop":i=new Hc(o(e.geometry),c(e.material));break;case"LineSegments":i=new _n(o(e.geometry),c(e.material));break;case"PointCloud":case"Points":i=new Wc(o(e.geometry),c(e.material));break;case"Sprite":i=new Xf(c(e.material));break;case"Group":i=new qs;break;case"Bone":i=new _o;break;default:i=new Ze}if(i.uuid=e.uuid,e.name!==void 0&&(i.name=e.name),e.matrix!==void 0?(i.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(i.matrixAutoUpdate=e.matrixAutoUpdate),i.matrixAutoUpdate&&i.matrix.decompose(i.position,i.quaternion,i.scale)):(e.position!==void 0&&i.position.fromArray(e.position),e.rotation!==void 0&&i.rotation.fromArray(e.rotation),e.quaternion!==void 0&&i.quaternion.fromArray(e.quaternion),e.scale!==void 0&&i.scale.fromArray(e.scale)),e.up!==void 0&&i.up.fromArray(e.up),e.pivot!==void 0&&(i.pivot=new E().fromArray(e.pivot)),e.morphTargetDictionary!==void 0&&(i.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),e.morphTargetInfluences!==void 0&&(i.morphTargetInfluences=e.morphTargetInfluences.slice()),e.castShadow!==void 0&&(i.castShadow=e.castShadow),e.receiveShadow!==void 0&&(i.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.intensity!==void 0&&(i.shadow.intensity=e.shadow.intensity),e.shadow.bias!==void 0&&(i.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(i.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(i.shadow.radius=e.shadow.radius),e.shadow.blurSamples!==void 0&&(i.shadow.blurSamples=e.shadow.blurSamples),e.shadow.focus!==void 0&&(i.shadow.focus=e.shadow.focus),e.shadow.aspect!==void 0&&(i.shadow.aspect=e.shadow.aspect),e.shadow.mapSize!==void 0&&i.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(i.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(i.visible=e.visible),e.frustumCulled!==void 0&&(i.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(i.renderOrder=e.renderOrder),e.static!==void 0&&(i.static=e.static),e.userData!==void 0&&(i.userData=e.userData),e.layers!==void 0&&(i.layers.mask=e.layers),e.children!==void 0){let d=e.children;for(let f=0;f<d.length;f++)i.add(this.parseObject(d[f],t,s,n,a))}if(e.animations!==void 0){let d=e.animations;for(let f=0;f<d.length;f++){let p=d[f];i.animations.push(a[p])}}if(e.type==="LOD"){e.autoUpdate!==void 0&&(i.autoUpdate=e.autoUpdate);let d=e.levels;for(let f=0;f<d.length;f++){let p=d[f],m=i.getObjectByProperty("uuid",p.object);m!==void 0&&i.addLevel(m,p.distance,p.hysteresis)}}return i}bindSkeletons(e,t){Object.keys(t).length!==0&&e.traverse(function(s){if(s.isSkinnedMesh===!0&&s.skeleton!==void 0){let n=t[s.skeleton];n===void 0?K("ObjectLoader: No skeleton found with UUID:",s.skeleton):s.bind(n,s.bindMatrix)}})}bindLightTargets(e){e.traverse(function(t){if(t.isDirectionalLight||t.isSpotLight){let s=t.target,n=e.getObjectByProperty("uuid",s);n!==void 0?t.target=n:t.target=new Ze}})}},OD={UVMapping:Tu,CubeReflectionMapping:Wi,CubeRefractionMapping:ol,EquirectangularReflectionMapping:vu,EquirectangularRefractionMapping:_u,CubeUVReflectionMapping:cl},K8={RepeatWrapping:Zn,ClampToEdgeWrapping:hs,MirroredRepeatWrapping:ai},J8={NearestFilter:pt,NearestMipmapNearestFilter:ll,NearestMipmapLinearFilter:fi,LinearFilter:Ye,LinearMipmapNearestFilter:Fo,LinearMipmapLinearFilter:on},g_=new WeakMap,fu=class extends us{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&K("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&K("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,s,n){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let a=this,i=ni.get(`image-bitmap:${e}`);if(i!==void 0){if(a.manager.itemStart(e),i.then){i.then(l=>{g_.has(i)===!0?(n&&n(g_.get(i)),a.manager.itemError(e),a.manager.itemEnd(e)):(t&&t(l),a.manager.itemEnd(e))});return}setTimeout(function(){t&&t(i),a.manager.itemEnd(e)},0);return}let o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader,o.signal=typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;let c=fetch(e,o).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,Object.assign({},a.options,{colorSpaceConversion:"none"}))}).then(function(l){return ni.add(`image-bitmap:${e}`,l),t&&t(l),a.manager.itemEnd(e),l}).catch(function(l){n&&n(l),g_.set(c,l),ni.remove(`image-bitmap:${e}`),a.manager.itemError(e),a.manager.itemEnd(e)});ni.add(`image-bitmap:${e}`,c),a.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}},Og,pu=class{static getContext(){return Og===void 0&&(Og=new(window.AudioContext||window.webkitAudioContext)),Og}static setContext(e){Og=e}},by=class extends us{constructor(e){super(e)}load(e,t,s,n){let a=this,i=new an(this.manager);i.setResponseType("arraybuffer"),i.setPath(this.path),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(e,function(c){try{let l=c.slice(0),h=pu.getContext(),u=e+"#decode";a.manager.itemStart(u),h.decodeAudioData(l,function(d){t(d),a.manager.itemEnd(u)}).catch(function(d){o(d),a.manager.itemEnd(u)})}catch(l){o(l)}},s,n);function o(c){n?n(c):W(c),a.manager.itemError(e)}}},$8=new le,Y8=new le,Ic=new le,gy=class{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new qt,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new qt,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){let t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,Ic.copy(e.projectionMatrix);let n=t.eyeSep/2,a=n*t.near/t.focus,i=t.near*Math.tan(Uc*t.fov*.5)/t.zoom,o,c;Y8.elements[12]=-n,$8.elements[12]=n,o=-i*t.aspect+a,c=i*t.aspect+a,Ic.elements[0]=2*t.near/(c-o),Ic.elements[8]=(c+o)/(c-o),this.cameraL.projectionMatrix.copy(Ic),o=-i*t.aspect-a,c=i*t.aspect-a,Ic.elements[0]=2*t.near/(c-o),Ic.elements[8]=(c+o)/(c-o),this.cameraR.projectionMatrix.copy(Ic)}this.cameraL.matrix.copy(e.matrixWorld).multiply(Y8),this.cameraL.matrixWorldNeedsUpdate=!0,this.cameraR.matrix.copy(e.matrixWorld).multiply($8),this.cameraR.matrixWorldNeedsUpdate=!0}},Sh=-90,Nh=1,Cp=class extends Ze{constructor(e,t,s){super(),this.type="CubeCamera",this.renderTarget=s,this.coordinateSystem=null,this.activeMipmapLevel=0;let n=new qt(Sh,Nh,e,t);n.layers=this.layers,this.add(n);let a=new qt(Sh,Nh,e,t);a.layers=this.layers,this.add(a);let i=new qt(Sh,Nh,e,t);i.layers=this.layers,this.add(i);let o=new qt(Sh,Nh,e,t);o.layers=this.layers,this.add(o);let c=new qt(Sh,Nh,e,t);c.layers=this.layers,this.add(c);let l=new qt(Sh,Nh,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[s,n,a,i,o,c]=t;for(let l of t)this.remove(l);if(e===sn)s.up.set(0,1,0),s.lookAt(1,0,0),n.up.set(0,1,0),n.lookAt(-1,0,0),a.up.set(0,0,-1),a.lookAt(0,1,0),i.up.set(0,0,1),i.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===Xs)s.up.set(0,-1,0),s.lookAt(-1,0,0),n.up.set(0,-1,0),n.lookAt(1,0,0),a.up.set(0,0,1),a.lookAt(0,1,0),i.up.set(0,0,-1),i.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let l of t)this.add(l),l.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();let{renderTarget:s,activeMipmapLevel:n}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[a,i,o,c,l,h]=this.children,u=e.getRenderTarget(),d=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;let m=s.texture.generateMipmaps;s.texture.generateMipmaps=!1;let b=!1;e.isWebGLRenderer===!0?b=e.state.buffers.depth.getReversed():b=e.reversedDepthBuffer,e.setRenderTarget(s,0,n),b&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(s,1,n),b&&e.autoClear===!1&&e.clearDepth(),e.render(t,i),e.setRenderTarget(s,2,n),b&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(s,3,n),b&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),e.setRenderTarget(s,4,n),b&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),s.texture.generateMipmaps=m,e.setRenderTarget(s,5,n),b&&e.autoClear===!1&&e.clearDepth(),e.render(t,h),e.setRenderTarget(u,d,f),e.xr.enabled=p,s.texture.needsPMREMUpdate=!0}},kp=class extends qt{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}},Ip=class{constructor(){this._previousTime=0,this._currentTime=0,this._startTime=performance.now(),this._delta=0,this._elapsed=0,this._timescale=1,this._document=null,this._pageVisibilityHandler=null}connect(e){this._document=e,e.hidden!==void 0&&(this._pageVisibilityHandler=UD.bind(this),e.addEventListener("visibilitychange",this._pageVisibilityHandler,!1))}disconnect(){this._pageVisibilityHandler!==null&&(this._document.removeEventListener("visibilitychange",this._pageVisibilityHandler),this._pageVisibilityHandler=null),this._document=null}getDelta(){return this._delta/1e3}getElapsed(){return this._elapsed/1e3}getTimescale(){return this._timescale}setTimescale(e){return this._timescale=e,this}reset(){return this._currentTime=performance.now()-this._startTime,this}dispose(){this.disconnect()}update(e){return this._pageVisibilityHandler!==null&&this._document.hidden===!0?this._delta=0:(this._previousTime=this._currentTime,this._currentTime=(e!==void 0?e:performance.now())-this._startTime,this._delta=(this._currentTime-this._previousTime)*this._timescale,this._elapsed+=this._delta),this}};function UD(){this._document.hidden===!1&&this.reset()}var Bc=new E,y_=new It,LD=new E,Fc=new E,Pc=new E,yy=class extends Ze{constructor(){super(),this.type="AudioListener",this.context=pu.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._timer=new Ip}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e),this._timer.update();let t=this.context.listener;if(this.timeDelta=this._timer.getDelta(),this.matrixWorld.decompose(Bc,y_,LD),Fc.set(0,0,-1).applyQuaternion(y_),Pc.set(0,1,0).applyQuaternion(y_),t.positionX){let s=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(Bc.x,s),t.positionY.linearRampToValueAtTime(Bc.y,s),t.positionZ.linearRampToValueAtTime(Bc.z,s),t.forwardX.linearRampToValueAtTime(Fc.x,s),t.forwardY.linearRampToValueAtTime(Fc.y,s),t.forwardZ.linearRampToValueAtTime(Fc.z,s),t.upX.linearRampToValueAtTime(Pc.x,s),t.upY.linearRampToValueAtTime(Pc.y,s),t.upZ.linearRampToValueAtTime(Pc.z,s)}else t.setPosition(Bc.x,Bc.y,Bc.z),t.setOrientation(Fc.x,Fc.y,Fc.z,Pc.x,Pc.y,Pc.z)}},Bp=class extends Ze{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){K("Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){K("Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;let t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){K("Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(e=0){if(this.hasPlaybackControl===!1){K("Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(this.context.currentTime+e),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this._connected!==!1){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}}getFilters(){return this.filters}setFilters(e){return e||(e=[]),this._connected===!0?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){return this.detune=e,this.isPlaying===!0&&this.source.detune!==void 0&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(e){return this.setFilters(e?[e]:[])}setPlaybackRate(e){if(this.hasPlaybackControl===!1){K("Audio: this Audio has no playback control.");return}return this.playbackRate=e,this.isPlaying===!0&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1,this._progress=0}getLoop(){return this.hasPlaybackControl===!1?(K("Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(this.hasPlaybackControl===!1){K("Audio: this Audio has no playback control.");return}return this.loop=e,this.isPlaying===!0&&(this.source.loop=this.loop),this}setLoopStart(e){return this.loopStart=e,this}setLoopEnd(e){return this.loopEnd=e,this}getVolume(){return this.gain.gain.value}setVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}copy(e,t){return super.copy(e,t),e.sourceType!=="buffer"?(K("Audio: Audio source type cannot be copied."),this):(this.autoplay=e.autoplay,this.buffer=e.buffer,this.detune=e.detune,this.loop=e.loop,this.loopStart=e.loopStart,this.loopEnd=e.loopEnd,this.offset=e.offset,this.duration=e.duration,this.playbackRate=e.playbackRate,this.hasPlaybackControl=e.hasPlaybackControl,this.sourceType=e.sourceType,this.filters=e.filters.slice(),this)}clone(e){return new this.constructor(this.listener).copy(this,e)}},Dc=new E,Z8=new It,zD=new E,Oc=new E,xy=class extends Bp{constructor(e){super(e),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){return super.connect(),this.panner.connect(this.gain),this}disconnect(){return super.disconnect(),this.panner.disconnect(this.gain),this}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(e){return this.panner.refDistance=e,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(e){return this.panner.rolloffFactor=e,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(e){return this.panner.distanceModel=e,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(e){return this.panner.maxDistance=e,this}setDirectionalCone(e,t,s){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=s,this}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.hasPlaybackControl===!0&&this.isPlaying===!1)return;this.matrixWorld.decompose(Dc,Z8,zD),Oc.set(0,0,1).applyQuaternion(Z8);let t=this.panner;if(t.positionX){let s=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(Dc.x,s),t.positionY.linearRampToValueAtTime(Dc.y,s),t.positionZ.linearRampToValueAtTime(Dc.z,s),t.orientationX.linearRampToValueAtTime(Oc.x,s),t.orientationY.linearRampToValueAtTime(Oc.y,s),t.orientationZ.linearRampToValueAtTime(Oc.z,s)}else t.setPosition(Dc.x,Dc.y,Dc.z),t.setOrientation(Oc.x,Oc.y,Oc.z)}},wy=class{constructor(e,t=2048){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=t,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let e=0,t=this.getFrequencyData();for(let s=0;s<t.length;s++)e+=t[s];return e/t.length}},Fp=class{constructor(e,t,s){this.binding=e,this.valueSize=s;let n,a,i;switch(t){case"quaternion":n=this._slerp,a=this._slerpAdditive,i=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(s*6),this._workIndex=5;break;case"string":case"bool":n=this._select,a=this._select,i=this._setAdditiveIdentityOther,this.buffer=new Array(s*5);break;default:n=this._lerp,a=this._lerpAdditive,i=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(s*5)}this._mixBufferRegion=n,this._mixBufferRegionAdditive=a,this._setIdentity=i,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){let s=this.buffer,n=this.valueSize,a=e*n+n,i=this.cumulativeWeight;if(i===0){for(let o=0;o!==n;++o)s[a+o]=s[o];i=t}else{i+=t;let o=t/i;this._mixBufferRegion(s,a,0,o,n)}this.cumulativeWeight=i}accumulateAdditive(e){let t=this.buffer,s=this.valueSize,n=s*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,n,0,e,s),this.cumulativeWeightAdditive+=e}apply(e){let t=this.valueSize,s=this.buffer,n=e*t+t,a=this.cumulativeWeight,i=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,a<1){let c=t*this._origIndex;this._mixBufferRegion(s,n,c,1-a,t)}i>0&&this._mixBufferRegionAdditive(s,n,this._addIndex*t,1,t);for(let c=t,l=t+t;c!==l;++c)if(s[c]!==s[c+t]){o.setValue(s,n);break}}saveOriginalState(){let e=this.binding,t=this.buffer,s=this.valueSize,n=s*this._origIndex;e.getValue(t,n);for(let a=s,i=n;a!==i;++a)t[a]=t[n+a%s];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let s=e;s<t;s++)this.buffer[s]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let s=0;s<this.valueSize;s++)this.buffer[t+s]=this.buffer[e+s]}_select(e,t,s,n,a){if(n>=.5)for(let i=0;i!==a;++i)e[t+i]=e[s+i]}_slerp(e,t,s,n){It.slerpFlat(e,t,e,t,e,s,n)}_slerpAdditive(e,t,s,n,a){let i=this._workIndex*a;It.multiplyQuaternionsFlat(e,i,e,t,e,s),It.slerpFlat(e,t,e,t,e,i,n)}_lerp(e,t,s,n,a){let i=1-n;for(let o=0;o!==a;++o){let c=t+o;e[c]=e[c]*i+e[s+o]*n}}_lerpAdditive(e,t,s,n,a){for(let i=0;i!==a;++i){let o=t+i;e[o]=e[o]+e[s+i]*n}}},dA="\\[\\]\\.:\\/",VD=new RegExp("["+dA+"]","g"),fA="[^"+dA+"]",jD="[^"+dA.replace("\\.","")+"]",GD=/((?:WC+[\/:])*)/.source.replace("WC",fA),HD=/(WCOD+)?/.source.replace("WCOD",jD),WD=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",fA),qD=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",fA),XD=new RegExp("^"+GD+HD+WD+qD+"$"),KD=["material","materials","bones","map"],I_=class{constructor(e,t,s){let n=s||dt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,n)}getValue(e,t){this.bind();let s=this._targetGroup.nCachedObjects_,n=this._bindings[s];n!==void 0&&n.getValue(e,t)}setValue(e,t){let s=this._bindings;for(let n=this._targetGroup.nCachedObjects_,a=s.length;n!==a;++n)s[n].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,s=e.length;t!==s;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,s=e.length;t!==s;++t)e[t].unbind()}},dt=class r{constructor(e,t,s){this.path=t,this.parsedPath=s||r.parseTrackName(t),this.node=r.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,s){return e&&e.isAnimationObjectGroup?new r.Composite(e,t,s):new r(e,t,s)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(VD,"")}static parseTrackName(e){let t=XD.exec(e);if(t===null)throw new Error("THREE.PropertyBinding: Cannot parse trackName: "+e);let s={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},n=s.nodeName&&s.nodeName.lastIndexOf(".");if(n!==void 0&&n!==-1){let a=s.nodeName.substring(n+1);KD.indexOf(a)!==-1&&(s.nodeName=s.nodeName.substring(0,n),s.objectName=a)}if(s.propertyName===null||s.propertyName.length===0)throw new Error("THREE.PropertyBinding: can not parse propertyName from trackName: "+e);return s}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let s=e.skeleton.getBoneByName(t);if(s!==void 0)return s}if(e.children){let s=function(a){for(let i=0;i<a.length;i++){let o=a[i];if(o.name===t||o.uuid===t)return o;let c=s(o.children);if(c)return c}return null},n=s(e.children);if(n)return n}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let s=this.resolvedProperty;for(let n=0,a=s.length;n!==a;++n)e[t++]=s[n]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let s=this.resolvedProperty;for(let n=0,a=s.length;n!==a;++n)s[n]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let s=this.resolvedProperty;for(let n=0,a=s.length;n!==a;++n)s[n]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let s=this.resolvedProperty;for(let n=0,a=s.length;n!==a;++n)s[n]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,s=t.objectName,n=t.propertyName,a=t.propertyIndex;if(e||(e=r.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){K("PropertyBinding: No target node found for track: "+this.path+".");return}if(s){let l=t.objectIndex;switch(s){case"materials":if(!e.material){W("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){W("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){W("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let h=0;h<e.length;h++)if(e[h].name===l){l=h;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){W("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){W("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[s]===void 0){W("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[s]}if(l!==void 0){if(e[l]===void 0){W("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[l]}}let i=e[n];if(i===void 0){let l=t.nodeName;W("PropertyBinding: Trying to update property for track: "+l+"."+n+" but it wasn't found.",e);return}let o=this.Versioning.None;this.targetObject=e,e.isMaterial===!0?o=this.Versioning.NeedsUpdate:e.isObject3D===!0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(a!==void 0){if(n==="morphTargetInfluences"){if(!e.geometry){W("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){W("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[a]!==void 0&&(a=e.morphTargetDictionary[a])}c=this.BindingType.ArrayElement,this.resolvedProperty=i,this.propertyIndex=a}else i.fromArray!==void 0&&i.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=i):Array.isArray(i)?(c=this.BindingType.EntireArray,this.resolvedProperty=i):this.propertyName=n;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};dt.Composite=I_;dt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};dt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};dt.prototype.GetterByBindingType=[dt.prototype._getValue_direct,dt.prototype._getValue_array,dt.prototype._getValue_arrayElement,dt.prototype._getValue_toArray];dt.prototype.SetterByBindingTypeAndVersioning=[[dt.prototype._setValue_direct,dt.prototype._setValue_direct_setNeedsUpdate,dt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[dt.prototype._setValue_array,dt.prototype._setValue_array_setNeedsUpdate,dt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[dt.prototype._setValue_arrayElement,dt.prototype._setValue_arrayElement_setNeedsUpdate,dt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[dt.prototype._setValue_fromArray,dt.prototype._setValue_fromArray_setNeedsUpdate,dt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var Ty=class{constructor(){this.isAnimationObjectGroup=!0,this.uuid=Yn(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;let e={};this._indicesByUUID=e;for(let s=0,n=arguments.length;s!==n;++s)e[arguments[s].uuid]=s;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};let t=this;this.stats={objects:{get total(){return t._objects.length},get inUse(){return this.total-t.nCachedObjects_}},get bindingsPerObject(){return t._bindings.length}}}add(){let e=this._objects,t=this._indicesByUUID,s=this._paths,n=this._parsedPaths,a=this._bindings,i=a.length,o,c=e.length,l=this.nCachedObjects_;for(let h=0,u=arguments.length;h!==u;++h){let d=arguments[h],f=d.uuid,p=t[f];if(p===void 0){p=c++,t[f]=p,e.push(d);for(let m=0,b=i;m!==b;++m)a[m].push(new dt(d,s[m],n[m]))}else if(p<l){o=e[p];let m=--l,b=e[m];t[b.uuid]=p,e[p]=b,t[f]=m,e[m]=d;for(let g=0,x=i;g!==x;++g){let T=a[g],y=T[m],v=T[p];T[p]=y,v===void 0&&(v=new dt(d,s[g],n[g])),T[m]=v}}else e[p]!==o&&W("AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=l}remove(){let e=this._objects,t=this._indicesByUUID,s=this._bindings,n=s.length,a=this.nCachedObjects_;for(let i=0,o=arguments.length;i!==o;++i){let c=arguments[i],l=c.uuid,h=t[l];if(h!==void 0&&h>=a){let u=a++,d=e[u];t[d.uuid]=h,e[h]=d,t[l]=u,e[u]=c;for(let f=0,p=n;f!==p;++f){let m=s[f],b=m[u],g=m[h];m[h]=b,m[u]=g}}}this.nCachedObjects_=a}uncache(){let e=this._objects,t=this._indicesByUUID,s=this._bindings,n=s.length,a=this.nCachedObjects_,i=e.length;for(let o=0,c=arguments.length;o!==c;++o){let l=arguments[o],h=l.uuid,u=t[h];if(u!==void 0)if(delete t[h],u<a){let d=--a,f=e[d],p=--i,m=e[p];u!==d&&(t[f.uuid]=u),e[u]=f,d!==p&&(t[m.uuid]=d),e[d]=m,e.pop();for(let b=0,g=n;b!==g;++b){let x=s[b],T=x[d],y=x[p];x[u]=T,x[d]=y,x.pop()}}else{let d=--i,f=e[d];u!==d&&(t[f.uuid]=u),e[u]=f,e.pop();for(let p=0,m=n;p!==m;++p){let b=s[p];b[u]=b[d],b.pop()}}}this.nCachedObjects_=a}subscribe_(e,t){let s=this._bindingsIndicesByPath,n=s[e],a=this._bindings;if(n!==void 0)return a[n];let i=this._paths,o=this._parsedPaths,c=this._objects,l=c.length,h=this.nCachedObjects_,u=new Array(l);n=a.length,s[e]=n,i.push(e),o.push(t),a.push(u);for(let d=h,f=c.length;d!==f;++d){let p=c[d];u[d]=new dt(p,e,t)}return u}unsubscribe_(e){let t=this._bindingsIndicesByPath,s=t[e];if(s!==void 0){let n=this._paths,a=this._parsedPaths,i=this._bindings,o=i.length-1,c=i[o],l=n[o];t[l]=s,i[s]=c,i.pop(),a[s]=a[o],a.pop(),n[s]=n[o],n.pop()}}},Pp=class{constructor(e,t,s=null,n=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=s,this.blendMode=n;let a=t.tracks,i=a.length,o=new Array(i),c={endingStart:yo,endingEnd:yo};for(let l=0;l!==i;++l){let h=a[l].createInterpolant(null);o[l]=h,h.settings=c}this._interpolantSettings=c,this._interpolants=o,this._propertyBindings=new Array(i),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._restoreTimeScale=null,this._weightInterpolant=null,this.loop=G_,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,s=!1){if(e.fadeOut(t),this.fadeIn(t),s===!0){let n=this._clip.duration,a=e._clip.duration,i=a/n,o=n/a;e._restoreTimeScale=e.timeScale,this._restoreTimeScale=this.timeScale,e.warp(1,i,t),this.warp(o,1,t)}return this}crossFadeTo(e,t,s=!1){return e.crossFadeFrom(this,t,s)}stopFading(){let e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,s){let n=this._mixer,a=n.time,i=this.timeScale,o=this._timeScaleInterpolant;o===null&&(o=n._lendControlInterpolant(),this._timeScaleInterpolant=o);let c=o.parameterPositions,l=o.sampleValues;return c[0]=a,c[1]=a+s,l[0]=e/i,l[1]=t/i,this}stopWarping(){let e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this._restoreTimeScale=null,this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,s,n){if(!this.enabled){this._updateWeight(e);return}let a=this._startTime;if(a!==null){let c=(e-a)*s;c<0||s===0?t=0:(this._startTime=null,t=s*c)}t*=this._updateTimeScale(e);let i=this._updateTime(t),o=this._updateWeight(e);if(o>0){let c=this._interpolants,l=this._propertyBindings;switch(this.blendMode){case mx:for(let h=0,u=c.length;h!==u;++h)c[h].evaluate(i),l[h].accumulateAdditive(o);break;case Xp:default:for(let h=0,u=c.length;h!==u;++h)c[h].evaluate(i),l[h].accumulate(n,o)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let s=this._weightInterpolant;if(s!==null){let n=s.evaluate(e)[0];t*=n,e>s.parameterPositions[1]&&(this.stopFading(),n===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let s=this._timeScaleInterpolant;if(s!==null){let n=s.evaluate(e)[0];t*=n,e>s.parameterPositions[1]&&(t===0?this.paused=!0:(this._restoreTimeScale!==null&&(t=this._restoreTimeScale),this.timeScale=t),this.stopWarping())}}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,s=this.loop,n=this.time+e,a=this._loopCount,i=s===H_;if(e===0)return a===-1?n:i&&(a&1)===1?t-n:n;if(s===j_){a===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(n>=t)n=t;else if(n<0)n=0;else{this.time=n;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(a===-1&&(e>=0?(a=0,this._setEndings(!0,this.repetitions===0,i)):this._setEndings(this.repetitions===0,!0,i)),n>=t||n<0){let o=Math.floor(n/t);n-=t*o,a+=Math.abs(o);let c=this.repetitions-a;if(c<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,n=e>0?t:0,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(c===1){let l=e<0;this._setEndings(l,!l,i)}else this._setEndings(!1,!1,i);this._loopCount=a,this.time=n,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this._loopCount=a,this.time=n;if(i&&(a&1)===1)return t-n}return n}_setEndings(e,t,s){let n=this._interpolantSettings;s?(n.endingStart=xo,n.endingEnd=xo):(e?n.endingStart=this.zeroSlopeAtStart?xo:yo:n.endingStart=zh,t?n.endingEnd=this.zeroSlopeAtEnd?xo:yo:n.endingEnd=zh)}_scheduleFading(e,t,s){let n=this._mixer,a=n.time,i=this._weightInterpolant;i===null&&(i=n._lendControlInterpolant(),this._weightInterpolant=i);let o=i.parameterPositions,c=i.sampleValues;return o[0]=a,c[0]=t,o[1]=a+e,c[1]=s,this}},JD=new Float32Array(1),vy=class extends Bs{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}_bindAction(e,t){let s=e._localRoot||this._root,n=e._clip.tracks,a=n.length,i=e._propertyBindings,o=e._interpolants,c=s.uuid,l=this._bindingsByRootAndName,h=l[c];h===void 0&&(h={},l[c]=h);for(let u=0;u!==a;++u){let d=n[u],f=d.name,p=h[f];if(p!==void 0)++p.referenceCount,i[u]=p;else{if(p=i[u],p!==void 0){p._cacheIndex===null&&(++p.referenceCount,this._addInactiveBinding(p,c,f));continue}let m=t&&t._propertyBindings[u].binding.parsedPath;p=new Fp(dt.create(s,f,m),d.ValueTypeName,d.getValueSize()),++p.referenceCount,this._addInactiveBinding(p,c,f),i[u]=p}o[u].resultBuffer=p.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let s=(e._localRoot||this._root).uuid,n=e._clip.uuid,a=this._actionsByClip[n];this._bindAction(e,a&&a.knownActions[0]),this._addInactiveAction(e,n,s)}let t=e._propertyBindings;for(let s=0,n=t.length;s!==n;++s){let a=t[s];a.useCount++===0&&(this._lendBinding(a),a.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let s=0,n=t.length;s!==n;++s){let a=t[s];--a.useCount===0&&(a.restoreOriginalState(),this._takeBackBinding(a))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,s){let n=this._actions,a=this._actionsByClip,i=a[t];if(i===void 0)i={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,a[t]=i;else{let o=i.knownActions;e._byClipCacheIndex=o.length,o.push(e)}e._cacheIndex=n.length,n.push(e),i.actionByRoot[s]=e}_removeInactiveAction(e){let t=this._actions,s=t[t.length-1],n=e._cacheIndex;s._cacheIndex=n,t[n]=s,t.pop(),e._cacheIndex=null;let a=e._clip.uuid,i=this._actionsByClip,o=i[a],c=o.knownActions,l=c[c.length-1],h=e._byClipCacheIndex;l._byClipCacheIndex=h,c[h]=l,c.pop(),e._byClipCacheIndex=null;let u=o.actionByRoot,d=(e._localRoot||this._root).uuid;delete u[d],c.length===0&&delete i[a],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let s=0,n=t.length;s!==n;++s){let a=t[s];--a.referenceCount===0&&this._removeInactiveBinding(a)}}_lendAction(e){let t=this._actions,s=e._cacheIndex,n=this._nActiveActions++,a=t[n];e._cacheIndex=n,t[n]=e,a._cacheIndex=s,t[s]=a}_takeBackAction(e){let t=this._actions,s=e._cacheIndex,n=--this._nActiveActions,a=t[n];e._cacheIndex=n,t[n]=e,a._cacheIndex=s,t[s]=a}_addInactiveBinding(e,t,s){let n=this._bindingsByRootAndName,a=this._bindings,i=n[t];i===void 0&&(i={},n[t]=i),i[s]=e,e._cacheIndex=a.length,a.push(e)}_removeInactiveBinding(e){let t=this._bindings,s=e.binding,n=s.rootNode.uuid,a=s.path,i=this._bindingsByRootAndName,o=i[n],c=t[t.length-1],l=e._cacheIndex;c._cacheIndex=l,t[l]=c,t.pop(),delete o[a],Object.keys(o).length===0&&delete i[n]}_lendBinding(e){let t=this._bindings,s=e._cacheIndex,n=this._nActiveBindings++,a=t[n];e._cacheIndex=n,t[n]=e,a._cacheIndex=s,t[s]=a}_takeBackBinding(e){let t=this._bindings,s=e._cacheIndex,n=--this._nActiveBindings,a=t[n];e._cacheIndex=n,t[n]=e,a._cacheIndex=s,t[s]=a}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,s=e[t];return s===void 0&&(s=new ou(new Float32Array(2),new Float32Array(2),1,JD),s.__cacheIndex=t,e[t]=s),s}_takeBackControlInterpolant(e){let t=this._controlInterpolants,s=e.__cacheIndex,n=--this._nActiveControlInterpolants,a=t[n];e.__cacheIndex=n,t[n]=e,a.__cacheIndex=s,t[s]=a}clipAction(e,t,s){let n=t||this._root,a=n.uuid,i=typeof e=="string"?Vi.findByName(n,e):e,o=i!==null?i.uuid:e,c=this._actionsByClip[o],l=null;if(s===void 0&&(i!==null?s=i.blendMode:s=Xp),c!==void 0){let u=c.actionByRoot[a];if(u!==void 0&&u.blendMode===s)return u;l=c.knownActions[0],i===null&&(i=l._clip)}if(i===null)return null;let h=new Pp(this,i,t,s);return this._bindAction(h,l),this._addInactiveAction(h,o,a),h}existingAction(e,t){let s=t||this._root,n=s.uuid,a=typeof e=="string"?Vi.findByName(s,e):e,i=a?a.uuid:e,o=this._actionsByClip[i];return o!==void 0&&o.actionByRoot[n]||null}stopAllAction(){let e=this._actions,t=this._nActiveActions;for(let s=t-1;s>=0;--s)e[s].stop();return this}update(e){e*=this.timeScale;let t=this._actions,s=this._nActiveActions,n=this.time+=e,a=Math.sign(e),i=this._accuIndex^=1;for(let l=0;l!==s;++l)t[l]._update(n,e,a,i);let o=this._bindings,c=this._nActiveBindings;for(let l=0;l!==c;++l)o[l].apply(i);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){let t=this._actions,s=e.uuid,n=this._actionsByClip,a=n[s];if(a!==void 0){let i=a.knownActions;for(let o=0,c=i.length;o!==c;++o){let l=i[o];this._deactivateAction(l);let h=l._cacheIndex,u=t[t.length-1];l._cacheIndex=null,l._byClipCacheIndex=null,u._cacheIndex=h,t[h]=u,t.pop(),this._removeInactiveBindingsForAction(l)}delete n[s]}}uncacheRoot(e){let t=e.uuid,s=this._actionsByClip;for(let i in s){let o=s[i].actionByRoot,c=o[t];c!==void 0&&(this._deactivateAction(c),this._removeInactiveAction(c))}let n=this._bindingsByRootAndName,a=n[t];if(a!==void 0)for(let i in a){let o=a[i];o.restoreOriginalState(),this._removeInactiveBinding(o)}}uncacheAction(e,t){let s=this.existingAction(e,t);s!==null&&(this._deactivateAction(s),this._removeInactiveAction(s))}},_y=class extends Ps{constructor(e=1,t=1,s=1,n={}){super(e,t,n),this.isRenderTarget3D=!0,this.depth=s;for(let a=0;a<this.textures.length;a++){let i=new Hh(null,e,t,s);i.isRenderTargetTexture=!0,i.renderTarget=this,this.textures[a]=i}this._setTextureOptions(n)}},Ay=class r{constructor(e){this.value=e}clone(){return new r(this.value.clone===void 0?this.value:this.value.clone())}},$D=0,My=class extends Bs{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:$D++}),this.name="",this.usage=Uo,this.uniforms=[]}add(e){return this.uniforms.push(e),this}remove(e){let t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}setName(e){return this.name=e,this}setUsage(e){return this.usage=e,this}dispose(){this.dispatchEvent({type:"dispose"})}copy(e){this.name=e.name,this.usage=e.usage;let t=e.uniforms;this.uniforms.length=0;for(let s=0,n=t.length;s<n;s++){let a=Array.isArray(t[s])?t[s]:[t[s]];for(let i=0;i<a.length;i++)this.uniforms.push(a[i].clone())}return this}clone(){return new this.constructor().copy(this)}},Dp=class extends ri{constructor(e,t,s=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=s}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){let t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){let t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}},Sy=class{constructor(e,t,s,n,a,i=!1){this.isGLBufferAttribute=!0,this.name="",this.buffer=e,this.type=t,this.itemSize=s,this.elementSize=n,this.count=a,this.normalized=i,this.version=0}set needsUpdate(e){e===!0&&this.version++}setBuffer(e){return this.buffer=e,this}setType(e,t){return this.type=e,this.elementSize=t,this}setItemSize(e){return this.itemSize=e,this}setCount(e){return this.count=e,this}},Q8=new le,Ny=class{constructor(e,t,s=0,n=1/0){this.ray=new oi(e,t),this.near=s,this.far=n,this.camera=null,this.layers=new Wh,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,t.projectionMatrix.elements[14]).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):W("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return Q8.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Q8),this}intersectObject(e,t=!0,s=[]){return B_(e,this,s,t),s.sort(eC),s}intersectObjects(e,t=!0,s=[]){for(let n=0,a=e.length;n<a;n++)B_(e[n],this,s,t);return s.sort(eC),s}};function eC(r,e){return r.distance-e.distance}function B_(r,e,t,s){let n=!0;if(r.layers.test(e.layers)&&r.raycast(e,t)===!1&&(n=!1),n===!0&&s===!0){let a=r.children;for(let i=0,o=a.length;i<o;i++)B_(a[i],e,t,!0)}}var Ry=class{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1,K("Clock: This module has been deprecated. Please use THREE.Timer instead.")}start(){this.startTime=performance.now(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let t=performance.now();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}},il=class{constructor(e=1,t=0,s=0){this.radius=e,this.phi=t,this.theta=s}set(e,t,s){return this.radius=e,this.phi=t,this.theta=s,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Be(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,s){return this.radius=Math.sqrt(e*e+t*t+s*s),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,s),this.phi=Math.acos(Be(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}},Ey=class{constructor(e=1,t=0,s=0){this.radius=e,this.theta=t,this.y=s}set(e,t,s){return this.radius=e,this.theta=t,this.y=s,this}copy(e){return this.radius=e.radius,this.theta=e.theta,this.y=e.y,this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,s){return this.radius=Math.sqrt(e*e+s*s),this.theta=Math.atan2(e,s),this.y=t,this}clone(){return new this.constructor().copy(this)}},mu=class r{static{r.prototype.isMatrix2=!0}constructor(e,t,s,n){this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,s,n)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let s=0;s<4;s++)this.elements[s]=e[s+t];return this}set(e,t,s,n){let a=this.elements;return a[0]=e,a[2]=t,a[1]=s,a[3]=n,this}},tC=new q,Op=class{constructor(e=new q(1/0,1/0),t=new q(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,s=e.length;t<s;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let s=tC.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(s),this.max.copy(e).add(s),this}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,tC).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},sC=new E,Ug=new E,Rh=new E,Eh=new E,x_=new E,YD=new E,ZD=new E,Cy=class{constructor(e=new E,t=new E){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){sC.subVectors(e,this.start),Ug.subVectors(this.end,this.start);let s=Ug.dot(Ug);if(s===0)return 0;let a=Ug.dot(sC)/s;return t&&(a=Be(a,0,1)),a}closestPointToPoint(e,t,s){let n=this.closestPointToPointParameter(e,t);return this.delta(s).multiplyScalar(n).add(this.start)}distanceSqToLine3(e,t=YD,s=ZD){let n=10000000000000001e-32,a,i,o=this.start,c=e.start,l=this.end,h=e.end;Rh.subVectors(l,o),Eh.subVectors(h,c),x_.subVectors(o,c);let u=Rh.dot(Rh),d=Eh.dot(Eh),f=Eh.dot(x_);if(u<=n&&d<=n)return t.copy(o),s.copy(c),t.sub(s),t.dot(t);if(u<=n)a=0,i=f/d,i=Be(i,0,1);else{let p=Rh.dot(x_);if(d<=n)i=0,a=Be(-p/u,0,1);else{let m=Rh.dot(Eh),b=u*d-m*m;b!==0?a=Be((m*f-p*d)/b,0,1):a=0,i=(m*a+f)/d,i<0?(i=0,a=Be(-p/u,0,1)):i>1&&(i=1,a=Be((m-p)/u,0,1))}}return t.copy(o).addScaledVector(Rh,a),s.copy(c).addScaledVector(Eh,i),t.distanceToSquared(s)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}},nC=new E,ky=class extends Ze{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";let s=new ke,n=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let i=0,o=1,c=32;i<c;i++,o++){let l=i/c*Math.PI*2,h=o/c*Math.PI*2;n.push(Math.cos(l),Math.sin(l),1,Math.cos(h),Math.sin(h),1)}s.setAttribute("position",new ge(n,3));let a=new ns({fog:!1,toneMapped:!1});this.cone=new _n(s,a),this.add(this.cone),this.update()}dispose(){super.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorldNeedsUpdate=!0;let e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),nC.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(nC),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},go=new E,Lg=new le,w_=new le,Iy=class extends _n{constructor(e){let t=zC(e),s=new ke,n=[],a=[];for(let l=0;l<t.length;l++){let h=t[l];h.parent&&h.parent.isBone&&(n.push(0,0,0),n.push(0,0,0),a.push(0,0,0),a.push(0,0,0))}s.setAttribute("position",new ge(n,3)),s.setAttribute("color",new ge(a,3));let i=new ns({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(s,i),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1;let o=new be(255),c=new be(65280);this.setColors(o,c)}updateMatrixWorld(e){let t=this.bones,s=this.geometry,n=s.getAttribute("position");w_.copy(this.root.matrixWorld).invert();for(let a=0,i=0;a<t.length;a++){let o=t[a];o.parent&&o.parent.isBone&&(Lg.multiplyMatrices(w_,o.matrixWorld),go.setFromMatrixPosition(Lg),n.setXYZ(i,go.x,go.y,go.z),Lg.multiplyMatrices(w_,o.parent.matrixWorld),go.setFromMatrixPosition(Lg),n.setXYZ(i+1,go.x,go.y,go.z),i+=2)}s.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}setColors(e,t){let n=this.geometry.getAttribute("color");for(let a=0;a<n.count;a+=2)n.setXYZ(a,e.r,e.g,e.b),n.setXYZ(a+1,t.r,t.g,t.b);return n.needsUpdate=!0,this}dispose(){super.dispose(),this.geometry.dispose(),this.material.dispose()}};function zC(r){let e=[];r.isBone===!0&&e.push(r);for(let t=0;t<r.children.length;t++)e.push(...zC(r.children[t]));return e}var By=class extends at{constructor(e,t,s){let n=new Yc(t,4,2),a=new Bt({wireframe:!0,fog:!1,toneMapped:!1});super(n,a),this.light=e,this.color=s,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){super.dispose(),this.geometry.dispose(),this.material.dispose()}update(){this.matrixWorldNeedsUpdate=!0,this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}},QD=new E,aC=new be,iC=new be,Fy=class extends Ze{constructor(e,t,s){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=s,this.type="HemisphereLightHelper";let n=new nu(t);n.rotateY(Math.PI*.5),this.material=new Bt({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);let a=n.getAttribute("position"),i=new Float32Array(a.count*3);n.setAttribute("color",new Xe(i,3)),this.add(new at(n,this.material)),this.update()}dispose(){super.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){let e=this.children[0];if(this.color!==void 0)this.material.color.set(this.color);else{let t=e.geometry.getAttribute("color");aC.copy(this.light.color),iC.copy(this.light.groundColor);for(let s=0,n=t.count;s<n;s++){let a=s<n/2?aC:iC;t.setXYZ(s,a.r,a.g,a.b)}t.needsUpdate=!0}this.matrixWorldNeedsUpdate=!0,this.light.updateWorldMatrix(!0,!1),e.lookAt(QD.setFromMatrixPosition(this.light.matrixWorld).negate())}},Py=class extends _n{constructor(e=10,t=10,s=4473924,n=8947848){s=new be(s),n=new be(n);let a=t/2,i=e/t,o=e/2,c=[],l=[];for(let d=0,f=0,p=-o;d<=t;d++,p+=i){c.push(-o,0,p,o,0,p),c.push(p,0,-o,p,0,o);let m=d===a?s:n;m.toArray(l,f),f+=3,m.toArray(l,f),f+=3,m.toArray(l,f),f+=3,m.toArray(l,f),f+=3}let h=new ke;h.setAttribute("position",new ge(c,3)),h.setAttribute("color",new ge(l,3));let u=new ns({vertexColors:!0,toneMapped:!1});super(h,u),this.type="GridHelper"}dispose(){super.dispose(),this.geometry.dispose(),this.material.dispose()}},Dy=class extends _n{constructor(e=10,t=16,s=8,n=64,a=4473924,i=8947848){a=new be(a),i=new be(i);let o=[],c=[];if(t>1)for(let u=0;u<t;u++){let d=u/t*(Math.PI*2),f=Math.sin(d)*e,p=Math.cos(d)*e;o.push(0,0,0),o.push(f,0,p);let m=u&1?a:i;c.push(m.r,m.g,m.b),c.push(m.r,m.g,m.b)}for(let u=0;u<s;u++){let d=u&1?a:i,f=e-e/s*u;for(let p=0;p<n;p++){let m=p/n*(Math.PI*2),b=Math.sin(m)*f,g=Math.cos(m)*f;o.push(b,0,g),c.push(d.r,d.g,d.b),m=(p+1)/n*(Math.PI*2),b=Math.sin(m)*f,g=Math.cos(m)*f,o.push(b,0,g),c.push(d.r,d.g,d.b)}}let l=new ke;l.setAttribute("position",new ge(o,3)),l.setAttribute("color",new ge(c,3));let h=new ns({vertexColors:!0,toneMapped:!1});super(l,h),this.type="PolarGridHelper"}dispose(){super.dispose(),this.geometry.dispose(),this.material.dispose()}},rC=new E,zg=new E,oC=new E,Oy=class extends Ze{constructor(e,t,s){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=s,this.type="DirectionalLightHelper",t===void 0&&(t=1);let n=new ke;n.setAttribute("position",new ge([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));let a=new ns({fog:!1,toneMapped:!1});this.lightPlane=new Qn(n,a),this.add(this.lightPlane),n=new ke,n.setAttribute("position",new ge([0,0,0,0,0,1],3)),this.targetLine=new Qn(n,a),this.add(this.targetLine),this.update()}dispose(){super.dispose(),this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.matrixWorldNeedsUpdate=!0,this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),rC.setFromMatrixPosition(this.light.matrixWorld),zg.setFromMatrixPosition(this.light.target.matrixWorld),oC.subVectors(zg,rC),this.lightPlane.lookAt(zg),this.color!==void 0?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(zg),this.targetLine.scale.z=oC.length()}},Vg=new E,Ht=new tl,Uy=class extends _n{constructor(e){let t=new ke,s=new ns({color:16777215,vertexColors:!0,toneMapped:!1}),n=[],a=[],i={};o("n1","n2"),o("n2","n4"),o("n4","n3"),o("n3","n1"),o("f1","f2"),o("f2","f4"),o("f4","f3"),o("f3","f1"),o("n1","f1"),o("n2","f2"),o("n3","f3"),o("n4","f4"),o("p","n1"),o("p","n2"),o("p","n3"),o("p","n4"),o("u1","u2"),o("u2","u3"),o("u3","u1"),o("c","t"),o("p","c"),o("cn1","cn2"),o("cn3","cn4"),o("cf1","cf2"),o("cf3","cf4");function o(p,m){c(p),c(m)}function c(p){n.push(0,0,0),a.push(0,0,0),i[p]===void 0&&(i[p]=[]),i[p].push(n.length/3-1)}t.setAttribute("position",new ge(n,3)),t.setAttribute("color",new ge(a,3)),super(t,s),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=i,this.update();let l=new be(16755200),h=new be(16711680),u=new be(43775),d=new be(16777215),f=new be(3355443);this.setColors(l,h,u,d,f)}setColors(e,t,s,n,a){let o=this.geometry.getAttribute("color");return o.setXYZ(0,e.r,e.g,e.b),o.setXYZ(1,e.r,e.g,e.b),o.setXYZ(2,e.r,e.g,e.b),o.setXYZ(3,e.r,e.g,e.b),o.setXYZ(4,e.r,e.g,e.b),o.setXYZ(5,e.r,e.g,e.b),o.setXYZ(6,e.r,e.g,e.b),o.setXYZ(7,e.r,e.g,e.b),o.setXYZ(8,e.r,e.g,e.b),o.setXYZ(9,e.r,e.g,e.b),o.setXYZ(10,e.r,e.g,e.b),o.setXYZ(11,e.r,e.g,e.b),o.setXYZ(12,e.r,e.g,e.b),o.setXYZ(13,e.r,e.g,e.b),o.setXYZ(14,e.r,e.g,e.b),o.setXYZ(15,e.r,e.g,e.b),o.setXYZ(16,e.r,e.g,e.b),o.setXYZ(17,e.r,e.g,e.b),o.setXYZ(18,e.r,e.g,e.b),o.setXYZ(19,e.r,e.g,e.b),o.setXYZ(20,e.r,e.g,e.b),o.setXYZ(21,e.r,e.g,e.b),o.setXYZ(22,e.r,e.g,e.b),o.setXYZ(23,e.r,e.g,e.b),o.setXYZ(24,t.r,t.g,t.b),o.setXYZ(25,t.r,t.g,t.b),o.setXYZ(26,t.r,t.g,t.b),o.setXYZ(27,t.r,t.g,t.b),o.setXYZ(28,t.r,t.g,t.b),o.setXYZ(29,t.r,t.g,t.b),o.setXYZ(30,t.r,t.g,t.b),o.setXYZ(31,t.r,t.g,t.b),o.setXYZ(32,s.r,s.g,s.b),o.setXYZ(33,s.r,s.g,s.b),o.setXYZ(34,s.r,s.g,s.b),o.setXYZ(35,s.r,s.g,s.b),o.setXYZ(36,s.r,s.g,s.b),o.setXYZ(37,s.r,s.g,s.b),o.setXYZ(38,n.r,n.g,n.b),o.setXYZ(39,n.r,n.g,n.b),o.setXYZ(40,a.r,a.g,a.b),o.setXYZ(41,a.r,a.g,a.b),o.setXYZ(42,a.r,a.g,a.b),o.setXYZ(43,a.r,a.g,a.b),o.setXYZ(44,a.r,a.g,a.b),o.setXYZ(45,a.r,a.g,a.b),o.setXYZ(46,a.r,a.g,a.b),o.setXYZ(47,a.r,a.g,a.b),o.setXYZ(48,a.r,a.g,a.b),o.setXYZ(49,a.r,a.g,a.b),o.needsUpdate=!0,this}update(){let e=this.geometry,t=this.pointMap,s=1,n=1,a,i;if(Ht.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),this.camera.reversedDepth===!0)a=1,i=0;else if(this.camera.coordinateSystem===sn)a=-1,i=1;else if(this.camera.coordinateSystem===Xs)a=0,i=1;else throw new Error("THREE.CameraHelper.update(): Invalid coordinate system: "+this.camera.coordinateSystem);ts("c",t,e,Ht,0,0,a),ts("t",t,e,Ht,0,0,i),ts("n1",t,e,Ht,-s,-n,a),ts("n2",t,e,Ht,s,-n,a),ts("n3",t,e,Ht,-s,n,a),ts("n4",t,e,Ht,s,n,a),ts("f1",t,e,Ht,-s,-n,i),ts("f2",t,e,Ht,s,-n,i),ts("f3",t,e,Ht,-s,n,i),ts("f4",t,e,Ht,s,n,i),ts("u1",t,e,Ht,s*.7,n*1.1,a),ts("u2",t,e,Ht,-s*.7,n*1.1,a),ts("u3",t,e,Ht,0,n*2,a),ts("cf1",t,e,Ht,-s,0,i),ts("cf2",t,e,Ht,s,0,i),ts("cf3",t,e,Ht,0,-n,i),ts("cf4",t,e,Ht,0,n,i),ts("cn1",t,e,Ht,-s,0,a),ts("cn2",t,e,Ht,s,0,a),ts("cn3",t,e,Ht,0,-n,a),ts("cn4",t,e,Ht,0,n,a),e.getAttribute("position").needsUpdate=!0}dispose(){super.dispose(),this.geometry.dispose(),this.material.dispose()}};function ts(r,e,t,s,n,a,i){Vg.set(n,a,i).unproject(s);let o=e[r];if(o!==void 0){let c=t.getAttribute("position");for(let l=0,h=o.length;l<h;l++)c.setXYZ(o[l],Vg.x,Vg.y,Vg.z)}}var jg=new ss,Ly=class extends _n{constructor(e,t=16776960){let s=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),n=new Float32Array(24),a=new ke;a.setIndex(new Xe(s,1)),a.setAttribute("position",new Xe(n,3)),super(a,new ns({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(){if(this.object!==void 0&&jg.setFromObject(this.object),jg.isEmpty())return;let e=jg.min,t=jg.max,s=this.geometry.attributes.position,n=s.array;n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=e.x,n[4]=t.y,n[5]=t.z,n[6]=e.x,n[7]=e.y,n[8]=t.z,n[9]=t.x,n[10]=e.y,n[11]=t.z,n[12]=t.x,n[13]=t.y,n[14]=e.z,n[15]=e.x,n[16]=t.y,n[17]=e.z,n[18]=e.x,n[19]=e.y,n[20]=e.z,n[21]=t.x,n[22]=e.y,n[23]=e.z,s.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(e){return this.object=e,this.update(),this}copy(e,t){return super.copy(e,t),this.object=e.object,this}dispose(){super.dispose(),this.geometry.dispose(),this.material.dispose()}},zy=class extends _n{constructor(e,t=16776960){let s=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),n=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],a=new ke;a.setIndex(new Xe(s,1)),a.setAttribute("position",new ge(n,3)),super(a,new ns({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){let t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){super.dispose(),this.geometry.dispose(),this.material.dispose()}},Vy=class extends Qn{constructor(e,t=1,s=16776960){let n=s,a=[1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],i=new ke;i.setAttribute("position",new ge(a,3)),i.computeBoundingSphere(),super(i,new ns({color:n,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t;let o=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],c=new ke;c.setAttribute("position",new ge(o,3)),c.computeBoundingSphere(),this.add(new at(c,new Bt({color:n,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(e){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(e)}dispose(){super.dispose(),this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}},cC=new E,Gg,T_,jy=class extends Ze{constructor(e=new E(0,0,1),t=new E(0,0,0),s=1,n=16776960,a=s*.2,i=a*.2){super(),this.type="ArrowHelper",Gg===void 0&&(Gg=new ke,Gg.setAttribute("position",new ge([0,0,0,0,1,0],3)),T_=new $h(.5,1,5,1),T_.translate(0,-.5,0)),this.position.copy(t),this.line=new Qn(Gg,new ns({color:n,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new at(T_,new Bt({color:n,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(s,a,i)}setDirection(e){if(e.y>.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{cC.set(e.z,0,-e.x).normalize();let t=Math.acos(e.y);this.quaternion.setFromAxisAngle(cC,t)}}setLength(e,t=e*.2,s=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(s,t,s),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){super.dispose(),this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}},Gy=class extends _n{constructor(e=1){let t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],s=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],n=new ke;n.setAttribute("position",new ge(t,3)),n.setAttribute("color",new ge(s,3));let a=new ns({vertexColors:!0,toneMapped:!1});super(n,a),this.type="AxesHelper"}setColors(e,t,s){let n=new be,a=this.geometry.attributes.color.array;return n.set(e),n.toArray(a,0),n.toArray(a,3),n.set(t),n.toArray(a,6),n.toArray(a,9),n.set(s),n.toArray(a,12),n.toArray(a,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){super.dispose(),this.geometry.dispose(),this.material.dispose()}},Hy=class{constructor(){this.type="ShapePath",this.color=new be,this.subPaths=[],this.currentPath=null,this.userData={}}moveTo(e,t){return this.currentPath=new Ao,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,s,n){return this.currentPath.quadraticCurveTo(e,t,s,n),this}bezierCurveTo(e,t,s,n,a,i){return this.currentPath.bezierCurveTo(e,t,s,n,a,i),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(){function e(c,l){let h=!1,u=l.length;for(let d=0,f=u-1;d<u;f=d++){let p=l[d],m=l[f];p.y>c.y!=m.y>c.y&&c.x<(m.x-p.x)*(c.y-p.y)/(m.y-p.y)+p.x&&(h=!h)}return h}function t(c,l){let h=l.getCenter(new q);if(e(h,c))return h;let u=h.y,d=[],f=c.length;for(let p=0;p<f;p++){let m=c[p],b=c[(p+1)%f];if(m.y>u!=b.y>u){let g=m.x+(u-m.y)*(b.x-m.x)/(b.y-m.y);d.push(g)}}return d.length>1&&(d.sort((p,m)=>p-m),h.x=(d[0]+d[1])/2),h}let s=this.userData.style&&this.userData.style.fillRule||"nonzero";s!=="nonzero"&&s!=="evenodd"&&(K('Fill-rule "'+s+'" is not supported, falling back to "nonzero".'),s="nonzero");let n=s==="nonzero"?(c=>c!==0):(c=>(c&1)!==0),a=[];for(let c of this.subPaths){let l=c.getPoints();if(l.length<3)continue;let h=Sa.area(l);if(h===0)continue;let u=new Op;for(let d=0;d<l.length;d++)u.expandByPoint(l[d]);a.push({subPath:c,points:l,boundingBox:u,interiorPoint:t(l,u),absArea:Math.abs(h),winding:h<0?-1:1,container:null,exclude:!1,role:null})}a.sort((c,l)=>l.absArea-c.absArea);for(let c=0;c<a.length;c++){let l=a[c],h=0;for(let u=c-1;u>=0;u--){let d=a[u];if(d.boundingBox.containsBox(l.boundingBox)&&e(l.interiorPoint,d.points)){l.container=d.exclude?d.container:d,h=d.winding,l.winding+=h;break}}n(l.winding)===n(h)&&(l.exclude=!0)}for(let c of a)c.exclude||(c.role=c.container===null||c.container.role==="hole"?"outer":"hole");let i=[],o=new Map;for(let c of a){if(c.exclude||c.role!=="outer")continue;let l=new Mo;l.curves=c.subPath.curves,i.push(l),o.set(c,l)}for(let c of a){if(c.exclude||c.role!=="hole")continue;let l=o.get(c.container);if(!l)continue;let h=new Ao;h.curves=c.subPath.curves,l.holes.push(h)}return i}},bu=class extends Bs{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}};function eO(r,e){let t=r.image&&r.image.width?r.image.width/r.image.height:1;return t>e?(r.repeat.x=1,r.repeat.y=t/e,r.offset.x=0,r.offset.y=(1-r.repeat.y)/2):(r.repeat.x=e/t,r.repeat.y=1,r.offset.x=(1-r.repeat.x)/2,r.offset.y=0),r}function tO(r,e){let t=r.image&&r.image.width?r.image.width/r.image.height:1;return t>e?(r.repeat.x=e/t,r.repeat.y=1,r.offset.x=(1-r.repeat.x)/2,r.offset.y=0):(r.repeat.x=1,r.repeat.y=t/e,r.offset.x=0,r.offset.y=(1-r.repeat.y)/2),r}function sO(r){return r.repeat.x=1,r.repeat.y=1,r.offset.x=0,r.offset.y=0,r}function Ax(r,e,t,s){let n=nO(s);switch(t){case Su:return r*e;case Lr:return r*e/n.components*n.byteLength;case zr:return r*e/n.components*n.byteLength;case cn:return r*e*2/n.components*n.byteLength;case Do:return r*e*2/n.components*n.byteLength;case Po:return r*e*3/n.components*n.byteLength;case gs:return r*e*4/n.components*n.byteLength;case Nu:return r*e*4/n.components*n.byteLength;case hl:case ul:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*8;case dl:case fl:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*16;case Hp:case qp:return Math.max(r,16)*Math.max(e,8)/4;case Gp:case Wp:return Math.max(r,8)*Math.max(e,8)/2;case Ru:case Eu:case ku:case Iu:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*8;case Cu:case Vr:case Bu:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*16;case Fu:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*16;case Pu:return Math.floor((r+4)/5)*Math.floor((e+3)/4)*16;case Du:return Math.floor((r+4)/5)*Math.floor((e+4)/5)*16;case Ou:return Math.floor((r+5)/6)*Math.floor((e+4)/5)*16;case Uu:return Math.floor((r+5)/6)*Math.floor((e+5)/6)*16;case Lu:return Math.floor((r+7)/8)*Math.floor((e+4)/5)*16;case zu:return Math.floor((r+7)/8)*Math.floor((e+5)/6)*16;case Vu:return Math.floor((r+7)/8)*Math.floor((e+7)/8)*16;case ju:return Math.floor((r+9)/10)*Math.floor((e+4)/5)*16;case Gu:return Math.floor((r+9)/10)*Math.floor((e+5)/6)*16;case Hu:return Math.floor((r+9)/10)*Math.floor((e+7)/8)*16;case Wu:return Math.floor((r+9)/10)*Math.floor((e+9)/10)*16;case qu:return Math.floor((r+11)/12)*Math.floor((e+9)/10)*16;case Xu:return Math.floor((r+11)/12)*Math.floor((e+11)/12)*16;case Ku:case Ju:case $u:return Math.ceil(r/4)*Math.ceil(e/4)*16;case Yu:case Zu:return Math.ceil(r/4)*Math.ceil(e/4)*8;case jr:case Qu:return Math.ceil(r/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function nO(r){switch(r){case ws:case Ur:return{byteLength:1,components:1};case ka:case pi:case ds:return{byteLength:2,components:1};case zp:case Vp:return{byteLength:2,components:4};case St:case Ts:case Mt:return{byteLength:4,components:1};case Au:case Mu:return{byteLength:4,components:3}}throw new Error(`THREE.TextureUtils: Unknown texture type ${r}.`)}var Wy=class{static contain(e,t){return eO(e,t)}static cover(e,t){return tO(e,t)}static fill(e){return sO(e)}static getByteLength(e,t,s,n){return Ax(e,t,s,n)}};typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"186"}}));typeof window<"u"&&(window.__THREE__?K("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="186");var aO=["alphaMap","alphaTest","anisotropy","anisotropyMap","anisotropyRotation","aoMap","aoMapIntensity","attenuationColor","attenuationDistance","bumpMap","bumpScale","clearcoat","clearcoatMap","clearcoatNormalMap","clearcoatNormalScale","clearcoatRoughness","color","dashOffset","dashSize","dispersion","displacementBias","displacementMap","displacementScale","emissive","emissiveIntensity","emissiveMap","envMap","envMapIntensity","envMapRotation","gapSize","gradientMap","ior","iridescence","iridescenceIOR","iridescenceMap","iridescenceThickness","iridescenceThicknessMap","lightMap","lightMapIntensity","linewidth","map","matcap","metalness","metalnessMap","normalMap","normalScale","opacity","reflectivity","retroreflectivity","rotation","roughness","roughnessMap","scale","sheen","sheenColor","sheenColorMap","sheenRoughness","sheenRoughnessMap","shininess","size","specular","specularColor","specularColorMap","specularIntensity","specularIntensityMap","specularMap","steps","thickness","transmission","transmissionMap","wireframe"],VC=new WeakMap,jC=new WeakMap,GC=new WeakMap,HC=new WeakMap,b0=class{constructor(e){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(e),this.hasAnimation=e.object.isSkinnedMesh===!0,this.refreshUniforms=aO,this.renderId=0}firstInitialization(e){return this.renderObjects.has(e)===!1?(this.getRenderObjectData(e),!0):!1}hasDynamicInstancing(e){return e.isInstancedMesh===!0&&(e.instanceMatrix.usage===Gr||e.instanceColor!==null&&e.instanceColor.usage===Gr)}needsVelocity(e){let t=e.getMRT();return t!==null&&t.has("velocity")}getRenderObjectData(e){let t=this.renderObjects.get(e);if(t===void 0){let{geometry:s,object:n}=e;t={geometryId:s.id,geometryVersion:this.getGeometryData(s)._version,materialVersion:this.getMaterialData(e.material)._version,worldMatrix:n.matrixWorld.clone()},n.center&&(t.center=n.center.clone()),n.morphTargetInfluences&&(t.morphTargetInfluences=n.morphTargetInfluences.slice()),n.isInstancedMesh===!0&&(t.instanceMatrixVersion=n.instanceMatrix.version,t.instanceColorVersion=n.instanceColor!==null?n.instanceColor.version:null,t.morphTextureVersion=n.morphTexture!==null?n.morphTexture.version:null),n.isBatchedMesh===!0&&(t.matricesTextureVersion=n._matricesTexture.version,t.colorsTextureVersion=n._colorsTexture!==null?n._colorsTexture.version:null,t.indirectTextureVersion=n._indirectTexture.version),e.bundle!==null&&(t.version=e.bundle.version);let{width:a,height:i}=e.context;t.bufferWidth=a,t.bufferHeight=i;let{environmentIntensity:o,environmentRotation:c}=e.scene;t.environmentIntensity=o,t.environmentRotation=c.clone(),t.lights=this.getLightsData(e.lightsNode.getBuiltinLights(),[]),this.renderObjects.set(e,t)}return t}getAttributesData(e){let t={};for(let s in e){let n=e[s];t[s]={id:n.isInterleavedBufferAttribute?n.data.uuid:n.id,version:n.isInterleavedBufferAttribute?n.data.version:n.version}}return t}containsNode(e){let t=e.material;for(let s in t)if(t[s]&&t[s].isNode)return!0;return!!(e.context.modelViewMatrix||e.context.modelNormalViewMatrix||e.context.getAO||e.context.getShadow)}getGeometryData(e){let t=GC.get(e);return t===void 0&&(t={_renderId:-1,_version:0,attributes:this.getAttributesData(e.attributes),indexId:e.index?e.index.id:null,indexVersion:e.index?e.index.version:null,drawRange:{start:e.drawRange.start,count:e.drawRange.count}},e.addEventListener("dispose",()=>{t._version++}),GC.set(e,t)),t}getTextureData(e){let t=HC.get(e);if(t===void 0){t={_version:0};let s=()=>{t._version++};e.renderTarget!==null?e.renderTarget.addEventListener("dispose",s):e.addEventListener("dispose",s),HC.set(e,t)}return t}getMaterialData(e){let t=jC.get(e);if(t===void 0){t={_renderId:-1,_version:0};for(let s of this.refreshUniforms){let n=e[s];n!==void 0&&(n===null?t[s]=null:typeof n=="object"&&n.clone!==void 0?n.isTexture===!0?t[s]={id:n.id,version:0,cacheVersion:this.getTextureData(n)._version}:t[s]=n.clone():t[s]=n)}jC.set(e,t)}return t}equals(e,t,s){let{object:n,material:a,geometry:i}=e,o=this.getRenderObjectData(e);if(o.worldMatrix.equals(n.matrixWorld)!==!0)return o.worldMatrix.copy(n.matrixWorld),!1;let c=this.getMaterialData(e.material);if(c._renderId!==s){c._renderId=s;let f=!1;for(let p in c){let m=c[p],b=a[p];if(p!=="_renderId"&&p!=="_version")if(m===null||b===null||b===void 0)m!==(b===void 0?null:b)&&(b==null?c[p]=null:b.isTexture===!0?c[p]={id:b.id,version:b.version,cacheVersion:this.getTextureData(b)._version}:typeof b=="object"&&b.clone!==void 0?c[p]=b.clone():c[p]=b,f=!0);else if(m.equals!==void 0)m.equals(b)===!1&&(m.copy(b),f=!0);else if(b.isTexture===!0){let g=this.getTextureData(b);(m.id!==b.id||m.version!==b.version||m.cacheVersion!==g._version)&&(m.id=b.id,m.version=b.version,m.cacheVersion=g._version,f=!0)}else m!==b&&(c[p]=b,f=!0)}f===!0&&c._version++}if(o.materialVersion!==c._version)return o.materialVersion=c._version,!1;let{width:l,height:h}=e.context;if(o.bufferWidth!==l||o.bufferHeight!==h)return o.bufferWidth=l,o.bufferHeight=h,!1;if(o.geometryId!==i.id)return o.geometryId=i.id,o.geometryVersion=this.getGeometryData(i)._version,!1;let u=this.getGeometryData(e.geometry);if(u._renderId!==s){u._renderId=s;let f=!1,p=i.attributes,m=u.attributes,b=0,g=0;for(let v in p)b++;for(let v in m){g++;let _=m[v],A=p[v];if(A===void 0){delete m[v],f=!0;continue}let M=A.isInterleavedBufferAttribute?A.data.uuid:A.id,N=A.isInterleavedBufferAttribute?A.data.version:A.version;(_.id!==M||_.version!==N)&&(_.id=M,_.version=N,f=!0)}g!==b&&(u.attributes=this.getAttributesData(p),f=!0);let x=i.index,T=x?x.id:null,y=x?x.version:null;(u.indexId!==T||u.indexVersion!==y)&&(u.indexId=T,u.indexVersion=y,f=!0),(u.drawRange.start!==i.drawRange.start||u.drawRange.count!==i.drawRange.count)&&(u.drawRange.start=i.drawRange.start,u.drawRange.count=i.drawRange.count,f=!0),f===!0&&u._version++}if(o.geometryVersion!==u._version)return o.geometryVersion=u._version,!1;if(o.morphTargetInfluences){let f=!1;for(let p=0;p<o.morphTargetInfluences.length;p++)o.morphTargetInfluences[p]!==n.morphTargetInfluences[p]&&(o.morphTargetInfluences[p]=n.morphTargetInfluences[p],f=!0);if(f)return!1}if(n.isInstancedMesh===!0){let f=n.instanceColor!==null?n.instanceColor.version:null,p=n.morphTexture!==null?n.morphTexture.version:null;if(o.instanceMatrixVersion!==n.instanceMatrix.version||o.instanceColorVersion!==f||o.morphTextureVersion!==p)return o.instanceMatrixVersion=n.instanceMatrix.version,o.instanceColorVersion=f,o.morphTextureVersion=p,!1}if(n.isBatchedMesh===!0){let f=n._colorsTexture!==null?n._colorsTexture.version:null;if(o.matricesTextureVersion!==n._matricesTexture.version||o.colorsTextureVersion!==f||o.indirectTextureVersion!==n._indirectTexture.version)return o.matricesTextureVersion=n._matricesTexture.version,o.colorsTextureVersion=f,o.indirectTextureVersion=n._indirectTexture.version,!1}if(o.lights)for(let f=0;f<t.length;f++){let p=o.lights[f],m=t[f];if(p.map!==m.map||p.cacheVersion!==m.cacheVersion||p.shadowMapWidth!==m.shadowMapWidth||p.shadowMapHeight!==m.shadowMapHeight)return p.map=m.map,p.cacheVersion=m.cacheVersion,p.shadowMapWidth=m.shadowMapWidth,p.shadowMapHeight=m.shadowMapHeight,!1}let d=e.scene;return d.environment!==null&&a.envMap===null&&(o.environmentIntensity!==d.environmentIntensity||o.environmentRotation.equals(d.environmentRotation)===!1)?(o.environmentIntensity=d.environmentIntensity,o.environmentRotation.copy(d.environmentRotation),!1):o.center&&o.center.equals(n.center)===!1?(o.center.copy(n.center),!1):(e.bundle!==null&&(o.version=e.bundle.version),!0)}getLightsData(e,t){t.length=0;for(let s of e){let n=null;s.isSpotLight===!0&&s.map!==null&&(n={map:s.map.version,cacheVersion:this.getTextureData(s.map)._version}),s.castShadow===!0&&s.shadow!==void 0&&(n===null&&(n={}),n.shadowMapWidth=s.shadow.mapSize.width,n.shadowMapHeight=s.shadow.mapSize.height),n!==null&&t.push(n)}return t}getLights(e,t){let s=VC.get(e);return s===void 0&&(s={renderId:-1,lightsData:[]},VC.set(e,s)),s.renderId===t||(s.renderId=t,this.getLightsData(e.getBuiltinLights(),s.lightsData)),s.lightsData}needsRefresh(e,t){if(this.hasNode||this.hasAnimation||this.hasDynamicInstancing(e.object)||this.firstInitialization(e)||this.needsVelocity(t.renderer))return bi.FULL;let{renderId:s}=t,n=bi.NONE;this.renderId!==s&&(this.renderId=s,n=bi.SHARED);let a=e.object.static===!0,i=e.bundle!==null&&e.bundle.static===!0&&this.getRenderObjectData(e).version===e.bundle.version;if(a||i)return n;let o=this.getLights(e.lightsNode,s);return this.equals(e,o,s)===!1&&(n=bi.FULL),n}},iO=[/^StackTrace\.js$/,/^TSLCore\.js$/,/^.*Node\.js$/,/^three\.webgpu.*\.js$/];function rO(r){let e=/(?:at\s+(.+?)\s+\()?(?:(.+?)@)?([^@\s()]+):(\d+):(\d+)/;return r.split(`
`).map(t=>{let s=t.match(e);if(!s)return null;let n=s[1]||s[2]||"",a=s[3].split("?")[0],i=parseInt(s[4],10),o=parseInt(s[5],10),c=a.split("/").pop();return{fn:n,file:c,line:i,column:o}}).filter(t=>t&&!iO.some(s=>s.test(t.file)))}var is=class{constructor(e=null){this.isStackTrace=!0,this.stack=rO(e||new Error().stack)}getLocation(){if(this.stack.length===0)return"[Unknown location]";let e=this.stack[0],t=e.fn;return`${t?`"${t}()" at `:""}"${e.file}:${e.line}"`}getError(e){if(this.stack.length===0)return e;let t=this.stack.map(s=>{let n=`${s.file}:${s.line}:${s.column}`;return s.fn?`    at ${s.fn} (${n})`:`    at ${n}`}).join(`
`);return`${e}
${t}`}};function l1(r,e=0){let t=3735928559^e,s=1103547991^e;if(Array.isArray(r))for(let n=0,a;n<r.length;n++)a=r[n],t=Math.imul(t^a,2654435761),s=Math.imul(s^a,1597334677);else for(let n=0,a;n<r.length;n++)a=r.charCodeAt(n),t=Math.imul(t^a,2654435761),s=Math.imul(s^a,1597334677);return t=Math.imul(t^t>>>16,2246822507),t^=Math.imul(s^s>>>13,3266489909),s=Math.imul(s^s>>>16,2246822507),s^=Math.imul(t^t>>>13,3266489909),4294967296*(2097151&s)+(t>>>0)}var fc=r=>l1(r),$d=r=>l1(r),wd=(...r)=>l1(r),oO=new Map([[1,"float"],[2,"vec2"],[3,"vec3"],[4,"vec4"],[9,"mat3"],[16,"mat4"]]),WC=new WeakMap;function CT(r){return oO.get(r)}function Rm(r){if(/[iu]?vec\d/.test(r))return r.startsWith("ivec")?Int32Array:r.startsWith("uvec")?Uint32Array:Float32Array;if(/mat\d/.test(r)||/float/.test(r))return Float32Array;if(/uint/.test(r))return Uint32Array;if(/int/.test(r))return Int32Array;throw new Error(`THREE.NodeUtils: Unsupported type: ${r}`)}function h1(r){if(/float|int|uint|bool/.test(r))return 1;if(/vec2/.test(r))return 2;if(/vec3/.test(r))return 3;if(/vec4/.test(r)||/mat2/.test(r))return 4;if(/mat3/.test(r))return 9;if(/mat4/.test(r))return 16;W(`TSL: Unsupported type: ${r}`,new is)}function dI(r){if(/float|int|uint|bool/.test(r))return 1;if(/vec2/.test(r))return 2;if(/vec3/.test(r))return 3;if(/vec4/.test(r)||/mat2/.test(r))return 4;if(/mat3/.test(r))return 12;if(/mat4/.test(r))return 16;W(`TSL: Unsupported type: ${r}`,new is)}function fI(r){if(/float|int|uint|bool/.test(r))return 1;if(/vec2/.test(r))return 2;if(/vec3/.test(r)||/vec4/.test(r))return 4;if(/mat2/.test(r))return 2;if(/mat3/.test(r)||/mat4/.test(r))return 4;W(`TSL: Unsupported type: ${r}`,new is)}function to(r){if(r==null)return null;let e=typeof r;return r.isNode===!0?"node":e==="number"?"float":e==="boolean"?"bool":e==="string"?"string":e==="function"?"shader":r.isVector2===!0?"vec2":r.isVector3===!0?"vec3":r.isVector4===!0?"vec4":r.isMatrix2===!0?"mat2":r.isMatrix3===!0?"mat3":r.isMatrix4===!0?"mat4":r.isColor===!0?"color":r instanceof ArrayBuffer?"ArrayBuffer":null}function u1(r){if(r.isDepthTexture===!0)return"float";let e=r.format,t;e===Lr||e===zr||e===vn||e===na||e===Su?t=1:e===cn||e===Do?t=2:e===Po||e===jp?t=3:t=4;let s;if(r.type===St?s="uint":r.type===Ts?s="int":s="float",t===1)return s;let n=CT(t);return s!=="float"&&(n=s[0]+n),n}function kT(r,...e){let t=r?r.slice(-4):void 0;return e.length===1&&(t==="vec2"?e=[e[0],e[0]]:t==="vec3"?e=[e[0],e[0],e[0]]:t==="vec4"&&(e=[e[0],e[0],e[0],e[0]])),r==="color"?new be(...e):t==="vec2"?new q(...e):t==="vec3"?new E(...e):t==="vec4"?new Ge(...e):t==="mat2"?new mu(...e):t==="mat3"?new Fs(...e):t==="mat4"?new le(...e):r==="bool"?e[0]||!1:r==="float"||r==="int"||r==="uint"?e[0]||0:r==="string"?e[0]||"":r==="ArrayBuffer"?mI(e[0]):null}function d1(r){let e=WC.get(r);return e===void 0&&(e={},WC.set(r,e)),e}function pI(r){let e="",t=new Uint8Array(r);for(let s=0;s<t.length;s++)e+=String.fromCharCode(t[s]);return btoa(e)}function mI(r){return Uint8Array.from(atob(r),e=>e.charCodeAt(0)).buffer}function IT(r){return r[0]!==void 0&&r[0]!==null&&(r[0].isNode||Object.getPrototypeOf(r[0])!==Object.prototype)}var cO=Object.freeze({__proto__:null,arrayBufferToBase64:pI,base64ToArrayBuffer:mI,getAlignmentFromType:fI,getDataFromObject:d1,getLengthFromType:h1,getMemoryLengthFromType:dI,getTextureType:u1,getTypeFromLength:CT,getTypedArrayFromType:Rm,getValueFromType:kT,getValueType:to,hash:wd,hashArray:$d,hashString:fc,isArrayAsParameter:IT}),Ml={VERTEX:"vertex",FRAGMENT:"fragment"},Me={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},bI={BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},As={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},f1=["fragment","vertex"],xm=["setup","analyze","generate"],wm=[...f1,"compute"],pc=["x","y","z","w"],lO={analyze:"setup",generate:"analyze"},hO=0,we=class r extends Bs{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=Me.NONE,this.updateBeforeType=Me.NONE,this.updateAfterType=Me.NONE,this.version=0,this.name="",this.global=!1,this.parents=!1,this.isNode=!0,this._beforeNodes=null,this._cacheKey=null,this._uuid=null,this._cacheKeyVersion=0,this.id=hO++,this.stackTrace=null,r.captureStackTrace===!0&&(this.stackTrace=new is)}set needsUpdate(e){e===!0&&this.version++}get uuid(){return this._uuid===null&&(this._uuid=Lo.generateUUID()),this._uuid}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this),this}onFrameUpdate(e){return this.onUpdate(e,Me.FRAME)}onRenderUpdate(e){return this.onUpdate(e,Me.RENDER)}onObjectUpdate(e){return this.onUpdate(e,Me.OBJECT)}onReference(e){return this.updateReference=e.bind(this),this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(let{childNode:e}of this._getChildren())yield e}dispose(){this.dispatchEvent({type:"dispose"})}traverse(e){e(this);for(let t of this.getChildren())t.traverse(e)}_getChildren(e=new Set){let t=[];e.add(this);for(let s of Object.getOwnPropertyNames(this)){let n=this[s];if(!(s.startsWith("_")===!0||e.has(n))){if(Array.isArray(n)===!0)for(let a=0;a<n.length;a++){let i=n[a];i&&i.isNode===!0&&t.push({property:s,index:a,childNode:i})}else if(n&&n.isNode===!0)t.push({property:s,childNode:n});else if(n&&Object.getPrototypeOf(n)===Object.prototype)for(let a in n){if(a.startsWith("_")===!0)continue;let i=n[a];i&&i.isNode===!0&&t.push({property:s,index:a,childNode:i})}}}return t}getCacheKey(e=!1,t=null){if(e=e||this.version!==this._cacheKeyVersion,e===!0||this._cacheKey===null){t===null&&(t=new Set);let s=[];for(let{property:n,childNode:a}of this._getChildren(t))s.push(fc(n.slice(0,-4)),a.getCacheKey(e,t));this._cacheKey=wd($d(s),this.customCacheKey()),this._cacheKeyVersion=this.version}return this._cacheKey}customCacheKey(){return this.id}getScope(){return this}getHash(){return String(this.id)}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(e){let t=this.getNodeType(e);return e.getElementType(t)}getMemberType(){return"void"}getNodeType(e,t=null){let s=e.getDataFromNode(this),n;return t!==null?(s.typeFromOutput=s.typeFromOutput||{},n=s.typeFromOutput[t],n===void 0&&(n=this.generateNodeType(e,t),s.typeFromOutput[t]=n)):(n=s.type,n===void 0&&(n=this.generateNodeType(e),s.type=n)),n}generateNodeType(e,t=null){let s=e.getNodeProperties(this);return s.outputNode?s.outputNode.getNodeType(e,t):this.nodeType}getShared(e){let t=this.getHash(e),s=e.getNodeFromHash(t),n=null;if(s&&s!==this)n=s;else if(e.context.overrideNodes){let a=e.context.overrideNodes.get(this);if(a){let i=e.getDataFromNode(this);i.isOverwritten!==!0?(i.isOverwritten=!0,n=a(e).overrideNode(this,null),i.sharedNode=n):n=i.sharedNode}}return n||this}getArrayCount(){return null}setup(e){let t=e.getNodeProperties(this),s=0;for(let n of this.getChildren())t["node"+s++]=n;return t.outputNode||null}analyze(e,t=null){let s=e.increaseUsage(this);if(this.parents===!0){let n=e.getDataFromNode(this,"any");n.stages=n.stages||{},n.stages[e.shaderStage]=n.stages[e.shaderStage]||[],n.stages[e.shaderStage].push(t)}if(s===1){let n=e.getNodeProperties(this);for(let a of Object.values(n))a&&a.isNode===!0&&a.build(e,this)}}generate(e,t){let{outputNode:s}=e.getNodeProperties(this);if(s&&s.isNode===!0)return s.build(e,t)}updateBefore(){K("Abstract function.")}updateAfter(){K("Abstract function.")}update(){K("Abstract function.")}before(e){return this._beforeNodes===null&&(this._beforeNodes=[]),this._beforeNodes.push(e),this}build(e,t=null){let s=this.getShared(e);if(this!==s)return s.build(e,t);if(this._beforeNodes!==null){let c=this._beforeNodes;this._beforeNodes=null;for(let l of c)l.build(e,t);this._beforeNodes=c}let n=e.getDataFromNode(this);n.buildStages=n.buildStages||{},n.buildStages[e.buildStage]=!0;let a=lO[e.buildStage];if(a&&n.buildStages[a]!==!0){let c=e.getBuildStage();e.setBuildStage(a),this.build(e),e.setBuildStage(c)}e.addChain(this);let i=null,o=e.getBuildStage();if(o==="setup"){e.addNode(this),this.updateReference(e);let c=e.getNodeProperties(this);if(c.initialized!==!0){c.initialized=!0,c.outputNode=this.setup(e)||c.outputNode||null;for(let l of Object.values(c))if(l&&l.isNode===!0){if(l.parents===!0){let h=e.getNodeProperties(l);h.parents=h.parents||[],h.parents.push(this)}l.build(e)}e.addSequentialNode(this)}i=c.outputNode}else if(o==="analyze")this.analyze(e,t);else if(o==="generate"){if(this.generate.length<2){let l=this.getNodeType(e),h=e.getDataFromNode(this);i=h.snippet,i===void 0?h.generated===void 0?(h.generated=!0,i=this.generate(e)||"",h.snippet=i):(K("Node: Recursion detected.",this),i="/* Recursion detected. */"):h.flowCodes!==void 0&&e.context.nodeBlock!==void 0&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),i=e.format(i,l,t)}else i=this.generate(e,t)||"";i===""&&t!==null&&t!=="void"&&t!=="OutputType"&&(W(`TSL: Invalid generated code, expected a "${t}".`),i=e.generateConst(t))}return e.removeChain(this),i}getSerializeChildren(){return this._getChildren()}serialize(e){let t=this.getSerializeChildren(),s={};for(let{property:n,index:a,childNode:i}of t)a!==void 0?(s[n]===void 0&&(s[n]=Number.isInteger(a)?[]:{}),s[n][a]=i.toJSON(e.meta).uuid):s[n]=i.toJSON(e.meta).uuid;Object.keys(s).length>0&&(e.inputNodes=s)}deserialize(e){if(e.inputNodes!==void 0){let t=e.meta.nodes;for(let s in e.inputNodes)if(Array.isArray(e.inputNodes[s])){let n=[];for(let a of e.inputNodes[s])n.push(t[a]);this[s]=n}else if(typeof e.inputNodes[s]=="object"){let n={};for(let a in e.inputNodes[s]){let i=e.inputNodes[s][a];n[a]=t[i]}this[s]=n}else{let n=e.inputNodes[s];this[s]=t[n]}}}toJSON(e){let{uuid:t,type:s}=this,n=e===void 0||typeof e=="string";n&&(e={textures:{},images:{},nodes:{}});let a=e.nodes[t];a===void 0&&(a={uuid:t,type:s,meta:e,metadata:{version:4.7,type:"Node",generator:"Node.toJSON"}},n!==!0&&(e.nodes[a.uuid]=a),this.serialize(a),delete a.meta);function i(o){let c=[];for(let l in o){let h=o[l];delete h.metadata,c.push(h)}return c}if(n){let o=i(e.textures),c=i(e.images),l=i(e.nodes);o.length>0&&(a.textures=o),c.length>0&&(a.images=c),l.length>0&&(a.nodes=l)}return a}};we.captureStackTrace=!1;var no=class extends we{static get type(){return"ArrayElementNode"}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}generateNodeType(e){return this.node.getElementType(e)}getMemberType(e,t){return this.node.getMemberType(e,t)}generate(e){let t=this.indexNode.getNodeType(e),s=this.node.build(e),n=this.indexNode.build(e,!e.isVector(t)&&e.isInteger(t)?t:"uint");return`${s}[ ${n} ]`}},Em=class extends we{static get type(){return"ConvertNode"}constructor(e,t){super(),this.node=e,this.convertTo=t}generateNodeType(e){let t=this.node.getNodeType(e),s=null;for(let n of this.convertTo.split("|"))(s===null||e.getTypeLength(t)===e.getTypeLength(n))&&(s=n);return s}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){let s=this.node,n=this.getNodeType(e),a=s.build(e,n);return e.format(a,n,t)}},xt=class extends we{static get type(){return"TempNode"}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){if(e.getBuildStage()==="generate"){let n=e.getVectorType(this.getNodeType(e,t)),a=e.getDataFromNode(this);if(a.propertyName!==void 0)return e.format(a.propertyName,n,t);if(n!=="void"&&t!=="void"&&this.hasDependencies(e)){let i=super.build(e,n),o=e.getVarFromNode(this,null,n),c=e.getPropertyName(o);return e.addLineFlowCode(`${c} = ${i}`,this),a.snippet=i,a.propertyName=c,e.format(a.propertyName,n,t)}}return super.build(e,t)}},g0=class extends xt{static get type(){return"JoinNode"}constructor(e=[],t=null){super(t),this.nodes=e}generateNodeType(e){return this.nodeType!==null?e.getVectorType(this.nodeType):e.getTypeFromLength(this.nodes.reduce((t,s)=>t+e.getTypeLength(s.getNodeType(e)),0))}generate(e,t){let s=this.getNodeType(e),n=e.getTypeLength(s),a=this.nodes,i=e.getComponentType(s),o=[],c=0;for(let h of a){if(c>=n){W(`TSL: Length of parameters exceeds maximum length of function '${s}()' type.`,this.stackTrace);break}let u=h.getNodeType(e),d=e.getTypeLength(u),f;if(c+d>n&&(W(`TSL: Length of '${s}()' data exceeds maximum length of output type.`,this.stackTrace),d=n-c,u=e.getTypeFromLength(d)),c+=d,f=h.build(e,u),e.getComponentType(u)!==i){let m=e.getTypeFromLength(d,i);f=e.format(f,u,m)}o.push(f)}let l=`${e.getType(s)}( ${o.join(", ")} )`;return e.format(l,s,t)}},uO=pc.join(""),Cm=class extends we{static get type(){return"SplitNode"}constructor(e,t="x"){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(let t of this.components)e=Math.max(pc.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}generateNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}getScope(){return this.node.getScope()}generate(e,t){let s=this.node,n=e.getTypeLength(s.getNodeType(e)),a=null;if(n>1){let i=null;this.getVectorLength()>=n&&(i=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));let c=s.build(e,i);this.components.length===n&&this.components===uO.slice(0,this.components.length)?a=e.format(c,i,t):a=e.format(`${c}.${this.components}`,this.getNodeType(e),t)}else a=s.build(e,t);return a}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}},y0=class extends xt{static get type(){return"SetNode"}constructor(e,t,s){super(),this.sourceNode=e,this.components=t,this.targetNode=s}generateNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){let{sourceNode:t,components:s,targetNode:n}=this,a=this.getNodeType(e),i=e.getComponentType(n.getNodeType(e)),o=e.getTypeFromLength(s.length,i),c=n.build(e,o),l=t.build(e,a),h=e.getTypeLength(a),u=[];for(let d=0;d<h;d++){let f=pc[d];f===s[0]?(u.push(c),d+=s.length-1):u.push(l+"."+f)}return`${e.getType(a)}( ${u.join(", ")} )`}},x0=class extends xt{static get type(){return"FlipNode"}constructor(e,t){super(),this.sourceNode=e,this.components=t}generateNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){let{components:t,sourceNode:s}=this,n=this.getNodeType(e),a=s.build(e),i=e.getVarFromNode(this),o=e.getPropertyName(i);e.addLineFlowCode(o+" = "+a,this);let c=e.getTypeLength(n),l=[],h=0;for(let u=0;u<c;u++){let d=pc[u];d===t[h]?(l.push("1.0 - "+(o+"."+d)),h++):l.push(o+"."+d)}return`${e.getType(n)}( ${l.join(", ")} )`}},Md=class extends we{static get type(){return"InputNode"}constructor(e,t=null){super(t),this.isInputNode=!0,this.value=e,this.precision=null}generateNodeType(){return this.nodeType===null?to(this.value):this.nodeType}getInputType(e){return this.getNodeType(e)}setPrecision(e){return this.precision=e,this}serialize(e){super.serialize(e),e.value=this.value,this.value&&this.value.toArray&&(e.value=this.value.toArray()),e.valueType=to(this.value),e.nodeType=this.nodeType,e.valueType==="ArrayBuffer"&&(e.value=pI(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?kT(e.valueType,...e.value):e.value,this.precision=e.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(e.value))}generate(){K("Abstract function.")}},qC=/float|u?int/,fa=class extends Md{static get type(){return"ConstNode"}constructor(e,t=null){super(e,t),this.isConstNode=!0}generateConst(e){return e.generateConst(this.getNodeType(e),this.value)}generate(e,t){let s=this.getNodeType(e);return qC.test(s)&&qC.test(t)?e.generateConst(t,this.value):e.format(this.generateConst(e),s,t)}},w0=class extends we{static get type(){return"MemberNode"}constructor(e,t){super(),this.structNode=e,this.property=t,this.isMemberNode=!0}hasMember(e){return this.structNode.isMemberNode&&this.structNode.hasMember(e)===!1?!1:this.structNode.getMemberType(e,this.property)!=="void"}generateNodeType(e){return this.hasMember(e)===!1?"float":this.structNode.getMemberType(e,this.property)}getMemberType(e,t){if(this.hasMember(e)===!1)return"float";let s=this.getNodeType(e);return e.getStructTypeNode(s).getMemberType(e,t)}generate(e){if(this.hasMember(e)===!1){K(`TSL: Member "${this.property}" does not exist in struct.`,this.stackTrace);let s=this.getNodeType(e);return e.generateConst(s)}return this.structNode.build(e)+"."+this.property}},nc=null,JA=new Map;function G(r,e){if(JA.has(r)){K(`TSL: Redefinition of method chaining '${r}'.`);return}if(typeof e!="function")throw new Error(`THREE.TSL: Node element ${r} is not a function`);JA.set(r,e),r!=="assign"&&(we.prototype[r]=function(...t){return this.isStackNode?this.addToStack(e(...t)):e(this,...t)},we.prototype[r+"Assign"]=function(...t){return this.isStackNode?this.assign(t[0],e(...t)):this.assign(e(this,...t))})}var dO=r=>r.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),XC=r=>dO(r).split("").sort().join("");we.prototype.assign=function(...r){if(this.isStackNode!==!0)return nc!==null?nc.assign(this,...r):W("TSL: No stack defined for assign operation. Make sure the assign is inside a Fn().",new is),this;{let e=JA.get("assign");return this.addToStack(e(...r))}};we.prototype.toVarIntent=function(){return this};we.prototype.get=function(r){return new w0(this,r)};var Tm={};function Mx(r,e,t){Tm[r]=Tm[e]=Tm[t]={get(){this._cache=this._cache||{};let i=this._cache[r];return i===void 0&&(i=new Cm(this,r),this._cache[r]=i),i},set(i){this[r].assign(pe(i))}};let s=r.toUpperCase(),n=e.toUpperCase(),a=t.toUpperCase();we.prototype["set"+s]=we.prototype["set"+n]=we.prototype["set"+a]=function(i){let o=XC(r);return new y0(this,o,pe(i))},we.prototype["flip"+s]=we.prototype["flip"+n]=we.prototype["flip"+a]=function(){let i=XC(r);return new x0(this,i)}}var Xi=["x","y","z","w"],Ki=["r","g","b","a"],Ji=["s","t","p","q"];for(let r=0;r<4;r++){let e=Xi[r],t=Ki[r],s=Ji[r];Mx(e,t,s);for(let n=0;n<4;n++){e=Xi[r]+Xi[n],t=Ki[r]+Ki[n],s=Ji[r]+Ji[n],Mx(e,t,s);for(let a=0;a<4;a++){e=Xi[r]+Xi[n]+Xi[a],t=Ki[r]+Ki[n]+Ki[a],s=Ji[r]+Ji[n]+Ji[a],Mx(e,t,s);for(let i=0;i<4;i++)e=Xi[r]+Xi[n]+Xi[a]+Xi[i],t=Ki[r]+Ki[n]+Ki[a]+Ki[i],s=Ji[r]+Ji[n]+Ji[a]+Ji[i],Mx(e,t,s)}}}for(let r=0;r<32;r++)Tm[r]={get(){this._cache=this._cache||{};let e=this._cache[r];return e===void 0&&(e=new no(this,new fa(r,"uint")),this._cache[r]=e),e},set(e){this[r].assign(pe(e))}};Object.defineProperties(we.prototype,Tm);var fO=function(r,e=null){let t=to(r);return t==="node"?r:e===null&&(t==="float"||t==="boolean")||t&&t!=="shader"&&t!=="string"?pe(ZA(r,e)):t==="shader"?r.isFn?r:F(r):r},pO=function(r,e=null){for(let t in r)r[t]=pe(r[t],e);return r},mO=function(r,e=null){let t=r.length;for(let s=0;s<t;s++)r[s]=pe(r[s],e);return r},gI=function(r,e=null,t=null,s=null){function n(h){return s!==null?(h=pe(Object.assign(h,s)),s.intent===!0&&(h=h.toVarIntent())):h=pe(h),h}let a,i=e,o,c;function l(h){let u;return i?u=/[a-z]/i.test(i)?i+"()":i:u=r.type,o!==void 0&&h.length<o?(W(`TSL: "${u}" parameter length is less than minimum required.`,new is),h.concat(new Array(o-h.length).fill(0))):c!==void 0&&h.length>c?(W(`TSL: "${u}" parameter length exceeds limit.`,new is),h.slice(0,c)):h}return e===null?a=(...h)=>n(new r(...kl(l(h)))):t!==null?(t=pe(t),a=(...h)=>n(new r(e,...kl(l(h)),t))):a=(...h)=>n(new r(e,...kl(l(h)))),a.setParameterLength=(...h)=>(h.length===1?o=c=h[0]:h.length===2&&([o,c]=h),a),a.setName=h=>(i=h,a),a},bO=function(r,...e){return new r(...kl(e))},$A=class extends we{constructor(e,t){super(),this.shaderNode=e,this.rawInputs=t,this.isShaderCallNodeInternal=!0}generateNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}getElementType(e){return this.getOutputNode(e).getElementType(e)}getMemberType(e,t){return this.getOutputNode(e).getMemberType(e,t)}call(e){let{shaderNode:t,rawInputs:s}=this,n=e.getNodeProperties(t),a=e.getClosestSubBuild(t.subBuilds)||"",i=a||"default";if(n[i])return n[i];let o=e.subBuildFn,c=e.fnCall;e.subBuildFn=a,e.fnCall=this;let l=null;if(t.layout){if(s){let d=t.layout.inputs;if(IT(s)){let f=s;for(let p=0;p<d.length;p++){let m=f[p];m&&m.isNode&&m.build(e)}}else{let f=s[0];for(let p of d){let m=f[p.name];m&&m.isNode&&m.build(e)}}}let h=e.buildFunctionNode(t);e.addInclude(h);let u=s?gO(s):null;l=h.call(u)}else{let h=new Proxy(e,{get:(m,b,g)=>{let x;return Symbol.iterator===b?x=function*(){yield void 0}:x=Reflect.get(m,b,g),x}}),u=s?yO(s):null,d=Array.isArray(s)?s.length>0:s!==null,f=t.jsFunc,p=d||f.length>1?f(u,h):f(h);l=pe(p)}return e.subBuildFn=o,e.fnCall=c,t.once&&(n[i]=l),l}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}getOutputNode(e){let t=e.getNodeProperties(this),s=e.getSubBuildOutput(this);return t[s]=t[s]||this.setupOutput(e),t[s].subBuild=e.getClosestSubBuild(this),t[s]}build(e,t=null){let s=null,n=e.getBuildStage(),a=e.getNodeProperties(this),i=e.getSubBuildOutput(this),o=this.getOutputNode(e),c=e.fnCall;if(e.fnCall=this,n==="setup"){let l=e.getSubBuildProperty("initialized",this);if(a[l]!==!0&&(a[l]=!0,a[i]=this.getOutputNode(e),a[i].build(e),this.shaderNode.subBuilds))for(let h of e.chaining){let u=e.getDataFromNode(h,"any");u.subBuilds=u.subBuilds||new Set;for(let d of this.shaderNode.subBuilds)u.subBuilds.add(d)}s=a[i]}else n==="analyze"?o.build(e,t):n==="generate"&&(s=o.build(e,t)||"");return e.fnCall=c,s}};function gO(r){let e;return PT(r),IT(r)?e=[...r]:e=r[0],e}function yO(r){let e=0;return PT(r),new Proxy(r,{get:(t,s,n)=>{let a;if(s==="length")return a=r.length,a;if(Symbol.iterator===s)a=function*(){for(let i of r)yield pe(i)};else{if(r.length>0)if(Object.getPrototypeOf(r[0])===Object.prototype){let i=r[0];i[s]===void 0?a=i[e++]:a=Reflect.get(i,s,n)}else r[0]instanceof we&&(r[s]===void 0?a=r[e++]:a=Reflect.get(r,s,n));else a=Reflect.get(t,s,n);a=pe(a)}return a}})}var YA=class extends we{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1}setLayout(e){return this.layout=e,this}getLayout(){return this.layout}call(e=null){return new $A(this,e)}setup(){return this.call()}},xO=[!1,!0],wO=[0,1,2,3],TO=[-1,-2],yI=[.5,1.5,1/3,1e-6,1e6,Math.PI,Math.PI*2,1/Math.PI,2/Math.PI,1/(Math.PI*2),Math.PI/2],p1=new Map;for(let r of xO)p1.set(r,new fa(r));var m1=new Map;for(let r of wO)m1.set(r,new fa(r,"uint"));var b1=new Map([...m1].map(r=>new fa(r.value,"int")));for(let r of TO)b1.set(r,new fa(r,"int"));var BT=new Map([...b1].map(r=>new fa(r.value)));for(let r of yI)BT.set(r,new fa(r));for(let r of yI)BT.set(-r,new fa(-r));var FT={bool:p1,uint:m1,ints:b1,float:BT},KC=new Map([...p1,...BT]),ZA=(r,e)=>KC.has(r)?KC.get(r):r.isNode===!0?r:new fa(r,e),fs=function(r,e=null){return(...t)=>{for(let n of t)if(n===void 0)return W(`TSL: Invalid parameter for the type "${r}".`,new is),new fa(0,r);if((t.length===0||!["bool","float","int","uint"].includes(r)&&t.every(n=>{let a=typeof n;return a!=="object"&&a!=="function"}))&&(t=[kT(r,...t)]),t.length===1&&e!==null&&e.has(t[0]))return bm(e.get(t[0]));if(t.length===1){let n=ZA(t[0],r);return n.nodeType===r?bm(n):bm(new Em(n,r))}let s=t.map(n=>ZA(n));return bm(new g0(s,r))}};function Cl(r){return r&&r.isNode&&r.traverse(e=>{e.isConstNode&&(r=e.value)}),!!r}var xI=r=>r!=null?r.nodeType||r.convertTo||(typeof r=="string"?r:null):null;function gd(r,e){return new YA(r,e)}var pe=(r,e=null)=>fO(r,e),bm=(r,e=null)=>pe(r,e).toVarIntent(),PT=(r,e=null)=>new pO(r,e),kl=(r,e=null)=>new mO(r,e),He=(r,e=null,t=null,s=null)=>new gI(r,e,t,s),ie=(r,...e)=>new bO(r,...e),X=(r,e=null,t=null,s={})=>new gI(r,e,t,{...s,intent:!0}),g1=(r,e)=>new Proxy(r,{get(t,s,n){return Reflect.get(e,s,n)},set(t,s,n){return Reflect.set(e,s,n)}}),vO=0,QA=class extends we{constructor(e,t=null){super();let s=null;t!==null&&(typeof t=="object"?s=t.return:(typeof t=="string"?s=t:W("TSL: Invalid layout type.",new is),t=null)),this.shaderNode=new gd(e,s),t!==null&&this.setLayout(t),this.isFn=!0}setLayout(e){let t=this.shaderNode.nodeType;if(typeof e.inputs!="object"){let s={name:"fn"+vO++,type:t,inputs:[]};for(let n in e)n!=="return"&&s.inputs.push({name:n,type:e[n]});e=s}return this.shaderNode.setLayout(e),this}generateNodeType(e){return this.shaderNode.getNodeType(e)||"float"}call(...e){let t=this.shaderNode.call(e);return this.shaderNode.nodeType==="void"&&t.toStack(),t.toVarIntent()}once(e=null){return this.shaderNode.once=!0,this.shaderNode.subBuilds=e,this}generate(e){let t=this.getNodeType(e);return W('TSL: "Fn()" was declared but not invoked. Try calling it like "Fn()( ...params )".',this.stackTrace),e.generateConst(t)}};function F(r,e=null){let t=new QA(r,e);return new Proxy(()=>{},{apply(s,n,a){return t.call(...a)},get(s,n,a){return Reflect.get(t,n,a)},set(s,n,a,i){return Reflect.set(t,n,a,i)}})}var km=r=>{nc=r},y1=()=>nc,fe=(...r)=>nc.If(...r),_O=(...r)=>nc.Switch(...r);function wI(r){return nc&&nc.addToStack(r),r}G("toStack",wI);var TI=new fs("color"),S=new fs("float",FT.float),k=new fs("int",FT.ints),V=new fs("uint",FT.uint),Va=new fs("bool",FT.bool),Z=new fs("vec2"),Dt=new fs("ivec2"),x1=new fs("uvec2"),vI=new fs("bvec2"),C=new fs("vec3"),w1=new fs("ivec3"),ya=new fs("uvec3"),T1=new fs("bvec3"),ce=new fs("vec4"),Sd=new fs("ivec4"),Vl=new fs("uvec4"),_I=new fs("bvec4"),DT=new fs("mat2"),Ms=new fs("mat3"),so=new fs("mat4");G("toColor",TI);G("toFloat",S);G("toInt",k);G("toUint",V);G("toBool",Va);G("toVec2",Z);G("toIVec2",Dt);G("toUVec2",x1);G("toBVec2",vI);G("toVec3",C);G("toIVec3",w1);G("toUVec3",ya);G("toBVec3",T1);G("toVec4",ce);G("toIVec4",Sd);G("toUVec4",Vl);G("toBVec4",_I);G("toMat2",DT);G("toMat3",Ms);G("toMat4",so);var AI=He(no).setParameterLength(2),MI=(r,e)=>new Em(pe(r),e),AO=(r,e)=>new Cm(pe(r),e);G("element",AI);G("convert",MI);var st=class extends we{static get type(){return"PropertyNode"}constructor(e,t=null,s=!1,n=null){super(e),this.name=t,this.varying=s,this.placeholderNode=pe(n),this.isPropertyNode=!0,this.global=!0}getNodeType(e){let t=super.getNodeType(e);return t==="output"?e.getOutputType():t}customCacheKey(){return fc(this.type+":"+(this.name||"")+":"+(this.varying?"1":"0"))}getHash(e){return this.name||super.getHash(e)}generate(e){let t;if(this.varying===!0)t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0;else if(t=e.getVarFromNode(this,this.name),this.placeholderNode!==null&&e.hasWriteUsage(this)===!1){let s=this.placeholderNode.build(e,this.getNodeType(e));e.addLineFlowCode(`${e.getPropertyName(t)} = ${s}`,this)}return e.getPropertyName(t)}},za=(r,e,t=null)=>new st(r,e,!1,t),mc=(r,e,t=null)=>new st(r,e,!0,t),rt=ie(st,"vec4","DiffuseColor"),Sl=ie(st,"vec3","DiffuseContribution"),eM=ie(st,"vec3","EmissiveColor"),Oa=ie(st,"float","Roughness"),Qo=ie(st,"float","Metalness"),T0=ie(st,"float","Clearcoat"),Td=ie(st,"float","ClearcoatRoughness"),Un=ie(st,"vec3","Sheen"),Jo=ie(st,"float","SheenRoughness"),OT=ie(st,"float","Iridescence"),v0=ie(st,"float","IridescenceIOR"),_0=ie(st,"float","IridescenceThickness"),A0=ie(st,"float","AlphaT"),Ko=ie(st,"float","Anisotropy"),vm=ie(st,"vec3","AnisotropyT"),Il=ie(st,"vec3","AnisotropyB"),wi=ie(st,"color","SpecularColor"),Jr=ie(st,"color","SpecularColorBlended"),tr=ie(st,"float","SpecularF90"),M0=ie(st,"float","Shininess"),ec=ie(st,"output","Output"),Bl=ie(st,"float","dashSize"),Im=ie(st,"float","gapSize"),MO=ie(st,"float","pointWidth"),_m=ie(st,"float","IOR"),S0=ie(st,"float","Transmission"),v1=ie(st,"float","Thickness"),_1=ie(st,"float","AttenuationDistance"),A1=ie(st,"color","AttenuationColor"),M1=ie(st,"float","Dispersion"),Bm=ie(st,"float","Retroreflectivity"),tM=ie(st,"float","AmbientOcclusion",!1,1),Fm=class extends we{static get type(){return"UniformGroupNode"}constructor(e,t=!1,s=1,n=null){super("string"),this.name=e,this.shared=t,this.order=s,this.updateType=n,this.isUniformGroup=!0}update(){this.needsUpdate=!0}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}},SI=(r,e=1,t=null)=>new Fm(r,!1,e,t),UT=(r,e=0,t=null)=>new Fm(r,!0,e,t),SO=UT("frame",0,Me.FRAME),ye=UT("render",0,Me.RENDER),NI=SI("object",1,Me.OBJECT),ac=class extends Md{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=NI}setName(e){return this.name=e,this}label(e){return K('TSL: "label()" has been deprecated. Use "setName()" instead.',new is),this.setName(e)}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}getSharedNode(e){let t=this.getUniformHash(e),s=e.getNodeFromHash(t);return s===void 0&&(e.setHashNode(this,t),s=this),s}onUpdate(e,t){return e=e.bind(this),super.onUpdate(s=>{let n=e(s,this);n!==void 0&&(this.value=n)},t)}getInputType(e){let t=super.getInputType(e);return t==="bool"&&(t="uint"),t}generate(e,t){let s=this.getNodeType(e),n=this.getSharedNode(e),a=n.getInputType(e),i=e.getUniformFromNode(n,a,e.shaderStage,this.name||e.context.nodeName),o=e.getPropertyName(i);e.context.nodeName!==void 0&&delete e.context.nodeName;let c=o;if(s==="bool"){let l=e.getDataFromNode(this),h=l.propertyName;if(h===void 0){let u=e.getVarFromNode(this,null,"bool");h=e.getPropertyName(u),l.propertyName=h,c=e.format(o,a,s),e.addLineFlowCode(`${h} = ${c}`,this)}c=h}return e.format(c,s,t)}},xe=(r,e)=>{let t=xI(e||r);if(t===r&&(r=kT(t)),r&&r.isNode===!0){let s=r.value;r.traverse(n=>{n.isConstNode===!0&&(s=n.value)}),r=s}return new ac(r,t)},Pm=class extends xt{static get type(){return"ArrayNode"}constructor(e,t,s=null){super(e),this.count=t,this.values=s,this.isArrayNode=!0}getArrayCount(){return this.count}generateNodeType(e){return this.nodeType===null?this.values[0].getNodeType(e):this.nodeType}getElementType(e){return this.getNodeType(e)}getMemberType(e,t){return this.nodeType===null?this.values[0].getMemberType(e,t):super.getMemberType(e,t)}generate(e){let t=this.getNodeType(e);return e.generateArray(t,this.count,this.values)}},N0=(...r)=>{let e;if(r.length===1){let t=r[0].map(s=>pe(s));e=new Pm(null,t.length,t)}else{let t=r[0],s=r[1];e=new Pm(t,s)}return e};G("toArray",(r,e)=>N0(Array(e).fill(r)));var R0=class extends xt{static get type(){return"AssignNode"}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}generateNodeType(e,t){return t!=="void"?this.targetNode.getNodeType(e):"void"}needsSplitAssign(e){let{targetNode:t}=this;if(e.isAvailable("swizzleAssign")===!1&&t.isSplitNode&&t.components.length>1){let s=e.getTypeLength(t.node.getNodeType(e));return pc.join("").slice(0,s)!==t.components}return!1}setup(e){let{targetNode:t,sourceNode:s}=this,n=t.getScope(),a=e.getDataFromNode(n);a.assign=!0;let i=e.getNodeProperties(this);i.sourceNode=s,i.targetNode=t.context({assign:!0})}generate(e,t){let{targetNode:s,sourceNode:n}=e.getNodeProperties(this),a=this.needsSplitAssign(e),i=s.build(e),o=s.getNodeType(e),c=n.build(e,o),l=n.getNodeType(e),h=e.getDataFromNode(this),u;if(h.initialized===!0)t!=="void"&&(u=i);else if(a){let d=e.getVarFromNode(this,null,o),f=e.getPropertyName(d);e.addLineFlowCode(`${f} = ${c}`,this);let p=s.node,b=p.node.context({assign:!0}).build(e);for(let g=0;g<p.components.length;g++){let x=p.components[g];e.addLineFlowCode(`${b}.${x} = ${f}[ ${g} ]`,this)}t!=="void"&&(u=i)}else u=`${i} = ${c}`,(t==="void"||l==="void")&&(e.addLineFlowCode(u,this),t!=="void"&&(u=i));return h.initialized=!0,e.format(u,o,t)}},RI=He(R0).setParameterLength(2);G("assign",RI);var E0=class extends xt{static get type(){return"FunctionCallNode"}constructor(e=null,t={}){super(),this.functionNode=e,this.parameters=t}setParameters(e){return this.parameters=e,this}getParameters(){return this.parameters}generateNodeType(e){return this.functionNode.getNodeType(e)}getMemberType(e,t){return this.functionNode.getMemberType(e,t)}generate(e){let t=[],s=this.functionNode,n=s.getInputs(e),a=this.parameters,i=(c,l)=>{let h=l.type,u=h==="pointer",d;return u?d="&"+c.build(e):d=c.build(e,h),d};if(Array.isArray(a)){if(a.length>n.length)W("TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'."),a.length=n.length;else if(a.length<n.length)for(W("TSL: The number of provided parameters is less than the expected number of inputs in 'Fn()'.");a.length<n.length;)a.push(S(0));for(let c=0;c<a.length;c++)t.push(i(a[c],n[c]))}else for(let c of n){let l=a[c.name];l!==void 0?t.push(i(l,c)):(W(`TSL: Input '${c.name}' not found in 'Fn()'.`),t.push(i(S(0),c)))}return`${s.build(e,"property")}( ${t.join(", ")} )`}},EI=(r,...e)=>(e=e.length>1||e[0]&&e[0].isNode===!0?kl(e):PT(e[0]),new E0(pe(r),e));G("call",EI);var NO={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"},Ut=class r extends xt{static get type(){return"OperatorNode"}constructor(e,t,s,...n){if(super(),n.length>0){let a=new r(e,t,s);for(let i=0;i<n.length-1;i++)a=new r(e,a,n[i]);t=a,s=n[n.length-1]}this.op=e,this.aNode=t,this.bNode=s,this.isOperatorNode=!0}getOperatorMethod(e,t){return e.getMethod(NO[this.op],t)}generateNodeType(e,t=null){let s=this.op,n=this.aNode,a=this.bNode,i=n.getNodeType(e),o=a?a.getNodeType(e):null;if(i==="void"||o==="void")return t||"void";if(s==="%")return i;if(s==="~"||s==="&"||s==="|"||s==="^"||s===">>"||s==="<<")return e.getIntegerType(i);if(s==="&&"||s==="||"||s==="^^")return"bool";if(s==="!"){let c=e.getTypeLength(i);return c>1?`bvec${c}`:"bool"}else if(s==="=="||s==="!="||s==="<"||s===">"||s==="<="||s===">="){let c=Math.max(e.getTypeLength(i),e.getTypeLength(o));return c>1?`bvec${c}`:"bool"}else{if(e.isMatrix(i)){if(o==="float")return i;if(e.isVector(o))return e.getVectorFromMatrix(i);if(e.isMatrix(o))return i}else if(e.isMatrix(o)){if(i==="float")return o;if(e.isVector(i))return e.getVectorFromMatrix(o)}return e.getTypeLength(o)>e.getTypeLength(i)?o:i}}generate(e,t){let s=this.op,{aNode:n,bNode:a}=this,i=this.getNodeType(e,t),o=null,c=null;i!=="void"?(o=n.getNodeType(e),c=a?a.getNodeType(e):null,s==="<"||s===">"||s==="<="||s===">="||s==="=="||s==="!="?e.isVector(o)?c=o:e.isVector(c)?o=c:o!==c&&(o=c="float"):s===">>"||s==="<<"?(o=i,c=e.changeComponentType(c,"uint")):s==="%"?(o=i,c=e.isInteger(o)&&e.isInteger(c)?c:o):e.isMatrix(o)?c==="float"?c="float":e.isVector(c)?c=e.getVectorFromMatrix(o):e.isMatrix(c)||(o=c=i):e.isMatrix(c)?o==="float"?o="float":e.isVector(o)?o=e.getVectorFromMatrix(c):o=c=i:o=c=i):o=c=i;let l=n.build(e,o),h=a?a.build(e,c):null,u=e.getFunctionOperator(s);if(t!=="void"){let d=e.renderer.coordinateSystem===sn;if(s==="=="||s==="!="||s==="<"||s===">"||s==="<="||s===">=")return d?e.isVector(o)?e.format(`${this.getOperatorMethod(e,t)}( ${l}, ${h} )`,i,t):e.format(`( ${l} ${s} ${h} )`,i,t):e.format(`( ${l} ${s} ${h} )`,i,t);if(s==="%")return e.isInteger(c)?e.format(`( ${l} % ${h} )`,i,t):e.format(`${this.getOperatorMethod(e,i)}( ${l}, ${h} )`,i,t);if(s==="!")return d&&e.isVector(o)?e.format(`not( ${l} )`,t):e.format(`( ${s} ${l} )`,o,t);if(s==="~")return e.format(`( ${s} ${l} )`,o,t);if(u)return e.format(`${u}( ${l}, ${h} )`,i,t);if(e.isMatrix(o)&&c==="float")return e.format(`( ${h} ${s} ${l} )`,i,t);if(o==="float"&&e.isMatrix(c))return e.format(`${l} ${s} ${h}`,i,t);{let f=`( ${l} ${s} ${h} )`;return!d&&i==="bool"&&e.isVector(o)&&e.isVector(c)&&(f=`all${f}`),e.format(f,i,t)}}else if(o!=="void")return u?e.format(`${u}( ${l}, ${h} )`,i,t):e.isMatrix(o)&&c==="float"?e.format(`${h} ${s} ${l}`,i,t):e.format(`${l} ${s} ${h}`,i,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}},lt=X(Ut,"+").setParameterLength(2,1/0).setName("add"),ze=X(Ut,"-").setParameterLength(2,1/0).setName("sub"),Te=X(Ut,"*").setParameterLength(2,1/0).setName("mul"),js=X(Ut,"/").setParameterLength(2,1/0).setName("div"),S1=X(Ut,"%").setParameterLength(2).setName("mod"),CI=X(Ut,"==").setParameterLength(2).setName("equal"),kI=X(Ut,"!=").setParameterLength(2).setName("notEqual"),II=X(Ut,"<").setParameterLength(2).setName("lessThan"),N1=X(Ut,">").setParameterLength(2).setName("greaterThan"),BI=X(Ut,"<=").setParameterLength(2).setName("lessThanEqual"),FI=X(Ut,">=").setParameterLength(2).setName("greaterThanEqual"),PI=X(Ut,"&&").setParameterLength(2,1/0).setName("and"),DI=X(Ut,"||").setParameterLength(2,1/0).setName("or"),OI=X(Ut,"!").setParameterLength(1).setName("not"),UI=X(Ut,"^^").setParameterLength(2).setName("xor"),LI=X(Ut,"&").setParameterLength(2).setName("bitAnd"),zI=X(Ut,"~").setParameterLength(1).setName("bitNot"),VI=X(Ut,"|").setParameterLength(2).setName("bitOr"),jI=X(Ut,"^").setParameterLength(2).setName("bitXor"),GI=X(Ut,"<<").setParameterLength(2).setName("shiftLeft"),HI=X(Ut,">>").setParameterLength(2).setName("shiftRight"),WI=F(([r])=>(r.addAssign(1),r)),qI=F(([r])=>(r.subAssign(1),r)),XI=F(([r])=>{let e=k(r).toConst();return r.addAssign(1),e}),KI=F(([r])=>{let e=k(r).toConst();return r.subAssign(1),e});G("add",lt);G("sub",ze);G("mul",Te);G("div",js);G("mod",S1);G("equal",CI);G("notEqual",kI);G("lessThan",II);G("greaterThan",N1);G("lessThanEqual",BI);G("greaterThanEqual",FI);G("and",PI);G("or",DI);G("not",OI);G("xor",UI);G("bitAnd",LI);G("bitNot",zI);G("bitOr",VI);G("bitXor",jI);G("shiftLeft",GI);G("shiftRight",HI);G("incrementBefore",WI);G("decrementBefore",qI);G("increment",XI);G("decrement",KI);var L=class r extends xt{static get type(){return"MathNode"}constructor(e,t,s=null,n=null){if(super(),(e===r.MAX||e===r.MIN)&&arguments.length>3){let a=new r(e,t,s);for(let i=3;i<arguments.length-1;i++)a=new r(e,a,arguments[i]);t=a,s=arguments[arguments.length-1],n=null}this.method=e,this.aNode=t,this.bNode=s,this.cNode=n,this.isMathNode=!0}getInputType(e){let t=this.aNode.getNodeType(e),s=this.bNode?this.bNode.getNodeType(e):null,n=this.cNode?this.cNode.getNodeType(e):null,a=e.isMatrix(t)?0:e.getTypeLength(t),i=e.isMatrix(s)?0:e.getTypeLength(s),o=e.isMatrix(n)?0:e.getTypeLength(n);return a>i&&a>o?t:i>o?s:o>a?n:t}generateNodeType(e){let t=this.method;return t===r.LENGTH||t===r.DISTANCE||t===r.DOT||t===r.DETERMINANT?"float":t===r.CROSS?"vec3":t===r.ALL||t===r.ANY?"bool":t===r.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):this.getInputType(e)}setup(e){let{aNode:t,bNode:s,method:n}=this,a=null;if(n===r.ONE_MINUS)a=ze(1,t);else if(n===r.RECIPROCAL)a=js(1,t);else if(n===r.DIFFERENCE)a=bt(ze(t,s));else if(n===r.TRANSFORM_DIRECTION){let i,o;e.isMatrix(t.getNodeType(e))?(i=t,o=s):(i=s,o=t),a=Vs(Te(i,ce(C(o),0)).xyz)}return a!==null?a:super.setup(e)}generate(e,t){if(e.getNodeProperties(this).outputNode)return super.generate(e,t);let n=this.method,a=this.getNodeType(e),i=this.getInputType(e),o=this.aNode,c=this.bNode,l=this.cNode,h=e.renderer.coordinateSystem;if(n===r.NEGATE)return e.format("( - "+o.build(e,i)+" )",a,t);{let u=[];return n===r.CROSS?u.push(o.build(e,a),c.build(e,a)):h===sn&&n===r.STEP?u.push(o.build(e,e.getTypeLength(o.getNodeType(e))===1?"float":i),c.build(e,i)):h===sn&&(n===r.MIN||n===r.MAX)?u.push(o.build(e,i),c.build(e,e.getTypeLength(c.getNodeType(e))===1?e.getComponentType(i):i)):n===r.REFRACT?u.push(o.build(e,i),c.build(e,i),l.build(e,"float")):n===r.MIX?u.push(o.build(e,i),c.build(e,i),l.build(e,e.getTypeLength(l.getNodeType(e))===1?"float":i)):(h===Xs&&n===r.ATAN&&c!==null&&(n="atan2"),e.shaderStage!=="fragment"&&(n===r.DFDX||n===r.DFDY)&&(W(`TSL: '${n}' is not supported in the ${e.shaderStage} stage.`,this.stackTrace),n="/*"+n+"*/"),u.push(o.build(e,i)),c!==null&&u.push(c.build(e,i)),l!==null&&u.push(l.build(e,i))),e.format(`${e.getMethod(n,a)}( ${u.join(", ")} )`,a,t)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}};L.ALL="all";L.ANY="any";L.RADIANS="radians";L.DEGREES="degrees";L.EXP="exp";L.EXP2="exp2";L.LOG="log";L.LOG2="log2";L.SQRT="sqrt";L.INVERSE_SQRT="inversesqrt";L.FLOOR="floor";L.CEIL="ceil";L.NORMALIZE="normalize";L.FRACT="fract";L.SIN="sin";L.SINH="sinh";L.COS="cos";L.COSH="cosh";L.TAN="tan";L.TANH="tanh";L.ASIN="asin";L.ASINH="asinh";L.ACOS="acos";L.ACOSH="acosh";L.ATAN="atan";L.ATANH="atanh";L.ABS="abs";L.SIGN="sign";L.LENGTH="length";L.NEGATE="negate";L.ONE_MINUS="oneMinus";L.DFDX="dFdx";L.DFDY="dFdy";L.ROUND="round";L.RECIPROCAL="reciprocal";L.TRUNC="trunc";L.FWIDTH="fwidth";L.TRANSPOSE="transpose";L.DETERMINANT="determinant";L.INVERSE="inverse";L.EQUALS="equals";L.MIN="min";L.MAX="max";L.STEP="step";L.REFLECT="reflect";L.DISTANCE="distance";L.DIFFERENCE="difference";L.DOT="dot";L.CROSS="cross";L.POW="pow";L.TRANSFORM_DIRECTION="transformDirection";L.MIX="mix";L.CLAMP="clamp";L.REFRACT="refract";L.SMOOTHSTEP="smoothstep";L.FACEFORWARD="faceforward";var R1=S(1e-6),RO=S(1e6),E1=S(Math.PI),EO=S(Math.PI*2),CO=S(Math.PI*2),kO=S(Math.PI*.5),JI=X(L,L.ALL).setParameterLength(1),$I=X(L,L.ANY).setParameterLength(1),YI=X(L,L.RADIANS).setParameterLength(1),ZI=X(L,L.DEGREES).setParameterLength(1),LT=X(L,L.EXP).setParameterLength(1),Nd=X(L,L.EXP2).setParameterLength(1),wb=X(L,L.LOG).setParameterLength(1),nr=X(L,L.LOG2).setParameterLength(1),fn=X(L,L.SQRT).setParameterLength(1),C1=X(L,L.INVERSE_SQRT).setParameterLength(1),zs=X(L,L.FLOOR).setParameterLength(1),zT=X(L,L.CEIL).setParameterLength(1),Vs=X(L,L.NORMALIZE).setParameterLength(1),ja=X(L,L.FRACT).setParameterLength(1),_s=X(L,L.SIN).setParameterLength(1),QI=X(L,L.SINH).setParameterLength(1),Ln=X(L,L.COS).setParameterLength(1),e9=X(L,L.COSH).setParameterLength(1),t9=X(L,L.TAN).setParameterLength(1),s9=X(L,L.TANH).setParameterLength(1),n9=X(L,L.ASIN).setParameterLength(1),a9=X(L,L.ASINH).setParameterLength(1),k1=X(L,L.ACOS).setParameterLength(1),i9=X(L,L.ACOSH).setParameterLength(1),I1=X(L,L.ATAN).setParameterLength(1,2),r9=X(L,L.ATANH).setParameterLength(1),bt=X(L,L.ABS).setParameterLength(1),B1=X(L,L.SIGN).setParameterLength(1),ar=X(L,L.LENGTH).setParameterLength(1),F1=X(L,L.NEGATE).setParameterLength(1),o9=X(L,L.ONE_MINUS).setParameterLength(1),P1=X(L,L.DFDX).setParameterLength(1),D1=X(L,L.DFDY).setParameterLength(1),c9=X(L,L.ROUND).setParameterLength(1),l9=X(L,L.RECIPROCAL).setParameterLength(1),O1=X(L,L.TRUNC).setParameterLength(1),U1=X(L,L.FWIDTH).setParameterLength(1),h9=X(L,L.TRANSPOSE).setParameterLength(1),u9=X(L,L.DETERMINANT).setParameterLength(1),d9=X(L,L.INVERSE).setParameterLength(1),pa=X(L,L.MIN).setParameterLength(2,1/0),Pt=X(L,L.MAX).setParameterLength(2,1/0),rr=X(L,L.STEP).setParameterLength(2),f9=X(L,L.REFLECT).setParameterLength(2),p9=X(L,L.DISTANCE).setParameterLength(2),m9=X(L,L.DIFFERENCE).setParameterLength(2),Gn=X(L,L.DOT).setParameterLength(2),Mi=X(L,L.CROSS).setParameterLength(2),zn=X(L,L.POW).setParameterLength(2),L1=r=>Te(r,r),b9=r=>Te(r,r,r),VT=r=>Te(r,r,r,r),g9=X(L,L.TRANSFORM_DIRECTION).setParameterLength(2),y9=(r,e)=>Vs(Te(e,ce(C(r),0)).xyz),x9=(r,e)=>Vs(ce(C(r),0).mul(e).xyz),w9=r=>Te(B1(r),zn(bt(r),1/3)),z1=r=>Gn(r,r),Ke=X(L,L.MIX).setParameterLength(3),Hn=(r,e=0,t=1)=>new L(L.CLAMP,pe(r),pe(e),pe(t)),jT=r=>Hn(r),V1=X(L,L.REFRACT).setParameterLength(3),ma=X(L,L.SMOOTHSTEP).setParameterLength(3),j1=X(L,L.FACEFORWARD).setParameterLength(3),T9=F(([r])=>{let s=43758.5453,n=Gn(r.xy,Z(12.9898,78.233)),a=S1(n,E1);return ja(_s(a).mul(s))}),v9=(r,e,t)=>Ke(e,t,r),_9=(r,e,t)=>ma(e,t,r),A9=(r,e)=>rr(e,r),IO=j1,BO=C1;G("all",JI);G("any",$I);G("radians",YI);G("degrees",ZI);G("exp",LT);G("exp2",Nd);G("log",wb);G("log2",nr);G("sqrt",fn);G("inverseSqrt",C1);G("floor",zs);G("ceil",zT);G("normalize",Vs);G("fract",ja);G("sin",_s);G("sinh",QI);G("cos",Ln);G("cosh",e9);G("tan",t9);G("tanh",s9);G("asin",n9);G("asinh",a9);G("acos",k1);G("acosh",i9);G("atan",I1);G("atanh",r9);G("abs",bt);G("sign",B1);G("length",ar);G("lengthSq",z1);G("negate",F1);G("oneMinus",o9);G("dFdx",P1);G("dFdy",D1);G("round",c9);G("reciprocal",l9);G("trunc",O1);G("fwidth",U1);G("min",pa);G("max",Pt);G("step",A9);G("reflect",f9);G("distance",p9);G("dot",Gn);G("cross",Mi);G("pow",zn);G("pow2",L1);G("pow3",b9);G("pow4",VT);G("transformDirection",g9);G("transformNormalByViewMatrix",y9);G("transformNormalByInverseViewMatrix",x9);G("mix",v9);G("clamp",Hn);G("refract",V1);G("smoothstep",_9);G("faceForward",j1);G("difference",m9);G("saturate",jT);G("cbrt",w9);G("transpose",h9);G("determinant",u9);G("inverse",d9);G("rand",T9);var C0=class extends we{static get type(){return"ConditionalNode"}constructor(e,t,s=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=s}generateNodeType(e){let{ifNode:t,elseNode:s}=e.getNodeProperties(this);if(t===void 0)return e.flowBuildStage(this,"setup"),this.getNodeType(e);let n=t.getNodeType(e);if(s!==null){let a=s.getNodeType(e);if(e.getTypeLength(a)>e.getTypeLength(n))return a}return n}setup(e){let t=this.condNode,s=this.ifNode.isolate(),n=this.elseNode?this.elseNode.isolate():null,a=e.context.nodeBlock;e.getDataFromNode(s).parentNodeBlock=a,n!==null&&(e.getDataFromNode(n).parentNodeBlock=a);let i=e.context.uniformFlow,o=e.getNodeProperties(this);o.condNode=t,o.ifNode=i?s:s.context({nodeBlock:s}),o.elseNode=n?i?n:n.context({nodeBlock:n}):null}generate(e,t){let s=this.getNodeType(e),n=e.getDataFromNode(this);if(n.nodeProperty!==void 0)return n.nodeProperty;let{condNode:a,ifNode:i,elseNode:o}=e.getNodeProperties(this),c=e.currentFunctionNode,l=t!=="void",h=l?za(s).build(e):"";n.nodeProperty=h;let u=a.build(e,"bool");if(e.context.uniformFlow&&o!==null){let p=i.build(e,s),m=o.build(e,s),b=e.getTernary(u,p,m);return e.format(b,s,t)}e.addFlowCode(`
${e.tab}if ( ${u} ) {

`).addFlowTab();let f=i.build(e,s);if(f&&(l?f=h+" = "+f+";":(f="return "+f+";",c===null&&(K("TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.",this.stackTrace),f="// "+f))),e.removeFlowTab().addFlowCode(e.tab+"	"+f+`

`+e.tab+"}"),o!==null){e.addFlowCode(` else {

`).addFlowTab();let p=o.build(e,s);p&&(l?p=h+" = "+p+";":(p="return "+p+";",c===null&&(K("TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.",this.stackTrace),p="// "+p))),e.removeFlowTab().addFlowCode(e.tab+"	"+p+`

`+e.tab+`}

`)}else e.addFlowCode(`

`);return e.format(h,s,t)}},$s=He(C0).setParameterLength(2,3);G("select",$s);var Rd=class extends we{static get type(){return"ContextNode"}constructor(e=null,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}generateNodeType(e){return this.node.getNodeType(e)}getFlowContextData(){let e=[];return this.traverse(t=>{t.isContextNode===!0&&e.push(t.value)}),Object.assign({},...e)}getMemberType(e,t){return this.node.getMemberType(e,t)}analyze(e){if(e.increaseUsage(this)===1){let s=e.addContext(this.value);this.node.build(e,this),e.setContext(s)}}setup(e){let t=e.addContext(this.value),s=this.node.build(e);return e.setContext(t),s}generate(e,t){let s=e.addContext(this.value),n=this.node.build(e,t);return e.setContext(s),n}},Wn=(r=null,e={})=>{let t=r;return(t===null||t.isNode!==!0)&&(e=t||e,t=null),new Rd(t,e)},M9=r=>Wn(r,{uniformFlow:!0}),G1=(r,e)=>Wn(r,{nodeName:e});function S9(r,e,t=null){return Wn(t,{getShadow:({light:s,shadowColorNode:n})=>e===s?n.mul(r):n})}function N9(r,e=null){return Wn(e,{getAO:(t,{material:s})=>s.transparent===!0?t:t!==null?t.mul(r):r})}function R9(r,e,t=null){let s=r.max(.001);return Wn(t,{getAO:(n,{material:a})=>a.transparent===!0?n:n!==null?n.mul(s):s,getGI:(n,{material:a})=>{if(a.transparent===!0)return n;let i=e.div(s);return n!==null?n.add(i):i}})}function E9(r,e){return K('TSL: "label()" has been deprecated. Use "setName()" instead.'),G1(r,e)}G("context",Wn);G("label",E9);G("uniformFlow",M9);G("setName",G1);G("builtinShadowContext",(r,e,t)=>S9(e,t,r));G("builtinAOContext",(r,e)=>N9(e,r));G("builtinGIContext",(r,e,t)=>R9(e,t,r));var Fl=class extends we{static get type(){return"VarNode"}constructor(e,t=null,s=!1){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0,this.readOnly=s,this.parents=!0,this.intent=!1}setIntent(e){return this.intent=e,this}isIntent(e){return e.getDataFromNode(this).forceDeclaration===!0?!1:this.intent}getIntent(){return this.intent}getMemberType(e,t){return this.node.getMemberType(e,t)}getElementType(e){return this.node.getElementType(e)}generateNodeType(e){return this.node.getNodeType(e)}getArrayCount(e){return this.node.getArrayCount(e)}isAssign(e){return e.getDataFromNode(this).assign}build(...e){let t=e[0],s=this.getShared(t);if(this!==s)return s.build(...e);if(this._hasStack(t)===!1&&t.buildStage==="setup"&&(t.context.nodeLoop||t.context.nodeBlock)){let n=!1;if(this.node.isShaderCallNodeInternal&&this.node.shaderNode.getLayout()===null&&t.fnCall&&t.fnCall.shaderNode&&t.getDataFromNode(this.node.shaderNode).hasLoop){let o=t.getDataFromNode(this);o.forceDeclaration=!0,n=!0}let a=t.getBaseStack();n?a.addToStackBefore(this):a.addToStack(this)}return this.isIntent(t)&&this.isAssign(t)!==!0?this.node.build(...e):super.build(...e)}generate(e){let{node:t,name:s,readOnly:n}=this,{renderer:a}=e,i=a.backend.isWebGPUBackend===!0,o=!1,c=!1;n&&(o=e.isDeterministic(t),c=i?n:o);let l=this.getNodeType(e);if(l=="void")return this.isIntent(e)!==!0&&W('TSL: ".toVar()" can not be used with void type.',this.stackTrace),t.build(e);let h=e.getVectorType(l),u=t.build(e,h),d=e.getVarFromNode(this,s,h,void 0,c),f=e.getPropertyName(d),p=f;if(c)if(i)p=o?`const ${f}`:`let ${f}`;else{let m=t.getArrayCount(e);p=`const ${e.getVar(d.type,f,m)}`}return e.addLineFlowCode(`${p} = ${u}`,this),f}_hasStack(e){return e.getDataFromNode(this).stack!==void 0}},H1=He(Fl),C9=(r,e=null)=>H1(r,e).toStack(),k9=(r,e=null)=>H1(r,e,!0).toStack(),I9=r=>H1(r).setIntent(!0).toStack();G("toVar",C9);G("toConst",k9);G("toVarIntent",I9);var k0=class extends we{static get type(){return"SubBuild"}constructor(e,t,s=null){super(s),this.node=e,this.name=t,this.isSubBuildNode=!0}generateNodeType(e){if(this.nodeType!==null)return this.nodeType;e.addSubBuild(this.name);let t=this.node.getNodeType(e);return e.removeSubBuild(),t}build(e,...t){e.addSubBuild(this.name);let s=this.node.build(e,...t);return e.removeSubBuild(),s}},Pl=(r,e,t=null)=>new k0(pe(r),e,t),I0=class extends we{static get type(){return"VaryingNode"}constructor(e,t=null){super(),this.node=Pl(e,"VERTEX"),this.name=t,this.isVaryingNode=!0,this.interpolationType=null,this.interpolationSampling=null,this.global=!0}setInterpolation(e,t=null){return this.interpolationType=e,this.interpolationSampling=t,this}getHash(e){return this.name||super.getHash(e)}generateNodeType(e){return this.node.getNodeType(e)}setupVarying(e){let t=e.getNodeProperties(this),s=t.varying;if(s===void 0){let n=this.name,a=this.getNodeType(e),i=this.interpolationType,o=this.interpolationSampling;t.varying=s=e.getVaryingFromNode(this,n,a,i,o),t.node=Pl(this.node,"VERTEX")}return s.needsInterpolation||(s.needsInterpolation=e.shaderStage==="fragment"),s}setup(e){this.setupVarying(e),e.flowNodeFromShaderStage(Ml.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(Ml.VERTEX,this.node)}generate(e){let t=e.getSubBuildProperty("property",e.currentStack),s=e.getNodeProperties(this),n=this.setupVarying(e);if(s[t]===void 0){let a=this.getNodeType(e),i=e.getPropertyName(n,Ml.VERTEX);if(e.shaderStage===Ml.VERTEX){let o=s.node.build(e,a);e.addLineFlowCode(`${i} = ${o}`,this)}else e.flowNodeFromShaderStage(Ml.VERTEX,s.node,a,i);s[t]=i}return e.getPropertyName(n)}},bc=He(I0).setParameterLength(1,2),B9=r=>bc(r);G("toVarying",bc);G("toVertexStage",B9);var F9=F(([r])=>{let e=r.mul(.9478672986).add(.0521327014).pow(2.4),t=r.mul(.0773993808),s=r.lessThanEqual(.04045);return Ke(e,t,s)}).setLayout({name:"sRGBTransferEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),P9=F(([r])=>{let e=r.pow(.41666).mul(1.055).sub(.055),t=r.mul(12.92),s=r.lessThanEqual(.0031308);return Ke(e,t,s)}).setLayout({name:"sRGBTransferOETF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),W1="WorkingColorSpace",FO="OutputColorSpace",Ed=class extends xt{static get type(){return"ColorSpaceNode"}constructor(e,t,s){super("vec4"),this.colorNode=e,this.source=t,this.target=s}resolveColorSpace(e,t){return t===W1?qe.workingColorSpace:t===FO?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){let{colorNode:t}=this,s=this.resolveColorSpace(e,this.source),n=this.resolveColorSpace(e,this.target),a=t;return qe.enabled===!1||s===n||!s||!n||(qe.getTransfer(s)===Ie&&(a=ce(F9(a.rgb),a.a)),qe.getPrimaries(s)!==qe.getPrimaries(n)&&(a=ce(Ms(qe._getMatrix(new Fs,s,n)).mul(a.rgb),a.a)),qe.getTransfer(n)===Ie&&(a=ce(P9(a.rgb),a.a))),a}},D9=(r,e)=>new Ed(pe(r),W1,e),GT=(r,e)=>new Ed(pe(r),e,W1),PO=(r,e,t)=>new Ed(pe(r),e,t);G("workingToColorSpace",D9);G("colorSpaceToWorking",GT);var Dm=class extends no{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}generateNodeType(){return this.referenceNode.uniformType}generate(e){let t=super.generate(e),s=this.referenceNode.getNodeType(e),n=this.getNodeType(e);return e.format(t,s,n)}},Om=class extends we{static get type(){return"ReferenceBaseNode"}constructor(e,t,s=null,n=null){super(),this.property=e,this.uniformType=t,this.object=s,this.count=n,this.properties=e.split("."),this.reference=s,this.node=null,this.group=null,this.updateType=Me.OBJECT}setGroup(e){return this.group=e,this}element(e){return new Dm(this,pe(e))}setNodeType(e){let t=xe(null,e);this.group!==null&&t.setGroup(this.group),this.node=t}generateNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){let{properties:t}=this,s=e[t[0]];for(let n=1;n<t.length;n++)s=s[t[n]];return s}updateReference(e){return this.reference=this.object!==null?this.object:e.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);let e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}},DO=(r,e,t)=>new Om(r,e,t),B0=class extends Om{static get type(){return"RendererReferenceNode"}constructor(e,t,s=null){super(e,t,s),this.renderer=s,this.setGroup(ye)}updateReference(e){return this.reference=this.renderer!==null?this.renderer:e.renderer,this.reference}},O9=(r,e,t=null)=>new B0(r,e,t),F0=class extends xt{static get type(){return"ToneMappingNode"}constructor(e,t=L9,s=null){super("vec3"),this._toneMapping=e,this.exposureNode=t,this.colorNode=s}customCacheKey(){return wd(this._toneMapping)}setToneMapping(e){return this._toneMapping=e,this}getToneMapping(){return this._toneMapping}setup(e){let t=this.colorNode||e.context.color,s=this._toneMapping;if(s===Hi)return t;let n=null,a=e.renderer.library.getToneMappingFunction(s);return a!==null?n=ce(a(t.rgb,this.exposureNode),t.a):(W("ToneMappingNode: Unsupported Tone Mapping configuration.",s),n=t),n}},U9=(r,e,t)=>new F0(r,pe(e),pe(t)),L9=O9("toneMappingExposure","float");G("toneMapping",(r,e,t)=>U9(e,t,r));var JC=new WeakMap;function $C(r,e){let t=JC.get(r);return t===void 0&&(t=new ri(r,e),JC.set(r,t)),t}var xi=class extends Md{static get type(){return"BufferAttributeNode"}constructor(e,t=null,s=0,n=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=s,this.bufferOffset=n,this.usage=Uo,this.instanced=!1,this.attribute=null,this.global=!0,e&&e.isBufferAttribute===!0&&e.itemSize<=4&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){let t;if(this.bufferStride===0&&this.bufferOffset===0){let s=e.globalCache.getData(this.value);s===void 0&&(s={node:this},e.globalCache.setData(this.value,s)),t=s.node.id}else t=this.id;return String(t)}generateNodeType(e){return this.bufferType===null&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(this.attribute!==null)return;let t=this.getNodeType(e),s=e.getTypeLength(t),n=this.value,a=this.bufferStride||s,i=this.bufferOffset,o;n.isInterleavedBuffer===!0?o=n:n.isBufferAttribute===!0?o=$C(n.array,a):o=$C(n,a);let c=new Ra(o,s,i);o.setUsage(this.usage),this.attribute=c,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){let t=this.getNodeType(e),s=e.context.nodeName;s!==void 0&&delete e.context.nodeName;let n=e.getBufferAttributeFromNode(this,t,s),a=e.getPropertyName(n),i=null;if(e.shaderStage==="vertex"||e.shaderStage==="compute")this.name=a,i=a;else{let o;s&&(o=s+"Varying"),i=bc(this,o).build(e,t)}return i}getInputType(){return"bufferAttribute"}setUsage(e){return this.usage=e,this.attribute&&this.attribute.isBufferAttribute===!0&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}};function HT(r,e=null,t=0,s=0,n=Uo,a=!1){return e==="mat3"||e===null&&r.itemSize===9?Ms(new xi(r,"vec3",9,0).setUsage(n).setInstanced(a),new xi(r,"vec3",9,3).setUsage(n).setInstanced(a),new xi(r,"vec3",9,6).setUsage(n).setInstanced(a)):e==="mat4"||e===null&&r.itemSize===16?so(new xi(r,"vec4",16,0).setUsage(n).setInstanced(a),new xi(r,"vec4",16,4).setUsage(n).setInstanced(a),new xi(r,"vec4",16,8).setUsage(n).setInstanced(a),new xi(r,"vec4",16,12).setUsage(n).setInstanced(a)):new xi(r,e,t,s).setUsage(n)}var q1=(r,e=null,t=0,s=0)=>HT(r,e,t,s),OO=(r,e=null,t=0,s=0)=>HT(r,e,t,s,Gr),WT=(r,e=null,t=0,s=0)=>HT(r,e,t,s,Uo,!0),X1=(r,e=null,t=0,s=0)=>HT(r,e,t,s,Gr,!0);G("toAttribute",r=>q1(r.value,r.bufferType));var rs=class r extends we{static get type(){return"IndexNode"}constructor(e){super("uint"),this.scope=e,this.isIndexNode=!0}generate(e){let t=this.getNodeType(e),s=this.scope,n;if(s===r.VERTEX)n=e.getVertexIndex();else if(s===r.INSTANCE)n=e.getInstanceIndex();else if(s===r.DRAW)n=e.getDrawIndex();else if(s===r.INVOCATION_LOCAL)n=e.getInvocationLocalIndex();else if(s===r.INVOCATION_SUBGROUP)n=e.getInvocationSubgroupIndex();else if(s===r.SUBGROUP)n=e.getSubgroupIndex();else throw new Error("THREE.IndexNode: Unknown scope: "+s);let a;return e.shaderStage==="vertex"||e.shaderStage==="compute"?a=n:a=bc(this).build(e,t),a}};rs.VERTEX="vertex";rs.INSTANCE="instance";rs.SUBGROUP="subgroup";rs.INVOCATION_LOCAL="invocationLocal";rs.INVOCATION_SUBGROUP="invocationSubgroup";rs.DRAW="draw";var P0=ie(rs,rs.VERTEX),_i=ie(rs,rs.INSTANCE),UO=ie(rs,rs.SUBGROUP),LO=ie(rs,rs.INVOCATION_SUBGROUP),zO=ie(rs,rs.INVOCATION_LOCAL),z9=ie(rs,rs.DRAW),D0=class extends we{static get type(){return"ComputeNode"}constructor(e,t){super("void"),this.isComputeNode=!0,this.computeNode=e,this.workgroupSize=t,this.count=null,this.dispatchSize=null,this.version=1,this.name="",this.onInitFunction=null,this.countNode=null,this.updateBeforeType=Me.FRAME}setName(e){return this.name=e,this}label(e){return K('TSL: "label()" has been deprecated. Use "setName()" instead.',new is),this.setName(e)}onInit(e){return this.onInitFunction=e,this}getUpdateBeforeType(e){return e.compute!==this?this.updateBeforeType:Me.NONE}updateBefore({renderer:e}){e.compute(this)}setup(e){this.count!==null&&this.countNode===null&&(this.countNode=xe(this.count,"uint").onObjectUpdate(()=>this.count));let t=this.computeNode.build(e);if(t){let s=e.getNodeProperties(this);s.outputComputeNode=t.outputNode,t.outputNode=null}return t}generate(e,t){let{shaderStage:s}=e;if(s==="compute"){let n=this.computeNode.build(e,"void");if(n!==""&&e.addLineFlowCode(n,this),this.count!==null&&e.allowEarlyReturns===!0){let a=this.countNode.build(e,"uint"),i=_i.build(e,"uint");e.flow.code=`${e.tab}if ( ${i} >= ${a} ) { return; }

${e.flow.code}`}}else{let a=e.getNodeProperties(this).outputComputeNode;if(a)return a.build(e,t)}}},K1=(r,e=[64])=>{(e.length===0||e.length>3)&&W("TSL: compute() workgroupSize must have 1, 2, or 3 elements",new is);for(let t=0;t<e.length;t++){let s=e[t];(typeof s!="number"||s<=0||!Number.isInteger(s))&&W(`TSL: compute() workgroupSize element at index [ ${t} ] must be a positive integer`,new is)}for(;e.length<3;)e.push(1);return new D0(pe(r),e)},V9=(r,e,t)=>{let s=K1(r,t);return typeof e=="number"?s.count=e:s.dispatchSize=e,s};G("compute",V9);G("computeKernel",K1);var O0=class extends we{static get type(){return"IsolateNode"}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isIsolateNode=!0}generateNodeType(e){let t=e.getCache(),s=e.getCacheFromNode(this,this.parent);e.setCache(s);let n=this.node.getNodeType(e);return e.setCache(t),n}build(e,...t){let s=e.getCache(),n=e.getCacheFromNode(this,this.parent);e.setCache(n);let a=this.node.build(e,...t);return e.setCache(s),a}setParent(e){return this.parent=e,this}getParent(){return this.parent}},Nl=r=>new O0(pe(r));function j9(r,e=!0){return K('TSL: "cache()" has been deprecated. Use "isolate()" instead.'),Nl(r).setParent(e)}G("cache",j9);G("isolate",Nl);var U0=class extends we{static get type(){return"BypassNode"}constructor(e,t){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=t}generateNodeType(e){return this.outputNode.getNodeType(e)}generate(e){let t=this.callNode.build(e,"void");return t!==""&&e.addLineFlowCode(t,this),this.outputNode.build(e)}},G9=He(U0).setParameterLength(2);G("bypass",G9);var J1=F(([r,e,t,s=S(0),n=S(1),a=Va(!1)])=>{let i=r.sub(e).div(t.sub(e));return Cl(a)&&(i=i.clamp()),i.mul(n.sub(s)).add(s)});function H9(r,e,t,s=S(0),n=S(1)){return J1(r,e,t,s,n,!0)}G("remap",J1);G("remapClamp",H9);var Dl=class extends we{static get type(){return"ExpressionNode"}constructor(e="",t="void"){super(t),this.snippet=e}generate(e,t){let s=this.getNodeType(e),n=this.snippet;if(s==="void")e.addLineFlowCode(n,this);else return e.format(n,s,t)}},ua=He(Dl).setParameterLength(1,2),W9=r=>(r?$s(r,ua("discard")):ua("discard")).toStack(),VO=()=>ua("return").toStack();G("discard",W9);var $1=F(([r])=>ce(r.rgb.mul(r.a),r.a),{color:"vec4",return:"vec4"}),q9=F(([r])=>r.a.equal(0).select(ce(0),ce(r.rgb.div(r.a),r.a)),{color:"vec4",return:"vec4"}),L0=class extends xt{static get type(){return"RenderOutputNode"}constructor(e,t,s){super("vec4"),this.colorNode=e,this._toneMapping=t,this.outputColorSpace=s,this.isRenderOutputNode=!0}setToneMapping(e){return this._toneMapping=e,this}getToneMapping(){return this._toneMapping}setup({context:e}){let t=this.colorNode||e.color;t=ce(t.rgb,t.a.clamp(0,1)),t=q9(t);let s=(this._toneMapping!==null?this._toneMapping:e.toneMapping)||Hi,n=(this.outputColorSpace!==null?this.outputColorSpace:e.outputColorSpace)||qi;return s!==Hi&&(t=t.toneMapping(s)),n!==qi&&n!==qe.workingColorSpace&&(t=t.workingToColorSpace(n)),t=$1(t),t}},Tb=(r,e=null,t=null)=>new L0(pe(r),e,t);G("renderOutput",Tb);var z0=class extends xt{static get type(){return"DebugNode"}constructor(e,t=null){super(),this.node=e,this.callback=t}generateNodeType(e){return this.node.getNodeType(e)}setup(e){return this.node.build(e)}analyze(e){return this.node.build(e)}generate(e){let t=this.callback,s=this.node.build(e);if(t!==null)t(e,s);else{let n="--- TSL debug - "+e.shaderStage+" shader ---",a="-".repeat(n.length),i="";i+="// #"+n+`#
`,i+=e.flow.code.replace(/^\t/mg,"")+`
`,i+="/* ... */ "+s+` /* ... */
`,i+="// #"+a+`#
`,jf(i)}return s}},X9=(r,e=null)=>new z0(pe(r),e).toStack();G("debug",X9);var Um=class extends Bs{constructor(){super(),this._renderer=null,this.currentFrame=null,this.isRunning=!1,this.enabled=!0}get nodeFrame(){return this._renderer._nodes.nodeFrame}setRenderer(e){return this._renderer=e,this}getRenderer(){return this._renderer}begin(){this.isRunning=!0}finish(){this.isRunning=!1}inspect(){}computeAsync(){}beginCompute(){}finishCompute(){}beginRender(){}finishRender(){}copyTextureToTexture(){}copyFramebufferToTexture(){}dispose(){this.isRunning===!0&&this.finish(),this.dispatchEvent({type:"dispose"})}},V0=class extends we{static get type(){return"InspectorNode"}constructor(e,t="",s=null){super(),this.node=e,this.name=t,this.callback=s,this.updateType=Me.FRAME,this.isInspectorNode=!0}getName(){return this.name||this.node.name}update(e){e.renderer.inspector.inspect(this)}generateNodeType(e){return this.node.getNodeType(e)}setup(e){let t=this.node;return e.context.inspector===!0&&this.callback!==null&&(t=this.callback(t)),e.renderer.backend.isWebGPUBackend!==!0&&e.renderer.inspector.constructor!==Um&&je('TSL: ".toInspector()" is only available with WebGPU.'),t}};function K9(r,e="",t=null){return r=pe(r),r.before(new V0(r,e,t))}G("toInspector",K9);function jO(r){K("TSL: AddNodeElement has been removed in favor of tree-shaking. Trying add",r)}var Lm=class extends we{static get type(){return"AttributeNode"}constructor(e,t=null){super(t),this.global=!0,this._attributeName=e}getHash(e){return this.getAttributeName(e)}generateNodeType(e){let t=this.nodeType;if(t===null){let s=this.getAttributeName(e);if(e.hasGeometryAttribute(s)){let n=e.geometry.getAttribute(s);t=e.getTypeFromAttribute(n)}else t="float"}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){let t=this.getAttributeName(e),s=this.getNodeType(e);if(e.hasGeometryAttribute(t)===!0){let a=e.geometry.getAttribute(t),i=e.getTypeFromAttribute(a),o=e.getAttribute(t,i);return e.shaderStage==="vertex"?e.format(o.name,i,s):bc(this).build(e,s)}else return K(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(s)}serialize(e){super.serialize(e),e.global=this.global,e._attributeName=this._attributeName}deserialize(e){super.deserialize(e),this.global=e.global,this._attributeName=e._attributeName}},Rn=(r,e=null)=>new Lm(r,e),ot=(r=0)=>Rn("uv"+(r>0?r:""),"vec2"),j0=class extends we{static get type(){return"TextureSizeNode"}constructor(e,t=null){super("uvec2"),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e){let t=this.textureNode.build(e,"property"),s=this.levelNode===null?"0":this.levelNode.build(e,"int"),n=e.generateTextureSize(this.textureNode.value,t,s);return e.format(n,this.getNodeType(e))}},ic=He(j0).setParameterLength(1,2),G0=class extends ac{static get type(){return"MaxMipLevelNode"}constructor(e){super(0),this._textureNode=e,this.updateType=Me.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){let e=this.texture,t=e.images,s=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(s&&s.width!==void 0){let{width:n,height:a}=s;this.value=Math.log2(Math.max(n,a))}}},Y1=He(G0).setParameterLength(1),zm=class extends Error{constructor(e,t=null){super(e),this.name="NodeError",this.stackTrace=t}},Z1=new gt,ba=class extends ac{static get type(){return"TextureNode"}constructor(e=Z1,t=null,s=null,n=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=s,this.biasNode=n,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.gatherNode=null,this.offsetNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=Me.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=null,this._flipYUniform=null,this._samplerComparison=!1,this.setUpdateMatrix(t===null)}set value(e){this.referenceNode?this.referenceNode.value=e:this._value=e}get value(){return this.referenceNode?this.referenceNode.value:this._value}getUniformHash(){return this.value.uuid}generateNodeType(){return this.gatherNode!==null?"vec4":u1(this.value)}getInputType(){return"texture"}getDefaultUV(){return ot(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return this._matrixUniform===null&&(this._matrixUniform=xe(this.value.matrix)),this._matrixUniform.mul(C(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this}setupUV(e,t){return e.isFlipY()&&(this._flipYUniform===null&&(this._flipYUniform=xe(!1)),t=t.toVar(),this.sampler?t=this._flipYUniform.select(t.flipY(),t):t=this._flipYUniform.select(t.setY(k(ic(this,this.levelNode).y).sub(t.y).sub(1)),t)),t}setup(e){let t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;let s=this.value;if(!s||s.isTexture!==!0)throw new zm("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().",this.stackTrace);let n=F(()=>{let c=this.uvNode;return(c===null||e.context.forceUVContext===!0)&&e.context.getUV&&(c=e.context.getUV(this,e)),c||(c=this.getDefaultUV()),this.updateMatrix===!0&&(c=this.getTransformedUV(c)),c=this.setupUV(e,c),this.updateType=this._matrixUniform!==null||this._flipYUniform!==null?Me.OBJECT:Me.NONE,c})(),a=this.levelNode;a===null&&e.context.getTextureLevel&&(a=e.context.getTextureLevel(this));let i=null,o=null;if(this.compareNode!==null)if(e.renderer.hasCompatibility(Hr.TEXTURE_COMPARE))i=this.compareNode;else{let c=s.compareFunction;c===null||c===$p||c===ml||c===td||c===Oo?o=this.compareNode:(i=this.compareNode,je('TSL: Only "LessCompare", "LessEqualCompare", "GreaterCompare" and "GreaterEqualCompare" are supported for depth texture comparison fallback.'))}t.uvNode=n,t.levelNode=a,t.biasNode=this.biasNode,t.compareNode=i,t.compareStepNode=o,t.gradNode=this.gradNode,t.gatherNode=this.gatherNode,t.depthNode=this.depthNode,t.offsetNode=this.offsetNode}generateUV(e,t){return t.build(e,this.sampler===!0?"vec2":"ivec2")}generateOffset(e,t){return t.build(e,"ivec2")}generateSnippet(e,t,s,n,a,i,o,c,l,h,u){let d=this.value,f;return a?f=e.generateTextureBias(d,t,s,a,i,h):c?f=e.generateTextureGrad(d,t,s,c,i,h):l?o?f=e.generateTextureGatherCompare(d,t,s,o,i,h,u):f=e.generateTextureGather(d,t,s,l,i,h,u):o?f=e.generateTextureCompare(d,t,s,o,i,h):this.sampler===!1?f=e.generateTextureLoad(d,t,s,n,i,h):n?f=e.generateTextureLevel(d,t,s,n,i,h):f=e.generateTexture(d,t,s,i,h),f}generate(e,t){let s=this.value,n=e.getNodeProperties(this),a=super.generate(e,"property");if(/^sampler/.test(t)){if(t==="samplerComparison"){this._samplerComparison=!0;let i=this.getSharedNode(e);i._samplerComparison=!0}return a+"_sampler"}else{if(e.isReference(t))return a;{let i=e.getDataFromNode(this),o=this.getNodeType(e),c=i.propertyName;if(c===void 0){let{uvNode:h,levelNode:u,biasNode:d,compareNode:f,compareStepNode:p,depthNode:m,gradNode:b,gatherNode:g,offsetNode:x}=n,T=this.generateUV(e,h),y=u?u.build(e,"float"):null,v=d?d.build(e,"float"):null,_=m?m.build(e,"int"):null,A=f?f.build(e,"float"):null,M=p?p.build(e,"float"):null,N=b?[b[0].build(e,"vec2"),b[1].build(e,"vec2")]:null,R=g?g.build(e,"int"):null,I=x?this.generateOffset(e,x):null,D=this._flipYUniform?this._flipYUniform.build(e,"bool"):null,O=_;O===null&&s.isArrayTexture&&this.isTexture3DNode!==!0&&(O="0");let P=e.getVarFromNode(this);c=e.getPropertyName(P);let U=this.generateSnippet(e,a,T,y,v,O,A,N,R,I,D),j;if(s.isDepthTexture===!0&&R===null?j="float":j=s.type===St?"uvec4":s.type===Ts?"ivec4":"vec4",U=e.format(U,j,o),M!==null){let z=s.compareFunction;z===td||z===Oo?U=rr(ua(U,o),ua(M,"float")).build(e,o):U=rr(ua(M,"float"),ua(U,o)).build(e,o)}e.addLineFlowCode(`${c} = ${U}`,this),i.snippet=U,i.propertyName=c}let l=c;return e.needsToWorkingColorSpace(s)&&(l=GT(ua(l,o),s.colorSpace).setup(e).build(e,o)),e.format(l,o,t)}}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}sample(e){let t=this.clone();return t.uvNode=pe(e),t.referenceNode=this.getBase(),pe(t)}load(e){return this.sample(e).setSampler(!1)}blur(e){let t=this.clone();t.biasNode=pe(e).mul(Y1(t)),t.referenceNode=this.getBase();let s=t.value;return t.generateMipmaps===!1&&(s&&s.generateMipmaps===!1||s.minFilter===pt||s.magFilter===pt)&&(K("TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture."),t.biasNode=null),pe(t)}level(e){let t=this.clone();return t.levelNode=pe(e),t.referenceNode=this.getBase(),pe(t)}size(e){return ic(this,e)}bias(e){let t=this.clone();return t.biasNode=pe(e),t.referenceNode=this.getBase(),pe(t)}getBase(){return this.referenceNode?this.referenceNode.getBase():this}compare(e){let t=this.clone();return t.compareNode=pe(e),t.referenceNode=this.getBase(),pe(t)}grad(e,t){let s=this.clone();return s.gradNode=[pe(e),pe(t)],s.referenceNode=this.getBase(),pe(s)}gather(e=0){let t=this.clone();return t.gatherNode=pe(e),t.referenceNode=this.getBase(),pe(t)}isSampleCompare(){return this.compareNode!==null||this._samplerComparison===!0}depth(e){let t=this.clone();return t.depthNode=pe(e),t.referenceNode=this.getBase(),pe(t)}offset(e){let t=this.clone();return t.offsetNode=pe(e),t.referenceNode=this.getBase(),pe(t)}serialize(e){super.serialize(e),e.value=this.value.toJSON(e.meta).uuid,e.sampler=this.sampler,e.updateMatrix=this.updateMatrix,e.updateType=this.updateType}deserialize(e){super.deserialize(e),this.value=e.meta.textures[e.value],this.sampler=e.sampler,this.updateMatrix=e.updateMatrix,this.updateType=e.updateType}update(){let e=this.value,t=this._matrixUniform;t!==null&&(t.value=e.matrix),e.matrixAutoUpdate===!0&&e.updateMatrix();let s=this._flipYUniform;s!==null&&(s.value=e.image instanceof ImageBitmap&&e.flipY===!0||e.isRenderTargetTexture===!0||e.isFramebufferTexture===!0||e.isDepthTexture===!0)}clone(){let e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.gatherNode=this.gatherNode,e.offsetNode=this.offsetNode,e}},GO=He(ba).setParameterLength(1,4).setName("texture"),et=(r=Z1,e=null,t=null,s=null)=>{let n;return r&&r.isTextureNode===!0?(n=pe(r.clone()),n.referenceNode=r.getBase(),e!==null&&(n.uvNode=pe(e)),t!==null&&(n.levelNode=pe(t)),s!==null&&(n.biasNode=pe(s))):n=GO(r,e,t,s),n},HO=(r=Z1)=>et(r),Jt=(...r)=>et(...r).setSampler(!1),WO=(r,e,t)=>et(r,e).level(t),qO=r=>(r.isNode===!0?r:et(r)).convert("sampler"),XO=r=>(r.isNode===!0?r:et(r)).convert("samplerComparison"),Cd=class extends ac{static get type(){return"BufferNode"}constructor(e,t,s=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=s,this.updateRanges=[]}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}getElementType(e){return this.getNodeType(e)}getInputType(){return"buffer"}},Yd=(r,e,t)=>new Cd(r,e,t),sM=class extends no{static get type(){return"UniformArrayElementNode"}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){let t=super.generate(e),s=this.getNodeType(e),n=this.node.getPaddedType();return e.format(t,n,s)}},H0=class extends Cd{static get type(){return"UniformArrayNode"}constructor(e,t=null){super(null),this.array=e,this.elementType=t===null?to(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=Me.RENDER,this.isArrayBufferNode=!0}generateNodeType(){return this.paddedType}getElementType(){return this.elementType}getPaddedType(){let e=this.elementType,t="vec4";return e==="mat2"?t="mat2":/mat/.test(e)===!0?t="mat4":e.charAt(0)==="i"?t="ivec4":e.charAt(0)==="u"&&(t="uvec4"),t}update(){this.updateBuffer()}onUpdate(e,t){return e=e.bind(this),super.onUpdate((s,n)=>{e(s,n),this.updateBuffer()},t)}updateBuffer(){let{array:e,value:t}=this,s=this.elementType;if(s==="float"||s==="int"||s==="uint")for(let n=0;n<e.length;n++){let a=n*4;t[a]=e[n]}else if(s==="color")for(let n=0;n<e.length;n++){let a=n*4,i=e[n];t[a]=i.r,t[a+1]=i.g,t[a+2]=i.b||0}else if(s==="mat2")for(let n=0;n<e.length;n++){let a=n*4,i=e[n];t[a]=i.elements[0],t[a+1]=i.elements[1],t[a+2]=i.elements[2],t[a+3]=i.elements[3]}else if(s==="mat3")for(let n=0;n<e.length;n++){let a=n*16,i=e[n];t[a]=i.elements[0],t[a+1]=i.elements[1],t[a+2]=i.elements[2],t[a+4]=i.elements[3],t[a+5]=i.elements[4],t[a+6]=i.elements[5],t[a+8]=i.elements[6],t[a+9]=i.elements[7],t[a+10]=i.elements[8],t[a+15]=1}else if(s==="mat4")for(let n=0;n<e.length;n++){let a=n*16,i=e[n];for(let o=0;o<i.elements.length;o++)t[a+o]=i.elements[o]}else for(let n=0;n<e.length;n++){let a=n*4,i=e[n];t[a]=i.x,t[a+1]=i.y,t[a+2]=i.z||0,t[a+3]=i.w||0}}setup(e){let t=this.array.length,s=this.elementType,n=Float32Array,a=this.paddedType,i=e.getTypeLength(a);return s.charAt(0)==="i"&&(n=Int32Array),s.charAt(0)==="u"&&(n=Uint32Array),this.value=new n(t*i),this.bufferCount=t,this.bufferType=a,this.updateBuffer(),super.setup(e)}element(e){return new sM(this,pe(e))}},Us=(r,e)=>new H0(r,e),W0=class extends we{constructor(e){super("float"),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}},Ni=He(W0).setParameterLength(1),Yp,Zp,Cn=class r extends we{static get type(){return"ScreenNode"}constructor(e){super(),this.scope=e,this.isViewportNode=!0}generateNodeType(){return this.scope===r.VIEWPORT?"vec4":"vec2"}update({renderer:e}){let t=e.getRenderTarget();this.scope===r.VIEWPORT?t!==null?Zp.copy(t.viewport):(e.getViewport(Zp),Zp.multiplyScalar(e.getPixelRatio())):t!==null?(Yp.width=t.width,Yp.height=t.height):e.getDrawingBufferSize(Yp)}setup(){let e=this.scope,t=null;e===r.SIZE?t=xe(Yp||(Yp=new q)).setGroup(ye):e===r.VIEWPORT?t=xe(Zp||(Zp=new Ge)).setGroup(ye):t=Z($l.div(kd));let s=Me.NONE;return(this.scope===r.SIZE||this.scope===r.VIEWPORT)&&(s=Me.RENDER),this.updateType=s,t}generate(e){if(this.scope===r.COORDINATE){let t=e.getFragCoord();if(e.isFlipY()){let s=e.getNodeProperties(kd).outputNode.build(e);t=`${e.getType("vec2")}( ${t}.x, ${s}.y - ${t}.y )`}return t}return super.generate(e)}};Cn.COORDINATE="coordinate";Cn.VIEWPORT="viewport";Cn.SIZE="size";Cn.UV="uv";var Q1=xe(1).setGroup(ye).onRenderUpdate(({renderer:r})=>r.getPixelRatio()),vi=ie(Cn,Cn.UV),kd=ie(Cn,Cn.SIZE),$l=ie(Cn,Cn.COORDINATE),vd=ie(Cn,Cn.VIEWPORT),eN=vd.zw,J9=$l.sub(vd.xy),KO=J9.div(eN),pA=null,Sx=null,mA=null,Nx=null,bA=null,Rx=null,gA=null,Ex=null,yA=null,Cx=null,xA=null,kx=null,wA=null,Ix=null,fr=xe(0,"uint").setName("u_cameraIndex").setGroup(UT("cameraIndex")).toVarying("v_cameraIndex"),Yr=xe("float").setName("cameraNear").setGroup(ye).onRenderUpdate(({camera:r})=>r.near),Zr=xe("float").setName("cameraFar").setGroup(ye).onRenderUpdate(({camera:r})=>r.far),En=F(({camera:r})=>{let e;if(r.isArrayCamera&&r.cameras.length>0){let t=[];for(let s of r.cameras)t.push(s.projectionMatrix);Sx===null?Sx=Us(t).setGroup(ye).setName("cameraProjectionMatrices"):Sx.array=t,e=Sx.element(r.isMultiViewCamera?Ni("gl_ViewID_OVR"):fr)}else pA===null&&(pA=xe(r.projectionMatrix).setName("cameraProjectionMatrix").setGroup(ye).onRenderUpdate(({camera:t})=>t.projectionMatrix)),e=pA;return e}).once()(),tN=F(({camera:r})=>{let e;if(r.isArrayCamera&&r.cameras.length>0){let t=[];for(let s of r.cameras)t.push(s.projectionMatrixInverse);Nx===null?Nx=Us(t).setGroup(ye).setName("cameraProjectionMatricesInverse"):Nx.array=t,e=Nx.element(r.isMultiViewCamera?Ni("gl_ViewID_OVR"):fr)}else mA===null&&(mA=xe(r.projectionMatrixInverse).setName("cameraProjectionMatrixInverse").setGroup(ye).onRenderUpdate(({camera:t})=>t.projectionMatrixInverse)),e=mA;return e}).once()(),Ua=F(({camera:r})=>{let e;if(r.isArrayCamera&&r.cameras.length>0){let t=[];for(let s of r.cameras)t.push(s.matrixWorldInverse);Rx===null?Rx=Us(t).setGroup(ye).setName("cameraViewMatrices"):Rx.array=t,e=Rx.element(r.isMultiViewCamera?Ni("gl_ViewID_OVR"):fr)}else bA===null&&(bA=xe(r.matrixWorldInverse).setName("cameraViewMatrix").setGroup(ye).onRenderUpdate(({camera:t})=>t.matrixWorldInverse)),e=bA;return e}).once()(),Yl=F(({camera:r})=>{let e;if(r.isArrayCamera&&r.cameras.length>0){let t=[];for(let s of r.cameras)t.push(s.matrixWorld);Ex===null?Ex=Us(t).setGroup(ye).setName("cameraWorldMatrices"):Ex.array=t,e=Ex.element(r.isMultiViewCamera?Ni("gl_ViewID_OVR"):fr)}else gA===null&&(gA=xe(r.matrixWorld).setName("cameraWorldMatrix").setGroup(ye).onRenderUpdate(({camera:t})=>t.matrixWorld)),e=gA;return e}).once()(),JO=F(({camera:r})=>{let e;if(r.isArrayCamera&&r.cameras.length>0){let t=[];for(let s of r.cameras)t.push(s.normalMatrix);Cx===null?Cx=Us(t).setGroup(ye).setName("cameraNormalMatrices"):Cx.array=t,e=Cx.element(r.isMultiViewCamera?Ni("gl_ViewID_OVR"):fr)}else yA===null&&(yA=xe(r.normalMatrix).setName("cameraNormalMatrix").setGroup(ye).onRenderUpdate(({camera:t})=>t.normalMatrix)),e=yA;return e}).once()(),_d=F(({camera:r})=>{let e;if(r.isArrayCamera&&r.cameras.length>0){let t=[];for(let s=0,n=r.cameras.length;s<n;s++)t.push(new E);kx===null?kx=Us(t).setGroup(ye).setName("cameraPositions").onRenderUpdate(({camera:s},n)=>{let a=s.cameras,i=n.array;for(let o=0,c=a.length;o<c;o++)i[o].setFromMatrixPosition(a[o].matrixWorld)}):kx.array=t,e=kx.element(r.isMultiViewCamera?Ni("gl_ViewID_OVR"):fr)}else xA===null&&(xA=xe(new E).setName("cameraPosition").setGroup(ye).onRenderUpdate(({camera:t},s)=>s.value.setFromMatrixPosition(t.matrixWorld))),e=xA;return e}).once()(),h0=F(({camera:r})=>{let e;if(r.isArrayCamera&&r.cameras.length>0){let t=[];for(let s of r.cameras)t.push(s.viewport);Ix===null?Ix=Us(t,"vec4").setGroup(ye).setName("cameraViewports"):Ix.array=t,e=Ix.element(fr)}else wA===null&&(wA=ce(0,0,kd.x,kd.y).toConst("cameraViewport")),e=wA;return e}).once()(),YC=new jt,Yt=class r extends we{static get type(){return"Object3DNode"}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=Me.OBJECT,this.uniformNode=new ac(null)}generateNodeType(){let e=this.scope;if(e===r.WORLD_MATRIX)return"mat4";if(e===r.POSITION||e===r.VIEW_POSITION||e===r.DIRECTION||e===r.SCALE)return"vec3";if(e===r.RADIUS)return"float"}update(e){let t=this.object3d,s=this.uniformNode,n=this.scope;if(n===r.WORLD_MATRIX)s.value=t.matrixWorld;else if(n===r.POSITION)s.value=s.value||new E,s.value.setFromMatrixPosition(t.matrixWorld);else if(n===r.SCALE)s.value=s.value||new E,s.value.setFromMatrixScale(t.matrixWorld);else if(n===r.DIRECTION)s.value=s.value||new E,t.getWorldDirection(s.value);else if(n===r.VIEW_POSITION){let a=e.camera;s.value=s.value||new E,s.value.setFromMatrixPosition(t.matrixWorld),s.value.applyMatrix4(a.matrixWorldInverse)}else if(n===r.RADIUS){let a=e.object.geometry;a.boundingSphere===null&&a.computeBoundingSphere(),YC.copy(a.boundingSphere).applyMatrix4(t.matrixWorld),s.value=YC.radius}}generate(e){let t=this.scope;return t===r.WORLD_MATRIX?this.uniformNode.nodeType="mat4":t===r.POSITION||t===r.VIEW_POSITION||t===r.DIRECTION||t===r.SCALE?this.uniformNode.nodeType="vec3":t===r.RADIUS&&(this.uniformNode.nodeType="float"),this.uniformNode.build(e)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}};Yt.WORLD_MATRIX="worldMatrix";Yt.POSITION="position";Yt.SCALE="scale";Yt.VIEW_POSITION="viewPosition";Yt.DIRECTION="direction";Yt.RADIUS="radius";var $O=He(Yt,Yt.DIRECTION).setParameterLength(1),YO=He(Yt,Yt.WORLD_MATRIX).setParameterLength(1),ZO=He(Yt,Yt.POSITION).setParameterLength(1),QO=He(Yt,Yt.SCALE).setParameterLength(1),eU=He(Yt,Yt.VIEW_POSITION).setParameterLength(1),tU=He(Yt,Yt.RADIUS).setParameterLength(1),ZC=new le,kn=class extends Yt{static get type(){return"ModelNode"}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}},sU=ie(kn,kn.DIRECTION),da=ie(kn,kn.WORLD_MATRIX),nU=ie(kn,kn.POSITION),aU=ie(kn,kn.SCALE),iU=ie(kn,kn.VIEW_POSITION),$9=ie(kn,kn.RADIUS),Y9=xe(new Fs).onObjectUpdate(({object:r},e)=>e.value.getNormalMatrix(r.matrixWorld)),Z9=xe(new le).onObjectUpdate(({object:r},e)=>e.value.copy(r.matrixWorld).invert()),or=F(r=>r.context.modelViewMatrix||Q9).once()().toVar("modelViewMatrix"),Q9=Ua.mul(da),nM=F(r=>{r.context.isHighPrecisionModelViewMatrix=!0;let e=r.camera,t;if(e.isArrayCamera&&e.cameras.length>0){let s=[];for(let a=0;a<e.cameras.length;a++)s.push(new le);t=Us(s).onObjectUpdate(({object:a,camera:i},o)=>{let c=i.cameras,l=o.array;for(let h=0,u=c.length;h<u;h++)l[h].multiplyMatrices(c[h].matrixWorldInverse,a.matrixWorld)}).element(e.isMultiViewCamera?Ni("gl_ViewID_OVR"):fr)}else t=xe("mat4").onObjectUpdate(({object:s,camera:n})=>s.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,s.matrixWorld));return t}).once()().toVar("highpModelViewMatrix"),aM=F(r=>{let e=r.context.isHighPrecisionModelViewMatrix,t=r.camera,s;if(t.isArrayCamera&&t.cameras.length>0){let n=[];for(let i=0;i<t.cameras.length;i++)n.push(new Fs);s=Us(n).onObjectUpdate(({object:i,camera:o},c)=>{let l=o.cameras,h=c.array;for(let u=0,d=l.length;u<d;u++)ZC.multiplyMatrices(l[u].matrixWorldInverse,i.matrixWorld),h[u].getNormalMatrix(ZC)}).element(t.isMultiViewCamera?Ni("gl_ViewID_OVR"):fr)}else s=xe("mat3").onObjectUpdate(({object:n,camera:a})=>(e!==!0&&n.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,n.matrixWorld),n.normalMatrix.getNormalMatrix(n.modelViewMatrix)));return s}).once()().toVar("highpModelNormalViewMatrix"),eB=F(r=>r.shaderStage!=="fragment"?(je("TSL: `clipSpace` is only available in fragment stage."),ce()):r.context.clipSpace.toVarying("v_clipSpace")).once()(),vs=Rn("position","vec3"),Ct=vs.toVarying("positionLocal"),cr=vs.toVarying("positionPrevious"),Vn=F(r=>da.mul(Ct).xyz.toVarying(r.getSubBuildProperty("v_positionWorld")),"vec3").once(["POSITION"])(),sN=F(()=>Ct.transformDirection(da).toVarying("v_positionWorldDirection").normalize().toVar("positionWorldDirection"),"vec3").once(["POSITION"])(),$t=F(r=>{if(r.shaderStage==="fragment"&&r.material.vertexNode){let e=tN.mul(eB);return e.xyz.div(e.w).toVar("positionView")}return r.context.setupPositionView().toVarying("v_positionView")},"vec3").once(["POSITION","VERTEX"])(),yt=F(r=>{let e;return r.camera.isOrthographicCamera?e=C(0,0,1):e=$t.negate().toVarying("v_positionViewDirection").normalize(),e.toVar("positionViewDirection")},"vec3").once(["POSITION"])(),q0=class extends we{static get type(){return"FrontFacingNode"}constructor(){super("bool"),this.isFrontFacingNode=!0}generate(e){if(e.shaderStage!=="fragment")return"true";let{material:t}=e;return t.side===Xt?"false":e.getFrontFacing()}},tB=ie(q0),nN=S(tB).mul(2).sub(1),Zl=F(([r],{material:e})=>{let t=e.side;return t===Xt?r=r.mul(-1):t===rn&&(r=r.mul(nN)),r}),rU=r=>(je('TSL: "directionToFaceDirection()" has been renamed to "negateOnBackSide()".'),Zl(r)),aN=Rn("normal","vec3"),pn=F(r=>r.geometry.hasAttribute("normal")===!1?(K('TSL: Vertex attribute "normal" not found on geometry.'),C(0,1,0)):aN,"vec3").once()().toVar("normalLocal"),sB=$t.dFdx().cross($t.dFdy()).normalize().toVar("normalFlat"),Id=F(r=>{let e;return r.isFlatShading()?e=sB:e=rN(pn).toVarying("v_normalViewGeometry").normalize(),e},"vec3").once()().toVar("normalViewGeometry"),nB=F(r=>{let e=Id.transformNormalByInverseViewMatrix(Ua);return r.isFlatShading()!==!0&&(e=e.toVarying("v_normalWorldGeometry")),e.normalize().toVar("normalWorldGeometry")},"vec3").once()(),Qe=F(r=>{let e;return r.subBuildFn==="NORMAL"||r.subBuildFn==="VERTEX"?(e=Id,r.isFlatShading()!==!0&&(e=Zl(e))):e=r.context.setupNormal().context({getUV:null,getTextureLevel:null}),e},"vec3").once(["NORMAL","VERTEX"])().toVar("normalView"),gc=Qe.transformNormalByInverseViewMatrix(Ua).toVar("normalWorld"),$o=F(({subBuildFn:r,context:e})=>{let t;return r==="NORMAL"||r==="VERTEX"?t=Qe:t=e.setupClearcoatNormal().context({getUV:null,getTextureLevel:null}),t},"vec3").once(["NORMAL","VERTEX"])().toVar("clearcoatNormalView"),iN=F(([r,e=da])=>Ms(e).inverse().transpose().mul(r).normalize());G("transformNormal",iN);var rN=F(([r],e)=>{let t=e.context.modelNormalViewMatrix;return t?r.transformNormalByViewMatrix(t):Y9.mul(r).transformNormalByViewMatrix(Ua)}),oU=F(()=>(K('TSL: "transformedNormalView" is deprecated. Use "normalView" instead.'),Qe)).once(["NORMAL","VERTEX"])(),cU=F(()=>(K('TSL: "transformedNormalWorld" is deprecated. Use "normalWorld" instead.'),gc)).once(["NORMAL","VERTEX"])(),lU=F(()=>(K('TSL: "transformedClearcoatNormalView" is deprecated. Use "clearcoatNormalView" instead.'),$o)).once(["NORMAL","VERTEX"])(),TA=new le,aB=xe(0).onReference(({material:r})=>r).onObjectUpdate(({material:r})=>r.refractionRatio),gm=xe(1).onReference(({material:r})=>r).onObjectUpdate(function({material:r,scene:e}){return r.envMap?r.envMapIntensity:e.environmentIntensity}),X0=xe(new le).onReference(function(r){return r.material}).onObjectUpdate(function({material:r,scene:e}){let s=(e.environment!==null||e.environmentNode&&e.environmentNode.isNode)&&r.envMap===null?e.environmentRotation:r.envMapRotation;return s?TA.makeRotationFromEuler(s).transpose():TA.identity(),TA}),iB=yt.negate().reflect(Qe),rB=yt.negate().refract(Qe,aB),oB=iB.transformDirection(Yl).toVar("reflectVector"),cB=rB.transformDirection(Yl).toVar("refractVector"),lB=new Pi,K0=class extends ba{static get type(){return"CubeTextureNode"}constructor(e,t=null,s=null,n=null){super(e,t,s,n),this.isCubeTextureNode=!0}getInputType(){return this.value.isDepthTexture===!0?"cubeDepthTexture":"cubeTexture"}getDefaultUV(){let e=this.value;return e.mapping===Wi?oB:e.mapping===ol?cB:(W('CubeTextureNode: Mapping "%s" not supported.',e.mapping),C(0,0,0))}setUpdateMatrix(){}setupUV(e,t){let s=this.value;return s.isDepthTexture===!0?e.renderer.coordinateSystem===Xs?C(t.x,t.y.negate(),t.z):t:(t=X0.mul(t),(e.renderer.coordinateSystem===Xs||!s.isRenderTargetTexture)&&(t=C(t.x.negate(),t.yz)),t)}generateUV(e,t){return t.build(e,this.sampler===!0?"vec3":"ivec3")}},oN=He(K0).setParameterLength(1,4).setName("cubeTexture"),Nn=(r=lB,e=null,t=null,s=null)=>{let n;return r&&r.isCubeTextureNode===!0?(n=pe(r.clone()),n.referenceNode=r,e!==null&&(n.uvNode=pe(e)),t!==null&&(n.levelNode=pe(t)),s!==null&&(n.biasNode=pe(s))):n=oN(r,e,t,s),n},hU=(r=lB)=>oN(r),jl=class extends we{static get type(){return"ReferenceNode"}constructor(e,t,s=null,n=null){super(),this.property=e,this.uniformType=t,this.object=s,this.count=n,this.properties=e.split("."),this.reference=s,this.node=null,this.group=null,this.name=null,this.updateType=Me.OBJECT}element(e){return new Dm(this,pe(e))}setGroup(e){return this.group=e,this}setName(e){return this.name=e,this}label(e){return K('TSL: "label()" has been deprecated. Use "setName()" instead.'),this.setName(e)}setNodeType(e){let t=null;this.count!==null?t=Yd(null,e,this.count):Array.isArray(this.getValueFromReference())?(t=Us(null,e),t.updateType=Me.OBJECT):e==="texture"?t=et(null):e==="cubeTexture"?t=Nn(null):t=xe(null,e),this.group!==null&&t.setGroup(this.group),this.name!==null&&t.setName(this.name),this.node=t}generateNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){let{properties:t}=this,s=e[t[0]];for(let n=1;n<t.length;n++)s=s[t[n]];return s}updateReference(e){return this.reference=this.object!==null?this.object:e.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);let e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}},Et=(r,e,t)=>new jl(r,e,t),hB=(r,e,t,s)=>new jl(r,e,s,t),J0=class extends jl{static get type(){return"MaterialReferenceNode"}constructor(e,t,s=null){super(e,t,s),this.material=s,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=this.material!==null?this.material:e.material,this.reference}},Qr=(r,e,t=null)=>new J0(r,e,t),uB=ot(),uU=$t.dFdx(),dU=$t.dFdy(),dB=uB.dFdx(),fB=uB.dFdy(),pB=Qe,mB=dU.cross(pB),bB=pB.cross(uU),iM=mB.mul(dB.x).add(bB.mul(fB.x)),rM=mB.mul(dB.y).add(bB.mul(fB.y)),QC=iM.dot(iM).max(rM.dot(rM)),gB=QC.equal(0).select(0,QC.inverseSqrt()),yB=iM.mul(gB).toVar("tangentViewFrame"),xB=rM.mul(gB).toVar("bitangentViewFrame"),qT=Rn("tangent","vec4"),rc=qT.xyz.toVar("tangentLocal"),XT=F(r=>{let e;return r.subBuildFn==="VERTEX"||r.geometry.hasAttribute("tangent")?e=or.mul(ce(rc,0)).xyz.toVarying("v_tangentView").normalize():e=yB,r.isFlatShading()!==!0&&(e=Zl(e)),e},"vec3").once(["NORMAL","VERTEX"])().toVar("tangentView"),wB=XT.transformDirection(Yl).toVarying("v_tangentWorld").normalize().toVar("tangentWorld"),KT=F(([r,e],t)=>{let s=r.mul(qT.w).xyz;return t.subBuildFn==="NORMAL"&&t.isFlatShading()!==!0&&(s=s.toVarying(e)),s}).once(["NORMAL"]),fU=KT(aN.cross(qT),"v_bitangentGeometry").normalize().toVar("bitangentGeometry"),pU=KT(pn.cross(rc),"v_bitangentLocal").normalize().toVar("bitangentLocal"),TB=F(r=>{let e;return r.subBuildFn==="VERTEX"||r.geometry.hasAttribute("tangent")?e=KT(Qe.cross(XT),"v_bitangentView").normalize():e=xB,r.isFlatShading()!==!0&&(e=Zl(e)),e},"vec3").once(["NORMAL","VERTEX"])().toVar("bitangentView"),mU=KT(gc.cross(wB),"v_bitangentWorld").normalize().toVar("bitangentWorld"),Rl=Ms(XT,TB,Qe).toVar("TBNViewMatrix"),vB=yt.mul(Rl),bU=(r,e)=>r.sub(vB.mul(e)),_B=F(()=>{let r=Il.cross(yt);return r=r.cross(Il).normalize(),r=Ke(r,Qe,Ko.mul(Oa.oneMinus()).oneMinus().pow2().pow2()).normalize(),r}).once()(),cN=r=>pe(r).mul(.5).add(.5),AB=r=>pe(r).mul(2).sub(1),oM=r=>C(r,fn(jT(S(1).sub(Gn(r,r))))),gU=r=>(je('TSL: "directionToColor()" has been renamed to "packNormalToRGB()".'),cN(r)),yU=r=>(je('TSL: "colorToDirection()" has been renamed to "unpackRGBToNormal()".'),AB(r)),$0=class extends xt{static get type(){return"NormalMapNode"}constructor(e,t=null){super("vec3"),this.node=e,this.scaleNode=t,this.normalMapType=aa,this.unpackNormalMode=Jp}setup(e){let{normalMapType:t,scaleNode:s,unpackNormalMode:n}=this,a=this.node.mul(2).sub(1);if(t===aa?n===gx?a=oM(a.xy):n===q_?a=oM(a.yw):n!==Jp&&W(`THREE.NodeMaterial: Unexpected unpack normal mode: ${n}`):n!==Jp&&W(`THREE.NodeMaterial: Normal map type '${t}' is not compatible with unpack normal mode '${n}'`),s!==null){let o=s;e.isFlatShading()===!0&&(o=Zl(o)),a=C(a.xy.mul(o),a.z)}let i=null;return t===Kp?i=rN(a):t===aa?i=Rl.mul(a).normalize():(W(`NodeMaterial: Unsupported normal map type: ${t}`),i=Qe),i}},cM=He($0).setParameterLength(1,2),xU=F(({textureNode:r,bumpScale:e})=>{let t=n=>r.isolate().context({getUV:a=>n(a.uvNode||ot()),forceUVContext:!0}),s=S(t(n=>n));return Z(S(t(n=>n.add(n.dFdx()))).sub(s),S(t(n=>n.add(n.dFdy()))).sub(s)).mul(e)}),wU=F(r=>{let{surf_pos:e,surf_norm:t,dHdxy:s}=r,n=e.dFdx().normalize(),a=e.dFdy().normalize(),i=t,o=a.cross(i),c=i.cross(n),l=n.dot(o).mul(nN),h=l.sign().mul(s.x.mul(o).add(s.y.mul(c)));return l.abs().mul(t).sub(h).normalize()}),Y0=class extends xt{static get type(){return"BumpMapNode"}constructor(e,t=null){super("vec3"),this.textureNode=e,this.scaleNode=t}setup(e){if(e.material.wireframe===!0)return Qe;let t=this.scaleNode!==null?this.scaleNode:1,s=xU({textureNode:this.textureNode,bumpScale:t});return wU({surf_pos:$t,surf_norm:Qe,dHdxy:s})}},MB=He(Y0).setParameterLength(1,2),ek=new Map,$=class r extends we{static get type(){return"MaterialNode"}constructor(e){super(),this.scope=e}getCache(e,t){let s=ek.get(e);return s===void 0&&(s=Qr(e,t),ek.set(e,s)),s}getFloat(e){return this.getCache(e,"float")}getColor(e){return this.getCache(e,"color")}getTexture(e){return this.getCache(e==="map"?"map":e+"Map","texture")}setup(e){let t=e.context.material,s=this.scope,n=null;if(s===r.COLOR){let a=t.color!==void 0?this.getColor(s):C();t.map&&t.map.isTexture===!0?n=a.mul(this.getTexture("map")):n=a}else if(s===r.OPACITY){let a=this.getFloat(s);t.alphaMap&&t.alphaMap.isTexture===!0?n=a.mul(this.getTexture("alpha")):n=a}else if(s===r.SPECULAR_STRENGTH)t.specularMap&&t.specularMap.isTexture===!0?n=this.getTexture("specular").r:n=S(1);else if(s===r.SPECULAR_INTENSITY){let a=this.getFloat(s);t.specularIntensityMap&&t.specularIntensityMap.isTexture===!0?n=a.mul(this.getTexture(s).a):n=a}else if(s===r.SPECULAR_COLOR){let a=this.getColor(s);t.specularColorMap&&t.specularColorMap.isTexture===!0?n=a.mul(this.getTexture(s).rgb):n=a}else if(s===r.ROUGHNESS){let a=this.getFloat(s);t.roughnessMap&&t.roughnessMap.isTexture===!0?n=a.mul(this.getTexture(s).g):n=a}else if(s===r.METALNESS){let a=this.getFloat(s);t.metalnessMap&&t.metalnessMap.isTexture===!0?n=a.mul(this.getTexture(s).b):n=a}else if(s===r.EMISSIVE){let a=this.getFloat("emissiveIntensity"),i=this.getColor(s).mul(a);t.emissiveMap&&t.emissiveMap.isTexture===!0?n=i.mul(this.getTexture(s)):n=i}else if(s===r.NORMAL)t.normalMap?(n=cM(this.getTexture("normal"),this.getCache("normalScale","vec2")),n.normalMapType=t.normalMapType,(t.normalMap.format==cn||t.normalMap.format==jr||t.normalMap.format==Vr)&&(n.unpackNormalMode=gx)):t.bumpMap?n=MB(this.getTexture("bump").r,this.getFloat("bumpScale")):n=Qe;else if(s===r.CLEARCOAT){let a=this.getFloat(s);t.clearcoatMap&&t.clearcoatMap.isTexture===!0?n=a.mul(this.getTexture(s).r):n=a}else if(s===r.CLEARCOAT_ROUGHNESS){let a=this.getFloat(s);t.clearcoatRoughnessMap&&t.clearcoatRoughnessMap.isTexture===!0?n=a.mul(this.getTexture(s).r):n=a}else if(s===r.CLEARCOAT_NORMAL)t.clearcoatNormalMap?n=cM(this.getTexture(s),this.getCache(s+"Scale","vec2")):n=Qe;else if(s===r.SHEEN){let a=this.getColor("sheenColor").mul(this.getFloat("sheen"));t.sheenColorMap&&t.sheenColorMap.isTexture===!0?n=a.mul(this.getTexture("sheenColor").rgb):n=a}else if(s===r.SHEEN_ROUGHNESS){let a=this.getFloat(s);t.sheenRoughnessMap&&t.sheenRoughnessMap.isTexture===!0?n=a.mul(this.getTexture(s).a):n=a,n=n.clamp(1e-4,1)}else if(s===r.ANISOTROPY)if(t.anisotropyMap&&t.anisotropyMap.isTexture===!0){let a=this.getTexture(s);n=DT(md.x,md.y,md.y.negate(),md.x).mul(a.rg.mul(2).sub(Z(1)).normalize().mul(a.b))}else n=md;else if(s===r.IRIDESCENCE_THICKNESS){let a=Et("1","float",t.iridescenceThicknessRange);if(t.iridescenceThicknessMap){let i=Et("0","float",t.iridescenceThicknessRange);n=a.sub(i).mul(this.getTexture(s).g).add(i)}else n=a}else if(s===r.TRANSMISSION){let a=this.getFloat(s);t.transmissionMap?n=a.mul(this.getTexture(s).r):n=a}else if(s===r.THICKNESS){let a=this.getFloat(s);t.thicknessMap?n=a.mul(this.getTexture(s).g):n=a}else if(s===r.IOR)n=this.getFloat(s);else if(s===r.LIGHT_MAP)t.lightMap?n=this.getTexture(s).rgb.mul(this.getFloat("lightMapIntensity")):n=C(0);else if(s===r.AO)t.aoMap?n=this.getTexture(s).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1):n=S(1);else if(s===r.LINE_DASH_OFFSET)n=t.dashOffset?this.getFloat(s):S(0);else{let a=this.getNodeType(e);n=this.getCache(s,a)}return n}};$.ALPHA_TEST="alphaTest";$.COLOR="color";$.OPACITY="opacity";$.SHININESS="shininess";$.SPECULAR="specular";$.SPECULAR_STRENGTH="specularStrength";$.SPECULAR_INTENSITY="specularIntensity";$.SPECULAR_COLOR="specularColor";$.REFLECTIVITY="reflectivity";$.ROUGHNESS="roughness";$.METALNESS="metalness";$.NORMAL="normal";$.CLEARCOAT="clearcoat";$.CLEARCOAT_ROUGHNESS="clearcoatRoughness";$.CLEARCOAT_NORMAL="clearcoatNormal";$.EMISSIVE="emissive";$.ROTATION="rotation";$.SHEEN="sheen";$.SHEEN_ROUGHNESS="sheenRoughness";$.ANISOTROPY="anisotropy";$.IRIDESCENCE="iridescence";$.IRIDESCENCE_IOR="iridescenceIOR";$.IRIDESCENCE_THICKNESS="iridescenceThickness";$.IOR="ior";$.TRANSMISSION="transmission";$.THICKNESS="thickness";$.ATTENUATION_DISTANCE="attenuationDistance";$.ATTENUATION_COLOR="attenuationColor";$.LINE_SCALE="scale";$.LINE_DASH_SIZE="dashSize";$.LINE_GAP_SIZE="gapSize";$.LINE_WIDTH="linewidth";$.LINE_DASH_OFFSET="dashOffset";$.POINT_SIZE="size";$.DISPERSION="dispersion";$.RETROREFLECTIVITY="retroreflectivity";$.LIGHT_MAP="light";$.AO="ao";var SB=ie($,$.ALPHA_TEST),NB=ie($,$.COLOR),RB=ie($,$.SHININESS),EB=ie($,$.EMISSIVE),lN=ie($,$.OPACITY),CB=ie($,$.SPECULAR),kB=ie($,$.SPECULAR_INTENSITY),IB=ie($,$.SPECULAR_COLOR),Am=ie($,$.SPECULAR_STRENGTH),u0=ie($,$.REFLECTIVITY),BB=ie($,$.ROUGHNESS),FB=ie($,$.METALNESS),PB=ie($,$.NORMAL),DB=ie($,$.CLEARCOAT),OB=ie($,$.CLEARCOAT_ROUGHNESS),UB=ie($,$.CLEARCOAT_NORMAL),LB=ie($,$.ROTATION),zB=ie($,$.SHEEN),VB=ie($,$.SHEEN_ROUGHNESS),jB=ie($,$.ANISOTROPY),GB=ie($,$.IRIDESCENCE),HB=ie($,$.IRIDESCENCE_IOR),WB=ie($,$.IRIDESCENCE_THICKNESS),qB=ie($,$.TRANSMISSION),XB=ie($,$.THICKNESS),KB=ie($,$.IOR),JB=ie($,$.ATTENUATION_DISTANCE),$B=ie($,$.ATTENUATION_COLOR),hN=ie($,$.LINE_SCALE),uN=ie($,$.LINE_DASH_SIZE),dN=ie($,$.LINE_GAP_SIZE),Z0=ie($,$.LINE_WIDTH),fN=ie($,$.LINE_DASH_OFFSET),YB=ie($,$.POINT_SIZE),ZB=ie($,$.DISPERSION),QB=ie($,$.RETROREFLECTIVITY),pN=ie($,$.LIGHT_MAP),eF=ie($,$.AO),md=xe(new q).onReference(function(r){return r.material}).onRenderUpdate(function({material:r}){this.value.set(r.anisotropy*Math.cos(r.anisotropyRotation),r.anisotropy*Math.sin(r.anisotropyRotation))}),tF=F(r=>r.context.setupModelViewProjection(),"vec4").once()().toVarying("v_modelViewProjection"),Zt=class r extends we{static get type(){return"EventNode"}constructor(e,t){super("void"),this.eventType=e,this.callback=t,e===r.OBJECT?this.updateType=Me.OBJECT:e===r.MATERIAL?this.updateType=Me.RENDER:e===r.FRAME?this.updateType=Me.FRAME:e===r.AFTER_OBJECT?this.updateAfterType=Me.OBJECT:e===r.BEFORE_OBJECT?this.updateBeforeType=Me.OBJECT:e===r.BEFORE_MATERIAL?this.updateBeforeType=Me.RENDER:e===r.BEFORE_FRAME&&(this.updateBeforeType=Me.FRAME)}setup(e){let{eventType:t,callback:s}=this;if(t===r.BEFORE_RENDER_PIPELINE){let n=e.context.onBeforePipelineCallbacks;n&&n.push(s)}else if(t===r.AFTER_RENDER_PIPELINE){let n=e.context.onAfterPipelineCallbacks;n&&n.push(s)}return super.setup(e)}update(e){this.callback(e)}updateBefore(e){this.callback(e)}updateAfter(e){this.callback(e)}};Zt.OBJECT="object";Zt.MATERIAL="material";Zt.FRAME="frame";Zt.AFTER_OBJECT="afterObject";Zt.BEFORE_OBJECT="beforeObject";Zt.BEFORE_MATERIAL="beforeMaterial";Zt.BEFORE_FRAME="beforeFrame";Zt.BEFORE_RENDER_PIPELINE="beforeRenderPipeline";Zt.AFTER_RENDER_PIPELINE="afterRenderPipeline";var oo=(r,e)=>new Zt(r,e).toStack(),vb=r=>oo(Zt.OBJECT,r),TU=r=>oo(Zt.MATERIAL,r),vU=r=>oo(Zt.FRAME,r),mN=r=>oo(Zt.AFTER_OBJECT,r),_U=r=>oo(Zt.BEFORE_OBJECT,r),AU=r=>oo(Zt.BEFORE_MATERIAL,r),sF=r=>oo(Zt.BEFORE_FRAME,r),MU=r=>oo(Zt.BEFORE_RENDER_PIPELINE,r),SU=r=>oo(Zt.AFTER_RENDER_PIPELINE,r),Q0=class extends no{static get type(){return"StorageArrayElementNode"}constructor(e,t){super(e,t),this.isStorageArrayElementNode=!0}set storageBufferNode(e){this.node=e}get storageBufferNode(){return this.node}getMemberType(e,t){let s=this.storageBufferNode.structTypeNode;return s?s.getMemberType(e,t):"void"}setup(e){return e.isAvailable("storageBuffer")===!1&&this.node.isPBO===!0&&e.setupPBO(this.node),super.setup(e)}generate(e,t){let s,n=e.isContextAssign();if(e.isAvailable("storageBuffer")===!1?this.node.isPBO===!0&&n!==!0&&(this.node.value.isInstancedBufferAttribute||e.shaderStage!=="compute")?s=e.generatePBO(this):s=this.node.build(e):s=super.generate(e),n!==!0){let a=this.getNodeType(e);s=e.format(s,a,t)}return s}},nF=He(Q0).setParameterLength(2),ew=class extends Cd{static get type(){return"StorageBufferNode"}constructor(e,t=null,s=0){let n,a=null;t&&t.isStructTypeNode?(n="struct",a=t,(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(s=e.count)):t===null&&(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)?(n=CT(e.itemSize),s=e.count):n=t,super(e,n,s),this.isStorageBufferNode=!0,this.structTypeNode=a,this.access=As.READ_WRITE,this.isAtomic=!1,this.isPBO=!1,this._attribute=null,this._varying=null,this.global=!0,e.isStorageBufferAttribute!==!0&&e.isStorageInstancedBufferAttribute!==!0&&(e.isInstancedBufferAttribute?e.isStorageInstancedBufferAttribute=!0:e.isStorageBufferAttribute=!0)}getHash(e){let t;if(this.bufferCount===0){let s=e.globalCache.getData(this.value);s===void 0&&(s={node:this},e.globalCache.setData(this.value,s)),t=s.node.id}else t=this.id;return String(t)}getInputType(){return this.value.isIndirectStorageBufferAttribute?"indirectStorageBuffer":"storageBuffer"}element(e){return nF(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(As.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return this._attribute===null&&(this._attribute=q1(this.value),this._varying=bc(this._attribute)),{attribute:this._attribute,varying:this._varying}}generateNodeType(e){if(this.structTypeNode!==null)return this.structTypeNode.getNodeType(e);if(e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.generateNodeType(e);let{attribute:t}=this.getAttributeData();return t.getNodeType(e)}getMemberType(e,t){return this.structTypeNode!==null?this.structTypeNode.getMemberType(e,t):"void"}generate(e){if(this.structTypeNode!==null&&this.structTypeNode.build(e),e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.generate(e);let{attribute:t,varying:s}=this.getAttributeData(),n=s.build(e);return e.registerTransform(n,t),n}},tc=(r,e=null,t=0)=>new ew(r,e,t),tw=new WeakMap,tk=new WeakMap,lM=new WeakMap;function aF(r,e){let t,s=Math.max(e.count,1);if(e.isStorageInstancedBufferAttribute===!0)t=tc(e,"mat4",s).element(_i);else if(s*16*4<=r.getUniformBufferLimit())t=Yd(e.array,"mat4",s).element(_i);else{let i=tw.get(e);i||(i=new Dp(e.array,16,1),tw.set(e,i));let o=e.usage===Gr?X1:WT,c=[o(i,"vec4",16,0),o(i,"vec4",16,4),o(i,"vec4",16,8),o(i,"vec4",16,12)];t=so(...c)}return t}function NU(r,e,t){let s=lM.get(r);if(s===void 0){let n=e.clone();s={previousInstanceMatrix:n,node:aF(t,n)},lM.set(r,s)}return s.node}var bN=mc("vec3","vInstanceColor"),iF=F(([r,e=null],t)=>{let s=r.isStorageInstancedBufferAttribute===!0,n=e&&e.isStorageInstancedBufferAttribute===!0,a=aF(t,r),i=null;s||Math.max(r.count,1)*16*4>t.getUniformBufferLimit()&&(i=tw.get(r));let o=null,c=null;if(e)if(n)o=tc(e,"vec3",Math.max(e.count,1)).element(_i);else{let h=tk.get(e);h||(h=new ys(e.array,3),tk.set(e,h)),c=h;let u=e.usage===Gr?X1:WT;o=C(u(h,"vec3",3,0))}(i!==null||c!==null)&&sF(()=>{i!==null&&i.version!==r.version&&(i.clearUpdateRanges(),i.updateRanges.push(...r.updateRanges),r.clearUpdateRanges(),i.version=r.version),e&&c!==null&&c.version!==e.version&&(c.clearUpdateRanges(),c.updateRanges.push(...e.updateRanges),e.clearUpdateRanges(),c.version=e.version)});let l=a.mul(Ct).xyz;if(Ct.assign(l),t.needsPreviousData()){let h=t.object;mN(({object:d})=>{let{previousInstanceMatrix:f}=lM.get(d);f.array.set(r.array),f.version=r.version;let p=tw.get(f);p!==void 0&&(p.version=r.version)});let u=NU(h,r,t);cr.assign(u.mul(cr).xyz)}if(t.hasGeometryAttribute("normal")){let h=iN(pn,a);pn.assign(h)}o!==null&&bN.assign(o)},"void"),rF=F(([r])=>{let{instanceMatrix:e,instanceColor:t}=r;iF(e,t)},"void"),hM=new WeakMap,RU=F(([r,e])=>{let t=k(ic(Jt(r),0).x).toConst(),s=k(e),n=s.mod(t).toConst(),a=s.div(t).toConst();return Jt(r,Dt(n,a))}),EU=F(([r,e])=>{let t=k(ic(Jt(r),0).x).toConst(),s=k(e).mod(t).toConst(),n=k(e).div(t).toConst();return Jt(r,Dt(s,n)).x});function oF(r,e){let t=k(ic(Jt(r),0).x).toConst(),s=S(e).mul(4).toInt().toConst(),n=s.mod(t).toConst(),a=s.div(t).toConst();return so(Jt(r,Dt(n,a)),Jt(r,Dt(n.add(1),a)),Jt(r,Dt(n.add(2),a)),Jt(r,Dt(n.add(3),a)))}function CU(r,e){let t=hM.get(r);if(t===void 0){let{image:s,format:n,type:a}=r._matricesTexture,i=new Is(s.data.slice(),s.width,s.height,n,a);t={previousMatricesTexture:i,node:oF(i,e)},hM.set(r,t)}return t.node}var gN=mc("vec4","vBatchColor"),cF=mc("uint","vBatchIndirectId"),lF=F(([r],e)=>{let t=e.getDrawIndex()===null?_i:z9,s=EU(r._indirectTexture,k(t));cF.assign(s);let n=oF(r._matricesTexture,s),a=r._colorsTexture;if(a!==null){let l=RU(a,s);gN.assign(l)}let i=Ms(n);if(Ct.assign(n.mul(Ct)),e.needsPreviousData()){mN(({object:h})=>{let u=hM.get(h);u.previousMatricesTexture.image.data.set(h._matricesTexture.image.data),u.previousMatricesTexture.needsUpdate=!0});let l=CU(r,s);cr.assign(l.mul(cr).xyz)}let o=pn.div(C(i[0].dot(i[0]),i[1].dot(i[1]),i[2].dot(i[2]))),c=i.mul(o).xyz;pn.assign(c),e.hasGeometryAttribute("tangent")&&rc.mulAssign(i)},"void"),sw=new WeakMap,nw=new WeakMap;function hF(r){return{element:e=>{let t=k(ic(r).x).toConst(),s=k(e).mul(4).toConst(),n=s.div(t).toConst(),a=s.sub(n.mul(t)).toConst();return so(r.load(Dt(a,n)),r.load(Dt(a.add(1),n)),r.load(Dt(a.add(2),n)),r.load(Dt(a.add(3),n)))}}}function kU(r,e){let t;if(e.bones.length*16*4<=r.getUniformBufferLimit())t=hB("skeleton.boneMatrices","mat4",e.bones.length);else{e.boneTexture===null&&e.computeBoneTexture();let n=et(e.boneTexture);vb(({object:a})=>{let i=a.skeleton;i.boneTexture===null&&i.computeBoneTexture(),n.value=i.boneTexture}),t=hF(n)}return t}function yN(r,e,t,s,n,a){let i=r.element(n.x),o=r.element(n.y),c=r.element(n.z),l=r.element(n.w),h=t.mul(e),u=lt(i.mul(a.x).mul(h),o.mul(a.y).mul(h),c.mul(a.z).mul(h),l.mul(a.w).mul(h));return s.mul(u).xyz}function uF(r,e,t,s,n,a,i){let o=r.element(a.x),c=r.element(a.y),l=r.element(a.z),h=r.element(a.w),u=lt(i.x.mul(o),i.y.mul(c),i.z.mul(l),i.w.mul(h));u=n.mul(u).mul(s);let d=Ms(u),f=d.mul(e),p=d.mul(t);return{skinNormal:f,skinTangent:p}}function dF(r,e,t,s,n,a){let i=e.skeleton,o=nw.get(i);if(o===void 0){if(i.update(),i.bones.length*16*4<=r.getUniformBufferLimit()){let l=new Float32Array(i.boneMatrices);o={previousBoneMatrices:l,previousBoneTexture:null,node:Yd(l,"mat4",i.bones.length)}}else{i.boneTexture===null&&i.computeBoneTexture();let{width:l,height:h}=i.boneTexture.image,u=new Float32Array(i.boneMatrices),d=new Is(u,l,h,gs,Mt);d.needsUpdate=!0,o={previousBoneMatrices:u,previousBoneTexture:d,node:hF(et(d))}}nw.set(i,o)}return yN(o.node,cr,t,s,n,a)}var fF=F(([r],e)=>{let t=Rn("skinIndex","uvec4"),s=Rn("skinWeight","vec4"),n=Et("bindMatrix","mat4"),a=Et("bindMatrixInverse","mat4"),i=kU(e,r.skeleton);if(vb(({object:c,frameId:l})=>{let h=c.skeleton;if(sw.get(h)!==l){sw.set(h,l);let u=nw.get(h);u!==void 0&&(u.previousBoneMatrices.set(h.boneMatrices),u.previousBoneTexture!==null&&(u.previousBoneTexture.needsUpdate=!0)),h.update()}}),e.needsPreviousData()){let c=dF(e,r,n,a,t,s);cr.assign(c)}let o=yN(i,Ct,n,a,t,s);if(Ct.assign(o),e.hasGeometryAttribute("normal")){let{skinNormal:c,skinTangent:l}=uF(i,pn,rc,n,a,t,s);pn.assign(c),e.hasGeometryAttribute("tangent")&&rc.assign(l)}},"void"),IU=F(([r,e=null],t)=>{let s=tc(new ys(r.geometry.getAttribute("position").array,3),"vec3").setPBO(!0).toReadOnly().element(_i).toVar(),n=tc(new ys(new Uint32Array(r.geometry.getAttribute("skinIndex").array),4),"uvec4").setPBO(!0).toReadOnly().element(_i).toVar(),a=tc(new ys(r.geometry.getAttribute("skinWeight").array,4),"vec4").setPBO(!0).toReadOnly().element(_i).toVar(),i=xe(r.bindMatrix,"mat4"),o=xe(r.bindMatrixInverse,"mat4"),c=Yd(r.skeleton.boneMatrices,"mat4",r.skeleton.bones.length),l=r.skeleton;if(vb(({frameId:u})=>{if(sw.get(l)!==u){sw.set(l,u);let d=nw.get(l);d!==void 0&&(d.previousBoneMatrices.set(l.boneMatrices),d.previousBoneTexture!==null&&(d.previousBoneTexture.needsUpdate=!0)),l.update()}}),t.needsPreviousData()){let u=dF(t,r,i,o,n,a);cr.assign(u)}let h=yN(c,s,i,o,n,a);if(e!==null&&e.assign(h),t.hasGeometryAttribute("normal")){let{skinNormal:u,skinTangent:d}=uF(c,pn,rc,i,o,n,a);pn.assign(u),t.hasGeometryAttribute("tangent")&&rc.assign(d)}return h}),aw=class extends we{static get type(){return"LoopNode"}constructor(e=[]){super("void"),this.params=e}getVarName(e){return String.fromCharCode(105+e)}getProperties(e){let t=e.getNodeProperties(this);if(t.stackNode!==void 0)return t;let s={},n=this._getInternalParams();for(let c=0,l=n.length-1;c<l;c++){let h=n[c],u=h.isNode!==!0&&h.name||this.getVarName(c),d=h.isNode!==!0&&h.type||"int";s[u]=ua(u,d)}let a=e.addStack(),i=n[n.length-1](s);t.returnsNode=i.context({nodeLoop:i}),t.stackNode=a;let o=n[0];if(o.isNode!==!0&&typeof o.update=="function"){let c=F(o.update)(s);t.updateNode=c.context({nodeLoop:c})}return e.removeStack(),t}_getInternalParams(){let e=this.params;return typeof e[0]=="function"?[Va(!0),e[0]]:e}setup(e){if(this.getProperties(e),e.fnCall){let t=e.getDataFromNode(e.fnCall.shaderNode);t.hasLoop=!0}}generate(e){let t=this.getProperties(e),s=this._getInternalParams(),n=t.stackNode;for(let i=0,o=s.length-1;i<o;i++){let c=s[i],l=!1,h=null,u=null,d=null,f=null,p=null,m=null;c.isNode?c.getNodeType(e)==="bool"?(l=!0,f="bool",u=c.build(e,f)):(f="int",d=this.getVarName(i),h="0",u=c.build(e,f),p="<"):(f=c.type||"int",d=c.name||this.getVarName(i),h=c.start,u=c.end,p=c.condition,m=c.update,typeof h=="number"?h=e.generateConst(f,h):h&&h.isNode&&(h=h.build(e,f)),typeof u=="number"?u=e.generateConst(f,u):u&&u.isNode&&(u=u.build(e,f)),h!==void 0&&u===void 0?(h=h+" - 1",u="0",p=">="):u!==void 0&&h===void 0&&(h="0",p="<"),p===void 0&&(Number(h)>Number(u)?p=">=":p="<"));let b;if(l)b=`while ( ${u} )`;else{let g={start:h,end:u},x=g.start,T=g.end,y,v=()=>p.includes("<")?"+=":"-=";if(m!=null)switch(typeof m){case"function":y=e.flowStagesNode(t.updateNode,"void").code.replace(/\t|;/g,"");break;case"number":y=d+" "+v()+" "+e.generateConst(f,m);break;case"string":y=d+" "+m;break;default:m.isNode?y=d+" "+v()+" "+m.build(e):(W("TSL: 'Loop( { update: ... } )' is not a function, string or number.",this.stackTrace),y="break /* invalid update */")}else f==="int"||f==="uint"?m=p.includes("<")?"++":"--":m=v()+" 1.",y=d+" "+m;let _=e.getVar(f,d)+" = "+x,A=d+" "+p+" "+T;b=`for ( ${_}; ${A}; ${y} )`}e.addFlowCode((i===0?`
`:"")+e.tab+b+` {

`).addFlowTab()}let a=n.build(e,"void");t.returnsNode.build(e,"void"),e.removeFlowTab().addFlowCode(`
`+e.tab+a);for(let i=0,o=s.length-1;i<o;i++)e.addFlowCode((i===0?"":e.tab)+`}

`).removeFlowTab();e.addFlowTab()}},tt=(...r)=>new aw(kl(r,"int")).toStack(),BU=()=>ua("continue").toStack(),FU=()=>ua("break").toStack(),vA=new WeakMap,ia=new Ge,sk=new WeakMap,nk=F(({bufferMap:r,influence:e,stride:t,width:s,depth:n,offset:a})=>{let i=k(P0).mul(t).add(a),o=i.div(s),c=i.sub(o.mul(s));return Jt(r,Dt(c,o)).depth(n).xyz.mul(e)});function PU(r){let e=r.morphAttributes.position!==void 0,t=r.morphAttributes.normal!==void 0,s=r.morphAttributes.color!==void 0,n=r.morphAttributes.position||r.morphAttributes.normal||r.morphAttributes.color,a=n!==void 0?n.length:0,i=vA.get(r);if(i===void 0||i.count!==a){let g=function(){m.dispose(),vA.delete(r),r.removeEventListener("dispose",g)};i!==void 0&&i.texture.dispose();let o=r.morphAttributes.position||[],c=r.morphAttributes.normal||[],l=r.morphAttributes.color||[],h=0;e===!0&&(h=1),t===!0&&(h=2),s===!0&&(h=3);let u=r.attributes.position.count*h,d=1,f=4096;u>f&&(d=Math.ceil(u/f),u=f);let p=new Float32Array(u*d*4*a),m=new Gh(p,u,d,a);m.type=Mt,m.needsUpdate=!0;let b=h*4;for(let x=0;x<a;x++){let T=o[x],y=c[x],v=l[x],_=u*d*4*x;for(let A=0;A<T.count;A++){let M=A*b;e===!0&&(ia.fromBufferAttribute(T,A),p[_+M+0]=ia.x,p[_+M+1]=ia.y,p[_+M+2]=ia.z,p[_+M+3]=0),t===!0&&(ia.fromBufferAttribute(y,A),p[_+M+4]=ia.x,p[_+M+5]=ia.y,p[_+M+6]=ia.z,p[_+M+7]=0),s===!0&&(ia.fromBufferAttribute(v,A),p[_+M+8]=ia.x,p[_+M+9]=ia.y,p[_+M+10]=ia.z,p[_+M+11]=v.itemSize===4?ia.w:1)}}i={count:a,texture:m,stride:h,size:new q(u,d)},vA.set(r,i),r.addEventListener("dispose",g)}return i}var pF=F(([r])=>{let{geometry:e}=r,t=e.morphAttributes.position!==void 0,s=e.hasAttribute("normal")&&e.morphAttributes.normal!==void 0,n=e.morphAttributes.position||e.morphAttributes.normal||e.morphAttributes.color,a=n!==void 0?n.length:0;if(a===0)return;let i=sk.get(r);(i===void 0||i.count!==a)&&(i={base:xe(1),influences:r.morphTargetInfluences?Us(r.morphTargetInfluences,"float"):null,count:a},sk.set(r,i));let{base:o,influences:c}=i,{texture:l,stride:h,size:u}=PU(e);t===!0&&Ct.mulAssign(o),s===!0&&pn.mulAssign(o);let d=k(u.width);tt(a,({i:f})=>{let p=S(0).toVar();r.count>1&&r.morphTexture!==null&&r.morphTexture!==void 0?p.assign(Jt(r.morphTexture,Dt(k(f).add(1),k(_i))).r):p.assign(c.element(f).toVar()),fe(p.notEqual(0),()=>{t===!0&&Ct.addAssign(nk({bufferMap:l,influence:p,stride:h,width:d,depth:f,offset:k(0)})),s===!0&&pn.addAssign(nk({bufferMap:l,influence:p,stride:h,width:d,depth:f,offset:k(1)}))})}),vb(({object:f})=>{let{base:p,influences:m}=i;f.geometry.morphTargetsRelative?p.value=1:p.value=1-f.morphTargetInfluences.reduce((b,g)=>b+g,0),m&&(m.array=f.morphTargetInfluences,m.update())})},"void"),ao=class extends we{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}},iw=class extends ao{static get type(){return"AONode"}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}},rw=class extends Rd{static get type(){return"LightingContextNode"}constructor(e,t=null,s=[],n=null,a=null){super(e),this.lightingModel=t,this.materialLightings=s,this.backdropNode=n,this.backdropAlphaNode=a,this._value=null}getContext(){let{materialLightings:e,backdropNode:t,backdropAlphaNode:s}=this,n=C().toVar("directDiffuse"),a=C().toVar("directSpecular"),i=C().toVar("indirectDiffuse"),o=C().toVar("indirectSpecular"),c={directDiffuse:n,directSpecular:a,indirectDiffuse:i,indirectSpecular:o};return{radiance:C().toVar("radiance"),irradiance:C().toVar("irradiance"),iblIrradiance:C().toVar("iblIrradiance"),ambientOcclusion:S(1).toVar("ambientOcclusion"),reflectedLight:c,materialLightings:e,backdrop:t,backdropAlpha:s}}setup(e){return this.value=this._value||(this._value=this.getContext()),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}},mF=He(rw),Vm=class extends ao{static get type(){return"IrradianceNode"}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}},gl=new q,Gl=class extends ba{static get type(){return"ViewportTextureNode"}constructor(e=vi,t=null,s=null){let n=null;s===null?(n=new qc,n.minFilter=on,s=n):n=s,super(s,e,t),this.generateMipmaps=!1,this.defaultFramebuffer=n,this.isOutputTextureNode=!0,this.updateBeforeType=Me.RENDER,this._cacheTextures=new WeakMap}getTextureForReference(e=null){let t,s;if(this.referenceNode?(t=this.referenceNode.defaultFramebuffer,s=this.referenceNode._cacheTextures):(t=this.defaultFramebuffer,s=this._cacheTextures),e===null)return t;if(s.has(e)===!1){let n=t.clone();s.set(e,n)}return s.get(e)}updateReference(e){let t=e.renderer,s=t.getRenderTarget(),n=t.getCanvasTarget(),a=s||n;return this.value=this.getTextureForReference(a),this.value}updateBefore(e){let t=e.renderer,s=t.getRenderTarget(),n=t.getCanvasTarget(),a=s||n;a===null?t.getDrawingBufferSize(gl):a.getDrawingBufferSize?a.getDrawingBufferSize(gl):gl.set(a.width,a.height);let i=this.getTextureForReference(a);(i.image.width!==gl.width||i.image.height!==gl.height)&&(i.image.width=gl.width,i.image.height=gl.height,i.needsUpdate=!0);let o=i.generateMipmaps;i.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(i),i.generateMipmaps=o}clone(){let e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}},DU=He(Gl).setParameterLength(0,3),xN=He(Gl,null,null,{generateMipmaps:!0}).setParameterLength(0,3),OU=xN(),wN=(r=vi,e=null)=>OU.sample(r,e),_A=null,ow=class extends Gl{static get type(){return"ViewportDepthTextureNode"}constructor(e=vi,t=null,s=null){s===null&&(_A===null&&(_A=new Ds),s=_A),super(e,t,s)}},TN=He(ow).setParameterLength(0,3),Ga=class r extends we{static get type(){return"ViewportDepthNode"}constructor(e,t=null){super("float"),this.scope=e,this.valueNode=t,this.isViewportDepthNode=!0}generate(e){let{scope:t}=this;return t===r.DEPTH_BASE?e.getFragDepth():super.generate(e)}setup({camera:e}){let{scope:t}=this,s=this.valueNode,n=null;if(t===r.DEPTH_BASE)s!==null&&(n=yF().assign(s));else if(t===r.DEPTH)e.isPerspectiveCamera?n=JT($t.z,Yr,Zr):n=Ol($t.z,Yr,Zr);else if(t===r.LINEAR_DEPTH)if(s!==null)if(e.isPerspectiveCamera){let a=$T(s,Yr,Zr);n=Ol(a,Yr,Zr)}else n=s;else n=Ol($t.z,Yr,Zr);return n}};Ga.DEPTH_BASE="depthBase";Ga.DEPTH="depth";Ga.LINEAR_DEPTH="linearDepth";var Ol=(r,e,t)=>r.add(e).div(e.sub(t)),UU=(r,e,t)=>r.add(t).div(t.sub(e)),bF=F(([r,e,t],s)=>s.renderer.reversedDepthBuffer===!0?t.sub(e).mul(r).sub(t):e.sub(t).mul(r).sub(e)),JT=(r,e,t)=>e.add(r).mul(t).div(t.sub(e).mul(r)),gF=(r,e,t)=>e.mul(r.add(t)).div(r.mul(e.sub(t))),$T=F(([r,e,t],s)=>s.renderer.reversedDepthBuffer===!0?e.mul(t).div(e.sub(t).mul(r).sub(e)):e.mul(t).div(t.sub(e).mul(r).sub(t))),YT=(r,e,t)=>{e=e.max(1e-6).toVar();let s=nr(r.negate().div(e)),n=nr(t.div(e));return s.div(n)},LU=(r,e,t)=>{let s=r.mul(wb(t.div(e)));return S(Math.E).pow(s).mul(e).negate()},yF=He(Ga,Ga.DEPTH_BASE),vN=ie(Ga,Ga.DEPTH),Bd=He(Ga,Ga.LINEAR_DEPTH).setParameterLength(0,1),zU=Bd(TN());vN.assign=r=>yF(r);var Si=class r extends we{static get type(){return"ClippingNode"}constructor(e=r.DEFAULT){super(),this.scope=e}setup(e){super.setup(e);let t=e.clippingContext,{intersectionPlanes:s,unionPlanes:n}=t;return this.hardwareClipping=e.hardwareClipping,this.scope===r.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(s,n):this.scope===r.HARDWARE?this.setupHardwareClipping(n,e):this.setupDefault(s,n)}setupAlphaToCoverage(e,t){return F(()=>{let s=S().toVar("distanceToPlane"),n=S().toVar("distanceToGradient"),a=S(1).toVar("clipOpacity"),i=t.length;if(this.hardwareClipping===!1&&i>0){let c=Us(t).setGroup(ye);tt(i,({i:l})=>{let h=c.element(l);s.assign($t.dot(h.xyz).negate().add(h.w)),n.assign(s.fwidth().div(2)),a.mulAssign(ma(n.negate(),n,s))})}let o=e.length;if(o>0){let c=Us(e).setGroup(ye),l=S(1).toVar("intersectionClipOpacity");tt(o,({i:h})=>{let u=c.element(h);s.assign($t.dot(u.xyz).negate().add(u.w)),n.assign(s.fwidth().div(2)),l.mulAssign(ma(n.negate(),n,s).oneMinus())}),a.mulAssign(l.oneMinus())}rt.a.mulAssign(a),rt.a.equal(0).discard()})()}setupDefault(e,t){return F(()=>{let s=t.length;if(this.hardwareClipping===!1&&s>0){let a=Us(t).setGroup(ye);tt(s,({i})=>{let o=a.element(i);$t.dot(o.xyz).greaterThan(o.w).discard()})}let n=e.length;if(n>0){let a=Us(e).setGroup(ye),i=Va(!0).toVar("clipped");tt(n,({i:o})=>{let c=a.element(o);i.assign($t.dot(c.xyz).greaterThan(c.w).and(i))}),i.discard()}})()}setupHardwareClipping(e,t){let s=e.length;return t.enableHardwareClipping(s),F(()=>{let n=Us(e).setGroup(ye),a=Ni(t.getClipDistance());tt(s,({i})=>{let o=n.element(i),c=$t.dot(o.xyz).sub(o.w).negate();a.element(i).assign(c)})})()}};Si.ALPHA_TO_COVERAGE="alphaToCoverage";Si.DEFAULT="default";Si.HARDWARE="hardware";var xF=()=>new Si,wF=()=>new Si(Si.ALPHA_TO_COVERAGE),TF=()=>new Si(Si.HARDWARE),VU=.05,ak=F(([r])=>ja(Te(1e4,_s(Te(17,r.x).add(Te(.1,r.y)))).mul(lt(.1,bt(_s(Te(13,r.y).add(r.x))))))),ik=F(([r])=>ak(Z(ak(r.xy),r.z))),jU=F(([r])=>{let e=Pt(ar(P1(r.xyz)),ar(D1(r.xyz))),t=S(1).div(S(VU).mul(e)).toVar("pixScale"),s=Z(Nd(zs(nr(t))),Nd(zT(nr(t)))),n=Z(ik(zs(s.x.mul(r.xyz))),ik(zs(s.y.mul(r.xyz)))),a=ja(nr(t)),i=lt(Te(a.oneMinus(),n.x),Te(a,n.y)),o=pa(a,a.oneMinus()),c=C(i.mul(i).div(Te(2,o).mul(ze(1,o))),i.sub(Te(.5,o)).div(ze(1,o)),ze(1,ze(1,i).mul(ze(1,i)).div(Te(2,o).mul(ze(1,o))))),l=i.lessThan(o.oneMinus()).select(i.lessThan(o).select(c.x,c.y),c.z);return Hn(l,1e-6,1)}).setLayout({name:"getAlphaHashThreshold",type:"float",inputs:[{name:"position",type:"vec3"}]}),cw=class extends Lm{static get type(){return"VertexColorNode"}constructor(e){super(null,"vec4"),this.isVertexColorNode=!0,this.index=e}getAttributeName(){let e=this.index;return"color"+(e>0?e:"")}generate(e){let t=this.getAttributeName(e),s=e.hasGeometryAttribute(t),n;return s===!0?n=super.generate(e):n=e.generateConst(this.nodeType,new Ge(1,1,1,1)),n}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}},vF=(r=0)=>new cw(r),wt=class extends Rt{static get type(){return"NodeMaterial"}get type(){return this.constructor.type}set type(e){}constructor(){super(),this.isNodeMaterial=!0,this.fog=!0,this.lights=!1,this.lightsNode=null,this.envNode=null,this.aoNode=null,this.colorNode=null,this.normalNode=null,this.opacityNode=null,this.backdropNode=null,this.backdropAlphaNode=null,this.alphaTestNode=null,this.maskNode=null,this.maskShadowNode=null,this.positionNode=null,this.geometryNode=null,this.depthNode=null,this.receivedShadowPositionNode=null,this.castShadowPositionNode=null,this.receivedShadowNode=null,this.castShadowNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null,this.contextNode=null}_getNodeChildren(){let e=[];for(let t of Object.getOwnPropertyNames(this)){if(t.startsWith("_")===!0)continue;let s=this[t];s&&s.isNode===!0&&e.push({property:t,childNode:s})}return e}customProgramCacheKey(){let e=[];for(let{property:t,childNode:s}of this._getNodeChildren())e.push(fc(t.slice(0,-4)),s.getCacheKey());return this.type+$d(e)}build(e){this.setup(e)}setupObserver(e){return new b0(e)}setup(e){e.context.setupNormal=()=>Pl(this.setupNormal(e),"NORMAL","vec3"),e.context.setupPositionView=()=>this.setupPositionView(e),e.context.setupModelViewProjection=()=>this.setupModelViewProjection(e);let t=e.renderer,s=t.getRenderTarget();e.addStack();let n=this.setupVertex(e),a=Pl(this.vertexNode||n,"VERTEX");e.context.clipSpace=a,e.stack.outputNode=a,this.setupHardwareClipping(e),this.geometryNode!==null&&(e.stack.outputNode=e.stack.outputNode.bypass(this.geometryNode)),e.addFlow("vertex",e.removeStack()),e.addStack();let i,o=this.setupClipping(e);if((this.depthWrite===!0||this.depthTest===!0)&&(s!==null?s.depthBuffer===!0&&this.setupDepth(e):t.depth===!0&&this.setupDepth(e)),this.fragmentNode===null){this.setupDiffuseColor(e),this.setupAmbientOcclusion(e),this.setupVariants(e);let c=this.setupLighting(e);o!==null&&e.stack.addToStack(o);let l=ce(c,rt.a).max(0);i=this.setupOutput(e,l),ec.assign(i);let h=this.outputNode!==null;if(h&&(i=this.outputNode),e.context.getOutput&&(i=e.context.getOutput(i,e)),s!==null){let u=t.getMRT(),d=this.mrtNode;u!==null?(h&&ec.assign(i),i=u,d!==null&&(i=u.merge(d))):d!==null&&(i=d)}}else{let c=this.fragmentNode;c.isOutputStructNode!==!0&&(c=c.convert(e.getOutputType())),i=this.setupOutput(e,c)}e.stack.outputNode=i,e.addFlow("fragment",e.removeStack()),e.observer=this.setupObserver(e)}setupClipping(e){if(e.clippingContext===null)return null;let{unionPlanes:t,intersectionPlanes:s}=e.clippingContext,n=null;if(t.length>0||s.length>0){let a=e.renderer.currentSamples;this.alphaToCoverage&&a>1?n=wF():e.stack.addToStack(xF())}return n}setupHardwareClipping(e){if(e.hardwareClipping=!1,e.clippingContext===null)return;let t=e.clippingContext.unionPlanes.length;t>0&&t<=8&&e.isAvailable("clipDistance")&&(e.stack.addToStack(TF()),e.hardwareClipping=!0)}setupDepth(e){let{renderer:t,camera:s}=e,n=this.depthNode;if(n===null){let a=t.getMRT();a&&a.has("depth")?n=a.get("depth"):t.logarithmicDepthBuffer===!0&&(s.isPerspectiveCamera?n=YT($t.z,Yr,Zr):n=Ol($t.z,Yr,Zr))}n!==null&&vN.assign(n).toStack()}setupPositionView(){return or.mul(Ct).xyz}setupModelViewProjection(){return En.mul($t)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.position=e.removeStack(),tF}setupPosition(e){let{object:t,geometry:s}=e;if((s.morphAttributes.position||s.morphAttributes.normal||s.morphAttributes.color)&&pF(t),t.isSkinnedMesh===!0&&fF(t),this.displacementMap){let n=Qr("displacementMap","texture"),a=Qr("displacementScale","float"),i=Qr("displacementBias","float");Ct.addAssign(pn.normalize().mul(n.x.mul(a).add(i)))}return t.isBatchedMesh&&lF(t),t.isInstancedMesh&&t.instanceMatrix&&t.instanceMatrix.isInstancedBufferAttribute===!0&&rF(t),this.positionNode!==null&&Ct.assign(Pl(this.positionNode,"POSITION","vec3")),Ct}setupDiffuseColor(e){let{object:t,geometry:s}=e;this.maskNode!==null&&Va(this.maskNode).not().discard();let n=this.colorNode?ce(this.colorNode):NB;this.vertexColors===!0&&s.hasAttribute("color")&&(n=n.mul(vF())),t.instanceColor&&(n=bN.mul(n)),t.isBatchedMesh&&t._colorsTexture&&(n=gN.mul(n)),rt.assign(n);let a=this.opacityNode?S(this.opacityNode):lN;rt.a.assign(rt.a.mul(a));let i=null;(this.alphaTestNode!==null||this.alphaTest>0)&&(i=this.alphaTestNode!==null?S(this.alphaTestNode):SB,this.alphaToCoverage===!0?(rt.a=ma(i,i.add(U1(rt.a)),rt.a),rt.a.lessThanEqual(0).discard()):rt.a.lessThanEqual(i).discard()),this.alphaHash===!0&&rt.a.lessThan(jU(Ct)).discard(),e.isOpaque()&&rt.a.assign(1)}setupVariants(){}setupOutgoingLight(){return this.lights===!0?C(0):rt.rgb}setupNormal(){return this.normalNode?C(this.normalNode):PB}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?Qr("envMap","cubeTexture"):Qr("envMap","texture")),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new Vm(pN)),t}setupMaterialLightings(e){let t=[],s=this.setupEnvironment(e);s&&s.isLightingNode&&t.push(s);let n=this.setupLightMap(e);if(n&&n.isLightingNode&&t.push(n),e.context.ambientOcclusion&&t.push(new iw(e.context.ambientOcclusion)),e.context.getGI){let a=e.context.getGI(null,e);a!==null&&t.push(new Vm(a))}return t}setupAmbientOcclusion(e){let t=this.aoNode;t===null&&e.material.aoMap&&(t=eF),e.context.getAO&&(t=e.context.getAO(t,e)),t!==null&&(tM.assign(t),e.context.ambientOcclusion=tM)}setupLightingModel(){}setupLighting(e){let{material:t}=e,{backdropNode:s,backdropAlphaNode:n,emissiveNode:a}=this,i=this.lights===!0&&e.renderer.lighting.enabled,o=i||this.lightsNode!==null,c=i?this.setupMaterialLightings(e):[],l=o?this.lightsNode||e.lightsNode:null,h=this.setupOutgoingLight(e);if(l&&(c.length>0||l.getScope().hasLights)){let u=this.setupLightingModel(e)||null;h=mF(l,u,c,s,n)}else s!==null&&(h=C(n!==null?Ke(h,s,n):s));return(a&&a.isNode===!0||t.emissive&&t.emissive.isColor===!0)&&(eM.assign(C(a||EB)),h=h.add(eM)),h}setupFog(e,t){let s=e.fogNode;return s&&(ec.assign(t),t=ce(s.toVar())),t}setupPremultipliedAlpha(e,t){return $1(t)}setupOutput(e,t){return this.fog===!0&&(t=this.setupFog(e,t)),this.premultipliedAlpha===!0&&(t=this.setupPremultipliedAlpha(e,t)),t}setDefaultValues(e){for(let s in e){let n=e[s];this[s]===void 0&&(this[s]=n,n&&n.clone&&(this[s]=n.clone()))}let t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(let s in t)Object.getOwnPropertyDescriptor(this.constructor.prototype,s)===void 0&&t[s].get!==void 0&&Object.defineProperty(this.constructor.prototype,s,t[s])}toJSON(e){let t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{},nodes:{}});let s=Rt.prototype.toJSON.call(this,e);s.inputNodes={};for(let{property:a,childNode:i}of this._getNodeChildren())s.inputNodes[a]=i.toJSON(e).uuid;function n(a){let i=[];for(let o in a){let c=a[o];delete c.metadata,i.push(c)}return i}if(t){let a=n(e.textures),i=n(e.images),o=n(e.nodes);a.length>0&&(s.textures=a),i.length>0&&(s.images=i),o.length>0&&(s.nodes=o)}return s}copy(e){let t=Object.getOwnPropertyDescriptors(this.constructor.prototype);for(let s in t)if(t[s].set!==void 0&&e[s]!==void 0){let n=e[s];this[s]&&this[s].copy!==void 0?this[s].copy(n):this[s]=n}for(let s in this)if(!/^(?:is[A-Z]|_)|^(?:id|uuid|version|type|userData|clippingPlanes)$/.test(s)&&this[s]!==void 0&&e[s]!==void 0){let n=e[s];this[s]&&this[s].copy!==void 0?this[s].copy(n):this[s]=n}return this.clippingPlanes=e.clippingPlanes?e.clippingPlanes.map(s=>s.clone()):null,this.userData=JSON.parse(JSON.stringify(e.userData)),this}},GU=new ns,lw=class extends wt{static get type(){return"LineBasicNodeMaterial"}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.setDefaultValues(GU),this.setValues(e)}},HU=new Zc,hw=class extends wt{static get type(){return"LineDashedNodeMaterial"}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.setDefaultValues(HU),this.dashOffset=0,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){let e=this.offsetNode?S(this.offsetNode):fN,t=this.dashScaleNode?S(this.dashScaleNode):hN,s=this.dashSizeNode?S(this.dashSizeNode):uN,n=this.gapSizeNode?S(this.gapSizeNode):dN;Bl.assign(s),Im.assign(n);let a=bc(Rn("lineDistance").mul(t));(e?a.add(e):a).mod(Bl.add(Im)).greaterThan(Bl).discard()}},WU=new Zc,d0=mc("vec3","worldStart"),uM=mc("vec3","worldEnd"),_F=mc("float","lineDistance"),Al=mc("vec4","worldPos"),rk=F(({start:r,end:e})=>{let t=En.element(2).element(2),s=En.element(3).element(2);return t.greaterThan(0).select(s.negate().div(t.add(1)),s.mul(-.5).div(t)).sub(r.z).div(e.z.sub(r.z))},{start:"vec4",end:"vec4",return:"float"}),qU=F(({p1:r,p2:e,p3:t,p4:s})=>{let n=r.sub(t),a=s.sub(t),i=e.sub(r),o=n.dot(a),c=a.dot(i),l=n.dot(i),h=a.dot(a),d=i.dot(i).mul(h).sub(c.mul(c)),p=o.mul(c).sub(l.mul(h)).div(d).clamp(),m=o.add(c.mul(p)).div(h).clamp();return Z(p,m)},{p1:"vec3",p2:"vec3",p3:"vec3",p4:"vec3",return:"vec2"}),XU=F(({material:r})=>{let e=r._useDash,t=r._useWorldUnits,s=Rn("instanceStart"),n=Rn("instanceEnd"),a=ce(or.mul(ce(s,1))).toVar("start"),i=ce(or.mul(ce(n,1))).toVar("end"),o,c;e&&(o=S(Rn("instanceDistanceStart")).toVar("distanceStart"),c=S(Rn("instanceDistanceEnd")).toVar("distanceEnd")),t&&(d0.assign(a.xyz),uM.assign(i.xyz));let l=vd.z.div(vd.w),h=En.element(2).element(3).equal(-1);if(fe(h,()=>{fe(a.z.lessThan(0).and(i.z.greaterThan(0)),()=>{let g=rk({start:a,end:i});i.assign(ce(Ke(a.xyz,i.xyz,g),i.w)),e&&c.assign(Ke(o,c,g))}).ElseIf(i.z.lessThan(0).and(a.z.greaterThanEqual(0)),()=>{let g=rk({start:i,end:a});a.assign(ce(Ke(i.xyz,a.xyz,g),a.w)),e&&o.assign(Ke(c,o,g))})}),e){let g=r.dashScaleNode?S(r.dashScaleNode):hN,x=r.offsetNode?S(r.offsetNode):fN,T=vs.y.lessThan(.5).select(g.mul(o),g.mul(c));T=T.add(x),_F.assign(T)}let u=En.mul(a),d=En.mul(i),f=u.xyz.div(u.w),p=d.xyz.div(d.w),m=p.xy.sub(f.xy).toVar();m.x.assign(m.x.mul(l)),m.assign(m.normalize());let b=ce().toVar();if(t){let g=i.xyz.sub(a.xyz).normalize(),x=Ke(a.xyz,i.xyz,.5).normalize(),T=g.cross(x).normalize(),y=g.cross(T);Al.assign(vs.y.lessThan(.5).select(a,i));let v=Z0.mul(.5);Al.addAssign(ce(vs.x.lessThan(0).select(T.mul(v),T.mul(v).negate()),0)),e||(Al.addAssign(ce(vs.y.lessThan(.5).select(g.mul(v).negate(),g.mul(v)),0)),Al.addAssign(ce(y.mul(v),0)),fe(vs.y.greaterThan(1).or(vs.y.lessThan(0)),()=>{Al.subAssign(ce(y.mul(2).mul(v),0))})),b.assign(En.mul(Al));let _=C().toVar();_.assign(vs.y.lessThan(.5).select(f,p)),b.z.assign(_.z.mul(b.w))}else{let g=Z(m.y,m.x.negate()).toVar("offset");m.x.assign(m.x.div(l)),g.x.assign(g.x.div(l)),g.assign(vs.x.lessThan(0).select(g.negate(),g)),fe(vs.y.lessThan(0),()=>{g.assign(g.sub(m))}).ElseIf(vs.y.greaterThan(1),()=>{g.assign(g.add(m))}),g.assign(g.mul(Z0)),g.assign(g.div(vd.w.div(Q1))),b.assign(vs.y.lessThan(.5).select(u,d)),g.assign(g.mul(b.w)),b.assign(b.add(ce(g,0,0)))}return b})(),KU=F(({material:r,renderer:e})=>{let t=r._useAlphaToCoverage,s=r._useDash,n=r._useWorldUnits,a=ot();if(s){let o=r.dashSizeNode?S(r.dashSizeNode):uN,c=r.gapSizeNode?S(r.gapSizeNode):dN;Bl.assign(o),Im.assign(c),a.y.lessThan(-1).or(a.y.greaterThan(1)).discard(),_F.mod(Bl.add(Im)).greaterThan(Bl).discard()}let i=S(1).toVar("alpha");if(n){let o=Al.xyz.normalize().mul(1e5),c=uM.sub(d0),l=qU({p1:d0,p2:uM,p3:C(0,0,0),p4:o}),h=d0.add(c.mul(l.x)),u=o.mul(l.y),p=h.sub(u).length().div(Z0);if(!s)if(t&&e.currentSamples>0){let m=p.fwidth();i.assign(ma(m.negate().add(.5),m.add(.5),p).oneMinus())}else p.greaterThan(.5).discard()}else if(t&&e.currentSamples>0){let o=a.x,c=a.y.greaterThan(0).select(a.y.sub(1),a.y.add(1)),l=o.mul(o).add(c.mul(c)),h=S(l.fwidth()).toVar("dlen");fe(a.y.abs().greaterThan(1),()=>{i.assign(ma(h.oneMinus(),h.add(1),l).oneMinus())})}else fe(a.y.abs().greaterThan(1),()=>{let o=a.x,c=a.y.greaterThan(0).select(a.y.sub(1),a.y.add(1));o.mul(o).add(c.mul(c)).greaterThan(1).discard()});return i})(),dM=class extends wt{static get type(){return"Line2NodeMaterial"}constructor(e={}){super(),this.isLine2NodeMaterial=!0,this.setDefaultValues(WU),this.vertexColors=e.vertexColors,this.dashOffset=0,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.blending=Ca,this._useDash=e.dashed,this._useAlphaToCoverage=!0,this._useWorldUnits=!1,this.setValues(e)}setupDiffuseColor(e){if(super.setupDiffuseColor(e),rt.a.mulAssign(KU),this.vertexColors===!0&&e.geometry.hasAttribute("instanceColorStart")){let t=Rn("instanceColorStart"),s=Rn("instanceColorEnd"),n=vs.y.lessThan(.5).select(t,s);rt.rgb.mulAssign(n)}this.transparent&&rt.rgb.assign(rt.rgb.mul(rt.a).add(wN().rgb.mul(rt.a.oneMinus())))}setupPosition(e){let t=Z9.mul(Yl).mul(tN).mul(XU);return Ct.assign(t.xyz.div(t.w)),e.needsPreviousData()&&cr.assign(Ct),super.setupPosition(e)}get lineColorNode(){return this.colorNode}set lineColorNode(e){je('Line2NodeMaterial: "lineColorNode" has been deprecated. Use "colorNode" instead.'),this.colorNode=e}get worldUnits(){return this._useWorldUnits}set worldUnits(e){this._useWorldUnits!==e&&(this._useWorldUnits=e,this.needsUpdate=!0)}get dashed(){return this._useDash}set dashed(e){this._useDash!==e&&(this._useDash=e,this.needsUpdate=!0)}get alphaToCoverage(){return this._useAlphaToCoverage}set alphaToCoverage(e){this._useAlphaToCoverage!==e&&(this._useAlphaToCoverage=e,this.needsUpdate=!0)}},JU=new Ro,Fd=class extends wt{static get type(){return"MeshNormalNodeMaterial"}constructor(e){super(),this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(JU),this.setValues(e)}setupDiffuseColor(){let e=this.opacityNode?S(this.opacityNode):lN;rt.assign(GT(ce(cN(Qe),e),Wt))}},_N=F(([r=sN])=>{let e=r.z.atan(r.x).mul(1/(Math.PI*2)).add(.5),t=r.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5);return Z(e,t)}),fM=F(([r=ot()])=>{let e=r.x.sub(.5).mul(Math.PI*2),t=r.y.sub(.5).mul(Math.PI),s=t.cos(),n=s.mul(e.cos()),a=t.sin(),i=s.mul(e.sin());return C(n,a,i)}),jm=class extends Ps{constructor(e=1,t={}){super(e,e,t),this.isCubeRenderTarget=!0;let s={width:e,height:e,depth:1},n=[s,s,s,s,s,s];this.texture=new Pi(n),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){let s=t.minFilter,n=t.generateMipmaps;t.generateMipmaps=!0,this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let a=new kr(5,5,5),i=_N(sN),o=new wt;o.colorNode=et(t,i,0),o.side=Xt,o.blending=Ca;let c=new at(a,o),l=new ii;l.add(c),t.minFilter===on&&(t.minFilter=Ye);let h=new Cp(1,10,this),u=e.getMRT();return e.setMRT(null),h.update(e,l),e.setMRT(u),t.minFilter=s,t.generateMipmaps=n,c.geometry.dispose(),c.material.dispose(),this}clear(e,t=!0,s=!0,n=!0){let a=e.getRenderTarget();for(let i=0;i<6;i++)e.setRenderTarget(this,i),e.clear(t,s,n);e.setRenderTarget(a)}},Mm=new WeakMap,uw=class extends xt{static get type(){return"CubeMapNode"}constructor(e){super("vec3"),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=Nn(null);let t=new Pi;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=Me.RENDER}updateBefore(e){let{renderer:t,material:s}=e,n=this.envNode;if(n.isTextureNode||n.isMaterialReferenceNode){let a=n.isTextureNode?n.value:s[n.property];if(a&&a.isTexture){let i=a.mapping;if(i===vu||i===_u){if(Mm.has(a)){let o=Mm.get(a);ok(o,a.mapping),this._cubeTexture=o}else{let o=a.image;if($U(o)){let c=new jm(o.height);c.fromEquirectangularTexture(t,a),ok(c.texture,a.mapping),this._cubeTexture=c.texture,Mm.set(a,c.texture),a.addEventListener("dispose",AF)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}};function $U(r){return r==null?!1:r.height>0}function AF(r){let e=r.target;e.removeEventListener("dispose",AF);let t=Mm.get(e);t!==void 0&&(Mm.delete(e),t.dispose())}function ok(r,e){e===vu?r.mapping=Wi:e===_u&&(r.mapping=ol)}var MF=He(uw).setParameterLength(1),Pd=class extends ao{static get type(){return"BasicEnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=MF(this.envNode)}},dw=class extends ao{static get type(){return"BasicLightMapNode"}constructor(e=null){super(),this.lightMapNode=e}setup(e){let t=S(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}},oc=class{start(e){e.lightsNode.setupLights(e,e.lightsNode.getLightNodes(e)),this.indirect(e)}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}},fw=class extends oc{constructor(){super()}indirect({context:e}){let t=e.ambientOcclusion,s=e.reflectedLight,n=e.irradianceLightMap;s.indirectDiffuse.assign(ce(0)),n?s.indirectDiffuse.addAssign(n):s.indirectDiffuse.addAssign(ce(1,1,1,0)),s.indirectDiffuse.mulAssign(t),s.indirectDiffuse.mulAssign(rt.rgb)}finish(e){let{material:t,context:s}=e,n=s.outgoingLight,a=e.context.environment;if(a)switch(t.combine){case wu:n.rgb.assign(Ke(n.rgb,n.rgb.mul(a.rgb),Am.mul(u0)));break;case U_:n.rgb.assign(Ke(n.rgb,a.rgb,Am.mul(u0)));break;case L_:n.rgb.addAssign(a.rgb.mul(Am.mul(u0)));break;default:K("BasicLightingModel: Unsupported .combine value:",t.combine);break}}},YU=new Bt,cc=class extends wt{static get type(){return"MeshBasicNodeMaterial"}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(YU),this.setValues(e)}setupNormal(){return Zl(Id)}setupEnvironment(e){let t=super.setupEnvironment(e);return t?new Pd(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new dw(pN)),t}setupOutgoingLight(){return rt.rgb}setupLightingModel(){return new fw}},sc=F(({f0:r,f90:e,dotVH:t})=>{let s=t.mul(-5.55473).sub(6.98316).mul(t).exp2();return r.mul(s.oneMinus()).add(e.mul(s))}),Hl=F(r=>r.diffuseColor.mul(1/Math.PI)),ZU=()=>S(.25),QU=F(({dotNH:r})=>M0.mul(S(.5)).add(1).mul(S(1/Math.PI)).mul(r.pow(M0))),eL=F(({lightDirection:r})=>{let e=r.add(yt).normalize(),t=Qe.dot(e).clamp(),s=yt.dot(e).clamp(),n=sc({f0:wi,f90:1,dotVH:s}),a=ZU(),i=QU({dotNH:t});return n.mul(a).mul(i)}),Gm=class extends fw{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:s}){let a=Qe.dot(e).clamp().mul(t);s.directDiffuse.addAssign(a.mul(Hl({diffuseColor:rt.rgb}))),this.specular===!0&&s.directSpecular.addAssign(a.mul(eL({lightDirection:e})).mul(Am))}indirect(e){let{ambientOcclusion:t,irradiance:s,reflectedLight:n}=e.context;n.indirectDiffuse.addAssign(s.mul(Hl({diffuseColor:rt}))),n.indirectDiffuse.mulAssign(t)}},tL=new Di,Dd=class extends wt{static get type(){return"MeshLambertNodeMaterial"}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(tL),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t?new Pd(t):null}setupLightingModel(){return new Gm(!1)}},sL=new So,Od=class extends wt{static get type(){return"MeshPhongNodeMaterial"}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(sL),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t?new Pd(t):null}setupLightingModel(){return new Gm}setupVariants(){let e=(this.shininessNode?S(this.shininessNode):RB).max(1e-4);M0.assign(e);let t=this.specularNode||CB;wi.assign(t)}},SF=F(r=>{if(r.geometry.hasAttribute("normal")===!1)return S(0);let e=Id.dFdx().abs().max(Id.dFdy().abs());return e.x.max(e.y).max(e.z)}),AN=F(r=>{let{roughness:e}=r,t=SF(),s=e.max(.0525);return s=s.add(t),s=s.min(1),s}),NF=F(({alpha:r,dotNL:e,dotNV:t})=>{let s=r.pow2(),n=e.mul(s.add(s.oneMinus().mul(t.pow2())).sqrt()),a=t.mul(s.add(s.oneMinus().mul(e.pow2())).sqrt());return js(.5,n.add(a).max(R1))}).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),RF=F(({alphaT:r,alphaB:e,dotTV:t,dotBV:s,dotTL:n,dotBL:a,dotNV:i,dotNL:o})=>{let c=o.mul(C(r.mul(t),e.mul(s),i).length()),l=i.mul(C(r.mul(n),e.mul(a),o).length());return js(.5,c.add(l).max(R1))}).setLayout({name:"V_GGX_SmithCorrelated_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotTV",type:"float",qualifier:"in"},{name:"dotBV",type:"float",qualifier:"in"},{name:"dotTL",type:"float",qualifier:"in"},{name:"dotBL",type:"float",qualifier:"in"},{name:"dotNV",type:"float",qualifier:"in"},{name:"dotNL",type:"float",qualifier:"in"}]}),EF=F(({alpha:r,dotNH:e})=>{let t=r.pow2(),s=e.pow2().mul(t.oneMinus()).oneMinus();return t.div(s.pow2()).mul(1/Math.PI)}).setLayout({name:"D_GGX",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNH",type:"float"}]}),nL=S(1/Math.PI),CF=F(({alphaT:r,alphaB:e,dotNH:t,dotTH:s,dotBH:n})=>{let a=r.mul(e),i=C(e.mul(s),r.mul(n),a.mul(t)),o=i.dot(i),c=a.div(o);return nL.mul(a.mul(c.pow2()))}).setLayout({name:"D_GGX_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotNH",type:"float",qualifier:"in"},{name:"dotTH",type:"float",qualifier:"in"},{name:"dotBH",type:"float",qualifier:"in"}]}),f0=F(({lightDirection:r,f0:e,f90:t,roughness:s,f:n,normalView:a=Qe,viewDirection:i=yt,USE_IRIDESCENCE:o,USE_ANISOTROPY:c})=>{let l=s.pow2(),h=r.add(i).normalize(),u=a.dot(r).clamp(),d=a.dot(i).clamp(),f=a.dot(h).clamp(),p=i.dot(h).clamp(),m=sc({f0:e,f90:t,dotVH:p}),b,g;if(Cl(o)&&(m=OT.mix(m,n)),Cl(c)){let x=vm.dot(r),T=vm.dot(i),y=vm.dot(h),v=Il.dot(r),_=Il.dot(i),A=Il.dot(h);b=RF({alphaT:A0,alphaB:l,dotTV:T,dotBV:_,dotTL:x,dotBL:v,dotNV:d,dotNL:u}),g=CF({alphaT:A0,alphaB:l,dotNH:f,dotTH:y,dotBH:A})}else b=NF({alpha:l,dotNL:u,dotNV:d}),g=EF({alpha:l,dotNH:f});return m.mul(b).mul(g)}),aL=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]),$i=null,MN=F(({roughness:r,dotNV:e})=>{$i===null&&($i=new Is(aL,16,16,cn,ds),$i.name="DFG_LUT",$i.minFilter=Ye,$i.magFilter=Ye,$i.wrapS=hs,$i.wrapT=hs,$i.generateMipmaps=!1,$i.needsUpdate=!0);let t=Z(r,e);return et($i,t).rg}),SN=F(r=>{let{dotNV:e,specularColor:t,specularF90:s,roughness:n}=r,a=MN({dotNV:e,roughness:n});return t.mul(a.x).add(s.mul(a.y))}),pM=F(({f:r,f90:e,dotVH:t})=>{let s=t.oneMinus().saturate(),n=s.mul(s),a=s.mul(n,n).clamp(0,.9999);return r.sub(C(e).mul(a)).div(a.oneMinus())}).setLayout({name:"Schlick_to_F0",type:"vec3",inputs:[{name:"f",type:"vec3"},{name:"f90",type:"float"},{name:"dotVH",type:"float"}]}),iL=F(({roughness:r,dotNH:e})=>{let t=r.pow2(),s=S(1).div(t),a=e.pow2().oneMinus().max(.0078125);return S(2).add(s).mul(a.pow(s.mul(.5))).div(2*Math.PI)}).setLayout({name:"D_Charlie",type:"float",inputs:[{name:"roughness",type:"float"},{name:"dotNH",type:"float"}]}),rL=F(({dotNV:r,dotNL:e})=>S(1).div(S(4).mul(e.add(r).sub(e.mul(r)))).clamp()).setLayout({name:"V_Neubelt",type:"float",inputs:[{name:"dotNV",type:"float"},{name:"dotNL",type:"float"}]}),kF=F(({lightDirection:r})=>{let e=r.add(yt).normalize(),t=Qe.dot(r).clamp(),s=Qe.dot(yt).clamp(),n=Qe.dot(e).clamp(),a=iL({roughness:Jo,dotNH:n}),i=rL({dotNV:s,dotNL:t});return Un.mul(a).mul(i)}),mM=F(({N:r,V:e,roughness:t})=>{let a=.0078125,i=r.dot(e).saturate(),o=Z(t,i.oneMinus().sqrt());return o.assign(o.mul(.984375).add(a)),o}).setLayout({name:"LTC_Uv",type:"vec2",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"roughness",type:"float"}]}),IF=F(({f:r})=>{let e=r.length();return Pt(e.mul(e).add(r.z).div(e.add(1)),0)}).setLayout({name:"LTC_ClippedSphereFormFactor",type:"float",inputs:[{name:"f",type:"vec3"}]}),Zo=F(({v1:r,v2:e})=>{let t=r.dot(e),s=t.abs().toVar(),n=s.mul(.0145206).add(.4965155).mul(s).add(.8543985).toVar(),a=s.add(4.1616724).mul(s).add(3.417594).toVar(),i=n.div(a),o=t.greaterThan(0).select(i,Pt(t.mul(t).oneMinus(),1e-7).inverseSqrt().mul(.5).sub(i));return r.cross(e).mul(o)}).setLayout({name:"LTC_EdgeVectorFormFactor",type:"vec3",inputs:[{name:"v1",type:"vec3"},{name:"v2",type:"vec3"}]}),p0=F(({N:r,V:e,P:t,mInv:s,p0:n,p1:a,p2:i,p3:o})=>{let c=a.sub(n).toVar(),l=o.sub(n).toVar(),h=c.cross(l),u=C().toVar();return fe(h.dot(t.sub(n)).greaterThanEqual(0),()=>{let d=e.sub(r.mul(e.dot(r))).normalize(),f=r.cross(d).negate(),p=s.mul(Ms(d,f,r).transpose()).toVar(),m=p.mul(n.sub(t)).normalize().toVar(),b=p.mul(a.sub(t)).normalize().toVar(),g=p.mul(i.sub(t)).normalize().toVar(),x=p.mul(o.sub(t)).normalize().toVar(),T=C(0).toVar();T.addAssign(Zo({v1:m,v2:b})),T.addAssign(Zo({v1:b,v2:g})),T.addAssign(Zo({v1:g,v2:x})),T.addAssign(Zo({v1:x,v2:m})),u.assign(C(IF({f:T})))}),u}).setLayout({name:"LTC_Evaluate",type:"vec3",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"P",type:"vec3"},{name:"mInv",type:"mat3"},{name:"p0",type:"vec3"},{name:"p1",type:"vec3"},{name:"p2",type:"vec3"},{name:"p3",type:"vec3"}]}),BF=F(({P:r,p0:e,p1:t,p2:s,p3:n})=>{let a=t.sub(e).toVar(),i=n.sub(e).toVar(),o=a.cross(i),c=C().toVar();return fe(o.dot(r.sub(e)).greaterThanEqual(0),()=>{let l=e.sub(r).normalize().toVar(),h=t.sub(r).normalize().toVar(),u=s.sub(r).normalize().toVar(),d=n.sub(r).normalize().toVar(),f=C(0).toVar();f.addAssign(Zo({v1:l,v2:h})),f.addAssign(Zo({v1:h,v2:u})),f.addAssign(Zo({v1:u,v2:d})),f.addAssign(Zo({v1:d,v2:l})),c.assign(C(IF({f:f.abs()})))}),c}).setLayout({name:"LTC_Evaluate_Volume",type:"vec3",inputs:[{name:"P",type:"vec3"},{name:"p0",type:"vec3"},{name:"p1",type:"vec3"},{name:"p2",type:"vec3"},{name:"p3",type:"vec3"}]}),ZT=1/6,FF=r=>Te(ZT,Te(r,Te(r,r.negate().add(3)).sub(3)).add(1)),bM=r=>Te(ZT,Te(r,Te(r,Te(3,r).sub(6))).add(4)),PF=r=>Te(ZT,Te(r,Te(r,Te(-3,r).add(3)).add(3)).add(1)),gM=r=>Te(ZT,zn(r,3)),ck=r=>FF(r).add(bM(r)),lk=r=>PF(r).add(gM(r)),hk=r=>lt(-1,bM(r).div(FF(r).add(bM(r)))),uk=r=>lt(1,gM(r).div(PF(r).add(gM(r)))),dk=(r,e,t)=>{let s=r.uvNode,n=Te(s,e.zw).add(.5),a=zs(n),i=ja(n),o=ck(i.x),c=lk(i.x),l=hk(i.x),h=uk(i.x),u=hk(i.y),d=uk(i.y),f=Z(a.x.add(l),a.y.add(u)).sub(.5).mul(e.xy),p=Z(a.x.add(h),a.y.add(u)).sub(.5).mul(e.xy),m=Z(a.x.add(l),a.y.add(d)).sub(.5).mul(e.xy),b=Z(a.x.add(h),a.y.add(d)).sub(.5).mul(e.xy),g=ck(i.y).mul(lt(o.mul(r.sample(f).level(t)),c.mul(r.sample(p).level(t)))),x=lk(i.y).mul(lt(o.mul(r.sample(m).level(t)),c.mul(r.sample(b).level(t))));return g.add(x)},NN=F(([r,e])=>{let t=Z(r.size(k(e))),s=Z(r.size(k(e.add(1)))),n=js(1,t),a=js(1,s),i=dk(r,ce(n,t),zs(e)),o=dk(r,ce(a,s),zT(e));return ja(e).mix(i,o)}),oL=F(([r,e])=>{let t=e.mul(Y1(r));return NN(r,t)}),fk=F(([r,e,t,s,n])=>{let a=C(V1(e.negate(),Vs(r),js(1,s))),i=C(ar(n[0].xyz),ar(n[1].xyz),ar(n[2].xyz));return Vs(a).mul(t.mul(i))}).setLayout({name:"getVolumeTransmissionRay",type:"vec3",inputs:[{name:"n",type:"vec3"},{name:"v",type:"vec3"},{name:"thickness",type:"float"},{name:"ior",type:"float"},{name:"modelMatrix",type:"mat4"}]}),cL=F(([r,e])=>r.mul(Hn(e.mul(2).sub(2),0,1))).setLayout({name:"applyIorToRoughness",type:"float",inputs:[{name:"roughness",type:"float"},{name:"ior",type:"float"}]}),lL=xN(),hL=wN(),pk=F(([r,e,t],{material:s})=>{let a=(s.side===Xt?lL:hL).sample(r.mul(h0.zw).add(h0.xy).div(kd)),i=nr(h0.z).mul(cL(e,t));return NN(a,i)}),mk=F(([r,e,t])=>(fe(t.notEqual(0),()=>{let s=wb(e).negate().div(t);return LT(s.negate().mul(r))}),C(1))).setLayout({name:"volumeAttenuation",type:"vec3",inputs:[{name:"transmissionDistance",type:"float"},{name:"attenuationColor",type:"vec3"},{name:"attenuationDistance",type:"float"}]}),uL=F(([r,e,t,s,n,a,i,o,c,l,h,u,d,f,p])=>{let m,b;if(p){m=ce().toVar(),b=C().toVar();let v=h.sub(1).mul(p.mul(.025)),_=C(h.sub(v),h,h.add(v));tt({start:0,end:3},({i:A})=>{let M=_.element(A),N=fk(r,e,u,M,o),R=i.add(N),I=l.mul(c.mul(ce(R,1))),D=Z(I.xy.div(I.w)).toVar();D.addAssign(1),D.divAssign(2),D.assign(Z(D.x,D.y.oneMinus()));let O=pk(D,t,M);m.element(A).assign(O.element(A)),m.a.addAssign(O.a),b.element(A).assign(s.element(A).mul(mk(ar(N),d,f).element(A)))}),m.a.divAssign(3)}else{let v=fk(r,e,u,h,o),_=i.add(v),A=l.mul(c.mul(ce(_,1))),M=Z(A.xy.div(A.w)).toVar();M.addAssign(1),M.divAssign(2),M.assign(Z(M.x,M.y.oneMinus())),m=pk(M,t,h),b=s.mul(mk(ar(v),d,f))}let g=b.rgb.mul(m.rgb),x=r.dot(e).clamp(),T=C(SN({dotNV:x,specularColor:n,specularF90:a,roughness:t})),y=b.r.add(b.g,b.b).div(3);return ce(T.oneMinus().mul(g),m.a.oneMinus().mul(y).oneMinus())}),dL=Ms(3.2404542,-1.5371385,-.4985314,-.969266,1.8760108,.041556,.0556434,-.2040259,1.0572252),fL=r=>{let e=r.sqrt();return C(1).add(e).div(C(1).sub(e))},bk=(r,e)=>r.sub(e).div(r.add(e)).pow2(),pL=(r,e)=>{let t=r.mul(2*Math.PI*1e-9),s=C(54856e-17,44201e-17,52481e-17),n=C(1681e3,1795300,2208400),a=C(43278e5,93046e5,66121e5),i=S(9747e-17*Math.sqrt(2*Math.PI*45282e5)).mul(t.mul(2239900).add(e.x).cos()).mul(t.pow2().mul(-45282e5).exp()),o=s.mul(a.mul(2*Math.PI).sqrt()).mul(n.mul(t).add(e).cos()).mul(t.pow2().negate().mul(a).exp());return o=C(o.x.add(i),o.y,o.z).div(10685e-11),dL.mul(o)},gk=F(({outsideIOR:r,eta2:e,cosTheta1:t,thinFilmThickness:s,baseF0:n})=>{let a=Ke(r,e,ma(0,.03,s)),o=r.div(a).pow2().mul(t.pow2().oneMinus()).oneMinus();fe(o.lessThan(0),()=>C(1));let c=o.sqrt(),l=bk(a,r),h=sc({f0:l,f90:1,dotVH:t}),u=h.oneMinus(),d=a.lessThan(r).select(Math.PI,0),f=S(Math.PI).sub(d),p=fL(n.clamp(0,.9999)),m=bk(p,a.toVec3()),b=sc({f0:m,f90:1,dotVH:c}),g=C(p.x.lessThan(a).select(Math.PI,0),p.y.lessThan(a).select(Math.PI,0),p.z.lessThan(a).select(Math.PI,0)),x=a.mul(s,c,2),T=C(f).add(g),y=h.mul(b).clamp(1e-5,.9999),v=y.sqrt(),_=u.pow2().mul(b).div(C(1).sub(y)),M=h.add(_).toVar(),N=_.sub(u).toVar();return tt({start:1,end:2,condition:"<=",name:"m"},({m:R})=>{N.mulAssign(v);let I=pL(S(R).mul(x),S(R).mul(T)).mul(2);M.addAssign(N.mul(I))}),M.max(C(0))}).setLayout({name:"evalIridescence",type:"vec3",inputs:[{name:"outsideIOR",type:"float"},{name:"eta2",type:"float"},{name:"cosTheta1",type:"float"},{name:"thinFilmThickness",type:"float"},{name:"baseF0",type:"vec3"}]}),Qp=F(({normal:r,viewDir:e,roughness:t})=>{let s=r.dot(e).saturate(),n=t.mul(t),a=t.add(.1).reciprocal(),i=S(-1.9362).add(t.mul(1.0678)).add(n.mul(.4573)).sub(a.mul(.8469)),o=S(-.6014).add(t.mul(.5538)).sub(n.mul(.467)).sub(a.mul(.1255));return i.mul(s).add(o).exp().saturate()}),em=C(.04),Bx=S(1),Ud=class extends oc{constructor(e=!1,t=!1,s=!1,n=!1,a=!1,i=!1,o=!1){super(),this.clearcoat=e,this.sheen=t,this.iridescence=s,this.anisotropy=n,this.transmission=a,this.dispersion=i,this.retroreflection=o,this.clearcoatRadiance=null,this.clearcoatSpecularDirect=null,this.clearcoatSpecularIndirect=null,this.sheenSpecularDirect=null,this.sheenSpecularIndirect=null,this.iridescenceFresnel=null,this.iridescenceF0Dielectric=null,this.iridescenceF0Metallic=null,this.dfg=null,this.multiScatteringCompensation=null}start(e){if(this.clearcoat===!0&&(this.clearcoatRadiance=C().toVar("clearcoatRadiance"),this.clearcoatSpecularDirect=C().toVar("clearcoatSpecularDirect"),this.clearcoatSpecularIndirect=C().toVar("clearcoatSpecularIndirect")),this.sheen===!0&&(this.sheenSpecularDirect=C().toVar("sheenSpecularDirect"),this.sheenSpecularIndirect=C().toVar("sheenSpecularIndirect")),this.iridescence===!0){let n=Qe.dot(yt).clamp(),a=gk({outsideIOR:S(1),eta2:v0,cosTheta1:n,thinFilmThickness:_0,baseF0:wi}),i=gk({outsideIOR:S(1),eta2:v0,cosTheta1:n,thinFilmThickness:_0,baseF0:rt.rgb});this.iridescenceFresnel=Ke(a,i,Qo),this.iridescenceF0Dielectric=pM({f:a,f90:1,dotVH:n}),this.iridescenceF0Metallic=pM({f:i,f90:1,dotVH:n})}if(this.transmission===!0){let n=Vn,a=_d.sub(Vn).normalize(),i=gc,o=e.context;o.backdrop=uL(i,a,Oa,Sl,Jr,tr,n,da,Ua,En,_m,v1,A1,_1,this.dispersion?M1:null),o.backdropAlpha=S0,rt.a.mulAssign(Ke(1,o.backdrop.a,S0))}let t=Qe.dot(yt).clamp();this.dfg=MN({roughness:Oa,dotNV:t}).toConst("dfg");let s=this.dfg.x.add(this.dfg.y);this.multiScatteringCompensation=Jr.mul(s.reciprocal().sub(1)).add(1).toConst("multiScatteringCompensation"),super.start(e)}computeMultiscattering(e,t,s,n,a=null){let i=this.dfg,o=a?OT.mix(n,a):n,c=o.mul(i.x).add(s.mul(i.y)),h=i.x.add(i.y).oneMinus(),u=o.add(o.oneMinus().mul(.047619)),d=c.mul(u).div(h.mul(u).oneMinus());e.addAssign(c),t.addAssign(d.mul(h))}direct({lightDirection:e,lightColor:t,reflectedLight:s}){let a=Qe.dot(e).clamp().mul(t).toVar();if(this.sheen===!0){this.sheenSpecularDirect.addAssign(a.mul(kF({lightDirection:e})));let h=Qp({normal:Qe,viewDir:yt,roughness:Jo}),u=Qp({normal:Qe,viewDir:e,roughness:Jo}),d=Un.r.max(Un.g).max(Un.b).mul(h.max(u)).oneMinus();a.mulAssign(d)}if(this.clearcoat===!0){let u=$o.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(u.mul(f0({lightDirection:e,f0:em,f90:Bx,roughness:Td,normalView:$o})))}let i=e.add(yt).normalize(),o=yt.dot(i).clamp(),c=sc({f0:wi,f90:tr,dotVH:o}),l=f0({lightDirection:e,f0:Jr,f90:1,roughness:Oa,f:this.iridescenceFresnel,USE_IRIDESCENCE:this.iridescence,USE_ANISOTROPY:this.anisotropy});if(this.retroreflection===!0){let h=yt.negate().reflect(Qe),u=e.add(h).normalize(),d=h.dot(u).clamp(),f=sc({f0:wi,f90:tr,dotVH:d}),p=f0({lightDirection:e,viewDirection:h,f0:Jr,f90:1,roughness:Oa,f:this.iridescenceFresnel,USE_IRIDESCENCE:this.iridescence,USE_ANISOTROPY:this.anisotropy});c=Ke(c,f,Bm.clamp()),l=Ke(l,p,Bm.clamp())}s.directDiffuse.addAssign(a.mul(Hl({diffuseColor:Sl})).mul(c.oneMinus())),s.directSpecular.addAssign(a.mul(l).mul(this.multiScatteringCompensation))}directRectArea({lightColor:e,lightPosition:t,halfWidth:s,halfHeight:n,reflectedLight:a,ltc_1:i,ltc_2:o}){let c=t.add(s).sub(n),l=t.sub(s).sub(n),h=t.sub(s).add(n),u=t.add(s).add(n),d=Qe,f=yt,p=$t.toVar(),m=mM({N:d,V:f,roughness:Oa}),b=i.sample(m).toVar(),g=o.sample(m).toVar(),x=Ms(C(b.x,0,b.y),C(0,1,0),C(b.z,0,b.w)).toVar(),T=Jr.mul(g.x).add(tr.sub(Jr).mul(g.y)).toVar();if(a.directSpecular.addAssign(e.mul(T).mul(p0({N:d,V:f,P:p,mInv:x,p0:c,p1:l,p2:h,p3:u}))),a.directDiffuse.addAssign(e.mul(Sl).mul(p0({N:d,V:f,P:p,mInv:Ms(1,0,0,0,1,0,0,0,1),p0:c,p1:l,p2:h,p3:u}))),this.clearcoat===!0){let y=$o,v=mM({N:y,V:f,roughness:Td}),_=i.sample(v),A=o.sample(v),M=Ms(C(_.x,0,_.y),C(0,1,0),C(_.z,0,_.w)),N=em.mul(A.x).add(Bx.sub(em).mul(A.y));this.clearcoatSpecularDirect.addAssign(e.mul(N).mul(p0({N:y,V:f,P:p,mInv:M,p0:c,p1:l,p2:h,p3:u})))}}indirect(e){this.indirectDiffuse(e),this.indirectSpecular(e),this.ambientOcclusion(e)}indirectDiffuse(e){let{irradiance:t,reflectedLight:s}=e.context,n=C().toVar(),a=C().toVar();this.computeMultiscattering(n,a,tr,wi,this.iridescenceF0Dielectric);let i=t.mul(Hl({diffuseColor:Sl})).mul(n.add(a).oneMinus()).toVar();if(this.sheen===!0){let o=Qp({normal:Qe,viewDir:yt,roughness:Jo});this.sheenSpecularIndirect.addAssign(t.mul(Un,o,1/Math.PI));let c=Un.r.max(Un.g).max(Un.b).mul(o).oneMinus();i.mulAssign(c)}s.indirectDiffuse.addAssign(i)}indirectSpecular(e){let{radiance:t,iblIrradiance:s,reflectedLight:n}=e.context;if(this.sheen===!0&&this.sheenSpecularIndirect.addAssign(s.mul(Un,Qp({normal:Qe,viewDir:yt,roughness:Jo}),1/Math.PI)),this.clearcoat===!0){let b=$o.dot(yt).clamp(),g=SN({dotNV:b,specularColor:em,specularF90:Bx,roughness:Td});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(g))}let a=C().toVar("singleScatteringDielectric"),i=C().toVar("multiScatteringDielectric"),o=C().toVar("singleScatteringMetallic"),c=C().toVar("multiScatteringMetallic");this.computeMultiscattering(a,i,tr,wi,this.iridescenceF0Dielectric),this.computeMultiscattering(o,c,tr,rt.rgb,this.iridescenceF0Metallic);let l=Ke(a,o,Qo),h=Ke(i,c,Qo),u=a.add(i),d=Sl.mul(u.oneMinus()),f=s.mul(1/Math.PI),p=t.mul(l).add(h.mul(f)).toVar(),m=d.mul(f).toVar();if(this.sheen===!0){let b=Qp({normal:Qe,viewDir:yt,roughness:Jo}),g=Un.r.max(Un.g).max(Un.b).mul(b).oneMinus();p.mulAssign(g),m.mulAssign(g)}n.indirectSpecular.addAssign(p),n.indirectDiffuse.addAssign(m)}ambientOcclusion(e){let{ambientOcclusion:t,reflectedLight:s}=e.context,a=Qe.dot(yt).clamp().add(t),i=Oa.mul(-16).oneMinus().negate().exp2(),o=t.sub(a.pow(i).oneMinus()).clamp();this.clearcoat===!0&&this.clearcoatSpecularIndirect.mulAssign(t),this.sheen===!0&&this.sheenSpecularIndirect.mulAssign(t),s.indirectDiffuse.mulAssign(t),s.indirectSpecular.mulAssign(o)}finish({context:e}){let{outgoingLight:t}=e;if(this.clearcoat===!0){let s=$o.dot(yt).clamp(),n=sc({dotVH:s,f0:em,f90:Bx}),a=t.mul(T0.mul(n).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(T0));t.assign(a)}if(this.sheen===!0){let s=t.add(this.sheenSpecularDirect,this.sheenSpecularIndirect);t.assign(s)}}},mL=2.399963229728653,yk=S(1),yM=S(-2),Fx=S(.8),AA=S(-1),Px=S(.4),MA=S(2),Dx=S(.305),SA=S(3),xk=S(.21),bL=S(4),wk=S(4),gL=S(16),yL=F(([r])=>{let e=C(bt(r)).toVar(),t=S(-1).toVar();return fe(e.x.greaterThan(e.z),()=>{fe(e.x.greaterThan(e.y),()=>{t.assign($s(r.x.greaterThan(0),0,3))}).Else(()=>{t.assign($s(r.y.greaterThan(0),1,4))})}).Else(()=>{fe(e.z.greaterThan(e.y),()=>{t.assign($s(r.z.greaterThan(0),2,5))}).Else(()=>{t.assign($s(r.y.greaterThan(0),1,4))})}),t}).setLayout({name:"getFace",type:"float",inputs:[{name:"direction",type:"vec3"}]}),xL=F(([r,e])=>{let t=Z().toVar();return fe(e.equal(0),()=>{t.assign(Z(r.z,r.y).div(bt(r.x)))}).ElseIf(e.equal(1),()=>{t.assign(Z(r.x.negate(),r.z.negate()).div(bt(r.y)))}).ElseIf(e.equal(2),()=>{t.assign(Z(r.x.negate(),r.y).div(bt(r.z)))}).ElseIf(e.equal(3),()=>{t.assign(Z(r.z.negate(),r.y).div(bt(r.x)))}).ElseIf(e.equal(4),()=>{t.assign(Z(r.x.negate(),r.z).div(bt(r.y)))}).Else(()=>{t.assign(Z(r.x,r.y).div(bt(r.z)))}),Te(.5,t.add(1))}).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),wL=F(([r])=>{let e=S(0).toVar();return fe(r.greaterThanEqual(Fx),()=>{e.assign(yk.sub(r).mul(AA.sub(yM)).div(yk.sub(Fx)).add(yM))}).ElseIf(r.greaterThanEqual(Px),()=>{e.assign(Fx.sub(r).mul(MA.sub(AA)).div(Fx.sub(Px)).add(AA))}).ElseIf(r.greaterThanEqual(Dx),()=>{e.assign(Px.sub(r).mul(SA.sub(MA)).div(Px.sub(Dx)).add(MA))}).ElseIf(r.greaterThanEqual(xk),()=>{e.assign(Dx.sub(r).mul(bL.sub(SA)).div(Dx.sub(xk)).add(SA))}).Else(()=>{e.assign(S(-2).mul(nr(Te(1.16,r))))}),e}).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),TL=F(([r,e,t,s,n,a])=>{let i=S(t),o=C(e),c=Hn(wL(i),yM,a),l=ja(c),h=zs(c),u=C(Ld(r,o,h,s,n,a)).toVar();return fe(l.notEqual(0),()=>{let d=C(Ld(r,o,h.add(1),s,n,a)).toVar();u.assign(Ke(u,d,l))}),u}),Ld=F(([r,e,t,s,n,a])=>{let i=S(t).toVar(),o=C(e),c=S(yL(o)).toVar(),l=S(Pt(wk.sub(i),0)).toVar();i.assign(Pt(i,wk));let h=S(Nd(i)).toVar(),u=Z(xL(o,c).mul(h.sub(2)).add(1)).toVar();return fe(c.greaterThan(2),()=>{u.y.addAssign(h),c.subAssign(3)}),u.x.addAssign(c.mul(h)),u.x.addAssign(l.mul(Te(3,gL))),u.y.addAssign(Te(4,Nd(a).sub(h))),u.x.mulAssign(s),u.y.mulAssign(n),r.sample(u).grad(Z(),Z())}),vL=F(({SAMPLES:r,sigma:e,outputDirection:t,mipInt:s,envMap:n,CUBEUV_TEXEL_WIDTH:a,CUBEUV_TEXEL_HEIGHT:i,CUBEUV_MAX_MIP:o})=>{let c=C(0).toVar();return fe(e.equal(0),()=>{c.assign(Ld(n,t,s,a,i,o))}).Else(()=>{let l=$s(bt(t.z).lessThan(.999),C(0,0,1),C(1,0,0)),h=Vs(Mi(l,t)).toVar(),u=Mi(t,h).toVar(),d=pa(e.mul(3),Math.PI),f=LT(d.mul(d).mul(-.5).div(e.mul(e))).oneMinus().toVar(),p=S(0).toVar();tt({start:k(0),end:r},({i:m})=>{let b=S(m).add(.5).div(S(r)),g=e.mul(fn(wb(b.mul(f).oneMinus()).mul(-2))).toVar(),x=S(m).mul(mL).toVar(),T=h.mul(Ln(x)).add(u.mul(_s(x))),y=t.mul(Ln(g)).add(T.mul(_s(g))),v=_s(g).div(g).toVar();c.addAssign(Ld(n,y,s,a,i,o).mul(v)),p.addAssign(v)}),c.divAssign(p)}),ce(c,1)}),_L=F(([r])=>{let e=V(r).toVar();return e.assign(e.shiftLeft(V(16)).bitOr(e.shiftRight(V(16)))),e.assign(e.bitAnd(V(1431655765)).shiftLeft(V(1)).bitOr(e.bitAnd(V(2863311530)).shiftRight(V(1)))),e.assign(e.bitAnd(V(858993459)).shiftLeft(V(2)).bitOr(e.bitAnd(V(3435973836)).shiftRight(V(2)))),e.assign(e.bitAnd(V(252645135)).shiftLeft(V(4)).bitOr(e.bitAnd(V(4042322160)).shiftRight(V(4)))),e.assign(e.bitAnd(V(16711935)).shiftLeft(V(8)).bitOr(e.bitAnd(V(4278255360)).shiftRight(V(8)))),S(e).mul(23283064365386963e-26)}),AL=F(([r,e])=>Z(S(r).div(S(e)),_L(r))),ML=F(([r,e,t])=>{let s=t.mul(t).toConst(),n=C(1,0,0).toConst(),a=Mi(e,n).toConst(),i=fn(r.x).toConst(),o=Te(2,3.14159265359).mul(r.y).toConst(),c=i.mul(Ln(o)).toConst(),l=i.mul(_s(o)).toVar(),h=Te(.5,e.z.add(1)).toConst();l.assign(h.oneMinus().mul(fn(c.mul(c).oneMinus())).add(h.mul(l)));let u=n.mul(c).add(a.mul(l)).add(e.mul(fn(Pt(0,c.mul(c).add(l.mul(l)).oneMinus()))));return Vs(C(s.mul(u.x),s.mul(u.y),Pt(0,u.z)))}),SL=F(({roughness:r,mipInt:e,envMap:t,N_immutable:s,GGX_SAMPLES:n,CUBEUV_TEXEL_WIDTH:a,CUBEUV_TEXEL_HEIGHT:i,CUBEUV_MAX_MIP:o})=>{let c=C(s).toVar(),l=C(0).toVar(),h=S(0).toVar();return fe(r.lessThan(.001),()=>{l.assign(Ld(t,c,e,a,i,o))}).Else(()=>{let u=$s(bt(c.z).lessThan(.999),C(0,0,1),C(1,0,0)),d=Vs(Mi(u,c)).toVar(),f=Mi(c,d).toVar();tt({start:V(0),end:n},({i:p})=>{let m=AL(p,n),b=ML(m,C(0,0,1),r),g=Vs(d.mul(b.x).add(f.mul(b.y)).add(c.mul(b.z))),x=Vs(g.mul(Gn(c,g).mul(2)).sub(c)),T=Pt(Gn(c,x),0);fe(T.greaterThan(0),()=>{let y=Ld(t,x,e,a,i,o);l.addAssign(y.mul(T)),h.addAssign(T)})}),fe(h.greaterThan(0),()=>{l.assign(l.div(h))})}),ce(l,1)}),yd=4,NL=6,RL=20,EL=256,tm=new ji(-1,1,1,-1,0,1),CL=new qt(90,1),Tk=new be,NA=null,RA=0,EA=0,kL=new E,yl=new E,pw=new WeakMap,IL=[3,1,5,0,4,2],QT=Rn("outputDirection").normalize(),mw=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._lodMeshes=[],this._blurMaterial=null,this._ggxMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._backgroundBox=null}get _hasInitialized(){return this._renderer.hasInitialized()}fromScene(e,t=0,s=.1,n=100,a={}){let{size:i=256,position:o=kL,renderTarget:c=null}=a;if(this._setSize(i),this._hasInitialized===!1)throw new Error('THREE.PMREMGenerator: .fromScene() called before the backend is initialized. Use "await renderer.init();" before using this method.');NA=this._renderer.getRenderTarget(),RA=this._renderer.getActiveCubeFace(),EA=this._renderer.getActiveMipmapLevel();let l=c||this._allocateTarget(!0);return this._init(l),this._sceneToCubeUV(e,s,n,l,o),t>0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}async fromSceneAsync(e,t=0,s=.1,n=100,a={}){return je('PMREMGenerator: ".fromSceneAsync()" is deprecated. Use "await renderer.init()" instead.'),await this._renderer.init(),this.fromScene(e,t,s,n,a)}fromEquirectangular(e,t=null){if(this._hasInitialized===!1)throw new Error('THREE.PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Use "await renderer.init();" before using this method.');return this._fromTexture(e,t)}async fromEquirectangularAsync(e,t=null){return je('PMREMGenerator: ".fromEquirectangularAsync()" is deprecated. Use "await renderer.init()" instead.'),await this._renderer.init(),this._fromTexture(e,t)}fromCubemap(e,t=null){if(this._hasInitialized===!1)throw new Error('THREE.PMREMGenerator: .fromCubemap() called before the backend is initialized. Use "await renderer.init();" before using this method.');return this._fromTexture(e,t)}async fromCubemapAsync(e,t=null){return je('PMREMGenerator: ".fromCubemapAsync()" is deprecated. Use "await renderer.init()" instead.'),await this._renderer.init(),this._fromTexture(e,t)}async compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=_k(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Ak(),await this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSizeFromTexture(e){e.mapping===Wi||e.mapping===ol?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4)}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(NA,RA,EA),e.scissorTest=!1,this._setViewport(e,0,0,e.width,e.height)}_fromTexture(e,t){this._setSizeFromTexture(e),NA=this._renderer.getRenderTarget(),RA=this._renderer.getActiveCubeFace(),EA=this._renderer.getActiveMipmapLevel();let s=t||this._allocateTarget(!1);return this._init(s),this._textureToCubeUV(e,s),this._applyPMREM(s),this._cleanup(s),s}_allocateTarget(e){let t=3*Math.max(this._cubeSize,112),s=4*this._cubeSize;return vk(t,s,e)}_init(e){if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e.width||this._pingPongRenderTarget.height!==e.height){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=vk(e.width,e.height);let{_lodMax:t}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods}=BL(t)),this._blurMaterial=FL(t,e.width,e.height),this._ggxMaterial=PL(t,e.width,e.height)}}async _compileMaterial(e){let t=new at(new ke,e);await this._renderer.compile(t,tm)}_sceneToCubeUV(e,t,s,n,a){let i=CL;i.near=t,i.far=s;let o=[1,1,1,1,-1,1],c=[1,-1,1,-1,1,-1],l=this._renderer,h=l.autoClear;l.getClearColor(Tk),l.autoClear=!1,this._backgroundBox===null&&(this._backgroundBox=new at(new kr,new Bt({name:"PMREM.Background",side:Xt,depthWrite:!1,depthTest:!1})));let u=this._backgroundBox,d=u.material,f=!1,p=e.background;p?p.isColor&&(d.color.copy(p),e.background=null,f=!0):(d.color.copy(Tk),f=!0),l.setRenderTarget(n),l.clear(),f&&l.render(u,i);for(let m=0;m<6;m++){let b=m%3;b===0?(i.up.set(0,o[m],0),i.position.set(a.x,a.y,a.z),i.lookAt(a.x+c[m],a.y,a.z)):b===1?(i.up.set(0,0,o[m]),i.position.set(a.x,a.y,a.z),i.lookAt(a.x,a.y+c[m],a.z)):(i.up.set(0,o[m],0),i.position.set(a.x,a.y,a.z),i.lookAt(a.x,a.y,a.z+c[m]));let g=this._cubeSize;this._setViewport(n,b*g,m>2?g:0,g,g),l.render(e,i)}l.autoClear=h,e.background=p}_textureToCubeUV(e,t){let s=this._renderer,n=e.mapping===Wi||e.mapping===ol;n?this._cubemapMaterial===null&&(this._cubemapMaterial=_k(e)):this._equirectMaterial===null&&(this._equirectMaterial=Ak(e));let a=n?this._cubemapMaterial:this._equirectMaterial;a.fragmentNode.value=e;let i=this._lodMeshes[0];i.material=a;let o=this._cubeSize;this._setViewport(t,0,0,3*o,2*o),s.setRenderTarget(t),s.render(i,tm)}_applyPMREM(e){let t=this._renderer,s=t.autoClear;t.autoClear=!1;let n=this._lodMeshes.length;for(let a=1;a<n;a++)this._applyGGXFilter(e,a-1,a);t.autoClear=s}_applyGGXFilter(e,t,s){let n=this._renderer,a=this._pingPongRenderTarget,i=this._ggxMaterial,o=this._lodMeshes[s];o.material=i;let c=pw.get(i),l=s/(this._lodMeshes.length-1),h=t/(this._lodMeshes.length-1),u=Math.sqrt(l*l-h*h),d=l*1.25,f=u*d,{_lodMax:p}=this,m=this._sizeLods[s],b=3*m*(s>p-yd?s-p+yd:0),g=4*(this._cubeSize-m);e.texture.frame=(e.texture.frame||0)+1,c.envMap.value=e.texture,c.roughness.value=f,c.mipInt.value=p-t,this._setViewport(a,b,g,3*m,2*m),n.setRenderTarget(a),n.render(o,tm),a.texture.frame=(a.texture.frame||0)+1,c.envMap.value=a.texture,c.roughness.value=0,c.mipInt.value=p-s,this._setViewport(e,b,g,3*m,2*m),n.setRenderTarget(e),n.render(o,tm)}_blur(e,t,s,n){let a=this._pingPongRenderTarget,i=Math.min(n,Math.PI)/Math.SQRT2;this._blurPass(e,a,t,s,i),this._blurPass(a,e,s,s,i)}_blurPass(e,t,s,n,a){let i=this._renderer,o=this._blurMaterial,c=this._lodMeshes[n];c.material=o;let l=pw.get(o);e.texture.frame=(e.texture.frame||0)+1,l.envMap.value=e.texture,l.sigma.value=a,l.mipInt.value=this._lodMax-s;let h=this._sizeLods[n],u=3*h*(n>this._lodMax-yd?n-this._lodMax+yd:0),d=4*(this._cubeSize-h);this._setViewport(t,u,d,3*h,2*h),i.setRenderTarget(t),i.render(c,tm)}_setViewport(e,t,s,n,a){this._renderer.isWebGLRenderer?(e.viewport.set(t,e.height-a-s,n,a),e.scissor.set(t,e.height-a-s,n,a)):(e.viewport.set(t,s,n,a),e.scissor.set(t,s,n,a))}};function BL(r){let e=[],t=[],s=r,n=r-yd+1+NL;for(let a=0;a<n;a++){let i=Math.pow(2,s);e.push(i);let o=1/(i-2),c=-o,l=1+o,h=[c,c,l,c,l,l,c,c,l,l,c,l],u=6,d=6,f=3,p=new Float32Array(f*d*u),m=new Float32Array(f*d*u);for(let g=0;g<u;g++){let x=g%3*2/3-1,T=g>2?0:-1,y=[x,T,0,x+2/3,T,0,x+2/3,T+1,0,x,T,0,x+2/3,T+1,0,x,T+1,0],v=IL[g];p.set(y,f*d*v);for(let _=0;_<d;_++){let A=h[_*2]*2-1,M=h[_*2+1]*2-1;v===0?yl.set(1,M,A):v===1?yl.set(-A,1,-M):v===2?yl.set(-A,M,1):v===3?yl.set(-1,M,-A):v===4?yl.set(-A,-1,M):yl.set(A,M,-1),yl.toArray(m,(v*d+_)*f)}}let b=new ke;b.setAttribute("position",new Xe(p,f)),b.setAttribute("outputDirection",new Xe(m,f)),t.push(new at(b,null)),s>yd&&s--}return{lodMeshes:t,sizeLods:e}}function vk(r,e,t){let s={magFilter:Ye,minFilter:Ye,generateMipmaps:!1,type:ds,format:gs,colorSpace:nn,depthBuffer:t},n=new Ps(r,e,s);return n.texture.mapping=cl,n.texture.name="PMREM.cubeUv",n.texture.isPMREMTexture=!0,n.scissorTest=!0,n}function ev(r){let e=new wt;return e.depthTest=!1,e.depthWrite=!1,e.blending=Ca,e.name=`PMREM_${r}`,e}function FL(r,e,t){let s=et(),n=xe(0),a=xe(0),i=S(1/e),o=S(1/t),c=S(r),l={envMap:s,sigma:n,mipInt:a,CUBEUV_TEXEL_WIDTH:i,CUBEUV_TEXEL_HEIGHT:o,CUBEUV_MAX_MIP:c},h=ev("blur");return h.fragmentNode=vL({...l,outputDirection:QT,SAMPLES:k(RL)}),pw.set(h,l),h}function PL(r,e,t){let s=et(),n=xe(0),a=xe(0),i=S(1/e),o=S(1/t),c=S(r),l={envMap:s,roughness:n,mipInt:a,CUBEUV_TEXEL_WIDTH:i,CUBEUV_TEXEL_HEIGHT:o,CUBEUV_MAX_MIP:c},h=ev("ggx");return h.fragmentNode=SL({...l,N_immutable:QT,GGX_SAMPLES:V(EL)}),pw.set(h,l),h}function _k(r){let e=ev("cubemap");return e.fragmentNode=Nn(r,QT),e}function Ak(r){let e=ev("equirect");return e.fragmentNode=et(r,_N(QT),0),e}var Mk=new WeakMap;function DL(r){let e=Math.log2(r)-2,t=1/r;return{texelWidth:1/(3*Math.max(Math.pow(2,e),112)),texelHeight:t,maxMip:e}}function OL(r,e,t){let s=UL(e),n=s.get(r);if((n!==void 0?n.pmremVersion:-1)!==r.pmremVersion){let i=r.image;if(r.isCubeTexture)if(LL(i))n=t.fromCubemap(r,n);else return null;else if(zL(i))n=t.fromEquirectangular(r,n);else return null;if(n.pmremVersion=r.pmremVersion,s.has(r)===!1){let o=()=>{r.removeEventListener("dispose",o);let c=s.get(r);c!==void 0&&(c.dispose(),s.delete(r))};r.addEventListener("dispose",o)}s.set(r,n)}return n.texture}function UL(r){let e=Mk.get(r);return e===void 0&&(e=new WeakMap,Mk.set(r,e)),e}var bw=class extends xt{static get type(){return"PMREMNode"}constructor(e,t=null,s=null){super("vec3"),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=s,this._generator=null;let n=new gt;n.isRenderTargetTexture=!0,this._texture=et(n),this._width=xe(0),this._height=xe(0),this._maxMip=xe(0),this.updateBeforeType=Me.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){let t=DL(e.image.height);this._texture.value=e,this._width.value=t.texelWidth,this._height.value=t.texelHeight,this._maxMip.value=t.maxMip}updateBefore(e){let t=this._pmrem,s=t?t.pmremVersion:-1,n=this._value;s!==n.pmremVersion&&(n.isPMREMTexture===!0||n.mapping===cl?t=n:t=OL(n,e.renderer,this._generator),t!==null&&(this._pmrem=t,this.updateFromTexture(t)))}setup(e){this._generator===null&&(this._generator=new mw(e.renderer)),this.updateBefore(e);let t=this.uvNode;t===null&&e.context.getUV&&(t=e.context.getUV(this,e)),t=this._pmrem===null||this._pmrem.isRenderTargetTexture?X0.mul(C(t.x,t.y.negate(),t.z)):X0.mul(t);let s=this.levelNode;return s===null&&e.context.getTextureLevel&&(s=e.context.getTextureLevel(this)),TL(this._texture,t,s,this._width,this._height,this._maxMip)}dispose(){super.dispose(),this._generator!==null&&this._generator.dispose()}};function LL(r){if(r==null)return!1;let e=0,t=6;for(let s=0;s<t;s++)r[s]!==void 0&&e++;return e===t}function zL(r){return r==null?!1:r.height>0}var RN=He(bw).setParameterLength(1,3),Sk=new WeakMap,gw=class extends ao{static get type(){return"EnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){let{material:t}=e,s=this.envNode;if(s.isTextureNode||s.isMaterialReferenceNode){let h=s.isTextureNode?s.value:t[s.property],u=this._getPMREMNodeCache(e.renderer),d=u.get(h);d===void 0&&(d=RN(h),u.set(h,d)),s=d}let a=t.useAnisotropy===!0||t.anisotropy>0?_B:Qe,i=Nl(s.context(Nk(Oa,a)).mul(gm));if(t.useRetroreflection===!0||t.retroreflectivity>0){let h=Nl(s.context(VL(Oa,a)).mul(gm));i=Bm.clamp().mix(i,h)}let o=s.context(jL(gc)).mul(Math.PI).mul(gm),c=Nl(o);e.context.radiance.addAssign(i),e.context.iblIrradiance.addAssign(c);let l=e.context.lightingModel.clearcoatRadiance;if(l){let h=s.context(Nk(Td,$o)).mul(gm),u=Nl(h);l.addAssign(u)}}_getPMREMNodeCache(e){let t=Sk.get(e);return t===void 0&&(t=new WeakMap,Sk.set(e,t)),t}},Nk=(r,e)=>{let t=null;return{getUV:()=>(t===null&&(t=yt.negate().reflect(e),t=VT(r).mix(t,e).normalize(),t=t.transformDirection(Yl)),t),getTextureLevel:()=>r}},VL=(r,e)=>{let t=null;return{getUV:()=>(t===null&&(t=VT(r).mix(yt,e).normalize(),t=t.transformDirection(Yl)),t),getTextureLevel:()=>r}},jL=r=>({getUV:()=>r,getTextureLevel:()=>S(1)}),GL=new An,Wl=class extends wt{static get type(){return"MeshStandardNodeMaterial"}constructor(e){super(),this.isMeshStandardNodeMaterial=!0,this.lights=!0,this.emissiveNode=null,this.metalnessNode=null,this.roughnessNode=null,this.setDefaultValues(GL),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t===null&&e.environmentNode&&(t=e.environmentNode),t?new gw(t):null}setupLightingModel(){return new Ud}setupSpecular(){let e=Ke(C(.04),rt.rgb,Qo);wi.assign(C(.04)),Jr.assign(e),tr.assign(1)}setupVariants(){let e=this.metalnessNode?S(this.metalnessNode):FB;Qo.assign(e);let t=this.roughnessNode?S(this.roughnessNode):BB;t=AN({roughness:t}),Oa.assign(t),this.setupSpecular(),Sl.assign(rt.rgb.mul(e.oneMinus()))}},HL=new xs,ql=class extends Wl{static get type(){return"MeshPhysicalNodeMaterial"}constructor(e){super(),this.isMeshPhysicalNodeMaterial=!0,this.clearcoatNode=null,this.clearcoatRoughnessNode=null,this.clearcoatNormalNode=null,this.sheenNode=null,this.sheenRoughnessNode=null,this.iridescenceNode=null,this.iridescenceIORNode=null,this.iridescenceThicknessNode=null,this.specularIntensityNode=null,this.specularColorNode=null,this.iorNode=null,this.transmissionNode=null,this.thicknessNode=null,this.attenuationDistanceNode=null,this.attenuationColorNode=null,this.dispersionNode=null,this.retroreflectivityNode=null,this.anisotropyNode=null,this.setDefaultValues(HL),this.setValues(e)}get useClearcoat(){return this.clearcoat>0||this.clearcoatNode!==null}get useIridescence(){return this.iridescence>0||this.iridescenceNode!==null}get useSheen(){return this.sheen>0||this.sheenNode!==null}get useAnisotropy(){return this.anisotropy>0||this.anisotropyNode!==null}get useTransmission(){return this.transmission>0||this.transmissionNode!==null}get useDispersion(){return this.dispersion>0||this.dispersionNode!==null}get useRetroreflection(){return this.retroreflectivity>0||this.retroreflectivityNode!==null}setupSpecular(){let e=this.iorNode?S(this.iorNode):KB,t=this.specularColorNode?C(this.specularColorNode):IB,s=this.specularIntensityNode?S(this.specularIntensityNode):kB;_m.assign(e),wi.assign(pa(L1(_m.sub(1).div(_m.add(1))).mul(t),C(1)).mul(s)),Jr.assign(Ke(wi,rt.rgb,Qo)),tr.assign(Ke(s,1,Qo))}setupLightingModel(){return new Ud(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion,this.useRetroreflection)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){let t=this.clearcoatNode?S(this.clearcoatNode):DB,s=this.clearcoatRoughnessNode?S(this.clearcoatRoughnessNode):OB;T0.assign(t),Td.assign(AN({roughness:s}))}if(this.useSheen){let t=this.sheenNode?C(this.sheenNode):zB,s=this.sheenRoughnessNode?S(this.sheenRoughnessNode):VB;Un.assign(t),Jo.assign(s)}if(this.useRetroreflection){let t=this.retroreflectivityNode?S(this.retroreflectivityNode):QB;Bm.assign(t)}if(this.useIridescence){let t=this.iridescenceNode?S(this.iridescenceNode):GB,s=this.iridescenceIORNode?S(this.iridescenceIORNode):HB,n=this.iridescenceThicknessNode?S(this.iridescenceThicknessNode):WB;OT.assign(t),v0.assign(s),_0.assign(n)}if(this.useAnisotropy){let t=(this.anisotropyNode?Z(this.anisotropyNode):jB).toVar();Ko.assign(t.length()),fe(Ko.equal(0),()=>{t.assign(Z(1,0))}).Else(()=>{t.divAssign(Z(Ko)),Ko.assign(Ko.saturate())}),A0.assign(Ko.pow2().mix(Oa.pow2(),1)),vm.assign(Rl[0].mul(t.x).add(Rl[1].mul(t.y))),Il.assign(Rl[1].mul(t.x).sub(Rl[0].mul(t.y)))}if(this.useTransmission){let t=this.transmissionNode?S(this.transmissionNode):qB,s=this.thicknessNode?S(this.thicknessNode):XB,n=this.attenuationDistanceNode?S(this.attenuationDistanceNode):JB,a=this.attenuationColorNode?C(this.attenuationColorNode):$B;if(S0.assign(t),v1.assign(s),_1.assign(n),A1.assign(a),this.useDispersion){let i=this.dispersionNode?S(this.dispersionNode):ZB;M1.assign(i)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?C(this.clearcoatNormalNode):UB}setup(e){e.context.setupClearcoatNormal=()=>Pl(this.setupClearcoatNormal(e),"NORMAL","vec3"),super.setup(e)}},xM=class extends Ud{constructor(e=!1,t=!1,s=!1,n=!1,a=!1,i=!1,o=!1){super(e,t,s,n,a,i),this.useSSS=o}direct({lightDirection:e,lightColor:t,reflectedLight:s},n){if(this.useSSS===!0){let a=n.material,{thicknessColorNode:i,thicknessDistortionNode:o,thicknessAmbientNode:c,thicknessAttenuationNode:l,thicknessPowerNode:h,thicknessScaleNode:u}=a,d=e.add(Qe.mul(o)).normalize(),f=S(yt.dot(d.negate()).saturate().pow(h).mul(u)),p=C(f.add(c).mul(i));s.directDiffuse.addAssign(p.mul(l.mul(t)))}super.direct({lightDirection:e,lightColor:t,reflectedLight:s},n)}},wM=class extends ql{static get type(){return"MeshSSSNodeMaterial"}constructor(e){super(e),this.thicknessColorNode=null,this.thicknessDistortionNode=S(.1),this.thicknessAmbientNode=S(0),this.thicknessAttenuationNode=S(.1),this.thicknessPowerNode=S(2),this.thicknessScaleNode=S(10)}get useSSS(){return this.thicknessColorNode!==null}setupLightingModel(){return new xM(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion,this.useSSS)}},WL=F(({normal:r,lightDirection:e,builder:t})=>{let s=r.dot(e),n=Z(s.mul(.5).add(.5),0);if(t.material.gradientMap){let a=Qr("gradientMap","texture").context({getUV:()=>n});return C(a.r)}else{let a=n.fwidth().mul(.5);return Ke(C(.7),C(1),ma(S(.7).sub(a.x),S(.7).add(a.x),n.x))}}),TM=class extends oc{direct({lightDirection:e,lightColor:t,reflectedLight:s},n){let a=WL({normal:Qe,lightDirection:e,builder:n}).mul(t);s.directDiffuse.addAssign(a.mul(Hl({diffuseColor:rt.rgb})))}indirect(e){let{ambientOcclusion:t,irradiance:s,reflectedLight:n}=e.context;n.indirectDiffuse.addAssign(s.mul(Hl({diffuseColor:rt}))),n.indirectDiffuse.mulAssign(t)}},qL=new No,zd=class extends wt{static get type(){return"MeshToonNodeMaterial"}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(qL),this.setValues(e)}setupLightingModel(){return new TM}},DF=F(()=>{let r=C(yt.z,0,yt.x.negate()).normalize(),e=yt.cross(r);return Z(r.dot(Qe),e.dot(Qe)).mul(.495).add(.5)}).once(["NORMAL","VERTEX"])().toVar("matcapUV"),XL=new Eo,Vd=class extends wt{static get type(){return"MeshMatcapNodeMaterial"}constructor(e){super(),this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(XL),this.setValues(e)}setupVariants(e){let t=DF,s;e.material.matcap?s=Qr("matcap","texture").context({getUV:()=>t}):s=C(Ke(.2,.8,t.y)),rt.rgb.mulAssign(s.rgb)}},yw=class extends xt{static get type(){return"RotateNode"}constructor(e,t,s="XYZ"){super(),this.positionNode=e,this.rotationNode=t,this._order=s}customCacheKey(){return fc(this._order)}setOrder(e){return this._order=e,this}getOrder(){return this._order}generateNodeType(e){return this.positionNode.getNodeType(e)}setup(e){let{rotationNode:t,positionNode:s}=this;if(this.getNodeType(e)==="vec2"){let a=t.cos(),i=t.sin();return DT(a,i,i.negate(),a).mul(s)}else{let a=t,i=this._order,o=so(ce(1,0,0,0),ce(0,Ln(a.x),_s(a.x),0),ce(0,_s(a.x).negate(),Ln(a.x),0),ce(0,0,0,1)),c=so(ce(Ln(a.y),0,_s(a.y).negate(),0),ce(0,1,0,0),ce(_s(a.y),0,Ln(a.y),0),ce(0,0,0,1)),l=so(ce(Ln(a.z),_s(a.z),0,0),ce(_s(a.z).negate(),Ln(a.z),0,0),ce(0,0,1,0),ce(0,0,0,1)),h={X:o,Y:c,Z:l};return h[i.charAt(0)].mul(h[i.charAt(1)]).mul(h[i.charAt(2)]).mul(ce(s,1)).xyz}}serialize(e){super.serialize(e),e.order=this._order}deserialize(e){super.deserialize(e),this._order=e.order}},tv=He(yw).setParameterLength(2,3),KL=new Vc,Hm=class extends wt{static get type(){return"SpriteNodeMaterial"}constructor(e){super(),this.isSpriteNodeMaterial=!0,this._useSizeAttenuation=!0,this.positionNode=null,this.rotationNode=null,this.scaleNode=null,this.transparent=!0,this.setDefaultValues(KL),this.setValues(e)}setupPositionView(e){let{object:t,camera:s}=e,{positionNode:n,rotationNode:a,scaleNode:i,sizeAttenuation:o}=this,c=or.mul(C(n||0)),l=Z(da[0].xyz.length(),da[1].xyz.length());i!==null&&(l=l.mul(Z(i))),s.isPerspectiveCamera&&o===!1&&(l=l.mul(c.z.negate()));let h=vs.xy;if(t.center&&t.center.isVector2===!0){let f=DO("center","vec2",t);h=h.sub(f.sub(.5))}h=h.mul(l);let u=S(a||LB),d=tv(h,u);return ce(c.xy.add(d),c.zw)}get sizeAttenuation(){return this._useSizeAttenuation}set sizeAttenuation(e){this._useSizeAttenuation!==e&&(this._useSizeAttenuation=e,this.needsUpdate=!0)}},JL=new Cr,$L=new q,xw=class extends Hm{static get type(){return"PointsNodeMaterial"}constructor(e){super(),this.sizeNode=null,this.isPointsNodeMaterial=!0,this.setDefaultValues(JL),this.setValues(e)}setupPositionView(){let{positionNode:e}=this;return or.mul(C(e||Ct)).xyz}setupVertexSprite(e){let{material:t,camera:s}=e,{rotationNode:n,scaleNode:a,sizeNode:i,sizeAttenuation:o}=this,c=super.setupVertex(e);if(t.isNodeMaterial!==!0)return c;let l=i!==null?Z(i):YB;l=l.mul(Q1),s.isPerspectiveCamera&&o===!0&&(l=l.mul(YL.div($t.z.negate()))),a&&a.isNode&&(l=l.mul(Z(a)));let h=vs.xy;if(n&&n.isNode){let u=S(n);h=tv(h,u)}return h=h.mul(l),h=h.div(eN.div(2)),h=h.mul(c.w),c=c.add(ce(h,0,0)),c}setupVertex(e){return e.object.isPoints?super.setupVertex(e):this.setupVertexSprite(e)}get alphaToCoverage(){return this._useAlphaToCoverage}set alphaToCoverage(e){this._useAlphaToCoverage!==e&&(this._useAlphaToCoverage=e,this.needsUpdate=!0)}},YL=xe(1).setGroup(ye).onRenderUpdate(function({renderer:r}){let e=r.getSize($L);this.value=.5*e.y}),vM=class extends oc{constructor(){super(),this.shadowNode=S(1).toVar("shadowMask")}direct({lightNode:e}){e.shadowNode!==null&&this.shadowNode.mulAssign(e.shadowNode)}finish({context:e}){rt.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(rt.rgb)}},ZL=new iu,ww=class extends wt{static get type(){return"ShadowNodeMaterial"}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.transparent=!0,this.setDefaultValues(ZL),this.setValues(e)}setupLightingModel(){return new vM}},sd=za("vec3"),Rk=za("vec3"),Ox=za("vec3"),_M=class extends oc{constructor(){super()}start(e){let{material:t}=e,s=za("vec3"),n=za("vec3"),a=za("bool");fe(_d.sub(Vn).length().greaterThan($9.mul(2)),()=>{s.assign(_d),n.assign(Vn),a.assign(!0)}).Else(()=>{s.assign(Vn),n.assign(_d),a.assign(!1)});let i=n.sub(s),o=xe("int").onRenderUpdate(({material:d})=>d.steps),c=i.length().div(o).toVar(),l=i.normalize().toVar(),h=S(0).toVar(),u=C(1).toVar();t.offsetNode&&h.addAssign(t.offsetNode.mul(c)),tt(o,()=>{let d=s.add(l.mul(h)),f=Ua.mul(ce(d,1)).xyz;t.depthNode!==null&&(Rk.assign(Bd(JT(f.z,Yr,Zr))),e.context.sceneDepthNode=Bd(t.depthNode).toVar()),e.context.positionWorld=d,e.context.shadowPositionWorld=d,e.context.positionView=f,sd.assign(0);let p,m;t.scatteringNode&&(p=t.scatteringNode({positionRay:d})),t.scatteringEmissiveNode&&(m=t.scatteringEmissiveNode({positionRay:d})),super.start(e),p&&sd.mulAssign(p);let b=sd.mul(.01).toVar();m&&b.addAssign(m.mul(.01));let g=sd.mul(.01).negate().mul(c).exp();fe(a,()=>{Ox.addAssign(b.mul(u).mul(c))}).Else(()=>{Ox.assign(Ox.mul(g).add(b.mul(c)))}),u.mulAssign(g),h.addAssign(c)})}scatteringLight(e,t){let s=t.context.sceneDepthNode;s?fe(s.greaterThanEqual(Rk),()=>{sd.addAssign(e)}):sd.addAssign(e)}direct({lightNode:e,lightColor:t},s){if(e.isAnalyticLightNode!==!0||e.light.distance===void 0)return;let n=t.xyz.toVar();e.shadowNode!==null&&n.mulAssign(e.shadowNode),this.scatteringLight(n,s)}directRectArea({lightColor:e,lightPosition:t,halfWidth:s,halfHeight:n},a){let i=t.add(s).sub(n),o=t.sub(s).sub(n),c=t.sub(s).add(n),l=t.add(s).add(n),h=a.context.positionView,u=e.xyz.mul(BF({P:h,p0:i,p1:o,p2:c,p3:l})).pow(1.5);this.scatteringLight(u,a)}finish(e){e.context.outgoingLight.assign(Ox)}},AM=class extends wt{static get type(){return"VolumeNodeMaterial"}constructor(e){super(),this.isVolumeNodeMaterial=!0,this.steps=25,this.offsetNode=null,this.scatteringNode=null,this.lights=!0,this.transparent=!0,this.side=Xt,this.depthTest=!1,this.depthWrite=!1,this.setValues(e)}setupLightingModel(){return new _M}},MM=class{constructor(e,t,s){this.renderer=e,this.nodes=t,this.info=s,this._context=typeof self<"u"?self:null,this._animationLoop=null,this._requestId=null}start(){let e=(t,s)=>{this._requestId=this._context.requestAnimationFrame(e),this.renderer._inspector.isRunning&&this.renderer._inspector.finish(),this.info.autoReset===!0&&this.info.reset(),this.nodes.nodeFrame.update(),this.info.frame=this.nodes.nodeFrame.frameId,this.renderer._inspector.begin(),this._animationLoop!==null&&this._animationLoop(t,s)};e()}stop(){this.renderer._inspector.isRunning&&this.renderer._inspector.finish(),this._context!==null&&this._context.cancelAnimationFrame(this._requestId),this._requestId=null}getAnimationLoop(){return this._animationLoop}setAnimationLoop(e){this._animationLoop=e}getContext(){return this._context}setContext(e){this._context=e}dispose(){this.stop()}},lr=class{constructor(){this.weakMaps={}}_getWeakMap(e){let t=e.length,s=this.weakMaps[t];return s===void 0&&(s=new WeakMap,this.weakMaps[t]=s),s}get(e){let t=this._getWeakMap(e);for(let s=0;s<e.length-1;s++)if(t=t.get(e[s]),t===void 0)return;return t.get(e[e.length-1])}set(e,t){let s=this._getWeakMap(e);for(let n=0;n<e.length-1;n++){let a=e[n];s.has(a)===!1&&s.set(a,new WeakMap),s=s.get(a)}return s.set(e[e.length-1],t),this}delete(e){let t=this._getWeakMap(e);for(let s=0;s<e.length-1;s++)if(t=t.get(e[s]),t===void 0)return!1;return t.delete(e[e.length-1])}},QL=0,Ek=new WeakMap;function ez(r){let e=Object.keys(r),t=Ek.get(r.constructor);if(t===void 0){t=[];let s=Object.getPrototypeOf(r);for(;s;){let n=Object.getOwnPropertyDescriptors(s);for(let a in n){let i=n[a];i&&typeof i.get=="function"&&t.push(a)}s=Object.getPrototypeOf(s)}Ek.set(r.constructor,t)}for(let s=0;s<t.length;s++)e.push(t[s]);return e}var SM=class{constructor(e,t,s,n,a,i,o,c,l,h){this.id=QL++,this._nodes=e,this._geometries=t,this.renderer=s,this.object=n,this.material=a,this.scene=i,this.camera=o,this.lightsNode=c,this.context=l,this.geometry=n.geometry,this.version=a.version,this.drawRange=null,this.attributes=null,this.attributesId=null,this.pipeline=null,this.group=null,this.vertexBuffers=null,this.drawParams=null,this.bundle=null,this.clippingContext=h,this.clippingContextCacheKey=h!==null?h.cacheKey:"",this.initialNodesCacheKey=this.getDynamicCacheKey(),this.initialCacheKey=this.getCacheKey(),this._nodeBuilderState=null,this._bindings=null,this._monitor=null,this._sourceMaterial=s._currentSourceMaterial,this.onDispose=null,this.isRenderObject=!0,this.onMaterialDispose=()=>{this.dispose()},this.onGeometryDispose=()=>{this.attributes=null,this.attributesId=null},this.onObjectDispose=()=>{this.dispose()},this.object.addEventListener("dispose",this.onObjectDispose),this.material.addEventListener("dispose",this.onMaterialDispose),this.geometry.addEventListener("dispose",this.onGeometryDispose),this._sourceMaterial!==null&&this._sourceMaterial.addEventListener("dispose",this.onMaterialDispose)}updateClipping(e){this.clippingContext=e}get clippingNeedsUpdate(){return this.clippingContext===null||this.clippingContext.cacheKey===this.clippingContextCacheKey?!1:(this.clippingContextCacheKey=this.clippingContext.cacheKey,!0)}get hardwareClippingPlanes(){return this.getNodeBuilderState().hardwareClipping===!0?this.clippingContext.unionClippingCount:0}getNodeBuilderState(){return this._nodeBuilderState||(this._nodeBuilderState=this._nodes.getForRender(this))}getMonitor(){return this._monitor||(this._monitor=this.getNodeBuilderState().observer)}getBindings(){return this._bindings||(this._bindings=this.getNodeBuilderState().createBindings())}getBindingGroup(e){for(let t of this.getBindings())if(t.name===e)return t}getIndex(){return this._geometries.getIndex(this)}getIndirect(){return this._geometries.getIndirect(this)}getIndirectOffset(){return this._geometries.getIndirectOffset(this)}getChainArray(){return[this.object,this.material,this.context,this.lightsNode]}setGeometry(e){this.geometry=e,this.attributes=null,this.attributesId=null}getAttributes(){if(this.attributes!==null)return this.attributes;let e=this.getNodeBuilderState().nodeAttributes,t=this.geometry,s=[],n=new Set,a={};for(let i of e){let o;if(i.node&&i.node.attribute?o=i.node.attribute:(o=t.getAttribute(i.name),o!==void 0&&(o.isInterleavedBufferAttribute?a[i.name]=o.data.uuid:a[i.name]=o.id)),o===void 0)continue;s.push(o);let c=o.isInterleavedBufferAttribute?o.data:o;n.add(c)}return this.attributes=s,this.attributesId=a,this.vertexBuffers=Array.from(n.values()),s}getVertexBuffers(){return this.vertexBuffers===null&&this.getAttributes(),this.vertexBuffers}getDrawParameters(){let{object:e,material:t,geometry:s,group:n,drawRange:a}=this,i=this.drawParams||(this.drawParams={vertexCount:0,firstVertex:0,instanceCount:0,firstInstance:0}),o=this.getIndex(),c=o!==null,l=1;if(s.isInstancedBufferGeometry===!0?l=s.instanceCount:e.count!==void 0&&(l=Math.max(0,e.count)),l===0)return null;if(i.instanceCount=l,e.isBatchedMesh===!0)return i;let h=1;t.wireframe===!0&&!e.isPoints&&!e.isLineSegments&&!e.isLine&&!e.isLineLoop&&(h=2);let u=a.start*h,d=(a.start+a.count)*h;n!==null&&(u=Math.max(u,n.start*h),d=Math.min(d,(n.start+n.count)*h));let f=s.attributes.position,p=1/0;c?p=o.count:f!=null&&(p=f.count),u=Math.max(u,0),d=Math.min(d,p);let m=d-u;return m<0||m===1/0?null:(i.vertexCount=m,i.firstVertex=u,i)}getGeometryCacheKey(){let{geometry:e}=this,t="";for(let s of Object.keys(e.attributes).sort()){let n=e.attributes[s];t+=s+",",n.data&&(t+=n.data.stride+","),n.offset&&(t+=n.offset+","),n.itemSize&&(t+=n.itemSize+","),n.normalized&&(t+="n,")}for(let s of Object.keys(e.morphAttributes).sort()){let n=e.morphAttributes[s];t+="morph-"+s+",";for(let a=0,i=n.length;a<i;a++){let o=n[a];t+=o.id+","}}return e.index&&(t+="index,"),t}getMaterialCacheKey(){let{object:e,material:t,renderer:s}=this,n=t.customProgramCacheKey();for(let a of ez(t)){if(/^(is[A-Z]|_)|^(visible|version|uuid|name|opacity|userData)$/.test(a))continue;let i=t[a],o;if(i!==null){let c=typeof i;c==="number"?a==="side"?o=String(i):o=i!==0?"1":"0":c==="object"?(o="{",i.isTexture&&(o+=i.mapping,s.backend.isWebGPUBackend===!0&&(o+=i.magFilter,o+=i.minFilter,o+=i.wrapS,o+=i.wrapT,o+=i.wrapR)),o+="}"):o=String(i)}else o=String(i);n+=o+","}return n+=this.clippingContextCacheKey+",",e.geometry&&(n+=this.getGeometryCacheKey()),e.skeleton&&(n+=e.skeleton.bones.length+","),e.isBatchedMesh&&(n+=e._matricesTexture.uuid+",",e._colorsTexture!==null&&(n+=e._colorsTexture.uuid+",")),(e.isInstancedMesh||e.count>1)&&(n+=e.uuid+","),n+=this.context.id+",",n+=e.receiveShadow+",",fc(n)}get needsGeometryUpdate(){if(this.geometry.id!==this.object.geometry.id)return!0;if(this.attributes!==null){let e=this.attributesId;for(let t in e){let s=this.geometry.getAttribute(t);if(s===void 0)return!0;let n=s.isInterleavedBufferAttribute?s.data.uuid:s.id;if(e[t]!==n)return!0}}return!1}get needsUpdate(){return this.initialNodesCacheKey!==this.getDynamicCacheKey()||this.clippingNeedsUpdate}getDynamicCacheKey(){let e=0;return this.material.isShadowPassMaterial!==!0&&(e=this._nodes.getCacheKey(this.scene,this.lightsNode)),this.camera.isArrayCamera&&(e=wd(e,this.camera.cameras.length)),this.object.receiveShadow&&(e=wd(e,1)),e=wd(e,this.renderer.contextNode.id,this.renderer.contextNode.version),e}getCacheKey(){return this.getMaterialCacheKey()+this.getDynamicCacheKey()}dispose(){this.object.removeEventListener("dispose",this.onObjectDispose),this.material.removeEventListener("dispose",this.onMaterialDispose),this.geometry.removeEventListener("dispose",this.onGeometryDispose),this._sourceMaterial!==null&&this._sourceMaterial.removeEventListener("dispose",this.onMaterialDispose),this.onDispose()}},Yi=[],NM=class{constructor(e,t,s,n,a,i){this.renderer=e,this.nodes=t,this.geometries=s,this.pipelines=n,this.bindings=a,this.info=i,this._chainMaps={},this._renderObjects=new Set}get(e,t,s,n,a,i,o,c){let l=this.getChainMap(c);Yi[0]=e,Yi[1]=t,Yi[2]=i,Yi[3]=a;let h=l.get(Yi);return h===void 0?(h=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,s,n,a,i,o,c),l.set(Yi,h)):(h.camera=n,h.updateClipping(o),h.needsGeometryUpdate&&h.setGeometry(e.geometry),(h.version!==t.version||h.needsUpdate)&&(h.initialCacheKey!==h.getCacheKey()?(h.dispose(),h=this.get(e,t,s,n,a,i,o,c)):h.version=t.version)),Yi[0]=null,Yi[1]=null,Yi[2]=null,Yi[3]=null,h}getChainMap(e="default"){return this._chainMaps[e]||(this._chainMaps[e]=new lr)}dispose(){for(let e of this._renderObjects)e.dispose();this._renderObjects.clear(),this._chainMaps={}}createRenderObject(e,t,s,n,a,i,o,c,l,h,u){let d=this.getChainMap(u),f=new SM(e,t,s,n,a,i,o,c,l,h);return f.onDispose=()=>{this.pipelines.delete(f),this.bindings.deleteForRender(f),this.nodes.delete(f),d.delete(f.getChainArray()),this._renderObjects.delete(f)},this._renderObjects.add(f),f}},hr=class{constructor(){this.data=new WeakMap}get(e){let t=this.data.get(e);return t===void 0&&(t={},this.data.set(e,t)),t}delete(e){let t=null;return this.data.has(e)&&(t=this.data.get(e),this.data.delete(e)),t}has(e){return this.data.has(e)}dispose(){this.data=new WeakMap}},La={VERTEX:1,INDEX:2,STORAGE:3,INDIRECT:4},Yo=16,RM=class extends hr{constructor(e,t){super(),this.backend=e,this.info=t}delete(e){let t=super.delete(e);return t!==null&&(this.backend.destroyAttribute(e),this.info.destroyAttribute(e)),t}update(e,t){let s=this.get(e);if(s.version===void 0)t===La.VERTEX?(this.backend.createAttribute(e),this.info.createAttribute(e)):t===La.INDEX?(this.backend.createIndexAttribute(e),this.info.createIndexAttribute(e)):t===La.STORAGE?(this.backend.createStorageAttribute(e),this.info.createStorageAttribute(e)):t===La.INDIRECT&&(this.backend.createIndirectStorageAttribute(e),this.info.createIndirectStorageAttribute(e)),s.version=this._getBufferAttribute(e).version;else{let n=this._getBufferAttribute(e);(s.version<n.version||n.usage===Gr)&&(this.backend.updateAttribute(e),s.version=n.version)}}_getBufferAttribute(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}};function OF(r){return r.index!==null?r.index.version:r.attributes.position.version}function UF(r){return r.index!==null?r.index.id:r.attributes.position.id}function Ck(r){let e=[],t=r.index,s=r.attributes.position;if(t!==null){let a=t.array;for(let i=0,o=a.length;i<o;i+=3){let c=a[i+0],l=a[i+1],h=a[i+2];e.push(c,l,l,h,h,c)}}else{let a=s.array;for(let i=0,o=a.length/3-1;i<o;i+=3){let c=i+0,l=i+1,h=i+2;e.push(c,l,l,h,h,c)}}let n=new(s.count>=65535?Xh:qh)(e,1);return n.version=OF(r),n.__id=UF(r),n}var EM=class extends hr{constructor(e,t){super(),this.attributes=e,this.info=t,this.wireframes=new WeakMap,this.attributeCall=new WeakMap,this._geometryDisposeListeners=new Map}has(e){let t=e.geometry;return super.has(t)&&this.get(t).initialized===!0}updateForRender(e){this.has(e)===!1&&this.initGeometry(e),this.updateAttributes(e)}initGeometry(e){let t=e.geometry,s=this.get(t);s.initialized=!0,this.info.memory.geometries++;let n=()=>{this.info.memory.geometries--;let a=t.index;a!==null&&this.attributes.delete(a);for(let c of Object.values(t.attributes))this.attributes.delete(c);let i=this.wireframes.get(t);i!==void 0&&this.attributes.delete(i);let o=new Set(Object.values(e.geometry.attributes));for(let c of e.getAttributes())o.has(c)===!1&&this.attributes.delete(c);t.removeEventListener("dispose",n),this._geometryDisposeListeners.delete(t),this.delete(t)};t.addEventListener("dispose",n),this._geometryDisposeListeners.set(t,n)}updateAttributes(e){let t=e.getAttributes();for(let a of t)a.isStorageBufferAttribute||a.isStorageInstancedBufferAttribute?this.updateAttribute(a,La.STORAGE):this.updateAttribute(a,La.VERTEX);let s=this.getIndex(e);s!==null&&this.updateAttribute(s,La.INDEX);let n=e.geometry.indirect;n!==null&&this.updateAttribute(n,La.INDIRECT)}updateAttribute(e,t){let s=this.info.render.calls;e.isInterleavedBufferAttribute?this.attributeCall.get(e)===void 0?(this.attributes.update(e,t),this.attributeCall.set(e,s)):this.attributeCall.get(e.data)!==s&&(this.attributes.update(e,t),this.attributeCall.set(e.data,s),this.attributeCall.set(e,s)):this.attributeCall.get(e)!==s&&(this.attributes.update(e,t),this.attributeCall.set(e,s))}getIndirect(e){return e.geometry.indirect}getIndirectOffset(e){return e.geometry.indirectOffset}getIndex(e){let{geometry:t,material:s}=e,n=t.index;if(s.wireframe===!0){let a=this.wireframes,i=a.get(t);i===void 0?(i=Ck(t),a.set(t,i)):(i.version!==OF(t)||i.__id!==UF(t))&&(this.attributes.delete(i),i=Ck(t),a.set(t,i)),n=i}return n}dispose(){for(let[e,t]of this._geometryDisposeListeners.entries())e.removeEventListener("dispose",t);this._geometryDisposeListeners.clear()}},CM=class{constructor(){this.autoReset=!0,this.frame=0,this.calls=0,this.render={calls:0,frameCalls:0,drawCalls:0,triangles:0,points:0,lines:0,timestamp:0},this.compute={calls:0,frameCalls:0,timestamp:0},this.memory={attributes:0,attributesSize:0,geometries:0,indexAttributes:0,indexAttributesSize:0,indirectStorageAttributes:0,indirectStorageAttributesSize:0,programs:0,programsSize:0,readbackBuffers:0,readbackBuffersSize:0,renderTargets:0,storageAttributes:0,storageAttributesSize:0,textures:0,texturesSize:0,uniformBuffers:0,uniformBuffersSize:0,total:0},this.memoryMap=new WeakMap}update(e,t,s){this.render.drawCalls++,e.isMesh||e.isSprite?this.render.triangles+=s*(t/3):e.isPoints?this.render.points+=s*t:e.isLineSegments?this.render.lines+=s*(t/2):e.isLine?this.render.lines+=s*(t-1):W("WebGPUInfo: Unknown object type.")}reset(){this.render.drawCalls=0,this.render.frameCalls=0,this.compute.frameCalls=0,this.render.triangles=0,this.render.points=0,this.render.lines=0}dispose(){this.reset(),this.calls=0,this.render.calls=0,this.compute.calls=0,this.render.timestamp=0,this.compute.timestamp=0;for(let e in this.memory)this.memory[e]=0;this.memoryMap=new WeakMap}createTexture(e){let t=this._getTextureMemorySize(e);this.memoryMap.set(e,t),this.memory.textures++,this.memory.total+=t,this.memory.texturesSize+=t}destroyTexture(e){let t=this.memoryMap.get(e)||0;this.memoryMap.delete(e),this.memory.textures--,this.memory.total-=t,this.memory.texturesSize-=t}_createAttribute(e,t){let s=this._getAttributeMemorySize(e);this.memoryMap.set(e,{size:s,type:t}),this.memory[t]++,this.memory.total+=s,this.memory[t+"Size"]+=s}createAttribute(e){this._createAttribute(e,"attributes")}createIndexAttribute(e){this._createAttribute(e,"indexAttributes")}createStorageAttribute(e){this._createAttribute(e,"storageAttributes")}createIndirectStorageAttribute(e){this._createAttribute(e,"indirectStorageAttributes")}destroyAttribute(e){let t=this.memoryMap.get(e);t&&(this.memoryMap.delete(e),this.memory[t.type]--,this.memory.total-=t.size,this.memory[t.type+"Size"]-=t.size)}createReadbackBuffer(e){let t=e.maxByteLength;this.memoryMap.set(e,{size:t,type:"readbackBuffers"}),this.memory.readbackBuffers++,this.memory.total+=t,this.memory.readbackBuffersSize+=t}destroyReadbackBuffer(e){let{size:t}=this.memoryMap.get(e);this.memoryMap.delete(e),this.memory.readbackBuffers--,this.memory.total-=t,this.memory.readbackBuffersSize-=t}createUniformBuffer(e){let t=e.byteLength;this.memoryMap.set(e,{size:t,type:"uniformBuffers"}),this.memory.uniformBuffers++,this.memory.total+=t,this.memory.uniformBuffersSize+=t}destroyUniformBuffer(e){let t=this.memoryMap.get(e);t&&(this.memoryMap.delete(e),this.memory.uniformBuffers--,this.memory.total-=t.size,this.memory.uniformBuffersSize-=t.size)}createProgram(e){let t=e.code.length;this.memoryMap.set(e,t),this.memory.programs++,this.memory.total+=t,this.memory.programsSize+=t}destroyProgram(e){let t=this.memoryMap.get(e)||0;this.memoryMap.delete(e),this.memory.programs--,this.memory.total-=t,this.memory.programsSize-=t}_getTextureMemorySize(e){if(e.isCompressedTexture)return 1;let t=1;e.type===Ur||e.type===ws?t=1:e.type===pi||e.type===ka||e.type===ds?t=2:(e.type===Ts||e.type===St||e.type===Mt)&&(t=4);let s=4;e.format===Su||e.format===Lr||e.format===zr||e.format===vn||e.format===na?s=1:e.format===cn||e.format===Do?s=2:(e.format===Po||e.format===jp)&&(s=3);let n=t*s;e.type===zp||e.type===Vp?n=2:(e.type===mi||e.type===Au||e.type===Mu)&&(n=4);let a=e.width||1,i=e.height||1,o=e.isCubeTexture?6:e.depth||1,c=a*i*o*n,l=e.mipmaps;if(l&&l.length>0){let h=0;for(let u=0;u<l.length;u++){let d=l[u];if(d.data)h+=d.data.byteLength;else{let f=d.width||Math.max(1,a>>u),p=d.height||Math.max(1,i>>u);h+=f*p*o*n}}c+=h}else e.generateMipmaps&&(c=c*1.333);return Math.round(c)}_getAttributeMemorySize(e){return e.isInterleavedBufferAttribute&&(e=e.data),e.array?e.array.byteLength:e.count&&e.itemSize?e.count*e.itemSize*4:0}},Tw=class{constructor(e){this.cacheKey=e,this.usedTimes=0}},kM=class extends Tw{constructor(e,t,s){super(e),this.vertexProgram=t,this.fragmentProgram=s}},IM=class extends Tw{constructor(e,t){super(e),this.computeProgram=t,this.isComputePipeline=!0}},tz=0,Sm=class{constructor(e,t,s,n=null,a=null){this.id=tz++,this.code=e,this.stage=t,this.name=s,this.transforms=n,this.attributes=a,this.usedTimes=0}},BM=class extends hr{constructor(e,t,s){super(),this.backend=e,this.nodes=t,this.info=s,this.bindings=null,this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}getForCompute(e,t,s=null){let{backend:n}=this,a=this.get(e);if(this._needsComputeUpdate(e)){let i=a.pipeline;i&&(i.usedTimes--,i.computeProgram.usedTimes--);let o=this.nodes.getForCompute(e),c=this.programs.compute.get(o.computeShader);c===void 0&&(i&&i.computeProgram.usedTimes===0&&this._releaseProgram(i.computeProgram),c=new Sm(o.computeShader,"compute",e.name,o.transforms,o.nodeAttributes),this.programs.compute.set(o.computeShader,c),n.createProgram(c),this.info.createProgram(c));let l=this._getComputeCacheKey(e,c),h=this.caches.get(l);h===void 0&&(i&&i.usedTimes===0&&this._releasePipeline(i),h=this._getComputePipeline(e,c,l,t,s)),h.usedTimes++,c.usedTimes++,a.version=e.version,a.pipeline=h}return a.pipeline}getForRender(e,t=null){let{backend:s}=this,n=this.get(e);if(this._needsRenderUpdate(e)){let a=n.pipeline;a&&(a.usedTimes--,a.vertexProgram.usedTimes--,a.fragmentProgram.usedTimes--);let i=e.getNodeBuilderState(),o=e.material?e.material.name:"",c=this.programs.vertex.get(i.vertexShader);c===void 0&&(a&&a.vertexProgram.usedTimes===0&&this._releaseProgram(a.vertexProgram),c=new Sm(i.vertexShader,"vertex",o),this.programs.vertex.set(i.vertexShader,c),s.createProgram(c),this.info.createProgram(c));let l=this.programs.fragment.get(i.fragmentShader);l===void 0&&(a&&a.fragmentProgram.usedTimes===0&&this._releaseProgram(a.fragmentProgram),l=new Sm(i.fragmentShader,"fragment",o),this.programs.fragment.set(i.fragmentShader,l),s.createProgram(l),this.info.createProgram(l));let h=this._getRenderCacheKey(e,c,l),u=this.caches.get(h);u===void 0?(a&&a.usedTimes===0&&this._releasePipeline(a),u=this._getRenderPipeline(e,c,l,h,t)):e.pipeline=u,u.usedTimes++,c.usedTimes++,l.usedTimes++,n.pipeline=u}return n.pipeline}isReady(e){let s=this.get(e).pipeline;if(s===void 0)return!1;let n=this.backend.get(s);return n.pipeline!==void 0&&n.pipeline!==null}delete(e){let t=this.get(e).pipeline;return t&&(t.usedTimes--,t.usedTimes===0&&this._releasePipeline(t),t.isComputePipeline?(t.computeProgram.usedTimes--,t.computeProgram.usedTimes===0&&this._releaseProgram(t.computeProgram)):(t.fragmentProgram.usedTimes--,t.vertexProgram.usedTimes--,t.vertexProgram.usedTimes===0&&this._releaseProgram(t.vertexProgram),t.fragmentProgram.usedTimes===0&&this._releaseProgram(t.fragmentProgram))),super.delete(e)}dispose(){super.dispose(),this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}updateForRender(e){this.getForRender(e)}_getComputePipeline(e,t,s,n,a){s=s||this._getComputeCacheKey(e,t);let i=this.caches.get(s);return i===void 0&&(i=new IM(s,t),this.caches.set(s,i),this.backend.createComputePipeline(i,n,a)),i}_getRenderPipeline(e,t,s,n,a){n=n||this._getRenderCacheKey(e,t,s);let i=this.caches.get(n);return i===void 0&&(i=new kM(n,t,s),this.caches.set(n,i),e.pipeline=i,this.backend.createRenderPipeline(e,a)),i}_getComputeCacheKey(e,t){return e.id+","+t.id}_getRenderCacheKey(e,t,s){return t.id+","+s.id+","+this.backend.getRenderCacheKey(e)}_releasePipeline(e){this.caches.delete(e.cacheKey)}_releaseProgram(e){let t=e.code,s=e.stage;this.programs[s].delete(t),this.info.destroyProgram(e)}_needsComputeUpdate(e){let t=this.get(e);return t.pipeline===void 0||t.version!==e.version}_needsRenderUpdate(e){return this.get(e).pipeline===void 0||this.backend.needsRenderUpdate(e)}},FM=class extends hr{constructor(e,t,s,n,a,i){super(),this.backend=e,this.textures=s,this.pipelines=a,this.attributes=n,this.nodes=t,this.info=i,this.pipelines.bindings=this}getForRender(e){let t=e.getBindings(),s=this.get(e);return s.initialized!==!0&&(this._createBindings(t),s.initialized=!0),t}getForCompute(e){let t=this.nodes.getForCompute(e).bindings,s=this.get(e);return(s.initialized!==!0||s.bindings!==t)&&(s.bindings!==void 0&&this._destroyBindings(s.bindings),this._createBindings(t),s.initialized=!0,s.bindings=t),t}updateForCompute(e){this._updateBindings(this.getForCompute(e))}updateForRender(e){this._updateBindings(this.getForRender(e))}updateSharedForRender(e){let t=this.getForRender(e);for(let s of t)for(let n of s.bindings)if((n.isNodeUniformsGroup===!0||n.isNodeUniformBuffer===!0)&&n.groupNode.shared===!0){if(this.nodes.updateGroup(n)===!1)continue;n.update()&&this.backend.updateBinding(n),n.updateRanges.length>0&&n.clearUpdateRanges()}}deleteForCompute(e){let s=this.get(e).bindings||this.nodes.getForCompute(e).bindings;this._destroyBindings(s),this.delete(e)}deleteForRender(e){let t=e.getBindings();this._destroyBindings(t),this.delete(e)}_createBindings(e){for(let t of e){let s=this.get(t);if(s.bindGroup===void 0){for(let n of t.bindings)if(n.isUniformBuffer)this.backend.createUniformBuffer(n),this.info.createUniformBuffer(n);else if(n.isSampledTexture)this.textures.updateTexture(n.texture);else if(n.isSampler)this.textures.updateSampler(n);else if(n.isStorageBuffer){let a=n.attribute,i=a.isIndirectStorageBufferAttribute?La.INDIRECT:La.STORAGE;this.attributes.update(a,i)}this.backend.createBindings(t,e,""),s.bindGroup=t,s.usedTimes=1}else s.usedTimes++}}_destroyBindings(e){for(let t of e){let s=this.get(t);if(s.usedTimes--,s.usedTimes===0){for(let n of t.bindings)if(n.isUniformBuffer)this.backend.destroyUniformBuffer(n),this.info.destroyUniformBuffer(n),n.release();else if(n.isSampler){if(n.isSampledTexture!==!0)this.backend.destroySampler(n);else if(n.texture!==null){let a=this.textures.get(n.texture);a.bindGroups!==void 0&&a.bindGroups.delete(t)}n.release()}this.backend.deleteBindGroupData(t),this.delete(t)}}}_updateBindings(e){for(let t of e)this._update(t,e)}_update(e,t){let{backend:s}=this,n=!1,a=!0,i="",o=0;for(let c of e.bindings)if(this.nodes.updateGroup(c)!==!1){if(c.isStorageBuffer){let h=c.attribute,u=h.isIndirectStorageBufferAttribute?La.INDIRECT:La.STORAGE,d=s.get(c);this.attributes.update(h,u),d.attribute!==h&&(d.attribute=h,n=!0),i+=h.id+","}if(c.isUniformBuffer)c.update()&&s.updateBinding(c);else if(c.isSampledTexture){let h=c.update(),u=c.texture,d=this.textures.get(u);if(h&&(this.textures.updateTexture(u),c.generation!==d.generation&&(c.generation=d.generation,n=!0),d.bindGroups.add(e)),s.get(u).externalTexture!==void 0||d.isDefaultTexture?a=!1:(i+=u.id+",",o+=u.version),u.isStorageTexture===!0&&u.mipmapsAutoUpdate===!0){let p=this.get(u);c.store===!0?p.needsMipmap=!0:this.textures.needsMipmaps(u)&&p.needsMipmap===!0&&(this.backend.generateMipmaps(u),p.needsMipmap=!1)}}else if(c.isSampler&&c.update()){let u=this.textures.updateSampler(c);c.samplerKey!==u&&(c.samplerKey=u,n=!0)}c.isBuffer&&c.updateRanges.length>0&&c.clearUpdateRanges()}n===!0&&this.backend.updateBindings(e,t,a?i:"",o)}},sz=Object.freeze([]);function nz(r,e){return r.groupOrder!==e.groupOrder?r.groupOrder-e.groupOrder:r.renderOrder!==e.renderOrder?r.renderOrder-e.renderOrder:r.z!==e.z?r.z-e.z:r.id-e.id}function kk(r,e){return r.groupOrder!==e.groupOrder?r.groupOrder-e.groupOrder:r.renderOrder!==e.renderOrder?r.renderOrder-e.renderOrder:r.z!==e.z?e.z-r.z:r.id-e.id}function Ik(r){return(r.transmission>0||r.transmissionNode&&r.transmissionNode.isNode)&&r.side===rn&&r.forceSinglePass===!1}var PM=class{constructor(e,t,s){this.renderItems=[],this.renderItemsIndex=0,this.opaque=[],this.transparentDoublePass=[],this.transparent=[],this.bundles=[],this.lighting=e,this.lightsNode=e.getNode(t),this.lightsArray=[],this.scene=t,this.camera=s,this.occlusionQueryCount=0,this.frameId=-1,this._lastOcclusionObject=null}begin(){return this.renderItemsIndex=0,this.opaque.length=0,this.transparentDoublePass.length=0,this.transparent.length=0,this.bundles.length=0,this.lightsArray.length=0,this.occlusionQueryCount=0,this}getNextRenderItem(e,t,s,n,a,i,o){let c=this.renderItems[this.renderItemsIndex];return c===void 0?(c={id:e.id,object:e,geometry:t,material:s,groupOrder:n,renderOrder:e.renderOrder,z:a,group:i,clippingContext:o},this.renderItems[this.renderItemsIndex]=c):(c.id=e.id,c.object=e,c.geometry=t,c.material=s,c.groupOrder=n,c.renderOrder=e.renderOrder,c.z=a,c.group=i,c.clippingContext=o),this.renderItemsIndex++,c}push(e,t,s,n,a,i,o){this.camera.reversedDepth===!0&&(a=-a);let c=this.getNextRenderItem(e,t,s,n,a,i,o);e.occlusionTest===!0&&this._lastOcclusionObject!==e&&(this.occlusionQueryCount++,this._lastOcclusionObject=e),s.transparent===!0||s.transmission>0||s.transmissionNode&&s.transmissionNode.isNode||s.backdropNode&&s.backdropNode.isNode?(Ik(s)&&this.transparentDoublePass.push(c),this.transparent.push(c)):this.opaque.push(c)}unshift(e,t,s,n,a,i,o){let c=this.getNextRenderItem(e,t,s,n,a,i,o);s.transparent===!0||s.transmission>0||s.transmissionNode&&s.transmissionNode.isNode||s.backdropNode&&s.backdropNode.isNode?(Ik(s)&&this.transparentDoublePass.unshift(c),this.transparent.unshift(c)):this.opaque.unshift(c)}pushBundle(e){this.bundles.push(e)}pushLight(e){this.lightsArray.push(e)}sort(e,t){this.opaque.length>1&&this.opaque.sort(e||nz),this.transparentDoublePass.length>1&&this.transparentDoublePass.sort(t||kk),this.transparent.length>1&&this.transparent.sort(t||kk)}finish(){this.lightsNode.setLights(this.lighting.enabled?this.lightsArray:sz);for(let e=this.renderItemsIndex,t=this.renderItems.length;e<t;e++){let s=this.renderItems[e];if(s.id===null)break;Bk(s)}this._lastOcclusionObject=null}clear(){for(let e=0,t=this.renderItems.length;e<t;e++){let s=this.renderItems[e];if(s.id===null)break;Bk(s)}this.opaque.length=0,this.transparentDoublePass.length=0,this.transparent.length=0,this.bundles.length=0}};function Bk(r){r.id=null,r.object=null,r.geometry=null,r.material=null,r.groupOrder=null,r.renderOrder=null,r.z=null,r.group=null,r.clippingContext=null}var zo=[],DM=class{constructor(){this.lists=new lr,this._activeLists=new Set,this._frameId=-1}get(e,t,s){let n=this.lists;zo[0]=e,zo[1]=t,zo[2]=s;let a=n.get(zo);return a===void 0&&(a=new PM(s,e,t),n.set(zo,a)),zo[0]=null,zo[1]=null,zo[2]=null,a.frameId=this._frameId,this._activeLists.add(a),a}update(e){if(e!==this._frameId){this._frameId=e;for(let t of this._activeLists)e-t.frameId>10&&(t.clear(),this._activeLists.delete(t))}}dispose(){this.lists=new lr,this._activeLists.clear(),this._frameId=-1}},az=0,OM=class{constructor(){this.id=az++,this.mrt=null,this.color=!0,this.clearColor=!0,this.clearColorValue={r:0,g:0,b:0,a:1},this.depth=!0,this.clearDepth=!0,this.clearDepthValue=1,this.stencil=!1,this.clearStencil=!0,this.clearStencilValue=1,this.viewport=!1,this.viewportValue=new Ge,this.scissor=!1,this.scissorValue=new Ge,this.renderTarget=null,this.textures=null,this.depthTexture=null,this.activeCubeFace=0,this.activeMipmapLevel=0,this.sampleCount=1,this.width=0,this.height=0,this.occlusionQueryCount=0,this.clippingContext=null,this.camera=null,this.fullscreenPass=!1,this.isRenderContext=!0}getCacheKey(){return LF(this)}};function LF(r){let{textures:e,activeCubeFace:t,activeMipmapLevel:s}=r,n=[t,s];for(let a of e)n.push(a.id);return $d(n)}var UM=class{constructor(e){this.renderer=e,this._renderContexts={}}get(e=null,t=null,s=0){let n;if(e===null)n="default";else{let c=e.texture.format,l=e.texture.type;n=`${e.textures.length}:${c}:${l}:${e.samples}:${e.depthBuffer}:${e.stencilBuffer}`}let a=t!==null?t.id:"default",i=n+"-"+a+"-"+s,o=this._renderContexts[i];return o===void 0&&(o=new OM,o.mrt=t,this._renderContexts[i]=o),e!==null&&(o.sampleCount=e.samples===0?1:e.samples),o.clearDepthValue=this.renderer.getClearDepth(),o.clearStencilValue=this.renderer.getClearStencil(),o}dispose(){this._renderContexts={}}},iz=new E,LM=class extends hr{constructor(e,t,s){super(),this.renderer=e,this.backend=t,this.info=s,this._htmlTextures=new Set}updateRenderTarget(e,t=0){let s=this.get(e),n=e.samples===0?1:e.samples,a=s.depthTextureMips||(s.depthTextureMips={}),i=e.textures,o=this.getSize(i[0]),c=o.width>>t,l=o.height>>t,h=e.depthTexture||a[t],u=e.depthBuffer===!0||e.stencilBuffer===!0,d=!1,f=h!==void 0&&h.image!==void 0&&h.image.depth>1,p=o.depth>1&&(e.useArrayDepthTexture||e.multiview||f);h===void 0&&u&&(h=new Ds,h.format=e.stencilBuffer?na:vn,h.type=e.stencilBuffer?mi:St,h.image.width=c,h.image.height=l,h.image.depth=o.depth,h.renderTarget=e,a[t]=h),h&&(h.isArrayTexture=p),(s.width!==o.width||o.height!==s.height)&&(d=!0,h&&h.renderTarget===e&&(h.needsUpdate=!0,h.image.width=c,h.image.height=l,h.image.depth=p?o.depth:1)),s.width=o.width,s.height=o.height,s.textures=i,s.depthTexture=h||null,s.depth=e.depthBuffer,s.stencil=e.stencilBuffer,s.renderTarget=e,s.sampleCount!==n&&(d=!0,h&&h.renderTarget===e&&(h.needsUpdate=!0),s.sampleCount=n);let m={sampleCount:n};if(e.isXRRenderTarget!==!0){for(let b=0;b<i.length;b++){let g=i[b];d&&(g.needsUpdate=!0),this.updateTexture(g,m)}h&&this.updateTexture(h,m)}s.initialized!==!0&&(s.initialized=!0,this.info.memory.renderTargets++,s.onDispose=()=>{this._destroyRenderTarget(e)},e.addEventListener("dispose",s.onDispose))}updateTexture(e,t={}){let s=this.get(e);if(s.initialized===!0&&s.version===e.version)return;let n=e.isRenderTargetTexture||e.isDepthTexture||e.isFramebufferTexture,a=this.backend;if(n&&s.initialized===!0&&a.destroyTexture(e),e.isFramebufferTexture){let l=this.renderer.getRenderTarget();l?e.type=l.texture.type:e.type=ws}if(e.isHTMLTexture&&e.image){let l=this.renderer.domElement;if("requestPaint"in l){if(l.hasAttribute("layoutsubtree")||l.setAttribute("layoutsubtree","true"),e.image.parentNode!==l&&l.appendChild(e.image),this._htmlTextures.size===0){let h=this._htmlTextures;l.onpaint=u=>{let d=u&&u.changedElements;for(let f of h)(!d||d.includes(f.image))&&(f.needsUpdate=!0)}}this._htmlTextures.add(e)}}let{width:i,height:o,depth:c}=this.getSize(e);if(t.width=i,t.height=o,t.depth=c,t.needsMipmaps=this.needsMipmaps(e),t.levels=t.needsMipmaps?this.getMipLevels(e,i,o):1,e.isCubeTexture&&e.mipmaps.length>0&&t.levels++,n||e.isStorageTexture===!0||e.isExternalTexture===!0)a.createTexture(e,t),s.generation=e.version;else if(e.version>0){let l=e.image;if(l===void 0)K("Renderer: Texture marked for update but image is undefined.");else if(l.complete===!1)K("Renderer: Texture marked for update but image is incomplete.");else{if(e.images){let u=[];for(let d of e.images)u.push(d);t.images=u}else t.image=l;(s.isDefaultTexture===void 0||s.isDefaultTexture===!0)&&(a.createTexture(e,t),s.isDefaultTexture=!1,s.generation=e.version),e.source.dataReady===!0&&a.updateTexture(e,t);let h=e.isStorageTexture===!0&&e.mipmapsAutoUpdate===!1;t.needsMipmaps&&e.mipmaps.length===0&&!h&&a.generateMipmaps(e),e.onUpdate&&e.onUpdate(e)}}else a.createDefaultTexture(e),s.isDefaultTexture=!0,s.generation=e.version;s.initialized!==!0&&(s.initialized=!0,s.generation=e.version,s.bindGroups=new Set,this.info.createTexture(e),e.isVideoTexture&&qe.enabled===!0&&qe.getTransfer(e.colorSpace)!==Ie&&K("WebGPURenderer: Video textures must use a color space with a sRGB transfer function, e.g. SRGBColorSpace."),s.onDispose=()=>{this._destroyTexture(e)},e.addEventListener("dispose",s.onDispose)),s.version=e.version}updateSampler(e){return this.backend.updateSampler(e)}getSize(e,t=iz){let s=e.images?e.images[0]:e.image;return s?(s.image!==void 0&&(s=s.image),e.isHTMLTexture?(t.width=s.offsetWidth||1,t.height=s.offsetHeight||1,t.depth=1):typeof HTMLVideoElement<"u"&&s instanceof HTMLVideoElement?(t.width=s.videoWidth||1,t.height=s.videoHeight||1,t.depth=1):typeof VideoFrame<"u"&&s instanceof VideoFrame?(t.width=s.displayWidth||1,t.height=s.displayHeight||1,t.depth=1):(t.width=s.width||1,t.height=s.height||1,t.depth=e.isCubeTexture?6:s.depth||1)):t.width=t.height=t.depth=1,t}getMipLevels(e,t,s){let n;return e.mipmaps.length>0?n=e.mipmaps.length:e.isCompressedTexture===!0?n=1:n=Math.floor(Math.log2(Math.max(t,s)))+1,n}needsMipmaps(e){return e.generateMipmaps===!0||e.mipmaps.length>0}_destroyRenderTarget(e){if(this.has(e)===!0){let t=this.get(e),s=t.textures,n=t.depthTexture;e.removeEventListener("dispose",t.onDispose);for(let a=0;a<s.length;a++)this._destroyTexture(s[a]);n&&n.renderTarget===e&&this._destroyTexture(n),this.delete(e),this.backend.delete(e),this.info.memory.renderTargets--}}_destroyTexture(e){if(this.has(e)===!0){let t=this.get(e);e.removeEventListener("dispose",t.onDispose);let s=t.isDefaultTexture;if(this.backend.destroyTexture(e,s),t.bindGroups)for(let n of t.bindGroups){let a=this.backend.get(n);a.groups=void 0,a.versions=void 0;for(let i of n.bindings)i.isSampler&&i.texture===e&&(i.isSampledTexture!==!0&&this.backend.destroySampler(i),i.reset(),i.release())}this._htmlTextures.delete(e),this.delete(e),this.info.destroyTexture(e)}}},jd=class extends be{constructor(e,t,s,n=1){super(e,t,s),this.a=n}set(e,t,s,n=1){return this.a=n,super.set(e,t,s)}copy(e){return e.a!==void 0&&(this.a=e.a),super.copy(e)}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b,yield this.a}},Wm=class extends Rd{static get type(){return"OverrideContextNode"}constructor(e,t=null){super(t,{overrideNodes:e}),this.isOverrideContextNode=!0}getFlowContextData(){let e=[];this.traverse(n=>{n.isOverrideContextNode===!0&&e.push(n.value.overrideNodes)});let t=new Map(e.flatMap(n=>Array.from(n.entries()))),s=super.getFlowContextData();return s.overrideNodes=t,s}};function zF(r,e=null,t=null){if(e&&e.isNode){let s=e;e=()=>s}return new Wm(new Map([[r,e]]),t)}G("overrideNode",(r,e,t)=>zF(e,t,r));function VF(r,e=null){let t=new Map;for(let[s,n]of r){let a=n!==null?typeof n=="function"?n:()=>n:null;t.set(s,a)}return new Wm(t,e)}G("overrideNodes",(r,e)=>VF(e,r));var qm=class extends st{static get type(){return"ParameterNode"}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getMemberType(e,t){let s=this.getNodeType(e),n=e.getStructTypeNode(s),a;return n!==null?a=n.getMemberType(e,t):(W(`TSL: Member "${t}" not found in struct "${s}".`,new is),a="float"),a}getHash(){return String(this.id)}generate(){return this.name}},rz=(r,e)=>new qm(r,e),vw=class extends we{static get type(){return"StackNode"}constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this._expressionNode=null,this._currentNode=null,this._nodeDataLibrary=new Map,this.isStackNode=!0}getElementType(e){return this.outputNode?this.outputNode.getElementType(e):"void"}generateNodeType(e){return this.outputNode?this.outputNode.getNodeType(e):"void"}getMemberType(e,t){return this.outputNode?this.outputNode.getMemberType(e,t):"void"}addToStack(e,t=-1){if(e.isNode!==!0)return W("TSL: Invalid node added to stack.",new is),this;if(t===-1)if(this._currentNode){let s=this._nodeDataLibrary.get(this._currentNode);s===void 0&&(s={delta:0},this._nodeDataLibrary.set(this._currentNode,s)),s.delta++,t=this.nodes.indexOf(this._currentNode)+s.delta}else t=this.nodes.length;return this.nodes.splice(t,0,e),this}addToStackBefore(e){let t=this._currentNode?this.nodes.indexOf(this._currentNode):0;return this.addToStack(e,t)}If(e,t){let s=new gd(t);return this._currentCond=$s(e,s),this.addToStack(this._currentCond)}ElseIf(e,t){let s=new gd(t),n=$s(e,s);return this._currentCond.elseNode=n,this._currentCond=n,this}Else(e){return this._currentCond.elseNode=new gd(e),this}Switch(e){return this._expressionNode=pe(e),this}Case(...e){let t=[];if(e.length>=2)for(let o=0;o<e.length-1;o++)t.push(this._expressionNode.equal(pe(e[o])));else W("TSL: Invalid parameter length. Case() requires at least two parameters.",new is);let s=e[e.length-1],n=new gd(s),a=t[0];for(let o=1;o<t.length;o++)a=a.or(t[o]);let i=$s(a,n);return this._currentCond===null?(this._currentCond=i,this.addToStack(this._currentCond)):(this._currentCond.elseNode=i,this._currentCond=i,this)}Default(e){return this.Else(e),this}setup(e){let t=e.getNodeProperties(this),s=0;for(let n of this.getChildren())n.isVarNode&&n.isIntent(e)&&n.isAssign(e)!==!0||(t["node"+s++]=n);return t.outputNode||null}build(e,...t){let s=y1(),n=e.buildStage;km(this),e.setActiveStack(this);for(let i=0;i<this.nodes.length;i++){let o=this.nodes[i],c=this._currentNode;if(this._currentNode=o,!(o.isVarNode&&o.isIntent(e)&&o.isAssign(e)!==!0)){if(n==="setup")o.build(e);else if(n==="analyze")o.build(e,this);else if(n==="generate"){let l=e.getDataFromNode(o,"any").stages,h=l&&l[e.shaderStage];if(o.isVarNode&&h&&h.length===1&&h[0]&&h[0].isStackNode)continue;o.build(e,"void")}this._currentNode=c}}let a;if(this.outputNode){let i=this.outputNode.build(e,...t);(e.buildStage!=="generate"||this.outputNode.getNodeType(e)!=="void")&&(a=i)}else a=super.build(e,...t);return km(s),e.removeActiveStack(this),a}},m0=He(vw).setParameterLength(0,1);function oz(r){return Object.entries(r).map(([e,t])=>typeof t=="string"?{name:e,type:t,atomic:!1}:{name:e,type:t.type,atomic:t.atomic||!1})}var _w=class extends we{static get type(){return"StructTypeNode"}constructor(e,t=null){super("struct"),this.membersLayout=oz(e),this.name=t,this.isStructTypeNode=!0}getLength(){let e=1,t=0;for(let s of this.membersLayout){let n=s.type,a=dI(n),i=fI(n);e=Math.max(e,i);let c=t%e%i;c!==0&&(t+=i-c),t+=a}return Math.ceil(t/e)*e}getMemberType(e,t){let s=this.membersLayout.find(n=>n.name===t);return s?s.type:"void"}generateNodeType(e){return e.getStructTypeFromNode(this,this.membersLayout,this.name).name}setup(e){e.getStructTypeFromNode(this,this.membersLayout,this.name),e.addInclude(this)}generate(e){return this.getNodeType(e)}},Aw=class extends we{static get type(){return"StructNode"}constructor(e,t){super("vec3"),this.structTypeNode=e,this.values=t,this.isStructNode=!0}generateNodeType(e){return this.structTypeNode.getNodeType(e)}getMemberType(e,t){return this.structTypeNode.getMemberType(e,t)}_getChildren(){let e=super._getChildren(),t=e.find(s=>s.childNode===this.structTypeNode);return e.splice(e.indexOf(t),1),e.push(t),e}generate(e){let t=e.getVarFromNode(this),s=t.type,n=e.getPropertyName(t);return e.addLineFlowCode(`${n} = ${e.generateStruct(s,this.structTypeNode.membersLayout,this.values)}`,this),t.name}},cz=(r,e=null)=>{let t=new _w(r,e);return g1((...n)=>{let a=null;if(n.length>0)if(IT(n)){a={};let i=Object.keys(r);for(let o=0;o<n.length;o++)a[i[o]]=pe(n[o])}else a=n[0];return new Aw(t,a)},t)},Xm=class extends we{static get type(){return"OutputStructNode"}constructor(...e){super(),this.members=e,this.isOutputStructNode=!0}generateNodeType(){return"OutputType"}generate(e){let t=e.getDataFromNode(this);if(t.membersLayout===void 0){let i=this.members,o=[];for(let c=0;c<i.length;c++){let l="m"+c,h=i[c].getNodeType(e);o.push({name:l,type:h,index:c})}t.membersLayout=o,t.structType=e.getOutputStructTypeFromNode(this,t.membersLayout)}let s=e.getOutputStructName(),n=this.members,a=s!==""?s+".":"";for(let i=0;i<n.length;i++){let o=n[i].build(e,t.membersLayout[i].type);e.addLineFlowCode(`${a}m${i} = ${o}`,this)}return s}},lz=He(Xm),Km=class{constructor(e=ta){this.blending=e,this.blendSrc=yu,this.blendDst=xu,this.blendEquation=sa,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.premultiplyAlpha=!1}copy(e){return this.blending=e.blending,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.premultiplyAlpha=e.premultiplyAlpha,this}clone(){return new this.constructor().copy(this)}},hz=new Km(Ca),uz=new Km(Lp);function jF(r,e){for(let t=0;t<r.length;t++)if(r[t].name===e)return t;return-1}var Mw=class extends Xm{static get type(){return"MRTNode"}constructor(e){super(),this.outputNodes=e,this.blendModes={output:uz},this.clearColors={},this.isMRTNode=!0}setBlendMode(e,t){return this.blendModes[e]=t,this}getBlendMode(e){return this.blendModes[e]||hz}setClearColor(e,t,s=1){let n=this.clearColors[e]||(this.clearColors[e]=new jd);return n.set(t),n.a=s,this}getClearColor(e){return this.clearColors[e]||null}has(e){return this.outputNodes[e]!==void 0}get(e){return this.outputNodes[e]}merge(e){let t={...this.outputNodes,...e.outputNodes},s={...this.blendModes,...e.blendModes},n={...this.clearColors,...e.clearColors},a=GF(t);return a.blendModes=s,a.clearColors=n,a}setup(e){let t=this.outputNodes,s=e.renderer.getRenderTarget(),n=[],a=s.textures;for(let i in t){let o=jF(a,i);if(o===-1)continue;let c=e.getOutputType(o);n[o]=t[i].convert(c)}return this.members=n,super.setup(e)}},GF=He(Mw),lc=class extends xt{static get type(){return"BitcastNode"}constructor(e,t,s=null){super(),this.valueNode=e,this.conversionType=t,this.inputType=s,this.isBitcastNode=!0}generateNodeType(e){if(this.inputType!==null){let t=this.valueNode.getNodeType(e),s=e.getTypeLength(t);return e.getTypeFromLength(s,this.conversionType)}return this.conversionType}generate(e){let t=this.getNodeType(e),s="";if(this.inputType!==null){let n=this.valueNode.getNodeType(e);s=e.getTypeLength(n)===1?this.inputType:e.changeComponentType(n,this.inputType)}else s=this.valueNode.getNodeType(e);return`${e.getBitcastMethod(t,s)}( ${this.valueNode.build(e,s)} )`}},HF=X(lc).setParameterLength(2),dz=r=>new lc(r,"int","float"),WF=r=>new lc(r,"uint","float"),fz=r=>new lc(r,"float","int"),pz=r=>new lc(r,"float","uint"),Ux={},io=class r extends L{static get type(){return"BitcountNode"}constructor(e,t){super(e,t),this.isBitcountNode=!0}_resolveElementType(e,t,s){s==="int"?t.assign(HF(e,"uint")):t.assign(e)}_returnDataNode(e){switch(e){case"uint":return V;case"int":return k;case"uvec2":return x1;case"uvec3":return ya;case"uvec4":return Vl;case"ivec2":return Dt;case"ivec3":return w1;case"ivec4":return Sd}}_createTrailingZerosBaseLayout(e,t){let s=this._returnDataNode(t);return F(([a])=>{fe(a.equal(V(0)),()=>V(32));let i=V(0);this._resolveElementType(a,i,t);let o=S(i.bitAnd(F1(i))),l=WF(o).shiftRight(23).sub(127);return s(l)}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}_createLeadingZerosBaseLayout(e,t){let s=this._returnDataNode(t);return F(([a])=>{fe(a.equal(V(0)),()=>V(32));let i=V(0),o=V(0);return this._resolveElementType(a,i,t),fe(i.shiftRight(16).equal(0),()=>{o.addAssign(16),i.shiftLeftAssign(16)}),fe(i.shiftRight(24).equal(0),()=>{o.addAssign(8),i.shiftLeftAssign(8)}),fe(i.shiftRight(28).equal(0),()=>{o.addAssign(4),i.shiftLeftAssign(4)}),fe(i.shiftRight(30).equal(0),()=>{o.addAssign(2),i.shiftLeftAssign(2)}),fe(i.shiftRight(31).equal(0),()=>{o.addAssign(1)}),s(o)}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}_createOneBitsBaseLayout(e,t){let s=this._returnDataNode(t);return F(([a])=>{let i=V(0);this._resolveElementType(a,i,t),i.assign(i.sub(i.shiftRight(V(1)).bitAnd(V(1431655765)))),i.assign(i.bitAnd(V(858993459)).add(i.shiftRight(V(2)).bitAnd(V(858993459))));let o=i.add(i.shiftRight(V(4))).bitAnd(V(252645135)).mul(V(16843009)).shiftRight(V(24));return s(o)}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}_createMainLayout(e,t,s,n){let a=this._returnDataNode(t);return F(([o])=>{if(s===1)return a(n(o));{let c=a(0),l=["x","y","z","w"];for(let h=0;h<s;h++){let u=l[h];c[u].assign(n(o[u]))}return c}}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}setup(e){let{method:t,aNode:s}=this,{renderer:n}=e;if(n.backend.isWebGPUBackend)return super.setup(e);let a=this.getInputType(e),i=e.getElementType(a),o=e.getTypeLength(a),c=`${t}_base_${i}`,l=`${t}_${a}`,h=Ux[c];if(h===void 0){switch(t){case r.COUNT_LEADING_ZEROS:{h=this._createLeadingZerosBaseLayout(c,i);break}case r.COUNT_TRAILING_ZEROS:{h=this._createTrailingZerosBaseLayout(c,i);break}case r.COUNT_ONE_BITS:{h=this._createOneBitsBaseLayout(c,i);break}}Ux[c]=h}let u=Ux[l];return u===void 0&&(u=this._createMainLayout(l,a,o,h),Ux[l]=u),F(()=>u(s))()}static get COUNT_TRAILING_ZEROS(){return"countTrailingZeros"}static get COUNT_LEADING_ZEROS(){return"countLeadingZeros"}static get COUNT_ONE_BITS(){return"countOneBits"}},mz=X(io,io.COUNT_TRAILING_ZEROS).setParameterLength(1),bz=X(io,io.COUNT_LEADING_ZEROS).setParameterLength(1),gz=X(io,io.COUNT_ONE_BITS).setParameterLength(1),yz=F(([r])=>{let e=r.toUint().mul(747796405).add(2891336453),t=e.shiftRight(e.shiftRight(28).add(4)).bitXor(e).mul(277803737);return t.shiftRight(22).bitXor(t).toFloat().mul(1/2**32)}),xz=(r,e)=>zn(Te(4,r.mul(ze(1,r))),e),wz=(r,e)=>$s(r.lessThan(.5),zn(Te(2,r),e).mul(.5),ze(1,zn(Te(2,ze(1,r)),e).mul(.5))),Tz=(r,e,t)=>zn(js(zn(r,e),lt(zn(r,e),zn(ze(1,r),t))),js(1,e)),vz=(r,e)=>{let t=bt(E1.mul(e.mul(r).sub(1))).max(1e-6).toConst();return _s(t).div(t)},hc=class extends xt{static get type(){return"PackFloatNode"}constructor(e,t){super(),this.vectorNode=t,this.encoding=e,this.layout="2x16",this.isPackFloatNode=!0}generateNodeType(){return"uint"}generate(e){let t=this.vectorNode.getNodeType(e);return`${e.getFloatPackingMethod(this.encoding,this.layout)}(${this.vectorNode.build(e,t)})`}},_z=X(hc,"snorm").setParameterLength(1),Az=X(hc,"unorm").setParameterLength(1),Mz=X(hc,"float16").setParameterLength(1),Sz=X(hc,"snorm",null,{layout:"4x8"}).setParameterLength(1),Nz=X(hc,"unorm",null,{layout:"4x8"}).setParameterLength(1),Ns=class r extends xt{static get type(){return"Packed4x8IntegerNode"}constructor(e,t,s=null){super(),this.method=e,this.aNode=t,this.bNode=s,this.isPacked4x8IntegerNode=!0}getInputType(){let e=this.method;return e===r.PACK4X_I8||e===r.PACK4X_I8_CLAMP?"ivec4":e===r.PACK4X_U8||e===r.PACK4X_U8_CLAMP?"uvec4":"uint"}generateNodeType(){let e=this.method;return e===r.DOT4_I8_PACKED?"int":e===r.UNPACK4X_I8?"ivec4":e===r.UNPACK4X_U8?"uvec4":"uint"}_getEmulatedFn(){switch(this.method){case r.DOT4_U8_PACKED:return Cz;case r.DOT4_I8_PACKED:return kz;case r.PACK4X_I8:return qF;case r.PACK4X_U8:return EN;case r.PACK4X_I8_CLAMP:return Ez;case r.PACK4X_U8_CLAMP:return Rz;case r.UNPACK4X_I8:return VM;case r.UNPACK4X_U8:return zM}}setup(e){if(e.renderer.backend.isWebGPUBackend===!0&&typeof navigator<"u"&&navigator.gpu!==void 0&&navigator.gpu.wgslLanguageFeatures!==void 0&&navigator.gpu.wgslLanguageFeatures.has("packed_4x8_integer_dot_product"))return super.setup(e);let{aNode:t,bNode:s}=this,n=this._getEmulatedFn();return s!==null?n(t,s):n(t)}generate(e,t){if(e.getNodeProperties(this).outputNode)return super.generate(e,t);let n=this.getNodeType(e),a=this.getInputType(),i=[this.aNode.build(e,a)];return this.bNode!==null&&i.push(this.bNode.build(e,a)),e.format(`${this.method}( ${i.join(", ")} )`,n,t)}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}static get DOT4_U8_PACKED(){return"dot4U8Packed"}static get DOT4_I8_PACKED(){return"dot4I8Packed"}static get PACK4X_I8(){return"pack4xI8"}static get PACK4X_U8(){return"pack4xU8"}static get PACK4X_I8_CLAMP(){return"pack4xI8Clamp"}static get PACK4X_U8_CLAMP(){return"pack4xU8Clamp"}static get UNPACK4X_I8(){return"unpack4xI8"}static get UNPACK4X_U8(){return"unpack4xU8"}},EN=F(([r])=>{let e=r.x.bitAnd(V(255)),t=r.y.bitAnd(V(255)),s=r.z.bitAnd(V(255)),n=r.w.bitAnd(V(255));return e.bitOr(t.shiftLeft(V(8))).bitOr(s.shiftLeft(V(16))).bitOr(n.shiftLeft(V(24)))}).setLayout({name:"tsl_packed4x8_pack4xU8",type:"uint",inputs:[{name:"v",type:"uvec4"}]}),qF=F(([r])=>EN(Vl(r))).setLayout({name:"tsl_packed4x8_pack4xI8",type:"uint",inputs:[{name:"v",type:"ivec4"}]}),Rz=F(([r])=>EN(Hn(r,Vl(0),Vl(255)))).setLayout({name:"tsl_packed4x8_pack4xU8Clamp",type:"uint",inputs:[{name:"v",type:"uvec4"}]}),Ez=F(([r])=>qF(Hn(r,Sd(-128),Sd(127)))).setLayout({name:"tsl_packed4x8_pack4xI8Clamp",type:"uint",inputs:[{name:"v",type:"ivec4"}]}),zM=F(([r])=>Vl(r.bitAnd(V(255)),r.shiftRight(V(8)).bitAnd(V(255)),r.shiftRight(V(16)).bitAnd(V(255)),r.shiftRight(V(24)).bitAnd(V(255)))).setLayout({name:"tsl_packed4x8_unpack4xU8",type:"uvec4",inputs:[{name:"v",type:"uint"}]});function Lx(r,e){return k(r.shiftLeft(V(24-e))).shiftRight(k(24))}var VM=F(([r])=>Sd(Lx(r,0),Lx(r,8),Lx(r,16),Lx(r,24))).setLayout({name:"tsl_packed4x8_unpack4xI8",type:"ivec4",inputs:[{name:"v",type:"uint"}]}),Cz=F(([r,e])=>{let t=zM(r),s=zM(e);return t.x.mul(s.x).add(t.y.mul(s.y)).add(t.z.mul(s.z)).add(t.w.mul(s.w))}).setLayout({name:"tsl_packed4x8_dot4U8Packed",type:"uint",inputs:[{name:"a",type:"uint"},{name:"b",type:"uint"}]}),kz=F(([r,e])=>{let t=VM(r),s=VM(e);return t.x.mul(s.x).add(t.y.mul(s.y)).add(t.z.mul(s.z)).add(t.w.mul(s.w))}).setLayout({name:"tsl_packed4x8_dot4I8Packed",type:"int",inputs:[{name:"a",type:"uint"},{name:"b",type:"uint"}]}),Iz=X(Ns,Ns.DOT4_U8_PACKED).setParameterLength(2),Bz=X(Ns,Ns.DOT4_I8_PACKED).setParameterLength(2),Fz=X(Ns,Ns.PACK4X_I8).setParameterLength(1),Pz=X(Ns,Ns.PACK4X_U8).setParameterLength(1),Dz=X(Ns,Ns.PACK4X_I8_CLAMP).setParameterLength(1),Oz=X(Ns,Ns.PACK4X_U8_CLAMP).setParameterLength(1),Uz=X(Ns,Ns.UNPACK4X_I8).setParameterLength(1),Lz=X(Ns,Ns.UNPACK4X_U8).setParameterLength(1),uc=class extends xt{static get type(){return"UnpackFloatNode"}constructor(e,t){super(),this.uintNode=t,this.encoding=e,this.layout="2x16",this.isUnpackFloatNode=!0}generateNodeType(){return this.layout==="4x8"?"vec4":"vec2"}generate(e){let t=this.uintNode.getNodeType(e);return`${e.getFloatUnpackingMethod(this.encoding,this.layout)}(${this.uintNode.build(e,t)})`}},zz=X(uc,"snorm").setParameterLength(1),Vz=X(uc,"unorm").setParameterLength(1),jz=X(uc,"float16").setParameterLength(1),Gz=X(uc,"snorm",null,{layout:"4x8"}).setParameterLength(1),Hz=X(uc,"unorm",null,{layout:"4x8"}).setParameterLength(1),$r=F(([r])=>r.fract().sub(.5).abs()).setLayout({name:"tri",type:"float",inputs:[{name:"x",type:"float"}]}),Wz=F(([r])=>C($r(r.z.add($r(r.y.mul(1)))),$r(r.z.add($r(r.x.mul(1)))),$r(r.y.add($r(r.x.mul(1)))))).setLayout({name:"tri3",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),qz=F(([r,e,t])=>{let s=C(r).toVar(),n=S(1.4).toVar(),a=S(0).toVar(),i=C(s).toVar();return tt({start:S(0),end:S(3),type:"float",condition:"<="},()=>{let o=C(Wz(i.mul(2))).toVar();s.addAssign(o.add(t.mul(S(.1).mul(e)))),i.mulAssign(1.8),n.mulAssign(1.5),s.mulAssign(1.2);let c=S($r(s.z.add($r(s.x.add($r(s.y)))))).toVar();a.addAssign(c.div(n)),i.addAssign(.14)}),a}).setLayout({name:"triNoise3D",type:"float",inputs:[{name:"position",type:"vec3"},{name:"speed",type:"float"},{name:"time",type:"float"}]}),Sw=class extends we{static get type(){return"FunctionOverloadingNode"}constructor(e=[],...t){super(),this.functionNodes=e,this.parametersNodes=t,this._candidateFn=null,this.global=!0}generateNodeType(e){return this.getCandidateFn(e).shaderNode.layout.type}getCandidateFn(e){let t=this.parametersNodes,s=this._candidateFn;if(s===null){let n=null,a=-1;for(let i of this.functionNodes){let c=i.shaderNode.layout;if(c===null)throw new Error("THREE.FunctionOverloadingNode: FunctionNode must be a layout.");let l=c.inputs;if(t.length===l.length){let h=0;for(let u=0;u<t.length;u++){let d=t[u],f=l[u];d.getNodeType(e)===f.type&&h++}h>a&&(n=i,a=h)}}this._candidateFn=s=n}return s}setup(e){return this.getCandidateFn(e)(...this.parametersNodes)}},Xz=He(Sw),Ys=r=>(...e)=>Xz(r,...e),Zd=xe(0).setGroup(ye).onRenderUpdate(r=>r.time),Kz=xe(0).setGroup(ye).onRenderUpdate(r=>r.deltaTime),XF=xe(0,"uint").setGroup(ye).onRenderUpdate(r=>r.frameId),Jz=(r=Zd)=>r.add(.75).mul(Math.PI*2).sin().mul(.5).add(.5),$z=(r=Zd)=>r.fract().round(),Yz=(r=Zd)=>r.add(.5).fract().mul(2).sub(1).abs(),Zz=(r=Zd)=>r.fract();function Qz(r,e=null){return Wn(e,{getUV:typeof r=="function"?r:()=>r})}var eV=F(([r,e,t=Z(.5)])=>tv(r.sub(t),e).add(t)),tV=F(([r,e,t=Z(.5)])=>{let s=r.sub(t),n=s.dot(s),i=n.mul(n).mul(e);return r.add(s.mul(i))}),sV=F(({position:r=null,horizontal:e=!0,vertical:t=!1,horizontalRotation:s=!1})=>{let n;r!==null?n=pe(r):n=Vn.sub(da.mul(ce(vs,0)).xyz);let a=da.toVar();a[3][0]=n.x,a[3][1]=n.y,a[3][2]=n.z;let i=Ua.mul(a),o=da[0].length(),c=da[1].length(),l=da[2].length(),h,u,d;if(Cl(s)){let f=a[3].xyz,p=_d.sub(f),m=C(p.x,0,p.z).normalize(),b=C(m.z,0,m.x.negate());h=Ua.mul(ce(b,0)).xyz.mul(o),u=Ua[1].xyz.mul(c),d=Ua.mul(ce(m,0)).xyz.mul(l)}else Cl(e)&&(h=C(o,0,0)),Cl(t)&&(u=C(0,c,0)),d=C(0,0,1);return h&&(i[0][0]=h.x,i[0][1]=h.y,i[0][2]=h.z),u&&(i[1][0]=u.x,i[1][1]=u.y,i[1][2]=u.z),d&&(i[2][0]=d.x,i[2][1]=d.y,i[2][2]=d.z),En.mul(i).mul(vs)}),nV=F(([r=null])=>{let e=Bd();return Bd(TN(r)).sub(e).lessThan(0).select(vi,r)}),aV=F(([r,e=ot(),t=S(0)])=>{let s=r.x,n=r.y,a=t.mod(s.mul(n)).floor(),i=a.mod(s),o=n.sub(a.add(1).div(s).ceil()),c=r.reciprocal(),l=Z(i,o);return e.add(l).mul(c)}),KF=F(([r,e=null,t=null,s=S(1),n=Ct,a=pn])=>{let i=a.abs().normalize();i=i.div(i.dot(C(1)));let o=n.yz.mul(s),c=n.zx.mul(s),l=n.xy.mul(s),h=r.value,u=e!==null?e.value:h,d=t!==null?t.value:h,f=et(h,o).mul(i.x),p=et(u,c).mul(i.y),m=et(d,l).mul(i.z);return lt(f,p,m)}),iV=(...r)=>KF(...r),nd=new wn,xl=new E,ad=new E,CA=new E,sm=new le,zx=new E(0,0,-1),Zi=new Ge,nm=new E,Vx=new E,am=new Ge,jx=new q,Nw=new Ps,rV=vi.flipX();Nw.depthTexture=new Ds(1,1);var Gx=!1,Rw=class r extends ba{static get type(){return"ReflectorNode"}constructor(e={}){super(e.defaultTexture||Nw.texture,rV),this._reflectorBaseNode=e.reflector||new jM(this,e),this._depthNode=null,this.setUpdateMatrix(!1)}get reflector(){return this._reflectorBaseNode}get target(){return this._reflectorBaseNode.target}getDepthNode(){if(this._depthNode===null){if(this._reflectorBaseNode.depth!==!0)throw new Error("THREE.ReflectorNode: Depth node can only be requested when the reflector is created with { depth: true }. ");this._depthNode=new r({defaultTexture:Nw.depthTexture,reflector:this._reflectorBaseNode})}return this._depthNode}setup(e){return e.object.isQuadMesh||this._reflectorBaseNode.build(e),super.setup(e)}clone(){let e=new this.constructor(this.reflectorNode);return e.uvNode=this.uvNode,e.levelNode=this.levelNode,e.biasNode=this.biasNode,e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.gatherNode=this.gatherNode,e.offsetNode=this.offsetNode,e._reflectorBaseNode=this._reflectorBaseNode,e}dispose(){super.dispose(),this._reflectorBaseNode.dispose()}},jM=class extends we{static get type(){return"ReflectorBaseNode"}constructor(e,t={}){super();let{target:s=new Ze,resolutionScale:n=1,generateMipmaps:a=!1,bounces:i=!0,depth:o=!1,samples:c=0}=t;this.textureNode=e,this.target=s,this.resolutionScale=n,t.resolution!==void 0&&(je('ReflectorNode: The "resolution" parameter has been renamed to "resolutionScale".'),this.resolutionScale=t.resolution),this.generateMipmaps=a,this.bounces=i,this.depth=o,this.samples=c,this.updateBeforeType=i?Me.RENDER:Me.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new Map,this.forceUpdate=!1,this.hasOutput=!1}_updateResolution(e,t){let s=this.resolutionScale;t.getDrawingBufferSize(jx),e.setSize(Math.round(jx.width*s),Math.round(jx.height*s))}setup(e){return this._updateResolution(Nw,e.renderer),super.setup(e)}dispose(){super.dispose();for(let e of this.renderTargets.values())e.dispose()}getVirtualCamera(e){let t=this.virtualCameras.get(e);return t===void 0&&(t=e.clone(),this.virtualCameras.set(e,t)),t}getRenderTarget(e){let t=this.renderTargets.get(e);return t===void 0&&(t=new Ps(1,1,{type:ds,samples:this.samples}),this.generateMipmaps===!0&&(t.texture.minFilter=V_,t.texture.generateMipmaps=!0),this.depth===!0&&(t.depthTexture=new Ds),this.renderTargets.set(e,t)),t}updateBefore(e){if(this.bounces===!1&&Gx)return!1;Gx=!0;let{scene:t,camera:s,renderer:n,material:a}=e,{target:i}=this,o=this.getVirtualCamera(s),c=this.getRenderTarget(o);n.getDrawingBufferSize(jx),this._updateResolution(c,n),ad.setFromMatrixPosition(i.matrixWorld),CA.setFromMatrixPosition(s.matrixWorld),sm.extractRotation(i.matrixWorld),xl.set(0,0,1),xl.applyMatrix4(sm),nm.subVectors(ad,CA);let l=nm.dot(xl)>0,h=!1;if(l===!0&&this.forceUpdate===!1){if(this.hasOutput===!1){Gx=!1;return}h=!0}nm.reflect(xl).negate(),nm.add(ad),sm.extractRotation(s.matrixWorld),zx.set(0,0,-1),zx.applyMatrix4(sm),zx.add(CA),Vx.subVectors(ad,zx),Vx.reflect(xl).negate(),Vx.add(ad),o.coordinateSystem=s.coordinateSystem,o.position.copy(nm),o.up.set(0,1,0),o.up.applyMatrix4(sm),o.up.reflect(xl),o.lookAt(Vx),o.near=s.near,o.far=s.far,o.updateMatrixWorld(),o.projectionMatrix.copy(s.projectionMatrix),nd.setFromNormalAndCoplanarPoint(xl,ad),nd.applyMatrix4(o.matrixWorldInverse),Zi.set(nd.normal.x,nd.normal.y,nd.normal.z,nd.constant);let u=o.projectionMatrix;am.x=(Math.sign(Zi.x)+u.elements[8])/u.elements[0],am.y=(Math.sign(Zi.y)+u.elements[9])/u.elements[5],am.z=-1,am.w=(1+u.elements[10])/u.elements[14],Zi.multiplyScalar(1/Zi.dot(am));let d=0;u.elements[2]=Zi.x,u.elements[6]=Zi.y,u.elements[10]=n.coordinateSystem===Xs?Zi.z-d:Zi.z+1-d,u.elements[14]=Zi.w,this.textureNode.value=c.texture,this.depth===!0&&(this.textureNode.getDepthNode().value=c.depthTexture),a.visible=!1;let f=n.getRenderTarget(),p=n.getMRT(),m=n.autoClear;n.setMRT(null),n.setRenderTarget(c),n.autoClear=!0;let b=t.name;t.name=(t.name||"Scene")+" [ Reflector ]",h?(n.clear(),this.hasOutput=!1):(n.render(t,o),this.hasOutput=!0),t.name=b,n.setMRT(p),n.setRenderTarget(f),n.autoClear=m,a.visible=!0,Gx=!1,this.forceUpdate=!1}get resolution(){return je('ReflectorNode: The "resolution" property has been renamed to "resolutionScale".'),this.resolutionScale}set resolution(e){je('ReflectorNode: The "resolution" property has been renamed to "resolutionScale".'),this.resolutionScale=e}},oV=r=>new Rw(r),kA=new ji(-1,1,1,-1,0,1),GM=class extends ke{constructor(e=!1){super();let t=e===!1?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute("position",new ge([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new ge(t,2))}},cV=new GM,lV=ce(N0([-1,-1,3]).element(P0),N0([3,-1,-1]).element(P0),0,1),Xl=class extends at{constructor(e){super(cV,e),this.camera=kA,this.isQuadMesh=!0}async renderAsync(e){je('QuadMesh: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.'),await e.init(),e.render(this,kA)}render(e){let t=this.material.vertexNode;this.material.vertexNode=lV,e.render(this,kA),this.material.vertexNode=t}};function CN(r,e={}){return e.toneMapping=r.toneMapping,e.toneMappingExposure=r.toneMappingExposure,e.outputColorSpace=r.outputColorSpace,e.renderTarget=r.getRenderTarget(),e.activeCubeFace=r.getActiveCubeFace(),e.activeMipmapLevel=r.getActiveMipmapLevel(),e.renderObjectFunction=r.getRenderObjectFunction(),e.pixelRatio=r.getPixelRatio(),e.mrt=r.getMRT(),e.clearColor=r.getClearColor(e.clearColor||new be),e.clearAlpha=r.getClearAlpha(),e.autoClear=r.autoClear,e.scissorTest=r.getScissorTest(),e}function kN(r,e){return e=CN(r,e),r.setMRT(null),r.setRenderObjectFunction(null),r.setClearColor(0,1),r.autoClear=!0,e}function IN(r,e){r.toneMapping=e.toneMapping,r.toneMappingExposure=e.toneMappingExposure,r.outputColorSpace=e.outputColorSpace,r.setRenderTarget(e.renderTarget,e.activeCubeFace,e.activeMipmapLevel),r.setRenderObjectFunction(e.renderObjectFunction),r.setPixelRatio(e.pixelRatio),r.setMRT(e.mrt),r.setClearColor(e.clearColor,e.clearAlpha),r.autoClear=e.autoClear,r.setScissorTest(e.scissorTest)}function BN(r,e={}){return e.background=r.background,e.backgroundNode=r.backgroundNode,e.overrideMaterial=r.overrideMaterial,e}function JF(r,e){return e=BN(r,e),r.background=null,r.backgroundNode=null,r.overrideMaterial=null,e}function $F(r,e){r.background=e.background,r.backgroundNode=e.backgroundNode,r.overrideMaterial=e.overrideMaterial}function hV(r,e,t={}){return t=CN(r,t),t=BN(e,t),t}function YF(r,e,t){return t=kN(r,t),t=JF(e,t),t}function ZF(r,e,t){IN(r,t),$F(e,t)}var uV=Object.freeze({__proto__:null,resetRendererAndSceneState:YF,resetRendererState:kN,resetSceneState:JF,restoreRendererAndSceneState:ZF,restoreRendererState:IN,restoreSceneState:$F,saveRendererAndSceneState:hV,saveRendererState:CN,saveSceneState:BN}),dV=new q,Ew=class extends ba{static get type(){return"RTTNode"}constructor(e,t=null,s=null,n={}){let{autoUpdate:a=!0,resolutionScale:i=1}=n,o=new Ps(t??1,s??1,{type:ds,...n});super(o.texture,ot()),this.isRTTNode=!0,this.node=e,this.width=t,this.height=s,this.renderTarget=o,this.textureNeedsUpdate=!0,this.autoUpdate=a,this._resolutionScale=i,this._quadMesh=new Xl(new wt),this._rendererState={},this.updateBeforeType=Me.FRAME}get autoResize(){return this.width===null}setup(e){return this._quadMesh.material.contextNode=Wn(e.getSharedContext()),this._quadMesh.material.fragmentNode=this.node,this._quadMesh.material.name="RTT",this._quadMesh.material.needsUpdate=!0,super.setup(e)}setSize(e,t){let s=Math.floor(e*this._resolutionScale),n=Math.floor(t*this._resolutionScale);this.renderTarget.setSize(s,n),this.textureNeedsUpdate=!0}setResolutionScale(e){return this._resolutionScale=e,this.autoResize===!1&&this.setSize(this.width,this.height),this}getResolutionScale(){return this._resolutionScale}set value(e){this.renderTarget&&e!==this.renderTarget.texture&&W('TSL: "rtt()" does not allow overwriting the value.')}get value(){return this.renderTarget?this.renderTarget.texture:null}updateBefore(e){let{renderer:t}=e;if(this.textureNeedsUpdate===!1&&this.autoUpdate===!1)return;if(this.textureNeedsUpdate=!1,this.autoResize===!0){let a=t.getDrawingBufferSize(dV),i=Math.floor(a.width*this._resolutionScale),o=Math.floor(a.height*this._resolutionScale);(i!==this.renderTarget.width||o!==this.renderTarget.height)&&(this.renderTarget.setSize(i,o),this.textureNeedsUpdate=!0)}let s="RTT",n=this.name||this.node.name;n&&(s=n+" [ "+s+" ]"),this._quadMesh.name=s,kN(t,this._rendererState),t.setRenderTarget(this.renderTarget),this._quadMesh.render(t),IN(t,this._rendererState)}clone(){let e=new ba(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}dispose(){this.renderTarget.dispose(),this._quadMesh.material.dispose(),super.dispose()}},QF=(r,...e)=>new Ew(pe(r),...e),fV=(r,...e)=>r.isSampleNode||r.isTextureNode?r:r.isPassNode?r.getTextureNode():QF(r,...e),bd=F(([r,e,t],s)=>{let n;s.renderer.coordinateSystem===Xs?(r=Z(r.x,r.y.oneMinus()).mul(2).sub(1),n=ce(C(r,e),1)):n=ce(C(r.x,r.y.oneMinus(),e).mul(2).sub(1),1);let a=ce(t.mul(n));return a.xyz.div(a.w)}),pV=F(([r,e])=>{let t=e.mul(ce(r,1)),s=t.xy.div(t.w).mul(.5).add(.5).toVar();return Z(s.x,s.y.oneMinus())}),mV=F(([r])=>{let e=r.xy.div(r.w).mul(.5).add(.5).toVar();return Z(e.x,e.y.oneMinus())}).setLayout({name:"getScreenPositionFromClip",type:"vec2",inputs:[{name:"clipPosition",type:"vec4"}]}),bV=F(([r,e,t])=>{let s=ic(Jt(e)),n=Dt(r.mul(s)).toVar(),a=Jt(e,n).toVar(),i=Jt(e,n.sub(Dt(2,0))).toVar(),o=Jt(e,n.sub(Dt(1,0))).toVar(),c=Jt(e,n.add(Dt(1,0))).toVar(),l=Jt(e,n.add(Dt(2,0))).toVar(),h=Jt(e,n.add(Dt(0,2))).toVar(),u=Jt(e,n.add(Dt(0,1))).toVar(),d=Jt(e,n.sub(Dt(0,1))).toVar(),f=Jt(e,n.sub(Dt(0,2))).toVar(),p=bt(ze(S(2).mul(o).sub(i),a)).toVar(),m=bt(ze(S(2).mul(c).sub(l),a)).toVar(),b=bt(ze(S(2).mul(u).sub(h),a)).toVar(),g=bt(ze(S(2).mul(d).sub(f),a)).toVar(),x=bd(r,a,t).toVar(),T=p.lessThan(m).select(x.sub(bd(r.sub(Z(S(1).div(s.x),0)),o,t)),x.negate().add(bd(r.add(Z(S(1).div(s.x),0)),c,t))),y=b.lessThan(g).select(x.sub(bd(r.add(Z(0,S(1).div(s.y))),u,t)),x.negate().add(bd(r.sub(Z(0,S(1).div(s.y))),d,t)));return Vs(Mi(T,y))}),FN=F(([r])=>ja(S(52.9829189).mul(ja(Gn(r,Z(.06711056,.00583715)))))).setLayout({name:"interleavedGradientNoise",type:"float",inputs:[{name:"position",type:"vec2"}]}),Ti=F(([r,e,t])=>{let s=S(2.399963229728653),n=fn(S(r).add(.5).div(S(e))),a=S(r).mul(s).add(t);return Z(Ln(a),_s(a)).mul(n)}).setLayout({name:"vogelDiskSample",type:"vec2",inputs:[{name:"sampleIndex",type:"int"},{name:"samplesCount",type:"int"},{name:"phi",type:"float"}]}),Cw=class extends we{static get type(){return"SampleNode"}constructor(e,t=null){super(),this.callback=e,this.uvNode=t,this.isSampleNode=!0}setup(){return this.sample(ot())}sample(e){return this.callback(e)}},gV=(r,e=null)=>new Cw(r,pe(e)),kw=class extends ys{constructor(e,t,s=Float32Array){let n=ArrayBuffer.isView(e)?e:new s(e*t);super(n,t),this.isStorageInstancedBufferAttribute=!0}},mn=class extends Xe{constructor(e,t,s=Float32Array){let n=ArrayBuffer.isView(e)?e:new s(e*t);super(n,t),this.isStorageBufferAttribute=!0}},yV=(r,e="float")=>{let t,s;e.isStructTypeNode===!0?(t=e.getLength(),s=Rm("float")):(t=h1(e),s=Rm(e));let n=new mn(r,t,s);return tc(n,e,r)},xV=(r,e="float")=>{let t,s;e.isStructTypeNode===!0?(t=e.getLength(),s=Rm("float")):(t=h1(e),s=Rm(e));let n=new kw(r,t,s);return tc(n,e,n.count)},Iw=class extends we{static get type(){return"PointUVNode"}constructor(){super("vec2"),this.isPointUVNode=!0}generate(){return"vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )"}},wV=ie(Iw),IA=new le,e2=xe(0).setGroup(ye).onRenderUpdate(({scene:r})=>r.backgroundBlurriness),HM=xe(1).setGroup(ye).onRenderUpdate(({scene:r})=>r.backgroundIntensity),t2=xe(new le).setGroup(ye).onRenderUpdate(({scene:r})=>{let e=r.background;return e!==null&&e.isTexture&&e.mapping!==Tu||r.backgroundNode&&r.backgroundNode.isNode?IA.makeRotationFromEuler(r.backgroundRotation).transpose():IA.identity(),IA}),Jm=class extends ba{static get type(){return"StorageTextureNode"}constructor(e,t,s=null){super(e,t),this.storeNode=s,this.mipLevel=0,this.isStorageTextureNode=!0,this.access=As.WRITE_ONLY}getInputType(){return"storageTexture"}getTransformedUV(e){return e}setup(e){super.setup(e);let t=e.getNodeProperties(this);return t.storeNode=this.storeNode,t}setAccess(e){return this.access=e,this}setMipLevel(e){return this.mipLevel=e,this}generate(e,t){return this.storeNode!==null?(this.generateStore(e),""):super.generate(e,t)}generateSnippet(e,t,s,n,a,i,o,c,l){let h=this.value;return e.generateStorageTextureLoad(h,t,s,n,i,l)}toReadWrite(){return this.setAccess(As.READ_WRITE)}toReadOnly(){return this.setAccess(As.READ_ONLY)}toWriteOnly(){return this.setAccess(As.WRITE_ONLY)}store(e,t){let s=this.clone();return s.referenceNode=this.getBase(),s.uvNode=e,s.storeNode=t,t!==null&&s.toStack(),s}generateStore(e){let t=e.getNodeProperties(this),{uvNode:s,storeNode:n,depthNode:a}=t,i=super.generate(e,"property"),o=s.build(e,this.value.is3DTexture===!0?"uvec3":"uvec2"),c=e.getTypeFromLength(4,e.getComponentTypeFromTexture(this.value)),l=n.build(e,c),h=a?a.build(e,"int"):null,u=e.generateTextureStore(this.value,i,o,h,l);e.addLineFlowCode(u,this)}clone(){let e=super.clone();return e.storeNode=this.storeNode,e.mipLevel=this.mipLevel,e.access=this.access,e}},s2=He(Jm).setParameterLength(1,3),TV=(r,e,t)=>{let s;return r.isStorageTextureNode===!0?s=r.store(e,t):(s=s2(r,e,t),t!==null&&s.toStack()),s},Bw=class extends Jm{static get type(){return"StorageTexture3DNode"}constructor(e,t,s=null){super(e,t,s),this.isStorageTexture3DNode=!0}getDefaultUV(){return C(.5,.5,.5)}setUpdateMatrix(){}generateUV(e,t){return t.build(e,this.sampler===!0?"vec3":"ivec3")}generateOffset(e,t){return t.build(e,"ivec3")}},vV=He(Bw).setParameterLength(1,3),_V=F(({texture:r,uv:e})=>{let s=C().toVar();return fe(e.x.lessThan(1e-4),()=>{s.assign(C(1,0,0))}).ElseIf(e.y.lessThan(1e-4),()=>{s.assign(C(0,1,0))}).ElseIf(e.z.lessThan(1e-4),()=>{s.assign(C(0,0,1))}).ElseIf(e.x.greaterThan(1-1e-4),()=>{s.assign(C(-1,0,0))}).ElseIf(e.y.greaterThan(1-1e-4),()=>{s.assign(C(0,-1,0))}).ElseIf(e.z.greaterThan(1-1e-4),()=>{s.assign(C(0,0,-1))}).Else(()=>{let a=r.sample(e.add(C(-.01,0,0))).r.sub(r.sample(e.add(C(.01,0,0))).r),i=r.sample(e.add(C(0,-.01,0))).r.sub(r.sample(e.add(C(0,.01,0))).r),o=r.sample(e.add(C(0,0,-.01))).r.sub(r.sample(e.add(C(0,0,.01))).r);s.assign(C(a,i,o))}),s.normalize()}),Fw=class extends ba{static get type(){return"Texture3DNode"}constructor(e,t=null,s=null){super(e,t,s),this.isTexture3DNode=!0}getInputType(){return"texture3D"}getDefaultUV(){return C(.5,.5,.5)}setUpdateMatrix(){}generateUV(e,t){return t.build(e,this.sampler===!0?"vec3":"ivec3")}generateOffset(e,t){return t.build(e,"ivec3")}normal(e){return _V({texture:this,uv:e})}},PN=He(Fw).setParameterLength(1,3),AV=(...r)=>PN(...r).setSampler(!1),MV=(r,e,t)=>PN(r,e).level(t),Pw=class extends jl{static get type(){return"UserDataNode"}constructor(e,t,s=null){super(e,t,s),this.userData=s}updateReference(e){return this.reference=this.userData!==null?this.userData:e.object.userData,this.reference}},SV=(r,e,t)=>new Pw(r,e,t),Fk=new WeakMap,Dw=class extends xt{static get type(){return"VelocityNode"}constructor(){super("vec2"),this.projectionMatrix=null,this.updateType=Me.OBJECT,this.updateAfterType=Me.OBJECT,this.previousModelWorldMatrix=xe(new le),this.previousProjectionMatrix=xe(new le).setGroup(ye),this.previousCameraViewMatrix=xe(new le).setGroup(ye)}setProjectionMatrix(e){this.projectionMatrix=e}update({frameId:e,camera:t,object:s}){let n=Pk(s);this.previousModelWorldMatrix.value.copy(n);let a=n2(t);a.frameId!==e&&(a.frameId=e,a.previousProjectionMatrix===void 0?(a.previousProjectionMatrix=new le,a.previousCameraViewMatrix=new le,a.currentProjectionMatrix=new le,a.currentCameraViewMatrix=new le,a.previousProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),a.previousCameraViewMatrix.copy(t.matrixWorldInverse)):(a.previousProjectionMatrix.copy(a.currentProjectionMatrix),a.previousCameraViewMatrix.copy(a.currentCameraViewMatrix)),a.currentProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),a.currentCameraViewMatrix.copy(t.matrixWorldInverse),this.previousProjectionMatrix.value.copy(a.previousProjectionMatrix),this.previousCameraViewMatrix.value.copy(a.previousCameraViewMatrix))}updateAfter({object:e}){Pk(e).copy(e.matrixWorld)}setup(){let e=this.projectionMatrix===null?En:xe(this.projectionMatrix),t=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),s=e.mul(or).mul(Ct),n=this.previousProjectionMatrix.mul(t).mul(cr),a=s.xy.div(s.w),i=n.xy.div(n.w);return ze(a,i)}};function n2(r){let e=Fk.get(r);return e===void 0&&(e={},Fk.set(r,e)),e}function Pk(r,e=0){let t=n2(r),s=t[e];return s===void 0&&(t[e]=s=new le,t[e].copy(r.matrixWorld)),s}var NV=ie(Dw),RV=F(([r,e])=>pa(1,r.oneMinus().div(e)).oneMinus()).setLayout({name:"blendBurn",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),EV=F(([r,e])=>pa(r.div(e.oneMinus()),1)).setLayout({name:"blendDodge",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),CV=F(([r,e])=>r.oneMinus().mul(e.oneMinus()).oneMinus()).setLayout({name:"blendScreen",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),kV=F(([r,e])=>Ke(r.mul(2).mul(e),r.oneMinus().mul(2).mul(e.oneMinus()).oneMinus(),rr(.5,r))).setLayout({name:"blendOverlay",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),IV=F(([r,e])=>{let t=e.a.add(r.a.mul(e.a.oneMinus()));return ce(e.rgb.mul(e.a).add(r.rgb.mul(r.a).mul(e.a.oneMinus())).div(t),t)}).setLayout({name:"blendColor",type:"vec4",inputs:[{name:"base",type:"vec4"},{name:"blend",type:"vec4"}]}),BV=F(([r])=>DN(r.rgb)),FV=F(([r,e=S(1)])=>e.mix(DN(r.rgb),r.rgb).max(0)),PV=F(([r,e=S(0)])=>{let t=lt(r.r,r.g,r.b).div(3),s=r.r.max(r.g.max(r.b)),n=s.sub(t).mul(e).mul(-3);return Ke(r.rgb,s,n).max(0)}),DV=F(([r,e=S(1)])=>{let t=C(.57735,.57735,.57735),s=e.cos();return C(r.rgb.mul(s).add(t.cross(r.rgb).mul(e.sin()).add(t.mul(Gn(t,r.rgb).mul(s.oneMinus()))))).max(0)}),DN=(r,e=C(qe.getLuminanceCoefficients(new E)))=>Gn(r,e),OV=F(([r,e=C(1),t=C(0),s=C(1),n=S(1),a=C(qe.getLuminanceCoefficients(new E,nn))])=>{let i=r.rgb.dot(C(a)),o=Pt(r.rgb.mul(e).add(t),0),c=o.pow(s);return fe(o.r.greaterThan(0),()=>{o.r.assign(c.r)}),fe(o.g.greaterThan(0),()=>{o.g.assign(c.g)}),fe(o.b.greaterThan(0),()=>{o.b.assign(c.b)}),o.assign(i.add(o.sub(i).mul(n)).max(0)),ce(o.rgb,r.a)}),UV=F(([r,e])=>r.mul(e).floor().div(e)),Hx=null,Ow=class extends Gl{static get type(){return"ViewportSharedTextureNode"}constructor(e=vi,t=null){Hx===null&&(Hx=new qc),super(e,t,Hx)}getTextureForReference(){return Hx}updateReference(){return this}},LV=He(Ow).setParameterLength(0,2),Wx=new q,Uw=class extends ba{static get type(){return"PassTextureNode"}constructor(e,t){super(t),this.passNode=e,this.isPassTextureNode=!0,this.setUpdateMatrix(!1)}setup(e){let t=e.getNodeProperties(this);return t.passNode=this.passNode,super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}},Lw=class extends Uw{static get type(){return"PassMultipleTextureNode"}constructor(e,t,s=!1){super(e,null),this.textureName=t,this.previousTexture=s,this.isPassMultipleTextureNode=!0}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(e){return this.updateTexture(),super.setup(e)}clone(){let e=new this.constructor(this.passNode,this.textureName,this.previousTexture);return e.uvNode=this.uvNode,e.levelNode=this.levelNode,e.biasNode=this.biasNode,e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.gatherNode=this.gatherNode,e.offsetNode=this.offsetNode,e}},ro=class r extends xt{static get type(){return"PassNode"}constructor(e,t,s,n={}){super("vec4"),this.scope=e,this.scene=t,this.camera=s,this.options=n,this._width=1,this._height=1;let a=new Ps(this._width,this._height,{type:ds,...n});a.texture.name="output";let i=null;(this.scope===r.DEPTH||n.depthBuffer!==!1)&&(i=n.depthTexture||new Ds,i.isRenderTargetTexture=!0,i.name="depth",a.depthTexture=i),this.renderTarget=a,this.overrideMaterial=null,this.transparent=!0,this.opaque=!0,this.lighting=null,this.autoClear=n.autoClear!==void 0?n.autoClear:!0,this.autoClearColor=n.autoClearColor!==void 0?n.autoClearColor:!0,this.autoClearDepth=n.autoClearDepth!==void 0?n.autoClearDepth:!0,this.autoClearStencil=n.autoClearStencil!==void 0?n.autoClearStencil:!0,this.contextNode=null,this._contextNodeCache=null,this._textures={output:a.texture},i!==null&&(this._textures.depth=i),this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=xe(0),this._cameraFar=xe(0),this._mrt=null,this._layers=null,this._resolutionScale=1,this._viewport=null,this._scissor=null,this.isPassNode=!0,this.updateBeforeType=Me.FRAME,this.global=!0}setResolutionScale(e){return this._resolutionScale=e,this}getResolutionScale(){return this._resolutionScale}setResolution(e){return K("PassNode: .setResolution() is deprecated. Use .setResolutionScale() instead."),this.setResolutionScale(e)}getResolution(){return K("PassNode: .getResolution() is deprecated. Use .getResolutionScale() instead."),this.getResolutionScale()}setLayers(e){return this._layers=e,this}getLayers(){return this._layers}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getTexture(e){let t=this._textures[e];if(t===void 0){if(e==="depth")throw new Error("THREE.PassNode: Depth texture is not available for this pass.");t=this.renderTarget.texture.clone(),t.name=e,this._textures[e]=t,this.renderTarget.textures.push(t)}return t}getPreviousTexture(e){let t=this._previousTextures[e];return t===void 0&&(t=this.getTexture(e).clone(),this._previousTextures[e]=t),t}toggleTexture(e){let t=this._previousTextures[e];if(t!==void 0){let s=this._textures[e],n=this.renderTarget.textures.indexOf(s);this.renderTarget.textures[n]=t,this._textures[e]=t,this._previousTextures[e]=s,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e="output"){let t=this._textureNodes[e];return t===void 0&&(t=new Lw(this,e),t.updateTexture(),this._textureNodes[e]=t),t}getPreviousTextureNode(e="output"){let t=this._previousTextureNodes[e];return t===void 0&&(this._textureNodes[e]===void 0&&this.getTextureNode(e),t=new Lw(this,e,!0),t.updateTexture(),this._previousTextureNodes[e]=t),t}getViewZNode(e="depth"){let t=this._viewZNodes[e];if(t===void 0){let s=this._cameraNear,n=this._cameraFar;this._viewZNodes[e]=t=$T(this.getTextureNode(e),s,n)}return t}getLinearDepthNode(e="depth"){let t=this._linearDepthNodes[e];if(t===void 0){let s=this._cameraNear,n=this._cameraFar,a=this.getViewZNode(e);this._linearDepthNodes[e]=t=Ol(a,s,n)}return t}async compileAsync(e){let t=e.getRenderTarget(),s=e.getMRT();e.setRenderTarget(this.renderTarget),e.setMRT(this._mrt),await e.compileAsync(this.scene,this.camera),e.setRenderTarget(t),e.setMRT(s)}setup({renderer:e}){return this.renderTarget.samples=this.options.samples===void 0?e.samples:this.options.samples,this.renderTarget.texture.type=e.getOutputBufferType(),e.reversedDepthBuffer===!0&&this.renderTarget.depthTexture!==null&&(this.renderTarget.depthTexture.type=Mt),this.scope===r.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){let{renderer:t}=e,{scene:s}=this,n,a=t.getOutputRenderTarget();a&&a.isXRRenderTarget===!0?(n=t.xr.getCamera(),t.xr.updateCamera(n),Wx.set(a.width,a.height)):(n=this.camera,t.getDrawingBufferSize(Wx)),this.setSize(Wx.width,Wx.height);let i=t.getRenderTarget(),o=t.getMRT(),c=t.autoClear,l=t.autoClearColor,h=t.autoClearDepth,u=t.autoClearStencil,d=t.transparent,f=t.opaque,p=t.lighting,m=n.layers.mask,b=t.contextNode,g=s.overrideMaterial;this._cameraNear.value=n.near,this._cameraFar.value=n.far,this._layers!==null&&(n.layers.mask=this._layers.mask);for(let T in this._previousTextures)this.toggleTexture(T);this.overrideMaterial!==null&&(s.overrideMaterial=this.overrideMaterial),t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.autoClear=this.autoClear,t.autoClearColor=this.autoClearColor,t.autoClearDepth=this.autoClearDepth,t.autoClearStencil=this.autoClearStencil,t.transparent=this.transparent,t.opaque=this.opaque,this.lighting!==null&&(t.lighting=this.lighting),this.contextNode!==null&&((this._contextNodeCache===null||this._contextNodeCache.version!==this.version)&&(this._contextNodeCache={version:this.version,context:Wn({...t.contextNode.getFlowContextData(),...this.contextNode.getFlowContextData()})}),t.contextNode=this._contextNodeCache.context);let x=s.name;s.name=this.name?this.name:s.name,t.render(s,n),s.name=x,s.overrideMaterial=g,t.setRenderTarget(i),t.setMRT(o),t.autoClear=c,t.autoClearColor=l,t.autoClearDepth=h,t.autoClearStencil=u,t.transparent=d,t.opaque=f,t.contextNode=b,t.lighting=p,n.layers.mask=m}setSize(e,t){this._width=e,this._height=t;let s=Math.floor(this._width*this._resolutionScale),n=Math.floor(this._height*this._resolutionScale);this.renderTarget.setSize(s,n),this._scissor!==null?(this.renderTarget.scissor.copy(this._scissor).multiplyScalar(this._resolutionScale).floor(),this.renderTarget.scissorTest=!0):this.renderTarget.scissorTest=!1,this._viewport!==null&&this.renderTarget.viewport.copy(this._viewport).multiplyScalar(this._resolutionScale).floor()}setScissor(e,t,s,n){e===null?this._scissor=null:(this._scissor===null&&(this._scissor=new Ge),e.isVector4?this._scissor.copy(e):this._scissor.set(e,t,s,n))}setViewport(e,t,s,n){e===null?this._viewport=null:(this._viewport===null&&(this._viewport=new Ge),e.isVector4?this._viewport.copy(e):this._viewport.set(e,t,s,n))}dispose(){super.dispose(),this.renderTarget.dispose()}static get COLOR(){return"color"}static get DEPTH(){return"depth"}},zV=(r,e,t)=>new ro(ro.COLOR,r,e,t),VV=(r,e)=>new Uw(r,e),jV=(r,e,t)=>new ro(ro.DEPTH,r,e,t),zw=class extends ro{static get type(){return"ToonOutlinePassNode"}constructor(e,t,s,n,a){super(ro.COLOR,e,t),this.colorNode=s,this.thicknessNode=n,this.alphaNode=a,this._materialCache=new WeakMap,this.name="Outline Pass"}updateBefore(e){let{renderer:t}=e,s=t.getRenderObjectFunction();t.setRenderObjectFunction((n,a,i,o,c,l,h,u)=>{if((c.isMeshToonMaterial||c.isMeshToonNodeMaterial)&&c.wireframe===!1){let d=this._getOutlineMaterial(c);t.renderObject(n,a,i,o,d,l,h,u)}t.renderObject(n,a,i,o,c,l,h,u)}),super.updateBefore(e),t.setRenderObjectFunction(s)}_createMaterial(){let e=new wt;e.isMeshToonOutlineMaterial=!0,e.name="Toon_Outline",e.side=Xt;let t=pn.negate(),s=En.mul(or),n=S(1),a=s.mul(ce(Ct,1)),i=s.mul(ce(Ct.add(t),1)),o=Vs(a.sub(i));return e.vertexNode=a.add(o.mul(this.thicknessNode).mul(a.w).mul(n)),e.colorNode=ce(this.colorNode,this.alphaNode),e}_getOutlineMaterial(e){let t=this._materialCache.get(e);return t===void 0&&(t=this._createMaterial(),this._materialCache.set(e,t)),t}},GV=(r,e,t=new be(0,0,0),s=.003,n=1)=>new zw(r,e,pe(t),pe(s),pe(n)),ON=F(([r,e])=>r.mul(e).clamp()).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),UN=F(([r,e])=>(r=r.mul(e),r.div(r.add(1)).clamp())).setLayout({name:"reinhardToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),LN=F(([r,e])=>{r=r.mul(e),r=r.sub(.004).max(0);let t=r.mul(r.mul(6.2).add(.5)),s=r.mul(r.mul(6.2).add(1.7)).add(.06);return t.div(s).pow(2.2)}).setLayout({name:"cineonToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),HV=F(([r])=>{let e=r.mul(r.add(.0245786)).sub(90537e-9),t=r.mul(r.add(.432951).mul(.983729)).add(.238081);return e.div(t)}),zN=F(([r,e])=>{let t=Ms(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),s=Ms(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return r=r.mul(e).div(.6),r=t.mul(r),r=HV(r),r=s.mul(r),r.clamp()}).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),WV=Ms(C(1.6605,-.1246,-.0182),C(-.5876,1.1329,-.1006),C(-.0728,-.0083,1.1187)),qV=Ms(C(.6274,.0691,.0164),C(.3293,.9195,.088),C(.0433,.0113,.8956)),XV=F(([r])=>{let e=C(r).toVar(),t=C(e.mul(e)).toVar(),s=C(t.mul(t)).toVar();return S(15.5).mul(s.mul(t)).sub(Te(40.14,s.mul(e))).add(Te(31.96,s).sub(Te(6.868,t.mul(e))).add(Te(.4298,t).add(Te(.1191,e).sub(.00232))))}),VN=F(([r,e])=>{let t=C(r).toVar(),s=Ms(C(.856627153315983,.137318972929847,.11189821299995),C(.0951212405381588,.761241990602591,.0767994186031903),C(.0482516061458583,.101439036467562,.811302368396859)),n=Ms(C(1.1271005818144368,-.1413297634984383,-.14132976349843826),C(-.11060664309660323,1.157823702216272,-.11060664309660294),C(-.016493938717834573,-.016493938717834257,1.2519364065950405)),a=S(-12.47393),i=S(4.026069);return t.mulAssign(e),t.assign(qV.mul(t)),t.assign(s.mul(t)),t.assign(Pt(t,1e-10)),t.assign(nr(t)),t.assign(t.sub(a).div(i.sub(a))),t.assign(Hn(t,0,1)),t.assign(XV(t)),t.assign(n.mul(t)),t.assign(zn(Pt(C(0),t),C(2.2))),t.assign(WV.mul(t)),t.assign(Hn(t,0,1)),t}).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),jN=F(([r,e])=>{let t=S(.76),s=S(.15);r=r.mul(e);let n=pa(r.r,pa(r.g,r.b)),a=$s(n.lessThan(.08),n.sub(Te(6.25,n.mul(n))),.04);r.subAssign(a);let i=Pt(r.r,Pt(r.g,r.b));fe(i.lessThan(t),()=>r);let o=ze(1,t),c=ze(1,o.mul(o).div(i.add(o.sub(t))));r.mulAssign(c.div(i));let l=ze(1,js(1,s.mul(i.sub(c)).add(1)));return Ke(r,C(c),l)}).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),mt=class extends we{static get type(){return"CodeNode"}constructor(e="",t=[],s=""){super("code"),this.isCodeNode=!0,this.global=!0,this.code=e,this.includes=t,this.language=s}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){let t=this.getIncludes(e);for(let n of t)n.build(e,"void");let s=e.getCodeFromNode(this,this.getNodeType(e));return s.code=this.code,s.code}serialize(e){super.serialize(e),e.code=this.code,e.language=this.language}deserialize(e){super.deserialize(e),this.code=e.code,this.language=e.language}},sv=He(mt).setParameterLength(1,3),KV=(r,e)=>sv(r,e,"js"),JV=(r,e)=>sv(r,e,"wgsl"),$V=(r,e)=>sv(r,e,"glsl"),$m=class extends mt{static get type(){return"FunctionNode"}constructor(e="",t=[],s=""){super(e,t,s)}generateNodeType(e){return this.getNodeFunction(e).type}getMemberType(e,t){let s=this.getNodeType(e);return e.getStructTypeNode(s).getMemberType(e,t)}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){let t=e.getDataFromNode(this),s=t.nodeFunction;return s===void 0&&(s=e.parser.parseFunction(this.code),t.nodeFunction=s),s}generate(e,t){super.generate(e);let s=this.getNodeFunction(e),n=s.name,a=s.type,i=e.getCodeFromNode(this,a);if(n!==""){let l=e.getDataFromNode(this);l.declarationRegistered!==!0&&(i.name=n,e.registerDeclaration(i),l.declarationRegistered=!0)}let o=e.getPropertyName(i),c=this.getNodeFunction(e).getCode(o);return i.code=c+`
`,t==="property"?o:e.format(`${o}()`,a,t)}},a2=(r,e=[],t="")=>{let s=new $m(r,e,t);return g1((...a)=>s.call(...a),s)},YV=(r,e)=>a2(r,e,"glsl"),ZV=(r,e)=>a2(r,e,"wgsl");function GN(r){let e,t=r.context.getViewZ;return t!==void 0&&(e=t(this)),(e||$t.z).negate()}var i2=F(([r,e],t)=>{let s=GN(t);return ma(r,e,s)}),r2=F(([r],e)=>{let t=GN(e);return r.mul(r,t,t).negate().exp().oneMinus()}),QV=F(([r,e],t)=>{let s=GN(t),a=e.sub(Vn.y).max(0).toConst().mul(s).toConst();return r.mul(r,a,a).negate().exp().oneMinus()}),WM=F(([r,e])=>ce(e.toFloat().mix(ec.rgb,r.toVec3()),ec.a)),wl=null,Tl=null,Vw=class extends we{static get type(){return"RangeNode"}constructor(e=S(),t=S()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){let t=this.getConstNode(this.minNode),s=this.getConstNode(this.maxNode),n=e.getTypeLength(to(t.value)),a=e.getTypeLength(to(s.value));return n>a?n:a}generateNodeType(e){return e.object.count>1?e.getTypeFromLength(this.getVectorLength(e)):"float"}getConstNode(e){let t=null;if(e.traverse(s=>{s.isConstNode===!0&&(t=s)}),t===null)throw new zm('THREE.TSL: No "ConstNode" found in node graph.',this.stackTrace);return t}setup(e){let t=e.object,s=null;if(t.count>1){let n=this.getConstNode(this.minNode),a=this.getConstNode(this.maxNode),i=n.value,o=a.value,c=e.getTypeLength(to(i)),l=e.getTypeLength(to(o));wl=wl||new Ge,Tl=Tl||new Ge,wl.setScalar(0),Tl.setScalar(0),c===1?wl.setScalar(i):i.isColor?wl.set(i.r,i.g,i.b,1):wl.set(i.x,i.y,i.z||0,i.w||0),l===1?Tl.setScalar(o):o.isColor?Tl.set(o.r,o.g,o.b,1):Tl.set(o.x,o.y,o.z||0,o.w||0);let h=4,u=h*t.count,d=new Float32Array(u);for(let m=0;m<u;m++){let b=m%h,g=wl.getComponent(b),x=Tl.getComponent(b);d[m]=Lo.lerp(g,x,Math.random())}let f=this.getNodeType(e);if(t.count*4*4<=e.getUniformBufferLimit())s=Yd(d,"vec4",t.count).element(_i).convert(f);else{let m=new ys(d,4);e.geometry.setAttribute("__range"+this.id,m),s=WT(m).convert(f)}}else s=S(0);return s}},ej=He(Vw).setParameterLength(2),jw=class extends we{static get type(){return"ComputeBuiltinNode"}constructor(e,t){super(t),this._builtinName=e}getHash(e){return this.getBuiltinName(e)}generateNodeType(){return this.nodeType}setBuiltinName(e){return this._builtinName=e,this}getBuiltinName(){return this._builtinName}hasBuiltin(e){return e.hasBuiltin(this._builtinName)}generate(e,t){let s=this.getBuiltinName(e),n=this.getNodeType(e);return e.shaderStage==="compute"?e.format(s,n,t):(K(`TSL: Compute built-in value "${s}" can not be accessed in the ${e.shaderStage} stage`),e.generateConst(n))}serialize(e){super.serialize(e),e.global=this.global,e._builtinName=this._builtinName}deserialize(e){super.deserialize(e),this.global=e.global,this._builtinName=e._builtinName}},_b=(r,e)=>new jw(r,e),tj=_b("numWorkgroups","uvec3"),sj=_b("workgroupId","uvec3"),nj=_b("globalId","uvec3"),aj=_b("localId","uvec3"),ij=_b("subgroupSize","uint"),Gw=class extends we{constructor(e){super(),this.scope=e,this.isBarrierNode=!0}setup(e){e.allowEarlyReturns=!1,e.allowGlobalVariables=!1}generate(e){let{scope:t}=this,{renderer:s,shaderStage:n}=e,a=`${t}Barrier`;n!=="compute"&&W(`TSL: "${a}" is not supported in the ${n} stage and can only be executed in compute.`),s.backend.isWebGLBackend===!0?e.addFlowCode(`	// ${a}() 
`):e.addLineFlowCode(`${a}()`,this)}},HN=He(Gw),rj=()=>HN("workgroup").toStack(),oj=()=>HN("storage").toStack(),cj=()=>HN("texture").toStack(),qM=class extends no{constructor(e,t){super(e,t),this.isWorkgroupInfoElementNode=!0}generate(e,t){let s,n=e.isContextAssign();if(s=super.generate(e),n!==!0){let a=this.getNodeType(e);s=e.format(s,a,t)}return s}},Hw=class extends we{constructor(e,t,s=0){super(t),this.bufferType=t,this.bufferCount=s,this.isAtomic=!1,this.isWorkgroupInfoNode=!0,this.elementType=t,this.scope=e,this.name=""}setName(e){return this.name=e,this}label(e){return K('TSL: "label()" has been deprecated. Use "setName()" instead.',new is),this.setName(e)}setScope(e){return this.scope=e,this}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getElementType(){return this.elementType}getInputType(){return`${this.scope}Array`}element(e){return new qM(this,e)}generate(e){e.shaderStage!=="compute"&&W('TSL: "workgroupArray()" can only be executed within the compute shader stage');let t=this.name!==""?this.name:`${this.scope}Array_${this.id}`;return e.getScopedArray(t,this.scope.toLowerCase(),this.bufferType,this.bufferCount,this.isAtomic)}},lj=(r,e)=>new Hw("Workgroup",r,e),ga=class extends we{static get type(){return"AtomicFunctionNode"}constructor(e,t,s){super("uint"),this.method=e,this.pointerNode=t,this.valueNode=s,this.parents=!0}getInputType(e){return this.pointerNode.getNodeType(e)}generateNodeType(e){return this.getInputType(e)}generate(e){let t=this.method;e.shaderStage==="vertex"&&W(`TSL: "${this.method}" is not supported in the vertex stage.`);let s=e.getNodeProperties(this),n=s.parents,a=this.getNodeType(e),i=this.getInputType(e),o=this.pointerNode,c=this.valueNode,l=[];l.push(`&${o.build(e,i)}`),c!==null&&l.push(c.build(e,i));let h=`${e.getMethod(t,a)}( ${l.join(", ")} )`;if(n?n.length===1&&n[0].isStackNode===!0:!1)e.addLineFlowCode(h,this);else return s.constNode===void 0&&(s.constNode=ua(h,a).toConst()),s.constNode.build(e)}static get ATOMIC_LOAD(){return"atomicLoad"}static get ATOMIC_STORE(){return"atomicStore"}static get ATOMIC_ADD(){return"atomicAdd"}static get ATOMIC_SUB(){return"atomicSub"}static get ATOMIC_MAX(){return"atomicMax"}static get ATOMIC_MIN(){return"atomicMin"}static get ATOMIC_AND(){return"atomicAnd"}static get ATOMIC_OR(){return"atomicOr"}static get ATOMIC_XOR(){return"atomicXor"}},hj=He(ga),pr=(r,e,t)=>hj(r,e,t).toStack(),uj=r=>pr(ga.ATOMIC_LOAD,r,null),dj=(r,e)=>pr(ga.ATOMIC_STORE,r,e),fj=(r,e)=>pr(ga.ATOMIC_ADD,r,e),pj=(r,e)=>pr(ga.ATOMIC_SUB,r,e),mj=(r,e)=>pr(ga.ATOMIC_MAX,r,e),bj=(r,e)=>pr(ga.ATOMIC_MIN,r,e),gj=(r,e)=>pr(ga.ATOMIC_AND,r,e),yj=(r,e)=>pr(ga.ATOMIC_OR,r,e),xj=(r,e)=>pr(ga.ATOMIC_XOR,r,e),Re=class r extends xt{static get type(){return"SubgroupFunctionNode"}constructor(e,t=null,s=null){super(),this.method=e,this.aNode=t,this.bNode=s}getInputType(e){let t=this.aNode?this.aNode.getNodeType(e):null,s=this.bNode?this.bNode.getNodeType(e):null,n=e.isMatrix(t)?0:e.getTypeLength(t),a=e.isMatrix(s)?0:e.getTypeLength(s);return n>a?t:s}generateNodeType(e){let t=this.method;return t===r.SUBGROUP_ELECT?"bool":t===r.SUBGROUP_BALLOT?"uvec4":this.getInputType(e)}generate(e,t){let s=this.method;e.shaderStage==="vertex"&&W(`TSL: "${this.method}" is not supported in the vertex shader stage.`);let n=this.getNodeType(e),a=this.getInputType(e),i=this.aNode,o=this.bNode,c=[];if(s===r.SUBGROUP_BROADCAST||s===r.SUBGROUP_SHUFFLE||s===r.QUAD_BROADCAST){let h=o.getNodeType(e);c.push(i.build(e,n),o.build(e,h==="float"?"int":n))}else s===r.SUBGROUP_SHUFFLE_XOR||s===r.SUBGROUP_SHUFFLE_DOWN||s===r.SUBGROUP_SHUFFLE_UP?c.push(i.build(e,n),o.build(e,"uint")):(i!==null&&c.push(i.build(e,a)),o!==null&&c.push(o.build(e,a)));let l=c.length===0?"()":`( ${c.join(", ")} )`;return e.format(`${e.getMethod(s,n)}${l}`,n,t)}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}static get SUBGROUP_ELECT(){return"subgroupElect"}static get SUBGROUP_BALLOT(){return"subgroupBallot"}static get SUBGROUP_ADD(){return"subgroupAdd"}static get SUBGROUP_INCLUSIVE_ADD(){return"subgroupInclusiveAdd"}static get SUBGROUP_EXCLUSIVE_ADD(){return"subgroupExclusiveAdd"}static get SUBGROUP_MUL(){return"subgroupMul"}static get SUBGROUP_INCLUSIVE_MUL(){return"subgroupInclusiveMul"}static get SUBGROUP_EXCLUSIVE_MUL(){return"subgroupExclusiveMul"}static get SUBGROUP_AND(){return"subgroupAnd"}static get SUBGROUP_OR(){return"subgroupOr"}static get SUBGROUP_XOR(){return"subgroupXor"}static get SUBGROUP_MIN(){return"subgroupMin"}static get SUBGROUP_MAX(){return"subgroupMax"}static get SUBGROUP_ALL(){return"subgroupAll"}static get SUBGROUP_ANY(){return"subgroupAny"}static get SUBGROUP_BROADCAST_FIRST(){return"subgroupBroadcastFirst"}static get QUAD_SWAP_X(){return"quadSwapX"}static get QUAD_SWAP_Y(){return"quadSwapY"}static get QUAD_SWAP_DIAGONAL(){return"quadSwapDiagonal"}static get SUBGROUP_BROADCAST(){return"subgroupBroadcast"}static get SUBGROUP_SHUFFLE(){return"subgroupShuffle"}static get SUBGROUP_SHUFFLE_XOR(){return"subgroupShuffleXor"}static get SUBGROUP_SHUFFLE_UP(){return"subgroupShuffleUp"}static get SUBGROUP_SHUFFLE_DOWN(){return"subgroupShuffleDown"}static get QUAD_BROADCAST(){return"quadBroadcast"}},wj=X(Re,Re.SUBGROUP_ELECT).setParameterLength(0),Tj=X(Re,Re.SUBGROUP_BALLOT).setParameterLength(1),vj=X(Re,Re.SUBGROUP_ADD).setParameterLength(1),_j=X(Re,Re.SUBGROUP_INCLUSIVE_ADD).setParameterLength(1),Aj=X(Re,Re.SUBGROUP_EXCLUSIVE_ADD).setParameterLength(1),Mj=X(Re,Re.SUBGROUP_MUL).setParameterLength(1),Sj=X(Re,Re.SUBGROUP_INCLUSIVE_MUL).setParameterLength(1),Nj=X(Re,Re.SUBGROUP_EXCLUSIVE_MUL).setParameterLength(1),Rj=X(Re,Re.SUBGROUP_AND).setParameterLength(1),Ej=X(Re,Re.SUBGROUP_OR).setParameterLength(1),Cj=X(Re,Re.SUBGROUP_XOR).setParameterLength(1),kj=X(Re,Re.SUBGROUP_MIN).setParameterLength(1),Ij=X(Re,Re.SUBGROUP_MAX).setParameterLength(1),Bj=X(Re,Re.SUBGROUP_ALL).setParameterLength(1),Fj=X(Re,Re.SUBGROUP_ANY).setParameterLength(1),Pj=X(Re,Re.SUBGROUP_BROADCAST_FIRST).setParameterLength(1),Dj=X(Re,Re.QUAD_SWAP_X).setParameterLength(1),Oj=X(Re,Re.QUAD_SWAP_Y).setParameterLength(1),Uj=X(Re,Re.QUAD_SWAP_DIAGONAL).setParameterLength(1),Lj=X(Re,Re.SUBGROUP_BROADCAST).setParameterLength(2),zj=X(Re,Re.SUBGROUP_SHUFFLE).setParameterLength(2),Vj=X(Re,Re.SUBGROUP_SHUFFLE_XOR).setParameterLength(2),jj=X(Re,Re.SUBGROUP_SHUFFLE_UP).setParameterLength(2),Gj=X(Re,Re.SUBGROUP_SHUFFLE_DOWN).setParameterLength(2),Hj=X(Re,Re.QUAD_BROADCAST).setParameterLength(1),qx;function nv(r){qx=qx||new WeakMap;let e=qx.get(r);return e===void 0&&qx.set(r,e={}),e}function av(r){let e=nv(r);return e.shadowMatrix||(e.shadowMatrix=xe("mat4").setGroup(ye).onRenderUpdate(t=>((r.castShadow!==!0||t.renderer.shadowMap.enabled===!1)&&(r.shadow.camera.coordinateSystem!==t.camera.coordinateSystem&&(r.shadow.camera.coordinateSystem=t.camera.coordinateSystem,r.shadow.camera.updateProjectionMatrix()),r.shadow.updateMatrices(r)),r.shadow.matrix)))}function o2(r,e=Vn){let t=av(r).mul(e);return t.xyz.div(t.w)}function WN(r){let e=nv(r);return e.position||(e.position=xe(new E).setGroup(ye).onRenderUpdate((t,s)=>s.value.setFromMatrixPosition(r.matrixWorld)))}function c2(r){let e=nv(r);return e.targetPosition||(e.targetPosition=xe(new E).setGroup(ye).onRenderUpdate((t,s)=>s.value.setFromMatrixPosition(r.target.matrixWorld)))}function qN(r){let e=nv(r);return e.viewPosition||(e.viewPosition=xe(new E).setGroup(ye).onRenderUpdate(({camera:t},s)=>{s.value=s.value||new E,s.value.setFromMatrixPosition(r.matrixWorld),s.value.applyMatrix4(t.matrixWorldInverse)}))}var XN=r=>Ua.transformDirection(WN(r).sub(c2(r))),Wj=za("vec3","totalDiffuse"),qj=za("vec3","totalSpecular"),Xj=za("vec3","outgoingLight"),Kj=r=>r.sort((e,t)=>e.id-t.id),Jj=(r,e)=>{for(let t of e)if(t.isAnalyticLightNode&&t.light.id===r)return t;return null},BA=new WeakMap,im=[],Gd=class extends we{static get type(){return"LightsNode"}constructor(){super("vec3"),this.totalDiffuseNode=Wj,this.totalSpecularNode=qj,this.outgoingLightNode=Xj,this._lights=[],this.global=!0}customCacheKey(){let e=this.getBuiltinLights();for(let s=0;s<e.length;s++){let n=e[s];if(im.push(n.id),im.push(n.castShadow?1:0),n.isSpotLight===!0){let a=n.map!==null?n.map.id:-1,i=n.colorNode?n.colorNode.getCacheKey():-1;im.push(a,i)}}let t=$d(im);return im.length=0,t}getHash(e){let t=e.getDataFromNode(this);if(t.lightNodesHash===void 0){let s=this.setupLightsNode(e);t.lightNodes=s;let n=[];for(let a of s)n.push(a.getHash());t.lightNodesHash="lights-"+n.join(",")}return t.lightNodesHash}analyze(e){let t=e.getNodeProperties(this);for(let s of t.nodes)s.build(e);t.outputNode.build(e)}setupLightsNode(e){let t=e.getDataFromNode(this),s=[],n=t.lightNodes||null,a=e.context.materialLightings,i=this.getBuiltinLights(),o=Kj([...a,...i]),c=e.renderer.library;for(let l of o)if(l.isNode)s.push(l);else{let h=null;if(n!==null&&(h=Jj(l.id,n)),h===null){let u=c.getLightNodeClass(l.constructor);if(u===null){K(`LightsNode.setupNodeLights: Light node not found for ${l.constructor.name}`);continue}BA.has(l)===!1&&BA.set(l,new u(l)),h=BA.get(l)}s.push(h)}return s}setupDirectLight(e,t,s){let{lightingModel:n,reflectedLight:a}=e.context;n.direct({...s,lightNode:t,reflectedLight:a},e)}setupDirectRectAreaLight(e,t,s){let{lightingModel:n,reflectedLight:a}=e.context;n.directRectArea({...s,lightNode:t,reflectedLight:a},e)}setupLights(e,t){for(let s of t)s.build(e)}getLightNodes(e){let t=e.getDataFromNode(this);return t.lightNodes===void 0&&(t.lightNodes=this.setupLightsNode(e)),t.lightNodes}setup(e){let t=e.lightsNode;e.lightsNode=this;let s=this.outgoingLightNode,n=e.context,a=n.lightingModel,i=e.getNodeProperties(this);if(a){let{totalDiffuseNode:o,totalSpecularNode:c}=this;n.outgoingLight=s;let l=e.addStack();i.nodes=l.nodes,a.start(e);let{backdrop:h,backdropAlpha:u}=n,{directDiffuse:d,directSpecular:f,indirectDiffuse:p,indirectSpecular:m}=n.reflectedLight,b=d.add(p);h!==null&&(u!==null?b=C(u.mix(b,h)):b=C(h)),o.assign(b),c.assign(f.add(m)),s.assign(o.add(c)),a.finish(e),s=s.bypass(e.removeStack())}else i.nodes=[];return e.lightsNode=t,s}setLights(e){return this._lights=e,this}getLights(){return this._lights}getBuiltinLights(){return this._lights}get hasLights(){return this._lights.length>0}},$j=(r=[])=>new Gd().setLights(r),Ww=new WeakMap,Dk=new lr,id=[],Yj=r=>{let e=Ww.get(r);return e===void 0&&(e=new wt,e.colorNode=ce(0,0,0,1),e.isShadowPassMaterial=!0,e.name="ShadowMaterial",e.blending=Ca,e.fog=!1,Ww.set(r,e)),e},Zj=r=>{let e=Ww.get(r);e!==void 0&&(e.dispose(),Ww.delete(r))},Qj=(r,e,t,s)=>{id[0]=r,id[1]=e;let n=Dk.get(id);return(n===void 0||n.shadowType!==t||n.useVelocity!==s)&&(n=(a,i,o,c,l,h,u,d,f)=>{(a.castShadow===!0||a.receiveShadow&&t===rl)&&(s&&(d1(a).useVelocity=!0),a.onBeforeShadow(r,a,o,e.camera,c,i.overrideMaterial,h),r.renderObject(a,i,o,c,l,h,u,d,f),a.onAfterShadow(r,a,o,e.camera,c,i.overrideMaterial,h))},n.shadowType=t,n.useVelocity=s,Dk.set(id,n)),id[0]=null,id[1]=null,n},qw=class extends we{static get type(){return"ShadowBaseNode"}constructor(e){super(),this.light=e,this.updateBeforeType=Me.RENDER,this.isShadowBaseNode=!0}getShadowMaterial(){return Yj(this.light)}disposeShadowMaterial(){Zj(this.light)}getShadowRenderObjectFunction(e,t=this.light.shadow){let s=e.shadowMap.type,n=e.getMRT(),a=n?n.has("velocity"):!1;return Qj(e,t,s,a)}setupShadowPosition({context:e,material:t}){KN.assign(t.receivedShadowPositionNode||e.shadowPositionWorld||Vn)}},KN=za("vec3","shadowPositionWorld"),l2=F(({depthTexture:r,shadowCoord:e,depthLayer:t})=>{let s=et(r,e.xy).setName("t_basic");return r.isArrayTexture&&(s=s.depth(t)),s.compare(e.z)}),h2=F(({depthTexture:r,shadowCoord:e,shadow:t,depthLayer:s})=>{let n=(h,u)=>{let d=et(r,h);return r.isArrayTexture&&(d=d.depth(s)),d.compare(u)},a=Et("mapSize","vec2",t).setGroup(ye),i=Et("radius","float",t).setGroup(ye),o=Z(1).div(a),c=i.mul(o.x),l=FN($l.xy).mul(6.28318530718);return lt(n(e.xy.add(Ti(0,5,l).mul(c)),e.z),n(e.xy.add(Ti(1,5,l).mul(c)),e.z),n(e.xy.add(Ti(2,5,l).mul(c)),e.z),n(e.xy.add(Ti(3,5,l).mul(c)),e.z),n(e.xy.add(Ti(4,5,l).mul(c)),e.z)).mul(1/5)}),u2=F(({depthTexture:r,shadowCoord:e,depthLayer:t},s)=>{let n=et(r).sample(e.xy);r.isArrayTexture&&(n=n.depth(t)),n=n.rg;let a=n.x,i=Pt(1e-7,n.y.mul(n.y)),o=s.renderer.reversedDepthBuffer?rr(a,e.z):rr(e.z,a),c=S(1).toVar();return fe(o.notEqual(1),()=>{let l=e.z.sub(a),h=i.div(i.add(l.mul(l)));h=Hn(ze(h,.3).div(.65)),c.assign(Pt(o,h))}),c}),eG=F(({samples:r,radius:e,size:t,shadowPass:s,depthLayer:n})=>{let a=S(0).toVar("meanVertical"),i=S(0).toVar("squareMeanVertical"),o=r.lessThanEqual(S(1)).select(S(0),S(2).div(r.sub(1))),c=r.lessThanEqual(S(1)).select(S(0),S(-1));tt({start:k(0),end:k(r),type:"int",condition:"<"},({i:h})=>{let u=c.add(S(h).mul(o)),d=s.sample(lt($l.xy,Z(0,u).mul(e)).div(t));s.value.isArrayTexture&&(d=d.depth(n)),d=d.x,a.addAssign(d),i.addAssign(d.mul(d))}),a.divAssign(r),i.divAssign(r);let l=fn(i.sub(a.mul(a)).max(0));return Z(a,l)}),tG=F(({samples:r,radius:e,size:t,shadowPass:s,depthLayer:n})=>{let a=S(0).toVar("meanHorizontal"),i=S(0).toVar("squareMeanHorizontal"),o=r.lessThanEqual(S(1)).select(S(0),S(2).div(r.sub(1))),c=r.lessThanEqual(S(1)).select(S(0),S(-1));tt({start:k(0),end:k(r),type:"int",condition:"<"},({i:h})=>{let u=c.add(S(h).mul(o)),d=s.sample(lt($l.xy,Z(u,0).mul(e)).div(t));s.value.isArrayTexture&&(d=d.depth(n)),a.addAssign(d.x),i.addAssign(lt(d.y.mul(d.y),d.x.mul(d.x)))}),a.divAssign(r),i.divAssign(r);let l=fn(i.sub(a.mul(a)).max(0));return Z(a,l)}),sG=[l2,h2,null,u2],FA,Xx=new Xl,Ym=class extends qw{static get type(){return"ShadowNode"}constructor(e,t=null){super(e),this.shadow=t||e.shadow,this.shadowMap=null,this.vsmShadowMapVertical=null,this.vsmShadowMapHorizontal=null,this.vsmMaterialVertical=null,this.vsmMaterialHorizontal=null,this._node=null,this._currentShadowType=null,this._cameraFrameId=new WeakMap,this.isShadowNode=!0,this.depthLayer=0}setupShadowFilter(e,{filterFn:t,depthTexture:s,shadowCoord:n,shadow:a,depthLayer:i}){let o=n.x.greaterThanEqual(0).and(n.x.lessThanEqual(1)).and(n.y.greaterThanEqual(0)).and(n.y.lessThanEqual(1)).and(n.z.lessThanEqual(1)),c=t({depthTexture:s,shadowCoord:n,shadow:a,depthLayer:i});return o.select(c,S(1))}setupShadowCoord(e,t){let{shadow:s}=this,{renderer:n}=e,a=s.biasNode||Et("bias","float",s).setGroup(ye),i=t,o;if(s.camera.isOrthographicCamera||n.logarithmicDepthBuffer!==!0)i=i.xyz.div(i.w),o=i.z;else{let c=i.w;i=i.xy.div(c);let l=Et("near","float",s.camera).setGroup(ye),h=Et("far","float",s.camera).setGroup(ye);o=YT(c.negate(),l,h)}return i=C(i.x,i.y.oneMinus(),n.reversedDepthBuffer?o.sub(a):o.add(a)),i}getShadowFilterFn(e){return sG[e]}setupRenderTarget(e,t){let s=new Ds(e.mapSize.width,e.mapSize.height);s.name="ShadowDepthTexture",s.compareFunction=t.renderer.reversedDepthBuffer?Oo:ml;let n=t.createRenderTarget(e.mapSize.width,e.mapSize.height);return n.texture.name="ShadowMap",n.texture.type=e.mapType,n.depthTexture=s,{shadowMap:n,depthTexture:s}}setupShadow(e){let{renderer:t,camera:s}=e,{light:n,shadow:a}=this,{depthTexture:i,shadowMap:o}=this.setupRenderTarget(a,e),c=t.shadowMap.type,l=t.hasCompatibility(Hr.TEXTURE_COMPARE);if(c===gu&&l?(i.minFilter=Ye,i.magFilter=Ye):(i.minFilter=pt,i.magFilter=pt),a.camera.coordinateSystem=s.coordinateSystem,a.camera.updateProjectionMatrix(),c===rl&&a.isPointLightShadow!==!0){i.compareFunction=null,o.depth>1?(o._vsmShadowMapVertical||(o._vsmShadowMapVertical=e.createRenderTarget(a.mapSize.width,a.mapSize.height,{format:cn,type:ds,depth:o.depth,depthBuffer:!1}),o._vsmShadowMapVertical.texture.name="VSMVertical"),this.vsmShadowMapVertical=o._vsmShadowMapVertical,o._vsmShadowMapHorizontal||(o._vsmShadowMapHorizontal=e.createRenderTarget(a.mapSize.width,a.mapSize.height,{format:cn,type:ds,depth:o.depth,depthBuffer:!1}),o._vsmShadowMapHorizontal.texture.name="VSMHorizontal"),this.vsmShadowMapHorizontal=o._vsmShadowMapHorizontal):(this.vsmShadowMapVertical=e.createRenderTarget(a.mapSize.width,a.mapSize.height,{format:cn,type:ds,depthBuffer:!1}),this.vsmShadowMapHorizontal=e.createRenderTarget(a.mapSize.width,a.mapSize.height,{format:cn,type:ds,depthBuffer:!1}));let _=et(i);i.isArrayTexture&&(_=_.depth(this.depthLayer));let A=et(this.vsmShadowMapVertical.texture);i.isArrayTexture&&(A=A.depth(this.depthLayer));let M=Et("blurSamples","float",a).setGroup(ye),N=Et("radius","float",a).setGroup(ye),R=Et("mapSize","vec2",a).setGroup(ye),I=Wn(e.getSharedContext()),D=this.vsmMaterialVertical||(this.vsmMaterialVertical=new wt);D.contextNode=I,D.fragmentNode=eG({samples:M,radius:N,size:R,shadowPass:_,depthLayer:this.depthLayer}),D.name="VSMVertical",D=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new wt),D.contextNode=I,D.fragmentNode=tG({samples:M,radius:N,size:R,shadowPass:A,depthLayer:this.depthLayer}),D.name="VSMHorizontal"}let h=Et("intensity","float",a).setGroup(ye),u=Et("normalBias","float",a).setGroup(ye),d=av(n),f=gc.mul(u),p;!t.highPrecision||e.material.receivedShadowPositionNode||e.context.shadowPositionWorld?p=d.mul(KN.add(f)):p=xe("mat4").onObjectUpdate(({object:A},M)=>M.value.multiplyMatrices(d.value,A.matrixWorld)).mul(Ct).add(d.mul(ce(f,0)));let m=this.setupShadowCoord(e,p),b=a.filterNode||this.getShadowFilterFn(t.shadowMap.type)||null;if(b===null)throw new Error("THREE.WebGPURenderer: Shadow map type not supported yet.");let g=c===rl&&a.isPointLightShadow!==!0?this.vsmShadowMapHorizontal.texture:i,x=this.setupShadowFilter(e,{filterFn:b,shadowTexture:o.texture,depthTexture:g,shadowCoord:m,shadow:a,depthLayer:this.depthLayer}),T;t.shadowMap.transmitted===!0&&(o.texture.isCubeTexture?T=Nn(o.texture,m.xyz):(T=et(o.texture,m),i.isArrayTexture&&(T=T.depth(this.depthLayer))));let y;T?y=Ke(1,x.rgb.mix(T,1),h.mul(T.a)).toVar():y=Ke(1,x,h).toVar(),this.shadowMap=o,this.shadow.map=o;let v=`${this.light.type} Shadow [ ${this.light.name||"ID: "+this.light.id} ]`;return T&&y.toInspector(`${v} / Color`,()=>this.shadowMap.texture.isCubeTexture?Nn(this.shadowMap.texture,fM()):et(this.shadowMap.texture)),y.toInspector(`${v} / Depth`,()=>{let _=Et("near","float",this.shadow.camera),A=Et("far","float",this.shadow.camera),M;this.shadowMap.texture.isCubeTexture?M=Nn(this.shadowMap.depthTexture,fM()).r:M=et(this.shadowMap.depthTexture).r;let N;return this.shadow.camera.isPerspectiveCamera?N=$T(M,_,A):N=bF(M,_,A),N=Ol(N,_,A),N.oneMinus()})}setup(e){if(e.renderer.shadowMap.enabled!==!1)return F(()=>{let t=e.renderer.shadowMap.type;this._currentShadowType!==t&&(this._reset(),this._node=null);let s=this._node;return this.setupShadowPosition(e),s===null&&(this._node=s=this.setupShadow(e),this._currentShadowType=t),e.material.receivedShadowNode&&(s=e.material.receivedShadowNode(s)),s})()}renderShadow(e){let{shadow:t,shadowMap:s,light:n}=this,{renderer:a,scene:i}=e;t.updateMatrices(n),s.setSize(t.mapSize.width,t.mapSize.height,s.depth);let o=i.name;i.name=`Shadow Map [ ${n.name||"ID: "+n.id} ]`,a.render(i,t.camera),i.name=o}updateShadow(e){let{shadowMap:t,shadow:s}=this,{renderer:n,scene:a,camera:i}=e,o=n.shadowMap.type,c=t.depthTexture.version;this._depthVersionCached=c;let l=s.camera.layers.mask;(s.camera.layers.mask&4294967294)===0&&(s.camera.layers.mask=i.layers.mask);let h=n.getRenderObjectFunction();FA=YF(n,a,FA),a.overrideMaterial=this.getShadowMaterial(),n.setRenderObjectFunction(this.getShadowRenderObjectFunction(n,this.shadow||this.light.shadow)),n.setClearColor(0,0),n.setRenderTarget(t),this.renderShadow(e),n.setRenderObjectFunction(h),o===rl&&s.isPointLightShadow!==!0&&this.vsmPass(n),s.camera.layers.mask=l,ZF(n,a,FA)}vsmPass(e){let{shadow:t}=this,s=this.shadowMap.depth;this.vsmShadowMapVertical.setSize(t.mapSize.width,t.mapSize.height,s),this.vsmShadowMapHorizontal.setSize(t.mapSize.width,t.mapSize.height,s),e.setRenderTarget(this.vsmShadowMapVertical),Xx.material=this.vsmMaterialVertical,Xx.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),Xx.material=this.vsmMaterialHorizontal,Xx.render(e)}dispose(){this._reset(),super.dispose()}_reset(){this._currentShadowType=null,this.disposeShadowMaterial(),this.shadowMap&&(this.shadowMap.dispose(),this.shadowMap=null),this.vsmShadowMapVertical!==null&&(this.vsmShadowMapVertical.dispose(),this.vsmShadowMapVertical=null,this.vsmMaterialVertical.dispose(),this.vsmMaterialVertical=null),this.vsmShadowMapHorizontal!==null&&(this.vsmShadowMapHorizontal.dispose(),this.vsmShadowMapHorizontal=null,this.vsmMaterialHorizontal.dispose(),this.vsmMaterialHorizontal=null)}updateBefore(e){if(e.renderer._isPreCompiling===!0)return;let{shadow:t}=this,s=t.needsUpdate||t.autoUpdate;s&&(this._cameraFrameId.get(e.camera)===e.frameId&&(s=!1),this._cameraFrameId.set(e.camera,e.frameId)),s&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}},d2=(r,e)=>new Ym(r,e),nG=new be,Ok=new le,rm=new E,PA=new E,aG=[new E(1,0,0),new E(-1,0,0),new E(0,-1,0),new E(0,1,0),new E(0,0,1),new E(0,0,-1)],iG=[new E(0,-1,0),new E(0,-1,0),new E(0,0,-1),new E(0,0,1),new E(0,-1,0),new E(0,-1,0)],rG=[new E(1,0,0),new E(-1,0,0),new E(0,1,0),new E(0,-1,0),new E(0,0,1),new E(0,0,-1)],oG=[new E(0,-1,0),new E(0,-1,0),new E(0,0,1),new E(0,0,-1),new E(0,-1,0),new E(0,-1,0)],f2=F(({depthTexture:r,bd3D:e,dp:t})=>Nn(r,e).compare(t)),p2=F(({depthTexture:r,bd3D:e,dp:t,shadow:s})=>{let n=Et("radius","float",s).setGroup(ye),a=Et("mapSize","vec2",s).setGroup(ye),i=n.div(a.x),o=bt(e),c=Vs(Mi(e,o.x.greaterThan(o.z).select(C(0,1,0),C(1,0,0)))),l=Mi(e,c),h=FN($l.xy).mul(6.28318530718),u=Ti(0,5,h),d=Ti(1,5,h),f=Ti(2,5,h),p=Ti(3,5,h),m=Ti(4,5,h);return Nn(r,e.add(c.mul(u.x).add(l.mul(u.y)).mul(i))).compare(t).add(Nn(r,e.add(c.mul(d.x).add(l.mul(d.y)).mul(i))).compare(t)).add(Nn(r,e.add(c.mul(f.x).add(l.mul(f.y)).mul(i))).compare(t)).add(Nn(r,e.add(c.mul(p.x).add(l.mul(p.y)).mul(i))).compare(t)).add(Nn(r,e.add(c.mul(m.x).add(l.mul(m.y)).mul(i))).compare(t)).mul(1/5)}),cG=F(({filterFn:r,depthTexture:e,shadowCoord:t,shadow:s},n)=>{let a=t.xyz.toConst(),i=a.abs().toConst(),o=i.x.max(i.y).max(i.z),c=xe("float").setGroup(ye).onRenderUpdate(()=>s.camera.near),l=xe("float").setGroup(ye).onRenderUpdate(()=>s.camera.far),h=Et("bias","float",s).setGroup(ye),u=S(1).toVar();return fe(o.sub(l).lessThanEqual(0).and(o.sub(c).greaterThanEqual(0)),()=>{let d;n.renderer.reversedDepthBuffer?(d=gF(o.negate(),c,l),d.subAssign(h)):n.renderer.logarithmicDepthBuffer?(d=YT(o.negate(),c,l),d.addAssign(h)):(d=JT(o.negate(),c,l),d.addAssign(h));let f=a.normalize();u.assign(r({depthTexture:e,bd3D:f,dp:d,shadow:s}))}),u}),Xw=class extends Ym{static get type(){return"PointShadowNode"}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return e===O_?f2:p2}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,depthTexture:s,shadowCoord:n,shadow:a}){return cG({filterFn:t,depthTexture:s,shadowCoord:n,shadow:a})}setupRenderTarget(e,t){let s=new Yf(e.mapSize.width);s.name="PointShadowDepthTexture",s.compareFunction=t.renderer.reversedDepthBuffer?Oo:ml;let n=t.createCubeRenderTarget(e.mapSize.width);return n.texture.name="PointShadowMap",n.depthTexture=s,{shadowMap:n,depthTexture:s}}renderShadow(e){let{shadow:t,shadowMap:s,light:n}=this,{renderer:a,scene:i}=e,o=t.camera,c=t.matrix,l=a.coordinateSystem===Xs,h=l?aG:rG,u=l?iG:oG;s.setSize(t.mapSize.width,t.mapSize.width);let d=a.autoClear,f=a.getClearColor(nG),p=a.getClearAlpha();a.autoClear=!1,a.setClearColor(t.clearColor,t.clearAlpha);for(let m=0;m<6;m++){a.setRenderTarget(s,m),a.clear();let b=n.distance||o.far;b!==o.far&&(o.far=b,o.updateProjectionMatrix()),rm.setFromMatrixPosition(n.matrixWorld),o.position.copy(rm),PA.copy(o.position),PA.add(h[m]),o.up.copy(u[m]),o.lookAt(PA),o.updateMatrixWorld(),c.makeTranslation(-rm.x,-rm.y,-rm.z),Ok.multiplyMatrices(o.projectionMatrix,o.matrixWorldInverse),t._frustum.setFromProjectionMatrix(Ok,o.coordinateSystem,o.reversedDepth);let g=i.name;i.name=`Point Light Shadow [ ${n.name||"ID: "+n.id} ] - Face ${m+1}`,a.render(i,o),i.name=g}a.autoClear=d,a.setClearColor(f,p)}},m2=(r,e)=>new Xw(r,e),ur=class extends ao{static get type(){return"AnalyticLightNode"}constructor(e=null){super(),this.light=e,this.color=new be,this.colorNode=e&&e.colorNode||xe(this.color).setGroup(ye),this.baseColorNode=null,this.shadowNode=null,this.shadowColorNode=null,this.isAnalyticLightNode=!0,this.updateType=Me.FRAME,e&&e.shadow&&(this._shadowDisposeListener=()=>{this.disposeShadow()},e.addEventListener("dispose",this._shadowDisposeListener))}dispose(){this._shadowDisposeListener&&this.light.removeEventListener("dispose",this._shadowDisposeListener),super.dispose()}disposeShadow(){this.shadowNode!==null&&(this.shadowNode.dispose(),this.shadowNode=null),this.shadowColorNode=null,this.baseColorNode!==null&&(this.colorNode=this.baseColorNode,this.baseColorNode=null)}getHash(){return this.light.uuid}getLightVector(e){return qN(this.light).sub(e.context.positionView||$t)}setupDirect(){}setupDirectRectArea(){}setupShadowNode(){return d2(this.light)}setupShadow(e){let{renderer:t}=e;if(t.shadowMap.enabled===!1)return;let s=this.shadowColorNode;if(s===null){let n=this.light.shadow.shadowNode,a;n!==void 0?a=pe(n):a=this.setupShadowNode(),this.shadowNode=a,this.shadowColorNode=s=this.colorNode.mul(a),this.baseColorNode=this.colorNode}e.context.getShadow&&(s=e.context.getShadow(this,e)),this.colorNode=s}setup(e){this.colorNode=this.baseColorNode||this.colorNode,this.light.castShadow?e.object.receiveShadow&&this.setupShadow(e):this.shadowNode!==null&&(this.shadowNode.dispose(),this.shadowNode=null,this.shadowColorNode=null);let t=this.setupDirect(e),s=this.setupDirectRectArea(e);t&&e.lightsNode.setupDirectLight(e,this,t),s&&e.lightsNode.setupDirectRectAreaLight(e,this,s)}update(){let{light:e}=this;this.color.copy(e.color).multiplyScalar(e.intensity)}},JN=F(({lightDistance:r,cutoffDistance:e,decayExponent:t})=>{let s=r.pow(t).max(.01).reciprocal();return e.greaterThan(0).select(s.mul(r.div(e).pow4().oneMinus().clamp().pow2()),s)}),b2=({color:r,lightVector:e,cutoffDistance:t,decayExponent:s})=>{let n=e.normalize(),a=e.length(),i=JN({lightDistance:a,cutoffDistance:t,decayExponent:s}),o=r.mul(i);return{lightDirection:n,lightColor:o}},Zm=class extends ur{static get type(){return"PointLightNode"}constructor(e=null){super(e),this.cutoffDistanceNode=xe(0).setGroup(ye),this.decayExponentNode=xe(2).setGroup(ye)}update(e){let{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setupShadowNode(){return m2(this.light)}setupDirect(e){return b2({color:this.colorNode,lightVector:this.getLightVector(e),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode})}},lG=F(([r=ot()])=>{let e=r.mul(2),t=e.x.floor(),s=e.y.floor();return t.add(s).mod(2).sign()}),hG=F(([r=ot()],{renderer:e,material:t})=>{let s=z1(r.mul(2).sub(1)),n;if(t.alphaToCoverage&&e.currentSamples>0){let a=S(s.fwidth()).toVar();n=ma(a.oneMinus(),a.add(1),s).oneMinus()}else n=$s(s.greaterThan(1),0,1);return n}),Kw=(r,e=0)=>{r=Z(r),e=S(e);let t=Te(e,Math.PI/180),s=_s(t),n=Ln(t),a=r.x,i=r.y;return Z(lt(Te(n,a),Te(s,i)),ze(Te(n,i),Te(s,a)))},g2=(r,e=0,t=C(0,1,0))=>{r=C(r),e=S(e),t=C(t);let s=Vs(t),n=Te(e,Math.PI/180),a=_s(n),i=Ln(n),o=ze(1,i);return r.mul(i).add(r.cross(s).mul(a)).add(s.mul(s.dot(r).mul(o)))},Nm=F(([r,e,t])=>{let s=S(t).toVar(),n=S(e).toVar(),a=Va(r).toVar();return $s(a,n,s).uniformFlow()}).setLayout({name:"mx_select",type:"float",inputs:[{name:"b",type:"bool"},{name:"t",type:"float"},{name:"f",type:"float"}]}),Jw=F(([r,e])=>{let t=Va(e).toVar(),s=S(r).toVar();return $s(t,s.negate(),s).uniformFlow()}).setLayout({name:"mx_negate_if",type:"float",inputs:[{name:"val",type:"float"},{name:"b",type:"bool"}]}),Ls=F(([r])=>{let e=S(r).toVar();return k(zs(e))}).setLayout({name:"mx_floor",type:"int",inputs:[{name:"x",type:"float"}]}),_t=F(([r,e])=>{let t=S(r).toVar();return e.assign(Ls(t)),t.sub(S(e))}),y2=(r,e,t,s,n,a)=>{let i=S(ze(1,n)).toVar();return ze(1,a).mul(r.mul(i).add(e.mul(n))).add(a.mul(t.mul(i).add(s.mul(n))))},x2=(r,e,t,s,n,a,i,o,c,l,h)=>{let u=S(ze(1,c)).toVar(),d=S(ze(1,l)).toVar();return S(ze(1,h)).toVar().mul(d.mul(r.mul(u).add(e.mul(c))).add(l.mul(t.mul(u).add(s.mul(c))))).add(h.mul(d.mul(n.mul(u).add(a.mul(c))).add(l.mul(i.mul(u).add(o.mul(c))))))},uG=F(([r,e,t,s,n,a])=>{let i=S(a).toVar(),o=S(n).toVar(),c=S(s).toVar(),l=S(t).toVar(),h=S(e).toVar(),u=S(r).toVar();return y2(u,h,l,c,o,i)}).setLayout({name:"mx_bilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"}]}),dG=F(([r,e,t,s,n,a])=>{let i=S(a).toVar(),o=S(n).toVar(),c=C(s).toVar(),l=C(t).toVar(),h=C(e).toVar(),u=C(r).toVar();return y2(u,h,l,c,o,i)}).setLayout({name:"mx_bilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"}]}),w2=Ys([uG,dG]),fG=F(([r,e,t,s,n,a,i,o,c,l,h])=>{let u=S(h).toVar(),d=S(l).toVar(),f=S(c).toVar(),p=S(o).toVar(),m=S(i).toVar(),b=S(a).toVar(),g=S(n).toVar(),x=S(s).toVar(),T=S(t).toVar(),y=S(e).toVar(),v=S(r).toVar();return x2(v,y,T,x,g,b,m,p,f,d,u)}).setLayout({name:"mx_trilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"v4",type:"float"},{name:"v5",type:"float"},{name:"v6",type:"float"},{name:"v7",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]}),pG=F(([r,e,t,s,n,a,i,o,c,l,h])=>{let u=S(h).toVar(),d=S(l).toVar(),f=S(c).toVar(),p=C(o).toVar(),m=C(i).toVar(),b=C(a).toVar(),g=C(n).toVar(),x=C(s).toVar(),T=C(t).toVar(),y=C(e).toVar(),v=C(r).toVar();return x2(v,y,T,x,g,b,m,p,f,d,u)}).setLayout({name:"mx_trilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"v4",type:"vec3"},{name:"v5",type:"vec3"},{name:"v6",type:"vec3"},{name:"v7",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]}),T2=Ys([fG,pG]),mG=F(([r,e,t])=>{let s=S(t).toVar(),n=S(e).toVar(),a=V(r).toVar(),i=V(a.bitAnd(V(7))).toVar(),o=S(Nm(i.lessThan(V(4)),n,s)).toVar(),c=S(Te(2,Nm(i.lessThan(V(4)),s,n))).toVar();return Jw(o,Va(i.bitAnd(V(1)))).add(Jw(c,Va(i.bitAnd(V(2)))))}).setLayout({name:"mx_gradient_float_0",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"}]}),bG=F(([r,e,t,s])=>{let n=S(s).toVar(),a=S(t).toVar(),i=S(e).toVar(),o=V(r).toVar(),c=V(o.bitAnd(V(15))).toVar(),l=S(Nm(c.lessThan(V(8)),i,a)).toVar(),h=S(Nm(c.lessThan(V(4)),a,Nm(c.equal(V(12)).or(c.equal(V(14))),i,n))).toVar();return Jw(l,Va(c.bitAnd(V(1)))).add(Jw(h,Va(c.bitAnd(V(2)))))}).setLayout({name:"mx_gradient_float_1",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]}),Os=Ys([mG,bG]),gG=F(([r,e,t])=>{let s=S(t).toVar(),n=S(e).toVar(),a=ya(r).toVar();return C(Os(a.x,n,s),Os(a.y,n,s),Os(a.z,n,s))}).setLayout({name:"mx_gradient_vec3_0",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"}]}),yG=F(([r,e,t,s])=>{let n=S(s).toVar(),a=S(t).toVar(),i=S(e).toVar(),o=ya(r).toVar();return C(Os(o.x,i,a,n),Os(o.y,i,a,n),Os(o.z,i,a,n))}).setLayout({name:"mx_gradient_vec3_1",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]}),Pa=Ys([gG,yG]),xG=F(([r])=>{let e=S(r).toVar();return Te(.6616,e)}).setLayout({name:"mx_gradient_scale2d_0",type:"float",inputs:[{name:"v",type:"float"}]}),wG=F(([r])=>{let e=S(r).toVar();return Te(.982,e)}).setLayout({name:"mx_gradient_scale3d_0",type:"float",inputs:[{name:"v",type:"float"}]}),TG=F(([r])=>{let e=C(r).toVar();return Te(.6616,e)}).setLayout({name:"mx_gradient_scale2d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]}),v2=Ys([xG,TG]),vG=F(([r])=>{let e=C(r).toVar();return Te(.982,e)}).setLayout({name:"mx_gradient_scale3d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]}),_2=Ys([wG,vG]),ha=F(([r,e])=>{let t=k(e).toVar(),s=V(r).toVar();return s.shiftLeft(t).bitOr(s.shiftRight(k(32).sub(t)))}).setLayout({name:"mx_rotl32",type:"uint",inputs:[{name:"x",type:"uint"},{name:"k",type:"int"}]}),Ab=F(([r,e,t])=>(r=V(r).toVar(),e=V(e).toVar(),t=V(t).toVar(),r.subAssign(t),r.bitXorAssign(ha(t,k(4))),t.addAssign(e),e.subAssign(r),e.bitXorAssign(ha(r,k(6))),r.addAssign(t),t.subAssign(e),t.bitXorAssign(ha(e,k(8))),e.addAssign(r),r.subAssign(t),r.bitXorAssign(ha(t,k(16))),t.addAssign(e),e.subAssign(r),e.bitXorAssign(ha(r,k(19))),r.addAssign(t),t.subAssign(e),t.bitXorAssign(ha(e,k(4))),e.addAssign(r),ya(r,e,t))).setLayout({name:"mx_bjmix",type:"uvec3",inputs:[{name:"a",type:"uint"},{name:"b",type:"uint"},{name:"c",type:"uint"}]}),jn=F(([r,e,t])=>{let s=V(t).toVar(),n=V(e).toVar(),a=V(r).toVar();return s.bitXorAssign(n),s.subAssign(ha(n,k(14))),a.bitXorAssign(s),a.subAssign(ha(s,k(11))),n.bitXorAssign(a),n.subAssign(ha(a,k(25))),s.bitXorAssign(n),s.subAssign(ha(n,k(16))),a.bitXorAssign(s),a.subAssign(ha(s,k(4))),n.bitXorAssign(a),n.subAssign(ha(a,k(14))),s.bitXorAssign(n),s.subAssign(ha(n,k(24))),s}).setLayout({name:"mx_bjfinal",type:"uint",inputs:[{name:"a",type:"uint"},{name:"b",type:"uint"},{name:"c",type:"uint"}]}),Ss=F(([r])=>{let e=V(r).toVar();return S(e).div(S(V(4294967295)))}).setLayout({name:"mx_bits_to_01",type:"float",inputs:[{name:"bits",type:"uint"}]}),ir=F(([r])=>{let e=S(r).toVar();return e.mul(e).mul(e).mul(e.mul(e.mul(6).sub(15)).add(10))}).setLayout({name:"mx_fade",type:"float",inputs:[{name:"t",type:"float"}]}),_G=F(([r])=>{let e=k(r).toVar(),t=V(V(1)).toVar(),s=V(V(3735928559).add(t.shiftLeft(V(2))).add(V(13))).toVar();return jn(s.add(V(e)),s,s)}).setLayout({name:"mx_hash_int_0",type:"uint",inputs:[{name:"x",type:"int"}]}),AG=F(([r,e])=>{let t=k(e).toVar(),s=k(r).toVar(),n=V(V(2)).toVar(),a=V().toVar(),i=V().toVar(),o=V().toVar();return a.assign(i.assign(o.assign(V(3735928559).add(n.shiftLeft(V(2))).add(V(13))))),a.addAssign(V(s)),i.addAssign(V(t)),jn(a,i,o)}).setLayout({name:"mx_hash_int_1",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),MG=F(([r,e,t])=>{let s=k(t).toVar(),n=k(e).toVar(),a=k(r).toVar(),i=V(V(3)).toVar(),o=V().toVar(),c=V().toVar(),l=V().toVar();return o.assign(c.assign(l.assign(V(3735928559).add(i.shiftLeft(V(2))).add(V(13))))),o.addAssign(V(a)),c.addAssign(V(n)),l.addAssign(V(s)),jn(o,c,l)}).setLayout({name:"mx_hash_int_2",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),SG=F(([r,e,t,s])=>{let n=k(s).toVar(),a=k(t).toVar(),i=k(e).toVar(),o=k(r).toVar(),c=V(V(4)).toVar(),l=V().toVar(),h=V().toVar(),u=V().toVar();l.assign(h.assign(u.assign(V(3735928559).add(c.shiftLeft(V(2))).add(V(13))))),l.addAssign(V(o)),h.addAssign(V(i)),u.addAssign(V(a));let d=ya(Ab(l,h,u)).toVar();return l.assign(d.x),h.assign(d.y),u.assign(d.z),l.addAssign(V(n)),jn(l,h,u)}).setLayout({name:"mx_hash_int_3",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"}]}),NG=F(([r,e,t,s,n])=>{let a=k(n).toVar(),i=k(s).toVar(),o=k(t).toVar(),c=k(e).toVar(),l=k(r).toVar(),h=V(V(5)).toVar(),u=V().toVar(),d=V().toVar(),f=V().toVar();u.assign(d.assign(f.assign(V(3735928559).add(h.shiftLeft(V(2))).add(V(13))))),u.addAssign(V(l)),d.addAssign(V(c)),f.addAssign(V(o));let p=ya(Ab(u,d,f)).toVar();return u.assign(p.x),d.assign(p.y),f.assign(p.z),u.addAssign(V(i)),d.addAssign(V(a)),jn(u,d,f)}).setLayout({name:"mx_hash_int_4",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"},{name:"yy",type:"int"}]}),Ot=Ys([_G,AG,MG,SG,NG]),RG=F(([r,e])=>{let t=k(e).toVar(),s=k(r).toVar(),n=V(Ot(s,t)).toVar(),a=ya().toVar();return a.x.assign(n.bitAnd(k(255))),a.y.assign(n.shiftRight(k(8)).bitAnd(k(255))),a.z.assign(n.shiftRight(k(16)).bitAnd(k(255))),a}).setLayout({name:"mx_hash_vec3_0",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),EG=F(([r,e,t])=>{let s=k(t).toVar(),n=k(e).toVar(),a=k(r).toVar(),i=V(Ot(a,n,s)).toVar(),o=ya().toVar();return o.x.assign(i.bitAnd(k(255))),o.y.assign(i.shiftRight(k(8)).bitAnd(k(255))),o.z.assign(i.shiftRight(k(16)).bitAnd(k(255))),o}).setLayout({name:"mx_hash_vec3_1",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),Da=Ys([RG,EG]),CG=F(([r])=>{let e=Z(r).toVar(),t=k().toVar(),s=k().toVar(),n=S(_t(e.x,t)).toVar(),a=S(_t(e.y,s)).toVar(),i=S(ir(n)).toVar(),o=S(ir(a)).toVar(),c=S(w2(Os(Ot(t,s),n,a),Os(Ot(t.add(k(1)),s),n.sub(1),a),Os(Ot(t,s.add(k(1))),n,a.sub(1)),Os(Ot(t.add(k(1)),s.add(k(1))),n.sub(1),a.sub(1)),i,o)).toVar();return v2(c)}).setLayout({name:"mx_perlin_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"}]}),kG=F(([r])=>{let e=C(r).toVar(),t=k().toVar(),s=k().toVar(),n=k().toVar(),a=S(_t(e.x,t)).toVar(),i=S(_t(e.y,s)).toVar(),o=S(_t(e.z,n)).toVar(),c=S(ir(a)).toVar(),l=S(ir(i)).toVar(),h=S(ir(o)).toVar(),u=S(T2(Os(Ot(t,s,n),a,i,o),Os(Ot(t.add(k(1)),s,n),a.sub(1),i,o),Os(Ot(t,s.add(k(1)),n),a,i.sub(1),o),Os(Ot(t.add(k(1)),s.add(k(1)),n),a.sub(1),i.sub(1),o),Os(Ot(t,s,n.add(k(1))),a,i,o.sub(1)),Os(Ot(t.add(k(1)),s,n.add(k(1))),a.sub(1),i,o.sub(1)),Os(Ot(t,s.add(k(1)),n.add(k(1))),a,i.sub(1),o.sub(1)),Os(Ot(t.add(k(1)),s.add(k(1)),n.add(k(1))),a.sub(1),i.sub(1),o.sub(1)),c,l,h)).toVar();return _2(u)}).setLayout({name:"mx_perlin_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"}]}),Mb=Ys([CG,kG]),IG=F(([r])=>{let e=Z(r).toVar(),t=k().toVar(),s=k().toVar(),n=S(_t(e.x,t)).toVar(),a=S(_t(e.y,s)).toVar(),i=S(ir(n)).toVar(),o=S(ir(a)).toVar(),c=C(w2(Pa(Da(t,s),n,a),Pa(Da(t.add(k(1)),s),n.sub(1),a),Pa(Da(t,s.add(k(1))),n,a.sub(1)),Pa(Da(t.add(k(1)),s.add(k(1))),n.sub(1),a.sub(1)),i,o)).toVar();return v2(c)}).setLayout({name:"mx_perlin_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),BG=F(([r])=>{let e=C(r).toVar(),t=k().toVar(),s=k().toVar(),n=k().toVar(),a=S(_t(e.x,t)).toVar(),i=S(_t(e.y,s)).toVar(),o=S(_t(e.z,n)).toVar(),c=S(ir(a)).toVar(),l=S(ir(i)).toVar(),h=S(ir(o)).toVar(),u=C(T2(Pa(Da(t,s,n),a,i,o),Pa(Da(t.add(k(1)),s,n),a.sub(1),i,o),Pa(Da(t,s.add(k(1)),n),a,i.sub(1),o),Pa(Da(t.add(k(1)),s.add(k(1)),n),a.sub(1),i.sub(1),o),Pa(Da(t,s,n.add(k(1))),a,i,o.sub(1)),Pa(Da(t.add(k(1)),s,n.add(k(1))),a.sub(1),i,o.sub(1)),Pa(Da(t,s.add(k(1)),n.add(k(1))),a,i.sub(1),o.sub(1)),Pa(Da(t.add(k(1)),s.add(k(1)),n.add(k(1))),a.sub(1),i.sub(1),o.sub(1)),c,l,h)).toVar();return _2(u)}).setLayout({name:"mx_perlin_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),$N=Ys([IG,BG]),FG=F(([r])=>{let e=S(r).toVar(),t=k(Ls(e)).toVar();return Ss(Ot(t))}).setLayout({name:"mx_cell_noise_float_0",type:"float",inputs:[{name:"p",type:"float"}]}),PG=F(([r])=>{let e=Z(r).toVar(),t=k(Ls(e.x)).toVar(),s=k(Ls(e.y)).toVar();return Ss(Ot(t,s))}).setLayout({name:"mx_cell_noise_float_1",type:"float",inputs:[{name:"p",type:"vec2"}]}),DG=F(([r])=>{let e=C(r).toVar(),t=k(Ls(e.x)).toVar(),s=k(Ls(e.y)).toVar(),n=k(Ls(e.z)).toVar();return Ss(Ot(t,s,n))}).setLayout({name:"mx_cell_noise_float_2",type:"float",inputs:[{name:"p",type:"vec3"}]}),OG=F(([r])=>{let e=ce(r).toVar(),t=k(Ls(e.x)).toVar(),s=k(Ls(e.y)).toVar(),n=k(Ls(e.z)).toVar(),a=k(Ls(e.w)).toVar();return Ss(Ot(t,s,n,a))}).setLayout({name:"mx_cell_noise_float_3",type:"float",inputs:[{name:"p",type:"vec4"}]}),Ul=Ys([FG,PG,DG,OG]),UG=F(([r])=>{let e=S(r).toVar(),t=k(Ls(e)).toVar();return C(Ss(Ot(t,k(0))),Ss(Ot(t,k(1))),Ss(Ot(t,k(2))))}).setLayout({name:"mx_cell_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"float"}]}),LG=F(([r])=>{let e=Z(r).toVar(),t=k(Ls(e.x)).toVar(),s=k(Ls(e.y)).toVar();return C(Ss(Ot(t,s,k(0))),Ss(Ot(t,s,k(1))),Ss(Ot(t,s,k(2))))}).setLayout({name:"mx_cell_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),zG=F(([r])=>{let e=C(r).toVar(),t=k(zs(e.x)).toVar(),s=k(zs(e.y)).toVar(),n=k(zs(e.z)).toVar(),a=V(3735928588).toVar(),i=V().toVar(),o=V().toVar(),c=V().toVar();i.assign(o.assign(c.assign(a))),i.addAssign(V(t)),o.addAssign(V(s)),c.addAssign(V(n));let l=ya(Ab(i,o,c)).toVar(),h=jn(l.x,l.y,l.z),u=jn(lt(l.x,V(1)),l.y,l.z),d=jn(lt(l.x,V(2)),l.y,l.z);return C(Ss(h),Ss(u),Ss(d))}).setLayout({name:"mx_cell_noise_vec3_2",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),VG=F(([r])=>{let e=ce(r).toVar(),t=k(Ls(e.x)).toVar(),s=k(Ls(e.y)).toVar(),n=k(Ls(e.z)).toVar(),a=k(Ls(e.w)).toVar(),i=V(3735928592).toVar(),o=V().toVar(),c=V().toVar(),l=V().toVar();o.assign(c.assign(l.assign(i))),o.addAssign(V(t)),c.addAssign(V(s)),l.addAssign(V(n));let h=ya(Ab(o,c,l)).toVar();return o.assign(h.x),c.assign(h.y),l.assign(h.z),o.addAssign(V(a)),C(Ss(jn(o,c,l)),Ss(jn(o,lt(c,V(1)),l)),Ss(jn(o,lt(c,V(2)),l)))}).setLayout({name:"mx_cell_noise_vec3_3",type:"vec3",inputs:[{name:"p",type:"vec4"}]}),$w=Ys([UG,LG,zG,VG]),Yw=F(([r])=>{let e=C(r).toVar(),t=k(zs(e.x)).toVar(),s=k(zs(e.y)).toVar(),n=k(zs(e.z)).toVar(),a=V(3735928588).toVar(),i=V().toVar(),o=V().toVar(),c=V().toVar();i.assign(o.assign(c.assign(a))),i.addAssign(V(t)),o.addAssign(V(s)),c.addAssign(V(n));let l=ya(Ab(i,o,c)).toVar(),h=jn(l.x,l.y,l.z),u=jn(lt(l.x,V(1)),l.y,l.z),d=jn(lt(l.x,V(2)),l.y,l.z);return C(Ss(h),Ss(u),Ss(d))}),jG=F(([r,e,t,s])=>{let n=S(s).toVar(),a=S(t).toVar(),i=k(e).toVar(),o=Z(r).toVar(),c=S(0).toVar(),l=S(1).toVar();return tt(i,()=>{c.addAssign(l.mul(Mb(o))),l.mulAssign(n),o.mulAssign(a)}),c}).setLayout({name:"mx_fractal_noise_float_2d",type:"float",inputs:[{name:"p",type:"vec2"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),Hd=F(([r,e,t,s])=>{let n=S(s).toVar(),a=S(t).toVar(),i=k(e).toVar(),o=C(r).toVar(),c=S(0).toVar(),l=S(1).toVar();return tt(i,()=>{c.addAssign(l.mul(Mb(o))),l.mulAssign(n),o.mulAssign(a)}),c}).setLayout({name:"mx_fractal_noise_float",type:"float",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),A2=F(([r,e,t,s])=>{let n=S(s).toVar(),a=S(t).toVar(),i=k(e).toVar(),o=C(r).toVar(),c=C(0).toVar(),l=S(1).toVar();return tt(i,()=>{c.addAssign(l.mul($N(o))),l.mulAssign(n),o.mulAssign(a)}),c}).setLayout({name:"mx_fractal_noise_vec3",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),GG=F(([r,e,t,s])=>{let n=S(s).toVar(),a=S(t).toVar(),i=k(e).toVar(),o=C(r).toVar();return Z(Hd(o,i,a,n),Hd(o.add(C(k(19),k(193),k(17))),i,a,n))}).setLayout({name:"mx_fractal_noise_vec2",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),HG=F(([r,e,t,s])=>{let n=S(s).toVar(),a=S(t).toVar(),i=k(e).toVar(),o=C(r).toVar(),c=C(A2(o,i,a,n)).toVar(),l=S(Hd(o.add(C(k(19),k(193),k(17))),i,a,n)).toVar();return ce(c,l)}).setLayout({name:"mx_fractal_noise_vec4",type:"vec4",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),WG=F(([r,e,t,s,n,a,i])=>{let o=k(i).toVar(),c=S(a).toVar(),l=k(n).toVar(),h=k(s).toVar(),u=k(t).toVar(),d=k(e).toVar(),f=Z(r).toVar(),p=C($w(Z(d.add(h),u.add(l)))).toVar(),m=Z(p.x,p.y).toVar();m.subAssign(.5),m.mulAssign(c),m.addAssign(.5);let b=Z(Z(S(d),S(u)).add(m)).toVar(),g=Z(b.sub(f)).toVar();return fe(o.equal(k(2)),()=>bt(g.x).add(bt(g.y))),fe(o.equal(k(3)),()=>Pt(bt(g.x),bt(g.y))),Gn(g,g)}).setLayout({name:"mx_worley_distance_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),qG=F(([r,e,t,s,n,a,i,o,c])=>{let l=k(c).toVar(),h=S(o).toVar(),u=k(i).toVar(),d=k(a).toVar(),f=k(n).toVar(),p=k(s).toVar(),m=k(t).toVar(),b=k(e).toVar(),g=C(r).toVar(),x=C(Yw(C(b.add(f),m.add(d),p.add(u)))).toVar();x.subAssign(.5),x.mulAssign(h),x.addAssign(.5);let T=C(C(S(b),S(m),S(p)).add(x)).toVar(),y=C(T.sub(g)).toVar();return fe(l.equal(k(2)),()=>bt(y.x).add(bt(y.y)).add(bt(y.z))),fe(l.equal(k(3)),()=>Pt(bt(y.x),bt(y.y),bt(y.z))),Gn(y,y)}).setLayout({name:"mx_worley_distance_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"zoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),Ql=Ys([WG,qG]),M2=(r,e=1,t=0)=>Mb(r).mul(e).add(t),S2=F(([r,e,t])=>{let s=C(r).toVar(),n=S(e).toVar(),a=k(t).toVar(),i=k().toVar(),o=k().toVar(),c=k().toVar(),l=C(_t(s.x,i),_t(s.y,o),_t(s.z,c)).toVar(),h=S(1e6).toVar(),u=C(0,0,0).toVar();return tt({start:-1,end:k(1),name:"x",condition:"<="},({x:d})=>{tt({start:-1,end:k(1),name:"y",condition:"<="},({y:f})=>{tt({start:-1,end:k(1),name:"z",condition:"<="},({z:p})=>{let m=S(Ql(l,d,f,p,i,o,c,n,k(0))).toVar(),b=C(Yw(C(i.add(d),o.add(f),c.add(p)))).toVar();b.subAssign(.5),b.mulAssign(n),b.addAssign(.5);let g=C(C(S(d),S(f),S(p)).add(b).sub(l)).toVar();fe(m.lessThan(h),()=>{h.assign(m),u.assign(g)})})})}),fe(a.equal(k(1)),()=>{h.assign(Ul(u.add(s)))}).Else(()=>{h.assign(fn(h))}),h}),N2=F(([r,e,t])=>{let s=Z(r).toVar(),n=S(e).toVar(),a=k(t).toVar(),i=zs(s).toVar(),o=Z(ja(s.x),ja(s.y)).toVar(),c=S(1e6).toVar(),l=Z(0,0).toVar();return tt({start:-1,end:k(1),name:"x",condition:"<="},({x:h})=>{tt({start:-1,end:k(1),name:"y",condition:"<="},({y:u})=>{let d=Z(S(h),S(u)).toVar(),f=Z(d.x.add(i.x),d.y.add(i.y)).toVar(),p=Z(Ul(C(f.x,f.y,0)),Ul(C(f.x,f.y,1))).toVar();p.subAssign(.5),p.mulAssign(n),p.addAssign(.5);let m=Z(d.add(p).sub(o)).toVar(),b=Gn(m,m).toVar();fe(b.lessThan(c),()=>{c.assign(b),l.assign(m)})})}),fe(a.equal(k(1)),()=>{c.assign(Ul(l.add(s)))}).Else(()=>{c.assign(fn(c))}),c}),XG=F(([r,e,t])=>{let s=k(t).toVar(),n=S(e).toVar(),a=Z(r).toVar(),i=k().toVar(),o=k().toVar(),c=Z(_t(a.x,i),_t(a.y,o)).toVar(),l=Z(1e6,1e6).toVar();return tt({start:-1,end:k(1),name:"x",condition:"<="},({x:h})=>{tt({start:-1,end:k(1),name:"y",condition:"<="},({y:u})=>{let d=S(Ql(c,h,u,i,o,n,s)).toVar();fe(d.lessThan(l.x),()=>{l.y.assign(l.x),l.x.assign(d)}).ElseIf(d.lessThan(l.y),()=>{l.y.assign(d)})})}),fe(s.equal(k(0)),()=>{l.assign(fn(l))}),l}).setLayout({name:"mx_worley_noise_vec2_0",type:"vec2",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),KG=F(([r,e,t])=>{let s=k(t).toVar(),n=S(e).toVar(),a=Z(r).toVar(),i=k().toVar(),o=k().toVar(),c=Z(_t(a.x,i),_t(a.y,o)).toVar(),l=C(1e6,1e6,1e6).toVar();return tt({start:-1,end:k(1),name:"x",condition:"<="},({x:h})=>{tt({start:-1,end:k(1),name:"y",condition:"<="},({y:u})=>{let d=S(Ql(c,h,u,i,o,n,s)).toVar();fe(d.lessThan(l.x),()=>{l.z.assign(l.y),l.y.assign(l.x),l.x.assign(d)}).ElseIf(d.lessThan(l.y),()=>{l.z.assign(l.y),l.y.assign(d)}).ElseIf(d.lessThan(l.z),()=>{l.z.assign(d)})})}),fe(s.equal(k(0)),()=>{l.assign(fn(l))}),l}).setLayout({name:"mx_worley_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),JG=F(([r,e,t])=>{let s=k(t).toVar(),n=S(e).toVar(),a=C(r).toVar(),i=k().toVar(),o=k().toVar(),c=k().toVar(),l=C(_t(a.x,i),_t(a.y,o),_t(a.z,c)).toVar(),h=Z(1e6,1e6).toVar();return tt({start:-1,end:k(1),name:"x",condition:"<="},({x:u})=>{tt({start:-1,end:k(1),name:"y",condition:"<="},({y:d})=>{tt({start:-1,end:k(1),name:"z",condition:"<="},({z:f})=>{let p=S(Ql(l,u,d,f,i,o,c,n,s)).toVar();fe(p.lessThan(h.x),()=>{h.y.assign(h.x),h.x.assign(p)}).ElseIf(p.lessThan(h.y),()=>{h.y.assign(p)})})})}),fe(s.equal(k(0)),()=>{h.assign(fn(h))}),h}).setLayout({name:"mx_worley_noise_vec2_1",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),$G=Ys([XG,JG]),YG=F(([r,e,t])=>{let s=k(t).toVar(),n=S(e).toVar(),a=C(r).toVar(),i=k().toVar(),o=k().toVar(),c=k().toVar(),l=C(_t(a.x,i),_t(a.y,o),_t(a.z,c)).toVar(),h=C(1e6,1e6,1e6).toVar();return tt({start:-1,end:k(1),name:"x",condition:"<="},({x:u})=>{tt({start:-1,end:k(1),name:"y",condition:"<="},({y:d})=>{tt({start:-1,end:k(1),name:"z",condition:"<="},({z:f})=>{let p=S(Ql(l,u,d,f,i,o,c,n,s)).toVar();fe(p.lessThan(h.x),()=>{h.z.assign(h.y),h.y.assign(h.x),h.x.assign(p)}).ElseIf(p.lessThan(h.y),()=>{h.z.assign(h.y),h.y.assign(p)}).ElseIf(p.lessThan(h.z),()=>{h.z.assign(p)})})})}),fe(s.equal(k(0)),()=>{h.assign(fn(h))}),h}).setLayout({name:"mx_worley_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),YN=Ys([KG,YG]),ZG=F(([r,e,t,s])=>{let n=k(s).toVar(),a=k(t).toVar(),i=S(e).toVar(),o=Z(r).toVar(),c=k().toVar(),l=k().toVar(),h=Z(_t(o.x,c),_t(o.y,l)).toVar(),u=S(1e6).toVar(),d=Z(0,0).toVar();tt({start:-1,end:k(1),name:"x",condition:"<="},({x:p})=>{tt({start:-1,end:k(1),name:"y",condition:"<="},({y:m})=>{let b=S(Ql(h,p,m,c,l,i,n)).toVar(),g=C($w(Z(c.add(p),l.add(m)))).toVar(),x=Z(g.x,g.y).toVar();x.subAssign(.5),x.mulAssign(i),x.addAssign(.5);let T=Z(Z(S(p),S(m)).add(x).sub(h)).toVar();fe(b.lessThan(u),()=>{u.assign(b),d.assign(T)})})});let f=C(YN(o,i,n)).toVar();return fe(a.equal(k(1)),()=>{f.assign($w(d.add(o)))}),f}).setLayout({name:"mx_worley_noise_vec3_style_0",type:"vec3",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"style",type:"int"},{name:"metric",type:"int"}]}),QG=F(([r,e,t,s])=>{let n=k(s).toVar(),a=k(t).toVar(),i=S(e).toVar(),o=C(r).toVar(),c=k().toVar(),l=k().toVar(),h=k().toVar(),u=C(_t(o.x,c),_t(o.y,l),_t(o.z,h)).toVar(),d=S(1e6).toVar(),f=C(0,0,0).toVar();tt({start:-1,end:k(1),name:"x",condition:"<="},({x:m})=>{tt({start:-1,end:k(1),name:"y",condition:"<="},({y:b})=>{tt({start:-1,end:k(1),name:"z",condition:"<="},({z:g})=>{let x=S(Ql(u,m,b,g,c,l,h,i,n)).toVar(),T=C(Yw(C(c.add(m),l.add(b),h.add(g)))).toVar();T.subAssign(.5),T.mulAssign(i),T.addAssign(.5);let y=C(C(S(m),S(b),S(g)).add(T).sub(u)).toVar();fe(x.lessThan(d),()=>{d.assign(x),f.assign(y)})})})});let p=C(YN(o,i,n)).toVar();return fe(a.equal(k(1)),()=>{p.assign(Yw(f.add(o)))}),p}).setLayout({name:"mx_worley_noise_vec3_style_1",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"style",type:"int"},{name:"metric",type:"int"}]}),e4=Ys([ZG,QG]),t4=F(([r,e,t,s,n,a,i,o,c,l,h,u])=>{let d=k(r).toVar(),f=Z(e).toVar(),p=Z(t).toVar(),m=Z(s).toVar(),b=S(n).toVar(),g=S(a).toVar(),x=S(i).toVar(),T=S(o).toVar(),y=k(c).toVar(),v=S(l).toVar(),_=S(h).toVar(),A=k(u).toVar(),M=Te(f,p).toVar(),N=lt(M,m).toVar(),R=Te(ze(b,1),9e4).toVar(),I=Kw(N,R).toVar(),D=C(N.x,N.y,R).toVar(),O=S(0).toVar();fe(d.equal(k(0)),()=>{O.assign(M2(I,.5,.5))}),fe(d.equal(k(1)),()=>{O.assign(Ul(I))}),fe(d.equal(k(2)),()=>{O.assign(N2(N,b,A))}),fe(d.equal(k(3)),()=>{O.assign(Hd(D,y,v,_))});let P=lt(g,Te(O,ze(x,g))).toVar(),U=Hn(P,g,x).toVar(),j=P.toVar();return fe(T.equal(S(1)),()=>{j.assign(U)}),j}),s4=F(([r,e,t,s,n,a,i,o,c,l,h,u])=>{let d=k(r).toVar(),f=C(e).toVar(),p=C(t).toVar(),m=C(s).toVar(),b=S(n).toVar(),g=S(a).toVar(),x=S(i).toVar(),T=S(o).toVar(),y=k(c).toVar(),v=S(l).toVar(),_=S(h).toVar(),A=k(u).toVar(),M=Te(f,p).toVar(),N=lt(M,m).toVar(),R=Te(ze(b,1),9e4).toVar(),I=g2(N,R,C(.1,1,0)).toVar(),D=M2(I,.5,.5),O=Ul(I),P=S2(N,b,A),U=Hd(I,y,v,_),j=D.toVar();fe(d.equal(k(1)),()=>{j.assign(O)}),fe(d.equal(k(2)),()=>{j.assign(P)}),fe(d.equal(k(3)),()=>{j.assign(U)});let z=lt(g,Te(j,ze(x,g))).toVar(),H=Hn(z,g,x).toVar(),J=z.toVar();return fe(T.equal(S(1)),()=>{J.assign(H)}),J}),n4=F(([r])=>{let e=r.y,t=r.z,s=C().toVar();return fe(e.lessThan(1e-4),()=>{s.assign(C(t,t,t))}).Else(()=>{let n=r.x;n=n.sub(zs(n)).mul(6).toVar();let a=k(O1(n)),i=n.sub(S(a)),o=t.mul(e.oneMinus()),c=t.mul(e.mul(i).oneMinus()),l=t.mul(e.mul(i.oneMinus()).oneMinus());fe(a.equal(k(0)),()=>{s.assign(C(t,l,o))}).ElseIf(a.equal(k(1)),()=>{s.assign(C(c,t,o))}).ElseIf(a.equal(k(2)),()=>{s.assign(C(o,t,l))}).ElseIf(a.equal(k(3)),()=>{s.assign(C(o,c,t))}).ElseIf(a.equal(k(4)),()=>{s.assign(C(l,o,t))}).Else(()=>{s.assign(C(t,o,c))})}),s}).setLayout({name:"mx_hsvtorgb",type:"vec3",inputs:[{name:"hsv",type:"vec3"}]}),a4=F(([r])=>{let e=C(r).toVar(),t=S(e.x).toVar(),s=S(e.y).toVar(),n=S(e.z).toVar(),a=S(pa(t,pa(s,n))).toVar(),i=S(Pt(t,Pt(s,n))).toVar(),o=S(i.sub(a)).toVar(),c=S().toVar(),l=S().toVar(),h=S().toVar();return h.assign(i),fe(i.greaterThan(0),()=>{l.assign(o.div(i))}).Else(()=>{l.assign(0)}),fe(l.lessThanEqual(0),()=>{c.assign(0)}).Else(()=>{fe(t.greaterThanEqual(i),()=>{c.assign(s.sub(n).div(o))}).ElseIf(s.greaterThanEqual(i),()=>{c.assign(lt(2,n.sub(t).div(o)))}).Else(()=>{c.assign(lt(4,t.sub(s).div(o)))}),c.mulAssign(1/6),fe(c.lessThan(0),()=>{c.addAssign(1)})}),C(c,l,h)}).setLayout({name:"mx_rgbtohsv",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),i4=F(([r])=>{let e=C(r).toVar(),t=T1(N1(e,C(.04045))).toVar(),s=C(e.div(12.92)).toVar(),n=C(zn(Pt(e.add(C(.055)),C(0)).div(1.055),C(2.4))).toVar();return Ke(s,n,t)}).setLayout({name:"mx_srgb_texture_to_lin_rec709",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),R2=(r,e)=>{r=S(r),e=S(e);let t=Z(e.dFdx(),e.dFdy()).length().mul(.7071067811865476);return ma(r.sub(t),r.add(t),e)},E2=(r,e,t,s)=>Ke(r,e,t[s].clamp()),r4=(r,e,t=ot())=>E2(r,e,t,"x"),o4=(r,e,t=ot())=>E2(r,e,t,"y"),c4=(r,e,t,s,n=ot())=>{let a=n.x.clamp(),i=n.y.clamp(),o=Ke(r,e,a),c=Ke(t,s,a);return Ke(c,o,i)},C2=(r,e,t,s,n)=>Ke(r,e,R2(t,s[n])),l4=(r,e,t,s=ot())=>C2(r,e,t,s,"x"),h4=(r,e,t,s=ot())=>C2(r,e,t,s,"y"),u4=(r=1,e=0,t=ot())=>t.mul(r).add(e),d4=(r,e=1)=>(r=S(r),r.abs().pow(e).mul(r.sign())),f4=(r,e=1,t=.5)=>S(r).sub(t).mul(e).add(t),p4=(r=ot(),e=1,t=0)=>Mb(r.convert("vec2|vec3")).mul(e).add(t),m4=(r=ot(),e=1,t=0)=>$N(r.convert("vec2|vec3")).mul(e).add(t),b4=(r=ot(),e=1,t=0)=>(r=r.convert("vec2|vec3"),ce($N(r),Mb(r.add(Z(19,73)))).mul(e).add(t)),g4=(r,e=0,t=1)=>{let s=ze(t,e),n=Pt(bt(s),S(1e-6)),a=Hn(js(ze(r,e),n),S(0),S(1)),i=Te(Te(a,a),ze(S(3),Te(S(2),a))),o=rr(t,r),c=rr(t,e);return Ke(i,o,c)},y4=(r=ot())=>$w(r.convert("vec2|vec3")),x4=(r=ot(),e=1,t=0)=>N2(r,e,t),k2=(r=ot(),e=1,t=0)=>S2(r,e,t),w4=(r,e=ot(),t=Z(1,1),s=Z(0,0),n=1,a=0,i=1,o=!1,c=1,l=2,h=.5,u=0)=>t4(r,e,t,s,n,a,i,o,c,l,h,u),T4=(r,e=ot(),t=C(1,1,1),s=C(0,0,0),n=1,a=0,i=1,o=!1,c=1,l=2,h=.5,u=0)=>s4(r,e,t,s,n,a,i,o,c,l,h,u),v4=(r=ot(),e=1,t=0)=>k2(r.convert("vec2|vec3"),e,t),_4=(r=ot(),e=1)=>$G(r.convert("vec2|vec3"),e,k(1)),A4=(r=ot(),e=1,t=1)=>YN(r.convert("vec2|vec3"),e,k(t)),M4=(r=ot(),e=1,t=0,s=0)=>e4(r.convert("vec2|vec3"),e,k(t),k(s)),S4=(r=ot())=>Ul(r.convert("vec2|vec3")),N4=(r=ot(),e=3,t=2,s=.5,n=1)=>jG(r,k(e),t,s).mul(n),R4=(r=ot(),e=3,t=2,s=.5,n=1)=>Hd(r,k(e),t,s).mul(n),E4=(r=ot(),e=3,t=2,s=.5,n=1)=>GG(r,k(e),t,s).mul(n),C4=(r=ot(),e=3,t=2,s=.5,n=1)=>A2(r,k(e),t,s).mul(n),k4=(r=ot(),e=3,t=2,s=.5,n=1)=>HG(r,k(e),t,s).mul(n),I4=(r,e=S(0))=>lt(r,e),B4=(r,e=S(0))=>ze(r,e),F4=(r,e=S(1))=>Te(r,e),P4=(r,e=S(1))=>js(r,e),D4=(r,e=S(1))=>ze(r,Te(e,zs(js(r,e)))),O4=(r,e=S(1))=>zn(r,e),U4=(r=S(0),e=S(1))=>I1(r,e),L4=()=>Zd,z4=()=>XF,V4=(r,e=S(1))=>ze(e,r),j4=(r,e,t,s)=>r.greaterThan(e).mix(s,t),G4=(r,e,t,s)=>r.greaterThanEqual(e).mix(s,t),H4=(r,e,t,s)=>r.equal(e).mix(s,t),W4=(r,e=null)=>{if(typeof e=="string"){let t={x:0,r:0,y:1,g:1,z:2,b:2,w:3,a:3},s=e.replace(/^out/,"").toLowerCase();if(t[s]!==void 0)return r.element(t[s])}if(typeof e=="number")return r.element(e);if(typeof e=="string"&&e.length===1){let t={x:0,r:0,y:1,g:1,z:2,b:2,w:3,a:3};if(t[e]!==void 0)return r.element(t[e])}return r},q4=(r,e=Z(0,0),t=Z(1,1),s=S(0),n=Z(0,0),a=k(0))=>{let i=ze(r,e),o=lt(ze(Kw(js(i,t),s),n),e),c=lt(js(Kw(ze(i,n),s),t),e);return typeof a=="number"?Math.abs(a)>Number.EPSILON?c:o:Ke(o,c,rr(.5,S(a)))},X4=(r,e=1,t=ot())=>{let s=S(.0625),n=S(r),a=Z(t),i=Z(n.dFdx(),n.dFdy()).mul(S(e)).mul(s),o=Z(a.x.dFdx(),a.x.dFdy()),c=Z(a.y.dFdx(),a.y.dFdy()),l=C(o.x,c.x,i.x),h=C(o.y,c.y,i.y),u=Mi(l,h);return u=Gn(u,u).lessThan(S(1e-12)).mix(u,C(0,0,1)),u=u.z.lessThan(S(0)).mix(u,u.mul(-1)),Vs(u).mul(.5).add(.5)},K4=F(([r,e,t])=>{let s=Vs(r).toVar(),n=e.mul(.5).add(t).sub(Vn).div(s).toVar(),a=e.mul(-.5).add(t).sub(Vn).div(s).toVar(),i=C().toVar();i.x=s.x.greaterThan(S(0)).select(n.x,a.x),i.y=s.y.greaterThan(S(0)).select(n.y,a.y),i.z=s.z.greaterThan(S(0)).select(n.z,a.z);let o=pa(i.x,i.y,i.z).toVar();return Vn.add(s.mul(o)).toVar().sub(t)}),I2=F(([r,e])=>{let t=r.x,s=r.y,n=r.z,a=e.element(0).mul(.886227);return a=a.add(e.element(1).mul(2*.511664).mul(s)),a=a.add(e.element(2).mul(2*.511664).mul(n)),a=a.add(e.element(3).mul(2*.511664).mul(t)),a=a.add(e.element(4).mul(2*.429043).mul(t).mul(s)),a=a.add(e.element(5).mul(2*.429043).mul(s).mul(n)),a=a.add(e.element(6).mul(n.mul(n).mul(.743125).sub(.247708))),a=a.add(e.element(7).mul(2*.429043).mul(t).mul(n)),a=a.add(e.element(8).mul(.429043).mul(Te(t,t).sub(Te(s,s)))),a}),w=Object.freeze({__proto__:null,BRDF_GGX:f0,BRDF_Lambert:Hl,BRDF_Sheen:kF,BasicPointShadowFilter:f2,BasicShadowFilter:l2,Break:FU,Const:k9,Continue:BU,DFGLUT:MN,D_GGX:EF,D_GGX_Anisotropic:CF,Discard:W9,EPSILON:R1,EnvironmentBRDF:SN,F_Schlick:sc,Fn:F,HALF_PI:kO,INFINITY:RO,If:fe,LTC_Evaluate:p0,LTC_Evaluate_Volume:BF,LTC_Uv:mM,Loop:tt,NodeAccess:As,NodeShaderStage:Ml,NodeType:bI,NodeUpdateType:Me,OnAfterObjectUpdate:mN,OnAfterRenderPipeline:SU,OnBeforeFrameUpdate:sF,OnBeforeMaterialUpdate:AU,OnBeforeObjectUpdate:_U,OnBeforeRenderPipeline:MU,OnFrameUpdate:vU,OnMaterialUpdate:TU,OnObjectUpdate:vb,PCFShadowFilter:h2,PI:E1,PI2:EO,PointShadowFilter:p2,Return:VO,Schlick_to_F0:pM,ShaderNode:gd,Stack:wI,Switch:_O,TBNViewMatrix:Rl,TWO_PI:CO,VSMShadowFilter:u2,V_GGX_SmithCorrelated:NF,V_GGX_SmithCorrelated_Anisotropic:RF,Var:C9,VarIntent:I9,abs:bt,acesFilmicToneMapping:zN,acos:k1,acosh:i9,add:lt,addMethodChaining:G,addNodeElement:jO,agxToneMapping:VN,all:JI,alphaT:A0,ambientOcclusion:tM,and:PI,anisotropy:Ko,anisotropyB:Il,anisotropyT:vm,any:$I,array:N0,asin:n9,asinh:a9,assign:RI,atan:I1,atanh:r9,atomicAdd:fj,atomicAnd:gj,atomicFunc:pr,atomicLoad:uj,atomicMax:mj,atomicMin:bj,atomicOr:yj,atomicStore:dj,atomicSub:pj,atomicXor:xj,attenuationColor:A1,attenuationDistance:_1,attribute:Rn,attributeArray:yV,backgroundBlurriness:e2,backgroundIntensity:HM,backgroundRotation:t2,batch:lF,batchColor:gN,batchIndirectIndex:cF,bentNormalView:_B,billboarding:sV,bitAnd:LI,bitNot:zI,bitOr:VI,bitXor:jI,bitangentGeometry:fU,bitangentLocal:pU,bitangentView:TB,bitangentViewFrame:xB,bitangentWorld:mU,bitcast:HF,blendBurn:RV,blendColor:IV,blendDodge:EV,blendOverlay:kV,blendScreen:CV,bool:Va,buffer:Yd,bufferAttribute:q1,builtin:Ni,builtinAOContext:N9,builtinGIContext:R9,builtinShadowContext:S9,bumpMap:MB,bvec2:vI,bvec3:T1,bvec4:_I,bypass:G9,cache:j9,call:EI,cameraFar:Zr,cameraIndex:fr,cameraNear:Yr,cameraNormalMatrix:JO,cameraPosition:_d,cameraProjectionMatrix:En,cameraProjectionMatrixInverse:tN,cameraViewMatrix:Ua,cameraViewport:h0,cameraWorldMatrix:Yl,cbrt:w9,cdl:OV,ceil:zT,checker:lG,cineonToneMapping:LN,clamp:Hn,clearcoat:T0,clearcoatNormalView:$o,clearcoatRoughness:Td,clipSpace:eB,clipping:xF,clippingAlpha:wF,code:sv,color:TI,colorSpaceToWorking:GT,colorToDirection:yU,compute:V9,computeKernel:K1,computeSkinning:IU,context:Wn,convert:MI,convertColorSpace:PO,convertToTexture:fV,cos:Ln,cosh:e9,countLeadingZeros:bz,countOneBits:gz,countTrailingZeros:mz,cross:Mi,cubeTexture:Nn,cubeTextureBase:oN,dFdx:P1,dFdy:D1,dashSize:Bl,debug:X9,decrement:KI,decrementBefore:qI,defaultBuildStages:xm,defaultShaderStages:f1,defined:Cl,degrees:ZI,deltaTime:Kz,densityFogFactor:r2,depth:vN,depthPass:jV,determinant:u9,difference:m9,diffuseColor:rt,diffuseContribution:Sl,directPointLight:b2,directionToColor:gU,directionToFaceDirection:rU,dispersion:M1,distance:p9,div:js,dot:Gn,dot4I8Packed:Bz,dot4U8Packed:Iz,drawIndex:z9,dynamicBufferAttribute:OO,element:AI,emissive:eM,equal:CI,equirectDirection:fM,equirectUV:_N,exp:LT,exp2:Nd,exponentialHeightFogFactor:QV,expression:ua,faceDirection:nN,faceForward:j1,faceforward:IO,float:S,floatBitsToInt:dz,floatBitsToUint:WF,floor:zs,fog:WM,fract:ja,frameGroup:SO,frameId:XF,frontFacing:tB,fwidth:U1,gain:wz,gapSize:Im,getConstNodeType:xI,getCurrentStack:y1,getDistanceAttenuation:JN,getGeometryRoughness:SF,getNormalFromDepth:bV,getParallaxCorrectNormal:K4,getRoughness:AN,getScreenPosition:pV,getScreenPositionFromClip:mV,getShIrradianceAt:I2,getTextureIndex:jF,getViewPosition:bd,globalId:nj,glsl:$V,glslFn:YV,grayscale:BV,greaterThan:N1,greaterThanEqual:FI,hardwareClipping:TF,hash:yz,highpModelNormalViewMatrix:aM,highpModelViewMatrix:nM,hue:DV,increment:XI,incrementBefore:WI,inspect:K9,instance:iF,instanceColor:bN,instanceIndex:_i,instancedArray:xV,instancedBufferAttribute:WT,instancedDynamicBufferAttribute:X1,instancedMesh:rF,int:k,intBitsToFloat:fz,interleavedGradientNoise:FN,inverse:d9,inverseSqrt:C1,inversesqrt:BO,invocationLocalIndex:zO,invocationSubgroupIndex:LO,ior:_m,iridescence:OT,iridescenceIOR:v0,iridescenceThickness:_0,isolate:Nl,ivec2:Dt,ivec3:w1,ivec4:Sd,js:KV,label:E9,length:ar,lengthSq:z1,lessThan:II,lessThanEqual:BI,lightPosition:WN,lightProjectionUV:o2,lightShadowMatrix:av,lightTargetDirection:XN,lightTargetPosition:c2,lightViewPosition:qN,lightingContext:mF,lights:$j,linearDepth:Bd,linearToneMapping:ON,localId:aj,log:wb,log2:nr,logarithmicDepthToViewZ:LU,luminance:DN,mat2:DT,mat3:Ms,mat4:so,matcapUV:DF,materialAO:eF,materialAlphaTest:SB,materialAnisotropy:jB,materialAnisotropyVector:md,materialAttenuationColor:$B,materialAttenuationDistance:JB,materialClearcoat:DB,materialClearcoatNormal:UB,materialClearcoatRoughness:OB,materialColor:NB,materialDispersion:ZB,materialEmissive:EB,materialEnvIntensity:gm,materialEnvRotation:X0,materialIOR:KB,materialIridescence:GB,materialIridescenceIOR:HB,materialIridescenceThickness:WB,materialLightMap:pN,materialLineDashOffset:fN,materialLineDashSize:uN,materialLineGapSize:dN,materialLineScale:hN,materialLineWidth:Z0,materialMetalness:FB,materialNormal:PB,materialOpacity:lN,materialPointSize:YB,materialReference:Qr,materialReflectivity:u0,materialRefractionRatio:aB,materialRetroreflectivity:QB,materialRotation:LB,materialRoughness:BB,materialSheen:zB,materialSheenRoughness:VB,materialShininess:RB,materialSpecular:CB,materialSpecularColor:IB,materialSpecularIntensity:kB,materialSpecularStrength:Am,materialThickness:XB,materialTransmission:qB,max:Pt,maxMipLevel:Y1,mediumpModelViewMatrix:Q9,metalness:Qo,min:pa,mix:Ke,mixElement:v9,mod:S1,modelDirection:sU,modelNormalMatrix:Y9,modelPosition:nU,modelRadius:$9,modelScale:aU,modelViewMatrix:or,modelViewPosition:iU,modelViewProjection:tF,modelWorldMatrix:da,modelWorldMatrixInverse:Z9,morphReference:pF,mrt:GF,mul:Te,mx_aastep:R2,mx_add:I4,mx_atan2:U4,mx_cell_noise_float:S4,mx_cell_noise_vec3:y4,mx_contrast:f4,mx_divide:P4,mx_fractal_noise_float:R4,mx_fractal_noise_float_2d:N4,mx_fractal_noise_vec2:E4,mx_fractal_noise_vec3:C4,mx_fractal_noise_vec4:k4,mx_frame:z4,mx_heighttonormal:X4,mx_hsvtorgb:n4,mx_ifequal:H4,mx_ifgreater:j4,mx_ifgreatereq:G4,mx_invert:V4,mx_modulo:D4,mx_multiply:F4,mx_noise_float:p4,mx_noise_vec3:m4,mx_noise_vec4:b4,mx_place2d:q4,mx_power:O4,mx_ramp4:c4,mx_ramplr:r4,mx_ramptb:o4,mx_rgbtohsv:a4,mx_rotate2d:Kw,mx_rotate3d:g2,mx_safepower:d4,mx_separate:W4,mx_smoothstep:g4,mx_splitlr:l4,mx_splittb:h4,mx_srgb_texture_to_lin_rec709:i4,mx_subtract:B4,mx_timer:L4,mx_transform_uv:u4,mx_unifiednoise2d:w4,mx_unifiednoise3d:T4,mx_worley_noise_float:v4,mx_worley_noise_float_2d:x4,mx_worley_noise_float_3d:k2,mx_worley_noise_vec2:_4,mx_worley_noise_vec3:A4,mx_worley_noise_vec3_style:M4,negate:F1,negateOnBackSide:Zl,neutralToneMapping:jN,nodeArray:kl,nodeImmutable:ie,nodeObject:pe,nodeObjectIntent:bm,nodeObjects:PT,nodeProxy:He,nodeProxyConstructor:g1,nodeProxyIntent:X,normalFlat:sB,normalGeometry:aN,normalLocal:pn,normalMap:cM,normalView:Qe,normalViewGeometry:Id,normalWorld:gc,normalWorldGeometry:nB,normalize:Vs,not:OI,notEqual:kI,numWorkgroups:tj,objectDirection:$O,objectGroup:NI,objectPosition:ZO,objectRadius:tU,objectScale:QO,objectViewPosition:eU,objectWorldMatrix:YO,oneMinus:o9,or:DI,orthographicDepthToViewZ:bF,oscSawtooth:Zz,oscSine:Jz,oscSquare:$z,oscTriangle:Yz,output:ec,outputStruct:lz,overloadingFn:Ys,overrideNode:zF,overrideNodes:VF,pack4xI8:Fz,pack4xI8Clamp:Dz,pack4xU8:Pz,pack4xU8Clamp:Oz,packHalf2x16:Mz,packNormalToRGB:cN,packSnorm2x16:_z,packSnorm4x8:Sz,packUnorm2x16:Az,packUnorm4x8:Nz,parabola:xz,parallaxDirection:vB,parallaxUV:bU,parameter:rz,pass:zV,passTexture:VV,pcurve:Tz,perspectiveDepthToViewZ:$T,pmremTexture:RN,pointShadow:m2,pointUV:wV,pointWidth:MO,positionGeometry:vs,positionLocal:Ct,positionPrevious:cr,positionView:$t,positionViewDirection:yt,positionWorld:Vn,positionWorldDirection:sN,posterize:UV,pow:zn,pow2:L1,pow3:b9,pow4:VT,premultiplyAlpha:$1,property:za,quadBroadcast:Hj,quadSwapDiagonal:Uj,quadSwapX:Dj,quadSwapY:Oj,radians:YI,rand:T9,range:ej,rangeFogFactor:i2,reciprocal:l9,reference:Et,referenceBuffer:hB,reflect:f9,reflectVector:oB,reflectView:iB,reflector:oV,refract:V1,refractVector:cB,refractView:rB,reinhardToneMapping:UN,remap:J1,remapClamp:H9,renderGroup:ye,renderOutput:Tb,rendererReference:O9,replaceDefaultUV:Qz,retroreflectivity:Bm,rotate:tv,rotateUV:eV,roughness:Oa,round:c9,rtt:QF,sRGBTransferEOTF:F9,sRGBTransferOETF:P9,sample:gV,sampler:qO,samplerComparison:XO,saturate:jT,saturation:FV,screenCoordinate:$l,screenDPR:Q1,screenSize:kd,screenUV:vi,select:$s,setCurrentStack:km,setName:G1,shaderStages:wm,shadow:d2,shadowPositionWorld:KN,shapeCircle:hG,sharedUniformGroup:UT,sheen:Un,sheenRoughness:Jo,shiftLeft:GI,shiftRight:HI,shininess:M0,sign:B1,sin:_s,sinc:vz,sinh:QI,skinning:fF,smoothstep:ma,smoothstepElement:_9,specularColor:wi,specularColorBlended:Jr,specularF90:tr,spherizeUV:tV,split:AO,spritesheetUV:aV,sqrt:fn,stack:m0,step:rr,stepElement:A9,storage:tc,storageBarrier:oj,storageElement:nF,storageTexture:s2,storageTexture3D:vV,struct:cz,sub:ze,subBuild:Pl,subgroupAdd:vj,subgroupAll:Bj,subgroupAnd:Rj,subgroupAny:Fj,subgroupBallot:Tj,subgroupBroadcast:Lj,subgroupBroadcastFirst:Pj,subgroupElect:wj,subgroupExclusiveAdd:Aj,subgroupExclusiveMul:Nj,subgroupInclusiveAdd:_j,subgroupInclusiveMul:Sj,subgroupIndex:UO,subgroupMax:Ij,subgroupMin:kj,subgroupMul:Mj,subgroupOr:Ej,subgroupShuffle:zj,subgroupShuffleDown:Gj,subgroupShuffleUp:jj,subgroupShuffleXor:Vj,subgroupSize:ij,subgroupXor:Cj,tan:t9,tangentGeometry:qT,tangentLocal:rc,tangentView:XT,tangentViewFrame:yB,tangentWorld:wB,tanh:s9,texture:et,texture3D:PN,texture3DLevel:MV,texture3DLoad:AV,textureBarrier:cj,textureBicubic:oL,textureBicubicLevel:NN,textureLevel:WO,textureLoad:Jt,textureSize:ic,textureStore:TV,thickness:v1,time:Zd,toneMapping:U9,toneMappingExposure:L9,toonOutlinePass:GV,transformDirection:g9,transformNormal:iN,transformNormalByInverseViewMatrix:x9,transformNormalByViewMatrix:y9,transformNormalToView:rN,transformedClearcoatNormalView:lU,transformedNormalView:oU,transformedNormalWorld:cU,transmission:S0,transpose:h9,triNoise3D:qz,triplanarTexture:iV,triplanarTextures:KF,trunc:O1,uint:V,uintBitsToFloat:pz,uniform:xe,uniformArray:Us,uniformCubeTexture:hU,uniformFlow:M9,uniformGroup:SI,uniformTexture:HO,unpack4xI8:Uz,unpack4xU8:Lz,unpackHalf2x16:jz,unpackNormal:oM,unpackRGBToNormal:AB,unpackSnorm2x16:zz,unpackSnorm4x8:Gz,unpackUnorm2x16:Vz,unpackUnorm4x8:Hz,unpremultiplyAlpha:q9,userData:SV,uv:ot,uvec2:x1,uvec3:ya,uvec4:Vl,varying:bc,varyingProperty:mc,vec2:Z,vec3:C,vec4:ce,vectorComponents:pc,velocity:NV,vertexColor:vF,vertexIndex:P0,vertexStage:B9,vibrance:PV,viewZToLogarithmicDepth:YT,viewZToOrthographicDepth:Ol,viewZToPerspectiveDepth:JT,viewZToReversedOrthographicDepth:UU,viewZToReversedPerspectiveDepth:gF,viewport:vd,viewportCoordinate:J9,viewportDepthTexture:TN,viewportLinearDepth:zU,viewportMipTexture:xN,viewportOpaqueMipTexture:wN,viewportSafeUV:nV,viewportSharedTexture:LV,viewportSize:eN,viewportTexture:DU,viewportUV:KO,vogelDiskSample:Ti,wgsl:JV,wgslFn:ZV,workgroupArray:lj,workgroupBarrier:rj,workgroupId:sj,workingToColorSpace:D9,xor:UI}),gi=new jd,XM=class extends hr{constructor(e,t){super(),this.renderer=e,this.nodes=t}update(e,t,s){let n=this.renderer,a=this.nodes.getBackgroundNode(e)||e.background,i=!1;if(a===null)n._clearColor.getRGB(gi),gi.a=n._clearColor.a;else if(a.isColor===!0)a.getRGB(gi),gi.a=1,i=!0;else if(a.isNode===!0){let c=this.get(e),l=a;gi.copy(n._clearColor);let h=c.backgroundMesh;if(h===void 0){let T=function(){a.removeEventListener("dispose",T),h.material.dispose(),h.geometry.dispose()},d=ce(l).mul(HM).context({getUV:()=>t2.mul(nB),getTextureLevel:()=>e2}),f=En.element(3).element(3).equal(1),p=js(1,En.element(1).element(1)).mul(3),m=f.select(Ct.mul(p),Ct),b=or.mul(ce(m,0)),g=En.mul(ce(b.xyz,1));g=g.setZ(g.w);let x=new wt;x.name="Background.material",x.side=Xt,x.depthTest=!1,x.depthWrite=!1,x.allowOverride=!1,x.fog=!1,x.lights=!1,x.vertexNode=g,x.colorNode=d,c.backgroundMeshNode=d,c.backgroundMesh=h=new at(new Yc(1,32,32),x),h.frustumCulled=!1,h.name="Background.mesh",a.addEventListener("dispose",T)}let u=l.getCacheKey();c.backgroundCacheKey!==u&&(c.backgroundMeshNode.node=ce(l).mul(HM),c.backgroundMeshNode.needsUpdate=!0,h.material.needsUpdate=!0,c.backgroundCacheKey=u),t.unshift(h,h.geometry,h.material,0,0,null,null)}else W("Renderer: Unsupported background configuration.",a);let o=n.xr.getEnvironmentBlendMode();if(o==="additive"?gi.set(0,0,0,1):o==="alpha-blend"&&gi.set(0,0,0,0),n.autoClear===!0||i===!0){let c=s.clearColorValue;c.r=gi.r,c.g=gi.g,c.b=gi.b,c.a=gi.a,(n.backend.isWebGLBackend===!0||n.alpha===!0)&&(c.r*=c.a,c.g*=c.a,c.b*=c.a),s.depthClearValue=n.getClearDepth(),s.stencilClearValue=n.getClearStencil(),s.clearColor=n.autoClearColor===!0,s.clearDepth=n.autoClearDepth===!0,s.clearStencil=n.autoClearStencil===!0}else s.clearColor=!1,s.clearDepth=!1,s.clearStencil=!1}},J4=0,Qm=class{constructor(e="",t=[]){this.name=e,this.bindings=t,this.id=J4++}},KM=class{constructor(e,t,s,n,a,i,o,c,l,h,u=[]){this.vertexShader=e,this.fragmentShader=t,this.computeShader=s,this.transforms=u,this.nodeAttributes=n,this.bindings=a,this.updateNodes=i,this.updateBeforeNodes=o,this.updateAfterNodes=c,this.observer=l,this.hardwareClipping=h,this.usedTimes=0}createBindings(){let e=[];for(let t of this.bindings)if(t.bindings[0].groupNode.shared!==!0){let n=new Qm(t.name,[]);e.push(n);for(let a of t.bindings)n.bindings.push(a.clone())}else e.push(t);return e}},eb=class{constructor(e,t,s=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=s}},Zw=class{constructor(e,t,s){this.isNodeUniform=!0,this.name=e,this.type=t,this.node=s}get value(){return this.node.value}set value(e){this.node.value=e}get id(){return this.node.id}get groupNode(){return this.node.groupNode}},tb=class{constructor(e,t,s=!1,n=null){this.isNodeVar=!0,this.name=e,this.type=t,this.readOnly=s,this.count=n}},Qw=class extends tb{constructor(e,t,s=null,n=null){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0,this.interpolationType=s,this.interpolationSampling=n}},eT=class{constructor(e,t,s=""){this.name=e,this.type=t,this.code=s,Object.defineProperty(this,"isNodeCode",{value:!0})}},$4=0,Ad=class{constructor(e=null){this.id=$4++,this.nodesData=new WeakMap,this.parent=e}getData(e){let t=this.nodesData.get(e);return t===void 0&&this.parent!==null&&(t=this.parent.getData(e)),t}setData(e,t){this.nodesData.set(e,t)}},JM=class{constructor(e,t){this.name=e,this.members=t,this.output=!1}},dr=class{constructor(e,t){this.name=e,this.value=t,this.boundary=0,this.itemSize=0,this.offset=0,this.index=-1}setValue(e){this.value=e}getValue(){return this.value}},$M=class extends dr{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}},YM=class extends dr{constructor(e,t=new q){super(e,t),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}},ZM=class extends dr{constructor(e,t=new E){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}},QM=class extends dr{constructor(e,t=new Ge){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}},eS=class extends dr{constructor(e,t=new be){super(e,t),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}},tS=class extends dr{constructor(e,t=new mu){super(e,t),this.isMatrix2Uniform=!0,this.boundary=8,this.itemSize=4}},sS=class extends dr{constructor(e,t=new Fs){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}},nS=class extends dr{constructor(e,t=new le){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}},aS=class extends $M{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},iS=class extends YM{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},rS=class extends ZM{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},oS=class extends QM{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},cS=class extends eS{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},lS=class extends tS{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},hS=class extends sS{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},uS=class extends nS{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},Y4=0,Uk=new WeakMap,Lk=new WeakMap,Z4=new WeakMap,Q4=new Map([[Int8Array,"int"],[Int16Array,"int"],[Int32Array,"int"],[Uint8Array,"uint"],[Uint16Array,"uint"],[Uint32Array,"uint"],[Float32Array,"float"]]),Kx=r=>/e/g.test(r)?String(r).replace(/\+/g,""):(r=Number(r),r+(r%1?"":".0")),B2=r=>{if(r.writeUsageCount>0)return!0;if(r.subBuildsCache!==void 0){for(let e in r.subBuildsCache)if(B2(r.subBuildsCache[e]))return!0}return!1},sb=class{constructor(e,t,s){this.object=e,this.material=e&&e.material||null,this.geometry=e&&e.geometry||null,this.compute=null,this.renderer=t,this.parser=s,this.scene=null,this.camera=null,this.nodes=new Set,this.sequentialNodes=new Set,this.updateNodes=[],this.updateBeforeNodes=[],this.updateAfterNodes=[],this.hashNodes={},this.observer=null,this.lightsNode=null,this.environmentNode=null,this.fogNode=null,this.clippingContext=null,this.hardwareClipping=!1,this.vertexShader=null,this.fragmentShader=null,this.computeShader=null,this.flowNodes={vertex:[],fragment:[],compute:[]},this.flowCode={vertex:"",fragment:"",compute:""},this.uniforms={vertex:[],fragment:[],compute:[],index:0},this.structs={vertex:[],fragment:[],compute:[],index:0},this.types={vertex:[],fragment:[],compute:[],index:0},this.bindings={vertex:{},fragment:{},compute:{}},this.bindingsIndexes={},this.bindGroups=null,this.attributes=[],this.bufferAttributes=[],this.varyings=[],this.codes={},this.vars={},this.declarations={},this.flow={code:""},this.chaining=[],this.stack=m0(),this.stacks=[],this.tab="	",this.currentFunctionNode=null,this.context={material:this.material},this.cache=new Ad,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null,this.subBuildLayers=[],this.activeStacks=[],this.subBuildFn=null,this.fnCall=null,Object.defineProperty(this,"id",{value:Y4++})}isFlatShading(){return this.material.flatShading===!0||this.geometry.hasAttribute("normal")===!1}isOpaque(){let e=this.material;return e.transparent===!1&&e.blending===ta&&e.alphaToCoverage===!1}createRenderTarget(e,t,s){return new Ps(e,t,s)}createCubeRenderTarget(e,t){return new jm(e,t)}includes(e){return this.nodes.has(e)}getOutputType(e=0){let t=this.renderer.getRenderTarget();return t!==null?u1(t.textures[e]):"vec4"}getOutputStructName(){}_getBindGroup(e,t){let s=t[0].groupNode,n=s.shared;if(n)for(let i=1;i<t.length;i++)s!==t[i].groupNode&&(n=!1);let a;if(n){let i="";for(let h of t)if(h.isNodeUniformsGroup){h.uniforms.sort((u,d)=>u.nodeUniform.node.id-d.nodeUniform.node.id);for(let u of h.uniforms)i+=u.nodeUniform.node.id}else i+=h.nodeUniform.id;let o=this.renderer._currentRenderContext||this.renderer,c=Uk.get(o);c===void 0&&(c=new Map,Uk.set(o,c));let l=fc(i);a=c.get(l),a===void 0&&(a=new Qm(e,t),c.set(l,a))}else a=new Qm(e,t);return a}getBindGroupArray(e,t){let s=this.bindings[t],n=s[e];return n===void 0&&(this.bindingsIndexes[e]===void 0&&(this.bindingsIndexes[e]={binding:0,group:Object.keys(this.bindingsIndexes).length}),s[e]=n=[]),n}getBindings(){let e=this.bindGroups;if(e===null){let t={},s=this.bindings;for(let n of wm)for(let a in s[n]){let i=s[n][a],o=t[a]||(t[a]=[]);for(let c of i)o.includes(c)===!1&&o.push(c)}e=[];for(let n in t){let a=t[n],i=this._getBindGroup(n,a);e.push(i)}this.bindGroups=e}return e}sortBindingGroups(){let e=this.getBindings();e.sort((t,s)=>t.bindings[0].groupNode.order-s.bindings[0].groupNode.order);for(let t=0;t<e.length;t++){let s=e[t];this.bindingsIndexes[s.name].group=t}}setHashNode(e,t){this.hashNodes[t]=e}addNode(e){this.nodes.has(e)===!1&&(this.nodes.add(e),this.setHashNode(e,e.getHash(this)))}addSequentialNode(e){let t=e.updateBeforeType,s=e.updateAfterType;(t!==Me.NONE||s!==Me.NONE)&&this.sequentialNodes.add(e)}buildUpdateNodes(){for(let e of this.nodes)e.updateType!==Me.NONE&&this.updateNodes.push(e);for(let e of this.sequentialNodes){let t=e.updateBeforeType,s=e.updateAfterType;t!==Me.NONE&&this.updateBeforeNodes.push(e),s!==Me.NONE&&this.updateAfterNodes.push(e)}}get currentNode(){return this.chaining[this.chaining.length-1]}get renderPipeline(){return this.context.renderPipeline}isFilteredTexture(e){return e.magFilter===Ye||e.magFilter===Fo||e.magFilter===fi||e.magFilter===on||e.minFilter===Ye||e.minFilter===Fo||e.minFilter===fi||e.minFilter===on}getUniformBufferLimit(){return this.renderer.backend.capabilities.getUniformBufferLimit()}addChain(e){this.chaining.push(e)}removeChain(e){if(this.chaining.pop()!==e)throw new Error("THREE.NodeBuilder: Invalid node chaining!")}getMethod(e){return e}getTernary(){return null}getNodeFromHash(e){return this.hashNodes[e]}addFlow(e,t){return this.flowNodes[e].push(t),t}setContext(e){this.context=e}getContext(){return this.context}addContext(e){let t=this.getContext();return this.setContext({...this.context,...e}),t}getSharedContext(){let e={...this.context};return delete e.material,delete e.getUV,delete e.getOutput,delete e.getTextureLevel,delete e.getAO,delete e.getGI,delete e.getShadow,delete e.nodeLoop,delete e.nodeBlock,e}setCache(e){this.cache=e}getCache(){return this.cache}getCacheFromNode(e,t=!0){let s=this.getDataFromNode(e);return s.cache===void 0&&(s.cache=new Ad(t?this.getCache():null)),s.cache}isAvailable(){return!1}getVertexIndex(){K("Abstract function.")}getInstanceIndex(){K("Abstract function.")}getDrawIndex(){K("Abstract function.")}getFrontFacing(){K("Abstract function.")}getFragCoord(){K("Abstract function.")}isFlipY(){return!1}isContextAssign(){return this.context.assign===!0}increaseUsage(e){let t=this.getDataFromNode(e);return t.usageCount=t.usageCount===void 0?1:t.usageCount+1,this.isContextAssign()?t.writeUsageCount=t.writeUsageCount===void 0?1:t.writeUsageCount+1:t.readUsageCount=t.readUsageCount===void 0?1:t.readUsageCount+1,t.usageCount}hasWriteUsage(e){let t=e.getShared(this),n=(t.isGlobal(this)?this.globalCache:this.cache).getData(t);if(n!==void 0){for(let a in n)if(B2(n[a]))return!0}return!1}generateTexture(){K("Abstract function.")}generateTextureLod(){K("Abstract function.")}generateTextureSize(){K("Abstract function.")}generateArrayDeclaration(e,t){return this.getType(e)+"[ "+t+" ]"}generateArray(e,t,s=null){let n=this.generateArrayDeclaration(e,t)+"( ";for(let a=0;a<t;a++){let i=s?s[a]:null;i!==null?n+=i.build(this,e):n+=this.generateConst(e),a<t-1&&(n+=", ")}return n+=" )",n}generateStruct(e,t,s=null){let n=[];for(let a of t){let{name:i,type:o}=a;s&&s[i]&&s[i].isNode?n.push(s[i].build(this,o)):n.push(this.generateConst(o))}return e+"( "+n.join(", ")+" )"}generateConst(e,t=null){if(t===null&&(e==="float"||e==="int"||e==="uint"?t=0:e==="bool"?t=!1:e==="color"?t=new be:e==="vec2"||e==="uvec2"||e==="ivec2"?t=new q:e==="vec3"||e==="uvec3"||e==="ivec3"?t=new E:(e==="vec4"||e==="uvec4"||e==="ivec4")&&(t=new Ge)),e==="float")return Kx(t);if(e==="int")return`${Math.round(t)}`;if(e==="uint")return t>=0?`${Math.round(t)}u`:"0u";if(e==="bool")return t?"true":"false";if(e==="color")return`${this.getType("vec3")}( ${Kx(t.r)}, ${Kx(t.g)}, ${Kx(t.b)} )`;let s=this.getTypeLength(e),n=this.getComponentType(e),a=i=>this.generateConst(n,i);if(s===2)return`${this.getType(e)}( ${a(t.x)}, ${a(t.y)} )`;if(s===3)return`${this.getType(e)}( ${a(t.x)}, ${a(t.y)}, ${a(t.z)} )`;if(s===4&&e!=="mat2")return`${this.getType(e)}( ${a(t.x)}, ${a(t.y)}, ${a(t.z)}, ${a(t.w)} )`;if(s>=4&&t&&(t.isMatrix2||t.isMatrix3||t.isMatrix4))return`${this.getType(e)}( ${t.elements.map(a).join(", ")} )`;if(s>4)return`${this.getType(e)}()`;throw new Error(`THREE.NodeBuilder: Type '${e}' not found in generate constant attempt.`)}getType(e){return e==="color"?"vec3":e}hasGeometryAttribute(e){return this.geometry&&this.geometry.getAttribute(e)!==void 0}getAttribute(e,t){let s=this.attributes;for(let a of s)if(a.name===e)return a;let n=new eb(e,t);return this.registerDeclaration(n),s.push(n),n}getPropertyName(e){return e.name}isReservedKeyword(){return!1}isVector(e){return/vec\d/.test(e)}isMatrix(e){return/mat\d/.test(e)}isReference(e){return e==="void"||e==="property"||e==="sampler"||e==="samplerComparison"||e==="texture"||e==="cubeTexture"||e==="storageTexture"||e==="depthTexture"||e==="texture3D"}needsToWorkingColorSpace(){return!1}getComponentTypeFromTexture(e){let t=e.type;return e.isDepthTexture===!0?"float":t===Ts?"int":t===St?"uint":"float"}getElementType(e){return e==="mat2"?"vec2":e==="mat3"?"vec3":e==="mat4"?"vec4":this.getComponentType(e)}getComponentType(e){if(e=this.getVectorType(e),e==="float"||e==="bool"||e==="int"||e==="uint")return e;let t=/(b|i|u|)(vec|mat)([2-4])/.exec(e);return t===null?null:t[1]==="b"?"bool":t[1]==="i"?"int":t[1]==="u"?"uint":"float"}getVectorType(e){return e==="color"?"vec3":e==="texture"||e==="cubeTexture"||e==="storageTexture"||e==="texture3D"?"vec4":e}getTypeFromLength(e,t="float"){if(e===1)return t;let s=CT(e),n=t==="float"?"":t[0];return/mat2/.test(t)===!0&&(s=s.replace("vec","mat")),n+s}getTypeFromArray(e){return Q4.get(e.constructor)}isInteger(e){return/int|uint|(i|u)vec/.test(e)}getTypeFromAttribute(e){let t=e;e.isInterleavedBufferAttribute&&(t=e.data);let s=t.array,n=e.itemSize,a=e.normalized,i;return!(e instanceof Kh)&&a!==!0&&(i=this.getTypeFromArray(s)),this.getTypeFromLength(n,i)}getTypeLength(e){let t=this.getVectorType(e),s=/vec([2-4])/.exec(t);return s!==null?Number(s[1]):t==="float"||t==="bool"||t==="int"||t==="uint"?1:/mat2/.test(e)===!0?4:/mat3/.test(e)===!0?9:/mat4/.test(e)===!0?16:0}getVectorFromMatrix(e){return e.replace("mat","vec")}changeComponentType(e,t){return this.getTypeFromLength(this.getTypeLength(e),t)}getIntegerType(e){let t=this.getComponentType(e);return t==="int"||t==="uint"?e:this.changeComponentType(e,"int")}setActiveStack(e){this.activeStacks.push(e)}removeActiveStack(e){if(this.activeStacks[this.activeStacks.length-1]===e)this.activeStacks.pop();else throw new Error("THREE.NodeBuilder: Invalid active stack removal.")}getActiveStack(){return this.activeStacks[this.activeStacks.length-1]}getBaseStack(){return this.activeStacks[0]}addStack(){this.stack=m0(this.stack);let e=y1();return this.stacks.push(e),km(this.stack),this.stack}removeStack(){let e=this.stack;for(let t of e.nodes){let s=this.getDataFromNode(t);s.stack=e}return this.stack=e.parent,km(this.stacks.pop()),e}getDataFromNode(e,t=this.shaderStage,s=null){s=s===null?e.isGlobal(this)?this.globalCache:this.cache:s;let n=s.getData(e);n===void 0&&(n={},s.setData(e,n)),n[t]===void 0&&(n[t]={});let a=n[t];if(this.subBuildLayers.length===0)return a;let i=n.any?n.any.subBuilds:null,o=this.getClosestSubBuild(i);return o&&(a.subBuildsCache===void 0&&(a.subBuildsCache={}),a=a.subBuildsCache[o]||(a.subBuildsCache[o]={}),a.subBuilds=i),a}getNodeProperties(e,t="any"){let s=this.getDataFromNode(e,t);return s.properties||(s.properties={outputNode:null})}getBufferAttributeFromNode(e,t,s=null){let n=this.getDataFromNode(e,"vertex"),a=n.bufferAttribute;if(a===void 0){let i=this.uniforms.index++;s===null&&(s="nodeAttribute"+i),a=new eb(s,t,e),this.bufferAttributes.push(a),n.bufferAttribute=a}return a}getStructTypeNode(e,t=this.shaderStage){return this.types[t][e]||null}getStructTypeFromNode(e,t,s=null,n=this.shaderStage){let a=this.getDataFromNode(e,n,this.globalCache),i=a.structType;if(i===void 0){let o=this.structs.index++;s===null&&(s="StructType"+o),i=new JM(s,t),this.structs[n].push(i),this.types[n][s]=e,a.structType=i}return i}getOutputStructTypeFromNode(e,t){let s=this.getStructTypeFromNode(e,t,"OutputType","fragment");return s.output=!0,s}getUniformFromNode(e,t,s=this.shaderStage,n=null){let a=this.getDataFromNode(e,s,this.globalCache),i=a.uniform;if(i===void 0){let o=this.uniforms.index++;i=new Zw(n||"nodeUniform"+o,t,e),this.uniforms[s].push(i),this.registerDeclaration(i),a.uniform=i}return i}getVarFromNode(e,t=null,s=e.getNodeType(this),n=this.shaderStage,a=!1){let i=this.getDataFromNode(e,n),o=this.getSubBuildProperty("variable",i.subBuilds),c=i[o];if(c===void 0){let l=a?"_const":"_var",h=this.vars[n]||(this.vars[n]=[]),u=this.vars[l]||(this.vars[l]=0);t===null&&(t=(a?"nodeConst":"nodeVar")+u,this.vars[l]++),o!=="variable"&&(t=this.getSubBuildProperty(t,i.subBuilds));let d=e.getArrayCount(this);c=new tb(t,s,a,d),a||h.push(c),this.registerDeclaration(c),i[o]=c}return c}isDeterministic(e){if(e.isMathNode)return this.isDeterministic(e.aNode)&&(e.bNode?this.isDeterministic(e.bNode):!0)&&(e.cNode?this.isDeterministic(e.cNode):!0);if(e.isOperatorNode)return this.isDeterministic(e.aNode)&&(e.bNode?this.isDeterministic(e.bNode):!0);if(e.isArrayNode){if(e.values!==null){for(let t of e.values)if(!this.isDeterministic(t))return!1}return!0}else if(e.isConstNode)return!0;return!1}getVaryingFromNode(e,t=null,s=e.getNodeType(this),n=null,a=null){let i=this.getDataFromNode(e,"any"),o=this.getSubBuildProperty("varying",i.subBuilds),c=i[o];if(c===void 0){let l=this.varyings,h=l.length;t===null&&(t="nodeVarying"+h),o!=="varying"&&(t=this.getSubBuildProperty(t,i.subBuilds)),c=new Qw(t,s,n,a),l.push(c),this.registerDeclaration(c),i[o]=c}return c}registerDeclaration(e){let t=this.shaderStage,s=this.declarations[t]||(this.declarations[t]={}),n=this.renderer.debug.diagnostics.keywords,a=e.name,i=a,o=this.getPropertyName(e),c=1;for(;n&&this.isReservedKeyword(i)||s[o]!==void 0;)i=a+"_"+c++,e.name=i,o=this.getPropertyName(e);i!==a&&K(`TSL: Declaration name '${a}' of '${e.type}' is a reserved keyword or already in use. Renamed to '${i}'.`),s[o]=e}getCodeFromNode(e,t,s=this.shaderStage){let n=this.getDataFromNode(e),a=n.code;if(a===void 0){let i=this.codes[s]||(this.codes[s]=[]),o=i.length;a=new eT("nodeCode"+o,t),i.push(a),n.code=a}return a}addFlowCodeHierarchy(e,t){let{flowCodes:s,flowCodeBlock:n}=this.getDataFromNode(e),a=!0,i=t;for(;i;){if(n.get(i)===!0){a=!1;break}i=this.getDataFromNode(i).parentNodeBlock}if(a)for(let o of s)this.addLineFlowCode(o)}addLineFlowCodeBlock(e,t,s){let n=this.getDataFromNode(e),a=n.flowCodes||(n.flowCodes=[]),i=n.flowCodeBlock||(n.flowCodeBlock=new WeakMap);a.push(t),i.set(s,!0)}addLineFlowCode(e,t=null){return e===""?this:(t!==null&&this.context.nodeBlock&&this.addLineFlowCodeBlock(t,e,this.context.nodeBlock),e=this.tab+e,/;\s*$/.test(e)||(e=e+`;
`),this.flow.code+=e,this)}addFlowCode(e){return this.flow.code+=e,this}addFlowTab(){return this.tab+="	",this}removeFlowTab(){return this.tab=this.tab.slice(0,-1),this}getFlowData(e){return this.flowsData.get(e)}flowNode(e){let t=e.getNodeType(this),s=this.flowChildNode(e,t);return this.flowsData.set(e,s),s}addInclude(e){this.currentFunctionNode!==null&&this.currentFunctionNode.includes.push(e)}buildFunctionNode(e){let t=this.renderer.backend,s=Lk.get(t);s===void 0&&(s=new WeakMap,Lk.set(t,s));let n=s.get(e);if(n===void 0){n=new $m;let a=this.currentFunctionNode;this.currentFunctionNode=n,n.code=this.buildFunctionCode(e),this.currentFunctionNode=a,s.set(e,n)}return n}flowShaderNode(e){let t=e.layout,s={[Symbol.iterator](){let i=0,o=Object.values(this);return{next:()=>({value:o[i],done:i++>=o.length})}}};for(let i of t.inputs)s[i.name]=new qm(i.type,i.name);e.layout=null;let n=e.call(s),a=this.flowStagesNode(n,t.type);return e.layout=t,a}flowBuildStage(e,t,s=null){let n=this.getBuildStage();this.setBuildStage(t);let a=e.build(this,s);return this.setBuildStage(n),a}flowStagesNode(e,t=null){let s=this.flow,n=this.vars,a=this.declarations,i=this.cache,o=this.buildStage,c=this.stack,l={code:""};this.flow=l,this.vars={},this.declarations={},this.cache=new Ad,this.stack=m0();for(let h of xm)this.setBuildStage(h),l.result=e.build(this,t);return l.vars=this.getVars(this.shaderStage),this.flow=s,this.vars=n,this.declarations=a,this.cache=i,this.stack=c,this.setBuildStage(o),l}getFunctionOperator(){return null}buildFunctionCode(){K("Abstract function.")}flowChildNode(e,t=null){let s=this.flow,n={code:""};return this.flow=n,n.result=e.build(this,t),this.flow=s,n}flowNodeFromShaderStage(e,t,s=null,n=null){let a=this.tab,i=this.cache,o=this.shaderStage,c=this.context;this.setShaderStage(e);let l={...this.context};delete l.nodeBlock,this.cache=this.globalCache,this.tab="	",this.context=l;let h=null;if(this.buildStage==="generate"){let u=this.flowChildNode(t,s);n!==null&&(u.code+=`${this.tab+n} = ${u.result};
`),this.flowCode[e]=this.flowCode[e]+u.code,h=u}else h=t.build(this);return this.setShaderStage(o),this.cache=i,this.tab=a,this.context=c,h}getAttributesArray(){return this.attributes.concat(this.bufferAttributes)}getAttributes(){K("Abstract function.")}getVaryings(){K("Abstract function.")}getVar(e,t,s=null){return`${s!==null?this.generateArrayDeclaration(e,s):this.getType(e)} ${t}`}getVars(e,t=!1){let s=[],n=this.vars[e];if(n!==void 0)for(let a of n)s.push(`${this.getVar(a.type,a.name,a.count)};`);return s.join(t?`
`:`
	`)}getUniforms(){K("Abstract function.")}getCodes(e){let t=this.codes[e],s="";if(t!==void 0)for(let n of t)s+=n.code+`
`;return s}getHash(){return this.vertexShader+this.fragmentShader+this.computeShader}setShaderStage(e){this.shaderStage=e}getShaderStage(){return this.shaderStage}setBuildStage(e){this.buildStage=e}getBuildStage(){return this.buildStage}buildCode(){K("Abstract function.")}get subBuild(){return this.subBuildLayers[this.subBuildLayers.length-1]||null}addSubBuild(e){this.subBuildLayers.push(e)}removeSubBuild(){return this.subBuildLayers.pop()}getClosestSubBuild(e){let t;if(e&&e.isNode?e.isShaderCallNodeInternal?t=e.shaderNode.subBuilds:e.isStackNode?t=[e.subBuild]:t=this.getDataFromNode(e,"any").subBuilds:e instanceof Set?t=[...e]:t=e,!t)return null;let s=this.subBuildLayers;for(let n=t.length-1;n>=0;n--){let a=t[n];if(s.includes(a))return a}return null}getSubBuildOutput(e){return this.getSubBuildProperty("outputNode",e)}getSubBuildProperty(e="",t=null){let s;t!==null?s=this.getClosestSubBuild(t):s=this.subBuildFn;let n;return s?n=e?s+"_"+e:s:n=e,n}prebuild(){let{renderer:e,material:t}=this;if(e.contextNode.isContextNode===!0?this.context={...this.context,...e.contextNode.getFlowContextData()}:W('NodeBuilder: "renderer.contextNode" must be an instance of `context()`.'),t&&t.contextNode&&(t.contextNode.isContextNode===!0?this.context={...this.context,...t.contextNode.getFlowContextData()}:W('NodeBuilder: "material.contextNode" must be an instance of `context()`.')),t!==null){let s=e.library.fromMaterial(t);s===null&&(W(`NodeBuilder: Material "${t.type}" is not compatible.`),s=new wt),s.build(this)}else this.addFlow("compute",this.compute)}build(){this.prebuild();for(let e of xm){this.setBuildStage(e),this.context.position&&this.context.position.isNode&&this.flowNodeFromShaderStage("vertex",this.context.position);for(let t of wm){this.setShaderStage(t);let s=this.flowNodes[t];for(let n of s)e==="generate"?this.flowNode(n):n.build(this)}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}async buildAsync(){this.prebuild();for(let e of xm){this.setBuildStage(e),this.context.position&&this.context.position.isNode&&this.flowNodeFromShaderStage("vertex",this.context.position);for(let t of wm){this.setShaderStage(t);let s=this.flowNodes[t];for(let n of s)e==="generate"?this.flowNode(n):n.build(this);await _x()}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}getSharedDataFromNode(e){let t=Z4.get(e);return t===void 0&&(t={}),t}getNodeUniform(e,t){let s=this.getSharedDataFromNode(e),n=s.cache;if(n===void 0){if(t==="float"||t==="int"||t==="uint")n=new aS(e);else if(t==="vec2"||t==="ivec2"||t==="uvec2")n=new iS(e);else if(t==="vec3"||t==="ivec3"||t==="uvec3")n=new rS(e);else if(t==="vec4"||t==="ivec4"||t==="uvec4")n=new oS(e);else if(t==="color")n=new cS(e);else if(t==="mat2")n=new lS(e);else if(t==="mat3")n=new hS(e);else if(t==="mat4")n=new uS(e);else throw new Error(`THREE.NodeBuilder: Uniform "${t}" not implemented.`);s.cache=n}return n}format(e,t,s){if(t=this.getVectorType(t),s=this.getVectorType(s),t===s||s===null||this.isReference(s))return e;let n=this.getTypeLength(t),a=this.getTypeLength(s);return n===16&&a===9?`${this.getType(s)}( ${e}[ 0 ].xyz, ${e}[ 1 ].xyz, ${e}[ 2 ].xyz )`:n===9&&a===4?`${this.getType(s)}( ${e}[ 0 ].xy, ${e}[ 1 ].xy )`:n>4||a>4||a===0?e:n===a?`${this.getType(s)}( ${e} )`:n>a?(e=s==="bool"?`all( ${e} )`:`${e}.${"xyz".slice(0,a)}`,this.format(e,this.getTypeFromLength(a,this.getComponentType(t)),s)):a===4&&n>1?`${this.getType(s)}( ${this.format(e,t,"vec3")}, 1.0 )`:n===2?`${this.getType(s)}( ${this.format(e,t,"vec2")}, 0.0 )`:(n===1&&a>1&&t!==this.getComponentType(s)&&(e=`${this.getType(this.getComponentType(s))}( ${e} )`),`${this.getType(s)}( ${e} )`)}getSignature(){return`// Three.js r${"186"} - Node System
`}needsPreviousData(){let e=this.renderer.getMRT();return e&&e.has("velocity")||this.object!==null&&d1(this.object).useVelocity===!0}},nb=class{constructor(){this.time=0,this.deltaTime=0,this.frameId=0,this.renderId=0,this.updateMap=new WeakMap,this.updateBeforeMap=new WeakMap,this.updateAfterMap=new WeakMap,this.renderer=null,this.material=null,this.camera=null,this.object=null,this.scene=null,this.compute=null}_getMaps(e,t){let s=e.get(t);return s===void 0&&(s={renderId:0,frameId:0},e.set(t,s)),s}updateBeforeNode(e){let t=e.getUpdateBeforeType(this),s=e.updateReference(this);if(t===Me.FRAME){let n=this._getMaps(this.updateBeforeMap,s);if(n.frameId!==this.frameId){let a=n.frameId;n.frameId=this.frameId,e.updateBefore(this)===!1&&(n.frameId=a)}}else if(t===Me.RENDER){let n=this._getMaps(this.updateBeforeMap,s);if(n.renderId!==this.renderId){let a=n.renderId;n.renderId=this.renderId,e.updateBefore(this)===!1&&(n.renderId=a)}}else t===Me.OBJECT&&e.updateBefore(this)}updateAfterNode(e){let t=e.getUpdateAfterType(this),s=e.updateReference(this);if(t===Me.FRAME){let n=this._getMaps(this.updateAfterMap,s);n.frameId!==this.frameId&&e.updateAfter(this)!==!1&&(n.frameId=this.frameId)}else if(t===Me.RENDER){let n=this._getMaps(this.updateAfterMap,s);n.renderId!==this.renderId&&e.updateAfter(this)!==!1&&(n.renderId=this.renderId)}else t===Me.OBJECT&&e.updateAfter(this)}updateNode(e){let t=e.getUpdateType(this),s=e.updateReference(this);if(t===Me.FRAME){let n=this._getMaps(this.updateMap,s);n.frameId!==this.frameId&&e.update(this)!==!1&&(n.frameId=this.frameId)}else if(t===Me.RENDER){let n=this._getMaps(this.updateMap,s);n.renderId!==this.renderId&&e.update(this)!==!1&&(n.renderId=this.renderId)}else t===Me.OBJECT&&e.update(this)}update(){this.frameId++,this.lastTime===void 0&&(this.lastTime=performance.now()),this.deltaTime=(performance.now()-this.lastTime)/1e3,this.lastTime=performance.now(),this.time+=this.deltaTime}},Wd=class{constructor(e,t,s=null,n="",a=!1){this.type=e,this.name=t,this.count=s,this.qualifier=n,this.isConst=a}};Wd.isNodeFunctionInput=!0;var ab=class extends ur{static get type(){return"AmbientLightNode"}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}},ib=class extends ur{static get type(){return"DirectionalLightNode"}constructor(e=null){super(e)}setupDirect(){let e=this.colorNode;return{lightDirection:XN(this.light),lightColor:e}}},rb=class extends ur{static get type(){return"HemisphereLightNode"}constructor(e=null){super(e),this.lightPositionNode=WN(e),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=xe(new be).setGroup(ye)}update(e){let{light:t}=this;super.update(e),this.lightPositionNode.object3d=t,this.groundColorNode.value.copy(t.groundColor).multiplyScalar(t.intensity)}setup(e){let{colorNode:t,groundColorNode:s,lightDirectionNode:n}=this,i=gc.dot(n).mul(.5).add(.5),o=Ke(s,t,i);e.context.irradiance.addAssign(o)}},Kl=class extends ur{static get type(){return"SpotLightNode"}constructor(e=null){super(e),this.coneCosNode=xe(0).setGroup(ye),this.penumbraCosNode=xe(0).setGroup(ye),this.cutoffDistanceNode=xe(0).setGroup(ye),this.decayExponentNode=xe(0).setGroup(ye),this.colorNode=xe(this.color).setGroup(ye)}update(e){super.update(e);let{light:t}=this;this.coneCosNode.value=Math.cos(t.angle),this.penumbraCosNode.value=Math.cos(t.angle*(1-t.penumbra)),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}getSpotAttenuation(e,t){let{coneCosNode:s,penumbraCosNode:n}=this;return ma(s,n,t)}getLightCoord(e){let t=e.getNodeProperties(this),s=t.projectionUV;return s===void 0&&(s=o2(this.light,e.context.positionWorld),t.projectionUV=s),s}setupDirect(e){let{colorNode:t,cutoffDistanceNode:s,decayExponentNode:n,light:a}=this,i=this.getLightVector(e),o=i.normalize(),c=o.dot(XN(a)),l=this.getSpotAttenuation(e,c),h=i.length(),u=JN({lightDistance:h,cutoffDistance:s,decayExponent:n}),d=t.mul(l).mul(u),f,p;return a.colorNode?(p=this.getLightCoord(e),f=a.colorNode(p)):a.map&&(p=this.getLightCoord(e),f=et(a.map,p.xy).onRenderUpdate(()=>a.map)),f&&(d=p.mul(2).sub(1).abs().lessThan(1).all().select(d.mul(f),d)),{lightColor:d,lightDirection:o}}},ob=class extends Kl{static get type(){return"IESSpotLightNode"}constructor(e=null){super(e),this._iesTextureNode=null}getSpotAttenuation(e,t){let s=this.light.iesMap,n=null;if(s&&s.isTexture===!0){let a=t.acos().mul(1/Math.PI);this._iesTextureNode=et(s,Z(a,0),0),n=this._iesTextureNode.r}else n=super.getSpotAttenuation(e,t);return n}update(e){super.update(e),this._iesTextureNode!==null&&this.light.iesMap&&(this._iesTextureNode.value=this.light.iesMap)}},cb=class extends ur{static get type(){return"LightProbeNode"}constructor(e=null){super(e);let t=[];for(let s=0;s<9;s++)t.push(new E);this.lightProbe=Us(t)}update(e){let{light:t}=this;super.update(e);for(let s=0;s<9;s++)this.lightProbe.array[s].copy(t.sh.coefficients[s]).multiplyScalar(t.intensity)}setup(e){let t=I2(gc,this.lightProbe);e.context.irradiance.addAssign(t)}},eH=F(([r,e])=>{let t=r.abs().sub(e);return ar(Pt(t,0)).add(pa(Pt(t.x,t.y),0))}),lb=class extends Kl{static get type(){return"ProjectorLightNode"}update(e){super.update(e);let t=this.light;if(this.penumbraCosNode.value=Math.min(Math.cos(t.angle*(1-t.penumbra)),.99999),t.aspect===null){let s=1;t.map!==null&&(s=t.map.width/t.map.height),t.shadow.aspect=s}else t.shadow.aspect=t.aspect}getSpotAttenuation(e){let t=S(0),s=this.penumbraCosNode,n=av(this.light).mul(e.context.positionWorld||Vn);return fe(n.w.greaterThan(0),()=>{let a=n.xyz.div(n.w),i=eH(a.xy.sub(Z(.5)),Z(.5)),o=js(-1,ze(1,k1(s)).sub(1));t.assign(jT(i.mul(-2).mul(o)))}),t}},DA=new le,Jx=new le,om=null,hb=class extends ur{static get type(){return"RectAreaLightNode"}constructor(e=null){super(e),this.halfHeight=xe(new E).setGroup(ye),this.halfWidth=xe(new E).setGroup(ye),this.updateType=Me.RENDER}update(e){super.update(e);let{light:t}=this,s=e.camera.matrixWorldInverse;Jx.identity(),DA.copy(t.matrixWorld),DA.premultiply(s),Jx.extractRotation(DA),this.halfWidth.value.set(t.width*.5,0,0),this.halfHeight.value.set(0,t.height*.5,0),this.halfWidth.value.applyMatrix4(Jx),this.halfHeight.value.applyMatrix4(Jx)}setupDirectRectArea(e){let t,s;e.isAvailable("float32Filterable")?(t=et(om.LTC_FLOAT_1),s=et(om.LTC_FLOAT_2)):(t=et(om.LTC_HALF_1),s=et(om.LTC_HALF_2));let{colorNode:n,light:a}=this,i=qN(a);return{lightColor:n,lightPosition:i,halfWidth:this.halfWidth,halfHeight:this.halfHeight,ltc_1:t,ltc_2:s}}static setLTC(e){om=e}},tT=class{parseFunction(){K("Abstract function.")}},ub=class{constructor(e,t,s="",n=""){this.type=e,this.inputs=t,this.name=s,this.precision=n}getCode(){K("Abstract function.")}};ub.isNodeFunction=!0;var tH=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,sH=/[a-z_0-9]+/ig,zk="#pragma main",nH=r=>{r=r.trim();let e=r.indexOf(zk),t=(e!==-1?r.slice(e+zk.length):r).replace(/^(?:\s*\/\/[^\r\n]*|\s*\/\*[\s\S]*?\*\/|\s*)+/,""),s=t.match(tH);if(s!==null&&s.length===5){let n=s[4],a=[],i=null;for(;(i=sH.exec(n))!==null;)a.push(i);let o=[],c=0;for(;c<a.length;){let p=a[c][0]==="const";p===!0&&c++;let m=a[c][0];m==="in"||m==="out"||m==="inout"?c++:m="";let b=a[c++][0],g=Number.parseInt(a[c][0]);Number.isNaN(g)===!1?c++:g=null;let x=a[c++][0];o.push(new Wd(b,x,g,m,p))}let l=t.substring(s[0].length),h=s[3]!==void 0?s[3]:"",u=s[2],d=s[1]!==void 0?s[1]:"",f=e!==-1?r.slice(0,e):"";return{type:u,inputs:o,name:h,precision:d,inputsCode:n,blockCode:l,headerCode:f}}else throw new Error("THREE.FunctionNode: Function is not a GLSL code.")},dS=class extends ub{constructor(e){let{type:t,inputs:s,name:n,precision:a,inputsCode:i,blockCode:o,headerCode:c}=nH(e);super(t,s,n,a),this.inputsCode=i,this.blockCode=o,this.headerCode=c}getCode(e=this.name){let t,s=this.blockCode;if(s!==""){let{type:n,inputsCode:a,headerCode:i,precision:o}=this,c=`${n} ${e} ( ${a.trim()} )`;o!==""&&(c=`${o} ${c}`),t=i+c+s}else t="";return t}},sT=class extends tT{parseFunction(e){return new dS(e)}},Ba=[],Wr=[],Vk=xe(0,"int").setGroup(ye),fS=class extends hr{constructor(e,t){super(),this.renderer=e,this.backend=t,this.nodeFrame=new nb,this.nodeBuilderCache=new Map,this.callHashCache=new lr,this.groupsData=new lr,this._buildQueue=[],this._buildInProgress=!1,this.cacheLib={}}updateGroup(e){let t=e.groupNode;if(t.updateType===Me.OBJECT)return!0;Ba[0]=t,Ba[1]=e;let s=this.groupsData.get(Ba);return s===void 0&&this.groupsData.set(Ba,s={}),Ba[0]=null,Ba[1]=null,s.version!==t.version?(s.version=t.version,!0):!1}getForRenderCacheKey(e){return e.initialCacheKey}_createNodeBuilder(e,t){let s=this.backend.createNodeBuilder(e.object,this.renderer),n=this.renderer.debug.onNodeBuilderCreated;return n!==null&&n(s,e),s.scene=e.scene,s.material=t,s.camera=e.camera,s.context.material=t,s.lightsNode=e.lightsNode,s.environmentNode=this.getEnvironmentNode(e.scene),s.fogNode=this.getFogNode(e.scene),s.clippingContext=e.clippingContext,this.renderer.getOutputRenderTarget()&&this.renderer.getOutputRenderTarget().multiview&&s.enableMultiview(),s}getForRender(e,t=!1){let s=this.get(e),n=s.nodeBuilderState;if(n===void 0){let{nodeBuilderCache:a}=this,i=this.getForRenderCacheKey(e);if(n=a.get(i),n===void 0){let o=async()=>{let c=this._createNodeBuilder(e,e.material);try{t?await c.buildAsync():c.build()}catch(l){c=this._createNodeBuilder(e,new wt),t?await c.buildAsync():c.build(),W("TSL: "+l)}return c};if(t)return o().then(c=>(n=this._createNodeBuilderState(c),a.set(i,n),n.usedTimes++,s.nodeBuilderState=n,n));{let c=this._createNodeBuilder(e,e.material);try{c.build()}catch(l){c=this._createNodeBuilder(e,new wt),c.build();let h=l.stackTrace;!h&&l.stack&&(h=new is(l.stack)),W("TSL: "+l,h)}n=this._createNodeBuilderState(c),a.set(i,n)}}n.usedTimes++,s.nodeBuilderState=n}return n}getForRenderAsync(e){let t=this.getForRender(e,!0);return t.then?t:Promise.resolve(t)}getForRenderDeferred(e){let t=this.get(e);if(t.nodeBuilderState!==void 0)return t.nodeBuilderState;let s=this.getForRenderCacheKey(e),n=this.nodeBuilderCache.get(s);return n!==void 0?(n.usedTimes++,t.nodeBuilderState=n,n):(t.pendingBuild!==!0&&(t.pendingBuild=!0,this._buildQueue.push(()=>this.getForRenderAsync(e).then(()=>{t.pendingBuild=!1})),this._processBuildQueue()),null)}_processBuildQueue(){if(this._buildInProgress||this._buildQueue.length===0)return;this._buildInProgress=!0,this._buildQueue.shift()().then(()=>{this._buildInProgress=!1,this._processBuildQueue()})}delete(e){if(e.isRenderObject){let t=this.get(e).nodeBuilderState;t!==void 0&&(t.usedTimes--,t.usedTimes===0&&this.nodeBuilderCache.delete(this.getForRenderCacheKey(e)))}return super.delete(e)}getForCompute(e,t=!1){let s=this.get(e),n=s.nodeBuilderState;if(n===void 0||s.version!==e.version){let a=this.backend.createNodeBuilder(null,this.renderer);a.compute=e;let i=this.renderer.debug.onNodeBuilderCreated;if(i!==null&&i(a,e),t)return a.buildAsync().then(()=>(n=this._createNodeBuilderState(a),s.nodeBuilderState=n,s.version=e.version,n));a.build(),n=this._createNodeBuilderState(a),s.nodeBuilderState=n,s.version=e.version}return n}getForComputeAsync(e){let t=this.getForCompute(e,!0);return t.then?t:Promise.resolve(t)}_createNodeBuilderState(e){return new KM(e.vertexShader,e.fragmentShader,e.computeShader,e.getAttributesArray(),e.getBindings(),e.updateNodes,e.updateBeforeNodes,e.updateAfterNodes,e.observer,e.hardwareClipping,e.transforms)}getEnvironmentNode(e){if(this.renderer.lighting.enabled===!1)return null;this.updateEnvironment(e);let t=null;if(e.environmentNode&&e.environmentNode.isNode)t=e.environmentNode;else{let s=this.get(e);s.environmentNode&&(t=s.environmentNode)}return t}getBackgroundNode(e){this.updateBackground(e);let t=null;if(e.backgroundNode&&e.backgroundNode.isNode)t=e.backgroundNode;else{let s=this.get(e);s.backgroundNode&&(t=s.backgroundNode)}return t}getFogNode(e){return this.updateFog(e),e.fogNode||this.get(e).fogNode||null}getCacheKey(e,t){Ba[0]=e,Ba[1]=t;let s=this.renderer.info.calls,n=this.callHashCache.get(Ba)||{};if(n.callId!==s){if(Wr.push(this.renderer.getOutputRenderTarget()&&this.renderer.getOutputRenderTarget().multiview?1:0),Wr.push(this.renderer.lighting.enabled?1:0),this.renderer.lighting.enabled){Wr.push(t.getCacheKey(!0)),Wr.push(this.renderer.shadowMap.enabled?1:0),Wr.push(this.renderer.shadowMap.type);let i=this.getEnvironmentNode(e);i&&Wr.push(i.getCacheKey())}let a=this.getFogNode(e);a&&Wr.push(a.getCacheKey()),n.callId=s,n.cacheKey=$d(Wr),this.callHashCache.set(Ba,n),Wr.length=0}return Ba[0]=null,Ba[1]=null,n.cacheKey}get isToneMappingState(){return!this.renderer.getRenderTarget()}updateBackground(e){let t=this.get(e),s=e.background;if(s){let n=e.backgroundBlurriness===0&&t.backgroundBlurriness>0||e.backgroundBlurriness>0&&t.backgroundBlurriness===0;if(t.background!==s||n){let a=this.getCacheNode("background",s,()=>{if(s.isCubeTexture===!0||s.mapping===vu||s.mapping===_u||s.mapping===cl){if(e.backgroundBlurriness>0||s.mapping===cl)return RN(s);{let i;return s.isCubeTexture===!0?i=Nn(s):i=et(s),MF(i)}}else{if(s.isTexture===!0)return et(s,vi.flipY()).setUpdateMatrix(!0);s.isColor!==!0&&W("WebGPUNodes: Unsupported background configuration.",s)}},n);t.backgroundNode=a,t.background=s,t.backgroundBlurriness=e.backgroundBlurriness}}else t.backgroundNode&&(delete t.backgroundNode,delete t.background)}getCacheNode(e,t,s,n=!1){let a=this.cacheLib[e]||(this.cacheLib[e]=new WeakMap),i=a.get(t);if(i===void 0||n){if(i===void 0&&t.isTexture===!0){let o=()=>{t.removeEventListener("dispose",o);let c=a.get(t);c!==void 0&&(a.delete(t),c.dispose())};t.addEventListener("dispose",o)}i=s(),a.set(t,i)}return i}updateFog(e){let t=this.get(e),s=e.fog;if(s){if(t.fog!==s){let n=this.getCacheNode("fog",s,()=>{if(s.isFogExp2){let a=Et("color","color",s).setGroup(ye),i=Et("density","float",s).setGroup(ye);return WM(a,r2(i))}else if(s.isFog){let a=Et("color","color",s).setGroup(ye),i=Et("near","float",s).setGroup(ye),o=Et("far","float",s).setGroup(ye);return WM(a,i2(i,o))}else W("Renderer: Unsupported fog configuration.",s)});t.fogNode=n,t.fog=s}}else delete t.fogNode,delete t.fog}updateEnvironment(e){let t=this.get(e),s=e.environment;if(s){if(t.environment!==s){let n=this.getCacheNode("environment",s,()=>{if(s.isCubeTexture===!0)return Nn(s);if(s.isTexture===!0)return et(s);W("Nodes: Unsupported environment configuration.",s)});t.environmentNode=n,t.environment=s}}else t.environmentNode&&(delete t.environmentNode,delete t.environment)}getNodeFrame(e=this.renderer,t=null,s=null,n=null,a=null,i=null){let o=this.nodeFrame;return o.renderer=e,o.scene=t,o.object=s,o.camera=n,o.material=a,o.compute=i,o}getNodeFrameForRender(e){return this.getNodeFrame(e.renderer,e.scene,e.object,e.camera,e.material)}getNodeFrameForCompute(e){return this.getNodeFrame(this.renderer,null,null,null,null,e)}getOutputCacheKey(){let e=this.renderer;return e.toneMapping+","+e.currentColorSpace+","+e.xr.isPresenting}getOutputNode(e){let t=this.renderer,s;return e.isArrayTexture?this.backend.isWebGLBackend?s=et(e,vi).depth(Ni("gl_ViewID_OVR")).renderOutput(t.toneMapping,t.currentColorSpace):s=et(e,vi).depth(Vk).renderOutput(t.toneMapping,t.currentColorSpace):s=et(e,vi).renderOutput(t.toneMapping,t.currentColorSpace),s}setOutputLayerIndex(e){Vk.value=e}updateBefore(e){let t=e.getNodeBuilderState();for(let s of t.updateBeforeNodes)this.getNodeFrameForRender(e).updateBeforeNode(s)}updateAfter(e){let t=e.getNodeBuilderState();for(let s of t.updateAfterNodes)this.getNodeFrameForRender(e).updateAfterNode(s)}updateBeforeForCompute(e){let t=this.getForCompute(e);for(let s of t.updateBeforeNodes)this.getNodeFrameForCompute(e).updateBeforeNode(s)}updateAfterForCompute(e){let t=this.getForCompute(e);for(let s of t.updateAfterNodes)this.getNodeFrameForCompute(e).updateAfterNode(s)}updateForCompute(e){let t=this.getNodeFrame(),s=this.getForCompute(e);for(let n of s.updateNodes)t.updateNode(n)}updateForRender(e){let t=this.getNodeFrameForRender(e),s=e.getNodeBuilderState();for(let n of s.updateNodes)t.updateNode(n)}needsRefresh(e){let t=this.getNodeFrameForRender(e);return e.getMonitor().needsRefresh(e,t)}dispose(){super.dispose(),this.nodeFrame=new nb,this.nodeBuilderCache=new Map,this.cacheLib={}}},OA=new wn,aH=0,nT=class r{constructor(e=null){this.id=aH++,this.version=0,this.clipIntersection=null,this.cacheKey="",this.shadowPass=!1,this.viewMatrix=new le,this.viewNormalMatrix=new Fs,this.clippingGroupContexts=new WeakMap,this.intersectionPlanes=[],this.unionPlanes=[],this.parentVersion=null,e!==null&&(this.viewMatrix=e.viewMatrix,this.viewNormalMatrix=e.viewNormalMatrix,this.clippingGroupContexts=e.clippingGroupContexts,this.shadowPass=e.shadowPass)}projectPlanes(e,t,s){let n=e.length;for(let a=0;a<n;a++){OA.copy(e[a]).applyMatrix4(this.viewMatrix,this.viewNormalMatrix);let i=t[s+a],o=OA.normal;i.x=-o.x,i.y=-o.y,i.z=-o.z,i.w=OA.constant}}updateGlobal(e,t){this.shadowPass=e.overrideMaterial!==null&&e.overrideMaterial.isShadowPassMaterial,this.viewMatrix.copy(t.matrixWorldInverse),this.viewNormalMatrix.getNormalMatrix(this.viewMatrix)}update(e,t){let s=!1;e.version!==this.parentVersion&&(this.intersectionPlanes=Array.from(e.intersectionPlanes),this.unionPlanes=Array.from(e.unionPlanes),this.parentVersion=e.version),this.clipIntersection!==t.clipIntersection&&(this.clipIntersection=t.clipIntersection,this.clipIntersection?this.unionPlanes.length=e.unionPlanes.length:this.intersectionPlanes.length=e.intersectionPlanes.length);let n=t.clippingPlanes,a=n.length,i,o;if(this.clipIntersection?(i=this.intersectionPlanes,o=e.intersectionPlanes.length):(i=this.unionPlanes,o=e.unionPlanes.length),i.length!==o+a){i.length=o+a;for(let c=0;c<a;c++)i[o+c]=new Ge;s=!0}this.projectPlanes(n,i,o),s&&(this.version++,this.cacheKey=`${this.id}:${this.intersectionPlanes.length}:${this.unionPlanes.length}`)}getGroupContext(e){if(this.shadowPass&&!e.clipShadows)return this;let t=this.clippingGroupContexts.get(e);return t===void 0&&(t=new r(this),this.clippingGroupContexts.set(e,t)),t.update(this,e),t}get unionClippingCount(){return this.unionPlanes.length}},pS=class{constructor(e,t,s){this.bundleGroup=e,this.camera=t,this.renderContext=s}},Vo=[],mS=class{constructor(){this.bundles=new lr}get(e,t,s){let n=this.bundles;Vo[0]=e,Vo[1]=t,Vo[2]=s;let a=n.get(Vo);return a===void 0&&(a=new pS(e,t,s),n.set(Vo,a)),Vo[0]=null,Vo[1]=null,Vo[2]=null,a}dispose(){this.bundles=new lr}},db=class{constructor(){this.lightNodes=new WeakMap,this.materialNodes=new Map,this.toneMappingNodes=new Map}fromMaterial(e){if(e.isNodeMaterial)return e;let t=null,s=this.getMaterialNodeClass(e.type);if(s!==null){t=new s;for(let n in e)t[n]=e[n]}return t}addToneMapping(e,t){this.addType(e,t,this.toneMappingNodes)}getToneMappingFunction(e){return this.toneMappingNodes.get(e)||null}getMaterialNodeClass(e){return this.materialNodes.get(e)||null}addMaterial(e,t){this.addType(e,t,this.materialNodes)}getLightNodeClass(e){return this.lightNodes.get(e)||null}addLight(e,t){this.addClass(e,t,this.lightNodes)}addType(e,t,s){if(s.has(t)){K(`Redefinition of node ${t}`);return}if(typeof e!="function")throw new Error(`THREE.NodeLibrary: Node class ${e.name} is not a class.`);if(typeof t=="function"||typeof t=="object")throw new Error(`THREE.NodeLibrary: Base class ${t} is not a class.`);s.set(t,e)}addClass(e,t,s){if(s.has(t)){K(`Redefinition of node ${t.name}`);return}if(typeof e!="function")throw new Error(`THREE.NodeLibrary: Node class ${e.name} is not a class.`);if(typeof t!="function")throw new Error(`THREE.NodeLibrary: Base class ${t.name} is not a class.`);s.set(t,e)}},iH=new Gd,aT=class{constructor(){this.enabled=!0,this._cache=[],this._lightsNodeMap=new WeakMap}createNode(e=[]){return new Gd().setLights(e)}getNode(e){if(e.isScene!==!0&&e.isGroup!==!0)return iH;let t=this._lightsNodeMap.get(e);return t===void 0&&(t=this.createNode(),this._lightsNodeMap.set(e,t)),t}beginRender(e){this._cache.push(this.getNode(e).getLights())}finishRender(e){this.getNode(e).setLights(this._cache.pop())}},El=class extends Ps{constructor(e=1,t=1,s={}){super(e,t,s),this.isXRRenderTarget=!0,this._hasExternalTextures=!1,this._autoAllocateDepthBuffer=!0,this._isOpaqueFramebuffer=!1}copy(e){return super.copy(e),this._hasExternalTextures=e._hasExternalTextures,this._autoAllocateDepthBuffer=e._autoAllocateDepthBuffer,this._isOpaqueFramebuffer=e._isOpaqueFramebuffer,this}},jk=new E,Gk=new E,Hk=new WeakMap,bS=class extends Bs{constructor(e,t=!1){super(),this.enabled=!1,this.isPresenting=!1,this.cameraAutoUpdate=!0,this._renderer=e,this._cameraL=new qt,this._cameraL.viewport=new Ge,this._cameraL.matrixWorldAutoUpdate=!1,this._cameraR=new qt,this._cameraR.viewport=new Ge,this._cameraR.matrixWorldAutoUpdate=!1,this._cameras=[this._cameraL,this._cameraR],this._cameraXR=new kp,this._currentDepthNear=null,this._currentDepthFar=null,this._controllers=[],this._controllerInputSources=[],this._xrRenderTarget=null,this._layers=[],this._sessionUsesLayers=!1,this._supportsGlBinding=typeof XRWebGLBinding<"u",this._supportsWebGPUBinding=typeof globalThis.XRGPUBinding<"u",this._createXRLayer=uH.bind(this),this._gl=null,this._currentAnimationContext=null,this._currentAnimationLoop=null,this._currentPixelRatio=null,this._currentSize=new q,this._currentCameraSettings=null,this._onSessionEvent=cH.bind(this),this._onSessionEnd=lH.bind(this),this._onInputSourcesChange=hH.bind(this),this._onAnimationFrame=dH.bind(this),this._referenceSpace=null,this._referenceSpaceType="local-floor",this._customReferenceSpace=null,this._framebufferScaleFactor=1,this._foveation=1,this._session=null,this._glBaseLayer=null,this._glBinding=null,this._webgpuBinding=null,this._glProjLayer=null,this._xrFrame=null,this._supportsLayers=this._supportsGlBinding&&"createProjectionLayer"in XRWebGLBinding.prototype,this._useMultiviewIfPossible=t,this._useMultiview=!1}getController(e){return this._getController(e).getTargetRaySpace()}getControllerGrip(e){return this._getController(e).getGripSpace()}getHand(e){return this._getController(e).getHandSpace()}getFoveation(){return this._foveation}setFoveation(e){this._foveation=e,this._glProjLayer!==null&&(this._glProjLayer.fixedFoveation=e),this._glBaseLayer!==null&&this._glBaseLayer.fixedFoveation!==void 0&&(this._glBaseLayer.fixedFoveation=e)}getFramebufferScaleFactor(){return this._framebufferScaleFactor}setFramebufferScaleFactor(e){this._framebufferScaleFactor=e,this.isPresenting===!0&&K("XRManager: Cannot change framebuffer scale while presenting.")}getReferenceSpaceType(){return this._referenceSpaceType}setReferenceSpaceType(e){this._referenceSpaceType=e,this.isPresenting===!0&&K("XRManager: Cannot change reference space type while presenting.")}getReferenceSpace(){return this._customReferenceSpace||this._referenceSpace}setReferenceSpace(e){this._customReferenceSpace=e}getCamera(){return this._cameraXR}getEnvironmentBlendMode(){if(this._session!==null)return this._session.environmentBlendMode}getBaseLayer(){return this._glProjLayer!==null?this._glProjLayer:this._glBaseLayer}getBinding(){return this._glBinding===null&&this._supportsGlBinding&&(this._glBinding=new XRWebGLBinding(this._session,this._gl)),this._glBinding}foveateBoundTexture(e){if(e===null||e.isPostProcessingRenderTarget!==!0||this.isPresenting!==!0||this._glProjLayer===null)return;let t=this._renderer.backend;if(t===void 0||t.isWebGLBackend!==!0||t.state===null)return;let s=this._renderer.getOutputRenderTarget();if(s===null||s.isXRRenderTarget!==!0)return;let n=this.getBinding();if(n===null||typeof n.foveateBoundTexture!="function")return;this._renderer._textures.updateRenderTarget(e);let{textureGPU:a,glTextureType:i}=t.get(e.texture);if(!(a===void 0||i===void 0)&&e._xrFoveationTextureGPU!==a){e._xrFoveationTextureGPU=a,t.state.bindTexture(i,a);try{n.foveateBoundTexture(i,this.getFoveation())}catch(o){je(`XRManager: Unable to foveate bound XR post-processing texture. ${o.name}: ${o.message}`)}finally{t.state.unbindTexture()}}}getWebGPUBinding(){return this._webgpuBinding===null&&this._supportsWebGPUBinding&&(this._webgpuBinding=new globalThis.XRGPUBinding(this._session,this._renderer.backend.device)),this._webgpuBinding}_isWebGPUSession(){return this._renderer.backend.isWebGPUBackend===!0&&this._session!==null&&this._session.enabledFeatures.includes("webgpu")}_validateWebGPUSession(){if(this._renderer.backend.isWebGPUBackend===!0&&this._session.enabledFeatures.includes("webgpu")===!1)throw new Error('THREE.XRManager: WebGPU XR sessions require the "webgpu" session feature. Use VRButtonGPU/XRButton with "webgpu" enabled or use a WebGL backend.')}async _initWebGPUSession(e){let t=this.getWebGPUBinding(),s=t.createProjectionLayer({colorFormat:t.getPreferredColorFormat()});this._glProjLayer=s,e.updateRenderState({layers:[s]}),this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType()),this._xrRenderTarget=new Ps(s.textureWidth,s.textureHeight,{depth:2,minFilter:Ye,magFilter:Ye,depthBuffer:!0,multiview:!1,useArrayDepthTexture:!0,storeMultisampledColorBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,samples:this._renderer.samples}),this._xrRenderTarget.texture.isArrayTexture=!0,this._useMultiviewIfPossible===!0&&je("THREE.XRManager: WebGPU XR does not support multiview yet. Disabling multiview for this XR session."),this._useMultiview=!1}_disposeWebGPUSession(){let e=this._renderer,t=e.backend,s=this._xrRenderTarget;if(!(s===null||t.isWebGPUBackend!==!0)){e._renderContexts&&e._renderContexts.dispose&&e._renderContexts.dispose(),s.dispose();for(let n of s.textures)t.has(n)&&t.destroyTexture(n);t.delete(s)}}_getWebGPUViewData(e){let t=this.getWebGPUBinding(),s={colorTexture:null,viewDescriptors:[],viewports:[]};for(let n=0;n<e.length;n++){let a=t.getViewSubImage(this._glProjLayer,e[n]);s.colorTexture===null&&(s.colorTexture=a.colorTexture),s.viewports.push(a.viewport),a.getViewDescriptor&&s.viewDescriptors.push(a.getViewDescriptor())}return s}getFrame(){return this._xrFrame}useMultiview(){return this._useMultiview}createQuadLayer(e,t,s,n,a,i,o,c={}){let l=new au(e,t),h=new El(a,i,{format:gs,type:ws,depthTexture:new Ds(a,i,c.stencil?mi:St,void 0,void 0,void 0,void 0,void 0,void 0,c.stencil?na:vn),stencilBuffer:c.stencil,samples:c.samples??this._renderer.samples,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledColorBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1}),u=new Bt({color:16777215,side:ea});u.map=h.texture,u.map.offset.y=1,u.map.repeat.y=-1;let d=new at(l,u);d.position.copy(s),d.quaternion.copy(n);let f={type:"quad",width:e,height:t,translation:s,quaternion:n,pixelwidth:a,pixelheight:i,samples:h.samples,plane:d,material:u,rendercall:o,renderTarget:h};if(this._layers.push(f),this._session!==null){f.plane.material=new Bt({color:16777215,side:ea}),f.plane.material.blending=Or,f.plane.material.blendEquation=sa,f.plane.material.blendSrc=Gi,f.plane.material.blendDst=Gi,f.xrlayer=this._createXRLayer(f);let p=this._session.renderState.layers;p.unshift(f.xrlayer),this._session.updateRenderState({layers:p})}else h.isXRRenderTarget=!1;return d}createCylinderLayer(e,t,s,n,a,i,o,c,l={}){let h=new Kc(e,e,e*t/s,64,64,!0,Math.PI-t/2,t),u=new El(i,o,{format:gs,type:ws,depthTexture:new Ds(i,o,l.stencil?mi:St,void 0,void 0,void 0,void 0,void 0,void 0,l.stencil?na:vn),stencilBuffer:l.stencil,samples:l.samples??this._renderer.samples,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledColorBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1}),d=new Bt({color:16777215,side:Xt});d.map=u.texture,d.map.offset.y=1,d.map.repeat.y=-1;let f=new at(h,d);f.position.copy(n),f.quaternion.copy(a);let p={type:"cylinder",radius:e,centralAngle:t,aspectratio:s,translation:n,quaternion:a,pixelwidth:i,pixelheight:o,samples:u.samples,plane:f,material:d,rendercall:c,renderTarget:u};if(this._layers.push(p),this._session!==null){p.plane.material=new Bt({color:16777215,side:Xt}),p.plane.material.blending=Or,p.plane.material.blendEquation=sa,p.plane.material.blendSrc=Gi,p.plane.material.blendDst=Gi,p.xrlayer=this._createXRLayer(p);let m=this._session.renderState.layers;m.unshift(p.xrlayer),this._session.updateRenderState({layers:m})}else u.isXRRenderTarget=!1;return f}renderLayers(){let e=new E,t=new It,s=this._renderer,n=this.isPresenting;this.isPresenting=!1;let a=new q;s.getSize(a);let i=s.getRenderTarget();for(let o of this._layers){o.renderTarget.isXRRenderTarget=this._session!==null,o.renderTarget._hasExternalTextures=o.renderTarget.isXRRenderTarget;let c=s.contextNode,l;if(o.renderTarget.isXRRenderTarget&&this._sessionUsesLayers){o.xrlayer.transform=new XRRigidTransform(o.plane.getWorldPosition(e),o.plane.getWorldQuaternion(t));let h=this._glBinding.getSubImage(o.xrlayer,this._xrFrame);s.backend.setXRRenderTargetTextures(o.renderTarget,h.colorTexture,void 0),s._setXRLayerSize(o.renderTarget.width,o.renderTarget.height),l=Hk.get(c),l===void 0&&(l=Wn({getOutput:u=>Tb(u,s.toneMapping,s.outputColorSpace),...c.getFlowContextData()}),Hk.set(c,l))}else l=c;s.contextNode=l,s.setRenderTarget(o.renderTarget),o.rendercall(),s.contextNode=c}s.setRenderTarget(i),s._setXRLayerSize(a.x,a.y),this.isPresenting=n}getSession(){return this._session}async setSession(e){let t=this._renderer;t.initialized===!1&&await t.init(),this._gl=t.getContext();let s=this._gl;if(this._session=e,e!==null){if(e.addEventListener("select",this._onSessionEvent),e.addEventListener("selectstart",this._onSessionEvent),e.addEventListener("selectend",this._onSessionEvent),e.addEventListener("squeeze",this._onSessionEvent),e.addEventListener("squeezestart",this._onSessionEvent),e.addEventListener("squeezeend",this._onSessionEvent),e.addEventListener("end",this._onSessionEnd),e.addEventListener("inputsourceschange",this._onInputSourcesChange),this._validateWebGPUSession(),this._currentPixelRatio=t.getPixelRatio(),t.getSize(this._currentSize),this._currentAnimationContext=t._animation.getContext(),this._currentAnimationLoop=t._animation.getAnimationLoop(),t._animation.stop(),this._isWebGPUSession())await this._initWebGPUSession(e);else if(this._supportsLayers===!0){let n=null,a=null,i=null,o=s.getContextAttributes();await t.backend.makeXRCompatible(),this.setFoveation(this.getFoveation()),t.depth&&(i=t.stencil?s.DEPTH24_STENCIL8:s.DEPTH_COMPONENT24,n=t.stencil?na:vn,a=t.stencil?mi:St);let c={colorFormat:s.RGBA8,depthFormat:i,scaleFactor:this._framebufferScaleFactor,clearOnAccess:!1};this._useMultiviewIfPossible&&t.hasFeature("OVR_multiview2")&&(c.textureType="texture-array",this._useMultiview=!0),this._glBinding=this.getBinding();let l=this._glBinding.createProjectionLayer(c),h=[l];this._glProjLayer=l,t.setPixelRatio(1),t._setXRLayerSize(l.textureWidth,l.textureHeight);let u=this._useMultiview?2:1,d=new Ds(l.textureWidth,l.textureHeight,a,void 0,void 0,void 0,void 0,void 0,void 0,n,u);if(this._xrRenderTarget=new El(l.textureWidth,l.textureHeight,{format:gs,type:ws,colorSpace:t.outputColorSpace,depthTexture:d,stencilBuffer:t.stencil,samples:o.antialias?4:0,resolveDepthBuffer:l.ignoreDepthValues===!1,resolveStencilBuffer:l.ignoreDepthValues===!1,storeMultisampledColorBuffer:!1,storeMultisampledDepthBuffer:l.ignoreDepthValues===!1,storeMultisampledStencilBuffer:l.ignoreDepthValues===!1,depth:this._useMultiview?2:1,multiview:this._useMultiview}),this._xrRenderTarget._hasExternalTextures=!0,this._xrRenderTarget.depth=this._useMultiview?2:1,this._sessionUsesLayers=e.enabledFeatures.includes("layers"),this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType()),this._sessionUsesLayers)for(let f of this._layers)f.plane.material=new Bt({color:16777215,side:f.type==="cylinder"?Xt:ea}),f.plane.material.blending=Or,f.plane.material.blendEquation=sa,f.plane.material.blendSrc=Gi,f.plane.material.blendDst=Gi,f.xrlayer=this._createXRLayer(f),h.unshift(f.xrlayer);e.updateRenderState({layers:h})}else{await t.backend.makeXRCompatible(),this.setFoveation(this.getFoveation());let n={antialias:t.currentSamples>0,alpha:!0,depth:t.depth,stencil:t.stencil,framebufferScaleFactor:this.getFramebufferScaleFactor()},a=new XRWebGLLayer(e,s,n);this._glBaseLayer=a,e.updateRenderState({baseLayer:a}),t.setPixelRatio(1),t._setXRLayerSize(a.framebufferWidth,a.framebufferHeight),this._xrRenderTarget=new El(a.framebufferWidth,a.framebufferHeight,{format:gs,type:ws,colorSpace:t.outputColorSpace,stencilBuffer:t.stencil}),this._xrRenderTarget._isOpaqueFramebuffer=!0,this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType())}t._animation.setAnimationLoop(this._onAnimationFrame),t._animation.setContext(e),t._animation.start(),this.isPresenting=!0,this.dispatchEvent({type:"sessionstart"})}}updateCamera(e){let t=this._session;if(t===null)return;let s=e.near,n=e.far,a=this._cameraXR,i=this._cameraL,o=this._cameraR;a.near=o.near=i.near=s,a.far=o.far=i.far=n,a.isMultiViewCamera=this._useMultiview,(this._currentDepthNear!==a.near||this._currentDepthFar!==a.far)&&(t.updateRenderState({depthNear:a.near,depthFar:a.far}),this._currentDepthNear=a.near,this._currentDepthFar=a.far),a.layers.mask=e.layers.mask|6,i.layers.mask=a.layers.mask&-5,o.layers.mask=a.layers.mask&-3;let c=e.parent,l=a.cameras;Wk(a,c);for(let h=0;h<l.length;h++)Wk(l[h],c);l.length===2?rH(a,i,o):a.projectionMatrix.copy(i.projectionMatrix),this._currentCameraSettings===null&&e.isPerspectiveCamera&&(this._currentCameraSettings={camera:e,fov:e.fov,zoom:e.zoom}),oH(e,a,c)}_getController(e){let t=this._controllers[e];return t===void 0&&(t=new Hf,this._controllers[e]=t),t}};function rH(r,e,t){jk.setFromMatrixPosition(e.matrixWorld),Gk.setFromMatrixPosition(t.matrixWorld);let s=jk.distanceTo(Gk),n=e.projectionMatrix.elements,a=t.projectionMatrix.elements,i=n[14]/(n[10]-1),o=n[14]/(n[10]+1),c=(n[9]+1)/n[5],l=(n[9]-1)/n[5],h=(n[8]-1)/n[0],u=(a[8]+1)/a[0],d=i*h,f=i*u,p=s/(-h+u),m=p*-h;if(e.matrixWorld.decompose(r.position,r.quaternion,r.scale),r.translateX(m),r.translateZ(p),r.matrixWorld.compose(r.position,r.quaternion,r.scale),r.matrixWorldInverse.copy(r.matrixWorld).invert(),n[10]===-1)r.projectionMatrix.copy(e.projectionMatrix),r.projectionMatrixInverse.copy(e.projectionMatrixInverse);else{let b=i+p,g=o+p,x=d-m,T=f+(s-m),y=c*o/g*b,v=l*o/g*b;r.projectionMatrix.makePerspective(x,T,y,v,b,g),r.projectionMatrixInverse.copy(r.projectionMatrix).invert()}}function Wk(r,e){e===null?r.matrixWorld.copy(r.matrix):r.matrixWorld.multiplyMatrices(e.matrixWorld,r.matrix),r.matrixWorldInverse.copy(r.matrixWorld).invert()}function oH(r,e,t){t===null?r.matrix.copy(e.matrixWorld):(r.matrix.copy(t.matrixWorld),r.matrix.invert(),r.matrix.multiply(e.matrixWorld)),r.matrix.decompose(r.position,r.quaternion,r.scale),r.updateMatrixWorld(!0),r.projectionMatrix.copy(e.projectionMatrix),r.projectionMatrixInverse.copy(e.projectionMatrixInverse),r.isPerspectiveCamera&&(r.fov=zc*2*Math.atan(1/r.projectionMatrix.elements[5]),r.zoom=1)}function cH(r){let e=this._controllerInputSources.indexOf(r.inputSource);if(e===-1)return;let t=this._controllers[e];if(t!==void 0){let s=this.getReferenceSpace();t.update(r.inputSource,r.frame,s),t.dispatchEvent({type:r.type,data:r.inputSource})}}function lH(){let r=this._session,e=this._renderer;r.removeEventListener("select",this._onSessionEvent),r.removeEventListener("selectstart",this._onSessionEvent),r.removeEventListener("selectend",this._onSessionEvent),r.removeEventListener("squeeze",this._onSessionEvent),r.removeEventListener("squeezestart",this._onSessionEvent),r.removeEventListener("squeezeend",this._onSessionEvent),r.removeEventListener("end",this._onSessionEnd),r.removeEventListener("inputsourceschange",this._onInputSourcesChange);for(let t=0;t<this._controllers.length;t++){let s=this._controllerInputSources[t];s!==null&&(this._controllerInputSources[t]=null,this._controllers[t].disconnect(s))}if(this._currentDepthNear=null,this._currentDepthFar=null,e._resetXRState(),this._disposeWebGPUSession(),this._session=null,this._xrRenderTarget=null,this._glBinding=null,this._webgpuBinding=null,this._glBaseLayer=null,this._glProjLayer=null,this._sessionUsesLayers===!0)for(let t of this._layers)t.renderTarget=new El(t.pixelwidth,t.pixelheight,{format:gs,type:ws,depthTexture:new Ds(t.pixelwidth,t.pixelheight,t.stencilBuffer?mi:St,void 0,void 0,void 0,void 0,void 0,void 0,t.stencilBuffer?na:vn),stencilBuffer:t.stencilBuffer,samples:t.samples,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledColorBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1}),t.renderTarget.isXRRenderTarget=!1,t.plane.material=t.material,t.material.map=t.renderTarget.texture,t.material.map.offset.y=1,t.material.map.repeat.y=-1,delete t.xrlayer;if(this.isPresenting=!1,this._useMultiview=!1,e._animation.stop(),e._animation.setAnimationLoop(this._currentAnimationLoop),e._animation.setContext(this._currentAnimationContext),e._animation.start(),e.setPixelRatio(this._currentPixelRatio),e.setSize(this._currentSize.width,this._currentSize.height,!1),this._currentCameraSettings!==null){let t=this._currentCameraSettings.camera;t.fov=this._currentCameraSettings.fov,t.zoom=this._currentCameraSettings.zoom,t.updateProjectionMatrix(),this._currentCameraSettings=null}this.dispatchEvent({type:"sessionend"})}function hH(r){let e=this._controllers,t=this._controllerInputSources;for(let s=0;s<r.removed.length;s++){let n=r.removed[s],a=t.indexOf(n);a>=0&&(t[a]=null,e[a].disconnect(n))}for(let s=0;s<r.added.length;s++){let n=r.added[s],a=t.indexOf(n);if(a===-1){for(let o=0;o<e.length;o++)if(o>=t.length){t.push(n),a=o;break}else if(t[o]===null){t[o]=n,a=o;break}if(a===-1)break}let i=e[a];i&&i.connect(n)}}function uH(r){return r.type==="quad"?this._glBinding.createQuadLayer({transform:new XRRigidTransform(r.translation,r.quaternion),width:r.width/2,height:r.height/2,space:this._referenceSpace,viewPixelWidth:r.pixelwidth,viewPixelHeight:r.pixelheight,clearOnAccess:!1}):this._glBinding.createCylinderLayer({transform:new XRRigidTransform(r.translation,r.quaternion),radius:r.radius,centralAngle:r.centralAngle,aspectRatio:r.aspectRatio,space:this._referenceSpace,viewPixelWidth:r.pixelwidth,viewPixelHeight:r.pixelheight,clearOnAccess:!1})}function dH(r,e){if(e===void 0)return;let t=this._cameraXR,s=this._renderer,n=s.backend,a=this._glBaseLayer,i=this.getReferenceSpace(),o=e.getViewerPose(i);if(this._xrFrame=e,o!==null){let c=o.views,l=this._isWebGPUSession()?this._getWebGPUViewData(c):null;this._glBaseLayer!==null&&l===null&&n.setXRTarget(a.framebuffer);let h=!1;c.length!==t.cameras.length&&(t.cameras.length=0,h=!0);for(let d=0;d<c.length;d++){let f=c[d],p;if(l!==null)p=l.viewports[d];else if(this._supportsLayers===!0){let b=this._glBinding.getViewSubImage(this._glProjLayer,f);p=b.viewport,d===0&&n.setXRRenderTargetTextures(this._xrRenderTarget,b.colorTexture,this._glProjLayer.ignoreDepthValues&&!this._useMultiview?void 0:b.depthStencilTexture)}else p=a.getViewport(f);let m=this._cameras[d];m===void 0&&(m=new qt,m.layers.enable(d),m.viewport=new Ge,m.matrixWorldAutoUpdate=!1,this._cameras[d]=m),m.matrix.fromArray(f.transform.matrix),m.matrix.decompose(m.position,m.quaternion,m.scale),m.projectionMatrix.fromArray(f.projectionMatrix),m.projectionMatrixInverse.copy(m.projectionMatrix).invert(),m.viewport.set(p.x,p.y,p.width,p.height),d===0&&(t.matrix.copy(m.matrix),t.matrix.decompose(t.position,t.quaternion,t.scale)),h===!0&&t.cameras.push(m)}l!==null&&l.colorTexture!==null&&n.setXRRenderTargetTextures(this._xrRenderTarget,l.colorTexture,l.viewDescriptors),s.setOutputRenderTarget(this._xrRenderTarget);let u=s._getFrameBufferTarget();l!==null&&(this._xrRenderTarget.samples=u===null?s.samples:0,this._xrRenderTarget.depthBuffer=u===null),s.xr.foveateBoundTexture(u)}for(let c=0;c<this._controllers.length;c++){let l=this._controllerInputSources[c],h=this._controllers[c];l!==null&&h!==void 0&&h.update(l,e,i)}this._currentAnimationLoop&&this._currentAnimationLoop(r,e),e.detectedPlanes&&this.dispatchEvent({type:"planesdetected",data:e}),this._xrFrame=null}var iT=class extends Bs{constructor(e){super(),this.domElement=e,this._pixelRatio=1,this._width=this.domElement.width,this._height=this.domElement.height,this._viewport=new Ge(0,0,this._width,this._height),this._scissor=new Ge(0,0,this._width,this._height),this._scissorTest=!1,this.colorTexture=new qc,this.depthTexture=new Ds}getPixelRatio(){return this._pixelRatio}getDrawingBufferSize(e){return e.set(this._width*this._pixelRatio,this._height*this._pixelRatio).floor()}getSize(e){return e.set(this._width,this._height)}setPixelRatio(e=1){this._pixelRatio!==e&&(this._pixelRatio=e,this.setSize(this._width,this._height,!1))}setDrawingBufferSize(e,t,s){this.xr&&this.xr.isPresenting||(this._width=e,this._height=t,this._pixelRatio=s,this.domElement.width=Math.floor(e*s),this.domElement.height=Math.floor(t*s),this.setViewport(0,0,e,t),this._dispatchResize())}setSize(e,t,s=!0){this.xr&&this.xr.isPresenting||(this._width=e,this._height=t,this.domElement.width=Math.floor(e*this._pixelRatio),this.domElement.height=Math.floor(t*this._pixelRatio),s===!0&&(this.domElement.style.width=e+"px",this.domElement.style.height=t+"px"),this.setViewport(0,0,e,t),this._dispatchResize())}getScissor(e){let t=this._scissor;return e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height,e}setScissor(e,t,s,n){let a=this._scissor;e.isVector4?a.copy(e):a.set(e,t,s,n)}getScissorTest(){return this._scissorTest}setScissorTest(e){this._scissorTest=e}getViewport(e){return e.copy(this._viewport)}setViewport(e,t,s,n,a=0,i=1){let o=this._viewport;e.isVector4?o.copy(e):o.set(e,t,s,n),o.minDepth=a,o.maxDepth=i}_dispatchResize(){this.dispatchEvent({type:"resize"})}dispose(){this.dispatchEvent({type:"dispose"})}},qk=new ii,rd=new q,UA=new Ge,$x=new ci,Yx=new Jh,od=new le,qr=new Ge,fH={[ea]:Xt,[Xt]:ea,[rn]:rn},rT=class{constructor(e,t={}){this.isRenderer=!0;let{logarithmicDepthBuffer:s=!1,reversedDepthBuffer:n=!1,alpha:a=!0,depth:i=!0,stencil:o=!1,antialias:c=!1,samples:l=0,getFallback:h=null,outputBufferType:u=ds,multiview:d=!1}=t;this.backend=e,this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.alpha=a,this.logarithmicDepthBuffer=s,this.reversedDepthBuffer=n,this.outputColorSpace=Wt,this.toneMapping=Hi,this.toneMappingExposure=1,this.sortObjects=!0,this.depth=i,this.stencil=o,this.info=new CM,this.contextNode=Wn(),this.library=new db,this.lighting=new aT,this._samples=l||(c===!0?4:0),this._onCanvasTargetResize=this._onCanvasTargetResize.bind(this),this._canvasTarget=new iT(e.getDomElement()),this._canvasTarget.addEventListener("resize",this._onCanvasTargetResize),this._canvasTarget.isDefaultCanvasTarget=!0,this._inspector=new Um,this._inspector.setRenderer(this),this._getFallback=h,this._attributes=null,this._geometries=null,this._nodes=null,this._animation=null,this._bindings=null,this._objects=null,this._pipelines=null,this._bundles=null,this._renderLists=null,this._renderContexts=null,this._textures=null,this._background=null,this._quadCache=new Map,this._currentRenderContext=null,this._opaqueSort=null,this._transparentSort=null,this._frameBufferTargets=new Map;let f=this.alpha===!0?0:1;this._clearColor=new jd(0,0,0,f),this._clearDepth=1,this._clearStencil=0,this._renderTarget=null,this._activeCubeFace=0,this._activeMipmapLevel=0,this._outputRenderTarget=null,this._mrt=null,this._renderObjectFunction=null,this._currentRenderObjectFunction=null,this._currentRenderBundle=null,this._handleObjectFunction=this._renderObjectDirect,this._isDeviceLost=!1,this.onDeviceLost=this._onDeviceLost,this.onError=this._onError,this._outputBufferType=u,this._cacheShadowNodes=new WeakMap,this._initialized=!1,this._callDepth=-1,this._initPromise=null,this._compilationPromises=null,this._isPreCompiling=!1,this._currentSourceMaterial=null,this.transparent=!0,this.opaque=!0,this.shadowMap={enabled:!1,transmitted:!1,type:gu},this.xr=new bS(this,d),this.debug={checkShaderErrors:!0,diagnostics:{keywords:!1},onNodeBuilderCreated:null,onShaderError:null,getShaderAsync:async(p,m,b)=>{await this.compileAsync(b,m,p);let x=this.needsFrameBufferTarget&&this._renderTarget===null?this._getFrameBufferTarget():this._renderTarget||this._outputRenderTarget,T=this._renderLists.get(p,m,this.lighting),y=this._renderContexts.get(x,this._mrt),v=p.overrideMaterial||b.material,_=this._objects.get(b,v,p,m,T.lightsNode,y,y.clippingContext),{fragmentShader:A,vertexShader:M}=_.getNodeBuilderState();return{fragmentShader:A,vertexShader:M}}}}async init(){return this._initPromise!==null?this._initPromise:(this._initPromise=new Promise(async(e,t)=>{let s=this.backend;try{await s.init(this)}catch(n){if(this._getFallback!==null)try{this.backend=s=this._getFallback(n),await s.init(this)}catch(a){t(a);return}else{t(n);return}}this._nodes=new fS(this,s),this._animation=new MM(this,this._nodes,this.info),this._attributes=new RM(s,this.info),this._background=new XM(this,this._nodes),this._geometries=new EM(this._attributes,this.info),this._textures=new LM(this,s,this.info),this._pipelines=new BM(s,this._nodes,this.info),this._bindings=new FM(s,this._nodes,this._textures,this._attributes,this._pipelines,this.info),this._objects=new NM(this,this._nodes,this._geometries,this._pipelines,this._bindings,this.info),this._renderLists=new DM,this._bundles=new mS,this._renderContexts=new UM(this),this._animation.start(),this._initialized=!0,e(this)}),this._initPromise)}get domElement(){return this._canvasTarget.domElement}get coordinateSystem(){return this.backend.coordinateSystem}async compileAsync(e,t,s=null,n=null){if(this._isDeviceLost===!0)return;this._initialized===!1&&await this.init(),this.shadowMap.type===qy&&(K("WebGPURenderer: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.shadowMap.type=gu);let a=this._nodes.nodeFrame,i=a.renderId,o=this._currentRenderContext,c=this._currentRenderObjectFunction,l=this._handleObjectFunction,h=this._compilationPromises;s===null&&(s=e);let u=e.isScene===!0?e:s.isScene===!0?s:qk,d=this.needsFrameBufferTarget&&this._renderTarget===null,f=this._renderTarget||this._outputRenderTarget,p=this.xr.isPresenting===!0&&this.isOutputTarget,m=d?this._getFrameBufferTarget():f,b=this._renderContexts.get(m,this._mrt),g=this._activeMipmapLevel,x=[];this._currentRenderContext=b,this._currentRenderObjectFunction=this.renderObject,this._handleObjectFunction=this._createObjectPipeline,this._compilationPromises=x,a.renderId++,a.update(),b.depth=this.depth,b.stencil=this.stencil,b.clippingContext||(b.clippingContext=new nT),b.clippingContext.updateGlobal(u,t),e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t=this._updateCamera(t,p),u.onBeforeRender(this,e,t,m),od.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),t.isArrayCamera?Yx.setFromArrayCamera(t):$x.setFromProjectionMatrix(od,t.coordinateSystem,t.reversedDepth);let T=this._renderLists.get(u,t,this.lighting);if(T.begin(),this._projectObject(e,t,0,T,b.clippingContext),s!==e&&s.traverseVisible(function(R){R.isLight&&R.layers.test(t.layers)&&T.pushLight(R)}),T.finish(),m!==null){this._textures.updateRenderTarget(m,g);let R=this._textures.get(m);b.textures=R.textures,b.depthTexture=R.depthTexture}else b.textures=null,b.depthTexture=null;s!==e?this._background.update(s,T,b):this._background.update(u,T,b);let y=T.opaque,v=T.transparent,_=T.transparentDoublePass,A=T.lightsNode;this.opaque===!0&&y.length>0&&this._renderObjects(y,t,u,A),this.transparent===!0&&v.length>0&&this._renderTransparents(v,_,t,u,A),a.renderId=i,this._currentRenderContext=o,this._currentRenderObjectFunction=c,this._handleObjectFunction=l,this._compilationPromises=h;let M=x.length,N=0;for(let R of x){let I=this._objects.get(R.object,R.material,R.scene,R.camera,R.lightsNode,R.renderContext,R.clippingContext,R.passId);I.drawRange=R.object.geometry.drawRange,I.group=R.group,await this._nodes.getForRenderAsync(I),this._isPreCompiling=!0,this._nodes.updateBefore(I),this._geometries.updateForRender(I),this._nodes.updateForRender(I),this._bindings.updateForRender(I),this._isPreCompiling=!1;let D=[];this._pipelines.getForRender(I,D),D.length>0&&await Promise.all(D),this._isPreCompiling=!0,this._nodes.updateAfter(I),this._isPreCompiling=!1,N++,n!==null&&n(new ProgressEvent("progress",{lengthComputable:!0,loaded:N,total:M})),await _x()}}async compileComputeAsync(e,t=null){if(this._isDeviceLost===!0)return;this._initialized===!1&&await this.init();let s=Array.isArray(e)?e:[e];if(s.length===0||s.some(l=>l==null||l.isComputeNode!==!0))throw new Error("THREE.Renderer: .compileComputeAsync() expects a ComputeNode.");let n=s.length,a=0,i=this._pipelines,o=this._bindings,c=this._nodes;for(let l of s){if(i.has(l)===!1){let d=()=>{l.removeEventListener("dispose",d),i.delete(l),o.deleteForCompute(l),c.delete(l)};l.addEventListener("dispose",d);let f=l.onInitFunction;f!==null&&f.call(l,{renderer:this})}await c.getForComputeAsync(l),c.updateBeforeForCompute(l),c.updateForCompute(l),o.updateForCompute(l);let h=o.getForCompute(l),u=[];i.getForCompute(l,h,u),await Promise.all(u),c.updateAfterForCompute(l),a++,t!==null&&t(new ProgressEvent("progress",{lengthComputable:!0,loaded:a,total:n})),a<n&&await _x()}}async renderAsync(e,t){je('Renderer: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.render(e,t)}async waitForGPU(){W("Renderer: waitForGPU() has been removed. Read https://github.com/mrdoob/three.js/issues/32012 for more information.")}set inspector(e){this._inspector!==null&&this._inspector.setRenderer(null),this._inspector=e,this._inspector.setRenderer(this)}get inspector(){return this._inspector}set highPrecision(e){let t=this.contextNode.value;e===!0?(t.modelViewMatrix=nM,t.modelNormalViewMatrix=aM):this.highPrecision&&(delete t.modelViewMatrix,delete t.modelNormalViewMatrix)}get highPrecision(){let e=this.contextNode.value;return e.modelViewMatrix===nM&&e.modelNormalViewMatrix===aM}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getOutputBufferType(){return this._outputBufferType}getColorBufferType(){return je('Renderer: ".getColorBufferType()" has been renamed to ".getOutputBufferType()".'),this.getOutputBufferType()}_onDeviceLost(e){let t=`THREE.WebGPURenderer: ${e.api} Device Lost:

Message: ${e.message}`;e.reason&&(t+=`
Reason: ${e.reason}`),W(t),this._isDeviceLost=!0}_onError(e){let t=`WebGPURenderer: Uncaptured ${e.api} ${e.type}`;e.message&&(t+=`: ${e.message}`),W(t)}_bundleNeedsUpdate(e,t){return t.bundleGPU===void 0||e.version!==t.version}_renderBundle(e,t,s){let{bundleGroup:n,camera:a,renderList:i}=e,o=this._currentRenderContext,c=this._bundles.get(n,a,o),l=this.backend.get(c);if(this._bundleNeedsUpdate(n,l)){this.backend.beginBundle(o),this._currentRenderBundle=c;let{transparentDoublePass:u,transparent:d,opaque:f}=i;this.opaque===!0&&f.length>0&&this._renderObjects(f,a,t,s),this.transparent===!0&&d.length>0&&this._renderTransparents(d,u,a,t,s),this._currentRenderBundle=null,this.backend.finishBundle(o,c),l.version=n.version}else{let{renderObjects:u}=l;for(let d=0,f=u.length;d<f;d++){let p=u[d],m=this._nodes.needsRefresh(p);m===bi.FULL?(this._nodes.updateBefore(p),this._geometries.updateForRender(p),this._nodes.updateForRender(p),this._bindings.updateForRender(p),this._nodes.updateAfter(p)):m===bi.SHARED&&(this._nodes.updateBefore(p),this._nodes.updateForRender(p),this._bindings.updateSharedForRender(p),this._nodes.updateAfter(p))}}this.backend.addBundle(o,c)}render(e,t){if(this._initialized===!1)throw new Error('THREE.Renderer: .render() called before the backend is initialized. Use "await renderer.init();" before rendering.');this._renderScene(e,t)}get initialized(){return this._initialized}_renderOutputLayers(e,t){if(this.backend.isWebGLBackend===!0&&t.multiview===!0||t.texture.isArrayTexture!==!0||t.texture.image.depth<=1){this._renderScene(e,e.camera,!1);return}let n=this._activeCubeFace;try{for(let a=0;a<t.texture.image.depth;a++)this._nodes.setOutputLayerIndex(a),this._activeCubeFace=a,this._renderScene(e,e.camera,!1)}finally{this._nodes.setOutputLayerIndex(0),this._activeCubeFace=n}}_getFrameBufferTarget(){if(this.needsFrameBufferTarget===!1)return null;let{width:e,height:t}=this.getDrawingBufferSize(rd),{depth:s,stencil:n}=this,a=this._outputRenderTarget||this._canvasTarget,i=this._frameBufferTargets.get(a);if(i===void 0){i=new Ps(e,t,{depthBuffer:s,stencilBuffer:n,type:this._outputBufferType,format:gs,colorSpace:qe.workingColorSpace,generateMipmaps:!1,minFilter:Ye,magFilter:Ye,samples:this.samples}),i.isPostProcessingRenderTarget=!0;let d=()=>{a.removeEventListener("dispose",d),i.dispose(),this._frameBufferTargets.delete(a)};a.addEventListener("dispose",d),this._frameBufferTargets.set(a,i)}let o=this.getOutputRenderTarget();i.depthBuffer=s,i.stencilBuffer=n,o!==null?i.setSize(o.width,o.height,o.depth):i.setSize(e,t,1);let c=this._outputRenderTarget?this._outputRenderTarget.viewport:a._viewport,l=this._outputRenderTarget?this._outputRenderTarget.scissor:a._scissor,h=this._outputRenderTarget?1:a._pixelRatio,u=this._outputRenderTarget?this._outputRenderTarget.scissorTest:a._scissorTest;return i.viewport.copy(c),i.scissor.copy(l),i.viewport.multiplyScalar(h),i.scissor.multiplyScalar(h),i.scissorTest=u,i.multiview=o!==null?o.multiview:!1,i.useArrayDepthTexture=o!==null?o.useArrayDepthTexture:!1,i.resolveDepthBuffer=o!==null?o.resolveDepthBuffer:!0,i.resolveStencilBuffer=o!==null?o.resolveStencilBuffer:!0,i.storeMultisampledColorBuffer=o!==null?o.storeMultisampledColorBuffer:!0,i.storeMultisampledDepthBuffer=o!==null?o.storeMultisampledDepthBuffer:!0,i.storeMultisampledStencilBuffer=o!==null?o.storeMultisampledStencilBuffer:!0,i._autoAllocateDepthBuffer=o!==null?o._autoAllocateDepthBuffer:!1,i}_renderScene(e,t,s=!0){if(this._isDeviceLost===!0)return;this.shadowMap.type===qy&&(K("WebGPURenderer: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.shadowMap.type=gu);let n=s?this._getFrameBufferTarget():null,a=this._nodes.nodeFrame,i=a.renderId,o=this._currentRenderContext,c=this._currentRenderObjectFunction,l=this._handleObjectFunction;this.lighting.beginRender(e),this._callDepth++;let h=e.isScene===!0?e:qk,u=this._renderTarget||this._outputRenderTarget,d=this.xr.isPresenting===!0&&this.isOutputTarget,f=this._activeCubeFace,p=this._activeMipmapLevel,m;if(n!==null?(m=n,this.setRenderTarget(m)):m=u,m!==null&&m.depthBuffer===!0){let O=this._textures.get(m);O.depthInitialized!==!0&&((this.autoClear===!1||this.autoClear===!0&&this.autoClearDepth===!1)&&this.clearDepth(),O.depthInitialized=!0)}let b=this._renderContexts.get(m,this._mrt,this._callDepth);this._currentRenderContext=b,this._currentRenderObjectFunction=this._renderObjectFunction||this.renderObject,this._handleObjectFunction=this._renderObjectDirect,this.info.calls++,this.info.render.calls++,this.info.render.frameCalls++,a.renderId=this.info.calls,this.backend.updateTimeStampUID(b),this.inspector.beginRender(this.backend.getTimestampUID(b),e,t,m),e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t=this._updateCamera(t,d);let g=this._canvasTarget,x=g._viewport,T=g._scissor,y=g._pixelRatio;m!==null&&(x=m.viewport,T=m.scissor,y=1),this.getDrawingBufferSize(rd),UA.set(0,0,rd.width,rd.height);let v=x.minDepth===void 0?0:x.minDepth,_=x.maxDepth===void 0?1:x.maxDepth;b.viewportValue.copy(x).multiplyScalar(y).floor(),b.viewportValue.width>>=p,b.viewportValue.height>>=p,b.viewportValue.minDepth=v,b.viewportValue.maxDepth=_,b.viewport=b.viewportValue.equals(UA)===!1,b.scissorValue.copy(T).multiplyScalar(y).floor(),b.scissor=g._scissorTest&&b.scissorValue.equals(UA)===!1,b.scissorValue.width>>=p,b.scissorValue.height>>=p,b.clippingContext||(b.clippingContext=new nT),b.clippingContext.updateGlobal(h,t),h.onBeforeRender(this,e,t,m),od.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),t.isArrayCamera?Yx.setFromArrayCamera(t):$x.setFromProjectionMatrix(od,t.coordinateSystem,t.reversedDepth),this._renderLists.update(a.frameId);let A=this._renderLists.get(e,t,this.lighting);if(A.begin(),this._projectObject(e,t,0,A,b.clippingContext),A.finish(),this.sortObjects===!0&&A.sort(this._opaqueSort,this._transparentSort),m!==null){this._textures.updateRenderTarget(m,p);let O=this._textures.get(m);b.textures=O.textures,b.depthTexture=O.depthTexture,b.width=O.width,b.height=O.height,b.renderTarget=m,b.depth=m.depthBuffer,b.stencil=m.stencilBuffer}else b.textures=null,b.depthTexture=null,b.width=rd.width,b.height=rd.height,b.depth=this.depth,b.stencil=this.stencil;b.width>>=p,b.height>>=p,b.activeCubeFace=f,b.activeMipmapLevel=p,b.occlusionQueryCount=A.occlusionQueryCount,b.fullscreenPass=e.isQuadMesh===!0,b.scissorValue.max(qr.set(0,0,0,0)),b.scissorValue.x+b.scissorValue.width>b.width&&(b.scissorValue.width=Math.max(b.width-b.scissorValue.x,0)),b.scissorValue.y+b.scissorValue.height>b.height&&(b.scissorValue.height=Math.max(b.height-b.scissorValue.y,0)),this._background.update(h,A,b),b.camera=t,this.backend.beginRender(b);let{bundles:M,lightsNode:N,transparentDoublePass:R,transparent:I,opaque:D}=A;return M.length>0&&this._renderBundles(M,h,N),this.opaque===!0&&D.length>0&&this._renderObjects(D,t,h,N),this.transparent===!0&&I.length>0&&this._renderTransparents(I,R,t,h,N),this.backend.finishRender(b),a.renderId=i,this._currentRenderContext=o,this._currentRenderObjectFunction=c,this._handleObjectFunction=l,this.lighting.finishRender(e),this._callDepth--,n!==null&&(this.setRenderTarget(u,f,p),this._renderOutput(m)),h.onAfterRender(this,e,t,m),this.inspector.finishRender(this.backend.getTimestampUID(b)),b}_setXRLayerSize(e,t){this._canvasTarget._width=e,this._canvasTarget._height=t,this.setViewport(0,0,e,t)}_renderOutput(e){let t=this._nodes.getOutputCacheKey(),s=this._quadCache.get(e.texture),n;if(s===void 0){n=new Xl(new wt),n.name="Output Color Transform",n.material.name="outputColorTransform",n.material.fragmentNode=this._nodes.getOutputNode(e.texture),s={quad:n,cacheKey:t},this._quadCache.set(e.texture,s);let o=()=>{n.material.dispose(),this._quadCache.delete(e.texture),e.texture.removeEventListener("dispose",o)};e.texture.addEventListener("dispose",o)}else n=s.quad,s.cacheKey!==t&&(n.material.fragmentNode=this._nodes.getOutputNode(e.texture),n.material.needsUpdate=!0,s.cacheKey=t);let a=this.autoClear,i=this.xr.enabled;this.autoClear=!1,this.xr.enabled=!1,this._renderOutputLayers(n,e),this.autoClear=a,this.xr.enabled=i}getMaxAnisotropy(){return this.backend.capabilities.getMaxAnisotropy()}getActiveCubeFace(){return this._activeCubeFace}getActiveMipmapLevel(){return this._activeMipmapLevel}async setAnimationLoop(e){this._initialized===!1&&await this.init(),this._animation.setAnimationLoop(e)}getAnimationLoop(){return this._animation.getAnimationLoop()}async getArrayBufferAsync(e,t=null,s=0,n=-1){if(t!==null&&t.isReadbackBuffer&&this.info.memoryMap.has(t)===!1){this.info.createReadbackBuffer(t);let a=()=>{t.removeEventListener("dispose",a),this.info.destroyReadbackBuffer(t)};t.addEventListener("dispose",a)}if(s%4!==0||n>0&&n%4!==0)throw new Error('THREE.Renderer: "getArrayBufferAsync()" offset and count must be a multiple of 4.');return await this.backend.getArrayBufferAsync(e,t,s,n)}getContext(){return this.backend.getContext()}getPixelRatio(){return this._canvasTarget.getPixelRatio()}getDrawingBufferSize(e){return this._canvasTarget.getDrawingBufferSize(e)}getSize(e){return this._canvasTarget.getSize(e)}setPixelRatio(e=1){this._canvasTarget.setPixelRatio(e)}setDrawingBufferSize(e,t,s){this.xr&&this.xr.isPresenting||this._canvasTarget.setDrawingBufferSize(e,t,s)}setSize(e,t,s=!0){this.xr&&this.xr.isPresenting||this._canvasTarget.setSize(e,t,s)}setOpaqueSort(e){this._opaqueSort=e}setTransparentSort(e){this._transparentSort=e}getScissor(e){return this._canvasTarget.getScissor(e)}setScissor(e,t,s,n){this._canvasTarget.setScissor(e,t,s,n)}getScissorTest(){return this._canvasTarget.getScissorTest()}setScissorTest(e){this._canvasTarget.setScissorTest(e),this.backend.setScissorTest(e)}resetState(){if(this._initialized===!1)throw new Error('THREE.Renderer: .resetState() called before the backend is initialized. Use "await renderer.init();" before using this method.');this.backend.resetState()}getViewport(e){return this._canvasTarget.getViewport(e)}setViewport(e,t,s,n,a=0,i=1){this._canvasTarget.setViewport(e,t,s,n,a,i)}getClearColor(e){return e.copy(this._clearColor)}setClearColor(e,t=1){this._clearColor.set(e),this._clearColor.a=t}getClearAlpha(){return this._clearColor.a}setClearAlpha(e){this._clearColor.a=e}getClearDepth(){return this.reversedDepthBuffer===!0?1-this._clearDepth:this._clearDepth}setClearDepth(e){this._clearDepth=e}getClearStencil(){return this._clearStencil}setClearStencil(e){this._clearStencil=e}isOccluded(e){let t=this._currentRenderContext;return t&&this.backend.isOccluded(t,e)}clear(e=!0,t=!0,s=!0){if(this._initialized===!1)throw new Error('THREE.Renderer: .clear() called before the backend is initialized. Use "await renderer.init();" before using this method.');let n=this._renderTarget||this._getFrameBufferTarget(),a=null;if(n!==null){this._textures.updateRenderTarget(n);let i=this._textures.get(n);a=this._renderContexts.get(n,null,-1),a.textures=i.textures,a.depthTexture=i.depthTexture,a.width=i.width,a.height=i.height,a.renderTarget=n,a.depth=n.depthBuffer,a.stencil=n.stencilBuffer;let o=this.backend.getClearColor();a.clearColorValue.r=o.r,a.clearColorValue.g=o.g,a.clearColorValue.b=o.b,a.clearColorValue.a=o.a,a.clearDepthValue=this.getClearDepth(),a.clearStencilValue=this.getClearStencil(),a.activeCubeFace=this.getActiveCubeFace(),a.activeMipmapLevel=this.getActiveMipmapLevel(),n.depthBuffer===!0&&(i.depthInitialized=!0)}this.backend.clear(e,t,s,a),n!==null&&this._renderTarget===null&&this._renderOutput(n)}clearColor(){this.clear(!0,!1,!1)}clearDepth(){this.clear(!1,!0,!1)}clearStencil(){this.clear(!1,!1,!0)}async clearAsync(e=!0,t=!0,s=!0){je('Renderer: "clearAsync()" has been deprecated. Use "clear()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.clear(e,t,s)}async clearColorAsync(){je('Renderer: "clearColorAsync()" has been deprecated. Use "clearColor()" and "await renderer.init();" when creating the renderer.'),this.clear(!0,!1,!1)}async clearDepthAsync(){je('Renderer: "clearDepthAsync()" has been deprecated. Use "clearDepth()" and "await renderer.init();" when creating the renderer.'),this.clear(!1,!0,!1)}async clearStencilAsync(){je('Renderer: "clearStencilAsync()" has been deprecated. Use "clearStencil()" and "await renderer.init();" when creating the renderer.'),this.clear(!1,!1,!0)}get needsFrameBufferTarget(){let e=this.currentToneMapping!==Hi,t=this.currentColorSpace!==qe.workingColorSpace;return e||t}get samples(){return this._samples}get currentSamples(){let e=this._samples;return this._renderTarget!==null?e=this._renderTarget.samples:(this.needsFrameBufferTarget||this._currentRenderContext?.fullscreenPass===!0)&&(e=0),e}get currentToneMapping(){return this.isOutputTarget?this.toneMapping:Hi}get currentColorSpace(){return this.isOutputTarget?this.outputColorSpace:qe.workingColorSpace}get isOutputTarget(){return this._renderTarget===this._outputRenderTarget||this._renderTarget===null}async dispose(){if(this._initialized===!0){this.info.dispose(),this._inspector.dispose(),this._animation.dispose(),this._objects.dispose(),this._geometries.dispose(),this._pipelines.dispose(),this._nodes.dispose(),this._bindings.dispose(),this._renderLists.dispose(),this._renderContexts.dispose(),this._textures.dispose();for(let e of this._frameBufferTargets.keys())e.dispose();await this.backend.dispose()}this.setRenderTarget(null),this.setAnimationLoop(null)}setRenderTarget(e,t=0,s=0){this._renderTarget=e,this._activeCubeFace=t,this._activeMipmapLevel=s}getRenderTarget(){return this._renderTarget}setOutputRenderTarget(e){this._outputRenderTarget=e}getOutputRenderTarget(){return this._outputRenderTarget}setCanvasTarget(e){this._canvasTarget.removeEventListener("resize",this._onCanvasTargetResize),this._canvasTarget=e,this._canvasTarget.addEventListener("resize",this._onCanvasTargetResize)}getCanvasTarget(){return this._canvasTarget}_resetXRState(){this.backend.setXRTarget(null),this.setOutputRenderTarget(null),this.setRenderTarget(null);for(let e of this._frameBufferTargets.keys())e.dispose()}setRenderObjectFunction(e){this._renderObjectFunction=e}getRenderObjectFunction(){return this._renderObjectFunction}compute(e,t=null){if(this._isDeviceLost===!0)return;if(this._initialized===!1)return K('Renderer: ".compute()" called before the backend is initialized. Try using ".computeAsync()" instead.'),this.computeAsync(e,t);let s=this._nodes.nodeFrame,n=s.renderId;this.info.calls++,this.info.compute.calls++,this.info.compute.frameCalls++,s.renderId=this.info.calls,this.backend.updateTimeStampUID(e),this.inspector.beginCompute(this.backend.getTimestampUID(e),e);let a=this.backend,i=this._pipelines,o=this._bindings,c=this._nodes,l=Array.isArray(e)?e:[e];if(l[0]===void 0||l[0].isComputeNode!==!0)throw new Error("THREE.Renderer: .compute() expects a ComputeNode.");a.beginCompute(e);for(let h of l){if(i.has(h)===!1){let f=()=>{h.removeEventListener("dispose",f),i.delete(h),o.deleteForCompute(h),c.delete(h)};h.addEventListener("dispose",f);let p=h.onInitFunction;p!==null&&p.call(h,{renderer:this})}c.updateBeforeForCompute(h),c.updateForCompute(h),o.updateForCompute(h);let u=o.getForCompute(h),d=i.getForCompute(h,u);a.compute(e,h,u,d,t),c.updateAfterForCompute(h)}a.finishCompute(e),s.renderId=n,this.inspector.finishCompute(this.backend.getTimestampUID(e))}async computeAsync(e,t=null){this._initialized===!1&&await this.init(),this.compute(e,t)}async hasFeatureAsync(e){return je('Renderer: "hasFeatureAsync()" has been deprecated. Use "hasFeature()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.hasFeature(e)}async resolveTimestampsAsync(e="render"){return this._initialized===!1&&await this.init(),this.backend.resolveTimestampsAsync(e)}hasFeature(e){if(this._initialized===!1)throw new Error('THREE.Renderer: .hasFeature() called before the backend is initialized. Use "await renderer.init();" before using this method.');return this.backend.hasFeature(e)}hasInitialized(){return this._initialized}async initTextureAsync(e){je('Renderer: "initTextureAsync()" has been deprecated. Use "initTexture()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.initTexture(e)}initTexture(e){if(this._initialized===!1)throw new Error('THREE.Renderer: .initTexture() called before the backend is initialized. Use "await renderer.init();" before using this method.');this._textures.updateTexture(e)}initRenderTarget(e){if(this._initialized===!1)throw new Error('THREE.Renderer: .initRenderTarget() called before the backend is initialized. Use "await renderer.init();" before using this method.');this._textures.updateRenderTarget(e);let t=this._textures.get(e),s=this._renderContexts.get(e);s.textures=t.textures,s.depthTexture=t.depthTexture,s.width=t.width,s.height=t.height,s.renderTarget=e,s.depth=e.depthBuffer,s.stencil=e.stencilBuffer,this.backend.initRenderTarget(s)}copyFramebufferToTexture(e,t=null){if(t!==null)if(t.isVector2)t=qr.set(t.x,t.y,e.image.width,e.image.height).floor();else if(t.isVector4)t=qr.copy(t).floor();else{W("Renderer.copyFramebufferToTexture: Invalid rectangle.");return}else t=qr.set(0,0,e.image.width,e.image.height);let s=this._currentRenderContext,n;s!==null?n=s.renderTarget:(n=this._renderTarget||this._getFrameBufferTarget(),n!==null&&(this._textures.updateRenderTarget(n),s=this._textures.get(n))),this._textures.updateTexture(e,{renderTarget:n}),this.backend.copyFramebufferToTexture(e,s,t),this._inspector.copyFramebufferToTexture(e)}copyTextureToTexture(e,t,s=null,n=null,a=0,i=0){this._textures.updateTexture(e),this._textures.updateTexture(t),this.backend.copyTextureToTexture(e,t,s,n,a,i),this._inspector.copyTextureToTexture(e,t)}async readRenderTargetPixelsAsync(e,t,s,n,a,i=0,o=0){return this.backend.copyTextureToBuffer(e.textures[i],t,s,n,a,o)}_projectObject(e,t,s,n,a){if(e.visible===!1)return;if(e.layers.test(t.layers)){if(e.isGroup)s=e.renderOrder,e.isClippingGroup&&e.enabled&&(a=a.getGroupContext(e));else if(e.isLOD)e.autoUpdate===!0&&e.update(t);else if(e.isLight)n.pushLight(e);else if(e.isSprite){let c=t.isArrayCamera?Yx:$x;if(!e.frustumCulled||e.intersectsFrustum(c)){this.sortObjects===!0&&qr.setFromMatrixPosition(e.matrixWorld).applyMatrix4(od);let{geometry:l,material:h}=e;h.visible&&n.push(e,l,h,s,qr.z,null,a)}}else if(e.isLineLoop)W("Renderer: Objects of type THREE.LineLoop are not supported. Please use THREE.Line or THREE.LineSegments.");else if(e.isMesh||e.isLine||e.isPoints){let c=t.isArrayCamera?Yx:$x;if(!e.frustumCulled||e.intersectsFrustum(c)){let{geometry:l,material:h}=e;if(this.sortObjects===!0&&(l.boundingSphere===null&&l.computeBoundingSphere(),qr.copy(l.boundingSphere.center).applyMatrix4(e.matrixWorld).applyMatrix4(od)),Array.isArray(h)){let u=l.groups;for(let d=0,f=u.length;d<f;d++){let p=u[d],m=h[p.materialIndex];m&&m.visible&&n.push(e,l,m,s,qr.z,p,a)}}else h.visible&&n.push(e,l,h,s,qr.z,null,a)}}}if(e.isBundleGroup===!0&&this.backend.beginBundle!==void 0){let c=n;n=this._renderLists.get(e,t,this.lighting);let l=this._bundles.get(e,t,this._currentRenderContext),h=this.backend.get(l);if(this._bundleNeedsUpdate(e,h)){n.begin(),h.renderObjects===void 0?h.renderObjects=[]:h.renderObjects.length=0;let d=e.children;for(let f=0,p=d.length;f<p;f++)this._projectObject(d[f],t,s,n,a);n.finish()}c.pushBundle({bundleGroup:e,camera:t,renderList:n});return}let o=e.children;for(let c=0,l=o.length;c<l;c++)this._projectObject(o[c],t,s,n,a)}_renderBundles(e,t,s){for(let n of e)this._renderBundle(n,t,s)}_renderTransparents(e,t,s,n,a){if(t.length>0){for(let{material:i}of t)i.side=Xt;this._renderObjects(t,s,n,a,"backSide");for(let{material:i}of t)i.side=ea;this._renderObjects(e,s,n,a);for(let{material:i}of t)i.side=rn}else this._renderObjects(e,s,n,a)}_renderObjects(e,t,s,n,a=null){for(let i=0,o=e.length;i<o;i++){let{object:c,geometry:l,material:h,group:u,clippingContext:d}=e[i];this._currentRenderObjectFunction(c,s,t,l,h,u,n,d,a)}}_getShadowNodes(e){let t=e.version,s=this._cacheShadowNodes.get(e);if(s===void 0||s.version!==t){let n=e.map&&e.map.isTexture,a=e.colorNode&&e.colorNode.isNode,i=e.castShadowNode&&e.castShadowNode.isNode,o=e.maskShadowNode&&e.maskShadowNode.isNode||e.maskNode&&e.maskNode.isNode,c=null,l=null,h=null;if(n||a||i||o){let u,d;if(i?(u=e.castShadowNode.rgb,d=e.castShadowNode.a,this.shadowMap.transmitted!==!0&&je("Renderer: `shadowMap.transmitted` needs to be set to `true` when using `material.castShadowNode`.")):(u=C(0),d=S(1)),n&&(d=d.mul(Et("map","texture",e).a)),a&&(d=d.mul(e.colorNode.a)),l=ce(u,d),o){let f=e.maskShadowNode||e.maskNode;l=F(([p])=>(f.not().discard(),p))(l)}}e.depthNode&&e.depthNode.isNode&&(h=e.depthNode),e.castShadowPositionNode&&e.castShadowPositionNode.isNode?c=e.castShadowPositionNode:e.positionNode&&e.positionNode.isNode&&(c=e.positionNode),s={version:t,colorNode:l,depthNode:h,positionNode:c},this._cacheShadowNodes.set(e,s)}return s}_updateCamera(e,t){let s=this.xr;if(s.isPresenting===!1||t===!1){let n=!1;if(this.reversedDepthBuffer===!0&&e.reversedDepth!==!0){if(e._reversedDepth=!0,e.isArrayCamera)for(let i of e.cameras)i._reversedDepth=!0;n=!0}let a=this.coordinateSystem;if(e.coordinateSystem!==a){if(e.coordinateSystem=a,e.isArrayCamera)for(let i of e.cameras)i.coordinateSystem=a;n=!0}if(n===!0&&(e.updateProjectionMatrix(),e.isArrayCamera))for(let i of e.cameras)i.updateProjectionMatrix()}return e.parent===null&&e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t===!0&&s.enabled===!0&&s.isPresenting===!0&&(s.cameraAutoUpdate===!0&&s.updateCamera(e),e=s.getCamera()),e}renderObject(e,t,s,n,a,i,o,c=null,l=null){let h=!1,u,d,f,p,m,b,g,x=this._currentSourceMaterial;if(e.onBeforeRender(this,t,s,n,a,i),a.allowOverride===!0&&t.overrideMaterial!==null){this._currentSourceMaterial=a;let T=t.overrideMaterial;if(h=!0,u=T.isNodeMaterial?T.colorNode:null,d=T.isNodeMaterial?T.depthNode:null,f=T.isNodeMaterial?T.positionNode:null,p=t.overrideMaterial.side,m=T.displacementMap,b=T.displacementScale,g=T.displacementBias,a.positionNode&&a.positionNode.isNode&&(T.positionNode=a.positionNode),T.alphaTest=a.alphaTest,T.alphaMap=a.alphaMap,T.displacementMap=a.displacementMap,T.displacementScale=a.displacementScale,T.displacementBias=a.displacementBias,T.transparent=a.transparent||a.transmission>0||a.transmissionNode&&a.transmissionNode.isNode||a.backdropNode&&a.backdropNode.isNode,T.isShadowPassMaterial){let{colorNode:y,depthNode:v,positionNode:_}=this._getShadowNodes(a);this.shadowMap.type===rl?T.side=a.shadowSide!==null?a.shadowSide:a.side:T.side=a.shadowSide!==null?a.shadowSide:fH[a.side],y!==null&&(T.colorNode=y),v!==null&&(T.depthNode=v),_!==null&&(T.positionNode=_)}a=T}a.transparent===!0&&a.side===rn&&a.forceSinglePass===!1?(a.side=Xt,this._handleObjectFunction(e,a,t,s,o,i,c,"backSide"),a.side=ea,this._handleObjectFunction(e,a,t,s,o,i,c,l),a.side=rn):this._handleObjectFunction(e,a,t,s,o,i,c,l),h&&(t.overrideMaterial.colorNode=u,t.overrideMaterial.depthNode=d,t.overrideMaterial.positionNode=f,t.overrideMaterial.side=p,t.overrideMaterial.displacementMap=m,t.overrideMaterial.displacementScale=b,t.overrideMaterial.displacementBias=g),this._currentSourceMaterial=x,e.onAfterRender(this,t,s,n,a,i)}hasCompatibility(e){if(this._initialized===!1)throw new Error('THREE.Renderer: .hasCompatibility() called before the backend is initialized. Use "await renderer.init();" before using this method.');return this.backend.hasCompatibility(e)}_renderObjectDirect(e,t,s,n,a,i,o,c){let l=this._objects.get(e,t,s,n,a,this._currentRenderContext,o,c);l.drawRange=e.geometry.drawRange,l.group=i,this._currentRenderBundle!==null&&(this.backend.get(this._currentRenderBundle).renderObjects.push(l),l.bundle=this._currentRenderBundle.bundleGroup);let h=this._nodes.needsRefresh(l);h===bi.FULL?(this._nodes.updateBefore(l),this._geometries.updateForRender(l),this._nodes.updateForRender(l),this._bindings.updateForRender(l)):h===bi.SHARED&&(this._nodes.updateBefore(l),this._nodes.updateForRender(l),this._bindings.updateSharedForRender(l)),this._pipelines.updateForRender(l),this._pipelines.isReady(l)&&(this.backend.draw(l,this.info),h!==bi.NONE&&this._nodes.updateAfter(l))}_createObjectPipeline(e,t,s,n,a,i,o,c){if(this._compilationPromises!==null){this._compilationPromises.push({object:e,material:t,scene:s,camera:n,lightsNode:a,group:i,clippingContext:o,passId:c,renderContext:this._currentRenderContext});return}let l=this._objects.get(e,t,s,n,a,this._currentRenderContext,o,c);l.drawRange=e.geometry.drawRange,l.group=i,this._nodes.updateBefore(l),this._geometries.updateForRender(l),this._nodes.updateForRender(l),this._bindings.updateForRender(l),this._pipelines.getForRender(l,this._compilationPromises),this._nodes.updateAfter(l)}_onCanvasTargetResize(){this._initialized&&this.backend.updateSize()}get compile(){return this.compileAsync}},oT=class{constructor(e=""){this.name=e,this.visibility=0}setVisibility(e){this.visibility|=e}getVisibility(){return this.visibility}clone(){return Object.assign(new this.constructor,this)}};function F2(r){return r+(Yo-r%Yo)%Yo}var cT=class extends oT{constructor(e,t=null){super(e),this.isBuffer=!0,this.bytesPerElement=Float32Array.BYTES_PER_ELEMENT,this._buffer=t,this._updateRanges=[]}get updateRanges(){return this._updateRanges}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}get byteLength(){return F2(this._buffer.byteLength)}get buffer(){return this._buffer}update(){return!0}release(){this._buffer=null}},lT=class extends cT{constructor(e,t=null){super(e,t),this.isUniformBuffer=!0}},pH=0,hT=class extends lT{constructor(e,t){let s=e&&e.name?e.name:pH++;super("UniformBuffer_"+s,e?e.value:null),this.nodeUniform=e,this.groupNode=t,this.isNodeUniformBuffer=!0}set updateRanges(e){this.nodeUniform.updateRanges=e}get updateRanges(){return this.nodeUniform.updateRanges}addUpdateRange(e,t){this.nodeUniform.addUpdateRange(e,t)}clearUpdateRanges(){this.nodeUniform.clearUpdateRanges()}get byteLength(){return F2(this.buffer.byteLength)}get buffer(){return this.nodeUniform.value}},gS=class extends lT{constructor(e){super(e),this.isUniformsGroup=!0,this._values=null,this.uniforms=[],this._updateRangeCache=new Map,this._addedIndices=new Set}addUniformUpdateRange(e){let t=e.index;if(this._addedIndices.has(t))return;let s=this._updateRangeCache.get(t);s===void 0&&(s={start:0,count:0},this._updateRangeCache.set(t,s)),s.start=e.offset,s.count=e.itemSize,this._addedIndices.add(t),this.updateRanges.push(s)}clearUpdateRanges(){this._addedIndices.clear(),super.clearUpdateRanges()}addUniform(e){return this.uniforms.push(e),this}removeUniform(e){let t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}get values(){return this._values===null&&(this._values=Array.from(this.buffer)),this._values}get buffer(){let e=this._buffer;if(e===null){let t=this.byteLength;e=new Float32Array(new ArrayBuffer(t)),this._buffer=e}return e}get byteLength(){let e=this.bytesPerElement,t=0;for(let s=0,n=this.uniforms.length;s<n;s++){let a=this.uniforms[s],i=a.boundary,o=a.itemSize*e,c=t%Yo,l=c%i,h=c+l;t+=l,h!==0&&Yo-h<o&&(t+=Yo-h),a.offset=t/e,a.index=s,t+=o}return Math.ceil(t/Yo)*Yo}update(){let e=!1;for(let t of this.uniforms)this.updateByType(t)===!0&&(e=!0);return e}release(){super.release(),this._values=null}updateByType(e){if(e.isNumberUniform)return this.updateNumber(e);if(e.isVector2Uniform)return this.updateVector2(e);if(e.isVector3Uniform)return this.updateVector3(e);if(e.isVector4Uniform)return this.updateVector4(e);if(e.isColorUniform)return this.updateColor(e);if(e.isMatrix3Uniform)return this.updateMatrix3(e);if(e.isMatrix4Uniform)return this.updateMatrix4(e);W("WebGPUUniformsGroup: Unsupported uniform type.",e)}updateNumber(e){let t=!1,s=this.values,n=e.getValue(),a=e.offset,i=e.getType();if(s[a]!==n){let o=this._getBufferForType(i);o[a]=s[a]=n,t=!0,this.addUniformUpdateRange(e)}return t}updateVector2(e){let t=!1,s=this.values,n=e.getValue(),a=e.offset,i=e.getType();if(s[a+0]!==n.x||s[a+1]!==n.y){let o=this._getBufferForType(i);o[a+0]=s[a+0]=n.x,o[a+1]=s[a+1]=n.y,t=!0,this.addUniformUpdateRange(e)}return t}updateVector3(e){let t=!1,s=this.values,n=e.getValue(),a=e.offset,i=e.getType();if(s[a+0]!==n.x||s[a+1]!==n.y||s[a+2]!==n.z){let o=this._getBufferForType(i);o[a+0]=s[a+0]=n.x,o[a+1]=s[a+1]=n.y,o[a+2]=s[a+2]=n.z,t=!0,this.addUniformUpdateRange(e)}return t}updateVector4(e){let t=!1,s=this.values,n=e.getValue(),a=e.offset,i=e.getType();if(s[a+0]!==n.x||s[a+1]!==n.y||s[a+2]!==n.z||s[a+3]!==n.w){let o=this._getBufferForType(i);o[a+0]=s[a+0]=n.x,o[a+1]=s[a+1]=n.y,o[a+2]=s[a+2]=n.z,o[a+3]=s[a+3]=n.w,t=!0,this.addUniformUpdateRange(e)}return t}updateColor(e){let t=!1,s=this.values,n=e.getValue(),a=e.offset;if(s[a+0]!==n.r||s[a+1]!==n.g||s[a+2]!==n.b){let i=this.buffer;i[a+0]=s[a+0]=n.r,i[a+1]=s[a+1]=n.g,i[a+2]=s[a+2]=n.b,t=!0,this.addUniformUpdateRange(e)}return t}updateMatrix3(e){let t=!1,s=this.values,n=e.getValue().elements,a=e.offset;if(s[a+0]!==n[0]||s[a+1]!==n[1]||s[a+2]!==n[2]||s[a+4]!==n[3]||s[a+5]!==n[4]||s[a+6]!==n[5]||s[a+8]!==n[6]||s[a+9]!==n[7]||s[a+10]!==n[8]){let i=this.buffer;i[a+0]=s[a+0]=n[0],i[a+1]=s[a+1]=n[1],i[a+2]=s[a+2]=n[2],i[a+4]=s[a+4]=n[3],i[a+5]=s[a+5]=n[4],i[a+6]=s[a+6]=n[5],i[a+8]=s[a+8]=n[6],i[a+9]=s[a+9]=n[7],i[a+10]=s[a+10]=n[8],t=!0,this.addUniformUpdateRange(e)}return t}updateMatrix4(e){let t=!1,s=this.values,n=e.getValue().elements,a=e.offset;return bH(s,n,a)===!1&&(this.buffer.set(n,a),mH(s,n,a),t=!0,this.addUniformUpdateRange(e)),t}_getBufferForType(e){return e==="int"||e==="ivec2"||e==="ivec3"||e==="ivec4"?new Int32Array(this.buffer.buffer):e==="uint"||e==="uvec2"||e==="uvec3"||e==="uvec4"?new Uint32Array(this.buffer.buffer):this.buffer}};function mH(r,e,t){for(let s=0,n=e.length;s<n;s++)r[t+s]=e[s]}function bH(r,e,t){for(let s=0,n=e.length;s<n;s++)if(r[t+s]!==e[s])return!1;return!0}var gH=0,uT=class extends gS{constructor(e,t){super(e),this.id=gH++,this.groupNode=t,this.isNodeUniformsGroup=!0}},dT=class extends oT{constructor(e,t){super(e),this._texture=t,this.version=-1,this.generation=null,this.samplerKey="",this.isSampler=!0}set texture(e){this._texture!==e&&(this._texture=e,this.reset())}get texture(){return this._texture}update(){let{texture:e,version:t}=this;return t!==e.version?(this.version=e.version,!0):!1}reset(){this.generation=null,this.version=-1}release(){this._texture=null}},yH=0,yS=class extends dT{constructor(e,t){super(e,t),this.id=yH++,this.store=!1,this.mipLevel=0,this.isSampledTexture=!0}},qd=class extends yS{constructor(e,t,s,n=null){super(e,t?t.value:null),this.textureNode=t,this.groupNode=s,this.access=n}update(){let{textureNode:e}=this;return this.texture!==e.value?(this.texture=e.value,!0):super.update()}},fT=class extends qd{constructor(e,t,s,n=null){super(e,t,s,n),this.isSampledCubeTexture=!0}},fb=class extends qd{constructor(e,t,s,n=null){super(e,t,s,n),this.isSampledTexture3D=!0}},Xk={textureGather:new mt(`
vec4 tsl_textureGather( const int comp, sampler2D map, vec2 coord, ivec2 offset, bool flipY ) {
	if ( flipY ) offset.y = - offset.y;
	vec2 size = vec2( textureSize( map, 0 ) );
	vec2 st = floor( coord * size + vec2( offset ) - 0.5 );
	vec4 ij = vec4( st + 0.5, st + 1.5 ) / size.xyxy;
	vec4 ret = vec4(
		textureLod( map, ij.xw, 0.0 )[ comp ],
		textureLod( map, ij.zw, 0.0 )[ comp ],
		textureLod( map, ij.zy, 0.0 )[ comp ],
		textureLod( map, ij.xy, 0.0 )[ comp ]
	);
	return flipY ? ret.wzyx : ret;
}
`),textureGatherArray:new mt(`
vec4 tsl_textureGather_array( const int comp, sampler2DArray map, vec3 coord, ivec2 offset, bool flipY ) {
	if ( flipY ) offset.y = - offset.y;
	vec2 size = vec2( textureSize( map, 0 ).xy );
	vec2 st = floor( coord.xy * size + vec2( offset ) - 0.5 );
	vec4 ij = vec4( st + 0.5, st + 1.5 ) / size.xyxy;
	vec4 ret = vec4(
		textureLod( map, vec3( ij.xw, coord.z ), 0.0 )[ comp ],
		textureLod( map, vec3( ij.zw, coord.z ), 0.0 )[ comp ],
		textureLod( map, vec3( ij.zy, coord.z ), 0.0 )[ comp ],
		textureLod( map, vec3( ij.xy, coord.z ), 0.0 )[ comp ]
	);
	return flipY ? ret.wzyx : ret;
}
`),textureGatherCompare:new mt(`
vec4 tsl_textureGatherCompare( sampler2DShadow map, vec2 coord, ivec2 offset, float ref, bool flipY ) {
	if ( flipY ) offset.y = - offset.y;
	vec2 size = vec2( textureSize( map, 0 ) );
	vec2 st = floor( coord * size + vec2( offset ) - 0.5 );
	vec4 ij = vec4( st + 0.5, st + 1.5 ) / size.xyxy;
	vec4 ret = vec4(
		textureLod( map, vec3( ij.xw, ref ), 0.0 ),
		textureLod( map, vec3( ij.zw, ref ), 0.0 ),
		textureLod( map, vec3( ij.zy, ref ), 0.0 ),
		textureLod( map, vec3( ij.xy, ref ), 0.0 )
	);
	return flipY ? ret.wzyx : ret;
}
`),textureGatherCompareArray:new mt(`
vec4 tsl_textureGatherCompare_array( sampler2DArrayShadow map, vec3 coord, ivec2 offset, float ref, bool flipY ) {
	if ( flipY ) offset.y = - offset.y;
	vec2 size = vec2( textureSize( map, 0 ).xy );
	vec2 st = floor( coord.xy * size + vec2( offset ) - 0.5 );
	vec4 ij = vec4( st + 0.5, st + 1.5 ) / size.xyxy;
	vec4 ret = vec4(
		texture( map, vec4( ij.xw, coord.z, ref ) ),
		texture( map, vec4( ij.zw, coord.z, ref ) ),
		texture( map, vec4( ij.zy, coord.z, ref ) ),
		texture( map, vec4( ij.xy, coord.z, ref ) )
	);
	return flipY ? ret.wzyx : ret;
}
`),floatpack_snorm_4x8:new mt("uint tsl_packSnorm4x8( vec4 v ) { uvec4 u = uvec4( ivec4( round( clamp( v, -1.0, 1.0 ) * 127.0 ) ) & 0xff ); return u.x | u.y << 8 | u.z << 16 | u.w << 24; }"),floatpack_unorm_4x8:new mt("uint tsl_packUnorm4x8( vec4 v ) { uvec4 u = uvec4( round( clamp( v, 0.0, 1.0 ) * 255.0 ) ); return u.x | u.y << 8 | u.z << 16 | u.w << 24; }"),floatunpack_snorm_4x8:new mt("vec4 tsl_unpackSnorm4x8( uint x ) { return max( vec4( ivec4( x << 24, x << 16, x << 8, x ) >> 24 ) / 127.0, -1.0 ); }"),floatunpack_unorm_4x8:new mt("vec4 tsl_unpackUnorm4x8( uint x ) { return vec4( uvec4( x, x >> 8, x >> 16, x >> 24 ) & 0xffu ) / 255.0; }")},xH={equals:"equal",bitcast_float_int:"floatBitsToInt",bitcast_int_float:"intBitsToFloat",bitcast_uint_float:"uintBitsToFloat",bitcast_float_uint:"floatBitsToUint",floatpack_snorm_2x16:"packSnorm2x16",floatpack_unorm_2x16:"packUnorm2x16",floatpack_float16_2x16:"packHalf2x16",floatpack_snorm_4x8:"tsl_packSnorm4x8",floatpack_unorm_4x8:"tsl_packUnorm4x8",floatunpack_snorm_2x16:"unpackSnorm2x16",floatunpack_unorm_2x16:"unpackUnorm2x16",floatunpack_float16_2x16:"unpackHalf2x16",floatunpack_snorm_4x8:"tsl_unpackSnorm4x8",floatunpack_unorm_4x8:"tsl_unpackUnorm4x8"},Kk={low:"lowp",medium:"mediump",high:"highp"},Jk={swizzleAssign:!0,storageBuffer:!1},$k={perspective:"smooth",linear:"noperspective"},Yk={centroid:"centroid"},Zk=`
precision highp float;
precision highp int;
precision highp sampler2D;
precision highp sampler3D;
precision highp samplerCube;
precision highp sampler2DArray;

precision highp usampler2D;
precision highp usampler3D;
precision highp usamplerCube;
precision highp usampler2DArray;

precision highp isampler2D;
precision highp isampler3D;
precision highp isamplerCube;
precision highp isampler2DArray;

precision highp sampler2DShadow;
precision highp sampler2DArrayShadow;
precision highp samplerCubeShadow;
`,wH=new Set(["const","uniform","buffer","shared","attribute","varying","coherent","volatile","restrict","readonly","writeonly","atomic_uint","layout","centroid","flat","smooth","noperspective","patch","sample","invariant","precise","break","continue","do","for","while","switch","case","default","if","else","subroutine","in","out","inout","int","void","bool","true","false","float","double","discard","return","vec2","vec3","vec4","ivec2","ivec3","ivec4","bvec2","bvec3","bvec4","uint","uvec2","uvec3","uvec4","dvec2","dvec3","dvec4","mat2","mat3","mat4","mat2x2","mat2x3","mat2x4","mat3x2","mat3x3","mat3x4","mat4x2","mat4x3","mat4x4","dmat2","dmat3","dmat4","dmat2x2","dmat2x3","dmat2x4","dmat3x2","dmat3x3","dmat3x4","dmat4x2","dmat4x3","dmat4x4","lowp","mediump","highp","precision","sampler2D","sampler3D","samplerCube","sampler2DShadow","samplerCubeShadow","sampler2DArray","sampler2DArrayShadow","isampler2D","isampler3D","isamplerCube","isampler2DArray","usampler2D","usampler3D","usamplerCube","usampler2DArray","struct","common","partition","active","asm","class","union","enum","typedef","template","this","resource","goto","inline","noinline","public","static","extern","external","interface","long","short","half","fixed","unsigned","superp","input","output","hvec2","hvec3","hvec4","fvec2","fvec3","fvec4","sampler3DRect","filter","sizeof","cast","namespace","using","main"]),pT=class extends sb{constructor(e,t){super(e,t,new sT),this.uniformGroups={},this.transforms=[],this.extensions={},this.builtins={vertex:[],fragment:[],compute:[]}}needsToWorkingColorSpace(e){return e.isVideoTexture===!0&&e.colorSpace!==qi}_include(e){let t=Xk[e];return t.build(this),this.addInclude(t),t}getMethod(e){return Xk[e]!==void 0&&this._include(e),xH[e]||e}getBitcastMethod(e,t){let s=this.getComponentType(t),n=this.getComponentType(e);return s!=="float"&&n!=="float"&&this.getTypeLength(t)===this.getTypeLength(e)?this.getType(e):this.getMethod(`bitcast_${s}_${n}`)}getFloatPackingMethod(e,t="2x16"){return this.getMethod(`floatpack_${e}_${t}`)}getFloatUnpackingMethod(e,t="2x16"){return this.getMethod(`floatunpack_${e}_${t}`)}getTernary(e,t,s){return`${e} ? ${t} : ${s}`}getOutputStructName(){return""}buildFunctionCode(e){let t=e.layout,s=this.flowShaderNode(e),n=[];for(let i of t.inputs)n.push(this.getType(i.type)+" "+i.name);return`${this.getType(t.type)} ${t.name}( ${n.join(", ")} ) {

	${s.vars}

${s.code}
	return ${s.result};

}`}setupPBO(e){let t=e.value;if(t.pbo===void 0){let s=t.array,n=t.count*t.itemSize,{itemSize:a}=t,i=t.array.constructor.name.toLowerCase().includes("int"),o=i?zr:Lr;a===2?o=i?Do:cn:a===3?o=i?jp:Po:a===4&&(o=i?Nu:gs);let c={Float32Array:Mt,Uint8Array:ws,Uint16Array:ka,Uint32Array:St,Int8Array:Ur,Int16Array:pi,Int32Array:Ts,Uint8ClampedArray:ws},l=Math.pow(2,Math.ceil(Math.log2(Math.sqrt(n/a)))),h=Math.ceil(n/a/l);l*h*a<n&&h++;let u=l*h*a,d=new s.constructor(u);d.set(s,0),t.array=d;let f=new Is(t.array,l,h,o,c[t.array.constructor.name]||Mt);f.needsUpdate=!0,f.isPBOTexture=!0;let p=new ba(f,null,null);p.setPrecision("high"),t.pboNode=p,t.pbo=p.value,this.getUniformFromNode(t.pboNode,"texture",this.shaderStage,this.context.nodeName)}}getPropertyName(e,t=this.shaderStage){return e.isNodeUniform&&e.node.isTextureNode!==!0&&e.node.isBufferNode!==!0?e.name:super.getPropertyName(e,t)}isReservedKeyword(e){return wH.has(e)}generatePBO(e){let{node:t,indexNode:s}=e,n=t.value;if(this.renderer.backend.has(n)){let h=this.renderer.backend.get(n);h.pbo=n.pbo}let a=this.getUniformFromNode(n.pboNode,"texture",this.shaderStage,this.context.nodeName),i=this.getPropertyName(a);this.increaseUsage(s);let o=s.build(this,"uint"),c=this.getDataFromNode(e),l=c.propertyName;if(l===void 0){let h=this.getVarFromNode(e);l=this.getPropertyName(h);let u=this.getDataFromNode(t),d=u.propertySizeName;d===void 0&&(d=l+"Size",this.getVarFromNode(t,d,"uint"),this.addLineFlowCode(`${d} = uint( textureSize( ${i}, 0 ).x )`,e),u.propertySizeName=d);let{itemSize:f}=n,p="."+pc.join("").slice(0,f),m=`ivec2(${o} % ${d}, ${o} / ${d})`,b=this.generateTextureLoad(null,i,m,"0",null,null),g="vec4";n.pbo.type===St?g="uvec4":n.pbo.type===Ts&&(g="ivec4"),this.addLineFlowCode(`${l} = ${g}(${b})${p}`,e),c.propertyName=l}return l}generateTextureLoad(e,t,s,n,a,i){n===null&&(n="0");let o;return a?i?o=`texelFetchOffset( ${t}, ivec3( ${s}, ${a} ), int( ${n} ), ${i} )`:o=`texelFetch( ${t}, ivec3( ${s}, ${a} ), int( ${n} ) )`:i?o=`texelFetchOffset( ${t}, ${s}, int( ${n} ), ${i} )`:o=`texelFetch( ${t}, ${s}, int( ${n} ) )`,e!==null&&e.isDepthTexture&&(o+=".x"),o}generateTexture(e,t,s,n,a){return n&&(s=`vec3( ${s}, ${n} )`),e.isDepthTexture?a?`textureOffset( ${t}, ${s}, ${a} ).x`:`texture( ${t}, ${s} ).x`:a?`textureOffset( ${t}, ${s}, ${a} )`:`texture( ${t}, ${s} )`}generateTextureSize(e,t,s){return`textureSize( ${t}, ${s} )`}generateTextureLevel(e,t,s,n,a,i){return a&&(s=`vec3( ${s}, ${a} )`),i?`textureLodOffset( ${t}, ${s}, ${n}, ${i} )`:`textureLod( ${t}, ${s}, ${n} )`}generateTextureBias(e,t,s,n,a,i){return a&&(s=`vec3( ${s}, ${a} )`),i?`textureOffset( ${t}, ${s}, ${i}, ${n} )`:`texture( ${t}, ${s}, ${n} )`}generateTextureGrad(e,t,s,n,a,i){return a&&(s=`vec3( ${s}, ${a} )`),i?`textureGradOffset( ${t}, ${s}, ${n[0]}, ${n[1]}, ${i} )`:`textureGrad( ${t}, ${s}, ${n[0]}, ${n[1]} )`}generateTextureCompare(e,t,s,n,a,i,o=this.shaderStage){if(o==="fragment")return e.isCubeTexture?`texture( ${t}, vec4( ${s}, ${n} ) )`:a?i?`textureOffset( ${t}, vec4( ${s}, ${a}, ${n} ), ${i} )`:`texture( ${t}, vec4( ${s}, ${a}, ${n} ) )`:i?`textureOffset( ${t}, vec3( ${s}, ${n} ), ${i} )`:`texture( ${t}, vec3( ${s}, ${n} ) )`;W(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${o} shader.`)}generateTextureGather(e,t,s,n,a,i,o){return e.isDepthTexture&&(n="0"),i===null&&(i="ivec2( 0 )"),o===null&&(o="false"),a?(this._include("textureGatherArray"),`tsl_textureGather_array( ${n}, ${t}, vec3( ${s}, ${a} ), ${i}, ${o} )`):(this._include("textureGather"),`tsl_textureGather( ${n}, ${t}, ${s}, ${i}, ${o} )`)}generateTextureGatherCompare(e,t,s,n,a,i,o){return i===null&&(i="ivec2( 0 )"),o===null&&(o="false"),a?(this._include("textureGatherCompareArray"),`tsl_textureGatherCompare_array( ${t}, vec3( ${s}, ${a} ), ${i}, ${n}, ${o} )`):(this._include("textureGatherCompare"),`tsl_textureGatherCompare( ${t}, ${s}, ${i}, ${n}, ${o} )`)}getUniforms(e){let t=this.uniforms[e],s=[],n={};for(let i of t){let o=null,c=!1;if(i.type==="texture"||i.type==="texture3D"){let l=i.node,h=l.value,u=this.getComponentTypeFromTexture(h),d=u==="float"?"":u.charAt(0);i.type==="texture3D"&&h.isArrayTexture===!1?o=`${d}sampler3D ${i.name};`:h.compareFunction&&l.isSampleCompare()?h.isArrayTexture===!0?o=`sampler2DArrayShadow ${i.name};`:o=`sampler2DShadow ${i.name};`:h.isArrayTexture===!0||h.isDataArrayTexture===!0||h.isCompressedArrayTexture===!0?o=`${d}sampler2DArray ${i.name};`:o=`${d}sampler2D ${i.name};`}else if(i.type==="cubeTexture")o=`samplerCube ${i.name};`;else if(i.type==="cubeDepthTexture")i.node.value.compareFunction?o=`samplerCubeShadow ${i.name};`:o=`samplerCube ${i.name};`;else if(i.type==="buffer"){let l=i.node,h=this.getType(l.bufferType),u=l.bufferCount,d=u>0?u:"";o=`${l.name} {
	${h} ${i.name}[${d}];
};
`}else{let l=i.groupNode.name;if(n[l]===void 0){let h=this.uniformGroups[l];if(h!==void 0){let u=[];for(let d of h.uniforms){let f=d.getType(),p=this.getVectorType(f),m=d.nodeUniform.node.precision,b=`${p} ${d.name};`;m!==null&&(b=Kk[m]+" "+b),u.push("	"+b)}n[l]=u}}c=!0}if(!c){let l=i.node.precision;l!==null&&(o=Kk[l]+" "+o),o="uniform "+o,s.push(o)}}let a="";for(let i in n){let o=n[i];a+=this._getGLSLUniformStruct(i,o.join(`
`))+`
`}return a+=s.join(`
`),a}getTypeFromAttribute(e){let t=super.getTypeFromAttribute(e);if(/^[iu]/.test(t)&&e.gpuType!==Ts){let s=e;e.isInterleavedBufferAttribute&&(s=e.data);let n=s.array;n instanceof Uint32Array||n instanceof Int32Array||(t=t.slice(1))}return t}getAttributes(e){let t="";if(e==="vertex"||e==="compute"){let s=this.getAttributesArray(),n=0;for(let a of s)t+=`layout( location = ${n++} ) in ${a.type} ${a.name};
`}return t}getStructMembers(e){let t=[];for(let s of e.members)t.push(`	${s.type} ${s.name};`);return t.join(`
`)}getStructs(e){let t=[],s=this.structs[e],n=[];for(let a of s)if(a.output)for(let i of a.members)n.push(`layout( location = ${i.index} ) out ${i.type} ${i.name};`);else{let i="struct "+a.name+` {
`;i+=this.getStructMembers(a),i+=`
};
`,t.push(i)}return e==="fragment"&&n.length===0&&n.push(`layout( location = 0 ) out ${this.getOutputType()} fragColor;`),`
`+n.join(`
`)+`

`+t.join(`
`)}getVaryings(e){let t="",s=this.varyings;if(e==="vertex"||e==="compute")for(let n of s){e==="compute"&&(n.needsInterpolation=!0);let a=this.getType(n.type);if(n.needsInterpolation)if(n.interpolationType){let i=$k[n.interpolationType]||n.interpolationType,o=Yk[n.interpolationSampling]||"";t+=`${i} ${o} out ${a} ${n.name};
`}else{let i=a.includes("int")||a.includes("uv")||a.includes("iv")?"flat ":"";t+=`${i}out ${a} ${n.name};
`}else t+=`${a} ${n.name};
`}else if(e==="fragment"){for(let n of s)if(n.needsInterpolation){let a=this.getType(n.type);if(n.interpolationType){let i=$k[n.interpolationType]||n.interpolationType,o=Yk[n.interpolationSampling]||"";t+=`${i} ${o} in ${a} ${n.name};
`}else{let i=a.includes("int")||a.includes("uv")||a.includes("iv")?"flat ":"";t+=`${i}in ${a} ${n.name};
`}}}for(let n of this.builtins[e])t+=`${n};
`;return t}getVertexIndex(){return"uint( gl_VertexID )"}getInstanceIndex(){return"uint( gl_InstanceID )"}getInvocationLocalIndex(){return`uint( gl_InstanceID ) % ${this.compute.workgroupSize.reduce((s,n)=>s*n,1)}u`}getSubgroupSize(){W("GLSLNodeBuilder: WebGLBackend does not support the subgroupSize node")}getInvocationSubgroupIndex(){W("GLSLNodeBuilder: WebGLBackend does not support the invocationSubgroupIndex node")}getSubgroupIndex(){W("GLSLNodeBuilder: WebGLBackend does not support the subgroupIndex node")}getDrawIndex(){return this.renderer.backend.extensions.has("WEBGL_multi_draw")?"uint( gl_DrawID )":"nodeUniformDrawId"}getFrontFacing(){return"gl_FrontFacing"}getFragCoord(){return"gl_FragCoord.xy"}getFragDepth(){return"gl_FragDepth"}enableExtension(e,t,s=this.shaderStage){let n=this.extensions[s]||(this.extensions[s]=new Map);n.has(e)===!1&&n.set(e,{name:e,behavior:t})}getExtensions(e){let t=[];if(e==="vertex"){let n=this.renderer.backend.extensions;this.object.isBatchedMesh&&n.has("WEBGL_multi_draw")&&this.enableExtension("GL_ANGLE_multi_draw","require",e)}let s=this.extensions[e];if(s!==void 0)for(let{name:n,behavior:a}of s.values())t.push(`#extension ${n} : ${a}`);return t.join(`
`)}getClipDistance(){return"gl_ClipDistance"}isAvailable(e){let t=Jk[e];if(t===void 0){let s;switch(t=!1,e){case"float32Filterable":s="OES_texture_float_linear";break;case"clipDistance":s="WEBGL_clip_cull_distance";break}if(s!==void 0){let n=this.renderer.backend.extensions;n.has(s)&&(n.get(s),t=!0)}Jk[e]=t}return t}isFlipY(){return!0}enableHardwareClipping(e){this.enableExtension("GL_ANGLE_clip_cull_distance","require"),this.builtins.vertex.push(`out float gl_ClipDistance[ ${e} ]`)}enableMultiview(){this.enableExtension("GL_OVR_multiview2","require","fragment"),this.enableExtension("GL_OVR_multiview2","require","vertex"),this.builtins.vertex.push("layout(num_views = 2) in")}registerTransform(e,t){this.transforms.push({varyingName:e,attributeNode:t})}getTransforms(){let e=this.transforms,t="";for(let s=0;s<e.length;s++){let n=e[s],a=this.getPropertyName(n.attributeNode);a&&(t+=`${n.varyingName} = ${a};
	`)}return t}_getGLSLUniformStruct(e,t){return`
layout( std140 ) uniform ${e} {
${t}
};`}_getGLSLVertexCode(e){return`#version 300 es

${this.getSignature()}

// extensions
${e.extensions}

// precision
${Zk}

// structs
${e.structs}

// uniforms
${e.uniforms}

// varyings
${e.varyings}

// attributes
${e.attributes}

// vars
${e.vars}

// codes
${e.codes}

void main() {

	// transforms
	${e.transforms}

	// flow
	${e.flow}

	gl_PointSize = 1.0;

}
`}_getGLSLFragmentCode(e){return`#version 300 es

${this.getSignature()}

// extensions
${e.extensions}

// precision
${Zk}

// structs
${e.structs}

// uniforms
${e.uniforms}

// varyings
${e.varyings}

// vars
${e.vars}

// codes
${e.codes}

void main() {

	// flow
	${e.flow}

}
`}buildCode(){let e=this.material!==null?{fragment:{},vertex:{}}:{compute:{}};this.sortBindingGroups();for(let t in e){let s=`// code

`;s+=this.flowCode[t];let n=this.flowNodes[t],a=n[n.length-1];for(let o of n){let c=this.getFlowData(o),l=o.name;l&&(s.length>0&&(s+=`
`),s+=`	// flow -> ${l}
	`),s+=`${c.code}
	`,o===a&&t!=="compute"&&(s+=`// result
	`,t==="vertex"?(s+="gl_Position = ",s+=`${this.format(c.result,a.getNodeType(this),"vec4")};`):t==="fragment"&&(o.outputNode.isOutputStructNode||(s+="fragColor = ",s+=`${this.format(c.result,a.getNodeType(this),this.getOutputType())};`)))}let i=e[t];if(i.extensions=this.getExtensions(t),i.uniforms=this.getUniforms(t),i.attributes=this.getAttributes(t),i.varyings=this.getVaryings(t),i.vars=this.getVars(t,!0),i.structs=this.getStructs(t),i.codes=this.getCodes(t),i.transforms=this.getTransforms(t),i.flow=s,t==="vertex"){let o=this.renderer.backend.extensions;this.object.isBatchedMesh&&o.has("WEBGL_multi_draw")===!1&&(i.uniforms+=`
uniform uint nodeUniformDrawId;
`)}}this.material!==null?(this.vertexShader=this._getGLSLVertexCode(e.vertex),this.fragmentShader=this._getGLSLFragmentCode(e.fragment)):this.computeShader=this._getGLSLVertexCode(e.compute)}getUniformFromNode(e,t,s,n=null){let a=super.getUniformFromNode(e,t,s,n),i=this.getDataFromNode(e,s,this.globalCache),o=i.uniformGPU;if(o===void 0){let c=e.groupNode,l=c.name,h=this.getBindGroupArray(l,s);if(t==="texture")o=new qd(a.name,a.node,c),h.push(o);else if(t==="cubeTexture"||t==="cubeDepthTexture")o=new fT(a.name,a.node,c),h.push(o);else if(t==="texture3D")o=new fb(a.name,a.node,c),h.push(o);else if(t==="buffer"){a.name=`buffer${e.id}`;let u=this.getSharedDataFromNode(e),d=u.buffer;d===void 0&&(e.name=`NodeBuffer_${e.id}`,d=new hT(e,c),d.name=e.name,u.buffer=d),h.push(d),o=d}else{let u=this.uniformGroups[l];u===void 0?(u=new uT(l,c),this.uniformGroups[l]=u,h.push(u)):h.indexOf(u)===-1&&h.push(u),o=this.getNodeUniform(a,t);let d=o.name;u.uniforms.some(p=>p.name===d)||u.addUniform(o)}i.uniformGPU=o}return a}},LA=null,cd=null,pb=class{constructor(e={}){this.parameters=Object.assign({},e),this.data=new WeakMap,this.renderer=null,this.domElement=null,this.timestampQueryPool={[Ia.RENDER]:null,[Ia.COMPUTE]:null},this.trackTimestamp=e.trackTimestamp===!0}async init(e){this.renderer=e}get coordinateSystem(){}beginRender(){}finishRender(){}setXRTarget(){}beginCompute(){}finishCompute(){}draw(){}compute(){}createProgram(){}destroyProgram(){}createBindings(){}updateBindings(){}updateBinding(){}createRenderPipeline(){}createComputePipeline(){}needsRenderUpdate(){}getRenderCacheKey(){}createNodeBuilder(){}updateSampler(){}destroySampler(){}createDefaultTexture(){}createTexture(){}updateTexture(){}generateMipmaps(){}destroyTexture(){}async copyTextureToBuffer(){}copyTextureToTexture(){}copyFramebufferToTexture(){}createAttribute(){}createIndexAttribute(){}createStorageAttribute(){}createUniformBuffer(){}destroyUniformBuffer(){}updateAttribute(){}destroyAttribute(){}getContext(){}updateSize(){}updateViewport(){}updateTimeStampUID(e){let t=this.get(e),s=this.renderer.info.frame,n,a=e.id;Array.isArray(e)?(a=e.map(i=>i.id).join(","),n="c:"+this.renderer.info.compute.frameCalls):e.isComputeNode===!0?n="c:"+this.renderer.info.compute.frameCalls:n="r:"+this.renderer.info.render.frameCalls,t.timestampUID=n+":"+a+":f"+s}getTimestampUID(e){return this.get(e).timestampUID}getTimestampFrames(e){let t=this.timestampQueryPool[e];return t?t.getTimestampFrames():[]}_getQueryPool(e){let t=e.startsWith("c:")?Ia.COMPUTE:Ia.RENDER;return this.timestampQueryPool[t]}getTimestamp(e){return this._getQueryPool(e).getTimestamp(e)}get hasTimestamp(){return!1}hasTimestampQuery(e){return this._getQueryPool(e).hasTimestampQuery(e)}isOccluded(){}async resolveTimestampsAsync(e="render"){if(!this.trackTimestamp){je("WebGPURenderer: Timestamp tracking is disabled.");return}let t=this.timestampQueryPool[e];if(!t)return;let s=await t.resolveQueriesAsync();return this.renderer.info[e].timestamp=s,s}async getArrayBufferAsync(){}async hasFeatureAsync(){}hasFeature(){}getDrawingBufferSize(){return LA=LA||new q,this.renderer.getDrawingBufferSize(LA)}setScissorTest(){}resetState(){}getClearColor(){let e=this.renderer;return cd=cd||new jd,e.getClearColor(cd),cd.getRGB(cd),cd}getDomElement(){let e=this.domElement;return e===null&&(e=this.parameters.canvas!==void 0?this.parameters.canvas:oA(),"setAttribute"in e&&e.setAttribute("data-engine",`three.js r${"186"} webgpu`),this.domElement=e),e}hasCompatibility(){return!1}initRenderTarget(){}set(e,t){this.data.set(e,t)}get(e){let t=this.data.get(e);return t===void 0&&(t={},this.data.set(e,t)),t}has(e){return this.data.has(e)}delete(e){this.data.delete(e)}deleteBindGroupData(){}async dispose(){for(let e of Object.values(this.timestampQueryPool))e!==null&&await e.dispose()}},TH=0,xS=class{constructor(e,t){this.buffers=[e.bufferGPU,t],this.type=e.type,this.bufferType=e.bufferType,this.pbo=e.pbo,this.byteLength=e.byteLength,this.bytesPerElement=e.BYTES_PER_ELEMENT,this.version=e.version,this.isInteger=e.isInteger,this.activeBufferIndex=0,this.baseId=e.id}get id(){return`${this.baseId}|${this.activeBufferIndex}`}get bufferGPU(){return this.buffers[this.activeBufferIndex]}get transformBuffer(){return this.buffers[this.activeBufferIndex^1]}switchBuffers(){this.activeBufferIndex^=1}},wS=class{constructor(e){this.backend=e}createAttribute(e,t){let s=this.backend,{gl:n}=s,a=e.array,i=e.usage||n.STATIC_DRAW,o=e.isInterleavedBufferAttribute?e.data:e,c=s.get(o),l=c.bufferGPU;l===void 0&&(l=this._createBuffer(n,t,a,i),c.bufferGPU=l,c.bufferType=t,c.version=o.version);let h;if(a instanceof Float32Array)h=n.FLOAT;else if(typeof Float16Array<"u"&&a instanceof Float16Array)h=n.HALF_FLOAT;else if(a instanceof Uint16Array)e.isFloat16BufferAttribute?h=n.HALF_FLOAT:h=n.UNSIGNED_SHORT;else if(a instanceof Int16Array)h=n.SHORT;else if(a instanceof Uint32Array)h=n.UNSIGNED_INT;else if(a instanceof Int32Array)h=n.INT;else if(a instanceof Int8Array)h=n.BYTE;else if(a instanceof Uint8Array)h=n.UNSIGNED_BYTE;else if(a instanceof Uint8ClampedArray)h=n.UNSIGNED_BYTE;else throw new Error("THREE.WebGLBackend: Unsupported buffer data format: "+a);let u={bufferGPU:l,bufferType:t,type:h,byteLength:a.byteLength,bytesPerElement:a.BYTES_PER_ELEMENT,version:e.version,pbo:e.pbo,isInteger:h===n.INT||h===n.UNSIGNED_INT||e.gpuType===Ts,id:TH++};if(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute){let d=this._createBuffer(n,t,a,i);u=new xS(u,d)}s.set(e,u)}updateAttribute(e){let t=this.backend,{gl:s}=t,n=e.array,a=e.isInterleavedBufferAttribute?e.data:e,i=t.get(a),o=i.bufferType,c=e.isInterleavedBufferAttribute?e.data.updateRanges:e.updateRanges;if(s.bindBuffer(o,i.bufferGPU),c.length===0)s.bufferSubData(o,0,n);else{for(let l=0,h=c.length;l<h;l++){let u=c[l];s.bufferSubData(o,u.start*n.BYTES_PER_ELEMENT,n,u.start,u.count)}a.clearUpdateRanges()}s.bindBuffer(o,null),i.version=a.version}destroyAttribute(e){let t=this.backend,{gl:s}=t;e.isInterleavedBufferAttribute&&t.delete(e.data);let n=t.get(e);s.deleteBuffer(n.bufferGPU),t.delete(e)}async getArrayBufferAsync(e,t=null,s=0,n=-1){let a=this.backend,{gl:i}=a,o=e.isInterleavedBufferAttribute?e.data:e,c=a.get(o),{bufferGPU:l}=c,h=n===-1?c.byteLength-s:n,u;if(t===null)u=new Uint8Array(new ArrayBuffer(h));else if(t.isReadbackBuffer){if(t._mapped===!0)throw new Error("THREE.WebGPURenderer: ReadbackBuffer must be released before being used again.");let d=()=>{t.buffer=null,t._mapped=!1,t.removeEventListener("release",d),t.removeEventListener("dispose",d)};t.addEventListener("release",d),t.addEventListener("dispose",d),u=new Uint8Array(new ArrayBuffer(h)),t.buffer=u.buffer}else u=new Uint8Array(t);return i.bindBuffer(i.COPY_READ_BUFFER,l),i.getBufferSubData(i.COPY_READ_BUFFER,s,u),i.bindBuffer(i.COPY_READ_BUFFER,null),i.bindBuffer(i.COPY_WRITE_BUFFER,null),t&&t.isReadbackBuffer?t:u.buffer}_createBuffer(e,t,s,n){let a=e.createBuffer();return e.bindBuffer(t,a),e.bufferData(t,s,n),e.bindBuffer(t,null),a}},cm,Xr,TS=class{constructor(e){this.backend=e,this.gl=this.backend.gl,this.enabled={},this.parameters={},this.currentFlipSided=null,this.currentCullFace=null,this.currentProgram=null,this.currentBlendingEnabled=!1,this.currentBlending=null,this.currentBlendEquation=null,this.currentBlendEquationAlpha=null,this.currentBlendSrc=null,this.currentBlendDst=null,this.currentBlendSrcAlpha=null,this.currentBlendDstAlpha=null,this.currentBlendColor=new be(0,0,0),this.currentBlendAlpha=0,this.currentPremultipledAlpha=null,this.currentPolygonOffsetFactor=null,this.currentPolygonOffsetUnits=null,this.currentColorMask=null,this.currentDepthReversed=!1,this.currentDepthFunc=null,this.currentDepthMask=null,this.currentStencilFunc=null,this.currentStencilRef=null,this.currentStencilFuncMask=null,this.currentStencilFail=null,this.currentStencilZFail=null,this.currentStencilZPass=null,this.currentStencilMask=null,this.currentLineWidth=null,this.currentClippingPlanes=0,this.currentVAO=null,this.currentIndex=null,this.currentBoundFramebuffers={},this.currentDrawbuffers=new WeakMap,this.maxTextures=this.gl.getParameter(this.gl.MAX_TEXTURE_IMAGE_UNITS),this.currentTextureSlot=null,this.currentBoundTextures={},this.currentBoundBufferBases={},this._init()}_init(){let e=this.gl;cm={[sa]:e.FUNC_ADD,[Xy]:e.FUNC_SUBTRACT,[Ky]:e.FUNC_REVERSE_SUBTRACT,[Jy]:e.MIN,[$y]:e.MAX},Xr={[Gi]:e.ZERO,[Yy]:e.ONE,[Zy]:e.SRC_COLOR,[yu]:e.SRC_ALPHA,[ax]:e.SRC_ALPHA_SATURATE,[sx]:e.DST_COLOR,[ex]:e.DST_ALPHA,[Qy]:e.ONE_MINUS_SRC_COLOR,[xu]:e.ONE_MINUS_SRC_ALPHA,[nx]:e.ONE_MINUS_DST_COLOR,[tx]:e.ONE_MINUS_DST_ALPHA,[ix]:e.CONSTANT_COLOR,[rx]:e.ONE_MINUS_CONSTANT_COLOR,[ox]:e.CONSTANT_ALPHA,[cx]:e.ONE_MINUS_CONSTANT_ALPHA};let t=e.getParameter(e.SCISSOR_BOX),s=e.getParameter(e.VIEWPORT);this.currentScissor=new Ge().fromArray(t),this.currentViewport=new Ge().fromArray(s),this._tempVec4=new Ge}enable(e){let{enabled:t}=this;t[e]!==!0&&(this.gl.enable(e),t[e]=!0)}disable(e){let{enabled:t}=this;t[e]!==!1&&(this.gl.disable(e),t[e]=!1)}setFlipSided(e){if(this.currentFlipSided!==e){let{gl:t}=this;e?t.frontFace(t.CW):t.frontFace(t.CCW),this.currentFlipSided=e}}setCullFace(e){let{gl:t}=this;e!==F_?(this.enable(t.CULL_FACE),e!==this.currentCullFace&&(e===P_?t.cullFace(t.BACK):e===D_?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):this.disable(t.CULL_FACE),this.currentCullFace=e}setLineWidth(e){let{currentLineWidth:t,gl:s}=this;e!==t&&(s.lineWidth(e),this.currentLineWidth=e)}setMRTBlending(e,t,s){let n=this.gl,a=this.backend.drawBuffersIndexedExt;if(!a){je("WebGPURenderer: Multiple Render Targets (MRT) blending configuration is not fully supported in compatibility mode. The material blending will be used for all render targets.");return}for(let i=0;i<e.length;i++){let o=e[i],c=null;if(t!==null){let l=t.getBlendMode(o.name);l.blending===Lp?c=s:l.blending!==Ca&&(c=l)}else c=s;c!==null?this._setMRTBlendingIndex(i,c):a.blendFuncSeparateiOES(i,n.ONE,n.ZERO,n.ONE,n.ZERO)}}_setMRTBlendingIndex(e,t){let{gl:s}=this,n=this.backend.drawBuffersIndexedExt,a=t.blending,i=t.blendSrc,o=t.blendDst,c=t.blendEquation,l=t.premultipliedAlpha;if(a===Or){let h=t.blendSrcAlpha!==null?t.blendSrcAlpha:i,u=t.blendDstAlpha!==null?t.blendDstAlpha:o,d=t.blendEquationAlpha!==null?t.blendEquationAlpha:c;n.blendEquationSeparateiOES(e,cm[c],cm[d]),n.blendFuncSeparateiOES(e,Xr[i],Xr[o],Xr[h],Xr[u])}else if(n.blendEquationSeparateiOES(e,s.FUNC_ADD,s.FUNC_ADD),l)switch(a){case ta:n.blendFuncSeparateiOES(e,s.ONE,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case ko:n.blendFuncSeparateiOES(e,s.ONE,s.ONE,s.ONE,s.ONE);break;case Io:n.blendFuncSeparateiOES(e,s.ZERO,s.ONE_MINUS_SRC_COLOR,s.ZERO,s.ONE);break;case Bo:n.blendFuncSeparateiOES(e,s.DST_COLOR,s.ONE_MINUS_SRC_ALPHA,s.ZERO,s.ONE);break;default:n.blendFuncSeparateiOES(e,s.ONE,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break}else switch(a){case ta:n.blendFuncSeparateiOES(e,s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case ko:n.blendFuncSeparateiOES(e,s.SRC_ALPHA,s.ONE,s.ONE,s.ONE);break;case Io:n.blendFuncSeparateiOES(e,s.ZERO,s.ONE_MINUS_SRC_COLOR,s.ZERO,s.ONE);break;case Bo:n.blendFuncSeparateiOES(e,s.DST_COLOR,s.ONE_MINUS_SRC_ALPHA,s.ZERO,s.ONE);break;default:n.blendFuncSeparateiOES(e,s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break}}setBlending(e,t,s,n,a,i,o,c,l,h){let{gl:u}=this;if(e===Ca){this.currentBlendingEnabled===!0&&(this.disable(u.BLEND),this.currentBlendingEnabled=!1);return}if(this.currentBlendingEnabled===!1&&(this.enable(u.BLEND),this.currentBlendingEnabled=!0),e!==Or){if(e!==this.currentBlending||h!==this.currentPremultipledAlpha){if((this.currentBlendEquation!==sa||this.currentBlendEquationAlpha!==sa)&&(u.blendEquation(u.FUNC_ADD),this.currentBlendEquation=sa,this.currentBlendEquationAlpha=sa),h)switch(e){case ta:u.blendFuncSeparate(u.ONE,u.ONE_MINUS_SRC_ALPHA,u.ONE,u.ONE_MINUS_SRC_ALPHA);break;case ko:u.blendFunc(u.ONE,u.ONE);break;case Io:u.blendFuncSeparate(u.ZERO,u.ONE_MINUS_SRC_COLOR,u.ZERO,u.ONE);break;case Bo:u.blendFuncSeparate(u.DST_COLOR,u.ONE_MINUS_SRC_ALPHA,u.ZERO,u.ONE);break;default:W("WebGLState: Invalid blending: ",e);break}else switch(e){case ta:u.blendFuncSeparate(u.SRC_ALPHA,u.ONE_MINUS_SRC_ALPHA,u.ONE,u.ONE_MINUS_SRC_ALPHA);break;case ko:u.blendFuncSeparate(u.SRC_ALPHA,u.ONE,u.ONE,u.ONE);break;case Io:W("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Bo:W("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:W("WebGLState: Invalid blending: ",e);break}this.currentBlendSrc=null,this.currentBlendDst=null,this.currentBlendSrcAlpha=null,this.currentBlendDstAlpha=null,this.currentBlending=e,this.currentPremultipledAlpha=h}return}a=a||t,i=i||s,o=o||n,(t!==this.currentBlendEquation||a!==this.currentBlendEquationAlpha)&&(u.blendEquationSeparate(cm[t],cm[a]),this.currentBlendEquation=t,this.currentBlendEquationAlpha=a),(s!==this.currentBlendSrc||n!==this.currentBlendDst||i!==this.currentBlendSrcAlpha||o!==this.currentBlendDstAlpha)&&(u.blendFuncSeparate(Xr[s],Xr[n],Xr[i],Xr[o]),this.currentBlendSrc=s,this.currentBlendDst=n,this.currentBlendSrcAlpha=i,this.currentBlendDstAlpha=o),(c.equals(this.currentBlendColor)===!1||l!==this.currentBlendAlpha)&&(u.blendColor(c.r,c.g,c.b,l),this.currentBlendColor.copy(c),this.currentBlendAlpha=l),this.currentBlending=e,this.currentPremultipledAlpha=!1}setColorMask(e){this.currentColorMask!==e&&(this.gl.colorMask(e,e,e,e),this.currentColorMask=e)}setDepthTest(e){let{gl:t}=this;e?this.enable(t.DEPTH_TEST):this.disable(t.DEPTH_TEST)}setReversedDepth(e){if(this.currentDepthReversed!==e){let t=this.backend.extensions.get("EXT_clip_control");e?t.clipControlEXT(t.LOWER_LEFT_EXT,t.ZERO_TO_ONE_EXT):t.clipControlEXT(t.LOWER_LEFT_EXT,t.NEGATIVE_ONE_TO_ONE_EXT),this.currentDepthReversed=e}}setDepthMask(e){this.currentDepthMask!==e&&(this.gl.depthMask(e),this.currentDepthMask=e)}setDepthFunc(e){if(this.currentDepthReversed&&(e=cA[e]),this.currentDepthFunc!==e){let{gl:t}=this;switch(e){case Bh:t.depthFunc(t.NEVER);break;case Fh:t.depthFunc(t.ALWAYS);break;case Ph:t.depthFunc(t.LESS);break;case Lc:t.depthFunc(t.LEQUAL);break;case Dh:t.depthFunc(t.EQUAL);break;case Oh:t.depthFunc(t.GEQUAL);break;case Uh:t.depthFunc(t.GREATER);break;case Lh:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}this.currentDepthFunc=e}}scissor(e,t,s,n){let a=this._tempVec4.set(e,t,s,n);if(this.currentScissor.equals(a)===!1){let{gl:i}=this;i.scissor(a.x,a.y,a.z,a.w),this.currentScissor.copy(a)}}viewport(e,t,s,n){let a=this._tempVec4.set(e,t,s,n);if(this.currentViewport.equals(a)===!1){let{gl:i}=this;i.viewport(a.x,a.y,a.z,a.w),this.currentViewport.copy(a)}}setScissorTest(e){let t=this.gl;e?this.enable(t.SCISSOR_TEST):this.disable(t.SCISSOR_TEST)}setStencilTest(e){let{gl:t}=this;e?this.enable(t.STENCIL_TEST):this.disable(t.STENCIL_TEST)}setStencilMask(e){this.currentStencilMask!==e&&(this.gl.stencilMask(e),this.currentStencilMask=e)}setStencilFunc(e,t,s){(this.currentStencilFunc!==e||this.currentStencilRef!==t||this.currentStencilFuncMask!==s)&&(this.gl.stencilFunc(e,t,s),this.currentStencilFunc=e,this.currentStencilRef=t,this.currentStencilFuncMask=s)}setStencilOp(e,t,s){(this.currentStencilFail!==e||this.currentStencilZFail!==t||this.currentStencilZPass!==s)&&(this.gl.stencilOp(e,t,s),this.currentStencilFail=e,this.currentStencilZFail=t,this.currentStencilZPass=s)}setMaterial(e,t,s){let{gl:n}=this;e.side===rn?this.disable(n.CULL_FACE):this.enable(n.CULL_FACE);let a=e.side===Xt;t&&(a=!a),this.setFlipSided(a),e.blending===ta&&e.transparent===!1?this.setBlending(Ca):this.setBlending(e.blending,e.blendEquation,e.blendSrc,e.blendDst,e.blendEquationAlpha,e.blendSrcAlpha,e.blendDstAlpha,e.blendColor,e.blendAlpha,e.premultipliedAlpha),this.setDepthFunc(e.depthFunc),this.setDepthTest(e.depthTest),this.setDepthMask(e.depthWrite),this.setColorMask(e.colorWrite);let i=e.stencilWrite;if(this.setStencilTest(i),i&&(this.setStencilMask(e.stencilWriteMask),this.setStencilFunc(e.stencilFunc,e.stencilRef,e.stencilFuncMask),this.setStencilOp(e.stencilFail,e.stencilZFail,e.stencilZPass)),this.setPolygonOffset(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits),e.alphaToCoverage===!0&&this.backend.renderer.currentSamples>0?this.enable(n.SAMPLE_ALPHA_TO_COVERAGE):this.disable(n.SAMPLE_ALPHA_TO_COVERAGE),this.currentClippingPlanes!==s){for(let c=0;c<8;c++)c<s?this.enable(12288+c):this.disable(12288+c);this.currentClippingPlanes=s}}setPolygonOffset(e,t,s){let{gl:n}=this;e?(this.enable(n.POLYGON_OFFSET_FILL),(this.currentPolygonOffsetFactor!==t||this.currentPolygonOffsetUnits!==s)&&(n.polygonOffset(t,s),this.currentPolygonOffsetFactor=t,this.currentPolygonOffsetUnits=s)):this.disable(n.POLYGON_OFFSET_FILL)}useProgram(e){return this.currentProgram!==e?(this.gl.useProgram(e),this.currentProgram=e,!0):!1}setVertexState(e,t=null){let s=this.gl;return this.currentVAO!==e||this.currentIndex!==t?(s.bindVertexArray(e),t!==null&&s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,t),this.currentVAO=e,this.currentIndex=t,!0):!1}resetVertexState(){let e=this.gl;e.bindVertexArray(null),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null),this.currentVAO=null,this.currentIndex=null}bindFramebuffer(e,t){let{gl:s,currentBoundFramebuffers:n}=this;return n[e]!==t?(s.bindFramebuffer(e,t),n[e]=t,e===s.DRAW_FRAMEBUFFER&&(n[s.FRAMEBUFFER]=t),e===s.FRAMEBUFFER&&(n[s.DRAW_FRAMEBUFFER]=t),!0):!1}drawBuffers(e,t){let{gl:s}=this,n=[],a=!1;if(e.textures!==null){n=this.currentDrawbuffers.get(t),n===void 0&&(n=[],this.currentDrawbuffers.set(t,n));let i=e.textures;if(n.length!==i.length||n[0]!==s.COLOR_ATTACHMENT0){for(let o=0,c=i.length;o<c;o++)n[o]=s.COLOR_ATTACHMENT0+o;n.length=i.length,a=!0}}else n[0]!==s.BACK&&(n[0]=s.BACK,a=!0);a&&s.drawBuffers(n)}activeTexture(e){let{gl:t,currentTextureSlot:s,maxTextures:n}=this;e===void 0&&(e=t.TEXTURE0+n-1),s!==e&&(t.activeTexture(e),this.currentTextureSlot=e)}bindTexture(e,t,s){let{gl:n,currentTextureSlot:a,currentBoundTextures:i,maxTextures:o}=this;s===void 0&&(a===null?s=n.TEXTURE0+o-1:s=a);let c=i[s];c===void 0&&(c={type:void 0,texture:void 0},i[s]=c),(c.type!==e||c.texture!==t)&&(a!==s&&(n.activeTexture(s),this.currentTextureSlot=s),n.bindTexture(e,t),c.type=e,c.texture=t)}bindBufferBase(e,t,s){let{gl:n}=this,a=`${e}-${t}`;return this.currentBoundBufferBases[a]!==s?(n.bindBufferBase(e,t,s),this.currentBoundBufferBases[a]=s,!0):!1}unbindTexture(){let{gl:e,currentTextureSlot:t,currentBoundTextures:s}=this,n=s[t];n!==void 0&&n.type!==void 0&&(e.bindTexture(n.type,null),n.type=void 0,n.texture=void 0)}getParameter(e){let{gl:t,parameters:s}=this;return s[e]!==void 0?s[e]:t.getParameter(e)}pixelStorei(e,t){let{gl:s,parameters:n}=this;n[e]!==t&&(s.pixelStorei(e,t),n[e]=t)}reset(){let{gl:e}=this;e.disable(e.BLEND),e.disable(e.CULL_FACE),e.disable(e.DEPTH_TEST),e.disable(e.POLYGON_OFFSET_FILL),e.disable(e.SCISSOR_TEST),e.disable(e.STENCIL_TEST),e.disable(e.SAMPLE_ALPHA_TO_COVERAGE),e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ZERO),e.blendFuncSeparate(e.ONE,e.ZERO,e.ONE,e.ZERO),e.blendColor(0,0,0,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(e.LESS),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(e.ALWAYS,0,4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP),e.clearStencil(0),e.cullFace(e.BACK),e.frontFace(e.CCW),e.polygonOffset(0,0),e.activeTexture(e.TEXTURE0),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),e.bindFramebuffer(e.READ_FRAMEBUFFER,null),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),e.pixelStorei(e.PACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!1),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.BROWSER_DEFAULT_WEBGL),e.pixelStorei(e.PACK_ROW_LENGTH,0),e.pixelStorei(e.PACK_SKIP_PIXELS,0),e.pixelStorei(e.PACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_ROW_LENGTH,0),e.pixelStorei(e.UNPACK_IMAGE_HEIGHT,0),e.pixelStorei(e.UNPACK_SKIP_PIXELS,0),e.pixelStorei(e.UNPACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_SKIP_IMAGES,0),this.resetVertexState(),this.enabled={},this.parameters={},this.currentFlipSided=null,this.currentCullFace=null,this.currentProgram=null,this.currentBlendingEnabled=!1,this.currentBlending=null,this.currentBlendEquation=null,this.currentBlendEquationAlpha=null,this.currentBlendSrc=null,this.currentBlendDst=null,this.currentBlendSrcAlpha=null,this.currentBlendDstAlpha=null,this.currentBlendColor.set(0,0,0),this.currentBlendAlpha=0,this.currentPremultipledAlpha=null,this.currentPolygonOffsetFactor=null,this.currentPolygonOffsetUnits=null,this.currentColorMask=null,this.currentDepthFunc=null,this.currentDepthMask=null,this.currentStencilFunc=null,this.currentStencilRef=null,this.currentStencilFuncMask=null,this.currentStencilFail=null,this.currentStencilZFail=null,this.currentStencilZPass=null,this.currentStencilMask=null,this.currentLineWidth=null,this.currentClippingPlanes=0,this.currentBoundFramebuffers={},this.currentDrawbuffers=new WeakMap,this.currentTextureSlot=null,this.currentBoundTextures={},this.currentBoundBufferBases={},this.currentScissor.set(0,0,e.canvas.width,e.canvas.height),this.currentViewport.set(0,0,e.canvas.width,e.canvas.height),this.currentDepthReversed=!1,this.backend.renderer.reversedDepthBuffer===!0&&this.setReversedDepth(!0)}},vS=class{constructor(e){this.backend=e,this.gl=this.backend.gl,this.extensions=e.extensions}convert(e,t=qi){let{gl:s,extensions:n}=this,a,i=qe.getTransfer(t);if(e===ws)return s.UNSIGNED_BYTE;if(e===zp)return s.UNSIGNED_SHORT_4_4_4_4;if(e===Vp)return s.UNSIGNED_SHORT_5_5_5_1;if(e===Au)return s.UNSIGNED_INT_5_9_9_9_REV;if(e===Mu)return s.UNSIGNED_INT_10F_11F_11F_REV;if(e===Ur)return s.BYTE;if(e===pi)return s.SHORT;if(e===ka)return s.UNSIGNED_SHORT;if(e===Ts)return s.INT;if(e===St)return s.UNSIGNED_INT;if(e===Mt)return s.FLOAT;if(e===ds)return s.HALF_FLOAT;if(e===Su)return s.ALPHA;if(e===Po)return s.RGB;if(e===gs)return s.RGBA;if(e===vn)return s.DEPTH_COMPONENT;if(e===na)return s.DEPTH_STENCIL;if(e===Lr)return s.RED;if(e===zr)return s.RED_INTEGER;if(e===cn)return s.RG;if(e===Do)return s.RG_INTEGER;if(e===Nu)return s.RGBA_INTEGER;if(e===hl||e===ul||e===dl||e===fl)if(i===Ie)if(a=n.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(e===hl)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(e===ul)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(e===dl)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(e===fl)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=n.get("WEBGL_compressed_texture_s3tc"),a!==null){if(e===hl)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(e===ul)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(e===dl)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(e===fl)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(e===Gp||e===Hp||e===Wp||e===qp)if(a=n.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(e===Gp)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(e===Hp)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(e===Wp)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(e===qp)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(e===Ru||e===Eu||e===Cu||e===ku||e===Iu||e===Vr||e===Bu)if(a=n.get("WEBGL_compressed_texture_etc"),a!==null){if(e===Ru||e===Eu)return i===Ie?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(e===Cu)return i===Ie?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC;if(e===ku)return a.COMPRESSED_R11_EAC;if(e===Iu)return a.COMPRESSED_SIGNED_R11_EAC;if(e===Vr)return a.COMPRESSED_RG11_EAC;if(e===Bu)return a.COMPRESSED_SIGNED_RG11_EAC}else return null;if(e===Fu||e===Pu||e===Du||e===Ou||e===Uu||e===Lu||e===zu||e===Vu||e===ju||e===Gu||e===Hu||e===Wu||e===qu||e===Xu)if(a=n.get("WEBGL_compressed_texture_astc"),a!==null){if(e===Fu)return i===Ie?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(e===Pu)return i===Ie?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(e===Du)return i===Ie?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(e===Ou)return i===Ie?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(e===Uu)return i===Ie?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(e===Lu)return i===Ie?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(e===zu)return i===Ie?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(e===Vu)return i===Ie?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(e===ju)return i===Ie?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(e===Gu)return i===Ie?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(e===Hu)return i===Ie?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(e===Wu)return i===Ie?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(e===qu)return i===Ie?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(e===Xu)return i===Ie?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(e===Ku||e===Ju||e===$u)if(a=n.get("EXT_texture_compression_bptc"),a!==null){if(e===Ku)return i===Ie?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(e===Ju)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(e===$u)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(e===Yu||e===Zu||e===jr||e===Qu)if(a=n.get("EXT_texture_compression_rgtc"),a!==null){if(e===Yu)return a.COMPRESSED_RED_RGTC1_EXT;if(e===Zu)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(e===jr)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(e===Qu)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return e===mi?s.UNSIGNED_INT_24_8:s[e]!==void 0?s[e]:null}_clientWaitAsync(){let{gl:e}=this,t=e.fenceSync(e.SYNC_GPU_COMMANDS_COMPLETE,0);return e.flush(),new Promise((s,n)=>{function a(){let i=e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0);if(i===e.WAIT_FAILED){e.deleteSync(t),n();return}if(i===e.TIMEOUT_EXPIRED){requestAnimationFrame(a);return}e.deleteSync(t),s()}a()})}},Qk=!1,Zx,zA,eI,_S=class{constructor(e){this.backend=e,this.gl=e.gl,this.extensions=e.extensions,this.defaultTextures={},this._srcFramebuffer=null,this._dstFramebuffer=null,Qk===!1&&(this._init(),Qk=!0)}_init(){let e=this.gl;Zx={[Zn]:e.REPEAT,[hs]:e.CLAMP_TO_EDGE,[ai]:e.MIRRORED_REPEAT},zA={[pt]:e.NEAREST,[ll]:e.NEAREST_MIPMAP_NEAREST,[fi]:e.NEAREST_MIPMAP_LINEAR,[Ye]:e.LINEAR,[Fo]:e.LINEAR_MIPMAP_NEAREST,[on]:e.LINEAR_MIPMAP_LINEAR},eI={[xx]:e.NEVER,[vx]:e.ALWAYS,[$p]:e.LESS,[ml]:e.LEQUAL,[wx]:e.EQUAL,[Oo]:e.GEQUAL,[td]:e.GREATER,[Tx]:e.NOTEQUAL}}getGLTextureType(e){let{gl:t}=this,s;return e.isCubeTexture===!0?s=t.TEXTURE_CUBE_MAP:e.isArrayTexture===!0||e.isDataArrayTexture===!0||e.isCompressedArrayTexture===!0?s=t.TEXTURE_2D_ARRAY:e.isData3DTexture===!0?s=t.TEXTURE_3D:s=t.TEXTURE_2D,s}getInternalFormat(e,t,s,n,a,i=!1){let{gl:o,extensions:c}=this;if(e!==null){if(o[e]!==void 0)return o[e];K("WebGLBackend: Attempt to use non-existing WebGL internal format '"+e+"'")}let l=null;n&&(l=c.get("EXT_texture_norm16"),l||K("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let h=t;if(t===o.RED&&(s===o.FLOAT&&(h=o.R32F),s===o.HALF_FLOAT&&(h=o.R16F),s===o.UNSIGNED_BYTE&&(h=o.R8),s===o.BYTE&&(h=o.R8_SNORM),s===o.UNSIGNED_SHORT&&l&&(h=l.R16_EXT),s===o.SHORT&&l&&(h=l.R16_SNORM_EXT)),t===o.RED_INTEGER&&(s===o.UNSIGNED_BYTE&&(h=o.R8UI),s===o.UNSIGNED_SHORT&&(h=o.R16UI),s===o.UNSIGNED_INT&&(h=o.R32UI),s===o.BYTE&&(h=o.R8I),s===o.SHORT&&(h=o.R16I),s===o.INT&&(h=o.R32I)),t===o.RG&&(s===o.FLOAT&&(h=o.RG32F),s===o.HALF_FLOAT&&(h=o.RG16F),s===o.UNSIGNED_BYTE&&(h=o.RG8),s===o.BYTE&&(h=o.RG8_SNORM),s===o.UNSIGNED_SHORT&&l&&(h=l.RG16_EXT),s===o.SHORT&&l&&(h=l.RG16_SNORM_EXT)),t===o.RG_INTEGER&&(s===o.UNSIGNED_BYTE&&(h=o.RG8UI),s===o.UNSIGNED_SHORT&&(h=o.RG16UI),s===o.UNSIGNED_INT&&(h=o.RG32UI),s===o.BYTE&&(h=o.RG8I),s===o.SHORT&&(h=o.RG16I),s===o.INT&&(h=o.RG32I)),t===o.RGB){let u=i?Vh:qe.getTransfer(a);s===o.FLOAT&&(h=o.RGB32F),s===o.HALF_FLOAT&&(h=o.RGB16F),s===o.UNSIGNED_BYTE&&(h=u===Ie?o.SRGB8:o.RGB8),s===o.BYTE&&(h=o.RGB8_SNORM),s===o.UNSIGNED_SHORT&&l&&(h=l.RGB16_EXT),s===o.SHORT&&l&&(h=l.RGB16_SNORM_EXT),s===o.UNSIGNED_SHORT_5_6_5&&(h=o.RGB565),s===o.UNSIGNED_SHORT_5_5_5_1&&(h=o.RGB5_A1),s===o.UNSIGNED_SHORT_4_4_4_4&&(h=o.RGB4),s===o.UNSIGNED_INT_5_9_9_9_REV&&(h=o.RGB9_E5),s===o.UNSIGNED_INT_10F_11F_11F_REV&&(h=o.R11F_G11F_B10F)}if(t===o.RGB_INTEGER&&(s===o.UNSIGNED_BYTE&&(h=o.RGB8UI),s===o.UNSIGNED_SHORT&&(h=o.RGB16UI),s===o.UNSIGNED_INT&&(h=o.RGB32UI),s===o.BYTE&&(h=o.RGB8I),s===o.SHORT&&(h=o.RGB16I),s===o.INT&&(h=o.RGB32I)),t===o.RGBA){let u=i?Vh:qe.getTransfer(a);s===o.FLOAT&&(h=o.RGBA32F),s===o.HALF_FLOAT&&(h=o.RGBA16F),s===o.UNSIGNED_BYTE&&(h=u===Ie?o.SRGB8_ALPHA8:o.RGBA8),s===o.BYTE&&(h=o.RGBA8_SNORM),s===o.UNSIGNED_SHORT&&l&&(h=l.RGBA16_EXT),s===o.SHORT&&l&&(h=l.RGBA16_SNORM_EXT),s===o.UNSIGNED_SHORT_4_4_4_4&&(h=o.RGBA4),s===o.UNSIGNED_SHORT_5_5_5_1&&(h=o.RGB5_A1)}return t===o.RGBA_INTEGER&&(s===o.UNSIGNED_BYTE&&(h=o.RGBA8UI),s===o.UNSIGNED_SHORT&&(h=o.RGBA16UI),s===o.UNSIGNED_INT&&(h=o.RGBA32UI),s===o.BYTE&&(h=o.RGBA8I),s===o.SHORT&&(h=o.RGBA16I),s===o.INT&&(h=o.RGBA32I)),t===o.DEPTH_COMPONENT&&(s===o.UNSIGNED_SHORT&&(h=o.DEPTH_COMPONENT16),s===o.UNSIGNED_INT&&(h=o.DEPTH_COMPONENT24),s===o.FLOAT&&(h=o.DEPTH_COMPONENT32F)),t===o.DEPTH_STENCIL&&s===o.UNSIGNED_INT_24_8&&(h=o.DEPTH24_STENCIL8),(h===o.R16F||h===o.R32F||h===o.RG16F||h===o.RG32F||h===o.RGBA16F||h===o.RGBA32F)&&c.get("EXT_color_buffer_float"),h}setTextureParameters(e,t){let{gl:s,extensions:n,backend:a}=this,{state:i}=this.backend,o=qe.getPrimaries(qe.workingColorSpace),c=t.colorSpace===qi?null:qe.getPrimaries(t.colorSpace),l=t.colorSpace===qi||o===c?s.NONE:s.BROWSER_DEFAULT_WEBGL;i.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,t.flipY),i.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),i.pixelStorei(s.UNPACK_ALIGNMENT,t.unpackAlignment),i.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,l),s.texParameteri(e,s.TEXTURE_WRAP_S,Zx[t.wrapS]),s.texParameteri(e,s.TEXTURE_WRAP_T,Zx[t.wrapT]),(e===s.TEXTURE_3D||e===s.TEXTURE_2D_ARRAY)&&(t.isArrayTexture||s.texParameteri(e,s.TEXTURE_WRAP_R,Zx[t.wrapR])),s.texParameteri(e,s.TEXTURE_MAG_FILTER,zA[t.magFilter]);let h=t.mipmaps!==void 0&&t.mipmaps.length>0,u=t.minFilter===Ye&&h?on:t.minFilter;if(s.texParameteri(e,s.TEXTURE_MIN_FILTER,zA[u]),t.compareFunction&&(s.texParameteri(e,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE),s.texParameteri(e,s.TEXTURE_COMPARE_FUNC,eI[t.compareFunction])),n.has("EXT_texture_filter_anisotropic")===!0){if(t.magFilter===pt||t.minFilter!==fi&&t.minFilter!==on||t.type===Mt&&n.has("OES_texture_float_linear")===!1)return;if(t.anisotropy>1){let d=n.get("EXT_texture_filter_anisotropic");s.texParameterf(e,d.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(t.anisotropy,a.capabilities.getMaxAnisotropy()))}}}createDefaultTexture(e){let{gl:t,backend:s,defaultTextures:n}=this,a=this.getGLTextureType(e),i=n[a];i===void 0&&(i=t.createTexture(),s.state.bindTexture(a,i),t.texParameteri(a,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(a,t.TEXTURE_MAG_FILTER,t.NEAREST),n[a]=i),s.set(e,{textureGPU:i,glTextureType:a})}createTexture(e,t){let{gl:s,backend:n}=this,a,i,o,c,l;if(e.isExternalTexture===!0)a=e.sourceTexture,i=this.getGLTextureType(e);else{let{levels:h,width:u,height:d,depth:f}=t;o=n.utils.convert(e.format,e.colorSpace),c=n.utils.convert(e.type),l=this.getInternalFormat(e.internalFormat,o,c,e.normalized,e.colorSpace,e.isVideoTexture),a=s.createTexture(),i=this.getGLTextureType(e),n.state.bindTexture(i,a),this.setTextureParameters(i,e),e.isArrayTexture||e.isDataArrayTexture||e.isCompressedArrayTexture?s.texStorage3D(s.TEXTURE_2D_ARRAY,h,l,u,d,f):e.isData3DTexture?s.texStorage3D(s.TEXTURE_3D,h,l,u,d,f):e.isVideoTexture||s.texStorage2D(i,h,l,u,d)}n.set(e,{textureGPU:a,glTextureType:i,glFormat:o,glType:c,glInternalFormat:l})}copyBufferToTexture(e,t){let{gl:s,backend:n}=this,{state:a}=n,{textureGPU:i,glTextureType:o,glFormat:c,glType:l}=n.get(t),{width:h,height:u}=t.source.data;s.bindBuffer(s.PIXEL_UNPACK_BUFFER,e),n.state.bindTexture(o,i),a.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,!1),a.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),s.texSubImage2D(o,0,0,0,h,u,c,l,0),s.bindBuffer(s.PIXEL_UNPACK_BUFFER,null),n.state.unbindTexture()}updateTexture(e,t){let{gl:s}=this,{width:n,height:a}=t,{textureGPU:i,glTextureType:o,glFormat:c,glType:l,glInternalFormat:h}=this.backend.get(e);if(!(e.isRenderTargetTexture||i===void 0))if(this.backend.state.bindTexture(o,i),this.setTextureParameters(o,e),e.isCompressedTexture){let u=e.mipmaps,d=t.image;for(let f=0;f<u.length;f++){let p=u[f];if(e.isCompressedArrayTexture)if(e.format!==s.RGBA)if(c!==null)if(e.layerUpdates.size>0){let m=Ax(p.width,p.height,e.format,e.type);for(let b of e.layerUpdates){let g=p.data.subarray(b*m/p.data.BYTES_PER_ELEMENT,(b+1)*m/p.data.BYTES_PER_ELEMENT);s.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,f,0,0,b,p.width,p.height,1,c,g)}}else s.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,f,0,0,0,p.width,p.height,d.depth,c,p.data);else K("WebGLBackend: Attempt to load unsupported compressed texture format in .uploadTexture()");else s.texSubImage3D(s.TEXTURE_2D_ARRAY,f,0,0,0,p.width,p.height,d.depth,c,l,p.data);else c!==null?s.compressedTexSubImage2D(s.TEXTURE_2D,f,0,0,p.width,p.height,c,p.data):K("WebGLBackend: Unsupported compressed texture format")}e.isCompressedArrayTexture&&e.layerUpdates.size>0&&e.clearLayerUpdates()}else if(e.isCubeTexture){let u=t.images,d=e.mipmaps;for(let f=0;f<6;f++){let p=Qx(u[f]);s.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+f,0,0,0,n,a,c,l,p);for(let m=0;m<d.length;m++){let b=d[m],g=Qx(b.images[f]);s.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+f,m+1,0,0,g.width,g.height,c,l,g)}}}else if(e.isDataArrayTexture||e.isArrayTexture){let u=t.image;if(e.layerUpdates.size>0){let d=Ax(u.width,u.height,e.format,e.type);for(let f of e.layerUpdates){let p=u.data.subarray(f*d/u.data.BYTES_PER_ELEMENT,(f+1)*d/u.data.BYTES_PER_ELEMENT);s.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,f,u.width,u.height,1,c,l,p)}e.clearLayerUpdates()}else s.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,0,u.width,u.height,u.depth,c,l,u.data)}else if(e.isData3DTexture){let u=t.image;s.texSubImage3D(s.TEXTURE_3D,0,0,0,0,u.width,u.height,u.depth,c,l,u.data)}else if(e.isVideoTexture)e.update(),s.texImage2D(o,0,h,c,l,t.image);else if(e.isHTMLTexture)typeof s.texElementImage2D=="function"&&(s.texElementImage2D.length===3?s.texElementImage2D(s.TEXTURE_2D,s.RGBA8,t.image):s.texElementImage2D(s.TEXTURE_2D,0,s.RGBA,s.RGBA,s.UNSIGNED_BYTE,t.image));else{let u=e.mipmaps;if(u.length>0)for(let d=0,f=u.length;d<f;d++){let p=u[d],m=Qx(p);s.texSubImage2D(o,d,0,0,p.width,p.height,c,l,m)}else{let d=Qx(t.image);s.texSubImage2D(o,0,0,0,n,a,c,l,d)}}}generateMipmaps(e){let{gl:t,backend:s}=this,{textureGPU:n,glTextureType:a}=s.get(e);s.state.bindTexture(a,n),t.generateMipmap(a)}deallocateRenderBuffers(e){let{gl:t,backend:s}=this;if(e){let n=s.get(e);if(n.renderBufferStorageSetup=void 0,n.framebuffers){for(let a in n.framebuffers)t.deleteFramebuffer(n.framebuffers[a]);delete n.framebuffers}if(n.depthRenderbuffer&&(t.deleteRenderbuffer(n.depthRenderbuffer),delete n.depthRenderbuffer),n.stencilRenderbuffer&&(t.deleteRenderbuffer(n.stencilRenderbuffer),delete n.stencilRenderbuffer),n.msaaFrameBuffer&&(t.deleteFramebuffer(n.msaaFrameBuffer),delete n.msaaFrameBuffer),n.msaaRenderbuffers){for(let a=0;a<n.msaaRenderbuffers.length;a++)t.deleteRenderbuffer(n.msaaRenderbuffers[a]);delete n.msaaRenderbuffers}}}destroyTexture(e,t=!1){let{gl:s,backend:n}=this,{textureGPU:a,renderTarget:i}=n.get(e);this.deallocateRenderBuffers(i),t===!1&&e.isExternalTexture!==!0&&s.deleteTexture(a),n.delete(e)}copyTextureToTexture(e,t,s=null,n=null,a=0,i=0){let{gl:o,backend:c}=this,{state:l}=this.backend,{textureGPU:h,glTextureType:u,glType:d,glFormat:f}=c.get(t);l.bindTexture(u,h);let p,m,b,g,x,T,y,v,_,A=e.isCompressedTexture?e.mipmaps[i]:e.image;if(s!==null)p=s.max.x-s.min.x,m=s.max.y-s.min.y,b=s.isBox3?s.max.z-s.min.z:1,g=s.min.x,x=s.min.y,T=s.isBox3?s.min.z:0;else{let U=Math.pow(2,-a);p=Math.floor(A.width*U),m=Math.floor(A.height*U),e.isDataArrayTexture||e.isArrayTexture?b=A.depth:e.isData3DTexture?b=Math.floor(A.depth*U):b=1,g=0,x=0,T=0}n!==null?(y=n.x,v=n.y,_=n.z):(y=0,v=0,_=0),l.pixelStorei(o.UNPACK_FLIP_Y_WEBGL,t.flipY),l.pixelStorei(o.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),l.pixelStorei(o.UNPACK_ALIGNMENT,t.unpackAlignment);let M=l.getParameter(o.UNPACK_ROW_LENGTH),N=l.getParameter(o.UNPACK_IMAGE_HEIGHT),R=l.getParameter(o.UNPACK_SKIP_PIXELS),I=l.getParameter(o.UNPACK_SKIP_ROWS),D=l.getParameter(o.UNPACK_SKIP_IMAGES);l.pixelStorei(o.UNPACK_ROW_LENGTH,A.width),l.pixelStorei(o.UNPACK_IMAGE_HEIGHT,A.height),l.pixelStorei(o.UNPACK_SKIP_PIXELS,g),l.pixelStorei(o.UNPACK_SKIP_ROWS,x),l.pixelStorei(o.UNPACK_SKIP_IMAGES,T);let O=e.isDataArrayTexture||e.isData3DTexture||t.isArrayTexture,P=t.isDataArrayTexture||t.isData3DTexture||t.isArrayTexture;if(e.isDepthTexture){let U=c.get(e),j=c.get(t),z=c.get(U.renderTarget),H=c.get(j.renderTarget),J=z.framebuffers[U.cacheKey],ee=H.framebuffers[j.cacheKey],se=l.currentBoundFramebuffers[o.READ_FRAMEBUFFER]??null,_e=l.currentBoundFramebuffers[o.DRAW_FRAMEBUFFER]??null;l.bindFramebuffer(o.READ_FRAMEBUFFER,J),l.bindFramebuffer(o.DRAW_FRAMEBUFFER,ee);for(let Ae=0;Ae<b;Ae++)O&&(o.framebufferTextureLayer(o.READ_FRAMEBUFFER,o.COLOR_ATTACHMENT0,U.textureGPU,a,T+Ae),o.framebufferTextureLayer(o.DRAW_FRAMEBUFFER,o.COLOR_ATTACHMENT0,h,i,_+Ae)),o.blitFramebuffer(g,x,p,m,y,v,p,m,o.DEPTH_BUFFER_BIT,o.NEAREST);l.bindFramebuffer(o.READ_FRAMEBUFFER,se),l.bindFramebuffer(o.DRAW_FRAMEBUFFER,_e)}else if(a!==0||e.isRenderTargetTexture||c.has(e)){let U=c.get(e);this._srcFramebuffer===null&&(this._srcFramebuffer=o.createFramebuffer()),this._dstFramebuffer===null&&(this._dstFramebuffer=o.createFramebuffer());let j=l.currentBoundFramebuffers[o.READ_FRAMEBUFFER]??null,z=l.currentBoundFramebuffers[o.DRAW_FRAMEBUFFER]??null;l.bindFramebuffer(o.READ_FRAMEBUFFER,this._srcFramebuffer),l.bindFramebuffer(o.DRAW_FRAMEBUFFER,this._dstFramebuffer);for(let H=0;H<b;H++)O?o.framebufferTextureLayer(o.READ_FRAMEBUFFER,o.COLOR_ATTACHMENT0,U.textureGPU,a,T+H):o.framebufferTexture2D(o.READ_FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,U.textureGPU,a),P?o.framebufferTextureLayer(o.DRAW_FRAMEBUFFER,o.COLOR_ATTACHMENT0,h,i,_+H):o.framebufferTexture2D(o.DRAW_FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,h,i),a!==0?o.blitFramebuffer(g,x,p,m,y,v,p,m,o.COLOR_BUFFER_BIT,o.NEAREST):P?o.copyTexSubImage3D(u,i,y,v,_+H,g,x,p,m):o.copyTexSubImage2D(u,i,y,v,g,x,p,m);l.bindFramebuffer(o.READ_FRAMEBUFFER,j),l.bindFramebuffer(o.DRAW_FRAMEBUFFER,z)}else P?e.isDataTexture||e.isData3DTexture?o.texSubImage3D(u,i,y,v,_,p,m,b,f,d,A.data):t.isCompressedArrayTexture?o.compressedTexSubImage3D(u,i,y,v,_,p,m,b,f,A.data):o.texSubImage3D(u,i,y,v,_,p,m,b,f,d,A):e.isDataTexture?o.texSubImage2D(o.TEXTURE_2D,i,y,v,p,m,f,d,A.data):e.isCompressedTexture?o.compressedTexSubImage2D(o.TEXTURE_2D,i,y,v,A.width,A.height,f,A.data):o.texSubImage2D(o.TEXTURE_2D,i,y,v,p,m,f,d,A);l.pixelStorei(o.UNPACK_ROW_LENGTH,M),l.pixelStorei(o.UNPACK_IMAGE_HEIGHT,N),l.pixelStorei(o.UNPACK_SKIP_PIXELS,R),l.pixelStorei(o.UNPACK_SKIP_ROWS,I),l.pixelStorei(o.UNPACK_SKIP_IMAGES,D),i===0&&t.generateMipmaps&&o.generateMipmap(u),l.unbindTexture()}copyFramebufferToTexture(e,t,s){let{gl:n}=this,{state:a}=this.backend,{textureGPU:i}=this.backend.get(e),{x:o,y:c,z:l,w:h}=s,u=e.isDepthTexture===!0||t.renderTarget&&t.renderTarget.samples>0,d=t.renderTarget?t.renderTarget.height:this.backend.getDrawingBufferSize().y;if(u){let f=o!==0||c!==0,p,m;if(e.isDepthTexture===!0?(p=n.DEPTH_BUFFER_BIT,m=n.DEPTH_ATTACHMENT,t.stencil&&(p|=n.STENCIL_BUFFER_BIT)):(p=n.COLOR_BUFFER_BIT,m=n.COLOR_ATTACHMENT0),f){let b=this.backend.get(t.renderTarget),g=b.framebuffers[t.getCacheKey()],x=b.msaaFrameBuffer;a.bindFramebuffer(n.DRAW_FRAMEBUFFER,g),a.bindFramebuffer(n.READ_FRAMEBUFFER,x);let T=d-c-h;n.blitFramebuffer(o,T,o+l,T+h,o,T,o+l,T+h,p,n.NEAREST),a.bindFramebuffer(n.READ_FRAMEBUFFER,g),a.bindTexture(n.TEXTURE_2D,i),n.copyTexSubImage2D(n.TEXTURE_2D,0,0,0,o,T,l,h),a.unbindTexture()}else{let b=n.createFramebuffer();a.bindFramebuffer(n.DRAW_FRAMEBUFFER,b),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,m,n.TEXTURE_2D,i,0),n.blitFramebuffer(0,0,l,h,0,0,l,h,p,n.NEAREST),n.deleteFramebuffer(b)}}else a.bindTexture(n.TEXTURE_2D,i),n.copyTexSubImage2D(n.TEXTURE_2D,0,0,0,o,d-h-c,l,h),a.unbindTexture();e.generateMipmaps&&this.generateMipmaps(e),this.backend._setFramebuffer(t)}setupRenderBufferStorage(e,t,s,n=!1){let{gl:a}=this,i=t.renderTarget,{depthTexture:o,depthBuffer:c,stencilBuffer:l,width:h,height:u}=i;if(a.bindRenderbuffer(a.RENDERBUFFER,e),c&&!l){let d=a.DEPTH_COMPONENT24;n===!0?this.extensions.get("WEBGL_multisampled_render_to_texture").renderbufferStorageMultisampleEXT(a.RENDERBUFFER,i.samples,d,h,u):s>0?(o&&o.isDepthTexture&&o.type===a.FLOAT&&(d=a.DEPTH_COMPONENT32F),a.renderbufferStorageMultisample(a.RENDERBUFFER,s,d,h,u)):a.renderbufferStorage(a.RENDERBUFFER,d,h,u),a.framebufferRenderbuffer(a.FRAMEBUFFER,a.DEPTH_ATTACHMENT,a.RENDERBUFFER,e)}else c&&l&&(s>0?a.renderbufferStorageMultisample(a.RENDERBUFFER,s,a.DEPTH24_STENCIL8,h,u):a.renderbufferStorage(a.RENDERBUFFER,a.DEPTH_STENCIL,h,u),a.framebufferRenderbuffer(a.FRAMEBUFFER,a.DEPTH_STENCIL_ATTACHMENT,a.RENDERBUFFER,e));a.bindRenderbuffer(a.RENDERBUFFER,null)}async copyTextureToBuffer(e,t,s,n,a,i){let{backend:o,gl:c}=this,{textureGPU:l,glFormat:h,glType:u}=this.backend.get(e),d=c.createFramebuffer();if(o.state.bindFramebuffer(c.READ_FRAMEBUFFER,d),e.isData3DTexture||e.isDataArrayTexture||e.isArrayTexture)c.framebufferTextureLayer(c.READ_FRAMEBUFFER,c.COLOR_ATTACHMENT0,l,0,i);else{let T=e.isCubeTexture?c.TEXTURE_CUBE_MAP_POSITIVE_X+i:c.TEXTURE_2D;c.framebufferTexture2D(c.READ_FRAMEBUFFER,c.COLOR_ATTACHMENT0,T,l,0)}let f=this._getTypedArrayType(u),p=this._getBytesPerTexel(u,h),b=n*a*p,g=c.createBuffer();c.bindBuffer(c.PIXEL_PACK_BUFFER,g),c.bufferData(c.PIXEL_PACK_BUFFER,b,c.STREAM_READ),c.readPixels(t,s,n,a,h,u,0),c.bindBuffer(c.PIXEL_PACK_BUFFER,null),await o.utils._clientWaitAsync();let x=new f(b/f.BYTES_PER_ELEMENT);return c.bindBuffer(c.PIXEL_PACK_BUFFER,g),c.getBufferSubData(c.PIXEL_PACK_BUFFER,0,x),c.bindBuffer(c.PIXEL_PACK_BUFFER,null),o.state.bindFramebuffer(c.READ_FRAMEBUFFER,null),c.deleteBuffer(g),c.deleteFramebuffer(d),x}_getTypedArrayType(e){let{gl:t}=this;if(e===t.UNSIGNED_BYTE)return Uint8Array;if(e===t.UNSIGNED_SHORT_4_4_4_4||e===t.UNSIGNED_SHORT_5_5_5_1||e===t.UNSIGNED_SHORT_5_6_5||e===t.UNSIGNED_SHORT)return Uint16Array;if(e===t.UNSIGNED_INT)return Uint32Array;if(e===t.HALF_FLOAT)return Uint16Array;if(e===t.FLOAT)return Float32Array;throw new Error(`THREE.WebGLTextureUtils: Unsupported WebGL type: ${e}`)}_getBytesPerTexel(e,t){let{gl:s}=this,n=0;if(e===s.UNSIGNED_BYTE&&(n=1),(e===s.UNSIGNED_SHORT_4_4_4_4||e===s.UNSIGNED_SHORT_5_5_5_1||e===s.UNSIGNED_SHORT_5_6_5||e===s.UNSIGNED_SHORT||e===s.HALF_FLOAT)&&(n=2),(e===s.UNSIGNED_INT||e===s.FLOAT)&&(n=4),t===s.RGBA)return n*4;if(t===s.RGB)return n*3;if(t===s.ALPHA)return n}dispose(){let{gl:e}=this;this._srcFramebuffer!==null&&e.deleteFramebuffer(this._srcFramebuffer),this._dstFramebuffer!==null&&e.deleteFramebuffer(this._dstFramebuffer)}};function Qx(r){return r.isDataTexture?r.image.data:typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&r instanceof ImageBitmap||typeof OffscreenCanvas<"u"&&r instanceof OffscreenCanvas?r:r.data}var AS=class{constructor(e){this.backend=e,this.gl=this.backend.gl,this.availableExtensions=this.gl.getSupportedExtensions(),this.extensions={}}get(e){let t=this.extensions[e];return t===void 0&&(t=this.gl.getExtension(e),this.extensions[e]=t),t}has(e){return this.availableExtensions.includes(e)}},mT=class{constructor(e){this.backend=e,this.maxAnisotropy=null,this.maxUniformBlockSize=null}getMaxAnisotropy(){if(this.maxAnisotropy!==null)return this.maxAnisotropy;let e=this.backend.gl,t=this.backend.extensions;if(t.has("EXT_texture_filter_anisotropic")===!0){let s=t.get("EXT_texture_filter_anisotropic");this.maxAnisotropy=e.getParameter(s.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else this.maxAnisotropy=0;return this.maxAnisotropy}getUniformBufferLimit(){if(this.maxUniformBlockSize!==null)return this.maxUniformBlockSize;let e=this.backend.gl;return this.maxUniformBlockSize=e.getParameter(e.MAX_UNIFORM_BLOCK_SIZE),this.maxUniformBlockSize}},tI={WEBGL_multi_draw:"WEBGL_multi_draw",WEBGL_compressed_texture_astc:"texture-compression-astc",WEBGL_compressed_texture_etc:"texture-compression-etc2",WEBGL_compressed_texture_etc1:"texture-compression-etc1",WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBGL_compressed_texture_s3tc:"texture-compression-s3tc",EXT_texture_compression_bptc:"texture-compression-bc",EXT_disjoint_timer_query_webgl2:"timestamp-query",OVR_multiview2:"OVR_multiview2"},MS=class{constructor(e){this.gl=e.gl,this.extensions=e.extensions,this.info=e.renderer.info,this.mode=null,this.index=0,this.type=null,this.object=null}render(e,t){let{gl:s,mode:n,object:a,type:i,info:o,index:c}=this;c!==0?s.drawElements(n,t,i,e):s.drawArrays(n,e,t),o.update(a,t,1)}renderInstances(e,t,s){let{gl:n,mode:a,type:i,index:o,object:c,info:l}=this;s!==0&&(o!==0?n.drawElementsInstanced(a,t,i,e,s):n.drawArraysInstanced(a,e,t,s),l.update(c,t,s))}renderMultiDraw(e,t,s){let{extensions:n,mode:a,object:i,info:o}=this;if(s===0)return;let c=n.get("WEBGL_multi_draw");if(c===null)for(let l=0;l<s;l++)this.render(e[l],t[l]);else{this.index!==0?c.multiDrawElementsWEBGL(a,t,0,this.type,e,0,s):c.multiDrawArraysWEBGL(a,e,0,t,0,s);let l=0;for(let h=0;h<s;h++)l+=t[h];o.update(i,l,1)}}},bT=class{constructor(e=256){this.trackTimestamp=!0,this.maxQueries=e,this.currentQueryIndex=0,this.queryOffsets=new Map,this.isDisposed=!1,this.lastValue=0,this.frames=[],this.pendingResolve=!1,this.timestamps=new Map}getTimestampFrames(){return this.frames}getTimestamp(e){let t=this.timestamps.get(e);return t===void 0&&(K(`TimestampQueryPool: No timestamp available for uid ${e}.`),t=0),t}hasTimestampQuery(e){return this.timestamps.has(e)}allocateQueriesForContext(){}async resolveQueriesAsync(){}dispose(){}},SS=class extends bT{constructor(e,t,s=2048){if(super(s),this.gl=e,this.type=t,this.ext=e.getExtension("EXT_disjoint_timer_query_webgl2")||e.getExtension("EXT_disjoint_timer_query"),!this.ext){K("EXT_disjoint_timer_query not supported; timestamps will be disabled."),this.trackTimestamp=!1;return}this.queries=[];for(let n=0;n<this.maxQueries;n++)this.queries.push(e.createQuery());this.activeQuery=null,this.queryStates=new Map}allocateQueriesForContext(e){if(!this.trackTimestamp)return null;this.currentQueryIndex+2>this.maxQueries&&(this.resolveQueriesAsync(),this.currentQueryIndex=0,this.queryOffsets.clear(),this.queryStates.clear(),this.activeQuery=null);let t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryStates.set(t,"inactive"),this.queryOffsets.set(e,t),t}beginQuery(e){if(!this.trackTimestamp||this.isDisposed)return;let t=this.queryOffsets.get(e);if(t==null||this.activeQuery!==null)return;let s=this.queries[t];if(s)try{this.queryStates.get(t)==="inactive"&&(this.gl.beginQuery(this.ext.TIME_ELAPSED_EXT,s),this.activeQuery=t,this.queryStates.set(t,"started"))}catch(n){W("Error in beginQuery:",n),this.activeQuery=null,this.queryStates.set(t,"inactive")}}endQuery(e){if(!this.trackTimestamp||this.isDisposed)return;let t=this.queryOffsets.get(e);if(t!=null&&this.activeQuery===t)try{this.gl.endQuery(this.ext.TIME_ELAPSED_EXT),this.queryStates.set(t,"ended"),this.activeQuery=null}catch(s){W("Error in endQuery:",s),this.queryStates.set(t,"inactive"),this.activeQuery=null}}async resolveQueriesAsync(){if(!this.trackTimestamp||this.pendingResolve)return this.lastValue;this.pendingResolve=!0;try{let e=new Map;for(let[a,i]of this.queryOffsets)if(this.queryStates.get(i)==="ended"){let c=this.queries[i];e.set(a,this.resolveQuery(c))}if(e.size===0)return this.lastValue;let t={},s=[];this.timestamps.clear();for(let[a,i]of e){let o=a.match(/^(.*):f(\d+)$/),c=parseInt(o[2]);s.includes(c)===!1&&s.push(c),t[c]===void 0&&(t[c]=0);let l=await i;this.timestamps.set(a,l),t[c]+=l}let n=t[s[s.length-1]];return this.lastValue=n,this.frames=s,this.currentQueryIndex=0,this.queryOffsets.clear(),this.queryStates.clear(),this.activeQuery=null,n}catch(e){return W("Error resolving queries:",e),this.lastValue}finally{this.pendingResolve=!1}}async resolveQuery(e){return new Promise(t=>{if(this.isDisposed){t(this.lastValue);return}let s,n=!1,a=()=>{s&&(clearTimeout(s),s=null)},i=c=>{n||(n=!0,a(),t(c))},o=()=>{if(this.isDisposed){i(this.lastValue);return}try{if(this.gl.getParameter(this.ext.GPU_DISJOINT_EXT)){i(this.lastValue);return}if(!this.gl.getQueryParameter(e,this.gl.QUERY_RESULT_AVAILABLE)){s=setTimeout(o,1);return}let h=this.gl.getQueryParameter(e,this.gl.QUERY_RESULT);t(Number(h)/1e6)}catch(c){W("Error checking query:",c),t(this.lastValue)}};o()})}dispose(){if(!this.isDisposed&&(this.isDisposed=!0,!!this.trackTimestamp)){for(let e of this.queries)this.gl.deleteQuery(e);this.queries=[],this.queryStates.clear(),this.queryOffsets.clear(),this.timestamps.clear(),this.frames=[],this.lastValue=0,this.activeQuery=null}}},lm=[],mb=class extends pb{constructor(e={}){super(e),this.isWebGLBackend=!0,this.attributeUtils=null,this.extensions=null,this.capabilities=null,this.textureUtils=null,this.bufferRenderer=null,this.gl=null,this.state=null,this.utils=null,this.vaoCache={},this.transformFeedbackCache={},this.discard=!1,this.disjoint=null,this.parallel=null,this._currentContext=null,this._knownBindings=new WeakSet,this._supportsInvalidateFramebuffer=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),this._xrFramebuffer=null}init(e){super.init(e);let t=this.parameters,s={antialias:e.currentSamples>0,alpha:!0,depth:e.depth,stencil:e.stencil},n=t.context!==void 0?t.context:e.domElement.getContext("webgl2",s);function a(i){i.preventDefault();let o={api:"WebGL",message:i.statusMessage||"Unknown reason",reason:null,originalEvent:i};e.onDeviceLost(o)}this._onContextLost=a,e.domElement.addEventListener("webglcontextlost",a,!1),this.gl=n,this.extensions=new AS(this),this.capabilities=new mT(this),this.attributeUtils=new wS(this),this.textureUtils=new _S(this),this.bufferRenderer=new MS(this),this.state=new TS(this),this.utils=new vS(this),this.extensions.get("EXT_color_buffer_float"),this.extensions.get("WEBGL_clip_cull_distance"),this.extensions.get("OES_texture_float_linear"),this.extensions.get("EXT_color_buffer_half_float"),this.extensions.get("WEBGL_multisampled_render_to_texture"),this.extensions.get("WEBGL_render_shared_exponent"),this.extensions.get("WEBGL_multi_draw"),this.extensions.get("OVR_multiview2"),this.extensions.get("EXT_clip_control"),this.disjoint=this.extensions.get("EXT_disjoint_timer_query_webgl2"),this.parallel=this.extensions.get("KHR_parallel_shader_compile"),this.drawBuffersIndexedExt=this.extensions.get("OES_draw_buffers_indexed"),t.reversedDepthBuffer&&(this.extensions.has("EXT_clip_control")?e.reversedDepthBuffer=!0:(K("WebGPURenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer."),e.reversedDepthBuffer=!1)),e.reversedDepthBuffer&&this.state.setReversedDepth(!0)}get coordinateSystem(){return sn}get hasTimestamp(){return this.disjoint!==null}async getArrayBufferAsync(e,t=null,s=0,n=-1){return await this.attributeUtils.getArrayBufferAsync(e,t,s,n)}async makeXRCompatible(){this.gl.getContextAttributes().xrCompatible!==!0&&await this.gl.makeXRCompatible()}setXRTarget(e){this._xrFramebuffer=e}setXRRenderTargetTextures(e,t,s=null){let n=this.gl;if(this.set(e.texture,{textureGPU:t,glInternalFormat:n.RGBA8}),s!==null){let a=e.stencilBuffer?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24;this.set(e.depthTexture,{textureGPU:s,glInternalFormat:a}),this.extensions.has("WEBGL_multisampled_render_to_texture")===!0&&e._autoAllocateDepthBuffer===!0&&e.multiview===!1&&K("WebGLBackend: Render-to-texture extension was disabled because an external texture was provided"),e._autoAllocateDepthBuffer=!1}}initTimestampQuery(e,t){if(!this.disjoint||!this.trackTimestamp)return;this.timestampQueryPool[e]||(this.timestampQueryPool[e]=new SS(this.gl,e,2048));let s=this.timestampQueryPool[e];s.allocateQueriesForContext(t)!==null&&s.beginQuery(t)}prepareTimestampBuffer(e,t){if(!this.disjoint||!this.trackTimestamp)return;this.timestampQueryPool[e].endQuery(t)}getContext(){return this.gl}beginRender(e){let{state:t}=this,s=this.get(e);if(e.viewport)this.updateViewport(e);else{let{width:a,height:i}=this.getDrawingBufferSize();t.viewport(0,0,a,i)}if(e.scissor)this.updateScissor(e);else{let{width:a,height:i}=this.getDrawingBufferSize();t.scissor(0,0,a,i)}this.initTimestampQuery(Ia.RENDER,this.getTimestampUID(e)),s.previousContext=this._currentContext,this._currentContext=e,this._setFramebuffer(e),this.clear(e.clearColor,e.clearDepth,e.clearStencil,e,!1);let n=e.occlusionQueryCount;n>0?(s.currentOcclusionQueries=s.occlusionQueries,s.currentOcclusionQueryObjects=s.occlusionQueryObjects,s.lastOcclusionObject=null,s.occlusionQueries=new Array(n),s.occlusionQueryObjects=new Array(n),s.occlusionQueryIndex=0):s.lastOcclusionObject!==void 0&&(s.lastOcclusionObject=void 0)}finishRender(e){let{gl:t,state:s}=this,n=this.get(e),a=n.previousContext;if(s.resetVertexState(),e.occlusionQueryCount>0){let c=n.lastOcclusionObject;c&&c.occlusionTest===!0&&t.endQuery(t.ANY_SAMPLES_PASSED),this.resolveOccludedAsync(e)}let o=e.textures;if(o!==null)for(let c=0;c<o.length;c++){let l=o[c];l.generateMipmaps&&this.generateMipmaps(l)}if(this._currentContext=a,this._resolveRenderTarget(e),a!==null){if(this._setFramebuffer(a),a.viewport)this.updateViewport(a);else{let{width:c,height:l}=this.getDrawingBufferSize();s.viewport(0,0,c,l)}if(a.scissor)this.updateScissor(a);else{let{width:c,height:l}=this.getDrawingBufferSize();s.scissor(0,0,c,l)}}this.prepareTimestampBuffer(Ia.RENDER,this.getTimestampUID(e))}resolveOccludedAsync(e){let t=this.get(e),{currentOcclusionQueries:s,currentOcclusionQueryObjects:n}=t;if(s&&n){let a=new WeakSet,{gl:i}=this;t.currentOcclusionQueryObjects=null,t.currentOcclusionQueries=null;let o=()=>{let c=!0;for(let l=0;l<s.length;l++){let h=s[l];h&&(i.getQueryParameter(h,i.QUERY_RESULT_AVAILABLE)?(i.getQueryParameter(h,i.QUERY_RESULT)===0&&a.add(n[l]),s[l]=null,i.deleteQuery(h)):c=!1)}c===!1?requestAnimationFrame(o):t.occluded=a};o()}}isOccluded(e,t){let s=this.get(e);return s.occluded&&s.occluded.has(t)}updateViewport(e){let{state:t}=this,{x:s,y:n,width:a,height:i}=e.viewportValue;t.viewport(s,e.height-i-n,a,i)}updateScissor(e){let{state:t}=this,{x:s,y:n,width:a,height:i}=e.scissorValue;t.scissor(s,e.height-i-n,a,i)}setScissorTest(e){this.state.setScissorTest(e)}resetState(){this.state.reset()}getClearColor(){let e=super.getClearColor();return e.r*=e.a,e.g*=e.a,e.b*=e.a,e}clear(e,t,s,n=null,a=!0,i=!0){let{gl:o,renderer:c}=this;n===null&&(n={textures:null,clearColorValue:this.getClearColor()});let l=0;if(e&&(l|=o.COLOR_BUFFER_BIT),t&&(l|=o.DEPTH_BUFFER_BIT),s&&(l|=o.STENCIL_BUFFER_BIT),l!==0){let h;n.clearColorValue?h=n.clearColorValue:h=this.getClearColor();let u=c.getClearDepth(),d=c.getClearStencil();if(t&&this.state.setDepthMask(!0),s&&this.state.setStencilMask(4294967295),n.textures===null)e&&o.clearColor(h.r,h.g,h.b,h.a),t&&o.clearDepth(u),s&&o.clearStencil(d),o.clear(l);else{if(a&&this._setFramebuffer(n),e)for(let f=0;f<n.textures.length;f++){let p=n.mrt?n.mrt.getClearColor(n.textures[f].name):null;p!==null?o.clearBufferfv(o.COLOR,f,[p.r,p.g,p.b,p.a]):f===0?o.clearBufferfv(o.COLOR,f,[h.r,h.g,h.b,h.a]):o.clearBufferfv(o.COLOR,f,[0,0,0,1])}t&&s?o.clearBufferfi(o.DEPTH_STENCIL,0,u,d):t?o.clearBufferfv(o.DEPTH,0,[u]):s&&o.clearBufferiv(o.STENCIL,0,[d]),a&&i&&this._resolveRenderTarget(n),a&&this._currentContext!==null&&this._currentContext!==n&&this._setFramebuffer(this._currentContext)}}}beginCompute(e){let{state:t,gl:s}=this;t.bindFramebuffer(s.FRAMEBUFFER,null),this.initTimestampQuery(Ia.COMPUTE,this.getTimestampUID(e))}compute(e,t,s,n,a=null){let{state:i,gl:o}=this;this.discard===!1&&(i.enable(o.RASTERIZER_DISCARD),this.discard=!0);let{programGPU:c,transformBuffers:l,attributes:h}=this.get(n),u=this._getVaoKey(h),d=this.vaoCache[u];d===void 0?this.vaoCache[u]=this._createVao(h):i.setVertexState(d),i.useProgram(c),this._bindUniforms(s);let f=this._getTransformFeedback(l);o.bindTransformFeedback(o.TRANSFORM_FEEDBACK,f),o.beginTransformFeedback(o.POINTS),a=a!==null?a:t.count,Array.isArray(a)?(je("WebGLBackend.compute(): The count parameter must be a single number, not an array."),a=a[0]):a&&typeof a=="object"&&a.isIndirectStorageBufferAttribute&&(je("WebGLBackend.compute(): The count parameter must be a single number, not IndirectStorageBufferAttribute"),a=t.count),h[0].isStorageInstancedBufferAttribute?o.drawArraysInstanced(o.POINTS,0,1,a):o.drawArrays(o.POINTS,0,a),o.endTransformFeedback(),o.bindTransformFeedback(o.TRANSFORM_FEEDBACK,null);for(let p=0;p<l.length;p++){let m=l[p];m.pbo&&this.has(m.pbo)&&this.textureUtils.copyBufferToTexture(m.transformBuffer,m.pbo),m.switchBuffers()}}finishCompute(e){let{state:t,gl:s}=this;this.discard=!1,t.disable(s.RASTERIZER_DISCARD),this.prepareTimestampBuffer(Ia.COMPUTE,this.getTimestampUID(e)),this._currentContext&&this._setFramebuffer(this._currentContext)}_isRenderCameraDepthArray(e){return e.depthTexture&&e.depthTexture.isArrayTexture&&e.camera.isArrayCamera}_draw(e,t,s,n,a,i){if(e.isBatchedMesh)if(this.hasFeature("WEBGL_multi_draw")===!1){let{gl:o}=this,c=o.getUniformLocation(i,"nodeUniformDrawId"),l=e._multiDrawStarts,h=e._multiDrawCounts,u=e._multiDrawCount;for(let d=0;d<u;d++)o.uniform1ui(c,d),t.render(l[d],h[d])}else t.renderMultiDraw(e._multiDrawStarts,e._multiDrawCounts,e._multiDrawCount);else a>1?t.renderInstances(s,n,a):t.render(s,n)}draw(e){let{object:t,pipeline:s,material:n,context:a,hardwareClippingPlanes:i}=e,{programGPU:o}=this.get(s),{gl:c,state:l}=this,h=this.get(a),u=e.getDrawParameters();if(u===null)return;this._bindUniforms(e.getBindings());let d=t.isMesh&&t.matrixWorld.determinantAffine()<0;l.setMaterial(n,d,i),a.mrt!==null&&a.textures!==null&&l.setMRTBlending(a.textures,a.mrt,n),l.useProgram(o);let f=e.getAttributes(),p=this.get(f),m=p.vaoGPU;if(m===void 0){let A=this._getVaoKey(f);m=this.vaoCache[A],m===void 0&&(m=this._createVao(f),this.vaoCache[A]=m,p.vaoGPU=m)}let b=e.getIndex(),g=b!==null?this.get(b).bufferGPU:null;l.setVertexState(m,g);let x=h.lastOcclusionObject;if(x!==t&&x!==void 0){if(x!==null&&x.occlusionTest===!0&&(c.endQuery(c.ANY_SAMPLES_PASSED),h.occlusionQueryIndex++),t.occlusionTest===!0){let A=c.createQuery();c.beginQuery(c.ANY_SAMPLES_PASSED,A),h.occlusionQueries[h.occlusionQueryIndex]=A,h.occlusionQueryObjects[h.occlusionQueryIndex]=t}h.lastOcclusionObject=t}let T=this.bufferRenderer;t.isPoints?T.mode=c.POINTS:t.isLineSegments?T.mode=c.LINES:t.isLine?T.mode=c.LINE_STRIP:t.isLineLoop?T.mode=c.LINE_LOOP:n.wireframe===!0?(l.setLineWidth(n.wireframeLinewidth*this.renderer.getPixelRatio()),T.mode=c.LINES):T.mode=c.TRIANGLES;let{vertexCount:y,instanceCount:v}=u,{firstVertex:_}=u;if(T.object=t,b!==null){_*=b.array.BYTES_PER_ELEMENT;let A=this.get(b);T.index=b.count,T.type=A.type}else T.index=0;if(e.camera.isArrayCamera===!0&&e.camera.cameras.length>0&&e.camera.isMultiViewCamera===!1){let A=this.get(e.camera),M=e.camera.cameras,N=e.getBindingGroup("cameraIndex").bindings[0];if(A.indexesGPU===void 0||A.indexesGPU.length!==M.length){let U=new Uint32Array([0,0,0,0]),j=[];for(let z=0,H=M.length;z<H;z++){let J=c.createBuffer();U[0]=z,c.bindBuffer(c.UNIFORM_BUFFER,J),c.bufferData(c.UNIFORM_BUFFER,U,c.STATIC_DRAW),j.push(J)}A.indexesGPU=j}let R=0;e:for(let U of e.getBindings())for(let j of U.bindings){if(j===N)break e;(j.isUniformsGroup||j.isUniformBuffer)&&R++}let I=this._currentContext.renderTarget,D=I===null||I.isPostProcessingRenderTarget===!0?this.renderer.getPixelRatio():1,O=this._isRenderCameraDepthArray(this._currentContext),P=this._currentContext.activeCubeFace;if(O){let U=this.get(I.depthTexture);if(U.clearedRenderId!==this.renderer._nodes.nodeFrame.renderId){U.clearedRenderId=this.renderer._nodes.nodeFrame.renderId;let{stencilBuffer:j}=I;for(let z=0,H=M.length;z<H;z++)this.renderer._activeCubeFace=z,this._currentContext.activeCubeFace=z,this._setFramebuffer(this._currentContext),this.clear(!1,!0,j,this._currentContext,!1,!1);this.renderer._activeCubeFace=P,this._currentContext.activeCubeFace=P}}for(let U=0,j=M.length;U<j;U++){let z=M[U];if(t.layers.test(z.layers)){O&&(this.renderer._activeCubeFace=U,this._currentContext.activeCubeFace=U,this._setFramebuffer(this._currentContext));let H=z.viewport;if(H!==void 0){let J=H.x*D,ee=H.y*D,se=H.width*D,_e=H.height*D;l.viewport(Math.floor(J),Math.floor(e.context.height-_e-ee),Math.floor(se),Math.floor(_e))}l.bindBufferBase(c.UNIFORM_BUFFER,R,A.indexesGPU[U]),this._draw(t,T,_,y,v,o)}this._currentContext.activeCubeFace=P,this.renderer._activeCubeFace=P}}else this._draw(t,T,_,y,v,o)}needsRenderUpdate(){return!1}getRenderCacheKey(){return""}createDefaultTexture(e){this.textureUtils.createDefaultTexture(e)}createTexture(e,t){this.textureUtils.createTexture(e,t)}updateTexture(e,t){this.textureUtils.updateTexture(e,t)}generateMipmaps(e){this.textureUtils.generateMipmaps(e)}destroyTexture(e,t=!1){this.textureUtils.destroyTexture(e,t)}async copyTextureToBuffer(e,t,s,n,a,i){return this.textureUtils.copyTextureToBuffer(e,t,s,n,a,i)}updateSampler(){return""}createNodeBuilder(e,t){return new pT(e,t)}createProgram(e){let t=this.gl,{stage:s,code:n}=e,a=s==="fragment"?t.createShader(t.FRAGMENT_SHADER):t.createShader(t.VERTEX_SHADER);t.shaderSource(a,n),t.compileShader(a),this.set(e,{shaderGPU:a})}destroyProgram(e){this.delete(e)}createRenderPipeline(e,t){let s=this.gl,n=e.pipeline,{fragmentProgram:a,vertexProgram:i}=n,o=s.createProgram(),c=this.get(a).shaderGPU,l=this.get(i).shaderGPU;if(s.attachShader(o,c),s.attachShader(o,l),s.linkProgram(o),this.set(n,{programGPU:o,fragmentShader:c,vertexShader:l}),t!==null&&this.parallel){let h=new Promise(u=>{let d=this.parallel,f=()=>{s.getProgramParameter(o,d.COMPLETION_STATUS_KHR)?(this._completeCompile(e,n),u()):requestAnimationFrame(f)};f()});t.push(h);return}this._completeCompile(e,n)}_handleSource(e,t){let s=e.split(`
`),n=[],a=Math.max(t-6,0),i=Math.min(t+6,s.length);for(let o=a;o<i;o++){let c=o+1;n.push(`${c===t?">":" "} ${c}: ${s[o]}`)}return n.join(`
`)}_getShaderErrors(e,t,s){let n=e.getShaderParameter(t,e.COMPILE_STATUS),i=(e.getShaderInfoLog(t)||"").trim();if(n&&i==="")return"";let o=/ERROR: 0:(\d+)/.exec(i);if(o){let c=parseInt(o[1]);return s.toUpperCase()+`

`+i+`

`+this._handleSource(e.getShaderSource(t),c)}else return i}_logProgramError(e,t,s){if(this.renderer.debug.checkShaderErrors){let n=this.gl,i=(n.getProgramInfoLog(e)||"").trim();if(n.getProgramParameter(e,n.LINK_STATUS)===!1)if(typeof this.renderer.debug.onShaderError=="function")this.renderer.debug.onShaderError(n,e,s,t);else{let o=this._getShaderErrors(n,s,"vertex"),c=this._getShaderErrors(n,t,"fragment");W("WebGLProgram: Shader Error "+n.getError()+" - VALIDATE_STATUS "+n.getProgramParameter(e,n.VALIDATE_STATUS)+`

Program Info Log: `+i+`
`+o+`
`+c)}else i!==""&&K("WebGLProgram: Program Info Log:",i)}}_completeCompile(e,t){let{state:s,gl:n}=this,a=this.get(t),{programGPU:i,fragmentShader:o,vertexShader:c}=a;n.getProgramParameter(i,n.LINK_STATUS)===!1&&this._logProgramError(i,o,c),s.useProgram(i);let l=e.getBindings();this._setupBindings(l,i),this.set(t,{programGPU:i,pipeline:i})}createComputePipeline(e,t,s=null){let{gl:n}=this,a={stage:"fragment",code:`#version 300 es
precision highp float;
void main() {}`};this.createProgram(a);let{computeProgram:i}=e,o=n.createProgram(),c=this.get(a).shaderGPU,l=this.get(i).shaderGPU,h=i.transforms,u=[],d=[];for(let b=0;b<h.length;b++){let g=h[b];u.push(g.varyingName),d.push(g.attributeNode)}n.attachShader(o,c),n.attachShader(o,l),n.transformFeedbackVaryings(o,u,n.SEPARATE_ATTRIBS),n.linkProgram(o);let f=i.attributes,p=[],m=[];for(let b=0;b<f.length;b++){let g=f[b].node.attribute;p.push(g),this.has(g)||this.attributeUtils.createAttribute(g,n.ARRAY_BUFFER)}for(let b=0;b<d.length;b++){let g=d[b].attribute;this.has(g)||this.attributeUtils.createAttribute(g,n.ARRAY_BUFFER);let x=this.get(g);m.push(x)}if(this.set(e,{programGPU:o,fragmentShader:c,vertexShader:l,transformBuffers:m,attributes:p}),s!==null&&this.parallel){let b=this.parallel,g=new Promise(x=>{let T=()=>{n.getProgramParameter(o,b.COMPLETION_STATUS_KHR)?(this._completeComputeCompile(e,t),x()):requestAnimationFrame(T)};T()});s.push(g);return}this._completeComputeCompile(e,t)}_completeComputeCompile(e,t){let{state:s,gl:n}=this,{programGPU:a,fragmentShader:i,vertexShader:o}=this.get(e);n.getProgramParameter(a,n.LINK_STATUS)===!1&&this._logProgramError(a,i,o),s.useProgram(a),this._setupBindings(t,a)}createBindings(e,t){if(this._knownBindings.has(t)===!1){this._knownBindings.add(t);let s=0,n=0;for(let a of t){this.set(a,{textures:n,uniformBuffers:s});for(let i of a.bindings)i.isUniformBuffer&&s++,i.isSampledTexture&&n++}}this.updateBindings(e,t)}updateBindings(e){let{gl:t}=this;for(let s of e.bindings){let n=this.get(s);if(s.isUniformsGroup||s.isUniformBuffer){let a=s.buffer,i=n.bufferGPU;t.bindBuffer(t.UNIFORM_BUFFER,i);let o=s.updateRanges;if(t.bindBuffer(t.UNIFORM_BUFFER,i),o.length===0)t.bufferData(t.UNIFORM_BUFFER,a,t.DYNAMIC_DRAW);else{let c=bl(a),l=c?1:a.BYTES_PER_ELEMENT;for(let h=0,u=o.length;h<u;h++){let d=o[h],f=d.start*l,p=d.count*l,m=f*(c?a.BYTES_PER_ELEMENT:1);t.bufferSubData(t.UNIFORM_BUFFER,m,a,f,p)}}this.set(s,n)}else if(s.isSampledTexture){let{textureGPU:a,glTextureType:i}=this.get(s.texture);n.textureGPU=a,n.glTextureType=i,this.set(s,n)}}}updateBinding(e){let t=this.gl;if(e.isUniformsGroup||e.isUniformBuffer){let n=this.get(e).bufferGPU,a=e.buffer,i=e.updateRanges;if(t.bindBuffer(t.UNIFORM_BUFFER,n),i.length===0)t.bufferData(t.UNIFORM_BUFFER,a,t.DYNAMIC_DRAW);else{let o=bl(a),c=o?1:a.BYTES_PER_ELEMENT,l=i[0].start;for(let h=0,u=i.length;h<u;h++){let d=i[h],f=i[h+1],p=d.start+d.count;if(f!==void 0&&f.start===p)continue;let m=l*c,b=(p-l)*c,g=m*(o?a.BYTES_PER_ELEMENT:1);t.bufferSubData(t.UNIFORM_BUFFER,g,a,m,b),f!==void 0&&(l=f.start)}}}}createUniformBuffer(e){let t=this.get(e);if(t.bufferGPU===void 0){let s=this.gl,n=e.buffer;t.bufferGPU=s.createBuffer(),s.bindBuffer(s.UNIFORM_BUFFER,t.bufferGPU),s.bufferData(s.UNIFORM_BUFFER,n.byteLength,s.DYNAMIC_DRAW)}}destroyUniformBuffer(e){let t=this.get(e);this.gl.deleteBuffer(t.bufferGPU),this.delete(e)}createIndexAttribute(e){let t=this.gl;this.attributeUtils.createAttribute(e,t.ELEMENT_ARRAY_BUFFER)}createAttribute(e){if(this.has(e))return;let t=this.gl;this.attributeUtils.createAttribute(e,t.ARRAY_BUFFER)}createStorageAttribute(e){if(this.has(e))return;let t=this.gl;this.attributeUtils.createAttribute(e,t.ARRAY_BUFFER)}updateAttribute(e){this.attributeUtils.updateAttribute(e)}destroyAttribute(e){this.attributeUtils.destroyAttribute(e)}hasFeature(e){let t=Object.keys(tI).filter(n=>tI[n]===e),s=this.extensions;for(let n=0;n<t.length;n++)if(s.has(t[n]))return!0;return!1}copyTextureToTexture(e,t,s=null,n=null,a=0,i=0){this.textureUtils.copyTextureToTexture(e,t,s,n,a,i)}copyFramebufferToTexture(e,t,s){this.textureUtils.copyFramebufferToTexture(e,t,s)}hasCompatibility(e){return e===Hr.TEXTURE_COMPARE?!0:super.hasCompatibility(e)}initRenderTarget(e){let{gl:t,state:s}=this;this._setFramebuffer(e),s.bindFramebuffer(t.FRAMEBUFFER,null)}_setFramebuffer(e){let{gl:t,state:s}=this,n=null;if(e.textures!==null){let a=e.renderTarget,i=this.get(a),{depthBuffer:o,stencilBuffer:c}=a,l=a.isCubeRenderTarget===!0,h=a.isRenderTarget3D===!0,u=a.depth>1,d=a.isXRRenderTarget===!0,f=d===!0&&a._hasExternalTextures===!0,p=i.msaaFrameBuffer,m=i.depthRenderbuffer,b=this.extensions.get("WEBGL_multisampled_render_to_texture"),g=this.extensions.get("OVR_multiview2"),x=this._useMultisampledExtension(a),T=a.samples;e.depthTexture!==null&&e.depthTexture.renderTarget!==a&&x===!1&&T>0&&(je('WebGLBackend: Shared depth texture is not supported with MSAA when "WEBGL_multisampled_render_to_texture" is unsupported. Falling back to single-sample rendering.'),T=0);let y=LF(e),v;if(l?(i.cubeFramebuffers||(i.cubeFramebuffers={}),v=i.cubeFramebuffers[y]):d&&f===!1?v=this._xrFramebuffer:(i.framebuffers||(i.framebuffers={}),v=i.framebuffers[y]),v===void 0){v=t.createFramebuffer(),s.bindFramebuffer(t.FRAMEBUFFER,v);let _=e.textures,A=[];if(l){i.cubeFramebuffers[y]=v;let{textureGPU:N}=this.get(_[0]),R=this.renderer._activeCubeFace,I=this.renderer._activeMipmapLevel;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+R,N,I)}else{i.framebuffers[y]=v;for(let N=0;N<_.length;N++){let R=_[N],I=this.get(R);I.renderTarget=e.renderTarget,I.cacheKey=y;let D=t.COLOR_ATTACHMENT0+N;if(a.multiview)g.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,D,I.textureGPU,0,T,0,2);else if(h||u){let O=this.renderer._activeCubeFace,P=this.renderer._activeMipmapLevel;t.framebufferTextureLayer(t.FRAMEBUFFER,D,I.textureGPU,P,O)}else if(x)b.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,D,t.TEXTURE_2D,I.textureGPU,0,T);else{let O=this.renderer._activeMipmapLevel;t.framebufferTexture2D(t.FRAMEBUFFER,D,t.TEXTURE_2D,I.textureGPU,O)}}}let M=c?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;if(a._autoAllocateDepthBuffer===!0){let N=t.createRenderbuffer();this.textureUtils.setupRenderBufferStorage(N,e,0,x),i.xrDepthRenderbuffer=N,A.push(c?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT),t.bindRenderbuffer(t.RENDERBUFFER,N),t.framebufferRenderbuffer(t.FRAMEBUFFER,M,t.RENDERBUFFER,N)}else if(e.depthTexture!==null){A.push(c?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT);let N=this.get(e.depthTexture);if(N.renderTarget=e.renderTarget,N.cacheKey=y,a.multiview)g.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,M,N.textureGPU,0,T,0,2);else if(f&&x)b.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,M,t.TEXTURE_2D,N.textureGPU,0,T);else if(e.depthTexture.isArrayTexture){let R=this.renderer._activeCubeFace;t.framebufferTextureLayer(t.FRAMEBUFFER,M,N.textureGPU,0,R)}else if(e.depthTexture.isCubeTexture){let R=this.renderer._activeCubeFace;t.framebufferTexture2D(t.FRAMEBUFFER,M,t.TEXTURE_CUBE_MAP_POSITIVE_X+R,N.textureGPU,0)}else t.framebufferTexture2D(t.FRAMEBUFFER,M,t.TEXTURE_2D,N.textureGPU,0)}i.depthInvalidationArray=A}else{if(this._isRenderCameraDepthArray(e)){s.bindFramebuffer(t.FRAMEBUFFER,v);let A=this.renderer._activeCubeFace,M=this.get(e.depthTexture),N=c?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.framebufferTextureLayer(t.FRAMEBUFFER,N,M.textureGPU,0,A)}if((d||x||a.multiview)&&a._isOpaqueFramebuffer!==!0){s.bindFramebuffer(t.FRAMEBUFFER,v);let A=this.get(e.textures[0]);a.multiview?g.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,A.textureGPU,0,T,0,2):x?b.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,A.textureGPU,0,T):t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,A.textureGPU,0);let M=c?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;if(a._autoAllocateDepthBuffer===!0){let N=i.xrDepthRenderbuffer;t.bindRenderbuffer(t.RENDERBUFFER,N),t.framebufferRenderbuffer(t.FRAMEBUFFER,M,t.RENDERBUFFER,N)}else{let N=this.get(e.depthTexture);a.multiview?g.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,M,N.textureGPU,0,T,0,2):x?b.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,M,t.TEXTURE_2D,N.textureGPU,0,T):t.framebufferTexture2D(t.FRAMEBUFFER,M,t.TEXTURE_2D,N.textureGPU,0)}}}if(T>0&&x===!1&&!a.multiview){if(p===void 0){p=t.createFramebuffer(),s.bindFramebuffer(t.FRAMEBUFFER,p);let _=[],A=e.textures;for(let M=0;M<A.length;M++){_[M]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,_[M]);let N=e.textures[M],R=this.get(N);t.renderbufferStorageMultisample(t.RENDERBUFFER,T,R.glInternalFormat,e.width,e.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+M,t.RENDERBUFFER,_[M])}t.bindRenderbuffer(t.RENDERBUFFER,null),i.msaaFrameBuffer=p,i.msaaRenderbuffers=_,o&&m===void 0&&(m=t.createRenderbuffer(),this.textureUtils.setupRenderBufferStorage(m,e,T),i.depthRenderbuffer=m)}n=i.msaaFrameBuffer}else n=v;s.drawBuffers(e,v)}s.bindFramebuffer(t.FRAMEBUFFER,n)}_getVaoKey(e){let t="";for(let s=0;s<e.length;s++){let n=this.get(e[s]);t+=":"+n.id}return t}_createVao(e){let{gl:t}=this,s=t.createVertexArray();t.bindVertexArray(s);for(let n=0;n<e.length;n++){let a=e[n],i=this.get(a);t.bindBuffer(t.ARRAY_BUFFER,i.bufferGPU),t.enableVertexAttribArray(n);let o,c;a.isInterleavedBufferAttribute===!0?(o=a.data.stride*i.bytesPerElement,c=a.offset*i.bytesPerElement):(o=0,c=0),i.isInteger?t.vertexAttribIPointer(n,a.itemSize,i.type,o,c):t.vertexAttribPointer(n,a.itemSize,i.type,a.normalized,o,c),a.isInstancedBufferAttribute&&!a.isInterleavedBufferAttribute?t.vertexAttribDivisor(n,a.meshPerAttribute):a.isInterleavedBufferAttribute&&a.data.isInstancedInterleavedBuffer&&t.vertexAttribDivisor(n,a.data.meshPerAttribute)}return t.bindBuffer(t.ARRAY_BUFFER,null),s}_getTransformFeedback(e){let t="";for(let a=0;a<e.length;a++)t+=":"+e[a].id;let s=this.transformFeedbackCache[t];if(s!==void 0)return s;let{gl:n}=this;s=n.createTransformFeedback(),n.bindTransformFeedback(n.TRANSFORM_FEEDBACK,s);for(let a=0;a<e.length;a++){let i=e[a];n.bindBufferBase(n.TRANSFORM_FEEDBACK_BUFFER,a,i.transformBuffer)}return n.bindTransformFeedback(n.TRANSFORM_FEEDBACK,null),this.transformFeedbackCache[t]=s,s}_setupBindings(e,t){let s=this.gl,n=0,a=0;for(let i of e)for(let o of i.bindings)if(o.isUniformsGroup||o.isUniformBuffer){let c=n++,l=s.getUniformBlockIndex(t,o.name);s.uniformBlockBinding(t,l,c)}else if(o.isSampledTexture){let c=a++,l=s.getUniformLocation(t,o.name);s.uniform1i(l,c)}}_bindUniforms(e){let{gl:t,state:s}=this,n=0,a=0;for(let i of e)for(let o of i.bindings){let c=this.get(o);if(o.isUniformsGroup||o.isUniformBuffer){let l=n++;s.bindBufferBase(t.UNIFORM_BUFFER,l,c.bufferGPU)}else if(o.isSampledTexture){let l=a++;s.bindTexture(c.glTextureType,c.textureGPU,t.TEXTURE0+l)}}}_resolveRenderTarget(e){let{gl:t,state:s}=this,n=e.renderTarget;if(e.textures!==null&&n){let a=this.get(n);if(n.samples>0&&a.msaaFrameBuffer!==void 0&&this._useMultisampledExtension(n)===!1){let i=a.framebuffers[e.getCacheKey()],o=n.resolveColorBuffer===!1?0:t.COLOR_BUFFER_BIT;n.resolveDepthBuffer&&(n.depthBuffer&&(o|=t.DEPTH_BUFFER_BIT),n.stencilBuffer&&n.resolveStencilBuffer&&(o|=t.STENCIL_BUFFER_BIT));let c=a.msaaFrameBuffer,l=a.msaaRenderbuffers,h=e.textures,u=h.length>1;if(s.bindFramebuffer(t.READ_FRAMEBUFFER,c),s.bindFramebuffer(t.DRAW_FRAMEBUFFER,i),u)for(let d=0;d<h.length;d++)t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0+d,t.RENDERBUFFER,null),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+d,t.TEXTURE_2D,null,0);for(let d=0;d<h.length;d++){if(u){let{textureGPU:f}=this.get(h[d]);t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,l[d]),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,f,0)}if(e.scissor){let{x:f,y:p,width:m,height:b}=e.scissorValue,g=e.height-b-p;t.blitFramebuffer(f,g,f+m,g+b,f,g,f+m,g+b,o,t.NEAREST)}else t.blitFramebuffer(0,0,e.width,e.height,0,0,e.width,e.height,o,t.NEAREST)}if(u)for(let d=0;d<h.length;d++){let{textureGPU:f}=this.get(h[d]);t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0+d,t.RENDERBUFFER,l[d]),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+d,t.TEXTURE_2D,f,0)}if(this._supportsInvalidateFramebuffer===!0){if(n.storeMultisampledColorBuffer===!1)for(let d=0;d<h.length;d++)lm.push(t.COLOR_ATTACHMENT0+d);n.depthBuffer&&n.storeMultisampledDepthBuffer===!1&&lm.push(n.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT),lm.length>0&&(t.invalidateFramebuffer(t.READ_FRAMEBUFFER,lm),lm.length=0)}}else if(this._supportsInvalidateFramebuffer===!0&&a.framebuffers&&(n._autoAllocateDepthBuffer===!0||n.samples>0&&n.storeMultisampledDepthBuffer===!1)){let i=a.framebuffers[e.getCacheKey()];s.bindFramebuffer(t.DRAW_FRAMEBUFFER,i),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,a.depthInvalidationArray)}}}_useMultisampledExtension(e){return e.multiview===!0?!0:e.samples>0&&this.extensions.has("WEBGL_multisampled_render_to_texture")===!0&&e._autoAllocateDepthBuffer!==!1}async dispose(){await super.dispose(),this.textureUtils!==null&&this.textureUtils.dispose();let e=this.extensions.get("WEBGL_lose_context");e&&e.loseContext(),this.renderer.domElement.removeEventListener("webglcontextlost",this._onContextLost)}},ym={PointList:"point-list",LineList:"line-list",LineStrip:"line-strip",TriangleList:"triangle-list"},Ai=typeof self<"u"&&self.GPUShaderStage?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4},Ks={Never:"never",Less:"less",Equal:"equal",LessEqual:"less-equal",Greater:"greater",NotEqual:"not-equal",GreaterEqual:"greater-equal",Always:"always"},as={Store:"store",Discard:"discard"},ct={Load:"load",Clear:"clear"},sI={CCW:"ccw",CW:"cw"},nI={None:"none",Back:"back"},gT={Uint16:"uint16",Uint32:"uint32"},B={R8Unorm:"r8unorm",R8Snorm:"r8snorm",R8Uint:"r8uint",R8Sint:"r8sint",R16Uint:"r16uint",R16Sint:"r16sint",R16Float:"r16float",RG8Unorm:"rg8unorm",RG8Snorm:"rg8snorm",RG8Uint:"rg8uint",RG8Sint:"rg8sint",R16Unorm:"r16unorm",R16Snorm:"r16snorm",R32Uint:"r32uint",R32Sint:"r32sint",R32Float:"r32float",RG16Uint:"rg16uint",RG16Sint:"rg16sint",RG16Float:"rg16float",RGBA8Unorm:"rgba8unorm",RGBA8UnormSRGB:"rgba8unorm-srgb",RGBA8Snorm:"rgba8snorm",RGBA8Uint:"rgba8uint",RGBA8Sint:"rgba8sint",BGRA8Unorm:"bgra8unorm",BGRA8UnormSRGB:"bgra8unorm-srgb",RG16Unorm:"rg16unorm",RG16Snorm:"rg16snorm",RGB9E5UFloat:"rgb9e5ufloat",RGB10A2Unorm:"rgb10a2unorm",RG11B10UFloat:"rg11b10ufloat",RG32Uint:"rg32uint",RG32Sint:"rg32sint",RG32Float:"rg32float",RGBA16Uint:"rgba16uint",RGBA16Sint:"rgba16sint",RGBA16Float:"rgba16float",RGBA16Unorm:"rgba16unorm",RGBA16Snorm:"rgba16snorm",RGBA32Uint:"rgba32uint",RGBA32Sint:"rgba32sint",RGBA32Float:"rgba32float",Depth16Unorm:"depth16unorm",Depth24Plus:"depth24plus",Depth24PlusStencil8:"depth24plus-stencil8",Depth32Float:"depth32float",Depth32FloatStencil8:"depth32float-stencil8",BC1RGBAUnorm:"bc1-rgba-unorm",BC1RGBAUnormSRGB:"bc1-rgba-unorm-srgb",BC2RGBAUnorm:"bc2-rgba-unorm",BC2RGBAUnormSRGB:"bc2-rgba-unorm-srgb",BC3RGBAUnorm:"bc3-rgba-unorm",BC3RGBAUnormSRGB:"bc3-rgba-unorm-srgb",BC4RUnorm:"bc4-r-unorm",BC4RSnorm:"bc4-r-snorm",BC5RGUnorm:"bc5-rg-unorm",BC5RGSnorm:"bc5-rg-snorm",BC6HRGBUFloat:"bc6h-rgb-ufloat",BC6HRGBFloat:"bc6h-rgb-float",BC7RGBAUnorm:"bc7-rgba-unorm",BC7RGBAUnormSRGB:"bc7-rgba-unorm-srgb",ETC2RGB8Unorm:"etc2-rgb8unorm",ETC2RGB8UnormSRGB:"etc2-rgb8unorm-srgb",ETC2RGB8A1Unorm:"etc2-rgb8a1unorm",ETC2RGB8A1UnormSRGB:"etc2-rgb8a1unorm-srgb",ETC2RGBA8Unorm:"etc2-rgba8unorm",ETC2RGBA8UnormSRGB:"etc2-rgba8unorm-srgb",EACR11Unorm:"eac-r11unorm",EACR11Snorm:"eac-r11snorm",EACRG11Unorm:"eac-rg11unorm",EACRG11Snorm:"eac-rg11snorm",ASTC4x4Unorm:"astc-4x4-unorm",ASTC4x4UnormSRGB:"astc-4x4-unorm-srgb",ASTC5x4Unorm:"astc-5x4-unorm",ASTC5x4UnormSRGB:"astc-5x4-unorm-srgb",ASTC5x5Unorm:"astc-5x5-unorm",ASTC5x5UnormSRGB:"astc-5x5-unorm-srgb",ASTC6x5Unorm:"astc-6x5-unorm",ASTC6x5UnormSRGB:"astc-6x5-unorm-srgb",ASTC6x6Unorm:"astc-6x6-unorm",ASTC6x6UnormSRGB:"astc-6x6-unorm-srgb",ASTC8x5Unorm:"astc-8x5-unorm",ASTC8x5UnormSRGB:"astc-8x5-unorm-srgb",ASTC8x6Unorm:"astc-8x6-unorm",ASTC8x6UnormSRGB:"astc-8x6-unorm-srgb",ASTC8x8Unorm:"astc-8x8-unorm",ASTC8x8UnormSRGB:"astc-8x8-unorm-srgb",ASTC10x5Unorm:"astc-10x5-unorm",ASTC10x5UnormSRGB:"astc-10x5-unorm-srgb",ASTC10x6Unorm:"astc-10x6-unorm",ASTC10x6UnormSRGB:"astc-10x6-unorm-srgb",ASTC10x8Unorm:"astc-10x8-unorm",ASTC10x8UnormSRGB:"astc-10x8-unorm-srgb",ASTC10x10Unorm:"astc-10x10-unorm",ASTC10x10UnormSRGB:"astc-10x10-unorm-srgb",ASTC12x10Unorm:"astc-12x10-unorm",ASTC12x10UnormSRGB:"astc-12x10-unorm-srgb",ASTC12x12Unorm:"astc-12x12-unorm",ASTC12x12UnormSRGB:"astc-12x12-unorm-srgb"},VA={ClampToEdge:"clamp-to-edge",Repeat:"repeat",MirrorRepeat:"mirror-repeat"},Fa={Linear:"linear",Nearest:"nearest"},it={Zero:"zero",One:"one",Src:"src",OneMinusSrc:"one-minus-src",SrcAlpha:"src-alpha",OneMinusSrcAlpha:"one-minus-src-alpha",Dst:"dst",OneMinusDst:"one-minus-dst",DstAlpha:"dst-alpha",OneMinusDstAlpha:"one-minus-dst-alpha",SrcAlphaSaturated:"src-alpha-saturated",Constant:"constant",OneMinusConstant:"one-minus-constant"},vl={Add:"add",Subtract:"subtract",ReverseSubtract:"reverse-subtract",Min:"min",Max:"max"},aI={None:0,All:15},jo={Keep:"keep",Zero:"zero",Replace:"replace",Invert:"invert",IncrementClamp:"increment-clamp",DecrementClamp:"decrement-clamp",IncrementWrap:"increment-wrap",DecrementWrap:"decrement-wrap"},e0={Storage:"storage",ReadOnlyStorage:"read-only-storage"},jA={WriteOnly:"write-only",ReadOnly:"read-only",ReadWrite:"read-write"},iI={NonFiltering:"non-filtering",Comparison:"comparison"},Go={Float:"float",UnfilterableFloat:"unfilterable-float",Depth:"depth",SInt:"sint",UInt:"uint"},GA={TwoD:"2d",ThreeD:"3d"},Js={TwoD:"2d",TwoDArray:"2d-array",Cube:"cube",ThreeD:"3d"},vH={All:"all"},t0={Vertex:"vertex",Instance:"instance"},yT={CoreFeaturesAndLimits:"core-features-and-limits",DepthClipControl:"depth-clip-control",Depth32FloatStencil8:"depth32float-stencil8",TextureCompressionBC:"texture-compression-bc",TextureCompressionBCSliced3D:"texture-compression-bc-sliced-3d",TextureCompressionETC2:"texture-compression-etc2",TextureCompressionASTC:"texture-compression-astc",TextureCompressionASTCSliced3D:"texture-compression-astc-sliced-3d",TimestampQuery:"timestamp-query",IndirectFirstInstance:"indirect-first-instance",ShaderF16:"shader-f16",RG11B10UFloat:"rg11b10ufloat-renderable",BGRA8UNormStorage:"bgra8unorm-storage",Float32Filterable:"float32-filterable",Float32Blendable:"float32-blendable",ClipDistances:"clip-distances",DualSourceBlending:"dual-source-blending",Subgroups:"subgroups",TextureFormatsTier1:"texture-formats-tier1",TextureFormatsTier2:"texture-formats-tier2"},rI={"texture-compression-s3tc":"texture-compression-bc","texture-compression-etc1":"texture-compression-etc2"},NS=class extends dT{constructor(e,t,s){super(e,t?t.value:null),this.textureNode=t,this.groupNode=s}update(){let{textureNode:e}=this;return this.texture!==e.value?(this.texture=e.value,!0):super.update()}},RS=class extends cT{constructor(e,t){super(e,t?t.array:null),this._attribute=t,this.isStorageBuffer=!0}get attribute(){return this._attribute}},_H=0,ES=class extends RS{constructor(e,t){let s=e&&e.name?e.name:_H++;super("StorageBuffer_"+s,e?e.value:null),this.nodeUniform=e,this.access=e?e.access:As.READ_WRITE,this.groupNode=t}get attribute(){return this.nodeUniform.value}get buffer(){return this.nodeUniform.value.array}},HA=[null],CS=class{constructor(e){this.backend=e,this._preferredCanvasFormat=null}getCurrentDepthStencilFormat(e){let t;return e.depth&&(e.depthTexture!==null?t=this.getTextureFormatGPU(e.depthTexture):e.stencil?this.backend.renderer.reversedDepthBuffer===!0?t=B.Depth32FloatStencil8:t=B.Depth24PlusStencil8:this.backend.renderer.reversedDepthBuffer===!0?t=B.Depth32Float:t=B.Depth24Plus),t}getTextureFormatGPU(e){return this.backend.get(e).format}getTextureSampleData(e){let t;if(e.isFramebufferTexture)t=1;else if(e.isDepthTexture&&!e.renderTarget){let i=this.backend.get(e);i.texture!==void 0?t=i.texture.sampleCount:t=this.backend.renderer.currentSamples}else e.renderTarget&&(t=e.renderTarget.samples);t=this.getSampleCount(t||1);let s=t>1&&e.renderTarget!==null&&e.isDepthTexture!==!0&&e.isFramebufferTexture!==!0,n=t>1&&e.renderTarget!==null&&e.isDepthTexture===!0&&e.isArrayTexture===!0;return{samples:t,primarySamples:s||n?1:t,isMSAA:s}}getCurrentColorFormat(e){let t;return e.textures!==null?t=this.getTextureFormatGPU(e.textures[0]):t=this.getPreferredCanvasFormat(),t}getCurrentColorFormats(e){return e.textures!==null?e.textures.map(t=>this.getTextureFormatGPU(t)):[this.getPreferredCanvasFormat()]}getCurrentColorSpace(e){return e.textures!==null?e.textures[0].colorSpace:this.backend.renderer.outputColorSpace}getPrimitiveTopology(e,t){if(e.isPoints)return ym.PointList;if(e.isLineSegments||e.isMesh&&t.wireframe===!0)return ym.LineList;if(e.isLine)return ym.LineStrip;if(e.isMesh)return ym.TriangleList}getSampleCount(e){return e>=4?4:1}getSampleCountRenderContext(e){return e.textures!==null?this.getSampleCount(e.sampleCount):this.getSampleCount(this.backend.renderer.currentSamples)}getPreferredCanvasFormat(){let t=this.backend.parameters.outputType;if(t===void 0)return this._preferredCanvasFormat===null&&(this._preferredCanvasFormat=navigator.gpu.getPreferredCanvasFormat()),this._preferredCanvasFormat;if(t===ws)return B.BGRA8Unorm;if(t===ds)return B.RGBA16Float;throw new Error("THREE.WebGPUUtils: Unsupported output buffer type.")}};function sr(r,e){HA[0]=e,r.queue.submit(HA),HA[0]=null}var xT=class{constructor(){this.label="",this.layout=null,this.entries=[]}reset(){this.label="",this.layout=null,this.entries.length=0}},dc=class{constructor(){this.label="",this.size=0,this.usage=0,this.mappedAtCreation=!1}reset(){this.label="",this.size=0,this.usage=0,this.mappedAtCreation=!1}},Jl=class{constructor(){this.label=""}reset(){this.label=""}},wT=class{constructor(){this.label="",this.colorFormats=null,this.depthStencilFormat=void 0,this.sampleCount=1,this.depthReadOnly=!1,this.stencilReadOnly=!1}reset(){this.label="",this.colorFormats=null,this.depthStencilFormat=void 0,this.sampleCount=1,this.depthReadOnly=!1,this.stencilReadOnly=!1}},Ll=class{constructor(){this.view=null,this.depthSlice=void 0,this.resolveTarget=void 0,this.clearValue=void 0,this.loadOp=void 0,this.storeOp=void 0}reset(){this.view=null,this.depthSlice=void 0,this.resolveTarget=void 0,this.clearValue=void 0,this.loadOp=void 0,this.storeOp=void 0}},zl=class{constructor(){this.label="",this.colorAttachments=[],this.depthStencilAttachment=void 0,this.occlusionQuerySet=void 0,this.timestampWrites=void 0,this.maxDrawCount=5e7}reset(){this.label="",this.colorAttachments.length=0,this.depthStencilAttachment=void 0,this.occlusionQuerySet=void 0,this.timestampWrites=void 0,this.maxDrawCount=5e7}},TT=class{constructor(){this.label="",this.layout=null,this.vertex=null,this.primitive={},this.depthStencil=void 0,this.multisample=new kS,this.fragment=null}reset(){this.label="",this.layout=null,this.vertex=null,this.primitive={},this.depthStencil=void 0,this.multisample.reset(),this.fragment=null}},kS=class{constructor(){this.count=1,this.mask=4294967295,this.alphaToCoverageEnabled=!1}reset(){this.count=1,this.mask=4294967295,this.alphaToCoverageEnabled=!1}},vT=class{constructor(){this.label="",this.code="",this.compilationHints=[]}reset(){this.label="",this.code="",this.compilationHints.length=0}},Xd=class{constructor(){this.label="",this.size={width:0,height:1,depthOrArrayLayers:1},this.mipLevelCount=1,this.sampleCount=1,this.dimension="2d",this.format=void 0,this.usage=void 0,this.viewFormats=[],this.textureBindingViewDimension=void 0}reset(){this.label="",this.size.width=0,this.size.height=1,this.size.depthOrArrayLayers=1,this.mipLevelCount=1,this.sampleCount=1,this.dimension="2d",this.format=void 0,this.usage=void 0,this.viewFormats.length=0,this.textureBindingViewDimension=void 0}},bb=class{constructor(){this.label="",this.format=void 0,this.dimension=void 0,this.usage=0,this.aspect="all",this.baseMipLevel=0,this.mipLevelCount=void 0,this.baseArrayLayer=0,this.arrayLayerCount=void 0,this.swizzle="rgba"}reset(){this.label="",this.format=void 0,this.dimension=void 0,this.usage=0,this.aspect="all",this.baseMipLevel=0,this.mipLevelCount=void 0,this.baseArrayLayer=0,this.arrayLayerCount=void 0,this.swizzle="rgba"}},Ho=new xT,Wo=new dc,s0=new Jl,WA=new wT,qA=new zl,ld=new TT,hm=new Ll,n0=new vT,hd=new Xd,Kt=new bb,IS=class extends hr{constructor(e){super(),this.device=e;let t=`
struct VarysStruct {
	@builtin( position ) Position: vec4f,
	@location( 0 ) vTex : vec2f,
	@location( 1 ) @interpolate(flat, either) vBaseArrayLayer: u32,
};

@group( 0 ) @binding ( 2 )
var<uniform> flipY: u32;

@vertex
fn mainVS(
		@builtin( vertex_index ) vertexIndex : u32,
		@builtin( instance_index ) instanceIndex : u32 ) -> VarysStruct {

	var Varys : VarysStruct;

	var pos = array(
		vec2f( -1, -1 ),
		vec2f( -1,  3 ),
		vec2f(  3, -1 ),
	);

	let p = pos[ vertexIndex ];
	let mult = select( vec2f( 0.5, -0.5 ), vec2f( 0.5, 0.5 ), flipY != 0 );
	Varys.vTex = p * mult + vec2f( 0.5 );
	Varys.Position = vec4f( p, 0, 1 );
	Varys.vBaseArrayLayer = instanceIndex;

	return Varys;

}

@group( 0 ) @binding( 0 )
var imgSampler : sampler;

@group( 0 ) @binding( 1 )
var img2d : texture_2d<f32>;

@fragment
fn main_2d( Varys: VarysStruct ) -> @location( 0 ) vec4<f32> {

	return textureSample( img2d, imgSampler, Varys.vTex );

}

@group( 0 ) @binding( 1 )
var img2dArray : texture_2d_array<f32>;

@fragment
fn main_2d_array( Varys: VarysStruct ) -> @location( 0 ) vec4<f32> {

	return textureSample( img2dArray, imgSampler, Varys.vTex, Varys.vBaseArrayLayer );

}

const faceMat = array(
  mat3x3f(  0,  0,  -2,  0, -2,   0,  1,  1,   1 ),   // pos-x
  mat3x3f(  0,  0,   2,  0, -2,   0, -1,  1,  -1 ),   // neg-x
  mat3x3f(  2,  0,   0,  0,  0,   2, -1,  1,  -1 ),   // pos-y
  mat3x3f(  2,  0,   0,  0,  0,  -2, -1, -1,   1 ),   // neg-y
  mat3x3f(  2,  0,   0,  0, -2,   0, -1,  1,   1 ),   // pos-z
  mat3x3f( -2,  0,   0,  0, -2,   0,  1,  1,  -1 ),   // neg-z
);

@group( 0 ) @binding( 1 )
var imgCube : texture_cube<f32>;

@fragment
fn main_cube( Varys: VarysStruct ) -> @location( 0 ) vec4<f32> {

	return textureSample( imgCube, imgSampler, faceMat[ Varys.vBaseArrayLayer ] * vec3f( fract( Varys.vTex ), 1 ) );

}
`;this.mipmapSampler=e.createSampler({minFilter:Fa.Linear}),this.flipYSampler=e.createSampler({minFilter:Fa.Nearest}),Wo.size=4,Wo.usage=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,this.flipUniformBuffer=e.createBuffer(Wo),Wo.reset(),e.queue.writeBuffer(this.flipUniformBuffer,0,new Uint32Array([1])),Wo.size=4,Wo.usage=GPUBufferUsage.UNIFORM,this.noFlipUniformBuffer=e.createBuffer(Wo),Wo.reset(),this.transferPipelines={},n0.label="mipmap",n0.code=t,this.mipmapShaderModule=e.createShaderModule(n0),n0.reset()}getTransferPipeline(e,t){t=t||"2d-array";let s=`${e}-${t}`,n=this.transferPipelines[s];return n===void 0&&(ld.label=`mipmap-${e}-${t}`,ld.vertex={module:this.mipmapShaderModule},ld.fragment={module:this.mipmapShaderModule,entryPoint:`main_${t.replace("-","_")}`,targets:[{format:e}]},ld.layout="auto",n=this.device.createRenderPipeline(ld),ld.reset(),this.transferPipelines[s]=n),n}flipY(e,t,s=0){let n=t.format,{width:a,height:i}=t.size;hd.size.width=a,hd.size.height=i,hd.format=n,hd.usage=GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING;let o=this.device.createTexture(hd);hd.reset();let c=this.getTransferPipeline(n,e.textureBindingViewDimension),l=this.getTransferPipeline(n,o.textureBindingViewDimension),h=this.device.createCommandEncoder(s0),u=(d,f,p,m,b,g)=>{let x=d.getBindGroupLayout(0);Kt.dimension=f.textureBindingViewDimension||"2d-array",Kt.mipLevelCount=1;let T=f.createView(Kt);Kt.reset(),Ho.layout=x,Ho.entries.push({binding:0,resource:this.flipYSampler},{binding:1,resource:T},{binding:2,resource:{buffer:g?this.flipUniformBuffer:this.noFlipUniformBuffer}});let y=this.device.createBindGroup(Ho);Ho.reset(),Kt.dimension="2d",Kt.mipLevelCount=1,Kt.baseArrayLayer=b,Kt.arrayLayerCount=1;let v=m.createView(Kt);Kt.reset(),hm.view=v,hm.loadOp=ct.Clear,hm.storeOp=as.Store,qA.colorAttachments.push(hm);let _=h.beginRenderPass(qA);qA.reset(),hm.reset(),_.setPipeline(d),_.setBindGroup(0,y),_.draw(3,1,0,p),_.end()};u(c,e,s,o,0,!1),u(l,o,0,e,s,!0),sr(this.device,h.finish()),o.destroy()}generateMipmaps(e,t=null){let s=this.get(e),n=s.layers||this._mipmapCreateBundles(e),a=t;a===null&&(s0.label="mipmapEncoder",a=this.device.createCommandEncoder(s0),s0.reset()),this._mipmapRunBundles(a,n),t===null&&sr(this.device,a.finish()),s.layers=n}_mipmapCreateBundles(e){let t=e.textureBindingViewDimension||"2d-array",s=this.getTransferPipeline(e.format,t),n=s.getBindGroupLayout(0),a=[];for(let i=1;i<e.mipLevelCount;i++)for(let o=0;o<e.depthOrArrayLayers;o++){Kt.dimension=t,Kt.baseMipLevel=i-1,Kt.mipLevelCount=1;let c=e.createView(Kt);Kt.reset(),Ho.layout=n,Ho.entries.push({binding:0,resource:this.mipmapSampler},{binding:1,resource:c},{binding:2,resource:{buffer:this.noFlipUniformBuffer}});let l=this.device.createBindGroup(Ho);Ho.reset(),Kt.dimension="2d",Kt.baseMipLevel=i,Kt.mipLevelCount=1,Kt.baseArrayLayer=o,Kt.arrayLayerCount=1;let h=e.createView(Kt);Kt.reset();let u=new Ll;u.view=h,u.loadOp=ct.Clear,u.storeOp=as.Store;let d=new zl;d.colorAttachments.push(u),WA.colorFormats=[e.format];let f=this.device.createRenderBundleEncoder(WA);WA.reset(),f.setPipeline(s),f.setBindGroup(0,l),f.draw(3,1,0,o),a.push({renderBundles:[f.finish()],passDescriptor:d})}return a}_mipmapRunBundles(e,t){let s=t.length;for(let n=0;n<s;n++){let a=t[n],i=e.beginRenderPass(a.passDescriptor);i.executeBundles(a.renderBundles),i.end()}}},BS=class{constructor(){this.label="",this.addressModeU="clamp-to-edge",this.addressModeV="clamp-to-edge",this.addressModeW="clamp-to-edge",this.magFilter="nearest",this.minFilter="nearest",this.mipmapFilter="nearest",this.lodMinClamp=0,this.lodMaxClamp=32,this.compare=void 0,this.maxAnisotropy=1}reset(){this.label="",this.addressModeU="clamp-to-edge",this.addressModeV="clamp-to-edge",this.addressModeW="clamp-to-edge",this.magFilter="nearest",this.minFilter="nearest",this.mipmapFilter="nearest",this.lodMinClamp=0,this.lodMaxClamp=32,this.compare=void 0,this.maxAnisotropy=1}},Kd=class{constructor(){this.texture=null,this.mipLevel=0,this.origin={x:0,y:0,z:0},this.aspect="all"}reset(){this.texture=null,this.mipLevel=0,this.origin.x=0,this.origin.y=0,this.origin.z=0,this.aspect="all"}},FS=class{constructor(){this.buffer=null,this.offset=0,this.bytesPerRow=void 0,this.rowsPerImage=void 0}reset(){this.buffer=null,this.offset=0,this.bytesPerRow=void 0,this.rowsPerImage=void 0}},PS=class{constructor(){this.offset=0,this.bytesPerRow=void 0,this.rowsPerImage=void 0}reset(){this.offset=0,this.bytesPerRow=void 0,this.rowsPerImage=void 0}},DS=class{constructor(){this.source=null,this.origin={x:0,y:0},this.flipY=!1}reset(){this.source=null,this.origin.x=0,this.origin.y=0,this.flipY=!1}},OS=class extends Kd{constructor(){super(),this.colorSpace="srgb",this.premultipliedAlpha=!1}reset(){super.reset(),this.colorSpace="srgb",this.premultipliedAlpha=!1}},_T=class{constructor(){this.width=0,this.height=1,this.depthOrArrayLayers=1}reset(){this.width=0,this.height=1,this.depthOrArrayLayers=1}},a0=new dc,AH=new Jl,ln=new BS,dn=new Kd,i0=new FS,eo=new PS,r0=new DS,ud=new OS,qo=new Xd,un=new _T,MH={[xx]:"never",[$p]:"less",[wx]:"equal",[ml]:"less-equal",[td]:"greater",[Oo]:"greater-equal",[vx]:"always",[Tx]:"not-equal"},SH=[0,1,3,2,4,5];function oI(r,e,t,s,n,a,i,o,c,l){dn.texture=e,dn.mipLevel=t,dn.origin.z=s,eo.offset=s*a,eo.bytesPerRow=i,eo.rowsPerImage=o,un.width=c,un.height=l,r.queue.writeTexture(dn,n.data,eo,un),dn.reset(),eo.reset(),un.reset()}var US=class{constructor(e){this.backend=e,this._passUtils=null,this.defaultTexture={},this.defaultCubeTexture={},this.defaultVideoFrame=null,this._samplerCache=new Map}updateSampler(e){let t=this.backend,s=e.texture,n=e.textureNode,a=s.isDepthTexture===!0&&s.compareFunction!==null&&n.isSampleCompare()&&t.hasCompatibility(Hr.TEXTURE_COMPARE),i=s.minFilter+"-"+s.magFilter+"-"+s.wrapS+"-"+s.wrapT+"-"+(s.wrapR||"0")+"-"+s.anisotropy+"-"+(s.isDepthTexture===!0?1:0)+"-"+(a?s.compareFunction:0),o=this._samplerCache.get(i);if(o===void 0){ln.addressModeU=this._convertAddressMode(s.wrapS),ln.addressModeV=this._convertAddressMode(s.wrapT),ln.addressModeW=this._convertAddressMode(s.wrapR),ln.magFilter=this._convertFilterMode(s.magFilter),ln.minFilter=this._convertFilterMode(s.minFilter),ln.mipmapFilter=this._convertMipmapFilterMode(s.minFilter),s.isDepthTexture&&a===!1&&(ln.magFilter=Fa.Nearest,ln.minFilter=Fa.Nearest,ln.mipmapFilter=Fa.Nearest),ln.magFilter===Fa.Linear&&ln.minFilter===Fa.Linear&&ln.mipmapFilter===Fa.Linear&&(ln.maxAnisotropy=s.anisotropy),a&&(ln.compare=MH[s.compareFunction]);let l=t.device.createSampler(ln);ln.reset(),o={sampler:l,usedTimes:0},this._samplerCache.set(i,o)}let c=t.get(e);return c.sampler!==o.sampler&&(this._releaseSampler(c),c.samplerKey=i,c.sampler=o.sampler,o.usedTimes++),i}destroySampler(e){this._releaseSampler(this.backend.get(e))}_releaseSampler(e){if(e.sampler!==void 0){let t=this._samplerCache.get(e.samplerKey);t.usedTimes--,t.usedTimes===0&&this._samplerCache.delete(e.samplerKey),e.sampler=void 0,e.samplerKey=void 0}}createDefaultTexture(e){let t,s=LS(e,this.backend.device);e.isCubeTexture?t=this._getDefaultCubeTextureGPU(s):t=this._getDefaultTextureGPU(s),this.backend.get(e).texture=t}createTexture(e,t={}){let s=this.backend,n=s.get(e);if(n.initialized){if(n.externalTexture===!0)return;throw new Error("THREE.WebGPUTextureUtils: Texture already initialized.")}if(e.isExternalTexture){n.texture=e.sourceTexture,n.initialized=!0;return}t.needsMipmaps===void 0&&(t.needsMipmaps=!1),t.levels===void 0&&(t.levels=1),t.depth===void 0&&(t.depth=1);let{width:a,height:i,depth:o,levels:c}=t;e.isFramebufferTexture&&(t.renderTarget?t.format=this.backend.utils.getCurrentColorFormat(t.renderTarget):t.format=this.backend.utils.getPreferredCanvasFormat());let l=this._getDimension(e),h=e.internalFormat||t.format||LS(e,s.device);n.format=h;let{samples:u,primarySamples:d,isMSAA:f}=s.utils.getTextureSampleData(e),p=e.renderTarget,m=u>1&&p!==null&&o>1&&l===GA.TwoD,g=GPUTextureUsage.TRANSIENT_ATTACHMENT!==void 0&&m===!1,x=e.isDepthTexture===!0&&g&&p?.storeMultisampledDepthBuffer===!1&&(p.stencilBuffer===!1||p.storeMultisampledStencilBuffer===!1),T=e.isDepthTexture!==!0&&g&&p?.storeMultisampledColorBuffer===!1,y=GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC;e.isStorageTexture===!0&&(y|=GPUTextureUsage.STORAGE_BINDING),e.isCompressedTexture!==!0&&e.isCompressedArrayTexture!==!0&&h!==B.RGB9E5UFloat&&(y|=GPUTextureUsage.RENDER_ATTACHMENT),d>1&&x&&(y=GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TRANSIENT_ATTACHMENT);let v=new Xd;if(v.label=e.name,v.size.width=a,v.size.height=i,v.size.depthOrArrayLayers=o,v.mipLevelCount=c,v.sampleCount=d,v.dimension=l,v.format=h,v.usage=y,h===void 0){K("WebGPURenderer: Texture format not supported."),this.createDefaultTexture(e);return}e.isCubeTexture&&(v.textureBindingViewDimension=Js.Cube);try{n.texture=s.device.createTexture(v)}catch{K("WebGPURenderer: Failed to create texture with descriptor:",v),this.createDefaultTexture(e);return}if(f||m){let _=Object.assign({},v);if(_.label=_.label+"-msaa",_.sampleCount=u,_.mipLevelCount=1,(x||T)&&(_.usage=GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TRANSIENT_ATTACHMENT),m){_.size=Object.assign({},_.size,{depthOrArrayLayers:1}),n.msaaTextures=[];for(let A=0;A<o;A++)_.label=v.label+"-msaa-"+A,n.msaaTextures.push(s.device.createTexture(_))}else n.msaaTexture=s.device.createTexture(_)}n.initialized=!0,n.textureDescriptorGPU=v}destroyTexture(e,t=!1){let s=this.backend,n=s.get(e);if(n.texture!==void 0&&t===!1&&e.isExternalTexture!==!0&&n.externalTexture!==!0&&n.texture.destroy(),n.msaaTexture!==void 0&&n.msaaTexture.destroy(),n.msaaTextures!==void 0)for(let a of n.msaaTextures)a.destroy();s.delete(e)}generateMipmaps(e,t=null){let s=this.backend.get(e);this._generateMipmaps(s.texture,t)}getColorBuffer(){let e=this.backend,t=e.renderer.getCanvasTarget(),{width:s,height:n}=e.getDrawingBufferSize(),a=e.renderer.currentSamples,i=t.colorTexture,o=e.get(i);if(i.width===s&&i.height===n&&i.samples===a)return o.texture;let c=o.texture;return c&&c.destroy(),qo.label="colorBuffer",qo.size.width=s,qo.size.height=n,qo.sampleCount=e.utils.getSampleCount(e.renderer.currentSamples),qo.format=e.utils.getPreferredCanvasFormat(),qo.usage=GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,c=e.device.createTexture(qo),qo.reset(),i.source.width=s,i.source.height=n,i.samples=a,o.texture=c,c}getDepthBuffer(e=!0,t=!1){let s=this.backend,n=s.renderer.getCanvasTarget(),{width:a,height:i}=s.getDrawingBufferSize(),o=s.renderer.currentSamples,c=n.depthTexture;if(c.width===a&&c.height===i&&c.samples===o&&c.depth===e&&c.stencil===t)return s.get(c).texture;let l=s.get(c).texture,h,u;if(t?(h=na,u=s.renderer.reversedDepthBuffer===!0?Mt:mi):e&&(h=vn,u=s.renderer.reversedDepthBuffer===!0?Mt:St),l!==void 0){if(c.image.width===a&&c.image.height===i&&c.format===h&&c.type===u&&c.samples===o)return l;this.destroyTexture(c)}return c.name="depthBuffer",c.format=h,c.type=u,c.image.width=a,c.image.height=i,c.samples=o,this.createTexture(c,{width:a,height:i}),s.get(c).texture}updateTexture(e,t){let s=this.backend.get(e),n=e.mipmaps,{textureDescriptorGPU:a}=s;if(!(e.isRenderTargetTexture||a===void 0)){if(e.isDataTexture)if(n.length>0)for(let i=0,o=n.length;i<o;i++){let c=n[i];this._copyBufferToTexture(c,s.texture,a,0,e.flipY,0,i)}else this._copyBufferToTexture(t.image,s.texture,a,0,e.flipY);else if(e.isArrayTexture||e.isDataArrayTexture||e.isData3DTexture)if(e.layerUpdates&&e.layerUpdates.size>0){for(let i of e.layerUpdates)this._copyBufferToTexture(t.image,s.texture,a,i,e.flipY,i);e.clearLayerUpdates()}else for(let i=0;i<t.image.depth;i++)this._copyBufferToTexture(t.image,s.texture,a,i,e.flipY,i);else if(e.isCompressedTexture||e.isCompressedArrayTexture)e.isCompressedArrayTexture&&e.layerUpdates.size>0?(this._copyCompressedBufferToTexture(e.mipmaps,s.texture,a,e.layerUpdates),e.clearLayerUpdates()):this._copyCompressedBufferToTexture(e.mipmaps,s.texture,a);else if(e.isCubeTexture)this._copyCubeMapToTexture(e,s.texture,a);else if(e.isHTMLTexture){let i=this.backend.device,o=this.backend.renderer.domElement,c=e.image;if(typeof i.queue.copyElementImageToTexture!="function")return;if(!s.hasPaintCallback){s.hasPaintCallback=!0,o.requestPaint();return}let l=a.size.width,h=a.size.height;i.queue.copyElementImageToTexture.length===2?i.queue.copyElementImageToTexture({source:c},{destination:{texture:s.texture},width:l,height:h}):i.queue.copyElementImageToTexture(c,l,h,{texture:s.texture}),e.flipY&&this._flipY(s.texture,a)}else if(n.length>0)for(let i=0,o=n.length;i<o;i++){let c=n[i];this._copyImageToTexture(c,s.texture,a,0,e.flipY,e.premultiplyAlpha,i)}else this._copyImageToTexture(t.image,s.texture,a,0,e.flipY,e.premultiplyAlpha);s.version=e.version}}async copyTextureToBuffer(e,t,s,n,a,i){let o=this.backend.device,c=this.backend.get(e),l=c.texture,h=c.textureDescriptorGPU.format,u=this._getBytesPerTexel(h),d=n*u;d=Math.ceil(d/256)*256,a0.size=(a-1)*d+n*u,a0.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ;let f=o.createBuffer(a0);a0.reset();let p=o.createCommandEncoder(AH);dn.texture=l,dn.origin.x=t,dn.origin.y=s,dn.origin.z=i,i0.buffer=f,i0.bytesPerRow=d,un.width=n,un.height=a,p.copyTextureToBuffer(dn,i0,un),dn.reset(),i0.reset(),un.reset();let m=this._getTypedArrayType(h);sr(o,p.finish()),await f.mapAsync(GPUMapMode.READ);let b=f.getMappedRange().slice();return f.destroy(),new m(b)}dispose(){this._samplerCache.clear()}_getDefaultTextureGPU(e){let t=this.defaultTexture[e];if(t===void 0){let s=new gt;s.minFilter=pt,s.magFilter=pt,this.createTexture(s,{width:1,height:1,format:e}),this.defaultTexture[e]=t=s}return this.backend.get(t).texture}_getDefaultCubeTextureGPU(e){let t=this.defaultCubeTexture[e];if(t===void 0){let s=new Pi;s.minFilter=pt,s.magFilter=pt,this.createTexture(s,{width:1,height:1,depth:6}),this.defaultCubeTexture[e]=t=s}return this.backend.get(t).texture}_copyCubeMapToTexture(e,t,s){let n=e.images,a=e.mipmaps;for(let i=0;i<6;i++){let o=n[i],c=e.flipY===!0?SH[i]:i;o.isDataTexture?this._copyBufferToTexture(o.image,t,s,c,e.flipY):this._copyImageToTexture(o,t,s,c,e.flipY,e.premultiplyAlpha);for(let l=0;l<a.length;l++){let u=a[l].images[i];u.isDataTexture?this._copyBufferToTexture(u.image,t,s,c,e.flipY,0,l+1):this._copyImageToTexture(u,t,s,c,e.flipY,e.premultiplyAlpha,l+1)}}}_copyImageToTexture(e,t,s,n,a,i,o=0){let c=this.backend.device,l=o>0?e.width:s.size.width,h=o>0?e.height:s.size.height;r0.source=e,r0.flipY=a,ud.texture=t,ud.mipLevel=o,ud.origin.z=n,ud.premultipliedAlpha=i,un.width=l,un.height=h;try{c.queue.copyExternalImageToTexture(r0,ud,un)}catch{}finally{r0.reset(),ud.reset(),un.reset()}}_getPassUtils(){let e=this._passUtils;return e===null&&(this._passUtils=e=new IS(this.backend.device)),e}_generateMipmaps(e,t=null){this._getPassUtils().generateMipmaps(e,t)}_flipY(e,t,s=0){this._getPassUtils().flipY(e,t,s)}_copyBufferToTexture(e,t,s,n,a,i=0,o=0){let c=this.backend.device,l=e.data,h=this._getBytesPerTexel(s.format),u=e.width*h;dn.texture=t,dn.mipLevel=o,dn.origin.z=n,eo.offset=e.width*e.height*h*i,eo.bytesPerRow=u,un.width=e.width,un.height=e.height,c.queue.writeTexture(dn,l,eo,un),dn.reset(),eo.reset(),un.reset(),a===!0&&this._flipY(t,s,n)}_copyCompressedBufferToTexture(e,t,s,n=null){let a=this.backend.device,i=this._getBlockData(s.format),o=s.size.depthOrArrayLayers>1,c=n&&n.size>0?n:null;for(let l=0;l<e.length;l++){let h=e[l],u=h.width,d=h.height,f=o?s.size.depthOrArrayLayers:1,p=Math.ceil(u/i.width)*i.byteLength,m=Math.ceil(d/i.height),b=p*m,g=Math.ceil(u/i.width)*i.width,x=m*i.height;if(c!==null)for(let T of c)oI(a,t,l,T,h,b,p,m,g,x);else for(let T=0;T<f;T++)oI(a,t,l,T,h,b,p,m,g,x)}}_getBlockData(e){if(e===B.BC1RGBAUnorm||e===B.BC1RGBAUnormSRGB)return{byteLength:8,width:4,height:4};if(e===B.BC2RGBAUnorm||e===B.BC2RGBAUnormSRGB)return{byteLength:16,width:4,height:4};if(e===B.BC3RGBAUnorm||e===B.BC3RGBAUnormSRGB)return{byteLength:16,width:4,height:4};if(e===B.BC4RUnorm||e===B.BC4RSnorm)return{byteLength:8,width:4,height:4};if(e===B.BC5RGUnorm||e===B.BC5RGSnorm)return{byteLength:16,width:4,height:4};if(e===B.BC6HRGBUFloat||e===B.BC6HRGBFloat)return{byteLength:16,width:4,height:4};if(e===B.BC7RGBAUnorm||e===B.BC7RGBAUnormSRGB)return{byteLength:16,width:4,height:4};if(e===B.ETC2RGB8Unorm||e===B.ETC2RGB8UnormSRGB)return{byteLength:8,width:4,height:4};if(e===B.ETC2RGB8A1Unorm||e===B.ETC2RGB8A1UnormSRGB)return{byteLength:8,width:4,height:4};if(e===B.ETC2RGBA8Unorm||e===B.ETC2RGBA8UnormSRGB)return{byteLength:16,width:4,height:4};if(e===B.EACR11Unorm)return{byteLength:8,width:4,height:4};if(e===B.EACR11Snorm)return{byteLength:8,width:4,height:4};if(e===B.EACRG11Unorm)return{byteLength:16,width:4,height:4};if(e===B.EACRG11Snorm)return{byteLength:16,width:4,height:4};if(e===B.ASTC4x4Unorm||e===B.ASTC4x4UnormSRGB)return{byteLength:16,width:4,height:4};if(e===B.ASTC5x4Unorm||e===B.ASTC5x4UnormSRGB)return{byteLength:16,width:5,height:4};if(e===B.ASTC5x5Unorm||e===B.ASTC5x5UnormSRGB)return{byteLength:16,width:5,height:5};if(e===B.ASTC6x5Unorm||e===B.ASTC6x5UnormSRGB)return{byteLength:16,width:6,height:5};if(e===B.ASTC6x6Unorm||e===B.ASTC6x6UnormSRGB)return{byteLength:16,width:6,height:6};if(e===B.ASTC8x5Unorm||e===B.ASTC8x5UnormSRGB)return{byteLength:16,width:8,height:5};if(e===B.ASTC8x6Unorm||e===B.ASTC8x6UnormSRGB)return{byteLength:16,width:8,height:6};if(e===B.ASTC8x8Unorm||e===B.ASTC8x8UnormSRGB)return{byteLength:16,width:8,height:8};if(e===B.ASTC10x5Unorm||e===B.ASTC10x5UnormSRGB)return{byteLength:16,width:10,height:5};if(e===B.ASTC10x6Unorm||e===B.ASTC10x6UnormSRGB)return{byteLength:16,width:10,height:6};if(e===B.ASTC10x8Unorm||e===B.ASTC10x8UnormSRGB)return{byteLength:16,width:10,height:8};if(e===B.ASTC10x10Unorm||e===B.ASTC10x10UnormSRGB)return{byteLength:16,width:10,height:10};if(e===B.ASTC12x10Unorm||e===B.ASTC12x10UnormSRGB)return{byteLength:16,width:12,height:10};if(e===B.ASTC12x12Unorm||e===B.ASTC12x12UnormSRGB)return{byteLength:16,width:12,height:12}}_convertAddressMode(e){let t=VA.ClampToEdge;return e===Zn?t=VA.Repeat:e===ai&&(t=VA.MirrorRepeat),t}_convertFilterMode(e){let t=Fa.Linear;return(e===pt||e===ll||e===fi)&&(t=Fa.Nearest),t}_convertMipmapFilterMode(e){return e===fi||e===on?Fa.Linear:Fa.Nearest}_getBytesPerTexel(e){if(e===B.R8Unorm||e===B.R8Snorm||e===B.R8Uint||e===B.R8Sint)return 1;if(e===B.R16Uint||e===B.R16Sint||e===B.R16Float||e===B.RG8Unorm||e===B.RG8Snorm||e===B.RG8Uint||e===B.RG8Sint||e===B.R16Unorm||e===B.R16Snorm)return 2;if(e===B.R32Uint||e===B.R32Sint||e===B.R32Float||e===B.RG16Uint||e===B.RG16Sint||e===B.RG16Float||e===B.RGBA8Unorm||e===B.RGBA8UnormSRGB||e===B.RGBA8Snorm||e===B.RGBA8Uint||e===B.RGBA8Sint||e===B.BGRA8Unorm||e===B.BGRA8UnormSRGB||e===B.RG16Unorm||e===B.RG16Snorm||e===B.RGB9E5UFloat||e===B.RGB10A2Unorm||e===B.RG11B10UFloat||e===B.Depth32Float||e===B.Depth24Plus||e===B.Depth24PlusStencil8||e===B.Depth32FloatStencil8)return 4;if(e===B.RG32Uint||e===B.RG32Sint||e===B.RG32Float||e===B.RGBA16Uint||e===B.RGBA16Sint||e===B.RGBA16Float||e===B.RGBA16Unorm||e===B.RGBA16Snorm)return 8;if(e===B.RGBA32Uint||e===B.RGBA32Sint||e===B.RGBA32Float)return 16}_getTypedArrayType(e){if(e===B.R8Uint)return Uint8Array;if(e===B.R8Sint)return Int8Array;if(e===B.R8Unorm)return Uint8Array;if(e===B.R8Snorm)return Int8Array;if(e===B.RG8Uint)return Uint8Array;if(e===B.RG8Sint)return Int8Array;if(e===B.RG8Unorm)return Uint8Array;if(e===B.RG8Snorm)return Int8Array;if(e===B.RGBA8Uint)return Uint8Array;if(e===B.RGBA8Sint)return Int8Array;if(e===B.RGBA8Unorm||e===B.RGBA8UnormSRGB)return Uint8Array;if(e===B.RGBA8Snorm)return Int8Array;if(e===B.R16Uint)return Uint16Array;if(e===B.R16Sint)return Int16Array;if(e===B.RG16Uint)return Uint16Array;if(e===B.RG16Sint)return Int16Array;if(e===B.RGBA16Uint)return Uint16Array;if(e===B.RGBA16Sint)return Int16Array;if(e===B.R16Float||e===B.RG16Float||e===B.RGBA16Float||e===B.R16Unorm)return Uint16Array;if(e===B.R16Snorm)return Int16Array;if(e===B.RG16Unorm)return Uint16Array;if(e===B.RG16Snorm)return Int16Array;if(e===B.RGBA16Unorm)return Uint16Array;if(e===B.RGBA16Snorm)return Int16Array;if(e===B.R32Uint)return Uint32Array;if(e===B.R32Sint)return Int32Array;if(e===B.R32Float)return Float32Array;if(e===B.RG32Uint)return Uint32Array;if(e===B.RG32Sint)return Int32Array;if(e===B.RG32Float)return Float32Array;if(e===B.RGBA32Uint)return Uint32Array;if(e===B.RGBA32Sint)return Int32Array;if(e===B.RGBA32Float)return Float32Array;if(e===B.BGRA8Unorm||e===B.BGRA8UnormSRGB)return Uint8Array;if(e===B.RGB10A2Unorm||e===B.RGB9E5UFloat||e===B.RG11B10UFloat)return Uint32Array;if(e===B.Depth32Float)return Float32Array;if(e===B.Depth24Plus||e===B.Depth24PlusStencil8)return Uint32Array;if(e===B.Depth32FloatStencil8)return Float32Array}_getDimension(e){let t;return e.is3DTexture||e.isData3DTexture?t=GA.ThreeD:t=GA.TwoD,t}};function LS(r,e){let t=r.format,s=r.type,n=r.normalized,a=r.colorSpace,i=qe.getTransfer(a),o,c=!1;if(n&&(c=e.features.has(yT.TextureFormatsTier1),c===!1&&K("WebGPURenderer: Unable to use normalized textures without texture-formats-tier1 feature.")),r.isCompressedTexture===!0||r.isCompressedArrayTexture===!0)switch(t){case hl:case ul:o=i===Ie?B.BC1RGBAUnormSRGB:B.BC1RGBAUnorm;break;case dl:o=i===Ie?B.BC2RGBAUnormSRGB:B.BC2RGBAUnorm;break;case fl:o=i===Ie?B.BC3RGBAUnormSRGB:B.BC3RGBAUnorm;break;case Yu:o=B.BC4RUnorm;break;case Zu:o=B.BC4RSnorm;break;case jr:o=B.BC5RGUnorm;break;case Qu:o=B.BC5RGSnorm;break;case Ku:o=i===Ie?B.BC7RGBAUnormSRGB:B.BC7RGBAUnorm;break;case Ju:o=B.BC6HRGBFloat;break;case $u:o=B.BC6HRGBUFloat;break;case Eu:case Ru:o=i===Ie?B.ETC2RGB8UnormSRGB:B.ETC2RGB8Unorm;break;case Cu:o=i===Ie?B.ETC2RGBA8UnormSRGB:B.ETC2RGBA8Unorm;break;case ku:o=B.EACR11Unorm;break;case Iu:o=B.EACR11Snorm;break;case Vr:o=B.EACRG11Unorm;break;case Bu:o=B.EACRG11Snorm;break;case Fu:o=i===Ie?B.ASTC4x4UnormSRGB:B.ASTC4x4Unorm;break;case Pu:o=i===Ie?B.ASTC5x4UnormSRGB:B.ASTC5x4Unorm;break;case Du:o=i===Ie?B.ASTC5x5UnormSRGB:B.ASTC5x5Unorm;break;case Ou:o=i===Ie?B.ASTC6x5UnormSRGB:B.ASTC6x5Unorm;break;case Uu:o=i===Ie?B.ASTC6x6UnormSRGB:B.ASTC6x6Unorm;break;case Lu:o=i===Ie?B.ASTC8x5UnormSRGB:B.ASTC8x5Unorm;break;case zu:o=i===Ie?B.ASTC8x6UnormSRGB:B.ASTC8x6Unorm;break;case Vu:o=i===Ie?B.ASTC8x8UnormSRGB:B.ASTC8x8Unorm;break;case ju:o=i===Ie?B.ASTC10x5UnormSRGB:B.ASTC10x5Unorm;break;case Gu:o=i===Ie?B.ASTC10x6UnormSRGB:B.ASTC10x6Unorm;break;case Hu:o=i===Ie?B.ASTC10x8UnormSRGB:B.ASTC10x8Unorm;break;case Wu:o=i===Ie?B.ASTC10x10UnormSRGB:B.ASTC10x10Unorm;break;case qu:o=i===Ie?B.ASTC12x10UnormSRGB:B.ASTC12x10Unorm;break;case Xu:o=i===Ie?B.ASTC12x12UnormSRGB:B.ASTC12x12Unorm;break;case gs:o=i===Ie?B.RGBA8UnormSRGB:B.RGBA8Unorm;break;default:W("WebGPURenderer: Unsupported texture format.",t)}else switch(t){case gs:switch(s){case Ur:o=B.RGBA8Snorm;break;case pi:o=c?B.RGBA16Snorm:B.RGBA16Sint;break;case ka:o=c?B.RGBA16Unorm:B.RGBA16Uint;break;case St:o=B.RGBA32Uint;break;case Ts:o=B.RGBA32Sint;break;case ws:o=i===Ie?B.RGBA8UnormSRGB:B.RGBA8Unorm;break;case ds:o=B.RGBA16Float;break;case Mt:o=B.RGBA32Float;break;default:W("WebGPURenderer: Unsupported texture type with RGBAFormat.",s)}break;case Po:switch(s){case Au:o=B.RGB9E5UFloat;break;case Mu:o=B.RG11B10UFloat;break;default:W("WebGPURenderer: Unsupported texture type with RGBFormat.",s)}break;case Lr:switch(s){case Ur:o=B.R8Snorm;break;case pi:o=c?B.R16Snorm:B.R16Sint;break;case ka:o=c?B.R16Unorm:B.R16Uint;break;case St:o=B.R32Uint;break;case Ts:o=B.R32Sint;break;case ws:o=B.R8Unorm;break;case ds:o=B.R16Float;break;case Mt:o=B.R32Float;break;default:W("WebGPURenderer: Unsupported texture type with RedFormat.",s)}break;case cn:switch(s){case Ur:o=B.RG8Snorm;break;case pi:o=c?B.RG16Snorm:B.RG16Sint;break;case ka:o=c?B.RG16Unorm:B.RG16Uint;break;case St:o=B.RG32Uint;break;case Ts:o=B.RG32Sint;break;case ws:o=B.RG8Unorm;break;case ds:o=B.RG16Float;break;case Mt:o=B.RG32Float;break;default:W("WebGPURenderer: Unsupported texture type with RGFormat.",s)}break;case vn:switch(s){case ka:o=B.Depth16Unorm;break;case St:o=B.Depth24Plus;break;case Mt:o=B.Depth32Float;break;default:W("WebGPURenderer: Unsupported texture type with DepthFormat.",s)}break;case na:switch(s){case mi:o=B.Depth24PlusStencil8;break;case Mt:e&&e.features.has(yT.Depth32FloatStencil8)===!1&&W('WebGPURenderer: Depth textures with DepthStencilFormat + FloatType can only be used with the "depth32float-stencil8" GPU feature.'),o=B.Depth32FloatStencil8;break;default:W("WebGPURenderer: Unsupported texture type with DepthStencilFormat.",s)}break;case zr:switch(s){case Ts:o=B.R32Sint;break;case St:o=B.R32Uint;break;default:W("WebGPURenderer: Unsupported texture type with RedIntegerFormat.",s)}break;case Do:switch(s){case Ts:o=B.RG32Sint;break;case St:o=B.RG32Uint;break;default:W("WebGPURenderer: Unsupported texture type with RGIntegerFormat.",s)}break;case Nu:switch(s){case Ts:o=B.RGBA32Sint;break;case St:o=B.RGBA32Uint;break;default:W("WebGPURenderer: Unsupported texture type with RGBAIntegerFormat.",s)}break;default:W("WebGPURenderer: Unsupported texture format.",t)}return o}var NH=/^[fn]*\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)\s*[\-\>]*\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/i,RH=/([a-z_0-9]+)\s*:\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/ig,cI={f32:"float",i32:"int",u32:"uint",bool:"bool","vec2<f32>":"vec2","vec2<i32>":"ivec2","vec2<u32>":"uvec2","vec2<bool>":"bvec2",vec2f:"vec2",vec2i:"ivec2",vec2u:"uvec2",vec2b:"bvec2","vec3<f32>":"vec3","vec3<i32>":"ivec3","vec3<u32>":"uvec3","vec3<bool>":"bvec3",vec3f:"vec3",vec3i:"ivec3",vec3u:"uvec3",vec3b:"bvec3","vec4<f32>":"vec4","vec4<i32>":"ivec4","vec4<u32>":"uvec4","vec4<bool>":"bvec4",vec4f:"vec4",vec4i:"ivec4",vec4u:"uvec4",vec4b:"bvec4","mat2x2<f32>":"mat2",mat2x2f:"mat2","mat3x3<f32>":"mat3",mat3x3f:"mat3","mat4x4<f32>":"mat4",mat4x4f:"mat4",sampler:"sampler",sampler_comparison:"samplerComparison",texture_1d:"texture",texture_2d:"texture",texture_2d_array:"texture",texture_multisampled_2d:"cubeTexture",texture_depth_2d:"depthTexture",texture_depth_2d_array:"depthTexture",texture_depth_multisampled_2d:"depthTexture",texture_depth_cube:"depthTexture",texture_depth_cube_array:"depthTexture",texture_3d:"texture3D",texture_cube:"cubeTexture",texture_cube_array:"cubeTexture",texture_storage_1d:"storageTexture",texture_storage_2d:"storageTexture",texture_storage_2d_array:"storageTexture",texture_storage_3d:"storageTexture"},EH=r=>{r=r.replace(/^(?:\s*\/\/[^\r\n]*|\s*\/\*[\s\S]*?\*\/|\s*)+/,"");let e=r.match(NH);if(e!==null&&e.length===4){let t=e[2],s=[],n=null;for(;(n=RH.exec(t))!==null;)s.push({name:n[1],type:n[2]});let a=[];for(let h=0;h<s.length;h++){let{name:u,type:d}=s[h],f=d;f.startsWith("ptr")?f="pointer":(f.startsWith("texture")&&(f=d.split("<")[0]),f=cI[f]),a.push(new Wd(f,u))}let i=r.substring(e[0].length),o=e[3]||"void",c=e[1]!==void 0?e[1]:"";return{type:cI[o]||o,inputs:a,name:c,inputsCode:t,blockCode:i,outputType:o}}else throw new Error("THREE.WGSLNodeFunction: Function is not a WGSL code.")},zS=class extends ub{constructor(e){let{type:t,inputs:s,name:n,inputsCode:a,blockCode:i,outputType:o}=EH(e);super(t,s,n),this.inputsCode=a,this.blockCode=i,this.outputType=o}getCode(e=this.name){let t=this.outputType!=="void"?"-> "+this.outputType:"";return`fn ${e} ( ${this.inputsCode.trim()} ) ${t}`+this.blockCode}},VS=class extends tT{parseFunction(e){return new zS(e)}},CH={[As.READ_ONLY]:"read",[As.WRITE_ONLY]:"write",[As.READ_WRITE]:"read_write"},lI={[Zn]:"repeat",[hs]:"clamp",[ai]:"mirror"},XA={vertex:Ai.VERTEX,fragment:Ai.FRAGMENT,compute:Ai.COMPUTE},hI={instance:!0,swizzleAssign:!1,storageBuffer:!0},kH={"^^":"tsl_xor"},IH={float:"f32",int:"i32",uint:"u32",bool:"bool",color:"vec3<f32>",vec2:"vec2<f32>",ivec2:"vec2<i32>",uvec2:"vec2<u32>",bvec2:"vec2<bool>",vec3:"vec3<f32>",ivec3:"vec3<i32>",uvec3:"vec3<u32>",bvec3:"vec3<bool>",vec4:"vec4<f32>",ivec4:"vec4<i32>",uvec4:"vec4<u32>",bvec4:"vec4<bool>",mat2:"mat2x2<f32>",mat3:"mat3x3<f32>",mat4:"mat4x4<f32>"},uI={},um={tsl_xor:new mt("fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }"),mod_float:new mt("fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }"),mod_vec2:new mt("fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }"),mod_vec3:new mt("fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }"),mod_vec4:new mt("fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }"),equals_bool:new mt("fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }"),equals_bvec2:new mt("fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2<bool> { return vec2<bool>( a.x == b.x, a.y == b.y ); }"),equals_bvec3:new mt("fn tsl_equals_bvec3( a : vec3f, b : vec3f ) -> vec3<bool> { return vec3<bool>( a.x == b.x, a.y == b.y, a.z == b.z ); }"),equals_bvec4:new mt("fn tsl_equals_bvec4( a : vec4f, b : vec4f ) -> vec4<bool> { return vec4<bool>( a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w ); }"),repeatWrapping_float:new mt("fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }"),mirrorWrapping_float:new mt("fn tsl_mirrorWrapping_float( coord: f32 ) -> f32 { let mirrored = fract( coord * 0.5 ) * 2.0; return 1.0 - abs( 1.0 - mirrored ); }"),clampWrapping_float:new mt("fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }"),inverse_mat2:new mt(`
fn tsl_inverse_mat2( m : mat2x2<f32> ) -> mat2x2<f32> {

	let det = m[ 0 ][ 0 ] * m[ 1 ][ 1 ] - m[ 0 ][ 1 ] * m[ 1 ][ 0 ];

	return mat2x2<f32>(
		m[ 1 ][ 1 ], - m[ 0 ][ 1 ],
		- m[ 1 ][ 0 ], m[ 0 ][ 0 ]
	) * ( 1.0 / det );

}
`),inverse_mat3:new mt(`
fn tsl_inverse_mat3( m : mat3x3<f32> ) -> mat3x3<f32> {

	let a00 = m[ 0 ][ 0 ]; let a01 = m[ 0 ][ 1 ]; let a02 = m[ 0 ][ 2 ];
	let a10 = m[ 1 ][ 0 ]; let a11 = m[ 1 ][ 1 ]; let a12 = m[ 1 ][ 2 ];
	let a20 = m[ 2 ][ 0 ]; let a21 = m[ 2 ][ 1 ]; let a22 = m[ 2 ][ 2 ];

	let b01 = a22 * a11 - a12 * a21;
	let b11 = - a22 * a10 + a12 * a20;
	let b21 = a21 * a10 - a11 * a20;

	let det = a00 * b01 + a01 * b11 + a02 * b21;

	return mat3x3<f32>(
		b01, ( - a22 * a01 + a02 * a21 ), ( a12 * a01 - a02 * a11 ),
		b11, ( a22 * a00 - a02 * a20 ), ( - a12 * a00 + a02 * a10 ),
		b21, ( - a21 * a00 + a01 * a20 ), ( a11 * a00 - a01 * a10 )
	) * ( 1.0 / det );

}
`),inverse_mat4:new mt(`
fn tsl_inverse_mat4( m : mat4x4<f32> ) -> mat4x4<f32> {

	let a00 = m[ 0 ][ 0 ]; let a01 = m[ 0 ][ 1 ]; let a02 = m[ 0 ][ 2 ]; let a03 = m[ 0 ][ 3 ];
	let a10 = m[ 1 ][ 0 ]; let a11 = m[ 1 ][ 1 ]; let a12 = m[ 1 ][ 2 ]; let a13 = m[ 1 ][ 3 ];
	let a20 = m[ 2 ][ 0 ]; let a21 = m[ 2 ][ 1 ]; let a22 = m[ 2 ][ 2 ]; let a23 = m[ 2 ][ 3 ];
	let a30 = m[ 3 ][ 0 ]; let a31 = m[ 3 ][ 1 ]; let a32 = m[ 3 ][ 2 ]; let a33 = m[ 3 ][ 3 ];

	let b00 = a00 * a11 - a01 * a10;
	let b01 = a00 * a12 - a02 * a10;
	let b02 = a00 * a13 - a03 * a10;
	let b03 = a01 * a12 - a02 * a11;
	let b04 = a01 * a13 - a03 * a11;
	let b05 = a02 * a13 - a03 * a12;
	let b06 = a20 * a31 - a21 * a30;
	let b07 = a20 * a32 - a22 * a30;
	let b08 = a20 * a33 - a23 * a30;
	let b09 = a21 * a32 - a22 * a31;
	let b10 = a21 * a33 - a23 * a31;
	let b11 = a22 * a33 - a23 * a32;

	let det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;

	return mat4x4<f32>(
		a11 * b11 - a12 * b10 + a13 * b09,
		a02 * b10 - a01 * b11 - a03 * b09,
		a31 * b05 - a32 * b04 + a33 * b03,
		a22 * b04 - a21 * b05 - a23 * b03,
		a12 * b08 - a10 * b11 - a13 * b07,
		a00 * b11 - a02 * b08 + a03 * b07,
		a32 * b02 - a30 * b05 - a33 * b01,
		a20 * b05 - a22 * b02 + a23 * b01,
		a10 * b10 - a11 * b08 + a13 * b06,
		a01 * b08 - a00 * b10 - a03 * b06,
		a30 * b04 - a31 * b02 + a33 * b00,
		a21 * b02 - a20 * b04 - a23 * b00,
		a11 * b07 - a10 * b09 - a12 * b06,
		a00 * b09 - a01 * b07 + a02 * b06,
		a31 * b01 - a30 * b03 - a32 * b00,
		a20 * b03 - a21 * b01 + a22 * b00
	) * ( 1.0 / det );

}
`),biquadraticTexture:new mt(`
fn tsl_biquadraticTexture( map : texture_2d<f32>, coord : vec2f, iRes : vec2u, level : u32 ) -> vec4f {

	let res = vec2f( iRes );

	let uvScaled = coord * res;
	let uvWrapping = ( ( uvScaled % res ) + res ) % res;

	// https://www.shadertoy.com/view/WtyXRy

	let uv = uvWrapping - 0.5;
	let iuv = floor( uv );
	let f = fract( uv );

	let rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, level );
	let rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, level );
	let rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, level );
	let rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, level );

	return mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );

}
`),biquadraticTextureArray:new mt(`
fn tsl_biquadraticTexture_array( map : texture_2d_array<f32>, coord : vec2f, iRes : vec2u, layer : u32, level : u32 ) -> vec4f {

	let res = vec2f( iRes );

	let uvScaled = coord * res;
	let uvWrapping = ( ( uvScaled % res ) + res ) % res;

	// https://www.shadertoy.com/view/WtyXRy

	let uv = uvWrapping - 0.5;
	let iuv = floor( uv );
	let f = fract( uv );

	let rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, layer, level );
	let rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, layer, level );
	let rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, layer, level );
	let rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, layer, level );

	return mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );

}
`)},BH={dFdx:"dpdx",dFdy:"- dpdy",mod_float:"tsl_mod_float",mod_vec2:"tsl_mod_vec2",mod_vec3:"tsl_mod_vec3",mod_vec4:"tsl_mod_vec4",equals_bool:"tsl_equals_bool",equals_bvec2:"tsl_equals_bvec2",equals_bvec3:"tsl_equals_bvec3",equals_bvec4:"tsl_equals_bvec4",inverse_mat2:"tsl_inverse_mat2",inverse_mat3:"tsl_inverse_mat3",inverse_mat4:"tsl_inverse_mat4",inversesqrt:"inverseSqrt",faceforward:"faceForward",bitcast:"bitcast<f32>",floatpack_snorm_2x16:"pack2x16snorm",floatpack_unorm_2x16:"pack2x16unorm",floatpack_float16_2x16:"pack2x16float",floatpack_snorm_4x8:"pack4x8snorm",floatpack_unorm_4x8:"pack4x8unorm",floatunpack_snorm_2x16:"unpack2x16snorm",floatunpack_unorm_2x16:"unpack2x16unorm",floatunpack_float16_2x16:"unpack2x16float",floatunpack_snorm_4x8:"unpack4x8snorm",floatunpack_unorm_4x8:"unpack4x8unorm"},FH=new Set(["alias","break","case","const","const_assert","continue","continuing","default","diagnostic","discard","else","enable","false","fn","for","if","let","loop","override","requires","return","struct","switch","true","var","while","NULL","Self","abstract","active","alignas","alignof","as","asm","asm_fragment","async","attribute","auto","await","become","binding_array","cast","catch","class","co_await","co_return","co_yield","coherent","column_major","common","compile","compile_fragment","concept","const_cast","consteval","constexpr","constinit","crate","debugger","decltype","delete","demote","demote_to_helper","do","dynamic_cast","enum","explicit","export","extends","extern","external","fallthrough","filter","final","finally","friend","from","fxgroup","get","goto","groupshared","highp","impl","implements","import","inline","instanceof","interface","layout","lowp","macro","macro_rules","match","mediump","meta","mod","module","move","mut","mutable","namespace","new","nil","noexcept","noinline","nointerpolation","non_coherent","noncoherent","noperspective","null","nullptr","of","operator","package","packoffset","partition","pass","patch","pixelfragment","precise","precision","premerge","priv","protected","pub","public","readonly","ref","regardless","register","reinterpret_cast","require","resource","restrict","self","set","shared","sizeof","smooth","snorm","static","static_assert","static_cast","std","subroutine","super","target","template","this","thread_local","throw","trait","try","type","typedef","typeid","typename","typeof","union","unless","unorm","unsafe","unsized","use","using","varying","virtual","volatile","wgsl","where","with","writeonly","yield","main"]),P2="";(typeof navigator<"u"&&/Firefox|Deno/g.test(navigator.userAgent))!==!0&&(P2+=`diagnostic( off, derivative_uniformity );
`);var AT=class extends sb{constructor(e,t){super(e,t,new VS),this.uniformGroups={},this.uniformGroupsBindings={},this.builtins={},this.directives={},this.scopedArrays=new Map,this.allowEarlyReturns=!0,this.allowGlobalVariables=!0}_generateTextureSample(e,t,s,n,a,i=this.shaderStage){return i==="fragment"?n?a?`textureSample( ${t}, ${t}_sampler, ${s}, ${n}, ${a} )`:`textureSample( ${t}, ${t}_sampler, ${s}, ${n} )`:a?`textureSample( ${t}, ${t}_sampler, ${s}, ${a} )`:`textureSample( ${t}, ${t}_sampler, ${s} )`:this.generateTextureSampleLevel(e,t,s,"0",n)}generateTextureSampleLevel(e,t,s,n,a,i){return this.isUnfilterable(e)===!1?a?i?`textureSampleLevel( ${t}, ${t}_sampler, ${s}, ${a}, ${n}, ${i} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${s}, ${a}, ${n} )`:i?`textureSampleLevel( ${t}, ${t}_sampler, ${s}, ${n}, ${i} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${s}, ${n} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,s,i,n,a):this.generateTextureLod(e,t,s,a,i,n)}generateWrapFunction(e){let t=`tsl_coord_${lI[e.wrapS]}S_${lI[e.wrapT]}T_${e.is3DTexture||e.isData3DTexture?"3d":"2d"}`,s=uI[t];if(s===void 0){let n=[],a=e.is3DTexture||e.isData3DTexture?"vec3f":"vec2f",i=`fn ${t}( coord : ${a} ) -> ${a} {

	return ${a}(
`,o=(c,l)=>{c===Zn?(n.push(um.repeatWrapping_float),i+=`		tsl_repeatWrapping_float( coord.${l} )`):c===hs?(n.push(um.clampWrapping_float),i+=`		tsl_clampWrapping_float( coord.${l} )`):c===ai?(n.push(um.mirrorWrapping_float),i+=`		tsl_mirrorWrapping_float( coord.${l} )`):(i+=`		coord.${l}`,K(`WebGPURenderer: Unsupported texture wrap type "${c}" for vertex shader.`))};o(e.wrapS,"x"),i+=`,
`,o(e.wrapT,"y"),(e.is3DTexture||e.isData3DTexture)&&(i+=`,
`,o(e.wrapR,"z")),i+=`
	);

}
`,uI[t]=s=new mt(i,n)}return s.build(this),t}generateArrayDeclaration(e,t){return`array< ${this.getType(e)}, ${t} >`}generateTextureDimension(e,t,s){let n=this.getDataFromNode(e,this.shaderStage,this.cache);n.dimensionsSnippet===void 0&&(n.dimensionsSnippet={});let a=n.dimensionsSnippet[s];if(n.dimensionsSnippet[s]===void 0){let i,o,{primarySamples:c}=this.renderer.backend.utils.getTextureSampleData(e),l=c>1;e.is3DTexture||e.isData3DTexture?o="vec3<u32>":o="vec2<u32>",l||e.isStorageTexture?i=t:i=`${t}${s?`, u32( ${s} )`:""}`,a=new Fl(new Dl(`textureDimensions( ${i} )`,o)),n.dimensionsSnippet[s]=a,(e.isArrayTexture||e.isDataArrayTexture||e.is3DTexture||e.isData3DTexture)&&(n.arrayLayerCount=new Fl(new Dl(`textureNumLayers(${t})`,"u32"))),e.isTextureCube&&(n.cubeFaceCount=new Fl(new Dl("6u","u32")))}return a.build(this)}generateTextureSize(e,t,s){let{primarySamples:n}=this.renderer.backend.utils.getTextureSampleData(e);return`textureDimensions( ${n>1||e.isStorageTexture?t:`${t}, ${s}`} )`}generateFilteredTexture(e,t,s,n,a="0u",i){let o=this.generateWrapFunction(e),c=this.generateTextureDimension(e,t,a);return n&&(s=`${s} + vec2<f32>(${n}) / ${c}`),i?(this._include("biquadraticTextureArray"),`tsl_biquadraticTexture_array( ${t}, ${o}( ${s} ), ${c}, u32( ${i} ), u32( ${a} ) )`):(this._include("biquadraticTexture"),`tsl_biquadraticTexture( ${t}, ${o}( ${s} ), ${c}, u32( ${a} ) )`)}generateTextureLod(e,t,s,n,a,i="0u"){if(e.isCubeTexture===!0){a&&(s=`${s} + vec3<f32>(${a})`);let f=e.isDepthTexture?"u32":"f32";return`textureSampleLevel( ${t}, ${t}_sampler, ${s}, ${f}( ${i} ) )`}let o=this.generateWrapFunction(e),c=this.generateTextureDimension(e,t,i),l=e.is3DTexture||e.isData3DTexture?"vec3":"vec2",h=l==="vec3"?"vec3<u32>( 1, 1, 1 )":"vec2<u32>( 1, 1 )";a&&(s=`${s} + ${l}<f32>(${a}) / ${l}<f32>( ${c} )`);let u=`${l}<f32>( 0 )`,d=`${l}<f32>( ${c} - ${h} )`;return s=`${l}<u32>( clamp( floor( ${o}( ${s} ) * ${l}<f32>( ${c} ) ), ${u}, ${d} ) )`,this.generateTextureLoad(e,t,s,i,n,null)}generateStorageTextureLoad(e,t,s,n,a,i){i&&(s=`${s} + ${i}`);let o;return a?o=`textureLoad( ${t}, ${s}, ${a} )`:o=`textureLoad( ${t}, ${s} )`,o}generateTextureLoad(e,t,s,n,a,i){n===null&&(n="0u"),i&&(s=`${s} + ${i}`);let o;return a?o=`textureLoad( ${t}, ${s}, ${a}, u32( ${n} ) )`:(o=`textureLoad( ${t}, ${s}, u32( ${n} ) )`,this.renderer.backend.compatibilityMode&&e.isDepthTexture&&(o+=".x")),o}generateTextureStore(e,t,s,n,a){let i;return n?i=`textureStore( ${t}, ${s}, ${n}, ${a} )`:i=`textureStore( ${t}, ${s}, ${a} )`,i}isSampleCompare(e){return e.isDepthTexture===!0&&e.compareFunction!==null&&this.renderer.hasCompatibility(Hr.TEXTURE_COMPARE)}isUnfilterable(e){return this.getComponentTypeFromTexture(e)!=="float"||!this.isAvailable("float32Filterable")&&e.type===Mt||this.isSampleCompare(e)===!1&&e.minFilter===pt&&e.magFilter===pt||this.renderer.backend.utils.getTextureSampleData(e).primarySamples>1||e.normalized===!0&&(e.type===pi||e.type===ka)}generateTexture(e,t,s,n,a,i=this.shaderStage){let o=null;return this.isUnfilterable(e)?o=this.generateTextureLod(e,t,s,n,a,"0",i):o=this._generateTextureSample(e,t,s,n,a,i),o}generateTextureGrad(e,t,s,n,a,i,o=this.shaderStage){if(o==="fragment")return a?i?`textureSampleGrad( ${t}, ${t}_sampler, ${s}, ${a}, ${n[0]}, ${n[1]}, ${i} )`:`textureSampleGrad( ${t}, ${t}_sampler, ${s}, ${a}, ${n[0]}, ${n[1]} )`:i?`textureSampleGrad( ${t}, ${t}_sampler, ${s}, ${n[0]}, ${n[1]}, ${i} )`:`textureSampleGrad( ${t}, ${t}_sampler, ${s}, ${n[0]}, ${n[1]} )`;W(`WebGPURenderer: THREE.TextureNode.gradient() does not support ${o} shader.`)}generateTextureCompare(e,t,s,n,a,i,o=this.shaderStage){if(o==="fragment")return e.isDepthTexture===!0&&e.isArrayTexture===!0?i?`textureSampleCompare( ${t}, ${t}_sampler, ${s}, ${a}, ${n}, ${i} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${s}, ${a}, ${n} )`:i?`textureSampleCompare( ${t}, ${t}_sampler, ${s}, ${n}, ${i} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${s}, ${n} )`;W(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${o} shader.`)}generateTextureGather(e,t,s,n,a,i){let o=e.isDepthTexture===!0?"":`${n}, `;return a?i?`textureGather( ${o}${t}, ${t}_sampler, ${s}, ${a}, ${i} )`:`textureGather( ${o}${t}, ${t}_sampler, ${s}, ${a} )`:i?`textureGather( ${o}${t}, ${t}_sampler, ${s}, ${i} )`:`textureGather( ${o}${t}, ${t}_sampler, ${s})`}generateTextureGatherCompare(e,t,s,n,a,i){return a?i?`textureGatherCompare( ${t}, ${t}_sampler, ${s}, ${a}, ${n}, ${i} )`:`textureGatherCompare( ${t}, ${t}_sampler, ${s}, ${a}, ${n})`:i?`textureGatherCompare( ${t}, ${t}_sampler, ${s}, ${n}, ${i} )`:`textureGatherCompare( ${t}, ${t}_sampler, ${s}, ${n})`}generateTextureLevel(e,t,s,n,a,i){return this.isUnfilterable(e)===!1?a?i?`textureSampleLevel( ${t}, ${t}_sampler, ${s}, ${a}, ${n}, ${i} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${s}, ${a}, ${n} )`:i?`textureSampleLevel( ${t}, ${t}_sampler, ${s}, ${n}, ${i} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${s}, ${n} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,s,i,n,a):this.generateTextureLod(e,t,s,a,i,n)}generateTextureBias(e,t,s,n,a,i,o=this.shaderStage){if(o==="fragment")return a?i?`textureSampleBias( ${t}, ${t}_sampler, ${s}, ${a}, ${n}, ${i} )`:`textureSampleBias( ${t}, ${t}_sampler, ${s}, ${a}, ${n} )`:i?`textureSampleBias( ${t}, ${t}_sampler, ${s}, ${n}, ${i} )`:`textureSampleBias( ${t}, ${t}_sampler, ${s}, ${n} )`;W(`WebGPURenderer: THREE.TextureNode.biasNode does not support ${o} shader.`)}getPropertyName(e,t=this.shaderStage){if(e.isNodeVarying===!0&&e.needsInterpolation===!0){if(t==="vertex")return`varyings.${e.name}`}else if(e.isNodeUniform===!0){let s=e.name,n=e.type;return n==="texture"||n==="cubeTexture"||n==="cubeDepthTexture"||n==="storageTexture"||n==="texture3D"?s:n==="buffer"||n==="storageBuffer"||n==="indirectStorageBuffer"?this.isCustomStruct(e)?s:s+".value":e.groupNode.name+"."+s}return super.getPropertyName(e)}isReservedKeyword(e){return FH.has(e)}getOutputStructName(){return"output"}getFunctionOperator(e){let t=kH[e];return t!==void 0?(this._include(t),t):null}getNodeAccess(e,t){return t!=="compute"?e.isAtomic===!0?t==="vertex"?(K("WebGPURenderer: Atomic operations are not supported in the vertex stage. They are only available in the fragment and compute stages."),As.READ_ONLY):As.READ_WRITE:As.READ_ONLY:e.access}getStorageAccess(e,t){return CH[this.getNodeAccess(e,t)]}getUniformFromNode(e,t,s,n=null){let a=super.getUniformFromNode(e,t,s,n),i=this.getDataFromNode(e,s,this.globalCache);if(i.uniformGPU===void 0){let o,c=e.groupNode,l=c.name,h=this.getBindGroupArray(l,s);if(t==="texture"||t==="cubeTexture"||t==="cubeDepthTexture"||t==="storageTexture"||t==="texture3D"){let u=null,d=this.getNodeAccess(e,s);if(t==="texture"||t==="storageTexture"?e.value.is3DTexture===!0?u=new fb(a.name,a.node,c,d):u=new qd(a.name,a.node,c,d):t==="cubeTexture"||t==="cubeDepthTexture"?u=new fT(a.name,a.node,c,d):t==="texture3D"&&(u=new fb(a.name,a.node,c,d)),u.store=e.isStorageTextureNode===!0,u.mipLevel=u.store?e.mipLevel:0,u.setVisibility(XA[s]),e.value.isCubeTexture===!0||this.isUnfilterable(e.value)===!1&&u.store===!1||e.gatherNode!==null){let p=new NS(`${a.name}_sampler`,a.node,c);p.setVisibility(XA[s]),h.push(p,u),o=[p,u]}else h.push(u),o=[u]}else if(t==="buffer"||t==="storageBuffer"||t==="indirectStorageBuffer"){let u=this.getSharedDataFromNode(e),d=u.buffer;if(d===void 0){let f=t==="buffer"?hT:ES;d=new f(e,c),u.buffer=d}d.setVisibility(d.getVisibility()|XA[s]),h.push(d),o=d,a.name=n||"NodeBuffer_"+a.id}else{let u=this.uniformGroups[l];u===void 0&&(u=new uT(l,c),u.setVisibility(Ai.VERTEX|Ai.FRAGMENT|Ai.COMPUTE),this.uniformGroups[l]=u),h.indexOf(u)===-1&&h.push(u),o=this.getNodeUniform(a,t);let d=o.name;u.uniforms.some(p=>p.name===d)||u.addUniform(o)}i.uniformGPU=o}return a}getBuiltin(e,t,s,n=this.shaderStage){let a=this.builtins[n]||(this.builtins[n]=new Map);return a.has(e)===!1&&a.set(e,{name:e,property:t,type:s}),t}hasBuiltin(e,t=this.shaderStage){return this.builtins[t]!==void 0&&this.builtins[t].has(e)}getVertexIndex(){return this.shaderStage==="vertex"?this.getBuiltin("vertex_index","vertexIndex","u32","attribute"):"vertexIndex"}buildFunctionCode(e){let t=e.layout,s=this.flowShaderNode(e),n=[];for(let i of t.inputs)n.push(i.name+" : "+this.getType(i.type));let a=`fn ${t.name}( ${n.join(", ")} ) -> ${this.getType(t.type)} {
${s.vars}
${s.code}
`;return s.result&&(a+=`	return ${s.result};
`),a+=`
}
`,a}getInstanceIndex(){return this.shaderStage==="vertex"?this.getBuiltin("instance_index","instanceIndex","u32","attribute"):"instanceIndex"}getInvocationLocalIndex(){return this.getBuiltin("local_invocation_index","invocationLocalIndex","u32","attribute")}getSubgroupSize(){return this.enableSubGroups(),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute")}getInvocationSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_invocation_id","invocationSubgroupIndex","u32","attribute")}getSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_id","subgroupIndex","u32","attribute")}getDrawIndex(){return null}getFrontFacing(){return this.getBuiltin("front_facing","isFront","bool")}getFragCoord(){return this.getBuiltin("position","fragCoord","vec4<f32>")+".xy"}getFragDepth(){return"output."+this.getBuiltin("frag_depth","depth","f32","output")}getClipDistance(){return"varyings.hw_clip_distances"}isFlipY(){return!1}enableDirective(e,t=this.shaderStage){(this.directives[t]||(this.directives[t]=new Set)).add(e)}getDirectives(e){let t=[],s=this.directives[e];if(s!==void 0)for(let n of s)t.push(`enable ${n};`);return t.join(`
`)}enableSubGroups(){this.enableDirective("subgroups")}enableSubgroupsF16(){this.enableDirective("subgroups-f16")}enableClipDistances(){this.enableDirective("clip_distances")}enableShaderF16(){this.enableDirective("f16")}enableDualSourceBlending(){this.enableDirective("dual_source_blending")}enableHardwareClipping(e){this.enableClipDistances(),this.getBuiltin("clip_distances","hw_clip_distances",`array<f32, ${e} >`,"vertex")}getBuiltins(e){let t=[],s=this.builtins[e];if(s!==void 0)for(let{name:n,property:a,type:i}of s.values())t.push(`@builtin( ${n} ) ${a} : ${i}`);return t.join(`,
	`)}getScopedArray(e,t,s,n,a){return this.scopedArrays.has(e)===!1&&this.scopedArrays.set(e,{name:e,scope:t,bufferType:s,bufferCount:n,isAtomic:a}),e}getScopedArrays(e){if(e!=="compute")return;let t=[];for(let{name:s,scope:n,bufferType:a,bufferCount:i,isAtomic:o}of this.scopedArrays.values()){let c=this.getType(a);o===!0&&(c=`atomic<${c}>`),t.push(`var<${n}> ${s}: array< ${c}, ${i} >;`)}return t.join(`
`)}getAttributes(e){let t=[];if(e==="compute"&&(this.getBuiltin("global_invocation_id","globalId","vec3<u32>","attribute"),this.getBuiltin("workgroup_id","workgroupId","vec3<u32>","attribute"),this.getBuiltin("local_invocation_id","localId","vec3<u32>","attribute"),this.getBuiltin("num_workgroups","numWorkgroups","vec3<u32>","attribute"),this.renderer.hasFeature("subgroups")&&(this.enableDirective("subgroups",e),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute"))),e==="vertex"||e==="compute"){let s=this.getBuiltins("attribute");s&&t.push(s);let n=this.getAttributesArray();for(let a=0,i=n.length;a<i;a++){let o=n[a],c=o.name,l=this.getType(o.type);t.push(`@location( ${a} ) ${c} : ${l}`)}}return t.join(`,
	`)}getStructMembers(e){let t=[];for(let s of e.members){let n=e.output?"@location( "+s.index+" ) ":"",a=this.getType(s.type);s.atomic&&(a="atomic< "+a+" >"),t.push(`	${n+s.name} : ${a}`)}return e.output&&t.push(`	${this.getBuiltins("output")}`),t.join(`,
`)}getStructs(e){let t="",s=this.structs[e];if(s.length>0){let n=[];for(let a of s){let i=`struct ${a.name} {
`;i+=this.getStructMembers(a),i+=`
};`,n.push(i)}t=`
`+n.join(`

`)+`
`}return t}getVar(e,t,s=null,n=""){let a=`var${n} ${t} : `;return s!==null?a+=this.generateArrayDeclaration(e,s):a+=this.getType(e),a}getVars(e,t=!1){let s="";t&&(s="<private>");let n=[],a=this.vars[e];if(a!==void 0)for(let i of a)n.push(`${this.getVar(i.type,i.name,i.count,s)};`);return t?n.join(`
`):`
	${n.join(`
	`)}
`}getVaryings(e){let t=[];if(e==="vertex"&&this.getBuiltin("position","builtinClipSpace","vec4<f32>","vertex"),e==="vertex"||e==="fragment"){let a=this.varyings,i=this.vars[e],o=0;for(let c=0;c<a.length;c++){let l=a[c];if(l.needsInterpolation){let h=`@location( ${o++} )`;if(l.interpolationType){let u=l.interpolationSampling!==null?`, ${l.interpolationSampling} )`:" )";h+=` @interpolate( ${l.interpolationType}${u}`}else/^(int|uint|ivec|uvec)/.test(l.type)&&(h+=" @interpolate(flat, either)");t.push(`${h} ${l.name} : ${this.getType(l.type)}`)}else e==="vertex"&&i.includes(l)===!1&&i.push(l)}}let s=this.getBuiltins(e);s&&t.push(s);let n=t.join(`,
	`);return e==="vertex"?this._getWGSLStruct("VaryingsStruct","	"+n):n}isCustomStruct(e){let t=e.value,s=e.node,n=(t.isBufferAttribute||t.isInstancedBufferAttribute)&&s.structTypeNode!==null,a=s.value&&s.value.array&&typeof s.value.itemSize=="number"&&s.value.array.length>s.value.itemSize;return n&&!a}getUniforms(e){let t=this.renderer.backend,s=this.uniforms[e],n=[],a=[],i=[],o={};for(let l of s){let h=l.groupNode.name,u=this.bindingsIndexes[h];if(l.type==="texture"||l.type==="cubeTexture"||l.type==="cubeDepthTexture"||l.type==="storageTexture"||l.type==="texture3D"){let d=l.node,f=d.value;(f.isCubeTexture===!0||this.isUnfilterable(f)===!1&&d.isStorageTextureNode!==!0||d.gatherNode!==null)&&(this.isSampleCompare(f)&&d.isSampleCompare()?n.push(`@binding( ${u.binding++} ) @group( ${u.group} ) var ${l.name}_sampler : sampler_comparison;`):n.push(`@binding( ${u.binding++} ) @group( ${u.group} ) var ${l.name}_sampler : sampler;`));let m,b="",{primarySamples:g}=t.utils.getTextureSampleData(f);if(g>1&&(b="_multisampled"),f.isCubeTexture===!0&&f.isDepthTexture===!0)m="texture_depth_cube";else if(f.isCubeTexture===!0)m="texture_cube<f32>";else if(f.isDepthTexture===!0)t.compatibilityMode&&f.compareFunction===null?m=`texture${b}_2d<f32>`:m=`texture_depth${b}_2d${f.isArrayTexture===!0?"_array":""}`;else if(l.node.isStorageTextureNode===!0){let x=LS(f,t.device),T=this.getStorageAccess(l.node,e),y=l.node.value.is3DTexture,v=l.node.value.isArrayTexture;m=`texture_storage_${y?"3d":`2d${v?"_array":""}`}<${x}, ${T}>`}else if(f.isArrayTexture===!0||f.isDataArrayTexture===!0||f.isCompressedArrayTexture===!0)m=`texture_2d_array<${this.getComponentTypeFromTexture(f).charAt(0)}32>`;else if(f.is3DTexture===!0||f.isData3DTexture===!0)m=`texture_3d<${this.getComponentTypeFromTexture(f).charAt(0)}32>`;else{let x=this.getComponentTypeFromTexture(f).charAt(0);m=`texture${b}_2d<${x}32>`}n.push(`@binding( ${u.binding++} ) @group( ${u.group} ) var ${l.name} : ${m};`)}else if(l.type==="buffer"||l.type==="storageBuffer"||l.type==="indirectStorageBuffer"){let d=l.node,f=this.getType(d.getNodeType(this)),p=d.bufferCount,m=p>0&&l.type==="buffer"?", "+p:"",b=d.isStorageBufferNode?`storage, ${this.getStorageAccess(d,e)}`:"uniform";if(this.isCustomStruct(l))a.push(`@binding( ${u.binding++} ) @group( ${u.group} ) var<${b}> ${l.name} : ${f};`);else{let x=`	value : array< ${d.isAtomic?`atomic<${f}>`:`${f}`}${m} >`;a.push(this._getWGSLStructBinding(l.name,x,b,u.binding++,u.group))}}else{let d=l.groupNode.name;if(o[d]===void 0){let f=this.uniformGroups[d];if(f!==void 0){let p=[];for(let b of f.uniforms){let g=b.getType(),x=this.getType(this.getVectorType(g));p.push(`	${b.name} : ${x}`)}let m=this.uniformGroupsBindings[d];m===void 0&&(m={index:u.binding++,id:u.group},this.uniformGroupsBindings[d]=m),o[d]={index:m.index,id:m.id,snippets:p}}}}}for(let l in o){let h=o[l];i.push(this._getWGSLStructBinding(l,h.snippets.join(`,
`),"uniform",h.index,h.id))}return[...n,...a,...i].join(`
`)}buildCode(){let e=this.material!==null?{fragment:{},vertex:{}}:{compute:{}};this.sortBindingGroups();for(let t in e){this.shaderStage=t;let s=this.allowGlobalVariables,n=e[t];n.uniforms=this.getUniforms(t),n.attributes=this.getAttributes(t),n.varyings=this.getVaryings(t),n.structs=this.getStructs(t),n.vars=this.getVars(t,s),n.codes=this.getCodes(t),n.directives=this.getDirectives(t),n.scopedArrays=this.getScopedArrays(t);let a=`// code

`;a+=this.flowCode[t];let i=this.flowNodes[t],o=i[i.length-1],c=o.outputNode,l=c!==void 0&&c.isOutputStructNode===!0;for(let h of i){let u=this.getFlowData(h),d=h.name;if(d&&(a.length>0&&(a+=`
`),a+=`	// flow -> ${d}
`),a+=`${u.code}
	`,h===o&&t!=="compute"){if(a+=`// result

	`,t==="vertex")a+=`varyings.builtinClipSpace = ${u.result};`;else if(t==="fragment")if(l)n.returnType=c.getNodeType(this),n.structs+="var<private> output : "+n.returnType+";",a+=`return ${u.result};`;else{let f=`	@location( 0 ) color: ${this.getType(this.getOutputType())}`,p=this.getBuiltins("output");p&&(f+=`,
	`+p),n.returnType="OutputStruct",n.structs+=this._getWGSLStruct("OutputStruct",f),n.structs+=`
var<private> output : OutputStruct;`,a+=`output.color = ${this.format(u.result,o.getNodeType(this),this.getOutputType())};

	return output;`}}}n.flow=a}if(this.shaderStage=null,this.material!==null)this.vertexShader=this._getWGSLVertexCode(e.vertex),this.fragmentShader=this._getWGSLFragmentCode(e.fragment);else{let t=this.compute.workgroupSize;this.computeShader=this._getWGSLComputeCode(e.compute,t)}}getMethod(e,t=null){let s;return t!==null&&(s=this._getWGSLMethod(e+"_"+t)),s===void 0&&(s=this._getWGSLMethod(e)),s||e}getBitcastMethod(e){return`bitcast<${this.getType(e)}>`}getFloatPackingMethod(e,t="2x16"){return this.getMethod(`floatpack_${e}_${t}`)}getFloatUnpackingMethod(e,t="2x16"){return this.getMethod(`floatunpack_${e}_${t}`)}getTernary(e,t,s){return`select( ${s}, ${t}, ${e} )`}getType(e){return IH[e]||e}isAvailable(e){let t=hI[e];return t===void 0&&(e==="float32Filterable"?t=this.renderer.hasFeature("float32-filterable"):e==="clipDistance"&&(t=this.renderer.hasFeature("clip-distances")),hI[e]=t),t}_getWGSLMethod(e){return um[e]!==void 0&&this._include(e),BH[e]}_include(e){let t=um[e];return t.build(this),this.addInclude(t),t}_getWGSLVertexCode(e){return`${this.getSignature()}
// directives
${e.directives}

// structs
${e.structs}

// uniforms
${e.uniforms}

// varyings
${e.varyings}
var<private> varyings : VaryingsStruct;

// vars
${e.vars}

// codes
${e.codes}

@vertex
fn main( ${e.attributes} ) -> VaryingsStruct {

	// flow
	${e.flow}

	return varyings;

}
`}_getWGSLFragmentCode(e){return`${this.getSignature()}
// global
${P2}

// structs
${e.structs}

// uniforms
${e.uniforms}

// vars
${e.vars}

// codes
${e.codes}

@fragment
fn main( ${e.varyings} ) -> ${e.returnType} {

	// flow
	${e.flow}

}
`}_getWGSLComputeCode(e,t){let[s,n,a]=t;return`${this.getSignature()}
// directives
${e.directives}

// system
var<private> instanceIndex : u32;

// locals
${e.scopedArrays}

// structs
${e.structs}

// uniforms
${e.uniforms}

// vars
${this.allowGlobalVariables?e.vars:""}

// codes
${e.codes}

@compute @workgroup_size( ${s}, ${n}, ${a} )
fn main( ${e.attributes} ) {

	// local vars
	${this.allowGlobalVariables?"":e.vars}

	// system
	instanceIndex = globalId.x
		+ globalId.y * ( ${s} * numWorkgroups.x )
		+ globalId.z * ( ${s} * numWorkgroups.x ) * ( ${n} * numWorkgroups.y );

	// flow
	${e.flow}

}
`}_getWGSLStruct(e,t){return`
struct ${e} {
${t}
};`}_getWGSLStructBinding(e,t,s,n=0,a=0){let i=e+"Struct";return`${this._getWGSLStruct(i,t)}
@binding( ${n} ) @group( ${a} )
var<${s}> ${e} : ${i};`}},hn=new dc,KA=new Jl,D2=new Map([[Int8Array,["sint8","snorm8"]],[Uint8Array,["uint8","unorm8"]],[Int16Array,["sint16","snorm16"]],[Uint16Array,["uint16","unorm16"]],[Int32Array,["sint32"]],[Uint32Array,["uint32"]],[Float32Array,["float32"]]]);typeof Float16Array<"u"&&D2.set(Float16Array,["float16"]);var PH=new Map([[Kh,["float16"]]]),DH=new Map([[Int32Array,"sint32"],[Uint32Array,"uint32"],[Float32Array,"float32"]]),jS=class{constructor(e){this.backend=e}createAttribute(e,t){let s=this._getBufferAttribute(e),n=this.backend,a=n.get(s),i=a.buffer;if(i===void 0){let o=n.device,c=s.array;if(e.normalized===!1&&e.isInterleavedBufferAttribute!==!0){if(c.constructor===Int16Array||c.constructor===Int8Array)c=new Int32Array(c);else if((c.constructor===Uint16Array||c.constructor===Uint8Array)&&(c=new Uint32Array(c),t&GPUBufferUsage.INDEX))for(let d=0;d<c.length;d++)c[d]===65535&&(c[d]=4294967295)}s.array=c;let l;if((s.isStorageBufferAttribute||s.isStorageInstancedBufferAttribute)&&s.itemSize===3)l=4;else if(s.itemSize>1&&s.itemSize*c.BYTES_PER_ELEMENT%4!==0){let d=s.itemSize*c.BYTES_PER_ELEMENT;l=Math.floor((d+3)/4)*4/c.BYTES_PER_ELEMENT}if(l!==void 0){let d=s.itemSize,f=new c.constructor(s.count*l);for(let p=0;p<s.count;p++)f.set(c.subarray(p*d,p*d+d),p*l);(s.isStorageBufferAttribute||s.isStorageInstancedBufferAttribute)&&(s.itemSize=l,s.array=f),c=f,a._itemSize=d,a._paddedItemSize=l}let h=c.byteLength,u=h+(4-h%4)%4;hn.label=s.name,hn.size=u,hn.usage=t,hn.mappedAtCreation=!0,i=o.createBuffer(hn),hn.reset(),new c.constructor(i.getMappedRange()).set(c),i.unmap(),a.buffer=i}}updateAttribute(e){let t=this._getBufferAttribute(e),s=this.backend,n=s.device,a=s.get(t),i=s.get(t).buffer,o=t.array,c=a._itemSize,l=a._paddedItemSize;if(l!==void 0){o=new o.constructor(t.count*l);for(let u=0;u<t.count;u++)o.set(t.array.subarray(u*c,u*c+c),u*l);(t.isStorageBufferAttribute||t.isStorageInstancedBufferAttribute)&&(t.array=o)}let h=t.updateRanges;if(h.length===0)n.queue.writeBuffer(i,0,o,0);else{let u=bl(o),d=u?1:o.BYTES_PER_ELEMENT;for(let f=0,p=h.length;f<p;f++){let m=h[f],b,g;if(l!==void 0){let T=Math.floor(m.start/c),y=Math.ceil((m.start+m.count)/c)-T;b=T*l*d,g=y*l*d}else b=m.start*d,g=m.count*d;let x=b*(u?o.BYTES_PER_ELEMENT:1);n.queue.writeBuffer(i,x,o,b,g)}t.clearUpdateRanges()}}createShaderVertexBuffers(e){let t=e.getAttributes(),s=new Map;for(let n=0;n<t.length;n++){let a=t[n],i=a.array.BYTES_PER_ELEMENT,o=this._getBufferAttribute(a),c=s.get(o);if(c===void 0){let u,d;a.isInterleavedBufferAttribute===!0?(u=a.data.stride*i,d=a.data.isInstancedInterleavedBuffer?t0.Instance:t0.Vertex):(u=a.itemSize*i,d=a.isInstancedBufferAttribute?t0.Instance:t0.Vertex,a.itemSize>1&&u%4!==0&&(u=Math.floor((u+3)/4)*4)),c={arrayStride:u,attributes:[],stepMode:d},s.set(o,c)}let l=this._getVertexFormat(a),h=a.isInterleavedBufferAttribute===!0?a.offset*i:0;c.attributes.push({shaderLocation:n,offset:h,format:l})}return Array.from(s.values())}destroyAttribute(e){let t=this.backend;t.get(this._getBufferAttribute(e)).buffer.destroy(),t.delete(e)}async getArrayBufferAsync(e,t=null,s=0,n=-1){let a=this.backend,i=a.device,c=a.get(this._getBufferAttribute(e)).buffer,l=n===-1?c.size-s:n,h;if(t!==null&&t.isReadbackBuffer){let f=a.get(t);if(t._mapped===!0)throw new Error("THREE.WebGPUAttributeUtils: ReadbackBuffer must be released before being used again.");if(t._mapped=!0,f.readBufferGPU===void 0){hn.label=`${t.name}_readback`,hn.size=t.maxByteLength,hn.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,h=i.createBuffer(hn),hn.reset();let p=()=>{t.buffer=null,t._mapped=!1,h.unmap()},m=()=>{t.buffer=null,t._mapped=!1,h.destroy(),a.delete(t),t.removeEventListener("release",p),t.removeEventListener("dispose",m)};t.addEventListener("release",p),t.addEventListener("dispose",m),f.readBufferGPU=h}else h=f.readBufferGPU}else hn.label=`${e.name}_readback`,hn.size=l,hn.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,h=i.createBuffer(hn),hn.reset();KA.label=`readback_encoder_${e.name}`;let u=i.createCommandEncoder(KA);KA.reset(),u.copyBufferToBuffer(c,s,h,0,l);let d=u.finish();if(sr(i,d),await h.mapAsync(GPUMapMode.READ,0,l),t===null){let p=h.getMappedRange(0,l).slice();return h.destroy(),p}else{if(t.isReadbackBuffer)return t.buffer=h.getMappedRange(0,l),t;{let f=h.getMappedRange(0,l);return new Uint8Array(t).set(new Uint8Array(f)),h.destroy(),t}}}_getVertexFormat(e){let{itemSize:t,normalized:s}=e,n=e.array.constructor,a=e.constructor,i;if(t===1)i=DH.get(n);else{let c=(PH.get(a)||D2.get(n))[s?1:0];if(c){let l=n.BYTES_PER_ELEMENT*t,u=Math.floor((l+3)/4)*4/n.BYTES_PER_ELEMENT;if(u%1)throw new Error("THREE.WebGPUAttributeUtils: Bad vertex format item size.");i=`${c}x${u}`}}return i||W("WebGPUAttributeUtils: Vertex format not supported yet."),i}_getBufferAttribute(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}},ra=new xT,dm=new dc,dd=new bb,GS=class{constructor(e){this.layoutGPU=e,this.usedTimes=0}},HS=class{constructor(e){this.backend=e,this._bindGroupLayoutCache=new Map}createBindingsLayout(e){let t=this.backend,s=t.device,n=t.get(e);if(n.layout)return n.layout.layoutGPU;let a=this._createLayoutEntries(e),i=fc(JSON.stringify(a)),o=this._bindGroupLayoutCache.get(i);return o===void 0&&(o=new GS(s.createBindGroupLayout({entries:a})),this._bindGroupLayoutCache.set(i,o)),o.usedTimes++,n.layout=o,n.layoutKey=i,o.layoutGPU}createBindings(e,t,s,n=0){let{backend:a}=this,i=a.get(e),o=this.createBindingsLayout(e),c;s!==""&&(i.groups===void 0&&(i.groups={},i.versions={}),i.versions[s]===n&&(c=i.groups[s])),c===void 0&&(c=this.createBindGroup(e,o),s!==""&&(i.groups[s]=c,i.versions[s]=n)),i.group=c}updateBinding(e){let t=this.backend,s=t.device,n=e.buffer,a=t.get(e).buffer,i=e.updateRanges;if(i.length===0)s.queue.writeBuffer(a,0,n,0);else{let o=bl(n),c=o?1:n.BYTES_PER_ELEMENT,l=i[0].start;for(let h=0,u=i.length;h<u;h++){let d=i[h],f=i[h+1],p=d.start+d.count;if(f!==void 0&&f.start===p)continue;let m=l*c,b=(p-l)*c,g=m*(o?n.BYTES_PER_ELEMENT:1);s.queue.writeBuffer(a,g,n,m,b),f!==void 0&&(l=f.start)}}}createBindGroupIndex(e,t){let n=this.backend.device,a=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,i=e[0];dm.label="bindingCameraIndex_"+i,dm.size=16,dm.usage=a;let o=n.createBuffer(dm);dm.reset(),n.queue.writeBuffer(o,0,e,0),ra.label="bindGroupCameraIndex_"+i,ra.layout=t,ra.entries.push({binding:0,resource:{buffer:o}});let c=n.createBindGroup(ra);return ra.reset(),c}createBindGroup(e,t){let s=this.backend,n=s.device,a=0;ra.label="bindGroup_"+e.name,ra.layout=t;for(let o of e.bindings){if(o.isUniformBuffer){let c=s.get(o);ra.entries.push({binding:a,resource:{buffer:c.buffer}})}else if(o.isStorageBuffer){let c=s.get(o.attribute).buffer;ra.entries.push({binding:a,resource:{buffer:c}})}else if(o.isSampledTexture){let c=s.get(o.texture),l;if(c.externalTexture!==void 0)l=n.importExternalTexture({source:c.externalTexture});else{let h=o.store?1:c.texture.mipLevelCount,u=o.store?o.mipLevel:0,d=`view-${c.texture.width}-${c.texture.height}`;if(c.texture.depthOrArrayLayers>1&&(d+=`-${c.texture.depthOrArrayLayers}`),d+=`-${h}-${u}`,l=c[d],l===void 0){let f=vH.All,p;o.isSampledCubeTexture?p=Js.Cube:o.texture.isArrayTexture||o.texture.isDataArrayTexture||o.texture.isCompressedArrayTexture?p=Js.TwoDArray:o.isSampledTexture3D?p=Js.ThreeD:p=Js.TwoD,dd.aspect=f,dd.dimension=p,dd.mipLevelCount=h,dd.baseMipLevel=u,l=c[d]=c.texture.createView(dd),dd.reset()}}ra.entries.push({binding:a,resource:l})}else if(o.isSampler){let c=s.get(o);ra.entries.push({binding:a,resource:c.sampler})}a++}let i=n.createBindGroup(ra);return ra.reset(),i}_createLayoutEntries(e){let t=[],s=0;for(let n of e.bindings){let a=this.backend,i={binding:s,visibility:n.visibility};if(n.isUniformBuffer||n.isStorageBuffer){let o={};n.isStorageBuffer&&(n.visibility&Ai.COMPUTE?n.access===As.READ_WRITE||n.access===As.WRITE_ONLY?o.type=e0.Storage:o.type=e0.ReadOnlyStorage:n.nodeUniform&&n.nodeUniform.isAtomic&&n.visibility&Ai.FRAGMENT?o.type=e0.Storage:o.type=e0.ReadOnlyStorage),i.buffer=o}else if(n.isSampledTexture&&n.store){let o={};o.format=this.backend.get(n.texture).texture.format;let c=n.access;c===As.READ_WRITE?o.access=jA.ReadWrite:c===As.WRITE_ONLY?o.access=jA.WriteOnly:o.access=jA.ReadOnly,n.texture.isArrayTexture?o.viewDimension=Js.TwoDArray:n.texture.is3DTexture&&(o.viewDimension=Js.ThreeD),i.storageTexture=o}else if(n.isSampledTexture){let o={},{primarySamples:c}=a.utils.getTextureSampleData(n.texture);if(c>1&&(o.multisampled=!0,n.texture.isDepthTexture||(o.sampleType=Go.UnfilterableFloat)),n.texture.isDepthTexture)a.compatibilityMode&&n.texture.compareFunction===null?o.sampleType=Go.UnfilterableFloat:o.sampleType=Go.Depth;else{let l=n.texture.type;l===Ts?o.sampleType=Go.SInt:l===St?o.sampleType=Go.UInt:n.texture.normalized===!0&&(l===pi||l===ka)?o.sampleType=Go.UnfilterableFloat:l===Mt&&(this.backend.hasFeature("float32-filterable")?o.sampleType=Go.Float:o.sampleType=Go.UnfilterableFloat)}n.isSampledCubeTexture?o.viewDimension=Js.Cube:n.texture.isArrayTexture||n.texture.isDataArrayTexture||n.texture.isCompressedArrayTexture?o.viewDimension=Js.TwoDArray:n.isSampledTexture3D&&(o.viewDimension=Js.ThreeD),i.texture=o}else if(n.isSampler){let o={};n.texture.isDepthTexture&&(n.texture.compareFunction!==null&&n.textureNode.isSampleCompare()&&a.hasCompatibility(Hr.TEXTURE_COMPARE)?o.type=iI.Comparison:o.type=iI.NonFiltering),i.sampler=o}else W(`WebGPUBindingUtils: Unsupported binding "${n}".`);t.push(i),s++}return t}deleteBindGroupData(e){let{backend:t}=this,s=t.get(e);s.layout&&(s.layout.usedTimes--,s.layout.usedTimes===0&&this._bindGroupLayoutCache.delete(s.layoutKey),s.layout=void 0,s.layoutKey=void 0)}dispose(){this._bindGroupLayoutCache.clear()}},WS=class{constructor(e){this.backend=e}getMaxAnisotropy(){return 16}getUniformBufferLimit(){return this.backend.device.limits.maxUniformBufferBindingSize}},qS=class{constructor(){this.label="",this.layout=null,this.compute=null}reset(){this.label="",this.layout=null,this.compute=null}},XS=class{constructor(){this.label="",this.bindGroupLayouts=null}reset(){this.label="",this.bindGroupLayouts=null}},_l=new qS,fd=new XS,pd=new wT,oa=new TT,KS=class{constructor(e){this.backend=e}_getSampleCount(e){return this.backend.utils.getSampleCountRenderContext(e)}createRenderPipeline(e,t){let{object:s,material:n,geometry:a,pipeline:i}=e,{vertexProgram:o,fragmentProgram:c}=i,l=this.backend,h=l.device,u=l.utils,d=l.get(i),f=[];for(let U of e.getBindings()){let j=l.get(U),{layoutGPU:z}=j.layout;f.push(z)}let p=l.attributeUtils.createShaderVertexBuffers(e),m;n.blending!==Ca&&(n.blending!==ta||n.transparent!==!1)&&(m=this._getBlending(n));let b={};n.stencilWrite===!0&&(b={compare:this._getStencilCompare(n),failOp:this._getStencilOperation(n.stencilFail),depthFailOp:this._getStencilOperation(n.stencilZFail),passOp:this._getStencilOperation(n.stencilZPass)});let g=this._getColorWriteMask(n),x=[];if(e.context.textures!==null){let U=e.context.textures,j=e.context.mrt;for(let z=0;z<U.length;z++){let H=U[z],J=u.getTextureFormatGPU(H),ee;if(j!==null)if(this.backend.compatibilityMode!==!0){let se=j.getBlendMode(H.name);se.blending===Lp?ee=m:se.blending!==Ca&&(ee=this._getBlending(se))}else je("WebGPURenderer: Multiple Render Targets (MRT) blending configuration is not fully supported in compatibility mode. The material blending will be used for all render targets."),ee=m;else ee=m;x.push({format:J,blend:ee,writeMask:g})}}else{let U=u.getCurrentColorFormat(e.context);x.push({format:U,blend:m,writeMask:g})}let T=l.get(o).module,y=l.get(c).module,v=this._getPrimitiveState(s,a,n),_=this._getDepthCompare(n),A=u.getCurrentDepthStencilFormat(e.context),M=this._getSampleCount(e.context);fd.bindGroupLayouts=f;let N=h.createPipelineLayout(fd);fd.reset(),oa.label=`renderPipeline_${n.name||n.type}_${n.id}`,oa.vertex=Object.assign({},T,{buffers:p}),oa.fragment=Object.assign({},y,{targets:x}),oa.primitive=v,oa.multisample.count=M,oa.multisample.alphaToCoverageEnabled=n.alphaToCoverage&&M>1,oa.layout=N;let R={},I=e.context.depth,D=e.context.stencil;(I===!0||D===!0)&&(I===!0&&(R.format=A,R.depthWriteEnabled=n.depthWrite,R.depthCompare=_),D===!0&&(R.stencilFront=b,R.stencilBack=b,R.stencilReadMask=n.stencilFuncMask,R.stencilWriteMask=n.stencilWriteMask),n.polygonOffset===!0&&v.topology===ym.TriangleList&&(R.depthBias=n.polygonOffsetUnits,R.depthBiasSlopeScale=n.polygonOffsetFactor,R.depthBiasClamp=0),oa.depthStencil=R),h.pushErrorScope("validation");let O=[{program:o,module:T.module},{program:c,module:y.module}],P=oa.label;if(t===null)d.pipeline=h.createRenderPipeline(oa),oa.reset(),h.popErrorScope().then(U=>{U!==null&&(d.error=!0,W(`WebGPURenderer: Render pipeline creation failed (${P}): ${U.message}`),this._reportShaderDiagnostics(O,P))});else{let U=new Promise(async j=>{try{let z=null,H=null;try{H=h.createRenderPipelineAsync(oa)}catch(ee){z=ee}if(oa.reset(),H!==null)try{d.pipeline=await H}catch(ee){z=ee}let J=await h.popErrorScope();if(J!==null||z!==null){d.error=!0;let ee=J&&J.message||z&&z.message||"unknown";W(`WebGPURenderer: Async render pipeline creation failed (${P}): ${ee}`),await this._reportShaderDiagnostics(O,P)}}finally{j()}});t.push(U)}}createBundleEncoder(e,t="renderBundleEncoder"){let s=this.backend,{utils:n,device:a}=s,i=n.getCurrentDepthStencilFormat(e),o=n.getCurrentColorFormats(e),c=this._getSampleCount(e);pd.label=t,pd.colorFormats=o,pd.depthStencilFormat=i,pd.sampleCount=c;let l=a.createRenderBundleEncoder(pd);return pd.reset(),l}createComputePipeline(e,t,s=null){let n=this.backend,a=n.device,i=n.get(e.computeProgram).module,o=n.get(e),c=[];for(let d of t){let f=n.get(d),{layoutGPU:p}=f.layout;c.push(p)}let l=e.computeProgram,h=`computePipeline_${l.stage}${l.name?`_${l.name}`:""}`;a.pushErrorScope("validation"),fd.bindGroupLayouts=c;let u=a.createPipelineLayout(fd);if(fd.reset(),_l.label=h,_l.compute=i,_l.layout=u,s===null)o.pipeline=a.createComputePipeline(_l),_l.reset(),a.popErrorScope().then(d=>{d!==null&&(o.error=!0,W(`WebGPURenderer: Compute pipeline creation failed (${h}): ${d.message}`),this._reportShaderDiagnostics([{program:l,module:i.module}],h))});else{let d=new Promise(async f=>{try{let p=null,m=null;try{m=a.createComputePipelineAsync(_l)}catch(g){p=g}if(_l.reset(),m!==null)try{o.pipeline=await m}catch(g){p=g}let b=await a.popErrorScope();if(b!==null||p!==null){o.error=!0;let g=b&&b.message||p&&p.message||"unknown";W(`WebGPURenderer: Async compute pipeline creation failed (${h}): ${g}`),await this._reportShaderDiagnostics([{program:l,module:i.module}],h)}}finally{f()}});s.push(d)}}async _reportShaderDiagnostics(e,t){for(let{program:s,module:n}of e){let a=await n.getCompilationInfo();if(a.messages.length===0)continue;let i=s.code.split(`
`);for(let o of a.messages){let c=o.lineNum>0?` at line ${o.lineNum}${o.linePos>0?`:${o.linePos}`:""}`:"",l=`WebGPURenderer [${t} / ${s.stage} ${o.type}]${c}: ${o.message}`,h="";o.lineNum>0&&o.lineNum<=i.length&&(h=`
  ${i[o.lineNum-1]}`,o.linePos>0&&(h+=`
  ${" ".repeat(o.linePos-1)}^`)),(o.type==="error"?W:K)(l+h)}}}_getBlending(e){let t,s,n=e.blending,a=e.blendSrc,i=e.blendDst,o=e.blendEquation;if(n===Or){let c=e.blendSrcAlpha!==null?e.blendSrcAlpha:a,l=e.blendDstAlpha!==null?e.blendDstAlpha:i,h=e.blendEquationAlpha!==null?e.blendEquationAlpha:o;t={srcFactor:this._getBlendFactor(a),dstFactor:this._getBlendFactor(i),operation:this._getBlendOperation(o)},s={srcFactor:this._getBlendFactor(c),dstFactor:this._getBlendFactor(l),operation:this._getBlendOperation(h)}}else{let c=e.premultipliedAlpha,l=(h,u,d,f)=>{t={srcFactor:h,dstFactor:u,operation:vl.Add},s={srcFactor:d,dstFactor:f,operation:vl.Add}};if(c)switch(n){case ta:l(it.One,it.OneMinusSrcAlpha,it.One,it.OneMinusSrcAlpha);break;case ko:l(it.One,it.One,it.One,it.One);break;case Io:l(it.Zero,it.OneMinusSrc,it.Zero,it.One);break;case Bo:l(it.Dst,it.OneMinusSrcAlpha,it.Zero,it.One);break}else switch(n){case ta:l(it.SrcAlpha,it.OneMinusSrcAlpha,it.One,it.OneMinusSrcAlpha);break;case ko:l(it.SrcAlpha,it.One,it.One,it.One);break;case Io:W(`WebGPURenderer: "SubtractiveBlending" requires "${e.isMaterial?"material":"blendMode"}.premultipliedAlpha = true".`);break;case Bo:W(`WebGPURenderer: "MultiplyBlending" requires "${e.isMaterial?"material":"blendMode"}.premultipliedAlpha = true".`);break}}if(t!==void 0&&s!==void 0)return{color:t,alpha:s};W("WebGPURenderer: Invalid blending: ",n)}_getBlendFactor(e){let t;switch(e){case Gi:t=it.Zero;break;case Yy:t=it.One;break;case Zy:t=it.Src;break;case Qy:t=it.OneMinusSrc;break;case yu:t=it.SrcAlpha;break;case xu:t=it.OneMinusSrcAlpha;break;case sx:t=it.Dst;break;case nx:t=it.OneMinusDst;break;case ex:t=it.DstAlpha;break;case tx:t=it.OneMinusDstAlpha;break;case ax:t=it.SrcAlphaSaturated;break;case ix:case ox:t=it.Constant;break;case rx:case cx:t=it.OneMinusConstant;break;default:W("WebGPURenderer: Blend factor not supported.",e)}return t}_getStencilCompare(e){let t,s=e.stencilFunc;switch(s){case eA:t=Ks.Never;break;case yx:t=Ks.Always;break;case tA:t=Ks.Less;break;case nA:t=Ks.LessEqual;break;case sA:t=Ks.Equal;break;case rA:t=Ks.GreaterEqual;break;case aA:t=Ks.Greater;break;case iA:t=Ks.NotEqual;break;default:W("WebGPURenderer: Invalid stencil function.",s)}return t}_getStencilOperation(e){let t;switch(e){case kh:t=jo.Keep;break;case X_:t=jo.Zero;break;case K_:t=jo.Replace;break;case Q_:t=jo.Invert;break;case J_:t=jo.IncrementClamp;break;case $_:t=jo.DecrementClamp;break;case Y_:t=jo.IncrementWrap;break;case Z_:t=jo.DecrementWrap;break;default:W("WebGPURenderer: Invalid stencil operation.",t)}return t}_getBlendOperation(e){let t;switch(e){case sa:t=vl.Add;break;case Xy:t=vl.Subtract;break;case Ky:t=vl.ReverseSubtract;break;case Jy:t=vl.Min;break;case $y:t=vl.Max;break;default:W("WebGPUPipelineUtils: Blend equation not supported.",e)}return t}_getPrimitiveState(e,t,s){let n={},a=this.backend.utils;n.topology=a.getPrimitiveTopology(e,s),t.index!==null&&e.isLine===!0&&e.isLineSegments!==!0&&(n.stripIndexFormat=t.index.array instanceof Uint16Array?gT.Uint16:gT.Uint32);let i=s.side===Xt;return e.isMesh&&e.matrixWorld.determinantAffine()<0&&(i=!i),n.frontFace=i===!0?sI.CW:sI.CCW,n.cullMode=s.side===rn?nI.None:nI.Back,n}_getColorWriteMask(e){return e.colorWrite===!0?aI.All:aI.None}_getDepthCompare(e){let t;if(e.depthTest===!1)t=Ks.Always;else{let s=this.backend.parameters.reversedDepthBuffer?cA[e.depthFunc]:e.depthFunc;switch(s){case Bh:t=Ks.Never;break;case Fh:t=Ks.Always;break;case Ph:t=Ks.Less;break;case Lc:t=Ks.LessEqual;break;case Dh:t=Ks.Equal;break;case Oh:t=Ks.GreaterEqual;break;case Uh:t=Ks.Greater;break;case Lh:t=Ks.NotEqual;break;default:W("WebGPUPipelineUtils: Invalid depth function.",s)}}return t}},MT=class{constructor(){this.label="",this.type=void 0,this.count=0}reset(){this.label="",this.type=void 0,this.count=0}},Qi=new dc,OH=new Jl,fm=new MT,JS=class extends bT{constructor(e,t,s=2048){super(s),this.device=e,this.type=t,fm.label=`queryset_global_timestamp_${t}`,fm.type="timestamp",fm.count=this.maxQueries,this.querySet=this.device.createQuerySet(fm),fm.reset();let n=this.maxQueries*8;Qi.label=`buffer_timestamp_resolve_${t}`,Qi.size=n,Qi.usage=GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC,this.resolveBuffer=this.device.createBuffer(Qi),Qi.reset(),Qi.label=`buffer_timestamp_result_${t}`,Qi.size=n,Qi.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,this.resultBuffer=this.device.createBuffer(Qi),Qi.reset()}allocateQueriesForContext(e){if(!this.trackTimestamp||this.isDisposed)return null;this.currentQueryIndex+2>this.maxQueries&&(this.resolveQueriesAsync(),this.currentQueryIndex=0,this.queryOffsets.clear());let t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryOffsets.set(e,t),t}async resolveQueriesAsync(){if(!this.trackTimestamp||this.currentQueryIndex===0||this.isDisposed)return this.lastValue;if(this.pendingResolve)return this.pendingResolve;this.pendingResolve=this._resolveQueries();try{return await this.pendingResolve}finally{this.pendingResolve=null}}async _resolveQueries(){if(this.isDisposed)return this.lastValue;try{if(this.resultBuffer.mapState!=="unmapped")return this.lastValue;let e=new Map(this.queryOffsets),t=this.currentQueryIndex,s=t*8;this.currentQueryIndex=0,this.queryOffsets.clear();let n=this.device.createCommandEncoder(OH);n.resolveQuerySet(this.querySet,0,t,this.resolveBuffer,0),n.copyBufferToBuffer(this.resolveBuffer,0,this.resultBuffer,0,s);let a=n.finish();if(sr(this.device,a),this.resultBuffer.mapState!=="unmapped")return this.lastValue;if(await this.resultBuffer.mapAsync(GPUMapMode.READ,0,s),this.isDisposed)return this.resultBuffer.mapState==="mapped"&&this.resultBuffer.unmap(),this.lastValue;let i=new BigUint64Array(this.resultBuffer.getMappedRange(0,s)),o={},c=[];this.timestamps.clear();for(let[h,u]of e){let d=h.match(/^(.*):f(\d+)$/),f=parseInt(d[2]);c.includes(f)===!1&&c.push(f),o[f]===void 0&&(o[f]=0);let p=i[u],m=i[u+1],b=Number(m-p)/1e6;this.timestamps.set(h,b),o[f]+=b}let l=o[c[c.length-1]];return this.resultBuffer.unmap(),this.lastValue=l,this.frames=c,l}catch(e){return W("Error resolving queries:",e),this.resultBuffer.mapState==="mapped"&&this.resultBuffer.unmap(),this.lastValue}}async dispose(){if(!this.isDisposed){if(this.isDisposed=!0,this.pendingResolve)try{await this.pendingResolve}catch(e){W("Error waiting for pending resolve:",e)}if(this.resultBuffer&&this.resultBuffer.mapState==="mapped")try{this.resultBuffer.unmap()}catch(e){W("Error unmapping buffer:",e)}this.querySet&&(this.querySet.destroy(),this.querySet=null),this.resolveBuffer&&(this.resolveBuffer.destroy(),this.resolveBuffer=null),this.resultBuffer&&(this.resultBuffer.destroy(),this.resultBuffer=null),this.queryOffsets.clear(),this.timestamps.clear(),this.frames=[],this.pendingResolve=null}}},$S=class{constructor(){this.label="",this.timestampWrites=void 0}reset(){this.label="",this.timestampWrites=void 0}},xd=class{constructor(){this.view=null,this.depthLoadOp=void 0,this.depthStoreOp=void 0,this.depthClearValue=void 0,this.depthReadOnly=!1,this.stencilLoadOp=void 0,this.stencilStoreOp=void 0,this.stencilClearValue=0,this.stencilReadOnly=!1}reset(){this.view=null,this.depthLoadOp=void 0,this.depthStoreOp=void 0,this.depthClearValue=void 0,this.depthReadOnly=!1,this.stencilLoadOp=void 0,this.stencilStoreOp=void 0,this.stencilClearValue=0,this.stencilReadOnly=!1}},YS=class{constructor(){this.querySet=null,this.beginningOfPassWriteIndex=void 0,this.endOfPassWriteIndex=void 0}reset(){this.querySet=null,this.beginningOfPassWriteIndex=void 0,this.endOfPassWriteIndex=void 0}},yi={r:0,g:0,b:0,a:1},pm={r:0,g:0,b:0,a:0},ca=new dc,Sn=new Jl,o0=new $S,mm=new MT,c0=new vT,l0=new YS,la=new Kd,er=new Kd,Xo=new Xd,Ft=new bb,Kr=new _T,ST=class extends pb{constructor(e={}){super(e),this.isWebGPUBackend=!0,this.parameters.alpha=e.alpha===void 0?!0:e.alpha,this.parameters.requiredLimits=e.requiredLimits===void 0?{}:e.requiredLimits,this.compatibilityMode=null,this.device=null,this.defaultRenderPassdescriptor=null,this.utils=new CS(this),this.attributeUtils=new jS(this),this.bindingUtils=new HS(this),this.capabilities=new WS(this),this.pipelineUtils=new KS(this),this.textureUtils=new US(this),this.occludedResolveCache=new Map;let t=typeof navigator>"u"?!0:/Android/.test(navigator.userAgent)===!1;this._compatibility={[Hr.TEXTURE_COMPARE]:t}}async init(e){await super.init(e);let t=this.parameters,s;if(t.device===void 0){let n={powerPreference:t.powerPreference,featureLevel:"compatibility",xrCompatible:e.xr.enabled},a=typeof navigator<"u"?await navigator.gpu.requestAdapter(n):null;if(a===null)throw new Error("THREE.WebGPUBackend: Unable to create WebGPU adapter.");let i=Object.values(yT),o=[];for(let l of i)a.features.has(l)&&o.push(l);let c={requiredFeatures:o,requiredLimits:t.requiredLimits};s=await a.requestDevice(c)}else s=t.device;this.compatibilityMode=!s.features.has("core-features-and-limits"),this.compatibilityMode&&(e._samples=0),s.lost.then(n=>{if(n.reason==="destroyed")return;let a={api:"WebGPU",message:n.message||"Unknown reason",reason:n.reason||null,originalEvent:n};e.onDeviceLost(a)}),s.onuncapturederror=n=>{let a=n.error,i=a&&a.constructor?a.constructor.name:"GPUError",o=a&&a.message||"Unknown uncaptured GPU error";e.onError({api:"WebGPU",type:i,message:o,originalEvent:n})},this.device=s,this.trackTimestamp=this.trackTimestamp&&this.hasFeature(yT.TimestampQuery),this.updateSize()}setXRRenderTargetTextures(e,t,s=null){let n=this.get(e.texture);n.texture=t,n.format=t.format,n.externalTexture=!0,n.xrViewDescriptors=s,n.initialized=!0}get context(){let e=this.renderer.getCanvasTarget(),t=this.get(e),s=t.context;if(s===void 0){let n=this.parameters;e.isDefaultCanvasTarget===!0&&n.context!==void 0?s=n.context:s=e.domElement.getContext("webgpu"),"setAttribute"in e.domElement&&e.domElement.setAttribute("data-engine",`three.js r${"186"} webgpu`);let a=n.alpha?"premultiplied":"opaque",i=n.outputType===ds?"extended":"standard";s.configure({device:this.device,format:this.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:a,toneMapping:{mode:i}}),t.context=s}return s}get coordinateSystem(){return Xs}get hasTimestamp(){return!0}async getArrayBufferAsync(e,t=null,s=0,n=-1){return await this.attributeUtils.getArrayBufferAsync(e,t,s,n)}getContext(){return this.context}_getDefaultRenderPassDescriptor(){let e=this.renderer,t=e.getCanvasTarget(),s=this.get(t),n=e.currentSamples,a=s.descriptor;if(a===void 0||s.samples!==n){if(a=new zl,a.colorAttachments.push(new Ll),e.depth===!0||e.stencil===!0){let c=new xd;c.view=this.textureUtils.getDepthBuffer(e.depth,e.stencil).createView(),a.depthStencilAttachment=c}let o=a.colorAttachments[0];n>0?o.view=this.textureUtils.getColorBuffer().createView():o.resolveTarget=void 0,s.descriptor=a,s.samples=n}let i=a.colorAttachments[0];return n>0?i.resolveTarget=this.context.getCurrentTexture().createView():i.view=this.context.getCurrentTexture().createView(),a}_isRenderCameraDepthArray(e){let t=e.camera;return e.depthTexture&&e.depthTexture.isArrayTexture===!0&&t!==null&&t.isArrayCamera===!0}_hasExternalTexture(e){let t=e.textures;if(t===null)return!1;for(let s=0;s<t.length;s++)if(this.get(t[s]).externalTexture===!0)return!0;return!1}_getExternalMSAATextures(e,t,s){let n=this.utils.getSampleCount(e.sampleCount);if(n===1){if(t.msaaTextures!==void 0){for(let l of t.msaaTextures)l.destroy();t.msaaTextures=void 0}return null}let a=e.renderTarget,i=a.width,o=a.height,c=t.format;if(t.msaaTextures===void 0||t.msaaTextures.length!==s||t.msaaWidth!==i||t.msaaHeight!==o||t.msaaSamples!==n||t.msaaFormat!==c){if(t.msaaTextures!==void 0)for(let l of t.msaaTextures)l.destroy();Xo.size.width=i,Xo.size.height=o,Xo.sampleCount=n,Xo.format=c,Xo.usage=GPUTextureUsage.RENDER_ATTACHMENT,t.msaaTextures=[];for(let l=0;l<s;l++)Xo.label=a.texture.name+"-msaa-"+l,t.msaaTextures.push(this.device.createTexture(Xo));Xo.reset(),t.msaaWidth=i,t.msaaHeight=o,t.msaaSamples=n,t.msaaFormat=c}return t.msaaTextures}_createExternalTextureViews(e,t){let s=[],n=e.camera,a=t.xrViewDescriptors,i=Math.max(a?.length||0,e.activeCubeFace+1,1),o=this._getExternalMSAATextures(e,t,i);if(a&&n!==null&&n.isArrayCamera===!0)for(let c=0;c<a.length;c++){let l=t.texture.createView(a[c]);s.push({view:o!==null?o[c].createView():l,resolveTarget:o!==null&&e.renderTarget.resolveColorBuffer===!0?l:void 0,depthSlice:void 0})}else{let c=e.activeCubeFace,l=t.texture.createView({dimension:Js.TwoD,baseArrayLayer:c,arrayLayerCount:1});s.push({view:o!==null?o[c].createView():l,resolveTarget:o!==null&&e.renderTarget.resolveColorBuffer===!0?l:void 0,depthSlice:void 0})}return s}_getRenderPassDescriptor(e,t={}){let s=e.renderTarget,n=this.get(s),a=this._hasExternalTexture(e),i=n.descriptors;(i===void 0||n.width!==s.width||n.height!==s.height||n.samples!==s.samples||a)&&(i={},n.descriptors=i);let o=e.getCacheKey(),c=i[o];if(c===void 0||a){let h=e.textures,u=[],d,f=this._isRenderCameraDepthArray(e);for(let m=0;m<h.length;m++){let b=this.get(h[m]);if(b.externalTexture===!0){u.push(...this._createExternalTextureViews(e,b));continue}if(Ft.label=`colorAttachment_${m}`,Ft.baseMipLevel=e.activeMipmapLevel,Ft.mipLevelCount=1,Ft.baseArrayLayer=e.activeCubeFace,Ft.arrayLayerCount=1,Ft.dimension=Js.TwoD,s.isRenderTarget3D)d=e.activeCubeFace,Ft.baseArrayLayer=0,Ft.dimension=Js.ThreeD;else if(s.isRenderTarget&&h[m].image.depth>1)if(f===!0){let g=e.camera.cameras;for(let x=0;x<g.length;x++){Ft.baseArrayLayer=x,Ft.arrayLayerCount=1,Ft.dimension=Js.TwoD;let T=b.texture.createView(Ft),y=b.msaaTextures?.[x];u.push({view:y!==void 0?y.createView():T,resolveTarget:y!==void 0&&s.resolveColorBuffer===!0?T:void 0,depthSlice:void 0})}}else Ft.dimension=Js.TwoDArray;if(f!==!0){let g=b.texture.createView(Ft),x,T;b.msaaTexture!==void 0?(x=b.msaaTexture.createView(),T=s.resolveColorBuffer===!0?g:void 0):b.msaaTextures!==void 0?(x=b.msaaTextures[e.activeCubeFace].createView(),T=s.resolveColorBuffer===!0?g:void 0):(x=g,T=void 0),u.push({view:x,resolveTarget:T,depthSlice:d})}Ft.reset()}let p=[];for(let m=0;m<u.length;m++){let b=u[m],g=new Ll;g.view=b.view,g.depthSlice=b.depthSlice,g.resolveTarget=b.resolveTarget,p.push(g)}if(c={textureViews:u,colorAttachments:p,descriptor:new zl},e.depth){let m=this.get(e.depthTexture);(e.depthTexture.isArrayTexture||e.depthTexture.isCubeTexture)&&(Ft.dimension=Js.TwoD,Ft.arrayLayerCount=1,Ft.baseArrayLayer=e.activeCubeFace);let b=new xd,g=m.msaaTextures?.[e.activeCubeFace];b.view=g!==void 0?g.createView():m.texture.createView(Ft),c.depthStencilAttachment=b,Ft.reset()}i[o]=c,n.width=s.width,n.height=s.height,n.samples=s.samples,n.activeMipmapLevel=e.activeMipmapLevel,n.activeCubeFace=e.activeCubeFace}let l=c.descriptor;l.reset();for(let h=0;h<c.colorAttachments.length;h++){let u=c.colorAttachments[h],d={r:0,g:0,b:0,a:1};h===0&&t.clearValue&&(d=t.clearValue),u.loadOp=t.loadOp||ct.Load,u.storeOp=t.storeOp||as.Store,u.clearValue=d,l.colorAttachments.push(u)}return c.depthStencilAttachment&&(l.depthStencilAttachment=c.depthStencilAttachment),l}beginRender(e){let t=this.get(e),s=this.device,n=e.occlusionQueryCount,a;n>0?(t.currentOcclusionQuerySet&&t.currentOcclusionQuerySet.destroy(),t.currentOcclusionQueryBuffer&&t.currentOcclusionQueryBuffer.destroy(),t.currentOcclusionQuerySet=t.occlusionQuerySet,t.currentOcclusionQueryBuffer=t.occlusionQueryBuffer,t.currentOcclusionQueryObjects=t.occlusionQueryObjects,mm.label=`occlusionQuerySet_${e.id}`,mm.type="occlusion",mm.count=n,a=s.createQuerySet(mm),mm.reset(),t.occlusionQuerySet=a,t.occlusionQueryIndex=0,t.occlusionQueryObjects=new Array(n),t.lastOcclusionObject=null):t.lastOcclusionObject!==void 0&&(t.lastOcclusionObject=void 0,t.occlusionQuerySet.destroy(),t.occlusionQuerySet=void 0);let i;e.textures===null?i=this._getDefaultRenderPassDescriptor():i=this._getRenderPassDescriptor(e,{loadOp:ct.Load}),this.initTimestampQuery(Ia.RENDER,this.getTimestampUID(e),i),i.occlusionQuerySet=a;let o=i.depthStencilAttachment,c=e.renderTarget,l=e.sampleCount>1&&c?.storeMultisampledColorBuffer===!1,h=e.sampleCount>1&&c?.storeMultisampledDepthBuffer===!1,u=e.sampleCount>1&&c?.storeMultisampledStencilBuffer===!1,d=e.fullscreenPass===!0&&this._hasExternalTexture(e);if(e.textures!==null){let p=i.colorAttachments;for(let m=0;m<p.length;m++){let b=p[m];if(e.clearColor||l||d){let g=e.mrt?e.mrt.getClearColor(e.textures[m].name):null;g!==null?b.clearValue=g:m===0?b.clearValue=e.clearColorValue:(yi.r=0,yi.g=0,yi.b=0,yi.a=1,b.clearValue=yi),b.loadOp=ct.Clear}else b.loadOp=ct.Load;l?b.storeOp=as.Discard:b.storeOp=as.Store}}else{let p=i.colorAttachments[0];e.clearColor?(p.clearValue=e.clearColorValue,p.loadOp=ct.Clear):p.loadOp=ct.Load,p.storeOp=as.Store}e.depth&&(e.clearDepth||h?(o.depthClearValue=e.clearDepthValue,o.depthLoadOp=ct.Clear):o.depthLoadOp=ct.Load,h?o.depthStoreOp=as.Discard:o.depthStoreOp=as.Store),e.stencil&&(e.clearStencil||u?(o.stencilClearValue=e.clearStencilValue,o.stencilLoadOp=ct.Clear):o.stencilLoadOp=ct.Load,u?o.stencilStoreOp=as.Discard:o.stencilStoreOp=as.Store),Sn.label="renderContext_"+e.id;let f=s.createCommandEncoder(Sn);if(Sn.reset(),this._isRenderCameraDepthArray(e)===!0){let p=e.camera.cameras;!t.layerDescriptors||t.layerDescriptors.length!==p.length?this._createArrayCameraLayerDescriptors(e,t,i,p):this._updateArrayCameraLayerDescriptors(e,t,i,p),this._createArrayCameraBundleEncoders(e,t),t.arrayCameraRenderStages=[],t.currentPass=null}else{t.bundleEncoders=void 0,t.bundleSets=void 0,t.arrayCameraRenderStages=void 0;let p=f.beginRenderPass(i);t.currentPass=p,e.viewport&&this.updateViewport(e),e.scissor&&this.updateScissor(e)}t.descriptor=i,t.encoder=f,t.renderBundles=[],this._resetRenderContextData(t)}_resetRenderContextData(e){e.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},e.currentBlendColor===void 0&&(e.currentBlendColor=new be),e.currentBlendColor.setRGB(0,0,0),e.currentBlendAlpha=0,e.currentStencilRef=0}_createArrayCameraBundleEncoders(e,t){let s=e.camera.cameras;t.bundleEncoders=[],t.bundleSets=[];for(let n=0;n<s.length;n++){let a=this.pipelineUtils.createBundleEncoder(e,"renderBundleArrayCamera_"+n),i={attributes:{},bindingGroups:[],pipeline:null,index:null};t.bundleEncoders.push(a),t.bundleSets.push(i)}}_finishArrayCameraBundleEncoders(e){let t=[];for(let s of e.bundleEncoders)t.push(s.finish());return t}_createArrayCameraLayerDescriptors(e,t,s,n){let a=s.depthStencilAttachment;t.layerDescriptors=[];let i=this.get(e.depthTexture);i.viewCache||(i.viewCache=[]);for(let o=0;o<n.length;o++){let c=s.colorAttachments[0],l=s.colorAttachments[o],h=new Ll;h.view=l.view,h.depthSlice=l.depthSlice,h.resolveTarget=l.resolveTarget,h.loadOp=c.loadOp,h.storeOp=c.storeOp,h.clearValue=c.clearValue;let u=new zl;if(u.label=s.label,u.occlusionQuerySet=s.occlusionQuerySet,u.timestampWrites=s.timestampWrites,u.colorAttachments.push(h),s.depthStencilAttachment){let d=o;if(!i.viewCache[d]){let p=i.msaaTextures?.[d];p!==void 0?i.viewCache[d]=p.createView():(Ft.dimension=Js.TwoD,Ft.baseArrayLayer=o,Ft.arrayLayerCount=1,i.viewCache[d]=i.texture.createView(Ft)),Ft.reset()}let f=new xd;f.view=i.viewCache[d],f.depthLoadOp=a.depthLoadOp||ct.Clear,f.depthStoreOp=a.depthStoreOp||as.Store,f.depthClearValue=a.depthClearValue||1,e.stencil&&(f.stencilLoadOp=a.stencilLoadOp,f.stencilStoreOp=a.stencilStoreOp,f.stencilClearValue=a.stencilClearValue),u.depthStencilAttachment=f}else{let d=new xd;d.view=a.view,d.depthLoadOp=a.depthLoadOp,d.depthStoreOp=a.depthStoreOp,d.depthClearValue=a.depthClearValue,d.depthReadOnly=a.depthReadOnly,d.stencilLoadOp=a.stencilLoadOp,d.stencilStoreOp=a.stencilStoreOp,d.stencilClearValue=a.stencilClearValue,d.stencilReadOnly=a.stencilReadOnly,u.depthStencilAttachment=d}t.layerDescriptors.push(u)}}_updateArrayCameraLayerDescriptors(e,t,s,n){let a=e.renderTarget,i=e.sampleCount>1&&a?.storeMultisampledDepthBuffer===!1,o=e.sampleCount>1&&a?.storeMultisampledStencilBuffer===!1;for(let c=0;c<n.length;c++){let l=t.layerDescriptors[c],h=s.colorAttachments[0],u=s.colorAttachments[c],d=l.colorAttachments[0];if(d.view=u.view,d.resolveTarget=u.resolveTarget,d.depthSlice=u.depthSlice,d.loadOp=h.loadOp,d.storeOp=h.storeOp,d.clearValue=h.clearValue,l.depthStencilAttachment){let f=l.depthStencilAttachment;e.depth&&(e.clearDepth||i?(f.depthClearValue=e.clearDepthValue,f.depthLoadOp=ct.Clear):f.depthLoadOp=ct.Load),e.stencil&&(e.clearStencil||o?(f.stencilClearValue=e.clearStencilValue,f.stencilLoadOp=ct.Clear):f.stencilLoadOp=ct.Load)}}}finishRender(e){let t=this.get(e),s=e.occlusionQueryCount;t.renderBundles.length>0&&t.currentPass.executeBundles(t.renderBundles);let n=t.lastOcclusionObject;n&&n.occlusionTest===!0&&t.currentPass.endOcclusionQuery();let a=t.encoder;if(this._isRenderCameraDepthArray(e)===!0){let i=this._finishArrayCameraBundleEncoders(t),o=t.arrayCameraRenderStages;o.push({bundles:i});for(let c=0;c<t.layerDescriptors.length;c++){let l=t.layerDescriptors[c],h=l.colorAttachments.map(b=>b.loadOp),u=l.colorAttachments.map(b=>b.storeOp),d=l.depthStencilAttachment?.depthLoadOp,f=l.depthStencilAttachment?.depthStoreOp,p=l.depthStencilAttachment?.stencilLoadOp,m=l.depthStencilAttachment?.stencilStoreOp;for(let b=0;b<o.length;b++){let g=o[b],x=g.bundles[c],T=b===o.length-1;for(let v=0;v<l.colorAttachments.length;v++){let _=l.colorAttachments[v];_.loadOp=b===0?h[v]:ct.Load,_.storeOp=T?u[v]:as.Store}e.depth&&(l.depthStencilAttachment.depthLoadOp=b===0?d:ct.Load,l.depthStencilAttachment.depthStoreOp=T?f:as.Store),e.stencil&&(l.depthStencilAttachment.stencilLoadOp=b===0?p:ct.Load,l.depthStencilAttachment.stencilStoreOp=T?m:as.Store);let y=a.beginRenderPass(l);if(e.viewport){let{x:v,y:_,width:A,height:M,minDepth:N,maxDepth:R}=e.viewportValue;y.setViewport(v,_,A,M,N,R)}if(e.scissor){let{x:v,y:_,width:A,height:M}=e.scissorValue;y.setScissorRect(v,_,A,M)}if(y.executeBundles([x]),y.end(),g.framebufferCopy!==void 0){let{texture:v,sourceGPU:_,destinationGPU:A,rectangle:M,generateMipmaps:N}=g.framebufferCopy;this._copyFramebufferToTexture(a,v,_,A,M,c,N)}}for(let b=0;b<l.colorAttachments.length;b++)l.colorAttachments[b].loadOp=h[b],l.colorAttachments[b].storeOp=u[b];e.depth&&(l.depthStencilAttachment.depthLoadOp=d,l.depthStencilAttachment.depthStoreOp=f),e.stencil&&(l.depthStencilAttachment.stencilLoadOp=p,l.depthStencilAttachment.stencilStoreOp=m)}}else t.currentPass&&t.currentPass.end();if(s>0){let i=s*8,o=this.occludedResolveCache.get(i);o===void 0&&(ca.size=i,ca.usage=GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC,o=this.device.createBuffer(ca),ca.reset(),this.occludedResolveCache.set(i,o)),ca.size=i,ca.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ;let c=this.device.createBuffer(ca);ca.reset(),t.encoder.resolveQuerySet(t.occlusionQuerySet,0,s,o,0),t.encoder.copyBufferToBuffer(o,0,c,0,i),t.occlusionQueryBuffer=c,this.resolveOccludedAsync(e)}if(sr(this.device,t.encoder.finish()),e.textures!==null){let i=e.textures;for(let o=0;o<i.length;o++){let c=i[o];c.generateMipmaps===!0&&this.textureUtils.generateMipmaps(c)}}}isOccluded(e,t){let s=this.get(e);return s.occluded&&s.occluded.has(t)}async resolveOccludedAsync(e){let t=this.get(e),{currentOcclusionQueryBuffer:s,currentOcclusionQueryObjects:n}=t;if(s&&n){let a=new WeakSet;t.currentOcclusionQueryObjects=null,t.currentOcclusionQueryBuffer=null,await s.mapAsync(GPUMapMode.READ);let i=s.getMappedRange(),o=new BigUint64Array(i);for(let c=0;c<n.length;c++){let l=n[c];l!==void 0&&o[c]===BigInt(0)&&a.add(l)}s.destroy(),t.occluded=a}}updateViewport(e){let{currentPass:t}=this.get(e),{x:s,y:n,width:a,height:i,minDepth:o,maxDepth:c}=e.viewportValue;t.setViewport(s,n,a,i,o,c)}updateScissor(e){let{currentPass:t}=this.get(e),{x:s,y:n,width:a,height:i}=e.scissorValue;t.setScissorRect(s,n,a,i)}getClearColor(){let e=super.getClearColor();return this.renderer.alpha===!0&&(e.r*=e.a,e.g*=e.a,e.b*=e.a),e}clear(e,t,s,n=null){let a=this.device,i=this.renderer,o=[],c,l,h;if(e){let f=this.getClearColor();yi.r=f.r,yi.g=f.g,yi.b=f.b,yi.a=f.a}if(n===null){l=i.depth,h=i.stencil;let f=this._getDefaultRenderPassDescriptor();if(e){o=f.colorAttachments;let p=o[0];p.clearValue=yi,p.loadOp=ct.Clear,p.storeOp=as.Store}(l||h)&&(c=f.depthStencilAttachment)}else{l=n.depth,h=n.stencil;let f={loadOp:e?ct.Clear:ct.Load,clearValue:e?yi:void 0};l&&(f.depthLoadOp=t?ct.Clear:ct.Load,f.depthClearValue=t?i.getClearDepth():void 0,f.depthStoreOp=as.Store),h&&(f.stencilLoadOp=s?ct.Clear:ct.Load,f.stencilClearValue=s?i.getClearStencil():void 0,f.stencilStoreOp=as.Store);let p=this._getRenderPassDescriptor(n,f);o=p.colorAttachments,c=p.depthStencilAttachment}l&&c&&(t?(c.depthLoadOp=ct.Clear,c.depthClearValue=i.getClearDepth(),c.depthStoreOp=as.Store):(c.depthLoadOp=ct.Load,c.depthStoreOp=as.Store)),h&&c&&(s?(c.stencilLoadOp=ct.Clear,c.stencilClearValue=i.getClearStencil(),c.stencilStoreOp=as.Store):(c.stencilLoadOp=ct.Load,c.stencilStoreOp=as.Store)),Sn.label="clear";let u=a.createCommandEncoder(Sn);Sn.reset(),u.beginRenderPass({colorAttachments:o,depthStencilAttachment:c}).end(),sr(a,u.finish())}beginCompute(e){let t=this.get(e),s="computeGroup_"+e.id;o0.label=s,Sn.label=s,this.initTimestampQuery(Ia.COMPUTE,this.getTimestampUID(e),o0),t.cmdEncoderGPU=this.device.createCommandEncoder(Sn),t.passEncoderGPU=t.cmdEncoderGPU.beginComputePass(o0),t.currentPipeline=null,Sn.reset(),o0.reset()}compute(e,t,s,n,a=null){let i=this.get(t),o=this.get(e),{passEncoderGPU:c}=o,l=this.get(n).pipeline;o.currentPipeline!==l&&(c.setPipeline(l),o.currentPipeline=l);for(let h=0,u=s.length;h<u;h++){let d=s[h],f=this.get(d);c.setBindGroup(h,f.group)}if(a===null&&(a=t.dispatchSize||t.count),a&&a.isIndirectStorageBufferAttribute){let h=this.get(a).buffer;c.dispatchWorkgroupsIndirect(h,0);return}if(typeof a=="number"){let h=a;if(i.dispatchSize===void 0||i.count!==h){i.dispatchSize=[0,1,1],i.count=h;let u=t.workgroupSize,d=u[0];for(let m=1;m<u.length;m++)d*=u[m];let f=Math.ceil(h/d),p=this.device.limits.maxComputeWorkgroupsPerDimension;a=[f,1,1],f>p&&(a[0]=Math.min(f,p),a[1]=Math.ceil(f/p)),i.dispatchSize=a}a=i.dispatchSize}c.dispatchWorkgroups(a[0],a[1]||1,a[2]||1)}finishCompute(e){let t=this.get(e);t.passEncoderGPU.end(),sr(this.device,t.cmdEncoderGPU.finish())}_draw(e,t,s,n,a,i,o,c,l,h=-1){let{object:u,material:d,context:f}=e,p=e.getIndex(),m=p!==null;l.pipeline!==n&&(c.setPipeline(n),l.pipeline=n);let b=l.bindingGroups;for(let g=0,x=a.length;g<x;g++){if(g===h)continue;let T=a[g],y=this.get(T).group;b[g]!==y&&(c.setBindGroup(g,y),b[g]=y)}if(m===!0&&l.index!==p){let g=this.get(p).buffer,x=p.array instanceof Uint16Array?gT.Uint16:gT.Uint32;c.setIndexBuffer(g,x),l.index=p}for(let g=0,x=i.length;g<x;g++){let T=i[g];if(l.attributes[g]!==T){let y=this.get(T).buffer;c.setVertexBuffer(g,y),l.attributes[g]=T}}if(f.stencil===!0&&d.stencilWrite===!0&&s.currentStencilRef!==d.stencilRef&&(c.setStencilReference(d.stencilRef),s.currentStencilRef=d.stencilRef),d.blending===Or&&c.setBlendConstant!==void 0){let g=d.blendColor,x=d.blendAlpha;(g.equals(s.currentBlendColor)===!1||x!==s.currentBlendAlpha)&&(pm.r=g.r,pm.g=g.g,pm.b=g.b,pm.a=x,c.setBlendConstant(pm),s.currentBlendColor.copy(g),s.currentBlendAlpha=x)}if(u.isBatchedMesh===!0){let g=u._multiDrawStarts,x=u._multiDrawCounts,T=u._multiDrawCount,y=u._multiDrawBytesPerElement;for(let v=0;v<T;v++)m===!0?c.drawIndexed(x[v],1,g[v]/y,0,v):c.draw(x[v],1,g[v],v),t.update(u,x[v],1)}else if(m===!0){let{vertexCount:g,instanceCount:x,firstVertex:T}=o,y=e.getIndirect();if(y!==null){let v=this.get(y).buffer,_=e.getIndirectOffset(),A=Array.isArray(_)?_:[_];for(let M=0;M<A.length;M++)c.drawIndexedIndirect(v,A[M])}else c.drawIndexed(g,x,T,0,0);t.update(u,g,x)}else{let{vertexCount:g,instanceCount:x,firstVertex:T}=o,y=e.getIndirect();if(y!==null){let v=this.get(y).buffer,_=e.getIndirectOffset(),A=Array.isArray(_)?_:[_];for(let M=0;M<A.length;M++)c.drawIndirect(v,A[M])}else c.draw(g,x,T,0);t.update(u,g,x)}}draw(e,t){let{object:s,context:n,pipeline:a}=e,i=this.get(n),o=this.get(a),c=o.pipeline;if(o.error===!0)return;let l=e.getDrawParameters();if(l===null)return;let h=e.getBindings(),u=e.getVertexBuffers();if(e.camera.isArrayCamera&&e.camera.cameras.length>0){let d=this.get(e.camera),f=e.camera.cameras,p=e.getBindingGroup("cameraIndex");if(d.indexesGPU===void 0||d.indexesGPU.length!==f.length){let x=this.get(p),T=[],y=new Uint32Array([0,0,0,0]);for(let v=0,_=f.length;v<_;v++){y[0]=v;let{layoutGPU:A}=x.layout,M=this.bindingUtils.createBindGroupIndex(y,A);T.push(M)}d.indexesGPU=T}let m=n.renderTarget,b=m===null||m.isPostProcessingRenderTarget===!0?this.renderer.getPixelRatio():1,g=p?h.indexOf(p):-1;for(let x=0,T=f.length;x<T;x++){let y=f[x];if(s.layers.test(y.layers)){let v=y.viewport,_=i.currentPass,A=i.currentSets,M=i.bundleEncoders!==void 0;if(M){let N=i.bundleEncoders[x],R=i.bundleSets[x];_=N,A=R}if(v&&!M&&_.setViewport(Math.floor(v.x*b),Math.floor(v.y*b),Math.floor(v.width*b),Math.floor(v.height*b),n.viewportValue.minDepth,n.viewportValue.maxDepth),g!==-1&&d.indexesGPU){let N=d.indexesGPU[x];A.bindingGroups[g]!==N&&(_.setBindGroup(g,N),A.bindingGroups[g]=N)}this._draw(e,t,i,c,h,u,l,_,A,g)}}}else if(i.currentPass){if(i.currentPass instanceof GPURenderBundleEncoder)s.occlusionTest===!0&&je("WebGPUBackend: Occlusion queries can not be recorded into render bundles.");else if(i.occlusionQuerySet!==void 0){let d=i.lastOcclusionObject;d!==s&&(d!==null&&d.occlusionTest===!0&&(i.currentPass.endOcclusionQuery(),i.occlusionQueryIndex++),s.occlusionTest===!0&&(i.currentPass.beginOcclusionQuery(i.occlusionQueryIndex),i.occlusionQueryObjects[i.occlusionQueryIndex]=s),i.lastOcclusionObject=s)}this._draw(e,t,i,c,h,u,l,i.currentPass,i.currentSets)}}needsRenderUpdate(e){let t=this.get(e),{object:s,material:n}=e,a=this.utils,i=a.getSampleCountRenderContext(e.context),o=a.getCurrentColorSpace(e.context),c=a.getCurrentColorFormat(e.context),l=a.getCurrentDepthStencilFormat(e.context),h=a.getPrimitiveTopology(s,n),u=s.isMesh&&s.matrixWorld.determinantAffine()<0,d=!1;return(t.material!==n||t.materialVersion!==n.version||t.transparent!==n.transparent||t.blending!==n.blending||t.premultipliedAlpha!==n.premultipliedAlpha||t.blendSrc!==n.blendSrc||t.blendDst!==n.blendDst||t.blendEquation!==n.blendEquation||t.blendSrcAlpha!==n.blendSrcAlpha||t.blendDstAlpha!==n.blendDstAlpha||t.blendEquationAlpha!==n.blendEquationAlpha||t.colorWrite!==n.colorWrite||t.depthWrite!==n.depthWrite||t.depthTest!==n.depthTest||t.depthFunc!==n.depthFunc||t.stencilWrite!==n.stencilWrite||t.stencilFunc!==n.stencilFunc||t.stencilFail!==n.stencilFail||t.stencilZFail!==n.stencilZFail||t.stencilZPass!==n.stencilZPass||t.stencilFuncMask!==n.stencilFuncMask||t.stencilWriteMask!==n.stencilWriteMask||t.polygonOffset!==n.polygonOffset||t.polygonOffsetFactor!==n.polygonOffsetFactor||t.polygonOffsetUnits!==n.polygonOffsetUnits||t.side!==n.side||t.alphaToCoverage!==n.alphaToCoverage||t.sampleCount!==i||t.colorSpace!==o||t.colorFormat!==c||t.depthStencilFormat!==l||t.primitiveTopology!==h||t.frontFaceCW!==u||t.clippingContextCacheKey!==e.clippingContextCacheKey)&&(t.material=n,t.materialVersion=n.version,t.transparent=n.transparent,t.blending=n.blending,t.premultipliedAlpha=n.premultipliedAlpha,t.blendSrc=n.blendSrc,t.blendDst=n.blendDst,t.blendEquation=n.blendEquation,t.blendSrcAlpha=n.blendSrcAlpha,t.blendDstAlpha=n.blendDstAlpha,t.blendEquationAlpha=n.blendEquationAlpha,t.colorWrite=n.colorWrite,t.depthWrite=n.depthWrite,t.depthTest=n.depthTest,t.depthFunc=n.depthFunc,t.stencilWrite=n.stencilWrite,t.stencilFunc=n.stencilFunc,t.stencilFail=n.stencilFail,t.stencilZFail=n.stencilZFail,t.stencilZPass=n.stencilZPass,t.stencilFuncMask=n.stencilFuncMask,t.stencilWriteMask=n.stencilWriteMask,t.polygonOffset=n.polygonOffset,t.polygonOffsetFactor=n.polygonOffsetFactor,t.polygonOffsetUnits=n.polygonOffsetUnits,t.side=n.side,t.alphaToCoverage=n.alphaToCoverage,t.sampleCount=i,t.colorSpace=o,t.colorFormat=c,t.depthStencilFormat=l,t.primitiveTopology=h,t.frontFaceCW=u,t.clippingContextCacheKey=e.clippingContextCacheKey,d=!0),d}getRenderCacheKey(e){let{object:t,material:s}=e,n=this.utils,a=e.context,i=t.isMesh&&t.matrixWorld.determinantAffine()<0;return[s.transparent,s.blending,s.premultipliedAlpha,s.blendSrc,s.blendDst,s.blendEquation,s.blendSrcAlpha,s.blendDstAlpha,s.blendEquationAlpha,s.colorWrite,s.depthWrite,s.depthTest,s.depthFunc,s.stencilWrite,s.stencilFunc,s.stencilFail,s.stencilZFail,s.stencilZPass,s.stencilFuncMask,s.stencilWriteMask,s.polygonOffset,s.polygonOffsetFactor,s.polygonOffsetUnits,s.side,s.alphaToCoverage,i,n.getSampleCountRenderContext(a),n.getCurrentColorSpace(a),n.getCurrentColorFormat(a),n.getCurrentDepthStencilFormat(a),n.getPrimitiveTopology(t,s),e.getGeometryCacheKey(),e.clippingContextCacheKey].join()}updateSampler(e){return this.textureUtils.updateSampler(e)}destroySampler(e){this.textureUtils.destroySampler(e)}createDefaultTexture(e){return this.textureUtils.createDefaultTexture(e)}createTexture(e,t){this.textureUtils.createTexture(e,t)}updateTexture(e,t){this.textureUtils.updateTexture(e,t)}generateMipmaps(e){this.textureUtils.generateMipmaps(e)}destroyTexture(e,t=!1){this.textureUtils.destroyTexture(e,t)}async copyTextureToBuffer(e,t,s,n,a,i){return this.textureUtils.copyTextureToBuffer(e,t,s,n,a,i)}initTimestampQuery(e,t,s){if(!this.trackTimestamp)return;this.timestampQueryPool[e]||(this.timestampQueryPool[e]=new JS(this.device,e,2048));let n=this.timestampQueryPool[e],a=n.allocateQueriesForContext(t);l0.querySet=n.querySet,l0.beginningOfPassWriteIndex=a,l0.endOfPassWriteIndex=a+1,s.timestampWrites=l0}createNodeBuilder(e,t){return new AT(e,t)}createProgram(e){let t=this.get(e);c0.label=e.stage+(e.name!==""?`_${e.name}`:""),c0.code=e.code,t.module={module:this.device.createShaderModule(c0),entryPoint:"main"},c0.reset()}destroyProgram(e){this.delete(e)}createRenderPipeline(e,t){this.pipelineUtils.createRenderPipeline(e,t)}createComputePipeline(e,t,s=null){this.pipelineUtils.createComputePipeline(e,t,s)}beginBundle(e){let t=this.get(e);t._currentPass=t.currentPass,t._currentSets=t.currentSets,t.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.currentPass=this.pipelineUtils.createBundleEncoder(e)}finishBundle(e,t){let s=this.get(e),a=s.currentPass.finish();this.get(t).bundleGPU=a,s.currentSets=s._currentSets,s.currentPass=s._currentPass,s._currentPass=null,s._currentSets=null}addBundle(e,t){this.get(e).renderBundles.push(this.get(t).bundleGPU)}createUniformBuffer(e){let t=this.get(e);if(t.buffer===void 0){let s=e.byteLength,n=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,a=[];e.visibility&Ai.VERTEX&&a.push("vertex"),e.visibility&Ai.FRAGMENT&&a.push("fragment"),e.visibility&Ai.COMPUTE&&a.push("compute");let i=`(${a.join(",")})`;ca.label=`bindingBuffer${e.id}_${e.name}_${i}`,ca.size=s,ca.usage=n;let o=this.device.createBuffer(ca);ca.reset(),t.buffer=o}}destroyUniformBuffer(e){this.get(e).buffer.destroy(),this.delete(e)}createBindings(e,t,s,n){this.bindingUtils.createBindings(e,t,s,n)}updateBindings(e,t,s,n){this.bindingUtils.createBindings(e,t,s,n)}updateBinding(e){this.bindingUtils.updateBinding(e)}deleteBindGroupData(e){this.bindingUtils.deleteBindGroupData(e)}createIndexAttribute(e){let t=GPUBufferUsage.INDEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST;(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(t|=GPUBufferUsage.STORAGE),this.attributeUtils.createAttribute(e,t)}createAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createStorageAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createIndirectStorageAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.INDIRECT|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}updateAttribute(e){this.attributeUtils.updateAttribute(e)}destroyAttribute(e){this.attributeUtils.destroyAttribute(e)}updateSize(){this.delete(this.renderer.getCanvasTarget())}hasFeature(e){return rI[e]!==void 0&&(e=rI[e]),this.device.features.has(e)}copyTextureToTexture(e,t,s=null,n=null,a=0,i=0){let o=0,c=0,l=0,h=0,u=0,d=0,f=e.image.width,p=e.image.height,m=1;s!==null&&(s.isBox3===!0?(h=s.min.x,u=s.min.y,d=s.min.z,f=s.max.x-s.min.x,p=s.max.y-s.min.y,m=s.max.z-s.min.z):(h=s.min.x,u=s.min.y,f=s.max.x-s.min.x,p=s.max.y-s.min.y,m=1)),n!==null&&(o=n.x,c=n.y,l=n.z||0),Sn.label="copyTextureToTexture_"+e.id+"_"+t.id;let b=this.device.createCommandEncoder(Sn);Sn.reset();let g=this.get(e).texture,x=this.get(t).texture;la.texture=g,la.mipLevel=a,la.origin.x=h,la.origin.y=u,la.origin.z=d,er.texture=x,er.mipLevel=i,er.origin.x=o,er.origin.y=c,er.origin.z=l,Kr.width=f,Kr.height=p,Kr.depthOrArrayLayers=m,b.copyTextureToTexture(la,er,Kr),la.reset(),er.reset(),Kr.reset(),sr(this.device,b.finish()),i===0&&t.generateMipmaps&&this.textureUtils.generateMipmaps(t)}copyFramebufferToTexture(e,t,s){let n=this.get(t),a=null;t.renderTarget?e.isDepthTexture?a=this.get(t.depthTexture).texture:a=this.get(t.textures[0]).texture:e.isDepthTexture?a=this.textureUtils.getDepthBuffer(t.depth,t.stencil):a=this.context.getCurrentTexture();let i=this.get(e).texture;if(a.format!==i.format){W("WebGPUBackend: copyFramebufferToTexture: Source and destination formats do not match.",a.format,i.format);return}if(this._isRenderCameraDepthArray(t)===!0){let c=this._finishArrayCameraBundleEncoders(n);n.arrayCameraRenderStages.push({bundles:c,framebufferCopy:{texture:e,sourceGPU:a,destinationGPU:i,rectangle:{x:s.x,y:s.y,z:s.z,w:s.w},generateMipmaps:e.generateMipmaps}}),this._createArrayCameraBundleEncoders(t,n);return}let o;if(n.currentPass?(n.currentPass.end(),o=n.encoder):(Sn.label="copyFramebufferToTexture_"+e.id,o=this.device.createCommandEncoder(Sn),Sn.reset()),this._copyFramebufferToTexture(o,e,a,i,s),n.currentPass){let{descriptor:c}=n;for(let l=0;l<c.colorAttachments.length;l++)c.colorAttachments[l].loadOp=ct.Load;t.depth&&(c.depthStencilAttachment.depthLoadOp=ct.Load),t.stencil&&(c.depthStencilAttachment.stencilLoadOp=ct.Load),n.currentPass=o.beginRenderPass(c),this._resetRenderContextData(n),t.viewport&&this.updateViewport(t),t.scissor&&this.updateScissor(t)}else sr(this.device,o.finish())}_copyFramebufferToTexture(e,t,s,n,a,i=0,o=t.generateMipmaps){la.texture=s,la.origin.x=a.x,la.origin.y=a.y,la.origin.z=i,er.texture=n,Kr.width=a.z,Kr.height=a.w,e.copyTextureToTexture(la,er,Kr),la.reset(),er.reset(),Kr.reset(),o&&this.textureUtils.generateMipmaps(t,e)}hasCompatibility(e){return this._compatibility[e]!==void 0?this._compatibility[e]:super.hasCompatibility(e)}async dispose(){if(await super.dispose(),this.bindingUtils.dispose(),this.textureUtils.dispose(),this.occludedResolveCache){for(let e of this.occludedResolveCache.values())e.destroy();this.occludedResolveCache.clear()}this.parameters.device===void 0&&this.device!==null&&this.device.destroy()}},gb=class extends ui{constructor(e,t,s,n,a,i){super(e,t,s,n,a,i),this.iesMap=null}copy(e,t){return super.copy(e,t),this.iesMap=e.iesMap,this}},yb=class extends ui{constructor(e,t,s,n,a,i){super(e,t,s,n,a,i),this.aspect=null}copy(e,t){return super.copy(e,t),this.aspect=e.aspect,this}},NT=class extends db{constructor(){super(),this.addMaterial(Od,"MeshPhongMaterial"),this.addMaterial(Wl,"MeshStandardMaterial"),this.addMaterial(ql,"MeshPhysicalMaterial"),this.addMaterial(zd,"MeshToonMaterial"),this.addMaterial(cc,"MeshBasicMaterial"),this.addMaterial(Dd,"MeshLambertMaterial"),this.addMaterial(Fd,"MeshNormalMaterial"),this.addMaterial(Vd,"MeshMatcapMaterial"),this.addMaterial(lw,"LineBasicMaterial"),this.addMaterial(hw,"LineDashedMaterial"),this.addMaterial(xw,"PointsMaterial"),this.addMaterial(Hm,"SpriteMaterial"),this.addMaterial(ww,"ShadowMaterial"),this.addLight(Zm,di),this.addLight(ib,Fr),this.addLight(hb,nl),this.addLight(Kl,ui),this.addLight(ab,sl),this.addLight(rb,Qc),this.addLight(cb,al),this.addLight(ob,gb),this.addLight(lb,yb),this.addToneMapping(ON,lx),this.addToneMapping(UN,hx),this.addToneMapping(LN,ux),this.addToneMapping(zN,dx),this.addToneMapping(VN,fx),this.addToneMapping(jN,px)}},ZS=class extends rT{constructor(e={}){let t;e.forceWebGL?t=mb:(t=ST,e.getFallback=()=>(K("WebGPURenderer: WebGPU is not available, running under WebGL2 backend."),new mb(e)));let s=new t(e);super(s,e),this.library=new NT,this.isWebGPURenderer=!0,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}},QS=class extends qs{constructor(){super(),this.isBundleGroup=!0,this.type="BundleGroup",this.static=!0,this.version=0}set needsUpdate(e){e===!0&&this.version++}},xb=class{constructor(e,t=ce(0,0,1,1)){this.isRenderPipeline=!0,this.renderer=e,this.outputNode=t,this.outputColorTransform=!0,this.needsUpdate=!0;let s=new wt;s.name="RenderPipeline",this._quadMesh=new Xl(s),this._quadMesh.name="Render Pipeline",this._contextData=null,this._toneMapping=e.toneMapping,this._outputColorSpace=e.outputColorSpace}render(){let e=this.renderer;this._update();for(let a of this._contextData.onBeforePipelineCallbacks)a();let t=e.toneMapping,s=e.outputColorSpace;e.toneMapping=Hi,e.outputColorSpace=qe.workingColorSpace;let n=e.xr.enabled;e.xr.enabled=!1,this._quadMesh.render(e),e.xr.enabled=n,e.toneMapping=t,e.outputColorSpace=s;for(let a of this._contextData.onAfterPipelineCallbacks)a()}dispose(){this._quadMesh.material.dispose()}_updateContext(){let e=this._toneMapping,t=this._outputColorSpace,s={renderPipeline:this,renderPipelineState:{viewOffsetOwner:null},onBeforePipelineCallbacks:[],onAfterPipelineCallbacks:[]},n=this.outputNode;this.outputColorTransform===!0?n=Tb(n,e,t):(s.toneMapping=e,s.outputColorSpace=t),this._contextData=s,this._quadMesh.material.contextNode=Wn(s),this._quadMesh.material.fragmentNode=n,this._quadMesh.material.needsUpdate=!0}_update(){this._toneMapping!==this.renderer.toneMapping&&(this._toneMapping=this.renderer.toneMapping,this.needsUpdate=!0),this._outputColorSpace!==this.renderer.outputColorSpace&&(this._outputColorSpace=this.renderer.outputColorSpace,this.needsUpdate=!0),this.needsUpdate===!0&&(this._updateContext(),this.needsUpdate=!1)}async renderAsync(){je('RenderPipeline: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.'),await this.renderer.init(),this.render()}},e1=class extends xb{constructor(e,t=ec){super(e,t),this.isDirectRenderPipeline=!0,this._contextNode=null,this._rendererContextNode=null,this._backgroundNodes=new WeakMap}render(e,t){let s=this.renderer;this._update();let n=this._getBackgroundNode(e),a=n!==null?e.backgroundNode:null,i=s.contextNode,o=s.getOutputRenderTarget(),c=o!==null&&s.xr.isPresenting===!0&&s.backend.isWebGPUBackend===!0&&s.isOutputTarget===!0,l,h,u,d;n!==null&&(e.backgroundNode=n),s.contextNode=this._contextNode,c&&(l=o.samples,h=o.depthBuffer,o.samples=s.samples,o.depthBuffer=!0);try{for(let f of this._contextData.onBeforePipelineCallbacks)f();u=s.toneMapping,d=s.outputColorSpace,s.toneMapping=Hi,s.outputColorSpace=qe.workingColorSpace,s.xr.enabled&&s.xr.renderLayers(),s.render(e,t)}finally{u!==void 0&&(s.toneMapping=u),d!==void 0&&(s.outputColorSpace=d),n!==null&&e.backgroundNode===n&&(e.backgroundNode=a),s.contextNode===this._contextNode&&(s.contextNode=i),c&&(o.samples=l,o.depthBuffer=h);for(let f of this._contextData.onAfterPipelineCallbacks)f()}}_getBackgroundNode(e){if(e.isScene!==!0||e.backgroundNode!=null||e.background?.isColor!==!0)return null;let t=this.renderer.xr.getEnvironmentBlendMode();if(t==="additive"||t==="alpha-blend")return null;let s=this._backgroundNodes.get(e.background);return s===void 0&&(s=xe(e.background),this._backgroundNodes.set(e.background,s)),s}_update(){this._rendererContextNode!==this.renderer.contextNode&&(this._rendererContextNode=this.renderer.contextNode,this.needsUpdate=!0),super._update()}_updateContext(){super._updateContext();let e=this.outputNode,t=this._toneMapping,s=this._outputColorSpace,n=this.outputColorTransform;this._contextNode=this._rendererContextNode.context({...this._contextData,getOutput:(a,i)=>{let o=i.renderer,c=o.getRenderTarget();return o.isOutputTarget===!1&&c?._hasExternalTextures!==!0?a:(ec.assign(a),n===!0?Tb(e,t,s):e)}})}},t1=class extends xb{constructor(e,t){je('PostProcessing: "PostProcessing" has been renamed to "RenderPipeline". Please update your code to use "THREE.RenderPipeline" instead.'),super(e,t)}},s1=class extends Bs{constructor(e){super(),this.name="",this.buffer=null,this.maxByteLength=e,this.isReadbackBuffer=!0,this._mapped=!1}release(){this.dispatchEvent({type:"release"})}dispose(){this.dispatchEvent({type:"dispose"})}},n1=class extends gt{constructor(e=1,t=1){super(),this.image={width:e,height:t},this.magFilter=Ye,this.minFilter=Ye,this.isStorageTexture=!0,this.mipmapsAutoUpdate=!0}setSize(e,t){(this.image.width!==e||this.image.height!==t)&&(this.image.width=e,this.image.height=t,this.dispose())}},a1=class extends gt{constructor(e=1,t=1,s=1){super(),this.isArrayTexture=!1,this.image={width:e,height:t,depth:s},this.magFilter=Ye,this.minFilter=Ye,this.wrapR=hs,this.isStorageTexture=!0,this.is3DTexture=!0}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}setSize(e,t,s){(this.image.width!==e||this.image.height!==t||this.image.depth!==s)&&(this.image.width=e,this.image.height=t,this.image.depth=s,this.dispose())}},i1=class extends gt{constructor(e=1,t=1,s=1){super(),this.isArrayTexture=!0,this.image={width:e,height:t,depth:s},this.magFilter=Ye,this.minFilter=Ye,this.isStorageTexture=!0}setSize(e,t,s){(this.image.width!==e||this.image.height!==t||this.image.depth!==s)&&(this.image.width=e,this.image.height=t,this.image.depth=s,this.dispose())}},Jd=class extends mn{constructor(e,t){super(e,t,Uint32Array),this.isIndirectStorageBufferAttribute=!0}},RT=class extends us{constructor(e){super(e),this.textures={},this.nodes={}}load(e,t,s,n){let a=new an(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,i=>{try{t(this.parse(JSON.parse(i)))}catch(o){n?n(o):W(o),this.manager.itemError(e)}},s,n)}parseNodes(e){let t={};if(e!==void 0){for(let n of e){let{uuid:a,type:i}=n;t[a]=this.createNodeFromType(i),t[a].uuid=a}let s={nodes:t,textures:this.textures};for(let n of e)n.meta=s,t[n.uuid].deserialize(n),delete n.meta}return t}parse(e){let t=this.createNodeFromType(e.type);t.uuid=e.uuid;let n={nodes:this.parseNodes(e.nodes),textures:this.textures};return e.meta=n,t.deserialize(e),delete e.meta,t}setTextures(e){return this.textures=e,this}setNodes(e){return this.nodes=e,this}createNodeFromType(e){return this.nodes[e]===void 0?(W("NodeLoader: Node type not found:",e),S()):new this.nodes[e]}},ET=class extends du{constructor(e){super(e),this.nodes={},this.nodeMaterials={}}parse(e){let t=super.parse(e),s=this.nodes,n=e.inputNodes;for(let a in n){let i=n[a];t[a]=s[i]}return t}setNodes(e){return this.nodes=e,this}setNodeMaterials(e){return this.nodeMaterials=e,this}createMaterialFromType(e){let t=this.nodeMaterials[e];return t!==void 0?new t:super.createMaterialFromType(e)}},r1=class extends Ep{constructor(e){super(e),this.nodes={},this.nodeMaterials={},this._nodesJSON=null}setNodes(e){return this.nodes=e,this}setNodeMaterials(e){return this.nodeMaterials=e,this}parse(e,t){this._nodesJSON=e.nodes;let s=super.parse(e,t);return this._nodesJSON=null,s}async parseAsync(e){this._nodesJSON=e.nodes;let t=await super.parseAsync(e);return this._nodesJSON=null,t}parseNodes(e,t){if(e!==void 0){let s=new RT;return s.setNodes(this.nodes),s.setTextures(t),s.parseNodes(e)}return{}}parseMaterials(e,t){let s={};if(e!==void 0){let n=this.parseNodes(this._nodesJSON,t),a=new ET;a.setTextures(t),a.setNodes(n),a.setNodeMaterials(this.nodeMaterials);for(let i=0,o=e.length;i<o;i++){let c=e[i];s[c.uuid]=a.parse(c)}}return s}},o1=class extends db{constructor(){super(),this.addLight(Zm,di),this.addLight(ib,Fr),this.addLight(hb,nl),this.addLight(Kl,ui),this.addLight(ab,sl),this.addLight(rb,Qc),this.addLight(cb,al),this.addLight(ob,gb),this.addLight(lb,yb),this.addToneMapping(ON,lx),this.addToneMapping(UN,hx),this.addToneMapping(LN,ux),this.addToneMapping(zN,dx),this.addToneMapping(VN,fx),this.addToneMapping(jN,px)}},c1=class extends qs{constructor(){super(),this.isClippingGroup=!0,this.clippingPlanes=[],this.enabled=!0,this.clipIntersection=!1,this.clipShadows=!1}};var UH=w.BRDF_GGX,LH=w.BRDF_Lambert,zH=w.BRDF_Sheen,VH=w.BasicPointShadowFilter,jH=w.BasicShadowFilter,GH=w.Break,HH=w.Const,WH=w.Continue,qH=w.DFGLUT,XH=w.D_GGX,KH=w.D_GGX_Anisotropic,JH=w.Discard,$H=w.EPSILON,YH=w.EnvironmentBRDF,ZH=w.F_Schlick,Zs=w.Fn,QH=w.HALF_PI,eW=w.INFINITY,Tt=w.If,tW=w.LTC_Evaluate,sW=w.LTC_Evaluate_Volume,nW=w.LTC_Uv,co=w.Loop,aW=w.NodeAccess,iW=w.NodeShaderStage,rW=w.NodeType,oW=w.NodeUpdateType,cW=w.OnAfterObjectUpdate,lW=w.OnAfterRenderPipeline,hW=w.OnBeforeFrameUpdate,uW=w.OnBeforeMaterialUpdate,dW=w.OnBeforeObjectUpdate,fW=w.OnBeforeRenderPipeline,pW=w.OnFrameUpdate,mW=w.OnMaterialUpdate,bW=w.OnObjectUpdate,gW=w.PCFShadowFilter,yW=w.PI,xW=w.PI2,wW=w.PointShadowFilter,xa=w.Return,TW=w.Schlick_to_F0,vW=w.ShaderNode,_W=w.Stack,AW=w.Switch,MW=w.TBNViewMatrix,SW=w.TWO_PI,NW=w.VSMShadowFilter,RW=w.V_GGX_SmithCorrelated,EW=w.V_GGX_SmithCorrelated_Anisotropic,CW=w.Var,kW=w.VarIntent,IW=w.abs,BW=w.acesFilmicToneMapping,FW=w.acos,PW=w.acosh,DW=w.add,OW=w.addMethodChaining,UW=w.addNodeElement,LW=w.agxToneMapping,zW=w.all,VW=w.alphaT,jW=w.ambientOcclusion,GW=w.and,HW=w.anisotropy,WW=w.anisotropyB,qW=w.anisotropyT,XW=w.any,KW=w.array,JW=w.asin,$W=w.asinh,YW=w.assign,ZW=w.atan,QW=w.atanh,mr=w.atomicAdd,e6=w.atomicAnd,t6=w.atomicFunc,qn=w.atomicLoad,s6=w.atomicMax,n6=w.atomicMin,a6=w.atomicOr,Ha=w.atomicStore,i6=w.atomicSub,r6=w.atomicXor,o6=w.attenuationColor,c6=w.attenuationDistance,l6=w.attribute,h6=w.attributeArray,u6=w.backgroundBlurriness,d6=w.backgroundIntensity,f6=w.backgroundRotation,p6=w.batch,m6=w.batchColor,b6=w.batchIndirectIndex,g6=w.bentNormalView,y6=w.billboarding,x6=w.bitAnd,w6=w.bitNot,T6=w.bitOr,v6=w.bitXor,_6=w.bitangentGeometry,A6=w.bitangentLocal,M6=w.bitangentView,S6=w.bitangentViewFrame,N6=w.bitangentWorld,iv=w.bitcast,R6=w.blendBurn,E6=w.blendColor,C6=w.blendDodge,k6=w.blendOverlay,I6=w.blendScreen,eh=w.bool,B6=w.buffer,F6=w.bufferAttribute,P6=w.builtin,D6=w.builtinAOContext,O6=w.builtinGIContext,U6=w.builtinShadowContext,ZN=w.bumpMap,L6=w.bvec2,z6=w.bvec3,V6=w.bvec4,j6=w.bypass,G6=w.cache,H6=w.call,W6=w.cameraFar,q6=w.cameraIndex,X6=w.cameraNear,K6=w.cameraNormalMatrix,J6=w.cameraPosition,$6=w.cameraProjectionMatrix,Y6=w.cameraProjectionMatrixInverse,Sb=w.cameraViewMatrix,Z6=w.cameraViewport,Q6=w.cameraWorldMatrix,eq=w.cbrt,tq=w.cdl,QN=w.ceil,sq=w.checker,nq=w.cineonToneMapping,yc=w.clamp,aq=w.clearcoat,iq=w.clearcoatNormalView,rq=w.clearcoatRoughness,oq=w.clipSpace,cq=w.clipping,lq=w.clippingAlpha,hq=w.code,uq=w.color,dq=w.colorSpaceToWorking,fq=w.colorToDirection,pq=w.compute,mq=w.computeKernel,bq=w.computeSkinning,rv=w.context,gq=w.convert,yq=w.convertColorSpace,xq=w.convertToTexture,wq=w.cos,Tq=w.cosh,vq=w.countLeadingZeros,_q=w.countOneBits,Aq=w.countTrailingZeros,Mq=w.cross,Sq=w.cubeTexture,Nq=w.cubeTextureBase,Rq=w.dFdx,Eq=w.dFdy,Cq=w.dashSize,kq=w.debug,Iq=w.decrement,Bq=w.decrementBefore,Fq=w.defaultBuildStages,Pq=w.defaultShaderStages,Dq=w.defined,Oq=w.degrees,Uq=w.deltaTime,Lq=w.densityFogFactor,zq=w.depth,Vq=w.depthPass,jq=w.determinant,Gq=w.difference,Hq=w.diffuseColor,Wq=w.diffuseContribution,qq=w.directPointLight,Xq=w.directionToColor,Kq=w.directionToFaceDirection,Jq=w.dispersion,$q=w.distance,Yq=w.div,ov=w.dot,Zq=w.dot4I8Packed,Qq=w.dot4U8Packed,e5=w.drawIndex,t5=w.dynamicBufferAttribute,s5=w.element,n5=w.emissive,a5=w.equal,i5=w.equirectDirection,r5=w.equirectUV,o5=w.exp,eR=w.exp2,c5=w.exponentialHeightFogFactor,l5=w.expression,tR=w.faceDirection,h5=w.faceForward,u5=w.faceforward,ht=w.float,d5=w.floatBitsToInt,f5=w.floatBitsToUint,br=w.floor,p5=w.fog,cv=w.fract,m5=w.frameGroup,b5=w.frameId,g5=w.frontFacing,y5=w.fwidth,x5=w.gain,w5=w.gapSize,T5=w.getConstNodeType,v5=w.getCurrentStack,_5=w.getDistanceAttenuation,A5=w.getGeometryRoughness,M5=w.getNormalFromDepth,S5=w.getParallaxCorrectNormal,N5=w.getRoughness,R5=w.getScreenPosition,E5=w.getScreenPositionFromClip,C5=w.getShIrradianceAt,k5=w.getTextureIndex,I5=w.getViewPosition,B5=w.globalId,F5=w.glsl,P5=w.glslFn,D5=w.grayscale,O5=w.greaterThan,U5=w.greaterThanEqual,L5=w.hardwareClipping,Nb=w.hash,z5=w.highpModelNormalViewMatrix,V5=w.highpModelViewMatrix,j5=w.hue,G5=w.increment,H5=w.incrementBefore,W5=w.inspect,q5=w.instance,X5=w.instanceColor,xc=w.instanceIndex,K5=w.instancedArray,J5=w.instancedBufferAttribute,$5=w.instancedDynamicBufferAttribute,Y5=w.instancedMesh,lv=w.int,Z5=w.intBitsToFloat,Q5=w.interleavedGradientNoise,eX=w.inverse,tX=w.inverseSqrt,sX=w.inversesqrt,nX=w.invocationLocalIndex,aX=w.invocationSubgroupIndex,iX=w.ior,rX=w.iridescence,oX=w.iridescenceIOR,cX=w.iridescenceThickness,lX=w.isolate,sR=w.ivec2,hX=w.ivec3,uX=w.ivec4,dX=w.js,fX=w.label,gr=w.length,pX=w.lengthSq,mX=w.lessThan,bX=w.lessThanEqual,gX=w.lightPosition,yX=w.lightProjectionUV,xX=w.lightShadowMatrix,wX=w.lightTargetDirection,TX=w.lightTargetPosition,vX=w.lightViewPosition,_X=w.lightingContext,AX=w.lights,MX=w.linearDepth,SX=w.linearToneMapping,Qd=w.localId,nR=w.log,aR=w.log2,NX=w.logarithmicDepthToViewZ,RX=w.luminance,EX=w.mat2,iR=w.mat3,rR=w.mat4,CX=w.matcapUV,kX=w.materialAO,IX=w.materialAlphaTest,BX=w.materialAnisotropy,FX=w.materialAnisotropyVector,PX=w.materialAttenuationColor,DX=w.materialAttenuationDistance,OX=w.materialClearcoat,UX=w.materialClearcoatNormal,LX=w.materialClearcoatRoughness,ef=w.materialColor,zX=w.materialDispersion,VX=w.materialEmissive,jX=w.materialEnvIntensity,GX=w.materialEnvRotation,HX=w.materialIOR,WX=w.materialIridescence,qX=w.materialIridescenceIOR,XX=w.materialIridescenceThickness,KX=w.materialLightMap,JX=w.materialLineDashOffset,$X=w.materialLineDashSize,YX=w.materialLineGapSize,ZX=w.materialLineScale,QX=w.materialLineWidth,eK=w.materialMetalness,tK=w.materialNormal,sK=w.materialOpacity,nK=w.materialPointSize,Rb=w.materialReference,aK=w.materialReflectivity,iK=w.materialRefractionRatio,rK=w.materialRetroreflectivity,oK=w.materialRotation,cK=w.materialRoughness,lK=w.materialSheen,hK=w.materialSheenRoughness,uK=w.materialShininess,dK=w.materialSpecular,fK=w.materialSpecularColor,pK=w.materialSpecularIntensity,mK=w.materialSpecularStrength,bK=w.materialThickness,gK=w.materialTransmission,Xn=w.max,yK=w.maxMipLevel,xK=w.mediumpModelViewMatrix,wK=w.metalness,tf=w.min,TK=w.mix,vK=w.mixElement,_K=w.mod,AK=w.modelDirection,MK=w.modelNormalMatrix,SK=w.modelPosition,NK=w.modelRadius,RK=w.modelScale,EK=w.modelViewMatrix,CK=w.modelViewPosition,kK=w.modelViewProjection,oR=w.modelWorldMatrix,IK=w.modelWorldMatrixInverse,BK=w.morphReference,cR=w.mrt,FK=w.mul,PK=w.mx_aastep,DK=w.mx_add,OK=w.mx_atan2,UK=w.mx_cell_noise_float,LK=w.mx_cell_noise_vec3,zK=w.mx_contrast,VK=w.mx_divide,jK=w.mx_fractal_noise_float,GK=w.mx_fractal_noise_float_2d,HK=w.mx_fractal_noise_vec2,WK=w.mx_fractal_noise_vec3,qK=w.mx_fractal_noise_vec4,XK=w.mx_frame,KK=w.mx_heighttonormal,JK=w.mx_hsvtorgb,$K=w.mx_ifequal,YK=w.mx_ifgreater,ZK=w.mx_ifgreatereq,QK=w.mx_invert,eJ=w.mx_modulo,tJ=w.mx_multiply,sJ=w.mx_noise_float,nJ=w.mx_noise_vec3,aJ=w.mx_noise_vec4,iJ=w.mx_place2d,rJ=w.mx_power,oJ=w.mx_ramp4,cJ=w.mx_ramplr,lJ=w.mx_ramptb,hJ=w.mx_rgbtohsv,uJ=w.mx_rotate2d,dJ=w.mx_rotate3d,fJ=w.mx_safepower,pJ=w.mx_separate,mJ=w.mx_smoothstep,bJ=w.mx_splitlr,gJ=w.mx_splittb,yJ=w.mx_srgb_texture_to_lin_rec709,xJ=w.mx_subtract,wJ=w.mx_timer,TJ=w.mx_transform_uv,vJ=w.mx_unifiednoise2d,_J=w.mx_unifiednoise3d,AJ=w.mx_worley_noise_float,MJ=w.mx_worley_noise_float_2d,SJ=w.mx_worley_noise_float_3d,NJ=w.mx_worley_noise_vec2,RJ=w.mx_worley_noise_vec3,EJ=w.mx_worley_noise_vec3_style,CJ=w.negate,hv=w.negateOnBackSide,kJ=w.neutralToneMapping,IJ=w.nodeArray,BJ=w.nodeImmutable,FJ=w.nodeObject,PJ=w.nodeObjectIntent,DJ=w.nodeObjects,OJ=w.nodeProxy,UJ=w.nodeProxyConstructor,LJ=w.nodeProxyIntent,zJ=w.normalFlat,VJ=w.normalGeometry,lR=w.normalLocal,jJ=w.normalMap,hR=w.normalView,GJ=w.normalViewGeometry,HJ=w.normalWorld,WJ=w.normalWorldGeometry,sf=w.normalize,qJ=w.not,XJ=w.notEqual,Eb=w.numWorkgroups,KJ=w.objectDirection,JJ=w.objectGroup,$J=w.objectPosition,YJ=w.objectRadius,ZJ=w.objectScale,QJ=w.objectViewPosition,e$=w.objectWorldMatrix,t$=w.oneMinus,s$=w.or,n$=w.orthographicDepthToViewZ,a$=w.oscSawtooth,i$=w.oscSine,r$=w.oscSquare,o$=w.oscTriangle,c$=w.output,l$=w.outputStruct,h$=w.overloadingFn,u$=w.overrideNode,d$=w.overrideNodes,f$=w.pack4xI8,p$=w.pack4xI8Clamp,m$=w.pack4xU8,b$=w.pack4xU8Clamp,g$=w.packHalf2x16,y$=w.packNormalToRGB,x$=w.packSnorm2x16,w$=w.packSnorm4x8,T$=w.packUnorm2x16,v$=w.packUnorm4x8,_$=w.parabola,A$=w.parallaxDirection,M$=w.parallaxUV,S$=w.parameter,N$=w.pass,R$=w.passTexture,E$=w.pcurve,C$=w.perspectiveDepthToViewZ,k$=w.pmremTexture,I$=w.pointShadow,B$=w.pointUV,F$=w.pointWidth,P$=w.positionGeometry,uR=w.positionLocal,D$=w.positionPrevious,uv=w.positionView,O$=w.positionViewDirection,U$=w.positionWorld,L$=w.positionWorldDirection,z$=w.posterize,V$=w.pow,j$=w.pow2,G$=w.pow3,H$=w.pow4,W$=w.premultiplyAlpha,q$=w.property,X$=w.quadBroadcast,K$=w.quadSwapDiagonal,J$=w.quadSwapX,$$=w.quadSwapY,Y$=w.radians,Z$=w.rand,Q$=w.range,eY=w.rangeFogFactor,tY=w.reciprocal,sY=w.reference,nY=w.referenceBuffer,aY=w.reflect,iY=w.reflectVector,rY=w.reflectView,oY=w.reflector,cY=w.refract,lY=w.refractVector,hY=w.refractView,uY=w.reinhardToneMapping,dY=w.remap,fY=w.remapClamp,pY=w.renderGroup,mY=w.renderOutput,bY=w.rendererReference,gY=w.replaceDefaultUV,yY=w.retroreflectivity,xY=w.rotate,wY=w.rotateUV,TY=w.roughness,vY=w.round,_Y=w.rtt,AY=w.sRGBTransferEOTF,MY=w.sRGBTransferOETF,SY=w.sample,NY=w.sampler,RY=w.samplerComparison,EY=w.saturate,CY=w.saturation,dR=w.screenCoordinate,kY=w.screenDPR,IY=w.screenSize,BY=w.screenUV,os=w.select,FY=w.setCurrentStack,PY=w.setName,DY=w.shaderStages,OY=w.shadow,UY=w.shadowPositionWorld,LY=w.shapeCircle,zY=w.sharedUniformGroup,VY=w.sheen,jY=w.sheenRoughness,GY=w.shiftLeft,HY=w.shiftRight,WY=w.shininess,qY=w.sign,XY=w.sin,KY=w.sinc,JY=w.sinh,$Y=w.skinning,fR=w.smoothstep,YY=w.smoothstepElement,ZY=w.specularColor,QY=w.specularColorBlended,e7=w.specularF90,t7=w.spherizeUV,s7=w.split,n7=w.spritesheetUV,nf=w.sqrt,a7=w.stack,i7=w.step,r7=w.stepElement,Rs=w.storage,o7=w.storageBarrier,c7=w.storageElement,l7=w.storageTexture,h7=w.storageTexture3D,u7=w.struct,d7=w.sub,f7=w.subBuild,p7=w.subgroupAdd,m7=w.subgroupAll,b7=w.subgroupAnd,g7=w.subgroupAny,y7=w.subgroupBallot,x7=w.subgroupBroadcast,w7=w.subgroupBroadcastFirst,T7=w.subgroupElect,v7=w.subgroupExclusiveAdd,_7=w.subgroupExclusiveMul,A7=w.subgroupInclusiveAdd,M7=w.subgroupInclusiveMul,S7=w.subgroupIndex,N7=w.subgroupMax,R7=w.subgroupMin,E7=w.subgroupMul,C7=w.subgroupOr,k7=w.subgroupShuffle,I7=w.subgroupShuffleDown,B7=w.subgroupShuffleUp,F7=w.subgroupShuffleXor,P7=w.subgroupSize,D7=w.subgroupXor,O7=w.tan,U7=w.tangentGeometry,L7=w.tangentLocal,z7=w.tangentView,V7=w.tangentViewFrame,j7=w.tangentWorld,G7=w.tanh,Cb=w.texture,H7=w.texture3D,W7=w.texture3DLevel,q7=w.texture3DLoad,X7=w.textureBarrier,K7=w.textureBicubic,J7=w.textureBicubicLevel,$7=w.textureLevel,Y7=w.textureLoad,Z7=w.textureSize,Q7=w.textureStore,eZ=w.thickness,tZ=w.time,sZ=w.toneMapping,nZ=w.toneMappingExposure,aZ=w.toonOutlinePass,iZ=w.transformDirection,rZ=w.transformNormal,oZ=w.transformNormalByInverseViewMatrix,cZ=w.transformNormalByViewMatrix,pR=w.transformNormalToView,lZ=w.transformedClearcoatNormalView,hZ=w.transformedNormalView,uZ=w.transformedNormalWorld,dZ=w.transmission,fZ=w.transpose,pZ=w.triNoise3D,mZ=w.triplanarTexture,bZ=w.triplanarTextures,gZ=w.trunc,de=w.uint,yZ=w.uintBitsToFloat,kt=w.uniform,xZ=w.uniformArray,wZ=w.uniformCubeTexture,TZ=w.uniformFlow,vZ=w.uniformGroup,_Z=w.uniformTexture,AZ=w.unpack4xI8,MZ=w.unpack4xU8,SZ=w.unpackHalf2x16,NZ=w.unpackNormal,RZ=w.unpackRGBToNormal,EZ=w.unpackSnorm2x16,CZ=w.unpackSnorm4x8,mR=w.unpackUnorm2x16,kZ=w.unpackUnorm4x8,IZ=w.unpremultiplyAlpha,BZ=w.userData,FZ=w.uv,PZ=w.uvec2,DZ=w.uvec3,af=w.uvec4,OZ=w.varying,Wa=w.varyingProperty,bR=w.vec2,wc=w.vec3,Lt=w.vec4,UZ=w.vectorComponents,kb=w.velocity,LZ=w.vertexColor,dv=w.vertexIndex,zZ=w.vertexStage,VZ=w.vibrance,jZ=w.viewZToLogarithmicDepth,GZ=w.viewZToOrthographicDepth,HZ=w.viewZToPerspectiveDepth,WZ=w.viewZToReversedOrthographicDepth,qZ=w.viewZToReversedPerspectiveDepth,XZ=w.viewport,KZ=w.viewportCoordinate,JZ=w.viewportDepthTexture,$Z=w.viewportLinearDepth,YZ=w.viewportMipTexture,ZZ=w.viewportOpaqueMipTexture,QZ=w.viewportSafeUV,eQ=w.viewportSharedTexture,tQ=w.viewportSize,sQ=w.viewportTexture,nQ=w.viewportUV,aQ=w.vogelDiskSample,iQ=w.wgsl,rQ=w.wgslFn,gR=w.workgroupArray,yR=w.workgroupBarrier,Tc=w.workgroupId,oQ=w.workingToColorSpace,cQ=w.xor;var Ei=255,xR=Ei<<16,wR=Wa("vec2","vVgFade"),fv=kt(0);function TR(){let r=dR,e=r.x.add(ht(fv).mul(5.588238)),t=cv(cv(e.mul(.06711056).add(r.y.mul(.00583715))).mul(52.9829189)),s=br(t.mul(Ei)),n=wR.round();return s.greaterThanEqual(n.x).and(s.lessThan(n.y))}function vR(r,e,t,s){let n=s>1?t*s:t;if(!(r<=n&&e>t))return null;if(!(s>1))return[0,Ei];let a=Ei/Math.log(s),i=l=>Math.min(Ei,Math.max(0,Math.round(Math.log(Math.max(l,1e-30)/t)*a))),o=i(r),c=Number.isFinite(e)?i(e):Ei;return c>o?[o,c]:null}function lQ(r,e,t){let s=e.viewMatrix,n=r.meshletBounds,a=new Uint8Array(r.meshletCount),i=e.scale??1,o=(c,l,h,u,d)=>{if(d>=1e30*.5)return 1/0;let f=s[0]*c+s[4]*l+s[8]*h+s[12],p=s[1]*c+s[5]*l+s[9]*h+s[13],m=s[2]*c+s[6]*l+s[10]*h+s[14],b=Math.max(Math.hypot(f,p,m)-u*i,e.near);return d*i*e.projScale/b};for(let c=0;c<r.meshletCount;c++){let l=c*16,h=o(n[l],n[l+1],n[l+2],n[l+3],n[l+8]),u=o(n[l+4],n[l+5],n[l+6],n[l+7],n[l+9]);a[c]=h<=t&&u>t?1:0}return a}function hQ(r,e,t,s){let n=e.viewMatrix,a=r.meshletBounds,i=new Uint8Array(r.meshletCount),o=new Uint8Array(r.meshletCount),c=e.scale??1,l=(h,u,d,f,p)=>{if(p>=1e30*.5)return 1/0;let m=n[0]*h+n[4]*u+n[8]*d+n[12],b=n[1]*h+n[5]*u+n[9]*d+n[13],g=n[2]*h+n[6]*u+n[10]*d+n[14];return p*c*e.projScale/Math.max(Math.hypot(m,b,g)-f*c,e.near)};for(let h=0;h<r.meshletCount;h++){let u=h*16,d=l(a[u],a[u+1],a[u+2],a[u+3],a[u+8]),f=l(a[u+4],a[u+5],a[u+6],a[u+7],a[u+9]),p=vR(d,f,t,s);p&&([i[h],o[h]]=p)}return{lo:i,hi:o}}function uQ(r,e){let{replacementGroup:t,replacementStart:s,replacementIndices:n}=r,a=new Int8Array(r.meshletCount).fill(-1),i=c=>{if(a[c]!==-1)return a[c]===1;let l=!1,h=t[c];if(h>=0)for(let u=s[h];!l&&u<s[h+1];u++)l=e[n[u]]===1||i(n[u]);return a[c]=l?1:0,l},o=[];for(let c=0;c<r.meshletCount;c++)e[c]&&i(c)&&o.push(c);return o}function dQ(r,e){let t=new Int8Array(r.meshletCount).fill(-1),{replacementGroup:s,replacementStart:n,replacementIndices:a}=r,i=c=>{if(t[c]!==-1)return t[c]===1;let l=e[c]===1,h=s[c];if(h>=0)for(let u=n[h];!l&&u<n[h+1];u++)l=i(a[u]);return t[c]=l?1:0,l},o=[];for(let c=0;c<r.meshletCount;c++)r.meshletInfo[c*4+2]===0&&!i(c)&&o.push(c);return o}function z2(r,e){let t=e.viewMatrix,[s,n,a,i]=r.lodBoundsSphere,o=t[0]*s+t[4]*n+t[8]*a+t[12],c=t[1]*s+t[5]*n+t[9]*a+t[13],l=t[2]*s+t[6]*n+t[10]*a+t[14],h=Math.hypot(o,c,l),u=i*(e.scale??1);return[Math.max(h-u,e.near),Math.max(h+u,e.near)]}function fQ(r,e,t,s=1){let[n,a]=z2(r,e),i=t*Math.max(1,s),o=(e.scale??1)*e.projScale,c=-1,l=-1,h=r.levelRanges.length/2;for(let u=0;u<h;u++){let d=r.levelErrors[u*2],f=r.levelErrors[u*2+1],p=d*o/a<=i,m=f>=1e30*.5||f*o/n>t;p&&m&&(c<0&&(c=u),l=u)}return c<0?[0,0]:[r.levelRanges[c*2],r.levelRanges[l*2]+r.levelRanges[l*2+1]]}function pQ(r,e,t,s=1){let[n,a]=z2(r,e),i=t*Math.max(1,s),o=.001,c=(e.scale??1)*e.projScale,l=-1,h=-1,u=0,d=0,f=r.levelRanges.length/2;for(let b=0;b<f;b++){let g=r.levelErrors[b*2],x=r.levelErrors[b*2+1],T=g*c/a<=i,y=x>=1e30*.5||x*c/n>t;if(!T||!y)continue;l<0&&(l=b),h=b;let v=r.levelRanges[b*2+1];u+=v;let _=r.levelGuardErrors[b*2],A=r.levelGuardErrors[b*2+1],M=_*c/n<=t*(1-o),N=A>=1e30*.5||A*c/a>i*(1+o);M&&N&&(d+=v)}if(l<0)return null;let p=r.levelRanges[l*2],m=r.levelRanges[h*2]+r.levelRanges[h*2+1];return u!==m-p||d!==u||u>4?null:[p,m]}var sh=Wa("vec2","vVgUv");function V2(r){if(!(r?.isTextureNode!==!0||r.isCubeTextureNode||r.isTexture3DNode))return sh}function Ib(r){return Cb(r,sh).setUpdateMatrix(!0)}var mQ=[cn,jr,Vr];function _R(r,e,t=aa){let s=Ib(r),n=s.xyz.mul(2).sub(1);if(mQ.includes(r.format)){let b=s.xy.mul(2).sub(1);n=wc(b,nf(ht(1).sub(b.dot(b)).max(0)))}if(n=wc(n.xy.mul(e),n.z),t===Kp)return pR(n);let a=uv.dFdx(),i=uv.dFdy(),o=sh.dFdx(),c=sh.dFdy(),l=hR,h=i.cross(l),u=l.cross(a),d=h.mul(o.x).add(u.mul(c.x)),f=h.mul(o.y).add(u.mul(c.y)),p=d.dot(d).max(f.dot(f)),m=p.equal(0).select(0,p.inverseSqrt());return iR(hv(d.mul(m)),hv(f.mul(m)),l).mul(n).normalize()}function AR(r){let e=r;if(!e.colorNode&&(th(e.map)||th(e.alphaMap))){let t=Lt(ef,1);if(th(e.map)){let s=Ib(e.map);t=Lt(ef.mul(s.rgb),s.a)}th(e.alphaMap)&&(t=Lt(t.rgb,t.a.mul(Ib(e.alphaMap).g))),e.colorNode=t,e.map=null,e.alphaMap=null}e.normalNode||(th(e.normalMap)?e.normalNode=_R(e.normalMap,Rb("normalScale","vec2"),e.normalMapType):th(e.bumpMap)&&(e.normalNode=ZN(Ib(e.bumpMap).r,Rb("bumpScale","float")))),!e.clearcoatNormalNode&&th(e.clearcoatNormalMap)&&(e.clearcoatNormalNode=_R(e.clearcoatNormalMap,Rb("clearcoatNormalScale","vec2"))),e.contextNode=e.contextNode?rv(e.contextNode,{getUV:V2}):rv({getUV:V2}),r.needsUpdate=!0}var th=r=>r?.isTexture===!0;var lo=tf,of=Xn,j2=nR,Ub=Wa("vec3","vVgWorldNormal"),kR=Wa("float","vVgMeshlet"),IR=Wa("float","vVgLod"),xv=Wa("float","vVgInstance"),BR=Wa("vec3","vVgTint"),Lb=Wa("vec3","vVgInstanceOrigin"),ER=Math.ceil(Math.log2(128)),bQ=(1<<ER)-1,MR=65535,Db=128,pv=64,G2=64,H2=64,W2=48,wa=6,In=5,Ci=2,gQ=.15,wv=1e30,cf=5,rf=0,mv=1,SR=2,Bb=3,bv=4,vc=2+2*cf,_c=0,NR=2,Fb=4,q2=8,gv=1e4,yQ=2,X2=.82,K2=.9,J2=.75,xQ=1.25,wQ=2.5,ki=class{constructor(e,t,s,n=1/0){this.make=e;this.itemSize=t;this.maxItems=n;this.array=e(Math.max(1,s)*t),this.attribute=new mn(this.array,t)}make;itemSize;maxItems;array;attribute;used=0;get capacity(){return this.array.length/this.itemSize}reserve(e){if(this.used+e>this.capacity)return-1;let t=this.used;return this.used+=e,t}grow(e){let t=this.make(Math.min(Math.max(e,Math.ceil(this.capacity*1.6)),Math.max(e,this.maxItems))*this.itemSize);t.set(this.array),this.array=t,this.attribute=new mn(this.array,this.itemSize)}touch(e,t){t<=0||(this.attribute.addUpdateRange(e*this.itemSize,t*this.itemSize),this.attribute.needsUpdate=!0)}},yv=r=>new Float32Array(r),Pb=r=>new Uint32Array(r),Ob=class{constructor(e,t,s){this.context=e;this.capacity=t,this.maxBytes=s,this.meshSlotCapacity=64;let n=a=>Math.floor(s/a);this.vertexData=new ki(Pb,4,65536,n(16)),this.vertexAttrs=new ki(Pb,2,65536,n(8)),this.meshletBounds=new ki(yv,16,4096,n(64)),this.meshletInfo=new ki(Pb,4,4096,n(16)),this.meshletVertices=new ki(Pb,1,1<<18,n(4)),this.meshletTriangles=new ki(Pb,1,1<<18,n(4)),this.meshTable=new ki(yv,4,this.meshSlotCapacity*wa+1024,n(16)),this.meshTable.used=this.meshSlotCapacity*wa,this.instances=new ki(yv,4,4096,n(16*In)*In),this.cells=new ki(yv,4,256,n(16))}context;entries=[];meshSlots=kt(0,"uint");cellCount=kt(0,"uint");maxBytes;capacity;vertexData;vertexAttrs;meshletBounds;meshletInfo;meshletVertices;meshletTriangles;meshTable;instances;cells;meshSlotCapacity;levelUsed=0;countersAttribute;lodStateBase=0;controllerActive=!1;drawArgsAttribute;cameraIndex;shadowIndex;computeNodes=[];positionNode=null;version=0;needsRebuild=!0;indexBuffersReady=!1;pipelineState="none";dirty=!0;hasCut=!1;dedicated=!1;disabled=!1;static bytesOf(e){return Math.max(e.positions.length/3*16,e.meshletVertices.length*4,e.meshletTriangles.length*4,e.meshletCount*64)}fits(e,t){let s=(n,a,i)=>(n+a)*i<=this.maxBytes;return s(this.vertexData.used,e.positions.length/3,16)&&s(this.meshletBounds.used,e.meshletCount,64)&&s(this.meshletVertices.used,e.meshletVertices.length,4)&&s(this.meshletTriangles.used,e.meshletTriangles.length,4)&&s(this.instances.used,t*In,16)}add(e,t,s,n){let a=this.entries.indexOf(null);a===-1&&(a=this.entries.length),a>=this.meshSlotCapacity&&this.growMeshSlots(a+1);let i=e.positions.length/3,o=e.levelRanges.length/2,c=t.length/16,l=Math.ceil(c/Db),h=(d,f)=>{let p=d.reserve(f);return p===-1&&(d.grow(d.used+f),this.needsRebuild=!0,p=d.reserve(f)),p},u={slot:a,data:e,vertexBase:h(this.vertexData,i),meshletBase:h(this.meshletBounds,e.meshletCount),meshletVertexBase:h(this.meshletVertices,e.meshletVertices.length),triangleBase:h(this.meshletTriangles,e.meshletTriangles.length),levelBase:0,levelCount:o,instanceBase:h(this.instances,c*In)/In,instanceCount:c,cellBase:h(this.cells,l*Ci)/Ci,cellCount:l,uvScale:[1,1],uvOffset:[0,0]};return h(this.meshletInfo,e.meshletCount),h(this.vertexAttrs,i),u.levelBase=this.meshSlotCapacity*wa+this.levelUsed,u.levelBase+o*2>this.meshTable.capacity&&(this.meshTable.grow(u.levelBase+o*2),this.needsRebuild=!0),this.levelUsed+=o*2,this.meshTable.used=Math.max(this.meshTable.used,u.levelBase+o*2),this.entries[a]=u,this.writeGeometry(u),this.writeInstances(u,t,s,n),this.writeMeshRecord(u,{maxDrawDistance:wv,minPixelRadius:0,enabled:1,shadow:1,occlusion:0}),this.meshSlots.value=Math.max(this.meshSlots.value,a+1),this.cellCount.value=this.cells.used/Ci,this.dirty=!0,u}remove(e){this.writeFlags(e,{enabled:0}),this.entries[e.slot]=null,this.dirty=!0}growMeshSlots(e){let t=this.meshSlotCapacity,s=Math.max(e,t*2),n=(s-t)*wa,a=t*wa,i=this.meshTable.used+n;i>this.meshTable.capacity&&this.meshTable.grow(i);let o=this.meshTable.array;o.copyWithin((a+n)*4,a*4,this.meshTable.used*4),o.fill(0,a*4,(a+n)*4),this.meshTable.used+=n,this.meshSlotCapacity=s;for(let c of this.entries)c&&(c.levelBase+=n,o[(c.slot*wa+3)*4+3]=c.levelBase);this.needsRebuild=!0}writeGeometry(e){let t=e.data,s=t.positions.length/3,n=this.vertexData.array,a=new Float32Array(n.buffer,n.byteOffset,n.length);for(let d=0;d<s;d++){let f=(e.vertexBase+d)*4;a[f]=t.positions[d*3],a[f+1]=t.positions[d*3+1],a[f+2]=t.positions[d*3+2],n[f+3]=$2(t.normals[d*3],t.normals[d*3+1],t.normals[d*3+2])}this.vertexData.touch(e.vertexBase,s);let i=this.vertexAttrs.array,o=t.uvs?Y2(t.uvs):null;o&&(e.uvScale=o.scale,e.uvOffset=o.offset);let c=d=>Math.round(Math.max(0,Math.min(1,d))*255);for(let d=0;d<s;d++){let f=(e.vertexBase+d)*2;i[f]=t.colors?(c(t.colors[d*3])|c(t.colors[d*3+1])<<8|c(t.colors[d*3+2])<<16|255<<24)>>>0:4294967295,i[f+1]=o?o.packed[d]:0}this.vertexAttrs.touch(e.vertexBase,s),this.meshletBounds.array.set(t.meshletBounds,e.meshletBase*16),this.meshletBounds.touch(e.meshletBase,t.meshletCount);let l=this.meshletInfo.array;for(let d=0;d<t.meshletCount;d++){let f=(e.meshletBase+d)*4,p=d*4;l[f]=t.meshletInfo[p],l[f+1]=t.meshletInfo[p+1]+e.triangleBase*3,l[f+2]=t.meshletInfo[p+2],l[f+3]=t.meshletInfo[p+3]+e.meshletVertexBase}this.meshletInfo.touch(e.meshletBase,t.meshletCount);let h=this.meshletVertices.array;for(let d=0;d<t.meshletVertices.length;d++)h[e.meshletVertexBase+d]=t.meshletVertices[d]+e.vertexBase;this.meshletVertices.touch(e.meshletVertexBase,t.meshletVertices.length),this.meshletTriangles.array.set(t.meshletTriangles,e.triangleBase),this.meshletTriangles.touch(e.triangleBase,t.meshletTriangles.length);let u=this.meshTable.array;for(let d=0;d<e.levelCount;d++){let f=(e.levelBase+d*2)*4;u[f]=t.levelRanges[d*2]+e.meshletBase,u[f+1]=t.levelRanges[d*2+1],u[f+2]=t.levelErrors[d*2],u[f+3]=t.levelErrors[d*2+1],u[f+4]=t.levelGuardErrors[d*2],u[f+5]=t.levelGuardErrors[d*2+1],u[f+6]=0,u[f+7]=0}this.meshTable.touch(e.levelBase,e.levelCount*2)}writeMeshRecord(e,t){let s=this.meshTable.array,n=e.slot*wa*4;s.set(e.data.boundingSphere,n),s.set(e.data.lodBoundsSphere,n+4),s.set(e.data.cullBoundsSphere,n+8),s.set([t.maxDrawDistance,t.minPixelRadius,e.levelCount,e.levelBase],n+12),s.set([e.uvScale[0],e.uvScale[1],e.uvOffset[0],e.uvOffset[1]],n+16),s.set([t.enabled,t.shadow,t.occlusion,0],n+20),this.meshTable.touch(e.slot*wa,wa),this.dirty=!0}writeFlags(e,t){let s=this.meshTable.array,n=e.slot*wa*4,a=(i,o)=>{o===void 0||s[n+i]===o||(s[n+i]=o,this.meshTable.touch(e.slot*wa+(i>>2),1),this.dirty=!0)};a(12,t.maxDrawDistance),a(13,t.minPixelRadius),a(20,t.enabled),a(21,t.shadow),a(22,t.occlusion)}readFlag(e,t){let s={maxDrawDistance:12,minPixelRadius:13,enabled:20,shadow:21,occlusion:22};return this.meshTable.array[e.slot*wa*4+s[t]]}writeInstances(e,t,s,n){let a=this.instances.array;for(let i=0;i<e.instanceCount;i++){let o=n[i],c=(e.instanceBase+i)*In*4;a.set(t.subarray(o*16,o*16+16),c),s?a.set(s.subarray(o*4,o*4+3),c+16):a.fill(1,c+16,c+19),a[c+19]=e.slot}this.instances.touch(e.instanceBase*In,e.instanceCount*In);for(let i=0;i<e.cellCount;i++)this.computeCell(e,i);this.cells.touch(e.cellBase*Ci,e.cellCount*Ci)}setMatrix(e,t,s){s.toArray(this.instances.array,(e.instanceBase+t)*In*4)}commitInstances(e,t){this.instances.touch(e.instanceBase*In,e.instanceCount*In);for(let s of t)this.computeCell(e,s),this.cells.touch((e.cellBase+s)*Ci,Ci);this.dirty=!0}computeCell(e,t){let s=this.instances.array,n=t*Db,a=Math.min(n+Db,e.instanceCount),i=new Float64Array(4),o=[1/0,1/0,1/0],c=[-1/0,-1/0,-1/0],l=0;for(let m=n;m<a;m++){CR(s,(e.instanceBase+m)*In*4,e.data.boundingSphere,i);for(let b=0;b<3;b++)o[b]=Math.min(o[b],i[b]-i[3]),c[b]=Math.max(c[b],i[b]+i[3]);l=Math.max(l,i[3])}let h=(o[0]+c[0])/2,u=(o[1]+c[1])/2,d=(o[2]+c[2])/2,f=0;for(let m=n;m<a;m++)CR(s,(e.instanceBase+m)*In*4,e.data.boundingSphere,i),f=Math.max(f,Math.hypot(i[0]-h,i[1]-u,i[2]-d)+i[3]);let p=(e.cellBase+t)*Ci*4;this.cells.array.set([h,u,d,f*(1+1e-4)+.001,l*(1+1e-4)+1e-4,e.slot,e.instanceBase+n,a-n],p)}prepare(e){if(this.ensureBuilt(),this.indexBuffersReady)return;let t=e.backend;t.createIndexAttribute(this.cameraIndex),t.createIndexAttribute(this.shadowIndex),this.indexBuffersReady=!0}ensureBuilt(){this.needsRebuild&&this.build()}build(){this.needsRebuild=!1,this.indexBuffersReady=!1,this.pipelineState="none",this.hasCut=!1,this.version++;for(let Y of this.computeNodes)Y.dispose();let e=this.context,t=this.capacity,s=this.meshSlotCapacity,n=t.meshlets,a=Math.floor(this.instances.capacity/In),i=Math.floor(this.cells.capacity/Ci),o=t.triangles*3,c=t.shadowTriangles*3,l=(Y,he)=>Rs(Y.attribute,he,Y.capacity),h=l(this.vertexData,"uvec4").toReadOnly(),u=l(this.vertexAttrs,"uvec2").toReadOnly(),d=l(this.meshletBounds,"vec4").toReadOnly(),f=l(this.meshletInfo,"uvec4").toReadOnly(),p=l(this.meshletVertices,"uint").toReadOnly(),m=l(this.meshletTriangles,"uint").toReadOnly(),b=l(this.meshTable,"vec4").toReadOnly(),g=l(this.instances,"vec4").toReadOnly(),x=l(this.cells,"vec4").toReadOnly();this.lodStateBase=vc+2*s*4;let T=new Uint32Array(this.lodStateBase+q2);T.fill(gv,this.lodStateBase,this.lodStateBase+2),this.countersAttribute=new mn(T,1),this.drawArgsAttribute=new Jd(new Uint32Array(2*s*2*5),1),this.cameraIndex=new mn(new Uint32Array(o),1),this.shadowIndex=new mn(new Uint32Array(c),1);let y=new mn(new Uint32Array(i*4),4),v=new mn(new Uint32Array(a*2*4),4),_=new mn(new Uint32Array(n*2*4),4),A=()=>new Jd(new Uint32Array(3),3),M=A(),N=[A(),A()],R=[A(),A()],I=A(),D=Rs(this.countersAttribute,"uint",this.countersAttribute.count).toAtomic(),O=Y=>D.element(this.lodStateBase+Y),P=Y=>ht(qn(O(Y)).toVar()).div(gv),U=(Y,he)=>Ha(O(Y),de(ht(he).mul(gv).round())),j=Rs(I,"uint",3),z=Rs(this.drawArgsAttribute,"uint",this.drawArgsAttribute.count),H=Rs(this.cameraIndex,"uint",o),J=Rs(this.shadowIndex,"uint",c),ee=Rs(y,"uvec4",i),se=Rs(y,"uvec4",i).toReadOnly(),_e=Rs(v,"uvec4",a*2),Ae=Rs(_,"uvec4",n*2),Se=Rs(_,"uvec4",n*2).toReadOnly(),Fe=Rs(M,"uint",3),ft=N.map(Y=>Rs(Y,"uint",3)),te=R.map(Y=>Rs(Y,"uint",3)),re=(Y,he)=>D.element(2+Y*cf+he),Q=(Y,he,Ne)=>D.element(de(vc+Y*s*4).add(he.mul(4)).add(de(Ne).mul(2))),Ee=(Y,he,Ne)=>D.element(de(vc+Y*s*4+1).add(he.mul(4)).add(de(Ne).mul(2))),Oe=Y=>os(Y.bitAnd(16776960).equal(xR),de(0),de(1)),Ce=[o,c],Je=[H,J],ne=[],ae=()=>{let Y=P(_c).toVar(),he=P(_c+1).toVar(),Ne=ht(1).add(e.lodBlendMax.sub(1).mul(fR(xQ,wQ,e.errorThreshold.mul(Y)))).toVar(),Ve=Ne.greaterThan(1.001).toVar(),Le=os(Ve,ht(Ei).div(j2(Ne)),ht(0)).toVar();ne=[0,1].map(ut=>{let zt=ut===0?Y:of(Y,he),Qt=(ut===0?e.errorThreshold:e.errorThreshold.mul(e.shadowErrorScale)).mul(zt).toVar();return{low:Qt,high:os(Ve,Qt.mul(Ne),Qt).toVar(),fadeScale:Le}})},oe=e.minPixelRadius,me=e.occlusion,ve=(Y,he)=>g.element(Y.mul(In).add(he)),Pe=Y=>{let he=[0,1,2,3].map(Le=>ve(Y,Le).toVar()),Ne=rR(he[0],he[1],he[2],he[3]).toVar(),Ve=Xn(gr(he[0].xyz),Xn(gr(he[1].xyz),gr(he[2].xyz))).toVar();return{model:Ne,scale:Ve,columns:he}},ue=(Y,he)=>b.element(Y.mul(wa).add(he)),Ue=(Y,he,Ne,Ve)=>{let Le=e.viewMatrix.mul(Y.mul(Lt(Ne.xyz,1))),ut=Xn(gr(Le.xyz).sub(Ne.w.mul(he)),e.near),zt=Ve.mul(he).div(ut).mul(e.projScale);return os(Ve.greaterThanEqual(1e30*.5),ht(1e30),zt)},De=(Y,he)=>{let Ne=ht(1e30);for(let Ve of e.frustumPlanes){let Le=ov(Ve.xyz,Y).add(Ve.w);he!==!1&&(Le=Le.add(Xn(ov(Ve.xyz,e.shadowSweep),0).mul(he===!0?1:os(he,ht(1),ht(0))))),Ne=tf(Ne,Le)}return Ne},$e=(Y,he,Ne)=>{let Ve=e.viewMatrix.mul(Lt(he,1)).xyz.toVar(),Le=Ve.z.abs().mul(ne[0].high).div(e.projScale);return Y.and(me.activeNode.equal(1)).and(me.occluded(Ve,Ne.add(Le)))},At=(Y,he)=>{Y.element(0).assign(lo(he,de(MR))),Y.element(1).assign(he.add(MR-1).div(MR)),Y.element(2).assign(de(1))},ps=Zs(()=>{let Y=xc;Tt(Y.lessThan(de(vc)),()=>{Ha(D.element(Y),de(0))}),Tt(Y.lessThan(this.meshSlots.mul(8)),()=>{let he=Y.div(this.meshSlots.mul(4)),Ne=Y.mod(this.meshSlots.mul(4));Ha(D.element(de(vc).add(he.mul(s*4)).add(Ne)),de(0))})})().compute(Math.max(vc,s*8),[64]),bn=Zs(()=>{Tt(xc.greaterThanEqual(this.cellCount),()=>{xa()});let Y=xc.toVar(),he=x.element(Y.mul(Ci)).toVar(),Ne=x.element(Y.mul(Ci).add(1)).toVar(),Ve=de(Ne.y).toVar(),Le=ue(Ve,5).toVar();Tt(Le.x.equal(0),()=>{xa()});let ut=he.xyz.toVar(),zt=he.w.toVar();Tt(e.frustumCulling.equal(1).and(De(ut,Le.y.greaterThan(.5)).lessThan(zt.negate())),()=>{xa()});let Qt=ue(Ve,3).toVar(),es=Xn(oe,Qt.y),Gs=Ne.x,ms=gr(e.viewMatrix.mul(Lt(ut,1)).xyz).toVar().sub(zt).toVar();Tt(ms.greaterThan(Gs).and(Gs.mul(e.projScale).div(Xn(ms,1e-6)).lessThan(es)),()=>{xa()}),Tt(ms.greaterThan(Qt.x),()=>{xa()});let bs=mr(D.element(0),de(1)).toVar();ee.element(bs).assign(af(Ve,de(Ne.z),de(Ne.w),Y))})().compute(i,[pv]),Wb=Zs(()=>{At(Fe,qn(D.element(0)).toVar())})().compute(1),ah=gR("vec4",W2*2),uf=(Y,he,Ne,Ve,Le,ut,zt,Qt,es,Gs)=>{let{low:Hs,high:ms}=ne[Y],bs=de(4294967295).toVar(),gn=de(0).toVar(),Bn=de(0).toVar(),Ii=de(0).toVar();co({start:de(0),end:Ne,type:"uint",condition:"<"},({i:Cs})=>{let Nt=ah.element(Cs.mul(2)).toVar(),Ws=ah.element(Cs.mul(2).add(1)).toVar(),yn=de(Nt.x).toVar(),Ka=de(Nt.y).toVar(),Ja=Nt.z.mul(Gs).lessThanEqual(ms).and(Nt.w.greaterThanEqual(1e30*.5).or(Nt.w.mul(es).greaterThan(Hs))),xr=Ws.x.mul(es).lessThanEqual(Hs.mul(1-.001)).and(Ws.y.greaterThanEqual(1e30*.5).or(Ws.y.mul(Gs).greaterThan(ms.mul(1+.001))));Tt(Ja,()=>{bs.assign(lo(bs,yn)),gn.assign(of(gn,yn.add(Ka))),Bn.addAssign(Ka),Tt(xr,()=>{Ii.addAssign(Ka)})})});let Xa=zt.mul(Lt(Le.xyz,1)).xyz.toVar(),Fn=Le.w.mul(Qt).toVar(),Bi=Bn.greaterThan(de(0)).and(Bn.equal(gn.sub(bs))).and(Ii.equal(Bn)).and(Bn.lessThanEqual(de(4))).and(e.frustumCulling.equal(0).or(De(Xa,Y===1).greaterThanEqual(Fn))).toVar();Tt(gn.greaterThan(bs),()=>{mr(re(Y,SR),de(1)),Tt(Bi,()=>{let Cs=mr(re(Y,rf),Bn).toVar();for(let Nt=0;Nt<4;Nt++)Tt(de(Nt).lessThan(Bn).and(Cs.add(Nt).lessThan(de(n))),()=>{let Ws=bs.add(Nt).toVar(),yn=f.element(Ws).x.toVar(),Ka=mr(Q(Y,he,0),yn.mul(3)).toVar();Ae.element(Cs.add(Nt+Y*n)).assign(af(ut,Ws,Ka,yn.bitOr(xR)))})}).Else(()=>{let Cs=mr(re(Y,Bb),de(1)).toVar(),Nt=he.bitOr(os(Ve,de(2147483648),de(0)));_e.element(Cs.add(Y*a)).assign(af(ut,bs,gn,Nt))})})},qb=Y=>Zs(()=>{let he=Tc.x.add(Tc.y.mul(Eb.x)).toVar(),Ne=he.lessThan(qn(D.element(0))).toVar(),Ve=se.element(lo(he,de(i-1))).toVar(),Le=Ve.x,ut=ue(Le,3).toVar(),zt=os(Ne,lo(de(ut.z),de(W2)),de(0)).toVar(),Qt=de(ut.w).toVar();co({start:Qd.x,end:zt.mul(2),type:"uint",condition:"<",update:pv},({i:Fn})=>{ah.element(Fn).assign(b.element(Qt.add(Fn)))}),yR(),Tt(Ne.not(),()=>{xa()}),ae();let es=ue(Le,0).toVar(),Gs=ue(Le,1).toVar(),Hs=ue(Le,2).toVar(),ms=ue(Le,5).toVar(),bs=ms.y.greaterThan(.5),gn=ms.z.greaterThan(.5),Bn=Xn(oe,ut.y).toVar(),Ii=ut.x.toVar(),Xa=Ve.y.add(Ve.z);co({start:Ve.y.add(Qd.x),end:Xa,type:"uint",condition:"<",update:pv},({i:Fn})=>{let Bi=Fn.toVar(),{model:Cs,scale:Nt}=Pe(Bi),Ws=Cs.mul(Lt(es.xyz,1)).xyz.toVar(),yn=es.w.mul(Nt).toVar(),Ka=e.frustumCulling.equal(0),Ja=Ka.or(De(Ws,!1).greaterThanEqual(yn.negate())).toVar(),xr=bs.and(Ka.or(De(Ws,!0).greaterThanEqual(yn.negate()))).toVar();if(Y){let rh=P(Fb).toVar(),oh=P(Fb+1).toVar();Ja.assign(Ja.and(rh.greaterThan(.5))),xr.assign(xr.and(oh.greaterThan(.5)))}let pf=gr(e.viewMatrix.mul(Lt(Ws,1)).xyz).toVar(),Nv=pf.greaterThan(yn).and(yn.mul(e.projScale).div(pf).lessThan(Bn)),ih=pf.sub(yn).greaterThan(Ii),Jb=Ja.or(xr).and(Nv.not()).and(ih.not());Tt(Jb,()=>{Tt(Ja.and($e(gn,Ws,yn)),()=>{Ja.assign(eh(!1)),mr(D.element(1),de(1))});let rh=e.viewMatrix.mul(Cs.mul(Lt(Gs.xyz,1))),oh=gr(rh.xyz).toVar(),NE=Gs.w.mul(Nt),RE=Nt.mul(e.projScale).div(Xn(oh.sub(NE),e.near)).toVar(),EE=Nt.mul(e.projScale).div(Xn(oh.add(NE),e.near)).toVar();Tt(Ja,()=>{uf(0,Le,zt,gn,Hs,Bi,Cs,Nt,RE,EE)}),Tt(xr,()=>{uf(1,Le,zt,eh(!1),Hs,Bi,Cs,Nt,RE,EE)})})})})().compute(Y?I:M,[pv]),Xb=Y=>{let he=Zs(()=>{At(ft[Y],qn(re(Y,Bb)).toVar())})().compute(1),Ne=Zs(()=>{let Le=P(Fb+Y).toVar(),ut=qn(re(Y,Bb)).toVar();At(ft[Y],os(Le.greaterThan(.5),ut,de(0)).toVar())})().compute(1),Ve=Zs(()=>{let Le=Tc.x.add(Tc.y.mul(Eb.x)).toVar();Tt(Le.greaterThanEqual(qn(re(Y,Bb))),()=>{xa()});let ut=_e.element(Le.add(Y*a)).toVar(),zt=ut.x,Qt=ut.w.bitAnd(2147483647).toVar(),es=ut.w.shiftRight(31).equal(1),{model:Gs,scale:Hs}=Pe(zt);ae();let{low:ms,high:bs,fadeScale:gn}=ne[Y];co({start:ut.y.add(Qd.x),end:ut.z,type:"uint",condition:"<",update:G2},({i:Bn})=>{let Ii=Bn,Xa=Ii.mul(16/4).toVar(),Fn=d.element(Xa.add(3)),Bi=Gs.mul(Lt(Fn.xyz,1)).xyz,Cs=e.frustumCulling.equal(0).or(De(Bi,Y===1).greaterThanEqual(Fn.w.mul(Hs).negate()));Y===0&&(Cs=Cs.and($e(es,Bi,Fn.w.mul(Hs)).not()));let Nt=d.element(Xa.add(2)),Ws=Ue(Gs,Hs,d.element(Xa),Nt.x).toVar(),yn=Ue(Gs,Hs,d.element(Xa.add(1)),Nt.y).toVar(),Ka=ih=>de(j2(of(ih,1e-30).div(ms)).mul(gn).round().clamp(0,Ei)),Ja=os(gn.greaterThan(0),Ka(Ws),de(0)).toVar(),xr=os(gn.greaterThan(0),Ka(yn),de(Ei)).toVar(),pf=Ja.shiftLeft(8).bitOr(xr.shiftLeft(16)),Nv=Cs.and(Ws.lessThanEqual(bs)).and(yn.greaterThan(ms)).and(xr.greaterThan(Ja));Tt(Nv,()=>{let ih=mr(re(Y,rf),de(1)).toVar();Tt(ih.lessThan(de(n)),()=>{let Jb=f.element(Ii).x.toVar(),rh=Jb.bitOr(pf).toVar(),oh=mr(Q(Y,Qt,Oe(rh)),Jb.mul(3)).toVar();Ae.element(ih.add(Y*n)).assign(af(zt,Ii,oh,rh))})})})})().compute(N[Y],[G2]);return{argsNode:he,retryArgsNode:Ne,passNode:Ve}},df=Y=>Zs(()=>{let he=de(0).toVar(),Ne=de(Ce[Y]);co({start:de(0),end:this.meshSlots,type:"uint",condition:"<"},({i:Le})=>{for(let ut of[0,1]){let zt=qn(Q(Y,Le,ut)).toVar();Ha(Ee(Y,Le,ut),he);let Qt=os(he.lessThan(Ne),Ne.sub(he),de(0)),es=de(Y*s*10+ut*5).add(Le.mul(10)).toVar();z.element(es).assign(lo(zt,Qt)),z.element(es.add(1)).assign(de(1)),z.element(es.add(2)).assign(he),z.element(es.add(3)).assign(de(0)),z.element(es.add(4)).assign(de(0)),he.addAssign(zt)}}),Ha(re(Y,bv),he);let Ve=lo(qn(re(Y,rf)),de(n)).toVar();Ha(re(Y,mv),Ve),At(te[Y],Ve)})().compute(1),ff=Y=>Zs(()=>{let he=Tc.x.add(Tc.y.mul(Eb.x)).toVar();Tt(he.greaterThanEqual(qn(re(Y,mv))),()=>{xa()});let Ne=he.add(Y*n).toVar(),Ve=Se.element(Ne).toVar(),Le=de(ve(Ve.x,4).w).toVar(),ut=qn(Ee(Y,Le,Oe(Ve.w))).toVar(),zt=f.element(Ve.y).y.div(3).toVar(),Qt=Ne.shiftLeft(ER).toVar(),es=Je[Y],Gs=Ve.w.bitAnd(255).toVar();co({start:Qd.x,end:Gs,type:"uint",condition:"<",update:H2},({i:Hs})=>{let ms=ut.add(Ve.z).add(Hs.mul(3)).toVar();Tt(ms.add(2).lessThan(de(Ce[Y])),()=>{let bs=m.element(zt.add(Hs)).toVar();es.element(ms).assign(Qt.bitOr(bs.bitAnd(255))),es.element(ms.add(1)).assign(Qt.bitOr(bs.shiftRight(8).bitAnd(255))),es.element(ms.add(2)).assign(Qt.bitOr(bs.shiftRight(16).bitAnd(255)))})})})().compute(R[Y],[H2]),AE=Y=>{let he=qn(re(Y,bv)).toVar(),Ne=qn(re(Y,rf)).toVar();return of(ht(he).div(Ce[Y]),ht(Ne).div(n))},wP=Zs(()=>{let Y=eh(!1).toVar();for(let he of[0,1]){let Ne=AE(he).toVar(),Ve=P(_c+he).toVar();U(Fb+he,0),Tt(Ne.greaterThan(1).and(Ve.lessThan(e.lodScaleLimit)),()=>{U(_c+he,lo(Ve.mul(nf(Ne.div(X2)).clamp(1.1,4)),e.lodScaleLimit)),U(Fb+he,1),Y.assign(!0);for(let Le of[rf,mv,SR,Bb,bv])Ha(re(he,Le),de(0));he===0&&Ha(D.element(1),de(0)),co({start:de(0),end:this.meshSlots,type:"uint",condition:"<"},({i:Le})=>{Ha(Q(he,Le,0),de(0)),Ha(Q(he,Le,1),de(0))})})}j.element(0).assign(os(Y,Fe.element(0),de(0))),j.element(1).assign(os(Y,Fe.element(1),de(1))),j.element(2).assign(de(1))})().compute(1),TP=Zs(()=>{for(let Y of[0,1]){let he=AE(Y).toVar(),Ne=P(_c+Y).toVar();Tt(he.greaterThan(K2),()=>{Ne.assign(Ne.mul(lo(nf(he.div(X2)),1.03)))}).ElseIf(he.lessThan(J2),()=>{Ne.assign(Ne.div(1.01))}),U(_c+Y,of(lo(Ne,e.lodScaleLimit),1)),U(NR+Y,he)}})().compute(1),ME=[Xb(0),Xb(1)],SE=[df(0),df(1)],vP=qb(!1),_P=qb(!0),Kb=[];for(let Y=0;Y<yQ;Y++){Kb.push(wP,_P);for(let he of ME)Kb.push(he.retryArgsNode,he.passNode);Kb.push(...SE)}this.computeNodes=[ps,bn,Wb,vP,...ME.flatMap(Y=>[Y.argsNode,Y.passNode]),...SE,...Kb,TP,ff(0),ff(1)],this.positionNode=Zs(()=>{let Y=dv.shiftRight(ER),he=dv.bitAnd(bQ),Ne=Se.element(Y).toVar(),Ve=Ne.x,Le=Ne.y,ut=f.element(Le).toVar(),zt=p.element(ut.w.add(he)).toVar(),{model:Qt,columns:es}=Pe(Ve),Gs=ve(Ve,4).toVar(),Hs=de(Gs.w).toVar(),ms=ue(Hs,3),bs=ue(Hs,4).toVar(),gn=h.element(zt).toVar(),Bn=u.element(zt).toVar(),Ii=iv(gn.xyz,"vec3"),Xa=ms.x,Fn=es[3].xyz;Lb.assign(Fn);let Bi=gr(e.viewMatrix.mul(Lt(Fn,1)).xyz),Cs=Xa.sub(Bi).div(Xa.mul(gQ)).clamp(0,1),Nt=Fn.add(Qt.mul(Lt(Ii,0)).xyz.mul(Cs)),Ws=sf(Qt.mul(Lt(TQ(gn.w),0)).xyz);return lR.assign(Ws),Ub.assign(Ws),kR.assign(ht(Le)),wR.assign(bR(ht(Ne.w.shiftRight(8).bitAnd(255)),ht(Ne.w.shiftRight(16).bitAnd(255)))),IR.assign(ht(ut.z)),xv.assign(ht(Ve)),BR.assign(Gs.xyz.mul(vQ(Bn.x).xyz)),sh.assign(mR(Bn.y).mul(bs.xy).add(bs.zw)),Nt})()}async readCounters(e){let t=new Uint32Array(await e.getArrayBufferAsync(this.countersAttribute)),s=Array.from(t.subarray(this.lodStateBase,this.lodStateBase+q2),l=>l/gv),n=[s[_c],s[_c+1]],a=[s[NR],s[NR+1]];this.controllerActive=a.some((l,h)=>l>K2||l<J2&&n[h]>1.0001);let i=this.meshSlotCapacity,o=l=>({selected:t[2+l*cf+rf],drawn:t[2+l*cf+mv],survived:t[2+l*cf+SR],requestedTriangles:t[2+l*cf+bv]/3}),c=(l,h)=>(t[vc+(l*i+h)*4]+t[vc+(l*i+h)*4+2])/3;return{camera:o(0),shadow:o(1),occluded:t[1],perMesh:c,scale:n,fill:a}}drawArgsOffset(e,t,s=0){return((e*this.meshSlotCapacity+t)*2+s)*20}dispose(){for(let e of this.computeNodes)e.dispose();this.computeNodes=[]}};function CR(r,e,t,s){let[n,a,i,o]=t;s[0]=r[e]*n+r[e+4]*a+r[e+8]*i+r[e+12],s[1]=r[e+1]*n+r[e+5]*a+r[e+9]*i+r[e+13],s[2]=r[e+2]*n+r[e+6]*a+r[e+10]*i+r[e+14];let c=Math.hypot(r[e],r[e+1],r[e+2]),l=Math.hypot(r[e+4],r[e+5],r[e+6]),h=Math.hypot(r[e+8],r[e+9],r[e+10]);s[3]=o*Math.max(c,l,h)}function TQ(r){let e=iv(r,"int"),t=ht(e.shiftLeft(16).shiftRight(16)).div(32767),s=ht(e.shiftRight(16)).div(32767),n=ht(1).sub(t.abs()).sub(s.abs()),a=of(n.negate(),0),i=t.add(os(t.greaterThanEqual(0),a.negate(),a)),o=s.add(os(s.greaterThanEqual(0),a.negate(),a));return sf(wc(i,o,n))}function vQ(r){return Lt(ht(r.bitAnd(255)),ht(r.shiftRight(8).bitAnd(255)),ht(r.shiftRight(16).bitAnd(255)),ht(r.shiftRight(24))).div(255)}function $2(r,e,t){let s=Math.abs(r)+Math.abs(e)+Math.abs(t)||1,n=r/s,a=e/s;if(t<0){let c=(1-Math.abs(a))*(n>=0?1:-1),l=(1-Math.abs(n))*(a>=0?1:-1);n=c,a=l}let i=Math.round(Math.max(-1,Math.min(1,n))*32767)&65535,o=Math.round(Math.max(-1,Math.min(1,a))*32767)&65535;return(i|o<<16)>>>0}function Y2(r){let e=r.length/2,t=[1/0,1/0],s=[-1/0,-1/0];for(let o=0;o<r.length;o++){let c=o&1;r[o]<t[c]&&(t[c]=r[o]),r[o]>s[c]&&(s[c]=r[o])}e===0&&(t[0]=t[1]=s[0]=s[1]=0);let n=[s[0]-t[0]||1,s[1]-t[1]||1],a=new Uint32Array(e),i=(o,c)=>Math.round(Math.max(0,Math.min(1,(o-t[c])/n[c]))*65535);for(let o=0;o<e;o++)a[o]=(i(r[o*2],0)|i(r[o*2+1],1)<<16)>>>0;return{packed:a,scale:n,offset:[t[0],t[1]]}}function RR(r){return r&=1023,r=(r|r<<16)&50331903,r=(r|r<<8)&50393103,r=(r|r<<4)&51130563,r=(r|r<<2)&153391689,r}function Z2(r,e){let t=r.length/16,s=new Float64Array(4),n=new Float64Array(t*3),a=[1/0,1/0,1/0],i=[-1/0,-1/0,-1/0];for(let l=0;l<t;l++){CR(r,l*16,e,s);for(let h=0;h<3;h++)n[l*3+h]=s[h],a[h]=Math.min(a[h],s[h]),i[h]=Math.max(i[h],s[h])}let o=Math.max(i[0]-a[0],i[1]-a[1],i[2]-a[2],1e-9),c=new Uint32Array(t);for(let l=0;l<t;l++){let h=u=>Math.min(1023,Math.max(0,Math.floor((n[l*3+u]-a[u])/o*1024)));c[l]=(RR(h(0))|RR(h(1))<<1|RR(h(2))<<2)>>>0}return _Q(c)}function _Q(r){let e=r.length,t=Uint32Array.from({length:e},(a,i)=>i),s=new Uint32Array(e),n=new Uint32Array(32768);for(let a of[0,15]){n.fill(0);for(let o=0;o<e;o++)n[r[o]>>>a&32767]++;let i=0;for(let o=0;o<n.length;o++){let c=n[o];n[o]=i,i+=c}for(let o=0;o<e;o++){let c=t[o];s[n[r[c]>>>a&32767]++]=c}[t,s]=[s,t]}return t}var FR=class extends xt{projection=kt(new le);previousProjection=kt(new le);previousView=kt(new le);history=new WeakMap;constructor(){super("vec2"),this.updateType=Me.RENDER}update({frameId:e,camera:t}){if(!t)return;let s=kb.projectionMatrix??t.projectionMatrix,n=this.history.get(t);n?n.frame!==e&&(n.frame=e,n.previousProjection.copy(n.projection),n.previousView.copy(n.view),n.projection.copy(s),n.view.copy(t.matrixWorldInverse)):(n={frame:e,projection:s.clone(),view:t.matrixWorldInverse.clone(),previousProjection:s.clone(),previousView:t.matrixWorldInverse.clone()},this.history.set(t,n)),this.projection.value.copy(n.projection),this.previousProjection.value.copy(n.previousProjection),this.previousView.value.copy(n.previousView)}setup(){let e=oR.mul(Lt(uR,1)),t=this.projection.mul(Sb).mul(e),s=this.previousProjection.mul(this.previousView).mul(e);return t.xy.div(t.w).sub(s.xy.div(s.w))}},AQ=new FR,PR=cR({velocity:AQ});var Q2=new WeakMap;function MQ(r){let e=Q2.get(r);return e?e.clone():(Q2.set(r,r.clone()),r)}var SQ=new Set(["uuid","id","name","version","userData","maskNode","_listeners","_cacheKey","_needsUpdate","isMaterial"]);function zb(){let r=new ke;return r.setAttribute("position",new Xe(new Float32Array(3),3)),r.setAttribute("normal",new Xe(new Float32Array(3),3)),r}var Vb=class extends at{isVirtualMesh=!0;data;instanceCount;fullDetailTriangles;pool;entry;cameraGeometry=zb();shadowGeometry=zb();blendPart;cameraBlendGeometry=zb();shadowBlendGeometry=zb();blendSourceVersion=-1;lastShadowFrame=0;occluder;occlusionCulling=!0;gpuIndexOf;gpuToInput;dirtyCells=new Set;drawingShadow=!1;poolVersion=-1;ownMrt;velocityOutput=!1;deform;context;get maxDrawDistance(){let e=this.pool.readFlag(this.entry,"maxDrawDistance");return e>=wv?1/0:e}set maxDrawDistance(e){this.pool.writeFlags(this.entry,{maxDrawDistance:Number.isFinite(e)?Math.max(0,e):wv})}get minPixelRadius(){return this.pool.readFlag(this.entry,"minPixelRadius")}set minPixelRadius(e){this.pool.writeFlags(this.entry,{minPixelRadius:Math.max(0,e)})}get capacity(){return{meshlets:this.pool.capacity.meshlets,triangles:this.pool.capacity.triangles}}constructor(e,t,s,n,a={}){s=MQ(s);let i=zb();super(i,s),this.deform=a.deform,this.context=e,this.data=t,this.frustumCulled=!1,this.instanceCount=n.matrices.length/16,this.fullDetailTriangles=t.stats.leafTriangles*this.instanceCount,this.occluder=s.side!==rn&&!s.transparent&&s.alphaTest===0&&!s.alphaHash,this.gpuToInput=Z2(n.matrices,t.boundingSphere),this.gpuIndexOf=new Uint32Array(this.instanceCount);for(let f=0;f<this.instanceCount;f++)this.gpuIndexOf[this.gpuToInput[f]]=f;e.register(this,n),a.maxDrawDistance!==void 0&&(this.maxDrawDistance=a.maxDrawDistance),a.minPixelRadius!==void 0&&(this.minPixelRadius=a.minPixelRadius),AR(s);let o=s;this.ownMrt=o.mrtNode??null;let c=Lt(s.colorNode??ef).toVar(),l=f=>wc(Nb(f),Nb(f.add(17.17)),Nb(f.add(43.43))),h=os(e.debugMode.equal(bf.meshlets),l(kR.add(xv.mul(.618))),os(e.debugMode.equal(bf.lodLevel),l(IR.add(3)),l(xv)));s.colorNode=Lt(os(e.debugMode.equal(bf.shaded),c.xyz.mul(BR),h),c.w),s.side===rn&&!s.normalNode&&(s.normalNode=sf(Sb.mul(Lt(Ub,0)).xyz.mul(tR))),this.blendPart=new at(this.cameraBlendGeometry,s.clone()),this.blendPart.name="lod blend",Object.assign(this.blendPart,{isVirtualMeshPart:!0}),this.blendPart.frustumCulled=!1,this.add(this.blendPart),this.syncBlendPart(),this.syncPool(),this.geometry=this.cameraGeometry,i.dispose(),this.onBeforeShadow=(f,p,m,b)=>{this.lastShadowFrame=e.frameCount,e.noteShadowCamera(b),this.drawingShadow=!0,this.geometry=this.shadowGeometry};let u=this.onBeforeRender;this.onBeforeRender=(...f)=>{this.drawingShadow?this.drawingShadow=!1:this.geometry=this.cameraGeometry,u.apply(this,f)};let d=!1;this.blendPart.onBeforeShadow=()=>{d=!0,this.blendPart.geometry=this.shadowBlendGeometry},this.blendPart.onBeforeRender=()=>{d?d=!1:this.blendPart.geometry=this.cameraBlendGeometry}}syncBlendPart(){let e=this.blendPart;e.castShadow=this.castShadow,e.receiveShadow=this.receiveShadow,e.renderOrder=this.renderOrder,e.layers.mask=this.layers.mask;let t=this.material,s=e.material,n=t.version!==this.blendSourceVersion;for(let a of Object.keys(t)){if(SQ.has(a))continue;let i=t[a],o=s[a];i&&typeof i=="object"&&typeof i.copy=="function"&&typeof i.equals=="function"&&o&&o!==i&&typeof o.copy=="function"?o.equals(i)||o.copy(i):o!==i&&(s[a]=i)}(n||!s.maskNode)&&(s.maskNode=t.maskNode?eh(t.maskNode).and(TR()):TR()),n&&(this.blendSourceVersion=t.version,s.needsUpdate=!0)}syncPool(){let e=this.pool;if(this.poolVersion===e.version||!e.positionNode)return;this.poolVersion=e.version;let t=this.entry.slot,s=[[this.cameraGeometry,e.cameraIndex,0,0],[this.shadowGeometry,e.shadowIndex,1,0],[this.cameraBlendGeometry,e.cameraIndex,0,1],[this.shadowBlendGeometry,e.shadowIndex,1,1]];for(let[n,a,i,o]of s)n.setIndex(a),n.setIndirect(e.drawArgsAttribute,e.drawArgsOffset(i,t,o));this.material.positionNode=this.deform?this.deform(e.positionNode,{instanceOrigin:Lb}):e.positionNode,this.material.needsUpdate=!0,this.syncBlendPart()}setVelocityOutput(e){if(e===this.velocityOutput)return;this.velocityOutput=e;let t=this.material;t.mrtNode=e?this.ownMrt?this.ownMrt.merge(PR):PR:this.ownMrt,this.material.needsUpdate=!0,this.syncBlendPart()}markCutDirty(){this.pool.dirty=!0}setMatrixAt(e,t){let s=this.gpuIndexOf[e];this.pool.setMatrix(this.entry,s,t),this.dirtyCells.add(Math.floor(s/Db))}commitInstances(){this.pool.commitInstances(this.entry,this.dirtyCells),this.dirtyCells.clear()}dispose(e){this.visible=!1,(e??this.context).unregister(this),this.removeFromParent()}async readStats(e){let t=await this.pool.readCounters(e);return{drawnTriangles:t.perMesh(0,this.entry.slot),shadowTriangles:t.perMesh(1,this.entry.slot)}}};var eP={MeshPhysicalMaterial:[xs,ql],MeshStandardMaterial:[An,Wl],MeshPhongMaterial:[So,Od],MeshLambertMaterial:[Di,Dd],MeshBasicMaterial:[Bt,cc],MeshToonMaterial:[No,zd],MeshMatcapMaterial:[Eo,Vd],MeshNormalMaterial:[Ro,Fd]},NQ=[["isMeshPhysicalMaterial","MeshPhysicalMaterial"],["isMeshStandardMaterial","MeshStandardMaterial"],["isMeshPhongMaterial","MeshPhongMaterial"],["isMeshLambertMaterial","MeshLambertMaterial"],["isMeshBasicMaterial","MeshBasicMaterial"],["isMeshToonMaterial","MeshToonMaterial"],["isMeshMatcapMaterial","MeshMatcapMaterial"],["isMeshNormalMaterial","MeshNormalMaterial"]];function tP(r){let e=r,t=eP[r.type]?r.type:NQ.find(([s])=>e[s]===!0)?.[1];return t?eP[t]:null}function DR(r){return r.isNodeMaterial===!0||tP(r)!==null}function OR(r){if(r.isNodeMaterial)return r;let e=tP(r);if(!e)return null;let[t,s]=e,n=new s,a=n.defines;return t.prototype.copy.call(n,r),n.defines=a,n}var UR=1e-6,sP=1e-4;function LR(r,e={}){let t=r.attributes.position,s=e.uvs??!0?r.attributes.uv:void 0,n=e.colors?r.attributes.color:void 0,a=e.normals==="keep"?r.attributes.normal:void 0,i=r.index,o=i?i.count:t.count,c=Math.max(0,Math.min(o,e.range?.start??0)),l=Math.floor((Math.min(o,c+(e.range?.count??o))-c)/3)*3,h=g=>i?i.getX(c+g):c+g,u=nP(l,h,[{attribute:t,size:3,tolerance:UR}]),d=jb(u.firstVertex,t,3),f=null;if(!a){let g=new ke;g.setAttribute("position",new Xe(d,3)),g.setIndex(new Xe(u.indices,1)),g.computeVertexNormals(),f=g.attributes.normal.array}if(!s&&!n&&!a)return{positions:d,normals:f,indices:u.indices};let p=[{attribute:t,size:3,tolerance:UR}];s&&p.push({attribute:s,size:2,tolerance:UR}),a&&p.push({attribute:a,size:3,tolerance:sP}),n&&p.push({attribute:n,size:3,tolerance:sP});let m=nP(l,h,p),b={positions:jb(m.firstVertex,t,3),normals:new Float32Array(0),indices:m.indices};if(a){b.normals=jb(m.firstVertex,a,3);for(let g=0;g<b.normals.length;g+=3){let x=Math.hypot(b.normals[g],b.normals[g+1],b.normals[g+2])||1;b.normals[g]/=x,b.normals[g+1]/=x,b.normals[g+2]/=x}}else{b.normals=new Float32Array(m.firstVertex.length*3);for(let g=0;g<m.firstVertex.length;g++){let x=u.indices[m.firstCorner[g]];b.normals.set(f.subarray(x*3,x*3+3),g*3)}}return s&&(b.uvs=jb(m.firstVertex,s,2)),n&&(b.colors=jb(m.firstVertex,n,3)),b}function jb(r,e,t){let s=new Float32Array(r.length*t);for(let n=0;n<r.length;n++)for(let a=0;a<t;a++)s[n*t+a]=e.getComponent(r[n],a);return s}function nP(r,e,t){let s=t.reduce((p,m)=>p+m.size,0),n=t.map(({tolerance:p})=>{let m=Math.pow(10,Math.log10(1/p));return{multiplier:m,additive:p*.5*m}}),a=1;for(;a<r*2;)a<<=1;let i=a-1,o=new Int32Array(a).fill(-1),c=new Float64Array(r*s),l=new Float64Array(s),h=new Uint32Array(r),u=new Uint32Array(r),d=new Uint32Array(r),f=0;for(let p=0;p<r;p++){let m=e(p),b=0,g=0;for(let x=0;x<t.length;x++){let{attribute:T,size:y}=t[x],{multiplier:v,additive:_}=n[x];for(let A=0;A<y;A++,g++)l[g]=Math.trunc(T.getComponent(m,A)*v+_),b=b^Math.imul(l[g]|0,aP[g%aP.length])|0}for(b&=i;;){let x=o[b];if(x<0){o[b]=f,c.set(l,f*s),h[f]=m,u[f]=p,d[p]=f++;break}let T=!0;for(let y=0;y<s&&T;y++)T=c[x*s+y]===l[y];if(T){d[p]=x;break}b=b+1&i}}return{indices:d,firstVertex:h.slice(0,f),firstCorner:u.slice(0,f)}}var aP=[73856093,19349663,83492791,2654435761,2246822519,3266489917,668265263,374761393,1181783497,3735928559,2028178513];function RQ(r){let e=r.reduce((u,d)=>u+d.mesh.positions.length/3,0),t=r.reduce((u,d)=>u+d.mesh.indices.length,0),s=new Float32Array(e*3),n=new Float32Array(e*3),a=new Float32Array(e*3),i=r.some(u=>u.mesh.uvs)?new Float32Array(e*2):null,o=new Uint32Array(t),c=new be,l=0,h=0;for(let{mesh:u,color:d=16777215}of r){let f=u.positions.length/3;if(s.set(u.positions,l*3),n.set(u.normals,l*3),i&&u.uvs&&i.set(u.uvs,l*2),u.colors)a.set(u.colors,l*3);else{c.set(d);for(let p=0;p<f;p++)a.set([c.r,c.g,c.b],(l+p)*3)}for(let p=0;p<u.indices.length;p++)o[h+p]=u.indices[p]+l;l+=f,h+=u.indices.length}return i?{positions:s,normals:n,colors:a,uvs:i,indices:o}:{positions:s,normals:n,colors:a,indices:o}}var EQ=Lv,Tv=new WeakSet;function CQ(r){let e=r;if(!e.isMesh)return"not a mesh";if(e.isVirtualMesh||e.isVirtualMeshPart)return"already a VirtualMesh";if(e.isSkinnedMesh)return"skinned";if(e.isBatchedMesh)return"batched";let t=e.geometry;if(!t?.attributes?.position||t.isInstancedBufferGeometry)return"unsupported geometry";let s=t.morphAttributes;return(s.position?.length??0)>0||(s.normal?.length??0)>0||(e.morphTargetInfluences?.length??0)>0?"morph targets":(Array.isArray(e.material)?e.material:[e.material]).some(a=>!a||!DR(a))?"material without a node equivalent":null}function iP(r,e){r.updateWorldMatrix(!0,!0);let t=new Map,s=[],n=[],a=new le,i=new le,o=new be;r.traverse(l=>{if(!l.isMesh||Tv.has(l))return;let h=l,u=CQ(h)??(e&&!e(h)?"filtered out":null);if(u){n.push({object:h,reason:u});return}let d=h.geometry,f=Array.isArray(h.material)?h.material:[h.material],p=kQ(d,Array.isArray(h.material));if(p.length===0)return;s.push(h);let m=h.isInstancedMesh?h:null,b=m?m.count:1,g=IQ(h);for(let{start:x,count:T,materialIndex:y}of p){let v=f[y];if(!v)continue;let _=v.vertexColors===!0&&d.attributes.color!==void 0,A=[d.id,x,T,v.uuid,h.castShadow,h.receiveShadow,g,h.renderOrder,h.layers.mask].join(":"),M=t.get(A);M||(M={geometry:d,range:{start:x,count:T},material:v,matrices:new Float32Array(0),colors:null,instances:[],vertexColors:_,castShadow:h.castShadow,receiveShadow:h.receiveShadow,visible:g,renderOrder:h.renderOrder,layers:h.layers.mask,name:h.name,userData:{...h.userData},matrixList:[],colorList:null},t.set(A,M));for(let N=0;N<b;N++){m?(m.getMatrixAt(N,a),i.multiplyMatrices(h.matrixWorld,a)):i.copy(h.matrixWorld),M.matrixList.push(...i.elements);let R=!!m?.instanceColor;R&&m.getColorAt(N,o),R&&!M.colorList&&(M.colorList=new Array(M.instances.length*4).fill(1)),M.colorList&&(R?M.colorList.push(o.r,o.g,o.b,1):M.colorList.push(1,1,1,1)),M.instances.push({object:h,index:m?N:-1})}}});let c=[];for(let{matrixList:l,colorList:h,...u}of t.values())u.matrices=Float32Array.from(l),u.colors=h?Float32Array.from(h):null,c.push(u);return{groups:c,meshes:s,skipped:n}}function kQ(r,e){let t=r.index?r.index.count:r.attributes.position.count,s=Math.max(0,r.drawRange.start),n=Math.min(t,s+r.drawRange.count),a=e?r.groups:[{start:0,count:t,materialIndex:0}],i=[];for(let o of a){let c=Math.max(o.start,s),l=Math.min(o.start+o.count,n);l-c>=3&&i.push({start:c,count:l-c,materialIndex:o.materialIndex??0})}return i}function IQ(r){for(let e=r;e;e=e.parent)if(!e.visible)return!1;return!0}var vv=class{constructor(e,t){this.context=e;this.object.name="VirtualGeometryImport",this.groups=t.groups,this.skipped=t.skipped,this.stats.sourceMeshes=t.meshes.length,this.stats.instances=t.groups.reduce((s,n)=>s+n.instances.length,0)}context;object=new qs;meshes=[];groups;skipped;stats={sourceMeshes:0,instances:0,uniqueGeometries:0,buildMs:0};hidden=new Map;detached=new Map;hide(e,t){let s=new Set;for(let n of e){if(Tv.add(n),n.children.length===0&&n.parent){this.detached.set(n,n.parent),s.add(n.parent),n.parent.remove(n);continue}this.hidden.has(n)||this.hidden.set(n,n.layers.mask),n.layers.disableAll()}for(let n of s)for(;n!==t&&n.children.length===0&&n.parent&&(n.type==="Group"||n.type==="Object3D");){let a=n.parent;this.detached.set(n,a),a.remove(n),n=a}}worldMatrixOf(e){let t=this.detached.get(e);return t?(e.updateMatrix(),e.matrixWorld.multiplyMatrices(this.worldMatrixOf(t),e.matrix)):(e.updateWorldMatrix(!0,!1),e.matrixWorld)}syncTransforms(){let e=new le,t=new le,s=new Set;this.groups.forEach((n,a)=>{let i=this.meshes[a];n.instances.forEach(({object:o,index:c},l)=>{s.has(o)||(this.worldMatrixOf(o),s.add(o)),c>=0?(o.getMatrixAt(c,t),e.multiplyMatrices(o.matrixWorld,t)):e.copy(o.matrixWorld),i.setMatrixAt(l,e)}),i.commitInstances()})}dispose(){for(let e of this.meshes)e.dispose(this.context),e.material.dispose(),e.geometry.dispose();this.meshes.length=0;for(let[e,t]of this.hidden)e.layers.mask=t,Tv.delete(e);this.hidden.clear();for(let[e,t]of this.detached)t.add(e),Tv.delete(e);this.detached.clear(),this.object.removeFromParent()}};async function zR(r,e,t={}){let s=performance.now(),n=t.builder??EQ,a=iP(e,t.filter),i=new vv(r,a),o=new Map,c=p=>`${p.geometry.id}:${p.range.start}:${p.range.count}:${p.vertexColors}`;for(let p of i.groups){let m=c(p);o.has(m)||o.set(m,{group:p,triangles:p.range.count/3})}i.stats.uniqueGeometries=o.size;let l=[...o.values()].reduce((p,m)=>p+m.triangles,0)||1,h=0;for(let p of o.values()){let{geometry:m,range:b,vertexColors:g}=p.group,x=LR(m,{range:b,colors:g,normals:m.attributes.normal?"keep":"compute"});p.data=await n(x,{...t.build,onProgress:T=>t.onProgress?.((h+T*p.triangles)/l)}),h+=p.triangles}let u=new Map,d=[],f=new Set;for(let p of i.groups){let m=BQ(p,t,u);if(!m){for(let{object:x}of p.instances)f.add(x);continue}let b=typeof t.mesh=="function"?t.mesh(p):t.mesh,g=r.createMesh(o.get(c(p)).data,m,{matrices:p.matrices,colors:p.colors??void 0},b);g.matrixAutoUpdate=!1,g.matrixWorldAutoUpdate=!1,g.name=p.name,g.userData={...p.userData},g.castShadow=p.castShadow,g.receiveShadow=p.receiveShadow,g.visible=p.visible,g.renderOrder=p.renderOrder,g.layers.mask=p.layers,i.meshes.push(g),d.push(p),i.object.add(g)}return i.groups=d,(t.replace??!0)&&(i.hide(a.meshes.filter(p=>!f.has(p)),e),e.add(i.object)),await t.onProgress?.(1),i.stats.buildMs=performance.now()-s,i}function BQ(r,e,t){let s=r.material,n=!!(s.normalMap&&r.geometry.attributes.tangent&&s.normalMap.flipY===!1),a=`${s.uuid}:${n}`;if(t.has(a))return t.get(a);let i;if(e.material?i=e.material(s,r):(i=OR(s),i===s&&(i=s.clone())),i&&n){let o=i.normalScale;o&&(i.normalScale=o.clone().setY(-o.y))}return t.set(a,i),i}var VR=16,rP=VR*4+4,oP=VR*4,cP=64,FQ=[],lP=r=>r.reduce((e,t)=>e+t,0)/r.length,Gb=tf,ho=Xn,_v=class{enabled=!0;auto=!0;autoProbeFrames=40;autoHoldFrames=900;autoChoice=!1;phase="hold";phaseFrames=this.autoHoldFrames-120;samples=[];offMean=0;lastTick=0;resolutionScale=.5;maxSize;active=!1;activeNode=kt(0,"uint");depthScene=new ii;proxies=new Map;projection;near;levelCapacity;levelOffsets=[];hzbAttribute;hzbWrite;hzbRead;buildNodes=[];renderTarget=null;width=0;height=0;levels=0;bufferSize=new q;constructor(e,t,s=1024){this.maxSize=Math.max(1,Math.min(1<<VR-1,s)),this.projection=e,this.near=t;let n=this.maxSize,a=rP,i=0;for(;this.levelOffsets.push(a),a+=n*n,i++,n!==1;)n=Math.ceil(n/2);this.levelCapacity=i,this.hzbAttribute=new mn(new Float32Array(a),1),this.hzbWrite=Rs(this.hzbAttribute,"float",a),this.hzbRead=Rs(this.hzbAttribute,"float",a).toReadOnly()}occluded(e,t){let s=this.projection,n=e.z.negate(),a=n.sub(t).toVar(),i=n.add(t),o=e.x.sub(t),c=e.x.add(t),l=e.y.sub(t),h=e.y.add(t),u=s.element(0).x,d=s.element(1).y,f=Gb(o.div(a),o.div(i)).mul(u).sub(s.element(2).x),p=ho(c.div(a),c.div(i)).mul(u).sub(s.element(2).x),m=Gb(l.div(a),l.div(i)).mul(d).sub(s.element(2).y),b=ho(h.div(a),h.div(i)).mul(d).sub(s.element(2).y),g=s.element(3).z.div(a).sub(s.element(2).z),x=a.lessThanEqual(this.near),T=this.hzbRead,y=T.element(1),v=T.element(2),_=ht(0),A=yc(br(f.mul(.5).add(.5).mul(y)),_,y.sub(1)),M=yc(br(p.mul(.5).add(.5).mul(y)),_,y.sub(1)),N=yc(br(ht(.5).sub(b.mul(.5)).mul(v)),_,v.sub(1)),R=yc(br(ht(.5).sub(m.mul(.5)).mul(v)),_,v.sub(1)),I=ho(M.sub(A),R.sub(N)).add(1),D=Gb(QN(aR(I)),T.element(oP).sub(1)),O=de(D).mul(4),P=eR(D),U=T.element(O),j=T.element(O.add(1)),z=T.element(O.add(2)),H=(ee,se)=>{let _e=yc(br(ee.div(P)),_,j.sub(1)),Ae=yc(br(se.div(P)),_,z.sub(1));return T.element(de(U.add(Ae.mul(j)).add(_e)))},J=ho(ho(H(A,N),H(M,N)),ho(H(A,R),H(M,R)));return x.not().and(g.lessThan(1)).and(g.greaterThan(J.add(1e-6)))}tick(e){let t=this.lastTick?e-this.lastTick:0;this.lastTick=e,!(!this.auto||!this.enabled)&&(this.phaseFrames++,this.phase!=="hold"&&this.phaseFrames>5&&t>0&&t<250&&this.samples.push(t),this.phase==="probeOff"&&this.samples.length>=this.autoProbeFrames?(this.offMean=lP(this.samples),this.next("probeOn")):this.phase==="probeOn"&&this.samples.length>=this.autoProbeFrames?(this.autoChoice=lP(this.samples)<this.offMean*.97,this.next("hold")):this.phase==="hold"&&this.phaseFrames>=this.autoHoldFrames&&this.next("probeOff"))}next(e){this.phase=e,this.phaseFrames=0,this.samples=[]}autoWanted(){return this.phase==="probeOn"||this.phase==="hold"&&this.autoChoice}proxyOf(e){let t=this.proxies.get(e);t||(t=new at(e.cameraGeometry,new cc({colorWrite:!1})),t.frustumCulled=!1,this.depthScene.add(t),this.proxies.set(e,t));let s=t.material;return s.positionNode!==e.pool.positionNode&&(s.positionNode=e.pool.positionNode,s.needsUpdate=!0),t}unregisterMesh(e){let t=this.proxies.get(e);t&&(this.proxies.delete(e),t.removeFromParent(),t.material.dispose())}wantsFrame(e,t,s){let n=e,a=t.isPerspectiveCamera&&!n.reversedDepthBuffer&&!n.logarithmicDepthBuffer;return this.enabled&&a&&(!this.auto||this.autoWanted())}beginFrame(e,t,s){let n=!1;for(let h of s){let u=h.visible&&h.occluder&&h.pool.hasCut&&!!h.pool.positionNode;if(!u&&!this.proxies.has(h))continue;let d=this.proxyOf(h);d.visible=u,n=n||u}if(this.active=n,this.activeNode.value=n?1:0,!n)return FQ;e.getDrawingBufferSize(this.bufferSize);let a=Math.min(this.resolutionScale,this.maxSize/Math.max(this.bufferSize.x,this.bufferSize.y)),i=Math.max(1,Math.round(this.bufferSize.x*a)),o=Math.max(1,Math.round(this.bufferSize.y*a));(i!==this.width||o!==this.height)&&this.resize(i,o);let c=e.getRenderTarget(),l=e.getMRT();return e.setMRT(null),e.setRenderTarget(this.renderTarget),e.render(this.depthScene,t),e.setRenderTarget(c),e.setMRT(l),this.buildNodes}resize(e,t){let s=this.buildNodes;this.renderTarget?.dispose();let n=new Ds(e,t);n.type=Mt,this.renderTarget=new Ps(e,t,{depthBuffer:!0,depthTexture:n}),this.width=e,this.height=t;let a=this.hzbAttribute.array;a.fill(0,0,rP);let i=e,o=t,c=0;for(let d=0;d<this.levelCapacity&&(a[d*4]=this.levelOffsets[d],a[d*4+1]=i,a[d*4+2]=o,c++,!(i===1&&o===1));d++)i=Math.max(1,Math.ceil(i/2)),o=Math.max(1,Math.ceil(o/2));this.levels=c,a[oP]=c,this.hzbAttribute.needsUpdate=!0;let l=Cb(n),h=this.hzbWrite,u=Zs(()=>{let d=xc,f=de(h.element(1)),p=de(h.element(2));Tt(d.greaterThanEqual(f.mul(p)),()=>{xa()});let m=d.mod(f),b=d.div(f),g=de(h.element(0)).toVar();h.element(g.add(d)).assign(l.load(sR(lv(m),lv(b))))})().compute(e*t,[cP]);this.buildNodes=[u],i=e,o=t;for(let d=1;d<c;d++)i=Math.max(1,Math.ceil(i/2)),o=Math.max(1,Math.ceil(o/2)),this.buildNodes.push(Zs(()=>{let f=xc,p=de(h.element(d*4)).toVar(),m=de(h.element(d*4+1)),b=de(h.element(d*4+2));Tt(f.greaterThanEqual(m.mul(b)),()=>{xa()});let g=f.mod(m),x=f.div(m),T=de(h.element((d-1)*4)).toVar(),y=de(h.element((d-1)*4+1)),v=de(h.element((d-1)*4+2)),_=g.mul(2),A=x.mul(2),M=Gb(_.add(1),y.sub(1)),N=Gb(A.add(1),v.sub(1)),R=T.add(A.mul(y)),I=T.add(N.mul(y)),D=ho(ho(h.element(R.add(_)),h.element(R.add(M))),ho(h.element(I.add(_)),h.element(I.add(M))));h.element(p.add(f)).assign(D)})().compute(i*o,[cP]));for(let d of s)d.dispose()}dispose(){this.renderTarget?.dispose(),this.renderTarget=null;for(let e of[...this.proxies.keys()])this.unregisterMesh(e)}};var jR=45,PQ=1.03,DQ=1.01,OQ=new E,UQ=(r,e)=>r*Math.pow(e/.82,.25),GR=class{viewMatrix=kt(new le);projectionMatrix=kt(new le);projScale=kt(1);near=kt(.1);errorThreshold=kt(1);lodBlend=2;lodBlendTemporal=!1;lodBlendMax=kt(2);lodScaleLimit=kt(64);triangleBudget=0;thresholdRange=[.5,3];maxErrorThreshold=64;lastStats=null;statsInterval=10;frameCount=0;outOfBand=0;thresholdTarget=null;thresholdWritten=NaN;statsThreshold=1;statsPending=!1;frustumCulling=kt(1,"uint");debugMode=kt(0,"uint");minPixelRadius=kt(.7);frustumPlanes=Array.from({length:6},()=>kt(new Ge));shadowSweep=kt(new E);autoShadowSweep=!0;shadowErrorScale=kt(3);detectedSweep=new E;detectedSweepFrame=-1/0;occlusion=new _v(this.projectionMatrix,this.near);freeze=!1;autoUpdate=!0;errorInCssPixels=!0;meshes=[];pools=[];capacity;maxPoolBytes;constructor(e={}){this.capacity={triangles:e.maxTriangles??1e7,shadowTriangles:e.maxShadowTriangles??4e6,meshlets:Math.min(e.maxMeshlets??1<<20,1<<24)},this.maxPoolBytes=e.maxPoolBytes??120*1024*1024}frustum=new ci;projScreen=new le;size=new q;computeList=[];dispatchedPools=[];skippedFrames=0;cutInputs=new Float64Array(jR).fill(NaN);cutInputsScratch=new Float64Array(jR);sceneHooks=new WeakMap;autoCall=-1;autoCamera=null;manualCall=-1;manualCamera=null;updatingAuto=!1;add(e,t){return zR(this,e,t)}createMesh(e,t,s,n){return new Vb(this,e,t,s,n)}asyncCompile=!0;compilePool(e,t){t.pipelineState="compiling";let s=t.version,n=()=>{t.version===s&&(t.pipelineState="ready",t.dirty=!0)};e.compileComputeAsync(t.computeNodes).then(n,n)}preparePools(e){this.checkDeviceLimits(e);for(let t of this.pools)t.disabled||t.prepare(e);for(let t of this.meshes)t.syncPool()}checkedPools=new WeakSet;checkDeviceLimits(e){let t=e.backend.device;if(!t)return;let s=Math.min(t.limits.maxStorageBufferBindingSize,t.limits.maxBufferSize);for(let n of this.pools){if(this.checkedPools.has(n)||(this.checkedPools.add(n),n.maxBytes<=s))continue;n.disabled=!0;let a=this.meshes.filter(o=>o.pool===n);for(let o of a)o.visible=!1;let i=o=>`${Math.round(o/2**20)} MB`;console.error(`three-virtual-geometry: ${a.map(o=>`"${o.name||"mesh"}"`).join(", ")} needs ${i(n.maxBytes)} in a single GPU buffer, but this device allows ${i(s)}, so it is not drawn. Create the renderer with new WebGPURenderer({ requiredLimits: await virtualGeometryLimits() }) to use the GPU's full limits, or use a lighter version of the mesh.`)}}async compileAsync(e,t,s){this.preparePools(e);let n=this.pools.filter(a=>!a.disabled&&a.pipelineState!=="ready");for(let a of n)a.pipelineState="compiling";await Promise.all(n.map(a=>e.compileComputeAsync(a.computeNodes).catch(()=>{})));for(let a of n)a.pipelineState="ready",a.dirty=!0;await e.compileAsync(t,s)}noteShadowCamera(e){if(this.detectedSweepFrame===this.frameCount)return;let t=e;if(!t.isOrthographicCamera)return;let s=Math.max(t.top-t.bottom,t.right-t.left)/t.zoom;e.getWorldDirection(this.detectedSweep).multiplyScalar(s),this.detectedSweepFrame=this.frameCount}register(e,t){let s=t.matrices.length/16,n=Ob.bytesOf(e.data),a=n>this.maxPoolBytes,i=a?void 0:this.pools.find(o=>!o.dedicated&&o.fits(e.data,s));i||(i=new Ob(this,this.capacity,a?Math.ceil(n*1.01):this.maxPoolBytes),i.dedicated=a,this.pools.push(i)),e.pool=i,e.entry=i.add(e.data,t.matrices,t.colors,e.gpuToInput),i.ensureBuilt(),this.meshes.push(e),e.onBeforeRender=(o,c,l)=>this.autoUpdateFor(o,c,l,!1)}autoUpdateFor(e,t,s,n){if(!this.autoUpdate||this.meshes.length===0||t.overrideMaterial&&t.overrideMaterial.isShadowPassMaterial)return;if(!n&&t.isScene){if(t.onBeforeRender===this.sceneHooks.get(t))return;let i=t.onBeforeRender,o=this,c=function(l,h,u,...d){o.autoUpdateFor(l,h,u,!0),i.call(this,l,h,u,...d)};t.onBeforeRender=c,this.sceneHooks.set(t,c)}let a=e.info.render.calls;if(!(s===this.autoCamera&&a===this.autoCall)&&!(s===this.manualCamera&&a===this.manualCall+1)){this.autoCall=a,this.autoCamera=s,this.updatingAuto=!0;try{this.update(e,s)}finally{this.updatingAuto=!1}}}unregister(e){let t=this.meshes.indexOf(e);t!==-1&&(this.meshes.splice(t,1),e.pool.remove(e.entry),this.occlusion.unregisterMesh(e))}dispose(){for(let e of[...this.meshes])e.dispose(this);for(let e of this.pools)e.dispose();this.pools.length=0,this.occlusion.dispose()}update(e,t){if(this.updatingAuto||(this.manualCall=e.info.render.calls,this.manualCamera=t),this.freeze)return;this.occlusion.tick(performance.now()),this.stepThreshold();let s=Math.max(1,this.lodBlend);this.lodBlendMax.value!==s&&(this.lodBlendMax.value=s);let n=this.lodBlendTemporal?this.frameCount%64:0;fv.value!==n&&(fv.value=n);let a=Math.max(1,this.maxErrorThreshold/this.errorThreshold.value);this.lodScaleLimit.value!==a&&(this.lodScaleLimit.value=a);let i=!!e.getMRT()?.outputNodes?.velocity;for(let p of this.meshes)p.setVelocityOutput(i),p.syncBlendPart();t.updateMatrixWorld(),this.viewMatrix.value.copy(t.matrixWorldInverse);let o=kb.projectionMatrix??t.projectionMatrix;this.projectionMatrix.value.equals(o)||this.projectionMatrix.value.copy(o),e.getDrawingBufferSize(this.size);let c=this.size.y/(this.errorInCssPixels?e.getPixelRatio():1),l=o.elements[5]*c*.5;this.projScale.value!==l&&(this.projScale.value=l),this.near.value!==t.near&&(this.near.value=t.near),this.projScreen.multiplyMatrices(o,t.matrixWorldInverse),this.frustum.setFromProjectionMatrix(this.projScreen,Xs);for(let p=0;p<6;p++){let{normal:m,constant:b}=this.frustum.planes[p],g=this.frustumPlanes[p].value;(g.x!==m.x||g.y!==m.y||g.z!==m.z||g.w!==b)&&g.set(m.x,m.y,m.z,b)}if(this.autoShadowSweep){let p=this.frameCount-this.detectedSweepFrame<=2?this.detectedSweep:OQ;this.shadowSweep.value.equals(p)||this.shadowSweep.value.copy(p)}let h=this.occlusion.wantsFrame(e,t,this.frameCount);for(let p of this.meshes)p.pool.writeFlags(p.entry,{enabled:p.visible?1:0,shadow:p.castShadow&&this.frameCount-p.lastShadowFrame<=2?1:0,occlusion:h&&p.occlusionCulling?1:0});if(this.cutInputsChanged(t,o,e.getPixelRatio()))for(let p of this.pools)p.dirty=!0;for(let p of this.pools)p.controllerActive&&(p.dirty=!0);this.preparePools(e);let u=this.computeList;u.length=0;let d=this.dispatchedPools;d.length=0;for(let p of this.pools)if(!(p.disabled||!p.dirty||p.entries.length===0)){if(p.pipelineState!=="ready"){if(this.asyncCompile){p.pipelineState==="none"&&this.compilePool(e,p);continue}p.pipelineState="ready"}for(let m of p.computeNodes)u.push(m);d.push(p)}if(u.length>0){let p=h?this.occlusion.beginFrame(e,t,this.meshes):[];p.length&&u.unshift(...p),e.compute(u);for(let m of d)m.dirty=!1,m.hasCut=!0}else this.skippedFrames++;this.frameCount++;let f=this.thresholdTarget!==null?Math.min(2,this.statsInterval):this.statsInterval;this.meshes.length>0&&!this.statsPending&&this.frameCount%f===0&&(this.statsPending=!0,this.statsThreshold=this.errorThreshold.value,this.readStats(e).then(p=>{this.lastStats=p,this.triangleBudget>0&&this.adaptThreshold(p)}).finally(()=>this.statsPending=!1))}cutInputsChanged(e,t,s){let n=this.cutInputsScratch,a=0;for(let o=0;o<16;o++)n[a++]=e.matrixWorldInverse.elements[o];for(let o=0;o<16;o++)n[a++]=t.elements[o];n[a++]=e.near,n[a++]=this.size.x,n[a++]=this.size.y,n[a++]=s,n[a++]=this.errorInCssPixels?1:0,n[a++]=this.errorThreshold.value,n[a++]=this.lodBlend,n[a++]=this.minPixelRadius.value,n[a++]=this.frustumCulling.value,n[a++]=this.debugMode.value;let i=this.shadowSweep.value;n[a++]=i.x,n[a++]=i.y,n[a++]=i.z;for(let o=0;o<jR;o++)if(n[o]!==this.cutInputs[o])return this.cutInputs.set(n),!0;return!1}adaptThreshold(e){let t=this.statsThreshold,s=this.errorThreshold.value,n=e.capacityUse;if(this.thresholdTarget!==null&&this.thresholdTarget<s&&n>=.75&&(this.thresholdTarget=null),e.drawnTriangles<=0)return;let a=e.drawnTriangles/this.triangleBudget;if(Math.abs(a-1)<.15){this.outOfBand=0;return}if(++this.outOfBand<2)return;let[i,o]=this.thresholdRange,c=Math.min(o,Math.max(i,t*Math.sqrt(a)));c<t&&(c=Math.max(c,UQ(t,n))),this.glideTo(c)}glideTo(e){this.thresholdTarget=e===this.errorThreshold.value?null:e}stepThreshold(){let e=this.errorThreshold.value;e!==this.thresholdWritten&&!Number.isNaN(this.thresholdWritten)&&(this.thresholdTarget=null);let t=this.thresholdTarget;if(t!==null){let s=t>e?Math.min(t,e*PQ):Math.max(t,e/DQ);this.errorThreshold.value=s,s===t&&(this.thresholdTarget=null)}this.thresholdWritten=this.errorThreshold.value}async readStats(e){let t={drawnMeshlets:0,drawnTriangles:0,fullDetailTriangles:0,instances:0,visibleInstances:0,requestedTriangles:0,overflow:!1,capacityUse:0,occludedInstances:0,shadowTriangles:0,thresholdScale:1};for(let s of this.meshes)s.visible&&(t.fullDetailTriangles+=s.fullDetailTriangles,t.instances+=s.instanceCount);for(let s of this.pools){if(!s.hasCut)continue;let n=await s.readCounters(e),a=s.capacity;t.drawnMeshlets+=n.camera.drawn,t.drawnTriangles+=Math.min(n.camera.requestedTriangles,a.triangles),t.requestedTriangles+=n.camera.requestedTriangles,t.visibleInstances+=n.camera.survived,t.occludedInstances+=n.occluded,t.shadowTriangles+=Math.min(n.shadow.requestedTriangles,a.shadowTriangles),t.thresholdScale=Math.max(t.thresholdScale,n.scale[0]),(n.camera.selected>a.meshlets||n.camera.requestedTriangles>a.triangles)&&(t.overflow=!0),(n.shadow.selected>a.meshlets||n.shadow.requestedTriangles>a.shadowTriangles)&&(t.overflow=!0),t.capacityUse=Math.max(t.capacityUse,n.camera.requestedTriangles/a.triangles,n.camera.selected/a.meshlets,n.shadow.requestedTriangles/a.shadowTriangles,n.shadow.selected/a.meshlets)}return t}};async function LQ(r={}){let e=typeof navigator<"u"?navigator.gpu:void 0,t=e?await e.requestAdapter({powerPreference:r.powerPreference}).catch(()=>null):null;return t?{maxStorageBufferBindingSize:t.limits.maxStorageBufferBindingSize,maxBufferSize:t.limits.maxBufferSize}:{}}function HR(r,e){if(e===bx)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),r;if(e===pl||e===ed){let t=r.getIndex();if(t===null){let a=[],i=r.getAttribute("position");if(i!==void 0){for(let o=0;o<i.count;o++)a.push(o);r.setIndex(a),t=r.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),r}let s=t.count-2,n=[];if(e===pl)for(let a=1;a<=s;a++)n.push(t.getX(0)),n.push(t.getX(a)),n.push(t.getX(a+1));else for(let a=0;a<s;a++)a%2===0?(n.push(t.getX(a)),n.push(t.getX(a+1)),n.push(t.getX(a+2))):(n.push(t.getX(a+2)),n.push(t.getX(a+1)),n.push(t.getX(a)));return n.length/3!==s&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles."),r.setIndex(n),r.clearGroups(),r}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),r}function hP(r){let e=new Map,t=new Map,s=r.clone();return uP(r,s,function(n,a){e.set(a,n),t.set(n,a)}),s.traverse(function(n){if(!n.isSkinnedMesh)return;let a=n,i=e.get(n),o=i.skeleton.bones;a.skeleton=i.skeleton.clone(),a.bindMatrix.copy(i.bindMatrix),a.skeleton.bones=o.map(function(c){return t.get(c)}),a.bind(a.skeleton,a.bindMatrix)}),s}function uP(r,e,t){t(r,e);for(let s=0;s<r.children.length;s++)uP(r.children[s],e.children[s],t)}var KR=class extends us{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new ZR(t)}),this.register(function(t){return new QR(t)}),this.register(function(t){return new cE(t)}),this.register(function(t){return new lE(t)}),this.register(function(t){return new hE(t)}),this.register(function(t){return new tE(t)}),this.register(function(t){return new sE(t)}),this.register(function(t){return new nE(t)}),this.register(function(t){return new aE(t)}),this.register(function(t){return new YR(t)}),this.register(function(t){return new iE(t)}),this.register(function(t){return new eE(t)}),this.register(function(t){return new oE(t)}),this.register(function(t){return new rE(t)}),this.register(function(t){return new JR(t)}),this.register(function(t){return new Av(t,nt.EXT_MESHOPT_COMPRESSION)}),this.register(function(t){return new Av(t,nt.KHR_MESHOPT_COMPRESSION)}),this.register(function(t){return new uE(t)})}load(e,t,s,n){let a=this,i;if(this.resourcePath!=="")i=this.resourcePath;else if(this.path!==""){let l=Ea.extractUrlBase(e);i=Ea.resolveURL(l,this.path)}else i=Ea.extractUrlBase(e);this.manager.itemStart(e);let o=function(l){n?n(l):console.error(l),a.manager.itemError(e),a.manager.itemEnd(e)},c=new an(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(e,function(l){try{a.parse(l,i,function(h){t(h),a.manager.itemEnd(e)},o)}catch(h){o(h)}},s,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,s,n){let a,i={},o={},c=new TextDecoder;if(typeof e=="string")a=JSON.parse(e);else if(e instanceof ArrayBuffer)if(c.decode(new Uint8Array(e,0,4))===bP){try{i[nt.KHR_BINARY_GLTF]=new dE(e)}catch(u){n&&n(u);return}a=JSON.parse(i[nt.KHR_BINARY_GLTF].content)}else a=JSON.parse(c.decode(e));else a=e;if(a.asset===void 0||a.asset.version[0]<2){n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}let l=new xE(a,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let h=0;h<this.pluginCallbacks.length;h++){let u=this.pluginCallbacks[h](l);u.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),o[u.name]=u,i[u.name]=!0}if(a.extensionsUsed)for(let h=0;h<a.extensionsUsed.length;++h){let u=a.extensionsUsed[h],d=a.extensionsRequired||[];switch(u){case nt.KHR_MATERIALS_UNLIT:i[u]=new $R;break;case nt.KHR_DRACO_MESH_COMPRESSION:i[u]=new fE(a,this.dracoLoader);break;case nt.KHR_TEXTURE_TRANSFORM:i[u]=new pE;break;case nt.KHR_MESH_QUANTIZATION:i[u]=new mE;break;default:d.indexOf(u)>=0&&o[u]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}l.setExtensions(i),l.setPlugins(o),l.parse(s,n)}parseAsync(e,t){let s=this;return new Promise(function(n,a){s.parse(e,t,n,a)})}};function zQ(){let r={};return{get:function(e){return r[e]},add:function(e,t){r[e]=t},remove:function(e){delete r[e]},removeAll:function(){r={}}}}function cs(r,e,t){let s=r.json.materials[e];return s.extensions&&s.extensions[t]?s.extensions[t]:null}var nt={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",KHR_MESHOPT_COMPRESSION:"KHR_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"},JR=class{constructor(e){this.parser=e,this.name=nt.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let s=0,n=t.length;s<n;s++){let a=t[s];a.extensions&&a.extensions[this.name]&&a.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,a.extensions[this.name].light)}}_loadLight(e){let t=this.parser,s="light:"+e,n=t.cache.get(s);if(n)return n;let a=t.json,c=((a.extensions&&a.extensions[this.name]||{}).lights||[])[e],l,h=new be(16777215);c.color!==void 0&&h.setRGB(c.color[0],c.color[1],c.color[2],nn);let u=c.range!==void 0?c.range:0;switch(c.type){case"directional":l=new Fr(h),l.target.position.set(0,0,-1),l.add(l.target);break;case"point":l=new di(h),l.distance=u;break;case"spot":l=new ui(h),l.distance=u,c.spot=c.spot||{},c.spot.innerConeAngle=c.spot.innerConeAngle!==void 0?c.spot.innerConeAngle:0,c.spot.outerConeAngle=c.spot.outerConeAngle!==void 0?c.spot.outerConeAngle:Math.PI/4,l.angle=c.spot.outerConeAngle,l.penumbra=1-c.spot.innerConeAngle/c.spot.outerConeAngle,l.target.position.set(0,0,-1),l.add(l.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+c.type)}return l.position.set(0,0,0),yr(l,c),c.intensity!==void 0&&(l.intensity=c.intensity),l.name=t.createUniqueName(c.name||"light_"+e),n=Promise.resolve(l),t.cache.add(s,n),n}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){let t=this,s=this.parser,a=s.json.nodes[e],o=(a.extensions&&a.extensions[this.name]||{}).light;return o===void 0?null:this._loadLight(o).then(function(c){return s._getNodeRef(t.cache,o,c)})}},$R=class{constructor(){this.name=nt.KHR_MATERIALS_UNLIT}getMaterialType(){return Bt}extendParams(e,t,s){let n=[];e.color=new be(1,1,1),e.opacity=1;let a=t.pbrMetallicRoughness;if(a){if(Array.isArray(a.baseColorFactor)){let i=a.baseColorFactor;e.color.setRGB(i[0],i[1],i[2],nn),e.opacity=i[3]}a.baseColorTexture!==void 0&&n.push(s.assignTexture(e,"map",a.baseColorTexture,Wt))}return Promise.all(n)}},YR=class{constructor(e){this.parser=e,this.name=nt.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let s=cs(this.parser,e,this.name);return s===null||s.emissiveStrength!==void 0&&(t.emissiveIntensity=s.emissiveStrength),Promise.resolve()}},ZR=class{constructor(e){this.parser=e,this.name=nt.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return cs(this.parser,e,this.name)!==null?xs:null}extendMaterialParams(e,t){let s=cs(this.parser,e,this.name);if(s===null)return Promise.resolve();let n=[];if(s.clearcoatFactor!==void 0&&(t.clearcoat=s.clearcoatFactor),s.clearcoatTexture!==void 0&&n.push(this.parser.assignTexture(t,"clearcoatMap",s.clearcoatTexture)),s.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=s.clearcoatRoughnessFactor),s.clearcoatRoughnessTexture!==void 0&&n.push(this.parser.assignTexture(t,"clearcoatRoughnessMap",s.clearcoatRoughnessTexture)),s.clearcoatNormalTexture!==void 0&&(n.push(this.parser.assignTexture(t,"clearcoatNormalMap",s.clearcoatNormalTexture)),s.clearcoatNormalTexture.scale!==void 0)){let a=s.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new q(a,a)}return Promise.all(n)}},QR=class{constructor(e){this.parser=e,this.name=nt.KHR_MATERIALS_DISPERSION}getMaterialType(e){return cs(this.parser,e,this.name)!==null?xs:null}extendMaterialParams(e,t){let s=cs(this.parser,e,this.name);return s===null||(t.dispersion=s.dispersion!==void 0?s.dispersion:0),Promise.resolve()}},eE=class{constructor(e){this.parser=e,this.name=nt.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return cs(this.parser,e,this.name)!==null?xs:null}extendMaterialParams(e,t){let s=cs(this.parser,e,this.name);if(s===null)return Promise.resolve();let n=[];return s.iridescenceFactor!==void 0&&(t.iridescence=s.iridescenceFactor),s.iridescenceTexture!==void 0&&n.push(this.parser.assignTexture(t,"iridescenceMap",s.iridescenceTexture)),s.iridescenceIor!==void 0&&(t.iridescenceIOR=s.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),s.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=s.iridescenceThicknessMinimum),s.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=s.iridescenceThicknessMaximum),s.iridescenceThicknessTexture!==void 0&&n.push(this.parser.assignTexture(t,"iridescenceThicknessMap",s.iridescenceThicknessTexture)),Promise.all(n)}},tE=class{constructor(e){this.parser=e,this.name=nt.KHR_MATERIALS_SHEEN}getMaterialType(e){return cs(this.parser,e,this.name)!==null?xs:null}extendMaterialParams(e,t){let s=cs(this.parser,e,this.name);if(s===null)return Promise.resolve();let n=[];if(t.sheenColor=new be(0,0,0),t.sheenRoughness=0,t.sheen=1,s.sheenColorFactor!==void 0){let a=s.sheenColorFactor;t.sheenColor.setRGB(a[0],a[1],a[2],nn)}return s.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=s.sheenRoughnessFactor),s.sheenColorTexture!==void 0&&n.push(this.parser.assignTexture(t,"sheenColorMap",s.sheenColorTexture,Wt)),s.sheenRoughnessTexture!==void 0&&n.push(this.parser.assignTexture(t,"sheenRoughnessMap",s.sheenRoughnessTexture)),Promise.all(n)}},sE=class{constructor(e){this.parser=e,this.name=nt.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return cs(this.parser,e,this.name)!==null?xs:null}extendMaterialParams(e,t){let s=cs(this.parser,e,this.name);if(s===null)return Promise.resolve();let n=[];return s.transmissionFactor!==void 0&&(t.transmission=s.transmissionFactor),s.transmissionTexture!==void 0&&n.push(this.parser.assignTexture(t,"transmissionMap",s.transmissionTexture)),Promise.all(n)}},nE=class{constructor(e){this.parser=e,this.name=nt.KHR_MATERIALS_VOLUME}getMaterialType(e){return cs(this.parser,e,this.name)!==null?xs:null}extendMaterialParams(e,t){let s=cs(this.parser,e,this.name);if(s===null)return Promise.resolve();let n=[];t.thickness=s.thicknessFactor!==void 0?s.thicknessFactor:0,s.thicknessTexture!==void 0&&n.push(this.parser.assignTexture(t,"thicknessMap",s.thicknessTexture)),t.attenuationDistance=s.attenuationDistance||1/0;let a=s.attenuationColor||[1,1,1];return t.attenuationColor=new be().setRGB(a[0],a[1],a[2],nn),Promise.all(n)}},aE=class{constructor(e){this.parser=e,this.name=nt.KHR_MATERIALS_IOR}getMaterialType(e){return cs(this.parser,e,this.name)!==null?xs:null}extendMaterialParams(e,t){let s=cs(this.parser,e,this.name);return s===null||(t.ior=s.ior!==void 0?s.ior:1.5,t.ior===0&&(t.ior=1e3)),Promise.resolve()}},iE=class{constructor(e){this.parser=e,this.name=nt.KHR_MATERIALS_SPECULAR}getMaterialType(e){return cs(this.parser,e,this.name)!==null?xs:null}extendMaterialParams(e,t){let s=cs(this.parser,e,this.name);if(s===null)return Promise.resolve();let n=[];t.specularIntensity=s.specularFactor!==void 0?s.specularFactor:1,s.specularTexture!==void 0&&n.push(this.parser.assignTexture(t,"specularIntensityMap",s.specularTexture));let a=s.specularColorFactor||[1,1,1];return t.specularColor=new be().setRGB(a[0],a[1],a[2],nn),s.specularColorTexture!==void 0&&n.push(this.parser.assignTexture(t,"specularColorMap",s.specularColorTexture,Wt)),Promise.all(n)}},rE=class{constructor(e){this.parser=e,this.name=nt.EXT_MATERIALS_BUMP}getMaterialType(e){return cs(this.parser,e,this.name)!==null?xs:null}extendMaterialParams(e,t){let s=cs(this.parser,e,this.name);if(s===null)return Promise.resolve();let n=[];return t.bumpScale=s.bumpFactor!==void 0?s.bumpFactor:1,s.bumpTexture!==void 0&&n.push(this.parser.assignTexture(t,"bumpMap",s.bumpTexture)),Promise.all(n)}},oE=class{constructor(e){this.parser=e,this.name=nt.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return cs(this.parser,e,this.name)!==null?xs:null}extendMaterialParams(e,t){let s=cs(this.parser,e,this.name);if(s===null)return Promise.resolve();let n=[];return s.anisotropyStrength!==void 0&&(t.anisotropy=s.anisotropyStrength),s.anisotropyRotation!==void 0&&(t.anisotropyRotation=s.anisotropyRotation),s.anisotropyTexture!==void 0&&n.push(this.parser.assignTexture(t,"anisotropyMap",s.anisotropyTexture)),Promise.all(n)}},cE=class{constructor(e){this.parser=e,this.name=nt.KHR_TEXTURE_BASISU}loadTexture(e){let t=this.parser,s=t.json,n=s.textures[e];if(!n.extensions||!n.extensions[this.name])return null;let a=n.extensions[this.name],i=t.options.ktx2Loader;if(!i){if(s.extensionsRequired&&s.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,a.source,i)}},lE=class{constructor(e){this.parser=e,this.name=nt.EXT_TEXTURE_WEBP}loadTexture(e){let t=this.name,s=this.parser,n=s.json,a=n.textures[e];if(!a.extensions||!a.extensions[t])return null;let i=a.extensions[t],o=n.images[i.source],c=s.textureLoader;if(o.uri){let l=s.options.manager.getHandler(o.uri);l!==null&&(c=l)}return s.loadTextureImage(e,i.source,c)}},hE=class{constructor(e){this.parser=e,this.name=nt.EXT_TEXTURE_AVIF}loadTexture(e){let t=this.name,s=this.parser,n=s.json,a=n.textures[e];if(!a.extensions||!a.extensions[t])return null;let i=a.extensions[t],o=n.images[i.source],c=s.textureLoader;if(o.uri){let l=s.options.manager.getHandler(o.uri);l!==null&&(c=l)}return s.loadTextureImage(e,i.source,c)}},Av=class{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){let t=this.parser.json,s=t.bufferViews[e];if(s.extensions&&s.extensions[this.name]){let n=s.extensions[this.name],a=this.parser.getDependency("buffer",n.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return a.then(function(o){let c=n.byteOffset||0,l=n.byteLength||0,h=n.count,u=n.byteStride,d=new Uint8Array(o,c,l);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(h,u,d,n.mode,n.filter).then(function(f){return f.buffer}):i.ready.then(function(){let f=new ArrayBuffer(h*u);return i.decodeGltfBuffer(new Uint8Array(f),h,u,d,n.mode,n.filter),f})})}else return null}},uE=class{constructor(e){this.name=nt.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,s=t.nodes[e];if(!s.extensions||!s.extensions[this.name]||s.mesh===void 0)return null;let n=t.meshes[s.mesh];for(let l of n.primitives)if(l.mode!==qa.TRIANGLES&&l.mode!==qa.TRIANGLE_STRIP&&l.mode!==qa.TRIANGLE_FAN&&l.mode!==void 0)return null;let i=s.extensions[this.name].attributes,o=[],c={};for(let l in i)o.push(this.parser.getDependency("accessor",i[l]).then(h=>(c[l]=h,c[l])));return o.length<1?null:(o.push(this.parser.createNodeMesh(e)),Promise.all(o).then(l=>{let h=l.pop(),u=h.isGroup?h.children:[h],d=l[0].count,f=[];for(let p of u){let m=new le,b=new E,g=new It,x=new E(1,1,1),T=new Er(p.geometry,p.material,d);for(let v=0;v<d;v++)c.TRANSLATION&&b.fromBufferAttribute(c.TRANSLATION,v),c.ROTATION&&g.fromBufferAttribute(c.ROTATION,v),c.SCALE&&x.fromBufferAttribute(c.SCALE,v),T.setMatrixAt(v,m.compose(b,g,x));let y=null;for(let v in c)if(v==="_COLOR_0"){let _=c[v];T.instanceColor=new ys(_.array,_.itemSize,_.normalized)}else if(v!=="TRANSLATION"&&v!=="ROTATION"&&v!=="SCALE"){if(y===null){let A=T.geometry;y=new ke,y.name=A.name;for(let M in A.attributes)y.setAttribute(M,A.attributes[M]);for(let M in A.morphAttributes)y.morphAttributes[M]=A.morphAttributes[M];A.index!==null&&y.setIndex(A.index),y.morphTargetsRelative=A.morphTargetsRelative;for(let M of A.groups)y.addGroup(M.start,M.count,M.materialIndex);A.boundingBox!==null&&(y.boundingBox=A.boundingBox.clone()),A.boundingSphere!==null&&(y.boundingSphere=A.boundingSphere.clone()),y.drawRange.start=A.drawRange.start,y.drawRange.count=A.drawRange.count,y.userData=Object.assign({},A.userData),T.geometry=y}let _=c[v];y.setAttribute(v,new ys(_.array,_.itemSize,_.normalized))}Ze.prototype.copy.call(T,p),this.parser.assignFinalMaterial(T),f.push(T)}return h.isGroup?(h.clear(),h.add(...f),h):f[0]}))}},bP="glTF",Hb=12,dP={JSON:1313821514,BIN:5130562},dE=class{constructor(e){this.name=nt.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,Hb),s=new TextDecoder;if(this.header={magic:s.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==bP)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");let n=this.header.length-Hb,a=new DataView(e,Hb),i=0;for(;i<n;){let o=a.getUint32(i,!0);i+=4;let c=a.getUint32(i,!0);if(i+=4,c===dP.JSON){let l=new Uint8Array(e,Hb+i,o);this.content=s.decode(l)}else if(c===dP.BIN){let l=Hb+i;this.body=e.slice(l,l+o)}i+=o}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}},fE=class{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=nt.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){let s=this.json,n=this.dracoLoader,a=e.extensions[this.name].bufferView,i=e.extensions[this.name].attributes,o={},c={},l={};for(let h in i){let u=gE[h]||h.toLowerCase();o[u]=i[h]}for(let h in e.attributes){let u=gE[h]||h.toLowerCase();if(i[h]!==void 0){let d=s.accessors[e.attributes[h]],f=lf[d.componentType];l[u]=f.name,c[u]=d.normalized===!0}}return t.getDependency("bufferView",a).then(function(h){return new Promise(function(u,d){n.decodeDracoFile(h,function(f){for(let p in f.attributes){let m=f.attributes[p],b=c[p];b!==void 0&&(m.normalized=b)}u(f)},o,l,nn,d)})})}},pE=class{constructor(){this.name=nt.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){if((t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0)return e;if(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),t.rotation!==void 0){let s=Math.cos(e.rotation),n=Math.sin(e.rotation);e.matrix.set(e.repeat.x*s,e.repeat.y*n,e.offset.x,-e.repeat.x*n,e.repeat.y*s,e.offset.y,0,0,1),e.matrixAutoUpdate=!1}return e.needsUpdate=!0,e}},mE=class{constructor(){this.name=nt.KHR_MESH_QUANTIZATION}},Mv=class extends li{constructor(e,t,s,n){super(e,t,s,n)}copySampleValue_(e){let t=this.resultBuffer,s=this.sampleValues,n=this.valueSize,a=e*n*3+n;for(let i=0;i!==n;i++)t[i]=s[a+i];return t}interpolate_(e,t,s,n){let a=this.resultBuffer,i=this.sampleValues,o=this.valueSize,c=o*2,l=o*3,h=n-t,u=(s-t)/h,d=u*u,f=d*u,p=e*l,m=p-l,b=-2*f+3*d,g=f-d,x=1-b,T=g-d+u;for(let y=0;y!==o;y++){let v=i[m+y+o],_=i[m+y+c]*h,A=i[p+y+o],M=i[p+y]*h;a[y]=x*v+T*_+b*A+g*M}return a}},VQ=new It,bE=class extends Mv{interpolate_(e,t,s,n){let a=super.interpolate_(e,t,s,n);return VQ.fromArray(a).normalize().toArray(a),a}},qa={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},lf={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},fP={9728:pt,9729:Ye,9984:ll,9985:Fo,9986:fi,9987:on},pP={33071:hs,33648:ai,10497:Zn},WR={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},gE={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Ac={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},jQ={CUBICSPLINE:void 0,LINEAR:To,STEP:wo},qR={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function GQ(r){return r.DefaultMaterial===void 0&&(r.DefaultMaterial=new An({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:ea})),r.DefaultMaterial}function nh(r,e,t){for(let s in t.extensions)r[s]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[s]=t.extensions[s])}function yr(r,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(r.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function HQ(r,e,t){let s=!1,n=!1,a=!1;for(let l=0,h=e.length;l<h;l++){let u=e[l];if(u.POSITION!==void 0&&(s=!0),u.NORMAL!==void 0&&(n=!0),u.COLOR_0!==void 0&&(a=!0),s&&n&&a)break}if(!s&&!n&&!a)return Promise.resolve(r);let i=[],o=[],c=[];for(let l=0,h=e.length;l<h;l++){let u=e[l];if(s){let d=u.POSITION!==void 0?t.getDependency("accessor",u.POSITION):r.attributes.position;i.push(d)}if(n){let d=u.NORMAL!==void 0?t.getDependency("accessor",u.NORMAL):r.attributes.normal;o.push(d)}if(a){let d=u.COLOR_0!==void 0?t.getDependency("accessor",u.COLOR_0):r.attributes.color;c.push(d)}}return Promise.all([Promise.all(i),Promise.all(o),Promise.all(c)]).then(function(l){let h=l[0],u=l[1],d=l[2];return s&&(r.morphAttributes.position=h),n&&(r.morphAttributes.normal=u),a&&(r.morphAttributes.color=d),r.morphTargetsRelative=!0,r})}function WQ(r,e){if(r.updateMorphTargets(),e.weights!==void 0)for(let t=0,s=e.weights.length;t<s;t++)r.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){let t=e.extras.targetNames;if(r.morphTargetInfluences.length===t.length){r.morphTargetDictionary={};for(let s=0,n=t.length;s<n;s++)r.morphTargetDictionary[t[s]]=s}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function qQ(r){let e,t=r.extensions&&r.extensions[nt.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+XR(t.attributes):e=r.indices+":"+XR(r.attributes)+":"+r.mode,r.targets!==void 0)for(let s=0,n=r.targets.length;s<n;s++)e+=":"+XR(r.targets[s]);return e}function XR(r){let e="",t=Object.keys(r).sort();for(let s=0,n=t.length;s<n;s++)e+=t[s]+":"+r[t[s]]+";";return e}function yE(r){switch(r){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function XQ(r){return r.search(/\.jpe?g($|\?)/i)>0||r.search(/^data\:image\/jpeg/)===0?"image/jpeg":r.search(/\.webp($|\?)/i)>0||r.search(/^data\:image\/webp/)===0?"image/webp":r.search(/\.ktx2($|\?)/i)>0||r.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}var KQ=new le,xE=class{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new zQ,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let s=!1,n=-1,a=!1,i=-1;if(typeof navigator<"u"&&typeof navigator.userAgent<"u"){let o=navigator.userAgent;s=/^((?!chrome|android).)*safari/i.test(o)===!0;let c=o.match(/Version\/(\d+)/);n=s&&c?parseInt(c[1],10):-1,a=o.indexOf("Firefox")>-1,i=a?o.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||s&&n<17||a&&i<98?this.textureLoader=new hu(this.options.manager):this.textureLoader=new fu(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new an(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let s=this,n=this.json,a=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(i){return i._markDefs&&i._markDefs()}),Promise.all(this._invokeAll(function(i){return i.beforeRoot&&i.beforeRoot()})).then(function(){return Promise.all([s.getDependencies("scene"),s.getDependencies("animation"),s.getDependencies("camera")])}).then(function(i){let o={scene:i[0][n.scene||0],scenes:i[0],animations:i[1],cameras:i[2],asset:n.asset,parser:s,userData:{}};return nh(a,o,n),yr(o,n),Promise.all(s._invokeAll(function(c){return c.afterRoot&&c.afterRoot(o)})).then(function(){for(let c of o.scenes)c.updateMatrixWorld();e(o)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],s=this.json.meshes||[];for(let n=0,a=t.length;n<a;n++){let i=t[n].joints;for(let o=0,c=i.length;o<c;o++)e[i[o]].isBone=!0}for(let n=0,a=e.length;n<a;n++){let i=e[n];i.mesh!==void 0&&(this._addNodeRef(this.meshCache,i.mesh),i.skin!==void 0&&(s[i.mesh].isSkinnedMesh=!0)),i.camera!==void 0&&this._addNodeRef(this.cameraCache,i.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,s){if(e.refs[t]<=1)return s;let n=s.clone(),a=(i,o)=>{let c=this.associations.get(i);c!=null&&this.associations.set(o,c);for(let[l,h]of i.children.entries())a(h,o.children[l])};return a(s,n),n.name+="_instance_"+e.uses[t]++,n}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let s=0;s<t.length;s++){let n=e(t[s]);if(n)return n}return null}_invokeAll(e){let t=Object.values(this.plugins);t.unshift(this);let s=[];for(let n=0;n<t.length;n++){let a=e(t[n]);a&&s.push(a)}return s}getDependency(e,t){let s=e+":"+t,n=this.cache.get(s);if(!n){switch(e){case"scene":n=this.loadScene(t);break;case"node":n=this._invokeOne(function(a){return a.loadNode&&a.loadNode(t)});break;case"mesh":n=this._invokeOne(function(a){return a.loadMesh&&a.loadMesh(t)});break;case"accessor":n=this.loadAccessor(t);break;case"bufferView":n=this._invokeOne(function(a){return a.loadBufferView&&a.loadBufferView(t)});break;case"buffer":n=this.loadBuffer(t);break;case"material":n=this._invokeOne(function(a){return a.loadMaterial&&a.loadMaterial(t)});break;case"texture":n=this._invokeOne(function(a){return a.loadTexture&&a.loadTexture(t)});break;case"skin":n=this.loadSkin(t);break;case"animation":n=this._invokeOne(function(a){return a.loadAnimation&&a.loadAnimation(t)});break;case"camera":n=this.loadCamera(t);break;default:if(n=this._invokeOne(function(a){return a!=this&&a.getDependency&&a.getDependency(e,t)}),!n)throw new Error("Unknown type: "+e);break}this.cache.add(s,n)}return n}getDependencies(e){let t=this.cache.get(e);if(!t){let s=this,n=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(n.map(function(a,i){return s.getDependency(e,i)})),this.cache.add(e,t)}return t}loadBuffer(e){let t=this.json.buffers[e],s=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[nt.KHR_BINARY_GLTF].body);let n=this.options;return new Promise(function(a,i){s.load(Ea.resolveURL(t.uri,n.path),a,void 0,function(){i(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){let t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(s){let n=t.byteLength||0,a=t.byteOffset||0;return s.slice(a,a+n)})}loadAccessor(e){let t=this,s=this.json,n=this.json.accessors[e];if(n.bufferView===void 0&&n.sparse===void 0){let i=WR[n.type],o=lf[n.componentType],c=n.normalized===!0,l=new o(n.count*i);return Promise.resolve(new Xe(l,i,c))}let a=[];return n.bufferView!==void 0?a.push(this.getDependency("bufferView",n.bufferView)):a.push(null),n.sparse!==void 0&&(a.push(this.getDependency("bufferView",n.sparse.indices.bufferView)),a.push(this.getDependency("bufferView",n.sparse.values.bufferView))),Promise.all(a).then(function(i){let o=i[0],c=WR[n.type],l=lf[n.componentType],h=l.BYTES_PER_ELEMENT,u=h*c,d=n.byteOffset||0,f=n.bufferView!==void 0?s.bufferViews[n.bufferView].byteStride:void 0,p=n.normalized===!0,m,b;if(f&&f!==u){let g=Math.floor(d/f),x="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+g+":"+n.count,T=t.cache.get(x);T||(m=new l(o,g*f,n.count*f/h),T=new ri(m,f/h),t.cache.add(x,T)),b=new Ra(T,c,d%f/h,p)}else o===null?m=new l(n.count*c):m=new l(o,d,n.count*c),b=new Xe(m,c,p);if(n.sparse!==void 0){let g=WR.SCALAR,x=lf[n.sparse.indices.componentType],T=n.sparse.indices.byteOffset||0,y=n.sparse.values.byteOffset||0,v=new x(i[1],T,n.sparse.count*g),_=new l(i[2],y,n.sparse.count*c);o!==null&&(b=new Xe(b.array.slice(),b.itemSize,b.normalized)),b.normalized=!1;for(let A=0,M=v.length;A<M;A++){let N=v[A];if(b.setX(N,_[A*c]),c>=2&&b.setY(N,_[A*c+1]),c>=3&&b.setZ(N,_[A*c+2]),c>=4&&b.setW(N,_[A*c+3]),c>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}b.normalized=p}return b})}loadTexture(e){let t=this.json,s=this.options,a=t.textures[e].source,i=t.images[a],o=this.textureLoader;if(i.uri){let c=s.manager.getHandler(i.uri);c!==null&&(o=c)}return this.loadTextureImage(e,a,o)}loadTextureImage(e,t,s){let n=this,a=this.json,i=a.textures[e],o=a.images[t],c=(o.uri||o.bufferView)+":"+i.sampler;if(this.textureCache[c])return this.textureCache[c];let l=this.loadImageSource(t,s).then(function(h){h.flipY=!1,h.name=i.name||o.name||"",h.name===""&&typeof o.uri=="string"&&o.uri.startsWith("data:image/")===!1&&(h.name=o.uri);let d=(a.samplers||{})[i.sampler]||{};return h.magFilter=fP[d.magFilter]||Ye,h.minFilter=fP[d.minFilter]||on,h.wrapS=pP[d.wrapS]||Zn,h.wrapT=pP[d.wrapT]||Zn,h.generateMipmaps=!h.isCompressedTexture&&h.minFilter!==pt&&h.minFilter!==Ye,n.associations.set(h,{textures:e}),h}).catch(function(){return null});return this.textureCache[c]=l,l}loadImageSource(e,t){let s=this,n=this.json,a=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(u=>u.clone());let i=n.images[e],o=self.URL||self.webkitURL,c=i.uri||"",l=!1;if(i.bufferView!==void 0)c=s.getDependency("bufferView",i.bufferView).then(function(u){l=!0;let d=new Blob([u],{type:i.mimeType});return c=o.createObjectURL(d),c});else if(i.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");let h=Promise.resolve(c).then(function(u){return new Promise(function(d,f){let p=d;t.isImageBitmapLoader===!0&&(p=function(m){let b=new gt(m);b.needsUpdate=!0,d(b)}),t.load(Ea.resolveURL(u,a.path),p,void 0,f)})}).then(function(u){return l===!0&&o.revokeObjectURL(c),yr(u,i),u.userData.mimeType=i.mimeType||XQ(i.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",c),u});return this.sourceCache[e]=h,h}assignTexture(e,t,s,n){let a=this;return this.getDependency("texture",s.index).then(function(i){if(!i)return null;if(s.texCoord!==void 0&&s.texCoord>0&&(i=i.clone(),i.channel=s.texCoord),a.extensions[nt.KHR_TEXTURE_TRANSFORM]){let o=s.extensions!==void 0?s.extensions[nt.KHR_TEXTURE_TRANSFORM]:void 0;if(o){let c=a.associations.get(i);i=a.extensions[nt.KHR_TEXTURE_TRANSFORM].extendTexture(i,o),a.associations.set(i,c)}}return n!==void 0&&(i.colorSpace=n),e[t]=i,i})}assignFinalMaterial(e){let t=e.geometry,s=e.material,n=t.attributes.tangent===void 0,a=t.attributes.color!==void 0,i=t.attributes.normal===void 0;if(e.isPoints){let o="PointsMaterial:"+s.uuid,c=this.cache.get(o);c||(c=new Cr,Rt.prototype.copy.call(c,s),c.color.copy(s.color),c.map=s.map,c.sizeAttenuation=!1,this.cache.add(o,c)),s=c}else if(e.isLine){let o="LineBasicMaterial:"+s.uuid,c=this.cache.get(o);c||(c=new ns,Rt.prototype.copy.call(c,s),c.color.copy(s.color),c.map=s.map,this.cache.add(o,c)),s=c}if(n||a||i){let o="ClonedMaterial:"+s.uuid+":";n&&(o+="derivative-tangents:"),a&&(o+="vertex-colors:"),i&&(o+="flat-shading:");let c=this.cache.get(o);c||(c=s.clone(),a&&(c.vertexColors=!0),i&&(c.flatShading=!0),n&&(c.normalScale&&(c.normalScale.y*=-1),c.clearcoatNormalScale&&(c.clearcoatNormalScale.y*=-1)),this.cache.add(o,c),this.associations.set(c,this.associations.get(s))),s=c}e.material=s}getMaterialType(){return An}loadMaterial(e){let t=this,s=this.json,n=this.extensions,a=s.materials[e],i,o={},c=a.extensions||{},l=[];if(c[nt.KHR_MATERIALS_UNLIT]){let u=n[nt.KHR_MATERIALS_UNLIT];i=u.getMaterialType(),l.push(u.extendParams(o,a,t))}else{let u=a.pbrMetallicRoughness||{};if(o.color=new be(1,1,1),o.opacity=1,Array.isArray(u.baseColorFactor)){let d=u.baseColorFactor;o.color.setRGB(d[0],d[1],d[2],nn),o.opacity=d[3]}u.baseColorTexture!==void 0&&l.push(t.assignTexture(o,"map",u.baseColorTexture,Wt)),o.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,o.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(l.push(t.assignTexture(o,"metalnessMap",u.metallicRoughnessTexture)),l.push(t.assignTexture(o,"roughnessMap",u.metallicRoughnessTexture))),i=this._invokeOne(function(d){return d.getMaterialType&&d.getMaterialType(e)}),l.push(Promise.all(this._invokeAll(function(d){return d.extendMaterialParams&&d.extendMaterialParams(e,o)})))}a.doubleSided===!0&&(o.side=rn);let h=a.alphaMode||qR.OPAQUE;if(h===qR.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,h===qR.MASK&&(o.alphaTest=a.alphaCutoff!==void 0?a.alphaCutoff:.5)),a.normalTexture!==void 0&&i!==Bt&&(l.push(t.assignTexture(o,"normalMap",a.normalTexture)),o.normalScale=new q(1,1),a.normalTexture.scale!==void 0)){let u=a.normalTexture.scale;o.normalScale.set(u,u)}if(a.occlusionTexture!==void 0&&i!==Bt&&(l.push(t.assignTexture(o,"aoMap",a.occlusionTexture)),a.occlusionTexture.strength!==void 0&&(o.aoMapIntensity=a.occlusionTexture.strength)),a.emissiveFactor!==void 0&&i!==Bt){let u=a.emissiveFactor;o.emissive=new be().setRGB(u[0],u[1],u[2],nn)}return a.emissiveTexture!==void 0&&i!==Bt&&l.push(t.assignTexture(o,"emissiveMap",a.emissiveTexture,Wt)),Promise.all(l).then(function(){let u=new i(o);return a.name&&(u.name=a.name),yr(u,a),t.associations.set(u,{materials:e}),a.extensions&&nh(n,u,a),u})}createUniqueName(e){let t=dt.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){let t=this,s=this.extensions,n=this.primitiveCache;function a(o){return s[nt.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,t).then(function(c){return mP(c,o,t)})}let i=[];for(let o=0,c=e.length;o<c;o++){let l=e[o],h=qQ(l),u=n[h];if(u)i.push(u.promise);else{let d;l.extensions&&l.extensions[nt.KHR_DRACO_MESH_COMPRESSION]?d=a(l):d=mP(new ke,l,t),l.mode===qa.TRIANGLE_STRIP?d=d.then(f=>HR(f,ed)):l.mode===qa.TRIANGLE_FAN&&(d=d.then(f=>HR(f,pl))),n[h]={primitive:l,promise:d},i.push(d)}}return Promise.all(i)}loadMesh(e){let t=this,s=this.json,n=this.extensions,a=s.meshes[e],i=a.primitives,o=[];for(let c=0,l=i.length;c<l;c++){let h=i[c].material===void 0?GQ(this.cache):this.getDependency("material",i[c].material);o.push(h)}return o.push(t.loadGeometries(i)),Promise.all(o).then(async function(c){let l=c.slice(0,c.length-1),h=c[c.length-1],u=[];for(let f=0,p=h.length;f<p;f++){let m=h[f],b=i[f],g,x=l[f];if(b.mode===qa.TRIANGLES||b.mode===qa.TRIANGLE_STRIP||b.mode===qa.TRIANGLE_FAN||b.mode===void 0){let T=a.isSkinnedMesh===!0,y=m.hasAttribute("skinIndex")&&m.hasAttribute("skinWeight");T&&y===!1&&console.warn("THREE.GLTFLoader: Missing skinIndex or skinWeight attributes. Skinning disabled."),g=T&&y?new jc(m,x):new at(m,x),g.isSkinnedMesh===!0&&g.normalizeSkinWeights()}else if(b.mode===qa.LINES)g=new _n(m,x);else if(b.mode===qa.LINE_STRIP)g=new Qn(m,x);else if(b.mode===qa.LINE_LOOP)g=new Hc(m,x);else if(b.mode===qa.POINTS)g=new Wc(m,x);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+b.mode);Object.keys(g.geometry.morphAttributes).length>0&&WQ(g,a),g.name=t.createUniqueName(a.name||"mesh_"+e),yr(g,a),b.extensions&&nh(n,g,b),t.assignFinalMaterial(g),u.push(g)}for(let f=0,p=u.length;f<p;f++)t.associations.set(u[f],{meshes:e,primitives:f});if(u.length===1)return a.extensions&&nh(n,u[0],a),u[0];let d=new qs;a.extensions&&nh(n,d,a),t.associations.set(d,{meshes:e});for(let f=0,p=u.length;f<p;f++)d.add(u[f]);return d})}loadCamera(e){let t,s=this.json.cameras[e],n=s[s.type];if(!n){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return s.type==="perspective"?t=new qt(Lo.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):s.type==="orthographic"&&(t=new ji(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),s.name&&(t.name=this.createUniqueName(s.name)),yr(t,s),Promise.resolve(t)}loadSkin(e){let t=this.json.skins[e],s=[];for(let n=0,a=t.joints.length;n<a;n++)s.push(this._loadNodeShallow(t.joints[n]));return t.inverseBindMatrices!==void 0?s.push(this.getDependency("accessor",t.inverseBindMatrices)):s.push(null),Promise.all(s).then(function(n){let a=n.pop(),i=n,o=[],c=[];for(let l=0,h=i.length;l<h;l++){let u=i[l];if(u){o.push(u);let d=new le;a!==null&&d.fromArray(a.array,l*16),c.push(d)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[l])}return new Gc(o,c)})}loadAnimation(e){let t=this.json,s=this,n=t.animations[e],a=n.name?n.name:"animation_"+e,i=[],o=[],c=[],l=[],h=[];for(let u=0,d=n.channels.length;u<d;u++){let f=n.channels[u],p=n.samplers[f.sampler],m=f.target,b=m.node,g=n.parameters!==void 0?n.parameters[p.input]:p.input,x=n.parameters!==void 0?n.parameters[p.output]:p.output;m.node!==void 0&&(i.push(this.getDependency("node",b)),o.push(this.getDependency("accessor",g)),c.push(this.getDependency("accessor",x)),l.push(p),h.push(m))}return Promise.all([Promise.all(i),Promise.all(o),Promise.all(c),Promise.all(l),Promise.all(h)]).then(function(u){let d=u[0],f=u[1],p=u[2],m=u[3],b=u[4],g=[];for(let T=0,y=d.length;T<y;T++){let v=d[T],_=f[T],A=p[T],M=m[T],N=b[T];if(v===void 0)continue;v.updateMatrix&&v.updateMatrix();let R=s._createAnimationTracks(v,_,A,M,N);if(R)for(let I=0;I<R.length;I++)g.push(R[I])}let x=new Vi(a,void 0,g);return yr(x,n),x})}createNodeMesh(e){let t=this.json,s=this,n=t.nodes[e];return n.mesh===void 0?null:s.getDependency("mesh",n.mesh).then(function(a){let i=s._getNodeRef(s.meshCache,n.mesh,a);return n.weights!==void 0&&i.traverse(function(o){if(o.isMesh)for(let c=0,l=n.weights.length;c<l;c++)o.morphTargetInfluences[c]=n.weights[c]}),i})}loadNode(e){let t=this.json,s=this,n=t.nodes[e],a=s._loadNodeShallow(e),i=[],o=n.children||[];for(let l=0,h=o.length;l<h;l++)i.push(s.getDependency("node",o[l]));let c=n.skin===void 0?Promise.resolve(null):s.getDependency("skin",n.skin);return Promise.all([a,Promise.all(i),c]).then(function(l){let h=l[0],u=l[1],d=l[2];d!==null&&h.traverse(function(f){f.isSkinnedMesh&&f.bind(d,KQ)});for(let f=0,p=u.length;f<p;f++)h.add(u[f]);if(h.userData.pivot!==void 0&&u.length>0){let f=h.userData.pivot,p=u[0];h.pivot=new E().fromArray(f),h.position.x-=f[0],h.position.y-=f[1],h.position.z-=f[2],p.position.set(0,0,0),delete h.userData.pivot}return h})}_loadNodeShallow(e){let t=this.json,s=this.extensions,n=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];let a=t.nodes[e],i=a.name?n.createUniqueName(a.name):"",o=[],c=n._invokeOne(function(l){return l.createNodeMesh&&l.createNodeMesh(e)});return c&&o.push(c),a.camera!==void 0&&o.push(n.getDependency("camera",a.camera).then(function(l){return n._getNodeRef(n.cameraCache,a.camera,l)})),n._invokeAll(function(l){return l.createNodeAttachment&&l.createNodeAttachment(e)}).forEach(function(l){o.push(l)}),this.nodeCache[e]=Promise.all(o).then(function(l){let h;if(a.isBone===!0?h=new _o:l.length>1?h=new qs:l.length===1?h=l[0]:h=new Ze,h!==l[0])for(let u=0,d=l.length;u<d;u++)h.add(l[u]);if(a.name&&(h.userData.name=a.name,h.name=i),yr(h,a),a.extensions&&nh(s,h,a),a.matrix!==void 0){let u=new le;u.fromArray(a.matrix),h.applyMatrix4(u)}else a.translation!==void 0&&h.position.fromArray(a.translation),a.rotation!==void 0&&h.quaternion.fromArray(a.rotation),a.scale!==void 0&&h.scale.fromArray(a.scale);if(!n.associations.has(h))n.associations.set(h,{});else if(a.mesh!==void 0&&n.meshCache.refs[a.mesh]>1){let u=n.associations.get(h);n.associations.set(h,{...u})}return n.associations.get(h).nodes=e,h}),this.nodeCache[e]}loadScene(e){let t=this.extensions,s=this.json.scenes[e],n=this,a=new qs;s.name&&(a.name=n.createUniqueName(s.name)),yr(a,s),s.extensions&&nh(t,a,s);let i=s.nodes||[],o=[];for(let c=0,l=i.length;c<l;c++)o.push(n.getDependency("node",i[c]));return Promise.all(o).then(function(c){for(let h=0,u=c.length;h<u;h++){let d=c[h];d.parent!==null?a.add(hP(d)):a.add(d)}let l=h=>{let u=new Map;for(let[d,f]of n.associations)(d instanceof Rt||d instanceof gt)&&u.set(d,f);return h.traverse(d=>{let f=n.associations.get(d);f!=null&&u.set(d,f)}),u};return n.associations=l(a),a})}_createAnimationTracks(e,t,s,n,a){let i=[],o=e.name?e.name:e.uuid,c=[];function l(f){f.morphTargetInfluences&&c.push(f.name?f.name:f.uuid)}Ac[a.path]===Ac.weights?(l(e),e.isGroup&&e.children.forEach(l)):c.push(o);let h;switch(Ac[a.path]){case Ac.weights:h=Ui;break;case Ac.rotation:h=Li;break;case Ac.translation:case Ac.scale:h=Br;break;default:s.itemSize===1?h=Ui:h=Br;break}let u=n.interpolation!==void 0?jQ[n.interpolation]:To,d=this._getArrayFromAccessor(s);for(let f=0,p=c.length;f<p;f++){let m=new h(c[f]+"."+Ac[a.path],t.array,d,u);n.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(m),i.push(m)}return i}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){let s=yE(t.constructor),n=new Float32Array(t.length);for(let a=0,i=t.length;a<i;a++)n[a]=t[a]*s;t=n}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(s){let n=this instanceof Li?bE:Mv;return new n(this.times,this.values,this.getValueSize()/3,s)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}};function JQ(r,e,t){let s=e.attributes,n=new ss;if(s.POSITION!==void 0){let o=t.json.accessors[s.POSITION],c=o.min,l=o.max;if(c!==void 0&&l!==void 0){if(n.set(new E(c[0],c[1],c[2]),new E(l[0],l[1],l[2])),o.normalized){let h=yE(lf[o.componentType]);n.min.multiplyScalar(h),n.max.multiplyScalar(h)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;let a=e.targets;if(a!==void 0){let o=new E,c=new E;for(let l=0,h=a.length;l<h;l++){let u=a[l];if(u.POSITION!==void 0){let d=t.json.accessors[u.POSITION],f=d.min,p=d.max;if(f!==void 0&&p!==void 0){if(c.setX(Math.max(Math.abs(f[0]),Math.abs(p[0]))),c.setY(Math.max(Math.abs(f[1]),Math.abs(p[1]))),c.setZ(Math.max(Math.abs(f[2]),Math.abs(p[2]))),d.normalized){let m=yE(lf[d.componentType]);c.multiplyScalar(m)}o.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}n.expandByVector(o)}r.boundingBox=n;let i=new jt;n.getCenter(i.center),i.radius=n.min.distanceTo(n.max)/2,r.boundingSphere=i}function mP(r,e,t){let s=e.attributes,n=[];function a(i,o){return t.getDependency("accessor",i).then(function(c){r.setAttribute(o,c)})}for(let i in s){let o=gE[i]||i.toLowerCase();o in r.attributes||n.push(a(s[i],o))}if(e.indices!==void 0&&!r.index){let i=t.getDependency("accessor",e.indices).then(function(o){r.setIndex(o)});n.push(i)}return qe.workingColorSpace!==nn&&"COLOR_0"in s&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${qe.workingColorSpace}" not supported.`),yr(r,e),JQ(r,e,t),Promise.all(n).then(function(){return e.targets!==void 0?HQ(r,e.targets,t):r})}var gP={type:"change"},vE={type:"start"},xP={type:"end"},Sv=new oi,yP=new wn,$Q=Math.cos(70*Lo.DEG2RAD),Es=new E,Kn=2*Math.PI,vt={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},wE=1e-6,TE=class extends bu{constructor(e,t=null){super(e,t),this.state=vt.NONE,this.target=new E,this.cursor=new E,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:Pr.ROTATE,MIDDLE:Pr.DOLLY,RIGHT:Pr.PAN},this.touches={ONE:Dr.ROTATE,TWO:Dr.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._cursorStyle="auto",this._domElementKeyEvents=null,this._lastPosition=new E,this._lastQuaternion=new It,this._lastTargetPosition=new E,this._quat=new It().setFromUnitVectors(e.up,new E(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new il,this._sphericalDelta=new il,this._scale=1,this._panOffset=new E,this._rotateStart=new q,this._rotateEnd=new q,this._rotateDelta=new q,this._panStart=new q,this._panEnd=new q,this._panDelta=new q,this._dollyStart=new q,this._dollyEnd=new q,this._dollyDelta=new q,this._dollyDirection=new E,this._mouse=new q,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=ZQ.bind(this),this._onPointerDown=YQ.bind(this),this._onPointerUp=QQ.bind(this),this._onContextMenu=ree.bind(this),this._onMouseWheel=see.bind(this),this._onKeyDown=nee.bind(this),this._onTouchStart=aee.bind(this),this._onTouchMove=iee.bind(this),this._onMouseDown=eee.bind(this),this._onMouseMove=tee.bind(this),this._interceptControlDown=oee.bind(this),this._interceptControlUp=cee.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}set cursorStyle(e){this._cursorStyle=e,e==="grab"?this.domElement.style.cursor="grab":this.domElement.style.cursor="auto"}get cursorStyle(){return this._cursorStyle}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.state=vt.NONE,this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents();let e=this.domElement.getRootNode();e.removeEventListener("keydown",this._interceptControlDown,{capture:!0}),e.removeEventListener("keyup",this._interceptControlUp,{capture:!0}),this._controlActive=!1,this._pointers.length=0,this._pointerPositions={},this.domElement.style.touchAction="",this.domElement.style.cursor="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(gP),this.update(),this.state=vt.NONE}pan(e,t){this._pan(e,t),this.update()}dollyIn(e){this._dollyIn(e),this.update()}dollyOut(e){this._dollyOut(e),this.update()}rotateLeft(e){this._rotateLeft(e),this.update()}rotateUp(e){this._rotateUp(e),this.update()}update(e=null){let t=this.object.position;Es.copy(t).sub(this.target),Es.applyQuaternion(this._quat),this._spherical.setFromVector3(Es),this.autoRotate&&this.state===vt.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let s=this.minAzimuthAngle,n=this.maxAzimuthAngle;isFinite(s)&&isFinite(n)&&(s<-Math.PI?s+=Kn:s>Math.PI&&(s-=Kn),n<-Math.PI?n+=Kn:n>Math.PI&&(n-=Kn),s<=n?this._spherical.theta=Math.max(s,Math.min(n,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(s+n)/2?Math.max(s,this._spherical.theta):Math.min(n,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let a=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{let i=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),a=i!=this._spherical.radius}if(Es.setFromSpherical(this._spherical),Es.applyQuaternion(this._quatInverse),t.copy(this.target).add(Es),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let i=null;if(this.object.isPerspectiveCamera){let o=Es.length();i=this._clampDistance(o*this._scale);let c=o-i;this.object.position.addScaledVector(this._dollyDirection,c),this.object.updateMatrixWorld(),a=!!c}else if(this.object.isOrthographicCamera){let o=new E(this._mouse.x,this._mouse.y,0);o.unproject(this.object);let c=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),a=c!==this.object.zoom;let l=new E(this._mouse.x,this._mouse.y,0);l.unproject(this.object),this.object.position.sub(l).add(o),this.object.updateMatrixWorld(),i=Es.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;i!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(i).add(this.object.position):(Sv.origin.copy(this.object.position),Sv.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Sv.direction))<$Q?this.object.lookAt(this.target):(yP.setFromNormalAndCoplanarPoint(this.object.up,this.target),Sv.intersectPlane(yP,this.target))))}else if(this.object.isOrthographicCamera){let i=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),i!==this.object.zoom&&(this.object.updateProjectionMatrix(),a=!0)}return this._scale=1,this._performCursorZoom=!1,a||this._lastPosition.distanceToSquared(this.object.position)>wE||8*(1-this._lastQuaternion.dot(this.object.quaternion))>wE||this._lastTargetPosition.distanceToSquared(this.target)>wE?(this.dispatchEvent(gP),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Kn/60*this.autoRotateSpeed*e:Kn/60/60*this.autoRotateSpeed}_getZoomScale(e){let t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){Es.setFromMatrixColumn(t,0),Es.multiplyScalar(-e),this._panOffset.add(Es)}_panUp(e,t){this.screenSpacePanning===!0?Es.setFromMatrixColumn(t,1):(Es.setFromMatrixColumn(t,0),Es.crossVectors(this.object.up,Es)),Es.multiplyScalar(e),this._panOffset.add(Es)}_pan(e,t){let s=this.domElement;if(this.object.isPerspectiveCamera){let n=this.object.position;Es.copy(n).sub(this.target);let a=Es.length();a*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*a/s.clientHeight,this.object.matrix),this._panUp(2*t*a/s.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/s.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/s.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;let s=this.domElement.getBoundingClientRect(),n=e-s.left,a=t-s.top,i=s.width,o=s.height;this._mouse.x=n/i*2-1,this._mouse.y=-(a/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(Kn*this._rotateDelta.x/t.clientHeight),this._rotateUp(Kn*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(Kn*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-Kn*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(Kn*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-Kn*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),s=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._rotateStart.set(s,n)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),s=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._panStart.set(s,n)}}_handleTouchStartDolly(e){let t=this._getSecondPointerPosition(e),s=e.pageX-t.x,n=e.pageY-t.y,a=Math.sqrt(s*s+n*n);this._dollyStart.set(0,a)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{let s=this._getSecondPointerPosition(e),n=.5*(e.pageX+s.x),a=.5*(e.pageY+s.y);this._rotateEnd.set(n,a)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(Kn*this._rotateDelta.x/t.clientHeight),this._rotateUp(Kn*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),s=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._panEnd.set(s,n)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){let t=this._getSecondPointerPosition(e),s=e.pageX-t.x,n=e.pageY-t.y,a=Math.sqrt(s*s+n*n);this._dollyEnd.set(0,a),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);let i=(e.pageX+t.x)*.5,o=(e.pageY+t.y)*.5;this._updateZoomParameters(i,o)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new q,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){let t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){let t=e.deltaMode,s={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:s.deltaY*=16;break;case 2:s.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(s.deltaY*=10),s}};function YQ(r){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(r.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(r)&&(this._addPointer(r),r.pointerType==="touch"?this._onTouchStart(r):this._onMouseDown(r),this._cursorStyle==="grab"&&(this.domElement.style.cursor="grabbing")))}function ZQ(r){this.enabled!==!1&&(r.pointerType==="touch"?this._onTouchMove(r):this._onMouseMove(r))}function QQ(r){switch(this._removePointer(r),this._pointers.length){case 0:this.domElement.releasePointerCapture(r.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(xP),this.state=vt.NONE,this._cursorStyle==="grab"&&(this.domElement.style.cursor="grab");break;case 1:let e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function eee(r){let e;switch(r.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case Pr.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(r),this.state=vt.DOLLY;break;case Pr.ROTATE:if(r.ctrlKey||r.metaKey||r.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(r),this.state=vt.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(r),this.state=vt.ROTATE}break;case Pr.PAN:if(r.ctrlKey||r.metaKey||r.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(r),this.state=vt.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(r),this.state=vt.PAN}break;default:this.state=vt.NONE}this.state!==vt.NONE&&this.dispatchEvent(vE)}function tee(r){switch(this.state){case vt.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(r);break;case vt.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(r);break;case vt.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(r);break}}function see(r){this.enabled===!1||this.enableZoom===!1||this.state!==vt.NONE||(r.preventDefault(),this.dispatchEvent(vE),this._handleMouseWheel(this._customWheelEvent(r)),this.dispatchEvent(xP))}function nee(r){this.enabled!==!1&&this._handleKeyDown(r)}function aee(r){switch(this._trackPointer(r),this._pointers.length){case 1:switch(this.touches.ONE){case Dr.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(r),this.state=vt.TOUCH_ROTATE;break;case Dr.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(r),this.state=vt.TOUCH_PAN;break;default:this.state=vt.NONE}break;case 2:switch(this.touches.TWO){case Dr.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(r),this.state=vt.TOUCH_DOLLY_PAN;break;case Dr.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(r),this.state=vt.TOUCH_DOLLY_ROTATE;break;default:this.state=vt.NONE}break;default:this.state=vt.NONE}this.state!==vt.NONE&&this.dispatchEvent(vE)}function iee(r){switch(this._trackPointer(r),this.state){case vt.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(r),this.update();break;case vt.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(r),this.update();break;case vt.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(r),this.update();break;case vt.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(r),this.update();break;default:this.state=vt.NONE}}function ree(r){this.enabled!==!1&&r.preventDefault()}function oee(r){r.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function cee(r){r.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}var _E=class extends ii{constructor(){super(),this.name="RoomEnvironment",this.position.y=-3.5;let e=new kr;e.deleteAttribute("uv");let t=new An({side:Xt}),s=new An,n=new di(16777215,900,28,2);n.position.set(.418,16.199,.3),this.add(n);let a=new at(e,t);a.position.set(-.757,13.219,.717),a.scale.set(31.713,28.305,28.591),this.add(a);let i=new Er(e,s,6),o=new Ze;o.position.set(-10.906,2.009,1.846),o.rotation.set(0,-.195,0),o.scale.set(2.328,7.905,4.651),o.updateMatrix(),i.setMatrixAt(0,o.matrix),o.position.set(-5.607,-.754,-.758),o.rotation.set(0,.994,0),o.scale.set(1.97,1.534,3.955),o.updateMatrix(),i.setMatrixAt(1,o.matrix),o.position.set(6.167,.857,7.803),o.rotation.set(0,.561,0),o.scale.set(3.927,6.285,3.687),o.updateMatrix(),i.setMatrixAt(2,o.matrix),o.position.set(-2.017,.018,6.124),o.rotation.set(0,.333,0),o.scale.set(2.002,4.566,2.064),o.updateMatrix(),i.setMatrixAt(3,o.matrix),o.position.set(2.291,-.756,-2.621),o.rotation.set(0,-.286,0),o.scale.set(1.546,1.552,1.496),o.updateMatrix(),i.setMatrixAt(4,o.matrix),o.position.set(-2.193,-.369,-5.547),o.rotation.set(0,.516,0),o.scale.set(3.875,3.487,2.986),o.updateMatrix(),i.setMatrixAt(5,o.matrix),this.add(i);let c=new at(e,hf(50));c.position.set(-16.116,14.37,8.208),c.scale.set(.1,2.428,2.739),this.add(c);let l=new at(e,hf(50));l.position.set(-16.109,18.021,-8.207),l.scale.set(.1,2.425,2.751),this.add(l);let h=new at(e,hf(17));h.position.set(14.904,12.198,-1.832),h.scale.set(.15,4.265,6.331),this.add(h);let u=new at(e,hf(43));u.position.set(-.462,8.89,14.52),u.scale.set(4.38,5.441,.088),this.add(u);let d=new at(e,hf(20));d.position.set(3.235,11.486,-12.541),d.scale.set(2.5,2,.1),this.add(d);let f=new at(e,hf(100));f.position.set(0,20,0),f.scale.set(1,.1,1),this.add(f)}dispose(){let e=new Set;this.traverse(t=>{t.isMesh&&(e.add(t.geometry),e.add(t.material))});for(let t of e)t.dispose()}};function hf(r){return new Di({color:0,emissive:16777215,emissiveIntensity:r})}export{KR as GLTFLoader,Ei as LOD_FADE_STEPS,kE as MAX_MESHLET_TRIANGLES,Rv as MAX_MESHLET_VERTICES,TE as OrbitControls,_E as RoomEnvironment,Ri as THREE,O2 as TSL,KE as VG_BUILD_VERSION,bf as VG_DEBUG_MODES,ch as VG_FORMAT_VERSION,GR as VirtualGeometry,vv as VirtualGeometryImport,Vb as VirtualMesh,Gt as VirtualMeshFormatError,AR as bindVirtualGeometryTextures,Tf as buildVirtualMesh,Lv as buildVirtualMeshCached,DR as canConvertToNodeMaterial,t3 as clearVirtualMeshCache,iP as collectVirtualGeometryGroups,vf as decodeVirtualMesh,Ov as encodeVirtualMesh,LR as fromBufferGeometry,pQ as instanceGuaranteedRange,fQ as instanceMeshletRange,GP as loadVirtualMesh,vR as lodFadeRange,RQ as mergeSources,Cv as partitionMeshlets,hQ as selectBlendCut,lQ as selectCut,OR as toNodeMaterial,dQ as verifyCutCoverage,uQ as verifyCutOverlap,Lb as vgInstanceOrigin,_R as vgNormalMap,Ib as vgTexture,sh as vgUv,Ub as vgWorldNormal,LQ as virtualGeometryLimits,JE as virtualMeshCacheKey,zR as virtualMeshesFromObject3D};
//# sourceMappingURL=three-virtual-geometry.all.min.js.map