@soonspacejs/plugin-atmosphere 2.13.11 → 2.13.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -32,4 +32,4 @@ import{Vector3 as e,Matrix4 as t,MathUtils as n,REVISION as r,Loader as i,FileLo
32
32
  * @author Don Cross <cosinekitty@gmail.com>
33
33
  * @license MIT
34
34
  */
35
- const ti=.017453292519943295,ni=new Date("2000-01-01T12:00:00Z"),ri=2*Math.PI,ii=180/Math.PI*3600,ai=484813681109536e-20,oi=.0002959122082855911,si=2.825345909524226e-7,ci=8.459715185680659e-8,ui=1.292024916781969e-8,di=1.524358900784276e-8;function mi(e){if(!Number.isFinite(e))throw console.trace(),`Value is not a finite number: ${e}`;return e}function li(e){return e-Math.floor(e)}var hi;!function(e){e.Sun="Sun",e.Moon="Moon",e.Mercury="Mercury",e.Venus="Venus",e.Earth="Earth",e.Mars="Mars",e.Jupiter="Jupiter",e.Saturn="Saturn",e.Uranus="Uranus",e.Neptune="Neptune",e.Pluto="Pluto",e.SSB="SSB",e.EMB="EMB",e.Star1="Star1",e.Star2="Star2",e.Star3="Star3",e.Star4="Star4",e.Star5="Star5",e.Star6="Star6",e.Star7="Star7",e.Star8="Star8"}(hi||(hi={}));const pi=[hi.Star1,hi.Star2,hi.Star3,hi.Star4,hi.Star5,hi.Star6,hi.Star7,hi.Star8],_i=[{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0}];function gi(e){const t=function(e){const t=pi.indexOf(e);return t>=0?_i[t]:null}(e);return t&&t.dist>0?t:null}var fi;!function(e){e[e.From2000=0]="From2000",e[e.Into2000=1]="Into2000"}(fi||(fi={}));const vi={Mercury:[[[[4.40250710144,0,0],[.40989414977,1.48302034195,26087.9031415742],[.050462942,4.47785489551,52175.8062831484],[.00855346844,1.16520322459,78263.70942472259],[.00165590362,4.11969163423,104351.61256629678],[.00034561897,.77930768443,130439.51570787099],[7583476e-11,3.71348404924,156527.41884944518]],[[26087.90313685529,0,0],[.01131199811,6.21874197797,26087.9031415742],[.00292242298,3.04449355541,52175.8062831484],[.00075775081,6.08568821653,78263.70942472259],[.00019676525,2.80965111777,104351.61256629678]]],[[[.11737528961,1.98357498767,26087.9031415742],[.02388076996,5.03738959686,52175.8062831484],[.01222839532,3.14159265359,0],[.0054325181,1.79644363964,78263.70942472259],[.0012977877,4.83232503958,104351.61256629678],[.00031866927,1.58088495658,130439.51570787099],[7963301e-11,4.60972126127,156527.41884944518]],[[.00274646065,3.95008450011,26087.9031415742],[.00099737713,3.14159265359,0]]],[[[.39528271651,0,0],[.07834131818,6.19233722598,26087.9031415742],[.00795525558,2.95989690104,52175.8062831484],[.00121281764,6.01064153797,78263.70942472259],[.00021921969,2.77820093972,104351.61256629678],[4354065e-11,5.82894543774,130439.51570787099]],[[.0021734774,4.65617158665,26087.9031415742],[.00044141826,1.42385544001,52175.8062831484]]]],Venus:[[[[3.17614666774,0,0],[.01353968419,5.59313319619,10213.285546211],[.00089891645,5.30650047764,20426.571092422],[5477194e-11,4.41630661466,7860.4193924392],[3455741e-11,2.6996444782,11790.6290886588],[2372061e-11,2.99377542079,3930.2096962196],[1317168e-11,5.18668228402,26.2983197998],[1664146e-11,4.25018630147,1577.3435424478],[1438387e-11,4.15745084182,9683.5945811164],[1200521e-11,6.15357116043,30639.856638633]],[[10213.28554621638,0,0],[.00095617813,2.4640651111,10213.285546211],[7787201e-11,.6247848222,20426.571092422]]],[[[.05923638472,.26702775812,10213.285546211],[.00040107978,1.14737178112,20426.571092422],[.00032814918,3.14159265359,0]],[[.00287821243,1.88964962838,10213.285546211]]],[[[.72334820891,0,0],[.00489824182,4.02151831717,10213.285546211],[1658058e-11,4.90206728031,20426.571092422],[1378043e-11,1.12846591367,11790.6290886588],[1632096e-11,2.84548795207,7860.4193924392],[498395e-11,2.58682193892,9683.5945811164],[221985e-11,2.01346696541,19367.1891622328],[237454e-11,2.55136053886,15720.8387848784]],[[.00034551041,.89198706276,10213.285546211]]]],Earth:[[[[1.75347045673,0,0],[.03341656453,4.66925680415,6283.0758499914],[.00034894275,4.62610242189,12566.1516999828],[3417572e-11,2.82886579754,3.523118349],[3497056e-11,2.74411783405,5753.3848848968],[3135899e-11,3.62767041756,77713.7714681205],[2676218e-11,4.41808345438,7860.4193924392],[2342691e-11,6.13516214446,3930.2096962196],[1273165e-11,2.03709657878,529.6909650946],[1324294e-11,.74246341673,11506.7697697936],[901854e-11,2.04505446477,26.2983197998],[1199167e-11,1.10962946234,1577.3435424478],[857223e-11,3.50849152283,398.1490034082],[779786e-11,1.17882681962,5223.6939198022],[99025e-10,5.23268072088,5884.9268465832],[753141e-11,2.53339052847,5507.5532386674],[505267e-11,4.58292599973,18849.2275499742],[492392e-11,4.20505711826,775.522611324],[356672e-11,2.91954114478,.0673103028],[284125e-11,1.89869240932,796.2980068164],[242879e-11,.34481445893,5486.777843175],[317087e-11,5.84901948512,11790.6290886588],[271112e-11,.31486255375,10977.078804699],[206217e-11,4.80646631478,2544.3144198834],[205478e-11,1.86953770281,5573.1428014331],[202318e-11,2.45767790232,6069.7767545534],[126225e-11,1.08295459501,20.7753954924],[155516e-11,.83306084617,213.299095438]],[[6283.0758499914,0,0],[.00206058863,2.67823455808,6283.0758499914],[4303419e-11,2.63512233481,12566.1516999828]],[[8721859e-11,1.07253635559,6283.0758499914]]],[[],[[.00227777722,3.4137662053,6283.0758499914],[3805678e-11,3.37063423795,12566.1516999828]]],[[[1.00013988784,0,0],[.01670699632,3.09846350258,6283.0758499914],[.00013956024,3.05524609456,12566.1516999828],[308372e-10,5.19846674381,77713.7714681205],[1628463e-11,1.17387558054,5753.3848848968],[1575572e-11,2.84685214877,7860.4193924392],[924799e-11,5.45292236722,11506.7697697936],[542439e-11,4.56409151453,3930.2096962196],[47211e-10,3.66100022149,5884.9268465832],[8.5831e-7,1.27079125277,161000.6857376741],[5.7056e-7,2.01374292245,83996.84731811189],[5.5736e-7,5.2415979917,71430.69561812909],[174844e-11,3.01193636733,18849.2275499742],[243181e-11,4.2734953079,11790.6290886588]],[[.00103018607,1.10748968172,6283.0758499914],[1721238e-11,1.06442300386,12566.1516999828]],[[4359385e-11,5.78455133808,6283.0758499914]]]],Mars:[[[[6.20347711581,0,0],[.18656368093,5.0503710027,3340.6124266998],[.01108216816,5.40099836344,6681.2248533996],[.00091798406,5.75478744667,10021.8372800994],[.00027744987,5.97049513147,3.523118349],[.00010610235,2.93958560338,2281.2304965106],[.00012315897,.84956094002,2810.9214616052],[8926784e-11,4.15697846427,.0172536522],[8715691e-11,6.11005153139,13362.4497067992],[6797556e-11,.36462229657,398.1490034082],[7774872e-11,3.33968761376,5621.8429232104],[3575078e-11,1.6618650571,2544.3144198834],[4161108e-11,.22814971327,2942.4634232916],[3075252e-11,.85696614132,191.4482661116],[2628117e-11,.64806124465,3337.0893083508],[2937546e-11,6.07893711402,.0673103028],[2389414e-11,5.03896442664,796.2980068164],[2579844e-11,.02996736156,3344.1355450488],[1528141e-11,1.14979301996,6151.533888305],[1798806e-11,.65634057445,529.6909650946],[1264357e-11,3.62275122593,5092.1519581158],[1286228e-11,3.06796065034,2146.1654164752],[1546404e-11,2.91579701718,1751.539531416],[1024902e-11,3.69334099279,8962.4553499102],[891566e-11,.18293837498,16703.062133499],[858759e-11,2.4009381194,2914.0142358238],[832715e-11,2.46418619474,3340.5951730476],[83272e-10,4.49495782139,3340.629680352],[712902e-11,3.66335473479,1059.3819301892],[748723e-11,3.82248614017,155.4203994342],[723861e-11,.67497311481,3738.761430108],[635548e-11,2.92182225127,8432.7643848156],[655162e-11,.48864064125,3127.3133312618],[550474e-11,3.81001042328,.9803210682],[55275e-10,4.47479317037,1748.016413067],[425966e-11,.55364317304,6283.0758499914],[415131e-11,.49662285038,213.299095438],[472167e-11,3.62547124025,1194.4470102246],[306551e-11,.38052848348,6684.7479717486],[312141e-11,.99853944405,6677.7017350506],[293198e-11,4.22131299634,20.7753954924],[302375e-11,4.48618007156,3532.0606928114],[274027e-11,.54222167059,3340.545116397],[281079e-11,5.88163521788,1349.8674096588],[231183e-11,1.28242156993,3870.3033917944],[283602e-11,5.7688543494,3149.1641605882],[236117e-11,5.75503217933,3333.498879699],[274033e-11,.13372524985,3340.6797370026],[299395e-11,2.78323740866,6254.6266625236]],[[3340.61242700512,0,0],[.01457554523,3.60433733236,3340.6124266998],[.00168414711,3.92318567804,6681.2248533996],[.00020622975,4.26108844583,10021.8372800994],[3452392e-11,4.7321039319,3.523118349],[2586332e-11,4.60670058555,13362.4497067992],[841535e-11,4.45864030426,2281.2304965106]],[[.00058152577,2.04961712429,3340.6124266998],[.00013459579,2.45738706163,6681.2248533996]]],[[[.03197134986,3.76832042431,3340.6124266998],[.00298033234,4.10616996305,6681.2248533996],[.00289104742,0,0],[.00031365539,4.4465105309,10021.8372800994],[34841e-9,4.7881254926,13362.4497067992]],[[.00217310991,6.04472194776,3340.6124266998],[.00020976948,3.14159265359,0],[.00012834709,1.60810667915,6681.2248533996]]],[[[1.53033488271,0,0],[.1418495316,3.47971283528,3340.6124266998],[.00660776362,3.81783443019,6681.2248533996],[.00046179117,4.15595316782,10021.8372800994],[8109733e-11,5.55958416318,2810.9214616052],[7485318e-11,1.77239078402,5621.8429232104],[5523191e-11,1.3643630377,2281.2304965106],[382516e-10,4.49407183687,13362.4497067992],[2306537e-11,.09081579001,2544.3144198834],[1999396e-11,5.36059617709,3337.0893083508],[2484394e-11,4.9254563992,2942.4634232916],[1960195e-11,4.74249437639,3344.1355450488],[1167119e-11,2.11260868341,5092.1519581158],[1102816e-11,5.00908403998,398.1490034082],[899066e-11,4.40791133207,529.6909650946],[992252e-11,5.83861961952,6151.533888305],[807354e-11,2.10217065501,1059.3819301892],[797915e-11,3.44839203899,796.2980068164],[740975e-11,1.49906336885,2146.1654164752]],[[.01107433345,2.03250524857,3340.6124266998],[.00103175887,2.37071847807,6681.2248533996],[128772e-9,0,0],[.0001081588,2.70888095665,10021.8372800994]],[[.00044242249,.47930604954,3340.6124266998],[8138042e-11,.86998389204,6681.2248533996]]]],Jupiter:[[[[.59954691494,0,0],[.09695898719,5.06191793158,529.6909650946],[.00573610142,1.44406205629,7.1135470008],[.00306389205,5.41734730184,1059.3819301892],[.00097178296,4.14264726552,632.7837393132],[.00072903078,3.64042916389,522.5774180938],[.00064263975,3.41145165351,103.0927742186],[.00039806064,2.29376740788,419.4846438752],[.00038857767,1.27231755835,316.3918696566],[.00027964629,1.7845459182,536.8045120954],[.0001358973,5.7748104079,1589.0728952838],[8246349e-11,3.5822792584,206.1855484372],[8768704e-11,3.63000308199,949.1756089698],[7368042e-11,5.0810119427,735.8765135318],[626315e-10,.02497628807,213.299095438],[6114062e-11,4.51319998626,1162.4747044078],[4905396e-11,1.32084470588,110.2063212194],[5305285e-11,1.30671216791,14.2270940016],[5305441e-11,4.18625634012,1052.2683831884],[4647248e-11,4.69958103684,3.9321532631],[3045023e-11,4.31676431084,426.598190876],[2609999e-11,1.56667394063,846.0828347512],[2028191e-11,1.06376530715,3.1813937377],[1764763e-11,2.14148655117,1066.49547719],[1722972e-11,3.88036268267,1265.5674786264],[1920945e-11,.97168196472,639.897286314],[1633223e-11,3.58201833555,515.463871093],[1431999e-11,4.29685556046,625.6701923124],[973272e-11,4.09764549134,95.9792272178]],[[529.69096508814,0,0],[.00489503243,4.2208293947,529.6909650946],[.00228917222,6.02646855621,7.1135470008],[.00030099479,4.54540782858,1059.3819301892],[.0002072092,5.45943156902,522.5774180938],[.00012103653,.16994816098,536.8045120954],[6067987e-11,4.42422292017,103.0927742186],[5433968e-11,3.98480737746,419.4846438752],[4237744e-11,5.89008707199,14.2270940016]],[[.00047233601,4.32148536482,7.1135470008],[.00030649436,2.929777887,529.6909650946],[.00014837605,3.14159265359,0]]],[[[.02268615702,3.55852606721,529.6909650946],[.00109971634,3.90809347197,1059.3819301892],[.00110090358,0,0],[8101428e-11,3.60509572885,522.5774180938],[6043996e-11,4.25883108339,1589.0728952838],[6437782e-11,.30627119215,536.8045120954]],[[.00078203446,1.52377859742,529.6909650946]]],[[[5.20887429326,0,0],[.25209327119,3.49108639871,529.6909650946],[.00610599976,3.84115365948,1059.3819301892],[.00282029458,2.57419881293,632.7837393132],[.00187647346,2.07590383214,522.5774180938],[.00086792905,.71001145545,419.4846438752],[.00072062974,.21465724607,536.8045120954],[.00065517248,5.9799588479,316.3918696566],[.00029134542,1.67759379655,103.0927742186],[.00030135335,2.16132003734,949.1756089698],[.00023453271,3.54023522184,735.8765135318],[.00022283743,4.19362594399,1589.0728952838],[.00023947298,.2745803748,7.1135470008],[.00013032614,2.96042965363,1162.4747044078],[970336e-10,1.90669633585,206.1855484372],[.00012749023,2.71550286592,1052.2683831884],[7057931e-11,2.18184839926,1265.5674786264],[6137703e-11,6.26418240033,846.0828347512],[2616976e-11,2.00994012876,1581.959348283]],[[.0127180152,2.64937512894,529.6909650946],[.00061661816,3.00076460387,1059.3819301892],[.00053443713,3.89717383175,522.5774180938],[.00031185171,4.88276958012,536.8045120954],[.00041390269,0,0]]]],Saturn:[[[[.87401354025,0,0],[.11107659762,3.96205090159,213.299095438],[.01414150957,4.58581516874,7.1135470008],[.00398379389,.52112032699,206.1855484372],[.00350769243,3.30329907896,426.598190876],[.00206816305,.24658372002,103.0927742186],[792713e-9,3.84007056878,220.4126424388],[.00023990355,4.66976924553,110.2063212194],[.00016573588,.43719228296,419.4846438752],[.00014906995,5.76903183869,316.3918696566],[.0001582029,.93809155235,632.7837393132],[.00014609559,1.56518472,3.9321532631],[.00013160301,4.44891291899,14.2270940016],[.00015053543,2.71669915667,639.897286314],[.00013005299,5.98119023644,11.0457002639],[.00010725067,3.12939523827,202.2533951741],[5863206e-11,.23656938524,529.6909650946],[5227757e-11,4.20783365759,3.1813937377],[6126317e-11,1.76328667907,277.0349937414],[5019687e-11,3.17787728405,433.7117378768],[459255e-10,.61977744975,199.0720014364],[4005867e-11,2.24479718502,63.7358983034],[2953796e-11,.98280366998,95.9792272178],[387367e-10,3.22283226966,138.5174968707],[2461186e-11,2.03163875071,735.8765135318],[3269484e-11,.77492638211,949.1756089698],[1758145e-11,3.2658010994,522.5774180938],[1640172e-11,5.5050445305,846.0828347512],[1391327e-11,4.02333150505,323.5054166574],[1580648e-11,4.37265307169,309.2783226558],[1123498e-11,2.83726798446,415.5524906121],[1017275e-11,3.71700135395,227.5261894396],[848642e-11,3.1915017083,209.3669421749]],[[213.2990952169,0,0],[.01297370862,1.82834923978,213.299095438],[.00564345393,2.88499717272,7.1135470008],[.00093734369,1.06311793502,426.598190876],[.00107674962,2.27769131009,206.1855484372],[.00040244455,2.04108104671,220.4126424388],[.00019941774,1.2795439047,103.0927742186],[.00010511678,2.7488034213,14.2270940016],[6416106e-11,.38238295041,639.897286314],[4848994e-11,2.43037610229,419.4846438752],[4056892e-11,2.92133209468,110.2063212194],[3768635e-11,3.6496533078,3.9321532631]],[[.0011644133,1.17988132879,7.1135470008],[.00091841837,.0732519584,213.299095438],[.00036661728,0,0],[.00015274496,4.06493179167,206.1855484372]]],[[[.04330678039,3.60284428399,213.299095438],[.00240348302,2.85238489373,426.598190876],[.00084745939,0,0],[.00030863357,3.48441504555,220.4126424388],[.00034116062,.57297307557,206.1855484372],[.0001473407,2.11846596715,639.897286314],[9916667e-11,5.79003188904,419.4846438752],[6993564e-11,4.7360468972,7.1135470008],[4807588e-11,5.43305312061,316.3918696566]],[[.00198927992,4.93901017903,213.299095438],[.00036947916,3.14159265359,0],[.00017966989,.5197943111,426.598190876]]],[[[9.55758135486,0,0],[.52921382865,2.39226219573,213.299095438],[.01873679867,5.2354960466,206.1855484372],[.01464663929,1.64763042902,426.598190876],[.00821891141,5.93520042303,316.3918696566],[.00547506923,5.0153261898,103.0927742186],[.0037168465,2.27114821115,220.4126424388],[.00361778765,3.13904301847,7.1135470008],[.00140617506,5.70406606781,632.7837393132],[.00108974848,3.29313390175,110.2063212194],[.00069006962,5.94099540992,419.4846438752],[.00061053367,.94037691801,639.897286314],[.00048913294,1.55733638681,202.2533951741],[.00034143772,.19519102597,277.0349937414],[.00032401773,5.47084567016,949.1756089698],[.00020936596,.46349251129,735.8765135318],[9796004e-11,5.20477537945,1265.5674786264],[.00011993338,5.98050967385,846.0828347512],[208393e-9,1.52102476129,433.7117378768],[.00015298404,3.0594381494,529.6909650946],[6465823e-11,.17732249942,1052.2683831884],[.00011380257,1.7310542704,522.5774180938],[3419618e-11,4.94550542171,1581.959348283]],[[.0618298134,.2584351148,213.299095438],[.00506577242,.71114625261,206.1855484372],[.00341394029,5.79635741658,426.598190876],[.00188491195,.47215589652,220.4126424388],[.00186261486,3.14159265359,0],[.00143891146,1.40744822888,7.1135470008]],[[.00436902572,4.78671677509,213.299095438]]]],Uranus:[[[[5.48129294297,0,0],[.09260408234,.89106421507,74.7815985673],[.01504247898,3.6271926092,1.4844727083],[.00365981674,1.89962179044,73.297125859],[.00272328168,3.35823706307,149.5631971346],[.00070328461,5.39254450063,63.7358983034],[.00068892678,6.09292483287,76.2660712756],[.00061998615,2.26952066061,2.9689454166],[.00061950719,2.85098872691,11.0457002639],[.0002646877,3.14152083966,71.8126531507],[.00025710476,6.11379840493,454.9093665273],[.0002107885,4.36059339067,148.0787244263],[.00017818647,1.74436930289,36.6485629295],[.00014613507,4.73732166022,3.9321532631],[.00011162509,5.8268179635,224.3447957019],[.0001099791,.48865004018,138.5174968707],[9527478e-11,2.95516862826,35.1640902212],[7545601e-11,5.236265824,109.9456887885],[4220241e-11,3.23328220918,70.8494453042],[40519e-9,2.277550173,151.0476698429],[3354596e-11,1.0654900738,4.4534181249],[2926718e-11,4.62903718891,9.5612275556],[349034e-10,5.48306144511,146.594251718],[3144069e-11,4.75199570434,77.7505439839],[2922333e-11,5.35235361027,85.8272988312],[2272788e-11,4.36600400036,70.3281804424],[2051219e-11,1.51773566586,.1118745846],[2148602e-11,.60745949945,38.1330356378],[1991643e-11,4.92437588682,277.0349937414],[1376226e-11,2.04283539351,65.2203710117],[1666902e-11,3.62744066769,380.12776796],[1284107e-11,3.11347961505,202.2533951741],[1150429e-11,.93343589092,3.1813937377],[1533221e-11,2.58594681212,52.6901980395],[1281604e-11,.54271272721,222.8603229936],[1372139e-11,4.19641530878,111.4301614968],[1221029e-11,.1990065003,108.4612160802],[946181e-11,1.19253165736,127.4717966068],[1150989e-11,4.17898916639,33.6796175129]],[[74.7815986091,0,0],[.00154332863,5.24158770553,74.7815985673],[.00024456474,1.71260334156,1.4844727083],[9258442e-11,.4282973235,11.0457002639],[8265977e-11,1.50218091379,63.7358983034],[915016e-10,1.41213765216,149.5631971346]]],[[[.01346277648,2.61877810547,74.7815985673],[623414e-9,5.08111189648,149.5631971346],[.00061601196,3.14159265359,0],[9963722e-11,1.61603805646,76.2660712756],[992616e-10,.57630380333,73.297125859]],[[.00034101978,.01321929936,74.7815985673]]],[[[19.21264847206,0,0],[.88784984413,5.60377527014,74.7815985673],[.03440836062,.32836099706,73.297125859],[.0205565386,1.7829515933,149.5631971346],[.0064932241,4.52247285911,76.2660712756],[.00602247865,3.86003823674,63.7358983034],[.00496404167,1.40139935333,454.9093665273],[.00338525369,1.58002770318,138.5174968707],[.00243509114,1.57086606044,71.8126531507],[.00190522303,1.99809394714,1.4844727083],[.00161858838,2.79137786799,148.0787244263],[.00143706183,1.38368544947,11.0457002639],[.00093192405,.17437220467,36.6485629295],[.00071424548,4.24509236074,224.3447957019],[.00089806014,3.66105364565,109.9456887885],[.00039009723,1.66971401684,70.8494453042],[.00046677296,1.39976401694,35.1640902212],[.00039025624,3.36234773834,277.0349937414],[.00036755274,3.88649278513,146.594251718],[.00030348723,.70100838798,151.0476698429],[.00029156413,3.180563367,77.7505439839],[.00022637073,.72518687029,529.6909650946],[.00011959076,1.7504339214,984.6003316219],[.00025620756,5.25656086672,380.12776796]],[[.01479896629,3.67205697578,74.7815985673]]]],Neptune:[[[[5.31188633046,0,0],[.0179847553,2.9010127389,38.1330356378],[.01019727652,.48580922867,1.4844727083],[.00124531845,4.83008090676,36.6485629295],[.00042064466,5.41054993053,2.9689454166],[.00037714584,6.09221808686,35.1640902212],[.00033784738,1.24488874087,76.2660712756],[.00016482741,7727998e-11,491.5579294568],[9198584e-11,4.93747051954,39.6175083461],[899425e-10,.27462171806,175.1660598002]],[[38.13303563957,0,0],[.00016604172,4.86323329249,1.4844727083],[.00015744045,2.27887427527,38.1330356378]]],[[[.03088622933,1.44104372644,38.1330356378],[.00027780087,5.91271884599,76.2660712756],[.00027623609,0,0],[.00015355489,2.52123799551,36.6485629295],[.00015448133,3.50877079215,39.6175083461]]],[[[30.07013205828,0,0],[.27062259632,1.32999459377,38.1330356378],[.01691764014,3.25186135653,36.6485629295],[.00807830553,5.18592878704,1.4844727083],[.0053776051,4.52113935896,35.1640902212],[.00495725141,1.5710564165,491.5579294568],[.00274571975,1.84552258866,175.1660598002],[.0001201232,1.92059384991,1021.2488945514],[.00121801746,5.79754470298,76.2660712756],[.00100896068,.3770272493,73.297125859],[.00135134092,3.37220609835,39.6175083461],[7571796e-11,1.07149207335,388.4651552382]]]]};let Ti=function(e){var t,n,r,i;const a=2e3+(e-14)/365.24217;return a<-500?32*(t=(a-1820)/100)*t-20:a<500?10583.6-1014.41*(t=a/100)+33.78311*(n=t*t)-5.952053*(r=t*n)-.1798452*(i=n*n)+.022174192*(n*r)+.0090316521*(r*r):a<1600?1574.2-556.01*(t=(a-1e3)/100)+71.23472*(n=t*t)+.319781*(r=t*n)-.8503463*(i=n*n)-.005050998*(n*r)+.0083572073*(r*r):a<1700?120-.9808*(t=a-1600)-.01532*(n=t*t)+(r=t*n)/7129:a<1800?8.83+.1603*(t=a-1700)-.0059285*(n=t*t)+13336e-8*(r=t*n)-(i=n*n)/1174e3:a<1860?13.72-.332447*(t=a-1800)+.0068612*(n=t*t)+.0041116*(r=t*n)-37436e-8*(i=n*n)+121272e-10*(n*r)-1.699e-7*(r*r)+8.75e-10*(r*i):a<1900?7.62+.5737*(t=a-1860)-.251754*(n=t*t)+.01680668*(r=t*n)-.0004473624*(i=n*n)+n*r/233174:a<1920?1.494119*(t=a-1900)-2.79-.0598939*(n=t*t)+.0061966*(r=t*n)-197e-6*(i=n*n):a<1941?21.2+.84493*(t=a-1920)-.0761*(n=t*t)+.0020936*(r=t*n):a<1961?29.07+.407*(t=a-1950)-(n=t*t)/233+(r=t*n)/2547:a<1986?45.45+1.067*(t=a-1975)-(n=t*t)/260-(r=t*n)/718:a<2005?63.86+.3345*(t=a-2e3)-.060374*(n=t*t)+.0017275*(r=t*n)+651814e-9*(i=n*n)+2373599e-11*(n*r):a<2050?62.92+.32217*(t=a-2e3)+.005589*t*t:a<2150?32*(t=(a-1820)/100)*t-20-.5628*(2150-a):32*(t=(a-1820)/100)*t-20};function Si(e){return e+Ti(e)/86400}let Ei=class e{constructor(t){if(t instanceof e)return this.date=t.date,this.ut=t.ut,void(this.tt=t.tt);const n=864e5;if(t instanceof Date&&Number.isFinite(t.getTime()))return this.date=t,this.ut=(t.getTime()-ni.getTime())/n,void(this.tt=Si(this.ut));if(Number.isFinite(t))return this.date=new Date(ni.getTime()+t*n),this.ut=t,void(this.tt=Si(this.ut));throw"Argument must be a Date object, an AstroTime object, or a numeric UTC Julian date."}static FromTerrestrialTime(t){let n=new e(t);for(;;){const e=t-n.tt;if(Math.abs(e)<1e-12)return n;n=n.AddDays(e)}}toString(){return this.date.toISOString()}AddDays(t){return new e(this.ut+t)}};function Ri(e){return e instanceof Ei?e:new Ei(e)}function xi(e){var t=e.tt/36525;return(((((-4.34e-8*t-576e-9)*t+.0020034)*t-1831e-7)*t-46.836769)*t+84381.406)/3600}var Ai;function Ii(e){if(!Ai||Math.abs(Ai.tt-e.tt)>1e-6){const t=function(e){function t(e){return e%1296e3*ai}const n=e.tt/36525,r=t(1287104.79305+129596581.0481*n),i=t(335779.526232+1739527262.8478*n),a=t(1072260.70369+1602961601.209*n),o=t(450160.398036-6962890.5431*n);let s=Math.sin(o),c=Math.cos(o),u=(-172064161-174666*n)*s+33386*c,d=(92052331+9086*n)*c+15377*s,m=2*(i-a+o);return s=Math.sin(m),c=Math.cos(m),u+=(-13170906-1675*n)*s-13696*c,d+=(5730336-3015*n)*c-4587*s,m=2*(i+o),s=Math.sin(m),c=Math.cos(m),u+=(-2276413-234*n)*s+2796*c,d+=(978459-485*n)*c+1374*s,m=2*o,s=Math.sin(m),c=Math.cos(m),u+=(2074554+207*n)*s-698*c,d+=(470*n-897492)*c-291*s,s=Math.sin(r),c=Math.cos(r),u+=(1475877-3633*n)*s+11817*c,d+=(73871-184*n)*c-1924*s,{dpsi:1e-7*u-135e-6,deps:388e-6+1e-7*d}}(e),n=xi(e),r=n+t.deps/3600;Ai={tt:e.tt,dpsi:t.dpsi,deps:t.deps,ee:t.dpsi*Math.cos(n*ti)/15,mobl:n,tobl:r}}return Ai}function yi(e,t){return function(e,t){const n=e*ti,r=Math.cos(n),i=Math.sin(n);return[t[0],t[1]*r-t[2]*i,t[1]*i+t[2]*r]}(xi(e),t)}function Ni(e,t){const n=e.tt/36525;let r=84381.406,i=((((-9.51e-8*n+132851e-9)*n-.00114045)*n-1.0790069)*n+5038.481507)*n,a=((((3.337e-7*n-467e-9)*n-.00772503)*n+.0512623)*n-.025754)*n+r,o=((((-56e-9*n+170663e-9)*n-.00121197)*n-2.3814292)*n+10.556403)*n;r*=ai,i*=ai,a*=ai,o*=ai;const s=Math.sin(r),c=Math.cos(r),u=Math.sin(-i),d=Math.cos(-i),m=Math.sin(-a),l=Math.cos(-a),h=Math.sin(o),p=Math.cos(o),_=p*d-u*h*l,g=p*u*c+h*l*d*c-s*h*m,f=p*u*s+h*l*d*s+c*h*m,v=-h*d-u*p*l,T=-h*u*c+p*l*d*c-s*p*m,S=-h*u*s+p*l*d*s+c*p*m,E=u*m,R=-m*d*c-s*l,x=-m*d*s+l*c;if(t===fi.Into2000)return new Mi([[_,g,f],[v,T,S],[E,R,x]]);if(t===fi.From2000)return new Mi([[_,v,E],[g,T,R],[f,S,x]]);throw"Invalid precess direction"}let wi;function Ci(e){return function(e){if(!wi||wi.tt!==e.tt){const t=e.tt/36525;let n=15*Ii(e).ee;const r=function(e){let t=(.779057273264+.00273781191135448*e.ut+e.ut%1)%1*360;return t<0&&(t+=360),t}(e);let i=((n+.014506+((((-3.68e-8*t-29956e-9)*t-44e-8)*t+1.3915817)*t+4612.156534)*t)/3600+r)%360/15;i<0&&(i+=24),wi={tt:e.tt,st:i}}return wi.st}(Ri(e))}class bi{constructor(e,t,n,r){this.x=e,this.y=t,this.z=n,this.t=r}Length(){return Math.hypot(this.x,this.y,this.z)}}class Oi{constructor(e,t,n,r,i,a,o){this.x=e,this.y=t,this.z=n,this.vx=r,this.vy=i,this.vz=a,this.t=o}}class Di{constructor(e,t,n){this.lat=mi(e),this.lon=mi(t),this.dist=mi(n)}}class Mi{constructor(e){this.rot=e}}function Li(e){const t=Ri(e),n=function(e){const t=e.tt/36525;function n(e,t){const n=[];let r;for(r=0;r<=t-e;++r)n.push(0);return{min:e,array:n}}function r(e,t,r,i){const a=[];for(let o=0;o<=t-e;++o)a.push(n(r,i));return{min:e,array:a}}function i(e,t,n){const r=e.array[t-e.min];return r.array[n-r.min]}function a(e,t,n,r){const i=e.array[t-e.min];i.array[n-i.min]=r}let o,s,c,u,d,m,l,h,p,_,g,f,v,T,S,E,R,x,A,I,y,N,w,C=r(-6,6,1,4),b=r(-6,6,1,4);function O(e,t){return i(C,e,t)}function D(e,t){return i(b,e,t)}function M(e,t,n){return a(C,e,t,n)}function L(e,t,n){return a(b,e,t,n)}function P(e,t,n,r,i){i(e*n-t*r,t*n+e*r)}function U(e){return Math.sin(ri*e)}l=t*t,p=0,w=0,g=0,f=3422.7;var G=U(.19833+.05611*t),H=U(.27869+.04508*t),F=U(.16827-.36903*t),B=U(.34734-5.37261*t),z=U(.10498-5.37899*t),k=U(.42681-.41855*t);for(x=.84*G+.31*H+14.27*F+7.26*B+.28*z+.24*k,A=2.94*G+.31*H+14.27*F+9.34*B+1.12*z+.83*k,I=-6.4*G-1.89*k,y=.21*G+.31*H+14.27*F-88.7*B-15.3*z+.24*k-1.86*U(.14943-5.37511*t),N=x-I,h=-3332e-9*U(.59734-5.37261*t)-539e-9*U(.35498-5.37899*t)-64e-9*U(.39943-5.37511*t),v=ri*li(.60643382+1336.85522467*t-313e-8*l)+x/ii,T=ri*li(.37489701+1325.55240982*t+2565e-8*l)+A/ii,S=ri*li(.99312619+99.99735956*t-44e-8*l)+I/ii,E=ri*li(.25909118+1342.2278298*t-892e-8*l)+y/ii,R=ri*li(.82736186+1236.85308708*t-397e-8*l)+N/ii,d=1;d<=4;++d){switch(d){case 1:c=T,s=4,u=1.000002208;break;case 2:c=S,s=3,u=.997504612-.002495388*t;break;case 3:c=E,s=4,u=1.000002708+139.978*h;break;case 4:c=R,s=6,u=1;break;default:throw`Internal error: I = ${d}`}for(M(0,d,1),M(1,d,Math.cos(c)*u),L(0,d,0),L(1,d,Math.sin(c)*u),m=2;m<=s;++m)P(O(m-1,d),D(m-1,d),O(1,d),D(1,d),(e,t)=>(M(m,d,e),L(m,d,t)));for(m=1;m<=s;++m)M(-m,d,O(m,d)),L(-m,d,-D(m,d))}function W(e,t,n,r){for(var i={x:1,y:0},a=[0,e,t,n,r],o=1;o<=4;++o)0!==a[o]&&P(i.x,i.y,O(a[o],o),D(a[o],o),(e,t)=>(i.x=e,i.y=t));return i}function Y(e,t,n,r,i,a,o,s){var c=W(i,a,o,s);p+=e*c.y,w+=t*c.y,g+=n*c.x,f+=r*c.x}function V(e,t,n,r,i){return e*W(t,n,r,i).y}Y(13.902,14.06,-.001,.2607,0,0,0,4),Y(.403,-4.01,.394,.0023,0,0,0,3),Y(2369.912,2373.36,.601,28.2333,0,0,0,2),Y(-125.154,-112.79,-.725,-.9781,0,0,0,1),Y(1.979,6.98,-.445,.0433,1,0,0,4),Y(191.953,192.72,.029,3.0861,1,0,0,2),Y(-8.466,-13.51,.455,-.1093,1,0,0,1),Y(22639.5,22609.07,.079,186.5398,1,0,0,0),Y(18.609,3.59,-.094,.0118,1,0,0,-1),Y(-4586.465,-4578.13,-.077,34.3117,1,0,0,-2),Y(3.215,5.44,.192,-.0386,1,0,0,-3),Y(-38.428,-38.64,.001,.6008,1,0,0,-4),Y(-.393,-1.43,-.092,.0086,1,0,0,-6),Y(-.289,-1.59,.123,-.0053,0,1,0,4),Y(-24.42,-25.1,.04,-.3,0,1,0,2),Y(18.023,17.93,.007,.1494,0,1,0,1),Y(-668.146,-126.98,-1.302,-.3997,0,1,0,0),Y(.56,.32,-.001,-.0037,0,1,0,-1),Y(-165.145,-165.06,.054,1.9178,0,1,0,-2),Y(-1.877,-6.46,-.416,.0339,0,1,0,-4),Y(.213,1.02,-.074,.0054,2,0,0,4),Y(14.387,14.78,-.017,.2833,2,0,0,2),Y(-.586,-1.2,.054,-.01,2,0,0,1),Y(769.016,767.96,.107,10.1657,2,0,0,0),Y(1.75,2.01,-.018,.0155,2,0,0,-1),Y(-211.656,-152.53,5.679,-.3039,2,0,0,-2),Y(1.225,.91,-.03,-.0088,2,0,0,-3),Y(-30.773,-34.07,-.308,.3722,2,0,0,-4),Y(-.57,-1.4,-.074,.0109,2,0,0,-6),Y(-2.921,-11.75,.787,-.0484,1,1,0,2),Y(1.267,1.52,-.022,.0164,1,1,0,1),Y(-109.673,-115.18,.461,-.949,1,1,0,0),Y(-205.962,-182.36,2.056,1.4437,1,1,0,-2),Y(.233,.36,.012,-.0025,1,1,0,-3),Y(-4.391,-9.66,-.471,.0673,1,1,0,-4),Y(.283,1.53,-.111,.006,1,-1,0,4),Y(14.577,31.7,-1.54,.2302,1,-1,0,2),Y(147.687,138.76,.679,1.1528,1,-1,0,0),Y(-1.089,.55,.021,0,1,-1,0,-1),Y(28.475,23.59,-.443,-.2257,1,-1,0,-2),Y(-.276,-.38,-.006,-.0036,1,-1,0,-3),Y(.636,2.27,.146,-.0102,1,-1,0,-4),Y(-.189,-1.68,.131,-.0028,0,2,0,2),Y(-7.486,-.66,-.037,-.0086,0,2,0,0),Y(-8.096,-16.35,-.74,.0918,0,2,0,-2),Y(-5.741,-.04,0,-9e-4,0,0,2,2),Y(.255,0,0,0,0,0,2,1),Y(-411.608,-.2,0,-.0124,0,0,2,0),Y(.584,.84,0,.0071,0,0,2,-1),Y(-55.173,-52.14,0,-.1052,0,0,2,-2),Y(.254,.25,0,-.0017,0,0,2,-3),Y(.025,-1.67,0,.0031,0,0,2,-4),Y(1.06,2.96,-.166,.0243,3,0,0,2),Y(36.124,50.64,-1.3,.6215,3,0,0,0),Y(-13.193,-16.4,.258,-.1187,3,0,0,-2),Y(-1.187,-.74,.042,.0074,3,0,0,-4),Y(-.293,-.31,-.002,.0046,3,0,0,-6),Y(-.29,-1.45,.116,-.0051,2,1,0,2),Y(-7.649,-10.56,.259,-.1038,2,1,0,0),Y(-8.627,-7.59,.078,-.0192,2,1,0,-2),Y(-2.74,-2.54,.022,.0324,2,1,0,-4),Y(1.181,3.32,-.212,.0213,2,-1,0,2),Y(9.703,11.67,-.151,.1268,2,-1,0,0),Y(-.352,-.37,.001,-.0028,2,-1,0,-1),Y(-2.494,-1.17,-.003,-.0017,2,-1,0,-2),Y(.36,.2,-.012,-.0043,2,-1,0,-4),Y(-1.167,-1.25,.008,-.0106,1,2,0,0),Y(-7.412,-6.12,.117,.0484,1,2,0,-2),Y(-.311,-.65,-.032,.0044,1,2,0,-4),Y(.757,1.82,-.105,.0112,1,-2,0,2),Y(2.58,2.32,.027,.0196,1,-2,0,0),Y(2.533,2.4,-.014,-.0212,1,-2,0,-2),Y(-.344,-.57,-.025,.0036,0,3,0,-2),Y(-.992,-.02,0,0,1,0,2,2),Y(-45.099,-.02,0,-.001,1,0,2,0),Y(-.179,-9.52,0,-.0833,1,0,2,-2),Y(-.301,-.33,0,.0014,1,0,2,-4),Y(-6.382,-3.37,0,-.0481,1,0,-2,2),Y(39.528,85.13,0,-.7136,1,0,-2,0),Y(9.366,.71,0,-.0112,1,0,-2,-2),Y(.202,.02,0,0,1,0,-2,-4),Y(.415,.1,0,.0013,0,1,2,0),Y(-2.152,-2.26,0,-.0066,0,1,2,-2),Y(-1.44,-1.3,0,.0014,0,1,-2,2),Y(.384,-.04,0,0,0,1,-2,-2),Y(1.938,3.6,-.145,.0401,4,0,0,0),Y(-.952,-1.58,.052,-.013,4,0,0,-2),Y(-.551,-.94,.032,-.0097,3,1,0,0),Y(-.482,-.57,.005,-.0045,3,1,0,-2),Y(.681,.96,-.026,.0115,3,-1,0,0),Y(-.297,-.27,.002,-9e-4,2,2,0,-2),Y(.254,.21,-.003,0,2,-2,0,-2),Y(-.25,-.22,.004,.0014,1,3,0,-2),Y(-3.996,0,0,4e-4,2,0,2,0),Y(.557,-.75,0,-.009,2,0,2,-2),Y(-.459,-.38,0,-.0053,2,0,-2,2),Y(-1.298,.74,0,4e-4,2,0,-2,0),Y(.538,1.14,0,-.0141,2,0,-2,-2),Y(.263,.02,0,0,1,1,2,0),Y(.426,.07,0,-6e-4,1,1,-2,-2),Y(-.304,.03,0,3e-4,1,-1,2,0),Y(-.372,-.19,0,-.0027,1,-1,-2,2),Y(.418,0,0,0,0,0,4,0),Y(-.33,-.04,0,0,3,0,2,0),_=0,_+=V(-526.069,0,0,1,-2),_+=V(-3.352,0,0,1,-4),_+=V(44.297,1,0,1,-2),_+=V(-6,1,0,1,-4),_+=V(20.599,-1,0,1,0),_+=V(-30.598,-1,0,1,-2),_+=V(-24.649,-2,0,1,0),_+=V(-2,-2,0,1,-2),_+=V(-22.571,0,1,1,-2),_+=V(10.985,0,-1,1,-2),p+=.82*U(.7736-62.5512*t)+.31*U(.0466-125.1025*t)+.35*U(.5785-25.1042*t)+.66*U(.4591+1335.8075*t)+.64*U(.313-91.568*t)+1.14*U(.148+1331.2898*t)+.21*U(.5918+1056.5859*t)+.44*U(.5784+1322.8595*t)+.24*U(.2275-5.7374*t)+.28*U(.2965+2.6929*t)+.33*U(.3132+6.3368*t),o=E+w/ii;let X=(1.000002708+139.978*h)*(18518.511+1.189+g)*Math.sin(o)-6.24*Math.sin(3*o)+_;return{geo_eclip_lon:ri*li((v+p/ii)/ri),geo_eclip_lat:Math.PI/648e3*X,distance_au:4263520978299708e-20*ii/(.999953253*f)}}(t),r=n.distance_au*Math.cos(n.geo_eclip_lat),i=function(e,t,n){return function(e,t){return[e.rot[0][0]*t[0]+e.rot[1][0]*t[1]+e.rot[2][0]*t[2],e.rot[0][1]*t[0]+e.rot[1][1]*t[1]+e.rot[2][1]*t[2],e.rot[0][2]*t[0]+e.rot[1][2]*t[1]+e.rot[2][2]*t[2]]}(Ni(t,n),e)}(yi(t,[r*Math.cos(n.geo_eclip_lon),r*Math.sin(n.geo_eclip_lon),n.distance_au*Math.sin(n.geo_eclip_lat)]),t,fi.Into2000);return new bi(i[0],i[1],i[2],t)}function Pi(e,t,n){let r=1,i=0;for(let a of e){let e=0;for(let[n,r,i]of a)e+=n*Math.cos(r+t*i);let o=r*e;n&&(o%=ri),i+=o,r*=t}return i}function Ui(e,t){let n=1,r=0,i=0,a=0;for(let o of e){let e=0,s=0;for(let[n,r,i]of o){let o=r+t*i;e+=n*i*Math.sin(o),a>0&&(s+=n*Math.cos(o))}i+=a*r*s-n*e,r=n,n*=t,++a}return i}const Gi=365250;function Hi(e){return new Yi(e[0]+4.4036e-7*e[1]-1.90919e-7*e[2],-4.79966e-7*e[0]+.917482137087*e[1]-.397776982902*e[2],.397776982902*e[1]+.917482137087*e[2])}function Fi(e,t,n){const r=n*Math.cos(t);return[r*Math.cos(e),r*Math.sin(e),n*Math.sin(t)]}function Bi(e,t){const n=t.tt/Gi;return Hi(Fi(Pi(e[0],n,!0),Pi(e[1],n,!1),Pi(e[2],n,!1))).ToAstroVector(t)}function zi(e,t,n,r){const i=r/(r+oi),a=Bi(vi[n],t);e.x+=i*a.x,e.y+=i*a.y,e.z+=i*a.z}const ki=146,Wi=[[-73e4,[-26.118207232108,-14.376168177825,3.384402515299],[.0016339372163656,-.0027861699588508,-.0013585880229445]],[-700800,[41.974905202127,-.448502952929,-12.770351505989],[.00073458569351457,.0022785014891658,.00048619778602049]],[-671600,[14.706930780744,44.269110540027,9.353698474772],[-.00210001479998,.00022295915939915,.00070143443551414]],[-642400,[-29.441003929957,-6.43016153057,6.858481011305],[.00084495803960544,-.0030783914758711,-.0012106305981192]],[-613200,[39.444396946234,-6.557989760571,-13.913760296463],[.0011480029005873,.0022400006880665,.00035168075922288]],[-584e3,[20.2303809507,43.266966657189,7.382966091923],[-.0019754081700585,.00053457141292226,.00075929169129793]],[-554800,[-30.65832536462,2.093818874552,9.880531138071],[61010603013347e-18,-.0031326500935382,-.00099346125151067]],[-525600,[35.737703251673,-12.587706024764,-14.677847247563],[.0015802939375649,.0021347678412429,.00019074436384343]],[-496400,[25.466295188546,41.367478338417,5.216476873382],[-.0018054401046468,.0008328308359951,.00080260156912107]],[-467200,[-29.847174904071,10.636426313081,12.297904180106],[-.00063257063052907,-.0029969577578221,-.00074476074151596]],[-438e3,[30.774692107687,-18.236637015304,-14.945535879896],[.0020113162005465,.0019353827024189,-20937793168297e-19]],[-408800,[30.243153324028,38.656267888503,2.938501750218],[-.0016052508674468,.0011183495337525,.00083333973416824]],[-379600,[-27.288984772533,18.643162147874,14.023633623329],[-.0011856388898191,-.0027170609282181,-.00049015526126399]],[-350400,[24.519605196774,-23.245756064727,-14.626862367368],[.0024322321483154,.0016062008146048,-.00023369181613312]],[-321200,[34.505274805875,35.125338586954,.557361475637],[-.0013824391637782,.0013833397561817,.00084823598806262]],[-292e3,[-23.275363915119,25.818514298769,15.055381588598],[-.0016062295460975,-.0023395961498533,-.00024377362639479]],[-262800,[17.050384798092,-27.180376290126,-13.608963321694],[.0028175521080578,.0011358749093955,-.00049548725258825]],[-233600,[38.093671910285,30.880588383337,-1.843688067413],[-.0011317697153459,.0016128814698472,.00084177586176055]],[-204400,[-18.197852930878,31.932869934309,15.438294826279],[-.0019117272501813,-.0019146495909842,-19657304369835e-18]],[-175200,[8.528924039997,-29.618422200048,-11.805400994258],[.0031034370787005,.0005139363329243,-.00077293066202546]],[-146e3,[40.94685725864,25.904973592021,-4.256336240499],[-.00083652705194051,.0018129497136404,.0008156422827306]],[-116800,[-12.326958895325,36.881883446292,15.217158258711],[-.0021166103705038,-.001481442003599,.00017401209844705]],[-87600,[-.633258375909,-30.018759794709,-9.17193287495],[.0032016994581737,-.00025279858672148,-.0010411088271861]],[-58400,[42.936048423883,20.344685584452,-6.588027007912],[-.00050525450073192,.0019910074335507,.00077440196540269]],[-29200,[-5.975910552974,40.61180995846,14.470131723673],[-.0022184202156107,-.0010562361130164,.00033652250216211]],[0,[-9.875369580774,-27.978926224737,-5.753711824704],[.0030287533248818,-.0011276087003636,-.0012651326732361]],[29200,[43.958831986165,14.214147973292,-8.808306227163],[-.00014717608981871,.0021404187242141,.00071486567806614]],[58400,[.67813676352,43.094461639362,13.243238780721],[-.0022358226110718,-.00063233636090933,.00047664798895648]],[87600,[-18.282602096834,-23.30503958666,-1.766620508028],[.0025567245263557,-.0019902940754171,-.0013943491701082]],[116800,[43.873338744526,7.700705617215,-10.814273666425],[.00023174803055677,.0022402163127924,.00062988756452032]],[146e3,[7.392949027906,44.382678951534,11.629500214854],[-.002193281545383,-.00021751799585364,.00059556516201114]],[175200,[-24.981690229261,-16.204012851426,2.466457544298],[.001819398914958,-.0026765419531201,-.0013848283502247]],[204400,[42.530187039511,.845935508021,-12.554907527683],[.00065059779150669,.0022725657282262,.00051133743202822]],[233600,[13.999526486822,44.462363044894,9.669418486465],[-.0021079296569252,.00017533423831993,.00069128485798076]],[262800,[-29.184024803031,-7.371243995762,6.493275957928],[.00093581363109681,-.0030610357109184,-.0012364201089345]],[292e3,[39.831980671753,-6.078405766765,-13.909815358656],[.0011117769689167,.0022362097830152,.00036230548231153]],[321200,[20.294955108476,43.417190420251,7.450091985932],[-.0019742157451535,.00053102050468554,.00075938408813008]],[350400,[-30.66999230216,2.318743558955,9.973480913858],[45605107450676e-18,-.0031308219926928,-.00099066533301924]],[379600,[35.626122155983,-12.897647509224,-14.777586508444],[.0016015684949743,.0021171931182284,.00018002516202204]],[408800,[26.133186148561,41.232139187599,5.00640132622],[-.0017857704419579,.00086046232702817,.00080614690298954]],[438e3,[-29.57674022923,11.863535943587,12.631323039872],[-.00072292830060955,-.0029587820140709,-.000708242964503]],[467200,[29.910805787391,-19.159019294,-15.013363865194],[.0020871080437997,.0018848372554514,-38528655083926e-18]],[496400,[31.375957451819,38.050372720763,2.433138343754],[-.0015546055556611,.0011699815465629,.00083565439266001]],[525600,[-26.360071336928,20.662505904952,14.414696258958],[-.0013142373118349,-.0026236647854842,-.00042542017598193]],[554800,[22.599441488648,-24.508879898306,-14.484045731468],[.0025454108304806,.0014917058755191,-.00030243665086079]],[584e3,[35.877864013014,33.894226366071,-.224524636277],[-.0012941245730845,.0014560427668319,.00084762160640137]],[613200,[-21.538149762417,28.204068269761,15.321973799534],[-.001731211740901,-.0021939631314577,-.0001631691327518]],[642400,[13.971521374415,-28.339941764789,-13.083792871886],[.0029334630526035,.00091860931752944,-.00059939422488627]],[671600,[39.526942044143,28.93989736011,-2.872799527539],[-.0010068481658095,.001702113288809,.00083578230511981]],[700800,[-15.576200701394,34.399412961275,15.466033737854],[-.0020098814612884,-.0017191109825989,70414782780416e-18]],[73e4,[4.24325283709,-30.118201690825,-10.707441231349],[.0031725847067411,.0001609846120227,-.00090672150593868]]];class Yi{constructor(e,t,n){this.x=e,this.y=t,this.z=n}clone(){return new Yi(this.x,this.y,this.z)}ToAstroVector(e){return new bi(this.x,this.y,this.z,e)}static zero(){return new Yi(0,0,0)}quadrature(){return this.x*this.x+this.y*this.y+this.z*this.z}add(e){return new Yi(this.x+e.x,this.y+e.y,this.z+e.z)}sub(e){return new Yi(this.x-e.x,this.y-e.y,this.z-e.z)}incr(e){this.x+=e.x,this.y+=e.y,this.z+=e.z}decr(e){this.x-=e.x,this.y-=e.y,this.z-=e.z}mul(e){return new Yi(e*this.x,e*this.y,e*this.z)}div(e){return new Yi(this.x/e,this.y/e,this.z/e)}mean(e){return new Yi((this.x+e.x)/2,(this.y+e.y)/2,(this.z+e.z)/2)}neg(){return new Yi(-this.x,-this.y,-this.z)}}class Vi{constructor(e,t,n){this.tt=e,this.r=t,this.v=n}clone(){return new Vi(this.tt,this.r,this.v)}sub(e){return new Vi(this.tt,this.r.sub(e.r),this.v.sub(e.v))}}function Xi(e,t,n,r){const i=r/(r+oi),a=function(e,t){const n=t/Gi,r=Pi(e[0],n,!0),i=Pi(e[1],n,!1),a=Pi(e[2],n,!1),o=Ui(e[0],n),s=Ui(e[1],n),c=Ui(e[2],n),u=Math.cos(r),d=Math.sin(r),m=Math.cos(i),l=Math.sin(i),h=+c*m*u-a*l*u*s-a*m*d*o,p=+c*m*d-a*l*d*s+a*m*u*o,_=+c*l+a*m*s,g=Fi(r,i,a),f=[h/Gi,p/Gi,_/Gi],v=Hi(g),T=Hi(f);return new Vi(t,v,T)}(vi[n],t);return e.r.incr(a.r.mul(i)),e.v.incr(a.v.mul(i)),a}function ji(e,t,n){const r=n.sub(e),i=r.quadrature();return r.mul(t/(i*Math.sqrt(i)))}class qi{constructor(e){let t=new Vi(e,new Yi(0,0,0),new Yi(0,0,0));this.Jupiter=Xi(t,e,hi.Jupiter,si),this.Saturn=Xi(t,e,hi.Saturn,ci),this.Uranus=Xi(t,e,hi.Uranus,ui),this.Neptune=Xi(t,e,hi.Neptune,di),this.Jupiter.r.decr(t.r),this.Jupiter.v.decr(t.v),this.Saturn.r.decr(t.r),this.Saturn.v.decr(t.v),this.Uranus.r.decr(t.r),this.Uranus.v.decr(t.v),this.Neptune.r.decr(t.r),this.Neptune.v.decr(t.v),this.Sun=new Vi(e,t.r.mul(-1),t.v.mul(-1))}Acceleration(e){let t=ji(e,oi,this.Sun.r);return t.incr(ji(e,si,this.Jupiter.r)),t.incr(ji(e,ci,this.Saturn.r)),t.incr(ji(e,ui,this.Uranus.r)),t.incr(ji(e,di,this.Neptune.r)),t}}class Ki{constructor(e,t,n,r){this.tt=e,this.r=t,this.v=n,this.a=r}clone(){return new Ki(this.tt,this.r.clone(),this.v.clone(),this.a.clone())}}class Zi{constructor(e,t){this.bary=e,this.grav=t}}function $i(e,t,n,r){return new Yi(t.x+e*(n.x+e*r.x/2),t.y+e*(n.y+e*r.y/2),t.z+e*(n.z+e*r.z/2))}function Qi(e,t,n){return new Yi(t.x+e*n.x,t.y+e*n.y,t.z+e*n.z)}function Ji(e,t){const n=e-t.tt,r=new qi(e),i=$i(n,t.r,t.v,t.a),a=r.Acceleration(i).mean(t.a),o=$i(n,t.r,t.v,a),s=t.v.add(a.mul(n)),c=r.Acceleration(o),u=new Ki(e,o,s,c);return new Zi(r,u)}const ea=[];function ta(e,t){const n=Math.floor(e);return n<0?0:n>=t?t-1:n}function na(e){const t=function(e){let[t,[n,r,i],[a,o,s]]=e;return new Vi(t,new Yi(n,r,i),new Yi(a,o,s))}(e),n=new qi(t.tt),r=t.r.add(n.Sun.r),i=t.v.add(n.Sun.v),a=n.Acceleration(r),o=new Ki(t.tt,r,i,a);return new Zi(n,o)}function ra(e,t,n){let r=na(e);const i=Math.ceil((t-r.grav.tt)/n);for(let e=0;e<i;++e)r=Ji(e+1===i?t:r.grav.tt+n,r.grav);return r}function ia(e,t){let n,r,i;const a=function(e,t){const n=Wi[0][0];if(t<n||t>Wi[50][0])return null;const r=ta((t-n)/29200,50);if(!e[r]){const t=e[r]=[];t[0]=na(Wi[r]).grav,t[200]=na(Wi[r+1]).grav;let n,a=t[0].tt;for(n=1;n<200;++n)t[n]=Ji(a+=ki,t[n-1]).grav;a=t[200].tt;var i=[];for(i[200]=t[200],n=199;n>0;--n)i[n]=Ji(a-=ki,i[n+1]).grav;for(n=199;n>0;--n){const e=n/200;t[n].r=t[n].r.mul(1-e).add(i[n].r.mul(e)),t[n].v=t[n].v.mul(1-e).add(i[n].v.mul(e)),t[n].a=t[n].a.mul(1-e).add(i[n].a.mul(e))}}return e[r]}(ea,e.tt);if(a){const t=ta((e.tt-a[0].tt)/ki,200),i=a[t],o=a[t+1],s=i.a.mean(o.a),c=$i(e.tt-i.tt,i.r,i.v,s),u=Qi(e.tt-i.tt,i.v,s),d=$i(e.tt-o.tt,o.r,o.v,s),m=Qi(e.tt-o.tt,o.v,s),l=(e.tt-i.tt)/ki;n=c.mul(1-l).add(d.mul(l)),r=u.mul(1-l).add(m.mul(l))}else{let t;t=e.tt<Wi[0][0]?ra(Wi[0],e.tt,-ki):ra(Wi[50],e.tt,146),n=t.grav.r,r=t.grav.v,i=t.bary}return i||(i=new qi(e.tt)),n=n.sub(i.Sun.r),r=r.sub(i.Sun.v),new Oi(n.x,n.y,n.z,r.x,r.y,r.z,e)}function aa(e,t){var n=Ri(t);if(e in vi)return Bi(vi[e],n);if(e===hi.Pluto){const e=ia(n);return new bi(e.x,e.y,e.z,n)}if(e===hi.Sun)return new bi(0,0,0,n);if(e===hi.Moon){var r=Bi(vi.Earth,n),i=Li(n);return new bi(r.x+i.x,r.y+i.y,r.z+i.z,n)}if(e===hi.EMB){const e=Bi(vi.Earth,n),t=Li(n),r=82.30056;return new bi(e.x+t.x/r,e.y+t.y/r,e.z+t.z/r,n)}if(e===hi.SSB)return function(e){const t=new bi(0,0,0,e);return zi(t,e,hi.Jupiter,si),zi(t,e,hi.Saturn,ci),zi(t,e,hi.Uranus,ui),zi(t,e,hi.Neptune,di),t}(n);const a=gi(e);if(a){return function(e,t){t=Ri(t);const n=e.lat*ti,r=e.lon*ti,i=e.dist*Math.cos(n);return new bi(i*Math.cos(r),i*Math.sin(r),e.dist*Math.sin(n),t)}(new Di(a.dec,15*a.ra,a.dist),n)}throw`HelioVector: Unknown body "${e}"`}class oa{constructor(e,t,n,r){this.observerBody=e,this.targetBody=t,this.aberration=n,this.observerPos=r}Position(e){this.aberration&&(this.observerPos=aa(this.observerBody,e));const t=aa(this.targetBody,e);return new bi(t.x-this.observerPos.x,t.y-this.observerPos.y,t.z-this.observerPos.z,e)}}function sa(e,t,n,r){const i=Ri(e);if(gi(n)){const e=aa(n,i),r=aa(t,i);return new bi(e.x-r.x,e.y-r.y,e.z-r.z,i)}let a;a=aa(t,i);const o=new oa(t,n,r,a);return function(e,t){let n=t,r=0;for(let i=0;i<10;++i){const i=e(n),a=i.Length()/173.1446326846693;if(a>1)throw"Object is too distant for light-travel solver.";const o=t.AddDays(-a);if(r=Math.abs(o.tt-n.tt),r<1e-9)return i;n=o}throw`Light-travel time solver did not converge: dt = ${r}`}(e=>o.Position(e),i)}var ca,ua,da;function ma(e,t){return new Mi([[t.rot[0][0]*e.rot[0][0]+t.rot[1][0]*e.rot[0][1]+t.rot[2][0]*e.rot[0][2],t.rot[0][1]*e.rot[0][0]+t.rot[1][1]*e.rot[0][1]+t.rot[2][1]*e.rot[0][2],t.rot[0][2]*e.rot[0][0]+t.rot[1][2]*e.rot[0][1]+t.rot[2][2]*e.rot[0][2]],[t.rot[0][0]*e.rot[1][0]+t.rot[1][0]*e.rot[1][1]+t.rot[2][0]*e.rot[1][2],t.rot[0][1]*e.rot[1][0]+t.rot[1][1]*e.rot[1][1]+t.rot[2][1]*e.rot[1][2],t.rot[0][2]*e.rot[1][0]+t.rot[1][2]*e.rot[1][1]+t.rot[2][2]*e.rot[1][2]],[t.rot[0][0]*e.rot[2][0]+t.rot[1][0]*e.rot[2][1]+t.rot[2][0]*e.rot[2][2],t.rot[0][1]*e.rot[2][0]+t.rot[1][1]*e.rot[2][1]+t.rot[2][1]*e.rot[2][2],t.rot[0][2]*e.rot[2][0]+t.rot[1][2]*e.rot[2][1]+t.rot[2][2]*e.rot[2][2]]])}function la(e){const t=Ni(e=Ri(e),fi.From2000),n=function(e,t){const n=Ii(e),r=n.mobl*ti,i=n.tobl*ti,a=n.dpsi*ai,o=Math.cos(r),s=Math.sin(r),c=Math.cos(i),u=Math.sin(i),d=Math.cos(a),m=Math.sin(a),l=d,h=-m*o,p=-m*s,_=m*c,g=d*o*c+s*u,f=d*s*c-o*u,v=m*u,T=d*o*u-s*c,S=d*s*u+o*c;if(t===fi.From2000)return new Mi([[l,_,v],[h,g,T],[p,f,S]]);if(t===fi.Into2000)return new Mi([[l,h,p],[_,g,f],[v,T,S]]);throw"Invalid precess direction"}(e,fi.From2000);return ma(t,n)}function ha(e){return e instanceof Ei?e:new Ei(e instanceof Date?e:new Date(e))}function pa(e,n=new t){const r=ha(e),i=la(r),a=function(e){const t=Math.cos(e),n=Math.sin(e);return new Mi([[t,-n,0],[n,t,0],[0,0,1]])}(Ci(r)*(-Math.PI/12)),{rot:o}=ma(i,a);return n.set(o[0][0],o[0][1],o[0][2],0,o[1][0],o[1][1],o[1][2],0,o[2][0],o[2][1],o[2][2],0,0,0,0,1)}function _a(e,t,n){const{x:r,y:i,z:a}=function(e,t,n){const r=Ri(t);switch(e){case hi.Earth:return new bi(0,0,0,r);case hi.Moon:return Li(r);default:const t=sa(r,hi.Earth,e,n);return t.t=r,t}}(e,t,!1);return n.set(r,i,a).normalize()}function ga(e){return Math.sqrt(Math.max(e,0))}function fa(e,t,n){const{topRadius:r}=e;return function(e){return Math.max(e,0)}(-t*n+ga(t**2*(n**2-1)+r**2))}function va(e,t){return.5/t+e*(1-1/t)}!function(e){e[e.Pericenter=0]="Pericenter",e[e.Apocenter=1]="Apocenter"}(ca||(ca={})),function(e){e.Penumbral="penumbral",e.Partial="partial",e.Annular="annular",e.Total="total"}(ua||(ua={})),function(e){e[e.Invalid=0]="Invalid",e[e.Ascending=1]="Ascending",e[e.Descending=-1]="Descending"}(da||(da={}));const Ta=new e,Sa=new e,Ea=new e,Ra=new WeakMap;function xa(e,t,n){const r=4*t;return n.set(e[r],e[r+1],e[r+2])}function Aa(e,t,n){const r=function(e){let t=qn(e.image.data)?e.image.data:qn(e.userData.imageData)?e.userData.imageData:void 0;if(e.type===I&&t instanceof Uint16Array){const e=Ra.get(t.buffer);null==e?(t=new Xn(t.buffer),Ra.set(t.buffer,t)):t=e}return t}(e);if(null==r)return n.setScalar(0);const{width:i,height:a}=e.image,o=Kn(t.x,0,1)*(i-1),s=Kn(t.y,0,1)*(a-1),c=Math.floor(o),u=Math.floor(s),d=o-c,m=s-u,l=c%i,h=(l+1)%i,p=u%a,_=(p+1)%a,g=xa(r,p*i+l,Ta),f=xa(r,p*i+h,Sa),v=g.lerp(f,d),T=xa(r,_*i+l,Sa),S=xa(r,_*i+h,Ea),E=T.lerp(S,d);return n.copy(v.lerp(E,m))}const Ia=new e,ya=new e,Na=new u;function wa(e,t,n,r=new s,{ellipsoid:i=de.WGS84,correctAltitude:a=!0}={},o=Fr.DEFAULT){const c=Ia.copy(t);if(a){const e=i.projectOnSurface(t,ya);null!=e&&c.sub(i.getOsculatingSphereCenter(e,o.bottomRadius,ya))}const u=ya;let d=c.length(),m=c.dot(n);const{topRadius:l}=o,h=-m-Math.sqrt(m**2-d**2+l**2);if(h>0&&(d=l,m+=h),d>l)u.set(1,1,1);else{const t=m/d;if(function(e,t,n){const{bottomRadius:r}=e;return n<0&&t**2*(n**2-1)+r**2>=0}(o,d,t))u.setScalar(0);else{const n=function(e,t,n,r){const{topRadius:i,bottomRadius:a}=e,o=Math.sqrt(i**2-a**2),s=ga(t**2-a**2),c=i-t,u=(fa(e,t,n)-c)/(s+o-c),d=s/o;return r.set(va(u,Dr),va(d,Mr))}(o,d,t,Na);Aa(e,n,u)}}const p=u.multiply(o.solarIrradiance).multiply(o.sunRadianceToRelativeLuminance);return r.setFromVector3(p)}class Ca extends V{constructor(e,t){super("LightingMaskPass"),this.selection=new X,this.needsSwap=!1,this.needsDepthTexture=!0,this.renderPass=new j(e,t,new l),this.renderPass.ignoreBackground=!0,this.renderPass.skipShadowMapUpdate=!0,this.renderPass.selection=this.selection,this.depthTexture=new h(1,1,p),this.renderTarget=new _(1,1,{format:g,depthTexture:this.depthTexture}),this.depthCopyPass0=new q({depthPacking:f}),this.depthCopyPass1=new q({depthPacking:f}),this.clearPass=new K(!0,!1,!1),this.clearPass.overrideClearColor=new s(16777215),this.clearPass.overrideClearAlpha=1;const n=new Z;n.fragmentShader=_r('// Based on: https://github.com/pmndrs/postprocessing/blob/v6.37.4/src/materials/glsl/depth-mask.frag\n\n#include <common>\n#include <packing>\n\n#include "core/depth"\n\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nuniform highp sampler2D depthBuffer0;\nuniform highp sampler2D depthBuffer1;\n#else // GL_FRAGMENT_PRECISION_HIGH\nuniform mediump sampler2D depthBuffer0;\nuniform mediump sampler2D depthBuffer1;\n#endif // GL_FRAGMENT_PRECISION_HIGH\n\nuniform sampler2D inputBuffer;\nuniform vec2 cameraNearFar;\nuniform bool inverted;\n\nfloat getViewZ(const float depth) {\n #ifdef PERSPECTIVE_CAMERA\n return perspectiveDepthToViewZ(depth, cameraNearFar.x, cameraNearFar.y);\n #else // PERSPECTIVE_CAMERA\n return orthographicDepthToViewZ(depth, cameraNearFar.x, cameraNearFar.y);\n #endif // PERSPECTIVE_CAMERA\n}\n\nvarying vec2 vUv;\n\nvoid main() {\n vec2 depth;\n\n #if DEPTH_PACKING_0 == 3201\n depth.x = unpackRGBAToDepth(texture2D(depthBuffer0, vUv));\n #else // DEPTH_PACKING_0 == 3201\n depth.x = reverseLogDepth(texture2D(depthBuffer0, vUv).r, cameraNearFar.x, cameraNearFar.y);\n #endif // DEPTH_PACKING_0 == 3201\n\n #if DEPTH_PACKING_1 == 3201\n depth.y = unpackRGBAToDepth(texture2D(depthBuffer1, vUv));\n #else // DEPTH_PACKING_1 == 3201\n depth.y = reverseLogDepth(texture2D(depthBuffer1, vUv).r, cameraNearFar.x, cameraNearFar.y);\n #endif // DEPTH_PACKING_1 == 3201\n\n bool isMaxDepth = depth.x == 1.0;\n\n #ifdef PERSPECTIVE_CAMERA\n depth.x = viewZToOrthographicDepth(getViewZ(depth.x), cameraNearFar.x, cameraNearFar.y);\n depth.y = viewZToOrthographicDepth(getViewZ(depth.y), cameraNearFar.x, cameraNearFar.y);\n #endif // PERSPECTIVE_CAMERA\n\n #if DEPTH_TEST_STRATEGY == 0\n // Decide based on depth test.\n bool keep = depthTest(depth.x, depth.y);\n\n #elif DEPTH_TEST_STRATEGY == 1\n // Always keep max depth.\n bool keep = isMaxDepth || depthTest(depth.x, depth.y);\n\n #else // DEPTH_TEST_STRATEGY\n // Always discard max depth.\n bool keep = !isMaxDepth && depthTest(depth.x, depth.y);\n\n #endif // DEPTH_TEST_STRATEGY\n\n if (inverted) {\n keep = !keep;\n }\n if (keep) {\n gl_FragColor = texture2D(inputBuffer, vUv);\n } else {\n discard;\n }\n}\n',{core:{depth:vr}}),n.uniforms.inverted=new c(!1),n.copyCameraSettings(t),n.depthBuffer0=this.depthCopyPass0.texture,n.depthPacking0=f,n.depthBuffer1=this.depthCopyPass1.texture,n.depthPacking1=f,n.depthMode=v,n.maxDepthStrategy=$.DISCARD_MAX_DEPTH,this.depthMaskMaterial=n,this.depthMaskPass=new Q(n)}set mainScene(e){this.renderPass.mainScene=e}set mainCamera(e){this.renderPass.mainCamera=e,this.depthMaskMaterial.copyCameraSettings(e)}initialize(e,t,n){this.renderPass.initialize(e,t,n),this.clearPass.initialize(e,t,n),this.depthMaskPass.initialize(e,t,n)}setDepthTexture(e,t=T){this.depthCopyPass0.setDepthTexture(e,t),this.depthCopyPass1.setDepthTexture(this.depthTexture,t)}render(e,t,n,r,i){const a=e.autoClear;e.autoClear=!1,this.depthCopyPass0.render(e,null,null),this.renderPass.render(e,this.renderTarget,null),this.depthCopyPass1.render(e,null,null),this.clearPass.render(e,this.renderTarget,null),this.depthMaskPass.render(e,null,this.renderTarget),e.autoClear=a}setSize(e,t){this.renderTarget.setSize(e,t),this.depthCopyPass0.setSize(e,t),this.depthCopyPass1.setSize(e,t)}get texture(){return this.renderTarget.texture}get selectionLayer(){return this.selection.layer}set selectionLayer(e){this.selection.layer=e}get inverted(){return this.depthMaskMaterial.uniforms.inverted.value}set inverted(e){this.depthMaskMaterial.uniforms.inverted.value=e}}const ba=window.requestIdleCallback??function(e,t={}){const n=t.timeout??1,r=performance.now();return setTimeout(function(){e({get didTimeout(){return null==t.timeout&&performance.now()-r-1>n},timeRemaining:function(){return Math.max(0,performance.now()-r+1)}})},1)};function Oa(e,t,n){const r=new _(t,n,{depthBuffer:!1,type:e,format:C}),i=r.texture;return i.minFilter=b,i.magFilter=b,i.wrapS=O,i.wrapT=O,i.colorSpace=D,r}function Da(e,t,n,r){const i=new M(t,n,r,{depthBuffer:!1,type:e,format:C}),a=i.texture;return a.minFilter=b,a.magFilter=b,a.wrapS=O,a.wrapT=O,a.wrapR=O,a.colorSpace=D,i}async function Ma(e,t,n){const{width:r,height:i}=t,a=n.type===I?new Uint16Array(r*i*4):new Float32Array(r*i*4);await e.readRenderTargetPixelsAsync(t,0,0,t.width,t.height,a),n.userData.imageData=a}class La{constructor(t){this.lambdas=new e,this.luminanceFromRadiance=new S,t===I&&(this.opticalDepth=Oa(t,Dr,Mr)),this.deltaIrradiance=Oa(t,yr,Nr),this.deltaRayleighScattering=Da(t,Cr,br,Or),this.deltaMieScattering=Da(t,Cr,br,Or),this.deltaScatteringDensity=Da(t,Cr,br,Or),this.deltaMultipleScattering=this.deltaRayleighScattering}dispose(){var e;null==(e=this.opticalDepth)||e.dispose(),this.deltaIrradiance.dispose(),this.deltaRayleighScattering.dispose(),this.deltaMieScattering.dispose(),this.deltaScatteringDensity.dispose()}}class Pa extends m{constructor(e){super({glslVersion:N,vertexShader:"\n precision highp float;\n in vec2 position;\n void main() {\n gl_Position = vec4(position, 1.0, 1.0);\n }\n",...e,defines:{TRANSMITTANCE_TEXTURE_WIDTH:Dr.toFixed(0),TRANSMITTANCE_TEXTURE_HEIGHT:Mr.toFixed(0),SCATTERING_TEXTURE_R_SIZE:32..toFixed(0),SCATTERING_TEXTURE_MU_SIZE:wr.toFixed(0),SCATTERING_TEXTURE_MU_S_SIZE:32..toFixed(0),SCATTERING_TEXTURE_NU_SIZE:8..toFixed(0),IRRADIANCE_TEXTURE_WIDTH:yr.toFixed(0),IRRADIANCE_TEXTURE_HEIGHT:Nr.toFixed(0),...e.defines}})}set additive(e){this.transparent=e,this.blending=e?L:P,this.blendEquation=U,this.blendEquationAlpha=U,this.blendSrc=G,this.blendDst=G,this.blendSrcAlpha=G,this.blendDstAlpha=G}setUniforms(e){const t=this.uniforms;null!=t.luminanceFromRadiance&&t.luminanceFromRadiance.value.copy(e.luminanceFromRadiance),null!=t.singleRayleighScatteringTexture&&(t.singleRayleighScatteringTexture.value=e.deltaRayleighScattering.texture),null!=t.singleMieScatteringTexture&&(t.singleMieScatteringTexture.value=e.deltaMieScattering.texture),null!=t.multipleScatteringTexture&&(t.multipleScatteringTexture.value=e.deltaMultipleScattering.texture),null!=t.scatteringDensityTexture&&(t.scatteringDensityTexture.value=e.deltaScatteringDensity.texture),null!=t.irradianceTexture&&(t.irradianceTexture.value=e.deltaIrradiance.texture)}}class Ua{constructor(e,{type:t=(ge(e)?A:I),combinedScattering:n=!0,higherOrderScattering:r=!0}={}){var i,a;this.transmittanceMaterial=new Pa({fragmentShader:_r('precision highp float;\nprecision highp sampler3D;\n\n#include "bruneton/definitions"\n#include "bruneton/common"\n#include "bruneton/precompute"\n\nuniform AtmosphereParameters ATMOSPHERE;\n\nlayout(location = 0) out vec4 transmittance;\n\nvoid main() {\n transmittance.rgb = ComputeTransmittanceToTopAtmosphereBoundaryTexture(\n ATMOSPHERE,\n gl_FragCoord.xy\n );\n transmittance.a = 1.0;\n}\n',{bruneton:{common:Rr,definitions:xr,precompute:Ir}})}),this.directIrradianceMaterial=new Pa({fragmentShader:_r('precision highp float;\nprecision highp sampler3D;\n\n#include "bruneton/definitions"\n#include "bruneton/common"\n#include "bruneton/precompute"\n\nuniform AtmosphereParameters ATMOSPHERE;\n\nuniform sampler2D transmittanceTexture;\n\nlayout(location = 0) out vec4 outputColor;\n\nvoid main() {\n vec3 deltaIrradiance;\n vec3 irradiance;\n deltaIrradiance = ComputeDirectIrradianceTexture(\n ATMOSPHERE,\n transmittanceTexture,\n gl_FragCoord.xy\n );\n irradiance = vec3(0.0);\n outputColor = vec4(OUTPUT, 1.0);\n}\n',{bruneton:{common:Rr,definitions:xr,precompute:Ir}}),uniforms:{transmittanceTexture:new c(null)}}),this.singleScatteringMaterial=new Pa({fragmentShader:_r('precision highp float;\nprecision highp sampler3D;\n\n#include "bruneton/definitions"\n#include "bruneton/common"\n#include "bruneton/precompute"\n\nuniform AtmosphereParameters ATMOSPHERE;\n\nuniform mat3 luminanceFromRadiance;\nuniform sampler2D transmittanceTexture;\nuniform int layer;\n\nlayout(location = 0) out vec4 outputColor;\n\nvoid main() {\n vec4 deltaRayleigh;\n vec4 deltaMie;\n vec4 scattering;\n vec4 singleMieScattering;\n ComputeSingleScatteringTexture(\n ATMOSPHERE,\n transmittanceTexture,\n vec3(gl_FragCoord.xy, float(layer) + 0.5),\n deltaRayleigh.rgb,\n deltaMie.rgb\n );\n deltaRayleigh.a = 1.0;\n deltaMie.a = 1.0;\n scattering = vec4(\n luminanceFromRadiance * deltaRayleigh.rgb,\n (luminanceFromRadiance * deltaMie.rgb).r\n );\n singleMieScattering.rgb = luminanceFromRadiance * deltaMie.rgb;\n singleMieScattering.a = 1.0;\n outputColor = OUTPUT;\n}\n',{bruneton:{common:Rr,definitions:xr,precompute:Ir}}),uniforms:{luminanceFromRadiance:new c(new S),transmittanceTexture:new c(null),layer:new c(0)}}),this.scatteringDensityMaterial=new Pa({fragmentShader:_r('precision highp float;\nprecision highp sampler3D;\n\n#include "bruneton/definitions"\n#include "bruneton/common"\n#include "bruneton/precompute"\n\nuniform AtmosphereParameters ATMOSPHERE;\n\nuniform sampler2D transmittanceTexture;\nuniform sampler3D singleRayleighScatteringTexture;\nuniform sampler3D singleMieScatteringTexture;\nuniform sampler3D multipleScatteringTexture;\nuniform sampler2D irradianceTexture;\nuniform int scatteringOrder;\nuniform int layer;\n\nlayout(location = 0) out vec4 scatteringDensity;\n\nvoid main() {\n scatteringDensity.rgb = ComputeScatteringDensityTexture(\n ATMOSPHERE,\n transmittanceTexture,\n singleRayleighScatteringTexture,\n singleMieScatteringTexture,\n multipleScatteringTexture,\n irradianceTexture,\n vec3(gl_FragCoord.xy, float(layer) + 0.5),\n scatteringOrder\n );\n scatteringDensity.a = 1.0;\n}\n',{bruneton:{common:Rr,definitions:xr,precompute:Ir}}),uniforms:{transmittanceTexture:new c(null),singleRayleighScatteringTexture:new c(null),singleMieScatteringTexture:new c(null),multipleScatteringTexture:new c(null),irradianceTexture:new c(null),scatteringOrder:new c(0),layer:new c(0)}}),this.indirectIrradianceMaterial=new Pa({fragmentShader:_r('precision highp float;\nprecision highp sampler3D;\n\n#include "bruneton/definitions"\n#include "bruneton/common"\n#include "bruneton/precompute"\n\nuniform AtmosphereParameters ATMOSPHERE;\n\nuniform mat3 luminanceFromRadiance;\nuniform sampler3D singleRayleighScatteringTexture;\nuniform sampler3D singleMieScatteringTexture;\nuniform sampler3D multipleScatteringTexture;\nuniform int scatteringOrder;\n\nlayout(location = 0) out vec4 outputColor;\n\nvoid main() {\n vec3 deltaIrradiance;\n vec3 irradiance;\n deltaIrradiance = ComputeIndirectIrradianceTexture(\n ATMOSPHERE,\n singleRayleighScatteringTexture,\n singleMieScatteringTexture,\n multipleScatteringTexture,\n gl_FragCoord.xy,\n scatteringOrder\n );\n irradiance = luminanceFromRadiance * deltaIrradiance;\n outputColor = vec4(OUTPUT, 1.0);\n}\n',{bruneton:{common:Rr,definitions:xr,precompute:Ir}}),uniforms:{luminanceFromRadiance:new c(new S),singleRayleighScatteringTexture:new c(null),singleMieScatteringTexture:new c(null),multipleScatteringTexture:new c(null),scatteringOrder:new c(0)}}),this.multipleScatteringMaterial=new Pa({fragmentShader:_r('precision highp float;\nprecision highp sampler3D;\n\n#include "bruneton/definitions"\n#include "bruneton/common"\n#include "bruneton/precompute"\n\nuniform AtmosphereParameters ATMOSPHERE;\n\nuniform mat3 luminanceFromRadiance;\nuniform sampler2D transmittanceTexture;\nuniform sampler3D scatteringDensityTexture;\nuniform int layer;\n\nlayout(location = 0) out vec4 outputColor;\n\nvoid main() {\n vec4 deltaMultipleScattering;\n vec4 scattering;\n float nu;\n deltaMultipleScattering.rgb = ComputeMultipleScatteringTexture(\n ATMOSPHERE,\n transmittanceTexture,\n scatteringDensityTexture,\n vec3(gl_FragCoord.xy, float(layer) + 0.5),\n nu\n );\n deltaMultipleScattering.a = 1.0;\n scattering = vec4(\n luminanceFromRadiance * deltaMultipleScattering.rgb / RayleighPhaseFunction(nu),\n 0.0\n );\n outputColor = OUTPUT;\n}\n',{bruneton:{common:Rr,definitions:xr,precompute:Ir}}),uniforms:{luminanceFromRadiance:new c(new S),transmittanceTexture:new c(null),scatteringDensityTexture:new c(null),layer:new c(0)}}),this.mesh=new E(new R(2,2)),this.scene=(new x).add(this.mesh),this.camera=new d,this.updating=!1,this.renderer=e,this.type=t,this.transmittanceRenderTarget=Oa(t,Dr,Mr),this.scatteringRenderTarget=Da(t,Cr,br,Or),this.irradianceRenderTarget=Oa(t,yr,Nr),n||(this.singleMieScatteringRenderTarget=Da(t,Cr,br,Or)),r&&(this.higherOrderScatteringRenderTarget=Da(t,Cr,br,Or)),this.textures={transmittanceTexture:this.transmittanceRenderTarget.texture,scatteringTexture:this.scatteringRenderTarget.texture,irradianceTexture:this.irradianceRenderTarget.texture,singleMieScatteringTexture:null==(i=this.singleMieScatteringRenderTarget)?void 0:i.texture,higherOrderScatteringTexture:null==(a=this.higherOrderScatteringRenderTarget)?void 0:a.texture}}render3DRenderTarget(e,t){for(let n=0;n<e.depth;++n)t.uniforms.layer.value=n,this.renderer.setRenderTarget(e,n),this.renderer.render(this.scene,this.camera)}computeTransmittance(e){const t=this.transmittanceMaterial;delete t.defines.TRANSMITTANCE_PRECISION_LOG,t.needsUpdate=!0,this.mesh.material=t,this.renderer.setRenderTarget(e.renderTarget),this.renderer.render(this.scene,this.camera)}computeOpticalDepth(e){const t=this.transmittanceMaterial;t.defines.TRANSMITTANCE_PRECISION_LOG="1",t.needsUpdate=!0,this.mesh.material=t,this.renderer.setRenderTarget(e.renderTarget),this.renderer.render(this.scene,this.camera)}computeDirectIrradiance(e){var t;const n=this.directIrradianceMaterial;n.defines.OUTPUT=e.output,n.additive=e.additive,this.type===I?n.defines.TRANSMITTANCE_PRECISION_LOG="1":delete n.defines.TRANSMITTANCE_PRECISION_LOG,n.needsUpdate=!0;n.uniforms.transmittanceTexture.value=(null==(t=e.context.opticalDepth)?void 0:t.texture)??this.transmittanceRenderTarget.texture,this.mesh.material=n,this.renderer.setRenderTarget(e.renderTarget),this.renderer.render(this.scene,this.camera)}computeSingleScattering(e){var t;const n=this.singleScatteringMaterial;n.defines.OUTPUT=e.output,n.additive=e.additive,this.type===I?n.defines.TRANSMITTANCE_PRECISION_LOG="1":delete n.defines.TRANSMITTANCE_PRECISION_LOG,n.needsUpdate=!0;n.uniforms.transmittanceTexture.value=(null==(t=e.context.opticalDepth)?void 0:t.texture)??this.transmittanceRenderTarget.texture,n.setUniforms(e.context),this.mesh.material=n,this.render3DRenderTarget(e.renderTarget,n)}computeScatteringDensity(e){var t;const n=this.scatteringDensityMaterial;this.type===I?n.defines.TRANSMITTANCE_PRECISION_LOG="1":delete n.defines.TRANSMITTANCE_PRECISION_LOG,n.needsUpdate=!0;const r=n.uniforms;r.transmittanceTexture.value=(null==(t=e.context.opticalDepth)?void 0:t.texture)??this.transmittanceRenderTarget.texture,r.scatteringOrder.value=e.scatteringOrder,n.setUniforms(e.context),this.mesh.material=n,this.render3DRenderTarget(e.renderTarget,n)}computeIndirectIrradiance(e){const t=this.indirectIrradianceMaterial;t.defines.OUTPUT=e.output,t.additive=e.additive,t.needsUpdate=!0;t.uniforms.scatteringOrder.value=e.scatteringOrder-1,t.setUniforms(e.context),this.mesh.material=t,this.renderer.setRenderTarget(e.renderTarget),this.renderer.render(this.scene,this.camera)}computeMultipleScattering(e){var t;const n=this.multipleScatteringMaterial;n.defines.OUTPUT=e.output,n.additive=e.additive,this.type===I?n.defines.TRANSMITTANCE_PRECISION_LOG="1":delete n.defines.TRANSMITTANCE_PRECISION_LOG,n.needsUpdate=!0;n.uniforms.transmittanceTexture.value=(null==(t=e.context.opticalDepth)?void 0:t.texture)??this.transmittanceRenderTarget.texture,n.setUniforms(e.context),this.mesh.material=n,this.render3DRenderTarget(e.renderTarget,n)}*precompute(e,t){this.computeTransmittance({renderTarget:this.transmittanceRenderTarget}),this.type===I&&(function(e){if(!e)throw new Error("Invariant failed")}(null!=e.opticalDepth),this.computeOpticalDepth({renderTarget:e.opticalDepth})),this.computeDirectIrradiance({renderTarget:e.deltaIrradiance,context:e,output:"deltaIrradiance",additive:!1}),this.computeDirectIrradiance({renderTarget:this.irradianceRenderTarget,context:e,output:"irradiance",additive:t}),this.renderer.setRenderTarget(null),yield,this.computeSingleScattering({renderTarget:e.deltaRayleighScattering,context:e,output:"deltaRayleigh",additive:!1}),this.computeSingleScattering({renderTarget:e.deltaMieScattering,context:e,output:"deltaMie",additive:!1}),this.computeSingleScattering({renderTarget:this.scatteringRenderTarget,context:e,output:"scattering",additive:t}),null!=this.singleMieScatteringRenderTarget&&this.computeSingleScattering({renderTarget:this.singleMieScatteringRenderTarget,context:e,output:"singleMieScattering",additive:t}),this.renderer.setRenderTarget(null),yield;for(let t=2;t<=4;++t)this.computeScatteringDensity({renderTarget:e.deltaScatteringDensity,context:e,scatteringOrder:t}),this.computeIndirectIrradiance({renderTarget:e.deltaIrradiance,context:e,scatteringOrder:t,output:"deltaIrradiance",additive:!1}),this.computeIndirectIrradiance({renderTarget:this.irradianceRenderTarget,context:e,scatteringOrder:t,output:"irradiance",additive:!0}),this.computeMultipleScattering({renderTarget:e.deltaMultipleScattering,context:e,output:"deltaMultipleScattering",additive:!1}),this.computeMultipleScattering({renderTarget:this.scatteringRenderTarget,context:e,output:"scattering",additive:!0}),null!=this.higherOrderScatteringRenderTarget&&this.computeMultipleScattering({renderTarget:this.higherOrderScatteringRenderTarget,context:e,output:"scattering",additive:!0}),this.renderer.setRenderTarget(null),yield}async update(e=Fr.DEFAULT){var t;this.updating=!0;const n=e.toUniform();this.transmittanceMaterial.uniforms.ATMOSPHERE=n,this.directIrradianceMaterial.uniforms.ATMOSPHERE=n,this.singleScatteringMaterial.uniforms.ATMOSPHERE=n,this.scatteringDensityMaterial.uniforms.ATMOSPHERE=n,this.indirectIrradianceMaterial.uniforms.ATMOSPHERE=n,this.multipleScatteringMaterial.uniforms.ATMOSPHERE=n;const r=this.renderer,i=new La(this.type);i.lambdas.set(680,550,440),i.luminanceFromRadiance.identity();const a=r.autoClear;return r.autoClear=!1,await function(e){const t=e[Symbol.iterator]();return new Promise((e,n)=>{const r=()=>{try{const{value:n,done:i}=t.next();!0===i?e(n):ba(r)}catch(e){n(e instanceof Error?e:new Error)}};ba(r)})}(this.precompute(i,!1)),r.autoClear=a,i.dispose(),await Ma(this.renderer,this.transmittanceRenderTarget,this.transmittanceRenderTarget.texture),await Ma(this.renderer,this.irradianceRenderTarget,this.irradianceRenderTarget.texture),this.updating=!1,null==(t=this.disposeQueue)||t.call(this),this.textures}dispose(e={}){var t,n,r,i;if(this.updating)return void(this.disposeQueue=()=>{this.dispose(e),this.disposeQueue=void 0});const{textures:a=!0}=e;a||(this.transmittanceRenderTarget.textures.splice(0,1),this.scatteringRenderTarget.textures.splice(0,1),this.irradianceRenderTarget.textures.splice(0,1),null==(t=this.singleMieScatteringRenderTarget)||t.textures.splice(0,1),null==(n=this.higherOrderScatteringRenderTarget)||n.textures.splice(0,1)),this.transmittanceRenderTarget.dispose(),this.scatteringRenderTarget.dispose(),this.irradianceRenderTarget.dispose(),null==(r=this.singleMieScatteringRenderTarget)||r.dispose(),null==(i=this.higherOrderScatteringRenderTarget)||i.dispose(),this.transmittanceMaterial.dispose(),this.directIrradianceMaterial.dispose(),this.singleScatteringMaterial.dispose(),this.scatteringDensityMaterial.dispose(),this.indirectIrradianceMaterial.dispose(),this.multipleScatteringMaterial.dispose(),this.mesh.geometry.dispose()}}const Ga=1/Math.sqrt(Math.PI),Ha=Math.sqrt(3)/(2*Math.sqrt(Math.PI)),Fa=new e,Ba=new e,za=new u,ka=new t,Wa={ellipsoid:de.WGS84,correctAltitude:!0};class Ya extends y{constructor(n,r=Fr.DEFAULT){super(),this.atmosphere=r,this.ellipsoidCenter=new e,this.ellipsoidMatrix=new t;const{irradianceTexture:i=null,ellipsoid:a,correctAltitude:o,sunDirection:s}={...Wa,...n};this.irradianceTexture=i,this.ellipsoid=a,this.correctAltitude=o,this.sunDirection=(null==s?void 0:s.clone())??new e}update(){if(null==this.irradianceTexture)return;const e=ka.copy(this.ellipsoidMatrix).invert(),t=this.getWorldPosition(Fa).applyMatrix4(e).sub(this.ellipsoidCenter);if(this.correctAltitude){const e=this.ellipsoid.projectOnSurface(t,Ba);null!=e&&t.sub(zr(e,this.atmosphere.bottomRadius,this.ellipsoid,Ba))}const n=t.length(),r=t.dot(this.sunDirection)/n,i=function({topRadius:e,bottomRadius:t},n,r,i){const a=(n-t)/(e-t),o=.5*r+.5;return i.set(va(o,yr),va(a,Nr))}(this.atmosphere,n,r,za),a=Aa(this.irradianceTexture,i,Ba);a.multiply(this.atmosphere.skyRadianceToRelativeLuminance);const o=this.ellipsoid.getSurfaceNormal(t).applyMatrix4(this.ellipsoidMatrix),s=this.sh.coefficients;s[0].copy(a).multiplyScalar(Ga),s[1].copy(a).multiplyScalar(Ha*o.y),s[2].copy(a).multiplyScalar(Ha*o.z),s[3].copy(a).multiplyScalar(Ha*o.x)}}var Va=Object.defineProperty,Xa=(e,t,n,r)=>{for(var i,a=void 0,o=e.length-1;o>=0;o--)(i=e[o])&&(a=i(t,n,a)||a);return a&&Va(t,n,a),a};const ja={...Jr,sun:!0,moon:!0,moonAngularRadius:.0045,lunarRadianceScale:1,groundAlbedo:new s(0)};class qa extends ei{constructor(n){const{sun:r,moon:i,moonDirection:a,moonAngularRadius:o,lunarRadianceScale:s,groundAlbedo:u,...d}={...ja,...n};super({name:"SkyMaterial",glslVersion:N,vertexShader:"precision highp float;\nprecision highp sampler3D;\n\nuniform mat4 inverseProjectionMatrix;\nuniform mat4 inverseViewMatrix;\nuniform vec3 cameraPosition;\nuniform vec3 ellipsoidCenter;\nuniform mat4 inverseEllipsoidMatrix;\nuniform vec3 altitudeCorrection;\n\nlayout(location = 0) in vec3 position;\n\nout vec2 vUv;\nout vec3 vCameraPosition;\nout vec3 vRayDirection;\nout vec3 vEllipsoidCenter;\n\nvoid getCameraRay(out vec3 origin, out vec3 direction) {\n bool isPerspective = inverseProjectionMatrix[2][3] != 0.0; // 4th entry in the 3rd column\n\n if (isPerspective) {\n // Calculate the camera ray for a perspective camera.\n vec4 viewPosition = inverseProjectionMatrix * vec4(position, 1.0);\n vec4 worldDirection = inverseViewMatrix * vec4(viewPosition.xyz, 0.0);\n origin = cameraPosition;\n direction = worldDirection.xyz;\n } else {\n // Unprojected points to calculate direction.\n vec4 nearPoint = inverseProjectionMatrix * vec4(position.xy, -1.0, 1.0);\n vec4 farPoint = inverseProjectionMatrix * vec4(position.xy, -0.9, 1.0);\n nearPoint /= nearPoint.w;\n farPoint /= farPoint.w;\n\n // Calculate world values\n vec4 worldDirection = inverseViewMatrix * vec4(farPoint.xyz - nearPoint.xyz, 0.0);\n vec4 worldOrigin = inverseViewMatrix * nearPoint;\n\n // Outputs\n direction = worldDirection.xyz;\n origin = worldOrigin.xyz;\n }\n}\n\nvoid main() {\n vUv = position.xy * 0.5 + 0.5;\n\n vec3 direction, origin;\n getCameraRay(origin, direction);\n\n mat3 rotation = mat3(inverseEllipsoidMatrix);\n vCameraPosition = rotation * origin.xyz * METER_TO_LENGTH_UNIT;\n vRayDirection = rotation * direction.xyz;\n vEllipsoidCenter = (ellipsoidCenter + altitudeCorrection) * METER_TO_LENGTH_UNIT;\n\n gl_Position = vec4(position.xy, 1.0, 1.0);\n}\n",fragmentShader:_r('precision highp float;\nprecision highp sampler3D;\n\n#define RECIPROCAL_PI 0.3183098861837907\n\n#include "core/raySphereIntersection"\n\n#include "bruneton/definitions"\n\nuniform AtmosphereParameters ATMOSPHERE;\nuniform vec3 SUN_SPECTRAL_RADIANCE_TO_LUMINANCE;\nuniform vec3 SKY_SPECTRAL_RADIANCE_TO_LUMINANCE;\n\nuniform sampler2D transmittance_texture;\nuniform sampler3D scattering_texture;\nuniform sampler2D irradiance_texture;\nuniform sampler3D single_mie_scattering_texture;\nuniform sampler3D higher_order_scattering_texture;\n\n#include "bruneton/common"\n#include "bruneton/runtime"\n\n#include "sky"\n\nuniform vec3 sunDirection;\nuniform vec3 moonDirection;\nuniform float moonAngularRadius;\nuniform float lunarRadianceScale;\nuniform vec3 groundAlbedo;\n\n#ifdef HAS_SHADOW_LENGTH\nuniform sampler2D shadowLengthBuffer;\n#endif // HAS_SHADOW_LENGTH\n\nin vec2 vUv;\nin vec3 vCameraPosition;\nin vec3 vRayDirection;\nin vec3 vEllipsoidCenter;\n\nlayout(location = 0) out vec4 outputColor;\n\n#include <mrt_layout>\n\nbool rayIntersectsGround(const vec3 cameraPosition, const vec3 rayDirection) {\n float r = length(cameraPosition);\n float mu = dot(cameraPosition, rayDirection) / r;\n return mu < 0.0 &&\n r * r * (mu * mu - 1.0) + ATMOSPHERE.bottom_radius * ATMOSPHERE.bottom_radius >= 0.0;\n}\n\nvoid main() {\n float shadowLength = 0.0;\n #ifdef HAS_SHADOW_LENGTH\n shadowLength = texture(shadowLengthBuffer, vUv).r;\n #endif // HAS_SHADOW_LENGTH\n\n vec3 cameraPosition = vCameraPosition - vEllipsoidCenter;\n vec3 rayDirection = normalize(vRayDirection);\n\n #ifdef GROUND_ALBEDO\n\n bool intersectsGround = rayIntersectsGround(cameraPosition, rayDirection);\n if (intersectsGround) {\n float distanceToGround = raySphereFirstIntersection(\n cameraPosition,\n rayDirection,\n ATMOSPHERE.bottom_radius\n );\n vec3 groundPosition = rayDirection * distanceToGround + cameraPosition;\n vec3 surfaceNormal = normalize(groundPosition);\n vec3 skyIrradiance;\n vec3 sunIrradiance = GetSunAndSkyIrradiance(\n cameraPosition,\n surfaceNormal,\n sunDirection,\n skyIrradiance\n );\n vec3 transmittance;\n vec3 inscatter = GetSkyRadianceToPoint(\n cameraPosition,\n ATMOSPHERE.bottom_radius * surfaceNormal,\n shadowLength,\n sunDirection,\n transmittance\n );\n vec3 radiance = groundAlbedo * RECIPROCAL_PI * (sunIrradiance + skyIrradiance);\n outputColor.rgb = radiance * transmittance + inscatter;\n } else {\n outputColor.rgb = getSkyRadiance(\n cameraPosition,\n rayDirection,\n shadowLength,\n sunDirection,\n moonDirection,\n moonAngularRadius,\n lunarRadianceScale\n );\n }\n\n #else // GROUND_ALBEDO\n\n outputColor.rgb = getSkyRadiance(\n cameraPosition,\n rayDirection,\n shadowLength,\n sunDirection,\n moonDirection,\n moonAngularRadius,\n lunarRadianceScale\n );\n\n #endif // GROUND_ALBEDO\n\n outputColor.a = 1.0;\n\n #include <mrt_output>\n}\n',{core:{raySphereIntersection:Sr},bruneton:{common:Rr,definitions:xr,runtime:Ar},sky:kr}),...d,uniforms:{inverseProjectionMatrix:new c(new t),inverseViewMatrix:new c(new t),moonDirection:new c((null==a?void 0:a.clone())??new e),moonAngularRadius:new c(o),lunarRadianceScale:new c(s),groundAlbedo:new c(u.clone()),shadowLengthBuffer:new c(null),...d.uniforms},defines:{PERSPECTIVE_CAMERA:"1"},depthTest:!0}),this.shadowLength=null,this.sun=r,this.moon=i}onBeforeRender(e,t,n,r,i,a){super.onBeforeRender(e,t,n,r,i,a);const{uniforms:o,defines:s}=this;o.inverseProjectionMatrix.value.copy(n.projectionMatrixInverse),o.inverseViewMatrix.value.copy(n.matrixWorld);const c=null!=s.PERSPECTIVE_CAMERA,u=!0===n.isPerspectiveCamera;u!==c&&(u?s.PERSPECTIVE_CAMERA="1":delete s.PERSPECTIVE_CAMERA,this.needsUpdate=!0);const d=this.groundAlbedo,m=null!=s.GROUND_ALBEDO,l=0!==d.r||0!==d.g||0!==d.b;l!==m&&(l?this.defines.GROUND_ALBEDO="1":delete this.defines.GROUND_ALBEDO,this.needsUpdate=!0);const h=this.shadowLength,p=null!=h;p!==(null!=s.HAS_SHADOW_LENGTH)&&(p?s.HAS_SHADOW_LENGTH="1":(delete s.HAS_SHADOW_LENGTH,o.shadowLengthBuffer.value=null),this.needsUpdate=!0),p&&(o.shadowLengthBuffer.value=h.map)}get moonDirection(){return this.uniforms.moonDirection.value}get moonAngularRadius(){return this.uniforms.moonAngularRadius.value}set moonAngularRadius(e){this.uniforms.moonAngularRadius.value=e}get lunarRadianceScale(){return this.uniforms.lunarRadianceScale.value}set lunarRadianceScale(e){this.uniforms.lunarRadianceScale.value=e}get groundAlbedo(){return this.uniforms.groundAlbedo.value}}Xa([$n("SUN")],qa.prototype,"sun"),Xa([$n("MOON")],qa.prototype,"moon");var Ka=Object.defineProperty;const Za={...Jr,pointSize:1,intensity:1,background:!0};((e,t,n)=>{for(var r,i=void 0,a=e.length-1;a>=0;a--)(r=e[a])&&(i=r(t,n,i)||i);i&&Ka(t,n,i)})([$n("BACKGROUND")],class extends ei{constructor(e){const{pointSize:n,radianceScale:r,intensity:i,background:a,...o}={...Za,...e};super({name:"StarsMaterial",glslVersion:N,vertexShader:"precision highp float;\nprecision highp sampler3D;\n\n#define saturate(x) clamp(x, 0.0, 1.0)\n\nuniform mat4 projectionMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 viewMatrix;\nuniform mat4 matrixWorld;\nuniform vec3 cameraPosition;\nuniform float cameraFar;\nuniform vec3 ellipsoidCenter;\nuniform mat4 inverseEllipsoidMatrix;\nuniform vec3 altitudeCorrection;\nuniform float pointSize;\nuniform vec2 magnitudeRange;\nuniform float intensity;\n\nlayout(location = 0) in vec3 position;\nlayout(location = 1) in float magnitude;\nlayout(location = 2) in vec3 color;\n\nout vec3 vCameraPosition;\nout vec3 vRayDirection;\nout vec3 vEllipsoidCenter;\nout vec3 vColor;\n\nvoid main() {\n // Magnitude is stored between 0 to 1 within the given range.\n float m = mix(magnitudeRange.x, magnitudeRange.y, magnitude);\n vec3 v = pow(vec3(10.0), -vec3(magnitudeRange, m) / 2.5);\n vColor = vec3(intensity * color);\n vColor *= saturate((v.z - v.y) / (v.x - v.y));\n\n #ifdef BACKGROUND\n vec3 worldDirection = normalize(matrixWorld * vec4(position, 1.0)).xyz;\n mat3 rotation = mat3(inverseEllipsoidMatrix);\n vCameraPosition = rotation * cameraPosition * METER_TO_LENGTH_UNIT;\n vRayDirection = rotation * worldDirection;\n vEllipsoidCenter = (ellipsoidCenter + altitudeCorrection) * METER_TO_LENGTH_UNIT;\n gl_Position =\n projectionMatrix * viewMatrix * vec4(cameraPosition + worldDirection * cameraFar, 1.0);\n #else // BACKGROUND\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n #endif // BACKGROUND\n\n gl_PointSize = pointSize;\n}\n",fragmentShader:_r('precision highp float;\nprecision highp sampler3D;\n\n#include "bruneton/definitions"\n\nuniform AtmosphereParameters ATMOSPHERE;\nuniform vec3 SUN_SPECTRAL_RADIANCE_TO_LUMINANCE;\nuniform vec3 SKY_SPECTRAL_RADIANCE_TO_LUMINANCE;\n\nuniform sampler2D transmittance_texture;\nuniform sampler3D scattering_texture;\nuniform sampler2D irradiance_texture;\nuniform sampler3D single_mie_scattering_texture;\nuniform sampler3D higher_order_scattering_texture;\n\n#include "bruneton/common"\n#include "bruneton/runtime"\n\nuniform vec3 sunDirection;\n\nin vec3 vCameraPosition;\nin vec3 vRayDirection;\nin vec3 vEllipsoidCenter;\n\nlayout(location = 0) out vec4 outputColor;\n\n#include <mrt_layout>\n\nin vec3 vColor;\n\nvoid main() {\n #if !defined(PERSPECTIVE_CAMERA)\n outputColor = vec4(0.0);\n discard; // Rendering celestial objects without perspective doesn\'t make sense.\n #endif // !defined(PERSPECTIVE_CAMERA)\n\n #ifdef BACKGROUND\n vec3 cameraPosition = vCameraPosition - vEllipsoidCenter;\n vec3 rayDirection = normalize(vRayDirection);\n float r = length(cameraPosition);\n float mu = dot(cameraPosition, rayDirection) / r;\n\n if (RayIntersectsGround(ATMOSPHERE, r, mu)) {\n discard;\n }\n\n vec3 transmittance;\n vec3 radiance = GetSkyRadiance(\n vCameraPosition - vEllipsoidCenter,\n normalize(vRayDirection),\n 0.0,\n sunDirection,\n transmittance\n );\n radiance += transmittance * vColor;\n outputColor = vec4(radiance, 1.0);\n #else // BACKGROUND\n outputColor = vec4(vColor, 1.0);\n #endif // BACKGROUND\n\n #include <mrt_output>\n}\n',{bruneton:{common:Rr,definitions:xr,runtime:Ar}}),...o,uniforms:{projectionMatrix:new c(new t),modelViewMatrix:new c(new t),viewMatrix:new c(new t),matrixWorld:new c(new t),cameraFar:new c(0),pointSize:new c(0),magnitudeRange:new c(new u(-2,8)),intensity:new c(r??i),...o.uniforms},defines:{PERSPECTIVE_CAMERA:"1"}}),this.pointSize=n,this.background=a}onBeforeRender(e,t,n,r,i,a){super.onBeforeRender(e,t,n,r,i,a);const o=this.uniforms;o.projectionMatrix.value.copy(n.projectionMatrix),o.modelViewMatrix.value.copy(n.modelViewMatrix),o.viewMatrix.value.copy(n.matrixWorldInverse),o.matrixWorld.value.copy(i.matrixWorld),o.cameraFar.value=n.far,o.pointSize.value=this.pointSize*e.getPixelRatio();const s=!0===n.isPerspectiveCamera;null!=this.defines.PERSPECTIVE_CAMERA!==s&&(s?this.defines.PERSPECTIVE_CAMERA="1":delete this.defines.PERSPECTIVE_CAMERA,this.needsUpdate=!0)}get magnitudeRange(){return this.uniforms.magnitudeRange.value}get radianceScale(){return this.intensity}set radianceScale(e){this.intensity=e}get intensity(){return this.uniforms.intensity.value}set intensity(e){this.uniforms.intensity.value=e}}.prototype,"background");const $a=new e,Qa=new t,Ja={ellipsoid:de.WGS84,correctAltitude:!0,distance:1};class eo extends w{constructor(n,r=Fr.DEFAULT){super(),this.atmosphere=r,this.ellipsoidCenter=new e,this.ellipsoidMatrix=new t;const{irradianceTexture:i=null,ellipsoid:a,correctAltitude:o,sunDirection:s,distance:c}={...Ja,...n};this.transmittanceTexture=i,this.ellipsoid=a,this.correctAltitude=o,this.sunDirection=(null==s?void 0:s.clone())??new e,this.distance=c}update(){if(this.position.copy(this.sunDirection).applyMatrix4(this.ellipsoidMatrix).normalize().multiplyScalar(this.distance).add(this.target.position),null==this.transmittanceTexture)return;const e=Qa.copy(this.ellipsoidMatrix).invert(),t=this.target.getWorldPosition($a).applyMatrix4(e).sub(this.ellipsoidCenter);wa(this.transmittanceTexture,t,this.sunDirection,this.color,{ellipsoid:this.ellipsoid,correctAltitude:this.correctAltitude},this.atmosphere)}}var to=Object.defineProperty;const no={blendFunction:k.SRC,useTurbo:!1,near:1,far:1e3};((e,t,n)=>{for(var r,i=void 0,a=e.length-1;a>=0;a--)(r=e[a])&&(i=r(t,n,i)||i);i&&to(t,n,i)})([$n("USE_TURBO")],class extends W{constructor(e){const{blendFunction:t,useTurbo:n,near:r,far:i}={...no,...e};super("DepthEffect",_r('#include "core/depth"\n#include "core/turbo"\n\nuniform float near;\nuniform float far;\n\nvoid mainImage(const vec4 inputColor, const vec2 uv, out vec4 outputColor) {\n float depth = readDepth(uv);\n depth = reverseLogDepth(depth, cameraNear, cameraFar);\n depth = linearizeDepth(depth, near, far) / far;\n\n #ifdef USE_TURBO\n vec3 color = turbo(1.0 - depth);\n #else // USE_TURBO\n vec3 color = vec3(depth);\n #endif // USE_TURBO\n\n outputColor = vec4(color, inputColor.a);\n}\n',{core:{depth:vr,turbo:"// A fifth-order polynomial approximation of Turbo color map.\n// See: https://observablehq.com/@mbostock/turbo\n// prettier-ignore\nvec3 turbo(const float x) {\n float r = 0.1357 + x * (4.5974 - x * (42.3277 - x * (130.5887 - x * (150.5666 - x * 58.1375))));\n float g = 0.0914 + x * (2.1856 + x * (4.8052 - x * (14.0195 - x * (4.2109 + x * 2.7747))));\n float b = 0.1067 + x * (12.5925 - x * (60.1097 - x * (109.0745 - x * (88.5066 - x * 26.8183))));\n return vec3(r, g, b);\n}\n"}}),{blendFunction:t,attributes:Y.DEPTH,uniforms:new Map(Object.entries({near:new c(r),far:new c(i)}))}),this.useTurbo=n}get near(){return this.uniforms.get("near").value}set near(e){this.uniforms.get("near").value=e}get far(){return this.uniforms.get("far").value}set far(e){this.uniforms.get("far").value=e}}.prototype,"useTurbo");const ro={blendFunction:k.NORMAL};class io extends W{constructor(e){const{blendFunction:t}={...ro,...e};super("DitheringEffect","#define DITHERING\n\n#include <dithering_pars_fragment>\n\nvoid mainImage(const vec4 inputColor, const vec2 uv, out vec4 outputColor) {\n outputColor = vec4(saturate(dithering(inputColor.rgb)), inputColor.a);\n}\n",{blendFunction:t})}}const ao={thresholdLevel:10,thresholdRange:1};class oo extends H{constructor(e){const{inputBuffer:t=null,thresholdLevel:n,thresholdRange:r,...i}={...ao,...e};super({name:"DownsampleThresholdMaterial",fragmentShader:"#include <common>\n\nuniform sampler2D inputBuffer;\n\nuniform float thresholdLevel;\nuniform float thresholdRange;\n\nin vec2 vCenterUv1;\nin vec2 vCenterUv2;\nin vec2 vCenterUv3;\nin vec2 vCenterUv4;\nin vec2 vRowUv1;\nin vec2 vRowUv2;\nin vec2 vRowUv3;\nin vec2 vRowUv4;\nin vec2 vRowUv5;\nin vec2 vRowUv6;\nin vec2 vRowUv7;\nin vec2 vRowUv8;\nin vec2 vRowUv9;\n\nfloat clampToBorder(const vec2 uv) {\n return float(uv.x >= 0.0 && uv.x <= 1.0 && uv.y >= 0.0 && uv.y <= 1.0);\n}\n\n// Reference: https://learnopengl.com/Guest-Articles/2022/Phys.-Based-Bloom\nvoid main() {\n vec3 color = 0.125 * texture(inputBuffer, vec2(vRowUv5)).rgb;\n vec4 weight =\n 0.03125 *\n vec4(\n clampToBorder(vRowUv1),\n clampToBorder(vRowUv3),\n clampToBorder(vRowUv7),\n clampToBorder(vRowUv9)\n );\n color += weight.x * texture(inputBuffer, vec2(vRowUv1)).rgb;\n color += weight.y * texture(inputBuffer, vec2(vRowUv3)).rgb;\n color += weight.z * texture(inputBuffer, vec2(vRowUv7)).rgb;\n color += weight.w * texture(inputBuffer, vec2(vRowUv9)).rgb;\n\n weight =\n 0.0625 *\n vec4(\n clampToBorder(vRowUv2),\n clampToBorder(vRowUv4),\n clampToBorder(vRowUv6),\n clampToBorder(vRowUv8)\n );\n color += weight.x * texture(inputBuffer, vec2(vRowUv2)).rgb;\n color += weight.y * texture(inputBuffer, vec2(vRowUv4)).rgb;\n color += weight.z * texture(inputBuffer, vec2(vRowUv6)).rgb;\n color += weight.w * texture(inputBuffer, vec2(vRowUv8)).rgb;\n\n weight =\n 0.125 *\n vec4(\n clampToBorder(vRowUv2),\n clampToBorder(vRowUv4),\n clampToBorder(vRowUv6),\n clampToBorder(vRowUv8)\n );\n color += weight.x * texture(inputBuffer, vec2(vCenterUv1)).rgb;\n color += weight.y * texture(inputBuffer, vec2(vCenterUv2)).rgb;\n color += weight.z * texture(inputBuffer, vec2(vCenterUv3)).rgb;\n color += weight.w * texture(inputBuffer, vec2(vCenterUv4)).rgb;\n\n // WORKAROUND: Avoid screen flashes if the input buffer contains NaN texels.\n // See: https://github.com/takram-design-engineering/three-geospatial/issues/7\n if (any(isnan(color))) {\n gl_FragColor = vec4(vec3(0.0), 1.0);\n return;\n }\n\n float l = luminance(color);\n float scale = saturate(smoothstep(thresholdLevel, thresholdLevel + thresholdRange, l));\n gl_FragColor = vec4(color * scale, 1.0);\n}\n",vertexShader:"uniform vec2 texelSize;\n\nout vec2 vCenterUv1;\nout vec2 vCenterUv2;\nout vec2 vCenterUv3;\nout vec2 vCenterUv4;\nout vec2 vRowUv1;\nout vec2 vRowUv2;\nout vec2 vRowUv3;\nout vec2 vRowUv4;\nout vec2 vRowUv5;\nout vec2 vRowUv6;\nout vec2 vRowUv7;\nout vec2 vRowUv8;\nout vec2 vRowUv9;\n\nvoid main() {\n vec2 uv = position.xy * 0.5 + 0.5;\n vCenterUv1 = uv + texelSize * vec2(-1.0, 1.0);\n vCenterUv2 = uv + texelSize * vec2(1.0, 1.0);\n vCenterUv3 = uv + texelSize * vec2(-1.0, -1.0);\n vCenterUv4 = uv + texelSize * vec2(1.0, -1.0);\n vRowUv1 = uv + texelSize * vec2(-2.0, 2.0);\n vRowUv2 = uv + texelSize * vec2(0.0, 2.0);\n vRowUv3 = uv + texelSize * vec2(2.0, 2.0);\n vRowUv4 = uv + texelSize * vec2(-2.0, 0.0);\n vRowUv5 = uv + texelSize;\n vRowUv6 = uv + texelSize * vec2(2.0, 0.0);\n vRowUv7 = uv + texelSize * vec2(-2.0, -2.0);\n vRowUv8 = uv + texelSize * vec2(0.0, -2.0);\n vRowUv9 = uv + texelSize * vec2(2.0, -2.0);\n\n gl_Position = vec4(position.xy, 1.0, 1.0);\n}\n",blending:P,toneMapped:!1,depthWrite:!1,depthTest:!1,...i,uniforms:{inputBuffer:new c(t),texelSize:new c(new u),thresholdLevel:new c(n),thresholdRange:new c(r),...i.uniforms}})}setSize(e,t){this.uniforms.texelSize.value.set(1/e,1/t)}get inputBuffer(){return this.uniforms.inputBuffer.value}set inputBuffer(e){this.uniforms.inputBuffer.value=e}get thresholdLevel(){return this.uniforms.thresholdLevel.value}set thresholdLevel(e){this.uniforms.thresholdLevel.value=e}get thresholdRange(){return this.uniforms.thresholdRange.value}set thresholdRange(e){this.uniforms.thresholdRange.value=e}}const so={ghostAmount:.001,haloAmount:.001,chromaticAberration:10};class co extends H{constructor(e){const{inputBuffer:t=null,ghostAmount:n,haloAmount:r,chromaticAberration:i,...a}={...so,...e};super({name:"LensFlareFeaturesMaterial",fragmentShader:"#include <common>\n\n#define SQRT_2 0.7071067811865476\n\nuniform sampler2D inputBuffer;\n\nuniform vec2 texelSize;\nuniform float ghostAmount;\nuniform float haloAmount;\nuniform float chromaticAberration;\n\nin vec2 vUv;\nin vec2 vAspectRatio;\n\nvec3 sampleGhost(const vec2 direction, const vec3 color, const float offset) {\n vec2 suv = clamp(1.0 - vUv + direction * offset, 0.0, 1.0);\n vec3 result = texture(inputBuffer, suv).rgb * color;\n\n // Falloff at the perimeter.\n float d = clamp(length(0.5 - suv) / (0.5 * SQRT_2), 0.0, 1.0);\n result *= pow(1.0 - d, 3.0);\n return result;\n}\n\nvec4 sampleGhosts(float amount) {\n vec3 color = vec3(0.0);\n vec2 direction = vUv - 0.5;\n color += sampleGhost(direction, vec3(0.8, 0.8, 1.0), -5.0);\n color += sampleGhost(direction, vec3(1.0, 0.8, 0.4), -1.5);\n color += sampleGhost(direction, vec3(0.9, 1.0, 0.8), -0.4);\n color += sampleGhost(direction, vec3(1.0, 0.8, 0.4), -0.2);\n color += sampleGhost(direction, vec3(0.9, 0.7, 0.7), -0.1);\n color += sampleGhost(direction, vec3(0.5, 1.0, 0.4), 0.7);\n color += sampleGhost(direction, vec3(0.5, 0.5, 0.5), 1.0);\n color += sampleGhost(direction, vec3(1.0, 1.0, 0.6), 2.5);\n color += sampleGhost(direction, vec3(0.5, 0.8, 1.0), 10.0);\n return vec4(color * amount, 1.0);\n}\n\n// Reference: https://john-chapman.github.io/2017/11/05/pseudo-lens-flare.html\nfloat cubicRingMask(const float x, const float radius, const float thickness) {\n float v = min(abs(x - radius) / thickness, 1.0);\n return 1.0 - v * v * (3.0 - 2.0 * v);\n}\n\nvec3 sampleHalo(const float radius) {\n vec2 direction = normalize((vUv - 0.5) / vAspectRatio) * vAspectRatio;\n vec3 offset = vec3(texelSize.x * chromaticAberration) * vec3(-1.0, 0.0, 1.0);\n vec2 suv = fract(1.0 - vUv + direction * radius);\n vec3 result = vec3(\n texture(inputBuffer, suv + direction * offset.r).r,\n texture(inputBuffer, suv + direction * offset.g).g,\n texture(inputBuffer, suv + direction * offset.b).b\n );\n\n // Falloff at the center and perimeter.\n vec2 wuv = (vUv - vec2(0.5, 0.0)) / vAspectRatio + vec2(0.5, 0.0);\n float d = saturate(distance(wuv, vec2(0.5)));\n result *= cubicRingMask(d, 0.45, 0.25);\n return result;\n}\n\nvec4 sampleHalos(const float amount) {\n vec3 color = vec3(0.0);\n color += sampleHalo(0.3);\n return vec4(color, 1.0) * amount;\n}\n\nvoid main() {\n gl_FragColor += sampleGhosts(ghostAmount);\n gl_FragColor += sampleHalos(haloAmount);\n}\n\n",vertexShader:"uniform vec2 texelSize;\n\nout vec2 vUv;\nout vec2 vAspectRatio;\n\nvoid main() {\n vUv = position.xy * 0.5 + 0.5;\n vAspectRatio = vec2(texelSize.x / texelSize.y, 1.0);\n gl_Position = vec4(position.xy, 1.0, 1.0);\n}\n",blending:P,toneMapped:!1,depthWrite:!1,depthTest:!1,uniforms:{inputBuffer:new c(t),texelSize:new c(new u),ghostAmount:new c(n),haloAmount:new c(r),chromaticAberration:new c(i),...a.uniforms}})}setSize(e,t){this.uniforms.texelSize.value.set(1/e,1/t)}get inputBuffer(){return this.uniforms.inputBuffer.value}set inputBuffer(e){this.uniforms.inputBuffer.value=e}get ghostAmount(){return this.uniforms.ghostAmount.value}set ghostAmount(e){this.uniforms.ghostAmount.value=e}get haloAmount(){return this.uniforms.haloAmount.value}set haloAmount(e){this.uniforms.haloAmount.value=e}get chromaticAberration(){return this.uniforms.chromaticAberration.value}set chromaticAberration(e){this.uniforms.chromaticAberration.value=e}}const uo={blendFunction:k.NORMAL,resolutionScale:.5,width:J.AUTO_SIZE,height:J.AUTO_SIZE,intensity:.005};class mo extends W{constructor(e){const{blendFunction:t,resolutionScale:n,width:r,height:i,resolutionX:a=r,resolutionY:o=i,intensity:s}={...uo,...e};super("LensFlareEffect","uniform sampler2D bloomBuffer;\nuniform sampler2D featuresBuffer;\nuniform float intensity;\n\nvoid mainImage(const vec4 inputColor, const vec2 uv, out vec4 outputColor) {\n vec3 bloom = texture(bloomBuffer, uv).rgb;\n vec3 features = texture(featuresBuffer, uv).rgb;\n outputColor = vec4(inputColor.rgb + (bloom + features) * intensity, inputColor.a);\n}\n",{blendFunction:t,attributes:Y.CONVOLUTION,uniforms:new Map(Object.entries({bloomBuffer:new c(null),featuresBuffer:new c(null),intensity:new c(1)}))}),this.onResolutionChange=()=>{this.setSize(this.resolution.baseWidth,this.resolution.baseHeight)},this.renderTarget1=new _(1,1,{depthBuffer:!1,type:I}),this.renderTarget1.texture.name="LensFlare.Target1",this.renderTarget2=new _(1,1,{depthBuffer:!1,type:I}),this.renderTarget2.texture.name="LensFlare.Target2",this.thresholdMaterial=new oo,this.thresholdPass=new Q(this.thresholdMaterial),this.blurPass=new ee,this.blurPass.levels=8,this.preBlurPass=new te({kernelSize:ne.SMALL}),this.featuresMaterial=new co,this.featuresPass=new Q(this.featuresMaterial),this.uniforms.get("bloomBuffer").value=this.blurPass.texture,this.uniforms.get("featuresBuffer").value=this.renderTarget1.texture,this.resolution=new J(this,a,o,n),this.resolution.addEventListener("change",this.onResolutionChange),this.intensity=s}initialize(e,t,n){this.thresholdPass.initialize(e,t,n),this.blurPass.initialize(e,t,n),this.preBlurPass.initialize(e,t,n),this.featuresPass.initialize(e,t,n)}update(e,t,n){this.thresholdPass.render(e,t,this.renderTarget1),this.blurPass.render(e,this.renderTarget1,null),this.preBlurPass.render(e,this.renderTarget1,this.renderTarget2),this.featuresPass.render(e,this.renderTarget2,this.renderTarget1)}setSize(e,t){const n=this.resolution;n.setBaseSize(e,t);const{width:r,height:i}=n;this.renderTarget1.setSize(r,i),this.renderTarget2.setSize(r,i),this.thresholdMaterial.setSize(r,i),this.blurPass.setSize(r,i),this.preBlurPass.setSize(r,i),this.featuresMaterial.setSize(r,i)}get intensity(){return this.uniforms.get("intensity").value}set intensity(e){this.uniforms.get("intensity").value=e}get thresholdLevel(){return this.thresholdMaterial.thresholdLevel}set thresholdLevel(e){this.thresholdMaterial.thresholdLevel=e}get thresholdRange(){return this.thresholdMaterial.thresholdRange}set thresholdRange(e){this.thresholdMaterial.thresholdRange=e}}var lo=Object.defineProperty,ho=(e,t,n,r)=>{for(var i,a=void 0,o=e.length-1;o>=0;o--)(i=e[o])&&(a=i(t,n,a)||a);return a&&lo(t,n,a),a};const po={blendFunction:k.SRC,octEncoded:!1,reconstructFromDepth:!1};class _o extends W{constructor(e,n){const{blendFunction:r,normalBuffer:i=null,octEncoded:a,reconstructFromDepth:o}={...po,...n};super("NormalEffect",_r('#include "core/depth"\n#include "core/packing"\n#include "core/transform"\n\nuniform highp sampler2D normalBuffer;\n\nuniform mat4 projectionMatrix;\nuniform mat4 inverseProjectionMatrix;\n\nvec3 reconstructNormal(const vec2 uv) {\n float depth = readDepth(uv);\n depth = reverseLogDepth(depth, cameraNear, cameraFar);\n vec3 position = screenToView(\n uv,\n depth,\n getViewZ(depth),\n projectionMatrix,\n inverseProjectionMatrix\n );\n vec3 dx = dFdx(position);\n vec3 dy = dFdy(position);\n return normalize(cross(dx, dy));\n}\n\nvec3 readNormal(const vec2 uv) {\n #ifdef OCT_ENCODED\n return unpackVec2ToNormal(texture(normalBuffer, uv).xy);\n #else // OCT_ENCODED\n return 2.0 * texture(normalBuffer, uv).xyz - 1.0;\n #endif // OCT_ENCODED\n}\n\nvoid mainImage(const vec4 inputColor, const vec2 uv, out vec4 outputColor) {\n #ifdef RECONSTRUCT_FROM_DEPTH\n vec3 normal = reconstructNormal(uv);\n #else // RECONSTRUCT_FROM_DEPTH\n vec3 normal = readNormal(uv);\n #endif // RECONSTRUCT_FROM_DEPTH\n\n outputColor = vec4(normal * 0.5 + 0.5, inputColor.a);\n}\n',{core:{depth:vr,packing:Tr,transform:Er}}),{blendFunction:r,attributes:Y.DEPTH,uniforms:new Map(Object.entries({normalBuffer:new c(i),projectionMatrix:new c(new t),inverseProjectionMatrix:new c(new t)}))}),this.camera=e,null!=e&&(this.mainCamera=e),this.octEncoded=a,this.reconstructFromDepth=o}get mainCamera(){return this.camera}set mainCamera(e){this.camera=e}update(e,t,n){const r=this.uniforms,i=r.get("projectionMatrix"),a=r.get("inverseProjectionMatrix"),o=this.camera;null!=o&&(i.value.copy(o.projectionMatrix),a.value.copy(o.projectionMatrixInverse))}get normalBuffer(){return this.uniforms.get("normalBuffer").value}set normalBuffer(e){this.uniforms.get("normalBuffer").value=e}}ho([$n("OCT_ENCODED")],_o.prototype,"octEncoded"),ho([$n("RECONSTRUCT_FROM_DEPTH")],_o.prototype,"reconstructFromDepth");const go=new pe,fo=new e,vo=new e,To=new e,So=new e;(new F).enable(10);class Eo{set neesUpdate(e){!0===e&&(this.cacheKey=Math.random().toString())}constructor(n){this.ssp=n,this.cacheKey="",this.date=new Date,this.longitude=120,this.latitude=30,this.altitude=20,this.distance=300,this.target=new e,this.groundAlbedo="black",this.castShadow=!0,this.atmosphereProps={rotationMatrix:new t,sunDirection:new e,moonDirection:new e,ellipsoidCenter:new e,ellipsoidMatrix:new t},this._started=!1,this.update=()=>{const{date:t,longitude:n,latitude:r,altitude:i,distance:a,target:o,groundAlbedo:s,castShadow:c,skyMaterial:u,skyLight:d,sunLight:m,aerialPerspectiveEffect:l}=this,{rotationMatrix:h,sunDirection:p,moonDirection:_,ellipsoidCenter:g,ellipsoidMatrix:f}=this.atmosphereProps,{ssp:{viewport:{renderer:v}}}=this;pa(t,h),function(t,n=new e){return _a(hi.Sun,ha(t),n)}(t,p).applyMatrix4(h),function(t,n=new e){return _a(hi.Moon,ha(t),n)}(t,_).applyMatrix4(h),go.set(Zn(n),Zn(r),i),go.toECEF(fo),g.copy(fo).multiplyScalar(-1),de.WGS84.getEastNorthUpVectors(fo,vo,To,So),f.makeBasis(To,So,vo).invert(),u.groundAlbedo.set(s),u.sunDirection.copy(p),u.moonDirection.copy(_),u.ellipsoidCenter.copy(g),u.ellipsoidMatrix.copy(f),d.sunDirection.copy(p),d.ellipsoidCenter.copy(g),d.ellipsoidMatrix.copy(f),d.position.copy(o),m.castShadow=c,m.distance=a,m.shadow.camera.top=a,m.shadow.camera.bottom=-a,m.shadow.camera.left=-a,m.shadow.camera.right=a,m.shadow.camera.far=2*a,m.sunDirection.copy(p),m.ellipsoidCenter.copy(g),m.ellipsoidMatrix.copy(f),m.target.position.copy(o),l.sunDirection.copy(p),l.moonDirection.copy(_),l.ellipsoidCenter.copy(g),l.ellipsoidMatrix.copy(f);const T=this.getCacheKey();T!==this.cacheKey&&(this.cacheKey=T,c&&(m.shadow.needsUpdate=!0,m.shadow.camera.updateProjectionMatrix()),this.skyMesh.material.sun=!1,this.cubeCamera.update(v,this.skyMesh),this.skyMesh.material.sun=!0),d.update(),m.update()};const{viewport:{scene:r,camera:i,renderer:a}}=n;this.date.setHours(10,0,0,0),this.texturesGenerator=new Ua(a),this.arrayBufferLoader=new _e,this.skyMaterial=new qa,this.skyMesh=new E(new R(2,2),this.skyMaterial),this.skyMesh.frustumCulled=!1,this.skyMesh.renderOrder=100,this.skyLight=new Ya,this.sunLight=new eo,this.sunLight.shadow.autoUpdate=!1,this.sunLight.shadow.bias=-5e-4,this.sunLight.shadow.normalBias=.5,this.sunLight.shadow.camera.near=.01,this.sunLight.shadow.mapSize.width=a.capabilities.maxTextureSize,this.sunLight.shadow.mapSize.height=a.capabilities.maxTextureSize,this.aerialPerspectiveEffect=new Kr(i),this.aerialPerspective={effect:this.aerialPerspectiveEffect,enabled:!1},this.lensFlareEffect=new mo,this.lensFlare={effect:this.lensFlareEffect,enabled:!1},this.ditheringEffect=new io,this.dithering={effect:this.ditheringEffect,enabled:!1},this.lightingMaskPass=new Ca(r,i),this.lightingMaskPass.selectionLayer=10,this.cubeRenderTarget=new B(512,{type:I}),this.cubeCamera=new z(.1,1e3,this.cubeRenderTarget)}getCacheKey(){const{date:e,longitude:t,latitude:n,altitude:r,distance:i,target:a,groundAlbedo:o,castShadow:s}=this;return`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}-${e.getHours()}-${e.getMinutes()}-${t}-${n}-${r}-${i}-${a.x}-${a.y}-${a.z}-${o}-${s}`}start(){if(this._started)return;this._started=!0;const{scene:e,camera:t,effectManager:n,signals:r}=this.ssp.viewport;(async()=>{const e=await this.texturesGenerator.update();Object.assign(this.skyMaterial,e),this.sunLight.transmittanceTexture=e.transmittanceTexture,this.skyLight.irradianceTexture=e.irradianceTexture,Object.assign(this.aerialPerspectiveEffect,e),this.neesUpdate=!0,this.ssp.render()})(),e.add(this.skyMesh),e.add(this.skyLight),e.add(this.sunLight),e.add(this.sunLight.target),this.aerialPerspective.enabled=!0,this.aerialPerspectiveEffect.mainCamera=t,this.lensFlare.enabled=!0,this.dithering.enabled=!0;const i=n.effectsMap.get("smaaEffect"),a=n.passesMap.get("normalPass");i&&(i.enabled=!1),a?(a.enabled=!0,this.aerialPerspectiveEffect.normalBuffer=a.texture,this.aerialPerspectiveEffect.sunLight=!0,this.aerialPerspectiveEffect.skyLight=!0,this.aerialPerspectiveEffect.lightingMask={map:this.lightingMaskPass.texture,channel:"r"}):(this.aerialPerspectiveEffect.normalBuffer=null,this.aerialPerspectiveEffect.sunLight=!1,this.aerialPerspectiveEffect.skyLight=!1),this.ssp.setToneMapping({type:"AGX",exposure:10}),e.environment=this.cubeRenderTarget.texture,n.effectsMap.set("aerialPerspectiveEffect",this.aerialPerspective),n.effectsMap.set("lensFlareEffect",this.lensFlare),n.effectsMap.set("ditheringEffect",this.dithering),n.effectsNeedsUpdate=!0,n.effectComposer.addPass(this.lightingMaskPass,-1),r.beforeRender.add(this.update)}updateModelLightingMask(){this.ssp.viewport.scener.intersectsList.meshOfModelList.forEach(e=>{e.layers.enable(10)})}stop(){if(!this._started)return;this._started=!1;const{scene:e,effectManager:t,signals:n}=this.ssp.viewport;e.remove(this.skyMesh),e.remove(this.skyLight),e.remove(this.sunLight),e.remove(this.sunLight.target),this.aerialPerspective.enabled=!1,this.lensFlare.enabled=!1,this.dithering.enabled=!1;const r=t.effectsMap.get("smaaEffect"),i=t.passesMap.get("normalPass");r&&(r.enabled=!0),i&&(i.enabled=!1),this.ssp.setToneMapping({type:"ACESFilmic",exposure:.8}),this.ssp.setEnvironment(),t.effectsMap.delete("aerialPerspectiveEffect"),t.effectsMap.delete("lensFlareEffect"),t.effectsMap.delete("ditheringEffect"),t.effectsNeedsUpdate=!0,t.effectComposer.removePass(this.lightingMaskPass),n.beforeRender.remove(this.update),this.ssp.render()}dispose(){this.stop(),this.aerialPerspectiveEffect.dispose(),this.lensFlareEffect.dispose(),this.ditheringEffect.dispose(),this.lightingMaskPass.dispose(),this.texturesGenerator.dispose(),this.skyMesh.geometry.dispose(),this.skyMesh.material.dispose(),this.skyLight.dispose(),this.sunLight.dispose(),this.cubeRenderTarget.dispose()}}export{Eo as default};
35
+ const ti=.017453292519943295,ni=new Date("2000-01-01T12:00:00Z"),ri=2*Math.PI,ii=180/Math.PI*3600,ai=484813681109536e-20,oi=.0002959122082855911,si=2.825345909524226e-7,ci=8.459715185680659e-8,ui=1.292024916781969e-8,di=1.524358900784276e-8;function mi(e){if(!Number.isFinite(e))throw console.trace(),`Value is not a finite number: ${e}`;return e}function li(e){return e-Math.floor(e)}var hi;!function(e){e.Sun="Sun",e.Moon="Moon",e.Mercury="Mercury",e.Venus="Venus",e.Earth="Earth",e.Mars="Mars",e.Jupiter="Jupiter",e.Saturn="Saturn",e.Uranus="Uranus",e.Neptune="Neptune",e.Pluto="Pluto",e.SSB="SSB",e.EMB="EMB",e.Star1="Star1",e.Star2="Star2",e.Star3="Star3",e.Star4="Star4",e.Star5="Star5",e.Star6="Star6",e.Star7="Star7",e.Star8="Star8"}(hi||(hi={}));const pi=[hi.Star1,hi.Star2,hi.Star3,hi.Star4,hi.Star5,hi.Star6,hi.Star7,hi.Star8],_i=[{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0}];function gi(e){const t=function(e){const t=pi.indexOf(e);return t>=0?_i[t]:null}(e);return t&&t.dist>0?t:null}var fi;!function(e){e[e.From2000=0]="From2000",e[e.Into2000=1]="Into2000"}(fi||(fi={}));const vi={Mercury:[[[[4.40250710144,0,0],[.40989414977,1.48302034195,26087.9031415742],[.050462942,4.47785489551,52175.8062831484],[.00855346844,1.16520322459,78263.70942472259],[.00165590362,4.11969163423,104351.61256629678],[.00034561897,.77930768443,130439.51570787099],[7583476e-11,3.71348404924,156527.41884944518]],[[26087.90313685529,0,0],[.01131199811,6.21874197797,26087.9031415742],[.00292242298,3.04449355541,52175.8062831484],[.00075775081,6.08568821653,78263.70942472259],[.00019676525,2.80965111777,104351.61256629678]]],[[[.11737528961,1.98357498767,26087.9031415742],[.02388076996,5.03738959686,52175.8062831484],[.01222839532,3.14159265359,0],[.0054325181,1.79644363964,78263.70942472259],[.0012977877,4.83232503958,104351.61256629678],[.00031866927,1.58088495658,130439.51570787099],[7963301e-11,4.60972126127,156527.41884944518]],[[.00274646065,3.95008450011,26087.9031415742],[.00099737713,3.14159265359,0]]],[[[.39528271651,0,0],[.07834131818,6.19233722598,26087.9031415742],[.00795525558,2.95989690104,52175.8062831484],[.00121281764,6.01064153797,78263.70942472259],[.00021921969,2.77820093972,104351.61256629678],[4354065e-11,5.82894543774,130439.51570787099]],[[.0021734774,4.65617158665,26087.9031415742],[.00044141826,1.42385544001,52175.8062831484]]]],Venus:[[[[3.17614666774,0,0],[.01353968419,5.59313319619,10213.285546211],[.00089891645,5.30650047764,20426.571092422],[5477194e-11,4.41630661466,7860.4193924392],[3455741e-11,2.6996444782,11790.6290886588],[2372061e-11,2.99377542079,3930.2096962196],[1317168e-11,5.18668228402,26.2983197998],[1664146e-11,4.25018630147,1577.3435424478],[1438387e-11,4.15745084182,9683.5945811164],[1200521e-11,6.15357116043,30639.856638633]],[[10213.28554621638,0,0],[.00095617813,2.4640651111,10213.285546211],[7787201e-11,.6247848222,20426.571092422]]],[[[.05923638472,.26702775812,10213.285546211],[.00040107978,1.14737178112,20426.571092422],[.00032814918,3.14159265359,0]],[[.00287821243,1.88964962838,10213.285546211]]],[[[.72334820891,0,0],[.00489824182,4.02151831717,10213.285546211],[1658058e-11,4.90206728031,20426.571092422],[1378043e-11,1.12846591367,11790.6290886588],[1632096e-11,2.84548795207,7860.4193924392],[498395e-11,2.58682193892,9683.5945811164],[221985e-11,2.01346696541,19367.1891622328],[237454e-11,2.55136053886,15720.8387848784]],[[.00034551041,.89198706276,10213.285546211]]]],Earth:[[[[1.75347045673,0,0],[.03341656453,4.66925680415,6283.0758499914],[.00034894275,4.62610242189,12566.1516999828],[3417572e-11,2.82886579754,3.523118349],[3497056e-11,2.74411783405,5753.3848848968],[3135899e-11,3.62767041756,77713.7714681205],[2676218e-11,4.41808345438,7860.4193924392],[2342691e-11,6.13516214446,3930.2096962196],[1273165e-11,2.03709657878,529.6909650946],[1324294e-11,.74246341673,11506.7697697936],[901854e-11,2.04505446477,26.2983197998],[1199167e-11,1.10962946234,1577.3435424478],[857223e-11,3.50849152283,398.1490034082],[779786e-11,1.17882681962,5223.6939198022],[99025e-10,5.23268072088,5884.9268465832],[753141e-11,2.53339052847,5507.5532386674],[505267e-11,4.58292599973,18849.2275499742],[492392e-11,4.20505711826,775.522611324],[356672e-11,2.91954114478,.0673103028],[284125e-11,1.89869240932,796.2980068164],[242879e-11,.34481445893,5486.777843175],[317087e-11,5.84901948512,11790.6290886588],[271112e-11,.31486255375,10977.078804699],[206217e-11,4.80646631478,2544.3144198834],[205478e-11,1.86953770281,5573.1428014331],[202318e-11,2.45767790232,6069.7767545534],[126225e-11,1.08295459501,20.7753954924],[155516e-11,.83306084617,213.299095438]],[[6283.0758499914,0,0],[.00206058863,2.67823455808,6283.0758499914],[4303419e-11,2.63512233481,12566.1516999828]],[[8721859e-11,1.07253635559,6283.0758499914]]],[[],[[.00227777722,3.4137662053,6283.0758499914],[3805678e-11,3.37063423795,12566.1516999828]]],[[[1.00013988784,0,0],[.01670699632,3.09846350258,6283.0758499914],[.00013956024,3.05524609456,12566.1516999828],[308372e-10,5.19846674381,77713.7714681205],[1628463e-11,1.17387558054,5753.3848848968],[1575572e-11,2.84685214877,7860.4193924392],[924799e-11,5.45292236722,11506.7697697936],[542439e-11,4.56409151453,3930.2096962196],[47211e-10,3.66100022149,5884.9268465832],[8.5831e-7,1.27079125277,161000.6857376741],[5.7056e-7,2.01374292245,83996.84731811189],[5.5736e-7,5.2415979917,71430.69561812909],[174844e-11,3.01193636733,18849.2275499742],[243181e-11,4.2734953079,11790.6290886588]],[[.00103018607,1.10748968172,6283.0758499914],[1721238e-11,1.06442300386,12566.1516999828]],[[4359385e-11,5.78455133808,6283.0758499914]]]],Mars:[[[[6.20347711581,0,0],[.18656368093,5.0503710027,3340.6124266998],[.01108216816,5.40099836344,6681.2248533996],[.00091798406,5.75478744667,10021.8372800994],[.00027744987,5.97049513147,3.523118349],[.00010610235,2.93958560338,2281.2304965106],[.00012315897,.84956094002,2810.9214616052],[8926784e-11,4.15697846427,.0172536522],[8715691e-11,6.11005153139,13362.4497067992],[6797556e-11,.36462229657,398.1490034082],[7774872e-11,3.33968761376,5621.8429232104],[3575078e-11,1.6618650571,2544.3144198834],[4161108e-11,.22814971327,2942.4634232916],[3075252e-11,.85696614132,191.4482661116],[2628117e-11,.64806124465,3337.0893083508],[2937546e-11,6.07893711402,.0673103028],[2389414e-11,5.03896442664,796.2980068164],[2579844e-11,.02996736156,3344.1355450488],[1528141e-11,1.14979301996,6151.533888305],[1798806e-11,.65634057445,529.6909650946],[1264357e-11,3.62275122593,5092.1519581158],[1286228e-11,3.06796065034,2146.1654164752],[1546404e-11,2.91579701718,1751.539531416],[1024902e-11,3.69334099279,8962.4553499102],[891566e-11,.18293837498,16703.062133499],[858759e-11,2.4009381194,2914.0142358238],[832715e-11,2.46418619474,3340.5951730476],[83272e-10,4.49495782139,3340.629680352],[712902e-11,3.66335473479,1059.3819301892],[748723e-11,3.82248614017,155.4203994342],[723861e-11,.67497311481,3738.761430108],[635548e-11,2.92182225127,8432.7643848156],[655162e-11,.48864064125,3127.3133312618],[550474e-11,3.81001042328,.9803210682],[55275e-10,4.47479317037,1748.016413067],[425966e-11,.55364317304,6283.0758499914],[415131e-11,.49662285038,213.299095438],[472167e-11,3.62547124025,1194.4470102246],[306551e-11,.38052848348,6684.7479717486],[312141e-11,.99853944405,6677.7017350506],[293198e-11,4.22131299634,20.7753954924],[302375e-11,4.48618007156,3532.0606928114],[274027e-11,.54222167059,3340.545116397],[281079e-11,5.88163521788,1349.8674096588],[231183e-11,1.28242156993,3870.3033917944],[283602e-11,5.7688543494,3149.1641605882],[236117e-11,5.75503217933,3333.498879699],[274033e-11,.13372524985,3340.6797370026],[299395e-11,2.78323740866,6254.6266625236]],[[3340.61242700512,0,0],[.01457554523,3.60433733236,3340.6124266998],[.00168414711,3.92318567804,6681.2248533996],[.00020622975,4.26108844583,10021.8372800994],[3452392e-11,4.7321039319,3.523118349],[2586332e-11,4.60670058555,13362.4497067992],[841535e-11,4.45864030426,2281.2304965106]],[[.00058152577,2.04961712429,3340.6124266998],[.00013459579,2.45738706163,6681.2248533996]]],[[[.03197134986,3.76832042431,3340.6124266998],[.00298033234,4.10616996305,6681.2248533996],[.00289104742,0,0],[.00031365539,4.4465105309,10021.8372800994],[34841e-9,4.7881254926,13362.4497067992]],[[.00217310991,6.04472194776,3340.6124266998],[.00020976948,3.14159265359,0],[.00012834709,1.60810667915,6681.2248533996]]],[[[1.53033488271,0,0],[.1418495316,3.47971283528,3340.6124266998],[.00660776362,3.81783443019,6681.2248533996],[.00046179117,4.15595316782,10021.8372800994],[8109733e-11,5.55958416318,2810.9214616052],[7485318e-11,1.77239078402,5621.8429232104],[5523191e-11,1.3643630377,2281.2304965106],[382516e-10,4.49407183687,13362.4497067992],[2306537e-11,.09081579001,2544.3144198834],[1999396e-11,5.36059617709,3337.0893083508],[2484394e-11,4.9254563992,2942.4634232916],[1960195e-11,4.74249437639,3344.1355450488],[1167119e-11,2.11260868341,5092.1519581158],[1102816e-11,5.00908403998,398.1490034082],[899066e-11,4.40791133207,529.6909650946],[992252e-11,5.83861961952,6151.533888305],[807354e-11,2.10217065501,1059.3819301892],[797915e-11,3.44839203899,796.2980068164],[740975e-11,1.49906336885,2146.1654164752]],[[.01107433345,2.03250524857,3340.6124266998],[.00103175887,2.37071847807,6681.2248533996],[128772e-9,0,0],[.0001081588,2.70888095665,10021.8372800994]],[[.00044242249,.47930604954,3340.6124266998],[8138042e-11,.86998389204,6681.2248533996]]]],Jupiter:[[[[.59954691494,0,0],[.09695898719,5.06191793158,529.6909650946],[.00573610142,1.44406205629,7.1135470008],[.00306389205,5.41734730184,1059.3819301892],[.00097178296,4.14264726552,632.7837393132],[.00072903078,3.64042916389,522.5774180938],[.00064263975,3.41145165351,103.0927742186],[.00039806064,2.29376740788,419.4846438752],[.00038857767,1.27231755835,316.3918696566],[.00027964629,1.7845459182,536.8045120954],[.0001358973,5.7748104079,1589.0728952838],[8246349e-11,3.5822792584,206.1855484372],[8768704e-11,3.63000308199,949.1756089698],[7368042e-11,5.0810119427,735.8765135318],[626315e-10,.02497628807,213.299095438],[6114062e-11,4.51319998626,1162.4747044078],[4905396e-11,1.32084470588,110.2063212194],[5305285e-11,1.30671216791,14.2270940016],[5305441e-11,4.18625634012,1052.2683831884],[4647248e-11,4.69958103684,3.9321532631],[3045023e-11,4.31676431084,426.598190876],[2609999e-11,1.56667394063,846.0828347512],[2028191e-11,1.06376530715,3.1813937377],[1764763e-11,2.14148655117,1066.49547719],[1722972e-11,3.88036268267,1265.5674786264],[1920945e-11,.97168196472,639.897286314],[1633223e-11,3.58201833555,515.463871093],[1431999e-11,4.29685556046,625.6701923124],[973272e-11,4.09764549134,95.9792272178]],[[529.69096508814,0,0],[.00489503243,4.2208293947,529.6909650946],[.00228917222,6.02646855621,7.1135470008],[.00030099479,4.54540782858,1059.3819301892],[.0002072092,5.45943156902,522.5774180938],[.00012103653,.16994816098,536.8045120954],[6067987e-11,4.42422292017,103.0927742186],[5433968e-11,3.98480737746,419.4846438752],[4237744e-11,5.89008707199,14.2270940016]],[[.00047233601,4.32148536482,7.1135470008],[.00030649436,2.929777887,529.6909650946],[.00014837605,3.14159265359,0]]],[[[.02268615702,3.55852606721,529.6909650946],[.00109971634,3.90809347197,1059.3819301892],[.00110090358,0,0],[8101428e-11,3.60509572885,522.5774180938],[6043996e-11,4.25883108339,1589.0728952838],[6437782e-11,.30627119215,536.8045120954]],[[.00078203446,1.52377859742,529.6909650946]]],[[[5.20887429326,0,0],[.25209327119,3.49108639871,529.6909650946],[.00610599976,3.84115365948,1059.3819301892],[.00282029458,2.57419881293,632.7837393132],[.00187647346,2.07590383214,522.5774180938],[.00086792905,.71001145545,419.4846438752],[.00072062974,.21465724607,536.8045120954],[.00065517248,5.9799588479,316.3918696566],[.00029134542,1.67759379655,103.0927742186],[.00030135335,2.16132003734,949.1756089698],[.00023453271,3.54023522184,735.8765135318],[.00022283743,4.19362594399,1589.0728952838],[.00023947298,.2745803748,7.1135470008],[.00013032614,2.96042965363,1162.4747044078],[970336e-10,1.90669633585,206.1855484372],[.00012749023,2.71550286592,1052.2683831884],[7057931e-11,2.18184839926,1265.5674786264],[6137703e-11,6.26418240033,846.0828347512],[2616976e-11,2.00994012876,1581.959348283]],[[.0127180152,2.64937512894,529.6909650946],[.00061661816,3.00076460387,1059.3819301892],[.00053443713,3.89717383175,522.5774180938],[.00031185171,4.88276958012,536.8045120954],[.00041390269,0,0]]]],Saturn:[[[[.87401354025,0,0],[.11107659762,3.96205090159,213.299095438],[.01414150957,4.58581516874,7.1135470008],[.00398379389,.52112032699,206.1855484372],[.00350769243,3.30329907896,426.598190876],[.00206816305,.24658372002,103.0927742186],[792713e-9,3.84007056878,220.4126424388],[.00023990355,4.66976924553,110.2063212194],[.00016573588,.43719228296,419.4846438752],[.00014906995,5.76903183869,316.3918696566],[.0001582029,.93809155235,632.7837393132],[.00014609559,1.56518472,3.9321532631],[.00013160301,4.44891291899,14.2270940016],[.00015053543,2.71669915667,639.897286314],[.00013005299,5.98119023644,11.0457002639],[.00010725067,3.12939523827,202.2533951741],[5863206e-11,.23656938524,529.6909650946],[5227757e-11,4.20783365759,3.1813937377],[6126317e-11,1.76328667907,277.0349937414],[5019687e-11,3.17787728405,433.7117378768],[459255e-10,.61977744975,199.0720014364],[4005867e-11,2.24479718502,63.7358983034],[2953796e-11,.98280366998,95.9792272178],[387367e-10,3.22283226966,138.5174968707],[2461186e-11,2.03163875071,735.8765135318],[3269484e-11,.77492638211,949.1756089698],[1758145e-11,3.2658010994,522.5774180938],[1640172e-11,5.5050445305,846.0828347512],[1391327e-11,4.02333150505,323.5054166574],[1580648e-11,4.37265307169,309.2783226558],[1123498e-11,2.83726798446,415.5524906121],[1017275e-11,3.71700135395,227.5261894396],[848642e-11,3.1915017083,209.3669421749]],[[213.2990952169,0,0],[.01297370862,1.82834923978,213.299095438],[.00564345393,2.88499717272,7.1135470008],[.00093734369,1.06311793502,426.598190876],[.00107674962,2.27769131009,206.1855484372],[.00040244455,2.04108104671,220.4126424388],[.00019941774,1.2795439047,103.0927742186],[.00010511678,2.7488034213,14.2270940016],[6416106e-11,.38238295041,639.897286314],[4848994e-11,2.43037610229,419.4846438752],[4056892e-11,2.92133209468,110.2063212194],[3768635e-11,3.6496533078,3.9321532631]],[[.0011644133,1.17988132879,7.1135470008],[.00091841837,.0732519584,213.299095438],[.00036661728,0,0],[.00015274496,4.06493179167,206.1855484372]]],[[[.04330678039,3.60284428399,213.299095438],[.00240348302,2.85238489373,426.598190876],[.00084745939,0,0],[.00030863357,3.48441504555,220.4126424388],[.00034116062,.57297307557,206.1855484372],[.0001473407,2.11846596715,639.897286314],[9916667e-11,5.79003188904,419.4846438752],[6993564e-11,4.7360468972,7.1135470008],[4807588e-11,5.43305312061,316.3918696566]],[[.00198927992,4.93901017903,213.299095438],[.00036947916,3.14159265359,0],[.00017966989,.5197943111,426.598190876]]],[[[9.55758135486,0,0],[.52921382865,2.39226219573,213.299095438],[.01873679867,5.2354960466,206.1855484372],[.01464663929,1.64763042902,426.598190876],[.00821891141,5.93520042303,316.3918696566],[.00547506923,5.0153261898,103.0927742186],[.0037168465,2.27114821115,220.4126424388],[.00361778765,3.13904301847,7.1135470008],[.00140617506,5.70406606781,632.7837393132],[.00108974848,3.29313390175,110.2063212194],[.00069006962,5.94099540992,419.4846438752],[.00061053367,.94037691801,639.897286314],[.00048913294,1.55733638681,202.2533951741],[.00034143772,.19519102597,277.0349937414],[.00032401773,5.47084567016,949.1756089698],[.00020936596,.46349251129,735.8765135318],[9796004e-11,5.20477537945,1265.5674786264],[.00011993338,5.98050967385,846.0828347512],[208393e-9,1.52102476129,433.7117378768],[.00015298404,3.0594381494,529.6909650946],[6465823e-11,.17732249942,1052.2683831884],[.00011380257,1.7310542704,522.5774180938],[3419618e-11,4.94550542171,1581.959348283]],[[.0618298134,.2584351148,213.299095438],[.00506577242,.71114625261,206.1855484372],[.00341394029,5.79635741658,426.598190876],[.00188491195,.47215589652,220.4126424388],[.00186261486,3.14159265359,0],[.00143891146,1.40744822888,7.1135470008]],[[.00436902572,4.78671677509,213.299095438]]]],Uranus:[[[[5.48129294297,0,0],[.09260408234,.89106421507,74.7815985673],[.01504247898,3.6271926092,1.4844727083],[.00365981674,1.89962179044,73.297125859],[.00272328168,3.35823706307,149.5631971346],[.00070328461,5.39254450063,63.7358983034],[.00068892678,6.09292483287,76.2660712756],[.00061998615,2.26952066061,2.9689454166],[.00061950719,2.85098872691,11.0457002639],[.0002646877,3.14152083966,71.8126531507],[.00025710476,6.11379840493,454.9093665273],[.0002107885,4.36059339067,148.0787244263],[.00017818647,1.74436930289,36.6485629295],[.00014613507,4.73732166022,3.9321532631],[.00011162509,5.8268179635,224.3447957019],[.0001099791,.48865004018,138.5174968707],[9527478e-11,2.95516862826,35.1640902212],[7545601e-11,5.236265824,109.9456887885],[4220241e-11,3.23328220918,70.8494453042],[40519e-9,2.277550173,151.0476698429],[3354596e-11,1.0654900738,4.4534181249],[2926718e-11,4.62903718891,9.5612275556],[349034e-10,5.48306144511,146.594251718],[3144069e-11,4.75199570434,77.7505439839],[2922333e-11,5.35235361027,85.8272988312],[2272788e-11,4.36600400036,70.3281804424],[2051219e-11,1.51773566586,.1118745846],[2148602e-11,.60745949945,38.1330356378],[1991643e-11,4.92437588682,277.0349937414],[1376226e-11,2.04283539351,65.2203710117],[1666902e-11,3.62744066769,380.12776796],[1284107e-11,3.11347961505,202.2533951741],[1150429e-11,.93343589092,3.1813937377],[1533221e-11,2.58594681212,52.6901980395],[1281604e-11,.54271272721,222.8603229936],[1372139e-11,4.19641530878,111.4301614968],[1221029e-11,.1990065003,108.4612160802],[946181e-11,1.19253165736,127.4717966068],[1150989e-11,4.17898916639,33.6796175129]],[[74.7815986091,0,0],[.00154332863,5.24158770553,74.7815985673],[.00024456474,1.71260334156,1.4844727083],[9258442e-11,.4282973235,11.0457002639],[8265977e-11,1.50218091379,63.7358983034],[915016e-10,1.41213765216,149.5631971346]]],[[[.01346277648,2.61877810547,74.7815985673],[623414e-9,5.08111189648,149.5631971346],[.00061601196,3.14159265359,0],[9963722e-11,1.61603805646,76.2660712756],[992616e-10,.57630380333,73.297125859]],[[.00034101978,.01321929936,74.7815985673]]],[[[19.21264847206,0,0],[.88784984413,5.60377527014,74.7815985673],[.03440836062,.32836099706,73.297125859],[.0205565386,1.7829515933,149.5631971346],[.0064932241,4.52247285911,76.2660712756],[.00602247865,3.86003823674,63.7358983034],[.00496404167,1.40139935333,454.9093665273],[.00338525369,1.58002770318,138.5174968707],[.00243509114,1.57086606044,71.8126531507],[.00190522303,1.99809394714,1.4844727083],[.00161858838,2.79137786799,148.0787244263],[.00143706183,1.38368544947,11.0457002639],[.00093192405,.17437220467,36.6485629295],[.00071424548,4.24509236074,224.3447957019],[.00089806014,3.66105364565,109.9456887885],[.00039009723,1.66971401684,70.8494453042],[.00046677296,1.39976401694,35.1640902212],[.00039025624,3.36234773834,277.0349937414],[.00036755274,3.88649278513,146.594251718],[.00030348723,.70100838798,151.0476698429],[.00029156413,3.180563367,77.7505439839],[.00022637073,.72518687029,529.6909650946],[.00011959076,1.7504339214,984.6003316219],[.00025620756,5.25656086672,380.12776796]],[[.01479896629,3.67205697578,74.7815985673]]]],Neptune:[[[[5.31188633046,0,0],[.0179847553,2.9010127389,38.1330356378],[.01019727652,.48580922867,1.4844727083],[.00124531845,4.83008090676,36.6485629295],[.00042064466,5.41054993053,2.9689454166],[.00037714584,6.09221808686,35.1640902212],[.00033784738,1.24488874087,76.2660712756],[.00016482741,7727998e-11,491.5579294568],[9198584e-11,4.93747051954,39.6175083461],[899425e-10,.27462171806,175.1660598002]],[[38.13303563957,0,0],[.00016604172,4.86323329249,1.4844727083],[.00015744045,2.27887427527,38.1330356378]]],[[[.03088622933,1.44104372644,38.1330356378],[.00027780087,5.91271884599,76.2660712756],[.00027623609,0,0],[.00015355489,2.52123799551,36.6485629295],[.00015448133,3.50877079215,39.6175083461]]],[[[30.07013205828,0,0],[.27062259632,1.32999459377,38.1330356378],[.01691764014,3.25186135653,36.6485629295],[.00807830553,5.18592878704,1.4844727083],[.0053776051,4.52113935896,35.1640902212],[.00495725141,1.5710564165,491.5579294568],[.00274571975,1.84552258866,175.1660598002],[.0001201232,1.92059384991,1021.2488945514],[.00121801746,5.79754470298,76.2660712756],[.00100896068,.3770272493,73.297125859],[.00135134092,3.37220609835,39.6175083461],[7571796e-11,1.07149207335,388.4651552382]]]]};let Ti=function(e){var t,n,r,i;const a=2e3+(e-14)/365.24217;return a<-500?32*(t=(a-1820)/100)*t-20:a<500?10583.6-1014.41*(t=a/100)+33.78311*(n=t*t)-5.952053*(r=t*n)-.1798452*(i=n*n)+.022174192*(n*r)+.0090316521*(r*r):a<1600?1574.2-556.01*(t=(a-1e3)/100)+71.23472*(n=t*t)+.319781*(r=t*n)-.8503463*(i=n*n)-.005050998*(n*r)+.0083572073*(r*r):a<1700?120-.9808*(t=a-1600)-.01532*(n=t*t)+(r=t*n)/7129:a<1800?8.83+.1603*(t=a-1700)-.0059285*(n=t*t)+13336e-8*(r=t*n)-(i=n*n)/1174e3:a<1860?13.72-.332447*(t=a-1800)+.0068612*(n=t*t)+.0041116*(r=t*n)-37436e-8*(i=n*n)+121272e-10*(n*r)-1.699e-7*(r*r)+8.75e-10*(r*i):a<1900?7.62+.5737*(t=a-1860)-.251754*(n=t*t)+.01680668*(r=t*n)-.0004473624*(i=n*n)+n*r/233174:a<1920?1.494119*(t=a-1900)-2.79-.0598939*(n=t*t)+.0061966*(r=t*n)-197e-6*(i=n*n):a<1941?21.2+.84493*(t=a-1920)-.0761*(n=t*t)+.0020936*(r=t*n):a<1961?29.07+.407*(t=a-1950)-(n=t*t)/233+(r=t*n)/2547:a<1986?45.45+1.067*(t=a-1975)-(n=t*t)/260-(r=t*n)/718:a<2005?63.86+.3345*(t=a-2e3)-.060374*(n=t*t)+.0017275*(r=t*n)+651814e-9*(i=n*n)+2373599e-11*(n*r):a<2050?62.92+.32217*(t=a-2e3)+.005589*t*t:a<2150?32*(t=(a-1820)/100)*t-20-.5628*(2150-a):32*(t=(a-1820)/100)*t-20};function Si(e){return e+Ti(e)/86400}let Ei=class e{constructor(t){if(t instanceof e)return this.date=t.date,this.ut=t.ut,void(this.tt=t.tt);const n=864e5;if(t instanceof Date&&Number.isFinite(t.getTime()))return this.date=t,this.ut=(t.getTime()-ni.getTime())/n,void(this.tt=Si(this.ut));if(Number.isFinite(t))return this.date=new Date(ni.getTime()+t*n),this.ut=t,void(this.tt=Si(this.ut));throw"Argument must be a Date object, an AstroTime object, or a numeric UTC Julian date."}static FromTerrestrialTime(t){let n=new e(t);for(;;){const e=t-n.tt;if(Math.abs(e)<1e-12)return n;n=n.AddDays(e)}}toString(){return this.date.toISOString()}AddDays(t){return new e(this.ut+t)}};function Ri(e){return e instanceof Ei?e:new Ei(e)}function xi(e){var t=e.tt/36525;return(((((-4.34e-8*t-576e-9)*t+.0020034)*t-1831e-7)*t-46.836769)*t+84381.406)/3600}var Ai;function Ii(e){if(!Ai||Math.abs(Ai.tt-e.tt)>1e-6){const t=function(e){function t(e){return e%1296e3*ai}const n=e.tt/36525,r=t(1287104.79305+129596581.0481*n),i=t(335779.526232+1739527262.8478*n),a=t(1072260.70369+1602961601.209*n),o=t(450160.398036-6962890.5431*n);let s=Math.sin(o),c=Math.cos(o),u=(-172064161-174666*n)*s+33386*c,d=(92052331+9086*n)*c+15377*s,m=2*(i-a+o);return s=Math.sin(m),c=Math.cos(m),u+=(-13170906-1675*n)*s-13696*c,d+=(5730336-3015*n)*c-4587*s,m=2*(i+o),s=Math.sin(m),c=Math.cos(m),u+=(-2276413-234*n)*s+2796*c,d+=(978459-485*n)*c+1374*s,m=2*o,s=Math.sin(m),c=Math.cos(m),u+=(2074554+207*n)*s-698*c,d+=(470*n-897492)*c-291*s,s=Math.sin(r),c=Math.cos(r),u+=(1475877-3633*n)*s+11817*c,d+=(73871-184*n)*c-1924*s,{dpsi:1e-7*u-135e-6,deps:388e-6+1e-7*d}}(e),n=xi(e),r=n+t.deps/3600;Ai={tt:e.tt,dpsi:t.dpsi,deps:t.deps,ee:t.dpsi*Math.cos(n*ti)/15,mobl:n,tobl:r}}return Ai}function yi(e,t){return function(e,t){const n=e*ti,r=Math.cos(n),i=Math.sin(n);return[t[0],t[1]*r-t[2]*i,t[1]*i+t[2]*r]}(xi(e),t)}function Ni(e,t){const n=e.tt/36525;let r=84381.406,i=((((-9.51e-8*n+132851e-9)*n-.00114045)*n-1.0790069)*n+5038.481507)*n,a=((((3.337e-7*n-467e-9)*n-.00772503)*n+.0512623)*n-.025754)*n+r,o=((((-56e-9*n+170663e-9)*n-.00121197)*n-2.3814292)*n+10.556403)*n;r*=ai,i*=ai,a*=ai,o*=ai;const s=Math.sin(r),c=Math.cos(r),u=Math.sin(-i),d=Math.cos(-i),m=Math.sin(-a),l=Math.cos(-a),h=Math.sin(o),p=Math.cos(o),_=p*d-u*h*l,g=p*u*c+h*l*d*c-s*h*m,f=p*u*s+h*l*d*s+c*h*m,v=-h*d-u*p*l,T=-h*u*c+p*l*d*c-s*p*m,S=-h*u*s+p*l*d*s+c*p*m,E=u*m,R=-m*d*c-s*l,x=-m*d*s+l*c;if(t===fi.Into2000)return new Mi([[_,g,f],[v,T,S],[E,R,x]]);if(t===fi.From2000)return new Mi([[_,v,E],[g,T,R],[f,S,x]]);throw"Invalid precess direction"}let wi;function Ci(e){return function(e){if(!wi||wi.tt!==e.tt){const t=e.tt/36525;let n=15*Ii(e).ee;const r=function(e){let t=(.779057273264+.00273781191135448*e.ut+e.ut%1)%1*360;return t<0&&(t+=360),t}(e);let i=((n+.014506+((((-3.68e-8*t-29956e-9)*t-44e-8)*t+1.3915817)*t+4612.156534)*t)/3600+r)%360/15;i<0&&(i+=24),wi={tt:e.tt,st:i}}return wi.st}(Ri(e))}class bi{constructor(e,t,n,r){this.x=e,this.y=t,this.z=n,this.t=r}Length(){return Math.hypot(this.x,this.y,this.z)}}class Oi{constructor(e,t,n,r,i,a,o){this.x=e,this.y=t,this.z=n,this.vx=r,this.vy=i,this.vz=a,this.t=o}}class Di{constructor(e,t,n){this.lat=mi(e),this.lon=mi(t),this.dist=mi(n)}}class Mi{constructor(e){this.rot=e}}function Li(e){const t=Ri(e),n=function(e){const t=e.tt/36525;function n(e,t){const n=[];let r;for(r=0;r<=t-e;++r)n.push(0);return{min:e,array:n}}function r(e,t,r,i){const a=[];for(let o=0;o<=t-e;++o)a.push(n(r,i));return{min:e,array:a}}function i(e,t,n){const r=e.array[t-e.min];return r.array[n-r.min]}function a(e,t,n,r){const i=e.array[t-e.min];i.array[n-i.min]=r}let o,s,c,u,d,m,l,h,p,_,g,f,v,T,S,E,R,x,A,I,y,N,w,C=r(-6,6,1,4),b=r(-6,6,1,4);function O(e,t){return i(C,e,t)}function D(e,t){return i(b,e,t)}function M(e,t,n){return a(C,e,t,n)}function L(e,t,n){return a(b,e,t,n)}function P(e,t,n,r,i){i(e*n-t*r,t*n+e*r)}function U(e){return Math.sin(ri*e)}l=t*t,p=0,w=0,g=0,f=3422.7;var G=U(.19833+.05611*t),H=U(.27869+.04508*t),F=U(.16827-.36903*t),B=U(.34734-5.37261*t),z=U(.10498-5.37899*t),k=U(.42681-.41855*t);for(x=.84*G+.31*H+14.27*F+7.26*B+.28*z+.24*k,A=2.94*G+.31*H+14.27*F+9.34*B+1.12*z+.83*k,I=-6.4*G-1.89*k,y=.21*G+.31*H+14.27*F-88.7*B-15.3*z+.24*k-1.86*U(.14943-5.37511*t),N=x-I,h=-3332e-9*U(.59734-5.37261*t)-539e-9*U(.35498-5.37899*t)-64e-9*U(.39943-5.37511*t),v=ri*li(.60643382+1336.85522467*t-313e-8*l)+x/ii,T=ri*li(.37489701+1325.55240982*t+2565e-8*l)+A/ii,S=ri*li(.99312619+99.99735956*t-44e-8*l)+I/ii,E=ri*li(.25909118+1342.2278298*t-892e-8*l)+y/ii,R=ri*li(.82736186+1236.85308708*t-397e-8*l)+N/ii,d=1;d<=4;++d){switch(d){case 1:c=T,s=4,u=1.000002208;break;case 2:c=S,s=3,u=.997504612-.002495388*t;break;case 3:c=E,s=4,u=1.000002708+139.978*h;break;case 4:c=R,s=6,u=1;break;default:throw`Internal error: I = ${d}`}for(M(0,d,1),M(1,d,Math.cos(c)*u),L(0,d,0),L(1,d,Math.sin(c)*u),m=2;m<=s;++m)P(O(m-1,d),D(m-1,d),O(1,d),D(1,d),(e,t)=>(M(m,d,e),L(m,d,t)));for(m=1;m<=s;++m)M(-m,d,O(m,d)),L(-m,d,-D(m,d))}function W(e,t,n,r){for(var i={x:1,y:0},a=[0,e,t,n,r],o=1;o<=4;++o)0!==a[o]&&P(i.x,i.y,O(a[o],o),D(a[o],o),(e,t)=>(i.x=e,i.y=t));return i}function Y(e,t,n,r,i,a,o,s){var c=W(i,a,o,s);p+=e*c.y,w+=t*c.y,g+=n*c.x,f+=r*c.x}function V(e,t,n,r,i){return e*W(t,n,r,i).y}Y(13.902,14.06,-.001,.2607,0,0,0,4),Y(.403,-4.01,.394,.0023,0,0,0,3),Y(2369.912,2373.36,.601,28.2333,0,0,0,2),Y(-125.154,-112.79,-.725,-.9781,0,0,0,1),Y(1.979,6.98,-.445,.0433,1,0,0,4),Y(191.953,192.72,.029,3.0861,1,0,0,2),Y(-8.466,-13.51,.455,-.1093,1,0,0,1),Y(22639.5,22609.07,.079,186.5398,1,0,0,0),Y(18.609,3.59,-.094,.0118,1,0,0,-1),Y(-4586.465,-4578.13,-.077,34.3117,1,0,0,-2),Y(3.215,5.44,.192,-.0386,1,0,0,-3),Y(-38.428,-38.64,.001,.6008,1,0,0,-4),Y(-.393,-1.43,-.092,.0086,1,0,0,-6),Y(-.289,-1.59,.123,-.0053,0,1,0,4),Y(-24.42,-25.1,.04,-.3,0,1,0,2),Y(18.023,17.93,.007,.1494,0,1,0,1),Y(-668.146,-126.98,-1.302,-.3997,0,1,0,0),Y(.56,.32,-.001,-.0037,0,1,0,-1),Y(-165.145,-165.06,.054,1.9178,0,1,0,-2),Y(-1.877,-6.46,-.416,.0339,0,1,0,-4),Y(.213,1.02,-.074,.0054,2,0,0,4),Y(14.387,14.78,-.017,.2833,2,0,0,2),Y(-.586,-1.2,.054,-.01,2,0,0,1),Y(769.016,767.96,.107,10.1657,2,0,0,0),Y(1.75,2.01,-.018,.0155,2,0,0,-1),Y(-211.656,-152.53,5.679,-.3039,2,0,0,-2),Y(1.225,.91,-.03,-.0088,2,0,0,-3),Y(-30.773,-34.07,-.308,.3722,2,0,0,-4),Y(-.57,-1.4,-.074,.0109,2,0,0,-6),Y(-2.921,-11.75,.787,-.0484,1,1,0,2),Y(1.267,1.52,-.022,.0164,1,1,0,1),Y(-109.673,-115.18,.461,-.949,1,1,0,0),Y(-205.962,-182.36,2.056,1.4437,1,1,0,-2),Y(.233,.36,.012,-.0025,1,1,0,-3),Y(-4.391,-9.66,-.471,.0673,1,1,0,-4),Y(.283,1.53,-.111,.006,1,-1,0,4),Y(14.577,31.7,-1.54,.2302,1,-1,0,2),Y(147.687,138.76,.679,1.1528,1,-1,0,0),Y(-1.089,.55,.021,0,1,-1,0,-1),Y(28.475,23.59,-.443,-.2257,1,-1,0,-2),Y(-.276,-.38,-.006,-.0036,1,-1,0,-3),Y(.636,2.27,.146,-.0102,1,-1,0,-4),Y(-.189,-1.68,.131,-.0028,0,2,0,2),Y(-7.486,-.66,-.037,-.0086,0,2,0,0),Y(-8.096,-16.35,-.74,.0918,0,2,0,-2),Y(-5.741,-.04,0,-9e-4,0,0,2,2),Y(.255,0,0,0,0,0,2,1),Y(-411.608,-.2,0,-.0124,0,0,2,0),Y(.584,.84,0,.0071,0,0,2,-1),Y(-55.173,-52.14,0,-.1052,0,0,2,-2),Y(.254,.25,0,-.0017,0,0,2,-3),Y(.025,-1.67,0,.0031,0,0,2,-4),Y(1.06,2.96,-.166,.0243,3,0,0,2),Y(36.124,50.64,-1.3,.6215,3,0,0,0),Y(-13.193,-16.4,.258,-.1187,3,0,0,-2),Y(-1.187,-.74,.042,.0074,3,0,0,-4),Y(-.293,-.31,-.002,.0046,3,0,0,-6),Y(-.29,-1.45,.116,-.0051,2,1,0,2),Y(-7.649,-10.56,.259,-.1038,2,1,0,0),Y(-8.627,-7.59,.078,-.0192,2,1,0,-2),Y(-2.74,-2.54,.022,.0324,2,1,0,-4),Y(1.181,3.32,-.212,.0213,2,-1,0,2),Y(9.703,11.67,-.151,.1268,2,-1,0,0),Y(-.352,-.37,.001,-.0028,2,-1,0,-1),Y(-2.494,-1.17,-.003,-.0017,2,-1,0,-2),Y(.36,.2,-.012,-.0043,2,-1,0,-4),Y(-1.167,-1.25,.008,-.0106,1,2,0,0),Y(-7.412,-6.12,.117,.0484,1,2,0,-2),Y(-.311,-.65,-.032,.0044,1,2,0,-4),Y(.757,1.82,-.105,.0112,1,-2,0,2),Y(2.58,2.32,.027,.0196,1,-2,0,0),Y(2.533,2.4,-.014,-.0212,1,-2,0,-2),Y(-.344,-.57,-.025,.0036,0,3,0,-2),Y(-.992,-.02,0,0,1,0,2,2),Y(-45.099,-.02,0,-.001,1,0,2,0),Y(-.179,-9.52,0,-.0833,1,0,2,-2),Y(-.301,-.33,0,.0014,1,0,2,-4),Y(-6.382,-3.37,0,-.0481,1,0,-2,2),Y(39.528,85.13,0,-.7136,1,0,-2,0),Y(9.366,.71,0,-.0112,1,0,-2,-2),Y(.202,.02,0,0,1,0,-2,-4),Y(.415,.1,0,.0013,0,1,2,0),Y(-2.152,-2.26,0,-.0066,0,1,2,-2),Y(-1.44,-1.3,0,.0014,0,1,-2,2),Y(.384,-.04,0,0,0,1,-2,-2),Y(1.938,3.6,-.145,.0401,4,0,0,0),Y(-.952,-1.58,.052,-.013,4,0,0,-2),Y(-.551,-.94,.032,-.0097,3,1,0,0),Y(-.482,-.57,.005,-.0045,3,1,0,-2),Y(.681,.96,-.026,.0115,3,-1,0,0),Y(-.297,-.27,.002,-9e-4,2,2,0,-2),Y(.254,.21,-.003,0,2,-2,0,-2),Y(-.25,-.22,.004,.0014,1,3,0,-2),Y(-3.996,0,0,4e-4,2,0,2,0),Y(.557,-.75,0,-.009,2,0,2,-2),Y(-.459,-.38,0,-.0053,2,0,-2,2),Y(-1.298,.74,0,4e-4,2,0,-2,0),Y(.538,1.14,0,-.0141,2,0,-2,-2),Y(.263,.02,0,0,1,1,2,0),Y(.426,.07,0,-6e-4,1,1,-2,-2),Y(-.304,.03,0,3e-4,1,-1,2,0),Y(-.372,-.19,0,-.0027,1,-1,-2,2),Y(.418,0,0,0,0,0,4,0),Y(-.33,-.04,0,0,3,0,2,0),_=0,_+=V(-526.069,0,0,1,-2),_+=V(-3.352,0,0,1,-4),_+=V(44.297,1,0,1,-2),_+=V(-6,1,0,1,-4),_+=V(20.599,-1,0,1,0),_+=V(-30.598,-1,0,1,-2),_+=V(-24.649,-2,0,1,0),_+=V(-2,-2,0,1,-2),_+=V(-22.571,0,1,1,-2),_+=V(10.985,0,-1,1,-2),p+=.82*U(.7736-62.5512*t)+.31*U(.0466-125.1025*t)+.35*U(.5785-25.1042*t)+.66*U(.4591+1335.8075*t)+.64*U(.313-91.568*t)+1.14*U(.148+1331.2898*t)+.21*U(.5918+1056.5859*t)+.44*U(.5784+1322.8595*t)+.24*U(.2275-5.7374*t)+.28*U(.2965+2.6929*t)+.33*U(.3132+6.3368*t),o=E+w/ii;let X=(1.000002708+139.978*h)*(18518.511+1.189+g)*Math.sin(o)-6.24*Math.sin(3*o)+_;return{geo_eclip_lon:ri*li((v+p/ii)/ri),geo_eclip_lat:Math.PI/648e3*X,distance_au:4263520978299708e-20*ii/(.999953253*f)}}(t),r=n.distance_au*Math.cos(n.geo_eclip_lat),i=function(e,t,n){return function(e,t){return[e.rot[0][0]*t[0]+e.rot[1][0]*t[1]+e.rot[2][0]*t[2],e.rot[0][1]*t[0]+e.rot[1][1]*t[1]+e.rot[2][1]*t[2],e.rot[0][2]*t[0]+e.rot[1][2]*t[1]+e.rot[2][2]*t[2]]}(Ni(t,n),e)}(yi(t,[r*Math.cos(n.geo_eclip_lon),r*Math.sin(n.geo_eclip_lon),n.distance_au*Math.sin(n.geo_eclip_lat)]),t,fi.Into2000);return new bi(i[0],i[1],i[2],t)}function Pi(e,t,n){let r=1,i=0;for(let a of e){let e=0;for(let[n,r,i]of a)e+=n*Math.cos(r+t*i);let o=r*e;n&&(o%=ri),i+=o,r*=t}return i}function Ui(e,t){let n=1,r=0,i=0,a=0;for(let o of e){let e=0,s=0;for(let[n,r,i]of o){let o=r+t*i;e+=n*i*Math.sin(o),a>0&&(s+=n*Math.cos(o))}i+=a*r*s-n*e,r=n,n*=t,++a}return i}const Gi=365250;function Hi(e){return new Yi(e[0]+4.4036e-7*e[1]-1.90919e-7*e[2],-4.79966e-7*e[0]+.917482137087*e[1]-.397776982902*e[2],.397776982902*e[1]+.917482137087*e[2])}function Fi(e,t,n){const r=n*Math.cos(t);return[r*Math.cos(e),r*Math.sin(e),n*Math.sin(t)]}function Bi(e,t){const n=t.tt/Gi;return Hi(Fi(Pi(e[0],n,!0),Pi(e[1],n,!1),Pi(e[2],n,!1))).ToAstroVector(t)}function zi(e,t,n,r){const i=r/(r+oi),a=Bi(vi[n],t);e.x+=i*a.x,e.y+=i*a.y,e.z+=i*a.z}const ki=146,Wi=[[-73e4,[-26.118207232108,-14.376168177825,3.384402515299],[.0016339372163656,-.0027861699588508,-.0013585880229445]],[-700800,[41.974905202127,-.448502952929,-12.770351505989],[.00073458569351457,.0022785014891658,.00048619778602049]],[-671600,[14.706930780744,44.269110540027,9.353698474772],[-.00210001479998,.00022295915939915,.00070143443551414]],[-642400,[-29.441003929957,-6.43016153057,6.858481011305],[.00084495803960544,-.0030783914758711,-.0012106305981192]],[-613200,[39.444396946234,-6.557989760571,-13.913760296463],[.0011480029005873,.0022400006880665,.00035168075922288]],[-584e3,[20.2303809507,43.266966657189,7.382966091923],[-.0019754081700585,.00053457141292226,.00075929169129793]],[-554800,[-30.65832536462,2.093818874552,9.880531138071],[61010603013347e-18,-.0031326500935382,-.00099346125151067]],[-525600,[35.737703251673,-12.587706024764,-14.677847247563],[.0015802939375649,.0021347678412429,.00019074436384343]],[-496400,[25.466295188546,41.367478338417,5.216476873382],[-.0018054401046468,.0008328308359951,.00080260156912107]],[-467200,[-29.847174904071,10.636426313081,12.297904180106],[-.00063257063052907,-.0029969577578221,-.00074476074151596]],[-438e3,[30.774692107687,-18.236637015304,-14.945535879896],[.0020113162005465,.0019353827024189,-20937793168297e-19]],[-408800,[30.243153324028,38.656267888503,2.938501750218],[-.0016052508674468,.0011183495337525,.00083333973416824]],[-379600,[-27.288984772533,18.643162147874,14.023633623329],[-.0011856388898191,-.0027170609282181,-.00049015526126399]],[-350400,[24.519605196774,-23.245756064727,-14.626862367368],[.0024322321483154,.0016062008146048,-.00023369181613312]],[-321200,[34.505274805875,35.125338586954,.557361475637],[-.0013824391637782,.0013833397561817,.00084823598806262]],[-292e3,[-23.275363915119,25.818514298769,15.055381588598],[-.0016062295460975,-.0023395961498533,-.00024377362639479]],[-262800,[17.050384798092,-27.180376290126,-13.608963321694],[.0028175521080578,.0011358749093955,-.00049548725258825]],[-233600,[38.093671910285,30.880588383337,-1.843688067413],[-.0011317697153459,.0016128814698472,.00084177586176055]],[-204400,[-18.197852930878,31.932869934309,15.438294826279],[-.0019117272501813,-.0019146495909842,-19657304369835e-18]],[-175200,[8.528924039997,-29.618422200048,-11.805400994258],[.0031034370787005,.0005139363329243,-.00077293066202546]],[-146e3,[40.94685725864,25.904973592021,-4.256336240499],[-.00083652705194051,.0018129497136404,.0008156422827306]],[-116800,[-12.326958895325,36.881883446292,15.217158258711],[-.0021166103705038,-.001481442003599,.00017401209844705]],[-87600,[-.633258375909,-30.018759794709,-9.17193287495],[.0032016994581737,-.00025279858672148,-.0010411088271861]],[-58400,[42.936048423883,20.344685584452,-6.588027007912],[-.00050525450073192,.0019910074335507,.00077440196540269]],[-29200,[-5.975910552974,40.61180995846,14.470131723673],[-.0022184202156107,-.0010562361130164,.00033652250216211]],[0,[-9.875369580774,-27.978926224737,-5.753711824704],[.0030287533248818,-.0011276087003636,-.0012651326732361]],[29200,[43.958831986165,14.214147973292,-8.808306227163],[-.00014717608981871,.0021404187242141,.00071486567806614]],[58400,[.67813676352,43.094461639362,13.243238780721],[-.0022358226110718,-.00063233636090933,.00047664798895648]],[87600,[-18.282602096834,-23.30503958666,-1.766620508028],[.0025567245263557,-.0019902940754171,-.0013943491701082]],[116800,[43.873338744526,7.700705617215,-10.814273666425],[.00023174803055677,.0022402163127924,.00062988756452032]],[146e3,[7.392949027906,44.382678951534,11.629500214854],[-.002193281545383,-.00021751799585364,.00059556516201114]],[175200,[-24.981690229261,-16.204012851426,2.466457544298],[.001819398914958,-.0026765419531201,-.0013848283502247]],[204400,[42.530187039511,.845935508021,-12.554907527683],[.00065059779150669,.0022725657282262,.00051133743202822]],[233600,[13.999526486822,44.462363044894,9.669418486465],[-.0021079296569252,.00017533423831993,.00069128485798076]],[262800,[-29.184024803031,-7.371243995762,6.493275957928],[.00093581363109681,-.0030610357109184,-.0012364201089345]],[292e3,[39.831980671753,-6.078405766765,-13.909815358656],[.0011117769689167,.0022362097830152,.00036230548231153]],[321200,[20.294955108476,43.417190420251,7.450091985932],[-.0019742157451535,.00053102050468554,.00075938408813008]],[350400,[-30.66999230216,2.318743558955,9.973480913858],[45605107450676e-18,-.0031308219926928,-.00099066533301924]],[379600,[35.626122155983,-12.897647509224,-14.777586508444],[.0016015684949743,.0021171931182284,.00018002516202204]],[408800,[26.133186148561,41.232139187599,5.00640132622],[-.0017857704419579,.00086046232702817,.00080614690298954]],[438e3,[-29.57674022923,11.863535943587,12.631323039872],[-.00072292830060955,-.0029587820140709,-.000708242964503]],[467200,[29.910805787391,-19.159019294,-15.013363865194],[.0020871080437997,.0018848372554514,-38528655083926e-18]],[496400,[31.375957451819,38.050372720763,2.433138343754],[-.0015546055556611,.0011699815465629,.00083565439266001]],[525600,[-26.360071336928,20.662505904952,14.414696258958],[-.0013142373118349,-.0026236647854842,-.00042542017598193]],[554800,[22.599441488648,-24.508879898306,-14.484045731468],[.0025454108304806,.0014917058755191,-.00030243665086079]],[584e3,[35.877864013014,33.894226366071,-.224524636277],[-.0012941245730845,.0014560427668319,.00084762160640137]],[613200,[-21.538149762417,28.204068269761,15.321973799534],[-.001731211740901,-.0021939631314577,-.0001631691327518]],[642400,[13.971521374415,-28.339941764789,-13.083792871886],[.0029334630526035,.00091860931752944,-.00059939422488627]],[671600,[39.526942044143,28.93989736011,-2.872799527539],[-.0010068481658095,.001702113288809,.00083578230511981]],[700800,[-15.576200701394,34.399412961275,15.466033737854],[-.0020098814612884,-.0017191109825989,70414782780416e-18]],[73e4,[4.24325283709,-30.118201690825,-10.707441231349],[.0031725847067411,.0001609846120227,-.00090672150593868]]];class Yi{constructor(e,t,n){this.x=e,this.y=t,this.z=n}clone(){return new Yi(this.x,this.y,this.z)}ToAstroVector(e){return new bi(this.x,this.y,this.z,e)}static zero(){return new Yi(0,0,0)}quadrature(){return this.x*this.x+this.y*this.y+this.z*this.z}add(e){return new Yi(this.x+e.x,this.y+e.y,this.z+e.z)}sub(e){return new Yi(this.x-e.x,this.y-e.y,this.z-e.z)}incr(e){this.x+=e.x,this.y+=e.y,this.z+=e.z}decr(e){this.x-=e.x,this.y-=e.y,this.z-=e.z}mul(e){return new Yi(e*this.x,e*this.y,e*this.z)}div(e){return new Yi(this.x/e,this.y/e,this.z/e)}mean(e){return new Yi((this.x+e.x)/2,(this.y+e.y)/2,(this.z+e.z)/2)}neg(){return new Yi(-this.x,-this.y,-this.z)}}class Vi{constructor(e,t,n){this.tt=e,this.r=t,this.v=n}clone(){return new Vi(this.tt,this.r,this.v)}sub(e){return new Vi(this.tt,this.r.sub(e.r),this.v.sub(e.v))}}function Xi(e,t,n,r){const i=r/(r+oi),a=function(e,t){const n=t/Gi,r=Pi(e[0],n,!0),i=Pi(e[1],n,!1),a=Pi(e[2],n,!1),o=Ui(e[0],n),s=Ui(e[1],n),c=Ui(e[2],n),u=Math.cos(r),d=Math.sin(r),m=Math.cos(i),l=Math.sin(i),h=+c*m*u-a*l*u*s-a*m*d*o,p=+c*m*d-a*l*d*s+a*m*u*o,_=+c*l+a*m*s,g=Fi(r,i,a),f=[h/Gi,p/Gi,_/Gi],v=Hi(g),T=Hi(f);return new Vi(t,v,T)}(vi[n],t);return e.r.incr(a.r.mul(i)),e.v.incr(a.v.mul(i)),a}function ji(e,t,n){const r=n.sub(e),i=r.quadrature();return r.mul(t/(i*Math.sqrt(i)))}class qi{constructor(e){let t=new Vi(e,new Yi(0,0,0),new Yi(0,0,0));this.Jupiter=Xi(t,e,hi.Jupiter,si),this.Saturn=Xi(t,e,hi.Saturn,ci),this.Uranus=Xi(t,e,hi.Uranus,ui),this.Neptune=Xi(t,e,hi.Neptune,di),this.Jupiter.r.decr(t.r),this.Jupiter.v.decr(t.v),this.Saturn.r.decr(t.r),this.Saturn.v.decr(t.v),this.Uranus.r.decr(t.r),this.Uranus.v.decr(t.v),this.Neptune.r.decr(t.r),this.Neptune.v.decr(t.v),this.Sun=new Vi(e,t.r.mul(-1),t.v.mul(-1))}Acceleration(e){let t=ji(e,oi,this.Sun.r);return t.incr(ji(e,si,this.Jupiter.r)),t.incr(ji(e,ci,this.Saturn.r)),t.incr(ji(e,ui,this.Uranus.r)),t.incr(ji(e,di,this.Neptune.r)),t}}class Ki{constructor(e,t,n,r){this.tt=e,this.r=t,this.v=n,this.a=r}clone(){return new Ki(this.tt,this.r.clone(),this.v.clone(),this.a.clone())}}class Zi{constructor(e,t){this.bary=e,this.grav=t}}function $i(e,t,n,r){return new Yi(t.x+e*(n.x+e*r.x/2),t.y+e*(n.y+e*r.y/2),t.z+e*(n.z+e*r.z/2))}function Qi(e,t,n){return new Yi(t.x+e*n.x,t.y+e*n.y,t.z+e*n.z)}function Ji(e,t){const n=e-t.tt,r=new qi(e),i=$i(n,t.r,t.v,t.a),a=r.Acceleration(i).mean(t.a),o=$i(n,t.r,t.v,a),s=t.v.add(a.mul(n)),c=r.Acceleration(o),u=new Ki(e,o,s,c);return new Zi(r,u)}const ea=[];function ta(e,t){const n=Math.floor(e);return n<0?0:n>=t?t-1:n}function na(e){const t=function(e){let[t,[n,r,i],[a,o,s]]=e;return new Vi(t,new Yi(n,r,i),new Yi(a,o,s))}(e),n=new qi(t.tt),r=t.r.add(n.Sun.r),i=t.v.add(n.Sun.v),a=n.Acceleration(r),o=new Ki(t.tt,r,i,a);return new Zi(n,o)}function ra(e,t,n){let r=na(e);const i=Math.ceil((t-r.grav.tt)/n);for(let e=0;e<i;++e)r=Ji(e+1===i?t:r.grav.tt+n,r.grav);return r}function ia(e,t){let n,r,i;const a=function(e,t){const n=Wi[0][0];if(t<n||t>Wi[50][0])return null;const r=ta((t-n)/29200,50);if(!e[r]){const t=e[r]=[];t[0]=na(Wi[r]).grav,t[200]=na(Wi[r+1]).grav;let n,a=t[0].tt;for(n=1;n<200;++n)t[n]=Ji(a+=ki,t[n-1]).grav;a=t[200].tt;var i=[];for(i[200]=t[200],n=199;n>0;--n)i[n]=Ji(a-=ki,i[n+1]).grav;for(n=199;n>0;--n){const e=n/200;t[n].r=t[n].r.mul(1-e).add(i[n].r.mul(e)),t[n].v=t[n].v.mul(1-e).add(i[n].v.mul(e)),t[n].a=t[n].a.mul(1-e).add(i[n].a.mul(e))}}return e[r]}(ea,e.tt);if(a){const t=ta((e.tt-a[0].tt)/ki,200),i=a[t],o=a[t+1],s=i.a.mean(o.a),c=$i(e.tt-i.tt,i.r,i.v,s),u=Qi(e.tt-i.tt,i.v,s),d=$i(e.tt-o.tt,o.r,o.v,s),m=Qi(e.tt-o.tt,o.v,s),l=(e.tt-i.tt)/ki;n=c.mul(1-l).add(d.mul(l)),r=u.mul(1-l).add(m.mul(l))}else{let t;t=e.tt<Wi[0][0]?ra(Wi[0],e.tt,-ki):ra(Wi[50],e.tt,146),n=t.grav.r,r=t.grav.v,i=t.bary}return i||(i=new qi(e.tt)),n=n.sub(i.Sun.r),r=r.sub(i.Sun.v),new Oi(n.x,n.y,n.z,r.x,r.y,r.z,e)}function aa(e,t){var n=Ri(t);if(e in vi)return Bi(vi[e],n);if(e===hi.Pluto){const e=ia(n);return new bi(e.x,e.y,e.z,n)}if(e===hi.Sun)return new bi(0,0,0,n);if(e===hi.Moon){var r=Bi(vi.Earth,n),i=Li(n);return new bi(r.x+i.x,r.y+i.y,r.z+i.z,n)}if(e===hi.EMB){const e=Bi(vi.Earth,n),t=Li(n),r=82.30056;return new bi(e.x+t.x/r,e.y+t.y/r,e.z+t.z/r,n)}if(e===hi.SSB)return function(e){const t=new bi(0,0,0,e);return zi(t,e,hi.Jupiter,si),zi(t,e,hi.Saturn,ci),zi(t,e,hi.Uranus,ui),zi(t,e,hi.Neptune,di),t}(n);const a=gi(e);if(a){return function(e,t){t=Ri(t);const n=e.lat*ti,r=e.lon*ti,i=e.dist*Math.cos(n);return new bi(i*Math.cos(r),i*Math.sin(r),e.dist*Math.sin(n),t)}(new Di(a.dec,15*a.ra,a.dist),n)}throw`HelioVector: Unknown body "${e}"`}class oa{constructor(e,t,n,r){this.observerBody=e,this.targetBody=t,this.aberration=n,this.observerPos=r}Position(e){this.aberration&&(this.observerPos=aa(this.observerBody,e));const t=aa(this.targetBody,e);return new bi(t.x-this.observerPos.x,t.y-this.observerPos.y,t.z-this.observerPos.z,e)}}function sa(e,t,n,r){const i=Ri(e);if(gi(n)){const e=aa(n,i),r=aa(t,i);return new bi(e.x-r.x,e.y-r.y,e.z-r.z,i)}let a;a=aa(t,i);const o=new oa(t,n,r,a);return function(e,t){let n=t,r=0;for(let i=0;i<10;++i){const i=e(n),a=i.Length()/173.1446326846693;if(a>1)throw"Object is too distant for light-travel solver.";const o=t.AddDays(-a);if(r=Math.abs(o.tt-n.tt),r<1e-9)return i;n=o}throw`Light-travel time solver did not converge: dt = ${r}`}(e=>o.Position(e),i)}var ca,ua,da;function ma(e,t){return new Mi([[t.rot[0][0]*e.rot[0][0]+t.rot[1][0]*e.rot[0][1]+t.rot[2][0]*e.rot[0][2],t.rot[0][1]*e.rot[0][0]+t.rot[1][1]*e.rot[0][1]+t.rot[2][1]*e.rot[0][2],t.rot[0][2]*e.rot[0][0]+t.rot[1][2]*e.rot[0][1]+t.rot[2][2]*e.rot[0][2]],[t.rot[0][0]*e.rot[1][0]+t.rot[1][0]*e.rot[1][1]+t.rot[2][0]*e.rot[1][2],t.rot[0][1]*e.rot[1][0]+t.rot[1][1]*e.rot[1][1]+t.rot[2][1]*e.rot[1][2],t.rot[0][2]*e.rot[1][0]+t.rot[1][2]*e.rot[1][1]+t.rot[2][2]*e.rot[1][2]],[t.rot[0][0]*e.rot[2][0]+t.rot[1][0]*e.rot[2][1]+t.rot[2][0]*e.rot[2][2],t.rot[0][1]*e.rot[2][0]+t.rot[1][1]*e.rot[2][1]+t.rot[2][1]*e.rot[2][2],t.rot[0][2]*e.rot[2][0]+t.rot[1][2]*e.rot[2][1]+t.rot[2][2]*e.rot[2][2]]])}function la(e){const t=Ni(e=Ri(e),fi.From2000),n=function(e,t){const n=Ii(e),r=n.mobl*ti,i=n.tobl*ti,a=n.dpsi*ai,o=Math.cos(r),s=Math.sin(r),c=Math.cos(i),u=Math.sin(i),d=Math.cos(a),m=Math.sin(a),l=d,h=-m*o,p=-m*s,_=m*c,g=d*o*c+s*u,f=d*s*c-o*u,v=m*u,T=d*o*u-s*c,S=d*s*u+o*c;if(t===fi.From2000)return new Mi([[l,_,v],[h,g,T],[p,f,S]]);if(t===fi.Into2000)return new Mi([[l,h,p],[_,g,f],[v,T,S]]);throw"Invalid precess direction"}(e,fi.From2000);return ma(t,n)}function ha(e){return e instanceof Ei?e:new Ei(e instanceof Date?e:new Date(e))}function pa(e,n=new t){const r=ha(e),i=la(r),a=function(e){const t=Math.cos(e),n=Math.sin(e);return new Mi([[t,-n,0],[n,t,0],[0,0,1]])}(Ci(r)*(-Math.PI/12)),{rot:o}=ma(i,a);return n.set(o[0][0],o[0][1],o[0][2],0,o[1][0],o[1][1],o[1][2],0,o[2][0],o[2][1],o[2][2],0,0,0,0,1)}function _a(e,t,n){const{x:r,y:i,z:a}=function(e,t,n){const r=Ri(t);switch(e){case hi.Earth:return new bi(0,0,0,r);case hi.Moon:return Li(r);default:const t=sa(r,hi.Earth,e,n);return t.t=r,t}}(e,t,!1);return n.set(r,i,a).normalize()}function ga(e){return Math.sqrt(Math.max(e,0))}function fa(e,t,n){const{topRadius:r}=e;return function(e){return Math.max(e,0)}(-t*n+ga(t**2*(n**2-1)+r**2))}function va(e,t){return.5/t+e*(1-1/t)}!function(e){e[e.Pericenter=0]="Pericenter",e[e.Apocenter=1]="Apocenter"}(ca||(ca={})),function(e){e.Penumbral="penumbral",e.Partial="partial",e.Annular="annular",e.Total="total"}(ua||(ua={})),function(e){e[e.Invalid=0]="Invalid",e[e.Ascending=1]="Ascending",e[e.Descending=-1]="Descending"}(da||(da={}));const Ta=new e,Sa=new e,Ea=new e,Ra=new WeakMap;function xa(e,t,n){const r=4*t;return n.set(e[r],e[r+1],e[r+2])}function Aa(e,t,n){const r=function(e){let t=qn(e.image.data)?e.image.data:qn(e.userData.imageData)?e.userData.imageData:void 0;if(e.type===I&&t instanceof Uint16Array){const e=Ra.get(t.buffer);null==e?(t=new Xn(t.buffer),Ra.set(t.buffer,t)):t=e}return t}(e);if(null==r)return n.setScalar(0);const{width:i,height:a}=e.image,o=Kn(t.x,0,1)*(i-1),s=Kn(t.y,0,1)*(a-1),c=Math.floor(o),u=Math.floor(s),d=o-c,m=s-u,l=c%i,h=(l+1)%i,p=u%a,_=(p+1)%a,g=xa(r,p*i+l,Ta),f=xa(r,p*i+h,Sa),v=g.lerp(f,d),T=xa(r,_*i+l,Sa),S=xa(r,_*i+h,Ea),E=T.lerp(S,d);return n.copy(v.lerp(E,m))}const Ia=new e,ya=new e,Na=new u;function wa(e,t,n,r=new s,{ellipsoid:i=de.WGS84,correctAltitude:a=!0}={},o=Fr.DEFAULT){const c=Ia.copy(t);if(a){const e=i.projectOnSurface(t,ya);null!=e&&c.sub(i.getOsculatingSphereCenter(e,o.bottomRadius,ya))}const u=ya;let d=c.length(),m=c.dot(n);const{topRadius:l}=o,h=-m-Math.sqrt(m**2-d**2+l**2);if(h>0&&(d=l,m+=h),d>l)u.set(1,1,1);else{const t=m/d;if(function(e,t,n){const{bottomRadius:r}=e;return n<0&&t**2*(n**2-1)+r**2>=0}(o,d,t))u.setScalar(0);else{const n=function(e,t,n,r){const{topRadius:i,bottomRadius:a}=e,o=Math.sqrt(i**2-a**2),s=ga(t**2-a**2),c=i-t,u=(fa(e,t,n)-c)/(s+o-c),d=s/o;return r.set(va(u,Dr),va(d,Mr))}(o,d,t,Na);Aa(e,n,u)}}const p=u.multiply(o.solarIrradiance).multiply(o.sunRadianceToRelativeLuminance);return r.setFromVector3(p)}class Ca extends V{constructor(e,t){super("LightingMaskPass"),this.selection=new X,this.needsSwap=!1,this.needsDepthTexture=!0,this.renderPass=new j(e,t,new l),this.renderPass.ignoreBackground=!0,this.renderPass.skipShadowMapUpdate=!0,this.renderPass.selection=this.selection,this.depthTexture=new h(1,1,p),this.renderTarget=new _(1,1,{format:g,depthTexture:this.depthTexture}),this.depthCopyPass0=new q({depthPacking:f}),this.depthCopyPass1=new q({depthPacking:f}),this.clearPass=new K(!0,!1,!1),this.clearPass.overrideClearColor=new s(16777215),this.clearPass.overrideClearAlpha=1;const n=new Z;n.fragmentShader=_r('// Based on: https://github.com/pmndrs/postprocessing/blob/v6.37.4/src/materials/glsl/depth-mask.frag\n\n#include <common>\n#include <packing>\n\n#include "core/depth"\n\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nuniform highp sampler2D depthBuffer0;\nuniform highp sampler2D depthBuffer1;\n#else // GL_FRAGMENT_PRECISION_HIGH\nuniform mediump sampler2D depthBuffer0;\nuniform mediump sampler2D depthBuffer1;\n#endif // GL_FRAGMENT_PRECISION_HIGH\n\nuniform sampler2D inputBuffer;\nuniform vec2 cameraNearFar;\nuniform bool inverted;\n\nfloat getViewZ(const float depth) {\n #ifdef PERSPECTIVE_CAMERA\n return perspectiveDepthToViewZ(depth, cameraNearFar.x, cameraNearFar.y);\n #else // PERSPECTIVE_CAMERA\n return orthographicDepthToViewZ(depth, cameraNearFar.x, cameraNearFar.y);\n #endif // PERSPECTIVE_CAMERA\n}\n\nvarying vec2 vUv;\n\nvoid main() {\n vec2 depth;\n\n #if DEPTH_PACKING_0 == 3201\n depth.x = unpackRGBAToDepth(texture2D(depthBuffer0, vUv));\n #else // DEPTH_PACKING_0 == 3201\n depth.x = reverseLogDepth(texture2D(depthBuffer0, vUv).r, cameraNearFar.x, cameraNearFar.y);\n #endif // DEPTH_PACKING_0 == 3201\n\n #if DEPTH_PACKING_1 == 3201\n depth.y = unpackRGBAToDepth(texture2D(depthBuffer1, vUv));\n #else // DEPTH_PACKING_1 == 3201\n depth.y = reverseLogDepth(texture2D(depthBuffer1, vUv).r, cameraNearFar.x, cameraNearFar.y);\n #endif // DEPTH_PACKING_1 == 3201\n\n bool isMaxDepth = depth.x == 1.0;\n\n #ifdef PERSPECTIVE_CAMERA\n depth.x = viewZToOrthographicDepth(getViewZ(depth.x), cameraNearFar.x, cameraNearFar.y);\n depth.y = viewZToOrthographicDepth(getViewZ(depth.y), cameraNearFar.x, cameraNearFar.y);\n #endif // PERSPECTIVE_CAMERA\n\n #if DEPTH_TEST_STRATEGY == 0\n // Decide based on depth test.\n bool keep = depthTest(depth.x, depth.y);\n\n #elif DEPTH_TEST_STRATEGY == 1\n // Always keep max depth.\n bool keep = isMaxDepth || depthTest(depth.x, depth.y);\n\n #else // DEPTH_TEST_STRATEGY\n // Always discard max depth.\n bool keep = !isMaxDepth && depthTest(depth.x, depth.y);\n\n #endif // DEPTH_TEST_STRATEGY\n\n if (inverted) {\n keep = !keep;\n }\n if (keep) {\n gl_FragColor = texture2D(inputBuffer, vUv);\n } else {\n discard;\n }\n}\n',{core:{depth:vr}}),n.uniforms.inverted=new c(!1),n.copyCameraSettings(t),n.depthBuffer0=this.depthCopyPass0.texture,n.depthPacking0=f,n.depthBuffer1=this.depthCopyPass1.texture,n.depthPacking1=f,n.depthMode=v,n.maxDepthStrategy=$.DISCARD_MAX_DEPTH,this.depthMaskMaterial=n,this.depthMaskPass=new Q(n)}set mainScene(e){this.renderPass.mainScene=e}set mainCamera(e){this.renderPass.mainCamera=e,this.depthMaskMaterial.copyCameraSettings(e)}initialize(e,t,n){this.renderPass.initialize(e,t,n),this.clearPass.initialize(e,t,n),this.depthMaskPass.initialize(e,t,n)}setDepthTexture(e,t=T){this.depthCopyPass0.setDepthTexture(e,t),this.depthCopyPass1.setDepthTexture(this.depthTexture,t)}render(e,t,n,r,i){const a=e.autoClear;e.autoClear=!1,this.depthCopyPass0.render(e,null,null),this.renderPass.render(e,this.renderTarget,null),this.depthCopyPass1.render(e,null,null),this.clearPass.render(e,this.renderTarget,null),this.depthMaskPass.render(e,null,this.renderTarget),e.autoClear=a}setSize(e,t){this.renderTarget.setSize(e,t),this.depthCopyPass0.setSize(e,t),this.depthCopyPass1.setSize(e,t)}get texture(){return this.renderTarget.texture}get selectionLayer(){return this.selection.layer}set selectionLayer(e){this.selection.layer=e}get inverted(){return this.depthMaskMaterial.uniforms.inverted.value}set inverted(e){this.depthMaskMaterial.uniforms.inverted.value=e}}const ba=window.requestIdleCallback??function(e,t={}){const n=t.timeout??1,r=performance.now();return setTimeout(function(){e({get didTimeout(){return null==t.timeout&&performance.now()-r-1>n},timeRemaining:function(){return Math.max(0,performance.now()-r+1)}})},1)};function Oa(e,t,n){const r=new _(t,n,{depthBuffer:!1,type:e,format:C}),i=r.texture;return i.minFilter=b,i.magFilter=b,i.wrapS=O,i.wrapT=O,i.colorSpace=D,r}function Da(e,t,n,r){const i=new M(t,n,r,{depthBuffer:!1,type:e,format:C}),a=i.texture;return a.minFilter=b,a.magFilter=b,a.wrapS=O,a.wrapT=O,a.wrapR=O,a.colorSpace=D,i}async function Ma(e,t,n){const{width:r,height:i}=t,a=n.type===I?new Uint16Array(r*i*4):new Float32Array(r*i*4);await e.readRenderTargetPixelsAsync(t,0,0,t.width,t.height,a),n.userData.imageData=a}class La{constructor(t){this.lambdas=new e,this.luminanceFromRadiance=new S,t===I&&(this.opticalDepth=Oa(t,Dr,Mr)),this.deltaIrradiance=Oa(t,yr,Nr),this.deltaRayleighScattering=Da(t,Cr,br,Or),this.deltaMieScattering=Da(t,Cr,br,Or),this.deltaScatteringDensity=Da(t,Cr,br,Or),this.deltaMultipleScattering=this.deltaRayleighScattering}dispose(){var e;null==(e=this.opticalDepth)||e.dispose(),this.deltaIrradiance.dispose(),this.deltaRayleighScattering.dispose(),this.deltaMieScattering.dispose(),this.deltaScatteringDensity.dispose()}}class Pa extends m{constructor(e){super({glslVersion:N,vertexShader:"\n precision highp float;\n in vec2 position;\n void main() {\n gl_Position = vec4(position, 1.0, 1.0);\n }\n",...e,defines:{TRANSMITTANCE_TEXTURE_WIDTH:Dr.toFixed(0),TRANSMITTANCE_TEXTURE_HEIGHT:Mr.toFixed(0),SCATTERING_TEXTURE_R_SIZE:32..toFixed(0),SCATTERING_TEXTURE_MU_SIZE:wr.toFixed(0),SCATTERING_TEXTURE_MU_S_SIZE:32..toFixed(0),SCATTERING_TEXTURE_NU_SIZE:8..toFixed(0),IRRADIANCE_TEXTURE_WIDTH:yr.toFixed(0),IRRADIANCE_TEXTURE_HEIGHT:Nr.toFixed(0),...e.defines}})}set additive(e){this.transparent=e,this.blending=e?L:P,this.blendEquation=U,this.blendEquationAlpha=U,this.blendSrc=G,this.blendDst=G,this.blendSrcAlpha=G,this.blendDstAlpha=G}setUniforms(e){const t=this.uniforms;null!=t.luminanceFromRadiance&&t.luminanceFromRadiance.value.copy(e.luminanceFromRadiance),null!=t.singleRayleighScatteringTexture&&(t.singleRayleighScatteringTexture.value=e.deltaRayleighScattering.texture),null!=t.singleMieScatteringTexture&&(t.singleMieScatteringTexture.value=e.deltaMieScattering.texture),null!=t.multipleScatteringTexture&&(t.multipleScatteringTexture.value=e.deltaMultipleScattering.texture),null!=t.scatteringDensityTexture&&(t.scatteringDensityTexture.value=e.deltaScatteringDensity.texture),null!=t.irradianceTexture&&(t.irradianceTexture.value=e.deltaIrradiance.texture)}}class Ua{constructor(e,{type:t=(ge(e)?A:I),combinedScattering:n=!0,higherOrderScattering:r=!0}={}){var i,a;this.transmittanceMaterial=new Pa({fragmentShader:_r('precision highp float;\nprecision highp sampler3D;\n\n#include "bruneton/definitions"\n#include "bruneton/common"\n#include "bruneton/precompute"\n\nuniform AtmosphereParameters ATMOSPHERE;\n\nlayout(location = 0) out vec4 transmittance;\n\nvoid main() {\n transmittance.rgb = ComputeTransmittanceToTopAtmosphereBoundaryTexture(\n ATMOSPHERE,\n gl_FragCoord.xy\n );\n transmittance.a = 1.0;\n}\n',{bruneton:{common:Rr,definitions:xr,precompute:Ir}})}),this.directIrradianceMaterial=new Pa({fragmentShader:_r('precision highp float;\nprecision highp sampler3D;\n\n#include "bruneton/definitions"\n#include "bruneton/common"\n#include "bruneton/precompute"\n\nuniform AtmosphereParameters ATMOSPHERE;\n\nuniform sampler2D transmittanceTexture;\n\nlayout(location = 0) out vec4 outputColor;\n\nvoid main() {\n vec3 deltaIrradiance;\n vec3 irradiance;\n deltaIrradiance = ComputeDirectIrradianceTexture(\n ATMOSPHERE,\n transmittanceTexture,\n gl_FragCoord.xy\n );\n irradiance = vec3(0.0);\n outputColor = vec4(OUTPUT, 1.0);\n}\n',{bruneton:{common:Rr,definitions:xr,precompute:Ir}}),uniforms:{transmittanceTexture:new c(null)}}),this.singleScatteringMaterial=new Pa({fragmentShader:_r('precision highp float;\nprecision highp sampler3D;\n\n#include "bruneton/definitions"\n#include "bruneton/common"\n#include "bruneton/precompute"\n\nuniform AtmosphereParameters ATMOSPHERE;\n\nuniform mat3 luminanceFromRadiance;\nuniform sampler2D transmittanceTexture;\nuniform int layer;\n\nlayout(location = 0) out vec4 outputColor;\n\nvoid main() {\n vec4 deltaRayleigh;\n vec4 deltaMie;\n vec4 scattering;\n vec4 singleMieScattering;\n ComputeSingleScatteringTexture(\n ATMOSPHERE,\n transmittanceTexture,\n vec3(gl_FragCoord.xy, float(layer) + 0.5),\n deltaRayleigh.rgb,\n deltaMie.rgb\n );\n deltaRayleigh.a = 1.0;\n deltaMie.a = 1.0;\n scattering = vec4(\n luminanceFromRadiance * deltaRayleigh.rgb,\n (luminanceFromRadiance * deltaMie.rgb).r\n );\n singleMieScattering.rgb = luminanceFromRadiance * deltaMie.rgb;\n singleMieScattering.a = 1.0;\n outputColor = OUTPUT;\n}\n',{bruneton:{common:Rr,definitions:xr,precompute:Ir}}),uniforms:{luminanceFromRadiance:new c(new S),transmittanceTexture:new c(null),layer:new c(0)}}),this.scatteringDensityMaterial=new Pa({fragmentShader:_r('precision highp float;\nprecision highp sampler3D;\n\n#include "bruneton/definitions"\n#include "bruneton/common"\n#include "bruneton/precompute"\n\nuniform AtmosphereParameters ATMOSPHERE;\n\nuniform sampler2D transmittanceTexture;\nuniform sampler3D singleRayleighScatteringTexture;\nuniform sampler3D singleMieScatteringTexture;\nuniform sampler3D multipleScatteringTexture;\nuniform sampler2D irradianceTexture;\nuniform int scatteringOrder;\nuniform int layer;\n\nlayout(location = 0) out vec4 scatteringDensity;\n\nvoid main() {\n scatteringDensity.rgb = ComputeScatteringDensityTexture(\n ATMOSPHERE,\n transmittanceTexture,\n singleRayleighScatteringTexture,\n singleMieScatteringTexture,\n multipleScatteringTexture,\n irradianceTexture,\n vec3(gl_FragCoord.xy, float(layer) + 0.5),\n scatteringOrder\n );\n scatteringDensity.a = 1.0;\n}\n',{bruneton:{common:Rr,definitions:xr,precompute:Ir}}),uniforms:{transmittanceTexture:new c(null),singleRayleighScatteringTexture:new c(null),singleMieScatteringTexture:new c(null),multipleScatteringTexture:new c(null),irradianceTexture:new c(null),scatteringOrder:new c(0),layer:new c(0)}}),this.indirectIrradianceMaterial=new Pa({fragmentShader:_r('precision highp float;\nprecision highp sampler3D;\n\n#include "bruneton/definitions"\n#include "bruneton/common"\n#include "bruneton/precompute"\n\nuniform AtmosphereParameters ATMOSPHERE;\n\nuniform mat3 luminanceFromRadiance;\nuniform sampler3D singleRayleighScatteringTexture;\nuniform sampler3D singleMieScatteringTexture;\nuniform sampler3D multipleScatteringTexture;\nuniform int scatteringOrder;\n\nlayout(location = 0) out vec4 outputColor;\n\nvoid main() {\n vec3 deltaIrradiance;\n vec3 irradiance;\n deltaIrradiance = ComputeIndirectIrradianceTexture(\n ATMOSPHERE,\n singleRayleighScatteringTexture,\n singleMieScatteringTexture,\n multipleScatteringTexture,\n gl_FragCoord.xy,\n scatteringOrder\n );\n irradiance = luminanceFromRadiance * deltaIrradiance;\n outputColor = vec4(OUTPUT, 1.0);\n}\n',{bruneton:{common:Rr,definitions:xr,precompute:Ir}}),uniforms:{luminanceFromRadiance:new c(new S),singleRayleighScatteringTexture:new c(null),singleMieScatteringTexture:new c(null),multipleScatteringTexture:new c(null),scatteringOrder:new c(0)}}),this.multipleScatteringMaterial=new Pa({fragmentShader:_r('precision highp float;\nprecision highp sampler3D;\n\n#include "bruneton/definitions"\n#include "bruneton/common"\n#include "bruneton/precompute"\n\nuniform AtmosphereParameters ATMOSPHERE;\n\nuniform mat3 luminanceFromRadiance;\nuniform sampler2D transmittanceTexture;\nuniform sampler3D scatteringDensityTexture;\nuniform int layer;\n\nlayout(location = 0) out vec4 outputColor;\n\nvoid main() {\n vec4 deltaMultipleScattering;\n vec4 scattering;\n float nu;\n deltaMultipleScattering.rgb = ComputeMultipleScatteringTexture(\n ATMOSPHERE,\n transmittanceTexture,\n scatteringDensityTexture,\n vec3(gl_FragCoord.xy, float(layer) + 0.5),\n nu\n );\n deltaMultipleScattering.a = 1.0;\n scattering = vec4(\n luminanceFromRadiance * deltaMultipleScattering.rgb / RayleighPhaseFunction(nu),\n 0.0\n );\n outputColor = OUTPUT;\n}\n',{bruneton:{common:Rr,definitions:xr,precompute:Ir}}),uniforms:{luminanceFromRadiance:new c(new S),transmittanceTexture:new c(null),scatteringDensityTexture:new c(null),layer:new c(0)}}),this.mesh=new E(new R(2,2)),this.scene=(new x).add(this.mesh),this.camera=new d,this.updating=!1,this.renderer=e,this.type=t,this.transmittanceRenderTarget=Oa(t,Dr,Mr),this.scatteringRenderTarget=Da(t,Cr,br,Or),this.irradianceRenderTarget=Oa(t,yr,Nr),n||(this.singleMieScatteringRenderTarget=Da(t,Cr,br,Or)),r&&(this.higherOrderScatteringRenderTarget=Da(t,Cr,br,Or)),this.textures={transmittanceTexture:this.transmittanceRenderTarget.texture,scatteringTexture:this.scatteringRenderTarget.texture,irradianceTexture:this.irradianceRenderTarget.texture,singleMieScatteringTexture:null==(i=this.singleMieScatteringRenderTarget)?void 0:i.texture,higherOrderScatteringTexture:null==(a=this.higherOrderScatteringRenderTarget)?void 0:a.texture}}render3DRenderTarget(e,t){for(let n=0;n<e.depth;++n)t.uniforms.layer.value=n,this.renderer.setRenderTarget(e,n),this.renderer.render(this.scene,this.camera)}computeTransmittance(e){const t=this.transmittanceMaterial;delete t.defines.TRANSMITTANCE_PRECISION_LOG,t.needsUpdate=!0,this.mesh.material=t,this.renderer.setRenderTarget(e.renderTarget),this.renderer.render(this.scene,this.camera)}computeOpticalDepth(e){const t=this.transmittanceMaterial;t.defines.TRANSMITTANCE_PRECISION_LOG="1",t.needsUpdate=!0,this.mesh.material=t,this.renderer.setRenderTarget(e.renderTarget),this.renderer.render(this.scene,this.camera)}computeDirectIrradiance(e){var t;const n=this.directIrradianceMaterial;n.defines.OUTPUT=e.output,n.additive=e.additive,this.type===I?n.defines.TRANSMITTANCE_PRECISION_LOG="1":delete n.defines.TRANSMITTANCE_PRECISION_LOG,n.needsUpdate=!0;n.uniforms.transmittanceTexture.value=(null==(t=e.context.opticalDepth)?void 0:t.texture)??this.transmittanceRenderTarget.texture,this.mesh.material=n,this.renderer.setRenderTarget(e.renderTarget),this.renderer.render(this.scene,this.camera)}computeSingleScattering(e){var t;const n=this.singleScatteringMaterial;n.defines.OUTPUT=e.output,n.additive=e.additive,this.type===I?n.defines.TRANSMITTANCE_PRECISION_LOG="1":delete n.defines.TRANSMITTANCE_PRECISION_LOG,n.needsUpdate=!0;n.uniforms.transmittanceTexture.value=(null==(t=e.context.opticalDepth)?void 0:t.texture)??this.transmittanceRenderTarget.texture,n.setUniforms(e.context),this.mesh.material=n,this.render3DRenderTarget(e.renderTarget,n)}computeScatteringDensity(e){var t;const n=this.scatteringDensityMaterial;this.type===I?n.defines.TRANSMITTANCE_PRECISION_LOG="1":delete n.defines.TRANSMITTANCE_PRECISION_LOG,n.needsUpdate=!0;const r=n.uniforms;r.transmittanceTexture.value=(null==(t=e.context.opticalDepth)?void 0:t.texture)??this.transmittanceRenderTarget.texture,r.scatteringOrder.value=e.scatteringOrder,n.setUniforms(e.context),this.mesh.material=n,this.render3DRenderTarget(e.renderTarget,n)}computeIndirectIrradiance(e){const t=this.indirectIrradianceMaterial;t.defines.OUTPUT=e.output,t.additive=e.additive,t.needsUpdate=!0;t.uniforms.scatteringOrder.value=e.scatteringOrder-1,t.setUniforms(e.context),this.mesh.material=t,this.renderer.setRenderTarget(e.renderTarget),this.renderer.render(this.scene,this.camera)}computeMultipleScattering(e){var t;const n=this.multipleScatteringMaterial;n.defines.OUTPUT=e.output,n.additive=e.additive,this.type===I?n.defines.TRANSMITTANCE_PRECISION_LOG="1":delete n.defines.TRANSMITTANCE_PRECISION_LOG,n.needsUpdate=!0;n.uniforms.transmittanceTexture.value=(null==(t=e.context.opticalDepth)?void 0:t.texture)??this.transmittanceRenderTarget.texture,n.setUniforms(e.context),this.mesh.material=n,this.render3DRenderTarget(e.renderTarget,n)}*precompute(e,t){this.computeTransmittance({renderTarget:this.transmittanceRenderTarget}),this.type===I&&(function(e){if(!e)throw new Error("Invariant failed")}(null!=e.opticalDepth),this.computeOpticalDepth({renderTarget:e.opticalDepth})),this.computeDirectIrradiance({renderTarget:e.deltaIrradiance,context:e,output:"deltaIrradiance",additive:!1}),this.computeDirectIrradiance({renderTarget:this.irradianceRenderTarget,context:e,output:"irradiance",additive:t}),this.renderer.setRenderTarget(null),yield,this.computeSingleScattering({renderTarget:e.deltaRayleighScattering,context:e,output:"deltaRayleigh",additive:!1}),this.computeSingleScattering({renderTarget:e.deltaMieScattering,context:e,output:"deltaMie",additive:!1}),this.computeSingleScattering({renderTarget:this.scatteringRenderTarget,context:e,output:"scattering",additive:t}),null!=this.singleMieScatteringRenderTarget&&this.computeSingleScattering({renderTarget:this.singleMieScatteringRenderTarget,context:e,output:"singleMieScattering",additive:t}),this.renderer.setRenderTarget(null),yield;for(let t=2;t<=4;++t)this.computeScatteringDensity({renderTarget:e.deltaScatteringDensity,context:e,scatteringOrder:t}),this.computeIndirectIrradiance({renderTarget:e.deltaIrradiance,context:e,scatteringOrder:t,output:"deltaIrradiance",additive:!1}),this.computeIndirectIrradiance({renderTarget:this.irradianceRenderTarget,context:e,scatteringOrder:t,output:"irradiance",additive:!0}),this.computeMultipleScattering({renderTarget:e.deltaMultipleScattering,context:e,output:"deltaMultipleScattering",additive:!1}),this.computeMultipleScattering({renderTarget:this.scatteringRenderTarget,context:e,output:"scattering",additive:!0}),null!=this.higherOrderScatteringRenderTarget&&this.computeMultipleScattering({renderTarget:this.higherOrderScatteringRenderTarget,context:e,output:"scattering",additive:!0}),this.renderer.setRenderTarget(null),yield}async update(e=Fr.DEFAULT){var t;this.updating=!0;const n=e.toUniform();this.transmittanceMaterial.uniforms.ATMOSPHERE=n,this.directIrradianceMaterial.uniforms.ATMOSPHERE=n,this.singleScatteringMaterial.uniforms.ATMOSPHERE=n,this.scatteringDensityMaterial.uniforms.ATMOSPHERE=n,this.indirectIrradianceMaterial.uniforms.ATMOSPHERE=n,this.multipleScatteringMaterial.uniforms.ATMOSPHERE=n;const r=this.renderer,i=new La(this.type);i.lambdas.set(680,550,440),i.luminanceFromRadiance.identity();const a=r.autoClear;return r.autoClear=!1,await function(e){const t=e[Symbol.iterator]();return new Promise((e,n)=>{const r=()=>{try{const{value:n,done:i}=t.next();!0===i?e(n):ba(r)}catch(e){n(e instanceof Error?e:new Error)}};ba(r)})}(this.precompute(i,!1)),r.autoClear=a,i.dispose(),await Ma(this.renderer,this.transmittanceRenderTarget,this.transmittanceRenderTarget.texture),await Ma(this.renderer,this.irradianceRenderTarget,this.irradianceRenderTarget.texture),this.updating=!1,null==(t=this.disposeQueue)||t.call(this),this.textures}dispose(e={}){var t,n,r,i;if(this.updating)return void(this.disposeQueue=()=>{this.dispose(e),this.disposeQueue=void 0});const{textures:a=!0}=e;a||(this.transmittanceRenderTarget.textures.splice(0,1),this.scatteringRenderTarget.textures.splice(0,1),this.irradianceRenderTarget.textures.splice(0,1),null==(t=this.singleMieScatteringRenderTarget)||t.textures.splice(0,1),null==(n=this.higherOrderScatteringRenderTarget)||n.textures.splice(0,1)),this.transmittanceRenderTarget.dispose(),this.scatteringRenderTarget.dispose(),this.irradianceRenderTarget.dispose(),null==(r=this.singleMieScatteringRenderTarget)||r.dispose(),null==(i=this.higherOrderScatteringRenderTarget)||i.dispose(),this.transmittanceMaterial.dispose(),this.directIrradianceMaterial.dispose(),this.singleScatteringMaterial.dispose(),this.scatteringDensityMaterial.dispose(),this.indirectIrradianceMaterial.dispose(),this.multipleScatteringMaterial.dispose(),this.mesh.geometry.dispose()}}const Ga=1/Math.sqrt(Math.PI),Ha=Math.sqrt(3)/(2*Math.sqrt(Math.PI)),Fa=new e,Ba=new e,za=new u,ka=new t,Wa={ellipsoid:de.WGS84,correctAltitude:!0};class Ya extends y{constructor(n,r=Fr.DEFAULT){super(),this.atmosphere=r,this.ellipsoidCenter=new e,this.ellipsoidMatrix=new t;const{irradianceTexture:i=null,ellipsoid:a,correctAltitude:o,sunDirection:s}={...Wa,...n};this.irradianceTexture=i,this.ellipsoid=a,this.correctAltitude=o,this.sunDirection=(null==s?void 0:s.clone())??new e}update(){if(null==this.irradianceTexture)return;const e=ka.copy(this.ellipsoidMatrix).invert(),t=this.getWorldPosition(Fa).applyMatrix4(e).sub(this.ellipsoidCenter);if(this.correctAltitude){const e=this.ellipsoid.projectOnSurface(t,Ba);null!=e&&t.sub(zr(e,this.atmosphere.bottomRadius,this.ellipsoid,Ba))}const n=t.length(),r=t.dot(this.sunDirection)/n,i=function({topRadius:e,bottomRadius:t},n,r,i){const a=(n-t)/(e-t),o=.5*r+.5;return i.set(va(o,yr),va(a,Nr))}(this.atmosphere,n,r,za),a=Aa(this.irradianceTexture,i,Ba);a.multiply(this.atmosphere.skyRadianceToRelativeLuminance);const o=this.ellipsoid.getSurfaceNormal(t).applyMatrix4(this.ellipsoidMatrix),s=this.sh.coefficients;s[0].copy(a).multiplyScalar(Ga),s[1].copy(a).multiplyScalar(Ha*o.y),s[2].copy(a).multiplyScalar(Ha*o.z),s[3].copy(a).multiplyScalar(Ha*o.x)}}var Va=Object.defineProperty,Xa=(e,t,n,r)=>{for(var i,a=void 0,o=e.length-1;o>=0;o--)(i=e[o])&&(a=i(t,n,a)||a);return a&&Va(t,n,a),a};const ja={...Jr,sun:!0,moon:!0,moonAngularRadius:.0045,lunarRadianceScale:1,groundAlbedo:new s(0)};class qa extends ei{constructor(n){const{sun:r,moon:i,moonDirection:a,moonAngularRadius:o,lunarRadianceScale:s,groundAlbedo:u,...d}={...ja,...n};super({name:"SkyMaterial",glslVersion:N,vertexShader:"precision highp float;\nprecision highp sampler3D;\n\nuniform mat4 inverseProjectionMatrix;\nuniform mat4 inverseViewMatrix;\nuniform vec3 cameraPosition;\nuniform vec3 ellipsoidCenter;\nuniform mat4 inverseEllipsoidMatrix;\nuniform vec3 altitudeCorrection;\n\nlayout(location = 0) in vec3 position;\n\nout vec2 vUv;\nout vec3 vCameraPosition;\nout vec3 vRayDirection;\nout vec3 vEllipsoidCenter;\n\nvoid getCameraRay(out vec3 origin, out vec3 direction) {\n bool isPerspective = inverseProjectionMatrix[2][3] != 0.0; // 4th entry in the 3rd column\n\n if (isPerspective) {\n // Calculate the camera ray for a perspective camera.\n vec4 viewPosition = inverseProjectionMatrix * vec4(position, 1.0);\n vec4 worldDirection = inverseViewMatrix * vec4(viewPosition.xyz, 0.0);\n origin = cameraPosition;\n direction = worldDirection.xyz;\n } else {\n // Unprojected points to calculate direction.\n vec4 nearPoint = inverseProjectionMatrix * vec4(position.xy, -1.0, 1.0);\n vec4 farPoint = inverseProjectionMatrix * vec4(position.xy, -0.9, 1.0);\n nearPoint /= nearPoint.w;\n farPoint /= farPoint.w;\n\n // Calculate world values\n vec4 worldDirection = inverseViewMatrix * vec4(farPoint.xyz - nearPoint.xyz, 0.0);\n vec4 worldOrigin = inverseViewMatrix * nearPoint;\n\n // Outputs\n direction = worldDirection.xyz;\n origin = worldOrigin.xyz;\n }\n}\n\nvoid main() {\n vUv = position.xy * 0.5 + 0.5;\n\n vec3 direction, origin;\n getCameraRay(origin, direction);\n\n mat3 rotation = mat3(inverseEllipsoidMatrix);\n vCameraPosition = rotation * origin.xyz * METER_TO_LENGTH_UNIT;\n vRayDirection = rotation * direction.xyz;\n vEllipsoidCenter = (ellipsoidCenter + altitudeCorrection) * METER_TO_LENGTH_UNIT;\n\n gl_Position = vec4(position.xy, 1.0, 1.0);\n}\n",fragmentShader:_r('precision highp float;\nprecision highp sampler3D;\n\n#define RECIPROCAL_PI 0.3183098861837907\n\n#include "core/raySphereIntersection"\n\n#include "bruneton/definitions"\n\nuniform AtmosphereParameters ATMOSPHERE;\nuniform vec3 SUN_SPECTRAL_RADIANCE_TO_LUMINANCE;\nuniform vec3 SKY_SPECTRAL_RADIANCE_TO_LUMINANCE;\n\nuniform sampler2D transmittance_texture;\nuniform sampler3D scattering_texture;\nuniform sampler2D irradiance_texture;\nuniform sampler3D single_mie_scattering_texture;\nuniform sampler3D higher_order_scattering_texture;\n\n#include "bruneton/common"\n#include "bruneton/runtime"\n\n#include "sky"\n\nuniform vec3 sunDirection;\nuniform vec3 moonDirection;\nuniform float moonAngularRadius;\nuniform float lunarRadianceScale;\nuniform vec3 groundAlbedo;\n\n#ifdef HAS_SHADOW_LENGTH\nuniform sampler2D shadowLengthBuffer;\n#endif // HAS_SHADOW_LENGTH\n\nin vec2 vUv;\nin vec3 vCameraPosition;\nin vec3 vRayDirection;\nin vec3 vEllipsoidCenter;\n\nlayout(location = 0) out vec4 outputColor;\n\n#include <mrt_layout>\n\nbool rayIntersectsGround(const vec3 cameraPosition, const vec3 rayDirection) {\n float r = length(cameraPosition);\n float mu = dot(cameraPosition, rayDirection) / r;\n return mu < 0.0 &&\n r * r * (mu * mu - 1.0) + ATMOSPHERE.bottom_radius * ATMOSPHERE.bottom_radius >= 0.0;\n}\n\nvoid main() {\n float shadowLength = 0.0;\n #ifdef HAS_SHADOW_LENGTH\n shadowLength = texture(shadowLengthBuffer, vUv).r;\n #endif // HAS_SHADOW_LENGTH\n\n vec3 cameraPosition = vCameraPosition - vEllipsoidCenter;\n vec3 rayDirection = normalize(vRayDirection);\n\n #ifdef GROUND_ALBEDO\n\n bool intersectsGround = rayIntersectsGround(cameraPosition, rayDirection);\n if (intersectsGround) {\n float distanceToGround = raySphereFirstIntersection(\n cameraPosition,\n rayDirection,\n ATMOSPHERE.bottom_radius\n );\n vec3 groundPosition = rayDirection * distanceToGround + cameraPosition;\n vec3 surfaceNormal = normalize(groundPosition);\n vec3 skyIrradiance;\n vec3 sunIrradiance = GetSunAndSkyIrradiance(\n cameraPosition,\n surfaceNormal,\n sunDirection,\n skyIrradiance\n );\n vec3 transmittance;\n vec3 inscatter = GetSkyRadianceToPoint(\n cameraPosition,\n ATMOSPHERE.bottom_radius * surfaceNormal,\n shadowLength,\n sunDirection,\n transmittance\n );\n vec3 radiance = groundAlbedo * RECIPROCAL_PI * (sunIrradiance + skyIrradiance);\n outputColor.rgb = radiance * transmittance + inscatter;\n } else {\n outputColor.rgb = getSkyRadiance(\n cameraPosition,\n rayDirection,\n shadowLength,\n sunDirection,\n moonDirection,\n moonAngularRadius,\n lunarRadianceScale\n );\n }\n\n #else // GROUND_ALBEDO\n\n outputColor.rgb = getSkyRadiance(\n cameraPosition,\n rayDirection,\n shadowLength,\n sunDirection,\n moonDirection,\n moonAngularRadius,\n lunarRadianceScale\n );\n\n #endif // GROUND_ALBEDO\n\n outputColor.a = 1.0;\n\n #include <mrt_output>\n}\n',{core:{raySphereIntersection:Sr},bruneton:{common:Rr,definitions:xr,runtime:Ar},sky:kr}),...d,uniforms:{inverseProjectionMatrix:new c(new t),inverseViewMatrix:new c(new t),moonDirection:new c((null==a?void 0:a.clone())??new e),moonAngularRadius:new c(o),lunarRadianceScale:new c(s),groundAlbedo:new c(u.clone()),shadowLengthBuffer:new c(null),...d.uniforms},defines:{PERSPECTIVE_CAMERA:"1"},depthTest:!0}),this.shadowLength=null,this.sun=r,this.moon=i}onBeforeRender(e,t,n,r,i,a){super.onBeforeRender(e,t,n,r,i,a);const{uniforms:o,defines:s}=this;o.inverseProjectionMatrix.value.copy(n.projectionMatrixInverse),o.inverseViewMatrix.value.copy(n.matrixWorld);const c=null!=s.PERSPECTIVE_CAMERA,u=!0===n.isPerspectiveCamera;u!==c&&(u?s.PERSPECTIVE_CAMERA="1":delete s.PERSPECTIVE_CAMERA,this.needsUpdate=!0);const d=this.groundAlbedo,m=null!=s.GROUND_ALBEDO,l=0!==d.r||0!==d.g||0!==d.b;l!==m&&(l?this.defines.GROUND_ALBEDO="1":delete this.defines.GROUND_ALBEDO,this.needsUpdate=!0);const h=this.shadowLength,p=null!=h;p!==(null!=s.HAS_SHADOW_LENGTH)&&(p?s.HAS_SHADOW_LENGTH="1":(delete s.HAS_SHADOW_LENGTH,o.shadowLengthBuffer.value=null),this.needsUpdate=!0),p&&(o.shadowLengthBuffer.value=h.map)}get moonDirection(){return this.uniforms.moonDirection.value}get moonAngularRadius(){return this.uniforms.moonAngularRadius.value}set moonAngularRadius(e){this.uniforms.moonAngularRadius.value=e}get lunarRadianceScale(){return this.uniforms.lunarRadianceScale.value}set lunarRadianceScale(e){this.uniforms.lunarRadianceScale.value=e}get groundAlbedo(){return this.uniforms.groundAlbedo.value}}Xa([$n("SUN")],qa.prototype,"sun"),Xa([$n("MOON")],qa.prototype,"moon");var Ka=Object.defineProperty;const Za={...Jr,pointSize:1,intensity:1,background:!0};((e,t,n)=>{for(var r,i=void 0,a=e.length-1;a>=0;a--)(r=e[a])&&(i=r(t,n,i)||i);i&&Ka(t,n,i)})([$n("BACKGROUND")],class extends ei{constructor(e){const{pointSize:n,radianceScale:r,intensity:i,background:a,...o}={...Za,...e};super({name:"StarsMaterial",glslVersion:N,vertexShader:"precision highp float;\nprecision highp sampler3D;\n\n#define saturate(x) clamp(x, 0.0, 1.0)\n\nuniform mat4 projectionMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 viewMatrix;\nuniform mat4 matrixWorld;\nuniform vec3 cameraPosition;\nuniform float cameraFar;\nuniform vec3 ellipsoidCenter;\nuniform mat4 inverseEllipsoidMatrix;\nuniform vec3 altitudeCorrection;\nuniform float pointSize;\nuniform vec2 magnitudeRange;\nuniform float intensity;\n\nlayout(location = 0) in vec3 position;\nlayout(location = 1) in float magnitude;\nlayout(location = 2) in vec3 color;\n\nout vec3 vCameraPosition;\nout vec3 vRayDirection;\nout vec3 vEllipsoidCenter;\nout vec3 vColor;\n\nvoid main() {\n // Magnitude is stored between 0 to 1 within the given range.\n float m = mix(magnitudeRange.x, magnitudeRange.y, magnitude);\n vec3 v = pow(vec3(10.0), -vec3(magnitudeRange, m) / 2.5);\n vColor = vec3(intensity * color);\n vColor *= saturate((v.z - v.y) / (v.x - v.y));\n\n #ifdef BACKGROUND\n vec3 worldDirection = normalize(matrixWorld * vec4(position, 1.0)).xyz;\n mat3 rotation = mat3(inverseEllipsoidMatrix);\n vCameraPosition = rotation * cameraPosition * METER_TO_LENGTH_UNIT;\n vRayDirection = rotation * worldDirection;\n vEllipsoidCenter = (ellipsoidCenter + altitudeCorrection) * METER_TO_LENGTH_UNIT;\n gl_Position =\n projectionMatrix * viewMatrix * vec4(cameraPosition + worldDirection * cameraFar, 1.0);\n #else // BACKGROUND\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n #endif // BACKGROUND\n\n gl_PointSize = pointSize;\n}\n",fragmentShader:_r('precision highp float;\nprecision highp sampler3D;\n\n#include "bruneton/definitions"\n\nuniform AtmosphereParameters ATMOSPHERE;\nuniform vec3 SUN_SPECTRAL_RADIANCE_TO_LUMINANCE;\nuniform vec3 SKY_SPECTRAL_RADIANCE_TO_LUMINANCE;\n\nuniform sampler2D transmittance_texture;\nuniform sampler3D scattering_texture;\nuniform sampler2D irradiance_texture;\nuniform sampler3D single_mie_scattering_texture;\nuniform sampler3D higher_order_scattering_texture;\n\n#include "bruneton/common"\n#include "bruneton/runtime"\n\nuniform vec3 sunDirection;\n\nin vec3 vCameraPosition;\nin vec3 vRayDirection;\nin vec3 vEllipsoidCenter;\n\nlayout(location = 0) out vec4 outputColor;\n\n#include <mrt_layout>\n\nin vec3 vColor;\n\nvoid main() {\n #if !defined(PERSPECTIVE_CAMERA)\n outputColor = vec4(0.0);\n discard; // Rendering celestial objects without perspective doesn\'t make sense.\n #endif // !defined(PERSPECTIVE_CAMERA)\n\n #ifdef BACKGROUND\n vec3 cameraPosition = vCameraPosition - vEllipsoidCenter;\n vec3 rayDirection = normalize(vRayDirection);\n float r = length(cameraPosition);\n float mu = dot(cameraPosition, rayDirection) / r;\n\n if (RayIntersectsGround(ATMOSPHERE, r, mu)) {\n discard;\n }\n\n vec3 transmittance;\n vec3 radiance = GetSkyRadiance(\n vCameraPosition - vEllipsoidCenter,\n normalize(vRayDirection),\n 0.0,\n sunDirection,\n transmittance\n );\n radiance += transmittance * vColor;\n outputColor = vec4(radiance, 1.0);\n #else // BACKGROUND\n outputColor = vec4(vColor, 1.0);\n #endif // BACKGROUND\n\n #include <mrt_output>\n}\n',{bruneton:{common:Rr,definitions:xr,runtime:Ar}}),...o,uniforms:{projectionMatrix:new c(new t),modelViewMatrix:new c(new t),viewMatrix:new c(new t),matrixWorld:new c(new t),cameraFar:new c(0),pointSize:new c(0),magnitudeRange:new c(new u(-2,8)),intensity:new c(r??i),...o.uniforms},defines:{PERSPECTIVE_CAMERA:"1"}}),this.pointSize=n,this.background=a}onBeforeRender(e,t,n,r,i,a){super.onBeforeRender(e,t,n,r,i,a);const o=this.uniforms;o.projectionMatrix.value.copy(n.projectionMatrix),o.modelViewMatrix.value.copy(n.modelViewMatrix),o.viewMatrix.value.copy(n.matrixWorldInverse),o.matrixWorld.value.copy(i.matrixWorld),o.cameraFar.value=n.far,o.pointSize.value=this.pointSize*e.getPixelRatio();const s=!0===n.isPerspectiveCamera;null!=this.defines.PERSPECTIVE_CAMERA!==s&&(s?this.defines.PERSPECTIVE_CAMERA="1":delete this.defines.PERSPECTIVE_CAMERA,this.needsUpdate=!0)}get magnitudeRange(){return this.uniforms.magnitudeRange.value}get radianceScale(){return this.intensity}set radianceScale(e){this.intensity=e}get intensity(){return this.uniforms.intensity.value}set intensity(e){this.uniforms.intensity.value=e}}.prototype,"background");const $a=new e,Qa=new t,Ja={ellipsoid:de.WGS84,correctAltitude:!0,distance:1};class eo extends w{constructor(n,r=Fr.DEFAULT){super(),this.atmosphere=r,this.ellipsoidCenter=new e,this.ellipsoidMatrix=new t;const{irradianceTexture:i=null,ellipsoid:a,correctAltitude:o,sunDirection:s,distance:c}={...Ja,...n};this.transmittanceTexture=i,this.ellipsoid=a,this.correctAltitude=o,this.sunDirection=(null==s?void 0:s.clone())??new e,this.distance=c}update(){if(this.position.copy(this.sunDirection).applyMatrix4(this.ellipsoidMatrix).normalize().multiplyScalar(this.distance).add(this.target.position),null==this.transmittanceTexture)return;const e=Qa.copy(this.ellipsoidMatrix).invert(),t=this.target.getWorldPosition($a).applyMatrix4(e).sub(this.ellipsoidCenter);wa(this.transmittanceTexture,t,this.sunDirection,this.color,{ellipsoid:this.ellipsoid,correctAltitude:this.correctAltitude},this.atmosphere)}}var to=Object.defineProperty;const no={blendFunction:k.SRC,useTurbo:!1,near:1,far:1e3};((e,t,n)=>{for(var r,i=void 0,a=e.length-1;a>=0;a--)(r=e[a])&&(i=r(t,n,i)||i);i&&to(t,n,i)})([$n("USE_TURBO")],class extends W{constructor(e){const{blendFunction:t,useTurbo:n,near:r,far:i}={...no,...e};super("DepthEffect",_r('#include "core/depth"\n#include "core/turbo"\n\nuniform float near;\nuniform float far;\n\nvoid mainImage(const vec4 inputColor, const vec2 uv, out vec4 outputColor) {\n float depth = readDepth(uv);\n depth = reverseLogDepth(depth, cameraNear, cameraFar);\n depth = linearizeDepth(depth, near, far) / far;\n\n #ifdef USE_TURBO\n vec3 color = turbo(1.0 - depth);\n #else // USE_TURBO\n vec3 color = vec3(depth);\n #endif // USE_TURBO\n\n outputColor = vec4(color, inputColor.a);\n}\n',{core:{depth:vr,turbo:"// A fifth-order polynomial approximation of Turbo color map.\n// See: https://observablehq.com/@mbostock/turbo\n// prettier-ignore\nvec3 turbo(const float x) {\n float r = 0.1357 + x * (4.5974 - x * (42.3277 - x * (130.5887 - x * (150.5666 - x * 58.1375))));\n float g = 0.0914 + x * (2.1856 + x * (4.8052 - x * (14.0195 - x * (4.2109 + x * 2.7747))));\n float b = 0.1067 + x * (12.5925 - x * (60.1097 - x * (109.0745 - x * (88.5066 - x * 26.8183))));\n return vec3(r, g, b);\n}\n"}}),{blendFunction:t,attributes:Y.DEPTH,uniforms:new Map(Object.entries({near:new c(r),far:new c(i)}))}),this.useTurbo=n}get near(){return this.uniforms.get("near").value}set near(e){this.uniforms.get("near").value=e}get far(){return this.uniforms.get("far").value}set far(e){this.uniforms.get("far").value=e}}.prototype,"useTurbo");const ro={blendFunction:k.NORMAL};class io extends W{constructor(e){const{blendFunction:t}={...ro,...e};super("DitheringEffect","#define DITHERING\n\n#include <dithering_pars_fragment>\n\nvoid mainImage(const vec4 inputColor, const vec2 uv, out vec4 outputColor) {\n outputColor = vec4(saturate(dithering(inputColor.rgb)), inputColor.a);\n}\n",{blendFunction:t})}}const ao={thresholdLevel:10,thresholdRange:1};class oo extends H{constructor(e){const{inputBuffer:t=null,thresholdLevel:n,thresholdRange:r,...i}={...ao,...e};super({name:"DownsampleThresholdMaterial",fragmentShader:"#include <common>\n\nuniform sampler2D inputBuffer;\n\nuniform float thresholdLevel;\nuniform float thresholdRange;\n\nin vec2 vCenterUv1;\nin vec2 vCenterUv2;\nin vec2 vCenterUv3;\nin vec2 vCenterUv4;\nin vec2 vRowUv1;\nin vec2 vRowUv2;\nin vec2 vRowUv3;\nin vec2 vRowUv4;\nin vec2 vRowUv5;\nin vec2 vRowUv6;\nin vec2 vRowUv7;\nin vec2 vRowUv8;\nin vec2 vRowUv9;\n\nfloat clampToBorder(const vec2 uv) {\n return float(uv.x >= 0.0 && uv.x <= 1.0 && uv.y >= 0.0 && uv.y <= 1.0);\n}\n\n// Reference: https://learnopengl.com/Guest-Articles/2022/Phys.-Based-Bloom\nvoid main() {\n vec3 color = 0.125 * texture(inputBuffer, vec2(vRowUv5)).rgb;\n vec4 weight =\n 0.03125 *\n vec4(\n clampToBorder(vRowUv1),\n clampToBorder(vRowUv3),\n clampToBorder(vRowUv7),\n clampToBorder(vRowUv9)\n );\n color += weight.x * texture(inputBuffer, vec2(vRowUv1)).rgb;\n color += weight.y * texture(inputBuffer, vec2(vRowUv3)).rgb;\n color += weight.z * texture(inputBuffer, vec2(vRowUv7)).rgb;\n color += weight.w * texture(inputBuffer, vec2(vRowUv9)).rgb;\n\n weight =\n 0.0625 *\n vec4(\n clampToBorder(vRowUv2),\n clampToBorder(vRowUv4),\n clampToBorder(vRowUv6),\n clampToBorder(vRowUv8)\n );\n color += weight.x * texture(inputBuffer, vec2(vRowUv2)).rgb;\n color += weight.y * texture(inputBuffer, vec2(vRowUv4)).rgb;\n color += weight.z * texture(inputBuffer, vec2(vRowUv6)).rgb;\n color += weight.w * texture(inputBuffer, vec2(vRowUv8)).rgb;\n\n weight =\n 0.125 *\n vec4(\n clampToBorder(vRowUv2),\n clampToBorder(vRowUv4),\n clampToBorder(vRowUv6),\n clampToBorder(vRowUv8)\n );\n color += weight.x * texture(inputBuffer, vec2(vCenterUv1)).rgb;\n color += weight.y * texture(inputBuffer, vec2(vCenterUv2)).rgb;\n color += weight.z * texture(inputBuffer, vec2(vCenterUv3)).rgb;\n color += weight.w * texture(inputBuffer, vec2(vCenterUv4)).rgb;\n\n // WORKAROUND: Avoid screen flashes if the input buffer contains NaN texels.\n // See: https://github.com/takram-design-engineering/three-geospatial/issues/7\n if (any(isnan(color))) {\n gl_FragColor = vec4(vec3(0.0), 1.0);\n return;\n }\n\n float l = luminance(color);\n float scale = saturate(smoothstep(thresholdLevel, thresholdLevel + thresholdRange, l));\n gl_FragColor = vec4(color * scale, 1.0);\n}\n",vertexShader:"uniform vec2 texelSize;\n\nout vec2 vCenterUv1;\nout vec2 vCenterUv2;\nout vec2 vCenterUv3;\nout vec2 vCenterUv4;\nout vec2 vRowUv1;\nout vec2 vRowUv2;\nout vec2 vRowUv3;\nout vec2 vRowUv4;\nout vec2 vRowUv5;\nout vec2 vRowUv6;\nout vec2 vRowUv7;\nout vec2 vRowUv8;\nout vec2 vRowUv9;\n\nvoid main() {\n vec2 uv = position.xy * 0.5 + 0.5;\n vCenterUv1 = uv + texelSize * vec2(-1.0, 1.0);\n vCenterUv2 = uv + texelSize * vec2(1.0, 1.0);\n vCenterUv3 = uv + texelSize * vec2(-1.0, -1.0);\n vCenterUv4 = uv + texelSize * vec2(1.0, -1.0);\n vRowUv1 = uv + texelSize * vec2(-2.0, 2.0);\n vRowUv2 = uv + texelSize * vec2(0.0, 2.0);\n vRowUv3 = uv + texelSize * vec2(2.0, 2.0);\n vRowUv4 = uv + texelSize * vec2(-2.0, 0.0);\n vRowUv5 = uv + texelSize;\n vRowUv6 = uv + texelSize * vec2(2.0, 0.0);\n vRowUv7 = uv + texelSize * vec2(-2.0, -2.0);\n vRowUv8 = uv + texelSize * vec2(0.0, -2.0);\n vRowUv9 = uv + texelSize * vec2(2.0, -2.0);\n\n gl_Position = vec4(position.xy, 1.0, 1.0);\n}\n",blending:P,toneMapped:!1,depthWrite:!1,depthTest:!1,...i,uniforms:{inputBuffer:new c(t),texelSize:new c(new u),thresholdLevel:new c(n),thresholdRange:new c(r),...i.uniforms}})}setSize(e,t){this.uniforms.texelSize.value.set(1/e,1/t)}get inputBuffer(){return this.uniforms.inputBuffer.value}set inputBuffer(e){this.uniforms.inputBuffer.value=e}get thresholdLevel(){return this.uniforms.thresholdLevel.value}set thresholdLevel(e){this.uniforms.thresholdLevel.value=e}get thresholdRange(){return this.uniforms.thresholdRange.value}set thresholdRange(e){this.uniforms.thresholdRange.value=e}}const so={ghostAmount:.001,haloAmount:.001,chromaticAberration:10};class co extends H{constructor(e){const{inputBuffer:t=null,ghostAmount:n,haloAmount:r,chromaticAberration:i,...a}={...so,...e};super({name:"LensFlareFeaturesMaterial",fragmentShader:"#include <common>\n\n#define SQRT_2 0.7071067811865476\n\nuniform sampler2D inputBuffer;\n\nuniform vec2 texelSize;\nuniform float ghostAmount;\nuniform float haloAmount;\nuniform float chromaticAberration;\n\nin vec2 vUv;\nin vec2 vAspectRatio;\n\nvec3 sampleGhost(const vec2 direction, const vec3 color, const float offset) {\n vec2 suv = clamp(1.0 - vUv + direction * offset, 0.0, 1.0);\n vec3 result = texture(inputBuffer, suv).rgb * color;\n\n // Falloff at the perimeter.\n float d = clamp(length(0.5 - suv) / (0.5 * SQRT_2), 0.0, 1.0);\n result *= pow(1.0 - d, 3.0);\n return result;\n}\n\nvec4 sampleGhosts(float amount) {\n vec3 color = vec3(0.0);\n vec2 direction = vUv - 0.5;\n color += sampleGhost(direction, vec3(0.8, 0.8, 1.0), -5.0);\n color += sampleGhost(direction, vec3(1.0, 0.8, 0.4), -1.5);\n color += sampleGhost(direction, vec3(0.9, 1.0, 0.8), -0.4);\n color += sampleGhost(direction, vec3(1.0, 0.8, 0.4), -0.2);\n color += sampleGhost(direction, vec3(0.9, 0.7, 0.7), -0.1);\n color += sampleGhost(direction, vec3(0.5, 1.0, 0.4), 0.7);\n color += sampleGhost(direction, vec3(0.5, 0.5, 0.5), 1.0);\n color += sampleGhost(direction, vec3(1.0, 1.0, 0.6), 2.5);\n color += sampleGhost(direction, vec3(0.5, 0.8, 1.0), 10.0);\n return vec4(color * amount, 1.0);\n}\n\n// Reference: https://john-chapman.github.io/2017/11/05/pseudo-lens-flare.html\nfloat cubicRingMask(const float x, const float radius, const float thickness) {\n float v = min(abs(x - radius) / thickness, 1.0);\n return 1.0 - v * v * (3.0 - 2.0 * v);\n}\n\nvec3 sampleHalo(const float radius) {\n vec2 direction = normalize((vUv - 0.5) / vAspectRatio) * vAspectRatio;\n vec3 offset = vec3(texelSize.x * chromaticAberration) * vec3(-1.0, 0.0, 1.0);\n vec2 suv = fract(1.0 - vUv + direction * radius);\n vec3 result = vec3(\n texture(inputBuffer, suv + direction * offset.r).r,\n texture(inputBuffer, suv + direction * offset.g).g,\n texture(inputBuffer, suv + direction * offset.b).b\n );\n\n // Falloff at the center and perimeter.\n vec2 wuv = (vUv - vec2(0.5, 0.0)) / vAspectRatio + vec2(0.5, 0.0);\n float d = saturate(distance(wuv, vec2(0.5)));\n result *= cubicRingMask(d, 0.45, 0.25);\n return result;\n}\n\nvec4 sampleHalos(const float amount) {\n vec3 color = vec3(0.0);\n color += sampleHalo(0.3);\n return vec4(color, 1.0) * amount;\n}\n\nvoid main() {\n gl_FragColor += sampleGhosts(ghostAmount);\n gl_FragColor += sampleHalos(haloAmount);\n}\n\n",vertexShader:"uniform vec2 texelSize;\n\nout vec2 vUv;\nout vec2 vAspectRatio;\n\nvoid main() {\n vUv = position.xy * 0.5 + 0.5;\n vAspectRatio = vec2(texelSize.x / texelSize.y, 1.0);\n gl_Position = vec4(position.xy, 1.0, 1.0);\n}\n",blending:P,toneMapped:!1,depthWrite:!1,depthTest:!1,uniforms:{inputBuffer:new c(t),texelSize:new c(new u),ghostAmount:new c(n),haloAmount:new c(r),chromaticAberration:new c(i),...a.uniforms}})}setSize(e,t){this.uniforms.texelSize.value.set(1/e,1/t)}get inputBuffer(){return this.uniforms.inputBuffer.value}set inputBuffer(e){this.uniforms.inputBuffer.value=e}get ghostAmount(){return this.uniforms.ghostAmount.value}set ghostAmount(e){this.uniforms.ghostAmount.value=e}get haloAmount(){return this.uniforms.haloAmount.value}set haloAmount(e){this.uniforms.haloAmount.value=e}get chromaticAberration(){return this.uniforms.chromaticAberration.value}set chromaticAberration(e){this.uniforms.chromaticAberration.value=e}}const uo={blendFunction:k.NORMAL,resolutionScale:.5,width:J.AUTO_SIZE,height:J.AUTO_SIZE,intensity:.005};class mo extends W{constructor(e){const{blendFunction:t,resolutionScale:n,width:r,height:i,resolutionX:a=r,resolutionY:o=i,intensity:s}={...uo,...e};super("LensFlareEffect","uniform sampler2D bloomBuffer;\nuniform sampler2D featuresBuffer;\nuniform float intensity;\n\nvoid mainImage(const vec4 inputColor, const vec2 uv, out vec4 outputColor) {\n vec3 bloom = texture(bloomBuffer, uv).rgb;\n vec3 features = texture(featuresBuffer, uv).rgb;\n outputColor = vec4(inputColor.rgb + (bloom + features) * intensity, inputColor.a);\n}\n",{blendFunction:t,attributes:Y.CONVOLUTION,uniforms:new Map(Object.entries({bloomBuffer:new c(null),featuresBuffer:new c(null),intensity:new c(1)}))}),this.onResolutionChange=()=>{this.setSize(this.resolution.baseWidth,this.resolution.baseHeight)},this.renderTarget1=new _(1,1,{depthBuffer:!1,type:I}),this.renderTarget1.texture.name="LensFlare.Target1",this.renderTarget2=new _(1,1,{depthBuffer:!1,type:I}),this.renderTarget2.texture.name="LensFlare.Target2",this.thresholdMaterial=new oo,this.thresholdPass=new Q(this.thresholdMaterial),this.blurPass=new ee,this.blurPass.levels=8,this.preBlurPass=new te({kernelSize:ne.SMALL}),this.featuresMaterial=new co,this.featuresPass=new Q(this.featuresMaterial),this.uniforms.get("bloomBuffer").value=this.blurPass.texture,this.uniforms.get("featuresBuffer").value=this.renderTarget1.texture,this.resolution=new J(this,a,o,n),this.resolution.addEventListener("change",this.onResolutionChange),this.intensity=s}initialize(e,t,n){this.thresholdPass.initialize(e,t,n),this.blurPass.initialize(e,t,n),this.preBlurPass.initialize(e,t,n),this.featuresPass.initialize(e,t,n)}update(e,t,n){this.thresholdPass.render(e,t,this.renderTarget1),this.blurPass.render(e,this.renderTarget1,null),this.preBlurPass.render(e,this.renderTarget1,this.renderTarget2),this.featuresPass.render(e,this.renderTarget2,this.renderTarget1)}setSize(e,t){const n=this.resolution;n.setBaseSize(e,t);const{width:r,height:i}=n;this.renderTarget1.setSize(r,i),this.renderTarget2.setSize(r,i),this.thresholdMaterial.setSize(r,i),this.blurPass.setSize(r,i),this.preBlurPass.setSize(r,i),this.featuresMaterial.setSize(r,i)}get intensity(){return this.uniforms.get("intensity").value}set intensity(e){this.uniforms.get("intensity").value=e}get thresholdLevel(){return this.thresholdMaterial.thresholdLevel}set thresholdLevel(e){this.thresholdMaterial.thresholdLevel=e}get thresholdRange(){return this.thresholdMaterial.thresholdRange}set thresholdRange(e){this.thresholdMaterial.thresholdRange=e}}var lo=Object.defineProperty,ho=(e,t,n,r)=>{for(var i,a=void 0,o=e.length-1;o>=0;o--)(i=e[o])&&(a=i(t,n,a)||a);return a&&lo(t,n,a),a};const po={blendFunction:k.SRC,octEncoded:!1,reconstructFromDepth:!1};class _o extends W{constructor(e,n){const{blendFunction:r,normalBuffer:i=null,octEncoded:a,reconstructFromDepth:o}={...po,...n};super("NormalEffect",_r('#include "core/depth"\n#include "core/packing"\n#include "core/transform"\n\nuniform highp sampler2D normalBuffer;\n\nuniform mat4 projectionMatrix;\nuniform mat4 inverseProjectionMatrix;\n\nvec3 reconstructNormal(const vec2 uv) {\n float depth = readDepth(uv);\n depth = reverseLogDepth(depth, cameraNear, cameraFar);\n vec3 position = screenToView(\n uv,\n depth,\n getViewZ(depth),\n projectionMatrix,\n inverseProjectionMatrix\n );\n vec3 dx = dFdx(position);\n vec3 dy = dFdy(position);\n return normalize(cross(dx, dy));\n}\n\nvec3 readNormal(const vec2 uv) {\n #ifdef OCT_ENCODED\n return unpackVec2ToNormal(texture(normalBuffer, uv).xy);\n #else // OCT_ENCODED\n return 2.0 * texture(normalBuffer, uv).xyz - 1.0;\n #endif // OCT_ENCODED\n}\n\nvoid mainImage(const vec4 inputColor, const vec2 uv, out vec4 outputColor) {\n #ifdef RECONSTRUCT_FROM_DEPTH\n vec3 normal = reconstructNormal(uv);\n #else // RECONSTRUCT_FROM_DEPTH\n vec3 normal = readNormal(uv);\n #endif // RECONSTRUCT_FROM_DEPTH\n\n outputColor = vec4(normal * 0.5 + 0.5, inputColor.a);\n}\n',{core:{depth:vr,packing:Tr,transform:Er}}),{blendFunction:r,attributes:Y.DEPTH,uniforms:new Map(Object.entries({normalBuffer:new c(i),projectionMatrix:new c(new t),inverseProjectionMatrix:new c(new t)}))}),this.camera=e,null!=e&&(this.mainCamera=e),this.octEncoded=a,this.reconstructFromDepth=o}get mainCamera(){return this.camera}set mainCamera(e){this.camera=e}update(e,t,n){const r=this.uniforms,i=r.get("projectionMatrix"),a=r.get("inverseProjectionMatrix"),o=this.camera;null!=o&&(i.value.copy(o.projectionMatrix),a.value.copy(o.projectionMatrixInverse))}get normalBuffer(){return this.uniforms.get("normalBuffer").value}set normalBuffer(e){this.uniforms.get("normalBuffer").value=e}}ho([$n("OCT_ENCODED")],_o.prototype,"octEncoded"),ho([$n("RECONSTRUCT_FROM_DEPTH")],_o.prototype,"reconstructFromDepth");const go=new pe,fo=new e,vo=new e,To=new e,So=new e;(new F).enable(10);class Eo{set neesUpdate(e){!0===e&&(this.cacheKey=Math.random().toString())}constructor(n){this.ssp=n,this.cacheKey="",this.date=new Date,this.longitude=120,this.latitude=30,this.altitude=20,this.distance=300,this.target=new e,this.groundAlbedo="black",this.castShadow=!0,this.atmosphereProps={rotationMatrix:new t,sunDirection:new e,moonDirection:new e,ellipsoidCenter:new e,ellipsoidMatrix:new t},this._started=!1,this.update=()=>{const{date:t,longitude:n,latitude:r,altitude:i,distance:a,target:o,groundAlbedo:s,castShadow:c,skyMaterial:u,skyLight:d,sunLight:m,aerialPerspectiveEffect:l}=this,{rotationMatrix:h,sunDirection:p,moonDirection:_,ellipsoidCenter:g,ellipsoidMatrix:f}=this.atmosphereProps,{ssp:{viewport:{renderer:v}}}=this;pa(t,h),function(t,n=new e){return _a(hi.Sun,ha(t),n)}(t,p).applyMatrix4(h),function(t,n=new e){return _a(hi.Moon,ha(t),n)}(t,_).applyMatrix4(h),go.set(Zn(n),Zn(r),i),go.toECEF(fo),g.copy(fo).multiplyScalar(-1),de.WGS84.getEastNorthUpVectors(fo,vo,To,So),f.makeBasis(To,So,vo).invert(),u.groundAlbedo.set(s),u.sunDirection.copy(p),u.moonDirection.copy(_),u.ellipsoidCenter.copy(g),u.ellipsoidMatrix.copy(f),d.sunDirection.copy(p),d.ellipsoidCenter.copy(g),d.ellipsoidMatrix.copy(f),d.position.copy(o),m.castShadow=c,m.distance=a,m.shadow.camera.top=a,m.shadow.camera.bottom=-a,m.shadow.camera.left=-a,m.shadow.camera.right=a,m.shadow.camera.far=2*a,m.sunDirection.copy(p),m.ellipsoidCenter.copy(g),m.ellipsoidMatrix.copy(f),m.target.position.copy(o),l.sunDirection.copy(p),l.moonDirection.copy(_),l.ellipsoidCenter.copy(g),l.ellipsoidMatrix.copy(f);const T=this.getCacheKey();T!==this.cacheKey&&(this.cacheKey=T,c&&(m.shadow.needsUpdate=!0,m.shadow.camera.updateProjectionMatrix()),this.skyMesh.material.sun=!1,this.cubeCamera.update(v,this.skyMesh),this.skyMesh.material.sun=!0),d.update(),m.update()};const{viewport:{scene:r,camera:i,renderer:a}}=n;this.date.setHours(10,0,0,0),this.texturesGenerator=new Ua(a),this.arrayBufferLoader=new _e,this.skyMaterial=new qa,this.skyMesh=new E(new R(2,2),this.skyMaterial),this.skyMesh.frustumCulled=!1,this.skyMesh.renderOrder=100,this.skyLight=new Ya,this.sunLight=new eo,this.sunLight.shadow.autoUpdate=!1,this.sunLight.shadow.bias=-5e-4,this.sunLight.shadow.normalBias=.5,this.sunLight.shadow.camera.near=.01,this.sunLight.shadow.mapSize.width=a.capabilities.maxTextureSize,this.sunLight.shadow.mapSize.height=a.capabilities.maxTextureSize,this.aerialPerspectiveEffect=new Kr(i),this.aerialPerspective={effect:this.aerialPerspectiveEffect,enabled:!1},this.lensFlareEffect=new mo,this.lensFlare={effect:this.lensFlareEffect,enabled:!1},this.ditheringEffect=new io,this.dithering={effect:this.ditheringEffect,enabled:!1},this.lightingMaskPass=new Ca(r,i),this.lightingMaskPass.selectionLayer=10,this.cubeRenderTarget=new B(512,{type:I}),this.cubeCamera=new z(.1,1e3,this.cubeRenderTarget)}getCacheKey(){const{date:e,longitude:t,latitude:n,altitude:r,distance:i,target:a,groundAlbedo:o,castShadow:s}=this;return`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}-${e.getHours()}-${e.getMinutes()}-${t}-${n}-${r}-${i}-${a.x}-${a.y}-${a.z}-${o}-${s}`}start(){if(this._started)return;this._started=!0;const{scene:e,camera:t,effectManager:n,signals:r}=this.ssp.viewport;(async()=>{const e=await this.texturesGenerator.update();Object.assign(this.skyMaterial,e),this.sunLight.transmittanceTexture=e.transmittanceTexture,this.skyLight.irradianceTexture=e.irradianceTexture,Object.assign(this.aerialPerspectiveEffect,e),this.neesUpdate=!0,this.ssp.render()})(),e.add(this.skyMesh),e.add(this.skyLight),e.add(this.sunLight),e.add(this.sunLight.target),this.aerialPerspective.enabled=!0,this.aerialPerspectiveEffect.mainCamera=t,this.lensFlare.enabled=!0,this.dithering.enabled=!0;const i=n.effectsMap.get("smaaEffect"),a=n.passesMap.get("normalPass");i&&(i.enabled=!1),a?(a.enabled=!0,this.aerialPerspectiveEffect.normalBuffer=a.texture,this.aerialPerspectiveEffect.sunLight=!0,this.aerialPerspectiveEffect.skyLight=!0,this.aerialPerspectiveEffect.lightingMask={map:this.lightingMaskPass.texture,channel:"r"}):(this.aerialPerspectiveEffect.normalBuffer=null,this.aerialPerspectiveEffect.sunLight=!1,this.aerialPerspectiveEffect.skyLight=!1,this.aerialPerspectiveEffect.lightingMask=null),this.ssp.setToneMapping({type:"AGX",exposure:10}),e.environment=this.cubeRenderTarget.texture,n.effectsMap.set("aerialPerspectiveEffect",this.aerialPerspective),n.effectsMap.set("lensFlareEffect",this.lensFlare),n.effectsMap.set("ditheringEffect",this.dithering),n.effectsNeedsUpdate=!0,n.effectComposer.addPass(this.lightingMaskPass,-1),r.beforeRender.add(this.update)}updateModelLightingMask(){this.ssp.viewport.scener.intersectsList.meshOfModelList.forEach(e=>{e.layers.enable(10)})}stop(){if(!this._started)return;this._started=!1;const{scene:e,effectManager:t,signals:n}=this.ssp.viewport;e.remove(this.skyMesh),e.remove(this.skyLight),e.remove(this.sunLight),e.remove(this.sunLight.target),this.aerialPerspective.enabled=!1,this.lensFlare.enabled=!1,this.dithering.enabled=!1;const r=t.effectsMap.get("smaaEffect"),i=t.passesMap.get("normalPass");r&&(r.enabled=!0),i&&(i.enabled=!1),this.ssp.setToneMapping({type:"ACESFilmic",exposure:.8}),this.ssp.setEnvironment(),t.effectsMap.delete("aerialPerspectiveEffect"),t.effectsMap.delete("lensFlareEffect"),t.effectsMap.delete("ditheringEffect"),t.effectsNeedsUpdate=!0,t.effectComposer.removePass(this.lightingMaskPass),n.beforeRender.remove(this.update),this.ssp.render()}dispose(){this.stop(),this.aerialPerspectiveEffect.dispose(),this.lensFlareEffect.dispose(),this.ditheringEffect.dispose(),this.lightingMaskPass.dispose(),this.texturesGenerator.dispose(),this.skyMesh.geometry.dispose(),this.skyMesh.material.dispose(),this.skyLight.dispose(),this.sunLight.dispose(),this.cubeRenderTarget.dispose()}}export{Eo as default};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@soonspacejs/plugin-atmosphere",
3
3
  "pluginName": "AtmospherePlugin",
4
- "version": "2.13.11",
4
+ "version": "2.13.14",
5
5
  "description": "Atmosphere plugin for SoonSpace.js",
6
6
  "main": "dist/index.esm.js",
7
7
  "module": "dist/index.esm.js",
@@ -13,12 +13,13 @@
13
13
  ],
14
14
  "author": "xunwei",
15
15
  "license": "UNLICENSED",
16
- "gitHead": "08bf9efb38c291f22ca044b936fd49269c716bbb",
16
+ "gitHead": "71d91773a54276b7cbb0a0525ba5f921345f121f",
17
17
  "peerDependencies": {
18
- "soonspacejs": "2.13.11"
18
+ "soonspacejs": "2.13.14"
19
19
  },
20
20
  "devDependencies": {
21
21
  "@takram/three-atmosphere": "0.13.2",
22
+ "@takram/three-geospatial": "0.3.0",
22
23
  "@takram/three-geospatial-effects": "0.4.0"
23
24
  }
24
25
  }