index.js 636 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358
  1. /**
  2. * Name: Metaverse
  3. * Date: 2022/4/11
  4. * Author: https://www.4dkankan.com
  5. * Copyright © 2022 4DAGE Co., Ltd. All rights reserved.
  6. * Licensed under the GLP license
  7. */
  8. (function (factory) {
  9. typeof define === 'function' && define.amd ? define(factory) :
  10. factory();
  11. })((function () { 'use strict';
  12. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  13. try {
  14. var info = gen[key](arg);
  15. var value = info.value;
  16. } catch (error) {
  17. reject(error);
  18. return;
  19. }
  20. if (info.done) {
  21. resolve(value);
  22. } else {
  23. Promise.resolve(value).then(_next, _throw);
  24. }
  25. }
  26. function _asyncToGenerator(fn) {
  27. return function () {
  28. var self = this,
  29. args = arguments;
  30. return new Promise(function (resolve, reject) {
  31. var gen = fn.apply(self, args);
  32. function _next(value) {
  33. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
  34. }
  35. function _throw(err) {
  36. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
  37. }
  38. _next(undefined);
  39. });
  40. };
  41. }
  42. function createCommonjsModule(fn) {
  43. var module = { exports: {} };
  44. return fn(module, module.exports), module.exports;
  45. }
  46. /**
  47. * Copyright (c) 2014-present, Facebook, Inc.
  48. *
  49. * This source code is licensed under the MIT license found in the
  50. * LICENSE file in the root directory of this source tree.
  51. */
  52. var runtime_1 = createCommonjsModule(function (module) {
  53. var runtime = (function (exports) {
  54. var Op = Object.prototype;
  55. var hasOwn = Op.hasOwnProperty;
  56. var undefined$1; // More compressible than void 0.
  57. var $Symbol = typeof Symbol === "function" ? Symbol : {};
  58. var iteratorSymbol = $Symbol.iterator || "@@iterator";
  59. var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
  60. var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  61. function define(obj, key, value) {
  62. Object.defineProperty(obj, key, {
  63. value: value,
  64. enumerable: true,
  65. configurable: true,
  66. writable: true
  67. });
  68. return obj[key];
  69. }
  70. try {
  71. // IE 8 has a broken Object.defineProperty that only works on DOM objects.
  72. define({}, "");
  73. } catch (err) {
  74. define = function(obj, key, value) {
  75. return obj[key] = value;
  76. };
  77. }
  78. function wrap(innerFn, outerFn, self, tryLocsList) {
  79. // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
  80. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
  81. var generator = Object.create(protoGenerator.prototype);
  82. var context = new Context(tryLocsList || []);
  83. // The ._invoke method unifies the implementations of the .next,
  84. // .throw, and .return methods.
  85. generator._invoke = makeInvokeMethod(innerFn, self, context);
  86. return generator;
  87. }
  88. exports.wrap = wrap;
  89. // Try/catch helper to minimize deoptimizations. Returns a completion
  90. // record like context.tryEntries[i].completion. This interface could
  91. // have been (and was previously) designed to take a closure to be
  92. // invoked without arguments, but in all the cases we care about we
  93. // already have an existing method we want to call, so there's no need
  94. // to create a new function object. We can even get away with assuming
  95. // the method takes exactly one argument, since that happens to be true
  96. // in every case, so we don't have to touch the arguments object. The
  97. // only additional allocation required is the completion record, which
  98. // has a stable shape and so hopefully should be cheap to allocate.
  99. function tryCatch(fn, obj, arg) {
  100. try {
  101. return { type: "normal", arg: fn.call(obj, arg) };
  102. } catch (err) {
  103. return { type: "throw", arg: err };
  104. }
  105. }
  106. var GenStateSuspendedStart = "suspendedStart";
  107. var GenStateSuspendedYield = "suspendedYield";
  108. var GenStateExecuting = "executing";
  109. var GenStateCompleted = "completed";
  110. // Returning this object from the innerFn has the same effect as
  111. // breaking out of the dispatch switch statement.
  112. var ContinueSentinel = {};
  113. // Dummy constructor functions that we use as the .constructor and
  114. // .constructor.prototype properties for functions that return Generator
  115. // objects. For full spec compliance, you may wish to configure your
  116. // minifier not to mangle the names of these two functions.
  117. function Generator() {}
  118. function GeneratorFunction() {}
  119. function GeneratorFunctionPrototype() {}
  120. // This is a polyfill for %IteratorPrototype% for environments that
  121. // don't natively support it.
  122. var IteratorPrototype = {};
  123. define(IteratorPrototype, iteratorSymbol, function () {
  124. return this;
  125. });
  126. var getProto = Object.getPrototypeOf;
  127. var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  128. if (NativeIteratorPrototype &&
  129. NativeIteratorPrototype !== Op &&
  130. hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
  131. // This environment has a native %IteratorPrototype%; use it instead
  132. // of the polyfill.
  133. IteratorPrototype = NativeIteratorPrototype;
  134. }
  135. var Gp = GeneratorFunctionPrototype.prototype =
  136. Generator.prototype = Object.create(IteratorPrototype);
  137. GeneratorFunction.prototype = GeneratorFunctionPrototype;
  138. define(Gp, "constructor", GeneratorFunctionPrototype);
  139. define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
  140. GeneratorFunction.displayName = define(
  141. GeneratorFunctionPrototype,
  142. toStringTagSymbol,
  143. "GeneratorFunction"
  144. );
  145. // Helper for defining the .next, .throw, and .return methods of the
  146. // Iterator interface in terms of a single ._invoke method.
  147. function defineIteratorMethods(prototype) {
  148. ["next", "throw", "return"].forEach(function(method) {
  149. define(prototype, method, function(arg) {
  150. return this._invoke(method, arg);
  151. });
  152. });
  153. }
  154. exports.isGeneratorFunction = function(genFun) {
  155. var ctor = typeof genFun === "function" && genFun.constructor;
  156. return ctor
  157. ? ctor === GeneratorFunction ||
  158. // For the native GeneratorFunction constructor, the best we can
  159. // do is to check its .name property.
  160. (ctor.displayName || ctor.name) === "GeneratorFunction"
  161. : false;
  162. };
  163. exports.mark = function(genFun) {
  164. if (Object.setPrototypeOf) {
  165. Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
  166. } else {
  167. genFun.__proto__ = GeneratorFunctionPrototype;
  168. define(genFun, toStringTagSymbol, "GeneratorFunction");
  169. }
  170. genFun.prototype = Object.create(Gp);
  171. return genFun;
  172. };
  173. // Within the body of any async function, `await x` is transformed to
  174. // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
  175. // `hasOwn.call(value, "__await")` to determine if the yielded value is
  176. // meant to be awaited.
  177. exports.awrap = function(arg) {
  178. return { __await: arg };
  179. };
  180. function AsyncIterator(generator, PromiseImpl) {
  181. function invoke(method, arg, resolve, reject) {
  182. var record = tryCatch(generator[method], generator, arg);
  183. if (record.type === "throw") {
  184. reject(record.arg);
  185. } else {
  186. var result = record.arg;
  187. var value = result.value;
  188. if (value &&
  189. typeof value === "object" &&
  190. hasOwn.call(value, "__await")) {
  191. return PromiseImpl.resolve(value.__await).then(function(value) {
  192. invoke("next", value, resolve, reject);
  193. }, function(err) {
  194. invoke("throw", err, resolve, reject);
  195. });
  196. }
  197. return PromiseImpl.resolve(value).then(function(unwrapped) {
  198. // When a yielded Promise is resolved, its final value becomes
  199. // the .value of the Promise<{value,done}> result for the
  200. // current iteration.
  201. result.value = unwrapped;
  202. resolve(result);
  203. }, function(error) {
  204. // If a rejected Promise was yielded, throw the rejection back
  205. // into the async generator function so it can be handled there.
  206. return invoke("throw", error, resolve, reject);
  207. });
  208. }
  209. }
  210. var previousPromise;
  211. function enqueue(method, arg) {
  212. function callInvokeWithMethodAndArg() {
  213. return new PromiseImpl(function(resolve, reject) {
  214. invoke(method, arg, resolve, reject);
  215. });
  216. }
  217. return previousPromise =
  218. // If enqueue has been called before, then we want to wait until
  219. // all previous Promises have been resolved before calling invoke,
  220. // so that results are always delivered in the correct order. If
  221. // enqueue has not been called before, then it is important to
  222. // call invoke immediately, without waiting on a callback to fire,
  223. // so that the async generator function has the opportunity to do
  224. // any necessary setup in a predictable way. This predictability
  225. // is why the Promise constructor synchronously invokes its
  226. // executor callback, and why async functions synchronously
  227. // execute code before the first await. Since we implement simple
  228. // async functions in terms of async generators, it is especially
  229. // important to get this right, even though it requires care.
  230. previousPromise ? previousPromise.then(
  231. callInvokeWithMethodAndArg,
  232. // Avoid propagating failures to Promises returned by later
  233. // invocations of the iterator.
  234. callInvokeWithMethodAndArg
  235. ) : callInvokeWithMethodAndArg();
  236. }
  237. // Define the unified helper method that is used to implement .next,
  238. // .throw, and .return (see defineIteratorMethods).
  239. this._invoke = enqueue;
  240. }
  241. defineIteratorMethods(AsyncIterator.prototype);
  242. define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
  243. return this;
  244. });
  245. exports.AsyncIterator = AsyncIterator;
  246. // Note that simple async functions are implemented on top of
  247. // AsyncIterator objects; they just return a Promise for the value of
  248. // the final result produced by the iterator.
  249. exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
  250. if (PromiseImpl === void 0) PromiseImpl = Promise;
  251. var iter = new AsyncIterator(
  252. wrap(innerFn, outerFn, self, tryLocsList),
  253. PromiseImpl
  254. );
  255. return exports.isGeneratorFunction(outerFn)
  256. ? iter // If outerFn is a generator, return the full iterator.
  257. : iter.next().then(function(result) {
  258. return result.done ? result.value : iter.next();
  259. });
  260. };
  261. function makeInvokeMethod(innerFn, self, context) {
  262. var state = GenStateSuspendedStart;
  263. return function invoke(method, arg) {
  264. if (state === GenStateExecuting) {
  265. throw new Error("Generator is already running");
  266. }
  267. if (state === GenStateCompleted) {
  268. if (method === "throw") {
  269. throw arg;
  270. }
  271. // Be forgiving, per 25.3.3.3.3 of the spec:
  272. // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
  273. return doneResult();
  274. }
  275. context.method = method;
  276. context.arg = arg;
  277. while (true) {
  278. var delegate = context.delegate;
  279. if (delegate) {
  280. var delegateResult = maybeInvokeDelegate(delegate, context);
  281. if (delegateResult) {
  282. if (delegateResult === ContinueSentinel) continue;
  283. return delegateResult;
  284. }
  285. }
  286. if (context.method === "next") {
  287. // Setting context._sent for legacy support of Babel's
  288. // function.sent implementation.
  289. context.sent = context._sent = context.arg;
  290. } else if (context.method === "throw") {
  291. if (state === GenStateSuspendedStart) {
  292. state = GenStateCompleted;
  293. throw context.arg;
  294. }
  295. context.dispatchException(context.arg);
  296. } else if (context.method === "return") {
  297. context.abrupt("return", context.arg);
  298. }
  299. state = GenStateExecuting;
  300. var record = tryCatch(innerFn, self, context);
  301. if (record.type === "normal") {
  302. // If an exception is thrown from innerFn, we leave state ===
  303. // GenStateExecuting and loop back for another invocation.
  304. state = context.done
  305. ? GenStateCompleted
  306. : GenStateSuspendedYield;
  307. if (record.arg === ContinueSentinel) {
  308. continue;
  309. }
  310. return {
  311. value: record.arg,
  312. done: context.done
  313. };
  314. } else if (record.type === "throw") {
  315. state = GenStateCompleted;
  316. // Dispatch the exception by looping back around to the
  317. // context.dispatchException(context.arg) call above.
  318. context.method = "throw";
  319. context.arg = record.arg;
  320. }
  321. }
  322. };
  323. }
  324. // Call delegate.iterator[context.method](context.arg) and handle the
  325. // result, either by returning a { value, done } result from the
  326. // delegate iterator, or by modifying context.method and context.arg,
  327. // setting context.delegate to null, and returning the ContinueSentinel.
  328. function maybeInvokeDelegate(delegate, context) {
  329. var method = delegate.iterator[context.method];
  330. if (method === undefined$1) {
  331. // A .throw or .return when the delegate iterator has no .throw
  332. // method always terminates the yield* loop.
  333. context.delegate = null;
  334. if (context.method === "throw") {
  335. // Note: ["return"] must be used for ES3 parsing compatibility.
  336. if (delegate.iterator["return"]) {
  337. // If the delegate iterator has a return method, give it a
  338. // chance to clean up.
  339. context.method = "return";
  340. context.arg = undefined$1;
  341. maybeInvokeDelegate(delegate, context);
  342. if (context.method === "throw") {
  343. // If maybeInvokeDelegate(context) changed context.method from
  344. // "return" to "throw", let that override the TypeError below.
  345. return ContinueSentinel;
  346. }
  347. }
  348. context.method = "throw";
  349. context.arg = new TypeError(
  350. "The iterator does not provide a 'throw' method");
  351. }
  352. return ContinueSentinel;
  353. }
  354. var record = tryCatch(method, delegate.iterator, context.arg);
  355. if (record.type === "throw") {
  356. context.method = "throw";
  357. context.arg = record.arg;
  358. context.delegate = null;
  359. return ContinueSentinel;
  360. }
  361. var info = record.arg;
  362. if (! info) {
  363. context.method = "throw";
  364. context.arg = new TypeError("iterator result is not an object");
  365. context.delegate = null;
  366. return ContinueSentinel;
  367. }
  368. if (info.done) {
  369. // Assign the result of the finished delegate to the temporary
  370. // variable specified by delegate.resultName (see delegateYield).
  371. context[delegate.resultName] = info.value;
  372. // Resume execution at the desired location (see delegateYield).
  373. context.next = delegate.nextLoc;
  374. // If context.method was "throw" but the delegate handled the
  375. // exception, let the outer generator proceed normally. If
  376. // context.method was "next", forget context.arg since it has been
  377. // "consumed" by the delegate iterator. If context.method was
  378. // "return", allow the original .return call to continue in the
  379. // outer generator.
  380. if (context.method !== "return") {
  381. context.method = "next";
  382. context.arg = undefined$1;
  383. }
  384. } else {
  385. // Re-yield the result returned by the delegate method.
  386. return info;
  387. }
  388. // The delegate iterator is finished, so forget it and continue with
  389. // the outer generator.
  390. context.delegate = null;
  391. return ContinueSentinel;
  392. }
  393. // Define Generator.prototype.{next,throw,return} in terms of the
  394. // unified ._invoke helper method.
  395. defineIteratorMethods(Gp);
  396. define(Gp, toStringTagSymbol, "Generator");
  397. // A Generator should always return itself as the iterator object when the
  398. // @@iterator function is called on it. Some browsers' implementations of the
  399. // iterator prototype chain incorrectly implement this, causing the Generator
  400. // object to not be returned from this call. This ensures that doesn't happen.
  401. // See https://github.com/facebook/regenerator/issues/274 for more details.
  402. define(Gp, iteratorSymbol, function() {
  403. return this;
  404. });
  405. define(Gp, "toString", function() {
  406. return "[object Generator]";
  407. });
  408. function pushTryEntry(locs) {
  409. var entry = { tryLoc: locs[0] };
  410. if (1 in locs) {
  411. entry.catchLoc = locs[1];
  412. }
  413. if (2 in locs) {
  414. entry.finallyLoc = locs[2];
  415. entry.afterLoc = locs[3];
  416. }
  417. this.tryEntries.push(entry);
  418. }
  419. function resetTryEntry(entry) {
  420. var record = entry.completion || {};
  421. record.type = "normal";
  422. delete record.arg;
  423. entry.completion = record;
  424. }
  425. function Context(tryLocsList) {
  426. // The root entry object (effectively a try statement without a catch
  427. // or a finally block) gives us a place to store values thrown from
  428. // locations where there is no enclosing try statement.
  429. this.tryEntries = [{ tryLoc: "root" }];
  430. tryLocsList.forEach(pushTryEntry, this);
  431. this.reset(true);
  432. }
  433. exports.keys = function(object) {
  434. var keys = [];
  435. for (var key in object) {
  436. keys.push(key);
  437. }
  438. keys.reverse();
  439. // Rather than returning an object with a next method, we keep
  440. // things simple and return the next function itself.
  441. return function next() {
  442. while (keys.length) {
  443. var key = keys.pop();
  444. if (key in object) {
  445. next.value = key;
  446. next.done = false;
  447. return next;
  448. }
  449. }
  450. // To avoid creating an additional object, we just hang the .value
  451. // and .done properties off the next function object itself. This
  452. // also ensures that the minifier will not anonymize the function.
  453. next.done = true;
  454. return next;
  455. };
  456. };
  457. function values(iterable) {
  458. if (iterable) {
  459. var iteratorMethod = iterable[iteratorSymbol];
  460. if (iteratorMethod) {
  461. return iteratorMethod.call(iterable);
  462. }
  463. if (typeof iterable.next === "function") {
  464. return iterable;
  465. }
  466. if (!isNaN(iterable.length)) {
  467. var i = -1, next = function next() {
  468. while (++i < iterable.length) {
  469. if (hasOwn.call(iterable, i)) {
  470. next.value = iterable[i];
  471. next.done = false;
  472. return next;
  473. }
  474. }
  475. next.value = undefined$1;
  476. next.done = true;
  477. return next;
  478. };
  479. return next.next = next;
  480. }
  481. }
  482. // Return an iterator with no values.
  483. return { next: doneResult };
  484. }
  485. exports.values = values;
  486. function doneResult() {
  487. return { value: undefined$1, done: true };
  488. }
  489. Context.prototype = {
  490. constructor: Context,
  491. reset: function(skipTempReset) {
  492. this.prev = 0;
  493. this.next = 0;
  494. // Resetting context._sent for legacy support of Babel's
  495. // function.sent implementation.
  496. this.sent = this._sent = undefined$1;
  497. this.done = false;
  498. this.delegate = null;
  499. this.method = "next";
  500. this.arg = undefined$1;
  501. this.tryEntries.forEach(resetTryEntry);
  502. if (!skipTempReset) {
  503. for (var name in this) {
  504. // Not sure about the optimal order of these conditions:
  505. if (name.charAt(0) === "t" &&
  506. hasOwn.call(this, name) &&
  507. !isNaN(+name.slice(1))) {
  508. this[name] = undefined$1;
  509. }
  510. }
  511. }
  512. },
  513. stop: function() {
  514. this.done = true;
  515. var rootEntry = this.tryEntries[0];
  516. var rootRecord = rootEntry.completion;
  517. if (rootRecord.type === "throw") {
  518. throw rootRecord.arg;
  519. }
  520. return this.rval;
  521. },
  522. dispatchException: function(exception) {
  523. if (this.done) {
  524. throw exception;
  525. }
  526. var context = this;
  527. function handle(loc, caught) {
  528. record.type = "throw";
  529. record.arg = exception;
  530. context.next = loc;
  531. if (caught) {
  532. // If the dispatched exception was caught by a catch block,
  533. // then let that catch block handle the exception normally.
  534. context.method = "next";
  535. context.arg = undefined$1;
  536. }
  537. return !! caught;
  538. }
  539. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  540. var entry = this.tryEntries[i];
  541. var record = entry.completion;
  542. if (entry.tryLoc === "root") {
  543. // Exception thrown outside of any try block that could handle
  544. // it, so set the completion value of the entire function to
  545. // throw the exception.
  546. return handle("end");
  547. }
  548. if (entry.tryLoc <= this.prev) {
  549. var hasCatch = hasOwn.call(entry, "catchLoc");
  550. var hasFinally = hasOwn.call(entry, "finallyLoc");
  551. if (hasCatch && hasFinally) {
  552. if (this.prev < entry.catchLoc) {
  553. return handle(entry.catchLoc, true);
  554. } else if (this.prev < entry.finallyLoc) {
  555. return handle(entry.finallyLoc);
  556. }
  557. } else if (hasCatch) {
  558. if (this.prev < entry.catchLoc) {
  559. return handle(entry.catchLoc, true);
  560. }
  561. } else if (hasFinally) {
  562. if (this.prev < entry.finallyLoc) {
  563. return handle(entry.finallyLoc);
  564. }
  565. } else {
  566. throw new Error("try statement without catch or finally");
  567. }
  568. }
  569. }
  570. },
  571. abrupt: function(type, arg) {
  572. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  573. var entry = this.tryEntries[i];
  574. if (entry.tryLoc <= this.prev &&
  575. hasOwn.call(entry, "finallyLoc") &&
  576. this.prev < entry.finallyLoc) {
  577. var finallyEntry = entry;
  578. break;
  579. }
  580. }
  581. if (finallyEntry &&
  582. (type === "break" ||
  583. type === "continue") &&
  584. finallyEntry.tryLoc <= arg &&
  585. arg <= finallyEntry.finallyLoc) {
  586. // Ignore the finally entry if control is not jumping to a
  587. // location outside the try/catch block.
  588. finallyEntry = null;
  589. }
  590. var record = finallyEntry ? finallyEntry.completion : {};
  591. record.type = type;
  592. record.arg = arg;
  593. if (finallyEntry) {
  594. this.method = "next";
  595. this.next = finallyEntry.finallyLoc;
  596. return ContinueSentinel;
  597. }
  598. return this.complete(record);
  599. },
  600. complete: function(record, afterLoc) {
  601. if (record.type === "throw") {
  602. throw record.arg;
  603. }
  604. if (record.type === "break" ||
  605. record.type === "continue") {
  606. this.next = record.arg;
  607. } else if (record.type === "return") {
  608. this.rval = this.arg = record.arg;
  609. this.method = "return";
  610. this.next = "end";
  611. } else if (record.type === "normal" && afterLoc) {
  612. this.next = afterLoc;
  613. }
  614. return ContinueSentinel;
  615. },
  616. finish: function(finallyLoc) {
  617. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  618. var entry = this.tryEntries[i];
  619. if (entry.finallyLoc === finallyLoc) {
  620. this.complete(entry.completion, entry.afterLoc);
  621. resetTryEntry(entry);
  622. return ContinueSentinel;
  623. }
  624. }
  625. },
  626. "catch": function(tryLoc) {
  627. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  628. var entry = this.tryEntries[i];
  629. if (entry.tryLoc === tryLoc) {
  630. var record = entry.completion;
  631. if (record.type === "throw") {
  632. var thrown = record.arg;
  633. resetTryEntry(entry);
  634. }
  635. return thrown;
  636. }
  637. }
  638. // The context.catch method must only be called with a location
  639. // argument that corresponds to a known catch block.
  640. throw new Error("illegal catch attempt");
  641. },
  642. delegateYield: function(iterable, resultName, nextLoc) {
  643. this.delegate = {
  644. iterator: values(iterable),
  645. resultName: resultName,
  646. nextLoc: nextLoc
  647. };
  648. if (this.method === "next") {
  649. // Deliberately forget the last sent value so that we don't
  650. // accidentally pass it on to the delegate.
  651. this.arg = undefined$1;
  652. }
  653. return ContinueSentinel;
  654. }
  655. };
  656. // Regardless of whether this script is executing as a CommonJS module
  657. // or not, return the runtime object so that we can declare the variable
  658. // regeneratorRuntime in the outer scope, which allows this module to be
  659. // injected easily by `bin/regenerator --include-runtime script.js`.
  660. return exports;
  661. }(
  662. // If this script is executing as a CommonJS module, use module.exports
  663. // as the regeneratorRuntime namespace. Otherwise create a new empty
  664. // object. Either way, the resulting object will be used to initialize
  665. // the regeneratorRuntime variable at the top of this file.
  666. module.exports
  667. ));
  668. try {
  669. regeneratorRuntime = runtime;
  670. } catch (accidentalStrictMode) {
  671. // This module should not be running in strict mode, so the above
  672. // assignment should always work unless something is misconfigured. Just
  673. // in case runtime.js accidentally runs in strict mode, in modern engines
  674. // we can explicitly access globalThis. In older engines we can escape
  675. // strict mode using a global Function call. This could conceivably fail
  676. // if a Content Security Policy forbids using Function, but in that case
  677. // the proper solution is to fix the accidental strict mode problem. If
  678. // you've misconfigured your bundler to force strict mode and applied a
  679. // CSP to forbid Function, and you're not willing to fix either of those
  680. // problems, please detail your unique predicament in a GitHub issue.
  681. if (typeof globalThis === "object") {
  682. globalThis.regeneratorRuntime = runtime;
  683. } else {
  684. Function("r", "regeneratorRuntime = r")(runtime);
  685. }
  686. }
  687. });
  688. var regenerator = runtime_1;
  689. function _classCallCheck(instance, Constructor) {
  690. if (!(instance instanceof Constructor)) {
  691. throw new TypeError("Cannot call a class as a function");
  692. }
  693. }
  694. function _defineProperties(target, props) {
  695. for (var i = 0; i < props.length; i++) {
  696. var descriptor = props[i];
  697. descriptor.enumerable = descriptor.enumerable || false;
  698. descriptor.configurable = true;
  699. if ("value" in descriptor) descriptor.writable = true;
  700. Object.defineProperty(target, descriptor.key, descriptor);
  701. }
  702. }
  703. function _createClass(Constructor, protoProps, staticProps) {
  704. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  705. if (staticProps) _defineProperties(Constructor, staticProps);
  706. Object.defineProperty(Constructor, "prototype", {
  707. writable: false
  708. });
  709. return Constructor;
  710. }
  711. var Codes = {
  712. Success: 0,
  713. Param: 1001,
  714. Internal: 1002,
  715. Timeout: 1003,
  716. Authentication: 1004,
  717. TokenExpired: 1005,
  718. Unsupported: 1006,
  719. InitNetworkTimeout: 1007,
  720. InitDecoderTimeout: 1008,
  721. InitConfigTimeout: 1009,
  722. InitEngineTimeout: 1010,
  723. InitEngine: 1011,
  724. ActionBlocked: 1012,
  725. PreloadCanceled: 1013,
  726. FrequencyLimit: 1014,
  727. UsersUpperLimit: 2e3,
  728. RoomsUpperLimit: 2001,
  729. ServerParam: 2002,
  730. LackOfToken: 2003,
  731. LoginFailed: 2004,
  732. VerifyServiceDown: 2005,
  733. CreateSessionFailed: 2006,
  734. RtcConnection: 2008,
  735. DoActionFailed: 2009,
  736. StateSyncFailed: 2010,
  737. BroadcastFailed: 2011,
  738. DataAbnormal: 2012,
  739. GetOnVehicle: 2015,
  740. RepeatLogin: 2017,
  741. RoomDoseNotExist: 2018,
  742. TicketExpire: 2019,
  743. ServerRateLimit: 2020,
  744. DoActionBlocked: 2333,
  745. ActionMaybeDelay: 2334,
  746. ActionResponseTimeout: 2999
  747. };
  748. function _setPrototypeOf(o, p) {
  749. _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
  750. o.__proto__ = p;
  751. return o;
  752. };
  753. return _setPrototypeOf(o, p);
  754. }
  755. function _inherits(subClass, superClass) {
  756. if (typeof superClass !== "function" && superClass !== null) {
  757. throw new TypeError("Super expression must either be null or a function");
  758. }
  759. subClass.prototype = Object.create(superClass && superClass.prototype, {
  760. constructor: {
  761. value: subClass,
  762. writable: true,
  763. configurable: true
  764. }
  765. });
  766. Object.defineProperty(subClass, "prototype", {
  767. writable: false
  768. });
  769. if (superClass) _setPrototypeOf(subClass, superClass);
  770. }
  771. function _typeof(obj) {
  772. "@babel/helpers - typeof";
  773. return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
  774. return typeof obj;
  775. } : function (obj) {
  776. return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  777. }, _typeof(obj);
  778. }
  779. function _assertThisInitialized(self) {
  780. if (self === void 0) {
  781. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  782. }
  783. return self;
  784. }
  785. function _possibleConstructorReturn(self, call) {
  786. if (call && (_typeof(call) === "object" || typeof call === "function")) {
  787. return call;
  788. } else if (call !== void 0) {
  789. throw new TypeError("Derived constructors may only return object or undefined");
  790. }
  791. return _assertThisInitialized(self);
  792. }
  793. function _getPrototypeOf(o) {
  794. _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
  795. return o.__proto__ || Object.getPrototypeOf(o);
  796. };
  797. return _getPrototypeOf(o);
  798. }
  799. function _isNativeFunction(fn) {
  800. return Function.toString.call(fn).indexOf("[native code]") !== -1;
  801. }
  802. function _isNativeReflectConstruct$P() {
  803. if (typeof Reflect === "undefined" || !Reflect.construct) return false;
  804. if (Reflect.construct.sham) return false;
  805. if (typeof Proxy === "function") return true;
  806. try {
  807. Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
  808. return true;
  809. } catch (e) {
  810. return false;
  811. }
  812. }
  813. function _construct(Parent, args, Class) {
  814. if (_isNativeReflectConstruct$P()) {
  815. _construct = Reflect.construct;
  816. } else {
  817. _construct = function _construct(Parent, args, Class) {
  818. var a = [null];
  819. a.push.apply(a, args);
  820. var Constructor = Function.bind.apply(Parent, a);
  821. var instance = new Constructor();
  822. if (Class) _setPrototypeOf(instance, Class.prototype);
  823. return instance;
  824. };
  825. }
  826. return _construct.apply(null, arguments);
  827. }
  828. function _wrapNativeSuper(Class) {
  829. var _cache = typeof Map === "function" ? new Map() : undefined;
  830. _wrapNativeSuper = function _wrapNativeSuper(Class) {
  831. if (Class === null || !_isNativeFunction(Class)) return Class;
  832. if (typeof Class !== "function") {
  833. throw new TypeError("Super expression must either be null or a function");
  834. }
  835. if (typeof _cache !== "undefined") {
  836. if (_cache.has(Class)) return _cache.get(Class);
  837. _cache.set(Class, Wrapper);
  838. }
  839. function Wrapper() {
  840. return _construct(Class, arguments, _getPrototypeOf(this).constructor);
  841. }
  842. Wrapper.prototype = Object.create(Class.prototype, {
  843. constructor: {
  844. value: Wrapper,
  845. enumerable: false,
  846. writable: true,
  847. configurable: true
  848. }
  849. });
  850. return _setPrototypeOf(Wrapper, Class);
  851. };
  852. return _wrapNativeSuper(Class);
  853. }
  854. function _createSuper$O(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$O(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  855. function _isNativeReflectConstruct$O() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  856. var XverseError = /*#__PURE__*/function (_Error) {
  857. _inherits(XverseError, _Error);
  858. var _super = _createSuper$O(XverseError);
  859. function XverseError(e, t) {
  860. var _this;
  861. _classCallCheck(this, XverseError);
  862. _this = _super.call(this, t);
  863. _this.code = e;
  864. return _this;
  865. }
  866. _createClass(XverseError, [{
  867. key: "toJSON",
  868. value: function toJSON() {
  869. return {
  870. code: this.code,
  871. message: this.message
  872. };
  873. }
  874. }, {
  875. key: "toString",
  876. value: function toString() {
  877. if (Object(this) !== this) throw new TypeError();
  878. var t = this.name;
  879. t = t === void 0 ? "Error" : String(t);
  880. var r = this.message;
  881. r = r === void 0 ? "" : String(r);
  882. var n = this.code;
  883. return r = n === void 0 ? r : n + "," + r, t === "" ? r : r === "" ? t : t + ": " + r;
  884. }
  885. }]);
  886. return XverseError;
  887. }( /*#__PURE__*/_wrapNativeSuper(Error));
  888. function _createSuper$N(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$N(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  889. function _isNativeReflectConstruct$N() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  890. var ParamError$1 = /*#__PURE__*/function (_XverseError) {
  891. _inherits(ParamError, _XverseError);
  892. var _super = _createSuper$N(ParamError);
  893. function ParamError(e) {
  894. _classCallCheck(this, ParamError);
  895. return _super.call(this, 1001, e || "\u53C2\u6570\u9519\u8BEF");
  896. }
  897. return _createClass(ParamError);
  898. }(XverseError);
  899. function _createSuper$M(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$M(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  900. function _isNativeReflectConstruct$M() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  901. var InternalError = /*#__PURE__*/function (_XverseError) {
  902. _inherits(InternalError, _XverseError);
  903. var _super = _createSuper$M(InternalError);
  904. function InternalError(e) {
  905. _classCallCheck(this, InternalError);
  906. return _super.call(this, 1002, e || "\u5185\u90E8\u9519\u8BEF");
  907. }
  908. return _createClass(InternalError);
  909. }(XverseError);
  910. function _createSuper$L(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$L(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  911. function _isNativeReflectConstruct$L() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  912. var TimeoutError = /*#__PURE__*/function (_XverseError) {
  913. _inherits(TimeoutError, _XverseError);
  914. var _super = _createSuper$L(TimeoutError);
  915. function TimeoutError(e) {
  916. _classCallCheck(this, TimeoutError);
  917. return _super.call(this, 1003, e || "\u8D85\u65F6");
  918. }
  919. return _createClass(TimeoutError);
  920. }(XverseError);
  921. function _createSuper$K(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$K(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  922. function _isNativeReflectConstruct$K() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  923. var AuthenticationError$1 = /*#__PURE__*/function (_XverseError) {
  924. _inherits(AuthenticationError, _XverseError);
  925. var _super = _createSuper$K(AuthenticationError);
  926. function AuthenticationError(e) {
  927. _classCallCheck(this, AuthenticationError);
  928. return _super.call(this, 1004, e || "\u9274\u6743\u5931\u8D25");
  929. }
  930. return _createClass(AuthenticationError);
  931. }(XverseError);
  932. function _createSuper$J(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$J(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  933. function _isNativeReflectConstruct$J() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  934. var TokenExpiredError$1 = /*#__PURE__*/function (_XverseError) {
  935. _inherits(TokenExpiredError, _XverseError);
  936. var _super = _createSuper$J(TokenExpiredError);
  937. function TokenExpiredError(e) {
  938. _classCallCheck(this, TokenExpiredError);
  939. return _super.call(this, 1005, e || "Token \u5DF2\u8FC7\u671F");
  940. }
  941. return _createClass(TokenExpiredError);
  942. }(XverseError);
  943. function _createSuper$I(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$I(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  944. function _isNativeReflectConstruct$I() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  945. var UnsupportedError$1 = /*#__PURE__*/function (_XverseError) {
  946. _inherits(UnsupportedError, _XverseError);
  947. var _super = _createSuper$I(UnsupportedError);
  948. function UnsupportedError(e) {
  949. _classCallCheck(this, UnsupportedError);
  950. return _super.call(this, 1006, e || "\u624B\u673A\u7CFB\u7EDF\u4E0D\u652F\u6301XVerse");
  951. }
  952. return _createClass(UnsupportedError);
  953. }(XverseError);
  954. function _createSuper$H(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$H(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  955. function _isNativeReflectConstruct$H() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  956. var InitNetworkTimeoutError = /*#__PURE__*/function (_XverseError) {
  957. _inherits(InitNetworkTimeoutError, _XverseError);
  958. var _super = _createSuper$H(InitNetworkTimeoutError);
  959. function InitNetworkTimeoutError(e) {
  960. _classCallCheck(this, InitNetworkTimeoutError);
  961. return _super.call(this, 1007, e || "\u7F51\u7EDC\u521D\u59CB\u5316\u8D85\u65F6");
  962. }
  963. return _createClass(InitNetworkTimeoutError);
  964. }(XverseError);
  965. function _createSuper$G(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$G(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  966. function _isNativeReflectConstruct$G() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  967. var InitDecoderTimeoutError = /*#__PURE__*/function (_XverseError) {
  968. _inherits(InitDecoderTimeoutError, _XverseError);
  969. var _super = _createSuper$G(InitDecoderTimeoutError);
  970. function InitDecoderTimeoutError(e) {
  971. _classCallCheck(this, InitDecoderTimeoutError);
  972. return _super.call(this, 1008, e || "Decoder \u521D\u59CB\u5316\u8D85\u65F6");
  973. }
  974. return _createClass(InitDecoderTimeoutError);
  975. }(XverseError);
  976. function _createSuper$F(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$F(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  977. function _isNativeReflectConstruct$F() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  978. var InitConfigTimeoutError = /*#__PURE__*/function (_XverseError) {
  979. _inherits(InitConfigTimeoutError, _XverseError);
  980. var _super = _createSuper$F(InitConfigTimeoutError);
  981. function InitConfigTimeoutError(e) {
  982. _classCallCheck(this, InitConfigTimeoutError);
  983. return _super.call(this, 1009, e || "\u914D\u7F6E\u521D\u59CB\u5316\u8D85\u65F6");
  984. }
  985. return _createClass(InitConfigTimeoutError);
  986. }(XverseError);
  987. function _createSuper$E(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$E(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  988. function _isNativeReflectConstruct$E() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  989. var InitEngineTimeoutError = /*#__PURE__*/function (_XverseError) {
  990. _inherits(InitEngineTimeoutError, _XverseError);
  991. var _super = _createSuper$E(InitEngineTimeoutError);
  992. function InitEngineTimeoutError(e) {
  993. _classCallCheck(this, InitEngineTimeoutError);
  994. return _super.call(this, 1010, e || "\u5F15\u64CE\u521D\u59CB\u5316\u8D85\u65F6");
  995. }
  996. return _createClass(InitEngineTimeoutError);
  997. }(XverseError);
  998. function _createSuper$D(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$D(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  999. function _isNativeReflectConstruct$D() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  1000. var InitEngineError = /*#__PURE__*/function (_XverseError) {
  1001. _inherits(InitEngineError, _XverseError);
  1002. var _super = _createSuper$D(InitEngineError);
  1003. function InitEngineError(e) {
  1004. _classCallCheck(this, InitEngineError);
  1005. return _super.call(this, 1011, e || "\u5F15\u64CE\u521D\u59CB\u5316\u9519\u8BEF");
  1006. }
  1007. return _createClass(InitEngineError);
  1008. }(XverseError);
  1009. function _createSuper$C(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$C(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  1010. function _isNativeReflectConstruct$C() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  1011. var ActionBlockedError = /*#__PURE__*/function (_XverseError) {
  1012. _inherits(ActionBlockedError, _XverseError);
  1013. var _super = _createSuper$C(ActionBlockedError);
  1014. function ActionBlockedError(e) {
  1015. _classCallCheck(this, ActionBlockedError);
  1016. return _super.call(this, 1012, e || "\u52A8\u4F5C\u88AB\u5C4F\u853D");
  1017. }
  1018. return _createClass(ActionBlockedError);
  1019. }(XverseError);
  1020. function _createSuper$B(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$B(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  1021. function _isNativeReflectConstruct$B() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  1022. var PreloadCanceledError$1 = /*#__PURE__*/function (_XverseError) {
  1023. _inherits(PreloadCanceledError, _XverseError);
  1024. var _super = _createSuper$B(PreloadCanceledError);
  1025. function PreloadCanceledError(e) {
  1026. _classCallCheck(this, PreloadCanceledError);
  1027. return _super.call(this, 1013, e || "\u9884\u52A0\u8F7D\u88AB\u53D6\u6D88");
  1028. }
  1029. return _createClass(PreloadCanceledError);
  1030. }(XverseError);
  1031. function _createSuper$A(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$A(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  1032. function _isNativeReflectConstruct$A() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  1033. var FrequencyLimitError$1 = /*#__PURE__*/function (_XverseError) {
  1034. _inherits(FrequencyLimitError, _XverseError);
  1035. var _super = _createSuper$A(FrequencyLimitError);
  1036. function FrequencyLimitError(e) {
  1037. _classCallCheck(this, FrequencyLimitError);
  1038. return _super.call(this, 1014, e || "\u9891\u7387\u9650\u5236");
  1039. }
  1040. return _createClass(FrequencyLimitError);
  1041. }(XverseError);
  1042. function _createSuper$z(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$z(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  1043. function _isNativeReflectConstruct$z() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  1044. var UsersUpperLimitError = /*#__PURE__*/function (_XverseError) {
  1045. _inherits(UsersUpperLimitError, _XverseError);
  1046. var _super = _createSuper$z(UsersUpperLimitError);
  1047. function UsersUpperLimitError(e) {
  1048. _classCallCheck(this, UsersUpperLimitError);
  1049. return _super.call(this, 2e3, e || "\u76F4\u64AD\u95F4\u4EBA\u6570\u5DF2\u6EE1");
  1050. }
  1051. return _createClass(UsersUpperLimitError);
  1052. }(XverseError);
  1053. function _createSuper$y(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$y(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  1054. function _isNativeReflectConstruct$y() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  1055. var RoomsUpperLimitError = /*#__PURE__*/function (_XverseError) {
  1056. _inherits(RoomsUpperLimitError, _XverseError);
  1057. var _super = _createSuper$y(RoomsUpperLimitError);
  1058. function RoomsUpperLimitError(e) {
  1059. _classCallCheck(this, RoomsUpperLimitError);
  1060. return _super.call(this, 2001, e || "\u623F\u95F4\u5230\u8FBE\u4E0A\u9650");
  1061. }
  1062. return _createClass(RoomsUpperLimitError);
  1063. }(XverseError);
  1064. function _createSuper$x(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$x(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  1065. function _isNativeReflectConstruct$x() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  1066. var ServerParamError = /*#__PURE__*/function (_XverseError) {
  1067. _inherits(ServerParamError, _XverseError);
  1068. var _super = _createSuper$x(ServerParamError);
  1069. function ServerParamError(e) {
  1070. _classCallCheck(this, ServerParamError);
  1071. return _super.call(this, 2002, e || "\u670D\u52A1\u5668\u53C2\u6570\u9519\u8BEF");
  1072. }
  1073. return _createClass(ServerParamError);
  1074. }(XverseError);
  1075. function _createSuper$w(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$w(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  1076. function _isNativeReflectConstruct$w() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  1077. var LackOfTokenError = /*#__PURE__*/function (_XverseError) {
  1078. _inherits(LackOfTokenError, _XverseError);
  1079. var _super = _createSuper$w(LackOfTokenError);
  1080. function LackOfTokenError(e) {
  1081. _classCallCheck(this, LackOfTokenError);
  1082. return _super.call(this, 2003, e || "\u7F3A\u5C11 Token");
  1083. }
  1084. return _createClass(LackOfTokenError);
  1085. }(XverseError);
  1086. function _createSuper$v(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$v(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  1087. function _isNativeReflectConstruct$v() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  1088. var LoginFailedError = /*#__PURE__*/function (_XverseError) {
  1089. _inherits(LoginFailedError, _XverseError);
  1090. var _super = _createSuper$v(LoginFailedError);
  1091. function LoginFailedError(e) {
  1092. _classCallCheck(this, LoginFailedError);
  1093. return _super.call(this, 2004, e || "\u8FDB\u5165\u623F\u95F4\u5931\u8D25");
  1094. }
  1095. return _createClass(LoginFailedError);
  1096. }(XverseError);
  1097. function _createSuper$u(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$u(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  1098. function _isNativeReflectConstruct$u() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  1099. var VerifyServiceDownError = /*#__PURE__*/function (_XverseError) {
  1100. _inherits(VerifyServiceDownError, _XverseError);
  1101. var _super = _createSuper$u(VerifyServiceDownError);
  1102. function VerifyServiceDownError(e) {
  1103. _classCallCheck(this, VerifyServiceDownError);
  1104. return _super.call(this, 2005, e || "\u9274\u6743\u670D\u52A1\u5F02\u5E38");
  1105. }
  1106. return _createClass(VerifyServiceDownError);
  1107. }(XverseError);
  1108. function _createSuper$t(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$t(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  1109. function _isNativeReflectConstruct$t() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  1110. var CreateSessionFailedError = /*#__PURE__*/function (_XverseError) {
  1111. _inherits(CreateSessionFailedError, _XverseError);
  1112. var _super = _createSuper$t(CreateSessionFailedError);
  1113. function CreateSessionFailedError(e) {
  1114. _classCallCheck(this, CreateSessionFailedError);
  1115. return _super.call(this, 2006, e || "\u521B\u5EFA session \u5931\u8D25");
  1116. }
  1117. return _createClass(CreateSessionFailedError);
  1118. }(XverseError);
  1119. function _createSuper$s(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$s(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  1120. function _isNativeReflectConstruct$s() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  1121. var RtcConnectionError = /*#__PURE__*/function (_XverseError) {
  1122. _inherits(RtcConnectionError, _XverseError);
  1123. var _super = _createSuper$s(RtcConnectionError);
  1124. function RtcConnectionError(e) {
  1125. _classCallCheck(this, RtcConnectionError);
  1126. return _super.call(this, 2008, e || "RTC\u5EFA\u8054\u5931\u8D25");
  1127. }
  1128. return _createClass(RtcConnectionError);
  1129. }(XverseError);
  1130. function _createSuper$r(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$r(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  1131. function _isNativeReflectConstruct$r() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  1132. var DoActionFailedError = /*#__PURE__*/function (_XverseError) {
  1133. _inherits(DoActionFailedError, _XverseError);
  1134. var _super = _createSuper$r(DoActionFailedError);
  1135. function DoActionFailedError(e) {
  1136. _classCallCheck(this, DoActionFailedError);
  1137. return _super.call(this, 2009, e || "\u52A8\u4F5C\u6267\u884C\u5931\u8D25");
  1138. }
  1139. return _createClass(DoActionFailedError);
  1140. }(XverseError);
  1141. function _createSuper$q(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$q(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  1142. function _isNativeReflectConstruct$q() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  1143. var StateSyncFailedError = /*#__PURE__*/function (_XverseError) {
  1144. _inherits(StateSyncFailedError, _XverseError);
  1145. var _super = _createSuper$q(StateSyncFailedError);
  1146. function StateSyncFailedError(e) {
  1147. _classCallCheck(this, StateSyncFailedError);
  1148. return _super.call(this, 2010, e || "\u72B6\u6001\u540C\u6B65\u5931\u8D25");
  1149. }
  1150. return _createClass(StateSyncFailedError);
  1151. }(XverseError);
  1152. function _createSuper$p(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$p(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  1153. function _isNativeReflectConstruct$p() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  1154. var BroadcastFailedError = /*#__PURE__*/function (_XverseError) {
  1155. _inherits(BroadcastFailedError, _XverseError);
  1156. var _super = _createSuper$p(BroadcastFailedError);
  1157. function BroadcastFailedError(e) {
  1158. _classCallCheck(this, BroadcastFailedError);
  1159. return _super.call(this, 2011, e || "\u5E7F\u64AD\u63A5\u53E3\u63A5\u53E3\u5F02\u5E38");
  1160. }
  1161. return _createClass(BroadcastFailedError);
  1162. }(XverseError);
  1163. function _createSuper$o(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$o(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  1164. function _isNativeReflectConstruct$o() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  1165. var DataAbnormalError = /*#__PURE__*/function (_XverseError) {
  1166. _inherits(DataAbnormalError, _XverseError);
  1167. var _super = _createSuper$o(DataAbnormalError);
  1168. function DataAbnormalError(e) {
  1169. _classCallCheck(this, DataAbnormalError);
  1170. return _super.call(this, 2012, e || "\u6570\u636E\u5F02\u5E38");
  1171. }
  1172. return _createClass(DataAbnormalError);
  1173. }(XverseError);
  1174. function _createSuper$n(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$n(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  1175. function _isNativeReflectConstruct$n() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  1176. var GetOnVehicleError = /*#__PURE__*/function (_XverseError) {
  1177. _inherits(GetOnVehicleError, _XverseError);
  1178. var _super = _createSuper$n(GetOnVehicleError);
  1179. function GetOnVehicleError(e) {
  1180. _classCallCheck(this, GetOnVehicleError);
  1181. return _super.call(this, 2015, e || "\u4E0A\u8F7D\u5177\u5931\u8D25\u9700\u8981\u9884\u7EA6");
  1182. }
  1183. return _createClass(GetOnVehicleError);
  1184. }(XverseError);
  1185. function _createSuper$m(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$m(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  1186. function _isNativeReflectConstruct$m() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  1187. var RepeatLoginError = /*#__PURE__*/function (_XverseError) {
  1188. _inherits(RepeatLoginError, _XverseError);
  1189. var _super = _createSuper$m(RepeatLoginError);
  1190. function RepeatLoginError(e) {
  1191. _classCallCheck(this, RepeatLoginError);
  1192. return _super.call(this, 2017, e || "\u5F02\u5730\u767B\u5F55");
  1193. }
  1194. return _createClass(RepeatLoginError);
  1195. }(XverseError);
  1196. function _createSuper$l(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$l(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  1197. function _isNativeReflectConstruct$l() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  1198. var RoomDoseNotExistError = /*#__PURE__*/function (_XverseError) {
  1199. _inherits(RoomDoseNotExistError, _XverseError);
  1200. var _super = _createSuper$l(RoomDoseNotExistError);
  1201. function RoomDoseNotExistError(e) {
  1202. _classCallCheck(this, RoomDoseNotExistError);
  1203. return _super.call(this, 2018, e || "\u6307\u5B9A\u623F\u95F4\u4E0D\u5B58\u5728");
  1204. }
  1205. return _createClass(RoomDoseNotExistError);
  1206. }(XverseError);
  1207. function _createSuper$k(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$k(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  1208. function _isNativeReflectConstruct$k() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  1209. var TicketExpireError = /*#__PURE__*/function (_XverseError) {
  1210. _inherits(TicketExpireError, _XverseError);
  1211. var _super = _createSuper$k(TicketExpireError);
  1212. function TicketExpireError(e) {
  1213. _classCallCheck(this, TicketExpireError);
  1214. return _super.call(this, 2019, e || "\u7968\u636E\u8FC7\u671F");
  1215. }
  1216. return _createClass(TicketExpireError);
  1217. }(XverseError);
  1218. function _createSuper$j(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$j(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  1219. function _isNativeReflectConstruct$j() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  1220. var ServerRateLimitError = /*#__PURE__*/function (_XverseError) {
  1221. _inherits(ServerRateLimitError, _XverseError);
  1222. var _super = _createSuper$j(ServerRateLimitError);
  1223. function ServerRateLimitError(e) {
  1224. _classCallCheck(this, ServerRateLimitError);
  1225. return _super.call(this, 2020, e || "\u670D\u52A1\u7AEF\u9891\u7387\u9650\u5236");
  1226. }
  1227. return _createClass(ServerRateLimitError);
  1228. }(XverseError);
  1229. function _createSuper$i(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$i(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  1230. function _isNativeReflectConstruct$i() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  1231. var DoActionBlockedError = /*#__PURE__*/function (_XverseError) {
  1232. _inherits(DoActionBlockedError, _XverseError);
  1233. var _super = _createSuper$i(DoActionBlockedError);
  1234. function DoActionBlockedError(e) {
  1235. _classCallCheck(this, DoActionBlockedError);
  1236. return _super.call(this, 2333, e || "\u52A8\u4F5C\u88AB\u5C4F\u853D");
  1237. }
  1238. return _createClass(DoActionBlockedError);
  1239. }(XverseError);
  1240. function _createSuper$h(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$h(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  1241. function _isNativeReflectConstruct$h() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  1242. var ActionMaybeDelayError = /*#__PURE__*/function (_XverseError) {
  1243. _inherits(ActionMaybeDelayError, _XverseError);
  1244. var _super = _createSuper$h(ActionMaybeDelayError);
  1245. function ActionMaybeDelayError(e) {
  1246. _classCallCheck(this, ActionMaybeDelayError);
  1247. return _super.call(this, 2334, e || "\u52A8\u4F5C\u53EF\u80FD\u5EF6\u8FDF\u6267\u884C");
  1248. }
  1249. return _createClass(ActionMaybeDelayError);
  1250. }(XverseError);
  1251. function _createSuper$g(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$g(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  1252. function _isNativeReflectConstruct$g() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  1253. var ActionResponseTimeoutError$1 = /*#__PURE__*/function (_XverseError) {
  1254. _inherits(ActionResponseTimeoutError, _XverseError);
  1255. var _super = _createSuper$g(ActionResponseTimeoutError);
  1256. function ActionResponseTimeoutError(e) {
  1257. _classCallCheck(this, ActionResponseTimeoutError);
  1258. return _super.call(this, 2999, e || "action\u56DE\u5305\u8D85\u65F6");
  1259. }
  1260. return _createClass(ActionResponseTimeoutError);
  1261. }(XverseError);
  1262. var CodeErrorMap = {
  1263. 1001: ParamError$1,
  1264. 1002: InternalError,
  1265. 1003: TimeoutError,
  1266. 1004: AuthenticationError$1,
  1267. 1005: TokenExpiredError$1,
  1268. 1006: UnsupportedError$1,
  1269. 1007: InitNetworkTimeoutError,
  1270. 1008: InitDecoderTimeoutError,
  1271. 1009: InitConfigTimeoutError,
  1272. 1010: InitEngineTimeoutError,
  1273. 1011: InitEngineError,
  1274. 1012: ActionBlockedError,
  1275. 1013: PreloadCanceledError$1,
  1276. 1014: FrequencyLimitError$1,
  1277. 2e3: UsersUpperLimitError,
  1278. 2001: RoomsUpperLimitError,
  1279. 2002: ServerParamError,
  1280. 2003: LackOfTokenError,
  1281. 2004: LoginFailedError,
  1282. 2005: VerifyServiceDownError,
  1283. 2006: CreateSessionFailedError,
  1284. 2008: RtcConnectionError,
  1285. 2009: DoActionFailedError,
  1286. 2010: StateSyncFailedError,
  1287. 2011: BroadcastFailedError,
  1288. 2012: DataAbnormalError,
  1289. 2015: GetOnVehicleError,
  1290. 2017: RepeatLoginError,
  1291. 2018: RoomDoseNotExistError,
  1292. 2019: TicketExpireError,
  1293. 2020: ServerRateLimitError,
  1294. 2333: DoActionBlockedError,
  1295. 2334: ActionMaybeDelayError,
  1296. 2999: ActionResponseTimeoutError$1
  1297. };
  1298. var util = {
  1299. uuid() {
  1300. return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (i) {
  1301. var e = Math.random() * 16 | 0;
  1302. return (i === "x" ? e : e & 3 | 8).toString(16);
  1303. });
  1304. },
  1305. getFormattedDate(i) {
  1306. var e = i.getMonth() + 1,
  1307. t = i.getDate(),
  1308. r = i.getHours(),
  1309. n = i.getMinutes(),
  1310. o = i.getSeconds(),
  1311. a = i.getMilliseconds(),
  1312. s = (e < 10 ? "0" : "") + e,
  1313. l = (t < 10 ? "0" : "") + t,
  1314. u = (r < 10 ? "0" : "") + r,
  1315. c = (n < 10 ? "0" : "") + n,
  1316. h = (o < 10 ? "0" : "") + o;
  1317. return i.getFullYear() + "-" + s + "-" + l + " " + u + ":" + c + ":" + h + "." + a;
  1318. },
  1319. createInstance(i) {
  1320. var e = new Axios(i),
  1321. t = bind(Axios.prototype.request, e);
  1322. return utils.extend(t, Axios.prototype, e), utils.extend(t, e), t.create = function (n) {
  1323. return createInstance(mergeConfig(i, n));
  1324. }, t;
  1325. },
  1326. mapLimit(i, e, t) {
  1327. return new Promise(function (r, n) {
  1328. var o = i.length;
  1329. var a = e - 1,
  1330. s = 0;
  1331. var l = function l(u) {
  1332. u.forEach(function (c) {
  1333. t(c).then(function () {
  1334. if (s++, s === o) {
  1335. r();
  1336. return;
  1337. }
  1338. a++;
  1339. var h = i[a];
  1340. h && l([h]);
  1341. }, function (h) {
  1342. n(h);
  1343. });
  1344. });
  1345. };
  1346. l(i.slice(0, e));
  1347. });
  1348. },
  1349. isWebAssemblySupported() {
  1350. try {
  1351. if (typeof WebAssembly == "object" && typeof WebAssembly.instantiate == "function") {
  1352. var i = new WebAssembly.Module(Uint8Array.of(0, 97, 115, 109, 1, 0, 0, 0));
  1353. if (i instanceof WebAssembly.Module) return new WebAssembly.Instance(i) instanceof WebAssembly.Instance;
  1354. }
  1355. } catch (_unused) {}
  1356. return console.log("wasm is not supported"), !1;
  1357. },
  1358. isSupported() {
  1359. return typeof RTCPeerConnection == "function" && this.isWebAssemblySupported();
  1360. },
  1361. objectParseFloat(i) {
  1362. var e = {};
  1363. return i && Object.keys(i).forEach(function (t) {
  1364. e[t] = parseFloat(i[t]);
  1365. }), e;
  1366. },
  1367. getRandomItem(i) {
  1368. i.length === 0 ? null : i[Math.floor(Math.random() * i.length)];
  1369. },
  1370. getErrorByCode(i) {
  1371. if (i === Codes.Success) return InternalError;
  1372. var e = CodeErrorMap[i];
  1373. return e || console.warn("unkown code", i), e || InternalError;
  1374. }
  1375. };
  1376. function _createSuper$f(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$f(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  1377. function _isNativeReflectConstruct$f() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  1378. var Reporter = /*#__PURE__*/function (_EventEmitter) {
  1379. _inherits(Reporter, _EventEmitter);
  1380. var _super = _createSuper$f(Reporter);
  1381. function Reporter() {
  1382. var _this;
  1383. _classCallCheck(this, Reporter);
  1384. _this = _super.call(this);
  1385. _this._header = {};
  1386. _this._body = {};
  1387. _this._queue = [];
  1388. _this._disabled = !1;
  1389. _this._interval = null;
  1390. _this._reportUrl = null;
  1391. _this.isDocumentLoaded = function () {
  1392. return document.readyState === "complete";
  1393. };
  1394. _this._header.logModuleId = REPORT_MODULE_TYPE, _this._header.url = location.href, _this._header.enviroment = ENV, _this._header.networkType = window.navigator.connection ? window.navigator.connection.type : "unknown", _this._interval = window.setInterval(function () {
  1395. _this._flushReport();
  1396. }, 10 * 1e3);
  1397. return _this;
  1398. }
  1399. _createClass(Reporter, [{
  1400. key: "disable",
  1401. value: function disable() {
  1402. this._disabled = !0, this._interval && window.clearInterval(this._interval);
  1403. }
  1404. }, {
  1405. key: "updateHeader",
  1406. value: function updateHeader(e) {
  1407. Object.assign(this._header, e);
  1408. }
  1409. }, {
  1410. key: "updateBody",
  1411. value: function updateBody(e) {
  1412. Object.assign(this._body, e);
  1413. }
  1414. }, {
  1415. key: "updateReportUrl",
  1416. value: function updateReportUrl(e) {
  1417. this._reportUrl = e;
  1418. }
  1419. }, {
  1420. key: "report",
  1421. value: function report(e, t, r) {
  1422. var _this2 = this;
  1423. if (this._disabled) return;
  1424. r || (r = {});
  1425. var _r = r,
  1426. n = _r.immediate,
  1427. o = _r.sampleRate;
  1428. if (o && o > Math.random()) return;
  1429. this.updateBody({
  1430. logTime: util.getFormattedDate(new Date()),
  1431. logTimestamp: Date.now()
  1432. });
  1433. var a = function a(s) {
  1434. var l = oe(le(oe({}, _this2._body), {
  1435. type: e
  1436. }), s);
  1437. _this2._queue.push(l), e === "measurement" && _this2.emit("report", s);
  1438. };
  1439. Array.isArray(t) ? t.forEach(function (s) {
  1440. return a(s);
  1441. }) : a(t), (n || this._queue.length >= REPORT_NUM_PER_REQUEST) && this._flushReport();
  1442. }
  1443. }, {
  1444. key: "_flushReport",
  1445. value: function _flushReport() {
  1446. if (this._disabled || !this._queue.length || !this.isDocumentLoaded()) return;
  1447. var e = {
  1448. header: this._header,
  1449. body: this._queue.splice(0, REPORT_NUM_PER_REQUEST)
  1450. };
  1451. this._post(e);
  1452. }
  1453. }, {
  1454. key: "_post",
  1455. value: function _post(e) {
  1456. var t = this._reportUrl || REPORT_URL.DEV;
  1457. return new Promise(function (r, n) {
  1458. var o = new XMLHttpRequest();
  1459. o.open("POST", t), o.setRequestHeader("Content-Type", "application/json");
  1460. try {
  1461. o.send(JSON.stringify(e));
  1462. } catch (a) {
  1463. console.error(a);
  1464. }
  1465. o.addEventListener("readystatechange", function () {
  1466. if (o.readyState == 4) return o.status == 200 ? r(o) : n("Unable to send log");
  1467. });
  1468. });
  1469. }
  1470. }]);
  1471. return Reporter;
  1472. }(EventEmitter);
  1473. var reporter$1 = new Reporter();
  1474. function _arrayLikeToArray$5(arr, len) {
  1475. if (len == null || len > arr.length) len = arr.length;
  1476. for (var i = 0, arr2 = new Array(len); i < len; i++) {
  1477. arr2[i] = arr[i];
  1478. }
  1479. return arr2;
  1480. }
  1481. function _arrayWithoutHoles(arr) {
  1482. if (Array.isArray(arr)) return _arrayLikeToArray$5(arr);
  1483. }
  1484. function _iterableToArray(iter) {
  1485. if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
  1486. }
  1487. function _unsupportedIterableToArray$5(o, minLen) {
  1488. if (!o) return;
  1489. if (typeof o === "string") return _arrayLikeToArray$5(o, minLen);
  1490. var n = Object.prototype.toString.call(o).slice(8, -1);
  1491. if (n === "Object" && o.constructor) n = o.constructor.name;
  1492. if (n === "Map" || n === "Set") return Array.from(o);
  1493. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$5(o, minLen);
  1494. }
  1495. function _nonIterableSpread() {
  1496. throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  1497. }
  1498. function _toConsumableArray(arr) {
  1499. return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray$5(arr) || _nonIterableSpread();
  1500. }
  1501. var Logger = /*#__PURE__*/function () {
  1502. function Logger(e) {
  1503. _classCallCheck(this, Logger);
  1504. this.level = 3;
  1505. this.module = e;
  1506. }
  1507. _createClass(Logger, [{
  1508. key: "setLevel",
  1509. value: function setLevel(e) {
  1510. this.level = e;
  1511. }
  1512. }, {
  1513. key: "atleast",
  1514. value: function atleast(e) {
  1515. return e >= this.level && e >= this.level;
  1516. }
  1517. }, {
  1518. key: "print",
  1519. value: function print(e, t) {
  1520. for (var _len = arguments.length, r = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
  1521. r[_key - 2] = arguments[_key];
  1522. }
  1523. if (this.atleast(t)) {
  1524. var _console$n;
  1525. var n = e == "debug" ? "info" : e,
  1526. o = this.prefix(e);
  1527. (_console$n = console[n]).call.apply(_console$n, [null, o].concat(r));
  1528. }
  1529. if (e !== "debug" && e !== "info") {
  1530. var _n = r.map(function (o) {
  1531. if (o instanceof Object) try {
  1532. return JSON.stringify(o);
  1533. } catch (_unused) {
  1534. return o;
  1535. } else return o;
  1536. }).join(",");
  1537. reporter$1.report("log", {
  1538. message: _n,
  1539. level: e,
  1540. module: this.module
  1541. });
  1542. }
  1543. }
  1544. }, {
  1545. key: "debug",
  1546. value: function debug() {
  1547. for (var _len2 = arguments.length, e = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  1548. e[_key2] = arguments[_key2];
  1549. }
  1550. return this.print.apply(this, ["debug", 1].concat(e));
  1551. }
  1552. }, {
  1553. key: "info",
  1554. value: function info() {
  1555. for (var _len3 = arguments.length, e = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
  1556. e[_key3] = arguments[_key3];
  1557. }
  1558. return this.print.apply(this, ["info", 2].concat(e));
  1559. }
  1560. }, {
  1561. key: "infoAndReportLog",
  1562. value: function infoAndReportLog(e) {
  1563. for (var _len4 = arguments.length, t = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
  1564. t[_key4 - 1] = arguments[_key4];
  1565. }
  1566. var r = e.reportOptions;
  1567. delete e.reportOptions, reporter$1.report("log", e, r), t.length || (t = [e.message]), this.debug.apply(this, _toConsumableArray(t));
  1568. }
  1569. }, {
  1570. key: "infoAndReportMeasurement",
  1571. value: function infoAndReportMeasurement(e) {
  1572. for (var _len5 = arguments.length, t = new Array(_len5 > 1 ? _len5 - 1 : 0), _key5 = 1; _key5 < _len5; _key5++) {
  1573. t[_key5 - 1] = arguments[_key5];
  1574. }
  1575. var n;
  1576. var r = e.reportOptions;
  1577. if (e.startTime) {
  1578. var o = Date.now();
  1579. e.value === void 0 && (e.endTime = o), e.value === void 0 && (e.value = o - e.startTime);
  1580. }
  1581. if (e.error ? e.code = ((n = e.error) == null ? void 0 : n.code) || Codes.Internal : e.code = Codes.Success, reporter$1.report("measurement", e, r), t.length || (t = [e]), e.level === 4 || e.error) {
  1582. this.error.apply(this, _toConsumableArray(t));
  1583. return;
  1584. }
  1585. this.warn.apply(this, _toConsumableArray(t));
  1586. }
  1587. }, {
  1588. key: "warn",
  1589. value: function warn() {
  1590. for (var _len6 = arguments.length, e = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
  1591. e[_key6] = arguments[_key6];
  1592. }
  1593. return this.print.apply(this, ["warn", 3].concat(e));
  1594. }
  1595. }, {
  1596. key: "error",
  1597. value: function error() {
  1598. for (var _len7 = arguments.length, e = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
  1599. e[_key7] = arguments[_key7];
  1600. }
  1601. return this.print.apply(this, ["error", 4].concat(e));
  1602. }
  1603. }, {
  1604. key: "prefix",
  1605. value: function prefix(e) {
  1606. return "[".concat(this.module, "][").concat(e, "] ").concat(util.getFormattedDate(new Date()), ":");
  1607. }
  1608. }], [{
  1609. key: "setLevel",
  1610. value: function setLevel(e) {
  1611. this.level = e;
  1612. }
  1613. }]);
  1614. return Logger;
  1615. }();
  1616. var logger$1 = new Logger();
  1617. var AxiosCanceler = /*#__PURE__*/function () {
  1618. function AxiosCanceler() {
  1619. _classCallCheck(this, AxiosCanceler);
  1620. this.pendingMap = new Map();
  1621. }
  1622. _createClass(AxiosCanceler, [{
  1623. key: "addPending",
  1624. value: function addPending(e) {
  1625. var _this = this;
  1626. return new axios.CancelToken(function (t) {
  1627. _this.pendingMap.has(e) || _this.pendingMap.set(e, t);
  1628. });
  1629. }
  1630. }, {
  1631. key: "removeAllPending",
  1632. value: function removeAllPending() {
  1633. this.pendingMap.forEach(function (e) {
  1634. e && isFunction(e) && e();
  1635. }), this.pendingMap.clear();
  1636. }
  1637. }, {
  1638. key: "removePending",
  1639. value: function removePending(e) {
  1640. if (this.pendingMap.has(e)) {
  1641. var t = this.pendingMap.get(e);
  1642. t && t(e), this.pendingMap.delete(e);
  1643. }
  1644. }
  1645. }, {
  1646. key: "removeCancelToken",
  1647. value: function removeCancelToken(e) {
  1648. this.pendingMap.has(e) && this.pendingMap.delete(e);
  1649. }
  1650. }, {
  1651. key: "reset",
  1652. value: function reset() {
  1653. this.pendingMap = new Map();
  1654. }
  1655. }]);
  1656. return AxiosCanceler;
  1657. }();
  1658. function _createSuper$e(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$e(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  1659. function _isNativeReflectConstruct$e() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  1660. var Http1 = /*#__PURE__*/function (_EventEmitter) {
  1661. _inherits(Http1, _EventEmitter);
  1662. var _super = _createSuper$e(Http1);
  1663. function Http1() {
  1664. var _this;
  1665. _classCallCheck(this, Http1);
  1666. _this = _super.call(this);
  1667. _this.instatnce = axios.create(), _this.canceler = new AxiosCanceler();
  1668. return _this;
  1669. }
  1670. _createClass(Http1, [{
  1671. key: "requestConstant",
  1672. value: function requestConstant() {
  1673. return {
  1674. x_nounce: this.randomString(),
  1675. x_timestamp: new Date().getTime(),
  1676. x_os: "web"
  1677. };
  1678. }
  1679. }, {
  1680. key: "requestParams",
  1681. value: function requestParams(e) {
  1682. return oe({}, e.params);
  1683. }
  1684. }, {
  1685. key: "get",
  1686. value: function get(e) {
  1687. return this.request(le(oe({}, e), {
  1688. method: "GET"
  1689. }));
  1690. }
  1691. }, {
  1692. key: "post",
  1693. value: function post(e) {
  1694. return this.request(le(oe({}, e), {
  1695. method: "POST"
  1696. }));
  1697. }
  1698. }, {
  1699. key: "request",
  1700. value: function request(e) {
  1701. var _this2 = this;
  1702. var t = e.url,
  1703. _e$timeout = e.timeout,
  1704. r = _e$timeout === void 0 ? 1e4 : _e$timeout,
  1705. n = e.method,
  1706. o = e.key,
  1707. a = e.beforeRequest,
  1708. s = e.responseType,
  1709. l = e.data;
  1710. var _e$retry = e.retry,
  1711. u = _e$retry === void 0 ? 0 : _e$retry;
  1712. var c = this.patchUrl(t),
  1713. h = this.canceler.addPending(t);
  1714. a && isFunction(a) && a(e);
  1715. var f = this.requestParams(e);
  1716. var d = {
  1717. url: c,
  1718. method: n,
  1719. timeout: r,
  1720. cancelToken: h,
  1721. responseType: s,
  1722. params: f
  1723. };
  1724. n === "POST" && (d = oe({
  1725. data: l
  1726. }, d));
  1727. var _ = Date.now(),
  1728. g = function g() {
  1729. return _this2.instatnce.request(d).then(function (m) {
  1730. return o && logger$1.infoAndReportMeasurement({
  1731. metric: "http",
  1732. startTime: _,
  1733. extra: t,
  1734. group: "http",
  1735. tag: o
  1736. }), _this2.canceler.removeCancelToken(t), m;
  1737. }).catch(function (m) {
  1738. var v = axios.isCancel(m);
  1739. return u > 0 && !v ? (u--, logger$1.warn("request ".concat(t, " retry, left retry count"), u), g()) : (logger$1.infoAndReportMeasurement({
  1740. metric: "http",
  1741. startTime: _,
  1742. error: m,
  1743. extra: {
  1744. url: t,
  1745. isCanceled: v
  1746. },
  1747. tag: o,
  1748. group: "http"
  1749. }), _this2.canceler.removeCancelToken(t), Promise.reject(m));
  1750. });
  1751. };
  1752. return g();
  1753. }
  1754. }, {
  1755. key: "patchUrl",
  1756. value: function patchUrl(e) {
  1757. return e;
  1758. }
  1759. }, {
  1760. key: "randomString",
  1761. value: function randomString() {
  1762. var e = "";
  1763. var t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
  1764. r = t.length;
  1765. for (var n = 0; n < 8; n++) {
  1766. e += t.charAt(Math.floor(Math.random() * r));
  1767. }
  1768. return e;
  1769. }
  1770. }]);
  1771. return Http1;
  1772. }(EventEmitter);
  1773. var http1 = new Http1();
  1774. var ModelManager = /*#__PURE__*/function () {
  1775. function ModelManager(e, t) {
  1776. _classCallCheck(this, ModelManager);
  1777. this.avatarModelList = [];
  1778. this.skinList = [];
  1779. this.applicationConfig = null;
  1780. this.config = null;
  1781. this.appId = e, this.releaseId = t;
  1782. }
  1783. _createClass(ModelManager, [{
  1784. key: "findSkinConfig",
  1785. value: function () {
  1786. var _findSkinConfig = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  1787. var t, n;
  1788. return regenerator.wrap(function _callee$(_context) {
  1789. while (1) {
  1790. switch (_context.prev = _context.next) {
  1791. case 0:
  1792. t = null;
  1793. _context.next = 3;
  1794. return this.getSkinsList();
  1795. case 3:
  1796. t = (this.skinList = _context.sent).find(function (n) {
  1797. return n.id === e;
  1798. });
  1799. if (!t) {
  1800. _context.next = 6;
  1801. break;
  1802. }
  1803. return _context.abrupt("return", t);
  1804. case 6:
  1805. n = "skin is invalid: skinId: ".concat(e);
  1806. return _context.abrupt("return", Promise.reject(new ParamError(n)));
  1807. case 8:
  1808. case "end":
  1809. return _context.stop();
  1810. }
  1811. }
  1812. }, _callee, this);
  1813. }));
  1814. function findSkinConfig(_x) {
  1815. return _findSkinConfig.apply(this, arguments);
  1816. }
  1817. return findSkinConfig;
  1818. }()
  1819. }, {
  1820. key: "findRoute",
  1821. value: function () {
  1822. var _findRoute = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(e, t) {
  1823. var n, o;
  1824. return regenerator.wrap(function _callee2$(_context2) {
  1825. while (1) {
  1826. switch (_context2.prev = _context2.next) {
  1827. case 0:
  1828. _context2.next = 2;
  1829. return this.findSkinConfig(e);
  1830. case 2:
  1831. n = _context2.sent.routeList.find(function (o) {
  1832. return o.pathName === t;
  1833. });
  1834. if (n) {
  1835. _context2.next = 6;
  1836. break;
  1837. }
  1838. o = "find path failed: skinId: ".concat(e, ", pathName: ").concat(t);
  1839. return _context2.abrupt("return", Promise.reject(new ParamError(o)));
  1840. case 6:
  1841. return _context2.abrupt("return", (logger$1.debug("find route success", n), n));
  1842. case 7:
  1843. case "end":
  1844. return _context2.stop();
  1845. }
  1846. }
  1847. }, _callee2, this);
  1848. }));
  1849. function findRoute(_x2, _x3) {
  1850. return _findRoute.apply(this, arguments);
  1851. }
  1852. return findRoute;
  1853. }()
  1854. }, {
  1855. key: "findAssetList",
  1856. value: function () {
  1857. var _findAssetList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e) {
  1858. var r, n;
  1859. return regenerator.wrap(function _callee3$(_context3) {
  1860. while (1) {
  1861. switch (_context3.prev = _context3.next) {
  1862. case 0:
  1863. _context3.next = 2;
  1864. return this.findSkinConfig(e);
  1865. case 2:
  1866. r = _context3.sent.assetList;
  1867. if (r) {
  1868. _context3.next = 6;
  1869. break;
  1870. }
  1871. n = "find path failed: skinId: ".concat(e);
  1872. return _context3.abrupt("return", Promise.reject(new ParamError(n)));
  1873. case 6:
  1874. return _context3.abrupt("return", (logger$1.debug("find route success", r), r));
  1875. case 7:
  1876. case "end":
  1877. return _context3.stop();
  1878. }
  1879. }
  1880. }, _callee3, this);
  1881. }));
  1882. function findAssetList(_x4) {
  1883. return _findAssetList.apply(this, arguments);
  1884. }
  1885. return findAssetList;
  1886. }()
  1887. }, {
  1888. key: "findAsset",
  1889. value: function () {
  1890. var _findAsset = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(e, t) {
  1891. var r,
  1892. n,
  1893. o,
  1894. a,
  1895. _args4 = arguments;
  1896. return regenerator.wrap(function _callee4$(_context4) {
  1897. while (1) {
  1898. switch (_context4.prev = _context4.next) {
  1899. case 0:
  1900. r = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : "id";
  1901. _context4.next = 3;
  1902. return this.findSkinConfig(e);
  1903. case 3:
  1904. n = _context4.sent;
  1905. if (!Array.isArray(t)) {
  1906. _context4.next = 6;
  1907. break;
  1908. }
  1909. return _context4.abrupt("return", t.map(function (a) {
  1910. return n.models.find(function (s) {
  1911. return s[r] === a;
  1912. });
  1913. }).filter(Boolean));
  1914. case 6:
  1915. o = n.models.find(function (a) {
  1916. return a[r] === t;
  1917. });
  1918. if (o) {
  1919. _context4.next = 10;
  1920. break;
  1921. }
  1922. a = "find asset failed: skinId: ".concat(e, ", keyValue: ").concat(t);
  1923. return _context4.abrupt("return", Promise.reject(new ParamError(a)));
  1924. case 10:
  1925. return _context4.abrupt("return", (logger$1.debug("find asset success", o), o));
  1926. case 11:
  1927. case "end":
  1928. return _context4.stop();
  1929. }
  1930. }
  1931. }, _callee4, this);
  1932. }));
  1933. function findAsset(_x5, _x6) {
  1934. return _findAsset.apply(this, arguments);
  1935. }
  1936. return findAsset;
  1937. }()
  1938. }, {
  1939. key: "findPoint",
  1940. value: function () {
  1941. var _findPoint = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(e, t) {
  1942. var n, o;
  1943. return regenerator.wrap(function _callee5$(_context5) {
  1944. while (1) {
  1945. switch (_context5.prev = _context5.next) {
  1946. case 0:
  1947. _context5.next = 2;
  1948. return this.findSkinConfig(e);
  1949. case 2:
  1950. n = _context5.sent.pointList.find(function (o) {
  1951. return o.id === t;
  1952. });
  1953. if (n) {
  1954. _context5.next = 6;
  1955. break;
  1956. }
  1957. o = "find point failed: skinId: ".concat(e, ", id: ").concat(t);
  1958. return _context5.abrupt("return", Promise.reject(new ParamError(o)));
  1959. case 6:
  1960. return _context5.abrupt("return", (logger$1.debug("find point success", n), n));
  1961. case 7:
  1962. case "end":
  1963. return _context5.stop();
  1964. }
  1965. }
  1966. }, _callee5, this);
  1967. }));
  1968. function findPoint(_x7, _x8) {
  1969. return _findPoint.apply(this, arguments);
  1970. }
  1971. return findPoint;
  1972. }()
  1973. }, {
  1974. key: "requestConfig",
  1975. value: function () {
  1976. var _requestConfig = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6() {
  1977. var t, r, _ref, n, o;
  1978. return regenerator.wrap(function _callee6$(_context6) {
  1979. while (1) {
  1980. switch (_context6.prev = _context6.next) {
  1981. case 0:
  1982. if (!this.config) {
  1983. _context6.next = 2;
  1984. break;
  1985. }
  1986. return _context6.abrupt("return", this.config);
  1987. case 2:
  1988. // let e = `https://static.xverse.cn/console/config/${this.appId}/config.json`;
  1989. // this.releaseId && (e = `https://static.xverse.cn/console/config/${this.appId}/${this.releaseId}/config.json`);
  1990. // const t = Xverse.USE_TME_CDN ? "https://static.xverse.cn/tmeland/config/tme_config.json" : e;
  1991. t = './assets/config.json';
  1992. _context6.prev = 3;
  1993. _context6.next = 6;
  1994. return http1.get({
  1995. url: "".concat(t, "?t=").concat(Date.now()),
  1996. key: "config",
  1997. timeout: 6e3,
  1998. retry: 2
  1999. });
  2000. case 6:
  2001. r = _context6.sent;
  2002. _ref = r.data.data || {}, n = _ref.config, o = _ref.preload;
  2003. if (n) {
  2004. _context6.next = 10;
  2005. break;
  2006. }
  2007. throw new Error("config data parse error" + r.data);
  2008. case 10:
  2009. return _context6.abrupt("return", (this.config = {
  2010. config: n,
  2011. preload: o
  2012. }, logger$1.debug("get config success", this.config), this.config));
  2013. case 13:
  2014. _context6.prev = 13;
  2015. _context6.t0 = _context6["catch"](3);
  2016. return _context6.abrupt("return", Promise.reject(_context6.t0));
  2017. case 16:
  2018. case "end":
  2019. return _context6.stop();
  2020. }
  2021. }
  2022. }, _callee6, this, [[3, 13]]);
  2023. }));
  2024. function requestConfig() {
  2025. return _requestConfig.apply(this, arguments);
  2026. }
  2027. return requestConfig;
  2028. }()
  2029. }, {
  2030. key: "getApplicationConfig",
  2031. value: function () {
  2032. var _getApplicationConfig = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee7() {
  2033. var e;
  2034. return regenerator.wrap(function _callee7$(_context7) {
  2035. while (1) {
  2036. switch (_context7.prev = _context7.next) {
  2037. case 0:
  2038. if (!this.applicationConfig) {
  2039. _context7.next = 2;
  2040. break;
  2041. }
  2042. return _context7.abrupt("return", this.applicationConfig);
  2043. case 2:
  2044. _context7.prev = 2;
  2045. _context7.next = 5;
  2046. return this.requestConfig();
  2047. case 5:
  2048. e = _context7.sent;
  2049. return _context7.abrupt("return", (this.applicationConfig = e.config, this.applicationConfig));
  2050. case 9:
  2051. _context7.prev = 9;
  2052. _context7.t0 = _context7["catch"](2);
  2053. return _context7.abrupt("return", Promise.reject(_context7.t0));
  2054. case 12:
  2055. case "end":
  2056. return _context7.stop();
  2057. }
  2058. }
  2059. }, _callee7, this, [[2, 9]]);
  2060. }));
  2061. function getApplicationConfig() {
  2062. return _getApplicationConfig.apply(this, arguments);
  2063. }
  2064. return getApplicationConfig;
  2065. }()
  2066. }, {
  2067. key: "getAvatarModelList",
  2068. value: function () {
  2069. var _getAvatarModelList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee8() {
  2070. var _yield$this$getApplic, e;
  2071. return regenerator.wrap(function _callee8$(_context8) {
  2072. while (1) {
  2073. switch (_context8.prev = _context8.next) {
  2074. case 0:
  2075. if (!this.avatarModelList.length) {
  2076. _context8.next = 2;
  2077. break;
  2078. }
  2079. return _context8.abrupt("return", this.avatarModelList);
  2080. case 2:
  2081. _context8.prev = 2;
  2082. _context8.next = 5;
  2083. return this.getApplicationConfig();
  2084. case 5:
  2085. _yield$this$getApplic = _context8.sent;
  2086. e = _yield$this$getApplic.avatars;
  2087. return _context8.abrupt("return", (this.avatarModelList = e.map(function (t) {
  2088. return {
  2089. name: t.name,
  2090. id: t.id,
  2091. modelUrl: t.url,
  2092. gender: t.gender,
  2093. components: t.components
  2094. };
  2095. }), this.avatarModelList));
  2096. case 10:
  2097. _context8.prev = 10;
  2098. _context8.t0 = _context8["catch"](2);
  2099. return _context8.abrupt("return", (logger$1.error(_context8.t0), []));
  2100. case 13:
  2101. case "end":
  2102. return _context8.stop();
  2103. }
  2104. }
  2105. }, _callee8, this, [[2, 10]]);
  2106. }));
  2107. function getAvatarModelList() {
  2108. return _getAvatarModelList.apply(this, arguments);
  2109. }
  2110. return getAvatarModelList;
  2111. }()
  2112. }, {
  2113. key: "getSkinsList",
  2114. value: function () {
  2115. var _getSkinsList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee9() {
  2116. var _yield$this$getApplic2, e;
  2117. return regenerator.wrap(function _callee9$(_context9) {
  2118. while (1) {
  2119. switch (_context9.prev = _context9.next) {
  2120. case 0:
  2121. if (!this.skinList.length) {
  2122. _context9.next = 2;
  2123. break;
  2124. }
  2125. return _context9.abrupt("return", this.skinList);
  2126. case 2:
  2127. _context9.prev = 2;
  2128. _context9.next = 5;
  2129. return this.getApplicationConfig();
  2130. case 5:
  2131. _yield$this$getApplic2 = _context9.sent;
  2132. e = _yield$this$getApplic2.skins;
  2133. return _context9.abrupt("return", (this.skinList = e.map(function (t) {
  2134. var r;
  2135. return {
  2136. name: t.name,
  2137. dataVersion: t.id + t.versionId,
  2138. id: t.id,
  2139. fov: parseInt(t.fov || 90),
  2140. models: t.assetList.map(function (n) {
  2141. var o = n.assetId,
  2142. a = n.url,
  2143. s = n.thumbnailUrl,
  2144. l = n.typeName,
  2145. u = n.className;
  2146. return {
  2147. id: o,
  2148. modelUrl: a,
  2149. name: n.name,
  2150. thumbnailUrl: s,
  2151. typeName: l,
  2152. className: u === "\u4F4E\u6A21" ? "\u7C97\u6A21" : u
  2153. };
  2154. }),
  2155. routeList: (r = t.routeList) == null ? void 0 : r.map(function (n) {
  2156. var o = n.areaName,
  2157. a = n.attitude,
  2158. s = n.id,
  2159. l = n.pathName,
  2160. u = n.step,
  2161. c = n.birthPointList;
  2162. return {
  2163. areaName: o,
  2164. attitude: a,
  2165. id: s,
  2166. pathName: l,
  2167. step: u,
  2168. birthPointList: c.map(function (h) {
  2169. return {
  2170. camera: h.camera && {
  2171. position: util.objectParseFloat(h.camera.position),
  2172. angle: util.objectParseFloat(h.camera.rotation)
  2173. },
  2174. player: h.player && {
  2175. position: util.objectParseFloat(h.player.position),
  2176. angle: util.objectParseFloat(h.player.rotation)
  2177. }
  2178. };
  2179. })
  2180. };
  2181. }),
  2182. pointList: t.pointList.map(function (n) {
  2183. return le(oe({}, n), {
  2184. position: util.objectParseFloat(n.position),
  2185. rotation: util.objectParseFloat(n.rotation)
  2186. });
  2187. }),
  2188. versionId: t.versionId,
  2189. isEnable: t.isEnable,
  2190. assetList: t.assetList,
  2191. visibleRules: t.visibleRules,
  2192. animationList: t.animationList
  2193. };
  2194. }), this.skinList));
  2195. case 10:
  2196. _context9.prev = 10;
  2197. _context9.t0 = _context9["catch"](2);
  2198. return _context9.abrupt("return", (logger$1.error(_context9.t0), []));
  2199. case 13:
  2200. case "end":
  2201. return _context9.stop();
  2202. }
  2203. }
  2204. }, _callee9, this, [[2, 10]]);
  2205. }));
  2206. function getSkinsList() {
  2207. return _getSkinsList.apply(this, arguments);
  2208. }
  2209. return getSkinsList;
  2210. }()
  2211. }, {
  2212. key: "getBreathPointTextrueList",
  2213. value: function () {
  2214. var _getBreathPointTextrueList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee10() {
  2215. return regenerator.wrap(function _callee10$(_context10) {
  2216. while (1) {
  2217. switch (_context10.prev = _context10.next) {
  2218. case 0:
  2219. return _context10.abrupt("return", [{
  2220. url: TEXTURE_URL
  2221. }]);
  2222. case 1:
  2223. case "end":
  2224. return _context10.stop();
  2225. }
  2226. }
  2227. }, _callee10);
  2228. }));
  2229. function getBreathPointTextrueList() {
  2230. return _getBreathPointTextrueList.apply(this, arguments);
  2231. }
  2232. return getBreathPointTextrueList;
  2233. }()
  2234. }], [{
  2235. key: "getInstance",
  2236. value: function getInstance(e, t) {
  2237. //getInstance(e, t) {
  2238. return this.instance || (this.instance = new ModelManager(e, t)), this.instance;
  2239. }
  2240. }, {
  2241. key: "findModels",
  2242. value: function findModels(e, t, r) {
  2243. //findModels(e, t, r) {
  2244. return e.filter(function (o) {
  2245. return o.typeName === t && o.className === r;
  2246. });
  2247. }
  2248. }, {
  2249. key: "findModel",
  2250. value: function findModel(e, t, r) {
  2251. //findModel(e, t, r) {
  2252. var n = e.filter(function (o) {
  2253. return o.typeName === t && o.className === r;
  2254. })[0];
  2255. return n || null;
  2256. }
  2257. }]);
  2258. return ModelManager;
  2259. }();
  2260. // export { modelManager };
  2261. var JoyStick = /*#__PURE__*/function () {
  2262. function JoyStick(e) {
  2263. _classCallCheck(this, JoyStick);
  2264. this._zone = document.createElement("div");
  2265. this._joystick = null;
  2266. this._room = e;
  2267. }
  2268. _createClass(JoyStick, [{
  2269. key: "init",
  2270. value: function init(e) {
  2271. var _this = this;
  2272. var _e$interval = e.interval,
  2273. t = _e$interval === void 0 ? 33 : _e$interval,
  2274. _e$triggerDistance = e.triggerDistance,
  2275. r = _e$triggerDistance === void 0 ? 25 : _e$triggerDistance,
  2276. _e$style = e.style,
  2277. n = _e$style === void 0 ? {
  2278. left: 0,
  2279. bottom: 0
  2280. } : _e$style,
  2281. o = function o(u, c) {
  2282. _this._room.actionsHandler.joystick({
  2283. degree: Math.floor(u),
  2284. level: Math.floor(c / 5)
  2285. });
  2286. },
  2287. a = this._zone;
  2288. document.body.appendChild(a), a.style.position = "absolute", a.style.width = "200px", a.style.height = "200px", a.style.left = String(n.left), a.style.bottom = String(n.bottom), a.style.zIndex = "999", a.style.userSelect = "none", a.style.webkitUserSelect = "none", this._joystick = nipplejs.create({
  2289. zone: a,
  2290. mode: "static",
  2291. position: {
  2292. left: "50%",
  2293. top: "50%"
  2294. },
  2295. color: "white"
  2296. });
  2297. var s, l;
  2298. return this._joystick.on("move", function (u, c) {
  2299. s = c;
  2300. }), this._joystick.on("start", function () {
  2301. l = window.setInterval(function () {
  2302. s && s.distance > r && o && o(s.angle.degree, s.distance);
  2303. }, t);
  2304. }), this._joystick.on("end", function () {
  2305. l && window.clearInterval(l), l = void 0;
  2306. }), this._joystick;
  2307. }
  2308. }, {
  2309. key: "show",
  2310. value: function show() {
  2311. if (!this._joystick) throw new Error("joystick is not created");
  2312. this._zone.style.display = "block";
  2313. }
  2314. }, {
  2315. key: "hide",
  2316. value: function hide() {
  2317. if (!this._joystick) throw new Error("joystick is not created");
  2318. this._zone.style.display = "none";
  2319. }
  2320. }]);
  2321. return JoyStick;
  2322. }();
  2323. var CoreBroadcastType = {
  2324. PlayAnimation: 'PlayAnimation'
  2325. };
  2326. var AvatarGroup = {
  2327. Npc: 'npc',
  2328. User: 'user'
  2329. };
  2330. var MessageHandleType$1 = {
  2331. MHT_Undefined: 0,
  2332. MHT_RoomMulticast: 1,
  2333. MHT_FollowListMulticast: 2,
  2334. MHT_CustomTargetSync: 3
  2335. };
  2336. var Broadcast$1 = /*#__PURE__*/function () {
  2337. function Broadcast(e, t) {
  2338. _classCallCheck(this, Broadcast);
  2339. this.room = e;
  2340. this.handlers = [];
  2341. this.init(t);
  2342. }
  2343. _createClass(Broadcast, [{
  2344. key: "init",
  2345. value: function init(t) {
  2346. this.handlers.push(t);
  2347. }
  2348. }, {
  2349. key: "handleBroadcast",
  2350. value: function () {
  2351. var _handleBroadcast = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  2352. return regenerator.wrap(function _callee$(_context) {
  2353. while (1) {
  2354. switch (_context.prev = _context.next) {
  2355. case 0:
  2356. _context.prev = 1;
  2357. JSON.parse(e.broadcastAction.data);
  2358. _context.next = 9;
  2359. break;
  2360. case 5:
  2361. _context.prev = 5;
  2362. _context.t0 = _context["catch"](1);
  2363. logger$1.error(_context.t0);
  2364. return _context.abrupt("return");
  2365. case 9:
  2366. case "end":
  2367. return _context.stop();
  2368. }
  2369. }
  2370. }, _callee, null, [[1, 5]]);
  2371. }));
  2372. function handleBroadcast(_x) {
  2373. return _handleBroadcast.apply(this, arguments);
  2374. }
  2375. return handleBroadcast;
  2376. }()
  2377. }, {
  2378. key: "broadcast",
  2379. value: function broadcast(e) {
  2380. var t = e.data,
  2381. _e$msgType = e.msgType,
  2382. r = _e$msgType === void 0 ? MessageHandleType$1.MHT_FollowListMulticast : _e$msgType,
  2383. n = e.targetUserIds;
  2384. return this.room.actionsHandler.broadcast({
  2385. data: t,
  2386. msgType: r,
  2387. targetUserIds: n
  2388. });
  2389. }
  2390. }]);
  2391. return Broadcast;
  2392. }();
  2393. var XAvatarLoader = /*#__PURE__*/function () {
  2394. function XAvatarLoader() {
  2395. _classCallCheck(this, XAvatarLoader);
  2396. E(this, "containers", new Map());
  2397. E(this, "meshes", new Map());
  2398. E(this, "animations", new Map());
  2399. E(this, "aniPath", new Map());
  2400. E(this, "binPath", new Map());
  2401. E(this, "texPath", new Map());
  2402. E(this, "matPath", new Map());
  2403. E(this, "mshPath", new Map());
  2404. E(this, "rootPath", new Map());
  2405. E(this, "meshTexList", new Map());
  2406. E(this, "_enableIdb", !0);
  2407. E(this, "_mappings", new Map());
  2408. E(this, "_sharedTex", new Map());
  2409. E(this, "avaliableAnimation", new Map());
  2410. E(this, "enableShareTexture", !0);
  2411. E(this, "enableShareAnimation", !0);
  2412. E(this, "fillEmptyLod", !0);
  2413. var e = new BABYLON.GLTFFileLoader();
  2414. BABYLON.SceneLoader.RegisterPlugin(e), e.preprocessUrlAsync = function (t) {
  2415. var r = avatarLoader._mappings.get(t);
  2416. return r ? Promise.resolve(r) : Promise.resolve(t);
  2417. };
  2418. }
  2419. _createClass(XAvatarLoader, [{
  2420. key: "getParsedUrl",
  2421. value: function getParsedUrl(e, t, r) {
  2422. var _this = this;
  2423. return new Promise(function (o, a) {
  2424. if (!r || r.indexOf(".zip") === -1) return o(r);
  2425. var s = _this.rootPath.get(r);
  2426. if (s) return o(s);
  2427. {
  2428. var l = ".zip",
  2429. u = r.replace(l, "") + COMPONENT_LIST_PREFIX;
  2430. e.urlTransformer(u, !0).then(function (c) {
  2431. if (!c) return a("Loading Failed");
  2432. new Response(c).json().then(function (h) {
  2433. var _, g, m, v, y, b, T;
  2434. var f = r.replace(l, ""),
  2435. d = f + ((_ = h == null ? void 0 : h.components) == null ? void 0 : _.url.replace("./", ""));
  2436. if (_this.rootPath.set(r, d), h.components ? (h.components.url && _this.mshPath.set(t, f + "/" + ((g = h == null ? void 0 : h.components) == null ? void 0 : g.url.replace("./", ""))), h.components.url_lod2 && _this.mshPath.set(t + "_" + avatarSetting.lod[1].level, f + "/" + ((m = h == null ? void 0 : h.components) == null ? void 0 : m.url_lod2.replace("./", ""))), h.components.url_lod4 && _this.mshPath.set(t + "_" + avatarSetting.lod[2].level, f + "/" + ((v = h == null ? void 0 : h.components) == null ? void 0 : v.url_lod4.replace("./", "")))) : (h.meshes.url && _this.mshPath.set(t, f + "/" + ((y = h == null ? void 0 : h.meshes) == null ? void 0 : y.url.replace("./", ""))), h.meshes.url_lod2 && _this.mshPath.set(t + "_" + avatarSetting.lod[1].level, f + "/" + ((b = h == null ? void 0 : h.meshes) == null ? void 0 : b.url_lod2.replace("./", ""))), h.meshes.url_lod4 && _this.mshPath.set(t + "_" + avatarSetting.lod[2].level, f + "/" + ((T = h == null ? void 0 : h.meshes) == null ? void 0 : T.url_lod4.replace("./", "")))), h.materials && h.materials.forEach(function (C) {
  2437. var A = f + "/" + C.url;
  2438. _this.matPath.set(C.name, A);
  2439. }), h.bin) {
  2440. var C = f + "/" + h.bin.url;
  2441. _this.binPath.set(t, C);
  2442. var A = f + "/" + h.bin.url_lod2;
  2443. _this.binPath.set(t + "_" + avatarSetting.lod[1].level, A);
  2444. var S = f + "/" + h.bin.url_lod4;
  2445. _this.binPath.set(t + "_" + avatarSetting.lod[2].level, S);
  2446. }
  2447. return h.textures && h.textures.forEach(function (C) {
  2448. var A = f + "/" + C.url;
  2449. _this.texPath.set(C.url, A);
  2450. var S = _this.meshTexList.get(h.components.url);
  2451. C.type === "png" && (S ? S.find(function (P) {
  2452. return P === C.name;
  2453. }) || S.push(C.url) : _this.meshTexList.set(t, [C.name]));
  2454. }), o(d);
  2455. }).catch(function (h) {
  2456. logger$1.error("[Engine] parse json file error,".concat(h));
  2457. });
  2458. }).catch(function (c) {
  2459. logger$1.error("[Engine] ulrtransform error, cannot find resource in db,".concat(c));
  2460. });
  2461. }
  2462. });
  2463. }
  2464. }, {
  2465. key: "parse",
  2466. value: function () {
  2467. var _parse = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e, t) {
  2468. var _this2 = this;
  2469. var r;
  2470. return regenerator.wrap(function _callee$(_context) {
  2471. while (1) {
  2472. switch (_context.prev = _context.next) {
  2473. case 0:
  2474. r = [];
  2475. t.forEach(function (n) {
  2476. _this2._setAnimationList(n.id, n.animations), r.push(_this2.getParsedUrl(e, n.id, n.url)), n.components.forEach(function (o) {
  2477. o.units.forEach(function (a) {
  2478. r.push(_this2.getParsedUrl(e, a.name, a.url));
  2479. });
  2480. });
  2481. });
  2482. _context.next = 4;
  2483. return Promise.all(r);
  2484. case 4:
  2485. case "end":
  2486. return _context.stop();
  2487. }
  2488. }
  2489. }, _callee);
  2490. }));
  2491. function parse(_x, _x2) {
  2492. return _parse.apply(this, arguments);
  2493. }
  2494. return parse;
  2495. }()
  2496. }, {
  2497. key: "_setAnimationList",
  2498. value: function _setAnimationList(e, t) {
  2499. var _this3 = this;
  2500. t ? t.forEach(function (r) {
  2501. _this3.aniPath.set(e + "_" + r.name, r.url);
  2502. }) : logger$1.error("[Engine] no animation list exist, please check config for details");
  2503. }
  2504. }, {
  2505. key: "disposeContainer",
  2506. value: function disposeContainer() {
  2507. var _this4 = this;
  2508. this.containers.forEach(function (e, t) {
  2509. e.xReferenceCount < 1 && (_this4.enableShareTexture && e.textures.length > 0 && e.textures[0].xReferenceCount != null && (e.textures[0].xReferenceCount--, e.textures = []), e.dispose(), _this4.containers.delete(t));
  2510. }), this._sharedTex.forEach(function (e, t) {
  2511. e.xReferenceCount == 0 && (e.dispose(), _this4._sharedTex.delete(t));
  2512. });
  2513. }
  2514. }, {
  2515. key: "enableIdb",
  2516. set: function set(e) {
  2517. this._enableIdb = e;
  2518. }
  2519. }, {
  2520. key: "getGlbPath",
  2521. value: function getGlbPath(e) {
  2522. return this.aniPath.get(e + ".glb");
  2523. }
  2524. }, {
  2525. key: "getGltfPath",
  2526. value: function getGltfPath(e) {
  2527. return this.mshPath.get(e + ".gltf");
  2528. }
  2529. }, {
  2530. key: "getPngUrl",
  2531. value: function getPngUrl(e) {
  2532. return this.texPath.get(e + ".png");
  2533. }
  2534. }, {
  2535. key: "getMeshUrl",
  2536. value: function getMeshUrl(e) {
  2537. return this.mshPath.get(e);
  2538. }
  2539. }, {
  2540. key: "_getSourceKey",
  2541. value: function _getSourceKey(e, t) {
  2542. return t && avatarSetting.lod[t] ? e + avatarSetting.lod[t].fileName.split(".")[0] : e;
  2543. }
  2544. }, {
  2545. key: "_getAnimPath",
  2546. value: function _getAnimPath(e, t) {
  2547. var r = this.aniPath.get(t + "_animations_" + t.split("_")[1]);
  2548. return r || (r = this.aniPath.get(t + "_" + e)), r;
  2549. }
  2550. }, {
  2551. key: "load",
  2552. value: function load(e, t, r, n) {
  2553. var _this5 = this;
  2554. return new Promise(function (o, a) {
  2555. _this5.loadGlb(e, t, r).then(function (s) {
  2556. return s ? o(s) : a("[Engine] container load failed");
  2557. }).catch(function () {
  2558. return a("[Engine] container load failed");
  2559. });
  2560. });
  2561. }
  2562. }, {
  2563. key: "_searchAnimation",
  2564. value: function _searchAnimation(e, t) {
  2565. var r;
  2566. return this.containers.forEach(function (n, o) {
  2567. var a = t.split("_")[0];
  2568. o.indexOf(a) != -1 && o.indexOf(e) != -1 && (r = n);
  2569. }), r;
  2570. }
  2571. }, {
  2572. key: "loadAnimRes",
  2573. value: function loadAnimRes(e, t, r) {
  2574. var _this6 = this;
  2575. return new Promise(function (n, o) {
  2576. var a = _this6._getAnimPath(t, r),
  2577. s = getAnimationKey(t, r);
  2578. if (a && _this6.containers.get(a)) return n(_this6.containers.get(a));
  2579. if (a) _this6._loadGlbFromBlob(e, s, a).then(function (l) {
  2580. return l.animationGroups.length == 0 ? (_this6.containers.delete(s), l.dispose(), Promise.reject("container does not contains animation data")) : n(l);
  2581. });else return o("no such url");
  2582. });
  2583. }
  2584. }, {
  2585. key: "loadGlb",
  2586. value: function loadGlb(e, t, r) {
  2587. var n = this.getMeshUrl(this._getSourceKey(t, r));
  2588. return !n && this.fillEmptyLod && (r = 0, n = this.getMeshUrl(this._getSourceKey(t, r))), n && this.containers.get(n) ? Promise.resolve(this.containers.get(n)) : n ? this._enableIdb ? Promise.resolve(this._loadGlbFromBlob(e, this._getSourceKey(t, r), n)) : Promise.resolve(this._loadGlbFromUrl(e, this._getSourceKey(t, r), n)) : Promise.reject("no such url");
  2589. }
  2590. }, {
  2591. key: "loadGltf",
  2592. value: function loadGltf(e, t, r, n) {
  2593. var o = this._getSourceKey(t, r || 0);
  2594. var a = this.getGltfPath(o);
  2595. return !a && this.fillEmptyLod && (a = this.getGltfPath(t)), a && this.containers.get(a) ? Promise.resolve(this.containers.get(a)) : this._enableIdb ? this._loadGltfFromBlob(e, t, r, n) : a ? this._loadGltfFromUrl(e, t, a.replace(t + ".gltf", "")) : Promise.reject();
  2596. }
  2597. }, {
  2598. key: "loadSubsequence",
  2599. value: function loadSubsequence() {}
  2600. }, {
  2601. key: "loadVAT",
  2602. value: function loadVAT() {}
  2603. }, {
  2604. key: "getResourceName",
  2605. value: function getResourceName(e) {
  2606. return this.meshTexList.get(e);
  2607. }
  2608. }, {
  2609. key: "_loadGltfFromUrl",
  2610. value: function _loadGltfFromUrl(e, t, r) {
  2611. return BABYLON.SceneLoader.LoadAssetContainerAsync(r, t + ".gltf", e.Scene, null, ".gltf");
  2612. }
  2613. }, {
  2614. key: "_loadGlbFromBlob",
  2615. value: function _loadGlbFromBlob(e, t, r) {
  2616. var _this7 = this;
  2617. return new Promise(function (n, o) {
  2618. e.urlTransformer(r).then(function (a) {
  2619. BABYLON.SceneLoader.LoadAssetContainerAsync("", a, e.Scene, null, ".glb").then(function (s) {
  2620. if (s) {
  2621. if (_this7.enableShareTexture && s.textures.length > 0) {
  2622. var l = t.indexOf("_lod") != -1 ? t.slice(0, -5) : t,
  2623. u = _this7._sharedTex.get(l);
  2624. u ? (s.meshes[1].material._albedoTexture = u, s.textures.forEach(function (c) {
  2625. c.dispose();
  2626. }), s.textures = [u], u.xReferenceCount++) : (_this7._sharedTex.set(l, s.textures[0]), s.textures[0].xReferenceCount = 1);
  2627. }
  2628. return s.addAllToScene(), s.xReferenceCount = 0, s.meshes.forEach(function (l) {
  2629. l.setEnabled(!1);
  2630. }), _this7.containers.set(r, s), n(s);
  2631. } else o("glb file load failed");
  2632. });
  2633. });
  2634. });
  2635. }
  2636. }, {
  2637. key: "_loadGlbFromUrl",
  2638. value: function _loadGlbFromUrl(e, t, r) {
  2639. var _this8 = this;
  2640. return new Promise(function (n, o) {
  2641. BABYLON.SceneLoader.LoadAssetContainerAsync("", r, e.Scene, null, ".glb").then(function (a) {
  2642. if (a) {
  2643. if (a.addAllToScene(), a.meshes.forEach(function (s) {
  2644. s.setEnabled(!1);
  2645. }), _this8.enableShareTexture && a.textures.length > 0) {
  2646. var s = t.indexOf("_lod") != -1 ? t.slice(0, -5) : t,
  2647. l = _this8._sharedTex.get(s);
  2648. l ? (a.meshes[1].material._albedoTexture = l, a.textures.forEach(function (u) {
  2649. u.dispose();
  2650. }), a.textures = [l], l.xReferenceCount++) : (_this8._sharedTex.set(s, a.textures[0]), a.textures[0].xReferenceCount = 1);
  2651. }
  2652. return a.xReferenceCount = 0, _this8.containers.set(r, a), n(a);
  2653. } else o("glb file load failed");
  2654. });
  2655. });
  2656. }
  2657. }, {
  2658. key: "_loadGltfFromBlob",
  2659. value: function _loadGltfFromBlob(e, t, r, n) {
  2660. var _this9 = this;
  2661. return new Promise(function (o, a) {
  2662. var s = [];
  2663. var l = _this9._getSourceKey(t, r),
  2664. u = _this9.getGltfPath(l);
  2665. if (!u && _this9.fillEmptyLod && (r = 0, l = _this9._getSourceKey(t, r), u = _this9.getGltfPath(l)), !u) return a("[Engine] gltf path incorrect ".concat(l, ",cancel."));
  2666. var c = _this9.mshPath.get(l + ".gltf");
  2667. if (!c) return a("cannot find asset mshPath");
  2668. var h = _this9.binPath.get(l + ".bin");
  2669. if (!h) return a("cannot find asset binPath");
  2670. if (!n) {
  2671. var _ = _this9.meshTexList.get(t);
  2672. if (!_ || _.length == 0) return a("cannot find texture");
  2673. n = _[0];
  2674. }
  2675. var f = _this9.texPath.get(n + ".png");
  2676. if (!f) return a();
  2677. var d = _this9.texPath.get(n + "-astc.ktx");
  2678. if (!d) return a();
  2679. s.push(_this9._blobMapping(e, c)), s.push(_this9._blobMapping(e, h)), s.push(_this9._blobMapping(e, f)), s.push(_this9._blobMapping(e, d)), Promise.all(s).then(function () {
  2680. var _ = u.replace(l + ".gltf", "");
  2681. BABYLON.SceneLoader.LoadAssetContainerAsync(_, l + ".gltf", e.Scene, null, ".gltf").then(function (g) {
  2682. var v;
  2683. _this9.containers.set(u, g), g.addAllToScene(), g.meshes.forEach(function (y) {
  2684. y.setEnabled(!1);
  2685. });
  2686. var m = _this9._sharedTex.get(t);
  2687. m ? ((v = g.meshes[1].material._albedoTexture) == null || v.dispose(), g.meshes[1].material._albedoTexture = m) : _this9._sharedTex.set(t, g.meshes[1].material._albedoTexture), o(g);
  2688. });
  2689. });
  2690. });
  2691. }
  2692. }, {
  2693. key: "_blobMapping",
  2694. value: function _blobMapping(e, t) {
  2695. var _this10 = this;
  2696. return new Promise(function (r, n) {
  2697. e.urlTransformer(t).then(function (o) {
  2698. return o ? (_this10._mappings.set(t, o), r(t)) : n("[Engine] url urlTransformer parse error ".concat(t));
  2699. });
  2700. });
  2701. }
  2702. }]);
  2703. return XAvatarLoader;
  2704. }();
  2705. var avatarLoader = new XAvatarLoader();
  2706. function _createSuper$d(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$d(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  2707. function _isNativeReflectConstruct$d() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  2708. var XverseAvatarManager = /*#__PURE__*/function (_EventEmitter) {
  2709. _inherits(XverseAvatarManager, _EventEmitter);
  2710. var _super = _createSuper$d(XverseAvatarManager);
  2711. function XverseAvatarManager(e) {
  2712. var _this;
  2713. _classCallCheck(this, XverseAvatarManager);
  2714. _this = _super.call(this);
  2715. _this.xAvatarManager = null;
  2716. _this.avatars = new Map();
  2717. _this.syncAvatarsLength = 0;
  2718. _this._room = e;
  2719. _this._usersStatistics();
  2720. _this.broadcast = _this.setupBroadcast();
  2721. e.on("skinChanged", function () {
  2722. _this.avatars.forEach(function (t) {
  2723. t.disconnected && _this.removeAvatar(t.userId, !0);
  2724. });
  2725. });
  2726. return _this;
  2727. }
  2728. _createClass(XverseAvatarManager, [{
  2729. key: "setupBroadcast",
  2730. value: function setupBroadcast() {
  2731. var _this2 = this;
  2732. return new Broadcast$1(this._room, /*#__PURE__*/function () {
  2733. var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  2734. var t, r, n, o, a, _r$loop, s, l;
  2735. return regenerator.wrap(function _callee$(_context) {
  2736. while (1) {
  2737. switch (_context.prev = _context.next) {
  2738. case 0:
  2739. t = e.broadcastType, r = e.info;
  2740. if (!(t !== CoreBroadcastType.PlayAnimation)) {
  2741. _context.next = 3;
  2742. break;
  2743. }
  2744. return _context.abrupt("return");
  2745. case 3:
  2746. n = r.userId, o = r.animation, a = r.extra, _r$loop = r.loop, s = _r$loop === void 0 ? !1 : _r$loop, l = _this2.avatars.get(n);
  2747. _context.t0 = l && !l.isSelf;
  2748. if (!_context.t0) {
  2749. _context.next = 10;
  2750. break;
  2751. }
  2752. l.emit("animationStart", {
  2753. animationName: o,
  2754. extra: decodeURIComponent(a)
  2755. });
  2756. _context.next = 9;
  2757. return l == null ? void 0 : l._playAnimation(o, s);
  2758. case 9:
  2759. l.emit("animationEnd", {
  2760. animationName: o,
  2761. extra: decodeURIComponent(a)
  2762. });
  2763. case 10:
  2764. case "end":
  2765. return _context.stop();
  2766. }
  2767. }
  2768. }, _callee);
  2769. }));
  2770. return function (_x) {
  2771. return _ref.apply(this, arguments);
  2772. };
  2773. }());
  2774. }
  2775. }, {
  2776. key: "hideAll",
  2777. value: function hideAll() {
  2778. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : !0;
  2779. this.xAvatarManager.hideAll(e);
  2780. }
  2781. }, {
  2782. key: "showAll",
  2783. value: function showAll() {
  2784. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : !0;
  2785. this.xAvatarManager.showAll(e);
  2786. }
  2787. }, {
  2788. key: "init",
  2789. value: function () {
  2790. var _init = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
  2791. var e, t;
  2792. return regenerator.wrap(function _callee2$(_context2) {
  2793. while (1) {
  2794. switch (_context2.prev = _context2.next) {
  2795. case 0:
  2796. this.xAvatarManager = this._room.sceneManager.avatarComponent;
  2797. _context2.prev = 1;
  2798. _context2.next = 4;
  2799. return this._room.modelManager.getApplicationConfig();
  2800. case 4:
  2801. e = _context2.sent;
  2802. t = e.avatars;
  2803. if (!t) {
  2804. _context2.next = 10;
  2805. break;
  2806. }
  2807. _context2.next = 9;
  2808. return avatarLoader.parse(this._room.sceneManager, t);
  2809. case 9:
  2810. return _context2.abrupt("return");
  2811. case 10:
  2812. return _context2.abrupt("return", Promise.reject("cannot find avatar config list"));
  2813. case 13:
  2814. _context2.prev = 13;
  2815. _context2.t0 = _context2["catch"](1);
  2816. return _context2.abrupt("return", (logger$1.error(_context2.t0), Promise.reject("avatar mananger init error!")));
  2817. case 16:
  2818. case "end":
  2819. return _context2.stop();
  2820. }
  2821. }
  2822. }, _callee2, this, [[1, 13]]);
  2823. }));
  2824. function init() {
  2825. return _init.apply(this, arguments);
  2826. }
  2827. return init;
  2828. }()
  2829. }, {
  2830. key: "handleAvatar",
  2831. value: function () {
  2832. var _handleAvatar2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e) {
  2833. var _this3 = this;
  2834. var r, t, n, o, _n, a;
  2835. return regenerator.wrap(function _callee3$(_context3) {
  2836. while (1) {
  2837. switch (_context3.prev = _context3.next) {
  2838. case 0:
  2839. if (!(this._room.viewMode === "simple" || !this._room.joined || !e.newUserStates)) {
  2840. _context3.next = 2;
  2841. break;
  2842. }
  2843. return _context3.abrupt("return");
  2844. case 2:
  2845. t = e.newUserStates;
  2846. if (((r = this._room._userAvatar) == null ? void 0 : r.isMoving) && this._room._userAvatar.motionType === MotionType.Run) {
  2847. n = t.filter(function (a) {
  2848. return a.userId === _this3._room.userId;
  2849. }), o = t.filter(function (a) {
  2850. return a.userId !== _this3._room.userId;
  2851. }).slice(0, 2);
  2852. t = n.concat(o);
  2853. }
  2854. if (e.getStateType === GetStateTypes.Event) {
  2855. this.syncAvatarsLength = (t || []).length;
  2856. _n = this._room.avatars.filter(function (s) {
  2857. return s.group == AvatarGroup.User;
  2858. });
  2859. _n.filter(function (s) {
  2860. return !(t != null && t.find(function (l) {
  2861. return l.userId == s.userId;
  2862. }));
  2863. }).forEach(function (s) {
  2864. _this3.removeAvatar(s.userId);
  2865. });
  2866. a = t.filter(function (s) {
  2867. return !_n.find(function (l) {
  2868. return l.userId == s.userId;
  2869. });
  2870. });
  2871. this._handleAvatar(a);
  2872. }
  2873. this._handleAvatar(t);
  2874. case 6:
  2875. case "end":
  2876. return _context3.stop();
  2877. }
  2878. }
  2879. }, _callee3, this);
  2880. }));
  2881. function handleAvatar(_x2) {
  2882. return _handleAvatar2.apply(this, arguments);
  2883. }
  2884. return handleAvatar;
  2885. }()
  2886. }, {
  2887. key: "_handleAvatar",
  2888. value: function () {
  2889. var _handleAvatar3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(e) {
  2890. var _this4 = this;
  2891. return regenerator.wrap(function _callee4$(_context4) {
  2892. while (1) {
  2893. switch (_context4.prev = _context4.next) {
  2894. case 0:
  2895. e == null || e.forEach(function (t) {
  2896. var n, o, a, s, l, u, c, h, f;
  2897. var r = _this4._room.userId === t.userId;
  2898. if (((n = t.event) == null ? void 0 : n.type) === SyncEventType.ET_RemoveVisitor) {
  2899. var d = (a = (o = t.event) == null ? void 0 : o.removeVisitorEvent) == null ? void 0 : a.removeVisitorEvent,
  2900. _ = JSON.parse(safeDecodeURIComponent(((l = (s = t.event) == null ? void 0 : s.removeVisitorEvent) == null ? void 0 : l.extraInfo) || "")),
  2901. g = _.code,
  2902. m = _.msg;
  2903. d === RemoveVisitorType.RVT_ChangeToObserver ? _this4._room.audienceViewModeHook() : d === RemoveVisitorType.RVT_MoveOutOfTheRoom && _this4._room.leave(), _this4._room.emit("visitorStatusChanged", {
  2904. code: g,
  2905. msg: m
  2906. });
  2907. }
  2908. if (t.event && [SyncEventType.Appear, SyncEventType.Reset].includes(t.event.type) || !t.event) {
  2909. var _d = _this4.avatars.get(t.userId);
  2910. if (t.playerState.avatarId && (_d == null ? void 0 : _d.avatarId) !== t.playerState.avatarId && (_d = void 0, _this4.removeAvatar(t.userId)), _d) {
  2911. if (_d.disconnected && _d.setConnectionStatus(!1), (u = t.event) != null && u.id && _this4._room.actionsHandler.confirmEvent(t.event.id), t.playerState.nickName && (_d == null || _d._setNickname(t.playerState.nickName)), t.playerState.avatarComponents && !_d.isSelf && _d.xAvatar) {
  2912. var _2 = safeParseComponents(t.playerState.avatarComponents);
  2913. _d._changeComponents({
  2914. avatarComponents: _2,
  2915. mode: ChangeComponentsMode.Preview
  2916. });
  2917. }
  2918. } else {
  2919. var _t$playerState$player = t.playerState.player,
  2920. _3 = _t$playerState$player.position,
  2921. _g = _t$playerState$player.angle,
  2922. _m = t.playerState.avatarId,
  2923. v = t.playerState.prioritySync,
  2924. y = safelyJsonParse(t.playerState.extra);
  2925. if (!_m) return;
  2926. var b = safeParseComponents(t.playerState.avatarComponents),
  2927. T = safeDecodeURIComponent(t.playerState.nickName),
  2928. C = _this4.calculatePriority(t.userId, y);
  2929. _this4.addAvatar({
  2930. userId: t.userId,
  2931. isHost: t.playerState.isHost,
  2932. nickname: T,
  2933. avatarPosition: _3,
  2934. avatarRotation: _g,
  2935. avatarScale: t.playerState.avatarSize,
  2936. avatarId: _m,
  2937. avatarComponents: t.playerState.person === Person.First ? [] : b,
  2938. priority: C,
  2939. group: AvatarGroup.User,
  2940. prioritySync: v,
  2941. extraInfo: y
  2942. }).then(function () {
  2943. var A;
  2944. (A = t.event) != null && A.id && _this4._room.actionsHandler.confirmEvent(t.event.id), _this4.updateAvatarPositionAndRotation(t), r && (_this4.xAvatarManager.setMainAvatar(t.userId), _this4._room.emit("userAvatarLoaded"), logger$1.info("userAvatarLoaded"));
  2945. }).catch(function (A) {
  2946. r && (_this4.xAvatarManager.setMainAvatar(t.userId), _this4._room.emit("userAvatarFailed", {
  2947. error: A
  2948. }), logger$1.error("userAvatarFailed", A));
  2949. });
  2950. }
  2951. }
  2952. if (t.event && SyncEventType.Disappear === t.event.type && ((c = t == null ? void 0 : t.event) != null && c.id && _this4._room.actionsHandler.confirmEvent(t.event.id), _this4.removeAvatar(t.userId)), t.event && [SyncEventType.Move, SyncEventType.ChangeRenderInfo].includes(t.event.type) || !t.event) {
  2953. (h = t == null ? void 0 : t.event) != null && h.id && _this4._room.actionsHandler.confirmEvent(t.event.id);
  2954. var _d2 = _this4.avatars.get(t.userId);
  2955. _d2 && _d2.withModel && !_d2.isLoading && _this4.updateAvatarPositionAndRotation(t);
  2956. }
  2957. if (!r && ((f = t.event) == null ? void 0 : f.type) === SyncEventType.Rotate) {
  2958. var _d3 = _this4.avatars.get(t.userId);
  2959. _d3.statusSyncQueue.append({
  2960. type: QueueType.Rotate,
  2961. action: function action() {
  2962. return _d3.statusSync(t);
  2963. }
  2964. });
  2965. }
  2966. });
  2967. case 1:
  2968. case "end":
  2969. return _context4.stop();
  2970. }
  2971. }
  2972. }, _callee4);
  2973. }));
  2974. function _handleAvatar(_x3) {
  2975. return _handleAvatar3.apply(this, arguments);
  2976. }
  2977. return _handleAvatar;
  2978. }()
  2979. }, {
  2980. key: "calculatePriority",
  2981. value: function calculatePriority(e, t) {
  2982. var n;
  2983. return e === this._room.userId ? EAvatarRelationRank.Self : (n = this._room.options.firends) != null && n.includes(e) ? EAvatarRelationRank.Friend : EAvatarRelationRank.Stranger;
  2984. }
  2985. }, {
  2986. key: "updateAvatarPositionAndRotation",
  2987. value: function updateAvatarPositionAndRotation(e) {
  2988. var t, r;
  2989. if ((t = e == null ? void 0 : e.playerState) != null && t.player) {
  2990. var _e$playerState$player = e.playerState.player,
  2991. n = _e$playerState$player.position,
  2992. o = _e$playerState$player.angle;
  2993. var a = this.avatars.get(e.userId);
  2994. if (!a) return;
  2995. if (n = positionPrecisionProtect(n), o = rotationPrecisionProtect(o), a.isSelf && !this._room.networkController.rtcp.workers.inPanoMode && (a.setPosition(n), a.setRotation(o)), e.event && (((r = e.event) == null ? void 0 : r.points.length) || 0) > 1 && !a.isSelf && a.statusSyncQueue.append({
  2996. type: QueueType.Move,
  2997. action: function action() {
  2998. return a.statusSync(e);
  2999. }
  3000. }), e.renderInfo && a.isSelf) {
  3001. var _e$renderInfo = e.renderInfo,
  3002. s = _e$renderInfo.isMoving,
  3003. l = _e$renderInfo.isRotating;
  3004. this._updateAvatarMovingStatus({
  3005. id: e.userId,
  3006. isMoving: !!s,
  3007. isRotating: !!l
  3008. });
  3009. }
  3010. }
  3011. }
  3012. }, {
  3013. key: "addAvatar",
  3014. value: function () {
  3015. var _addAvatar = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(e) {
  3016. var t, r, n, o, a, s, _e$avatarComponents, l, u, _e$group, c, _e$avatarScale, h, f, d, _, g, v, y, b, T, C;
  3017. return regenerator.wrap(function _callee5$(_context5) {
  3018. while (1) {
  3019. switch (_context5.prev = _context5.next) {
  3020. case 0:
  3021. t = e.userId, r = e.isHost, n = e.avatarPosition, o = e.avatarId, a = e.avatarRotation, s = e.nickname, _e$avatarComponents = e.avatarComponents, l = _e$avatarComponents === void 0 ? [] : _e$avatarComponents, u = e.priority, _e$group = e.group, c = _e$group === void 0 ? AvatarGroup.Npc : _e$group, _e$avatarScale = e.avatarScale, h = _e$avatarScale === void 0 ? DEFAULT_AVATAR_SCALE : _e$avatarScale, f = e.extraInfo, d = e.prioritySync, _ = t === this._room.userId;
  3022. g = this.avatars.get(t);
  3023. if (!g) {
  3024. _context5.next = 4;
  3025. break;
  3026. }
  3027. return _context5.abrupt("return", Promise.resolve(g));
  3028. case 4:
  3029. if (!(g = new xe.subAvatar({
  3030. userId: t,
  3031. isHost: r,
  3032. isSelf: _,
  3033. room: this._room,
  3034. avatarComponents: l,
  3035. avatarId: o,
  3036. nickname: s,
  3037. group: c
  3038. }), this.avatars.set(t, g), !g.withModel)) {
  3039. _context5.next = 6;
  3040. break;
  3041. }
  3042. return _context5.abrupt("return", (g.isLoading = !1, g.avatarLoadedHook(), this._room.emit("avatarChanged", {
  3043. avatars: this._room.avatars
  3044. }), g));
  3045. case 6:
  3046. _context5.next = 8;
  3047. return this._room.modelManager.getAvatarModelList();
  3048. case 8:
  3049. v = _context5.sent.find(function (b) {
  3050. return b.id === o;
  3051. });
  3052. y = Date.now();
  3053. if (v) {
  3054. _context5.next = 12;
  3055. break;
  3056. }
  3057. return _context5.abrupt("return", (this._room.emit("avatarChanged", {
  3058. avatars: this._room.avatars
  3059. }), this.avatars.delete(t), Promise.reject("no such avatar model with id: ".concat(o))));
  3060. case 12:
  3061. _context5.prev = 12;
  3062. _context5.next = 15;
  3063. return avatarComponentsModify(v, l);
  3064. case 15:
  3065. b = _context5.sent;
  3066. b = b.filter(function (A) {
  3067. return A.type != "pendant";
  3068. });
  3069. _context5.next = 19;
  3070. return avatarComponentsParser(v, b);
  3071. case 19:
  3072. T = _context5.sent;
  3073. _context5.next = 22;
  3074. return this.xAvatarManager.loadAvatar({
  3075. id: t,
  3076. avatarType: o,
  3077. priority: u,
  3078. avatarManager: this.xAvatarManager,
  3079. assets: T,
  3080. status: {
  3081. avatarPosition: n,
  3082. avatarRotation: a,
  3083. avatarScale: h
  3084. }
  3085. })._timeout(8e3, new TimeoutError$1("loadAvatar timeout(8s)"));
  3086. case 22:
  3087. C = _context5.sent;
  3088. return _context5.abrupt("return", (C.setPickBoxScale(t === this._room.userId ? 0 : 1), g.xAvatar = C, g.setScale(h), g.extraInfo = f, g.priority = u, g.isLoading = !1, g.prioritySync = !!d, g._playAnimation("Idle", !0, !0), g.avatarLoadedHook(), this._room.emit("avatarChanged", {
  3089. avatars: this._room.avatars
  3090. }), s && g._setNickname(s), t === this._room.userId && (logger$1.infoAndReportMeasurement({
  3091. metric: "avatarLoadDuration",
  3092. startTime: y,
  3093. group: "costs"
  3094. }), logger$1.infoAndReportMeasurement({
  3095. metric: "avatarLoadAt",
  3096. startTime: this._room._startTime,
  3097. group: "costs"
  3098. })), g));
  3099. case 26:
  3100. _context5.prev = 26;
  3101. _context5.t0 = _context5["catch"](12);
  3102. return _context5.abrupt("return", (g.isLoading = !1, this._room.emit("avatarChanged", {
  3103. avatars: this._room.avatars
  3104. }), logger$1.error(_context5.t0), Promise.reject(_context5.t0)));
  3105. case 29:
  3106. case "end":
  3107. return _context5.stop();
  3108. }
  3109. }
  3110. }, _callee5, this, [[12, 26]]);
  3111. }));
  3112. function addAvatar(_x4) {
  3113. return _addAvatar.apply(this, arguments);
  3114. }
  3115. return addAvatar;
  3116. }()
  3117. }, {
  3118. key: "removeAvatar",
  3119. value: function removeAvatar(e) {
  3120. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !1;
  3121. var r = this.avatars.get(e);
  3122. if (!!r) {
  3123. if (r.removeWhenDisconnected || t) {
  3124. r.xAvatar && this.xAvatarManager.deleteAvatar(r.xAvatar), this.avatars.delete(e), this._room.emit("avatarChanged", {
  3125. avatars: this._room.avatars
  3126. });
  3127. return;
  3128. }
  3129. r.setConnectionStatus(!0);
  3130. }
  3131. }
  3132. }, {
  3133. key: "clearOtherUsers",
  3134. value: function clearOtherUsers() {
  3135. var _this5 = this;
  3136. this.avatars.forEach(function (e) {
  3137. !e.isSelf && e.group === AvatarGroup.User && _this5.removeAvatar(e.userId);
  3138. });
  3139. }
  3140. }, {
  3141. key: "_updateAvatarMovingStatus",
  3142. value: function () {
  3143. var _updateAvatarMovingStatus2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6(e) {
  3144. var t, r, n, o, a, _a;
  3145. return regenerator.wrap(function _callee6$(_context6) {
  3146. while (1) {
  3147. switch (_context6.prev = _context6.next) {
  3148. case 0:
  3149. t = e.id, r = e.isMoving, n = e.isRotating, o = this.avatars.get(t);
  3150. if (!!o) {
  3151. if (o.isRotating !== n) {
  3152. o.isRotating = n;
  3153. a = "Idle";
  3154. n && (a = "Walking", o.motionType === MotionType.Run && (a = "Running")), o._playAnimation(a, !0, !0), logger$1.infoAndReportMeasurement({
  3155. startTime: Date.now(),
  3156. value: 0,
  3157. metric: n ? "userAvatarStartRotating" : "userAvatarStopRotating",
  3158. extra: {
  3159. motionType: o.motionType,
  3160. moveToExtra: this._room.moveToExtra
  3161. }
  3162. });
  3163. }
  3164. if (o.isMoving !== r) {
  3165. o.isMoving = r;
  3166. _a = "Idle";
  3167. r && (_a = "Walking", o.motionType === MotionType.Run && (_a = "Running")), r ? (o.avatarStartMovingHook(), o.emit("startMoving", {
  3168. target: o,
  3169. extra: this._room.moveToExtra
  3170. })) : (o.avatarStopMovingHook(), o.emit("stopMoving", {
  3171. target: o,
  3172. extra: this._room.moveToExtra
  3173. })), o._playAnimation(_a, !0, !0), logger$1.infoAndReportMeasurement({
  3174. startTime: Date.now(),
  3175. value: 0,
  3176. metric: r ? "userAvatarStartMoving" : "userAvatarStopMoving",
  3177. extra: {
  3178. motionType: o.motionType,
  3179. moveToExtra: this._room.moveToExtra
  3180. }
  3181. });
  3182. }
  3183. }
  3184. case 2:
  3185. case "end":
  3186. return _context6.stop();
  3187. }
  3188. }
  3189. }, _callee6, this);
  3190. }));
  3191. function _updateAvatarMovingStatus(_x5) {
  3192. return _updateAvatarMovingStatus2.apply(this, arguments);
  3193. }
  3194. return _updateAvatarMovingStatus;
  3195. }()
  3196. }, {
  3197. key: "_usersStatistics",
  3198. value: function _usersStatistics() {
  3199. var _this6 = this;
  3200. this.on("userAvatarLoaded", function () {
  3201. window.setInterval(function () {
  3202. var e = _this6._room.avatars.filter(function (r) {
  3203. return r.group === AvatarGroup.User;
  3204. }).length || 0,
  3205. t = _this6._room.avatars.filter(function (r) {
  3206. return r.group === AvatarGroup.User && r.isRender;
  3207. }).length || 0;
  3208. _this6._room.stats.assign({
  3209. userNum: e,
  3210. syncUserNum: _this6.syncAvatarsLength,
  3211. renderedUserNum: t
  3212. });
  3213. }, 3e3);
  3214. });
  3215. }
  3216. }]);
  3217. return XverseAvatarManager;
  3218. }(EventEmitter);
  3219. var PathManager = /*#__PURE__*/function () {
  3220. function PathManager() {
  3221. _classCallCheck(this, PathManager);
  3222. this.currentArea = '';
  3223. this.currentPathName = '';
  3224. this.currentAttitude = '';
  3225. this.speed = 0;
  3226. }
  3227. _createClass(PathManager, [{
  3228. key: "getSpeed",
  3229. value: function getSpeed(e) {
  3230. var t = {
  3231. guangchang: {
  3232. [MotionType.Walk]: 17,
  3233. [MotionType.Run]: 51
  3234. },
  3235. tower: {
  3236. [MotionType.Walk]: 12.5,
  3237. [MotionType.Run]: 25
  3238. },
  3239. zhiboting: {
  3240. [MotionType.Walk]: 12.5,
  3241. [MotionType.Run]: 25
  3242. },
  3243. youxiting: {
  3244. [MotionType.Walk]: 12.5,
  3245. [MotionType.Run]: 25
  3246. },
  3247. diqing: {
  3248. [MotionType.Walk]: 12.5,
  3249. [MotionType.Run]: 25
  3250. }
  3251. },
  3252. r = t[this.currentArea] || t.guangchang;
  3253. return this.speed = r[e] * 30, this.speed;
  3254. }
  3255. }]);
  3256. return PathManager;
  3257. }();
  3258. var CameraStates = {
  3259. Normal: 0,
  3260. ItemView: 1,
  3261. CGView: 2,
  3262. PathView: 3
  3263. };
  3264. var Person$1 = {
  3265. Third: 0,
  3266. First: 1
  3267. };
  3268. var EImageQuality = {
  3269. low: 0,
  3270. mid: 1,
  3271. high: 2
  3272. };
  3273. var Actions = {
  3274. Clicking: 1,
  3275. PlayCG: 6,
  3276. Back: 7,
  3277. ChangeRoom: 8,
  3278. ChangeSkin: 13,
  3279. Joystick: 15,
  3280. Transfer: 18,
  3281. GetOnVehicle: 22,
  3282. GetOffVehicle: 23,
  3283. StopMoving: 34,
  3284. UnaryActionLine: 1e3,
  3285. Init: 1001,
  3286. Exit: 1002,
  3287. SetIFrameInfo: 1003,
  3288. GetNeighborPoints: 1004,
  3289. ReserveSeat: 1005,
  3290. GetReserveStatus: 1006,
  3291. ChangeNickname: 1007,
  3292. ChangeBitRateInfo: 1008,
  3293. Echo: 1009,
  3294. SetPlayerState: 1010,
  3295. TurnTo: 1011,
  3296. TurnToFace: 1012,
  3297. RotateTo: 1013,
  3298. Rotation: 1014,
  3299. CameraTurnTo: 1015,
  3300. ConfirmEvent: 1016,
  3301. Broadcast: 1017,
  3302. NotifyActionLine: 2e4,
  3303. AudienceChangeToVisitor: 1020,
  3304. VisitorChangeToAudience: 1021,
  3305. RemoveVisitor: 1022,
  3306. GetUserWithAvatar: 1023
  3307. };
  3308. function _createSuper$c(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$c(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  3309. function _isNativeReflectConstruct$c() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  3310. var Camera = /*#__PURE__*/function (_EventEmitter) {
  3311. _inherits(Camera, _EventEmitter);
  3312. var _super = _createSuper$c(Camera);
  3313. function Camera(e) {
  3314. var _this;
  3315. _classCallCheck(this, Camera);
  3316. _this = _super.call(this);
  3317. _this.initialFov = 0;
  3318. _this._state = CameraStates.Normal;
  3319. _this._person = Person$1.Third;
  3320. _this._cameraFollowing = !0;
  3321. _this._room = e;
  3322. return _this;
  3323. }
  3324. _createClass(Camera, [{
  3325. key: "checkPointOnLeftOrRight",
  3326. value: function checkPointOnLeftOrRight(e) {
  3327. var t = ue4Position2Xverse(e);
  3328. if (!t || this.checkPointInView(e)) return;
  3329. var o = this._room.scene.activeCamera;
  3330. if (!o) return;
  3331. var a = [o.target.x, o.target.y, o.target.z],
  3332. s = [o.position.x, o.position.y, o.position.z],
  3333. l = t.x,
  3334. u = t.y,
  3335. c = t.z,
  3336. h = calNormVector(s, a),
  3337. f = calNormVector(s, [l, u, c]);
  3338. return vectorCrossMulti(h, f) < 0 ? Direction.Right : Direction.Left;
  3339. }
  3340. }, {
  3341. key: "checkPointInView",
  3342. value: function checkPointInView(e, t, r) {
  3343. var n = ue4Position2Xverse({
  3344. x: e,
  3345. y: t,
  3346. z: r
  3347. });
  3348. if (!n) return !1;
  3349. for (var o = 0; o < 6; o++) {
  3350. if (this._room.scene.frustumPlanes[o].dotCoordinate(n) < 0) return !1;
  3351. }
  3352. return !0;
  3353. }
  3354. }, {
  3355. key: "person",
  3356. get: function get() {
  3357. return this._person;
  3358. }
  3359. }, {
  3360. key: "state",
  3361. get: function get() {
  3362. return this._state;
  3363. }
  3364. }, {
  3365. key: "pose",
  3366. get: function get() {
  3367. return this._room.currentClickingState.camera;
  3368. }
  3369. }, {
  3370. key: "cameraFollowing",
  3371. get: function get() {
  3372. return this._cameraFollowing;
  3373. },
  3374. set: function set(e) {
  3375. logger$1.info("cameraFollowing setter", e), this.setCameraFollowing({
  3376. isFollowHost: e
  3377. });
  3378. }
  3379. }, {
  3380. key: "setCameraFollowing",
  3381. value: function setCameraFollowing(_ref) {
  3382. _ref.isFollowHost;
  3383. }
  3384. }, {
  3385. key: "handleRenderInfo",
  3386. value: function handleRenderInfo(e) {
  3387. var t = e.renderInfo.cameraStateType,
  3388. r = this._room.sceneManager;
  3389. if (t !== this._state && (this._state = t, logger$1.debug("camera._state changed to", CameraStates[t]), t === CameraStates.CGView ? (r.cameraComponent.switchToCgCamera(), r.staticmeshComponent.getCgMesh().show()) : (r.cameraComponent.switchToMainCamera(), r.staticmeshComponent.getCgMesh().hide()), this.emit("stateChanged", {
  3390. state: t
  3391. })), this._room.isHost) return;
  3392. var n = e.playerState.isFollowHost;
  3393. !!n !== this._cameraFollowing && (this._cameraFollowing = !!n, this.emit("cameraFollowingChanged", {
  3394. cameraFollowing: !!n
  3395. }));
  3396. }
  3397. }, {
  3398. key: "setCameraState",
  3399. value: function setCameraState(_ref2) {
  3400. var e = _ref2.state;
  3401. if (this._state === e) {
  3402. logger$1.warn("You are already in ".concat(CameraStates[e], " camera state"));
  3403. return;
  3404. }
  3405. e === CameraStates.Normal || this._state === CameraStates.ItemView && logger$1.warn("CloseUp camera state can only be triggerd by room internally");
  3406. }
  3407. }, {
  3408. key: "turnToFace",
  3409. value: function turnToFace(_ref3) {
  3410. var _ref3$extra = _ref3.extra,
  3411. e = _ref3$extra === void 0 ? "" : _ref3$extra,
  3412. _ref3$offset = _ref3.offset,
  3413. t = _ref3$offset === void 0 ? 0 : _ref3$offset;
  3414. var r = {
  3415. action_type: Actions.TurnToFace,
  3416. turn_to_face_action: {
  3417. offset: t
  3418. }
  3419. };
  3420. return this.emit("viewChanged", {
  3421. extra: e
  3422. }), this._room.actionsHandler.sendData({
  3423. data: r
  3424. });
  3425. }
  3426. }, {
  3427. key: "isInDefaultView",
  3428. value: function isInDefaultView() {
  3429. if (!this._room.isHost) {
  3430. logger$1.warn("It is recommended to call the function on the host side");
  3431. return;
  3432. }
  3433. if (!this._room._currentClickingState) return logger$1.error("CurrentState should not be empty"), !1;
  3434. var _this$_room$_currentC = this._room._currentClickingState,
  3435. e = _this$_room$_currentC.camera,
  3436. t = _this$_room$_currentC.player;
  3437. return Math.abs(t.angle.yaw - 180 - e.angle.yaw) % 360 <= 4;
  3438. }
  3439. }, {
  3440. key: "screenShot",
  3441. value: function () {
  3442. var _screenShot = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(_ref4) {
  3443. var e, _ref4$autoSave, t, r, n, o;
  3444. return regenerator.wrap(function _callee$(_context) {
  3445. while (1) {
  3446. switch (_context.prev = _context.next) {
  3447. case 0:
  3448. e = _ref4.name, _ref4$autoSave = _ref4.autoSave, t = _ref4$autoSave === void 0 ? !1 : _ref4$autoSave;
  3449. r = this._room.scene.getEngine(), n = this._room.scene.activeCamera;
  3450. _context.prev = 2;
  3451. this._room.sceneManager.setImageQuality(EImageQuality.high);
  3452. _context.next = 6;
  3453. return CreateScreenshotAsync(r, n, {
  3454. precision: 1
  3455. });
  3456. case 6:
  3457. o = _context.sent;
  3458. return _context.abrupt("return", (this._room.sceneManager.setImageQuality(EImageQuality.low), t === !0 && downloadFileByBase64(o, e), Promise.resolve(o)));
  3459. case 10:
  3460. _context.prev = 10;
  3461. _context.t0 = _context["catch"](2);
  3462. return _context.abrupt("return", (this._room.sceneManager.setImageQuality(EImageQuality.low), Promise.reject(_context.t0)));
  3463. case 13:
  3464. case "end":
  3465. return _context.stop();
  3466. }
  3467. }
  3468. }, _callee, this, [[2, 10]]);
  3469. }));
  3470. function screenShot(_x) {
  3471. return _screenShot.apply(this, arguments);
  3472. }
  3473. return screenShot;
  3474. }()
  3475. }, {
  3476. key: "changeToFirstPerson",
  3477. value: function changeToFirstPerson(e, t, r) {
  3478. var _this2 = this;
  3479. var n = e.camera,
  3480. o = e.player,
  3481. a = e.attitude,
  3482. s = e.areaName,
  3483. l = e.pathName;
  3484. return this._room.actionsHandler.requestPanorama({
  3485. camera: n,
  3486. player: o,
  3487. attitude: a,
  3488. areaName: s,
  3489. pathName: l
  3490. }, t, r).then(function () {
  3491. _this2._room.networkController.rtcp.workers.changePanoMode(!0);
  3492. var _ref5 = o || {},
  3493. u = _ref5.position,
  3494. c = _ref5.angle;
  3495. _this2._room.sceneManager.cameraComponent.changeToFirstPersonView({
  3496. position: u,
  3497. rotation: c
  3498. });
  3499. });
  3500. }
  3501. }, {
  3502. key: "setPerson",
  3503. value: function setPerson(e) {
  3504. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
  3505. camera: this._room._currentClickingState.camera,
  3506. player: this._room._currentClickingState.player
  3507. };
  3508. var r = Date.now();
  3509. return this._setPerson(e, t).then(function (n) {
  3510. return logger$1.infoAndReportMeasurement({
  3511. tag: Person$1[e],
  3512. startTime: r,
  3513. metric: "setPerson"
  3514. }), n;
  3515. }).catch(function (n) {
  3516. return logger$1.infoAndReportMeasurement({
  3517. tag: Person$1[e],
  3518. startTime: r,
  3519. metric: "setPerson",
  3520. error: n
  3521. }), Promise.reject(n);
  3522. });
  3523. }
  3524. }, {
  3525. key: "_setPerson",
  3526. value: function _setPerson(e) {
  3527. var _this3 = this;
  3528. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
  3529. camera: this._room._currentClickingState.camera,
  3530. player: this._room._currentClickingState.player
  3531. };
  3532. return e !== Person$1.First && e !== Person$1.Third ? Promise.reject("invalid person " + e) : !t.camera || !t.player ? Promise.reject(new ParamError("wrong camera or player")) : e === Person$1.First ? this._room.panorama.access({
  3533. camera: t.camera,
  3534. player: t.player,
  3535. tag: "setPerson"
  3536. }).then(function () {
  3537. var o, a;
  3538. _this3._person = e, (o = _this3._room._userAvatar) == null || o.hide();
  3539. var _ref6 = ((a = _this3._room.currentClickingState) == null ? void 0 : a.camera) || {},
  3540. r = _ref6.position,
  3541. n = _ref6.angle;
  3542. !r || !n || _this3._room.sceneManager.cameraComponent.changeToFirstPersonView({
  3543. position: r,
  3544. rotation: n
  3545. });
  3546. }) : this._room.panorama.exit({
  3547. camera: t.camera,
  3548. player: t.player
  3549. }).then(function () {
  3550. var r, n;
  3551. _this3._person = e, (r = _this3._room._userAvatar) != null && r.xAvatar && ((n = _this3._room._userAvatar) == null || n.xAvatar.show());
  3552. });
  3553. }
  3554. }, {
  3555. key: "setCameraPose",
  3556. value: function setCameraPose(e) {
  3557. this._room.sceneManager.cameraComponent.setCameraPose({
  3558. position: e.position,
  3559. rotation: e.angle
  3560. });
  3561. }
  3562. }, {
  3563. key: "setMainCameraRotationLimit",
  3564. value: function setMainCameraRotationLimit(e) {
  3565. var t = e.limitAxis,
  3566. r = e.limitRotation;
  3567. this._room.sceneManager.cameraComponent.setMainCameraRotationLimit(t, r);
  3568. }
  3569. }]);
  3570. return Camera;
  3571. }(EventEmitter);
  3572. function _createSuper$b(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$b(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  3573. function _isNativeReflectConstruct$b() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  3574. var numberFormat = new Intl.NumberFormat(window.navigator.language, {
  3575. maximumFractionDigits: 0
  3576. });
  3577. var Stats = /*#__PURE__*/function (_EventEmitter) {
  3578. _inherits(Stats, _EventEmitter);
  3579. var _super = _createSuper$b(Stats);
  3580. function Stats(e) {
  3581. var _this;
  3582. _classCallCheck(this, Stats);
  3583. _this = _super.call(this);
  3584. _this._netInterval = null;
  3585. _this._disabled = !1;
  3586. _this._show = !1;
  3587. _this._aggregatedStats = {};
  3588. _this._displayElement = null;
  3589. _this._extraStats = {};
  3590. _this._networkSamples = [];
  3591. _this.externalStats = null;
  3592. _this.constructedTime = null;
  3593. _this.room = e, _this.constructedTime = Date.now(), _this._interval = window.setInterval(function () {
  3594. var t, r, n;
  3595. _this._disabled || _this.onStats((n = (r = (t = e.networkController) == null ? void 0 : t.rtcp) == null ? void 0 : r.workers) == null ? void 0 : n.uploadDataToServer());
  3596. }, 1e3), _this._netInterval = window.setInterval(function () {
  3597. _this.getIsWeakNet();
  3598. }, NET_INTERVAL * 1e3);
  3599. return _this;
  3600. }
  3601. _createClass(Stats, [{
  3602. key: "isShow",
  3603. get: function get() {
  3604. return this._show;
  3605. }
  3606. }, {
  3607. key: "assign",
  3608. value: function assign(e) {
  3609. Object.assign(this._extraStats, e), ((e == null ? void 0 : e.hb) || (e == null ? void 0 : e.rtt)) && this.startStatsNetSamples();
  3610. }
  3611. }, {
  3612. key: "appendExternalStats",
  3613. value: function appendExternalStats(e) {
  3614. var _this2 = this;
  3615. var t = {};
  3616. if (!e || typeof e != "object") {
  3617. console.warn("appendExternalStats should be plain object");
  3618. return;
  3619. }
  3620. Object.keys(e).forEach(function (r) {
  3621. Object.prototype.hasOwnProperty.call(_this2._aggregatedStats, r) ? console.warn("".concat(r, " is duplicate with internal stats")) : t[r] = e[r];
  3622. }), !(Object.keys(t).length > 10) && (this.externalStats = t);
  3623. }
  3624. }, {
  3625. key: "getRtt",
  3626. value: function getRtt() {
  3627. var e = this._extraStats.rtt;
  3628. return typeof e != "number" ? 0 : e > 999 ? 999 : e;
  3629. }
  3630. }, {
  3631. key: "enable",
  3632. value: function enable() {
  3633. this._disabled = !1;
  3634. }
  3635. }, {
  3636. key: "disable",
  3637. value: function disable() {
  3638. this._disabled = !0;
  3639. }
  3640. }, {
  3641. key: "disableNet",
  3642. value: function disableNet() {
  3643. this._netInterval && window.clearInterval(this._netInterval);
  3644. }
  3645. }, {
  3646. key: "show",
  3647. value: function show() {
  3648. this._show = !0, this._render();
  3649. }
  3650. }, {
  3651. key: "hide",
  3652. value: function hide() {
  3653. this._show = !1, this._displayElement && document.body.removeChild(this._displayElement), this._displayElement = null;
  3654. }
  3655. }, {
  3656. key: "getIsWeakNet",
  3657. value: function getIsWeakNet() {
  3658. var _this3 = this;
  3659. var e = !1;
  3660. var t = this._networkSamples.length - 1;
  3661. if (t < 0) return;
  3662. var r = this._networkSamples[t].time,
  3663. n = this._networkSamples[0].time,
  3664. o = r - n,
  3665. a = 1e3 * (DURATION - 2);
  3666. if (o < a) return;
  3667. var s = this._networkSamples.map(function (g) {
  3668. return _this3.isNetDelay(g, "rtt");
  3669. }),
  3670. l = this._networkSamples.map(function (g) {
  3671. return _this3.isNetDelay(g, "hb");
  3672. }),
  3673. u = s.reduce(function (g, m) {
  3674. return g + m;
  3675. }, 0),
  3676. c = l.reduce(function (g, m) {
  3677. return g + m;
  3678. }, 0),
  3679. h = Math.floor(u / this._networkSamples.length) * 100,
  3680. f = Math.floor(c / this._networkSamples.length) * 100,
  3681. d = 70;
  3682. (h >= d || f >= d) && (e = !0);
  3683. var _ = this.room.viewMode === "observer" || this.room.viewMode === "serverless";
  3684. e && !_ && (logger$1.infoAndReportMeasurement({
  3685. metric: "weakNetwork",
  3686. startTime: Date.now(),
  3687. extra: {
  3688. msg: this._networkSamples.slice(20),
  3689. netDelayRTTValues: u,
  3690. netDelayHBValues: c
  3691. }
  3692. }), this.emit("weakNetwork"));
  3693. }
  3694. }, {
  3695. key: "startStatsNetSamples",
  3696. value: function startStatsNetSamples() {
  3697. var _this$_extraStats = this._extraStats,
  3698. e = _this$_extraStats.rtt,
  3699. t = _this$_extraStats.hb;
  3700. if (e || t) {
  3701. var r = {
  3702. rtt: e,
  3703. hb: t,
  3704. time: new Date().getTime()
  3705. };
  3706. this._networkSamples.push(r);
  3707. var n = this._networkSamples.length - 1;
  3708. if (n < 0) return;
  3709. var o = this._networkSamples[n].time,
  3710. a = 1e3 * DURATION;
  3711. this._networkSamples = this._networkSamples.filter(function (s) {
  3712. return s.time > o - a;
  3713. });
  3714. }
  3715. }
  3716. }, {
  3717. key: "isNetDelay",
  3718. value: function isNetDelay(e, t) {
  3719. return t === "rtt" ? e.rtt > RTT_MAX_VALUE ? 1 : 0 : t === "hb" && e.hb > HB_MAX_VALUE ? 1 : 0;
  3720. }
  3721. }, {
  3722. key: "getPreciesTimer",
  3723. value: function getPreciesTimer(e, t) {
  3724. var r = t * 1e3,
  3725. n = new Date().getTime();
  3726. var o = 0;
  3727. o++;
  3728. var a = new Date().getTime() - (n + o * 1e3),
  3729. s = r - a,
  3730. l = setTimeout(function () {
  3731. clearTimeout(l), e();
  3732. }, s);
  3733. }
  3734. }, {
  3735. key: "_render",
  3736. value: function _render() {
  3737. var c, h, f, d, _, g, m, v, y, b, T, C, A, S, P, R, M, x, I, w;
  3738. if (!this._aggregatedStats) return;
  3739. this._displayElement || (this._displayElement = document.createElement("div"), this._displayElement.style.position = "absolute", this._displayElement.style.top = "10px", this._displayElement.style.left = "200px", this._displayElement.style.width = "200px", this._displayElement.style.backgroundColor = "rgba(0,0,0,.5)", this._displayElement.style.color = "white", this._displayElement.style.textAlign = "left", this._displayElement.style.fontSize = "8px", this._displayElement.style.lineHeight = "10px", document.body.appendChild(this._displayElement));
  3740. var e = [],
  3741. t = Date.now() - this.constructedTime,
  3742. r = Math.floor(t / 1e3 % 60),
  3743. n = Math.floor(t / (1e3 * 60) % 60),
  3744. o = Math.floor(t / (1e3 * 60 * 60) % 24),
  3745. a = o < 10 ? "0" + o.toString() : o.toString(),
  3746. s = n < 10 ? "0" + n : n,
  3747. l = r < 10 ? "0" + r : r;
  3748. e.push({
  3749. key: new Date(Math.floor(this._aggregatedStats.timestamp || 0)).toLocaleString("en-GB"),
  3750. value: a + ":" + s + ":" + l
  3751. }), e.push({
  3752. key: "rtt: " + this._extraStats.rtt + " hb: " + this._extraStats.hb,
  3753. value: "FPS: " + this._extraStats.fps + " avatar: " + ((c = this.room._userAvatar) == null ? void 0 : c.state)
  3754. }), e.push({
  3755. key: "SDK: " + Xverse$1.SUB_PACKAGE_VERSION,
  3756. value: "ENGINE:" + VERSION$1 + " uid:" + this._extraStats.userId
  3757. }), e.push({
  3758. key: "\u540C\u6B65/\u6709\u6548/\u663E\u793A\u73A9\u5BB6",
  3759. value: "".concat(this._extraStats.syncUserNum || 0, "/").concat(this._extraStats.userNum || 0, "/").concat(this._extraStats.renderedUserNum || 0)
  3760. }), e.push({
  3761. key: "media/meta bitrate(kbps)",
  3762. value: numberFormat.format(this._aggregatedStats.mediaBitrate || 0) + "/" + numberFormat.format(this._aggregatedStats.metaBitrate || 0)
  3763. }), e.push({
  3764. key: ":----------------Decoding---------------",
  3765. value: ""
  3766. }), e.push({
  3767. key: "-max/avg decodeTime(ms)",
  3768. value: numberFormat.format(this._aggregatedStats.decodeTimeMaxFrame || 0) + "/" + numberFormat.format(this._aggregatedStats.decodeTimePerFrame || 0)
  3769. }), e.push({
  3770. key: "-frmAwait/Lost/Drop",
  3771. value: numberFormat.format(this._aggregatedStats.framesAwait || 0) + "/" + numberFormat.format(this._aggregatedStats.packetsLost || 0) + "/" + numberFormat.format(this._aggregatedStats.packetsDrop || 0) + "/" + numberFormat.format(this._aggregatedStats.updateDropFrame) || 0
  3772. }), e.push({
  3773. key: ":----------------FrameLoop-------------",
  3774. value: ""
  3775. }), e.push({
  3776. key: "interval(max/avg/>40)",
  3777. value: (((h = this._extraStats.maxFrameTime) == null ? void 0 : h.toFixed(1)) || 0) + "/" + (((f = this._extraStats.avgFrameTime) == null ? void 0 : f.toFixed(0)) || 0) + "/" + this._extraStats.engineSloppyCnt
  3778. }), e.push({
  3779. key: "systemStuck",
  3780. value: this._extraStats.systemStuckCnt
  3781. }), e.push({
  3782. key: "--update",
  3783. value: (this._aggregatedStats.maxGraphicTime.toFixed(1) || 0) + "/" + (((d = this._aggregatedStats.averageGraphicTime) == null ? void 0 : d.toFixed(0)) || 0)
  3784. }), e.push({
  3785. key: "--timeout",
  3786. value: (((_ = this._extraStats.maxTimeoutTime) == null ? void 0 : _.toFixed(1)) || 0) + "/" + ((g = this._extraStats.avgTimeoutTime) == null ? void 0 : g.toFixed(0)) || 0
  3787. }), e.push({
  3788. key: "--render",
  3789. value: (((m = this._extraStats.maxRenderFrameTime) == null ? void 0 : m.toFixed(1)) || 0) + "/" + (((v = this._extraStats.renderFrameTime) == null ? void 0 : v.toFixed(0)) || 0)
  3790. }), e.push({
  3791. key: "---anim/regBR/clip(avg ms)",
  3792. value: (this._extraStats.animationTime.toFixed(2) || 0) + " / " + (this._extraStats.registerBeforeRenderTime.toFixed(2) || 0) + " / " + (this._extraStats.meshSelectTime.toFixed(2) || 0)
  3793. }), e.push({
  3794. key: "---anim/regBR/clip(max ms)",
  3795. value: (this._extraStats.maxAnimationTime.toFixed(2) || 0) + " / " + (this._extraStats.maxRegisterBeforeRenderTime.toFixed(2) || 0) + " / " + (this._extraStats.maxMeshSelectTime.toFixed(2) || 0)
  3796. }), e.push({
  3797. key: "---rTR/drC/regAF(avg ms)",
  3798. value: (this._extraStats.renderTargetRenderTime.toFixed(2) || 0) + " / " + (this._extraStats.drawcallTime.toFixed(2) || 0) + " / " + (this._extraStats.registerAfterRenderTime.toFixed(2) || 0)
  3799. }), e.push({
  3800. key: "---rTR/drC/regAF(max ms)",
  3801. value: (this._extraStats.maxRenderTargetRenderTime.toFixed(2) || 0) + " / " + (this._extraStats.maxDrawcallTime.toFixed(2) || 0) + " / " + (this._extraStats.maxRegisterAfterRenderTime.toFixed(2) || 0)
  3802. }), e.push({
  3803. key: "--tri/drC/pati/bones/anim(Num)",
  3804. value: (this._extraStats.triangle || 0) + " / " + (this._extraStats.drawcall.toFixed(0) || 0) + " / " + (this._extraStats.activeParticles.toFixed(0) || 0) + " / " + (this._extraStats.activeBones.toFixed(0) || 0) + " / " + (this._extraStats.activeAnimation.toFixed(0) || 0)
  3805. }), e.push({
  3806. key: "--rootN/mesh/geo/tex/mat(Num)",
  3807. value: (this._extraStats.totalRootNodes.toFixed(0) || 0) + " / " + (this._extraStats.totalMeshes.toFixed(0) || 0) + " / " + (this._extraStats.totalGeometries.toFixed(0) || 0) + " / " + (this._extraStats.totalTextures.toFixed(0) || 0) + " / " + (this._extraStats.totalMaterials.toFixed(0) || 0)
  3808. }), e.push({
  3809. key: "--registerBF/AF(Num)",
  3810. value: (this._extraStats.registerBeforeCount.toFixed(0) || 0) + " / " + (this._extraStats.registerAfterCount.toFixed(0) || 0)
  3811. }), e.push({
  3812. key: ":----------------Rotation-------------------",
  3813. value: ""
  3814. }), e.push({
  3815. key: "Total(ms/miss)",
  3816. value: (((y = this._aggregatedStats.avgOverallTime) == null ? void 0 : y.toFixed(2)) || 0) + "/" + (this._aggregatedStats.responseMissPs + this._aggregatedStats.processMissPs + this._aggregatedStats.displayMissPs)
  3817. }), e.push({
  3818. key: "--rotateRsp",
  3819. value: (((b = this._aggregatedStats.avgResponseTime) == null ? void 0 : b.toFixed(1)) || 0) + "/" + this._aggregatedStats.responseMissPs
  3820. }), e.push({
  3821. key: "--rotateProc",
  3822. value: (((T = this._aggregatedStats.avgProcessTime) == null ? void 0 : T.toFixed(1)) || 0) + "/" + this._aggregatedStats.processMissPs
  3823. }), e.push({
  3824. key: "--rotateShow",
  3825. value: (((C = this._aggregatedStats.avgDisplayTime) == null ? void 0 : C.toFixed(1)) || 0) + "/" + this._aggregatedStats.displayMissPs
  3826. }), ((A = this.room._userAvatar) == null ? void 0 : A.state) == "moving", e.push({
  3827. key: ":----------------Move----------------------",
  3828. value: ""
  3829. }), e.push({
  3830. key: "-startDelay",
  3831. value: (this._aggregatedStats.moveEvent == "MoveTo" ? this._aggregatedStats.moveResponseDelay || 0 : this._aggregatedStats.flyResponseDelay || 0) + "/" + (this._aggregatedStats.moveEvent == "MoveTo" ? this._aggregatedStats.moveProcessDelay || 0 : this._aggregatedStats.flyProcessDelay || 0) + "/" + (this._aggregatedStats.moveEvent == "MoveTo" ? this._aggregatedStats.moveDisplayDelay || 0 : this._aggregatedStats.flyDisplayDelay || 0)
  3832. }), (((S = this.room._userAvatar) == null ? void 0 : S.state) == "moving" || this._aggregatedStats.moveEvent == "GetOnAirship" || this._aggregatedStats.moveEvent == "GetOnVehicle") && e.push({
  3833. key: "-srvInterFrm(max/avg)",
  3834. value: (this._aggregatedStats.maxServerDiff || 0) + "/" + (this._aggregatedStats.avgServerDiff.toFixed(1) || 0)
  3835. }), e.push({
  3836. key: "-interFrameDelay",
  3837. value: "(max/avg/jank)"
  3838. }), e.push({
  3839. key: "--toDisplay",
  3840. value: (this._aggregatedStats.moveEvent == "MoveTo" ? this._aggregatedStats.maxDisplayMoveDiff || 0 : this._aggregatedStats.maxDisplayFlyDiff || 0) + "/" + (this._aggregatedStats.moveEvent == "MoveTo" ? this._aggregatedStats.avgDisplayMoveDiff.toFixed(1) || 0 : this._aggregatedStats.avgDisplayFlyDiff.toFixed(1) || 0) + "/" + (this._aggregatedStats.moveEvent == "MoveTo" ? ((P = this._aggregatedStats.moveDisplayJank) == null ? void 0 : P.toFixed(3)) || 0 : ((R = this._aggregatedStats.flyDisplayJank) == null ? void 0 : R.toFixed(3)) || 0)
  3841. }), e.push({
  3842. key: "--received",
  3843. value: (this._aggregatedStats.moveEvent == "MoveTo" ? this._aggregatedStats.maxResponseMoveDiff || 0 : this._aggregatedStats.maxResponseFlyDiff || 0) + "/" + (this._aggregatedStats.moveEvent == "MoveTo" ? this._aggregatedStats.avgResponseMoveDiff.toFixed(1) || 0 : this._aggregatedStats.avgResponseFlyDiff.toFixed(1) || 0) + "/" + (this._aggregatedStats.moveEvent == "MoveTo" ? ((M = this._aggregatedStats.moveResponseJank) == null ? void 0 : M.toFixed(3)) || 0 : ((x = this._aggregatedStats.flyResponseJank) == null ? void 0 : x.toFixed(3)) || 0)
  3844. }), e.push({
  3845. key: "--decoded",
  3846. value: (this._aggregatedStats.moveEvent == "MoveTo" ? this._aggregatedStats.maxProcessMoveDiff || 0 : this._aggregatedStats.maxProcessFlyDiff || 0) + "/" + (this._aggregatedStats.moveEvent == "MoveTo" ? this._aggregatedStats.avgProcessMoveDiff.toFixed(1) || 0 : this._aggregatedStats.avgProcessFlyDiff.toFixed(1) || 0) + "/" + (this._aggregatedStats.moveEvent == "MoveTo" ? ((I = this._aggregatedStats.moveProcessJank) == null ? void 0 : I.toFixed(3)) || 0 : ((w = this._aggregatedStats.flyProcessJank) == null ? void 0 : w.toFixed(3)) || 0)
  3847. }), e.push({
  3848. key: ":----------------DevInfo-----------------",
  3849. value: ""
  3850. }), e.push({
  3851. key: "sd",
  3852. value: (this._aggregatedStats.sdMoveResponseLongTime.toFixed(1) || 0) + "/" + (this._aggregatedStats.sdMoveProcessLongTime.toFixed(1) || 0) + "/" + (this._aggregatedStats.sdMoveDisplayLongTime.toFixed(1) || 0)
  3853. }), e.push({
  3854. key: "----hardwareInfo",
  3855. value: this._extraStats.hardwareInfo
  3856. });
  3857. var u = "";
  3858. for (var _i = 0, _e = e; _i < _e.length; _i++) {
  3859. var O = _e[_i];
  3860. u += "<div><span>".concat(O.key, "</span>: <span>").concat(O.value, "</span> </div>");
  3861. }
  3862. this._displayElement.innerHTML = u;
  3863. }
  3864. }, {
  3865. key: "onStats",
  3866. value: function onStats(e) {
  3867. var _this4 = this;
  3868. var n;
  3869. if (!e) return;
  3870. var t = {},
  3871. r = this;
  3872. r._aggregatedStats || (r._aggregatedStats = {}), t.timestamp = e.timestamp, t.mediaBytesReceived = e.mediaBytesReceived, t.metaBytesReceived = e.metaBytesReceived, t.packetsLost = e.packetsLost, t.frameHeight = e.frameHeight, t.frameWidth = e.frameWidth, t.framesReceivedUI = e.framesReceived, t.framesReceived = e.framesReceivedWorker, t.framesDecoded = e.framesDecoded, t.framesEmited = e.framesEmited, t.decodeTimePerFrame = e.decodeTimePerFrame, t.decodeTimeMaxFrame = e.decodeTimeMaxFrame, t.packetsDrop = e.packetsDrop, t.framesAwait = e.framesAwait, t.updateDropFrame = e.updateDropFrame, t.firstMediaArraval = e.firstMediaArraval, t.firstYUVDecoded = e.firstYUVDecoded, t.firstRender = e.firstRender, t.returnFrames = e.returnFrames, t.sendOutBuffer = e.sendOutBuffer, t.averageGraphicTime = e.averageGraphicTime, t.maxGraphicTime = e.maxGraphicTime, t.jankTimes = e.jankTimes, t.bigJankTimes = e.bigJankTimes, t.decodeJankTimes = e.decodeJankTimes, t.bigDecodeJankTimes = e.bigDecodeJankTimes, t.serverFrameFast = e.serverFrameFast, t.serverFrameSlow = e.serverFrameSlow, t.clientFrameFast = e.clientFrameFast, t.clientFrameSlow = e.clientFrameSlow, t.rtcMessageReceived = e.rtcMessageReceived, t.rtcBytesReceived = e.rtcBytesReceived, t.receiveIframes = e.receiveIframes, t.decodeIframes = e.decodeIframes, t.avgResponseTime = e.avgResponseTime, t.avgProcessTime = e.avgProcessTime, t.avgDisplayTime = e.avgDisplayTime, t.avgOverallTime = e.avgOverallTime, t.overallTimeCount = e.overallTimeCount, t.responseMiss = e.responseMiss, t.processMiss = e.processMiss, t.displayMiss = e.displayMiss, t.avgResponseMoveDiff = e.avgResponseMoveDiff, t.avgProcessMoveDiff = e.avgProcessMoveDiff, t.avgDisplayMoveDiff = e.avgDisplayMoveDiff, t.maxResponseMoveDiff = e.maxResponseMoveDiff, t.maxProcessMoveDiff = e.maxProcessMoveDiff, t.maxDisplayMoveDiff = e.maxDisplayMoveDiff, t.moveResponseDelay = e.moveResponseDelay, t.moveProcessDelay = e.moveProcessDelay, t.moveDisplayDelay = e.moveDisplayDelay, t.moveResponseJank = e.moveResponseJank, t.moveProcessJank = e.moveProcessJank, t.moveDisplayJank = e.moveDisplayJank, t.avgMetaParseTime = e.avgMetaParseTime, t.maxMetaParseTime = e.maxMetaParseTime, t.moveResponseCounts = e.moveResponseCounts, t.moveProcessCounts = e.moveProcessCounts, t.moveDisplayCounts = e.moveDisplayCounts, t.MoveDisplayCountGood = e.MoveDisplayCountGood, t.MoveDisplayCountWell = e.MoveDisplayCountWell, t.MoveDisplayCountFair = e.MoveDisplayCountFair, t.MoveDisplayCountBad = e.MoveDisplayCountBad, t.MoveDisplayCountRest = e.MoveDisplayCountRest, t.avgServerDiff = e.avgServerDiff, t.maxServerDiff = e.maxServerDiff, t.avgResponseFlyDiff = e.avgResponseFlyDiff, t.avgProcessFlyDiff = e.avgProcessFlyDiff, t.avgDisplayFlyDiff = e.avgDisplayFlyDiff, t.maxResponseFlyDiff = e.maxResponseFlyDiff, t.maxProcessFlyDiff = e.maxProcessFlyDiff, t.maxDisplayFlyDiff = e.maxDisplayFlyDiff, t.flyResponseCounts = e.flyResponseCounts, t.flyProcessCounts = e.flyProcessCounts, t.flyDisplayCounts = e.flyDisplayCounts, t.flyResponseJank = e.flyResponseJank, t.flyProcessJank = e.flyProcessJank, t.flyDisplayJank = e.flyDisplayJank, t.flyResponseDelay = e.flyResponseDelay, t.flyProcessDelay = e.flyProcessDelay, t.flyDisplayDelay = e.flyDisplayDelay, t.moveEvent = e.moveEvent, t.sdMoveResponseLongTime = e.sdMoveResponseLongTime, t.sdMoveProcessLongTime = e.sdMoveProcessLongTime, t.sdMoveDisplayLongTime = e.sdMoveDisplayLongTime, r._aggregatedStats && r._aggregatedStats.timestamp && (t.mediaBitrate = 8 * (t.mediaBytesReceived - r._aggregatedStats.mediaBytesReceived) / 1e3, t.mediaBitrate = Math.round(t.mediaBitrate || 0), t.metaBitrate = 8 * (t.metaBytesReceived - r._aggregatedStats.metaBytesReceived) / 1e3, t.metaBitrate = Math.round(t.metaBitrate || 0), t.rtcMessagePs = t.rtcMessageReceived - r._aggregatedStats.rtcMessageReceived, t.rtcBitrate = 8 * (t.rtcBytesReceived - r._aggregatedStats.rtcBytesReceived) / 1e3, t.rtcBitrate = Math.round(t.rtcBitrate || 0), t.framesEmitedPs = t.framesEmited - r._aggregatedStats.framesEmited, t.framesEmitedPs = Math.round(t.framesEmitedPs || 0), t.framesReceivedPs = t.framesReceived - r._aggregatedStats.framesReceived, t.framesReceivedPs = Math.round(t.framesReceivedPs || 0), t.framesDecodedPs = t.framesDecoded - r._aggregatedStats.framesDecoded, t.framesDecodedPs = Math.round(t.framesDecodedPs || 0), t.returnFramesPs = t.returnFrames - r._aggregatedStats.returnFrames, t.returnFramesPs = Math.round(t.returnFramesPs || 0), t.responseMissPs = t.responseMiss - r._aggregatedStats.responseMiss, t.processMissPs = t.processMiss - r._aggregatedStats.processMiss, t.displayMissPs = t.displayMiss - r._aggregatedStats.displayMiss, t.returnFrames = e.returnFrames), this._show && this._render(), t.registerBeforeRenderTime = this._extraStats.registerBeforeRenderTime, t.registerAfterRenderTime = this._extraStats.registerAfterRenderTime, t.renderTargetRenderTime = this._extraStats.renderTargetRenderTime, t.renderFrameTime = this._extraStats.renderFrameTime, t.maxRenderFrameTime = this._extraStats.maxRenderFrameTime, t.interFrameTime = this._extraStats.interFrameTime, t.animationTime = this._extraStats.animationTime, t.meshSelectTime = this._extraStats.meshSelectTime, t.drawcall = this._extraStats.drawcall, t.drawcallTime = this._extraStats.drawcallTime, t.triangle = this._extraStats.triangle, t.registerAfterCount = this._extraStats.registerAfterCount, t.registerBeforeCount = this._extraStats.registerBeforeCount, t.fps = this._extraStats.fps, t.rtt = this._extraStats.rtt, t.hb = this._extraStats.hb, t.avgFrameTime = this._extraStats.avgFrameTime, t.avgTimeoutTime = this._extraStats.avgTimeoutTime, t.engineSloppyCnt = this._extraStats.engineSloppyCnt, t.systemStuckCnt = this._extraStats.systemStuckCnt, t.avatarState = (n = this.room._userAvatar) == null ? void 0 : n.state, t.maxFrameTime = this._extraStats.maxFrameTime, t.maxTimeoutTime = this._extraStats.maxTimeoutTime, t.activeParticles = this._extraStats.activeParticles, t.activeBones = this._extraStats.activeBones, t.activeAnimation = this._extraStats.activeAnimation, t.totalRootNodes = this._extraStats.totalRootNodes, t.totalGeometries = this._extraStats.totalGeometries, t.totalMeshes = this._extraStats.totalMeshes, t.totalTextures = this._extraStats.totalTextures, t.totalMaterials = this._extraStats.totalMaterials, t.hardwareInfo = this._extraStats.hardwareInfo, t.maxInterFrameTime = this._extraStats.maxInterFrameTime, t.maxDrawcallTime = this._extraStats.maxDrawcallTime, t.maxMeshSelectTime = this._extraStats.maxMeshSelectTime, t.maxAnimationTime = this._extraStats.maxAnimationTime, t.maxRegisterBeforeRenderTime = this._extraStats.maxRegisterBeforeRenderTime, t.maxRegisterAfterRenderTime = this._extraStats.maxRegisterAfterRenderTime, t.maxRenderTargetRenderTime = this._extraStats.maxRenderTargetRenderTime, this.externalStats && Object.keys(this.externalStats || {}).forEach(function (o) {
  3873. t[o] = _this4.externalStats[o];
  3874. }), r._aggregatedStats = t, this.emit("stats", {
  3875. stats: t
  3876. });
  3877. }
  3878. }]);
  3879. return Stats;
  3880. }(EventEmitter);
  3881. function _createSuper$a(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$a(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  3882. function _isNativeReflectConstruct$a() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  3883. var EventsManager = /*#__PURE__*/function (_EventEmitter) {
  3884. _inherits(EventsManager, _EventEmitter);
  3885. var _super = _createSuper$a(EventsManager);
  3886. function EventsManager() {
  3887. var _this;
  3888. _classCallCheck(this, EventsManager);
  3889. _this = _super.apply(this, arguments);
  3890. E(_assertThisInitialized(_this), "events", new Map());
  3891. E(_assertThisInitialized(_this), "specialEvents", new Map());
  3892. return _this;
  3893. }
  3894. _createClass(EventsManager, [{
  3895. key: "remove",
  3896. value: function remove(e, t, r, n) {
  3897. if (this.specialEvents.has(e) && !n && t === Codes$1.Success) return;
  3898. this.events.get(e) && (this.emit(e, {
  3899. code: t,
  3900. data: r
  3901. }), this.events.delete(e), this.specialEvents.delete(e));
  3902. }
  3903. }, {
  3904. key: "track",
  3905. value: function () {
  3906. var _track = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e, t) {
  3907. var _this2 = this;
  3908. var r, _ref, n, _ref$noReport, o, a, s, l, u, c;
  3909. return regenerator.wrap(function _callee$(_context) {
  3910. while (1) {
  3911. switch (_context.prev = _context.next) {
  3912. case 0:
  3913. r = e.traceId;
  3914. this.emitTraceIdToDecoder(e);
  3915. _ref = t || {}, n = _ref.sampleRate, _ref$noReport = _ref.noReport, o = _ref$noReport === void 0 ? !1 : _ref$noReport, a = _ref.special;
  3916. if (!(n && Math.random() > n)) {
  3917. _context.next = 5;
  3918. break;
  3919. }
  3920. return _context.abrupt("return", Promise.resolve());
  3921. case 5:
  3922. s = Actions[e.event] + "Action", l = e.tag;
  3923. this.events.set(r, !0), a && this.specialEvents.set(r, !0);
  3924. u = Date.now();
  3925. c = null;
  3926. return _context.abrupt("return", new Promise(function (h, f) {
  3927. if (o) return _this2.off(r), _this2.events.delete(r), h(void 0);
  3928. _this2.on(r, function (_ref2) {
  3929. var _ = _ref2.code,
  3930. g = _ref2.data,
  3931. m = _ref2.msg;
  3932. if (_ === Codes$1.Success) h(g), _this2.off(r), logger$1.infoAndReportMeasurement({
  3933. metric: s,
  3934. tag: l,
  3935. extra: e.extra,
  3936. startTime: u,
  3937. traceId: r
  3938. });else {
  3939. if (_ === Codes$1.ActionMaybeDelay) return;
  3940. if (_ === Codes$1.DoActionBlocked && e.event === Actions.Rotation) {
  3941. logger$1.debug(s + " response code: " + _);
  3942. return;
  3943. }
  3944. var v = util.getErrorByCode(_),
  3945. y = new v(m);
  3946. _this2.off(r), f(y), _this2.emit("actionResponseError", {
  3947. error: y,
  3948. event: e,
  3949. tag: l
  3950. }), logger$1.infoAndReportMeasurement({
  3951. metric: s,
  3952. tag: l,
  3953. extra: e.extra,
  3954. error: y,
  3955. startTime: u,
  3956. traceId: r
  3957. });
  3958. }
  3959. });
  3960. var d = e.timeout || 2e3;
  3961. c = window.setTimeout(function () {
  3962. if (c && clearTimeout(c), !_this2.events.get(r)) return;
  3963. var _ = new ActionResponseTimeoutError("".concat(s, " timeout in ").concat(d, "ms"));
  3964. _this2.emit("actionResponseTimeout", {
  3965. error: _,
  3966. event: e,
  3967. tag: l
  3968. }), f(_), _this2.events.delete(r), _this2.off(r), logger$1.infoAndReportMeasurement({
  3969. metric: s,
  3970. tag: l,
  3971. extra: e.extra,
  3972. error: _,
  3973. startTime: u,
  3974. traceId: r
  3975. });
  3976. }, d);
  3977. }));
  3978. case 10:
  3979. case "end":
  3980. return _context.stop();
  3981. }
  3982. }
  3983. }, _callee, this);
  3984. }));
  3985. function track(_x, _x2) {
  3986. return _track.apply(this, arguments);
  3987. }
  3988. return track;
  3989. }()
  3990. }, {
  3991. key: "emitTraceIdToDecoder",
  3992. value: function emitTraceIdToDecoder(e) {
  3993. if (e.event === Actions.Rotation || e.event === Actions.Clicking || e.event === Actions.GetOnVehicle || e.event === Actions.GetOffVehicle) {
  3994. var t = {
  3995. [Actions.Rotation]: "Rotation",
  3996. [Actions.GetOnVehicle]: "GetOnVehicle",
  3997. [Actions.GetOffVehicle]: "GetOffVehicle",
  3998. [Actions.Clicking]: "MoveTo"
  3999. };
  4000. this.emit("traceId", {
  4001. traceId: e.traceId,
  4002. timestamp: Date.now(),
  4003. event: t[e.event]
  4004. });
  4005. }
  4006. }
  4007. }]);
  4008. return EventsManager;
  4009. }(EventEmitter);
  4010. var eventsManager = new EventsManager();
  4011. var QueueActions = [Actions.Transfer, Actions.ChangeSkin, Actions.GetOnVehicle, Actions.GetOffVehicle];
  4012. var ActionsHandler = /*#__PURE__*/function () {
  4013. function ActionsHandler(e) {
  4014. _classCallCheck(this, ActionsHandler);
  4015. this.currentActiveAction = null;
  4016. this.room = e;
  4017. }
  4018. _createClass(ActionsHandler, [{
  4019. key: "avatarComponentsSync",
  4020. value: function () {
  4021. var _avatarComponentsSync = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  4022. var t;
  4023. return regenerator.wrap(function _callee$(_context) {
  4024. while (1) {
  4025. switch (_context.prev = _context.next) {
  4026. case 0:
  4027. t = {
  4028. action_type: Actions.SetPlayerState,
  4029. set_player_state_action: {
  4030. player_state: {
  4031. avatar_components: JSON.stringify(e)
  4032. }
  4033. }
  4034. };
  4035. this.sendData({
  4036. data: t
  4037. });
  4038. case 2:
  4039. case "end":
  4040. return _context.stop();
  4041. }
  4042. }
  4043. }, _callee, this);
  4044. }));
  4045. function avatarComponentsSync(_x) {
  4046. return _avatarComponentsSync.apply(this, arguments);
  4047. }
  4048. return avatarComponentsSync;
  4049. }()
  4050. }, {
  4051. key: "sendData",
  4052. value: function () {
  4053. var _sendData = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(e) {
  4054. var _this = this;
  4055. var t, _e$sampleRate, r, _e$timeout, n, o, a, s;
  4056. return regenerator.wrap(function _callee2$(_context2) {
  4057. while (1) {
  4058. switch (_context2.prev = _context2.next) {
  4059. case 0:
  4060. _context2.next = 2;
  4061. return this.beforeSend(e);
  4062. case 2:
  4063. t = util.uuid();
  4064. if (!(this.room.networkController.sendRtcData(le(oe({}, e.data), {
  4065. trace_id: t,
  4066. user_id: this.room.options.userId
  4067. })), e.track === !1)) {
  4068. _context2.next = 5;
  4069. break;
  4070. }
  4071. return _context2.abrupt("return", Promise.resolve(null));
  4072. case 5:
  4073. _e$sampleRate = e.sampleRate, r = _e$sampleRate === void 0 ? 1 : _e$sampleRate, _e$timeout = e.timeout, n = _e$timeout === void 0 ? 2e3 : _e$timeout, o = e.tag, a = e.data, s = e.special;
  4074. return _context2.abrupt("return", eventsManager.track({
  4075. timeout: n,
  4076. traceId: t,
  4077. event: a.action_type,
  4078. tag: o,
  4079. extra: a
  4080. }, {
  4081. special: s,
  4082. sampleRate: r,
  4083. noReport: this.room.viewMode === "serverless" || this.room.options.viewMode === "serverless"
  4084. }).finally(function () {
  4085. QueueActions.includes(e.data.action_type) && (_this.currentActiveAction = void 0);
  4086. }));
  4087. case 7:
  4088. case "end":
  4089. return _context2.stop();
  4090. }
  4091. }
  4092. }, _callee2, this);
  4093. }));
  4094. function sendData(_x2) {
  4095. return _sendData.apply(this, arguments);
  4096. }
  4097. return sendData;
  4098. }()
  4099. }, {
  4100. key: "beforeSend",
  4101. value: function () {
  4102. var _beforeSend = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e) {
  4103. var o, t, r;
  4104. return regenerator.wrap(function _callee3$(_context3) {
  4105. while (1) {
  4106. switch (_context3.prev = _context3.next) {
  4107. case 0:
  4108. t = (o = this.room._userAvatar) == null ? void 0 : o.isMoving, r = e.data.action_type;
  4109. if (!QueueActions.includes(r)) {
  4110. _context3.next = 5;
  4111. break;
  4112. }
  4113. if (!this.currentActiveAction) {
  4114. _context3.next = 4;
  4115. break;
  4116. }
  4117. return _context3.abrupt("return", (logger$1.error("".concat(Actions[this.currentActiveAction], " still pending, reject ").concat(Actions[r])), Promise.reject(new FrequencyLimitError("".concat(Actions[r], " action request frequency limit")))));
  4118. case 4:
  4119. this.currentActiveAction = r;
  4120. case 5:
  4121. if (!(t && QueueActions.includes(e.data.action_type))) {
  4122. _context3.next = 14;
  4123. break;
  4124. }
  4125. _context3.prev = 6;
  4126. _context3.next = 9;
  4127. return this.stopMoving();
  4128. case 9:
  4129. _context3.next = 14;
  4130. break;
  4131. case 11:
  4132. _context3.prev = 11;
  4133. _context3.t0 = _context3["catch"](6);
  4134. this.currentActiveAction = void 0, logger$1.error("before action stopMoving failed", _context3.t0);
  4135. case 14:
  4136. case "end":
  4137. return _context3.stop();
  4138. }
  4139. }
  4140. }, _callee3, this, [[6, 11]]);
  4141. }));
  4142. function beforeSend(_x3) {
  4143. return _beforeSend.apply(this, arguments);
  4144. }
  4145. return beforeSend;
  4146. }()
  4147. }, {
  4148. key: "moveTo",
  4149. value: function () {
  4150. var _moveTo = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(e) {
  4151. var t, _e$extra, r, n, o;
  4152. return regenerator.wrap(function _callee4$(_context4) {
  4153. while (1) {
  4154. switch (_context4.prev = _context4.next) {
  4155. case 0:
  4156. t = e.point, _e$extra = e.extra, r = _e$extra === void 0 ? "" : _e$extra, n = e.motionType, o = {
  4157. action_type: Actions.Clicking,
  4158. clicking_action: {
  4159. clicking_point: t,
  4160. clicking_type: ClickType.IgnoreView,
  4161. extra: encodeURIComponent(r),
  4162. attitude: n
  4163. },
  4164. clicking_state: this.room._currentClickingState
  4165. };
  4166. return _context4.abrupt("return", this.sendData({
  4167. data: o
  4168. }));
  4169. case 2:
  4170. case "end":
  4171. return _context4.stop();
  4172. }
  4173. }
  4174. }, _callee4, this);
  4175. }));
  4176. function moveTo(_x4) {
  4177. return _moveTo.apply(this, arguments);
  4178. }
  4179. return moveTo;
  4180. }()
  4181. }, {
  4182. key: "transfer",
  4183. value: function transfer(e) {
  4184. var _this2 = this;
  4185. var t = e.renderType,
  4186. r = e.player,
  4187. n = e.camera,
  4188. o = e.areaName,
  4189. a = e.attitude,
  4190. s = e.pathName,
  4191. l = e.person,
  4192. u = e.noMedia,
  4193. c = e.timeout,
  4194. h = e.tag,
  4195. f = e.special,
  4196. d = {
  4197. data: {
  4198. action_type: Actions.Transfer,
  4199. transfer_action: {
  4200. render_type: t,
  4201. player: r,
  4202. camera: n,
  4203. areaName: o,
  4204. attitude: a,
  4205. pathName: s,
  4206. person: {
  4207. type: l
  4208. },
  4209. noMedia: u,
  4210. tiles: [0, 1, 2, 4]
  4211. }
  4212. },
  4213. special: f,
  4214. timeout: c || 4e3,
  4215. tag: h
  4216. };
  4217. return this.sendData(d).then(function (_) {
  4218. return typeof l != "undefined" && _this2.room.updateCurrentNetworkOptions({
  4219. person: l,
  4220. rotationRenderType: t
  4221. }), _;
  4222. });
  4223. }
  4224. }, {
  4225. key: "changeRotationRenderType",
  4226. value: function changeRotationRenderType(e) {
  4227. var t = e.renderType,
  4228. r = e.player,
  4229. n = e.camera,
  4230. o = e.areaName,
  4231. a = e.attitude,
  4232. s = e.pathName;
  4233. return this.transfer({
  4234. renderType: t,
  4235. player: r,
  4236. camera: n,
  4237. areaName: o,
  4238. attitude: a,
  4239. pathName: s,
  4240. tag: "changeToRotationVideo"
  4241. });
  4242. }
  4243. }, {
  4244. key: "requestPanorama",
  4245. value: function requestPanorama(e, t, r) {
  4246. var n = e.camera,
  4247. o = e.player,
  4248. a = e.areaName,
  4249. s = e.attitude,
  4250. l = e.pathName,
  4251. u = e.tag;
  4252. return this.transfer({
  4253. renderType: RenderType.ClientRotationPano,
  4254. player: o,
  4255. camera: n,
  4256. person: Person.First,
  4257. areaName: a,
  4258. attitude: s,
  4259. pathName: l,
  4260. noMedia: t,
  4261. timeout: r,
  4262. tag: u || "requestPanorama",
  4263. special: !t
  4264. });
  4265. }
  4266. }, {
  4267. key: "setMotionType",
  4268. value: function setMotionType(e) {
  4269. return this.transfer({
  4270. attitude: e,
  4271. tag: "setMotionType"
  4272. });
  4273. }
  4274. }, {
  4275. key: "setNickName",
  4276. value: function setNickName(e) {
  4277. var t = {
  4278. action_type: Actions.ChangeNickname,
  4279. change_nickname_action: {
  4280. nickname: e
  4281. }
  4282. };
  4283. return this.sendData({
  4284. data: t
  4285. });
  4286. }
  4287. }, {
  4288. key: "getReserveSeat",
  4289. value: function getReserveSeat(_ref) {
  4290. var e = _ref.routeId,
  4291. t = _ref.name;
  4292. var r = {
  4293. action_type: Actions.ReserveSeat,
  4294. reserve_seat_action: {
  4295. route_id: e,
  4296. name: t
  4297. }
  4298. };
  4299. return this.sendData({
  4300. data: r
  4301. });
  4302. }
  4303. }, {
  4304. key: "getReserveStatus",
  4305. value: function getReserveStatus(_ref2) {
  4306. var e = _ref2.routeId,
  4307. t = _ref2.name,
  4308. r = _ref2.need_detail;
  4309. var n = {
  4310. action_type: Actions.GetReserveStatus,
  4311. get_reserve_status_action: {
  4312. route_id: e,
  4313. name: t,
  4314. need_detail: r
  4315. }
  4316. };
  4317. return this.sendData({
  4318. data: n,
  4319. timeout: 2e3
  4320. }).then(function (o) {
  4321. return o.reserveDetail;
  4322. });
  4323. }
  4324. }, {
  4325. key: "stopMoving",
  4326. value: function stopMoving() {
  4327. var e = {
  4328. action_type: Actions.StopMoving,
  4329. stop_move_action: {}
  4330. };
  4331. return this.sendData({
  4332. data: e
  4333. });
  4334. }
  4335. }, {
  4336. key: "getOnVehicle",
  4337. value: function getOnVehicle(_ref3) {
  4338. var e = _ref3.routeId,
  4339. t = _ref3.name,
  4340. r = _ref3.camera;
  4341. var n = {
  4342. action_type: Actions.GetOnVehicle,
  4343. get_on_vehicle_action: {
  4344. route_id: e,
  4345. name: t,
  4346. camera: r
  4347. }
  4348. };
  4349. return this.sendData({
  4350. data: n
  4351. });
  4352. }
  4353. }, {
  4354. key: "getOffVehicle",
  4355. value: function getOffVehicle(_ref4) {
  4356. var e = _ref4.renderType,
  4357. t = _ref4.player,
  4358. r = _ref4.camera;
  4359. var n = {
  4360. action_type: Actions.GetOffVehicle,
  4361. get_off_vehicle_action: {
  4362. render_type: e,
  4363. player: t,
  4364. camera: r
  4365. }
  4366. };
  4367. return this.sendData({
  4368. data: n
  4369. });
  4370. }
  4371. }, {
  4372. key: "confirmEvent",
  4373. value: function confirmEvent(e) {
  4374. var t = {
  4375. action_type: Actions.ConfirmEvent,
  4376. confirm_event_action: {
  4377. id: e
  4378. }
  4379. };
  4380. return this.sendData({
  4381. data: t,
  4382. track: !1
  4383. });
  4384. }
  4385. }, {
  4386. key: "echo",
  4387. value: function echo(e) {
  4388. var t = {
  4389. action_type: Actions.Echo,
  4390. echo_msg: {
  4391. echoMsg: e
  4392. }
  4393. };
  4394. return this.sendData({
  4395. data: t,
  4396. track: !1
  4397. });
  4398. }
  4399. }, {
  4400. key: "changeSkin",
  4401. value: function () {
  4402. var _changeSkin = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6(e) {
  4403. var _this3 = this;
  4404. var t, r, n, _e$landingType, o, a, s, l, u, c, h, f, d, _, _e$roomTypeId, g, m, y, v;
  4405. return regenerator.wrap(function _callee6$(_context6) {
  4406. while (1) {
  4407. switch (_context6.prev = _context6.next) {
  4408. case 0:
  4409. t = e.special === void 0 ? e.renderType === RenderType.ClientRotationPano : e.special, r = e.skinId, n = e.mode, _e$landingType = e.landingType, o = _e$landingType === void 0 ? LandingType.Stay : _e$landingType, a = e.landingPoint, s = e.landingCamera, l = e.renderType, u = e.areaName, c = e.attitude, h = e.pathName, f = e.person, d = e.noMedia, _ = e.timeout, _e$roomTypeId = e.roomTypeId, g = _e$roomTypeId === void 0 ? "" : _e$roomTypeId, m = this.room.skinList.filter(function (y) {
  4410. return y.id === r;
  4411. })[0];
  4412. if (m) {
  4413. _context6.next = 4;
  4414. break;
  4415. }
  4416. y = "skin ".concat(r, " is invalid");
  4417. return _context6.abrupt("return", (logger$1.error(y), Promise.reject(new ParamError(y))));
  4418. case 4:
  4419. v = {
  4420. action_type: Actions.ChangeSkin,
  4421. change_skin_action: {
  4422. skinID: r,
  4423. mode: n === ChangeMode.Preview ? ChangeMode.Preview : ChangeMode.Confirm,
  4424. skin_data_version: r + m.versionId,
  4425. landing_type: o,
  4426. landing_point: a,
  4427. landing_camera: s,
  4428. render_wrapper: {
  4429. render_type: l
  4430. },
  4431. areaName: u,
  4432. attitude: c,
  4433. noMedia: d,
  4434. person: f,
  4435. pathName: h,
  4436. roomTypeId: g
  4437. }
  4438. };
  4439. return _context6.abrupt("return", this.sendData({
  4440. data: v,
  4441. timeout: _ || 6e3,
  4442. special: t
  4443. }).then( /*#__PURE__*/function () {
  4444. var _ref5 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(y) {
  4445. var b, _ref6, T;
  4446. return regenerator.wrap(function _callee5$(_context5) {
  4447. while (1) {
  4448. switch (_context5.prev = _context5.next) {
  4449. case 0:
  4450. if (!(l === RenderType.ClientRotationPano && y)) {
  4451. _context5.next = 8;
  4452. break;
  4453. }
  4454. _context5.next = 3;
  4455. return _this3.room.modelManager.findRoute(r, h);
  4456. case 3:
  4457. b = _context5.sent;
  4458. _ref6 = util.getRandomItem(b.birthPointList) || {};
  4459. T = _ref6.camera;
  4460. _context5.next = 8;
  4461. return _this3.room.panorama.handleReceivePanorama(y, T);
  4462. case 8:
  4463. return _context5.abrupt("return", _this3.handleChangeSkin(e));
  4464. case 9:
  4465. case "end":
  4466. return _context5.stop();
  4467. }
  4468. }
  4469. }, _callee5);
  4470. }));
  4471. return function (_x6) {
  4472. return _ref5.apply(this, arguments);
  4473. };
  4474. }()).catch(function (y) {
  4475. return d ? _this3.handleChangeSkin(e) : Promise.reject(y);
  4476. }));
  4477. case 6:
  4478. case "end":
  4479. return _context6.stop();
  4480. }
  4481. }
  4482. }, _callee6, this);
  4483. }));
  4484. function changeSkin(_x5) {
  4485. return _changeSkin.apply(this, arguments);
  4486. }
  4487. return changeSkin;
  4488. }()
  4489. }, {
  4490. key: "handleChangeSkin",
  4491. value: function handleChangeSkin(e) {
  4492. var _this4 = this;
  4493. var t = e.skinId,
  4494. r = e.mode,
  4495. n = e.renderType,
  4496. o = e.areaName,
  4497. a = e.attitude,
  4498. s = e.pathName;
  4499. return this.room.sceneManager.staticmeshComponent.getCgMesh().show(), this.room.sceneManager.cameraComponent.switchToCgCamera(), this.room.engineProxy._updateSkinAssets(t).then(function () {
  4500. _this4.room.sceneManager.staticmeshComponent.getCgMesh().hide(), _this4.room.sceneManager.cameraComponent.switchToMainCamera(), _this4.room.pathManager.currentArea = o, logger$1.info("changeSkin _updateSkinAssets susccss"), _this4.room.updateCurrentNetworkOptions({
  4501. pathName: s,
  4502. attitude: a,
  4503. areaName: o
  4504. }), _this4.room.skinChangedHook(), _this4.room.emit("skinChanged", {
  4505. skin: {
  4506. id: t
  4507. },
  4508. mode: r
  4509. }), n === RenderType.ClientRotationPano && _this4.room.sceneManager.cameraComponent.allowMainCameraController();
  4510. });
  4511. }
  4512. }, {
  4513. key: "rotate",
  4514. value: function rotate(_ref7) {
  4515. var e = _ref7.pitch,
  4516. t = _ref7.yaw;
  4517. var n;
  4518. if (this.room.disableRotate || this.room.isPano || ((n = this.room._userAvatar) == null ? void 0 : n._isChangingComponentsMode)) return;
  4519. var r = {
  4520. action_type: Actions.Rotation,
  4521. rotation_action: {
  4522. vertical_move: e,
  4523. horizontal_move: -t
  4524. }
  4525. };
  4526. this.sendData({
  4527. data: r,
  4528. sampleRate: .02
  4529. });
  4530. }
  4531. }, {
  4532. key: "turnTo",
  4533. value: function turnTo(e) {
  4534. var _ref8 = e || {},
  4535. t = _ref8.point,
  4536. _ref8$timeout = _ref8.timeout,
  4537. r = _ref8$timeout === void 0 ? 2e3 : _ref8$timeout,
  4538. _ref8$offset = _ref8.offset,
  4539. n = _ref8$offset === void 0 ? 8 : _ref8$offset,
  4540. o = {
  4541. action_type: Actions.TurnTo,
  4542. turn_to_action: {
  4543. turn_to_point: t,
  4544. offset: n
  4545. }
  4546. };
  4547. return this.sendData({
  4548. data: o,
  4549. timeout: r
  4550. });
  4551. }
  4552. }, {
  4553. key: "rotateTo",
  4554. value: function rotateTo(e) {
  4555. var _ref9 = e || {},
  4556. t = _ref9.point,
  4557. _ref9$offset = _ref9.offset,
  4558. r = _ref9$offset === void 0 ? 0 : _ref9$offset,
  4559. _ref9$speed = _ref9.speed,
  4560. n = _ref9$speed === void 0 ? 3 : _ref9$speed,
  4561. o = {
  4562. action_type: Actions.RotateTo,
  4563. rotate_to_action: {
  4564. rotate_to_point: t,
  4565. offset: r,
  4566. speed: n
  4567. }
  4568. };
  4569. return this.sendData({
  4570. data: o
  4571. });
  4572. }
  4573. }, {
  4574. key: "broadcast",
  4575. value: function broadcast(e) {
  4576. var t = e.data,
  4577. _e$msgType = e.msgType,
  4578. r = _e$msgType === void 0 ? MessageHandleType.MHT_FollowListMulticast : _e$msgType,
  4579. n = e.targetUserIds;
  4580. if (r === MessageHandleType.MHT_CustomTargetSync && !Array.isArray(n)) return Promise.reject(new ParamError("param targetUserIds is required when msgType is ".concat(MessageHandleType[r])));
  4581. var o = {
  4582. action_type: Actions.Broadcast,
  4583. broadcast_action: {
  4584. data: JSON.stringify(t),
  4585. user_id: this.room.options.userId,
  4586. msgType: r
  4587. }
  4588. };
  4589. return Array.isArray(n) && r === MessageHandleType.MHT_CustomTargetSync && (o.broadcast_action.target_user_ids = n), this.room.actionsHandler.sendData({
  4590. data: o,
  4591. tag: t.broadcastType
  4592. });
  4593. }
  4594. }, {
  4595. key: "getNeighborPoints",
  4596. value: function getNeighborPoints(e) {
  4597. var t = e.point,
  4598. _e$containSelf = e.containSelf,
  4599. r = _e$containSelf === void 0 ? !1 : _e$containSelf,
  4600. _e$searchRange = e.searchRange,
  4601. n = _e$searchRange === void 0 ? 500 : _e$searchRange,
  4602. o = {
  4603. action_type: Actions.GetNeighborPoints,
  4604. get_neighbor_points_action: {
  4605. point: t,
  4606. level: 1,
  4607. containSelf: r,
  4608. searchRange: n
  4609. }
  4610. };
  4611. return this.sendData({
  4612. data: o
  4613. }).then(function (a) {
  4614. return a.nps;
  4615. });
  4616. }
  4617. }, {
  4618. key: "playCG",
  4619. value: function playCG(e) {
  4620. var t = {
  4621. action_type: Actions.PlayCG,
  4622. play_cg_action: {
  4623. cg_name: e
  4624. }
  4625. };
  4626. return this.sendData({
  4627. data: t
  4628. });
  4629. }
  4630. }, {
  4631. key: "audienceToVisitor",
  4632. value: function audienceToVisitor(e) {
  4633. var t = e.avatarId,
  4634. r = e.avatarComponents,
  4635. n = e.player,
  4636. o = e.camera,
  4637. a = {
  4638. action_type: Actions.AudienceChangeToVisitor,
  4639. audienceChangeToVisitorAction: {
  4640. avatarID: t,
  4641. avatarComponents: r,
  4642. player: n,
  4643. camera: o
  4644. }
  4645. };
  4646. return logger$1.debug("send data: audience to visitor"), this.sendData({
  4647. data: a
  4648. });
  4649. }
  4650. }, {
  4651. key: "visitorToAudience",
  4652. value: function visitorToAudience(e) {
  4653. var t = e.renderType,
  4654. r = e.player,
  4655. n = e.camera,
  4656. o = e.areaName,
  4657. a = e.attitude,
  4658. s = e.pathName,
  4659. l = e.person,
  4660. u = e.noMedia,
  4661. c = {
  4662. action_type: Actions.VisitorChangeToAudience,
  4663. visitorChangeToAudienceAction: {
  4664. transferAction: {
  4665. render_type: t,
  4666. player: r,
  4667. camera: n,
  4668. areaName: o,
  4669. attitude: a,
  4670. pathName: s,
  4671. person: {
  4672. type: l
  4673. },
  4674. noMedia: u,
  4675. tiles: [0, 1, 2, 4]
  4676. }
  4677. }
  4678. };
  4679. return logger$1.debug("send data: visitor to audience"), this.sendData({
  4680. data: c
  4681. });
  4682. }
  4683. }, {
  4684. key: "removeVisitor",
  4685. value: function removeVisitor(e) {
  4686. var t = e.removeType,
  4687. r = e.userIDList,
  4688. _e$extraInfo = e.extraInfo,
  4689. n = _e$extraInfo === void 0 ? "" : _e$extraInfo,
  4690. o = {
  4691. action_type: Actions.RemoveVisitor,
  4692. removeVisitorAction: {
  4693. removeVisitorEvent: t,
  4694. userIDList: r,
  4695. extraInfo: encodeURIComponent(n)
  4696. }
  4697. };
  4698. return logger$1.debug("send data: remove visitor"), this.sendData({
  4699. data: o
  4700. });
  4701. }
  4702. }, {
  4703. key: "getUserWithAvatar",
  4704. value: function getUserWithAvatar(e, t) {
  4705. var r = {
  4706. action_type: Actions.GetUserWithAvatar,
  4707. getUserWithAvatarAction: {
  4708. userType: e,
  4709. roomID: t
  4710. }
  4711. };
  4712. return logger$1.debug("send data: get user with avatar"), this.sendData({
  4713. data: r
  4714. }).then(function (n) {
  4715. return n.userWithAvatarList;
  4716. });
  4717. }
  4718. }, {
  4719. key: "joystick",
  4720. value: function joystick(e) {
  4721. var t = e.degree,
  4722. _e$level = e.level,
  4723. r = _e$level === void 0 ? 1 : _e$level,
  4724. n = util.uuid();
  4725. var o = -t + 90 + 360;
  4726. o >= 360 && (o -= 360);
  4727. var a = {
  4728. action_type: Actions.Joystick,
  4729. dir_action: {
  4730. move_angle: o,
  4731. speed_level: r
  4732. },
  4733. trace_id: n,
  4734. user_id: this.room.options.userId,
  4735. packet_id: n
  4736. };
  4737. return this.sendData({
  4738. data: a,
  4739. track: !1
  4740. });
  4741. }
  4742. }]);
  4743. return ActionsHandler;
  4744. }();
  4745. var ECurrentShaderMode = {
  4746. default: 0,
  4747. video: 1,
  4748. pano: 2
  4749. };
  4750. var Signal = /*#__PURE__*/function () {
  4751. function Signal(e) {
  4752. _classCallCheck(this, Signal);
  4753. this.signalHandleActived = !0;
  4754. this.isUpdatedYUV = !0;
  4755. this._room = e;
  4756. }
  4757. _createClass(Signal, [{
  4758. key: "handleSignal",
  4759. value: function handleSignal(e) {
  4760. var _this = this;
  4761. var a, s, l;
  4762. if (!this.signalHandleActived) return;
  4763. var t = e.signal,
  4764. r = e.alreadyUpdateYUV;
  4765. if (this.handleActionResponses(t), this._room.handleSignalHook(t), !r) {
  4766. var u = (a = t.newUserStates) == null ? void 0 : a.find(function (c) {
  4767. return c.userId === _this._room.userId;
  4768. });
  4769. if ((u == null ? void 0 : u.renderInfo) && ((s = this._room._userAvatar) == null ? void 0 : s.isMoving)) {
  4770. logger$1.debug("stream stoped, make avatar to stop");
  4771. var _u$renderInfo = u.renderInfo,
  4772. c = _u$renderInfo.isMoving,
  4773. h = _u$renderInfo.isRotating;
  4774. this._room.avatarManager._updateAvatarMovingStatus({
  4775. id: u.userId,
  4776. isMoving: !!c,
  4777. isRotating: !!h
  4778. });
  4779. }
  4780. return;
  4781. }
  4782. this.isUpdatedYUV = r;
  4783. var n = t;
  4784. if (!t) {
  4785. logger$1.warn("metadata signal is empty");
  4786. return;
  4787. }
  4788. if (n.code === Codes.RepeatLogin) {
  4789. this._room.handleRepetLogin();
  4790. return;
  4791. }
  4792. n.code !== void 0 && n.code !== Codes.Success && n.code !== Codes.ActionMaybeDelay && n.code !== Codes.DoActionBlocked && n.code !== Codes.GetOnVehicle && (logger$1.error("signal errcode: ", n), this._room.emit("error", n));
  4793. var o = (l = n.newUserStates) == null ? void 0 : l.find(function (u) {
  4794. return u.userId === _this._room.userId;
  4795. });
  4796. if (n.broadcastAction) try {
  4797. var _u = JSON.parse(n.broadcastAction.data);
  4798. Broadcast.handlers.forEach(function (c) {
  4799. return c(_u);
  4800. });
  4801. } catch (u) {
  4802. logger$1.error(u);
  4803. }
  4804. if (n.newUserStates && n.newUserStates.length > 0 && this._room.avatarManager.handleAvatar(n), o != null && o.playerState) {
  4805. this._room._currentClickingState = o.playerState;
  4806. var _o$playerState = o.playerState,
  4807. _u2 = _o$playerState.pathName,
  4808. _c = _o$playerState.attitude,
  4809. _h = _o$playerState.areaName,
  4810. f = _o$playerState.skinId;
  4811. if (_u2 && (this._room.pathManager.currentPathName = _u2, this._room.updateCurrentState({
  4812. pathName: _u2
  4813. })), f && this.udpateSkinInfo(f), _h && this._room.updateCurrentState({
  4814. areaName: _h
  4815. }), _c) {
  4816. var d = this._room.skin.routeList.find(function (g) {
  4817. return g.areaName === _this._room.currentState.areaName;
  4818. }),
  4819. _ = ((d == null ? void 0 : d.step) || 7.5) * 30;
  4820. this._room.updateCurrentState({
  4821. speed: _,
  4822. attitude: _c
  4823. }), this._room.pathManager.currentAttitude = _c, this._room._userAvatar && (this._room._userAvatar.motionType = _c);
  4824. }
  4825. this._room.sceneManager.getCurrentShaderMode() !== ECurrentShaderMode.pano && !this._room.isPano && o.playerState.camera && this._room.camera.setCameraPose(o.playerState.camera);
  4826. }
  4827. if (o != null && o.renderInfo && this._room.camera.handleRenderInfo(o), n.actionType !== void 0) {
  4828. var _u3 = n.actionType,
  4829. _c2 = n.code,
  4830. _h2 = n.echoMsg,
  4831. _f = n.traceId;
  4832. _u3 === Actions.Echo && _c2 === Codes.Success && this._room.networkController.rtcp.heartbeat.pong(_h2, _f), _c2 !== Codes.Success ? eventsManager.remove(_f, _c2) : [Actions.GetReserveStatus, Actions.Broadcast, Actions.ChangeNickname, Actions.ConfirmEvent, Actions.ReserveSeat, Actions.Rotation, Actions.TurnTo, Actions.RotateTo, Actions.SetPlayerState, Actions.GetNeighborPoints, Actions.TurnToFace, Actions.AudienceChangeToVisitor, Actions.RemoveVisitor, Actions.GetUserWithAvatar].includes(_u3) && eventsManager.remove(_f, _c2, n);
  4833. }
  4834. }
  4835. }, {
  4836. key: "handleActionResponses",
  4837. value: function handleActionResponses(e) {
  4838. var _this2 = this;
  4839. !(e != null && e.actionResponses) || e.actionResponses.length === 0 || e.actionResponses.forEach(function (t) {
  4840. if (t.actionType == null) return;
  4841. var r = t.pointType,
  4842. n = t.extra,
  4843. o = t.actionType,
  4844. a = t.traceId,
  4845. s = t.code,
  4846. l = t.msg;
  4847. o === Actions.GetNeighborPoints ? eventsManager.remove(a, s, t.nps) : o === Actions.GetUserWithAvatar ? eventsManager.remove(a, s, t.userWithAvatarList) : eventsManager.remove(a, s, l), r === PointType.Path && o === Actions.Clicking && (_this2._room.moveToExtra = decodeURIComponent(n));
  4848. });
  4849. }
  4850. }, {
  4851. key: "udpateSkinInfo",
  4852. value: function () {
  4853. var _udpateSkinInfo = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  4854. var t;
  4855. return regenerator.wrap(function _callee$(_context) {
  4856. while (1) {
  4857. switch (_context.prev = _context.next) {
  4858. case 0:
  4859. this._room.updateCurrentState({
  4860. skinId: e
  4861. });
  4862. _context.next = 3;
  4863. return this._room.skinList.find(function (r) {
  4864. return r.id === e;
  4865. });
  4866. case 3:
  4867. t = _context.sent;
  4868. t && this._room.updateCurrentState({
  4869. skin: t
  4870. });
  4871. case 5:
  4872. case "end":
  4873. return _context.stop();
  4874. }
  4875. }
  4876. }, _callee, this);
  4877. }));
  4878. function udpateSkinInfo(_x) {
  4879. return _udpateSkinInfo.apply(this, arguments);
  4880. }
  4881. return udpateSkinInfo;
  4882. }()
  4883. }]);
  4884. return Signal;
  4885. }();
  4886. function _createSuper$9(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$9(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  4887. function _isNativeReflectConstruct$9() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  4888. var XverseEffectManager = /*#__PURE__*/function (_EventEmitter) {
  4889. _inherits(XverseEffectManager, _EventEmitter);
  4890. var _super = _createSuper$9(XverseEffectManager);
  4891. function XverseEffectManager(e) {
  4892. var _this;
  4893. _classCallCheck(this, XverseEffectManager);
  4894. _this = _super.call(this);
  4895. E(_assertThisInitialized(_this), "effects", new Map());
  4896. E(_assertThisInitialized(_this), "room");
  4897. _this.room = e;
  4898. return _this;
  4899. }
  4900. _createClass(XverseEffectManager, [{
  4901. key: "addEffect",
  4902. value: function () {
  4903. var _addEffect = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  4904. var o, t, r, _e$type, n, a;
  4905. return regenerator.wrap(function _callee$(_context) {
  4906. while (1) {
  4907. switch (_context.prev = _context.next) {
  4908. case 0:
  4909. t = e.jsonPath, r = e.id, _e$type = e.type, n = _e$type === void 0 ? IEffectType.SubSequence : _e$type;
  4910. _context.prev = 1;
  4911. this.effects.get(r) && ((o = this.effects.get(r)) == null || o.dispose());
  4912. a = new Ae.subEffect({
  4913. id: r,
  4914. jsonPath: t,
  4915. type: n,
  4916. room: this.room
  4917. });
  4918. this.effects.set(r, a);
  4919. _context.next = 7;
  4920. return a.init();
  4921. case 7:
  4922. return _context.abrupt("return", a);
  4923. case 10:
  4924. _context.prev = 10;
  4925. _context.t0 = _context["catch"](1);
  4926. return _context.abrupt("return", (this.effects.delete(r), logger$1.error(_context.t0), Promise.reject(_context.t0)));
  4927. case 13:
  4928. case "end":
  4929. return _context.stop();
  4930. }
  4931. }
  4932. }, _callee, this, [[1, 10]]);
  4933. }));
  4934. function addEffect(_x) {
  4935. return _addEffect.apply(this, arguments);
  4936. }
  4937. return addEffect;
  4938. }()
  4939. }, {
  4940. key: "clearEffects",
  4941. value: function clearEffects() {
  4942. var _this2 = this;
  4943. this.effects.forEach(function (e) {
  4944. e.dispose(), _this2.effects.delete(e.id);
  4945. });
  4946. }
  4947. }, {
  4948. key: "removeEffect",
  4949. value: function removeEffect(e) {
  4950. var t = this.effects.get(e);
  4951. t == null || t.dispose(), t && this.effects.delete(t.id);
  4952. }
  4953. }]);
  4954. return XverseEffectManager;
  4955. }(EventEmitter);
  4956. var MotionType$1 = {
  4957. Walk: 'walk',
  4958. Run: 'run',
  4959. Fly: 'fly'
  4960. };
  4961. var Heartbeat = /*#__PURE__*/function () {
  4962. function Heartbeat(e) {
  4963. var _this = this;
  4964. _classCallCheck(this, Heartbeat);
  4965. E(this, "_interval", null);
  4966. E(this, "ping", function () {
  4967. var e = Date.now().toString();
  4968. _this.handler.ping(e);
  4969. });
  4970. this.handler = e;
  4971. }
  4972. _createClass(Heartbeat, [{
  4973. key: "ping",
  4974. value: function ping() {
  4975. var e = Date.now().toString();
  4976. this.handler.ping(e);
  4977. }
  4978. }, {
  4979. key: "start",
  4980. value: function start() {
  4981. this.stop(), logger$1.debug("Setting ping interval to ".concat(PING_INTERVAL_MS, "ms")), this._interval = window.setInterval(this.ping, PING_INTERVAL_MS);
  4982. }
  4983. }, {
  4984. key: "stop",
  4985. value: function stop() {
  4986. logger$1.debug("stop heartbeat"), this._interval && window.clearInterval(this._interval);
  4987. }
  4988. }, {
  4989. key: "pong",
  4990. value: function pong(e, t) {
  4991. !e || typeof e == "string" && this.handler.pong(Date.now() - Number(e), t);
  4992. }
  4993. }]);
  4994. return Heartbeat;
  4995. }();
  4996. var Timeout$1 = /*#__PURE__*/function () {
  4997. function Timeout(e, t) {
  4998. var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : !0;
  4999. _classCallCheck(this, Timeout);
  5000. this._timeout = null;
  5001. this._fn = e, this._delay = t, r && this.start();
  5002. }
  5003. _createClass(Timeout, [{
  5004. key: "delay",
  5005. get: function get() {
  5006. return this._delay;
  5007. }
  5008. }, {
  5009. key: "isSet",
  5010. get: function get() {
  5011. return !!this._timeout;
  5012. }
  5013. }, {
  5014. key: "setDelay",
  5015. value: function setDelay(e) {
  5016. this._delay = e;
  5017. }
  5018. }, {
  5019. key: "start",
  5020. value: function start() {
  5021. var _this = this;
  5022. this.isSet || (this._timeout = window.setTimeout(function () {
  5023. var e = _this._fn;
  5024. _this.clear(), e();
  5025. }, this._delay));
  5026. }
  5027. }, {
  5028. key: "clear",
  5029. value: function clear() {
  5030. window.clearTimeout(this._timeout), this._timeout = void 0;
  5031. }
  5032. }, {
  5033. key: "reset",
  5034. value: function reset() {
  5035. this.clear(), this.start();
  5036. }
  5037. }]);
  5038. return Timeout;
  5039. }();
  5040. function _createSuper$8(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$8(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  5041. function _isNativeReflectConstruct$8() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  5042. var Socket = /*#__PURE__*/function (_EventEmitter) {
  5043. _inherits(Socket, _EventEmitter);
  5044. var _super = _createSuper$8(Socket);
  5045. function Socket(e) {
  5046. var _this;
  5047. _classCallCheck(this, Socket);
  5048. _this = _super.call(this);
  5049. E(_assertThisInitialized(_this), "_ws");
  5050. E(_assertThisInitialized(_this), "_openTimer");
  5051. E(_assertThisInitialized(_this), "connected", !1);
  5052. E(_assertThisInitialized(_this), "_hasTimeout", !1);
  5053. E(_assertThisInitialized(_this), "heartbeat");
  5054. E(_assertThisInitialized(_this), "latency", function (e, t) {
  5055. return _this.send({
  5056. id: "checkLatency",
  5057. data: JSON.stringify(e),
  5058. packet_id: t
  5059. });
  5060. });
  5061. E(_assertThisInitialized(_this), "send", function (e) {
  5062. if (_this.wsNoReady()) return;
  5063. var t = JSON.stringify(e);
  5064. e.id !== "heartbeat" && logger$1.info("send ws frame", t), _this._ws.send(t);
  5065. });
  5066. E(_assertThisInitialized(_this), "startGame", function () {
  5067. var _this$network$room$cu = _this.network.room.currentNetworkOptions,
  5068. e = _this$network$room$cu.roomId,
  5069. t = _this$network$room$cu.userId,
  5070. r = _this$network$room$cu.avatarId,
  5071. n = _this$network$room$cu.skinId,
  5072. o = _this$network$room$cu.role,
  5073. a = _this$network$room$cu.avatarComponents,
  5074. s = _this$network$room$cu.versionId,
  5075. l = _this$network$room$cu.rotationRenderType,
  5076. u = _this$network$room$cu.isAllSync,
  5077. c = _this$network$room$cu.nickname,
  5078. h = _this$network$room$cu.avatarScale,
  5079. f = _this$network$room$cu.appId,
  5080. d = _this$network$room$cu.camera,
  5081. _ = _this$network$room$cu.player,
  5082. g = _this$network$room$cu.firends,
  5083. m = _this$network$room$cu.syncByEvent,
  5084. v = _this$network$room$cu.areaName,
  5085. y = _this$network$room$cu.attitude,
  5086. b = _this$network$room$cu.pathName,
  5087. T = _this$network$room$cu.person,
  5088. _this$network$room$cu2 = _this$network$room$cu.roomTypeId,
  5089. C = _this$network$room$cu2 === void 0 ? "" : _this$network$room$cu2,
  5090. A = _this$network$room$cu.syncToOthers,
  5091. S = _this$network$room$cu.hasAvatar,
  5092. P = _this$network$room$cu.prioritySync,
  5093. _this$network$room$cu3 = _this$network$room$cu.extra,
  5094. R = _this$network$room$cu3 === void 0 ? {} : _this$network$room$cu3,
  5095. M = _this$network$room$cu.removeWhenDisconnected;
  5096. R.removeWhenDisconnected = M;
  5097. var x = {
  5098. id: "start",
  5099. room_id: e,
  5100. user_id: t,
  5101. trace_id: util.uuid(),
  5102. data: JSON.stringify({
  5103. avatar_components: JSON.stringify(a),
  5104. avatar_id: r,
  5105. skin_id: n,
  5106. is_host: o ? o == "host" : !0,
  5107. skin_data_version: n !== void 0 && s !== void 0 ? n + s : void 0,
  5108. rotation_render_type: l,
  5109. is_all_sync: u,
  5110. nick_name: encodeURIComponent(c || ""),
  5111. app_id: f,
  5112. camera: d,
  5113. player: _,
  5114. person: T,
  5115. firends: JSON.stringify(g),
  5116. sync_by_event: m,
  5117. area_name: v,
  5118. path_name: b,
  5119. attitude: y,
  5120. room_type_id: C,
  5121. syncToOthers: A,
  5122. hasAvatar: S,
  5123. avatarSize: h,
  5124. prioritySync: P,
  5125. extra: JSON.stringify(R)
  5126. })
  5127. };
  5128. _this.send(x), logger$1.warn("startGame", le(oe({}, x), {
  5129. data: JSON.parse(x.data)
  5130. }));
  5131. });
  5132. _this.network = e, _this.heartbeat = new Heartbeat({
  5133. ping: function ping(t) {
  5134. var r;
  5135. if (!_this.connected) {
  5136. _this.heartbeat.stop(), (r = e.room.stats) == null || r.assign({
  5137. rtt: 0
  5138. });
  5139. return;
  5140. }
  5141. _this.send({
  5142. id: "heartbeat",
  5143. data: t
  5144. });
  5145. },
  5146. pong(t) {
  5147. var r;
  5148. (r = e.room.stats) == null || r.assign({
  5149. rtt: t
  5150. });
  5151. }
  5152. });
  5153. return _this;
  5154. }
  5155. _createClass(Socket, [{
  5156. key: "connection",
  5157. get: function get() {
  5158. return this._ws;
  5159. }
  5160. }, {
  5161. key: "start",
  5162. value: function start() {
  5163. var _this2 = this;
  5164. this._hasTimeout = !1;
  5165. var e = this.getAddress();
  5166. logger$1.info("connecting to ".concat(e));
  5167. var t = Date.now();
  5168. this._ws = new WebSocket(e), this._openTimer = new Timeout$1(function () {
  5169. var r = "Failed to open websocket in ".concat(DEFAULT_OPEN_TIMEOUT_MS, " ms");
  5170. _this2._hasTimeout = !0, _this2.emit("socketClosed", new InitNetworkTimeoutError(r));
  5171. }, DEFAULT_OPEN_TIMEOUT_MS), this._ws.onopen = function () {
  5172. var r;
  5173. (r = _this2._openTimer) == null || r.clear(), _this2.connected = !0, _this2.heartbeat.start(), _this2.network.room.currentNetworkOptions.reconnect || (logger$1.infoAndReportMeasurement({
  5174. metric: "wsOpenedAt",
  5175. group: "joinRoom",
  5176. startTime: _this2.network.room._startTime
  5177. }), logger$1.infoAndReportMeasurement({
  5178. metric: "wsOpenedCost",
  5179. group: "joinRoom",
  5180. startTime: t
  5181. }));
  5182. }, this.handleWSEvent();
  5183. }
  5184. }, {
  5185. key: "getAddress",
  5186. value: function getAddress() {
  5187. var _this$network$room$cu4 = this.network.room.currentNetworkOptions,
  5188. e = _this$network$room$cu4.wsServerUrl,
  5189. t = _this$network$room$cu4.reconnect,
  5190. r = _this$network$room$cu4.sessionId,
  5191. n = _this$network$room$cu4.token,
  5192. o = _this$network$room$cu4.roomId,
  5193. a = _this$network$room$cu4.userId,
  5194. s = _this$network$room$cu4.pageSession,
  5195. l = this.network.room.skinId;
  5196. var u = e;
  5197. t && (u = u + "?reconnect=true&lastSessionID=".concat(r));
  5198. var c = "userId=".concat(a, "&roomId=").concat(o, "&pageSession=").concat(s) + (this.network.room.isHost ? "&skinId=".concat(l) : "") + (n ? "&token=".concat(n) : "");
  5199. return u = u.indexOf("?") > -1 ? u + "&" + c : u + "?" + c, u;
  5200. }
  5201. }, {
  5202. key: "handleWSEvent",
  5203. value: function handleWSEvent() {
  5204. var _this3 = this;
  5205. var e = this._ws;
  5206. e.addEventListener("error", function (t) {
  5207. _this3.connected = !1, logger$1.error("webscoket error", t), _this3.emit("socketClosed", new InternalError("connect to address error: " + _this3.network.room.currentNetworkOptions.wsServerUrl));
  5208. }), e.addEventListener("close", function (t) {
  5209. _this3.connected = !1, _this3._onClose(t);
  5210. }), e.addEventListener("message", function (t) {
  5211. if (!t || _this3._hasTimeout || !_this3.connected) return;
  5212. var r = null;
  5213. try {
  5214. r = JSON.parse(t.data);
  5215. } catch (o) {
  5216. logger$1.error(o);
  5217. return;
  5218. }
  5219. if (!r) return;
  5220. var n = r.id;
  5221. if (!!n) switch (n !== "heartbeat" && logger$1.info("receive ws frame: ".concat(t.data)), n) {
  5222. case "fail":
  5223. break;
  5224. case "init":
  5225. try {
  5226. var o = r.data.slice(-37, -1);
  5227. reporter$1.updateBody({
  5228. serverSession: o
  5229. });
  5230. } catch (o) {
  5231. console.error(o);
  5232. }
  5233. _this3.network.rtcp.start();
  5234. break;
  5235. case "heartbeat":
  5236. _this3.heartbeat.pong(r.data);
  5237. break;
  5238. case "offer":
  5239. _this3.network.rtcp.setRemoteDescription(r.data, _this3.network.stream.el);
  5240. break;
  5241. case "ice_candidate":
  5242. _this3.network.rtcp.addCandidate(r.data);
  5243. break;
  5244. case "start":
  5245. _this3.emit("gameRoomAvailable", r);
  5246. break;
  5247. case "error":
  5248. try {
  5249. var _JSON$parse = JSON.parse(r.data),
  5250. _o = _JSON$parse.Code,
  5251. a = _JSON$parse.Msg;
  5252. if (_o) {
  5253. if (_o == 3003) return _this3.emit("socketClosed", new TokenExpiredError());
  5254. if (authenticationErrorCodes.indexOf(_o) > -1) return _this3.emit("socketClosed", new AuthenticationError("\u9274\u6743\u9519\u8BEF:" + a));
  5255. {
  5256. var s = util.getErrorByCode(_o);
  5257. _this3.emit("socketClosed", new s(a));
  5258. }
  5259. }
  5260. } catch (o) {
  5261. logger$1.error(o), _this3.emit("socketClosed", new InternalError(r.data));
  5262. }
  5263. break;
  5264. case "checkLatency":
  5265. {
  5266. var _o2 = r.packet_id,
  5267. _a = r.data.split(",");
  5268. _this3.onLatencyCheck({
  5269. packetId: _o2,
  5270. addresses: _a
  5271. });
  5272. break;
  5273. }
  5274. default:
  5275. logger$1.warn("unkown ws message type", n, r);
  5276. }
  5277. });
  5278. }
  5279. }, {
  5280. key: "onLatencyCheck",
  5281. value: function onLatencyCheck(e) {
  5282. var _this4 = this;
  5283. var t = _toConsumableArray(new Set(e.addresses || []));
  5284. Promise.all(t.map(function (r) {
  5285. return {
  5286. [r]: 9999
  5287. };
  5288. })).then(function (r) {
  5289. var n = Object.assign.apply(Object, [{}].concat(_toConsumableArray(r)));
  5290. _this4.latency(n, e.packetId);
  5291. });
  5292. }
  5293. }, {
  5294. key: "wsNoReady",
  5295. value: function wsNoReady() {
  5296. return this._ws.readyState == WebSocket.CLOSED || this._ws.readyState == WebSocket.CLOSING || this._ws.readyState == WebSocket.CONNECTING;
  5297. }
  5298. }, {
  5299. key: "prepareReconnect",
  5300. value: function prepareReconnect() {
  5301. this._close({
  5302. code: WS_CLOSE_RECONNECT,
  5303. reason: "reconnect"
  5304. });
  5305. }
  5306. }, {
  5307. key: "_onClose",
  5308. value: function _onClose(_ref) {
  5309. var e = _ref.code,
  5310. t = _ref.reason;
  5311. this._openTimer && this._openTimer.clear(), logger$1.warn("ws closed: ".concat(e, " ") + t), [WS_CLOSE_RECONNECT, WS_CLOSE_NORMAL].includes(e) || this.emit("socketClosed", new InternalError("Websocket error"));
  5312. }
  5313. }, {
  5314. key: "_close",
  5315. value: function _close(_ref2) {
  5316. var e = _ref2.code,
  5317. t = _ref2.reason;
  5318. var r;
  5319. (r = this._ws) == null || r.close(e, t);
  5320. }
  5321. }, {
  5322. key: "quit",
  5323. value: function quit() {
  5324. this._close({
  5325. code: WS_CLOSE_NORMAL,
  5326. reason: "quit"
  5327. });
  5328. }
  5329. }]);
  5330. return Socket;
  5331. }(EventEmitter);
  5332. function add(i, e) {
  5333. return e == -1 && (e = 0), i + e;
  5334. }
  5335. function max(i, e) {
  5336. return Math.max(i, e);
  5337. }
  5338. function count_sd(i, e) {
  5339. function t(r, n) {
  5340. var o = 0;
  5341. return n == -1 ? o = 0 : o = (n - e) * (n - e), r + o;
  5342. }
  5343. return Math.sqrt(i.reduce(t, 0) / i.reduce(count_valid, 0)) || 0;
  5344. }
  5345. function count_valid(i, e) {
  5346. var t = 0;
  5347. return e != -1 && (t = 1), i + t;
  5348. }
  5349. function count_less(i, e) {
  5350. function t(r, n) {
  5351. var o = 0;
  5352. return n != -1 && n < e && (o = 1), r + o;
  5353. }
  5354. return i.reduce(t, 0);
  5355. }
  5356. var CircularArray = /*#__PURE__*/function () {
  5357. function CircularArray(e, t, r) {
  5358. _classCallCheck(this, CircularArray);
  5359. this.sum = 0, this.incomingSum = 0, this.count = 0, this.incomingCount = 0, this.max = 0, this.incomingMax = 0, this.goodLess = 0, this.wellLess = 0, this.fairLess = 0, this.badLess = 0, this.countLess = !1, this.lessThreshes = [], this.incomingData = [], this.circularData = Array(e).fill(-1), this.circularPtr = 0, this.circularLength = e, t && (this.countLess = !0, this.lessThreshes = r);
  5360. }
  5361. _createClass(CircularArray, [{
  5362. key: "add",
  5363. value: function add(e) {
  5364. this.circularData[this.circularPtr] != -1 ? (this.sum -= this.circularData[this.circularPtr], Math.abs(this.circularData[this.circularPtr] - this.max) < .01 && (this.circularData[this.circularPtr] = -1, this.max = this.getMax(!1))) : this.count += 1, this.sum += e, this.incomingSum += e, this.incomingCount += 1, this.max < e && (this.max = e), this.incomingMax < e && (this.incomingMax = e), this.circularData[this.circularPtr] = e, this.circularPtr = (this.circularPtr + 1) % this.circularLength, this.incomingData.push(e), this.incomingData.length > this.circularLength && (this.clearIncoming(), this.incomingCount = 0, this.incomingSum = 0);
  5365. }
  5366. }, {
  5367. key: "computeAvg",
  5368. value: function computeAvg(e) {
  5369. return e.reduce(add, 0) / e.reduce(count_valid, 0) || 0;
  5370. }
  5371. }, {
  5372. key: "computeMax",
  5373. value: function computeMax(e) {
  5374. return e.reduce(max, 0) || 0;
  5375. }
  5376. }, {
  5377. key: "computeThreshPercent",
  5378. value: function computeThreshPercent(e) {
  5379. if (this.countLess) {
  5380. var t = count_less(e, this.lessThreshes[0]) || 0,
  5381. r = count_less(e, this.lessThreshes[1]) || 0,
  5382. n = count_less(e, this.lessThreshes[2]) || 0,
  5383. o = count_less(e, this.lessThreshes[3]) || 0,
  5384. a = e.reduce(count_valid, 0);
  5385. return [t, r, n, o, a];
  5386. } else return [0, 0, 0, 0, 0];
  5387. }
  5388. }, {
  5389. key: "getAvg",
  5390. value: function getAvg() {
  5391. var e = this.sum / this.count || 0,
  5392. t = this.computeAvg(this.circularData) || 0;
  5393. return Math.abs(e - t) > .01 && console.error("avg value mismatch: ", e, t), this.computeAvg(this.circularData) || 0;
  5394. }
  5395. }, {
  5396. key: "getMax",
  5397. value: function getMax() {
  5398. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : !0;
  5399. var t = this.computeMax(this.circularData) || 0;
  5400. return e && Math.abs(t - this.max) > .01 && console.error("max value mismatch: ", this.max, t), this.computeMax(this.circularData) || 0;
  5401. }
  5402. }, {
  5403. key: "getStandardDeviation",
  5404. value: function getStandardDeviation() {
  5405. return count_sd(this.circularData, this.getAvg());
  5406. }
  5407. }, {
  5408. key: "getThreshPercent",
  5409. value: function getThreshPercent() {
  5410. return this.computeThreshPercent(this.circularData);
  5411. }
  5412. }, {
  5413. key: "getIncomingMax",
  5414. value: function getIncomingMax() {
  5415. return this.computeMax(this.incomingData) || 0;
  5416. }
  5417. }, {
  5418. key: "getIncomingAvg",
  5419. value: function getIncomingAvg() {
  5420. return this.computeAvg(this.incomingData) || 0;
  5421. }
  5422. }, {
  5423. key: "getIncomingStandardDeviation",
  5424. value: function getIncomingStandardDeviation() {
  5425. return count_sd(this.incomingData, this.getIncomingAvg());
  5426. }
  5427. }, {
  5428. key: "getIncomingThreshPercent",
  5429. value: function getIncomingThreshPercent() {
  5430. return this.computeThreshPercent(this.incomingData);
  5431. }
  5432. }, {
  5433. key: "clearFastComputeItem",
  5434. value: function clearFastComputeItem() {
  5435. this.sum = 0, this.incomingSum = 0, this.count = 0, this.incomingCount = 0, this.max = 0, this.incomingMax = 0, this.goodLess = 0, this.wellLess = 0, this.fairLess = 0, this.badLess = 0;
  5436. }
  5437. }, {
  5438. key: "clearIncoming",
  5439. value: function clearIncoming() {
  5440. for (; this.incomingData.length > 0;) {
  5441. this.incomingData.pop();
  5442. }
  5443. }
  5444. }, {
  5445. key: "clear",
  5446. value: function clear() {
  5447. this.circularData.fill(-1), this.circularPtr = 0, this.clearFastComputeItem(), this.clearIncoming();
  5448. }
  5449. }]);
  5450. return CircularArray;
  5451. }();
  5452. function _createForOfIteratorHelper$4(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$4(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
  5453. function _unsupportedIterableToArray$4(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$4(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$4(o, minLen); }
  5454. function _arrayLikeToArray$4(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  5455. var defaultLogger = {
  5456. info: console.log,
  5457. debug: console.log,
  5458. error: console.error,
  5459. infoAndReportMeasurement: function infoAndReportMeasurement() {}
  5460. };
  5461. var USER_ID = "987412365",
  5462. PAGE_SESSION = "aaabbbccc",
  5463. SERVER_SESSION = "cccbbbaaa",
  5464. COS_PREFIX = "error-bitstreams-auto-uploaded-from-application/",
  5465. FRAME_COMPOSE_LENGTH = 5;
  5466. var Workers = /*#__PURE__*/function () {
  5467. function Workers(e, t) {
  5468. var _this = this;
  5469. _classCallCheck(this, Workers);
  5470. this.rtcp = e, this.cacheSize = 0, this.cacheBuffer = new Uint8Array(262144), this.cacheFrameCnt = 0, this.startReceiveTime = 0, this.cacheFrameComposes = new Array(0), this.cacheSizes = new Array(5).fill(0), this.cacheFrameCnts = new Array(5).fill(-1), this.cacheStartReceiveTimes = new Array(5).fill(0), this.cacheBuffers = [new Uint8Array(262144), new Uint8Array(262144), new Uint8Array(262144), new Uint8Array(262144), new Uint8Array(262144)], this.panoCacheSize = 0, this.panoCacheBuffer = new Uint8Array(2097152), this.cachePanoTileID = 0, this.receivedMedia = 0, this.receivedMedia_worker = 0, this.receivedYUV = 0, this.receivedEmit = 0, this.returnFrames = 0, this.lastReturnFrames = 0, this.lastReceivedEmit = 0, this.mediaBytesReceived = 0, this.metaBytesReceived = 0, this.noWasmBytesReceived = 0, this.rtcBytesReceived = 0, this.rtcMessageReceived = 0, this.packetsDrop = 0, this.framesAwait = 0, this.sendOutBuffer = 0, this.decodeTimePerFrame = 0, this.decodeTimeMaxFrame = 0, this.lastRenderTs = 0, this.JankTimes = 0, this.bigJankTimes = 0, this.DecodeJankTimes = 0, this.bigDecodeJankTimes = 0, this.saveframe = !1, this.SaveMediaStream = !1, this.packetsLost = 0, this.showAllReceivedMetadata = !1, this.firstMediaArraval = 0, this.firstMediaReceived = !1, this.firstYUVDecoded = 0, this.firstRender = 0, this.firstYUVReceived = !1, this.reconnectSignal = !1, this.serverFrameSlow = 0, this.serverFrameFast = 0, this.clientFrameSlow = 0, this.clientFrameFast = 0, this.lastServerTS = 0, this.lastClientTS = 0, this.lastSeq = 0, this.lastIsPureMeta = !1, this.lastHBPacketTs = 0, this.HBPacketInterval = 0, this.lastHBPacketSrvSentTs = 0, this.HBPacketIntervalSrvSent = 0, this.cachedLength = 2, this.cachedStreams = new Array(this.cachedLength), this.cachedMetas = new Array(this.cachedLength), this.cachedPtss = new Array(this.cachedLength), this.cachedRender = Array(this.cachedLength).fill(!1), this.cachedResolution = new Array(this.cachedLength), this.getPtr = 0, this.setPtr = 0, this.receiveIframes = 0, this.decodeIframes = 0, this.prevSenderTs = -1, this.serverSendTimeArray = new CircularArray(120, !1, []), this.inPanoMode = !1, this.PanoStatus = {
  5471. x: 0,
  5472. y: 0,
  5473. z: 0,
  5474. tiles: []
  5475. }, this.DynamicPanoTest = !1, this.PanoMask = new ArrayBuffer(8), this.PanoView = new DataView(this.PanoMask), this.userId_test = "", this.PendingMasks = [], this.traceIdMap = new Map(), this.responseTimeArray = [], this.processTimeArray = [], this.displayTimeArray = [], this.overallTimeArray = [], this.responseMiss = 0, this.processMiss = 0, this.displayMiss = 0, this.updateYUVCircular = new CircularArray(120, !1, []), this.updateDropFrame = 0, this.metaParseAraay = [], this.responseMoveMiss = 0, this.processMoveMiss = 0, this.displayMoveMiss = 0, this.MovingTraceId = "", this.PendingMovingTraceId = "", this.inMovingMode = !1, this.StartMovingTs = 0, this.PendingStartMovingTs = 0, this.moveEvent = "", this.MoveToFrameCnt = 0, this.lastIsMoving = 0, this.MoveResponseDelay = 0, this.MoveProcessDelay = 0, this.MoveDisplayDelay = 0, this.lastMoveResponseTime = 0, this.lastMoveProcessTime = 0, this.lastMoveDisplayTime = 0, this.moveResponseCircular = new CircularArray(120, !0, [STUCK_STAGE_GOOD, STUCK_STAGE_WELL, STUCK_STAGE_FAIR, STUCK_STAGE_BAD]), this.moveProcessCircular = new CircularArray(120, !0, [STUCK_STAGE_GOOD, STUCK_STAGE_WELL, STUCK_STAGE_FAIR, STUCK_STAGE_BAD]), this.moveDisplayCircular = new CircularArray(120, !0, [STUCK_STAGE_GOOD, STUCK_STAGE_WELL, STUCK_STAGE_FAIR, STUCK_STAGE_BAD]), this.moveStartPts = -1, this.frameServerCircular = new CircularArray(120, !1, []), this.srvMetaIntervalCircular = new CircularArray(120, !1, []), this.srvMediaIntervalCircular = new CircularArray(120, !1, []), this.srvHBMetaIntervalCircular = new CircularArray(120, !1, []), this.srvHBMetaIntervalSrvSentCircular = new CircularArray(120, !1, []), this.frameClientCircular = new CircularArray(120, !1, []), this.firstUpdateYUV = !0, this.functionMap = new Map(), this.WASM_VERSION = "WASM-1.1", this.frameHistory = [], this.getVersion = function () {
  5476. return DECODER_VERSION;
  5477. }, this.downloadBlob = function (r, n, o) {
  5478. var a = new Blob([r], {
  5479. type: o
  5480. }),
  5481. s = window.URL.createObjectURL(a);
  5482. _this.downloadURL(s, n), setTimeout(function () {
  5483. return window.URL.revokeObjectURL(s);
  5484. }, 1e3);
  5485. }, this.downloadURL = function (r, n) {
  5486. var o = document.createElement("a");
  5487. o.href = r, o.download = n, document.body.appendChild(o), o.style.display = "none", o.click(), o.remove();
  5488. }, this.Stringify = function (r) {
  5489. var n = "";
  5490. for (var a = 0; a < r.length / 8192; a++) {
  5491. n += String.fromCharCode.apply(null, r.slice(a * 8192, (a + 1) * 8192));
  5492. }
  5493. return n;
  5494. }, this._rtcp = e;
  5495. }
  5496. _createClass(Workers, [{
  5497. key: "registerLogger",
  5498. value: function registerLogger(e) {//defaultLogger = e
  5499. }
  5500. }, {
  5501. key: "registerFunction",
  5502. value: function registerFunction(e, t) {
  5503. this.functionMap.set(e, t);
  5504. }
  5505. }, {
  5506. key: "hasFrmCntInCache",
  5507. value: function hasFrmCntInCache(e) {
  5508. var t = -1;
  5509. for (var r = 0; r < this.cacheFrameComposes.length; r++) {
  5510. this.cacheFrameComposes[r].frameCnt == e && (t = r);
  5511. }
  5512. return t;
  5513. }
  5514. }, {
  5515. key: "requestPanoramaTest",
  5516. value: function requestPanoramaTest(e, t, r, n, o) {
  5517. var a = o,
  5518. s = {
  5519. action_type: 16,
  5520. change_rotation_render_type_action: {
  5521. render_type: 5,
  5522. player: {
  5523. position: {
  5524. x: 0,
  5525. y: 0,
  5526. z: 0
  5527. },
  5528. angle: {
  5529. yaw: 0,
  5530. pitch: 0,
  5531. roll: 0
  5532. }
  5533. },
  5534. camera: {
  5535. position: {
  5536. x: e,
  5537. y: t,
  5538. z: r
  5539. },
  5540. angle: {
  5541. yaw: 0,
  5542. pitch: 0,
  5543. roll: 0
  5544. }
  5545. },
  5546. client_pano_titles_bitmap: n
  5547. },
  5548. trace_id: a,
  5549. user_id: this.userId_test,
  5550. packet_id: a
  5551. };
  5552. defaultLogger.debug("send data: ", s), this._rtcp.sendData(s);
  5553. }
  5554. }, {
  5555. key: "onRotateInPanoMode",
  5556. value: function onRotateInPanoMode(e) {
  5557. var t = e.traceId,
  5558. r = {};
  5559. r.width = 1280, r.height = 720, r.horz_fov = 92, r.angle = {
  5560. yaw: 100,
  5561. pitch: 30
  5562. };
  5563. var n = new ArrayBuffer(8),
  5564. o = new DataView(n);
  5565. getTilesInView(r, n);
  5566. var a = n.slice(0);
  5567. this.PendingMasks.unshift({
  5568. buffer: a,
  5569. angle: r.angle
  5570. }), MaskSetToOne(18, this.PanoView), operateForDataView(o, this.PanoView, o, function (s, l) {
  5571. return s ^ s & l;
  5572. }), this.requestPanoramaTest(0, 0, 0, [o.getUint8(0), o.getUint8(1), o.getUint8(2), o.getUint8(3), o.getUint8(4), o.getUint8(5), o.getUint8(6), o.getUint8(7)], t);
  5573. }
  5574. }, {
  5575. key: "processMetaWithTraceId",
  5576. value: function processMetaWithTraceId(e) {
  5577. var _iterator = _createForOfIteratorHelper$4(e.traceIds),
  5578. _step;
  5579. try {
  5580. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  5581. var t = _step.value;
  5582. if (this.traceIdMap.has(t)) {
  5583. var r = this.traceIdMap.get(t);
  5584. r != null && (r.receiveTime = Date.now(), r.status = 1);
  5585. }
  5586. if (t == this.PendingMovingTraceId) {
  5587. this.inMovingMode = !0, this.MovingTraceId = this.PendingMovingTraceId, this.StartMovingTs = this.PendingStartMovingTs, this.PendingMovingTraceId = "", this.PendingStartMovingTs = 0, defaultLogger.info("MoveTo TraceId match", this.StartMovingTs, Date.now());
  5588. var _r = Date.now();
  5589. this.lastMoveResponseTime = _r, this.lastMoveProcessTime = _r, this.lastMoveDisplayTime = _r, this.frameServerCircular.clear(), this.frameClientCircular.clear();
  5590. }
  5591. }
  5592. } catch (err) {
  5593. _iterator.e(err);
  5594. } finally {
  5595. _iterator.f();
  5596. }
  5597. }
  5598. }, {
  5599. key: "onTraceId",
  5600. value: function onTraceId(e) {
  5601. var _this2 = this;
  5602. var r = e.traceId,
  5603. n = e.timestamp,
  5604. o = e.event;
  5605. if (o === "Rotation") {
  5606. var a = {
  5607. traceId: r,
  5608. pts: 0,
  5609. startTime: n,
  5610. receiveTime: 0,
  5611. readyTime: 0,
  5612. displayTime: 0,
  5613. status: 0
  5614. };
  5615. this.traceIdMap.set(r, a);
  5616. var s = setTimeout(function () {
  5617. if (s && clearTimeout(s), _this2.traceIdMap.has(r)) {
  5618. var l = _this2.traceIdMap.get(r);
  5619. switch (l == null ? void 0 : l.status) {
  5620. case 0:
  5621. {
  5622. _this2.responseMiss += 1;
  5623. break;
  5624. }
  5625. case 1:
  5626. {
  5627. _this2.processMiss += 1;
  5628. var u = l.receiveTime - l.startTime;
  5629. _this2.responseTimeArray.push(u);
  5630. break;
  5631. }
  5632. case 2:
  5633. {
  5634. _this2.displayMiss += 1;
  5635. var _u = l.receiveTime - l.startTime,
  5636. c = l.readyTime - l.receiveTime;
  5637. _this2.responseTimeArray.push(_u), _this2.processTimeArray.push(c);
  5638. break;
  5639. }
  5640. case 3:
  5641. defaultLogger.debug("status is 3");
  5642. }
  5643. }
  5644. }, 1e3);
  5645. } else o === "MoveTo" ? (defaultLogger.info("receive moveto traceId ", r, " at timestamp", n), this.PendingMovingTraceId = r, this.PendingStartMovingTs = n, this.moveEvent = o, this.frameServerCircular.clear()) : o === "GetOnAirship" || o === "GetOnVehicle" ? (defaultLogger.info("receive airship traceId ", r, " at timestamp ", n), this.PendingMovingTraceId = r, this.PendingStartMovingTs = n, this.moveEvent = o, this.frameServerCircular.clear()) : (o === "GetOffAirship" || o === "GetOffVehicle") && this.clearMoveArray();
  5646. }
  5647. }, {
  5648. key: "executeFunction",
  5649. value: function executeFunction(e, t) {
  5650. if (this.functionMap.has(e)) {
  5651. var r = this.functionMap.get(e);
  5652. r != null && r(t);
  5653. }
  5654. }
  5655. }, {
  5656. key: "UpdateStats",
  5657. value: function UpdateStats(e) {
  5658. var _this3 = this;
  5659. var t;
  5660. (t = this._rtcp.connection) == null || t.getStats(null).then(function (r) {
  5661. r.forEach(function (n) {
  5662. n.type == "data-channel" && (_this3.rtcMessageReceived = n.messagesReceived - n.messagesSent, _this3.rtcBytesReceived = n.bytesReceived);
  5663. });
  5664. }), this.receivedMedia_worker = e.data.framesReceived, this.receivedYUV = e.data.framesDecoded, this.receivedEmit = e.data.framesRendered, this.mediaBytesReceived = e.data.mediaBytesReceived, this.metaBytesReceived = e.data.metaBytesReceived, this.packetsLost = e.data.packetsLost, this.packetsDrop = e.data.packetsDrop, this.framesAwait = e.data.framesAwait, this.decodeTimePerFrame = e.data.decodeTimePerFrame, this.decodeTimeMaxFrame = e.data.decodeTimeMaxFrame, this.returnFrames = e.data.framesReturned, this.sendOutBuffer = e.data.sendOutBuffer, this.DecodeJankTimes = e.data.JankTimes, this.bigDecodeJankTimes = e.data.bigJankTimes, this.receiveIframes = e.data.receivedIframe, this.decodeIframes = e.data.decodedIframe;
  5665. }
  5666. }, {
  5667. key: "ReceiveDecodeMessage",
  5668. value: function ReceiveDecodeMessage(e) {
  5669. var n;
  5670. if (!this.firstYUVReceived) {
  5671. this.firstYUVDecoded = e.data.yuv_ts;
  5672. var o = this.firstYUVDecoded - this.rtcp.network.room._startTime;
  5673. defaultLogger.infoAndReportMeasurement({
  5674. metric: "firstYUVDecodedAt",
  5675. value: o,
  5676. group: "joinRoom"
  5677. }), this.firstRender = Date.now();
  5678. var a = this.firstYUVDecoded - this.rtcp.network.room._startTime;
  5679. defaultLogger.infoAndReportMeasurement({
  5680. metric: "firstRenderAt",
  5681. value: a,
  5682. group: "joinRoom"
  5683. }), this.firstYUVReceived = !0, this.lastRenderTs = Date.now();
  5684. }
  5685. !this.cachedRender[this.setPtr] && this.cachedMetas[this.setPtr] != null && (this.cachedStreams[this.setPtr] != null && this.cachedStreams[this.setPtr].byteLength != 0 && (e.data.data == null ? (this.executeFunction("stream", {
  5686. stream: this.cachedStreams[this.setPtr],
  5687. width: this.cachedResolution[this.setPtr].width,
  5688. height: this.cachedResolution[this.setPtr].height,
  5689. pts: this.cachedPtss[this.setPtr]
  5690. }), this.executeFunction("signal", {
  5691. signal: this.cachedMetas[this.setPtr],
  5692. pts: this.cachedPtss[this.setPtr],
  5693. alreadyUpdateYUV: !0
  5694. })) : this.updateDropFrame += 1, this.decoderWorker.postMessage({
  5695. t: 2,
  5696. frameCnt: this.cachedPtss[this.setPtr],
  5697. buffer: this.cachedStreams[this.setPtr]
  5698. }, [this.cachedStreams[this.setPtr].buffer])), this.getPtr = (this.getPtr + 1) % this.cachedLength);
  5699. var t = e.data.metadata;
  5700. if ((n = t == null ? void 0 : t.traceIds) != null && n.length) {
  5701. var _iterator2 = _createForOfIteratorHelper$4(t.traceIds),
  5702. _step2;
  5703. try {
  5704. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  5705. var _o = _step2.value;
  5706. if (this.traceIdMap.has(_o)) {
  5707. var _a = this.traceIdMap.get(_o);
  5708. _a != null && (_a.readyTime = Date.now(), _a.status = 2);
  5709. }
  5710. }
  5711. } catch (err) {
  5712. _iterator2.e(err);
  5713. } finally {
  5714. _iterator2.f();
  5715. }
  5716. }
  5717. if (e.data.pts == this.moveStartPts && (this.MoveProcessDelay = Date.now() - this.StartMovingTs), this.userId_test = this.rtcp.network.room.userId, this.inMovingMode) {
  5718. var _o2 = Date.now(),
  5719. _a2 = _o2 - this.lastMoveProcessTime;
  5720. this.moveProcessCircular.add(_a2), this.lastMoveProcessTime = _o2;
  5721. }
  5722. var r = this.setPtr;
  5723. this.cachedStreams[r] = e.data.data, this.cachedMetas[r] = e.data.metadata, this.cachedPtss[r] = e.data.pts, this.cachedRender[r] = !1, this.cachedResolution[r] = {
  5724. width: e.data.width,
  5725. height: e.data.height
  5726. }, this.setPtr = (this.setPtr + 1) % this.cachedLength;
  5727. }
  5728. }, {
  5729. key: "SendCacheFrameInfo",
  5730. value: function SendCacheFrameInfo(e) {
  5731. var _this4 = this;
  5732. var h, f, d, _, g, m, v;
  5733. var t = e.data.cachedKey,
  5734. r = e.data.metadata,
  5735. n = t,
  5736. o = r,
  5737. a = (d = (f = (h = o.newUserStates) == null ? void 0 : h.find(function (y) {
  5738. return y.userId === _this4.rtcp.network.room.userId;
  5739. })) == null ? void 0 : f.playerState) == null ? void 0 : d.roomTypeId,
  5740. s = this.rtcp.network.room.skinId,
  5741. l = (v = (m = (g = (_ = o.newUserStates) == null ? void 0 : _.find(function (y) {
  5742. return y.userId === _this4._rtcp.network.room.userId;
  5743. })) == null ? void 0 : g.playerState) == null ? void 0 : m.player) == null ? void 0 : v.position,
  5744. u = {
  5745. MsgType: 1,
  5746. FrameCacheMsg: {
  5747. FrameIndex: n,
  5748. RoomTypeId: a,
  5749. SkinID: s,
  5750. Position: l
  5751. }
  5752. };
  5753. var c = "";
  5754. try {
  5755. c = JSON.stringify(u);
  5756. } catch (y) {
  5757. defaultLogger.error(y);
  5758. return;
  5759. }
  5760. }
  5761. }, {
  5762. key: "ReceivePanoramaDecodeMessage",
  5763. value: function ReceivePanoramaDecodeMessage(e) {
  5764. defaultLogger.info("Receive Panorama Image in Workers.ts"), MaskSetToOne(e.data.tileId, this.PanoView);
  5765. var t = 0,
  5766. r;
  5767. var n = this.PendingMasks.length;
  5768. for (t = 0; t < n; t++) {
  5769. var o = this.PendingMasks[t].buffer,
  5770. a = new DataView(o),
  5771. s = new ArrayBuffer(8),
  5772. l = new DataView(s);
  5773. if (operateForDataView(this.PanoView, a, l, function (u, c) {
  5774. return c ^ u & c;
  5775. }), IsAll0(l)) {
  5776. r = this.PendingMasks[t].angle;
  5777. break;
  5778. }
  5779. }
  5780. for (var _o3 = t; _o3 < n; _o3++) {
  5781. this.PendingMasks.pop();
  5782. }
  5783. this.executeFunction("panorama", {
  5784. data: e.data.data,
  5785. tileId: e.data.tileId,
  5786. pos: {
  5787. x: e.data.x,
  5788. y: e.data.y,
  5789. z: e.data.z
  5790. },
  5791. uuid: e.data.uuid,
  5792. finished: !0,
  5793. matchAngle: r
  5794. });
  5795. }
  5796. }, {
  5797. key: "enable_decoder_queue_logging",
  5798. value: function enable_decoder_queue_logging() {
  5799. this.decoderWorker.postMessage({
  5800. t: 100,
  5801. status: !0
  5802. });
  5803. }
  5804. }, {
  5805. key: "disable_decoder_queue_logging",
  5806. value: function disable_decoder_queue_logging() {
  5807. this.decoderWorker.postMessage({
  5808. t: 100,
  5809. status: !1
  5810. });
  5811. }
  5812. }, {
  5813. key: "init",
  5814. value: function () {
  5815. var _init = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
  5816. var _this5 = this;
  5817. var e,
  5818. r,
  5819. n,
  5820. t,
  5821. _args = arguments;
  5822. return regenerator.wrap(function _callee$(_context) {
  5823. while (1) {
  5824. switch (_context.prev = _context.next) {
  5825. case 0:
  5826. e = _args.length > 0 && _args[0] !== undefined ? _args[0] : {
  5827. width: 1280,
  5828. height: 720
  5829. };
  5830. for (r = 0; r < FRAME_COMPOSE_LENGTH; r++) {
  5831. n = {
  5832. buffer: new Uint8Array(2621440),
  5833. size: 0,
  5834. startReceiveTime: 0,
  5835. serverTime: 0,
  5836. frameCnt: -1
  5837. };
  5838. this.cacheFrameComposes.push(n);
  5839. }
  5840. t = new Blob([decoder], {
  5841. type: "application/javascript"
  5842. });
  5843. this.decoderWorker = new Worker(URL.createObjectURL(t));
  5844. this.decoderWorker.postMessage({
  5845. t: 9,
  5846. url: WASM_URLS[WASM_Version],
  5847. jitterLength: DECODER_PASSIVE_JITTER
  5848. });
  5849. this.decoderWorker.postMessage({
  5850. t: 1,
  5851. config: e
  5852. });
  5853. return _context.abrupt("return", new Promise(function (r) {
  5854. _this5.decoderWorker.onmessage = function (n) {
  5855. switch (n.data.t) {
  5856. case 0:
  5857. _this5.ReceiveDecodeMessage(n);
  5858. break;
  5859. case 1:
  5860. _this5.UpdateStats(n);
  5861. break;
  5862. case 2:
  5863. r();
  5864. break;
  5865. case 3:
  5866. _this5.SendCacheFrameInfo(n);
  5867. break;
  5868. case 4:
  5869. {
  5870. var o = new Date().toISOString(),
  5871. a = USER_ID + "-" + PAGE_SESSION + "-" + SERVER_SESSION + "-" + o + ".264";
  5872. uploadStream(COS_PREFIX + a, n.data.fileObj);
  5873. break;
  5874. }
  5875. case 5:
  5876. _this5.executeFunction("signal", {
  5877. signal: n.data.metadata,
  5878. pts: -1,
  5879. alreadyUpdateYUV: !1
  5880. });
  5881. break;
  5882. case 6:
  5883. defaultLogger.infoAndReportMeasurement(n.data), defaultLogger.debug("WASM Ready Cost");
  5884. break;
  5885. case 7:
  5886. _this5.ReceivePanoramaDecodeMessage(n);
  5887. break;
  5888. case 8:
  5889. {
  5890. var _o4 = {
  5891. MstType: 0
  5892. };
  5893. var _a3 = "";
  5894. try {
  5895. _a3 = JSON.stringify(_o4);
  5896. } catch (l) {
  5897. defaultLogger.error(l);
  5898. return;
  5899. }
  5900. var s = "wasm:" + _a3;
  5901. _this5._rtcp.sendStringData(s);
  5902. break;
  5903. }
  5904. case 9:
  5905. {
  5906. defaultLogger.info(n.data.printMsg);
  5907. break;
  5908. }
  5909. case 10:
  5910. {
  5911. defaultLogger.error(n.data.printMsg), _this5.executeFunction("error", {
  5912. code: n.data.code,
  5913. message: n.data.printMsg
  5914. });
  5915. break;
  5916. }
  5917. default:
  5918. defaultLogger.error("Receive unknown message event from decoder"), defaultLogger.debug(n.data);
  5919. break;
  5920. }
  5921. };
  5922. }));
  5923. case 7:
  5924. case "end":
  5925. return _context.stop();
  5926. }
  5927. }
  5928. }, _callee, this);
  5929. }));
  5930. function init() {
  5931. return _init.apply(this, arguments);
  5932. }
  5933. return init;
  5934. }()
  5935. }, {
  5936. key: "UpdateYUV",
  5937. value: function UpdateYUV() {
  5938. var t, r;
  5939. var e = this.getPtr;
  5940. if (this.cachedMetas[e] != null && !this.cachedRender[e]) {
  5941. var n = Date.now();
  5942. if (this.firstUpdateYUV) {
  5943. var h = ((t = this.cachedStreams[e]) == null ? void 0 : t.byteLength) || 0;
  5944. defaultLogger.infoAndReportMeasurement({
  5945. metric: "firstUpdateStreamLength",
  5946. value: h,
  5947. group: "joinRoom"
  5948. }), this.firstUpdateYUV = !1;
  5949. }
  5950. this.cachedStreams[e] != null && this.executeFunction("stream", {
  5951. stream: this.cachedStreams[e],
  5952. width: this.cachedResolution[e].width,
  5953. height: this.cachedResolution[e].height,
  5954. pts: this.cachedPtss[e]
  5955. });
  5956. var o = Date.now();
  5957. this.cachedStreams[e] != null && this.decoderWorker.postMessage({
  5958. t: 2,
  5959. frameCnt: this.cachedPtss[e],
  5960. buffer: this.cachedStreams[e]
  5961. }, [this.cachedStreams[e].buffer]);
  5962. var a = Date.now(),
  5963. s = o - n,
  5964. l = a - o;
  5965. (s > 33 || l > 10) && defaultLogger.debug("[wwwarning] updateYUV takes ", s, " ms, postMessage takes ", l, " ms for index ", this.cachedPtss[e]), o - this.lastRenderTs > 84 && this.JankTimes++, o - this.lastRenderTs > 125 && this.bigJankTimes++, this.lastRenderTs = o;
  5966. var u = o - n;
  5967. this.updateYUVCircular.add(u);
  5968. var c = this.cachedMetas[e];
  5969. if ((r = c == null ? void 0 : c.traceIds) != null && r.length) {
  5970. var _iterator3 = _createForOfIteratorHelper$4(c.traceIds),
  5971. _step3;
  5972. try {
  5973. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  5974. var _h = _step3.value;
  5975. if (this.traceIdMap.has(_h)) {
  5976. var f = this.traceIdMap.get(_h);
  5977. if (f != null) {
  5978. f.displayTime = Date.now(), f.status = 3;
  5979. var d = f.receiveTime - f.startTime,
  5980. _ = f.readyTime - f.receiveTime,
  5981. g = f.displayTime - f.readyTime,
  5982. m = f.displayTime - f.startTime;
  5983. this.responseTimeArray.push(d), this.processTimeArray.push(_), this.displayTimeArray.push(g), this.overallTimeArray.push(m), this.traceIdMap.delete(_h);
  5984. }
  5985. }
  5986. }
  5987. } catch (err) {
  5988. _iterator3.e(err);
  5989. } finally {
  5990. _iterator3.f();
  5991. }
  5992. }
  5993. if (this.cachedPtss[e] == this.moveStartPts && (this.MoveDisplayDelay = Date.now() - this.StartMovingTs), this.inMovingMode) {
  5994. var _h2 = Date.now(),
  5995. _f = _h2 - this.lastMoveDisplayTime;
  5996. this.moveDisplayCircular.add(_f), this.lastMoveDisplayTime = _h2;
  5997. }
  5998. this.executeFunction("signal", {
  5999. signal: this.cachedMetas[e],
  6000. pts: this.cachedPtss[e],
  6001. alreadyUpdateYUV: !0
  6002. }), this.cachedRender[e] = !0, this.getPtr = (this.getPtr + 1) % this.cachedLength;
  6003. }
  6004. }
  6005. }, {
  6006. key: "unmarshalPano",
  6007. value: function unmarshalPano(e) {
  6008. var t = new DataView(e);
  6009. if (t.getUint32(0) != 1723558763) return !1;
  6010. console.log("Receive Pano Message"), t.getUint16(4);
  6011. var n = t.getUint16(6),
  6012. o = t.getUint32(8),
  6013. a = t.getUint32(12) - (1 << 30) * 2,
  6014. s = t.getUint32(16) - (1 << 30) * 2,
  6015. l = t.getUint32(20) - (1 << 30) * 2,
  6016. u = t.getUint32(24),
  6017. c = new Uint8Array(e).subarray(28, 64),
  6018. h = String.fromCharCode.apply(null, c),
  6019. f = t.getUint32(64),
  6020. d = e.byteLength - n;
  6021. if (d == u) {
  6022. var g = {
  6023. data: new Uint8Array(e).subarray(n),
  6024. mediaLen: u,
  6025. tileId: o,
  6026. uuid: h,
  6027. x: a,
  6028. y: s,
  6029. z: l
  6030. };
  6031. this.decoderWorker.postMessage({
  6032. t: 8,
  6033. data: g
  6034. });
  6035. } else {
  6036. var _ = new Uint8Array(e, n, d);
  6037. if (this.cachePanoTileID == o) {
  6038. if (this.panoCacheBuffer.set(_, f), this.panoCacheSize += d, this.panoCacheSize === u) {
  6039. var m = {
  6040. data: new Uint8Array(this.panoCacheBuffer).slice(0, u),
  6041. mediaLen: u,
  6042. tileId: o,
  6043. uuid: h,
  6044. x: a,
  6045. y: s,
  6046. z: l
  6047. };
  6048. this.decoderWorker.postMessage({
  6049. t: 8,
  6050. data: m
  6051. }), this.panoCacheSize = 0;
  6052. }
  6053. } else this.panoCacheBuffer.set(_, f), this.panoCacheSize = d, this.cachePanoTileID = o;
  6054. }
  6055. return !0;
  6056. }
  6057. }, {
  6058. key: "clearMoveArray",
  6059. value: function clearMoveArray() {
  6060. this.MovingTraceId = "", this.inMovingMode = !1, this.StartMovingTs = 0, this.MoveToFrameCnt = 0, this.MoveResponseDelay = 0, this.MoveProcessDelay = 0, this.MoveDisplayDelay = 0, this.moveStartPts = -1, this.moveResponseCircular.clear(), this.moveProcessCircular.clear(), this.moveDisplayCircular.clear(), this.moveEvent = "";
  6061. }
  6062. }, {
  6063. key: "getIsMoving",
  6064. value: function getIsMoving(e) {
  6065. var t;
  6066. if (typeof e.newUserStates != "undefined") for (var r = 0; r < e.newUserStates.length; r++) {
  6067. var n = e.newUserStates[r];
  6068. if (n.userId == this.rtcp.network.room.userId) {
  6069. t = n.renderInfo.isMoving;
  6070. break;
  6071. }
  6072. }
  6073. return t;
  6074. }
  6075. }, {
  6076. key: "isHeartBeatPacket",
  6077. value: function isHeartBeatPacket(e, t) {
  6078. return new DataView(e).getUint32(0) == 2009889916;
  6079. }
  6080. }, {
  6081. key: "resetSendTimeDiff",
  6082. value: function resetSendTimeDiff() {
  6083. this.prevSenderTs = 0, this.serverSendTimeArray.clear();
  6084. }
  6085. }, {
  6086. key: "calcSendTimeDiff",
  6087. value: function calcSendTimeDiff(e) {
  6088. if (this.prevSenderTs == -1) {
  6089. this.prevSenderTs = e;
  6090. return;
  6091. }
  6092. var t = e - this.prevSenderTs;
  6093. this.serverSendTimeArray.add(t), this.prevSenderTs = e;
  6094. }
  6095. }, {
  6096. key: "unmarshalStream",
  6097. value: function unmarshalStream(e) {
  6098. var _this6 = this;
  6099. var T, C, A, S, P, R, M, x, I, w;
  6100. var t = new DataView(e);
  6101. if (t.getUint32(0) != 1437227610) return !1;
  6102. t.getUint16(4);
  6103. var n = t.getUint16(6),
  6104. o = t.getUint16(8),
  6105. a = o,
  6106. s = t.getUint16(10);
  6107. var l = !1;
  6108. s == 1 && (l = !0);
  6109. var u = t.getUint32(12),
  6110. c = t.getUint32(16),
  6111. h = t.getUint32(20),
  6112. f = t.getUint16(24),
  6113. d = t.getUint16(26),
  6114. _ = t.getUint32(28),
  6115. g = t.getUint32(n - 4),
  6116. m = u + c,
  6117. v = e.byteLength - n,
  6118. y = new Uint8Array(e, n, v);
  6119. this.calcSendTimeDiff(h);
  6120. var b;
  6121. if (this.inPanoMode && (c > 0 || f)) return defaultLogger.error("Stream Protocal Violation: receive illegal stream in Pano mode"), !0;
  6122. if (v === m) {
  6123. this.receivedMedia++;
  6124. var O = new Uint8Array(e).subarray(n);
  6125. h - this.lastServerTS > 60 ? this.serverFrameSlow++ : h - this.lastServerTS < 16 && this.serverFrameFast++;
  6126. var D = Date.now();
  6127. D - this.lastClientTS > 60 ? this.clientFrameSlow++ : D - this.lastClientTS < 16 && this.clientFrameFast++;
  6128. var F = c === 0,
  6129. V = h - this.lastServerTS;
  6130. this.lastServerTS != 0 && ((o + 65536 - this.lastSeq) % 65536 === 1 && this.lastIsPureMeta == F && (F ? this.srvMetaIntervalCircular.add(V) : this.srvMediaIntervalCircular.add(V)), this.frameServerCircular.add(V), this.frameClientCircular.add(D - this.lastClientTS)), this.lastSeq = o, this.lastIsPureMeta = F, this.lastServerTS = h, this.lastClientTS = D;
  6131. var N = O.subarray(0, u),
  6132. L = Date.now(),
  6133. k = JSON.parse(this.Stringify(N)),
  6134. U = Date.now();
  6135. this.showAllReceivedMetadata && console.log(h, D, k), this.metaParseAraay.push(U - L), (T = k.traceIds) != null && T.length && this.processMetaWithTraceId(k), c != 0 && this.moveStartPts == -1 && this.inMovingMode && (this.moveStartPts = o), this.moveStartPts == o && (this.MoveResponseDelay = Date.now() - this.StartMovingTs, console.log("move response delay: ", o, this.moveStartPts, this.MoveResponseDelay));
  6136. var z = this.getIsMoving(k);
  6137. if (this.inMovingMode && z == 0 && this.lastIsMoving == 1 && this.clearMoveArray(), typeof z != "undefined" && (this.lastIsMoving = z), this.inMovingMode) {
  6138. var G = Date.now(),
  6139. W = G - this.lastMoveResponseTime;
  6140. this.moveResponseCircular.add(W), this.lastMoveResponseTime = G;
  6141. }
  6142. (f || d) && (b = (P = (S = (A = (C = k.newUserStates) == null ? void 0 : C.find(function (G) {
  6143. return G.userId === _this6._rtcp.network.room.userId;
  6144. })) == null ? void 0 : A.playerState) == null ? void 0 : S.player) == null ? void 0 : P.position);
  6145. var H = {
  6146. t: 0,
  6147. data: O,
  6148. mediaLen: c,
  6149. metaLen: u,
  6150. metadata: k,
  6151. frameCnt: a,
  6152. server_ts: h,
  6153. isIDR: l,
  6154. cacheRequest: d,
  6155. cached: f,
  6156. cachedKey: _,
  6157. position: b
  6158. };
  6159. if (this.inPanoMode) return this.executeFunction("signal", {
  6160. signal: k,
  6161. pts: -1,
  6162. alreadyUpdateYUV: !0
  6163. }), !0;
  6164. if (this.decoderWorker.postMessage(H, [O.buffer]), !this.firstMediaReceived) {
  6165. this.firstMediaArraval = Date.now();
  6166. var _G = this.firstMediaArraval - this.rtcp.network.room._startTime;
  6167. defaultLogger.infoAndReportMeasurement({
  6168. metric: "firstMediaArravalAt",
  6169. value: _G,
  6170. group: "joinRoom"
  6171. }), this.firstMediaReceived = !0;
  6172. }
  6173. } else {
  6174. var _O = this.hasFrmCntInCache(a);
  6175. if (_O != -1) {
  6176. if (this.cacheFrameComposes[_O].buffer.set(y, g), this.cacheFrameComposes[_O].size += v, this.cacheFrameComposes[_O].size === m) {
  6177. var _D = new Uint8Array(this.cacheFrameComposes[_O].buffer).slice(0, m);
  6178. this.cacheFrameComposes[_O].frameCnt = -1, this.cacheFrameComposes[_O].size = 0, this.cacheFrameComposes[_O].startReceiveTime = 0, this.cacheFrameComposes[_O].serverTime = 0, this.receivedMedia++, h - this.lastServerTS > 60 ? this.serverFrameSlow++ : h - this.lastServerTS < 16 && this.serverFrameFast++;
  6179. var _F = Date.now();
  6180. _F - this.lastClientTS > 60 ? this.clientFrameSlow++ : _F - this.lastClientTS < 16 && this.clientFrameFast++, this.lastServerTS != 0 && (this.frameServerCircular.add(h - this.lastServerTS), this.frameClientCircular.add(_F - this.lastClientTS)), this.lastServerTS = h, this.lastClientTS = _F;
  6181. var _V = _D.subarray(0, u),
  6182. _N = Date.now(),
  6183. _L = JSON.parse(this.Stringify(_V)),
  6184. _k = Date.now();
  6185. this.showAllReceivedMetadata && console.log(h, _F, _L), this.metaParseAraay.push(_k - _N), (R = _L.traceIds) != null && R.length && this.processMetaWithTraceId(_L), c != 0 && this.moveStartPts == -1 && this.inMovingMode && (this.moveStartPts = o), this.moveStartPts == o && (this.MoveResponseDelay = Date.now() - this.StartMovingTs);
  6186. var _U = this.getIsMoving(_L);
  6187. if (this.inMovingMode && _U == 0 && this.lastIsMoving == 1 && this.clearMoveArray(), typeof _U != "undefined" && (this.lastIsMoving = _U), this.inMovingMode) {
  6188. var _H = Date.now(),
  6189. _G2 = _H - this.lastMoveResponseTime;
  6190. this.moveResponseCircular.add(_G2), this.lastMoveResponseTime = _H;
  6191. }
  6192. (f || d) && (b = (w = (I = (x = (M = _L.newUserStates) == null ? void 0 : M.find(function (H) {
  6193. return H.userId === _this6._rtcp.network.room.userId;
  6194. })) == null ? void 0 : x.playerState) == null ? void 0 : I.player) == null ? void 0 : w.position);
  6195. var _z = {
  6196. t: 0,
  6197. data: _D,
  6198. mediaLen: c,
  6199. metaLen: u,
  6200. metadata: _L,
  6201. frameCnt: a,
  6202. server_ts: h,
  6203. isIDR: l,
  6204. cacheRequest: d,
  6205. cached: f,
  6206. cachedKey: _,
  6207. position: b
  6208. };
  6209. if (this.inPanoMode) return this.executeFunction("signal", {
  6210. signal: _L,
  6211. pts: -1,
  6212. alreadyUpdateYUV: !0
  6213. }), !0;
  6214. if (this.decoderWorker.postMessage(_z, [_D.buffer]), !this.firstMediaReceived) {
  6215. this.firstMediaArraval = Date.now();
  6216. var _H2 = this.firstMediaArraval - this.rtcp.network.room._startTime;
  6217. defaultLogger.infoAndReportMeasurement({
  6218. metric: "firstMediaArravalAt",
  6219. value: _H2,
  6220. group: "joinRoom"
  6221. }), this.firstMediaReceived = !0;
  6222. }
  6223. } else this.cacheFrameComposes[_O].size > m && defaultLogger.debug("I frame exceed, cache size is ", this.cacheSize, ", total size is ", m);
  6224. } else if (_O == -1) {
  6225. var _D2 = this.hasFrmCntInCache(-1);
  6226. if (_D2 == -1) {
  6227. var _F2 = Date.now() + 1e18,
  6228. _V2 = -1;
  6229. for (var _N2 = 0; _N2 < this.cacheFrameComposes.length; _N2++) {
  6230. this.cacheFrameComposes[_N2].serverTime < _F2 && (_F2 = this.cacheFrameComposes[_N2].serverTime, _V2 = _N2);
  6231. }
  6232. _D2 = _V2;
  6233. }
  6234. this.cacheFrameComposes[_D2].buffer.set(y, g), this.cacheFrameComposes[_D2].size = v, this.cacheFrameComposes[_D2].frameCnt = a, this.cacheFrameComposes[_D2].startReceiveTime = Date.now(), this.cacheFrameComposes[_D2].serverTime = h;
  6235. }
  6236. }
  6237. return !0;
  6238. }
  6239. }, {
  6240. key: "reset",
  6241. value: function reset() {
  6242. defaultLogger.debug("Worker reset is called"), this.cacheFrameCnt = 0, this.receivedMedia = 0, this.reconnectSignal = !0, this.decoderWorker.postMessage({
  6243. t: 4
  6244. });
  6245. }
  6246. }, {
  6247. key: "dataHandleOff",
  6248. value: function dataHandleOff(e) {
  6249. defaultLogger.debug("hhh");
  6250. }
  6251. }, {
  6252. key: "dataHandle",
  6253. value: function dataHandle(e) {
  6254. this.saveframe && (this.decoderWorker.postMessage({
  6255. t: 6
  6256. }), this.saveframe = !1), this.SaveMediaStream && (this.decoderWorker.postMessage({
  6257. t: 7
  6258. }), this.SaveMediaStream = !1);
  6259. var t = new Uint8Array(e);
  6260. if (t.length >= 4 && this.isHeartBeatPacket(t.buffer, t.length) == !0) return;
  6261. if (t.length > 36 && this.unmarshalStream(t.buffer) == !0) {
  6262. this.reconnectSignal && (this.executeFunction("reconnectedFrame", {}), this.reconnectSignal = !1);
  6263. return;
  6264. }
  6265. if (t.length > 20 && this.unmarshalPano(t.buffer) == !0) return;
  6266. this.noWasmBytesReceived += e.byteLength;
  6267. var r = JSON.parse(this.Stringify(t));
  6268. this.executeFunction("signal", {
  6269. signal: r,
  6270. pts: -1,
  6271. alreadyUpdateYUV: !0
  6272. });
  6273. }
  6274. }, {
  6275. key: "changePanoMode",
  6276. value: function changePanoMode(e) {
  6277. this.inPanoMode = e;
  6278. }
  6279. }, {
  6280. key: "uploadDataToServer",
  6281. value: function uploadDataToServer() {
  6282. this.DynamicPanoTest == !0 && (this.onRotateInPanoMode({
  6283. traceId: "b2e1a296-6438-4371-8a31-687beb724ebe"
  6284. }), this.DynamicPanoTest = !1);
  6285. function e(ie, ee) {
  6286. return ee == -1 && (ee = 0), ie + ee;
  6287. }
  6288. function t(ie, ee) {
  6289. return Math.max(ie, ee);
  6290. }
  6291. var r = this.responseTimeArray.reduce(e, 0) / this.responseTimeArray.length || 0,
  6292. n = this.processTimeArray.reduce(e, 0) / this.processTimeArray.length || 0,
  6293. o = this.displayTimeArray.reduce(e, 0) / this.displayTimeArray.length || 0,
  6294. a = this.overallTimeArray.reduce(e, 0) / this.overallTimeArray.length || 0,
  6295. s = this.overallTimeArray.length;
  6296. this.responseTimeArray = [], this.processTimeArray = [], this.displayTimeArray = [], this.overallTimeArray = [];
  6297. var l = this.moveResponseCircular.getThreshPercent(),
  6298. u = l[0],
  6299. c = l[1],
  6300. h = l[2],
  6301. f = l[3],
  6302. d = l[4],
  6303. _ = d - f,
  6304. g = 1 - c / d || 0,
  6305. m = [u, c - u, h - c, f - h, _],
  6306. v = this.moveProcessCircular.getThreshPercent(),
  6307. y = v[0],
  6308. b = v[1],
  6309. T = v[2],
  6310. C = v[3],
  6311. A = v[4],
  6312. S = A - C,
  6313. P = 1 - b / A || 0,
  6314. R = [y, b - y, T - b, C - T, S],
  6315. M = this.moveDisplayCircular.getThreshPercent(),
  6316. x = M[0],
  6317. I = M[1],
  6318. w = M[2],
  6319. O = M[3],
  6320. D = M[4],
  6321. F = D - O,
  6322. V = 1 - I / D || 0,
  6323. N = [x, I - x, w - I, O - w, F],
  6324. L = x,
  6325. k = I - x,
  6326. U = w - I,
  6327. z = O - w,
  6328. H = F,
  6329. G = this.moveResponseCircular.getAvg(),
  6330. W = this.moveProcessCircular.getAvg(),
  6331. j = this.moveDisplayCircular.getAvg(),
  6332. B = this.moveResponseCircular.getMax(),
  6333. X = this.moveProcessCircular.getMax(),
  6334. $ = this.moveDisplayCircular.getMax(),
  6335. Y = this.moveResponseCircular.getStandardDeviation(),
  6336. K = this.moveProcessCircular.getStandardDeviation(),
  6337. Z = this.moveDisplayCircular.getStandardDeviation();
  6338. this.moveResponseCircular.getIncomingAvg(), this.moveProcessCircular.getIncomingAvg(), this.moveDisplayCircular.getIncomingAvg(), this.moveResponseCircular.getIncomingMax(), this.moveProcessCircular.getIncomingMax(), this.moveDisplayCircular.getIncomingMax(), this.moveResponseCircular.clearIncoming(), this.moveProcessCircular.clearIncoming(), this.moveDisplayCircular.clearIncoming();
  6339. var q = this.frameServerCircular.getAvg(),
  6340. J = this.frameServerCircular.getMax();
  6341. this.frameClientCircular.getAvg(), this.frameClientCircular.getMax();
  6342. var Q = this.metaParseAraay.reduce(e, 0) / this.metaParseAraay.length || 0,
  6343. te = this.metaParseAraay.reduce(t, 0);
  6344. this.metaParseAraay = [];
  6345. var re = {
  6346. mediaBytesReceived: this.mediaBytesReceived,
  6347. metaBytesReceived: this.metaBytesReceived,
  6348. packetsLost: this.packetsLost,
  6349. timestamp: Date.now(),
  6350. frameHeight: 1280,
  6351. frameWidth: 720,
  6352. framesReceived: this.receivedMedia,
  6353. framesReceivedWorker: this.receivedMedia_worker,
  6354. framesDecoded: this.receivedYUV,
  6355. framesEmited: this.receivedEmit,
  6356. decodeTimePerFrame: this.decodeTimePerFrame,
  6357. decodeTimeMaxFrame: this.decodeTimeMaxFrame,
  6358. packetsDrop: this.packetsDrop,
  6359. framesAwait: this.framesAwait,
  6360. firstMediaArraval: this.firstMediaArraval,
  6361. firstYUVDecoded: this.firstYUVDecoded,
  6362. firstRender: this.firstRender,
  6363. returnFrames: this.returnFrames,
  6364. sendOutBuffer: this.sendOutBuffer,
  6365. maxGraphicTime: this.updateYUVCircular.getMax(),
  6366. averageGraphicTime: this.updateYUVCircular.getAvg(),
  6367. jankTimes: this.JankTimes,
  6368. bigJankTimes: this.bigJankTimes,
  6369. decodeJankTimes: this.DecodeJankTimes,
  6370. bigDecodeJankTimes: this.bigDecodeJankTimes,
  6371. serverFrameSlow: this.serverFrameSlow,
  6372. serverFrameFast: this.serverFrameFast,
  6373. clientFrameSlow: this.clientFrameSlow,
  6374. clientFrameFast: this.clientFrameFast,
  6375. rtcMessageReceived: this.rtcMessageReceived,
  6376. rtcBytesReceived: this.rtcBytesReceived - this.noWasmBytesReceived,
  6377. receiveIframes: this.receiveIframes,
  6378. decodeIframes: this.decodeIframes,
  6379. avgResponseTime: r,
  6380. avgProcessTime: n,
  6381. avgDisplayTime: o,
  6382. avgOverallTime: a,
  6383. overallTimeCount: s,
  6384. responseMiss: this.responseMiss,
  6385. processMiss: this.processMiss,
  6386. displayMiss: this.displayMiss,
  6387. updateDropFrame: this.updateDropFrame,
  6388. moveEvent: this.moveEvent,
  6389. avgResponseMoveDiff: this.moveEvent == "MoveTo" ? G : 0,
  6390. avgProcessMoveDiff: this.moveEvent == "MoveTo" ? W : 0,
  6391. avgDisplayMoveDiff: this.moveEvent == "MoveTo" ? j : 0,
  6392. maxResponseMoveDiff: this.moveEvent == "MoveTo" ? B : 0,
  6393. maxProcessMoveDiff: this.moveEvent == "MoveTo" ? X : 0,
  6394. maxDisplayMoveDiff: this.moveEvent == "MoveTo" ? $ : 0,
  6395. moveResponseJank: this.moveEvent == "MoveTo" ? g : 0,
  6396. moveProcessJank: this.moveEvent == "MoveTo" ? P : 0,
  6397. moveDisplayJank: this.moveEvent == "MoveTo" ? V : 0,
  6398. moveResponseCounts: this.moveEvent == "MoveTo" ? m.toString() : "0,0,0,0,0",
  6399. moveProcessCounts: this.moveEvent == "MoveTo" ? R.toString() : "0,0,0,0,0",
  6400. moveDisplayCounts: this.moveEvent == "MoveTo" ? N.toString() : "0,0,0,0,0",
  6401. MoveDisplayCountGood: this.moveEvent == "MoveTo" ? L.toString() : "0",
  6402. MoveDisplayCountWell: this.moveEvent == "MoveTo" ? k.toString() : "0",
  6403. MoveDisplayCountFair: this.moveEvent == "MoveTo" ? U.toString() : "0",
  6404. MoveDisplayCountBad: this.moveEvent == "MoveTo" ? z.toString() : "0",
  6405. MoveDisplayCountRest: this.moveEvent == "MoveTo" ? H.toString() : "0",
  6406. moveResponseDelay: this.moveEvent == "MoveTo" ? this.MoveResponseDelay : 0,
  6407. moveProcessDelay: this.moveEvent == "MoveTo" ? this.MoveProcessDelay : 0,
  6408. moveDisplayDelay: this.moveEvent == "MoveTo" ? this.MoveDisplayDelay : 0,
  6409. sdMoveResponseLongTime: Y,
  6410. sdMoveProcessLongTime: K,
  6411. sdMoveDisplayLongTime: Z,
  6412. avgResponseFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? G : 0,
  6413. avgProcessFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? W : 0,
  6414. avgDisplayFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? j : 0,
  6415. maxResponseFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? B : 0,
  6416. maxProcessFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? X : 0,
  6417. maxDisplayFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? $ : 0,
  6418. flyResponseJank: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? g : 0,
  6419. flyProcessJank: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? P : 0,
  6420. flyDisplayJank: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? V : 0,
  6421. flyResponseCounts: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? m.toString() : "0,0,0,0,0",
  6422. flyProcessCounts: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? R.toString() : "0,0,0,0,0",
  6423. flyDisplayCounts: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? N.toString() : "0,0,0,0,0",
  6424. flyResponseDelay: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? this.MoveResponseDelay : 0,
  6425. flyProcessDelay: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? this.MoveProcessDelay : 0,
  6426. flyDisplayDelay: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? this.MoveDisplayDelay : 0,
  6427. avgMetaParseTime: Q,
  6428. maxMetaParseTime: te,
  6429. avgServerDiff: q,
  6430. maxServerDiff: J,
  6431. streamType: WASM_Version
  6432. };
  6433. return this.lastReturnFrames = this.returnFrames, this.lastReceivedEmit = this.receivedEmit, re;
  6434. }
  6435. }]);
  6436. return Workers;
  6437. }();
  6438. function _createSuper$7(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$7(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  6439. function _isNativeReflectConstruct$7() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  6440. var Rtcp = /*#__PURE__*/function (_EventEmitter) {
  6441. _inherits(Rtcp, _EventEmitter);
  6442. var _super = _createSuper$7(Rtcp);
  6443. function Rtcp(e) {
  6444. var _this;
  6445. _classCallCheck(this, Rtcp);
  6446. _this = _super.call(this);
  6447. E(_assertThisInitialized(_this), "connection", null);
  6448. E(_assertThisInitialized(_this), "inputChannel", null);
  6449. E(_assertThisInitialized(_this), "mediaStream");
  6450. E(_assertThisInitialized(_this), "socket");
  6451. E(_assertThisInitialized(_this), "connected", !1);
  6452. E(_assertThisInitialized(_this), "candidates", []);
  6453. E(_assertThisInitialized(_this), "isAnswered", !1);
  6454. E(_assertThisInitialized(_this), "isFlushing", !1);
  6455. E(_assertThisInitialized(_this), "inputReady", !1);
  6456. E(_assertThisInitialized(_this), "workers");
  6457. E(_assertThisInitialized(_this), "actived", !0);
  6458. E(_assertThisInitialized(_this), "heartbeat");
  6459. E(_assertThisInitialized(_this), "onIcecandidate", function (e) {
  6460. if (e.candidate != null) {
  6461. var t = JSON.stringify(e.candidate);
  6462. logger$1.debug("Got ice candidate: ".concat(t)), _this.network.socket.send({
  6463. id: "ice_candidate",
  6464. data: btoa(t)
  6465. });
  6466. }
  6467. });
  6468. E(_assertThisInitialized(_this), "onIcecandidateerror", function (e) {
  6469. logger$1.error("onicecandidateerror", e.errorCode, e.errorText, e);
  6470. });
  6471. E(_assertThisInitialized(_this), "onIceStateChange", function (e) {
  6472. switch (e.target.iceGatheringState) {
  6473. case "gathering":
  6474. logger$1.info("ice gathering");
  6475. break;
  6476. case "complete":
  6477. logger$1.info("Ice gathering completed");
  6478. }
  6479. });
  6480. E(_assertThisInitialized(_this), "onIceConnectionStateChange", function () {
  6481. if (!!_this.connection) switch (logger$1.info("iceConnectionState: ".concat(_this.connection.iceConnectionState)), _this.connection.iceConnectionState) {
  6482. case "connected":
  6483. {
  6484. _this.connected = !0;
  6485. break;
  6486. }
  6487. case "disconnected":
  6488. {
  6489. _this.connected = !1, _this.emit("rtcDisconnected");
  6490. break;
  6491. }
  6492. case "failed":
  6493. {
  6494. _this.emit("rtcDisconnected"), _this.connected = !1;
  6495. break;
  6496. }
  6497. }
  6498. });
  6499. E(_assertThisInitialized(_this), "setRemoteDescription", /*#__PURE__*/function () {
  6500. var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e, t) {
  6501. var a, s, l, r, n, o, u;
  6502. return regenerator.wrap(function _callee$(_context) {
  6503. while (1) {
  6504. switch (_context.prev = _context.next) {
  6505. case 0:
  6506. if (_this.connection) {
  6507. _context.next = 2;
  6508. break;
  6509. }
  6510. return _context.abrupt("return");
  6511. case 2:
  6512. r = JSON.parse(atob(e)), n = new RTCSessionDescription(r);
  6513. _context.next = 5;
  6514. return _this.connection.setRemoteDescription(n);
  6515. case 5:
  6516. _context.next = 7;
  6517. return _this.connection.createAnswer();
  6518. case 7:
  6519. o = _context.sent;
  6520. if (o.sdp = (a = o.sdp) == null ? void 0 : a.replace(/(a=fmtp:111 .*)/g, "$1;stereo=1;sprop-stereo=1"), ((l = (s = o.sdp) == null ? void 0 : s.match(/a=mid:1/g)) == null ? void 0 : l.length) == 2) {
  6521. u = o.sdp.lastIndexOf("a=mid:1");
  6522. o.sdp = o.sdp.slice(0, u) + "a=mid:2" + o.sdp.slice(u + 7);
  6523. }
  6524. _context.prev = 9;
  6525. _context.next = 12;
  6526. return _this.connection.setLocalDescription(o);
  6527. case 12:
  6528. _context.next = 17;
  6529. break;
  6530. case 14:
  6531. _context.prev = 14;
  6532. _context.t0 = _context["catch"](9);
  6533. logger$1.error("error", _context.t0);
  6534. case 17:
  6535. _this.isAnswered = !0, _this.network.rtcp.flushCandidate(), _this.network.socket.send({
  6536. id: "answer",
  6537. data: btoa(JSON.stringify(o))
  6538. }), t.srcObject = _this.mediaStream;
  6539. case 18:
  6540. case "end":
  6541. return _context.stop();
  6542. }
  6543. }
  6544. }, _callee, null, [[9, 14]]);
  6545. }));
  6546. return function (_x, _x2) {
  6547. return _ref.apply(this, arguments);
  6548. };
  6549. }());
  6550. E(_assertThisInitialized(_this), "flushCandidate", function () {
  6551. _this.isFlushing || !_this.isAnswered || (_this.isFlushing = !0, _this.candidates.forEach(function (e) {
  6552. var t = atob(e),
  6553. r = JSON.parse(t);
  6554. if (/172\./.test(r.candidate)) return;
  6555. var n = new RTCIceCandidate(r);
  6556. _this.connection && _this.connection.addIceCandidate(n).then(function () {}, function (o) {
  6557. logger$1.info("add candidate failed", o);
  6558. });
  6559. }), _this.isFlushing = !1);
  6560. });
  6561. E(_assertThisInitialized(_this), "input", function (e) {
  6562. var t;
  6563. !_this.actived || !_this.inputChannel || _this.inputChannel.readyState === "open" && ((t = _this.inputChannel) == null || t.send(e));
  6564. });
  6565. _this.network = e, _this.workers = new Workers(_assertThisInitialized(_this), logger$1), _this.workers.registerLogger(logger$1), _this.workers.registerFunction("data", function (t) {
  6566. _this.emit("data", t);
  6567. }), _this.heartbeat = new Heartbeat({
  6568. ping: function ping(t) {
  6569. e.room.actionsHandler.echo(t);
  6570. },
  6571. pong(t, r) {
  6572. var n;
  6573. r && t > 500 && logger$1.warn("high hb value ".concat(t, ", traceId:") + r), (n = e.room.stats) == null || n.assign({
  6574. hb: t
  6575. });
  6576. }
  6577. });
  6578. return _this;
  6579. }
  6580. _createClass(Rtcp, [{
  6581. key: "start",
  6582. value: function start() {
  6583. var _this2 = this;
  6584. this.connection = new RTCPeerConnection();
  6585. var e = Date.now();
  6586. this.connection.ondatachannel = function (t) {
  6587. logger$1.info("ondatachannel: ".concat(t.channel.label));
  6588. _this2.inputChannel = t.channel;
  6589. _this2.inputChannel.onopen = function () {
  6590. var r;
  6591. logger$1.info("The input channel has opened, id:", (r = _this2.inputChannel) == null ? void 0 : r.id), _this2.inputReady = !0, _this2.emit("rtcConnected"), _this2.network.room.currentNetworkOptions.reconnect || (logger$1.infoAndReportMeasurement({
  6592. metric: "datachannelOpenedAt",
  6593. startTime: _this2.network.room._startTime,
  6594. group: "joinRoom"
  6595. }), logger$1.infoAndReportMeasurement({
  6596. metric: "datachannelOpenedCost",
  6597. startTime: e,
  6598. group: "joinRoom"
  6599. }));
  6600. console.log('this.inputChannel', _this2.inputChannel);
  6601. }, _this2.inputChannel.onclose = function () {
  6602. var r;
  6603. return logger$1.info("The input channel has closed, id:", (r = _this2.inputChannel) == null ? void 0 : r.id);
  6604. }, _this2.inputChannel.onmessage = function (r) {
  6605. // console.log('this.workers',this.workers)
  6606. //console.log('inputChannel',r.data)
  6607. _this2.workers.dataHandle(r.data);
  6608. };
  6609. }, this.connection.oniceconnectionstatechange = this.onIceConnectionStateChange, this.connection.onicegatheringstatechange = this.onIceStateChange, this.connection.onicecandidate = this.onIcecandidate, this.connection.onicecandidateerror = this.onIcecandidateerror, this.network.socket.send({
  6610. id: "init_webrtc",
  6611. data: JSON.stringify({
  6612. is_mobile: !0
  6613. })
  6614. });
  6615. }
  6616. }, {
  6617. key: "addCandidate",
  6618. value: function addCandidate(e) {
  6619. e === "" ? this.network.rtcp.flushCandidate() : this.candidates.push(e);
  6620. }
  6621. }, {
  6622. key: "disconnect",
  6623. value: function disconnect() {
  6624. var e, t, r;
  6625. this.heartbeat.stop(), logger$1.info("ready to close datachannel, id", (e = this.inputChannel) == null ? void 0 : e.id), (t = this.inputChannel) == null || t.close(), (r = this.connection) == null || r.close(), this.connection = null, this.inputChannel = null;
  6626. }
  6627. }, {
  6628. key: "sendStringData",
  6629. value: function sendStringData(e) {
  6630. console.log('e', e);
  6631. this.input(e);
  6632. }
  6633. }, {
  6634. key: "sendData",
  6635. value: function sendData(e) {
  6636. var t = "";
  6637. try {
  6638. t = JSON.stringify(e);
  6639. } catch (r) {
  6640. logger$1.error(r);
  6641. return;
  6642. }
  6643. this.input(t);
  6644. }
  6645. }]);
  6646. return Rtcp;
  6647. }(EventEmitter);
  6648. var NetworkMonitor = /*#__PURE__*/function () {
  6649. function NetworkMonitor(e) {
  6650. _classCallCheck(this, NetworkMonitor);
  6651. this._listener = e;
  6652. }
  6653. _createClass(NetworkMonitor, [{
  6654. key: "isOnline",
  6655. get: function get() {
  6656. var e = window.navigator;
  6657. return typeof e.onLine == "boolean" ? e.onLine : !0;
  6658. }
  6659. }, {
  6660. key: "start",
  6661. value: function start() {
  6662. window.addEventListener("online", this._listener), window.addEventListener("offline", this._listener);
  6663. }
  6664. }, {
  6665. key: "stop",
  6666. value: function stop() {
  6667. window.removeEventListener("online", this._listener), window.removeEventListener("offline", this._listener);
  6668. }
  6669. }]);
  6670. return NetworkMonitor;
  6671. }();
  6672. var Stream = /*#__PURE__*/function () {
  6673. function Stream(e) {
  6674. _classCallCheck(this, Stream);
  6675. this.el = null;
  6676. this._streamPlayTimer = null;
  6677. if (!e) {
  6678. this.el = this.createVideoElement();
  6679. return;
  6680. }
  6681. this.el = e;
  6682. }
  6683. _createClass(Stream, [{
  6684. key: "play",
  6685. value: function play() {
  6686. var _this = this;
  6687. return new Promise(function (e, t) {
  6688. _this._streamPlayTimer = new Timeout(function () {
  6689. t(new InternalError("Stream play timeout"));
  6690. }, 5e3), _this.el && _this.el.play().then(function () {
  6691. var r;
  6692. e(), logger$1.info("Media can autoplay"), (r = _this._streamPlayTimer) == null || r.clear();
  6693. }).catch(function (r) {
  6694. var n;
  6695. logger$1.error("Media Failed to autoplay"), logger$1.error(r), t(new InternalError("Media Failed to autoplay")), (n = _this._streamPlayTimer) == null || n.clear();
  6696. });
  6697. });
  6698. }
  6699. }, {
  6700. key: "createVideoElement",
  6701. value: function createVideoElement() {
  6702. var e = document.createElement("video");
  6703. return e.muted = !0, e.autoplay = !1, e.playsInline = !0, e.setAttribute("autostart", "false"), e.setAttribute("controls", "controls"), e.setAttribute("muted", "true"), e.setAttribute("preload", "auto"), e.setAttribute("hidden", "hidden"), document.body.appendChild(e), e;
  6704. }
  6705. }]);
  6706. return Stream;
  6707. }();
  6708. function _createSuper$6(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$6(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  6709. function _isNativeReflectConstruct$6() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  6710. var workerSourceCode = "onmessage = function (event) {\n const data = event.data\n if (!data) return\n \n if (data.type === 'start') {\n const startTime = Date.now()\n const request = new XMLHttpRequest()\n request.open('GET', data.url)\n try {\n request.send()\n } catch (error) {\n console.error(error)\n }\n request.addEventListener('readystatechange', () => {\n if (request.readyState == 4) {\n if (request.status == 200) {\n postMessage(Date.now() - startTime)\n }\n }\n })\n }\n }\n ";
  6711. var NetworkController = /*#__PURE__*/function (_EventEmitter) {
  6712. _inherits(NetworkController, _EventEmitter);
  6713. var _super = _createSuper$6(NetworkController);
  6714. function NetworkController(e) {
  6715. var _this;
  6716. _classCallCheck(this, NetworkController);
  6717. _this = _super.call(this);
  6718. _this.socket = null;
  6719. _this.rtcp = null;
  6720. _this.stream = null;
  6721. _this._state = 'connecting';
  6722. _this._networkMonitor = null;
  6723. _this.blockedActions = [];
  6724. _this.reconnectCount = 0;
  6725. _this.room = e, _this.socket = new Socket(_assertThisInitialized(_this));
  6726. _this.rtcp = new Rtcp(_assertThisInitialized(_this));
  6727. _this.stream = new Stream();
  6728. _this._networkMonitor = new NetworkMonitor(function () {
  6729. logger$1.info("network changed, online:", _this._networkMonitor.isOnline), _this._state === "disconnected" && _this._networkMonitor.isOnline && (logger$1.info("network back to online, try to reconnect"), _this.reconnect());
  6730. });
  6731. _this.checkNetworkQuality(_this.room.currentNetworkOptions.wsServerUrl);
  6732. _this._networkMonitor.start();
  6733. new VisibilityChangeHandler().subscribe(function (r) {
  6734. var n, o;
  6735. r ? ((o = _this.room.stats) == null || o.disable(), logger$1.infoAndReportMeasurement({
  6736. metric: "pageHide",
  6737. startTime: Date.now()
  6738. })) : ((n = _this.room.stats) == null || n.enable(), logger$1.infoAndReportMeasurement({
  6739. metric: "pageShow",
  6740. startTime: Date.now(),
  6741. extra: {
  6742. state: _this._state
  6743. }
  6744. }), _this._state === "disconnected" && _this.reconnect());
  6745. });
  6746. return _this;
  6747. }
  6748. _createClass(NetworkController, [{
  6749. key: "startGame",
  6750. value: function startGame() {
  6751. var _this2 = this;
  6752. return new Promise(function (e, t) {
  6753. if (!_this2.rtcp.connected) return t(new InternalError("Game cannot load. Please refresh"));
  6754. if (!_this2.rtcp.inputReady) return t(new InternalError("Game is not ready yet. Please wait"));
  6755. _this2.socket.on("gameRoomAvailable", function (r) {
  6756. _this2.setState("connected"), e(r), _this2.rtcp.heartbeat.start();
  6757. }), _this2.socket.on("socketClosed", function (r) {
  6758. t(r);
  6759. }), _this2.socket.startGame();
  6760. });
  6761. }
  6762. }, {
  6763. key: "addBlockedActions",
  6764. value: function addBlockedActions(e) {
  6765. var _this$blockedActions;
  6766. (_this$blockedActions = this.blockedActions).push.apply(_this$blockedActions, _toConsumableArray(e));
  6767. }
  6768. }, {
  6769. key: "removeBlockedActions",
  6770. value: function removeBlockedActions(e) {
  6771. if (!e) {
  6772. this.blockedActions = [];
  6773. return;
  6774. }
  6775. var t = this.blockedActions.indexOf(e);
  6776. this.blockedActions.splice(t, 1);
  6777. }
  6778. }, {
  6779. key: "setState",
  6780. value: function setState(e) {
  6781. this._state !== e && (logger$1.info("Set network state to ", e), this._state = e);
  6782. }
  6783. }, {
  6784. key: "connectAndStart",
  6785. value: function () {
  6786. var _connectAndStart = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  6787. return regenerator.wrap(function _callee$(_context) {
  6788. while (1) {
  6789. switch (_context.prev = _context.next) {
  6790. case 0:
  6791. return _context.abrupt("return", this.connect(e).then(this.startGame));
  6792. case 1:
  6793. case "end":
  6794. return _context.stop();
  6795. }
  6796. }
  6797. }, _callee, this);
  6798. }));
  6799. function connectAndStart(_x) {
  6800. return _connectAndStart.apply(this, arguments);
  6801. }
  6802. return connectAndStart;
  6803. }()
  6804. }, {
  6805. key: "connect",
  6806. value: function () {
  6807. var _connect = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
  6808. var _this3 = this;
  6809. var e,
  6810. _args2 = arguments;
  6811. return regenerator.wrap(function _callee2$(_context2) {
  6812. while (1) {
  6813. switch (_context2.prev = _context2.next) {
  6814. case 0:
  6815. e = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : !1;
  6816. this.room.updateCurrentNetworkOptions({
  6817. reconnect: e
  6818. });
  6819. return _context2.abrupt("return", new Promise(function (t, r) {
  6820. _this3.rtcp.on("rtcConnected", function () {
  6821. _this3.setState("connected"), t();
  6822. }), _this3.rtcp.on("rtcDisconnected", function () {
  6823. logger$1.info("rtc disconnected"), _this3._state === "connecting" ? (_this3.setState("disconnected"), r(new InternalError("rtc connect failed"))) : (_this3.setState("disconnected"), logger$1.info("rtc disconnected, start to reconnect"), _this3.reconnect());
  6824. }), _this3.socket.on("socketQuit", function () {
  6825. logger$1.info("socket quit success"), _this3.setState("closed");
  6826. }), _this3.socket.on("socketClosed", function (n) {
  6827. _this3._state === "connecting" && (_this3.setState("disconnected"), r(n)), r(n);
  6828. }), _this3.socket.start();
  6829. }));
  6830. case 3:
  6831. case "end":
  6832. return _context2.stop();
  6833. }
  6834. }
  6835. }, _callee2, this);
  6836. }));
  6837. function connect() {
  6838. return _connect.apply(this, arguments);
  6839. }
  6840. return connect;
  6841. }()
  6842. }, {
  6843. key: "reconnect",
  6844. value: function reconnect() {
  6845. var _this4 = this;
  6846. if (this.room.viewMode === "observer") return;
  6847. var e = Date.now();
  6848. if (this.reconnectCount++, this.reconnectCount > MAX_RECONNECT_COUNT) {
  6849. logger$1.error("reconnect failed, reached max reconnect count", MAX_RECONNECT_COUNT), this.reconnectCount = 0, this.emit("stateChanged", {
  6850. state: "disconnected"
  6851. });
  6852. return;
  6853. }
  6854. return logger$1.info("start reconnect, count:", this.reconnectCount), this._reconnect().then(function () {
  6855. logger$1.infoAndReportMeasurement({
  6856. startTime: e,
  6857. metric: "reconnect"
  6858. });
  6859. }).catch(function (t) {
  6860. if (logger$1.infoAndReportMeasurement({
  6861. startTime: e,
  6862. metric: "reconnect",
  6863. error: t
  6864. }), t.code === Codes.RepeatLogin) {
  6865. _this4.room.handleRepetLogin();
  6866. return;
  6867. }
  6868. var r = 1e3;
  6869. logger$1.info("reconnect failed, wait " + r + " ms for next reconnect"), setTimeout(function () {
  6870. _this4.reconnect();
  6871. }, r);
  6872. });
  6873. }
  6874. }, {
  6875. key: "_reconnect",
  6876. value: function _reconnect() {
  6877. var _this5 = this;
  6878. return this._state === "closed" ? (logger$1.warn("connection closed already"), Promise.reject()) : this._state === "connecting" ? (logger$1.warn("connection is already in connecting state"), Promise.reject()) : this._state !== "disconnected" ? Promise.reject() : (this.prepareReconnect(), this._state = "connecting", this.emit("stateChanged", {
  6879. state: "reconnecting",
  6880. count: this.reconnectCount
  6881. }), this.socket.off("gameRoomAvailable"), this.socket.off("socketClosed"), this.rtcp.off("rtcDisconnected"), this.rtcp.off("rtcConnected"), this.connectAndStart(!0).then(function (_ref) {
  6882. var e = _ref.session_id;
  6883. _this5.room.updateCurrentNetworkOptions({
  6884. sessionId: e
  6885. }), reporter.updateBody({
  6886. serverSession: e
  6887. }), logger$1.info("reconnect success"), _this5.setState("connected"), _this5.reconnectCount = 0, _this5.emit("stateChanged", {
  6888. state: "reconnected"
  6889. });
  6890. }));
  6891. }
  6892. }, {
  6893. key: "prepareReconnect",
  6894. value: function prepareReconnect() {
  6895. this.rtcp.disconnect(), this.socket.prepareReconnect(), this.prepareReconnectOptions();
  6896. }
  6897. }, {
  6898. key: "prepareReconnectOptions",
  6899. value: function prepareReconnectOptions() {
  6900. var _ref2 = this.room.currentClickingState || {},
  6901. e = _ref2.camera,
  6902. t = _ref2.player;
  6903. e && t && this.room.updateCurrentNetworkOptions({
  6904. camera: e,
  6905. player: t
  6906. });
  6907. }
  6908. }, {
  6909. key: "sendRtcData",
  6910. value: function sendRtcData(e) {
  6911. if (this.blockedActions.includes(e.action_type)) {
  6912. logger$1.info("action: ".concat(Actions[e.action_type], " was blocked"));
  6913. return;
  6914. }
  6915. this.rtcp.sendData(e);
  6916. }
  6917. }, {
  6918. key: "sendSocketData",
  6919. value: function sendSocketData(e) {
  6920. logger$1.debug("ws send ->", e), this.socket.send(e);
  6921. }
  6922. }, {
  6923. key: "quit",
  6924. value: function quit() {
  6925. var e = util.uuid(),
  6926. t = {
  6927. action_type: Actions.Exit,
  6928. trace_id: e,
  6929. exit_action: {},
  6930. user_id: this.room.options.userId,
  6931. packet_id: e
  6932. };
  6933. this.setState("closed"), this.socket.quit(), this.sendRtcData(t);
  6934. }
  6935. }, {
  6936. key: "checkNetworkQuality",
  6937. value: function checkNetworkQuality(i) {
  6938. var worker = null;
  6939. if (!i) return;
  6940. var e = Date.now();
  6941. if (this.pingOthers("https://www.baidu.com", function (t, r) {
  6942. logger$1.infoAndReportMeasurement({
  6943. metric: "baiduRtt",
  6944. group: "http",
  6945. value: r,
  6946. startTime: e
  6947. });
  6948. }), !worker) {
  6949. var t = new Blob([workerSourceCode], {
  6950. type: "application/javascript"
  6951. });
  6952. worker = new Worker(URL.createObjectURL(t)), worker.onmessage = function (r) {
  6953. logger$1.infoAndReportMeasurement({
  6954. metric: "workerRtt",
  6955. group: "http",
  6956. startTime: e,
  6957. value: r.data
  6958. });
  6959. };
  6960. }
  6961. }
  6962. }, {
  6963. key: "pingOthers",
  6964. value: function pingOthers(i, e) {
  6965. var t = !1;
  6966. var r = new Image();
  6967. r.onload = o, r.onerror = a;
  6968. var n = Date.now();
  6969. function o(l) {
  6970. t = !0, s();
  6971. }
  6972. function a(l) {}
  6973. function s() {
  6974. var l = Date.now() - n;
  6975. if (typeof e == "function") return t ? e(null, l) : (console.error("error loading resource"), e("error", l));
  6976. }
  6977. r.src = i + "/favicon.ico?" + +new Date();
  6978. }
  6979. }]);
  6980. return NetworkController;
  6981. }(EventEmitter);
  6982. var AssetTypeName = {
  6983. Config: 'CONFIG',
  6984. Model: 'MODEL',
  6985. Vedio: 'VEDIO',
  6986. Media: 'MEDIA',
  6987. Effects: 'EFFECTS',
  6988. Gift: 'GIFT',
  6989. Textures: 'TEXTURES'
  6990. };
  6991. var AssetClassName = {
  6992. Effects: '\u7279\u6548',
  6993. Tv: 'TV',
  6994. Lpm: '\u7C97\u6A21',
  6995. Reward: '\u571F\u8C6A\u699C',
  6996. Env: '\u73AF\u5883\u5149',
  6997. Gbq: '\u544A\u767D\u5899',
  6998. BreathPoint: '\u547C\u5438\u70B9',
  6999. Gifts: '\u9001\u793C',
  7000. Panorama: '\u5168\u666F\u56FE',
  7001. GiftBubble: '\u9001\u793C\u6C14\u6CE1',
  7002. SayBubble: '\u804A\u5929\u6C14\u6CE1'
  7003. };
  7004. var LoggerLevels$1 = {
  7005. Debug: 1,
  7006. Info: 2,
  7007. Warn: 3,
  7008. Error: 4,
  7009. Off: 5
  7010. };
  7011. var EShaderMode = {
  7012. default: 0,
  7013. video: 1,
  7014. videoAndPano: 2
  7015. };
  7016. var EFitMode = {
  7017. fill: 'fill',
  7018. contain: 'contain',
  7019. cover: 'cover'
  7020. };
  7021. var BaseTable = /*#__PURE__*/function () {
  7022. function BaseTable(e, t) {
  7023. _classCallCheck(this, BaseTable);
  7024. this.db = null;
  7025. this.isCreatingTable = !1;
  7026. this.hasCleared = !1;
  7027. this.dbName = e, this.dbVersion = t;
  7028. }
  7029. _createClass(BaseTable, [{
  7030. key: "clearDataBase",
  7031. value: function () {
  7032. var _clearDataBase = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  7033. var _this = this;
  7034. return regenerator.wrap(function _callee$(_context) {
  7035. while (1) {
  7036. switch (_context.prev = _context.next) {
  7037. case 0:
  7038. return _context.abrupt("return", this.hasCleared || (e && (this.hasCleared = !0), !window.indexedDB.databases) ? Promise.resolve() : new Promise(function (t, r) {
  7039. var n = window.indexedDB.deleteDatabase(_this.dbName);
  7040. n.onsuccess = function () {
  7041. t();
  7042. }, n.onerror = r;
  7043. }));
  7044. case 1:
  7045. case "end":
  7046. return _context.stop();
  7047. }
  7048. }
  7049. }, _callee, this);
  7050. }));
  7051. function clearDataBase(_x) {
  7052. return _clearDataBase.apply(this, arguments);
  7053. }
  7054. return clearDataBase;
  7055. }()
  7056. }, {
  7057. key: "tableName",
  7058. value: function tableName() {
  7059. throw new Error("Derived class have to override 'tableName', and set a proper table name!");
  7060. }
  7061. }, {
  7062. key: "keyPath",
  7063. value: function keyPath() {
  7064. throw new Error("Derived class have to override 'keyPath', and set a proper index name!");
  7065. }
  7066. }, {
  7067. key: "index",
  7068. value: function index() {
  7069. throw new Error("Derived class have to override 'index', and set a proper index name!");
  7070. }
  7071. }, {
  7072. key: "checkAndOpenDatabase",
  7073. value: function () {
  7074. var _checkAndOpenDatabase = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
  7075. var _this2 = this;
  7076. return regenerator.wrap(function _callee2$(_context2) {
  7077. while (1) {
  7078. switch (_context2.prev = _context2.next) {
  7079. case 0:
  7080. return _context2.abrupt("return", this.db ? Promise.resolve(this.db) : new Promise(function (e, t) {
  7081. var n = setTimeout(function () {
  7082. logger$1.info("wait db to open for", 200), _this2.db ? e(_this2.db) : e(_this2.checkAndOpenDatabase()), clearTimeout(n);
  7083. }, 200);
  7084. _this2.openDatabase(_this2.dbName, _this2.dbVersion || 1, function () {
  7085. _this2.db && !_this2.isCreatingTable && e(_this2.db), logger$1.info("successCallback called, this.db: ".concat(!!_this2.db, ", this.isCreatingStore: ").concat(_this2.isCreatingTable)), clearTimeout(n);
  7086. }, function () {
  7087. t(new Error("Failed to open database!")), clearTimeout(n);
  7088. }, function () {
  7089. _this2.db && e(_this2.db), clearTimeout(n), logger$1.info("successCallback called, this.db: ".concat(!!_this2.db, ", this.isCreatingStore: ").concat(_this2.isCreatingTable));
  7090. });
  7091. }));
  7092. case 1:
  7093. case "end":
  7094. return _context2.stop();
  7095. }
  7096. }
  7097. }, _callee2, this);
  7098. }));
  7099. function checkAndOpenDatabase() {
  7100. return _checkAndOpenDatabase.apply(this, arguments);
  7101. }
  7102. return checkAndOpenDatabase;
  7103. }()
  7104. }, {
  7105. key: "openDatabase",
  7106. value: function openDatabase(e, t, r, n, o) {
  7107. var _this3 = this;
  7108. if (this.isCreatingTable) return;
  7109. this.isCreatingTable = !0, logger$1.info(e, t);
  7110. var a = window.indexedDB.open(e, t),
  7111. s = this.tableName();
  7112. a.onsuccess = function (l) {
  7113. _this3.db = a.result, logger$1.info("IndexedDb ".concat(e, " is opened.")), _this3.db.objectStoreNames.contains(s) && (_this3.isCreatingTable = !1), r && r(l);
  7114. }, a.onerror = function (l) {
  7115. var u;
  7116. logger$1.error("Failed to open database", (u = l == null ? void 0 : l.srcElement) == null ? void 0 : u.error), _this3.isCreatingTable = !1, n && n(l), _this3.clearDataBase(!0);
  7117. }, a.onupgradeneeded = function (l) {
  7118. var u = l.target.result,
  7119. c = _this3.index();
  7120. logger$1.info("Creating table ".concat(s, "."));
  7121. var h = u.objectStoreNames.contains(s);
  7122. if (h) h = u.transaction([s], "readwrite").objectStore(s);else {
  7123. var f = _this3.keyPath();
  7124. h = u.createObjectStore(s, {
  7125. keyPath: f
  7126. });
  7127. }
  7128. c.map(function (f) {
  7129. h.createIndex(f, f, {
  7130. unique: !1
  7131. });
  7132. }), _this3.isCreatingTable = !1, logger$1.info("Table ".concat(s, " opened")), o && o(l);
  7133. };
  7134. }
  7135. }, {
  7136. key: "add",
  7137. value: function () {
  7138. var _add = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e) {
  7139. var t, o;
  7140. return regenerator.wrap(function _callee3$(_context3) {
  7141. while (1) {
  7142. switch (_context3.prev = _context3.next) {
  7143. case 0:
  7144. t = this.tableName();
  7145. _context3.next = 3;
  7146. return this.checkAndOpenDatabase();
  7147. case 3:
  7148. o = _context3.sent.transaction([t], "readwrite").objectStore(t).add(e);
  7149. return _context3.abrupt("return", new Promise(function (a, s) {
  7150. o.onsuccess = function (l) {
  7151. a(l);
  7152. }, o.onerror = function (l) {
  7153. var u;
  7154. logger$1.error((u = l.srcElement) == null ? void 0 : u.error), s(l);
  7155. };
  7156. }));
  7157. case 5:
  7158. case "end":
  7159. return _context3.stop();
  7160. }
  7161. }
  7162. }, _callee3, this);
  7163. }));
  7164. function add(_x2) {
  7165. return _add.apply(this, arguments);
  7166. }
  7167. return add;
  7168. }()
  7169. }, {
  7170. key: "put",
  7171. value: function () {
  7172. var _put = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(e) {
  7173. var t, o;
  7174. return regenerator.wrap(function _callee4$(_context4) {
  7175. while (1) {
  7176. switch (_context4.prev = _context4.next) {
  7177. case 0:
  7178. t = this.tableName();
  7179. _context4.next = 3;
  7180. return this.checkAndOpenDatabase();
  7181. case 3:
  7182. o = _context4.sent.transaction([t], "readwrite").objectStore(t).put(e);
  7183. return _context4.abrupt("return", new Promise(function (a, s) {
  7184. o.onsuccess = function (l) {
  7185. a(l);
  7186. }, o.onerror = function (l) {
  7187. var u;
  7188. logger$1.error("db put error", (u = l.srcElement) == null ? void 0 : u.error), s(l);
  7189. };
  7190. }));
  7191. case 5:
  7192. case "end":
  7193. return _context4.stop();
  7194. }
  7195. }
  7196. }, _callee4, this);
  7197. }));
  7198. function put(_x3) {
  7199. return _put.apply(this, arguments);
  7200. }
  7201. return put;
  7202. }()
  7203. }, {
  7204. key: "delete",
  7205. value: function _delete(e, t, r) {
  7206. var n = this.tableName();
  7207. this.checkAndOpenDatabase().then(function (o) {
  7208. var s = o.transaction([n], "readwrite").objectStore(n).delete(e);
  7209. s.onsuccess = t, s.onerror = r;
  7210. });
  7211. }
  7212. }, {
  7213. key: "update",
  7214. value: function update() {
  7215. this.checkAndOpenDatabase().then(function (e) {});
  7216. }
  7217. }, {
  7218. key: "getAllKeys",
  7219. value: function () {
  7220. var _getAllKeys = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5() {
  7221. var e, t;
  7222. return regenerator.wrap(function _callee5$(_context5) {
  7223. while (1) {
  7224. switch (_context5.prev = _context5.next) {
  7225. case 0:
  7226. e = this.tableName();
  7227. _context5.next = 3;
  7228. return this.checkAndOpenDatabase();
  7229. case 3:
  7230. t = _context5.sent;
  7231. return _context5.abrupt("return", new Promise(function (r, n) {
  7232. var a = t.transaction([e], "readonly").objectStore(e).getAllKeys();
  7233. a.onsuccess = function (s) {
  7234. r(s.target.result);
  7235. }, a.onerror = function (s) {
  7236. logger$1.error("db getAllKeys error", s), n(s);
  7237. };
  7238. }));
  7239. case 5:
  7240. case "end":
  7241. return _context5.stop();
  7242. }
  7243. }
  7244. }, _callee5, this);
  7245. }));
  7246. function getAllKeys() {
  7247. return _getAllKeys.apply(this, arguments);
  7248. }
  7249. return getAllKeys;
  7250. }()
  7251. }, {
  7252. key: "query",
  7253. value: function () {
  7254. var _query = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6(e, t) {
  7255. var r, n;
  7256. return regenerator.wrap(function _callee6$(_context6) {
  7257. while (1) {
  7258. switch (_context6.prev = _context6.next) {
  7259. case 0:
  7260. r = this.tableName();
  7261. _context6.next = 3;
  7262. return this.checkAndOpenDatabase();
  7263. case 3:
  7264. n = _context6.sent;
  7265. return _context6.abrupt("return", new Promise(function (o, a) {
  7266. var u = n.transaction([r], "readonly").objectStore(r).index(e).get(t);
  7267. u.onsuccess = function (c) {
  7268. var f;
  7269. var h = (f = c == null ? void 0 : c.target) == null ? void 0 : f.result;
  7270. o && o(h);
  7271. }, u.onerror = function (c) {
  7272. logger$1.error("db query error", c), a(c);
  7273. };
  7274. }));
  7275. case 5:
  7276. case "end":
  7277. return _context6.stop();
  7278. }
  7279. }
  7280. }, _callee6, this);
  7281. }));
  7282. function query(_x4, _x5) {
  7283. return _query.apply(this, arguments);
  7284. }
  7285. return query;
  7286. }()
  7287. }, {
  7288. key: "sleep",
  7289. value: function () {
  7290. var _sleep = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee7(e) {
  7291. return regenerator.wrap(function _callee7$(_context7) {
  7292. while (1) {
  7293. switch (_context7.prev = _context7.next) {
  7294. case 0:
  7295. return _context7.abrupt("return", new Promise(function (t) {
  7296. setTimeout(function () {
  7297. t("");
  7298. }, e);
  7299. }));
  7300. case 1:
  7301. case "end":
  7302. return _context7.stop();
  7303. }
  7304. }
  7305. }, _callee7);
  7306. }));
  7307. function sleep(_x6) {
  7308. return _sleep.apply(this, arguments);
  7309. }
  7310. return sleep;
  7311. }()
  7312. }]);
  7313. return BaseTable;
  7314. }();
  7315. function _createSuper$5(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$5(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  7316. function _isNativeReflectConstruct$5() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  7317. var ModelTable = /*#__PURE__*/function (_BaseTable) {
  7318. _inherits(ModelTable, _BaseTable);
  7319. var _super = _createSuper$5(ModelTable);
  7320. function ModelTable() {
  7321. _classCallCheck(this, ModelTable);
  7322. return _super.call(this, "XverseDatabase", 1);
  7323. }
  7324. _createClass(ModelTable, [{
  7325. key: "tableName",
  7326. value: function tableName() {
  7327. return "models";
  7328. }
  7329. }, {
  7330. key: "index",
  7331. value: function index() {
  7332. return ["url"];
  7333. }
  7334. }, {
  7335. key: "keyPath",
  7336. value: function keyPath() {
  7337. return "url";
  7338. }
  7339. }]);
  7340. return ModelTable;
  7341. }(BaseTable);
  7342. var modelTable = new ModelTable();
  7343. function _createSuper$4(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$4(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  7344. function _isNativeReflectConstruct$4() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  7345. var isIndexedDbSupported = function isIndexedDbSupported() {
  7346. return (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB) !== void 0;
  7347. };
  7348. var dataURItoBlob = function dataURItoBlob(i) {
  7349. var e;
  7350. i.split(",")[0].indexOf("base64") >= 0 ? e = atob(i.split(",")[1]) : e = unescape(i.split(",")[1]);
  7351. var t = i.split(",")[0].split(":")[1].split(";")[0],
  7352. r = new Uint8Array(e.length);
  7353. for (var o = 0; o < e.length; o++) {
  7354. r[o] = e.charCodeAt(o);
  7355. }
  7356. return new Blob([r], {
  7357. type: t
  7358. });
  7359. };
  7360. var Http = /*#__PURE__*/function (_EventEmitter) {
  7361. _inherits(Http, _EventEmitter);
  7362. var _super = _createSuper$4(Http);
  7363. function Http() {
  7364. _classCallCheck(this, Http);
  7365. return _super.apply(this, arguments);
  7366. }
  7367. _createClass(Http, [{
  7368. key: "get",
  7369. value: function () {
  7370. var _get = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(_ref) {
  7371. var e, _ref$useIndexedDb, t, _ref$timeout, r, n, _ref$isOutPutObjectUR, o, a, s, l;
  7372. return regenerator.wrap(function _callee2$(_context2) {
  7373. while (1) {
  7374. switch (_context2.prev = _context2.next) {
  7375. case 0:
  7376. e = _ref.url, _ref$useIndexedDb = _ref.useIndexedDb, t = _ref$useIndexedDb === void 0 ? !1 : _ref$useIndexedDb, _ref$timeout = _ref.timeout, r = _ref$timeout === void 0 ? 15e3 : _ref$timeout, n = _ref.key, _ref$isOutPutObjectUR = _ref.isOutPutObjectURL, o = _ref$isOutPutObjectUR === void 0 ? !0 : _ref$isOutPutObjectUR;
  7377. if (!(Xverse.NO_CACHE !== void 0 && (t = !Xverse.NO_CACHE), t)) {
  7378. _context2.next = 25;
  7379. break;
  7380. }
  7381. if (!isIndexedDbSupported()) {
  7382. _context2.next = 22;
  7383. break;
  7384. }
  7385. window.performance.now();
  7386. a = null;
  7387. _context2.prev = 5;
  7388. _context2.next = 8;
  7389. return modelTable.query("url", e);
  7390. case 8:
  7391. a = _context2.sent;
  7392. _context2.next = 14;
  7393. break;
  7394. case 11:
  7395. _context2.prev = 11;
  7396. _context2.t0 = _context2["catch"](5);
  7397. return _context2.abrupt("return", (logger$1.debug(_context2.t0), logger$1.warn("cache query error", e), Promise.resolve(e)));
  7398. case 14:
  7399. if (!(a && a.model)) {
  7400. _context2.next = 19;
  7401. break;
  7402. }
  7403. s = dataURItoBlob(a.model), l = Promise.resolve(o ? URL.createObjectURL(s) : s);
  7404. return _context2.abrupt("return", (window.performance.now(), l));
  7405. case 19:
  7406. return _context2.abrupt("return", this.request({
  7407. url: e,
  7408. timeout: r,
  7409. contentType: "blob",
  7410. key: n
  7411. }).then( /*#__PURE__*/function () {
  7412. var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(s) {
  7413. var l;
  7414. return regenerator.wrap(function _callee$(_context) {
  7415. while (1) {
  7416. switch (_context.prev = _context.next) {
  7417. case 0:
  7418. _context.next = 2;
  7419. return blobToDataURI(s.response);
  7420. case 2:
  7421. l = _context.sent;
  7422. _context.prev = 3;
  7423. _context.next = 6;
  7424. return modelTable.put({
  7425. url: e,
  7426. model: l
  7427. });
  7428. case 6:
  7429. _context.next = 11;
  7430. break;
  7431. case 8:
  7432. _context.prev = 8;
  7433. _context.t0 = _context["catch"](3);
  7434. logger$1.warn("unable to add data to indexedDB", _context.t0);
  7435. case 11:
  7436. return _context.abrupt("return", Promise.resolve(o ? URL.createObjectURL(s.response) : s.response));
  7437. case 12:
  7438. case "end":
  7439. return _context.stop();
  7440. }
  7441. }
  7442. }, _callee, null, [[3, 8]]);
  7443. }));
  7444. return function (_x2) {
  7445. return _ref2.apply(this, arguments);
  7446. };
  7447. }()));
  7448. case 20:
  7449. _context2.next = 23;
  7450. break;
  7451. case 22:
  7452. return _context2.abrupt("return", this.request({
  7453. url: e,
  7454. timeout: r,
  7455. contentType: "blob",
  7456. key: n
  7457. }).then(function (a) {
  7458. var s = a.response;
  7459. return Promise.resolve(o ? URL.createObjectURL(s) : s);
  7460. }).catch(function (a) {
  7461. return Promise.reject(a);
  7462. }));
  7463. case 23:
  7464. _context2.next = 26;
  7465. break;
  7466. case 25:
  7467. return _context2.abrupt("return", this.request({
  7468. url: e,
  7469. timeout: r,
  7470. key: n
  7471. }).then(function (a) {
  7472. return a.getResponseHeader("content-type") === "application/json" ? Promise.resolve(JSON.parse(a.responseText)) : Promise.resolve(a.responseText);
  7473. }));
  7474. case 26:
  7475. case "end":
  7476. return _context2.stop();
  7477. }
  7478. }
  7479. }, _callee2, this, [[5, 11]]);
  7480. }));
  7481. function get(_x) {
  7482. return _get.apply(this, arguments);
  7483. }
  7484. return get;
  7485. }()
  7486. }, {
  7487. key: "request",
  7488. value: function request(e) {
  7489. var _this = this;
  7490. var _e$timeout = e.timeout,
  7491. t = _e$timeout === void 0 ? 3e4 : _e$timeout,
  7492. r = e.contentType;
  7493. e.key;
  7494. var o = e.onRequestStart,
  7495. a = e.url;
  7496. return new Promise(function (s, l) {
  7497. window.performance.now();
  7498. var u = new XMLHttpRequest();
  7499. r && (u.responseType = r), u.timeout = t, u.addEventListener("readystatechange", function () {
  7500. if (u.readyState == 4) {
  7501. if (u.status == 200) return window.performance.now(), _this.emit("loadend", {
  7502. message: "request ".concat(a, " load success")
  7503. }), s(u);
  7504. {
  7505. var c = "Unable to load the request ".concat(a);
  7506. return _this.emit("error", {
  7507. message: c
  7508. }), logger$1.error(c), l(c);
  7509. }
  7510. }
  7511. }), o && o(u), u.open("GET", a), u.send();
  7512. });
  7513. }
  7514. }]);
  7515. return Http;
  7516. }(EventEmitter); // const http = new Http();
  7517. var Logger1 = /*#__PURE__*/function () {
  7518. function Logger1(e) {
  7519. _classCallCheck(this, Logger1);
  7520. E(this, "module");
  7521. this.module = e;
  7522. }
  7523. _createClass(Logger1, [{
  7524. key: "debug",
  7525. value: function debug() {
  7526. var _Logger1$instance;
  7527. return (_Logger1$instance = Logger1.instance).debug.apply(_Logger1$instance, arguments);
  7528. }
  7529. }, {
  7530. key: "info",
  7531. value: function info() {
  7532. var _Logger1$instance2;
  7533. return (_Logger1$instance2 = Logger1.instance).info.apply(_Logger1$instance2, arguments);
  7534. }
  7535. }, {
  7536. key: "warn",
  7537. value: function warn() {
  7538. var _Logger1$instance3;
  7539. return (_Logger1$instance3 = Logger1.instance).warn.apply(_Logger1$instance3, arguments);
  7540. }
  7541. }, {
  7542. key: "error",
  7543. value: function error() {
  7544. var _Logger1$instance4;
  7545. return (_Logger1$instance4 = Logger1.instance).error.apply(_Logger1$instance4, arguments);
  7546. }
  7547. }], [{
  7548. key: "setLogger",
  7549. value: function setLogger(e) {
  7550. Logger1.instance = e;
  7551. }
  7552. }]);
  7553. return Logger1;
  7554. }();
  7555. var XCameraComponent = /*#__PURE__*/function () {
  7556. function XCameraComponent(e, t, r) {
  7557. var _this = this;
  7558. _classCallCheck(this, XCameraComponent);
  7559. E(this, "maincameraRotLimitObserver", null);
  7560. E(this, "mainCamera");
  7561. E(this, "cgCamera");
  7562. E(this, "saveCameraPose");
  7563. E(this, "_cameraPose");
  7564. E(this, "scene");
  7565. E(this, "canvas");
  7566. E(this, "yuvInfo");
  7567. E(this, "forceKeepVertical", !1);
  7568. E(this, "initCamera", function (e) {
  7569. var _e$maxZ = e.maxZ,
  7570. t = _e$maxZ === void 0 ? 1e4 : _e$maxZ,
  7571. _e$minZ = e.minZ,
  7572. r = _e$minZ === void 0 ? .1 : _e$minZ,
  7573. _e$angularSensibility = e.angularSensibility,
  7574. n = _e$angularSensibility === void 0 ? 2e3 : _e$angularSensibility;
  7575. _this.mainCamera = new BABYLON.FreeCamera("camera_main", new BABYLON.Vector3(0, 1e3, 0), _this.scene), _this.mainCamera.mode = BABYLON.Camera.PERSPECTIVE_CAMERA, _this.mainCamera.speed = .1, _this.mainCamera.angularSensibility = n, _this.mainCamera.setTarget(new BABYLON.Vector3(0, 1010, 0)), _this.mainCamera.minZ = r, _this.mainCamera.fov = Math.PI * _this.yuvInfo.fov / 180, _this.mainCamera.maxZ = t, _this.mainCamera.fovMode = BABYLON.Camera.FOVMODE_HORIZONTAL_FIXED, _this.cgCamera = new BABYLON.FreeCamera("camera_temp", new BABYLON.Vector3(0, 1e3, 0), _this.scene), _this.cgCamera.mode = BABYLON.Camera.PERSPECTIVE_CAMERA, _this.cgCamera.speed = .1, _this.cgCamera.setTarget(new BABYLON.Vector3(0, 1010, 0)), _this.cgCamera.maxZ = t, _this.cgCamera.minZ = r, _this.cgCamera.fovMode = BABYLON.Camera.FOVMODE_HORIZONTAL_FIXED, _this.cameraFovChange(_this.yuvInfo);
  7576. });
  7577. E(this, "cameraFovChange", function (e) {
  7578. _this.yuvInfo = e;
  7579. var t = e.width,
  7580. r = e.height,
  7581. n = _this.canvas.width,
  7582. o = _this.canvas.height,
  7583. a = e.fov;
  7584. if (_this.forceKeepVertical == !0) {
  7585. var s = t / (2 * Math.tan(Math.PI * a / 360)),
  7586. l = 2 * Math.atan(r / (2 * s));
  7587. _this.mainCamera.fov = l, _this.cgCamera.fov = l, _this.mainCamera.fovMode = BABYLON.Camera.FOVMODE_VERTICAL_FIXED, _this.cgCamera.fovMode = BABYLON.Camera.FOVMODE_VERTICAL_FIXED;
  7588. } else if (_this.mainCamera.fovMode = BABYLON.Camera.FOVMODE_HORIZONTAL_FIXED, _this.cgCamera.fovMode = BABYLON.Camera.FOVMODE_HORIZONTAL_FIXED, n / o < t / r && _this.mainCamera.fov) {
  7589. var _s = o,
  7590. _l = n,
  7591. u = _s * t / r / (2 * Math.tan(a * Math.PI / 360)),
  7592. c = 2 * Math.atan(_l / (2 * u));
  7593. _this.mainCamera.fov = c, _this.cgCamera.fov = c;
  7594. } else _this.mainCamera.fov = Math.PI * a / 180, _this.cgCamera.fov = Math.PI * a / 180;
  7595. });
  7596. E(this, "setCameraPose", function (e) {
  7597. var n;
  7598. var t = ue4Position2Xverse(e.position);
  7599. var r = null;
  7600. e.rotation != null && (r = ue4Rotation2Xverse(e.rotation)), _this._cameraPose = {
  7601. position: t
  7602. }, r != null && (_this._cameraPose.rotation = r), _this.scene.activeCamera === _this.mainCamera && !((n = _this.mainCamera) != null && n.isDisposed()) && _this._setCamPositionRotation(_this.mainCamera, _this._cameraPose);
  7603. });
  7604. E(this, "_setCamPositionRotation", function (e, t) {
  7605. var r, n;
  7606. t.position && (e.position = (r = t.position) == null ? void 0 : r.clone()), t.rotation && (e.rotation = (n = t.rotation) == null ? void 0 : n.clone());
  7607. });
  7608. E(this, "switchCamera", function (e) {
  7609. var t;
  7610. (t = _this.scene.activeCamera) == null || t.detachControl(_this.canvas), _this.scene.activeCamera = e;
  7611. });
  7612. E(this, "reCalXYZRot", function (e, t) {
  7613. return e = e % (2 * Math.PI), Math.abs(t - e) >= Math.PI && (e = e - 2 * Math.PI), e;
  7614. });
  7615. E(this, "_moveCam", function (e, t, r, n, o, a, s, l) {
  7616. var u = function u(v, y, b) {
  7617. return v.x = _this.reCalXYZRot(v.x, y.x), v.y = _this.reCalXYZRot(v.y, y.y), v.z = _this.reCalXYZRot(v.z, y.z), new BABYLON.Vector3((y.x - v.x) * b + v.x, (y.y - v.y) * b + v.y, (y.z - v.z) * b + v.z);
  7618. },
  7619. c = function c(v, y, b) {
  7620. return new BABYLON.Vector3((y.x - v.x) * b + v.x, (y.y - v.y) * b + v.y, (y.z - v.z) * b + v.z);
  7621. },
  7622. h = new Animation("myAnimation1", "position", s, Animation.ANIMATIONTYPE_VECTOR3, Animation.ANIMATIONLOOPMODE_CONSTANT);
  7623. var f = [],
  7624. d = t,
  7625. _ = r;
  7626. for (var v = 0; v < a; ++v) {
  7627. f.push({
  7628. frame: v,
  7629. value: c(d, _, v / a)
  7630. });
  7631. }
  7632. f.push({
  7633. frame: f.length,
  7634. value: c(d, _, 1)
  7635. }), h.setKeys(f);
  7636. var g = new Animation("myAnimation2", "rotation", s, Animation.ANIMATIONTYPE_VECTOR3, Animation.ANIMATIONLOOPMODE_CONSTANT);
  7637. f = [], d = n, _ = o;
  7638. for (var _v = 0; _v < a; ++_v) {
  7639. f.push({
  7640. frame: _v,
  7641. value: u(d, _, _v / a)
  7642. });
  7643. }
  7644. f.push({
  7645. frame: f.length,
  7646. value: u(d, _, 1)
  7647. }), g.setKeys(f), e.animations.push(g), e.animations.push(h);
  7648. var m = _this.scene.beginAnimation(e, 0, a, !1);
  7649. m.onAnimationEnd = function () {
  7650. l(), m.stop(), m.animationStarted = !1;
  7651. };
  7652. });
  7653. this.scene = t, this.canvas = e, this.yuvInfo = r.yuvInfo, r.forceKeepVertical != null && (this.forceKeepVertical = r.forceKeepVertical), this.initCamera(r.cameraParam);
  7654. }
  7655. _createClass(XCameraComponent, [{
  7656. key: "MainCamera",
  7657. get: function get() {
  7658. return this.mainCamera;
  7659. }
  7660. }, {
  7661. key: "CgCamera",
  7662. get: function get() {
  7663. return this.cgCamera;
  7664. }
  7665. }, {
  7666. key: "getCameraHorizonFov",
  7667. value: function getCameraHorizonFov() {
  7668. return this.mainCamera.fovMode == BABYLON.Camera.FOVMODE_HORIZONTAL_FIXED ? this.mainCamera.fov : Math.PI * this.yuvInfo.fov / 180;
  7669. }
  7670. }, {
  7671. key: "changeMainCameraRotationDamping",
  7672. value: function changeMainCameraRotationDamping() {
  7673. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 2e3;
  7674. this.mainCamera.angularSensibility = e;
  7675. }
  7676. }, {
  7677. key: "removeMainCameraRotationLimit",
  7678. value: function removeMainCameraRotationLimit() {
  7679. this.maincameraRotLimitObserver != null && this.mainCamera.onAfterCheckInputsObservable.remove(this.maincameraRotLimitObserver);
  7680. }
  7681. }, {
  7682. key: "setMainCameraInfo",
  7683. value: function setMainCameraInfo(e) {
  7684. var _e$maxZ2 = e.maxZ,
  7685. t = _e$maxZ2 === void 0 ? 1e4 : _e$maxZ2,
  7686. _e$minZ2 = e.minZ,
  7687. r = _e$minZ2 === void 0 ? .1 : _e$minZ2,
  7688. _e$angularSensibility2 = e.angularSensibility,
  7689. n = _e$angularSensibility2 === void 0 ? 2e3 : _e$angularSensibility2;
  7690. this.mainCamera.maxZ = t, this.mainCamera.minZ = r, this.mainCamera.angularSensibility = n;
  7691. }
  7692. }, {
  7693. key: "getMainCameraInfo",
  7694. value: function getMainCameraInfo() {
  7695. return {
  7696. maxZ: this.mainCamera.maxZ,
  7697. minZ: this.mainCamera.minZ,
  7698. angularSensibility: this.mainCamera.angularSensibility
  7699. };
  7700. }
  7701. }, {
  7702. key: "_limitAngle",
  7703. value: function _limitAngle(e, t) {
  7704. return Math.abs(Math.abs(t[0] - t[1]) - 360) < 1e-6 || (e = (e % 360 + 360) % 360, t[0] = (t[0] % 360 + 360) % 360, t[1] = (t[1] % 360 + 360) % 360, t[0] > t[1] ? e > t[1] && e < t[0] && (Math.abs(e - t[0]) < Math.abs(e - t[1]) ? e = t[0] : e = t[1]) : e < t[0] ? e = t[0] : e > t[1] && (e = t[1])), e;
  7705. }
  7706. }, {
  7707. key: "setMainCameraRotationLimit",
  7708. value: function setMainCameraRotationLimit(e, t) {
  7709. var _this2 = this;
  7710. this.maincameraRotLimitObserver != null && this.removeMainCameraRotationLimit();
  7711. var r = this.mainCamera,
  7712. n = e.yaw,
  7713. o = e.pitch,
  7714. a = e.roll,
  7715. s = t.yaw,
  7716. l = t.pitch,
  7717. u = t.roll;
  7718. if (s < 0 || l < 0 || u < 0) throw new Error("\u76F8\u673A\u65CB\u8F6C\u9650\u5236\u53EA\u80FD\u8BBE\u7F6E\u4E3A\u5927\u4E8E0");
  7719. var c = [o - l, o + l],
  7720. h = [n - s, n + s],
  7721. f = [a - u, a + u];
  7722. this.maincameraRotLimitObserver = r.onAfterCheckInputsObservable.add(function () {
  7723. var _xverseRotation2Ue = xverseRotation2Ue4(r.rotation),
  7724. d = _xverseRotation2Ue.pitch,
  7725. _ = _xverseRotation2Ue.yaw,
  7726. g = _xverseRotation2Ue.roll;
  7727. d = _this2._limitAngle(d, c), _ = _this2._limitAngle(_, h), g = _this2._limitAngle(g, f), r.rotation = ue4Rotation2Xverse({
  7728. pitch: d,
  7729. yaw: _,
  7730. roll: g
  7731. });
  7732. });
  7733. }
  7734. }, {
  7735. key: "setMainCameraRotationLimitByAnchor",
  7736. value: function setMainCameraRotationLimitByAnchor(e, t, r) {
  7737. this.maincameraRotLimitObserver != null && this.removeMainCameraRotationLimit();
  7738. var n = this.mainCamera,
  7739. o = ue4Rotation2Xverse_mesh(t),
  7740. a = ue4Rotation2Xverse_mesh(r);
  7741. a != null && o != null && e.mesh != null && (this.maincameraRotLimitObserver = n.onAfterCheckInputsObservable.add(function () {
  7742. var s = e.mesh.rotation;
  7743. r.yaw > 0 && (n.rotation.y <= s.y - a.y + o.y ? n.rotation.y = s.y - a.y + o.y : n.rotation.y >= s.y + a.y + o.y && (n.rotation.y = s.y + a.y + o.y)), r.pitch > 0 && (n.rotation.x <= s.x - a.x + o.x ? n.rotation.x = s.x - a.x + o.x : n.rotation.x >= s.x + a.x + o.x && (n.rotation.x = s.x + a.x + o.x)), r.roll > 0 && (n.rotation.z <= s.z - a.z + o.z ? n.rotation.z = s.z - a.z + o.z : n.rotation.z >= s.z + a.z + o.z && (n.rotation.z = s.z + a.z + o.z));
  7744. }));
  7745. }
  7746. }, {
  7747. key: "getCameraPose",
  7748. value: function getCameraPose() {
  7749. var e = xversePosition2Ue4({
  7750. x: this.mainCamera.position.x,
  7751. y: this.mainCamera.position.y,
  7752. z: this.mainCamera.position.z
  7753. }),
  7754. t = xverseRotation2Ue4({
  7755. x: this.mainCamera.rotation.x,
  7756. y: this.mainCamera.rotation.y,
  7757. z: this.mainCamera.rotation.z
  7758. });
  7759. return {
  7760. position: e,
  7761. rotation: t
  7762. };
  7763. }
  7764. }, {
  7765. key: "changeCameraFov",
  7766. value: function changeCameraFov(e, t) {
  7767. this.mainCamera.fov = e, t != null && (this.mainCamera.fovMode = t == 0 ? BABYLON.Camera.FOVMODE_HORIZONTAL_FIXED : BABYLON.Camera.FOVMODE_VERTICAL_FIXED);
  7768. }
  7769. }, {
  7770. key: "controlCameraRotation",
  7771. value: function controlCameraRotation(e, t) {
  7772. var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : .5;
  7773. var n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : .5;
  7774. var o = {
  7775. pitch: n * t * 180,
  7776. yaw: r * e * 180,
  7777. roll: 0
  7778. };
  7779. this.addRot(o);
  7780. }
  7781. }, {
  7782. key: "addRot",
  7783. value: function addRot(e) {
  7784. var t = this.mainCamera,
  7785. r = ue4Rotation2Xverse_mesh(e);
  7786. r != null && t.rotation.addInPlace(r);
  7787. }
  7788. }, {
  7789. key: "getCameraFov",
  7790. value: function getCameraFov() {
  7791. return this.mainCamera.fov;
  7792. }
  7793. }, {
  7794. key: "allowMainCameraController",
  7795. value: function allowMainCameraController() {
  7796. this.mainCamera.attachControl(this.canvas, !0);
  7797. }
  7798. }, {
  7799. key: "detachMainCameraController",
  7800. value: function detachMainCameraController() {
  7801. this.mainCamera.detachControl(this.canvas);
  7802. }
  7803. }, {
  7804. key: "forceChangeSavedCameraPose",
  7805. value: function forceChangeSavedCameraPose(e) {
  7806. this.saveCameraPose != null && (e.position != null && (this.saveCameraPose.position = ue4Position2Xverse(e.position)), e.rotation != null && (this.saveCameraPose.rotation = ue4Rotation2Xverse(e.rotation)));
  7807. }
  7808. }, {
  7809. key: "changeToFirstPersonView",
  7810. value: function changeToFirstPersonView(e) {
  7811. this.saveCameraPose = {
  7812. position: this.mainCamera.position.clone(),
  7813. rotation: this.mainCamera.rotation.clone()
  7814. }, this.mainCamera.attachControl(this.canvas, !0), e.position != null && (this.mainCamera.position = ue4Position2Xverse(e.position)), e.rotation != null && (this.mainCamera.rotation = ue4Rotation2Xverse(e.rotation));
  7815. }
  7816. }, {
  7817. key: "changeToThirdPersonView",
  7818. value: function changeToThirdPersonView() {
  7819. this.saveCameraPose != null && this.mainCamera != null && (this.mainCamera.position = this.saveCameraPose.position.clone(), this.mainCamera.rotation = this.saveCameraPose.rotation.clone(), this.mainCamera.detachControl(this.canvas));
  7820. }
  7821. }, {
  7822. key: "switchToMainCamera",
  7823. value: function switchToMainCamera() {
  7824. this.switchCamera(this.mainCamera);
  7825. }
  7826. }, {
  7827. key: "switchToCgCamera",
  7828. value: function switchToCgCamera() {
  7829. this.switchCamera(this.cgCamera);
  7830. }
  7831. }, {
  7832. key: "moveMainCamera",
  7833. value: function moveMainCamera(e, t, r, n, o) {
  7834. this._moveCam(this.mainCamera, this.mainCamera.position, e, this.mainCamera.rotation, t, r, n, o);
  7835. }
  7836. }]);
  7837. return XCameraComponent;
  7838. }();
  7839. var EMeshType = {
  7840. XAvatar: 'XAvatar',
  7841. XStaticMesh: 'XStaticMesh',
  7842. XBreathPoint: 'breathpoint',
  7843. Decal: 'decal',
  7844. Cgplane: 'cgplane',
  7845. Tv: 'tv',
  7846. XSubSequence: 'XSubSequence',
  7847. XBillboard: 'XBillboard'
  7848. };
  7849. var XStaticMesh = /*#__PURE__*/function () {
  7850. function XStaticMesh(_ref) {
  7851. var _this = this;
  7852. var e = _ref.id,
  7853. t = _ref.mesh,
  7854. _ref$group = _ref.group,
  7855. r = _ref$group === void 0 ? "default" : _ref$group,
  7856. _ref$lod = _ref.lod,
  7857. n = _ref$lod === void 0 ? 0 : _ref$lod,
  7858. _ref$xtype = _ref.xtype,
  7859. o = _ref$xtype === void 0 ? EMeshType.XStaticMesh : _ref$xtype,
  7860. _ref$skinInfo = _ref.skinInfo,
  7861. a = _ref$skinInfo === void 0 ? "default" : _ref$skinInfo,
  7862. _ref$url = _ref.url,
  7863. s = _ref$url === void 0 ? "" : _ref$url;
  7864. _classCallCheck(this, XStaticMesh);
  7865. E(this, "_mesh");
  7866. E(this, "_id", "-1");
  7867. E(this, "_group");
  7868. E(this, "_lod");
  7869. E(this, "_isMoving", !1);
  7870. E(this, "_isRotating", !1);
  7871. E(this, "_isVisible", !0);
  7872. E(this, "_skinInfo");
  7873. E(this, "setVisibility", function (e, t) {
  7874. Array.isArray(e) ? e.forEach(function (r) {
  7875. _this.setVisibility(r, t);
  7876. }) : e.isAnInstance || (e.visibility = t);
  7877. });
  7878. E(this, "setPickable", function (e, t) {
  7879. Array.isArray(e) ? e.forEach(function (r) {
  7880. _this.setPickable(r, t);
  7881. }) : ("isPickable" in e && (e.isPickable = t), e.setEnabled(t));
  7882. });
  7883. E(this, "hide", function () {
  7884. var e;
  7885. _this._isVisible = !1, _this.mesh && _this.setVisibility(_this.mesh, 0), _this.mesh && _this.setPickable(_this.mesh, !1), (e = _this.mesh) == null || e.getChildMeshes().forEach(function (t) {
  7886. _this.setVisibility(t, 0), _this.setPickable(t, !1);
  7887. });
  7888. });
  7889. E(this, "show", function () {
  7890. var e;
  7891. _this._isVisible = !0, _this.mesh && _this.setVisibility(_this.mesh, 1), _this.mesh && _this.setPickable(_this.mesh, !0), (e = _this.mesh) == null || e.getChildMeshes().forEach(function (t) {
  7892. _this.setVisibility(t, 1), _this.setPickable(t, !0);
  7893. });
  7894. });
  7895. E(this, "attachToAvatar", function (e) {
  7896. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
  7897. x: 0,
  7898. y: .5,
  7899. z: 0
  7900. };
  7901. var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
  7902. yaw: 0,
  7903. pitch: 0,
  7904. roll: 0
  7905. };
  7906. var n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {
  7907. x: .35,
  7908. y: .35,
  7909. z: .35
  7910. };
  7911. var o = ue4Scaling2Xverse(n),
  7912. a = ue4Rotation2Xverse(r),
  7913. s = ue4Position2Xverse(t),
  7914. l = _this._mesh;
  7915. e && l ? (e.setParent(l), e.position = s, e.rotation = a, e.scaling = o) : logger$1.error("[Engine] avatar or attachment not found!");
  7916. });
  7917. E(this, "detachFromAvatar", function (e) {
  7918. _this._mesh && e ? _this._mesh.removeChild(e) : logger$1.error("[Engine] avatar not found!");
  7919. });
  7920. this._id = e, this._mesh = t, this._group = r, this._lod = n, this._skinInfo = a, this.unallowMove(), this._mesh.xtype = o, this._mesh.xid = e, this._mesh.xgroup = this._group, this._mesh.xlod = this._lod, this._mesh.xskinInfo = this._skinInfo, this._mesh.xurl = s;
  7921. }
  7922. _createClass(XStaticMesh, [{
  7923. key: "mesh",
  7924. get: function get() {
  7925. return this._mesh;
  7926. }
  7927. }, {
  7928. key: "position",
  7929. get: function get() {
  7930. var o;
  7931. if (!this._mesh) return null;
  7932. var _ref2 = (o = this._mesh) == null ? void 0 : o.position,
  7933. e = _ref2.x,
  7934. t = _ref2.y,
  7935. r = _ref2.z;
  7936. return xversePosition2Ue4({
  7937. x: e,
  7938. y: t,
  7939. z: r
  7940. });
  7941. }
  7942. }, {
  7943. key: "id",
  7944. get: function get() {
  7945. return this._id;
  7946. }
  7947. }, {
  7948. key: "group",
  7949. get: function get() {
  7950. return this._group;
  7951. }
  7952. }, {
  7953. key: "isMoving",
  7954. get: function get() {
  7955. return this._isMoving;
  7956. }
  7957. }, {
  7958. key: "isVisible",
  7959. get: function get() {
  7960. return this._isVisible;
  7961. }
  7962. }, {
  7963. key: "isRotating",
  7964. get: function get() {
  7965. return this._isRotating;
  7966. }
  7967. }, {
  7968. key: "skinInfo",
  7969. get: function get() {
  7970. return this._skinInfo;
  7971. }
  7972. }, {
  7973. key: "allowMove",
  7974. value: function allowMove() {
  7975. this._mesh != null && (this._mesh.getChildMeshes().forEach(function (e) {
  7976. e.unfreezeWorldMatrix();
  7977. }), this._mesh.unfreezeWorldMatrix());
  7978. }
  7979. }, {
  7980. key: "unallowMove",
  7981. value: function unallowMove() {
  7982. this._mesh != null && (this._mesh.getChildMeshes().forEach(function (e) {
  7983. e.freezeWorldMatrix();
  7984. }), this._mesh.freezeWorldMatrix());
  7985. }
  7986. }, {
  7987. key: "getID",
  7988. value: function getID() {
  7989. return this._id;
  7990. }
  7991. }, {
  7992. key: "setPosition",
  7993. value: function setPosition(e) {
  7994. if (this._mesh) {
  7995. var t = ue4Position2Xverse(e);
  7996. this._mesh.position = t;
  7997. } else logger$1.error("[Engine] no root for positioning");
  7998. }
  7999. }, {
  8000. key: "setRotation",
  8001. value: function setRotation(e) {
  8002. var t = ue4Rotation2Xverse_mesh(e);
  8003. this._mesh ? this._mesh.rotation = t : logger$1.error("[Engine] no root for rotating");
  8004. }
  8005. }, {
  8006. key: "setScale",
  8007. value: function setScale(e) {
  8008. this._mesh ? this._mesh.scaling = new BABYLON.Vector3(e, e, -e) : logger$1.error("[Engine] no root for scaling");
  8009. }
  8010. }, {
  8011. key: "disableAvatar",
  8012. value: function disableAvatar() {
  8013. var e;
  8014. (e = this._mesh) == null || e.setEnabled(!1);
  8015. }
  8016. }, {
  8017. key: "enableAvatar",
  8018. value: function enableAvatar() {
  8019. var e;
  8020. (e = this._mesh) == null || e.setEnabled(!0);
  8021. }
  8022. }, {
  8023. key: "togglePickable",
  8024. value: function togglePickable(e) {
  8025. var t;
  8026. (t = this.mesh) == null || t.getChildMeshes().forEach(function (r) {
  8027. "instances" in r && "isPickable" in r && (r.isPickable = e);
  8028. }), this.mesh != null && "isPickable" in this.mesh && (this.mesh.isPickable = e);
  8029. }
  8030. }, {
  8031. key: "setMaterial",
  8032. value: function setMaterial(e) {
  8033. var t;
  8034. (t = this.mesh) == null || t.getChildMeshes().forEach(function (r) {
  8035. "instances" in r && "material" in r && (r.material = e);
  8036. }), this.mesh != null && "material" in this.mesh && (this.mesh.material = e);
  8037. }
  8038. }, {
  8039. key: "dispose",
  8040. value: function dispose() {
  8041. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : !1;
  8042. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !1;
  8043. !this.mesh.isDisposed() && this.mesh.dispose(e, t);
  8044. }
  8045. }]);
  8046. return XStaticMesh;
  8047. }();
  8048. function _createSuper$3(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$3(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  8049. function _isNativeReflectConstruct$3() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  8050. var XLowpolyModelError = /*#__PURE__*/function (_XverseError) {
  8051. _inherits(XLowpolyModelError, _XverseError);
  8052. var _super = _createSuper$3(XLowpolyModelError);
  8053. function XLowpolyModelError(e) {
  8054. _classCallCheck(this, XLowpolyModelError);
  8055. return _super.call(this, 5204, e || "[Engine] \u4F20\u5165\u6A21\u578Burl\u9519\u8BEF");
  8056. }
  8057. return _createClass(XLowpolyModelError);
  8058. }(XverseError);
  8059. var XStaticMeshFromOneGltf = /*#__PURE__*/function () {
  8060. function XStaticMeshFromOneGltf(e, t) {
  8061. var _this = this;
  8062. _classCallCheck(this, XStaticMeshFromOneGltf);
  8063. E(this, "_scene");
  8064. E(this, "_url");
  8065. E(this, "_group");
  8066. E(this, "_pickable");
  8067. E(this, "_meshes");
  8068. E(this, "_id");
  8069. E(this, "_lod");
  8070. E(this, "_groupUuid");
  8071. E(this, "_isInScene");
  8072. E(this, "_skinInfo");
  8073. E(this, "loadMesh", function (e, t) {
  8074. var r = _this._meshes.length,
  8075. n = t ? 1 : 0,
  8076. o = _this._url;
  8077. return BABYLON.SceneLoader.LoadAssetContainerAsync("", o, _this._scene, function () {
  8078. _this._scene.blockMaterialDirtyMechanism = !0;
  8079. }, ".glb").then(function (a) {
  8080. for (var s = a.materials.length - 1; s >= 0; --s) {
  8081. a.materials[s].dispose();
  8082. }
  8083. _this._scene.blockMaterialDirtyMechanism = !0;
  8084. for (var _s = 0; _s < a.meshes.length; ++_s) {
  8085. var l = a.meshes[_s];
  8086. if ("instances" in l) {
  8087. "visibility" in l && (l.visibility = 0), "isPickable" in l && (l.isPickable = _this._pickable), e != null && (l.material = e), "hasVertexAlpha" in l && (l.hasVertexAlpha = !1);
  8088. var u = new XStaticMesh({
  8089. id: _this._groupUuid + "-" + Math.random().toString(36).substr(2, 5),
  8090. mesh: l,
  8091. lod: _this._lod,
  8092. group: _this._group,
  8093. url: _this._url,
  8094. xtype: EMeshType.XStaticMesh,
  8095. skinInfo: _this._skinInfo
  8096. });
  8097. _this._meshes.push(u);
  8098. }
  8099. _this._scene.addMesh(l);
  8100. }
  8101. return !0;
  8102. }).then(function () {
  8103. _this._isInScene = !0;
  8104. for (var a = r; a < _this._meshes.length; ++a) {
  8105. _this._meshes[a].mesh.visibility = n;
  8106. }
  8107. return Promise.resolve(!0);
  8108. }).catch(function (a) {
  8109. logger$1.error("[Engine] input gltf mesh uri error! " + a), Promise.reject(new XLowpolyModelError("[Engine] input gltf mesh uri error! " + a));
  8110. });
  8111. });
  8112. this._meshes = [], this._scene = e, this._url = t.url, t.group != null ? this._group = t.group : this._group = "default", t.pick != null ? this._pickable = t.pick : this._pickable = !1, t.id != null ? this._id = t.id : this._id = "default", t.lod != null ? this._lod = t.lod : this._lod = -1, t.skinInfo != null ? this._skinInfo = t.skinInfo : this._skinInfo = "default", this._groupUuid = util.uuid(), this._isInScene = !1;
  8113. }
  8114. _createClass(XStaticMeshFromOneGltf, [{
  8115. key: "isinscene",
  8116. get: function get() {
  8117. return this._isInScene;
  8118. }
  8119. }, {
  8120. key: "groupUuid",
  8121. get: function get() {
  8122. return this._groupUuid;
  8123. }
  8124. }, {
  8125. key: "skinInfo",
  8126. get: function get() {
  8127. return this._skinInfo;
  8128. }
  8129. }, {
  8130. key: "group",
  8131. get: function get() {
  8132. return this._group;
  8133. }
  8134. }, {
  8135. key: "meshes",
  8136. get: function get() {
  8137. return this._meshes;
  8138. }
  8139. }, {
  8140. key: "url",
  8141. get: function get() {
  8142. return this._url;
  8143. }
  8144. }, {
  8145. key: "id",
  8146. get: function get() {
  8147. return this._id;
  8148. }
  8149. }, {
  8150. key: "lod",
  8151. get: function get() {
  8152. return this._lod;
  8153. }
  8154. }, {
  8155. key: "removeFromScene",
  8156. value: function removeFromScene() {
  8157. if (this._isInScene) {
  8158. this._isInScene = !1;
  8159. for (var e = 0, t = this._meshes.length; e < t; ++e) {
  8160. this._meshes[e].mesh != null && this._scene.removeMesh(this._meshes[e].mesh);
  8161. }
  8162. }
  8163. }
  8164. }, {
  8165. key: "addToScene",
  8166. value: function addToScene() {
  8167. if (this._isInScene == !1) {
  8168. this._isInScene = !0;
  8169. for (var e = 0, t = this._meshes.length; e < t; ++e) {
  8170. this._meshes[e].mesh != null && this._scene.addMesh(this._meshes[e].mesh);
  8171. }
  8172. }
  8173. }
  8174. }, {
  8175. key: "toggleVisibility",
  8176. value: function toggleVisibility(e) {
  8177. var t = e ? 1 : 0;
  8178. for (var r = 0, n = this._meshes.length; r < n; ++r) {
  8179. "visibility" in this._meshes[r].mesh && (this._meshes[r].mesh.visibility = t);
  8180. }
  8181. }
  8182. }, {
  8183. key: "togglePickable",
  8184. value: function togglePickable(e) {
  8185. for (var t = 0, r = this._meshes.length; t < r; ++t) {
  8186. "isPickable" in this._meshes[t].mesh && (this._meshes[t].mesh.isPickable = e);
  8187. }
  8188. }
  8189. }, {
  8190. key: "setMaterial",
  8191. value: function setMaterial(e) {
  8192. for (var t = 0, r = this._meshes.length; t < r; ++t) {
  8193. "material" in this._meshes[t].mesh && (this._meshes[t].mesh.material = e);
  8194. }
  8195. }
  8196. }, {
  8197. key: "dispose",
  8198. value: function dispose() {
  8199. for (var e = 0, t = this._meshes.length; e < t; ++e) {
  8200. this._meshes[e].mesh.dispose(!1, !1);
  8201. }
  8202. }
  8203. }]);
  8204. return XStaticMeshFromOneGltf;
  8205. }();
  8206. var XStaticMeshComponent = /*#__PURE__*/function () {
  8207. function XStaticMeshComponent(e) {
  8208. var _this = this;
  8209. _classCallCheck(this, XStaticMeshComponent);
  8210. E(this, "scene");
  8211. E(this, "_staticmeshes");
  8212. E(this, "_lowModel_group");
  8213. E(this, "_CgPlane");
  8214. E(this, "_rootDir");
  8215. E(this, "_abosoluteUrl");
  8216. E(this, "_partMeshSkinInfo");
  8217. E(this, "_meshInfoJson");
  8218. E(this, "_orijson");
  8219. E(this, "_notUsedRegionLists");
  8220. E(this, "_meshInfoKeys");
  8221. E(this, "_currentUpdateRegionCount");
  8222. E(this, "_currentMeshUsedLod");
  8223. E(this, "_currentPartGroup");
  8224. E(this, "_allowRegionUpdate");
  8225. E(this, "_allowRegionForceLod");
  8226. E(this, "_forceLod");
  8227. E(this, "_scenemanager");
  8228. E(this, "regionIdInCamera");
  8229. E(this, "regionIdInCameraConst");
  8230. E(this, "_cameraInRegionId");
  8231. E(this, "_meshVis");
  8232. E(this, "_doMeshVisChangeNumber");
  8233. E(this, "_meshVisTypeName");
  8234. E(this, "_visCheckDurationFrameNumber");
  8235. E(this, "_regionLodRule");
  8236. E(this, "reg_staticmesh_partupdate", function () {
  8237. if (_this._allowRegionUpdate && (_this.scene.getFrameId(), _this._meshUpdateFrame()), _this._allowRegionForceLod) {
  8238. _this.scene.getFrameId() % 2 == 0 && _this.setOneRegionLod(_this._meshInfoKeys[_this._currentUpdateRegionCount % _this._meshInfoKeys.length].toString(), _this._forceLod);
  8239. var t = !0;
  8240. var r = Array.from(_this._currentMeshUsedLod.keys());
  8241. if (r.length > 0) {
  8242. for (var n = 0; n < r.length; ++n) {
  8243. _this._currentMeshUsedLod.get(r[n]) != _this._forceLod && (t = !1);
  8244. }
  8245. t && (_this._allowRegionForceLod = !1);
  8246. }
  8247. }
  8248. });
  8249. E(this, "setMeshInfo", function (e) {
  8250. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
  8251. _this._abosoluteUrl != e && (_this._abosoluteUrl.length > 0 && _this.deleteLastRegionMesh(), _this._partMeshSkinInfo = t, _this._abosoluteUrl = e, _this._rootDir = _this._abosoluteUrl.slice(0, -4) + "/", _this.parseJson(_this._rootDir + "meshInfo.json").then(function () {
  8252. _this.startMeshUpdate();
  8253. }));
  8254. });
  8255. E(this, "_meshUpdateFrame", function () {
  8256. {
  8257. var _e = _this._meshInfoKeys[_this._currentUpdateRegionCount % _this._meshInfoKeys.length];
  8258. var t = !0;
  8259. var r = 3;
  8260. if (_this._scenemanager != null && _this._scenemanager.cameraComponent != null) {
  8261. var n = _this._getMainPlayerPosition();
  8262. if (n != null) {
  8263. if (_this._cameraInRegionId >= 0) {
  8264. var a = _this.getRegionIdWhichIncludeCamera(n);
  8265. (_this._cameraInRegionId != a || _this.regionIdInCamera.length == 0) && (_this._cameraInRegionId = a, _this.regionIdInCamera = _this._getNeighborId(_this._cameraInRegionId.toString()), _this.regionIdInCameraConst = _this.regionIdInCamera.slice());
  8266. var s = _this.regionIdInCamera.pop();
  8267. for (; s != null;) {
  8268. if (_this._notUsedRegionLists.indexOf(s) >= 0) s = _this.regionIdInCamera.pop();else break;
  8269. }
  8270. s != null && (_e = s.toString());
  8271. } else _this._cameraInRegionId = _this.getRegionIdWhichIncludeCamera(n);
  8272. if (_this._currentMeshUsedLod.size == 0 || _this._notUsedRegionLists.indexOf(parseInt(_e)) >= 0) {
  8273. _e = _this._cameraInRegionId.toString();
  8274. var _a = _this._getNeighborId(_e);
  8275. for (; _a.length == 0 && (_e = _this.getNearestRegionIdWithCamera(n).toString()), _this._notUsedRegionLists.indexOf(parseInt(_e)) >= 0;) {
  8276. _e = _a.pop().toString();
  8277. }
  8278. }
  8279. var o = _this._meshInfoJson[_this._cameraInRegionId.toString()].lod;
  8280. r = 3, _this._cameraInRegionId.toString() == _e ? r = _this._regionLodRule[0] : o[0].indexOf(parseInt(_e)) >= 0 ? r = _this._regionLodRule[1] : o[1].indexOf(parseInt(_e)) >= 0 ? r = _this._regionLodRule[2] : o[2].indexOf(parseInt(_e)) >= 0 ? r = _this._regionLodRule[3] : r = _this._regionLodRule[4];
  8281. }
  8282. }
  8283. _this.setOneRegionLod(_e, r, t), _this.updateRegionNotInLocalNeighbor(), _this.cleanRootNodes();
  8284. }
  8285. });
  8286. E(this, "updateRegionNotInLocalNeighbor", function () {
  8287. Array.from(_this._currentMeshUsedLod.keys()).forEach(function (t) {
  8288. _this.regionIdInCameraConst.indexOf(parseInt(t)) < 0 && _this.setOneRegionLod(t, -1);
  8289. });
  8290. });
  8291. E(this, "cleanRootNodes", function () {
  8292. if (_this.scene.getFrameId() % 3 == 0) {
  8293. var _e2 = [];
  8294. _this.scene.rootNodes.forEach(function (t) {
  8295. (t.getClassName() == "TransformNode" && t.getChildren().length == 0 || t.getClassName() == "Mesh" && t.name == "__root__" && t.getChildren().length == 0) && _e2.push(t);
  8296. }), _e2.forEach(function (t) {
  8297. t.dispose();
  8298. });
  8299. }
  8300. });
  8301. E(this, "setOneRegionLod", function (e, t) {
  8302. _this._currentUpdateRegionCount++;
  8303. var n = _this._calHashCode(_this._rootDir),
  8304. o = "region_" + n + "_" + e;
  8305. if (t < 0) {
  8306. _this._currentMeshUsedLod.has(e) && (_this._currentMeshUsedLod.delete(e), _this._currentPartGroup.delete(o), _this.deleteMeshesByCustomProperty("group", "region_" + n + "_" + e));
  8307. return;
  8308. }
  8309. var a = _this._rootDir + e + "_lod" + t + "_xverse.glb",
  8310. s = _this._currentMeshUsedLod.get(e);
  8311. _this._currentPartGroup.add(o), s != null ? s != t && (_this._currentMeshUsedLod.set(e, t), _this._scenemanager.addNewLowPolyMesh({
  8312. url: a,
  8313. group: "region_" + n + "_" + e,
  8314. pick: !0,
  8315. lod: t,
  8316. skinInfo: _this._partMeshSkinInfo
  8317. }, [{
  8318. group: "region_" + n + "_" + e,
  8319. mode: 0
  8320. }])) : (_this._currentMeshUsedLod.set(e, t), _this._scenemanager.addNewLowPolyMesh({
  8321. url: a,
  8322. group: "region_" + n + "_" + e,
  8323. pick: !0,
  8324. lod: t,
  8325. skinInfo: _this._partMeshSkinInfo
  8326. }));
  8327. });
  8328. E(this, "checkPointInView", function (_ref) {
  8329. var e = _ref.x,
  8330. t = _ref.y,
  8331. r = _ref.z;
  8332. var n = ue4Position2Xverse({
  8333. x: e,
  8334. y: t,
  8335. z: r
  8336. });
  8337. if (!n) return !1;
  8338. for (var o = 0; o < 6; o++) {
  8339. if (_this.scene.frustumPlanes[o].dotCoordinate(n) < 0) return !1;
  8340. }
  8341. return !0;
  8342. });
  8343. E(this, "addNewLowPolyMesh", function (e, t, r) {
  8344. if (!e.url.endsWith("glb") && !e.url.startsWith("blob:")) return e.url.endsWith("zip") ? (_this.setMeshInfo(e.url, e.skinInfo), Promise.resolve(!0)) : (logger$1.error("[Engine] input model path is error! ", e.url), Promise.reject(new XLowpolyModelError("[Engine] input model path is error! " + e.url)));
  8345. {
  8346. var n = e.url;
  8347. return new Promise(function (o, a) {
  8348. return _this._scenemanager.urlTransformer(e.url).then(function (s) {
  8349. e.url = s;
  8350. var l = new XStaticMeshFromOneGltf(_this.scene, e),
  8351. u = Date.now();
  8352. return new Promise(function (c, h) {
  8353. l.loadMesh(r, !0).then(function (f) {
  8354. var d = Date.now();
  8355. if (_this._scenemanager.engineRunTimeStats.timeArray_loadStaticMesh.add(d - u), f == !0) {
  8356. var _ = _this.getLowModelType(e);
  8357. var g = 0;
  8358. if (_this._lowModel_group.has(_) && (g = _this._lowModel_group.get(_).length), r != null && _this._scenemanager.currentShader != null && _this._scenemanager.currentShader.name != r.name && l.setMaterial(_this._scenemanager.currentShader), _this._allowRegionUpdate == !1 && _.startsWith("region_")) l.dispose();else if (_this._staticmeshes.push(l), _this.lowmodelGroupMapAddValue(_, l), t != null && t.length > 0) {
  8359. var m = [];
  8360. for (var v = 0; v < t.length; ++v) {
  8361. m.push(t[v].group), _this.updateLowModelGroup(t[v], _, g);
  8362. }
  8363. }
  8364. _this._scenemanager.engineRunTimeStats.timeArray_updateStaticMesh.add(Date.now() - d), c(!0);
  8365. } else h(new XLowpolyModelError("[Engine] after lowmodel error!"));
  8366. }).catch(function (f) {
  8367. logger$1.error("[Engine] load Mesh [" + n + "] error! " + f), h(new XLowpolyModelError("[Engine] load Mesh [".concat(n, "] error! ").concat(f)));
  8368. });
  8369. });
  8370. }).then(function (s) {
  8371. s == !0 ? (logger$1.info("[Engine] load Mesh [".concat(n, "] successfully.")), o(!0)) : a(!1);
  8372. }).catch(function (s) {
  8373. logger$1.error("[Engine] addNewLowPolyMesh [" + n + "] error! " + s), a(new XLowpolyModelError("[Engine] addNewLowPolyMesh [".concat(n, "] error! ").concat(s)));
  8374. });
  8375. });
  8376. }
  8377. });
  8378. E(this, "toggleLowModelVisibility", function (e) {
  8379. var t = e.vis,
  8380. _e$groupName = e.groupName,
  8381. r = _e$groupName === void 0 ? "" : _e$groupName,
  8382. _e$skinInfo = e.skinInfo,
  8383. n = _e$skinInfo === void 0 ? "" : _e$skinInfo;
  8384. _this._meshVis = t, _this._meshVisTypeName = {
  8385. groupName: r,
  8386. skinInfo: n
  8387. }, _this._doMeshVisChangeNumber = 0, r == Te.ALL_MESHES || _this._currentPartGroup.has(r) == !0 || _this._partMeshSkinInfo == n ? t == !1 ? (_this._visCheckDurationFrameNumber = 100, _this.stopMeshUpdate()) : (_this._visCheckDurationFrameNumber = 1, _this.startMeshUpdate()) : _this._visCheckDurationFrameNumber = 1;
  8388. });
  8389. E(this, "reg_staticmesh_visibility", function () {
  8390. if (_this._doMeshVisChangeNumber >= 0) if (_this._doMeshVisChangeNumber < _this._visCheckDurationFrameNumber) {
  8391. if (_this._doMeshVisChangeNumber = _this._doMeshVisChangeNumber + 1, _this._meshVisTypeName.groupName == Te.ALL_MESHES) _this._lowModel_group.forEach(function (e, t) {
  8392. for (var r = 0, n = e.length; r < n; ++r) {
  8393. e[r].toggleVisibility(_this._meshVis);
  8394. }
  8395. });else {
  8396. if (_this._lowModel_group.has(_this._meshVisTypeName.groupName)) for (var _e3 = 0; _e3 < _this._lowModel_group.get(_this._meshVisTypeName.groupName).length; ++_e3) {
  8397. _this._lowModel_group.get(_this._meshVisTypeName.groupName)[_e3].toggleVisibility(_this._meshVis);
  8398. }
  8399. if (_this._meshVisTypeName.skinInfo != "") for (var _e4 = 0; _e4 < _this._staticmeshes.length; ++_e4) {
  8400. _this._staticmeshes[_e4].skinInfo == _this._meshVisTypeName.skinInfo && _this._staticmeshes[_e4].toggleVisibility(_this._meshVis);
  8401. }
  8402. }
  8403. } else _this._meshVis = !0, _this._meshVisTypeName = {
  8404. groupName: "",
  8405. skinInfo: ""
  8406. }, _this._doMeshVisChangeNumber = -1;
  8407. });
  8408. E(this, "_getMeshesByCustomProperty", function (e, t) {
  8409. var r = [];
  8410. return _this._staticmeshes.forEach(function (n) {
  8411. n[e] != null && n[e] == t && (r = r.concat(n.meshes));
  8412. }), r;
  8413. });
  8414. this._lowModel_group = new Map(), this._staticmeshes = [], this._meshInfoJson = null, this._meshInfoKeys = [], this._currentUpdateRegionCount = 0, this._abosoluteUrl = "", this._partMeshSkinInfo = "", this._forceLod = 3, this._allowRegionUpdate = !1, this._allowRegionForceLod = !1, this._currentMeshUsedLod = new Map(), this._currentPartGroup = new Set(), this._scenemanager = e, this.scene = e.Scene, this.regionIdInCamera = [], this.regionIdInCameraConst = [], this._cameraInRegionId = -1, this._rootDir = "", this._meshVis = !0, this._meshVisTypeName = {
  8415. groupName: "",
  8416. skinInfo: ""
  8417. }, this._doMeshVisChangeNumber = -1, this._visCheckDurationFrameNumber = -1, this._regionLodRule = [0, 1, 3, 3, -1], this.initCgLowModel(), this._regionPartLoop();
  8418. }
  8419. _createClass(XStaticMeshComponent, [{
  8420. key: "cameraInRegionId",
  8421. get: function get() {
  8422. return this._cameraInRegionId;
  8423. }
  8424. }, {
  8425. key: "setRegionLodRule",
  8426. value: function setRegionLodRule(e) {
  8427. return e.length != 5 ? !1 : (e.forEach(function (t) {}), this._regionLodRule = e, !0);
  8428. }
  8429. }, {
  8430. key: "lowModel_group",
  8431. get: function get() {
  8432. return this._lowModel_group;
  8433. }
  8434. }, {
  8435. key: "_regionPartLoop",
  8436. value: function _regionPartLoop() {
  8437. this.scene.registerBeforeRender(this.reg_staticmesh_partupdate), this.scene.registerAfterRender(this.reg_staticmesh_visibility);
  8438. }
  8439. }, {
  8440. key: "_globalSearchCameraInWhichRegion",
  8441. value: function _globalSearchCameraInWhichRegion(e, t) {
  8442. var r = -1;
  8443. for (var n = 0; n < t.length; ++n) {
  8444. var o = this._meshInfoJson[t[n].toString()].boundingbox,
  8445. a = o[0],
  8446. s = o[1];
  8447. if (e.x >= a[0] && e.x <= s[0] && e.y >= a[1] && e.y <= s[1] && e.z >= a[2] && e.z <= s[2] || e.x >= s[0] && e.x <= a[0] && e.y >= s[1] && e.y <= a[1] && e.z >= s[2] && e.z <= a[2]) {
  8448. r = parseInt(t[n].toString());
  8449. break;
  8450. }
  8451. }
  8452. return r;
  8453. }
  8454. }, {
  8455. key: "getRegionIdByPosition",
  8456. value: function getRegionIdByPosition(e) {
  8457. return this.getRegionIdWhichIncludeCamera(e);
  8458. }
  8459. }, {
  8460. key: "getRegionIdWhichIncludeCamera",
  8461. value: function getRegionIdWhichIncludeCamera(e) {
  8462. var t = -1;
  8463. if (this._allowRegionUpdate == !1) return t;
  8464. if (this._cameraInRegionId == -1 ? t = this._globalSearchCameraInWhichRegion(e, this._meshInfoKeys) : (t = this._globalSearchCameraInWhichRegion(e, this.regionIdInCameraConst), t == -1 && (t = this._globalSearchCameraInWhichRegion(e, this._meshInfoKeys))), t == -1) {
  8465. var r = 1e7;
  8466. for (var n = 0; n < this._meshInfoKeys.length; ++n) {
  8467. var o = this._meshInfoJson[this._meshInfoKeys[n]].center,
  8468. a = Math.abs(e.x - o[0]) + Math.abs(e.y - o[1]);
  8469. r > a && (r = a, t = parseInt(this._meshInfoKeys[n]));
  8470. }
  8471. }
  8472. return t;
  8473. }
  8474. }, {
  8475. key: "getNearestRegionIdWithCamera",
  8476. value: function getNearestRegionIdWithCamera(e) {
  8477. var t = 1,
  8478. r = 1e7;
  8479. for (var n = 0; n < this._meshInfoKeys.length; ++n) {
  8480. if (this._notUsedRegionLists.indexOf(parseInt(this._meshInfoKeys[n])) >= 0) continue;
  8481. var o = this._meshInfoJson[this._meshInfoKeys[n]].center,
  8482. a = Math.abs(e.x - o[0]) + Math.abs(e.y - o[1]);
  8483. r > a && (r = a, t = parseInt(this._meshInfoKeys[n]));
  8484. }
  8485. return t;
  8486. }
  8487. }, {
  8488. key: "_getNeighborId",
  8489. value: function _getNeighborId(e) {
  8490. var t = this._meshInfoJson[e].lod;
  8491. var r = [];
  8492. var n = Object.keys(t);
  8493. for (var o = n.length - 1; o >= 0; --o) {
  8494. r = r.concat(t[n[o]]);
  8495. }
  8496. return r.push(parseInt(e)), r;
  8497. }
  8498. }, {
  8499. key: "_getMainPlayerPosition",
  8500. value: function _getMainPlayerPosition() {
  8501. var e = this._scenemanager.cameraComponent.getCameraPose().position,
  8502. t = this._scenemanager.avatarComponent.getMainAvatar();
  8503. if (t != null && t != null) {
  8504. var r = t.position;
  8505. if (r != null) return r;
  8506. }
  8507. return e;
  8508. }
  8509. }, {
  8510. key: "_calHashCode",
  8511. value: function _calHashCode(e) {
  8512. return hashCode(e) + "_" + this._partMeshSkinInfo;
  8513. }
  8514. }, {
  8515. key: "forceAllRegionLod",
  8516. value: function forceAllRegionLod() {
  8517. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 3;
  8518. e < 0 && (e = 0), e > 3 && (e = 3), this.stopMeshUpdate(), this._allowRegionForceLod = !0, this._forceLod = e;
  8519. }
  8520. }, {
  8521. key: "deleteLastRegionMesh",
  8522. value: function deleteLastRegionMesh() {
  8523. if (this._rootDir != "") {
  8524. var e = this._calHashCode(this._rootDir);
  8525. this._currentMeshUsedLod.clear(), this._currentPartGroup.clear(), this._meshInfoJson = null, this._meshInfoKeys = [], this._currentUpdateRegionCount = 0, this._orijson = null, this._notUsedRegionLists = [], this._partMeshSkinInfo = "", this._abosoluteUrl = "", this.stopMeshUpdate(), this.deleteMeshesByCustomProperty("group", "region_" + e, !0);
  8526. }
  8527. }
  8528. }, {
  8529. key: "startMeshUpdate",
  8530. value: function startMeshUpdate() {
  8531. this._allowRegionUpdate == !1 && this._meshInfoJson != null && this._abosoluteUrl != "" && this._meshInfoKeys.length > 0 && (this._allowRegionUpdate = !0);
  8532. }
  8533. }, {
  8534. key: "stopMeshUpdate",
  8535. value: function stopMeshUpdate() {
  8536. this._allowRegionUpdate = !1;
  8537. }
  8538. }, {
  8539. key: "parseJson",
  8540. value: function parseJson(e) {
  8541. var _this2 = this;
  8542. return new Promise(function (t, r) {
  8543. return _this2._scenemanager.urlTransformer(e).then(function (n) {
  8544. var o = new XMLHttpRequest();
  8545. o.open("get", n), o.send(null), o.onload = function () {
  8546. if (o.status == 200) {
  8547. var a = JSON.parse(o.responseText);
  8548. _this2._orijson = a, _this2._meshInfoJson = _this2._orijson.usedRegion, _this2._notUsedRegionLists = _this2._orijson.notUsedRegion, _this2._meshInfoKeys = Object.keys(_this2._meshInfoJson), logger$1.info("[Engine] parse zip mesh info successful"), t();
  8549. }
  8550. }, o.onerror = function () {
  8551. logger$1.error("[Engine] load zip mesh info json error, (provided by blob): ".concat(n)), r(new XLowpolyJsonError("[Engine] load zip mesh info json error, (provided by blob): ".concat(n)));
  8552. };
  8553. }).catch(function (n) {
  8554. logger$1.error("[Engine] load zip mesh info json error: ".concat(n, ", link:").concat(e)), r(new XLowpolyJsonError("[Engine] load zip mesh info json error: ".concat(n, ", link: ").concat(e)));
  8555. });
  8556. });
  8557. }
  8558. }, {
  8559. key: "initCgLowModel",
  8560. value: function initCgLowModel() {
  8561. var e = BABYLON.MeshBuilder.CreatePlane("CgPlane", {
  8562. size: 400
  8563. });
  8564. e.position = new BABYLON.Vector3(0, 1010, 0), e.rotation = new BABYLON.Vector3(3 * Math.PI / 2, 0, 0), this._CgPlane = new XStaticMesh({
  8565. id: "CgPlane",
  8566. mesh: e,
  8567. xtype: EMeshType.Cgplane
  8568. }), this._CgPlane.hide();
  8569. }
  8570. }, {
  8571. key: "getLowModelType",
  8572. value: function getLowModelType(e) {
  8573. var t = "";
  8574. return e.group != null ? t = e.group : t = "default", t;
  8575. }
  8576. }, {
  8577. key: "lowmodelGroupMapAddValue",
  8578. value: function lowmodelGroupMapAddValue(e, t) {
  8579. var r = this._lowModel_group.get(e);
  8580. r != null ? (r.push(t), this._lowModel_group.set(e, r)) : this._lowModel_group.set(e, [t]);
  8581. }
  8582. }, {
  8583. key: "updateLowModelGroup",
  8584. value: function updateLowModelGroup(e, t, r) {
  8585. var n = r;
  8586. e.group == t || (n = -1), e.mode == 0 ? this.deleteLowModelGroup(e.group, n) : e.mode == 1 ? this.toggleVisibleLowModelGroup(!1, e.group, n) : e.mode == 2 && this.toggleVisibleLowModelGroup(!0, e.group, n);
  8587. }
  8588. }, {
  8589. key: "toggleVisibleLowModelGroup",
  8590. value: function toggleVisibleLowModelGroup(e, t) {
  8591. var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : -1;
  8592. if (this._lowModel_group.has(t)) {
  8593. var n = this._lowModel_group.get(t);
  8594. var o = n.length;
  8595. r >= 0 && o >= r && (o = r);
  8596. for (var a = 0; a < o; ++a) {
  8597. n[a].toggleVisibility(e);
  8598. }
  8599. }
  8600. }
  8601. }, {
  8602. key: "deleteLowModelGroup",
  8603. value: function deleteLowModelGroup(e) {
  8604. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -1;
  8605. if (this._lowModel_group.has(e)) {
  8606. var o = this._lowModel_group.get(e);
  8607. var a = o.length;
  8608. t >= 0 && a >= t && (a = t);
  8609. for (var s = 0; s < a; ++s) {
  8610. o[s].dispose();
  8611. }
  8612. t >= 0 ? this._lowModel_group.set(e, this._lowModel_group.get(e).slice(a)) : this._lowModel_group.delete(e);
  8613. }
  8614. var r = this._lowModel_group.get(e),
  8615. n = [];
  8616. r != null && r.length > 0 ? this._staticmeshes.forEach(function (o) {
  8617. if (o.group != e) n.push(o);else for (var _a2 = 0; _a2 < r.length; ++_a2) {
  8618. o.groupUuid == r[_a2].groupUuid && n.push(o);
  8619. }
  8620. }) : this._staticmeshes.forEach(function (o) {
  8621. o.group != e && n.push(o);
  8622. }), this._staticmeshes = n;
  8623. }
  8624. }, {
  8625. key: "deleteMeshesByGroup",
  8626. value: function deleteMeshesByGroup(e) {
  8627. this.deleteLowModelGroup(e);
  8628. }
  8629. }, {
  8630. key: "deleteMeshesById",
  8631. value: function deleteMeshesById(e) {
  8632. this.deleteMeshesByCustomProperty("id", e);
  8633. }
  8634. }, {
  8635. key: "deleteMeshesByLoD",
  8636. value: function deleteMeshesByLoD(e) {
  8637. this.deleteMeshesByCustomProperty("lod", e);
  8638. }
  8639. }, {
  8640. key: "deleteMeshesBySkinInfo",
  8641. value: function deleteMeshesBySkinInfo(e) {
  8642. this.deleteMeshesByCustomProperty("skinInfo", e);
  8643. }
  8644. }, {
  8645. key: "removeMeshesFromSceneByGroup",
  8646. value: function removeMeshesFromSceneByGroup(e) {
  8647. this.removeMeshesFromSceneByCustomProperty("group", e);
  8648. }
  8649. }, {
  8650. key: "removeMeshesFromSceneById",
  8651. value: function removeMeshesFromSceneById(e) {
  8652. this.removeMeshesFromSceneByCustomProperty("id", e);
  8653. }
  8654. }, {
  8655. key: "addMeshesToSceneByGroup",
  8656. value: function addMeshesToSceneByGroup(e) {
  8657. this.addMeshesToSceneByCustomProperty("group", e);
  8658. }
  8659. }, {
  8660. key: "addMeshesToSceneById",
  8661. value: function addMeshesToSceneById(e) {
  8662. this.addMeshesToSceneByCustomProperty("id", e);
  8663. }
  8664. }, {
  8665. key: "removeMeshesFromSceneByCustomProperty",
  8666. value: function removeMeshesFromSceneByCustomProperty(e, t) {
  8667. var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : !1;
  8668. this._staticmeshes.forEach(function (n) {
  8669. n.isinscene && n[e] != null && (r ? n[e].indexOf(t) < 0 || n.removeFromScene() : n[e] != t || n.removeFromScene());
  8670. });
  8671. }
  8672. }, {
  8673. key: "addMeshesToSceneByCustomProperty",
  8674. value: function addMeshesToSceneByCustomProperty(e, t) {
  8675. var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : !1;
  8676. this._staticmeshes.forEach(function (n) {
  8677. n.isinscene == !1 && n[e] != null && (r ? n[e].indexOf(t) < 0 || n.addToScene() : n[e] != t || n.addToScene());
  8678. });
  8679. }
  8680. }, {
  8681. key: "deleteMeshesByCustomProperty",
  8682. value: function deleteMeshesByCustomProperty(e, t) {
  8683. var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : !1;
  8684. var n = [];
  8685. this._staticmeshes.forEach(function (a) {
  8686. a[e] != null && (r ? a[e].indexOf(t) < 0 ? n.push(a) : a.dispose() : a[e] != t ? n.push(a) : a.dispose());
  8687. }), this._staticmeshes = n;
  8688. var o = Array.from(this._lowModel_group.keys());
  8689. for (var a = 0; a < o.length; ++a) {
  8690. var s = o[a],
  8691. l = this._lowModel_group.get(s);
  8692. if (l != null) {
  8693. var u = [];
  8694. for (var c = 0; c < l.length; ++c) {
  8695. l[c][e] != null && (r ? l[c][e].indexOf(t) < 0 && u.push(l[c]) : l[c][e] != t && u.push(l[c]));
  8696. }
  8697. u.length > 0 ? this._lowModel_group.set(s, u) : this._lowModel_group.delete(s);
  8698. }
  8699. }
  8700. }
  8701. }, {
  8702. key: "getMeshes",
  8703. value: function getMeshes() {
  8704. var e = [];
  8705. for (var t = 0; t < this._staticmeshes.length; ++t) {
  8706. e = e.concat(this._staticmeshes[t].meshes);
  8707. }
  8708. return e;
  8709. }
  8710. }, {
  8711. key: "getCgMesh",
  8712. value: function getCgMesh() {
  8713. return this._CgPlane;
  8714. }
  8715. }, {
  8716. key: "getMeshesByGroup",
  8717. value: function getMeshesByGroup() {
  8718. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "default";
  8719. var t = this._lowModel_group.get(e);
  8720. if (t != null) {
  8721. var r = [];
  8722. for (var n = 0; n < t.length; ++n) {
  8723. r = r.concat(t[n].meshes);
  8724. }
  8725. return r;
  8726. } else return null;
  8727. }
  8728. }, {
  8729. key: "getMeshesByGroup2",
  8730. value: function getMeshesByGroup2() {
  8731. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "default";
  8732. return this._getMeshesByCustomProperty("group", e);
  8733. }
  8734. }]);
  8735. return XStaticMeshComponent;
  8736. }();
  8737. var XVideoRawYUV = /*#__PURE__*/function () {
  8738. function XVideoRawYUV(e, t) {
  8739. var _this = this;
  8740. _classCallCheck(this, XVideoRawYUV);
  8741. E(this, "scene");
  8742. E(this, "_videoRawYUVTexture");
  8743. E(this, "videosResOriArray");
  8744. E(this, "_currentVideoId");
  8745. this.scene = e, this._videoRawYUVTexture = [], this.videosResOriArray = t, this._currentVideoId = -1;
  8746. for (var r = 0; r < t.length; ++r) {
  8747. (function (n) {
  8748. var o = BABYLON.RawTexture.CreateLuminanceTexture(null, t[n].width, t[n].height * 1.5, _this.scene, !1, !0);
  8749. o.name = "videoTex_" + t[n].width + "_" + t[n].height, _this._videoRawYUVTexture.push(o);
  8750. })(r);
  8751. }
  8752. }
  8753. _createClass(XVideoRawYUV, [{
  8754. key: "inRange",
  8755. value: function inRange(e) {
  8756. return e >= 0 && e < this._videoRawYUVTexture.length;
  8757. }
  8758. }, {
  8759. key: "getVideoYUVTex",
  8760. value: function getVideoYUVTex(e) {
  8761. return this.inRange(e) ? this._videoRawYUVTexture[e] : null;
  8762. }
  8763. }, {
  8764. key: "findId",
  8765. value: function findId(e, t) {
  8766. var r = 0;
  8767. for (var n = 0; n < this.videosResOriArray.length; ++n) {
  8768. if (this.videosResOriArray[n].width == e && this.videosResOriArray[n].height == t) {
  8769. r = n;
  8770. break;
  8771. }
  8772. }
  8773. return r;
  8774. }
  8775. }, {
  8776. key: "getCurrentVideoTexId",
  8777. value: function getCurrentVideoTexId() {
  8778. return this._currentVideoId;
  8779. }
  8780. }, {
  8781. key: "setCurrentVideoTexId",
  8782. value: function setCurrentVideoTexId(e) {
  8783. this._currentVideoId = e;
  8784. }
  8785. }]);
  8786. return XVideoRawYUV;
  8787. }();
  8788. var XMaterialComponent = /*#__PURE__*/function () {
  8789. function XMaterialComponent(e, t) {
  8790. var _this = this;
  8791. _classCallCheck(this, XMaterialComponent);
  8792. E(this, "scene");
  8793. E(this, "engine");
  8794. E(this, "yuvInfo");
  8795. E(this, "shaderMode");
  8796. E(this, "_panoInfo");
  8797. E(this, "_dynamic_size");
  8798. E(this, "_dynamic_babylonpose");
  8799. E(this, "_dynamic_textures");
  8800. E(this, "_dynamic_shaders");
  8801. E(this, "_scenemanager");
  8802. E(this, "_videoTexture");
  8803. E(this, "_videoElement");
  8804. E(this, "_lowModelShader");
  8805. E(this, "_defaultShader");
  8806. E(this, "_inputYUV420", !0);
  8807. E(this, "_inputPanoYUV420", !0);
  8808. E(this, "_videoRawYUVTexArray");
  8809. E(this, "_isUpdateYUV", !0);
  8810. E(this, "initMaterial", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
  8811. return regenerator.wrap(function _callee$(_context) {
  8812. while (1) {
  8813. switch (_context.prev = _context.next) {
  8814. case 0:
  8815. return _context.abrupt("return", new Promise(function (e, t) {
  8816. _this._initDefaultShader(), _this.shaderMode == 2 ? _this.initDynamicData(_this._panoInfo.dynamicRange, _this._panoInfo.width, _this._panoInfo.height).then(function () {
  8817. _this._initPureVideoShader(), _this._prepareRender(_this.yuvInfo);
  8818. }) : _this.shaderMode == 1 ? (_this._initPureVideoShader(), _this._prepareRender(_this.yuvInfo)) : _this.shaderMode == 0, e(!0);
  8819. }));
  8820. case 1:
  8821. case "end":
  8822. return _context.stop();
  8823. }
  8824. }
  8825. }, _callee);
  8826. })));
  8827. E(this, "_initPureVideoContent", function (e) {
  8828. _this._inputYUV420 ? _this._videoRawYUVTexArray.getVideoYUVTex(0) != null && (_this._lowModelShader.setTexture("texture_video", _this._videoRawYUVTexArray.getVideoYUVTex(0)), _this._lowModelShader.setFloat("isYUV", 1), BABYLON.Texture.WhenAllReady([_this._videoRawYUVTexArray.getVideoYUVTex(0)], function () {
  8829. _this._changePureVideoLowModelShaderCanvasSize(e);
  8830. })) : (_this._videoElement = e.videoElement, _this._videoTexture || (_this._videoTexture = new VideoTexture("InterVideoTexture", _this._videoElement, _this.scene, !0, !1)), BABYLON.Texture.WhenAllReady([_this._videoTexture], function () {
  8831. _this._changePureVideoLowModelShaderCanvasSize({
  8832. width: _this._videoElement.height,
  8833. height: _this._videoElement.width,
  8834. fov: e.fov
  8835. });
  8836. }), _this._lowModelShader.setTexture("texture_video", _this._videoTexture), _this._lowModelShader.setFloat("isYUV", 0));
  8837. });
  8838. E(this, "_changePureVideoLowModelShaderCanvasSize", function (e) {
  8839. var a;
  8840. var t = e.fov || 50,
  8841. r = e.width || 720,
  8842. n = e.height || 1280,
  8843. o = r / (2 * Math.tan(Math.PI * t / 360));
  8844. (a = _this._lowModelShader) == null || a.setVector3("focal_width_height", new BABYLON.Vector3(o, r, n));
  8845. });
  8846. E(this, "updateRawYUVData", function (e, t, r) {
  8847. var n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : -1;
  8848. var o, a;
  8849. if (n == -1 && (n = _this.yuvInfo.fov), _this._isUpdateYUV == !0) {
  8850. var s = {
  8851. width: t,
  8852. height: r,
  8853. fov: n
  8854. },
  8855. l = _this._videoRawYUVTexArray.findId(t, r),
  8856. u = _this._videoRawYUVTexArray.getCurrentVideoTexId();
  8857. (u < 0 || l != u || n != _this.yuvInfo.fov) && (_this.yuvInfo.width = t, _this.yuvInfo.height = r, _this.yuvInfo.fov = n, _this._videoRawYUVTexArray.setCurrentVideoTexId(l), _this._changeVideoRes(l), _this._changePureVideoLowModelShaderCanvasSize(s), _this._scenemanager.cameraComponent.cameraFovChange(s), _this._scenemanager.yuvInfo = s), (o = _this._videoRawYUVTexArray.getVideoYUVTex(l)) == null || o.update(e), (a = _this._videoRawYUVTexArray.getVideoYUVTex(l)) == null || a.updateSamplingMode(BABYLON.Texture.BILINEAR_SAMPLINGMODE);
  8858. }
  8859. });
  8860. E(this, "_changeVideoRes", function (e) {
  8861. _this._lowModelShader.setTexture("texture_video", _this._videoRawYUVTexArray.getVideoYUVTex(e));
  8862. });
  8863. E(this, "initDynamicData", function (e, t, r) {
  8864. return new Promise(function (n, o) {
  8865. _this.setDynamicSize(e).then(function (a) {
  8866. if (a) {
  8867. for (var s = 0; s < e; ++s) {
  8868. (function (l) {
  8869. _this.initDynamicTexture(l, t, r), _this.initDynamicShaders(l).then(function () {
  8870. _this._updatePanoShaderInput(l);
  8871. });
  8872. })(s);
  8873. }
  8874. n(!0);
  8875. } else o(new XMaterialError("[Engine] DynamicRoomSize (".concat(e, ") is too small")));
  8876. });
  8877. }).catch(function (n) {
  8878. return logger$1.error("[Engine] ".concat(n));
  8879. });
  8880. });
  8881. E(this, "_initDefaultShader", function () {
  8882. _this._defaultShader == null && (_this._defaultShader = new BABYLON.GridMaterial("GridShader", _this.scene), _this._defaultShader.gridRatio = 50, _this._defaultShader.lineColor = new BABYLON.Color3(0, 0, .5), _this._defaultShader.majorUnitFrequency = 1, _this._defaultShader.mainColor = new BABYLON.Color3(.6, .6, .6), _this._defaultShader.backFaceCulling = !1);
  8883. });
  8884. E(this, "_initPureVideoShader", function () {
  8885. if (_this._lowModelShader == null) {
  8886. var _e = new BABYLON.ShaderMaterial("PureVideoShader", _this.scene, {
  8887. vertexSource: pureVideoVertex,
  8888. fragmentSource: pureVideoFragment
  8889. }, {
  8890. attributes: ["uv", "position", "world0", "world1", "world2", "world3"],
  8891. uniforms: ["view", "projection", "worldViewProjection", "world"],
  8892. defines: ["#define SHADOWFULLFLOAT"]
  8893. });
  8894. _e.setTexture("shadowSampler", null), _e.setMatrix("lightSpaceMatrix", null), _e.setFloat("haveShadowLight", 0), _e.setTexture("texture_video", null), _e.setFloat("isYUV", _this._inputYUV420 ? 1 : 0), _e.setFloat("fireworkLight", 0), _e.setVector3("fireworkLightPosition", new BABYLON.Vector3(0, 0, 0)), _e.setVector3("focal_width_height", new BABYLON.Vector3(772.022491, 720, 1280)), _e.backFaceCulling = !1, _this._lowModelShader = _e;
  8895. }
  8896. });
  8897. E(this, "setDynamicSize", function (e) {
  8898. return new Promise(function (t, r) {
  8899. e >= 1 && e <= 100 ? (_this._dynamic_size = e, t(!0)) : (_this._dynamic_size = 1, t(!1));
  8900. });
  8901. });
  8902. E(this, "_isInDynamicRange", function (e) {
  8903. return e < _this._dynamic_size && e >= 0;
  8904. });
  8905. E(this, "initDynamicTexture", function (e, t, r) {
  8906. _this._isInDynamicRange(e) && (_this._dynamic_textures[e] != null && (_this._dynamic_textures[e].dispose(), _this._dynamic_textures[e] = null), _this._dynamic_textures[e] = new BABYLON.RawTexture(null, t, r * 1.5, BABYLON.Engine.TEXTUREFORMAT_LUMINANCE, _this.scene, !1, !0, BABYLON.Texture.NEAREST_SAMPLINGMODE, BABYLON.Engine.TEXTURETYPE_UNSIGNED_BYTE), _this._dynamic_textures[e].name = "Pano_Dynamic_" + e + "_" + Date.now());
  8907. });
  8908. E(this, "initDynamicShaders", function (e) {
  8909. return logger$1.info("[Engine] Material init dynamic shader."), new Promise(function (t, r) {
  8910. _this._dynamic_shaders[e] != null && _this._dynamic_shaders[e].dispose();
  8911. var n = new BABYLON.ShaderMaterial("Pano_Shader_" + e, _this.scene, {
  8912. vertexSource: panoVertex,
  8913. fragmentSource: panoFragment
  8914. }, {
  8915. attributes: ["uv", "position", "world0", "world1", "world2", "world3"],
  8916. uniforms: ["view", "projection", "worldViewProjection", "world"],
  8917. defines: ["#define SHADOWFULLFLOAT"]
  8918. });
  8919. n.setTexture("texture_pano", null), n.setVector3("centre_pose", new BABYLON.Vector3(0, 0, 0)), n.setFloat("isYUV", _this._inputPanoYUV420 ? 1 : 0), n.setTexture("shadowSampler", null), n.setMatrix("lightSpaceMatrix", null), n.setFloat("haveShadowLight", 0), n.setFloat("fireworkLight", 0), n.setVector3("fireworkLightPosition", new BABYLON.Vector3(0, 0, 0)), n.backFaceCulling = !1, _this._dynamic_shaders[e] = n, t(!0);
  8920. });
  8921. });
  8922. this._scenemanager = e, this.scene = e.Scene, this.engine = this.scene.getEngine(), this.shaderMode = 1, this._dynamic_textures = [], this._dynamic_shaders = [], this._dynamic_babylonpose = [], this._videoRawYUVTexArray = new XVideoRawYUV(this.scene, t.videoResOriArray), this.shaderMode = t.shaderMode, t.yuvInfo != null && (this.yuvInfo = t.yuvInfo), t.panoInfo != null && this.setPanoInfo(t.panoInfo);
  8923. }
  8924. _createClass(XMaterialComponent, [{
  8925. key: "stopYUVUpdate",
  8926. value: function stopYUVUpdate() {
  8927. this._isUpdateYUV = !1;
  8928. }
  8929. }, {
  8930. key: "allowYUVUpdate",
  8931. value: function allowYUVUpdate() {
  8932. this._isUpdateYUV = !0;
  8933. }
  8934. }, {
  8935. key: "setPanoInfo",
  8936. value: function setPanoInfo(e) {
  8937. this._panoInfo = e;
  8938. }
  8939. }, {
  8940. key: "_prepareRender",
  8941. value: function _prepareRender(e) {
  8942. e && (this._initPureVideoContent(e), this._updatePureVideoShaderInput());
  8943. }
  8944. }, {
  8945. key: "getPureVideoShader",
  8946. value: function getPureVideoShader() {
  8947. return this._lowModelShader;
  8948. }
  8949. }, {
  8950. key: "getDefaultShader",
  8951. value: function getDefaultShader() {
  8952. return this._defaultShader;
  8953. }
  8954. }, {
  8955. key: "updatePanoPartYUV",
  8956. value: function updatePanoPartYUV(e, t, r) {
  8957. var n = t.subarray(0, r.width * r.height),
  8958. o = t.subarray(r.width * r.height, r.width * r.height * 1.25),
  8959. a = t.subarray(r.width * r.height * 1.25),
  8960. s = this._panoInfo.width,
  8961. l = this._panoInfo.height;
  8962. if (this._dynamic_textures[e] != null) {
  8963. var u = this._dynamic_textures[e].getInternalTexture();
  8964. if (u != null && u != null) {
  8965. var c = this.engine._getTextureTarget(u);
  8966. this.engine._bindTextureDirectly(c, u, !0), this.engine.updateTextureData(u, n, r.startX, l * 1.5 - r.startY - r.height, r.width, r.height), this.engine.updateTextureData(u, o, r.startX * .5, (l - r.startY - r.height) * .5, r.width * .5 - 1, r.height * .5 - 1), this.engine.updateTextureData(u, a, r.startX * .5 + s * .5, (l - r.startY - r.height) * .5, r.width * .5, r.height * .5), this.engine._bindTextureDirectly(c, null);
  8967. }
  8968. }
  8969. }
  8970. }, {
  8971. key: "changePanoImg",
  8972. value: function changePanoImg(e, t) {
  8973. var _this2 = this;
  8974. if (logger$1.info("[Engine] changePanoImg, id=".concat(e, ", pose=").concat(t.pose.position.x, ",").concat(t.pose.position.y, ",").concat(t.pose.position.z)), !this._isInDynamicRange(e)) return logger$1.error("[Engine] ".concat(e, " is bigger than dynamic size set in PanoInfo")), Promise.reject(new XMaterialError("[Engine] ".concat(e, " is bigger than dynamic size set in PanoInfo")));
  8975. var r = ue4Position2Xverse(t.pose.position);
  8976. return r && (this._dynamic_babylonpose[e] = {
  8977. position: r
  8978. }), new Promise(function (n, o) {
  8979. try {
  8980. typeof t.data == "string" ? (_this2.setPanoYUV420(!1), _this2._dynamic_textures[e].updateURL(t.data, null, function () {
  8981. _this2._dynamic_textures[e].updateSamplingMode(BABYLON.Texture.NEAREST_SAMPLINGMODE);
  8982. })) : (_this2.isPanoYUV420() == !1 && _this2.initDynamicTexture(e, _this2._panoInfo.width, _this2._panoInfo.height), _this2.setPanoYUV420(!0), _this2._dynamic_textures[e].update(t.data), _this2._dynamic_textures[e].updateSamplingMode(BABYLON.Texture.NEAREST_SAMPLINGMODE)), n(_this2);
  8983. } catch (a) {
  8984. o(new XMaterialError("[Engine] ChangePanoImg Error! ".concat(a)));
  8985. }
  8986. }).then(function (n) {
  8987. return t.fov != null && _this2._scenemanager.cameraComponent.changeCameraFov(t.fov * Math.PI / 180), _this2._dynamic_shaders[e].setFloat("isYUV", _this2._inputPanoYUV420 ? 1 : 0), _this2._dynamic_shaders[e].setTexture("texture_pano", _this2._dynamic_textures[e]), _this2._dynamic_shaders[e].setVector3("centre_pose", _this2._dynamic_babylonpose[e].position), !0;
  8988. });
  8989. }
  8990. }, {
  8991. key: "setYUV420",
  8992. value: function setYUV420(e) {
  8993. this._inputYUV420 = e;
  8994. }
  8995. }, {
  8996. key: "isYUV420",
  8997. value: function isYUV420() {
  8998. return this._inputYUV420;
  8999. }
  9000. }, {
  9001. key: "setPanoYUV420",
  9002. value: function setPanoYUV420(e) {
  9003. this._inputPanoYUV420 = e;
  9004. }
  9005. }, {
  9006. key: "isPanoYUV420",
  9007. value: function isPanoYUV420() {
  9008. return this._inputPanoYUV420;
  9009. }
  9010. }, {
  9011. key: "getDynamicShader",
  9012. value: function getDynamicShader(e) {
  9013. return this._dynamic_shaders[e];
  9014. }
  9015. }, {
  9016. key: "_updatePureVideoShaderInput",
  9017. value: function _updatePureVideoShaderInput() {
  9018. var _this3 = this;
  9019. var e, t, r, n, o, a, s, l, u, c;
  9020. if (this.scene.getLightByName("AvatarLight") ? ((e = this._lowModelShader) == null || e.setFloat("haveShadowLight", 1), (n = this._lowModelShader) == null || n.setTexture("shadowSampler", (r = (t = this.scene.getLightByName("AvatarLight")) == null ? void 0 : t.getShadowGenerator()) == null ? void 0 : r.getShadowMapForRendering()), (s = this._lowModelShader) == null || s.setMatrix("lightSpaceMatrix", (a = (o = this.scene.getLightByName("AvatarLight")) == null ? void 0 : o.getShadowGenerator()) == null ? void 0 : a.getTransformMatrix())) : ((l = this._lowModelShader) == null || l.setTexture("shadowSampler", this._videoTexture), (u = this._lowModelShader) == null || u.setMatrix("lightSpaceMatrix", new Matrix()), (c = this._lowModelShader) == null || c.setFloat("haveShadowLight", 0)), this.scene.getLightByName("fireworkLight")) this.scene.registerBeforeRender(function () {
  9021. var h;
  9022. _this3._lowModelShader.setFloat("fireworkLight", _this3.scene.getLightByName("fireworkLight").getScaledIntensity()), _this3._lowModelShader.setVector3("fireworkLightPosition", (h = _this3.scene.getLightByName("fireworkLight")) == null ? void 0 : h.position);
  9023. });else {
  9024. var h = new BABYLON.PointLight("fireworkLight", new BABYLON.Vector3(0, 0, 0), this.scene);
  9025. h.intensity = 0;
  9026. }
  9027. }
  9028. }, {
  9029. key: "_updatePanoShaderInput",
  9030. value: function _updatePanoShaderInput(e) {
  9031. var _this4 = this;
  9032. var t, r, n, o, a, s, l, u, c, h;
  9033. if (this._isInDynamicRange(e)) if (this.scene.getLightByName("AvatarLight") ? ((t = this._dynamic_shaders[e]) == null || t.setFloat("haveShadowLight", 1), (o = this._dynamic_shaders[e]) == null || o.setTexture("shadowSampler", (n = (r = this.scene.getLightByName("AvatarLight")) == null ? void 0 : r.getShadowGenerator()) == null ? void 0 : n.getShadowMapForRendering()), (l = this._dynamic_shaders[e]) == null || l.setMatrix("lightSpaceMatrix", (s = (a = this.scene.getLightByName("AvatarLight")) == null ? void 0 : a.getShadowGenerator()) == null ? void 0 : s.getTransformMatrix())) : ((u = this._dynamic_shaders[e]) == null || u.setTexture("shadowSampler", null), (c = this._dynamic_shaders[e]) == null || c.setMatrix("lightSpaceMatrix", new Matrix()), (h = this._dynamic_shaders[e]) == null || h.setFloat("haveShadowLight", 0)), this.scene.getLightByName("fireworkLight")) this.scene.registerBeforeRender(function () {
  9034. var f;
  9035. _this4._dynamic_shaders[e].setFloat("fireworkLight", _this4.scene.getLightByName("fireworkLight").getScaledIntensity()), _this4._dynamic_shaders[e].setVector3("fireworkLightPosition", (f = _this4.scene.getLightByName("fireworkLight")) == null ? void 0 : f.position);
  9036. });else {
  9037. var f = new BABYLON.PointLight("fireworkLight", new BABYLON.Vector3(0, 0, 0), this.scene);
  9038. f.intensity = 0;
  9039. }
  9040. }
  9041. }]);
  9042. return XMaterialComponent;
  9043. }();
  9044. var XStats = /*#__PURE__*/function () {
  9045. function XStats(e) {
  9046. _classCallCheck(this, XStats);
  9047. E(this, "scene");
  9048. E(this, "sceneInstrumentation");
  9049. E(this, "engineInstrumentation");
  9050. E(this, "caps");
  9051. E(this, "engine");
  9052. E(this, "_canvas");
  9053. E(this, "_osversion");
  9054. E(this, "_scenemanager");
  9055. this._scenemanager = e, this.scene = e.Scene, this._canvas = e.canvas, this.initSceneInstrument();
  9056. }
  9057. _createClass(XStats, [{
  9058. key: "initSceneInstrument",
  9059. value: function initSceneInstrument() {
  9060. this.sceneInstrumentation = new BABYLON.SceneInstrumentation(this.scene), this.sceneInstrumentation.captureCameraRenderTime = !0, this.sceneInstrumentation.captureActiveMeshesEvaluationTime = !0, this.sceneInstrumentation.captureRenderTargetsRenderTime = !0, this.sceneInstrumentation.captureFrameTime = !0, this.sceneInstrumentation.captureRenderTime = !0, this.sceneInstrumentation.captureInterFrameTime = !0, this.sceneInstrumentation.captureParticlesRenderTime = !0, this.sceneInstrumentation.captureSpritesRenderTime = !0, this.sceneInstrumentation.capturePhysicsTime = !0, this.sceneInstrumentation.captureAnimationsTime = !0, this.engineInstrumentation = new BABYLON.EngineInstrumentation(this.scene.getEngine()), this.caps = this.scene.getEngine().getCaps(), this.engine = this.scene.getEngine(), this._osversion = this.osVersion();
  9061. }
  9062. }, {
  9063. key: "getFrameTimeCounter",
  9064. value: function getFrameTimeCounter() {
  9065. return this.sceneInstrumentation.frameTimeCounter.current;
  9066. }
  9067. }, {
  9068. key: "getInterFrameTimeCounter",
  9069. value: function getInterFrameTimeCounter() {
  9070. return this.sceneInstrumentation.interFrameTimeCounter.current;
  9071. }
  9072. }, {
  9073. key: "getActiveMeshEvaluationTime",
  9074. value: function getActiveMeshEvaluationTime() {
  9075. return this.sceneInstrumentation.activeMeshesEvaluationTimeCounter.current;
  9076. }
  9077. }, {
  9078. key: "getDrawCall",
  9079. value: function getDrawCall() {
  9080. return this.sceneInstrumentation.drawCallsCounter.current;
  9081. }
  9082. }, {
  9083. key: "getDrawCallTime",
  9084. value: function getDrawCallTime() {
  9085. return this.sceneInstrumentation.renderTimeCounter.current;
  9086. }
  9087. }, {
  9088. key: "getAnimationTime",
  9089. value: function getAnimationTime() {
  9090. return this.sceneInstrumentation.animationsTimeCounter.current;
  9091. }
  9092. }, {
  9093. key: "getActiveMesh",
  9094. value: function getActiveMesh() {
  9095. return this.scene.getActiveMeshes().length;
  9096. }
  9097. }, {
  9098. key: "getActiveFaces",
  9099. value: function getActiveFaces() {
  9100. return Math.round(this.scene.getActiveIndices() / 3);
  9101. }
  9102. }, {
  9103. key: "getActiveBones",
  9104. value: function getActiveBones() {
  9105. return this.scene.getActiveBones();
  9106. }
  9107. }, {
  9108. key: "getActiveAnimation",
  9109. value: function getActiveAnimation() {
  9110. return this.scene._activeAnimatables.length;
  9111. }
  9112. }, {
  9113. key: "getActiveParticles",
  9114. value: function getActiveParticles() {
  9115. return this.scene.getActiveParticles();
  9116. }
  9117. }, {
  9118. key: "getTotalMaterials",
  9119. value: function getTotalMaterials() {
  9120. return this.scene.materials.length;
  9121. }
  9122. }, {
  9123. key: "getTotalTextures",
  9124. value: function getTotalTextures() {
  9125. return this.scene.textures.length;
  9126. }
  9127. }, {
  9128. key: "getTotalGeometries",
  9129. value: function getTotalGeometries() {
  9130. return this.scene.geometries.length;
  9131. }
  9132. }, {
  9133. key: "getTotalMeshes",
  9134. value: function getTotalMeshes() {
  9135. return this.scene.meshes.length;
  9136. }
  9137. }, {
  9138. key: "getCameraRenderTime",
  9139. value: function getCameraRenderTime() {
  9140. return this.sceneInstrumentation.cameraRenderTimeCounter.current;
  9141. }
  9142. }, {
  9143. key: "getTotalRootNodes",
  9144. value: function getTotalRootNodes() {
  9145. return this.scene.rootNodes.length;
  9146. }
  9147. }, {
  9148. key: "getRenderTargetRenderTime",
  9149. value: function getRenderTargetRenderTime() {
  9150. var e = this.getDrawCallTime(),
  9151. t = this.getActiveMeshEvaluationTime(),
  9152. r = this.getCameraRenderTime() - (t + e);
  9153. return this.getRTT1Time() + r;
  9154. }
  9155. }, {
  9156. key: "getRegisterBeforeRenderTime",
  9157. value: function getRegisterBeforeRenderTime() {
  9158. return this.sceneInstrumentation.registerBeforeTimeCounter.current;
  9159. }
  9160. }, {
  9161. key: "getRegisterAfterRenderTime",
  9162. value: function getRegisterAfterRenderTime() {
  9163. return this.sceneInstrumentation.registerAfterTimeCounter.current;
  9164. }
  9165. }, {
  9166. key: "getRTT1Time",
  9167. value: function getRTT1Time() {
  9168. return this.sceneInstrumentation.getRTT1TimeCounter.current;
  9169. }
  9170. }, {
  9171. key: "getRegisterBeforeRenderObserverLength",
  9172. value: function getRegisterBeforeRenderObserverLength() {
  9173. return this.scene.onBeforeRenderObservable.observers.length;
  9174. }
  9175. }, {
  9176. key: "getRegisterAfterRenderObserverLength",
  9177. value: function getRegisterAfterRenderObserverLength() {
  9178. return this.scene.onAfterRenderObservable.observers.length;
  9179. }
  9180. }, {
  9181. key: "getTotalMeshByType",
  9182. value: function getTotalMeshByType() {
  9183. var e = new Map();
  9184. return this.scene.meshes.forEach(function (t) {
  9185. e.has(t.xtype) ? e.set(t.xtype, e.get(t.xtype) + 1) : e.set(t.xtype, 1);
  9186. }), e;
  9187. }
  9188. }, {
  9189. key: "getHardwareRenderInfo",
  9190. value: function getHardwareRenderInfo() {
  9191. return {
  9192. maxTexturesUnits: this.caps.maxTexturesImageUnits,
  9193. maxVertexTextureImageUnits: this.caps.maxVertexTextureImageUnits,
  9194. maxCombinedTexturesImageUnits: this.caps.maxCombinedTexturesImageUnits,
  9195. maxTextureSize: this.caps.maxTextureSize,
  9196. maxSamples: this.caps.maxSamples,
  9197. maxCubemapTextureSize: this.caps.maxCubemapTextureSize,
  9198. maxRenderTextureSize: this.caps.maxRenderTextureSize,
  9199. maxVertexAttribs: this.caps.maxVertexAttribs,
  9200. maxVaryingVectors: this.caps.maxVaryingVectors,
  9201. maxVertexUniformVectors: this.caps.maxVertexUniformVectors,
  9202. maxFragmentUniformVectors: this.caps.maxFragmentUniformVectors,
  9203. standardDerivatives: this.caps.standardDerivatives,
  9204. supportTextureCompress: {
  9205. s3tc: this.caps.s3tc !== void 0,
  9206. s3tc_srgb: this.caps.s3tc_srgb !== void 0,
  9207. pvrtc: this.caps.pvrtc !== void 0,
  9208. etc1: this.caps.etc1 !== void 0,
  9209. etc2: this.caps.etc2 !== void 0,
  9210. astc: this.caps.astc !== void 0,
  9211. bptc: this.caps.bptc !== void 0
  9212. },
  9213. textureFloat: this.caps.textureFloat,
  9214. vertexArrayObject: this.caps.vertexArrayObject,
  9215. textureAnisotropicFilterExtension: this.caps.textureAnisotropicFilterExtension !== void 0,
  9216. maxAnisotropy: this.caps.maxAnisotropy,
  9217. instancedArrays: this.caps.instancedArrays,
  9218. uintIndices: this.caps.uintIndices,
  9219. highPrecisionShaders: this.caps.highPrecisionShaderSupported,
  9220. fragmentDepth: this.caps.fragmentDepthSupported,
  9221. textureFloatLinearFiltering: this.caps.textureFloatLinearFiltering,
  9222. renderToTextureFloat: this.caps.textureFloatRender,
  9223. textureHalfFloat: this.caps.textureHalfFloat,
  9224. textureHalfFloatLinearFiltering: this.caps.textureHalfFloatLinearFiltering,
  9225. textureHalfFloatRender: this.caps.textureHalfFloatRender,
  9226. textureLOD: this.caps.textureLOD,
  9227. drawBuffersExtension: this.caps.drawBuffersExtension,
  9228. depthTextureExtension: this.caps.depthTextureExtension,
  9229. colorBufferFloat: this.caps.colorBufferFloat,
  9230. supportTimerQuery: this.caps.timerQuery !== void 0,
  9231. canUseTimestampForTimerQuery: this.caps.canUseTimestampForTimerQuery,
  9232. supportOcclusionQuery: this.caps.supportOcclusionQuery,
  9233. multiview: this.caps.multiview,
  9234. oculusMultiview: this.caps.oculusMultiview,
  9235. maxMSAASamples: this.caps.maxMSAASamples,
  9236. blendMinMax: this.caps.blendMinMax,
  9237. canUseGLInstanceID: this.caps.canUseGLInstanceID,
  9238. canUseGLVertexID: this.caps.canUseGLVertexID,
  9239. supportComputeShaders: this.caps.supportComputeShaders,
  9240. supportSRGBBuffers: this.caps.supportSRGBBuffers,
  9241. supportStencil: this.engine.isStencilEnable
  9242. };
  9243. }
  9244. }, {
  9245. key: "getSystemInfo",
  9246. value: function getSystemInfo() {
  9247. return {
  9248. resolution: "real: " + this.engine.getRenderWidth() + "x" + this.engine.getRenderHeight() + " cavs: " + this._canvas.clientWidth + "x" + this._canvas.clientHeight,
  9249. hardwareScalingLevel: this.engine.getHardwareScalingLevel().toFixed(2).toString() + "_" + this._scenemanager.initEngineScaleNumber.toFixed(2).toString(),
  9250. driver: this.engine.getGlInfo().renderer,
  9251. vender: this.engine.getGlInfo().vendor,
  9252. version: this.engine.getGlInfo().version,
  9253. os: this._osversion
  9254. };
  9255. }
  9256. }, {
  9257. key: "getFps",
  9258. value: function getFps() {
  9259. var e = this.sceneInstrumentation.frameTimeCounter.lastSecAverage,
  9260. t = this.sceneInstrumentation.interFrameTimeCounter.lastSecAverage;
  9261. return 1e3 / (e + t);
  9262. }
  9263. }, {
  9264. key: "osVersion",
  9265. value: function osVersion() {
  9266. var e = window.navigator.userAgent;
  9267. var t;
  9268. return /iphone|ipad|ipod/gi.test(e) ? t = e.match(/OS (\d+)_(\d+)_?(\d+)?/) : /android/gi.test(e) && (t = e.match(/Android (\d+)/)), t != null && t.length > 0 ? t[0] : null;
  9269. }
  9270. }]);
  9271. return XStats;
  9272. }();
  9273. function _arrayWithHoles(arr) {
  9274. if (Array.isArray(arr)) return arr;
  9275. }
  9276. function _iterableToArrayLimit(arr, i) {
  9277. var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
  9278. if (_i == null) return;
  9279. var _arr = [];
  9280. var _n = true;
  9281. var _d = false;
  9282. var _s, _e;
  9283. try {
  9284. for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
  9285. _arr.push(_s.value);
  9286. if (i && _arr.length === i) break;
  9287. }
  9288. } catch (err) {
  9289. _d = true;
  9290. _e = err;
  9291. } finally {
  9292. try {
  9293. if (!_n && _i["return"] != null) _i["return"]();
  9294. } finally {
  9295. if (_d) throw _e;
  9296. }
  9297. }
  9298. return _arr;
  9299. }
  9300. function _nonIterableRest() {
  9301. throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  9302. }
  9303. function _slicedToArray(arr, i) {
  9304. return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray$5(arr, i) || _nonIterableRest();
  9305. }
  9306. function _createForOfIteratorHelper$3(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$3(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
  9307. function _unsupportedIterableToArray$3(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$3(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$3(o, minLen); }
  9308. function _arrayLikeToArray$3(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  9309. var XBreathPointManager = /*#__PURE__*/function () {
  9310. function XBreathPointManager(e) {
  9311. var _this = this;
  9312. _classCallCheck(this, XBreathPointManager);
  9313. E(this, "_scene");
  9314. E(this, "materialMap", new Map());
  9315. E(this, "breathPoints", new Map());
  9316. E(this, "_sceneManager");
  9317. E(this, "_allIds", new Set());
  9318. E(this, "_loopBPKeys", []);
  9319. E(this, "addBreathPoint", /*#__PURE__*/function () {
  9320. var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  9321. var t, r, n, _e$spriteSheet, o, _e$spriteWidthNumber, a, _e$spriteHeightNumber, s, l, _e$rotation, u, _e$size, c, _e$width, h, _e$height, f, _e$fps, d, _e$billboardMode, _, _e$forceLeaveGround, g, _e$type, m, _e$lifeTime, v, _e$backfaceculling, y, _e$maxVisibleRegion, b, _e$skinInfo, T, I, C, _I, _I2, A, _I3, S, P, R, M, x;
  9322. return regenerator.wrap(function _callee$(_context) {
  9323. while (1) {
  9324. switch (_context.prev = _context.next) {
  9325. case 0:
  9326. t = [{
  9327. url: "https://static.xverse.cn/qqktv/texture.png"
  9328. }];
  9329. if (!(t.length <= 0)) {
  9330. _context.next = 4;
  9331. break;
  9332. }
  9333. logger$1.warn("[Engine] BreathPoint get texture list error: textureList.length <= 0"), new XBreathPointError("[Engine] BreathPoint get texture list error!");
  9334. return _context.abrupt("return");
  9335. case 4:
  9336. r = t[0], n = e.id, _e$spriteSheet = e.spriteSheet, o = _e$spriteSheet === void 0 ? r.url : _e$spriteSheet, _e$spriteWidthNumber = e.spriteWidthNumber, a = _e$spriteWidthNumber === void 0 ? 20 : _e$spriteWidthNumber, _e$spriteHeightNumber = e.spriteHeightNumber, s = _e$spriteHeightNumber === void 0 ? 1 : _e$spriteHeightNumber, l = e.position, _e$rotation = e.rotation, u = _e$rotation === void 0 ? {
  9337. pitch: -90,
  9338. yaw: 270,
  9339. roll: 0
  9340. } : _e$rotation, _e$size = e.size, c = _e$size === void 0 ? .6 : _e$size, _e$width = e.width, h = _e$width === void 0 ? -1 : _e$width, _e$height = e.height, f = _e$height === void 0 ? -1 : _e$height, _e$fps = e.fps, d = _e$fps === void 0 ? 30 : _e$fps, _e$billboardMode = e.billboardMode, _ = _e$billboardMode === void 0 ? !1 : _e$billboardMode, _e$forceLeaveGround = e.forceLeaveGround, g = _e$forceLeaveGround === void 0 ? !1 : _e$forceLeaveGround, _e$type = e.type, m = _e$type === void 0 ? "default" : _e$type, _e$lifeTime = e.lifeTime, v = _e$lifeTime === void 0 ? -1 : _e$lifeTime, _e$backfaceculling = e.backfaceculling, y = _e$backfaceculling === void 0 ? !0 : _e$backfaceculling, _e$maxVisibleRegion = e.maxVisibleRegion, b = _e$maxVisibleRegion === void 0 ? -1 : _e$maxVisibleRegion, _e$skinInfo = e.skinInfo, T = _e$skinInfo === void 0 ? "default" : _e$skinInfo;
  9341. if (!_this.breathPoints.get(n)) {
  9342. _context.next = 8;
  9343. break;
  9344. }
  9345. logger$1.warn("[Engine] Cannot add breathPoint with an existing id: [" + n + "]"), new XBreathPointError("[Engine] Cannot add breathPoint with an existing id: [" + n + "]");
  9346. return _context.abrupt("return");
  9347. case 8:
  9348. if (g) {
  9349. I = _this.castRay(new BABYLON.Vector3(l.x, l.y, l.z)) * scaleFromUE4toXverse;
  9350. I != 0 ? l.z = l.z - I + 1 : l.z = l.z + 1;
  9351. }
  9352. if (_this.materialMap.get(m)) {
  9353. _I = _this.materialMap.get(m);
  9354. _I.count = _I.count + 1, C = _I.mat;
  9355. } else {
  9356. _I2 = new Texture(o, _this._scene, !0, !0, Texture.BILINEAR_SAMPLINGMODE, null, function () {
  9357. logger$1.error("[Engine] Breathpoint create texture error."), new XBreathPointError("[Engine] Breathpoint create texture error.");
  9358. }, null, !0);
  9359. _I2.name = "TexBreathPoint_" + n, C = new StandardMaterial("MaterialBreathPoint_".concat(n), _this._scene), C.alpha = 1, C.emissiveTexture = _I2, C.backFaceCulling = y, C.diffuseTexture = _I2, C.diffuseTexture.hasAlpha = !0, C.useAlphaFromDiffuseTexture = !0, _this.materialMap.set(m, {
  9360. mat: C,
  9361. count: 1,
  9362. lastRenderTime: Date.now(),
  9363. fps: d,
  9364. spriteWidthNumber: a,
  9365. spriteHeightNumber: s,
  9366. spriteSheet: o,
  9367. texture: _I2
  9368. });
  9369. }
  9370. A = new Array(6);
  9371. for (_I3 = 0; _I3 < 6; _I3++) {
  9372. A[_I3] = new Vector4(0, 0, 0, 0);
  9373. }
  9374. A[0] = new Vector4(0, 0, 1 / a, 1 / s), A[1] = new Vector4(0, 0, 1 / a, 1 / s);
  9375. S = {};
  9376. h > 0 && f > 0 ? S = {
  9377. width: h,
  9378. height: f,
  9379. depth: .01,
  9380. faceUV: A
  9381. } : S = {
  9382. size: c,
  9383. depth: .01,
  9384. faceUV: A
  9385. };
  9386. P = BABYLON.MeshBuilder.CreateBox(n, S, _this._scene);
  9387. P.material = C;
  9388. R = new XStaticMesh({
  9389. id: n,
  9390. mesh: P,
  9391. xtype: EMeshType.XBreathPoint,
  9392. skinInfo: T
  9393. });
  9394. M = u;
  9395. _ && (P.billboardMode = Mesh.BILLBOARDMODE_ALL, R.allowMove(), M = {
  9396. pitch: 0,
  9397. yaw: 270,
  9398. roll: 0
  9399. });
  9400. x = new BreathPoint({
  9401. type: m,
  9402. mesh: R,
  9403. id: n,
  9404. position: l,
  9405. rotation: M,
  9406. mat: C,
  9407. maxVisibleRegion: b,
  9408. scene: _this._scene,
  9409. skinInfo: T
  9410. });
  9411. _this.breathPoints.set(n, x), _this._allIds.add(n), v > 0 && setTimeout(function () {
  9412. _this.clearBreathPoints(n);
  9413. }, v * 1e3);
  9414. case 22:
  9415. case "end":
  9416. return _context.stop();
  9417. }
  9418. }
  9419. }, _callee);
  9420. }));
  9421. return function (_x) {
  9422. return _ref.apply(this, arguments);
  9423. };
  9424. }());
  9425. E(this, "reg_breathpoint_update", function () {
  9426. var e = new Date().getTime();
  9427. if (_this.materialMap != null) {
  9428. var _iterator = _createForOfIteratorHelper$3(_this.materialMap),
  9429. _step;
  9430. try {
  9431. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  9432. var _step$value = _slicedToArray(_step.value, 2),
  9433. t = _step$value[0],
  9434. r = _step$value[1];
  9435. e - r.lastRenderTime > 1e3 / r.fps && (r.lastRenderTime = e, Math.abs(r.mat.diffuseTexture.uOffset - (1 - 1 / r.spriteWidthNumber)) < 1e-6 ? (r.mat.diffuseTexture.uOffset = 0, Math.abs(r.mat.diffuseTexture.vOffset - (1 - 1 / r.spriteHeightNumber)) < 1e-6 ? r.mat.diffuseTexture.vOffset = 0 : r.mat.diffuseTexture.vOffset += 1 / r.spriteHeightNumber) : r.mat.diffuseTexture.uOffset += 1 / r.spriteWidthNumber);
  9436. }
  9437. } catch (err) {
  9438. _iterator.e(err);
  9439. } finally {
  9440. _iterator.f();
  9441. }
  9442. }
  9443. });
  9444. E(this, "reg_breathpoint_autovisible", function () {
  9445. if (_this._scene.getFrameId() % 2 == 0) if (_this._loopBPKeys.length == 0) _this._loopBPKeys = Array.from(_this._allIds);else {
  9446. var _e = _this._getMainPlayerPosition();
  9447. for (var t = 0; t < 5 && _this._loopBPKeys.length > 0; ++t) {
  9448. var r = _this._loopBPKeys.pop();
  9449. if (r != null) {
  9450. var n = _this.getBreathPoint(r);
  9451. if (n != null && n.maxvisibleregion >= 0 && n.mesh.visibility == 1) {
  9452. var o = n.mesh.position;
  9453. calcDistance3DVector(_e, o) >= n.maxvisibleregion ? n == null || n.removeFromScene() : n == null || n.addToScene();
  9454. }
  9455. }
  9456. }
  9457. }
  9458. });
  9459. this._sceneManager = e, this._scene = e.Scene, this._scene.registerBeforeRender(this.reg_breathpoint_update), this._scene.registerBeforeRender(this.reg_breathpoint_autovisible);
  9460. }
  9461. _createClass(XBreathPointManager, [{
  9462. key: "setAllBreathPointVisibility",
  9463. value: function setAllBreathPointVisibility(e) {
  9464. var _iterator2 = _createForOfIteratorHelper$3(this.breathPoints.entries()),
  9465. _step2;
  9466. try {
  9467. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  9468. var _step2$value = _slicedToArray(_step2.value, 2),
  9469. t = _step2$value[0],
  9470. r = _step2$value[1];
  9471. r.toggleVisibility(e);
  9472. }
  9473. } catch (err) {
  9474. _iterator2.e(err);
  9475. } finally {
  9476. _iterator2.f();
  9477. }
  9478. }
  9479. }, {
  9480. key: "toggleBPVisibilityBySkinInfo",
  9481. value: function toggleBPVisibilityBySkinInfo(e, t) {
  9482. var _iterator3 = _createForOfIteratorHelper$3(this.breathPoints.entries()),
  9483. _step3;
  9484. try {
  9485. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  9486. var _step3$value = _slicedToArray(_step3.value, 2),
  9487. r = _step3$value[0],
  9488. n = _step3$value[1];
  9489. n.skinInfo == e && n.toggleVisibility(t);
  9490. }
  9491. } catch (err) {
  9492. _iterator3.e(err);
  9493. } finally {
  9494. _iterator3.f();
  9495. }
  9496. }
  9497. }, {
  9498. key: "toggleBPVisibilityById",
  9499. value: function toggleBPVisibilityById(e, t) {
  9500. var r = this.getBreathPoint(e);
  9501. r != null && r.toggleVisibility(t);
  9502. }
  9503. }, {
  9504. key: "getBreathPointBySkinInfo",
  9505. value: function getBreathPointBySkinInfo(e) {
  9506. var t = [];
  9507. var _iterator4 = _createForOfIteratorHelper$3(this.breathPoints.entries()),
  9508. _step4;
  9509. try {
  9510. for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
  9511. var _step4$value = _slicedToArray(_step4.value, 2),
  9512. r = _step4$value[0],
  9513. n = _step4$value[1];
  9514. n.skinInfo == e && t.push(n);
  9515. }
  9516. } catch (err) {
  9517. _iterator4.e(err);
  9518. } finally {
  9519. _iterator4.f();
  9520. }
  9521. return t;
  9522. }
  9523. }, {
  9524. key: "getAllBreathPoint",
  9525. value: function getAllBreathPoint() {
  9526. return this.breathPoints;
  9527. }
  9528. }, {
  9529. key: "getBreathPoint",
  9530. value: function getBreathPoint(e) {
  9531. return this.breathPoints.get(e);
  9532. }
  9533. }, {
  9534. key: "delete",
  9535. value: function _delete(e) {
  9536. var t = this.breathPoints.get(e);
  9537. if (t != null) {
  9538. t.dispose(), this._allIds.delete(e);
  9539. var r = this.materialMap.get(t._type);
  9540. r != null && (r.count = r.count - 1, r.count <= 0 && (r.count = 0, r.texture.dispose(), r.mat.dispose(!0, !0), this.materialMap.delete(t._type))), this.breathPoints.delete(e);
  9541. }
  9542. }
  9543. }, {
  9544. key: "castRay",
  9545. value: function castRay(e) {
  9546. var s;
  9547. e = ue4Position2Xverse({
  9548. x: e.x,
  9549. y: e.y,
  9550. z: e.z
  9551. });
  9552. var t = new BABYLON.Vector3(0, -1, 0),
  9553. r = new Ray(e, t, length),
  9554. n = [],
  9555. o = (s = this._sceneManager) == null ? void 0 : s.getGround({
  9556. x: e.x,
  9557. y: e.y,
  9558. z: e.z
  9559. });
  9560. var a = r.intersectsMeshes(o);
  9561. if (a.length > 0) {
  9562. var l = a[0];
  9563. if (l && l.pickedMesh) {
  9564. var u = l.distance;
  9565. t.y = 1;
  9566. var c = r.intersectsMeshes(n);
  9567. var h = 1e8;
  9568. if (c.length > 0) {
  9569. var f = c[0];
  9570. return f && f.pickedMesh && (h = -f.distance), h == 1e8 ? u : Math.abs(h) < Math.abs(u) ? h : u;
  9571. }
  9572. }
  9573. } else if (t.y = 1, a = r.intersectsMeshes(n), a.length > 0) {
  9574. var _l = a[0];
  9575. if (_l && _l.pickedMesh) return _l.distance;
  9576. }
  9577. return 0;
  9578. }
  9579. }, {
  9580. key: "changePickable",
  9581. value: function changePickable(e) {
  9582. var _iterator5 = _createForOfIteratorHelper$3(this.breathPoints.entries()),
  9583. _step5;
  9584. try {
  9585. for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
  9586. var _step5$value = _slicedToArray(_step5.value, 2),
  9587. t = _step5$value[0],
  9588. r = _step5$value[1];
  9589. r.changePickable(e);
  9590. }
  9591. } catch (err) {
  9592. _iterator5.e(err);
  9593. } finally {
  9594. _iterator5.f();
  9595. }
  9596. }
  9597. }, {
  9598. key: "clearBreathPoints",
  9599. value: function clearBreathPoints(e) {
  9600. logger$1.info("[Engine] clearBreathPoints: ".concat(e));
  9601. var _iterator6 = _createForOfIteratorHelper$3(this.breathPoints.entries()),
  9602. _step6;
  9603. try {
  9604. for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
  9605. var _step6$value = _slicedToArray(_step6.value, 2),
  9606. t = _step6$value[0],
  9607. r = _step6$value[1];
  9608. (r._type == e || r._id == e) && this.delete(r._id);
  9609. }
  9610. } catch (err) {
  9611. _iterator6.e(err);
  9612. } finally {
  9613. _iterator6.f();
  9614. }
  9615. }
  9616. }, {
  9617. key: "clearBreathPointsBySkinInfo",
  9618. value: function clearBreathPointsBySkinInfo(e) {
  9619. logger$1.info("[Engine] clearBreathPointsBySkinInfo: ".concat(e));
  9620. var _iterator7 = _createForOfIteratorHelper$3(this.breathPoints.entries()),
  9621. _step7;
  9622. try {
  9623. for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
  9624. var _step7$value = _slicedToArray(_step7.value, 2),
  9625. t = _step7$value[0],
  9626. r = _step7$value[1];
  9627. r.skinInfo == e && this.delete(r._id);
  9628. }
  9629. } catch (err) {
  9630. _iterator7.e(err);
  9631. } finally {
  9632. _iterator7.f();
  9633. }
  9634. }
  9635. }, {
  9636. key: "clearAllBreathPoints",
  9637. value: function clearAllBreathPoints() {
  9638. logger$1.info("[Engine] ClearAllBreathPoints");
  9639. var _iterator8 = _createForOfIteratorHelper$3(this.breathPoints.entries()),
  9640. _step8;
  9641. try {
  9642. for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
  9643. var _step8$value = _slicedToArray(_step8.value, 2),
  9644. e = _step8$value[0],
  9645. t = _step8$value[1];
  9646. this.delete(t._id);
  9647. }
  9648. } catch (err) {
  9649. _iterator8.e(err);
  9650. } finally {
  9651. _iterator8.f();
  9652. }
  9653. }
  9654. }, {
  9655. key: "_getMainPlayerPosition",
  9656. value: function _getMainPlayerPosition() {
  9657. var r;
  9658. var e = this._sceneManager.cameraComponent.MainCamera.position,
  9659. t = this._sceneManager.avatarComponent.getMainAvatar();
  9660. if (t != null && t != null) {
  9661. var n = (r = t == null ? void 0 : t.rootNode) == null ? void 0 : r.position;
  9662. if (n != null) return n;
  9663. }
  9664. return e;
  9665. }
  9666. }, {
  9667. key: "changeBreathPointPose",
  9668. value: function changeBreathPointPose(e, t, r) {
  9669. var n = new BABYLON.Vector3(e.position.x, e.position.y, e.position.z);
  9670. if (this.breathPoints.get(r) != null) {
  9671. logger$1.info("[Engine] changeBreathPointPose, id:".concat(r));
  9672. var o = this.breathPoints.get(r),
  9673. a = o.mesh.position;
  9674. var s = a.subtract(n);
  9675. s = BABYLON.Vector3.Normalize(s);
  9676. var l = BABYLON.Vector3.Distance(a, n),
  9677. u = new Ray(n, s, l),
  9678. c = this._scene.multiPickWithRay(u);
  9679. if (c) {
  9680. for (var h = 0; h < c.length; h++) {
  9681. if (c[h].pickedMesh != null && t.mesh.name.indexOf(c[h].pickedMesh.name) >= 0) {
  9682. var f = c[h].pickedPoint;
  9683. o.mesh.position = n.add(f.subtract(n).scale(.99)), this.breathPoints.set(r, o);
  9684. }
  9685. }
  9686. }
  9687. } else logger$1.warn("[Engine] changeBreathPointPose, id:".concat(r, " is not existing!"));
  9688. }
  9689. }]);
  9690. return XBreathPointManager;
  9691. }();
  9692. function _createForOfIteratorHelper$2(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$2(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
  9693. function _unsupportedIterableToArray$2(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$2(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$2(o, minLen); }
  9694. function _arrayLikeToArray$2(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  9695. var XDecalManager = /*#__PURE__*/function () {
  9696. function XDecalManager(e) {
  9697. _classCallCheck(this, XDecalManager);
  9698. E(this, "scene");
  9699. E(this, "_decal");
  9700. E(this, "_mat");
  9701. E(this, "_sharedMat");
  9702. E(this, "_scenemanager");
  9703. this._decal = new Map(), this._mat = new Map(), this._sharedMat = new Map(), this._scenemanager = e, this.scene = e.Scene;
  9704. }
  9705. _createClass(XDecalManager, [{
  9706. key: "decals",
  9707. get: function get() {
  9708. return Array.from(this._decal.values());
  9709. }
  9710. }, {
  9711. key: "getMesh",
  9712. value: function getMesh() {
  9713. return this._decal;
  9714. }
  9715. }, {
  9716. key: "addDecal",
  9717. value: function () {
  9718. var _addDecal = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  9719. var _this = this;
  9720. var t, r, _e$skinInfo, n;
  9721. return regenerator.wrap(function _callee$(_context) {
  9722. while (1) {
  9723. switch (_context.prev = _context.next) {
  9724. case 0:
  9725. t = e.id, r = e.meshPath, _e$skinInfo = e.skinInfo, n = _e$skinInfo === void 0 ? "default" : _e$skinInfo;
  9726. return _context.abrupt("return", this._decal.get(t) ? (logger.warn("[Engine] Cannot add decal with an existing id: [".concat(t, "], meshPath: ").concat(r, ", skinInfo:").concat(n)), Promise.resolve(!0)) : (logger.info("[Engine] addDecal wiht id:[".concat(t, "], meshPath: ").concat(r, ", skinInfo:").concat(n)), new Promise(function (o, a) {
  9727. return _this._scenemanager.urlTransformer(r).then(function (s) {
  9728. return new Promise(function (l, u) {
  9729. if (_this._decal.get(t)) l(!0);else {
  9730. var c = new XDecal({
  9731. id: t,
  9732. scene: _this.scene,
  9733. meshPath: s,
  9734. skinInfo: n
  9735. });
  9736. _this._decal.set(t, c), c.loadModel().then(function () {
  9737. l(!0);
  9738. }).catch(function (h) {
  9739. logger.error("[Engine] addDecal Error! id: [".concat(t, "], meshpath:").concat(r, ", skin: ").concat(n, ". ").concat(h)), u(new XDecalError("[Engine] addDecal Error! id: [".concat(t, "], meshpath:").concat(r, ", skin: ").concat(n, ". ").concat(h)));
  9740. });
  9741. }
  9742. });
  9743. }).then(function (s) {
  9744. s == !0 ? o(!0) : a(!1);
  9745. }).catch(function (s) {
  9746. logger.error("[Engine] Add Decal error! id: [".concat(t, "], meshpath:").concat(r, ", skin:").concat(n, ". ").concat(s)), a(new XDecalError("[Engine] addDecal error! id: [".concat(t, "], meshpath:").concat(r, ", skin:").concat(n, ". ").concat(s)));
  9747. });
  9748. })));
  9749. case 2:
  9750. case "end":
  9751. return _context.stop();
  9752. }
  9753. }
  9754. }, _callee, this);
  9755. }));
  9756. function addDecal(_x) {
  9757. return _addDecal.apply(this, arguments);
  9758. }
  9759. return addDecal;
  9760. }()
  9761. }, {
  9762. key: "setDecalTexture",
  9763. value: function setDecalTexture(e) {
  9764. var _this2 = this;
  9765. var t = e.id,
  9766. r = e.buffer,
  9767. _e$isDynamic = e.isDynamic,
  9768. n = _e$isDynamic === void 0 ? !1 : _e$isDynamic,
  9769. _e$width = e.width,
  9770. o = _e$width === void 0 ? 1100 : _e$width,
  9771. _e$height = e.height,
  9772. a = _e$height === void 0 ? 25 : _e$height,
  9773. _e$slots = e.slots,
  9774. s = _e$slots === void 0 ? 1 : _e$slots,
  9775. _e$visibleSlots = e.visibleSlots,
  9776. l = _e$visibleSlots === void 0 ? 1 : _e$visibleSlots,
  9777. u = !0;
  9778. return logger.info("[Engine] setDecalTexture wiht id:[".concat(t, "]")), new Promise(function (c, h) {
  9779. var f = _this2._decal.get(t);
  9780. if (f != null) {
  9781. if (_this2._mat.get(t) != null) _this2.changeDecalTexture({
  9782. id: t,
  9783. buffer: r,
  9784. isUrl: u,
  9785. isDynamic: n,
  9786. width: o,
  9787. height: a,
  9788. slots: s,
  9789. visibleSlots: l
  9790. }), c(!0);else {
  9791. var d = new XDecalMaterial(t, _this2.scene);
  9792. d.setTexture(r, u, n, o, a, s, l).then(function () {
  9793. f.setMat(d.getMat()), _this2._decal.set(t, f), _this2._mat.set(t, d), c(!0);
  9794. }).catch(function (_) {
  9795. logger.error("[Engine] setDecalTexture Error! " + _), h(new XDecalTextureError("[Engine] decal set texture error! ".concat(_)));
  9796. });
  9797. }
  9798. } else logger.error("[Engine] Error! decal id: [" + t + "] is not find!"), h(new XDecalTextureError("[Engine] decal id: [".concat(t, "] is not find!")));
  9799. });
  9800. }
  9801. }, {
  9802. key: "shareDecal",
  9803. value: function () {
  9804. var _shareDecal = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(e) {
  9805. var _this3 = this;
  9806. var t, r, n, _e$skinInfo2, o;
  9807. return regenerator.wrap(function _callee2$(_context2) {
  9808. while (1) {
  9809. switch (_context2.prev = _context2.next) {
  9810. case 0:
  9811. t = e.idTar, r = e.meshPath, n = e.idSrc, _e$skinInfo2 = e.skinInfo, o = _e$skinInfo2 === void 0 ? "default" : _e$skinInfo2;
  9812. return _context2.abrupt("return", this._decal.has(n) && !this._decal.has(t) && this._mat.has(n) && !this._mat.has(t) ? (logger.info("[Engine] shareDecal wiht idTar:[".concat(t, "], idSrc:[").concat(n, "], skinInfo: ").concat(o, ", meshPath: ").concat(r)), new Promise(function (a, s) {
  9813. return _this3._scenemanager.urlTransformer(r).then(function (l) {
  9814. var u = new XDecal({
  9815. id: t,
  9816. scene: _this3.scene,
  9817. meshPath: l,
  9818. skinInfo: o
  9819. }),
  9820. c = _this3._mat.get(n);
  9821. c != null && (u.setMat(c.getMat()), u.sourceMatId = n, _this3._decal.set(t, u), _this3.addSharedMatCount(n)), a(!0);
  9822. }).catch(function (l) {
  9823. s(new XDecalError("[Engine] decal shareDecal error! ".concat(l)));
  9824. });
  9825. })) : (logger.error("[Engine] shareDecal Error. idSrc: [".concat(n, "] not exist! or idTar: [").concat(t, "] exists!")), Promise.reject("[Engine] shareDecal Error. idSrc: [".concat(n, "] not exist! or idTar: [").concat(t, "] exists!"))));
  9826. case 2:
  9827. case "end":
  9828. return _context2.stop();
  9829. }
  9830. }
  9831. }, _callee2, this);
  9832. }));
  9833. function shareDecal(_x2) {
  9834. return _shareDecal.apply(this, arguments);
  9835. }
  9836. return shareDecal;
  9837. }()
  9838. }, {
  9839. key: "changeDecalModel",
  9840. value: function () {
  9841. var _changeDecalModel = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e) {
  9842. var _this4 = this;
  9843. var t, r, n;
  9844. return regenerator.wrap(function _callee3$(_context3) {
  9845. while (1) {
  9846. switch (_context3.prev = _context3.next) {
  9847. case 0:
  9848. t = e.id, r = e.meshPath, n = this._decal.get(t);
  9849. return _context3.abrupt("return", new Promise(function (o, a) {
  9850. return n != null ? (logger.info("[Engine] changeDecalModel id:".concat(t)), n.changeModel(r).then(function () {
  9851. _this4._decal.set(t, n), o(!0);
  9852. })) : (logger.warn("[Engine] changeDecalModel id:".concat(t, " is not exist")), a("[Engine] changeDecalModel id:".concat(t, " is not exist")));
  9853. }));
  9854. case 2:
  9855. case "end":
  9856. return _context3.stop();
  9857. }
  9858. }
  9859. }, _callee3, this);
  9860. }));
  9861. function changeDecalModel(_x3) {
  9862. return _changeDecalModel.apply(this, arguments);
  9863. }
  9864. return changeDecalModel;
  9865. }()
  9866. }, {
  9867. key: "changeDecalTexture",
  9868. value: function changeDecalTexture(e) {
  9869. var t = e.id,
  9870. r = e.buffer,
  9871. _e$isUrl = e.isUrl,
  9872. n = _e$isUrl === void 0 ? !1 : _e$isUrl,
  9873. _e$isDynamic2 = e.isDynamic,
  9874. o = _e$isDynamic2 === void 0 ? !1 : _e$isDynamic2,
  9875. _e$width2 = e.width,
  9876. a = _e$width2 === void 0 ? 1110 : _e$width2,
  9877. _e$height2 = e.height,
  9878. s = _e$height2 === void 0 ? 25 : _e$height2,
  9879. _e$slots2 = e.slots,
  9880. l = _e$slots2 === void 0 ? 1 : _e$slots2,
  9881. _e$visibleSlots2 = e.visibleSlots,
  9882. u = _e$visibleSlots2 === void 0 ? 1 : _e$visibleSlots2,
  9883. c = this._mat.get(t);
  9884. c != null && this._decal.has(t) ? (c.changeTexture(r, n, o, a, s, l, u), this._mat.set(t, c)) : logger.error("[Engine] changeDecalTexture Error. id:".concat(t, " is not exist"));
  9885. }
  9886. }, {
  9887. key: "deleteDecal",
  9888. value: function deleteDecal(e) {
  9889. var t, r;
  9890. if (this._decal.has(e)) {
  9891. var n = this._decal.get(e);
  9892. n != null && n.cleanMesh(), this._sharedMat.get(e) != null ? this.minusSharedMatCount(e) : this._mat.get(e) != null ? ((t = this._mat.get(e)) == null || t.cleanTexture(), this._mat.delete(e)) : ((r = n.sourceMatId) == null ? void 0 : r.length) > 0 && this.minusSharedMatCount(n.sourceMatId), this._decal.delete(e);
  9893. }
  9894. }
  9895. }, {
  9896. key: "deleteDecalBySkinInfo",
  9897. value: function deleteDecalBySkinInfo(e) {
  9898. var _iterator = _createForOfIteratorHelper$2(this._decal.entries()),
  9899. _step;
  9900. try {
  9901. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  9902. var _step$value = _slicedToArray(_step.value, 2),
  9903. t = _step$value[0],
  9904. r = _step$value[1];
  9905. r.skinInfo == e && this.deleteDecal(t);
  9906. }
  9907. } catch (err) {
  9908. _iterator.e(err);
  9909. } finally {
  9910. _iterator.f();
  9911. }
  9912. }
  9913. }, {
  9914. key: "addSharedMatCount",
  9915. value: function addSharedMatCount(e) {
  9916. var t = this._sharedMat.get(e);
  9917. t != null ? this._sharedMat.set(e, t + 1) : this._sharedMat.set(e, 1);
  9918. }
  9919. }, {
  9920. key: "minusSharedMatCount",
  9921. value: function minusSharedMatCount(e) {
  9922. var r;
  9923. var t = this._sharedMat.get(e);
  9924. t != null && (this._sharedMat.set(e, t - 1), t == 0 && (this._sharedMat.delete(e), (r = this._mat.get(e)) == null || r.cleanTexture(), this._mat.delete(e)));
  9925. }
  9926. }, {
  9927. key: "toggle",
  9928. value: function toggle(e, t) {
  9929. var r = this._decal.get(e);
  9930. r == null || r.toggle(t);
  9931. }
  9932. }, {
  9933. key: "toggleDecalBySkinInfo",
  9934. value: function toggleDecalBySkinInfo(e, t) {
  9935. var _iterator2 = _createForOfIteratorHelper$2(this._decal.entries()),
  9936. _step2;
  9937. try {
  9938. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  9939. var _step2$value = _slicedToArray(_step2.value, 2),
  9940. r = _step2$value[0],
  9941. n = _step2$value[1];
  9942. n.skinInfo == e && n.toggle(t);
  9943. }
  9944. } catch (err) {
  9945. _iterator2.e(err);
  9946. } finally {
  9947. _iterator2.f();
  9948. }
  9949. }
  9950. }, {
  9951. key: "updateTexAsWords",
  9952. value: function updateTexAsWords(e, t) {
  9953. var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  9954. var _r$clearArea = r.clearArea,
  9955. n = _r$clearArea === void 0 ? !0 : _r$clearArea,
  9956. _r$w = r.w,
  9957. o = _r$w === void 0 ? 480 : _r$w,
  9958. _r$h = r.h,
  9959. a = _r$h === void 0 ? 480 : _r$h,
  9960. _r$y = r.y,
  9961. s = _r$y === void 0 ? a / 2 : _r$y,
  9962. _r$fontsize = r.fontsize,
  9963. l = _r$fontsize === void 0 ? 70 : _r$fontsize,
  9964. _r$slots = r.slots,
  9965. u = _r$slots === void 0 ? 1 : _r$slots,
  9966. _r$visibleSlots = r.visibleSlots,
  9967. c = _r$visibleSlots === void 0 ? 1 : _r$visibleSlots,
  9968. _r$font = r.font,
  9969. h = _r$font === void 0 ? "black-body" : _r$font,
  9970. _r$color = r.color,
  9971. f = _r$color === void 0 ? "white" : _r$color,
  9972. _r$fontweight = r.fontweight,
  9973. d = _r$fontweight === void 0 ? 100 : _r$fontweight;
  9974. var _r$x = r.x,
  9975. _ = _r$x === void 0 ? o / 2 : _r$x;
  9976. var g = this._mat.get(e);
  9977. if (g) {
  9978. _ == -1 && (_ = (g.getUOffset() + c / u) % 1 * o * u);
  9979. var v = g.getMat().diffuseTexture,
  9980. y = v.getContext();
  9981. n && y.clearRect(_ - o / 2, s - a / 2, o, a), y.textAlign = "center", y.textBaseline = "middle", v.drawText(t, _, s, d + " " + l + "px " + h, f, "transparent", !0), v.hasAlpha = !0, v.update();
  9982. }
  9983. }
  9984. }, {
  9985. key: "updateTexAsImg",
  9986. value: function () {
  9987. var _updateTexAsImg = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(e, t) {
  9988. var _this5 = this;
  9989. var r,
  9990. _r$clearArea2,
  9991. n,
  9992. _r$w2,
  9993. o,
  9994. _r$h2,
  9995. a,
  9996. _r$x2,
  9997. s,
  9998. _r$y2,
  9999. l,
  10000. _r$clearW,
  10001. u,
  10002. _r$clearH,
  10003. c,
  10004. _args4 = arguments;
  10005. return regenerator.wrap(function _callee4$(_context4) {
  10006. while (1) {
  10007. switch (_context4.prev = _context4.next) {
  10008. case 0:
  10009. r = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : {};
  10010. _r$clearArea2 = r.clearArea, n = _r$clearArea2 === void 0 ? !0 : _r$clearArea2, _r$w2 = r.w, o = _r$w2 === void 0 ? 480 : _r$w2, _r$h2 = r.h, a = _r$h2 === void 0 ? 480 : _r$h2, _r$x2 = r.x, s = _r$x2 === void 0 ? o / 2 : _r$x2, _r$y2 = r.y, l = _r$y2 === void 0 ? a / 2 : _r$y2, _r$clearW = r.clearW, u = _r$clearW === void 0 ? o : _r$clearW, _r$clearH = r.clearH, c = _r$clearH === void 0 ? a : _r$clearH;
  10011. return _context4.abrupt("return", t == null || t == null || t == "" ? (logger.error("[Engine] updateTexAsImg Error. id: [".concat(e, "], newBuffer is Null or \"\"!")), Promise.reject(new XDecalError("[Engine] updateTexAsImg Error. id: [".concat(e, "], newBuffer is Null or \"\"!")))) : new Promise(function (h, f) {
  10012. return _this5._scenemanager.urlTransformer(t).then(function (d) {
  10013. return new Promise(function (_, g) {
  10014. var m = _this5._mat.get(e);
  10015. if (m) {
  10016. var y = m.getMat().diffuseTexture;
  10017. if (typeof t == "string") {
  10018. var b = new Image();
  10019. b.crossOrigin = "anonymous", b.src = d, b.onload = function () {
  10020. var T = y.getContext();
  10021. n && T.clearRect(s - u / 2, l - c / 2, u, c), T.drawImage(b, s - o / 2, l - a / 2, o, a), y.update(), _(!0);
  10022. }, b.onerror = function () {
  10023. logger.error("[Engine] updateTexAsImg Error.newImg load error. id: [".concat(e, "], decalMat is Null or undefined!")), g(new XDecalError("[Engine] updateTexAsImg Error. id: [".concat(e, "], decalMat is Null or undefined!")));
  10024. };
  10025. } else logger.error("[Engine] updateTexAsImg Error. id: [".concat(e, "], Buffer is not string!")), g(new XDecalError("[Engine] updateTexAsImg Error. id: [".concat(e, "], Buffer is not string!")));
  10026. } else logger.error("[Engine] updateTexAsImg Error. id: [".concat(e, "], decalMat is Null or undefined!")), g(new XDecalError("[Engine] updateTexAsImg Error. id: [".concat(e, "], decalMat is Null or undefined!")));
  10027. }).then(function (_) {
  10028. _ == !0 ? h(!0) : (logger.error("[Engine] updateTexAsImg Error. id: [".concat(e, "] !")), f(new XDecalError("[Engine] updateTexAsImg error! id: [".concat(e, "]"))));
  10029. }).catch(function (_) {
  10030. logger.error("[Engine] updateTexAsImg Error. id: [".concat(e, "]. ").concat(_));
  10031. });
  10032. });
  10033. }));
  10034. case 3:
  10035. case "end":
  10036. return _context4.stop();
  10037. }
  10038. }
  10039. }, _callee4);
  10040. }));
  10041. function updateTexAsImg(_x4, _x5) {
  10042. return _updateTexAsImg.apply(this, arguments);
  10043. }
  10044. return updateTexAsImg;
  10045. }()
  10046. }, {
  10047. key: "startAnime",
  10048. value: function startAnime(e, t) {
  10049. logger.info("[Engine] Decal Start Anime. [".concat(e, "]"));
  10050. var _t$speed = t.speed,
  10051. r = _t$speed === void 0 ? .001 : _t$speed,
  10052. n = t.callback,
  10053. o = this._mat.get(e);
  10054. o ? (o.do_animation(r), n && o.uOffsetObserverable.add(n)) : (logger.error("[Engine] startAnime Error. id: [".concat(e, "] is not exist!")), new XDecalError("[Engine] startAnime Error. id: [".concat(e, "] is not exist!")));
  10055. }
  10056. }]);
  10057. return XDecalManager;
  10058. }();
  10059. var PoolObject = /*#__PURE__*/function () {
  10060. function PoolObject(e, t, r) {
  10061. var n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : !0;
  10062. _classCallCheck(this, PoolObject);
  10063. E(this, "data");
  10064. E(this, "nextFree");
  10065. E(this, "previousFree");
  10066. E(this, "free");
  10067. this.data = e, this.nextFree = t, this.previousFree = r, this.free = n;
  10068. }
  10069. _createClass(PoolObject, [{
  10070. key: "dispose",
  10071. value: function dispose() {
  10072. this.data && this.data instanceof Mesh && this.data.dispose(!0, !0), this.previousFree = null, this.nextFree = null, this.data = null;
  10073. }
  10074. }]);
  10075. return PoolObject;
  10076. }();
  10077. var Pool = /*#__PURE__*/function () {
  10078. function Pool(e, t, r, n) {
  10079. _classCallCheck(this, Pool);
  10080. this.lastFree = null;
  10081. this.nextFree = null;
  10082. this._pool = [], this.objCreator = e, this.objReseter = t;
  10083. for (var _len = arguments.length, o = new Array(_len > 4 ? _len - 4 : 0), _key = 4; _key < _len; _key++) {
  10084. o[_key - 4] = arguments[_key];
  10085. }
  10086. for (var a = 0; a < n; a++) {
  10087. this.addNewObject(this.newPoolObject.apply(this, o));
  10088. }
  10089. this.capacity = r;
  10090. }
  10091. _createClass(Pool, [{
  10092. key: "addNewObject",
  10093. value: function addNewObject(e) {
  10094. return this._pool.push(e), this.release(e), e;
  10095. }
  10096. }, {
  10097. key: "release",
  10098. value: function release(e) {
  10099. e.free = !0, e.nextFree = null, e.previousFree = this.lastFree, this.lastFree ? this.lastFree.nextFree = e : this.nextFree = e, this.lastFree = e, this.objReseter(e);
  10100. }
  10101. }, {
  10102. key: "getFree",
  10103. value: function getFree() {
  10104. var t = this.nextFree ? this.nextFree : this.addNewObject(this.newPoolObject.apply(this, arguments));
  10105. return t.free = !1, this.nextFree = t.nextFree, this.nextFree || (this.lastFree = null), t;
  10106. }
  10107. }, {
  10108. key: "newPoolObject",
  10109. value: function newPoolObject() {
  10110. var t = this.objCreator.apply(this, arguments);
  10111. return new PoolObject(t, this.nextFree, this.lastFree);
  10112. }
  10113. }, {
  10114. key: "releaseAll",
  10115. value: function releaseAll() {
  10116. var _this = this;
  10117. this._pool.forEach(function (e) {
  10118. return _this.release(e);
  10119. });
  10120. }
  10121. }, {
  10122. key: "clean",
  10123. value: function clean() {
  10124. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  10125. var r = this.nextFree;
  10126. if (!r) return;
  10127. var n = 0;
  10128. for (; r;) {
  10129. n += 1, r = r.nextFree;
  10130. }
  10131. var o = !1;
  10132. if (n > e && this._pool.length > this.capacity && (o = !0), o) for (r = this.nextFree; r;) {
  10133. r.free = !1, this.nextFree = r.nextFree;
  10134. var a = this._pool.indexOf(r);
  10135. this._pool.splice(a, 1), this.nextFree || (this.lastFree = null), r == null || r.dispose(), r = this.nextFree;
  10136. }
  10137. }
  10138. }]);
  10139. return Pool;
  10140. }();
  10141. var BillboardStatus = {
  10142. SHOW: 1,
  10143. HIDE: 0,
  10144. DISPOSE: -1
  10145. };
  10146. function _createForOfIteratorHelper$1(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$1(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
  10147. function _unsupportedIterableToArray$1(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$1(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen); }
  10148. function _arrayLikeToArray$1(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  10149. var XAvatarManager = /*#__PURE__*/function () {
  10150. function XAvatarManager(e) {
  10151. var _this = this;
  10152. _classCallCheck(this, XAvatarManager);
  10153. this.characterMap = new Map();
  10154. this.curAnimList = [];
  10155. this.extraComps = new Map();
  10156. this._mainUser = null;
  10157. this._lodSettings = null;
  10158. this.maxBillBoardDist = 0;
  10159. this.maxAvatarNum = 0;
  10160. this.currentLODUsers = [];
  10161. this.bboxMeshPool = null;
  10162. this._distLevels = [];
  10163. this._maxLODUsers = [];
  10164. this._cullingDistance = 0;
  10165. this._maxDistRange = null;
  10166. this._delayTime = 100;
  10167. this._queueLength = -1;
  10168. this._queue = [];
  10169. this._processList = [];
  10170. this._process = null;
  10171. this._updateLoopObserver = null;
  10172. this._avatarInDistance = [];
  10173. this._renderedAvatar = [];
  10174. this._enableNickname = !0;
  10175. this._tickObserver = null;
  10176. this._tickInterval = null;
  10177. this._defaultAnims = null;
  10178. this._tickDispose = 0;
  10179. this._disposeTime = 100;
  10180. this.avatarLoader = avatarLoader;
  10181. this._scene = e.mainScene;
  10182. this._sceneManager = e;
  10183. this.initAvatarMap();
  10184. this._initSettings();
  10185. this._maxDistRange = this._distLevels[this._distLevels.length - 1], this.bboxMeshPool = new Pool(this.createBboxAsset, this.resetBboxAsset, 0, this.maxAvatarNum, this._sceneManager.Scene, 0, 0, 0), this._tickInterval = 250;
  10186. var t = 0;
  10187. this._tickObserver = this._scene.onAfterRenderObservable.add(function () {
  10188. t += 1, t == _this._tickInterval && (_this.tick(), t = 0);
  10189. });
  10190. }
  10191. _createClass(XAvatarManager, [{
  10192. key: "tick",
  10193. value: function tick() {
  10194. this.bboxMeshPool.clean(0);
  10195. }
  10196. }, {
  10197. key: "createBboxAsset",
  10198. value: function createBboxAsset(e, t, r, n) {
  10199. return BABYLON.MeshBuilder.CreateBox("avatarBbox", {
  10200. width: t,
  10201. height: r,
  10202. depth: n
  10203. }, e);
  10204. }
  10205. }, {
  10206. key: "resetBboxAsset",
  10207. value: function resetBboxAsset(e) {
  10208. var t = e.data;
  10209. return t.setEnabled(!1), t.isPickable = !1, e;
  10210. }
  10211. }, {
  10212. key: "_initSettings",
  10213. value: function _initSettings() {
  10214. this._defaultAnims = avatarSetting.defaultIdle, this._lodSettings = avatarSetting.lod, this._distLevels = avatarSetting.lod.map(function (e) {
  10215. return e.dist;
  10216. }), this._maxLODUsers = avatarSetting.lod.map(function (e) {
  10217. return e.quota;
  10218. }), this.currentLODUsers = new Array(this._distLevels.length).fill(0), this.maxAvatarNum = avatarSetting.maxAvatarNum, this.maxBillBoardDist = avatarSetting.maxBillBoardDist, this._cullingDistance = avatarSetting.cullingDistance;
  10219. }
  10220. }, {
  10221. key: "maxRenderNum",
  10222. value: function maxRenderNum() {
  10223. var e = 0;
  10224. return this._maxLODUsers.forEach(function (t) {
  10225. e += t;
  10226. }), e;
  10227. }
  10228. }, {
  10229. key: "curRenderNum",
  10230. value: function curRenderNum() {
  10231. var e = 0;
  10232. return this.currentLODUsers.forEach(function (t) {
  10233. e += t;
  10234. }), e;
  10235. }
  10236. }, {
  10237. key: "setLoDLevels",
  10238. value: function setLoDLevels(e) {
  10239. this._distLevels = e;
  10240. }
  10241. }, {
  10242. key: "cullingDistance",
  10243. get: function get() {
  10244. return this._cullingDistance;
  10245. },
  10246. set: function set(e) {
  10247. this._cullingDistance = e;
  10248. }
  10249. }, {
  10250. key: "getLoDLevels",
  10251. value: function getLoDLevels() {
  10252. return this._distLevels;
  10253. }
  10254. }, {
  10255. key: "setLodUserLimits",
  10256. value: function setLodUserLimits(e, t) {
  10257. this._maxLODUsers.length > e && (this._maxLODUsers[e] = t);
  10258. }
  10259. }, {
  10260. key: "setLodDist",
  10261. value: function setLodDist(e, t) {
  10262. this._distLevels[e] = t;
  10263. }
  10264. }, {
  10265. key: "setMaxDistRange",
  10266. value: function setMaxDistRange(e) {
  10267. this._maxDistRange = e, this._distLevels[this._distLevels.length - 1] = e;
  10268. }
  10269. }, {
  10270. key: "scene",
  10271. get: function get() {
  10272. return this._scene;
  10273. }
  10274. }, {
  10275. key: "setMainAvatar",
  10276. value: function setMainAvatar(e) {
  10277. var t;
  10278. this._mainUser = (t = this.characterMap.get(0)) == null ? void 0 : t.get(e);
  10279. }
  10280. }, {
  10281. key: "getMainAvatar",
  10282. value: function getMainAvatar() {
  10283. return this._mainUser;
  10284. }
  10285. }, {
  10286. key: "enableAllNickname",
  10287. value: function enableAllNickname(e) {
  10288. var _this2 = this;
  10289. return this.characterMap.forEach(function (t, r) {
  10290. r != 0 && t.forEach(function (n, o) {
  10291. _this2._updateBillboardStatus(n, e ? BillboardStatus.SHOW : BillboardStatus.HIDE);
  10292. });
  10293. }), this._enableNickname = e;
  10294. }
  10295. }, {
  10296. key: "getAvatarById",
  10297. value: function getAvatarById(e) {
  10298. var t;
  10299. return this.characterMap.forEach(function (r, n) {
  10300. r.get(e) && (t = r.get(e));
  10301. }), t;
  10302. }
  10303. }, {
  10304. key: "getAvatarNums",
  10305. value: function getAvatarNums() {
  10306. var e = 0;
  10307. return this.characterMap.forEach(function (t, r) {
  10308. e += t.size;
  10309. }), e;
  10310. }
  10311. }, {
  10312. key: "registerAvatar",
  10313. value: function registerAvatar(e) {
  10314. this.characterMap.get(e.priority).set(e.id, e);
  10315. }
  10316. }, {
  10317. key: "unregisterAvatar",
  10318. value: function unregisterAvatar(e) {
  10319. this.characterMap.get(e.priority).delete(e.id);
  10320. }
  10321. }, {
  10322. key: "initAvatarMap",
  10323. value: function initAvatarMap() {
  10324. this.characterMap.set(0, new Map()), this.characterMap.set(1, new Map()), this.characterMap.set(2, new Map()), this.characterMap.set(3, new Map()), this.characterMap.set(4, new Map()), this.characterMap.set(5, new Map());
  10325. }
  10326. }, {
  10327. key: "loadAvatar",
  10328. value: function loadAvatar(_ref) {
  10329. var _this3 = this;
  10330. var e = _ref.id,
  10331. t = _ref.avatarType,
  10332. r = _ref.priority,
  10333. n = _ref.avatarManager,
  10334. o = _ref.assets,
  10335. a = _ref.status;
  10336. return new Promise(function (s, l) {
  10337. if (_this3.getAvatarById(e)) return l(new DuplicateAvatarIDError("[Engine] cannot init avatar with the same id = ".concat(e)));
  10338. if (_this3.getAvatarNums() > _this3.maxAvatarNum) return l(new ExceedMaxAvatarNumError("[Engine] \u8D85\u51FA\u6700\u5927\u89D2\u8272\u9650\u5236 ".concat(_this3.maxAvatarNum)));
  10339. var u = new XAvatar({
  10340. id: e,
  10341. avatarType: t,
  10342. priority: r,
  10343. avatarManager: n,
  10344. assets: o,
  10345. status: a
  10346. });
  10347. if (_this3.registerAvatar(u), r == 0) _this3.setMainAvatar(u.id), _this3.addAvatarToScene(u, 0).then(function (c) {
  10348. return logger$1.debug("[Engine] avatar ".concat(u.id, " has been added to scene")), c ? (_this3._updateBillboardStatus(c, BillboardStatus.SHOW), setTimeout(function () {
  10349. _this3.launchProcessLoadingLoop();
  10350. }, _this3._delayTime), s(c)) : (u.removeAvatarFromScene(), l(new AvatarAssetLoadingError()));
  10351. }).catch(function (c) {
  10352. return u.removeAvatarFromScene(), l(new AvatarAssetLoadingError(c));
  10353. });else return s(u);
  10354. });
  10355. }
  10356. }, {
  10357. key: "deleteAvatar",
  10358. value: function deleteAvatar(e) {
  10359. return e.isRender ? (e.removeAvatarFromScene(), this.currentLODUsers[e.distLevel]--) : e.bbComponent.disposeBillBoard(e), this._processList = this._processList.filter(function (t) {
  10360. return t.id !== e.id;
  10361. }), this.unregisterAvatar(e), e.rootNode && (e.rootNode.dispose(), e.rootNode = void 0), e.bbComponent.bbox && e.bbComponent.bbox.dispose(), e.removeObserver(), e;
  10362. }
  10363. }, {
  10364. key: "_checkLODLevel",
  10365. value: function _checkLODLevel(e) {
  10366. if (e < this._distLevels[0]) return 0;
  10367. for (var t = 1; t < this._distLevels.length; ++t) {
  10368. if (e >= this._distLevels[t - 1] && e < this._distLevels[t]) return t;
  10369. }
  10370. return this._distLevels.length - 1;
  10371. }
  10372. }, {
  10373. key: "sceneManager",
  10374. get: function get() {
  10375. return this._sceneManager;
  10376. }
  10377. }, {
  10378. key: "launchProcessLoadingLoop",
  10379. value: function launchProcessLoadingLoop() {
  10380. this._updateAvatarStatus();
  10381. }
  10382. }, {
  10383. key: "stopProcessLoadingLoop",
  10384. value: function stopProcessLoadingLoop() {
  10385. var e;
  10386. this._updateLoopObserver && ((e = this._scene) == null || e.onBeforeRenderObservable.remove(this._updateLoopObserver));
  10387. }
  10388. }, {
  10389. key: "_distToMain",
  10390. value: function _distToMain(e) {
  10391. var n;
  10392. var t = (n = this._mainUser) == null ? void 0 : n.position,
  10393. r = e.position;
  10394. if (r && t) {
  10395. var o = this.sceneManager.cameraComponent.MainCamera.getFrontPosition(1).subtract(this.sceneManager.cameraComponent.MainCamera.position).normalize(),
  10396. a = e.rootNode.position.subtract(this.sceneManager.cameraComponent.MainCamera.position).normalize();
  10397. var s = 1;
  10398. if (o && a) {
  10399. var l = a.multiply(o);
  10400. s = Math.acos(l.x + l.y + l.z) < this.sceneManager.cameraComponent.MainCamera.fov / 2 ? 1 : 1e11;
  10401. }
  10402. return calcDistance3D(t, r) * s;
  10403. } else return logger$1.warn("user position or camera position is not correct!"), 1e11;
  10404. }
  10405. }, {
  10406. key: "_distToCamera",
  10407. value: function _distToCamera(e) {
  10408. var n;
  10409. var t = (n = this._sceneManager) == null ? void 0 : n.cameraComponent.getCameraPose().position,
  10410. r = e.position;
  10411. return r && t ? calcDistance3D(t, r) : (logger$1.warn("user position or camera position is not correct!"), 1e11);
  10412. }
  10413. }, {
  10414. key: "showAll",
  10415. value: function showAll(e) {
  10416. this.characterMap.forEach(function (t, r) {
  10417. e && r == 0 && t.forEach(function (n, o) {
  10418. n.show();
  10419. }), r != 0 && t.forEach(function (n, o) {
  10420. n.show();
  10421. });
  10422. });
  10423. }
  10424. }, {
  10425. key: "hideAll",
  10426. value: function hideAll(e) {
  10427. this.characterMap.forEach(function (t, r) {
  10428. e && r == 0 && t.forEach(function (n, o) {
  10429. n.hide();
  10430. }), r != 0 && t.forEach(function (n, o) {
  10431. n.hide();
  10432. });
  10433. });
  10434. }
  10435. }, {
  10436. key: "_assemblyAvatar",
  10437. value: function _assemblyAvatar(e, t) {
  10438. var _this4 = this;
  10439. var n, o;
  10440. var r = e.get(avatarSetting.body);
  10441. if (r && !t.attachBody(r)) {
  10442. t.isInLoadingList = !1, e.clear();
  10443. return;
  10444. }
  10445. var _iterator = _createForOfIteratorHelper$1(e),
  10446. _step;
  10447. try {
  10448. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  10449. var a = _step.value;
  10450. if (a[0] != avatarSetting.body && a[0] != avatarSetting.animations && !t.attachDecoration(a[1])) {
  10451. t.isInLoadingList = !1, t.removeAvatarFromScene(), e.clear();
  10452. return;
  10453. }
  10454. }
  10455. } catch (err) {
  10456. _iterator.e(err);
  10457. } finally {
  10458. _iterator.f();
  10459. }
  10460. t.isRender = !0, (n = t.controller) == null || n.playAnimation(t.controller.onPlay, t.controller.loop), (o = t.controller) == null || o.onPlayObservable.addOnce(function () {
  10461. var a, s;
  10462. if (!_this4.getAvatarById(t.id)) {
  10463. t.isInLoadingList = !1, t.removeAvatarFromScene(), _this4.currentLODUsers[t.distLevel]--;
  10464. return;
  10465. }
  10466. if (_this4.getAvatarById(t.id).rootNode.getChildMeshes().length < e.size) {
  10467. logger$1.error("this avatar does not have complete components, render failed. current list ".concat((a = _this4.getAvatarById(t.id)) == null ? void 0 : a.clothesList, ",avatar: ").concat(t.id, ",").concat(t.nickName)), t.isInLoadingList = !1, t.removeAvatarFromScene(), _this4.currentLODUsers[t.distLevel]--;
  10468. return;
  10469. }
  10470. t.setIsPickable(!0), t.isInLoadingList = !1, t.setAvatarVisible(!0), (s = _this4._sceneManager) == null || s.lightComponent.setShadow(t), t.getBbox(), t.nameBoard && t.nickName.length > 0 && t.setNickName(t.nickName, t.nameBoard.DEFAULT_CONFIGS), t.bubble && t.words.length > 0 && t.say(t.words, t.bubble.DEFAULT_CONFIGS), logger$1.debug("[Engine] avatar ".concat(t.id, " has been added to scene, current number of users : ").concat(_this4.currentLODUsers));
  10471. });
  10472. }
  10473. }, {
  10474. key: "_disposeUnusedAssets",
  10475. value: function _disposeUnusedAssets() {
  10476. this._tickDispose++, this._tickDispose > this._disposeTime && (avatarLoader.disposeContainer(), this._tickDispose = 0);
  10477. }
  10478. }, {
  10479. key: "_addResourcesToList",
  10480. value: function _addResourcesToList(e, t) {
  10481. var _this5 = this;
  10482. return e.clothesList.forEach(function (r) {
  10483. r.lod = t, _this5._queue.push(r);
  10484. }), this._queue.push({
  10485. type: avatarSetting.animations,
  10486. id: this._defaultAnims
  10487. }), this._queue.push({
  10488. type: avatarSetting.body,
  10489. id: e.avatarType,
  10490. lod: t
  10491. }), !0;
  10492. }
  10493. }, {
  10494. key: "_updateBillboardStatus",
  10495. value: function _updateBillboardStatus(e, t) {
  10496. e.bbComponent.updateBillboardStatus(e, t);
  10497. }
  10498. }, {
  10499. key: "_processLayer",
  10500. value: function _processLayer(e) {
  10501. var _this6 = this;
  10502. var t = this.characterMap.get(e),
  10503. r = [];
  10504. for (t == null || t.forEach(function (n) {
  10505. n.distToCam = _this6._distToCamera(n);
  10506. var o = n.distToCam < _this6._cullingDistance;
  10507. if (n.isRender && (!n.isHide && o ? n._hide_culling() : n._show_culling()), n.priority != 0) {
  10508. n.distance = _this6._distToMain(n);
  10509. var _a = BillboardStatus.SHOW;
  10510. n.distance < _this6._maxDistRange && (o ? _a = BillboardStatus.HIDE : n._show_culling(), _this6._updateBillboardStatus(n, _a)), n.isHide || (n.isInLoadingList ? _this6.currentLODUsers[n.distLevel]++ : r.push(n));
  10511. }
  10512. }), r.sort(function (n, o) {
  10513. return o.distance - n.distance;
  10514. }); r.length > 0 && this.curRenderNum() < this.maxRenderNum();) {
  10515. var n = r.pop();
  10516. var o = this._checkLODLevel(n.distance),
  10517. a = !1;
  10518. for (var s = 0; s < this._maxLODUsers.length; ++s) {
  10519. if (this.currentLODUsers[s] < this._maxLODUsers[s]) {
  10520. o = s, a = !0;
  10521. break;
  10522. }
  10523. }
  10524. if (!a || n.distance > this._maxDistRange) {
  10525. if (n.isRender) {
  10526. n._removeAvatarFromScene();
  10527. var _s = BillboardStatus.HIDE;
  10528. n.distance < this._maxDistRange && (_s = BillboardStatus.SHOW), this._updateBillboardStatus(n, _s);
  10529. }
  10530. break;
  10531. }
  10532. o != n.distLevel ? (n.isRender && (n.pendingLod = !0), n.distLevel = o, this._processList.push(n), n.isInLoadingList = !0) : n.isRender || (this._processList.push(n), n.isInLoadingList = !0), this.currentLODUsers[o]++;
  10533. }
  10534. return this.curRenderNum() >= this.maxRenderNum() && r.forEach(function (n) {
  10535. if (n.isRender) {
  10536. n._removeAvatarFromScene();
  10537. var _o = BillboardStatus.HIDE;
  10538. n.distance < _this6._maxDistRange && (_o = BillboardStatus.SHOW), _this6._updateBillboardStatus(n, _o);
  10539. }
  10540. }), this.curRenderNum() < this.maxRenderNum();
  10541. }
  10542. }, {
  10543. key: "_updateAvatar",
  10544. value: function _updateAvatar() {
  10545. var _this7 = this;
  10546. this.currentLODUsers = [0, 0, 0];
  10547. var e = [5, 4, 3, 2, 1, 0];
  10548. for (; e.length > 0;) {
  10549. var t = e.pop();
  10550. if (!this._processLayer(t)) {
  10551. e.forEach(function (n) {
  10552. var o;
  10553. (o = _this7.characterMap.get(n)) == null || o.forEach(function (a) {
  10554. a.distance = _this7._distToMain(a);
  10555. var s = BillboardStatus.HIDE;
  10556. a.distToCam < _this7._maxDistRange && (s = BillboardStatus.SHOW, a.isRender && a._removeAvatarFromScene()), _this7._updateBillboardStatus(a, s);
  10557. });
  10558. });
  10559. break;
  10560. }
  10561. }
  10562. }
  10563. }, {
  10564. key: "_updateAvatarStatus",
  10565. value: function _updateAvatarStatus() {
  10566. var _this8 = this;
  10567. var e = new Map();
  10568. this._updateLoopObserver = this.scene.onBeforeRenderObservable.add(function () {
  10569. var t;
  10570. if (_this8._disposeUnusedAssets(), !(_this8.getAvatarNums() <= 0)) {
  10571. if (!_this8._process && _this8._processList.length == 0 && _this8._updateAvatar(), !_this8._process && _this8._processList.length > 0) {
  10572. var r = _this8._processList.shift();
  10573. r != _this8._process && !r.isCulling ? _this8._addResourcesToList(r, r.distLevel) ? (_this8._process = r, _this8._queueLength = _this8._queue.length) : (_this8._process = void 0, _this8._queue = [], r.isInLoadingList = !1) : r.isInLoadingList = !1;
  10574. }
  10575. if (e.size === _this8._queueLength && _this8._process) {
  10576. _this8._process.pendingLod && (_this8._process.pendingLod = !1, _this8._process._removeAvatarFromScene());
  10577. var _r = Date.now();
  10578. _this8._assemblyAvatar(e, _this8._process), (t = _this8._sceneManager) == null || t.engineRunTimeStats.timeArray_addAvatarToScene.add(Date.now() - _r), _this8._updateBillboardStatus(_this8._process, BillboardStatus.SHOW), e.clear(), _this8._queue = [], _this8._process.isInLoadingList = !1, _this8._process = void 0, _this8._disposeUnusedAssets();
  10579. }
  10580. _this8._loadResByList(e);
  10581. }
  10582. });
  10583. }
  10584. }, {
  10585. key: "_loadResByList",
  10586. value: function _loadResByList(e) {
  10587. var _this9 = this;
  10588. var t = 0;
  10589. var r = 5;
  10590. if (!this._process) {
  10591. e.clear();
  10592. return;
  10593. }
  10594. var _loop = function _loop() {
  10595. var n = Date.now(),
  10596. o = _this9._queue.pop();
  10597. setTimeout(function () {
  10598. o ? o.type === avatarSetting.body ? _this9.loadBody(o.type, o.id, o.lod).then(function (a) {
  10599. a && e.set(avatarSetting.body, a), t += Date.now() - n;
  10600. }).catch(function (a) {
  10601. _this9._process && (_this9._process.isHide = !0, _this9.currentLODUsers[_this9._process.distLevel]--, e.clear(), _this9._queue = [], _this9._process.isInLoadingList = !1, _this9._process = void 0, t += 100), logger$1.warn("[Engine] body ".concat(o.id, " uri error, type ").concat(o.type, ", avatar has been hided") + a);
  10602. }) : o.type === avatarSetting.animations ? _this9.loadAnimation(_this9._process.avatarType, o.id).then(function (a) {
  10603. a && e.set(avatarSetting.animations, a), t += Date.now() - n;
  10604. }).catch(function (a) {
  10605. _this9._process && (_this9._process.isHide = !0, _this9.currentLODUsers[_this9._process.distLevel]--, e.clear(), _this9._queue = [], _this9._process.isInLoadingList = !1, _this9._process = void 0, t += 100), logger$1.warn("animation ".concat(o.id, " uri error, type ").concat(o.type, ", avatar has been hided") + a);
  10606. }) : _this9.loadDecoration(o.type, o.id, o.lod).then(function (a) {
  10607. a && e.set(a.type, a), t += Date.now() - n;
  10608. }).catch(function (a) {
  10609. _this9._process && (_this9._process.isHide = !0, _this9.currentLODUsers[_this9._process.distLevel]--, e.clear(), _this9._queue = [], _this9._process.isInLoadingList = !1, _this9._process = void 0, t += 100), logger$1.warn("component ".concat(o.id, " uri error, type ").concat(o.type, ", avatar has been hided") + a);
  10610. }) : t += 100;
  10611. }, 0);
  10612. };
  10613. for (; t < r && this._queue.length > 0;) {
  10614. _loop();
  10615. }
  10616. }
  10617. }, {
  10618. key: "_validateContainer",
  10619. value: function _validateContainer(e) {
  10620. return !e.meshes || e.meshes.length <= 1 ? (logger$1.warn("import container has no valid meshes"), !1) : !e.skeletons || e.skeletons.length == 0 ? (logger$1.warn("import container has no valid skeletons"), !1) : !0;
  10621. }
  10622. }, {
  10623. key: "_getAssetContainer",
  10624. value: function _getAssetContainer(e, t) {
  10625. var _this10 = this;
  10626. return new Promise(function (r, n) {
  10627. var o = _this10._getSourceKey(e, t || 0),
  10628. a = avatarLoader.containers.get(o);
  10629. if (a) return r(a);
  10630. avatarLoader.load(_this10.sceneManager, e, t).then(function (s) {
  10631. return s ? _this10._validateContainer(s) ? (avatarLoader.containers.set(o, s), r(s)) : n(new ContainerLoadingFailedError("[Engine] :: cannot load body type ".concat(e, "."))) : n(new ContainerLoadingFailedError("[Engine] container load failed cannot load body type ".concat(e, ".")));
  10632. }).catch(function (s) {
  10633. return n(new ContainerLoadingFailedError("[Engine] ".concat(s, " :: cannot load body type ").concat(e, ".")));
  10634. });
  10635. });
  10636. }
  10637. }, {
  10638. key: "_clipContainerRes",
  10639. value: function _clipContainerRes(e) {
  10640. e.transformNodes.forEach(function (t) {
  10641. t.dispose();
  10642. }), e.transformNodes = [], e.skeletons.forEach(function (t) {
  10643. t.dispose();
  10644. }), e.skeletons = [];
  10645. }
  10646. }, {
  10647. key: "loadBody",
  10648. value: function loadBody(e, t, r) {
  10649. var _this11 = this;
  10650. return new Promise(function (n, o) {
  10651. return avatarLoader.load(_this11.sceneManager, t, r).then(function (a) {
  10652. if (a) {
  10653. var s = a.instantiateModelsToScene();
  10654. a.xReferenceCount++;
  10655. var l = {
  10656. isRender: !1,
  10657. uId: Math.random(),
  10658. root: s.rootNodes[0],
  10659. skeletonType: e,
  10660. name: t,
  10661. animations: s.animationGroups,
  10662. skeleton: s.skeletons[0],
  10663. lod: r
  10664. };
  10665. return s.rootNodes[0]._parentContainer = a, s.rootNodes[0].setEnabled(!1), n(l);
  10666. } else return o(new ContainerLoadingFailedError("[Engine] container failed instanciates failed"));
  10667. }).catch(function () {
  10668. return o(new ContainerLoadingFailedError("[Engine] body type ".concat(e, " instanciates failed")));
  10669. });
  10670. });
  10671. }
  10672. }, {
  10673. key: "updateAnimationLists",
  10674. value: function updateAnimationLists(e, t) {
  10675. return new Promise(function (r, n) {
  10676. return avatarLoader.avaliableAnimation.set(t, e), r();
  10677. });
  10678. }
  10679. }, {
  10680. key: "loadAnimation",
  10681. value: function loadAnimation(e, t) {
  10682. var _this12 = this;
  10683. return new Promise(function (r, n) {
  10684. return avatarLoader.loadAnimRes(_this12.sceneManager, t, e).then(function (o) {
  10685. if (o) {
  10686. var a;
  10687. var s = _this12.avatarLoader.animations;
  10688. return o.animationGroups.forEach(function (l) {
  10689. l.stop(), l.name === t && (a = l, a.pContainer = o), s.set(getAnimationKey(l.name, e), l);
  10690. }), _this12._clipContainerRes(o), o.xReferenceCount++, r(a);
  10691. } else return n(new ContainerLoadingFailedError("[Engine] container failed instanciates failed"));
  10692. });
  10693. });
  10694. }
  10695. }, {
  10696. key: "loadDecoration",
  10697. value: function loadDecoration(e, t, r) {
  10698. var _this13 = this;
  10699. return new Promise(function (n, o) {
  10700. return avatarLoader.load(_this13.sceneManager, t, r).then(function (a) {
  10701. if (a) {
  10702. _this13._clipContainerRes(a);
  10703. var s = a.meshes[1].clone(a.meshes[1].name, null);
  10704. if (!s) {
  10705. logger$1.warn("[Engine] decoration does not exist!"), n(null);
  10706. return;
  10707. }
  10708. var l = {
  10709. isRender: !1,
  10710. uId: Math.random(),
  10711. root: s,
  10712. type: e,
  10713. name: t,
  10714. isSelected: !1,
  10715. lod: r
  10716. };
  10717. if (a.xReferenceCount++, s._parentContainer = a, a.meshes.length > 1) for (var u = 2; u < a.meshes.length; u++) {
  10718. s.addChild(a.meshes[u].clone(a.meshes[u].name, null));
  10719. }
  10720. s.setEnabled(!1), l.isSelected = !0, n(l);
  10721. } else return o(new ContainerLoadingFailedError("[Engine] container failed, instanciates failed."));
  10722. }).catch(function () {
  10723. return o(new ContainerLoadingFailedError("[Engine] body type ".concat(e, " instanciates failed.")));
  10724. });
  10725. });
  10726. }
  10727. }, {
  10728. key: "_getSourceKey",
  10729. value: function _getSourceKey(e, t) {
  10730. return t && avatarSetting.lod[t] ? e + avatarSetting.lod[t].fileName.split(".")[0] : e;
  10731. }
  10732. }, {
  10733. key: "addAvatarToScene",
  10734. value: function addAvatarToScene(e, t) {
  10735. var _this14 = this;
  10736. var r = Date.now();
  10737. return new Promise(function (n, o) {
  10738. _this14.loadBody(e.avatarType, e.avatarType, t).then(function (a) {
  10739. var s;
  10740. if (!a) return e.isInLoadingList = !1, o(new ContainerLoadingFailedError("[Engine] avatar ".concat(e.id, " instanciates failed")));
  10741. if (e.attachBody(a), a.animations.length > 0) return a.animations.forEach(function (l) {
  10742. l.stop();
  10743. }), e.setAnimations(a.animations), (s = e.controller) == null || s.playAnimation(e.controller.onPlay, !0), e.isRender = !0, e.isInLoadingList = !1, e.setAvatarVisible(!0), n(e);
  10744. _this14.loadAnimation(e.avatarType, _this14._defaultAnims).then(function (l) {
  10745. if (!l) return e.removeAvatarFromScene(), e.isInLoadingList = !1, o(new AvatarAnimationError());
  10746. var u = [];
  10747. e.clothesList.length > 0 && e.clothesList.forEach(function (c) {
  10748. u.push(_this14.loadDecoration(c.type, c.id, t));
  10749. }), Promise.all(u).then(function (c) {
  10750. var d, _, g, m;
  10751. c.forEach(function (v) {
  10752. if (v && !v.isRender) e.attachDecoration(v);else return e.isInLoadingList = !1, e.removeAvatarFromScene(), o(new AvatarAssetLoadingError());
  10753. }), e.isRender = !0, (d = e.controller) == null || d.playAnimation(e.controller.onPlay, e.controller.loop), e.setAvatarVisible(!0);
  10754. var h = avatarLoader.mshPath.get("meshes/ygb.glb"),
  10755. f = avatarLoader.matPath.get(avatarResources.ygb.mesh);
  10756. h && f ? _this14.loadExtra(f, h).then(function (v) {
  10757. var y;
  10758. e.isRender = !0, e.isInLoadingList = !1, e.distLevel = t, (y = _this14._sceneManager) == null || y.engineRunTimeStats.timeArray_addAvatarToScene.add(Date.now() - r), n(e);
  10759. }) : (e.isRender = !0, e.isInLoadingList = !1, e.distLevel = t, (_ = _this14._sceneManager) == null || _.engineRunTimeStats.timeArray_addAvatarToScene.add(Date.now() - r), n(e)), (g = _this14._sceneManager) == null || g.lightComponent.setShadow(e), e.isInLoadingList = !1, e.distLevel = t, (m = _this14._sceneManager) == null || m.engineRunTimeStats.timeArray_addAvatarToScene.add(Date.now() - r), n(e);
  10760. }).catch(function () {
  10761. return o(new AvatarAssetLoadingError("[Engine] avatar ".concat(e.id, " instanciates failed.")));
  10762. });
  10763. }).catch(function () {
  10764. return o(new AvatarAssetLoadingError("[Engine] avatar ".concat(e.id, " instanciates failed.")));
  10765. });
  10766. }).catch(function () {
  10767. return o(new AvatarAssetLoadingError("[Engine] avatar ".concat(e.id, " instanciates failed.")));
  10768. });
  10769. });
  10770. }
  10771. }, {
  10772. key: "loadExtra",
  10773. value: function loadExtra(e, t) {
  10774. var _this15 = this;
  10775. var r = avatarResources.ygb.name;
  10776. return new Promise(function (n, o) {
  10777. var a;
  10778. (a = _this15.sceneManager) == null || a.urlTransformer(e).then(function (s) {
  10779. BABYLON.SceneLoader.LoadAssetContainerAsync("", s, _this15.scene, null, avatarSetting.fileType).then(function (l) {
  10780. var c;
  10781. _this15.extraComps.set(r, l.meshes[0]);
  10782. var u = new NodeMaterial("material_".concat(r), _this15._scene, {
  10783. emitComments: !1
  10784. });
  10785. (c = _this15.sceneManager) == null || c.urlTransformer(t).then(function (h) {
  10786. u.loadAsync(h).then(function () {
  10787. l.meshes[2].material.dispose(!0, !0), u.build(!1), l.meshes[2].material = u, n(l.meshes[2]);
  10788. });
  10789. });
  10790. });
  10791. });
  10792. });
  10793. }
  10794. }, {
  10795. key: "getAvatarList",
  10796. value: function getAvatarList() {
  10797. var e = [];
  10798. return this.characterMap.forEach(function (t, r) {
  10799. t.forEach(function (n, o) {
  10800. e.push(n);
  10801. });
  10802. }), e;
  10803. }
  10804. }, {
  10805. key: "_debug_avatar",
  10806. value: function _debug_avatar() {
  10807. var t, r;
  10808. console.error("===>currentLODUsers", this.currentLODUsers), console.error("===>maxLODUsers", this._maxLODUsers), console.error("===>Loddist", this.getLoDLevels()), console.error("===> main character loc", (r = (t = this._mainUser) == null ? void 0 : t.rootNode) == null ? void 0 : r.position);
  10809. var e = 0;
  10810. this.getAvatarList().forEach(function (n) {
  10811. n.isRender && (console.error("avatar id : ".concat(n.id, ",lod ").concat(n.distLevel, ",is Hide ").concat(n.isHide, ", distance ").concat(n.distance, ", is pending ").concat(n.isInLoadingList)), e++);
  10812. }), console.error("========= avatar num", e), console.error("loop:", this._updateLoopObserver ? "on" : "false", "=> process", this._process, "===> comp", this._processList), console.error("===>maxLODUsers", this._maxLODUsers);
  10813. }
  10814. }]);
  10815. return XAvatarManager;
  10816. }();
  10817. var texRootDir = "https://app-asset-1258211750.file.myqcloud.com/1/textures/";
  10818. var XBillboardManager = /*#__PURE__*/function () {
  10819. function XBillboardManager(e) {
  10820. var _this = this;
  10821. _classCallCheck(this, XBillboardManager);
  10822. E(this, "billboardMap", new Map());
  10823. E(this, "sceneManager");
  10824. E(this, "billboardPool");
  10825. E(this, "userBackGroundBlob", new Array());
  10826. E(this, "npcBackGroundBlob", new Array());
  10827. E(this, "tickObserver");
  10828. E(this, "tickInterval");
  10829. E(this, "_updateLoopObserver");
  10830. this.sceneManager = e, this.billboardPool = new Pool(this.createBillboardAsset, this.resetBillboardAsset, 0, 60, this.sceneManager.Scene, !1), this.tickInterval = 250;
  10831. var t = 0;
  10832. this.tickObserver = this.sceneManager.Scene.onAfterRenderObservable.add(function () {
  10833. t += 1, t == _this.tickInterval && (_this.tick(), t = 0);
  10834. }), this.launchBillboardStatusLoop();
  10835. }
  10836. _createClass(XBillboardManager, [{
  10837. key: "tick",
  10838. value: function tick() {
  10839. this.billboardPool.clean(0, this.sceneManager.Scene, !1);
  10840. }
  10841. }, {
  10842. key: "createBillboardAsset",
  10843. value: function createBillboardAsset(e) {
  10844. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !1;
  10845. var r = BABYLON.MeshBuilder.CreatePlane("billboard-", {
  10846. height: .001,
  10847. width: .001,
  10848. sideOrientation: BABYLON.Mesh.DOUBLESIDE
  10849. }, e);
  10850. r.isPickable = !0, r.setEnabled(!1);
  10851. var n = new BABYLON.DynamicTexture("billboard-tex-", {
  10852. width: .001 + 1,
  10853. height: .001 + 1
  10854. }, e, t, BABYLON.Texture.BILINEAR_SAMPLINGMODE);
  10855. n.hasAlpha = !0;
  10856. var o = new BABYLON.StandardMaterial("billboard-mat-", e);
  10857. return o.diffuseTexture = n, o.emissiveColor = new BABYLON.Color3(.95, .95, .95), o.useAlphaFromDiffuseTexture = !0, r.material = o, r.billboardMode = BABYLON.Mesh.BILLBOARDMODE_Y, r.position.y = 0, r;
  10858. }
  10859. }, {
  10860. key: "resetBillboardAsset",
  10861. value: function resetBillboardAsset(e) {
  10862. var t = e.data;
  10863. return t.setEnabled(!1), t.isPickable = !1, e;
  10864. }
  10865. }, {
  10866. key: "loadBackGroundTexToIDB",
  10867. value: function () {
  10868. var _loadBackGroundTexToIDB = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
  10869. var _this2 = this;
  10870. return regenerator.wrap(function _callee$(_context) {
  10871. while (1) {
  10872. switch (_context.prev = _context.next) {
  10873. case 0:
  10874. XBillboardManager.userBubbleUrls.forEach(function (r) {
  10875. _this2.sceneManager.urlTransformer(r).then(function (n) {
  10876. _this2.userBackGroundBlob.push(n);
  10877. });
  10878. }), XBillboardManager.npcBubbleUrls.forEach(function (r) {
  10879. _this2.sceneManager.urlTransformer(r).then(function (n) {
  10880. _this2.npcBackGroundBlob.push(n);
  10881. });
  10882. });
  10883. case 1:
  10884. case "end":
  10885. return _context.stop();
  10886. }
  10887. }
  10888. }, _callee);
  10889. }));
  10890. function loadBackGroundTexToIDB() {
  10891. return _loadBackGroundTexToIDB.apply(this, arguments);
  10892. }
  10893. return loadBackGroundTexToIDB;
  10894. }()
  10895. }, {
  10896. key: "addBillboardToMap",
  10897. value: function addBillboardToMap(e, t) {
  10898. this.billboardMap.set(e, t);
  10899. }
  10900. }, {
  10901. key: "addBillboard",
  10902. value: function addBillboard(e, t, r) {
  10903. var n = this.getBillboard(e);
  10904. return n || (n = new XBillboard(this, t, r), this.addBillboardToMap(e, n)), n;
  10905. }
  10906. }, {
  10907. key: "generateStaticBillboard",
  10908. value: function generateStaticBillboard(e, _ref) {
  10909. var _ref$id = _ref.id,
  10910. t = _ref$id === void 0 ? "billboard" : _ref$id,
  10911. r = _ref.isUser,
  10912. n = _ref.background,
  10913. _ref$font = _ref.font,
  10914. o = _ref$font === void 0 ? "Arial" : _ref$font,
  10915. _ref$fontsize = _ref.fontsize,
  10916. a = _ref$fontsize === void 0 ? 40 : _ref$fontsize,
  10917. _ref$fontcolor = _ref.fontcolor,
  10918. s = _ref$fontcolor === void 0 ? "#ffffff" : _ref$fontcolor,
  10919. _ref$fontstyle = _ref.fontstyle,
  10920. l = _ref$fontstyle === void 0 ? "600" : _ref$fontstyle,
  10921. _ref$linesize = _ref.linesize,
  10922. u = _ref$linesize === void 0 ? 16 : _ref$linesize,
  10923. c = _ref.linelimit,
  10924. _ref$scale = _ref.scale,
  10925. h = _ref$scale === void 0 ? 1 : _ref$scale,
  10926. _ref$width = _ref.width,
  10927. f = _ref$width === void 0 ? .01 : _ref$width,
  10928. _ref$height = _ref.height,
  10929. d = _ref$height === void 0 ? .01 : _ref$height,
  10930. _ref$position = _ref.position,
  10931. _ = _ref$position === void 0 ? {
  10932. x: 0,
  10933. y: 0,
  10934. z: 0
  10935. } : _ref$position;
  10936. var g = this.addBillboard(t, !1, !0);
  10937. g.getMesh() == null && g.init(t, f, d);
  10938. var m;
  10939. r != null && (m = r ? XBillboardManager.userBubbleUrls : XBillboardManager.npcBubbleUrls), g && g.getMesh() && (g.DEFAULT_CONFIGS = {
  10940. id: t,
  10941. isUser: r,
  10942. background: n,
  10943. font: o,
  10944. fontsize: a,
  10945. fontcolor: s,
  10946. fontstyle: l,
  10947. linesize: u,
  10948. linelimit: c,
  10949. scale: h,
  10950. width: f,
  10951. height: d,
  10952. position: _
  10953. }, g.drawBillboard({
  10954. imageList: n || m
  10955. }, {
  10956. texts: e,
  10957. font: o,
  10958. fontsize: a,
  10959. fontcolor: s,
  10960. fontstyle: l,
  10961. linesize: u,
  10962. linelimit: c
  10963. }, {
  10964. position: _,
  10965. scale: h
  10966. }), t && g.setId(t), g.setStatus(BillboardStatus.SHOW));
  10967. }
  10968. }, {
  10969. key: "getBillboard",
  10970. value: function getBillboard(e) {
  10971. return this.billboardMap.get(e);
  10972. }
  10973. }, {
  10974. key: "toggle",
  10975. value: function toggle(e, t) {
  10976. var r;
  10977. (r = this.getBillboard(e)) == null || r.setStatus(t ? BillboardStatus.SHOW : BillboardStatus.HIDE);
  10978. }
  10979. }, {
  10980. key: "removeBillboard",
  10981. value: function removeBillboard(e) {
  10982. var t = this.getBillboard(e);
  10983. t && (t.setStatus(BillboardStatus.DISPOSE), this.billboardMap.delete(e));
  10984. }
  10985. }, {
  10986. key: "launchBillboardStatusLoop",
  10987. value: function launchBillboardStatusLoop() {
  10988. var _this3 = this;
  10989. this._updateLoopObserver = this.sceneManager.Scene.onBeforeRenderObservable.add(function () {
  10990. _this3.billboardMap.size <= 0 || _this3.billboardMap.forEach(function (e) {
  10991. e.stageChanged && (e.status == BillboardStatus.SHOW ? e.show() : e.status == BillboardStatus.HIDE ? e.hide() : (e.hide(), e.dispose()), e.stageChanged = !1);
  10992. });
  10993. });
  10994. }
  10995. }]);
  10996. return XBillboardManager;
  10997. }();
  10998. E(XBillboardManager, "alphaWidthMap", new Map()), E(XBillboardManager, "userBubbleUrls", [texRootDir + "bubble01.png", texRootDir + "bubble02.png", texRootDir + "bubble03.png"]), E(XBillboardManager, "npcBubbleUrls", [texRootDir + "bubble01_npc.png", texRootDir + "bubble02_npc.png", texRootDir + "bubble03_npc.png"]);
  10999. var XLightManager = /*#__PURE__*/function () {
  11000. function XLightManager(e) {
  11001. _classCallCheck(this, XLightManager);
  11002. E(this, "_scene");
  11003. E(this, "_envTexture");
  11004. E(this, "_shadowLight");
  11005. E(this, "_shadowGenerator");
  11006. E(this, "_avatarShadowMeshMap");
  11007. E(this, "_cullingShadowObservers");
  11008. E(this, "sceneManager");
  11009. this.sceneManager = e, this._scene = this.sceneManager.Scene, this._envTexture = null, this.shadowLean = .1;
  11010. var t = new BABYLON.Vector3(this.shadowLean, -1, 0),
  11011. r = 1024;
  11012. this._shadowLight = new BABYLON.DirectionalLight("AvatarLight", t, this._scene), this._shadowLight.shadowMaxZ = 5e3, this._shadowLight.intensity = 0, this.attachLightToCamera(this._shadowLight), this._shadowGenerator = new BABYLON.ShadowGenerator(r, this._shadowLight, !0), this._avatarShadowMeshMap = new Map(), this._cullingShadowObservers = new Map();
  11013. }
  11014. _createClass(XLightManager, [{
  11015. key: "shadowLean",
  11016. set: function set(e) {
  11017. e = Math.min(e, 1), e = Math.max(e, -1), this._shadowLight && (this._shadowLight.direction = new BABYLON.Vector3(e, -1, 0));
  11018. }
  11019. }, {
  11020. key: "setIBL",
  11021. value: function setIBL(e) {
  11022. var _this = this;
  11023. return new Promise(function (t, r) {
  11024. _this.sceneManager.urlTransformer(e).then(function (n) {
  11025. var o;
  11026. if (n == ((o = _this._envTexture) == null ? void 0 : o.url)) return t("env set success");
  11027. _this._envTexture != null && _this.disposeIBL(), _this._envTexture = BABYLON.CubeTexture.CreateFromPrefilteredData(n, _this._scene, ".env"), _this._scene.environmentTexture = _this._envTexture, _this._envTexture.onLoadObservable.addOnce(function () {
  11028. t("env set success"), logger$1.info("env set success");
  11029. });
  11030. }).catch(function () {
  11031. r("env set fail");
  11032. });
  11033. });
  11034. }
  11035. }, {
  11036. key: "disposeIBL",
  11037. value: function disposeIBL() {
  11038. this._envTexture == null ? logger$1.info("env not exist") : (this._envTexture.dispose(), this._envTexture = null, this._scene.environmentTexture = null, logger$1.info("env dispose success"));
  11039. }
  11040. }, {
  11041. key: "removeShadow",
  11042. value: function removeShadow(e) {
  11043. var t;
  11044. if (this._avatarShadowMeshMap.has(e)) {
  11045. this._avatarShadowMeshMap.delete(e), this._cullingShadowObservers.get(e) && (this._scene.onBeforeRenderObservable.remove(this._cullingShadowObservers.get(e)), this._cullingShadowObservers.delete(e));
  11046. var r = e.rootNode;
  11047. r && ((t = this._shadowGenerator) == null || t.removeShadowCaster(r));
  11048. } else return;
  11049. }
  11050. }, {
  11051. key: "setShadow",
  11052. value: function setShadow(e) {
  11053. if (this._avatarShadowMeshMap.has(e)) return;
  11054. e.rootNode && this._avatarShadowMeshMap.set(e, e.rootNode.getChildMeshes());
  11055. var t = 20,
  11056. r = 10,
  11057. n = this.cullingShadow(t, r, e);
  11058. this._cullingShadowObservers.set(e, n);
  11059. }
  11060. }, {
  11061. key: "cullingShadow",
  11062. value: function cullingShadow(e, t, r) {
  11063. var _this2 = this;
  11064. var n = 0;
  11065. var o = function o() {
  11066. var s, l;
  11067. if (n == t) {
  11068. var u = _this2._avatarShadowMeshMap.get(r),
  11069. c = (s = r.rootNode) == null ? void 0 : s.getChildMeshes(),
  11070. h = _this2._scene.activeCamera;
  11071. u == null || u.forEach(function (f) {
  11072. var d;
  11073. (d = _this2._shadowGenerator) == null || d.removeShadowCaster(f, !1);
  11074. }), c == null || c.forEach(function (f) {
  11075. var d;
  11076. (d = _this2._shadowGenerator) == null || d.addShadowCaster(f, !1);
  11077. }), h && r.rootNode && ((l = r.rootNode.position) == null ? void 0 : l.subtract(h.position).length()) > e && (c == null || c.forEach(function (f) {
  11078. var d;
  11079. (d = _this2._shadowGenerator) == null || d.removeShadowCaster(f, !1);
  11080. })), c && _this2._avatarShadowMeshMap.set(r, c), n = 0;
  11081. } else n += 1;
  11082. };
  11083. return this._scene.onBeforeRenderObservable.add(o);
  11084. }
  11085. }, {
  11086. key: "attachLightToCamera",
  11087. value: function attachLightToCamera(e) {
  11088. var _this3 = this;
  11089. var t = e,
  11090. r = 15,
  11091. n = function n() {
  11092. var o = _this3._scene.activeCamera;
  11093. if (o) {
  11094. var a = t.direction,
  11095. s = new BABYLON.Vector3(r * a.x, r * a.y, r * a.z),
  11096. l = o.position;
  11097. t.position = l.subtract(s);
  11098. }
  11099. };
  11100. return t && this._scene.registerBeforeRender(n), n;
  11101. }
  11102. }]);
  11103. return XLightManager;
  11104. }();
  11105. var RunTimeArray = /*#__PURE__*/function () {
  11106. function RunTimeArray() {
  11107. _classCallCheck(this, RunTimeArray);
  11108. E(this, "circularData");
  11109. this.circularData = [];
  11110. }
  11111. _createClass(RunTimeArray, [{
  11112. key: "add",
  11113. value: function add(e) {
  11114. this.circularData.length > 1e3 && this.circularData.shift(), this.circularData.push(e);
  11115. }
  11116. }, {
  11117. key: "getAvg",
  11118. value: function getAvg() {
  11119. var e = 0;
  11120. for (var t = 0; t < this.circularData.length; t++) {
  11121. e += this.circularData[t];
  11122. }
  11123. return {
  11124. sum: e,
  11125. avg: e / this.circularData.length || 0
  11126. };
  11127. }
  11128. }, {
  11129. key: "getMax",
  11130. value: function getMax() {
  11131. var e = 0;
  11132. for (var t = 0; t < this.circularData.length; t++) {
  11133. e < this.circularData[t] && (e = this.circularData[t]);
  11134. }
  11135. return e || 0;
  11136. }
  11137. }, {
  11138. key: "clear",
  11139. value: function clear() {
  11140. this.circularData = [];
  11141. }
  11142. }, {
  11143. key: "getStat",
  11144. value: function getStat() {
  11145. var e = this.getAvg(),
  11146. t = {
  11147. sum: e.sum,
  11148. avg: e.avg,
  11149. max: this.getMax()
  11150. };
  11151. return this.clear(), t;
  11152. }
  11153. }]);
  11154. return RunTimeArray;
  11155. }();
  11156. var XEngineRunTimeStats = /*#__PURE__*/_createClass(function XEngineRunTimeStats() {
  11157. _classCallCheck(this, XEngineRunTimeStats);
  11158. E(this, "timeArray_loadStaticMesh", new RunTimeArray());
  11159. E(this, "timeArray_updateStaticMesh", new RunTimeArray());
  11160. E(this, "timeArray_addAvatarToScene", new RunTimeArray());
  11161. });
  11162. function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
  11163. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  11164. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  11165. var getAlphaWidthMap = function getAlphaWidthMap(i, e) {
  11166. var t = new BABYLON.DynamicTexture("test", 3, e),
  11167. r = new Map();
  11168. for (var n = 32; n < 127; n++) {
  11169. var o = String.fromCodePoint(n),
  11170. a = 2 + "px " + i;
  11171. t.drawText(o, null, null, a, "#000000", "#ffffff", !0);
  11172. var s = t.getContext();
  11173. s.font = a;
  11174. var l = s.measureText(o).width;
  11175. r.set(n, l);
  11176. }
  11177. return t.dispose(), r;
  11178. };
  11179. var XSceneManager = /*#__PURE__*/function () {
  11180. function XSceneManager(e, t) {
  11181. var _this = this;
  11182. _classCallCheck(this, XSceneManager);
  11183. E(this, "scene");
  11184. E(this, "engine");
  11185. E(this, "canvas");
  11186. E(this, "gl");
  11187. E(this, "_yuvInfo");
  11188. E(this, "cameraParam");
  11189. E(this, "shaderMode");
  11190. E(this, "panoInfo");
  11191. E(this, "_initEngineScaleNumber");
  11192. E(this, "_forceKeepVertical", !1);
  11193. E(this, "_currentShader");
  11194. E(this, "_currentPanoId");
  11195. E(this, "_renderStatusCheckCount", 0);
  11196. E(this, "_renderStatusNotChecktCount", 0);
  11197. E(this, "_nonlinearCanvasResize", !1);
  11198. E(this, "_bChangeEngineSize", !0);
  11199. E(this, "_cameraManager");
  11200. E(this, "_lowpolyManager");
  11201. E(this, "_materialManager");
  11202. E(this, "_statisticManager");
  11203. E(this, "_breathPointManager");
  11204. E(this, "_skytv");
  11205. E(this, "_mv", []);
  11206. E(this, "_decalManager");
  11207. E(this, "_lightManager");
  11208. E(this, "_avatarManager");
  11209. E(this, "urlTransformer");
  11210. E(this, "_billboardManager");
  11211. E(this, "_backgroundImg");
  11212. E(this, "engineRunTimeStats");
  11213. E(this, "uploadHardwareSystemInfo", function () {
  11214. var e = _this.statisticComponent.getHardwareRenderInfo(),
  11215. t = _this.statisticComponent.getSystemInfo(),
  11216. r = {
  11217. driver: t.driver,
  11218. vender: t.vender,
  11219. webgl: t.version,
  11220. os: t.os
  11221. };
  11222. logger$1.warn(JSON.stringify(e)), logger$1.warn(JSON.stringify(r));
  11223. });
  11224. E(this, "addNewLowPolyMesh", /*#__PURE__*/function () {
  11225. var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e, t) {
  11226. return regenerator.wrap(function _callee$(_context) {
  11227. while (1) {
  11228. switch (_context.prev = _context.next) {
  11229. case 0:
  11230. _context.t0 = _this._currentShader == null;
  11231. if (!_context.t0) {
  11232. _context.next = 4;
  11233. break;
  11234. }
  11235. _context.next = 4;
  11236. return _this.initSceneManager();
  11237. case 4:
  11238. return _context.abrupt("return", _this._lowpolyManager.addNewLowPolyMesh(e, t, _this._currentShader));
  11239. case 5:
  11240. case "end":
  11241. return _context.stop();
  11242. }
  11243. }
  11244. }, _callee);
  11245. }));
  11246. return function (_x, _x2) {
  11247. return _ref.apply(this, arguments);
  11248. };
  11249. }());
  11250. E(this, "initSceneManager", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
  11251. return regenerator.wrap(function _callee2$(_context2) {
  11252. while (1) {
  11253. switch (_context2.prev = _context2.next) {
  11254. case 0:
  11255. _context2.next = 2;
  11256. return _this._materialManager.initMaterial();
  11257. case 2:
  11258. return _context2.abrupt("return", _this.applyShader());
  11259. case 3:
  11260. case "end":
  11261. return _context2.stop();
  11262. }
  11263. }
  11264. }, _callee2);
  11265. })));
  11266. E(this, "registerAfterRender", function () {
  11267. var e;
  11268. if (_this._forceKeepVertical) {
  11269. var _t = _this.canvas.width,
  11270. _r = _this.canvas.height;
  11271. var _n = 0,
  11272. _o = [[0, 0, 0, 0], [0, 0, 0, 0]];
  11273. if (((e = _this._cameraManager.MainCamera) == null ? void 0 : e.fovMode) === BABYLON.Camera.FOVMODE_HORIZONTAL_FIXED ? (_n = Math.ceil((_r - _this._yuvInfo.height * _t / _this._yuvInfo.width) / 2), _o = [[0, 0, _t, _n], [0, _r - _n, _t, _n]]) : (_n = Math.ceil((_t - _this._yuvInfo.width * _r / _this._yuvInfo.height) / 2), _o = [[0, 0, _n, _r], [_t - _n, 0, _n, _r]]), _n > 0) {
  11274. _this.gl.enable(_this.gl.SCISSOR_TEST);
  11275. for (var a = 0; a < _o.length; ++a) {
  11276. _this.gl.scissor(_o[a][0], _o[a][1], _o[a][2], _o[a][3]), _this.gl.clearColor(0, 0, 0, 1), _this.gl.clear(_this.gl.COLOR_BUFFER_BIT);
  11277. }
  11278. _this.gl.disable(_this.gl.SCISSOR_TEST);
  11279. }
  11280. }
  11281. });
  11282. E(this, "resetRender", function () {
  11283. _this.scene.environmentTexture && (_this.scene.environmentTexture._texture ? _this.lightComponent.setIBL(_this.scene.environmentTexture._texture.url) : _this.scene.environmentTexture.url && _this.lightComponent.setIBL(_this.scene.environmentTexture.url));
  11284. });
  11285. var r = /iphone|ipad/gi.test(window.navigator.userAgent) || t.disableWebGL2,
  11286. n = new BABYLON.Engine(e, !0, {
  11287. preserveDrawingBuffer: !0,
  11288. stencil: !0,
  11289. disableWebGL2Support: r
  11290. }, !0),
  11291. o = new BABYLON.Scene(n);
  11292. this.scene = o, this.engine = n, this.canvas = e, this.scene.clearColor = new BABYLON.Color4(.7, .7, .7, 1), this.engine.getCaps().parallelShaderCompile = void 0, this._initEngineScaleNumber = this.engine.getHardwareScalingLevel(), this.engine.enableOfflineSupport = !1, this.engine.doNotHandleContextLost = !0, this.scene.clearCachedVertexData(), this.scene.cleanCachedTextureBuffer(), this.urlTransformer = t.urlTransformer || function (s) {
  11293. return Promise.resolve(s);
  11294. }, t.logger && Logger1.setLogger(t.logger), this.gl = e.getContext("webgl2", {
  11295. preserveDrawingBuffer: !0
  11296. }) || e.getContext("webgl", {
  11297. preserveDrawingBuffer: !0
  11298. }) || e.getContext("experimental-webgl", {
  11299. preserveDrawingBuffer: !0
  11300. }), this.gl.pixelStorei(this.gl.UNPACK_ALIGNMENT, 1), this._currentPanoId = 0, t.forceKeepVertical != null && (this._forceKeepVertical = t.forceKeepVertical), t.panoInfo != null && (this.panoInfo = t.panoInfo), t.shaderMode != null && (this.shaderMode = t.shaderMode), t.yuvInfo != null ? this._yuvInfo = t.yuvInfo : this._yuvInfo = {
  11301. width: t.videoResOriArray[0].width,
  11302. height: t.videoResOriArray[0].height,
  11303. fov: 50
  11304. }, t.cameraParam != null && (this.cameraParam = t.cameraParam), t.nonlinearCanvasResize != null && (this._nonlinearCanvasResize = t.nonlinearCanvasResize), this._cameraManager = new XCameraComponent(this.canvas, this.scene, {
  11305. cameraParam: this.cameraParam,
  11306. yuvInfo: this._yuvInfo,
  11307. forceKeepVertical: this._forceKeepVertical
  11308. }), this._lowpolyManager = new XStaticMeshComponent(this), this._materialManager = new XMaterialComponent(this, {
  11309. videoResOriArray: t.videoResOriArray,
  11310. yuvInfo: this._yuvInfo,
  11311. panoInfo: this.panoInfo,
  11312. shaderMode: this.shaderMode
  11313. }), this._statisticManager = new XStats(this), this._breathPointManager = new XBreathPointManager(this), this._decalManager = new XDecalManager(this), this._avatarManager = new XAvatarManager(this), this._billboardManager = new XBillboardManager(this), this.billboardComponent.loadBackGroundTexToIDB(), this._lightManager = new XLightManager(this), this.postprocessing(), this.initSceneManager(), this.engineRunTimeStats = new XEngineRunTimeStats(), /iphone/gi.test(window.navigator.userAgent) && window.devicePixelRatio && window.devicePixelRatio === 3 && window.screen.width === 375 && window.screen.height === 812 ? this.engine.setHardwareScalingLevel(this._initEngineScaleNumber * 2) : this.engine.setHardwareScalingLevel(this._initEngineScaleNumber * 1.8), this.scene.registerBeforeRender(function () {
  11314. _this._nonlinearCanvasResize && _this._bChangeEngineSize && (_this.setEngineSize(_this._yuvInfo), _this._bChangeEngineSize = !1);
  11315. }), this.scene.registerAfterRender(function () {
  11316. _this._nonlinearCanvasResize || _this.registerAfterRender();
  11317. }), window.addEventListener("resize", function () {
  11318. _this._nonlinearCanvasResize ? _this._bChangeEngineSize = !0 : _this.engine.resize();
  11319. }), XBillboardManager.alphaWidthMap = getAlphaWidthMap("Arial", this.scene), this.uploadHardwareSystemInfo();
  11320. }
  11321. _createClass(XSceneManager, [{
  11322. key: "yuvInfo",
  11323. get: function get() {
  11324. return this.getCurrentShaderMode() == 1 ? this._yuvInfo : {
  11325. width: -1,
  11326. height: -1,
  11327. fov: -1
  11328. };
  11329. },
  11330. set: function set(e) {
  11331. this.getCurrentShaderMode() == 1 && (this._yuvInfo = e, this._cameraManager.cameraFovChange(e));
  11332. }
  11333. }, {
  11334. key: "mainScene",
  11335. get: function get() {
  11336. return this.scene;
  11337. }
  11338. }, {
  11339. key: "cameraComponent",
  11340. get: function get() {
  11341. return this._cameraManager;
  11342. }
  11343. }, {
  11344. key: "staticmeshComponent",
  11345. get: function get() {
  11346. return this._lowpolyManager;
  11347. }
  11348. }, {
  11349. key: "materialComponent",
  11350. get: function get() {
  11351. return this._materialManager;
  11352. }
  11353. }, {
  11354. key: "statisticComponent",
  11355. get: function get() {
  11356. return this._statisticManager;
  11357. }
  11358. }, {
  11359. key: "avatarComponent",
  11360. get: function get() {
  11361. return this._avatarManager;
  11362. }
  11363. }, {
  11364. key: "lightComponent",
  11365. get: function get() {
  11366. return this._lightManager;
  11367. }
  11368. }, {
  11369. key: "Engine",
  11370. get: function get() {
  11371. return this.engine;
  11372. }
  11373. }, {
  11374. key: "Scene",
  11375. get: function get() {
  11376. return this.scene;
  11377. }
  11378. }, {
  11379. key: "billboardComponent",
  11380. get: function get() {
  11381. return this._billboardManager;
  11382. }
  11383. }, {
  11384. key: "breathPointComponent",
  11385. get: function get() {
  11386. return this._breathPointManager;
  11387. }
  11388. }, {
  11389. key: "skytvComponent",
  11390. get: function get() {
  11391. return this._skytv;
  11392. }
  11393. }, {
  11394. key: "mvComponent",
  11395. get: function get() {
  11396. return this._mv;
  11397. }
  11398. }, {
  11399. key: "decalComponent",
  11400. get: function get() {
  11401. return this._decalManager;
  11402. }
  11403. }, {
  11404. key: "currentShader",
  11405. get: function get() {
  11406. return this._currentShader;
  11407. }
  11408. }, {
  11409. key: "initEngineScaleNumber",
  11410. get: function get() {
  11411. return this._initEngineScaleNumber;
  11412. }
  11413. }, {
  11414. key: "setImageQuality",
  11415. value: function setImageQuality(e) {
  11416. e == 0 ? (this.engine.setHardwareScalingLevel(this._initEngineScaleNumber * 1.8), logger$1.info("[Engine] change image quality to low, [" + this._initEngineScaleNumber * 1.8 + "]")) : e == 1 ? (this.engine.setHardwareScalingLevel(this._initEngineScaleNumber * 1.5), logger$1.info("[Engine] change image quality to mid, [" + this._initEngineScaleNumber * 1.5 + "]")) : e == 2 && (this.engine.setHardwareScalingLevel(this._initEngineScaleNumber * 1), logger$1.info("[Engine] change image quality to high, [" + this._initEngineScaleNumber * 1 + "]"));
  11417. }
  11418. }, {
  11419. key: "setNonlinearCanvasResize",
  11420. value: function setNonlinearCanvasResize(e) {
  11421. this._nonlinearCanvasResize = e, this._bChangeEngineSize = e, e || this.engine.resize();
  11422. }
  11423. }, {
  11424. key: "setBackgroundColor",
  11425. value: function setBackgroundColor(e) {
  11426. this.scene.clearColor = new Color4(e.r, e.g, e.b, e.a);
  11427. }
  11428. }, {
  11429. key: "setBackgroundImg",
  11430. value: function setBackgroundImg(e) {
  11431. var _this2 = this;
  11432. return this._backgroundImg != null && this._backgroundImg.url == e ? Promise.resolve(!0) : new Promise(function (t, r) {
  11433. _this2.urlTransformer(e).then(function (n) {
  11434. _this2._backgroundImg == null ? _this2._backgroundImg = {
  11435. layer: new Layer("tex_background_" + Date.now(), n, _this2.Scene, !0),
  11436. url: e
  11437. } : _this2._backgroundImg.url != e && _this2._backgroundImg.layer != null && _this2._backgroundImg.layer.texture != null && (_this2._backgroundImg.layer.texture.updateURL(n), _this2._backgroundImg.layer.name = "tex_background_" + Date.now(), _this2._backgroundImg.url = e), t(!0);
  11438. }).catch(function (n) {
  11439. logger$1.error("[Engine] set background image Error: ".concat(n)), r("[Engine] set background image Error: ".concat(n));
  11440. });
  11441. });
  11442. }
  11443. }, {
  11444. key: "cleanTheWholeScene",
  11445. value: function cleanTheWholeScene() {
  11446. var _this3 = this;
  11447. var e = this.scene.getFrameId();
  11448. this.scene.onBeforeRenderObservable.clear(), this.scene.onAfterRenderObservable.clear(), this.scene.clearCachedVertexData(), this.scene.cleanCachedTextureBuffer(), this.scene.registerBeforeRender(function () {
  11449. _this3.scene.getFrameId() - e > 5 && _this3.scene.dispose();
  11450. });
  11451. }
  11452. }, {
  11453. key: "getAreaAvatar",
  11454. value: function getAreaAvatar(e, t) {
  11455. var r = [];
  11456. return this._avatarManager.getAvatarList().forEach(function (n) {
  11457. var o = e,
  11458. a = n.position;
  11459. a && o && calcDistance3D(o, a) < t && r.push(n.id);
  11460. }), r;
  11461. }
  11462. }, {
  11463. key: "setEngineSize",
  11464. value: function setEngineSize(e) {
  11465. var t = e.width,
  11466. r = e.height,
  11467. n = this.canvas.width;
  11468. this.canvas.height, this.engine.setSize(Math.round(n), Math.round(n * (r / t)));
  11469. }
  11470. }, {
  11471. key: "getCurrentShaderMode",
  11472. value: function getCurrentShaderMode() {
  11473. return this._currentShader === this._materialManager.getDefaultShader() ? 0 : this._currentShader === this._materialManager.getPureVideoShader() ? 1 : 2;
  11474. }
  11475. }, {
  11476. key: "addSkyTV",
  11477. value: function addSkyTV(e, t) {
  11478. return this._skytv = new XTelevision(this.scene, e, this, t), this._skytv;
  11479. }
  11480. }, {
  11481. key: "addMv",
  11482. value: function addMv(e, t) {
  11483. this._mv.push(new XTelevision(this.scene, e, this, t));
  11484. }
  11485. }, {
  11486. key: "addMeshInfo",
  11487. value: function addMeshInfo(e) {
  11488. this._lowpolyManager.setMeshInfo(e);
  11489. }
  11490. }, {
  11491. key: "applyShader",
  11492. value: function applyShader() {
  11493. var _this4 = this;
  11494. return new Promise(function (e, t) {
  11495. _this4.shaderMode == EShaderMode.videoAndPano || _this4.shaderMode == EShaderMode.video ? _this4.changeVideoShaderForLowModel() : _this4.shaderMode == EShaderMode.default && _this4.changeDefaultShaderForLowModel(), e(!0);
  11496. });
  11497. }
  11498. }, {
  11499. key: "changeHardwareScaling",
  11500. value: function changeHardwareScaling(e) {
  11501. e < 1 ? e = 1 : e > 2.5 && (e = 2.5), this._bChangeEngineSize = !0, this.engine.setHardwareScalingLevel(this._initEngineScaleNumber * e);
  11502. }
  11503. }, {
  11504. key: "getCurrentUsedPanoId",
  11505. value: function getCurrentUsedPanoId() {
  11506. return this._currentPanoId;
  11507. }
  11508. }, {
  11509. key: "render",
  11510. value: function render() {
  11511. try {
  11512. this.scene.render();
  11513. } catch (e) {
  11514. throw logger$1.error("[Engine] Render Error: ".concat(e)), e;
  11515. }
  11516. }
  11517. }, {
  11518. key: "isReadyToRender",
  11519. value: function isReadyToRender(e) {
  11520. var _e$checkMesh = e.checkMesh,
  11521. t = _e$checkMesh === void 0 ? !0 : _e$checkMesh,
  11522. _e$checkEffect = e.checkEffect,
  11523. r = _e$checkEffect === void 0 ? !1 : _e$checkEffect,
  11524. _e$checkPostProgress = e.checkPostProgress,
  11525. n = _e$checkPostProgress === void 0 ? !1 : _e$checkPostProgress,
  11526. _e$checkParticle = e.checkParticle,
  11527. o = _e$checkParticle === void 0 ? !1 : _e$checkParticle,
  11528. _e$checkAnimation = e.checkAnimation,
  11529. a = _e$checkAnimation === void 0 ? !1 : _e$checkAnimation;
  11530. e.materialNameWhiteLists;
  11531. if (this.scene._isDisposed) return logger$1.error("[Engine] this.scene._isDisposed== false "), !1;
  11532. var l;
  11533. var u = this.scene.getEngine();
  11534. if (r && !u.areAllEffectsReady()) return logger$1.error("[Engine] engine.areAllEffectsReady == false"), !1;
  11535. if (a && this.scene._pendingData.length > 0) return logger$1.error("[Engine] scene._pendingData.length > 0 && animation error"), !1;
  11536. if (t) {
  11537. for (l = 0; l < this.scene.meshes.length; l++) {
  11538. var c = this.scene.meshes[l];
  11539. if (!c.isEnabled() || !c.subMeshes || c.subMeshes.length === 0 || c != null && c.material != null && !(c.material.name.startsWith("Pure") || c.material.name.startsWith("Pano"))) continue;
  11540. if (!c.isReady(!0)) return logger$1.error("[Engine] scene. mesh isReady == false, mesh name:".concat(c.name, ", mesh xtype: ").concat(c == null ? void 0 : c.xtype, ", mesh xgroup: ").concat(c == null ? void 0 : c.xgroup, ", mesh xskinInfo: ").concat(c == null ? void 0 : c.xskinInfo)), !1;
  11541. var h = c.hasThinInstances || c.getClassName() === "InstancedMesh" || c.getClassName() === "InstancedLinesMesh" || u.getCaps().instancedArrays && c.instances.length > 0;
  11542. var _iterator = _createForOfIteratorHelper(this.scene._isReadyForMeshStage),
  11543. _step;
  11544. try {
  11545. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  11546. var f = _step.value;
  11547. if (!f.action(c, h)) return logger$1.error("[Engine] scene._isReadyForMeshStage == false, mesh name:".concat(c.name, ", mesh xtype: ").concat(c == null ? void 0 : c.xtype, ", mesh xgroup: ").concat(c == null ? void 0 : c.xgroup, ", mesh xskinInfo: ").concat(c == null ? void 0 : c.xskinInfo)), !1;
  11548. }
  11549. } catch (err) {
  11550. _iterator.e(err);
  11551. } finally {
  11552. _iterator.f();
  11553. }
  11554. }
  11555. for (l = 0; l < this.scene.geometries.length; l++) {
  11556. if (this.scene.geometries[l].delayLoadState === 2) return logger$1.error("[Engine] geometry.delayLoadState === 2"), !1;
  11557. }
  11558. }
  11559. if (n) {
  11560. if (this.scene.activeCameras && this.scene.activeCameras.length > 0) {
  11561. var _iterator2 = _createForOfIteratorHelper(this.scene.activeCameras),
  11562. _step2;
  11563. try {
  11564. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  11565. var _c = _step2.value;
  11566. if (!_c.isReady(!0)) return logger$1.error("[Engine] camera not ready === false, ", _c.name), !1;
  11567. }
  11568. } catch (err) {
  11569. _iterator2.e(err);
  11570. } finally {
  11571. _iterator2.f();
  11572. }
  11573. } else if (this.scene.activeCamera && !this.scene.activeCamera.isReady(!0)) return logger$1.error("[Engine] activeCamera ready === false, ", this.scene.activeCamera.name), !1;
  11574. }
  11575. if (o) {
  11576. var _iterator3 = _createForOfIteratorHelper(this.scene.particleSystems),
  11577. _step3;
  11578. try {
  11579. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  11580. var _c2 = _step3.value;
  11581. if (!_c2.isReady()) return logger$1.error("[Engine] particleSystem ready === false, ", _c2.name), !1;
  11582. }
  11583. } catch (err) {
  11584. _iterator3.e(err);
  11585. } finally {
  11586. _iterator3.f();
  11587. }
  11588. }
  11589. return !0;
  11590. }
  11591. }, {
  11592. key: "changePanoShaderForLowModel",
  11593. value: function changePanoShaderForLowModel(e) {
  11594. var _this5 = this;
  11595. return logger$1.info("[Engine] changePanoShaderForLowModel: ".concat(e)), this._materialManager.allowYUVUpdate(), new Promise(function (t, r) {
  11596. _this5._materialManager._isInDynamicRange(e) == !1 && r(!1), _this5._currentPanoId = e, _this5._currentShader = _this5._materialManager.getDynamicShader(e), _this5.changeShaderForLowModel().then(function () {
  11597. t(!0);
  11598. });
  11599. });
  11600. }
  11601. }, {
  11602. key: "changeVideoShaderForLowModel",
  11603. value: function changeVideoShaderForLowModel() {
  11604. return logger$1.info("[Engine] changeVideoShaderForLowModel"), this._currentShader = this._materialManager.getPureVideoShader(), this._materialManager.allowYUVUpdate(), this.changeShaderForLowModel();
  11605. }
  11606. }, {
  11607. key: "changeDefaultShaderForLowModel",
  11608. value: function changeDefaultShaderForLowModel() {
  11609. return logger$1.info("[Engine] changeDefaultShaderForLowModel"), this._currentShader = this._materialManager.getDefaultShader(), this._materialManager.stopYUVUpdate(), this.changeShaderForLowModel();
  11610. }
  11611. }, {
  11612. key: "changeShaderForLowModel",
  11613. value: function changeShaderForLowModel() {
  11614. var _this6 = this;
  11615. return new Promise(function (e, t) {
  11616. _this6._lowpolyManager.getMeshes().forEach(function (r) {
  11617. r.setMaterial(_this6._currentShader);
  11618. }), _this6._lowpolyManager.getCgMesh().mesh.material = _this6._currentShader, e(!0);
  11619. });
  11620. }
  11621. }, {
  11622. key: "setIBL",
  11623. value: function setIBL(e) {
  11624. this._lightManager.setIBL(e);
  11625. }
  11626. }, {
  11627. key: "postprocessing",
  11628. value: function postprocessing() {
  11629. var e = new BABYLON.DefaultRenderingPipeline("default", !0, this.scene);
  11630. e.imageProcessingEnabled = !1, e.bloomEnabled = !0, e.bloomThreshold = 1, e.bloomWeight = 1, e.bloomKernel = 64, e.bloomScale = .1;
  11631. }
  11632. }, {
  11633. key: "getGround",
  11634. value: function getGround(e) {
  11635. var t = this._lowpolyManager.getMeshes(),
  11636. r = [];
  11637. return t.forEach(function (n) {
  11638. n.mesh.name.indexOf("SM_Stage") >= 0 && r.push(n.mesh);
  11639. }), this.Scene.meshes.forEach(function (n) {
  11640. n.name.split("_")[0] === "ground" && r.push(n);
  11641. }), r;
  11642. }
  11643. }]);
  11644. return XSceneManager;
  11645. }();
  11646. var http = new Http();
  11647. var urlMap = new Map(),
  11648. urlTransformer = /*#__PURE__*/function () {
  11649. var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(i) {
  11650. var e,
  11651. _args2 = arguments;
  11652. return regenerator.wrap(function _callee2$(_context2) {
  11653. while (1) {
  11654. switch (_context2.prev = _context2.next) {
  11655. case 0:
  11656. e = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : !1;
  11657. return _context2.abrupt("return", typeof i != "string" ? (console.warn("url transformer error", i), i) : i.startsWith("blob:") ? i : e ? http.get({
  11658. url: i,
  11659. useIndexedDb: !0,
  11660. key: "url",
  11661. isOutPutObjectURL: !1
  11662. }) : urlMap.has(i) ? urlMap.get(i) : http.get({
  11663. url: i,
  11664. useIndexedDb: !0,
  11665. key: "url"
  11666. }).then(function (t) {
  11667. return urlMap.set(i, t), t;
  11668. }));
  11669. case 2:
  11670. case "end":
  11671. return _context2.stop();
  11672. }
  11673. }
  11674. }, _callee2);
  11675. }));
  11676. return function urlTransformer(_x2) {
  11677. return _ref2.apply(this, arguments);
  11678. };
  11679. }();
  11680. var sceneManager;
  11681. function getSceneManager(i, e) {
  11682. return sceneManager || (sceneManager = new XSceneManager(i, e)), sceneManager;
  11683. }
  11684. var EngineProxy = /*#__PURE__*/function () {
  11685. function EngineProxy(e) {
  11686. var _this = this;
  11687. _classCallCheck(this, EngineProxy);
  11688. E(this, "_tvs", []);
  11689. E(this, "isRenderFirstFrame", !1);
  11690. E(this, "_idleTime", 0);
  11691. E(this, "renderTimer");
  11692. E(this, "lightManager");
  11693. E(this, "_checkSceneNotReadyCount", 0);
  11694. E(this, "_checkSceneDurationFrameNum", 0);
  11695. E(this, "_checkSceneFrameCount", 0);
  11696. E(this, "timeoutCircularArray", new CircularArray(120, !1, []));
  11697. E(this, "frameCircularArray", new CircularArray(120, !1, []));
  11698. E(this, "interFrameCircularArray", new CircularArray(120, !1, []));
  11699. E(this, "drawCallCntCircularArray", new CircularArray(120, !1, []));
  11700. E(this, "activeFacesCircularArray", new CircularArray(120, !1, []));
  11701. E(this, "renderTimeCircularArray", new CircularArray(120, !1, []));
  11702. E(this, "drawCallTimeCircularArray", new CircularArray(120, !1, []));
  11703. E(this, "animationCircularArray", new CircularArray(120, !1, []));
  11704. E(this, "meshSelectCircularArray", new CircularArray(120, !1, []));
  11705. E(this, "renderTargetCircularArray", new CircularArray(120, !1, []));
  11706. E(this, "regBeforeRenderCircularArray", new CircularArray(120, !1, []));
  11707. E(this, "regAfterRenderCircularArray", new CircularArray(120, !1, []));
  11708. E(this, "renderCnt", 0);
  11709. E(this, "renderErrorCount", 0);
  11710. E(this, "engineSloppyCnt", 0);
  11711. E(this, "systemStuckCnt", 0);
  11712. E(this, "frameRenderNumber", 0);
  11713. E(this, "_setFPS", function (e) {
  11714. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 25;
  11715. logger$1.info("Set fps to", t);
  11716. var r = t > 60 ? 60 : t < 24 ? 24 : t;
  11717. e.Engine.stopRenderLoop();
  11718. var n = 1e3 / r;
  11719. var o = Date.now(),
  11720. a = Date.now(),
  11721. s = n,
  11722. l = 1;
  11723. var u = function u() {
  11724. var T;
  11725. var c = Date.now(),
  11726. h = c - o,
  11727. f = c - a;
  11728. a = c, _this.frameCircularArray.add(f), h - s > n && (_this.systemStuckCnt += 1);
  11729. var d = h / s;
  11730. l = .9 * l + .1 * d;
  11731. var _ = Date.now();
  11732. var g = 0,
  11733. m = 0;
  11734. if (_this.room.isUpdatedRawYUVData || _this.room.isPano) {
  11735. if (_this.isRenderFirstFrame = !0, _this._checkSceneDurationFrameNum > 0) _this._checkSceneFrameCount++, _this.room.sceneManager.isReadyToRender({}) && _this._checkSceneDurationFrameNum--, _this._checkSceneFrameCount > EngineProxy._CHECK_DURATION && (_this._checkSceneDurationFrameNum = EngineProxy._CHECK_DURATION, _this._checkSceneFrameCount = 0, _this._checkSceneNotReadyCount++, (_this._checkSceneNotReadyCount == 1 || _this._checkSceneNotReadyCount % 100 == 0) && logger$1.error("[SDK] Scene not ready, skip render. loop: ".concat(_this._checkSceneNotReadyCount)), _this._checkSceneNotReadyCount > 10 && (logger$1.error("[SDK] Scene not ready, reload later"), _this.room.proxyEvents("renderError", {
  11736. error: new Error("[SDK] Scene not ready, skip render and reload.")
  11737. })), _this.room.stats.assign({
  11738. renderErrorCount: _this._checkSceneNotReadyCount
  11739. }), logger$1.infoAndReportMeasurement({
  11740. value: 0,
  11741. startTime: Date.now(),
  11742. metric: "renderError",
  11743. error: new Error("[SDK] Scene not ready, skip render and reload."),
  11744. reportOptions: {
  11745. sampleRate: .1
  11746. }
  11747. }));else try {
  11748. e.render();
  11749. } catch (C) {
  11750. _this.renderErrorCount++, _this.renderErrorCount > 10 && _this.room.proxyEvents("renderError", {
  11751. error: C
  11752. }), _this.room.stats.assign({
  11753. renderErrorCount: _this.renderErrorCount
  11754. }), logger$1.infoAndReportMeasurement({
  11755. value: 0,
  11756. startTime: Date.now(),
  11757. metric: "renderError",
  11758. error: C,
  11759. reportOptions: {
  11760. sampleRate: .1
  11761. }
  11762. });
  11763. }
  11764. g = Date.now() - _, _this.frameRenderNumber < 1e3 && _this.frameRenderNumber++, _this.room.networkController.rtcp.workers.UpdateYUV(), m = Date.now() - _ - g;
  11765. }
  11766. _this.isRenderFirstFrame || _this.room.networkController.rtcp.workers.UpdateYUV();
  11767. var y = Date.now() - _;
  11768. o = c + y, s = Math.min(Math.max((n - y) / l, 5), 200), y > n && (s = 10, _this.engineSloppyCnt += 1), _this._idleTime = s;
  11769. var b = s;
  11770. if (s > 150 && console.log("lastGap is ", s, ", ratio is ", l, ", usedTimeMs is ", y, ", cpuRenderTime is ", g, ", cpuUpdateYUVTime is ", m), _this.timeoutCircularArray.add(b), _this.renderCnt % 25 == 0) {
  11771. var C = _this.frameCircularArray.getAvg(),
  11772. A = _this.timeoutCircularArray.getAvg(),
  11773. S = _this.frameCircularArray.getMax(),
  11774. P = _this.timeoutCircularArray.getMax();
  11775. (T = _this.room.stats) == null || T.assign({
  11776. avgFrameTime: C,
  11777. avgTimeoutTime: A,
  11778. maxFrameTime: S,
  11779. maxTimeoutTime: P,
  11780. systemStuckCnt: _this.systemStuckCnt
  11781. });
  11782. }
  11783. _this.renderTimer = window.setTimeout(u, s);
  11784. };
  11785. _this.renderTimer = window.setTimeout(u, n / l);
  11786. });
  11787. E(this, "updateStats", function () {
  11788. var e;
  11789. (e = _this.room.stats) == null || e.assign({
  11790. renderFrameTime: _this.renderTimeCircularArray.getAvg(),
  11791. maxRenderFrameTime: _this.renderTimeCircularArray.getMax(),
  11792. interFrameTime: _this.interFrameCircularArray.getAvg(),
  11793. animationTime: _this.animationCircularArray.getAvg(),
  11794. meshSelectTime: _this.meshSelectCircularArray.getAvg(),
  11795. drawcallTime: _this.drawCallTimeCircularArray.getAvg(),
  11796. idleTime: _this._idleTime,
  11797. registerBeforeRenderTime: _this.regBeforeRenderCircularArray.getAvg(),
  11798. registerAfterRenderTime: _this.regAfterRenderCircularArray.getAvg(),
  11799. renderTargetRenderTime: _this.renderTargetCircularArray.getAvg(),
  11800. fps: (1e3 / (_this.renderTimeCircularArray.getAvg() + _this.interFrameCircularArray.getAvg())).toFixed(2),
  11801. drawcall: _this.drawCallCntCircularArray.getAvg(),
  11802. engineSloppyCnt: _this.engineSloppyCnt,
  11803. maxInterFrameTime: _this.interFrameCircularArray.getMax(),
  11804. maxDrawcallTime: _this.drawCallTimeCircularArray.getMax(),
  11805. maxMeshSelectTime: _this.meshSelectCircularArray.getMax(),
  11806. maxAnimationTime: _this.animationCircularArray.getMax(),
  11807. maxRegisterBeforeRenderTime: _this.regBeforeRenderCircularArray.getMax(),
  11808. maxRegisterAfterRenderTime: _this.regAfterRenderCircularArray.getMax(),
  11809. maxRenderTargetRenderTime: _this.renderTargetCircularArray.getMax(),
  11810. avgFrameTime: _this.frameCircularArray.getAvg(),
  11811. avgTimeoutTime: _this.timeoutCircularArray.getAvg(),
  11812. maxFrameTime: _this.frameCircularArray.getMax(),
  11813. maxTimeoutTime: _this.timeoutCircularArray.getMax()
  11814. });
  11815. });
  11816. this.room = e;
  11817. }
  11818. _createClass(EngineProxy, [{
  11819. key: "initEngine",
  11820. value: function () {
  11821. var _initEngine = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e) {
  11822. var t, r, n, o, a;
  11823. return regenerator.wrap(function _callee3$(_context3) {
  11824. while (1) {
  11825. switch (_context3.prev = _context3.next) {
  11826. case 0:
  11827. _context3.next = 2;
  11828. return this.updateBillboard();
  11829. case 2:
  11830. logger$1.info("engine version:", VERSION$1);
  11831. t = logger$1;
  11832. t.setLevel(LoggerLevels$1.Warn);
  11833. r = {
  11834. videoResOriArray: [{
  11835. width: 720,
  11836. height: 1280
  11837. }, {
  11838. width: 1280,
  11839. height: 720
  11840. }, {
  11841. width: 480,
  11842. height: 654
  11843. }, {
  11844. width: 654,
  11845. height: 480
  11846. }, {
  11847. width: 1920,
  11848. height: 1080
  11849. }, {
  11850. width: 1080,
  11851. height: 1920
  11852. }, {
  11853. width: 414,
  11854. height: 896
  11855. }],
  11856. forceKeepVertical: this.room.options.objectFit !== "cover",
  11857. panoInfo: {
  11858. dynamicRange: 1,
  11859. width: 4096,
  11860. height: 2048
  11861. },
  11862. shaderMode: EShaderMode.videoAndPano,
  11863. yuvInfo: {
  11864. width: 1280,
  11865. height: 720,
  11866. fov: e.fov || DEFAULT_MAIN_CAMERA_FOV
  11867. },
  11868. cameraParam: {
  11869. maxZ: 1e4
  11870. },
  11871. urlTransformer,
  11872. logger: t,
  11873. disableWebGL2: this.room.options.disableWebGL2 || !1
  11874. }, n = this.room.options.resolution;
  11875. n && (r.videoResOriArray.some(function (l) {
  11876. return l.width === n.width && l.height === n.height;
  11877. }) || r.videoResOriArray.push(n));
  11878. o = this.room.sceneManager = getSceneManager(this.room.canvas, r);
  11879. this.room.setPictureQualityLevel(this.room.options.pictureQualityLevel || "high");
  11880. this.room.sceneManager.staticmeshComponent.setRegionLodRule([2, 2, -1, -1, -1]);
  11881. this.room.scene = o.Scene;
  11882. this.room.breathPointManager = o.breathPointComponent;
  11883. this.lightManager = o.lightComponent;
  11884. this.registerStats();
  11885. this.setEnv(e);
  11886. _context3.next = 17;
  11887. return this.room.avatarManager.init();
  11888. case 17:
  11889. a = this._createAssetList(e);
  11890. _context3.next = 20;
  11891. return this.loadAssets(a, "");
  11892. case 20:
  11893. this._setFPS(o);
  11894. case 21:
  11895. case "end":
  11896. return _context3.stop();
  11897. }
  11898. }
  11899. }, _callee3, this);
  11900. }));
  11901. function initEngine(_x3) {
  11902. return _initEngine.apply(this, arguments);
  11903. }
  11904. return initEngine;
  11905. }()
  11906. }, {
  11907. key: "pause",
  11908. value: function pause() {
  11909. clearTimeout(this.renderTimer), logger$1.info("Invoke room.pause to pause render");
  11910. var e = {
  11911. roomId: this.room.id,
  11912. effects: [],
  11913. lowPolyModels: [],
  11914. breathPointsConfig: [],
  11915. skinId: this.room.skinId
  11916. };
  11917. return this.loadAssets(e, this.room.skinId);
  11918. }
  11919. }, {
  11920. key: "resume",
  11921. value: function () {
  11922. var _resume = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4() {
  11923. var e;
  11924. return regenerator.wrap(function _callee4$(_context4) {
  11925. while (1) {
  11926. switch (_context4.prev = _context4.next) {
  11927. case 0:
  11928. this._setFPS(this.room.sceneManager), this.room.sceneManager.cameraComponent.cameraFovChange(this.room.sceneManager.yuvInfo), logger$1.info("Invoke room.resume to render");
  11929. e = this._createAssetList(this.room.skin);
  11930. _context4.next = 4;
  11931. return this.loadAssets(e, "");
  11932. case 4:
  11933. case "end":
  11934. return _context4.stop();
  11935. }
  11936. }
  11937. }, _callee4, this);
  11938. }));
  11939. function resume() {
  11940. return _resume.apply(this, arguments);
  11941. }
  11942. return resume;
  11943. }()
  11944. }, {
  11945. key: "setEnv",
  11946. value: function setEnv(e) {
  11947. var r;
  11948. this.lightManager || (this.lightManager = this.room.sceneManager.lightComponent), e = e || this.room.skin;
  11949. var t = ModelManager.findModel(e.models, AssetTypeName.Config, AssetClassName.Env);
  11950. return t ? (r = this.lightManager) == null ? void 0 : r.setIBL(t.modelUrl) : (logger$1.error("env file not found"), Promise.resolve());
  11951. }
  11952. }, {
  11953. key: "_parseModelsAndLoad",
  11954. value: function () {
  11955. var _parseModelsAndLoad2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(e, t, r) {
  11956. var n, o, a, u, c, h, _c, s, l, _u, _c2, _h;
  11957. return regenerator.wrap(function _callee5$(_context5) {
  11958. while (1) {
  11959. switch (_context5.prev = _context5.next) {
  11960. case 0:
  11961. logger$1.info("Invoke _parseModelsAndLoad start", t);
  11962. n = ["airship", "balloon", "default", "ground_feiting", "ground_reqiqiu"], o = new Map();
  11963. r == null && (r = "xxxx");
  11964. a = !0;
  11965. u = 0;
  11966. case 5:
  11967. if (!(u < e.length)) {
  11968. _context5.next = 20;
  11969. break;
  11970. }
  11971. a = !0;
  11972. c = 0;
  11973. case 8:
  11974. if (!(c < n.length)) {
  11975. _context5.next = 16;
  11976. break;
  11977. }
  11978. if (!(e[u].modelUrl.toLowerCase().indexOf(n[c]) >= 0)) {
  11979. _context5.next = 13;
  11980. break;
  11981. }
  11982. h = o.get(n[c]);
  11983. h ? (h.push(e[u]), o.set(n[c], h)) : o.set(n[c], [e[u]]), a = !1;
  11984. return _context5.abrupt("break", 16);
  11985. case 13:
  11986. ++c;
  11987. _context5.next = 8;
  11988. break;
  11989. case 16:
  11990. if (a) {
  11991. _c = o.get("default");
  11992. _c ? (_c.push(e[u]), o.set("default", _c)) : o.set("default", [e[u]]);
  11993. }
  11994. case 17:
  11995. ++u;
  11996. _context5.next = 5;
  11997. break;
  11998. case 20:
  11999. s = o.get(t) || [];
  12000. if (!(this.room.viewMode === "simple" && (s = s.filter(function (u) {
  12001. return !u.modelUrl.endsWith("zip");
  12002. })), !s)) {
  12003. _context5.next = 23;
  12004. break;
  12005. }
  12006. return _context5.abrupt("return", Promise.reject("no invalid scene model with group name: ".concat(t)));
  12007. case 23:
  12008. l = [];
  12009. for (_u = 0; _u < s.length; ++_u) {
  12010. _c2 = s[_u];
  12011. if (_c2.modelUrl.toLowerCase().endsWith("zip")) _c2.modelUrl.toLowerCase().endsWith("zip") && l.push(this.room.sceneManager.addNewLowPolyMesh({
  12012. url: _c2.modelUrl,
  12013. skinInfo: r
  12014. }));else {
  12015. _h = t;
  12016. l.push(this.room.sceneManager.addNewLowPolyMesh({
  12017. url: _c2.modelUrl,
  12018. group: _h,
  12019. pick: !0,
  12020. skinInfo: r
  12021. }));
  12022. }
  12023. }
  12024. return _context5.abrupt("return", Promise.all(l));
  12025. case 26:
  12026. case "end":
  12027. return _context5.stop();
  12028. }
  12029. }
  12030. }, _callee5, this);
  12031. }));
  12032. function _parseModelsAndLoad(_x4, _x5, _x6) {
  12033. return _parseModelsAndLoad2.apply(this, arguments);
  12034. }
  12035. return _parseModelsAndLoad;
  12036. }()
  12037. }, {
  12038. key: "_deleteAssetsLowpolyModel",
  12039. value: function () {
  12040. var _deleteAssetsLowpolyModel2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6(e) {
  12041. var t;
  12042. return regenerator.wrap(function _callee6$(_context6) {
  12043. while (1) {
  12044. switch (_context6.prev = _context6.next) {
  12045. case 0:
  12046. this.room.sceneManager.staticmeshComponent.deleteMeshesBySkinInfo(e), this.room.sceneManager.breathPointComponent.clearBreathPointsBySkinInfo(e), this.room.sceneManager.decalComponent.deleteDecalBySkinInfo(e);
  12047. t = [];
  12048. this.room.sceneManager.Scene.meshes.forEach(function (r) {
  12049. r.xskinInfo == e && t.push(r);
  12050. }), t.forEach(function (r) {
  12051. r.dispose(!1, !1);
  12052. });
  12053. case 3:
  12054. case "end":
  12055. return _context6.stop();
  12056. }
  12057. }
  12058. }, _callee6, this);
  12059. }));
  12060. function _deleteAssetsLowpolyModel(_x7) {
  12061. return _deleteAssetsLowpolyModel2.apply(this, arguments);
  12062. }
  12063. return _deleteAssetsLowpolyModel;
  12064. }()
  12065. }, {
  12066. key: "loadLandAssets",
  12067. value: function () {
  12068. var _loadLandAssets = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee7() {
  12069. var _this2 = this;
  12070. var e;
  12071. return regenerator.wrap(function _callee7$(_context7) {
  12072. while (1) {
  12073. switch (_context7.prev = _context7.next) {
  12074. case 0:
  12075. e = this._createAssetList(this.room.skin);
  12076. return _context7.abrupt("return", this.loadAssets(e, this.room.skinId).catch(function () {
  12077. return _this2.loadAssets(e, _this2.room.skinId);
  12078. }));
  12079. case 2:
  12080. case "end":
  12081. return _context7.stop();
  12082. }
  12083. }
  12084. }, _callee7, this);
  12085. }));
  12086. function loadLandAssets() {
  12087. return _loadLandAssets.apply(this, arguments);
  12088. }
  12089. return loadLandAssets;
  12090. }()
  12091. }, {
  12092. key: "loadAssets",
  12093. value: function () {
  12094. var _loadAssets2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee8(e) {
  12095. var t,
  12096. r,
  12097. n,
  12098. _args8 = arguments;
  12099. return regenerator.wrap(function _callee8$(_context8) {
  12100. while (1) {
  12101. switch (_context8.prev = _context8.next) {
  12102. case 0:
  12103. t = _args8.length > 1 && _args8[1] !== undefined ? _args8[1] : "";
  12104. r = _args8.length > 2 && _args8[2] !== undefined ? _args8[2] : 8e3;
  12105. n = Date.now();
  12106. return _context8.abrupt("return", this._loadAssets(e, t)._timeout(r, new InitEngineTimeoutError("loadAssets timeout(".concat(r, "ms)"))).then(function (o) {
  12107. return logger$1.infoAndReportMeasurement({
  12108. tag: "loadAssets",
  12109. startTime: n,
  12110. metric: "loadAssets"
  12111. }), o;
  12112. }).catch(function (o) {
  12113. return logger$1.infoAndReportMeasurement({
  12114. tag: "loadAssets",
  12115. startTime: n,
  12116. metric: "loadAssets",
  12117. error: o
  12118. }), Promise.reject(o);
  12119. }));
  12120. case 4:
  12121. case "end":
  12122. return _context8.stop();
  12123. }
  12124. }
  12125. }, _callee8, this);
  12126. }));
  12127. function loadAssets(_x8) {
  12128. return _loadAssets2.apply(this, arguments);
  12129. }
  12130. return loadAssets;
  12131. }()
  12132. }, {
  12133. key: "_loadAssets",
  12134. value: function () {
  12135. var _loadAssets3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee9(e) {
  12136. var t,
  12137. r,
  12138. _args9 = arguments;
  12139. return regenerator.wrap(function _callee9$(_context9) {
  12140. while (1) {
  12141. switch (_context9.prev = _context9.next) {
  12142. case 0:
  12143. t = _args9.length > 1 && _args9[1] !== undefined ? _args9[1] : "";
  12144. _context9.prev = 1;
  12145. r = [];
  12146. r.push(this._loadAssetsLowpolyModel(e, t));
  12147. _context9.next = 6;
  12148. return Promise.all(r);
  12149. case 6:
  12150. _context9.next = 8;
  12151. return this.setEnv();
  12152. case 8:
  12153. this._checkSceneDurationFrameNum = EngineProxy._CHECK_DURATION;
  12154. this._checkSceneNotReadyCount = 0;
  12155. this._checkSceneFrameCount = 0;
  12156. this.updateAnimationList();
  12157. this.room.loadAssetsHook();
  12158. _context9.next = 18;
  12159. break;
  12160. case 15:
  12161. _context9.prev = 15;
  12162. _context9.t0 = _context9["catch"](1);
  12163. return _context9.abrupt("return", Promise.reject(_context9.t0));
  12164. case 18:
  12165. case "end":
  12166. return _context9.stop();
  12167. }
  12168. }
  12169. }, _callee9, this, [[1, 15]]);
  12170. }));
  12171. function _loadAssets(_x9) {
  12172. return _loadAssets3.apply(this, arguments);
  12173. }
  12174. return _loadAssets;
  12175. }()
  12176. }, {
  12177. key: "updateAnimationList",
  12178. value: function updateAnimationList() {
  12179. var _this3 = this;
  12180. if (this.room.avatarManager && this.room.avatarManager.xAvatarManager) {
  12181. var e = this.room.skin.animationList;
  12182. if (!e) return;
  12183. e.forEach(function (t) {
  12184. _this3.room.avatarManager.xAvatarManager.updateAnimationLists(t.animations, t.avatarId);
  12185. });
  12186. }
  12187. }
  12188. }, {
  12189. key: "_loadAssetsLowpolyModel",
  12190. value: function () {
  12191. var _loadAssetsLowpolyModel2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee11(e) {
  12192. var _this4 = this;
  12193. var t,
  12194. r,
  12195. n,
  12196. o,
  12197. a,
  12198. s,
  12199. u,
  12200. c,
  12201. h,
  12202. _args11 = arguments;
  12203. return regenerator.wrap(function _callee11$(_context11) {
  12204. while (1) {
  12205. switch (_context11.prev = _context11.next) {
  12206. case 0:
  12207. t = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : "";
  12208. r = [], n = [], o = [];
  12209. e.lowPolyModels.forEach(function (f) {
  12210. f.group === "TV" ? n.push({
  12211. id: "",
  12212. name: "",
  12213. thumbnailUrl: "",
  12214. typeName: AssetTypeName.Model,
  12215. className: AssetClassName.Tv,
  12216. modelUrl: f.url
  12217. }) : f.group === "\u544A\u767D\u5899" ? o.push({
  12218. id: "",
  12219. name: "",
  12220. thumbnailUrl: "",
  12221. typeName: AssetTypeName.Model,
  12222. className: AssetClassName.Lpm,
  12223. modelUrl: f.url
  12224. }) : r.push({
  12225. id: "",
  12226. name: "",
  12227. thumbnailUrl: "",
  12228. typeName: AssetTypeName.Model,
  12229. className: AssetClassName.Lpm,
  12230. modelUrl: f.url
  12231. });
  12232. }), t != "" && t != null && this._deleteAssetsLowpolyModel(t);
  12233. a = e.skinId;
  12234. logger$1.info("====> from ", t, " to ", a), this._tvs.forEach(function (f) {
  12235. return f.clean();
  12236. }), this._tvs = [];
  12237. s = EFitMode.cover;
  12238. a == "10048" && (s = EFitMode.contain), Array.isArray(n) && n.forEach(function (f, d) {
  12239. _this4._tvs.push(new TV("squareTv" + d, f.modelUrl, _this4.room, {
  12240. fitMode: s
  12241. }));
  12242. }), e.breathPointsConfig.forEach( /*#__PURE__*/function () {
  12243. var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee10(f) {
  12244. var d;
  12245. return regenerator.wrap(function _callee10$(_context10) {
  12246. while (1) {
  12247. switch (_context10.prev = _context10.next) {
  12248. case 0:
  12249. _context10.prev = 0;
  12250. _context10.next = 3;
  12251. return urlTransformer(f.imageUrl);
  12252. case 3:
  12253. d = _context10.sent;
  12254. _context10.next = 9;
  12255. break;
  12256. case 6:
  12257. _context10.prev = 6;
  12258. _context10.t0 = _context10["catch"](0);
  12259. d = f.imageUrl, logger$1.error("urlTransformer error", _context10.t0);
  12260. case 9:
  12261. _this4.room.breathPointManager.addBreathPoint({
  12262. id: f.id,
  12263. position: f.position,
  12264. spriteSheet: d,
  12265. rotation: f.rotation || {
  12266. pitch: 0,
  12267. yaw: 270,
  12268. roll: 0
  12269. },
  12270. billboardMode: !0,
  12271. type: f.type || "no_type",
  12272. spriteWidthNumber: f.spriteWidthNum || 1,
  12273. spriteHeightNumber: f.spriteHeightNum || 1,
  12274. maxVisibleRegion: f.maxVisibleRegion || 150,
  12275. width: f.width,
  12276. height: f.height,
  12277. skinInfo: f.skinId
  12278. });
  12279. case 10:
  12280. case "end":
  12281. return _context10.stop();
  12282. }
  12283. }
  12284. }, _callee10, null, [[0, 6]]);
  12285. }));
  12286. return function (_x11) {
  12287. return _ref3.apply(this, arguments);
  12288. };
  12289. }()), o.forEach(function (f) {
  12290. _this4.room.sceneManager.decalComponent.addDecal({
  12291. id: f.id || "gbq",
  12292. meshPath: f.modelUrl,
  12293. skinInfo: a
  12294. });
  12295. });
  12296. u = this.room.sceneManager.staticmeshComponent.lowModel_group, c = Array.from(u.keys()).filter(function (f) {
  12297. return !f.startsWith("region_");
  12298. }), h = ["airship", "balloon", "ground_feiting", "ground_reqiqiu", "default"];
  12299. return _context11.abrupt("return", new Promise(function (f, d) {
  12300. Promise.all(h.map(function (_) {
  12301. return _this4._parseModelsAndLoad(r, _, a);
  12302. })).then(function () {
  12303. var _ = !1;
  12304. r.forEach(function (v) {
  12305. v.modelUrl.endsWith("zip") && (_ = !0);
  12306. }), _ == !1 && _this4.room.sceneManager.staticmeshComponent.deleteLastRegionMesh(), _this4.room.sceneManager.staticmeshComponent.lowModel_group;
  12307. var g = Array.from(u.keys()).filter(function (v) {
  12308. return !v.startsWith("region_");
  12309. }),
  12310. m = c.filter(function (v) {
  12311. return g.indexOf(v) < 0;
  12312. });
  12313. m.length > 0 && m.forEach(function (v) {
  12314. _this4.room.sceneManager.staticmeshComponent.deleteMeshesByGroup(v);
  12315. }), f(!0);
  12316. }).catch(function (_) {
  12317. d(_);
  12318. });
  12319. }));
  12320. case 9:
  12321. case "end":
  12322. return _context11.stop();
  12323. }
  12324. }
  12325. }, _callee11, this);
  12326. }));
  12327. function _loadAssetsLowpolyModel(_x10) {
  12328. return _loadAssetsLowpolyModel2.apply(this, arguments);
  12329. }
  12330. return _loadAssetsLowpolyModel;
  12331. }()
  12332. }, {
  12333. key: "_updateSkinAssets",
  12334. value: function () {
  12335. var _updateSkinAssets2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee12(e) {
  12336. var t, r, n;
  12337. return regenerator.wrap(function _callee12$(_context12) {
  12338. while (1) {
  12339. switch (_context12.prev = _context12.next) {
  12340. case 0:
  12341. t = this.room.lastSkinId;
  12342. _context12.next = 3;
  12343. return this.room.getSkin(e);
  12344. case 3:
  12345. r = _context12.sent;
  12346. n = this._createAssetList(r);
  12347. _context12.prev = 5;
  12348. _context12.next = 8;
  12349. return this.loadAssets(n, t);
  12350. case 8:
  12351. this.room.updateCurrentState({
  12352. versionId: r.versionId,
  12353. skinId: r.id,
  12354. skin: r
  12355. });
  12356. _context12.next = 16;
  12357. break;
  12358. case 11:
  12359. _context12.prev = 11;
  12360. _context12.t0 = _context12["catch"](5);
  12361. _context12.next = 15;
  12362. return this.loadAssets(n, t);
  12363. case 15:
  12364. this.room.updateCurrentState({
  12365. versionId: r.versionId,
  12366. skinId: r.id,
  12367. skin: r
  12368. });
  12369. case 16:
  12370. this.setEnv(r);
  12371. case 17:
  12372. case "end":
  12373. return _context12.stop();
  12374. }
  12375. }
  12376. }, _callee12, this, [[5, 11]]);
  12377. }));
  12378. function _updateSkinAssets(_x12) {
  12379. return _updateSkinAssets2.apply(this, arguments);
  12380. }
  12381. return _updateSkinAssets;
  12382. }()
  12383. }, {
  12384. key: "_createAssetList",
  12385. value: function _createAssetList(e) {
  12386. var t = [],
  12387. r = [],
  12388. n = [];
  12389. var o = e.models;
  12390. var a = this.room.modelManager.config.preload;
  12391. return this.room.viewMode === "simple" ? a && (o = a.baseUrls.map(function (l) {
  12392. return l.modelUrl = l.url, l;
  12393. })) : this.room.viewMode, ModelManager.findModels(o, AssetTypeName.Effects, AssetClassName.Effects).forEach(function (l) {
  12394. t.push({
  12395. url: l.modelUrl,
  12396. group: l.className,
  12397. name: l.name
  12398. });
  12399. }), ModelManager.findModels(o, AssetTypeName.Model, AssetClassName.Lpm).forEach(function (l) {
  12400. r.push({
  12401. url: l.modelUrl,
  12402. group: l.className
  12403. });
  12404. }), ModelManager.findModels(o, AssetTypeName.Model, AssetClassName.Gbq).forEach(function (l) {
  12405. r.push({
  12406. url: l.modelUrl,
  12407. group: l.className
  12408. });
  12409. }), ModelManager.findModels(o, AssetTypeName.Model, AssetClassName.Tv).forEach(function (l) {
  12410. r.push({
  12411. url: l.modelUrl,
  12412. group: l.className
  12413. });
  12414. }), [].forEach(function (l) {
  12415. l.skinId == e.id && n.push(l);
  12416. }), {
  12417. roomId: this.room.id,
  12418. effects: t,
  12419. lowPolyModels: r,
  12420. breathPointsConfig: n,
  12421. skinId: e.id
  12422. };
  12423. }
  12424. }, {
  12425. key: "registerStats",
  12426. value: function registerStats() {
  12427. var _this5 = this;
  12428. var e = this.room.sceneManager;
  12429. this.room.scene.registerAfterRender(function () {
  12430. var I;
  12431. var t = e.statisticComponent.getInterFrameTimeCounter(),
  12432. r = e.statisticComponent.getDrawCall(),
  12433. n = e.statisticComponent.getActiveFaces(),
  12434. o = e.statisticComponent.getFrameTimeCounter(),
  12435. a = e.statisticComponent.getDrawCallTime(),
  12436. s = e.statisticComponent.getAnimationTime(),
  12437. l = e.statisticComponent.getActiveMeshEvaluationTime(),
  12438. u = e.statisticComponent.getRenderTargetRenderTime(),
  12439. c = e.statisticComponent.getRegisterBeforeRenderTime(),
  12440. h = e.statisticComponent.getRegisterAfterRenderTime(),
  12441. f = e.statisticComponent.getActiveParticles(),
  12442. d = e.statisticComponent.getActiveBones(),
  12443. _ = e.Scene._activeAnimatables.length,
  12444. g = e.statisticComponent.getTotalRootNodes(),
  12445. m = e.Scene.geometries.length,
  12446. v = e.Scene.onBeforeRenderObservable.observers.length,
  12447. y = e.Scene.onAfterRenderObservable.observers.length,
  12448. b = e.statisticComponent.getTotalMeshes(),
  12449. T = e.statisticComponent.getTotalTextures(),
  12450. C = e.statisticComponent.getTotalMaterials(),
  12451. A = e.statisticComponent.getSystemInfo(),
  12452. S = A.resolution,
  12453. P = A.driver;
  12454. A.vender;
  12455. var R = A.version,
  12456. M = A.hardwareScalingLevel,
  12457. x = S + "_" + P + "_" + R + "_" + M;
  12458. _this5.interFrameCircularArray.add(t), _this5.renderTimeCircularArray.add(o), _this5.animationCircularArray.add(s), _this5.meshSelectCircularArray.add(l), _this5.drawCallTimeCircularArray.add(a), _this5.regAfterRenderCircularArray.add(h), _this5.regBeforeRenderCircularArray.add(c), _this5.renderTargetCircularArray.add(u), _this5.drawCallCntCircularArray.add(r), _this5.renderCnt += 1, _this5.renderCnt % 25 == 0 && ((I = _this5.room.stats) == null || I.assign({
  12459. renderFrameTime: _this5.renderTimeCircularArray.getAvg(),
  12460. maxRenderFrameTime: _this5.renderTimeCircularArray.getMax(),
  12461. interFrameTime: _this5.interFrameCircularArray.getAvg(),
  12462. animationTime: _this5.animationCircularArray.getAvg(),
  12463. meshSelectTime: _this5.meshSelectCircularArray.getAvg(),
  12464. drawcallTime: _this5.drawCallTimeCircularArray.getAvg(),
  12465. idleTime: _this5._idleTime,
  12466. registerBeforeRenderTime: _this5.regBeforeRenderCircularArray.getAvg(),
  12467. registerAfterRenderTime: _this5.regAfterRenderCircularArray.getAvg(),
  12468. renderTargetRenderTime: _this5.renderTargetCircularArray.getAvg(),
  12469. fps: (1e3 / (_this5.renderTimeCircularArray.getAvg() + _this5.interFrameCircularArray.getAvg())).toFixed(2),
  12470. drawcall: _this5.drawCallCntCircularArray.getAvg(),
  12471. triangle: n.toString(),
  12472. engineSloppyCnt: _this5.engineSloppyCnt,
  12473. maxInterFrameTime: _this5.interFrameCircularArray.getMax(),
  12474. maxDrawcallTime: _this5.drawCallTimeCircularArray.getMax(),
  12475. maxMeshSelectTime: _this5.meshSelectCircularArray.getMax(),
  12476. maxAnimationTime: _this5.animationCircularArray.getMax(),
  12477. maxRegisterBeforeRenderTime: _this5.regBeforeRenderCircularArray.getMax(),
  12478. maxRegisterAfterRenderTime: _this5.regAfterRenderCircularArray.getMax(),
  12479. maxRenderTargetRenderTime: _this5.renderTargetCircularArray.getMax(),
  12480. activeParticles: f,
  12481. activeBones: d,
  12482. activeAnimation: _,
  12483. totalMeshes: b,
  12484. totalRootNodes: g,
  12485. totalGeometries: m,
  12486. totalTextures: T,
  12487. totalMaterials: C,
  12488. registerBeforeCount: v,
  12489. registerAfterCount: y,
  12490. hardwareInfo: x
  12491. }));
  12492. });
  12493. }
  12494. }, {
  12495. key: "updateBillboard",
  12496. value: function () {
  12497. var _updateBillboard = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee13() {
  12498. var e, r, n, o, a, s;
  12499. return regenerator.wrap(function _callee13$(_context13) {
  12500. while (1) {
  12501. switch (_context13.prev = _context13.next) {
  12502. case 0:
  12503. e = this.room.options.skinId;
  12504. _context13.next = 3;
  12505. return this.room.modelManager.findAssetList(e);
  12506. case 3:
  12507. r = _context13.sent.filter(function (a) {
  12508. return a.typeName === AssetTypeName.Textures && a.className === AssetClassName.SayBubble;
  12509. });
  12510. n = ["bubble01", "bubble02", "bubble03"];
  12511. o = ["bubble01_npc", "bubble02_npc", "bubble03_npc"];
  12512. if (r.length) {
  12513. a = r.filter(function (l) {
  12514. return n.includes(l.name);
  12515. }).map(function (l) {
  12516. return l.url;
  12517. }), s = r.filter(function (l) {
  12518. return o.includes(l.name);
  12519. }).map(function (l) {
  12520. return l.url;
  12521. });
  12522. a.length && (XBillboardManager.userBubbleUrls = a), s.length && (XBillboardManager.npcBubbleUrls = s);
  12523. }
  12524. case 7:
  12525. case "end":
  12526. return _context13.stop();
  12527. }
  12528. }
  12529. }, _callee13, this);
  12530. }));
  12531. function updateBillboard() {
  12532. return _updateBillboard.apply(this, arguments);
  12533. }
  12534. return updateBillboard;
  12535. }()
  12536. }]);
  12537. return EngineProxy;
  12538. }();
  12539. function _createSuper$2(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$2(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  12540. function _isNativeReflectConstruct$2() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  12541. var LongPressMesh = [EMeshType.XAvatar];
  12542. var StaticMeshEvent = /*#__PURE__*/function (_EventEmitter) {
  12543. _inherits(StaticMeshEvent, _EventEmitter);
  12544. var _super = _createSuper$2(StaticMeshEvent);
  12545. function StaticMeshEvent(e) {
  12546. var _this;
  12547. _classCallCheck(this, StaticMeshEvent);
  12548. _this = _super.call(this);
  12549. E(_assertThisInitialized(_this), "scene");
  12550. E(_assertThisInitialized(_this), "_staringPointerTime", -1);
  12551. E(_assertThisInitialized(_this), "_pickedMeshID", "0");
  12552. E(_assertThisInitialized(_this), "_pointerDownTime", -1);
  12553. E(_assertThisInitialized(_this), "_currentPickPoint");
  12554. E(_assertThisInitialized(_this), "_longPressDelay", 500);
  12555. E(_assertThisInitialized(_this), "_pointerTapDelay", 200);
  12556. E(_assertThisInitialized(_this), "_pickedMeshType");
  12557. E(_assertThisInitialized(_this), "registerEvent", function () {
  12558. _this.scene.onPrePointerObservable.add(_this.onDown, BABYLON.PointerEventTypes.POINTERDOWN), _this.scene.onPrePointerObservable.add(_this.onUp, BABYLON.PointerEventTypes.POINTERUP), _this.scene.onPrePointerObservable.add(_this.onDoubleTap, BABYLON.PointerEventTypes.POINTERDOUBLETAP), _this.scene.onDispose = function () {
  12559. _this.scene.onPrePointerObservable.removeCallback(_this.onUp), _this.scene.onPrePointerObservable.removeCallback(_this.onDown), _this.scene.onPrePointerObservable.removeCallback(_this.onDoubleTap);
  12560. };
  12561. });
  12562. E(_assertThisInitialized(_this), "onUp", function () {
  12563. if (Date.now() - _this._pointerDownTime < _this._pointerTapDelay && !_this.scene._inputManager._isPointerSwiping()) {
  12564. _this.scene._inputManager._totalPointersPressed = 0;
  12565. var _e = _this._currentPickPoint;
  12566. _e != null && LongPressMesh.indexOf(_e.type) == -1 && _this.scene._inputManager._totalPointersPressed == 0 && _this.emit("pointTap", _e), _e != null && LongPressMesh.indexOf(_e.type) != -1 && (_e = _this.onPointerTap(function (t) {
  12567. return t.isPickable && LongPressMesh.indexOf(t.xtype) == -1;
  12568. }), _e != null && _this.emit("pointTap", _e));
  12569. }
  12570. });
  12571. E(_assertThisInitialized(_this), "onDown", function () {
  12572. var e = _this.onPointerTap(function (t) {
  12573. return t.isPickable;
  12574. });
  12575. _this._currentPickPoint = e, _this._pointerDownTime = Date.now(), e != null && LongPressMesh.indexOf(e.type) != -1 && (_this._staringPointerTime = Date.now(), _this._pickedMeshID = e.id, _this._pickedMeshType = e.type, window.setTimeout(function () {
  12576. e = _this.onPointerTap(function (t) {
  12577. return t.isPickable && t.xtype == _this._pickedMeshType && t.xid == _this._pickedMeshID;
  12578. }), e !== null && Date.now() - _this._staringPointerTime > _this._longPressDelay && !_this.scene._inputManager._isPointerSwiping() && _this.scene._inputManager._totalPointersPressed !== 0 && (_this._staringPointerTime = 0, _this.emit("longPress", e));
  12579. }, _this._longPressDelay));
  12580. });
  12581. E(_assertThisInitialized(_this), "onDoubleTap", function () {
  12582. var e = _this.onPointerTap(void 0);
  12583. e != null && _this.emit("pointDoubleTap", e);
  12584. });
  12585. _this.manager = e, _this.scene = e.Scene, _this.registerEvent(), _this._currentPickPoint = null, _this._pickedMeshType = null;
  12586. return _this;
  12587. }
  12588. _createClass(StaticMeshEvent, [{
  12589. key: "onPointerTap",
  12590. value: function onPointerTap(e) {
  12591. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !1;
  12592. var n, o;
  12593. var r = new BABYLON.PickingInfo();
  12594. if (t) {
  12595. var a = this.scene.multiPick(this.scene.pointerX, this.scene.pointerY, e, void 0, void 0);
  12596. a && a.length > 1 ? r = a[1] : a && (r = a[0]);
  12597. } else r = this.scene.pick(this.scene.pointerX, this.scene.pointerY, e, !1, null);
  12598. if (r.hit) {
  12599. var _a = (n = r == null ? void 0 : r.pickedPoint) == null ? void 0 : n.asArray();
  12600. if (_a) {
  12601. var _a2 = _slicedToArray(_a, 3),
  12602. s = _a2[0],
  12603. l = _a2[1],
  12604. u = _a2[2],
  12605. c = xversePosition2Ue4({
  12606. x: s,
  12607. y: l,
  12608. z: u
  12609. });
  12610. return {
  12611. name: (o = r.pickedMesh) == null ? void 0 : o.name,
  12612. type: r.pickedMesh.xtype,
  12613. id: r.pickedMesh.xid,
  12614. point: c
  12615. };
  12616. }
  12617. }
  12618. return null;
  12619. }
  12620. }]);
  12621. return StaticMeshEvent;
  12622. }(EventEmitter);
  12623. var RotationEvent = /*#__PURE__*/function () {
  12624. function RotationEvent(e) {
  12625. var _this = this;
  12626. _classCallCheck(this, RotationEvent);
  12627. E(this, "touchStartX");
  12628. E(this, "touchStartY");
  12629. E(this, "handelResize");
  12630. E(this, "_room");
  12631. E(this, "_canvas");
  12632. E(this, "handleTouchStart", function (e) {
  12633. var t = e.touches[0];
  12634. _this.touchStartX = t.pageX, _this.touchStartY = t.pageY, _this._room.emit("touchStart", {
  12635. event: e
  12636. });
  12637. });
  12638. E(this, "handleMouseDown", function (e) {
  12639. _this.touchStartX = e.pageX, _this.touchStartY = e.pageY;
  12640. });
  12641. E(this, "handleMouseMove", function (e) {
  12642. if (!_this.touchStartX || !_this.touchStartY) return;
  12643. var t = e.pageX,
  12644. r = e.pageY,
  12645. n = t - _this.touchStartX,
  12646. o = r - _this.touchStartY,
  12647. a = _this._room.options.canvas.offsetHeight,
  12648. s = _this._room.options.canvas.offsetWidth;
  12649. var l = 2 * o / a,
  12650. u = 2 * n / s;
  12651. l > 1 && (l = 1), u > 1 && (u = 1), _this._room.actionsHandler.rotate({
  12652. pitch: l,
  12653. yaw: u
  12654. }), _this.touchStartX = t, _this.touchStartY = r;
  12655. });
  12656. E(this, "handleMouseUp", function () {
  12657. _this.touchStartX = void 0, _this.touchStartY = void 0;
  12658. });
  12659. E(this, "handleTouchMove", function (e) {
  12660. if (!_this.touchStartX || !_this.touchStartY) return;
  12661. var t = e.touches[0],
  12662. r = t.pageX,
  12663. n = t.pageY,
  12664. o = r - _this.touchStartX,
  12665. a = n - _this.touchStartY,
  12666. s = _this._room.options.canvas.offsetHeight,
  12667. l = _this._room.options.canvas.offsetWidth;
  12668. var u = 2 * a / s,
  12669. c = 2 * o / l;
  12670. u > 1 && (u = 1), c > 1 && (c = 1), _this._room.actionsHandler.rotate({
  12671. pitch: u,
  12672. yaw: c
  12673. }), _this.touchStartX = r, _this.touchStartY = n, _this._room.emit("touchMove", {
  12674. pitch: u,
  12675. yaw: c,
  12676. event: e
  12677. });
  12678. });
  12679. E(this, "handleTouchEnd", function (e) {
  12680. _this._room.emit("touchEnd", {
  12681. event: e
  12682. });
  12683. });
  12684. this._room = e, this._canvas = e.canvas, this.handelResize = this.reiszeChange();
  12685. }
  12686. _createClass(RotationEvent, [{
  12687. key: "init",
  12688. value: function init() {
  12689. this._canvas.addEventListener("touchstart", this.handleTouchStart), this._canvas.addEventListener("touchmove", this.handleTouchMove), this._canvas.addEventListener("touchend", this.handleTouchEnd), this._room.scene.preventDefaultOnPointerDown = !1, this._room.scene.preventDefaultOnPointerUp = !1, this._canvas.addEventListener("mousedown", this.handleMouseDown), this._canvas.addEventListener("mousemove", this.handleMouseMove), this._canvas.addEventListener("mouseup", this.handleMouseUp);
  12690. }
  12691. }, {
  12692. key: "clear",
  12693. value: function clear() {
  12694. this._canvas.removeEventListener("touchstart", this.handleTouchStart), this._canvas.removeEventListener("touchmove", this.handleTouchMove), this._canvas.removeEventListener("touchend", this.handleTouchEnd), this._canvas.removeEventListener("mousedown", this.handleMouseDown), this._canvas.removeEventListener("mousemove", this.handleMouseMove), this._canvas.removeEventListener("mouseup", this.handleMouseUp);
  12695. }
  12696. }, {
  12697. key: "reiszeChange",
  12698. value: function reiszeChange() {
  12699. window.addEventListener("resize", function () {});
  12700. }
  12701. }]);
  12702. return RotationEvent;
  12703. }();
  12704. var EventsController = /*#__PURE__*/function () {
  12705. function EventsController(e) {
  12706. var _this = this;
  12707. _classCallCheck(this, EventsController);
  12708. E(this, "staticmeshEvent");
  12709. E(this, "rotationEvent");
  12710. E(this, "resize", function () {
  12711. _this.room.sceneManager.cameraComponent.cameraFovChange(_this.room.sceneManager.yuvInfo);
  12712. });
  12713. E(this, "clickEvent", function (e) {
  12714. var t = e.point,
  12715. r = e.name,
  12716. n = e.type,
  12717. o = e.id;
  12718. logger$1.debug("pointEvent", e), _this.room.proxyEvents("pointTap", {
  12719. point: t,
  12720. meshName: r,
  12721. type: n,
  12722. id: o
  12723. }), _this.room.proxyEvents("_coreClick", e);
  12724. });
  12725. E(this, "longPressEvent", function (e) {
  12726. _this.room.proxyEvents("_corePress", e);
  12727. });
  12728. E(this, "handleActionResponseTimeout", function (_ref) {
  12729. var e = _ref.error,
  12730. t = _ref.event;
  12731. _this.room.proxyEvents("actionResponseTimeout", {
  12732. error: e,
  12733. event: t
  12734. });
  12735. });
  12736. E(this, "handleNetworkStateChange", function (e) {
  12737. var t = e.state,
  12738. r = e.count;
  12739. t == "reconnecting" ? _this.room.proxyEvents("reconnecting", {
  12740. count: r || 1
  12741. }) : t === "reconnected" ? (_this.room.networkController.rtcp.workers.reset(), _this.room.proxyEvents("reconnected"), _this.room.afterReconnected()) : t === "disconnected" && _this.room.proxyEvents("disconnected");
  12742. });
  12743. this.room = e, this.staticmeshEvent = new StaticMeshEvent(this.room.sceneManager), this.rotationEvent = new RotationEvent(e);
  12744. }
  12745. _createClass(EventsController, [{
  12746. key: "bindEvents",
  12747. value: function bindEvents() {
  12748. window.addEventListener("orientationchange" in window ? "orientationchange" : "resize", this.resize), this.staticmeshEvent.on("pointTap", this.clickEvent), this.staticmeshEvent.on("longPress", this.longPressEvent), this.rotationEvent.init(), eventsManager.on("actionResponseTimeout", this.handleActionResponseTimeout), this.room.networkController.on("stateChanged", this.handleNetworkStateChange);
  12749. }
  12750. }, {
  12751. key: "clearEvents",
  12752. value: function clearEvents() {
  12753. window.removeEventListener("orientationchange" in window ? "orientationchange" : "resize", this.resize), this.staticmeshEvent.off("pointTap", this.clickEvent), this.staticmeshEvent.off("longPress", this.longPressEvent), eventsManager.off("actionResponseTimeout", this.handleActionResponseTimeout), this.room.networkController.off("stateChanged", this.handleNetworkStateChange), this.rotationEvent.clear();
  12754. }
  12755. }]);
  12756. return EventsController;
  12757. }();
  12758. var Panorama = /*#__PURE__*/function () {
  12759. function Panorama(e) {
  12760. var _this = this;
  12761. _classCallCheck(this, Panorama);
  12762. E(this, "_actived", !1);
  12763. E(this, "handleReceivePanorama", /*#__PURE__*/function () {
  12764. var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e, t) {
  12765. var r, n, _this$room$currentSta, o, a, s, _ref2, l;
  12766. return regenerator.wrap(function _callee$(_context) {
  12767. while (1) {
  12768. switch (_context.prev = _context.next) {
  12769. case 0:
  12770. logger$1.warn("handle panorama", e.uuid, e.pos, e.finished);
  12771. r = {
  12772. data: e.data,
  12773. pose: {
  12774. position: e.pos
  12775. }
  12776. }, n = _this.room.sceneManager;
  12777. _this.room.networkController.rtcp.workers.changePanoMode(!0);
  12778. _context.next = 5;
  12779. return n.materialComponent.changePanoImg(0, r);
  12780. case 5:
  12781. if (!e.finished) {
  12782. _context.next = 23;
  12783. break;
  12784. }
  12785. _context.next = 8;
  12786. return n.changePanoShaderForLowModel(0);
  12787. case 8:
  12788. _this.room.isPano = !0;
  12789. _this._actived = !0;
  12790. if (!t) {
  12791. _context.next = 14;
  12792. break;
  12793. }
  12794. _this.room.sceneManager.cameraComponent.changeToFirstPersonView({
  12795. position: t.position,
  12796. rotation: t.angle
  12797. });
  12798. _context.next = 23;
  12799. break;
  12800. case 14:
  12801. _this$room$currentSta = _this.room.currentState, o = _this$room$currentSta.skinId, a = _this$room$currentSta.pathName;
  12802. if (!(!o || !a)) {
  12803. _context.next = 17;
  12804. break;
  12805. }
  12806. return _context.abrupt("return");
  12807. case 17:
  12808. _context.next = 19;
  12809. return _this.room.modelManager.findRoute(o, a);
  12810. case 19:
  12811. s = _context.sent;
  12812. _ref2 = util.getRandomItem(s.birthPointList) || {};
  12813. l = _ref2.camera;
  12814. l && _this.room.sceneManager.cameraComponent.changeToFirstPersonView(le(oe({}, l), {
  12815. rotation: l.angle
  12816. }));
  12817. case 23:
  12818. case "end":
  12819. return _context.stop();
  12820. }
  12821. }
  12822. }, _callee);
  12823. }));
  12824. return function (_x, _x2) {
  12825. return _ref.apply(this, arguments);
  12826. };
  12827. }());
  12828. this.room = e;
  12829. }
  12830. _createClass(Panorama, [{
  12831. key: "actived",
  12832. get: function get() {
  12833. return this._actived;
  12834. }
  12835. }, {
  12836. key: "bindListener",
  12837. value: function bindListener(e) {
  12838. var _this2 = this;
  12839. this.room.networkController.rtcp.workers.registerFunction("panorama", function (r) {
  12840. logger$1.warn("receive panorama", r.uuid, r.pos), r.uuid && eventsManager.remove(r.uuid, Codes.Success, r, !0), _this2.room.isFirstDataUsed || (_this2.room.isFirstDataUsed = !0, _this2.handleReceivePanorama(r, _this2.room.options.camera).then(e));
  12841. });
  12842. }
  12843. }, {
  12844. key: "access",
  12845. value: function access(e, t, r) {
  12846. var _this3 = this;
  12847. var n = e.camera,
  12848. o = e.player,
  12849. a = e.attitude,
  12850. s = e.areaName,
  12851. l = e.pathName,
  12852. u = e.tag;
  12853. return this.room.actionsHandler.requestPanorama({
  12854. camera: n,
  12855. player: o,
  12856. attitude: a,
  12857. areaName: s,
  12858. pathName: l,
  12859. tag: u
  12860. }, t, r).then(function (c) {
  12861. return _this3.handleReceivePanorama(c, o);
  12862. });
  12863. }
  12864. }, {
  12865. key: "exit",
  12866. value: function exit(e) {
  12867. var _this4 = this;
  12868. var t = e.camera,
  12869. r = e.player,
  12870. n = e.attitude,
  12871. o = e.areaName,
  12872. a = e.pathName;
  12873. return this.room.networkController.rtcp.workers.changePanoMode(!1), this.room.actionsHandler.changeRotationRenderType({
  12874. renderType: RenderType.RotationVideo,
  12875. player: r,
  12876. camera: t,
  12877. attitude: n,
  12878. areaName: o,
  12879. pathName: a
  12880. }).then(function () {
  12881. return _this4.handleExitPanorama();
  12882. }).catch(function (s) {
  12883. return _this4.room.networkController.rtcp.workers.changePanoMode(!0), Promise.reject(s);
  12884. });
  12885. }
  12886. }, {
  12887. key: "handleExitPanorama",
  12888. value: function handleExitPanorama() {
  12889. var e, t, r, n, o, a;
  12890. this.room.isPano = !1, this._actived = !1, (n = (e = this.room.sceneManager) == null ? void 0 : e.cameraComponent) == null || n.forceChangeSavedCameraPose({
  12891. position: (t = this.room._currentClickingState) == null ? void 0 : t.camera.position,
  12892. rotation: (r = this.room._currentClickingState) == null ? void 0 : r.camera.angle
  12893. }), this.room.sceneManager.changeVideoShaderForLowModel(), (a = (o = this.room.sceneManager) == null ? void 0 : o.cameraComponent) == null || a.changeToThirdPersonView();
  12894. }
  12895. }]);
  12896. return Panorama;
  12897. }();
  12898. function _createSuper$1(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  12899. function _isNativeReflectConstruct$1() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  12900. var Xverse_Room = /*#__PURE__*/function (_EventEmitter) {
  12901. _inherits(Xverse_Room, _EventEmitter);
  12902. var _super = _createSuper$1(Xverse_Room);
  12903. function Xverse_Room(e) {
  12904. var _this;
  12905. _classCallCheck(this, Xverse_Room);
  12906. _this = _super.call(this);
  12907. E(_assertThisInitialized(_this), "disableAutoTurn", !1);
  12908. E(_assertThisInitialized(_this), "options");
  12909. E(_assertThisInitialized(_this), "_currentNetworkOptions");
  12910. E(_assertThisInitialized(_this), "lastSkinId");
  12911. E(_assertThisInitialized(_this), "debug");
  12912. E(_assertThisInitialized(_this), "isFirstDataUsed", !1);
  12913. E(_assertThisInitialized(_this), "userId", null);
  12914. E(_assertThisInitialized(_this), "pathManager", new PathManager());
  12915. E(_assertThisInitialized(_this), "networkController");
  12916. E(_assertThisInitialized(_this), "_startTime", Date.now());
  12917. E(_assertThisInitialized(_this), "canvas");
  12918. E(_assertThisInitialized(_this), "modelManager");
  12919. E(_assertThisInitialized(_this), "eventsController");
  12920. E(_assertThisInitialized(_this), "panorama");
  12921. E(_assertThisInitialized(_this), "engineProxy");
  12922. E(_assertThisInitialized(_this), "_id");
  12923. E(_assertThisInitialized(_this), "skinList", []);
  12924. E(_assertThisInitialized(_this), "isHost", !1);
  12925. E(_assertThisInitialized(_this), "avatarManager", new XverseAvatarManager(_assertThisInitialized(_this)));
  12926. E(_assertThisInitialized(_this), "effectManager", new XverseEffectManager(_assertThisInitialized(_this)));
  12927. E(_assertThisInitialized(_this), "sceneManager");
  12928. E(_assertThisInitialized(_this), "scene");
  12929. E(_assertThisInitialized(_this), "breathPointManager");
  12930. E(_assertThisInitialized(_this), "_currentState");
  12931. E(_assertThisInitialized(_this), "joined", !1);
  12932. E(_assertThisInitialized(_this), "disableRotate", !1);
  12933. E(_assertThisInitialized(_this), "isPano", !1);
  12934. E(_assertThisInitialized(_this), "movingByClick", !0);
  12935. E(_assertThisInitialized(_this), "camera", new Camera(_assertThisInitialized(_this)));
  12936. E(_assertThisInitialized(_this), "stats", new Stats(_assertThisInitialized(_this)));
  12937. E(_assertThisInitialized(_this), "isUpdatedRawYUVData", !1);
  12938. E(_assertThisInitialized(_this), "actionsHandler", new ActionsHandler(_assertThisInitialized(_this)));
  12939. E(_assertThisInitialized(_this), "_currentClickingState", null);
  12940. E(_assertThisInitialized(_this), "signal", new Signal(_assertThisInitialized(_this)));
  12941. E(_assertThisInitialized(_this), "firstFrameTimestamp");
  12942. E(_assertThisInitialized(_this), "receiveRtcData", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
  12943. var e, t, r, n;
  12944. return regenerator.wrap(function _callee$(_context) {
  12945. while (1) {
  12946. switch (_context.prev = _context.next) {
  12947. case 0:
  12948. logger$1.info("Invoke receiveRtcData");
  12949. e = !1, t = !1, r = !1, n = !1;
  12950. return _context.abrupt("return", _this.viewMode === "serverless" ? (logger$1.warn("set view mode to serverless"), _this.setViewMode("observer").then(function () {
  12951. return _assertThisInitialized(_this);
  12952. }, function () {
  12953. return _assertThisInitialized(_this);
  12954. })) : new Promise(function (o) {
  12955. var a = _this.networkController.rtcp.workers;
  12956. a.registerFunction("signal", function (s) {
  12957. _this.signal.handleSignal(s);
  12958. }), a.registerFunction("stream", function (s) {
  12959. var l;
  12960. if (_this.emit("streamTimestamp", {
  12961. timestamp: Date.now()
  12962. }), t || (t = !0, logger$1.info("Invoke stream event")), s.stream) {
  12963. r || (r = !0, logger$1.info("Invoke updateRawYUVData")), _this.isUpdatedRawYUVData = !1;
  12964. var u = (l = _this._currentState.skin) == null ? void 0 : l.fov;
  12965. _this.sceneManager.materialComponent.updateRawYUVData(s.stream, s.width, s.height, u), _this.isUpdatedRawYUVData = !0;
  12966. }
  12967. e || (logger$1.info("Invoke isAfterRenderRegistered"), e = !0, _this.scene.registerAfterRender(function () {
  12968. _this.engineProxy.frameRenderNumber >= 2 && (n || (n = !0, logger$1.info("Invoke registerAfterRender")), _this.isFirstDataUsed || (logger$1.info("Invoke isStreamAvailable"), _this.isFirstDataUsed = !0, _this.firstFrameTimestamp = Date.now(), o(_assertThisInitialized(_this)), _this.afterJoinRoom()));
  12969. }));
  12970. }), _this.panorama.bindListener(function () {
  12971. o(_assertThisInitialized(_this)), _this.afterJoinRoom();
  12972. }), a.registerFunction("reconnectedFrame", function () {}), logger$1.info("Invoke decoderWorker.postMessage"), a.decoderWorker.postMessage({
  12973. t: 5
  12974. });
  12975. }));
  12976. case 3:
  12977. case "end":
  12978. return _context.stop();
  12979. }
  12980. }
  12981. }, _callee);
  12982. })));
  12983. E(_assertThisInitialized(_this), "moveToExtra", "");
  12984. _this.options = e, _this.options.wsServerUrl || (_this.options.wsServerUrl = SERVER_URLS.DEV), _this.modelManager = ModelManager.getInstance(e.appId, e.releaseId), _this.updateReporter();
  12985. var n = e;
  12986. n.canvas;
  12987. var r = Oe(n, ["canvas"]);
  12988. logger$1.infoAndReportMeasurement({
  12989. metric: "startJoinRoomAt",
  12990. startTime: Date.now(),
  12991. group: "joinRoom",
  12992. extra: r,
  12993. value: 0
  12994. });
  12995. return _this;
  12996. }
  12997. _createClass(Xverse_Room, [{
  12998. key: "currentNetworkOptions",
  12999. get: function get() {
  13000. return this._currentNetworkOptions;
  13001. }
  13002. }, {
  13003. key: "viewMode",
  13004. get: function get() {
  13005. var e;
  13006. return ((e = this._currentState) == null ? void 0 : e.viewMode) || "full";
  13007. }
  13008. }, {
  13009. key: "id",
  13010. get: function get() {
  13011. return this._id;
  13012. }
  13013. }, {
  13014. key: "skinId",
  13015. get: function get() {
  13016. return this._currentState.skinId;
  13017. }
  13018. }, {
  13019. key: "skin",
  13020. get: function get() {
  13021. return this._currentState.skin;
  13022. }
  13023. }, {
  13024. key: "sessionId",
  13025. get: function get() {
  13026. return this.currentNetworkOptions.sessionId;
  13027. }
  13028. }, {
  13029. key: "pictureQualityLevel",
  13030. get: function get() {
  13031. return this.currentState.pictureQualityLevel;
  13032. }
  13033. }, {
  13034. key: "avatars",
  13035. get: function get() {
  13036. return Array.from(this.avatarManager.avatars.values());
  13037. }
  13038. }, {
  13039. key: "currentState",
  13040. get: function get() {
  13041. var e;
  13042. return le(oe({}, this._currentState), {
  13043. state: (e = this.networkController) == null ? void 0 : e._state
  13044. });
  13045. }
  13046. }, {
  13047. key: "_userAvatar",
  13048. get: function get() {
  13049. var _this2 = this;
  13050. return this.avatars.find(function (e) {
  13051. return e.userId === _this2.userId;
  13052. });
  13053. }
  13054. }, {
  13055. key: "tvs",
  13056. get: function get() {
  13057. return this.engineProxy._tvs;
  13058. }
  13059. }, {
  13060. key: "tv",
  13061. get: function get() {
  13062. return this.tvs[0];
  13063. }
  13064. }, {
  13065. key: "currentClickingState",
  13066. get: function get() {
  13067. return this._currentClickingState;
  13068. }
  13069. }, {
  13070. key: "afterJoinRoomHook",
  13071. value: function afterJoinRoomHook() {}
  13072. }, {
  13073. key: "beforeJoinRoomResolveHook",
  13074. value: function beforeJoinRoomResolveHook() {}
  13075. }, {
  13076. key: "afterReconnectedHook",
  13077. value: function afterReconnectedHook() {}
  13078. }, {
  13079. key: "handleSignalHook",
  13080. value: function handleSignalHook(e) {}
  13081. }, {
  13082. key: "skinChangedHook",
  13083. value: function skinChangedHook() {}
  13084. }, {
  13085. key: "beforeStartGameHook",
  13086. value: function () {
  13087. var _beforeStartGameHook = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(e) {
  13088. return regenerator.wrap(function _callee2$(_context2) {
  13089. while (1) {
  13090. switch (_context2.prev = _context2.next) {
  13091. case 0:
  13092. case "end":
  13093. return _context2.stop();
  13094. }
  13095. }
  13096. }, _callee2);
  13097. }));
  13098. function beforeStartGameHook(_x) {
  13099. return _beforeStartGameHook.apply(this, arguments);
  13100. }
  13101. return beforeStartGameHook;
  13102. }()
  13103. }, {
  13104. key: "loadAssetsHook",
  13105. value: function loadAssetsHook() {}
  13106. }, {
  13107. key: "afterUserAvatarLoadedHook",
  13108. value: function afterUserAvatarLoadedHook() {}
  13109. }, {
  13110. key: "audienceViewModeHook",
  13111. value: function audienceViewModeHook() {}
  13112. }, {
  13113. key: "setViewModeToObserver",
  13114. value: function setViewModeToObserver() {}
  13115. }, {
  13116. key: "handleVehicleHook",
  13117. value: function handleVehicleHook(e) {}
  13118. }, {
  13119. key: "updateReporter",
  13120. value: function updateReporter() {
  13121. var _this$options = this.options,
  13122. e = _this$options.avatarId,
  13123. t = _this$options.skinId,
  13124. r = _this$options.userId,
  13125. n = _this$options.roomId,
  13126. o = _this$options.role,
  13127. a = _this$options.appId,
  13128. s = _this$options.wsServerUrl;
  13129. reporter$1.updateHeader({
  13130. userId: r
  13131. }), reporter$1.updateBody({
  13132. roomId: n,
  13133. role: o,
  13134. skinId: t,
  13135. avatarId: e,
  13136. appId: a,
  13137. wsServerUrl: s
  13138. });
  13139. }
  13140. }, {
  13141. key: "initRoom",
  13142. value: function () {
  13143. var _initRoom2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3() {
  13144. var _this$options$timeout, e;
  13145. return regenerator.wrap(function _callee3$(_context3) {
  13146. while (1) {
  13147. switch (_context3.prev = _context3.next) {
  13148. case 0:
  13149. _this$options$timeout = this.options.timeout, e = _this$options$timeout === void 0 ? DEFAULT_JOINROOM_TIMEOUT : _this$options$timeout;
  13150. if (!util.isSupported()) {
  13151. _context3.next = 5;
  13152. break;
  13153. }
  13154. return _context3.abrupt("return", this._initRoom()._timeout(e, new TimeoutError("initRoom timeout")));
  13155. case 5:
  13156. return _context3.abrupt("return", Promise.reject(new UnsupportedError()));
  13157. case 6:
  13158. case "end":
  13159. return _context3.stop();
  13160. }
  13161. }
  13162. }, _callee3, this);
  13163. }));
  13164. function initRoom() {
  13165. return _initRoom2.apply(this, arguments);
  13166. }
  13167. return initRoom;
  13168. }()
  13169. }, {
  13170. key: "_initRoom",
  13171. value: function () {
  13172. var _initRoom3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4() {
  13173. var e, _this$options2, t, r, n, o, a, s, l, u, c, _this$options2$isAllS, h, f, d, _, g, m, v, _this$options2$firend, y, _this$options2$syncBy, b, T, _this$options2$attitu, C, A, _this$options2$viewMo, S, P, R, M, _this$options2$hasAva, x, _this$options2$syncTo, I, _this$options2$priori, w, _this$options2$remove, O, D, F, V, N;
  13174. return regenerator.wrap(function _callee4$(_context4) {
  13175. while (1) {
  13176. switch (_context4.prev = _context4.next) {
  13177. case 0:
  13178. e = this.validateOptions(this.options);
  13179. if (!e) {
  13180. _context4.next = 3;
  13181. break;
  13182. }
  13183. return _context4.abrupt("return", (logger$1.error("initRoom param error", e), Promise.reject(e)));
  13184. case 3:
  13185. _this$options2 = this.options, t = _this$options2.canvas, r = _this$options2.avatarId, n = _this$options2.skinId, o = _this$options2.userId, a = _this$options2.wsServerUrl, s = _this$options2.role, l = _this$options2.token, u = _this$options2.pageSession, c = _this$options2.rotationRenderType, _this$options2$isAllS = _this$options2.isAllSync, h = _this$options2$isAllS === void 0 ? !1 : _this$options2$isAllS, f = _this$options2.appId, d = _this$options2.camera, _ = _this$options2.player, g = _this$options2.avatarComponents, m = _this$options2.nickname, v = _this$options2.avatarScale, _this$options2$firend = _this$options2.firends, y = _this$options2$firend === void 0 ? [] : _this$options2$firend, _this$options2$syncBy = _this$options2.syncByEvent, b = _this$options2$syncBy === void 0 ? !1 : _this$options2$syncBy, T = _this$options2.areaName, _this$options2$attitu = _this$options2.attitude, C = _this$options2$attitu === void 0 ? MotionType$1.Walk : _this$options2$attitu, A = _this$options2.pathName, _this$options2$viewMo = _this$options2.viewMode, S = _this$options2$viewMo === void 0 ? "full" : _this$options2$viewMo, P = _this$options2.person, R = _this$options2.roomId, M = _this$options2.roomTypeId, _this$options2$hasAva = _this$options2.hasAvatar, x = _this$options2$hasAva === void 0 ? !1 : _this$options2$hasAva, _this$options2$syncTo = _this$options2.syncToOthers, I = _this$options2$syncTo === void 0 ? !1 : _this$options2$syncTo, _this$options2$priori = _this$options2.prioritySync, w = _this$options2$priori === void 0 ? !1 : _this$options2$priori, _this$options2$remove = _this$options2.removeWhenDisconnected, O = _this$options2$remove === void 0 ? !0 : _this$options2$remove, D = _this$options2.extra;
  13186. this.setCurrentNetworkOptions({
  13187. avatarId: r,
  13188. skinId: n,
  13189. roomId: R,
  13190. userId: o,
  13191. wsServerUrl: a,
  13192. role: s,
  13193. token: l,
  13194. pageSession: u,
  13195. rotationRenderType: c,
  13196. isAllSync: h,
  13197. appId: f,
  13198. camera: d,
  13199. player: _,
  13200. avatarComponents: g,
  13201. nickname: m,
  13202. avatarScale: v,
  13203. firends: y,
  13204. syncByEvent: b,
  13205. areaName: T,
  13206. attitude: C,
  13207. pathName: A,
  13208. person: P,
  13209. roomTypeId: M,
  13210. hasAvatar: x,
  13211. syncToOthers: I,
  13212. prioritySync: w,
  13213. extra: D,
  13214. removeWhenDisconnected: O
  13215. });
  13216. this.userId = o;
  13217. this.canvas = t;
  13218. T && (this.pathManager.currentArea = T);
  13219. this.networkController = new NetworkController(this);
  13220. this.setCurrentState({
  13221. areaName: T,
  13222. pathName: A,
  13223. attitude: C,
  13224. speed: 0,
  13225. viewMode: S,
  13226. state: this.networkController._state,
  13227. skinId: n
  13228. });
  13229. _context4.prev = 10;
  13230. _context4.next = 13;
  13231. return Promise.all([this.initNetwork(), this.initConfig(), this.initWasm()]);
  13232. case 13:
  13233. logger$1.info("network config wasm all ready, start to create game");
  13234. _context4.next = 16;
  13235. return this.requestCreateRoom({
  13236. skinId: n
  13237. });
  13238. case 16:
  13239. F = _context4.sent;
  13240. V = F.routeList.find(function (L) {
  13241. return L.areaName === T;
  13242. });
  13243. N = ((V == null ? void 0 : V.step) || 7.5) * 30;
  13244. this.updateCurrentState({
  13245. skin: F,
  13246. skinId: F.id,
  13247. versionId: F.versionId,
  13248. speed: N
  13249. });
  13250. _context4.next = 22;
  13251. return this.initEngine(F);
  13252. case 22:
  13253. _context4.next = 27;
  13254. break;
  13255. case 24:
  13256. _context4.prev = 24;
  13257. _context4.t0 = _context4["catch"](10);
  13258. return _context4.abrupt("return", Promise.reject(_context4.t0));
  13259. case 27:
  13260. this.beforeJoinRoomResolve();
  13261. return _context4.abrupt("return", this.receiveRtcData());
  13262. case 29:
  13263. case "end":
  13264. return _context4.stop();
  13265. }
  13266. }
  13267. }, _callee4, this, [[10, 24]]);
  13268. }));
  13269. function _initRoom() {
  13270. return _initRoom3.apply(this, arguments);
  13271. }
  13272. return _initRoom;
  13273. }()
  13274. }, {
  13275. key: "beforeJoinRoomResolve",
  13276. value: function beforeJoinRoomResolve() {
  13277. this.setupStats(), this.eventsController = new EventsController(this), this.eventsController.bindEvents(), this.panorama = new Panorama(this), this.beforeJoinRoomResolveHook();
  13278. }
  13279. }, {
  13280. key: "afterJoinRoom",
  13281. value: function afterJoinRoom() {
  13282. this.joined = !0, this.viewMode === "observer" && this.setViewModeToObserver(), logger$1.infoAndReportMeasurement({
  13283. tag: this.viewMode,
  13284. value: this.firstFrameTimestamp - this._startTime,
  13285. startTime: Date.now(),
  13286. metric: "joinRoom"
  13287. }), this.camera.initialFov = this.sceneManager.cameraComponent.getCameraFov(), this.stats.on("stats", function (_ref2) {
  13288. var e = _ref2.stats;
  13289. reporter$1.report("stats", oe({}, e));
  13290. }), this.debug = new Debug(this), this.afterJoinRoomHook();
  13291. }
  13292. }, {
  13293. key: "afterReconnected",
  13294. value: function afterReconnected() {
  13295. this.avatarManager.clearOtherUsers(), this.afterReconnectedHook();
  13296. }
  13297. }, {
  13298. key: "leave",
  13299. value: function leave() {
  13300. var e, t;
  13301. return logger$1.info("Invoke room.leave"), (e = this.eventsController) == null || e.clearEvents(), (t = this.networkController) == null || t.quit(), this;
  13302. }
  13303. }, {
  13304. key: "validateOptions",
  13305. value: function validateOptions(e) {
  13306. var _ref3 = e || {},
  13307. t = _ref3.canvas,
  13308. r = _ref3.avatarId,
  13309. n = _ref3.skinId,
  13310. o = _ref3.userId,
  13311. a = _ref3.role;
  13312. _ref3.roomId;
  13313. var l = _ref3.token,
  13314. u = _ref3.appId;
  13315. _ref3.avatarComponents;
  13316. var h = [];
  13317. t instanceof HTMLCanvasElement || h.push(new ParamError$1("`canvas` must be instanceof of HTMLCanvasElement"));
  13318. (!o || typeof o != "string") && h.push(new ParamError$1("`userId` must be string"));
  13319. (!l || typeof l != "string") && h.push(new ParamError$1("`token` must be string"));
  13320. (!u || typeof u != "string") && h.push(new ParamError$1("`appId` must be string"));
  13321. a == "audience" || (!r || !n) && h.push(new ParamError$1("`avatarId` and `skinId` is required when create room"));
  13322. return h[0];
  13323. }
  13324. }, {
  13325. key: "initNetwork",
  13326. value: function () {
  13327. var _initNetwork = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5() {
  13328. var e;
  13329. return regenerator.wrap(function _callee5$(_context5) {
  13330. while (1) {
  13331. switch (_context5.prev = _context5.next) {
  13332. case 0:
  13333. if (!(this.viewMode === "serverless")) {
  13334. _context5.next = 2;
  13335. break;
  13336. }
  13337. return _context5.abrupt("return", Promise.resolve());
  13338. case 2:
  13339. e = Date.now();
  13340. _context5.prev = 3;
  13341. _context5.next = 6;
  13342. return this.networkController.connect()._timeout(8e3, new InitNetworkTimeoutError());
  13343. case 6:
  13344. logger$1.infoAndReportMeasurement({
  13345. metric: "networkInitAt",
  13346. startTime: this._startTime,
  13347. group: "joinRoom"
  13348. });
  13349. logger$1.infoAndReportMeasurement({
  13350. metric: "networkInitCost",
  13351. startTime: e,
  13352. group: "joinRoom"
  13353. });
  13354. _context5.next = 13;
  13355. break;
  13356. case 10:
  13357. _context5.prev = 10;
  13358. _context5.t0 = _context5["catch"](3);
  13359. throw logger$1.infoAndReportMeasurement({
  13360. metric: "networkInitAt",
  13361. startTime: e,
  13362. group: "joinRoom",
  13363. error: _context5.t0
  13364. }), _context5.t0;
  13365. case 13:
  13366. case "end":
  13367. return _context5.stop();
  13368. }
  13369. }
  13370. }, _callee5, this, [[3, 10]]);
  13371. }));
  13372. function initNetwork() {
  13373. return _initNetwork.apply(this, arguments);
  13374. }
  13375. return initNetwork;
  13376. }()
  13377. }, {
  13378. key: "initConfig",
  13379. value: function () {
  13380. var _initConfig = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6() {
  13381. var e;
  13382. return regenerator.wrap(function _callee6$(_context6) {
  13383. while (1) {
  13384. switch (_context6.prev = _context6.next) {
  13385. case 0:
  13386. e = Date.now();
  13387. _context6.prev = 1;
  13388. _context6.next = 4;
  13389. return this.modelManager.getApplicationConfig()._timeout(8e3, new InitConfigTimeoutError());
  13390. case 4:
  13391. logger$1.infoAndReportMeasurement({
  13392. metric: "configInitAt",
  13393. startTime: this._startTime,
  13394. group: "joinRoom"
  13395. });
  13396. logger$1.infoAndReportMeasurement({
  13397. metric: "configInitCost",
  13398. startTime: e,
  13399. group: "joinRoom"
  13400. });
  13401. _context6.next = 11;
  13402. break;
  13403. case 8:
  13404. _context6.prev = 8;
  13405. _context6.t0 = _context6["catch"](1);
  13406. throw logger$1.infoAndReportMeasurement({
  13407. metric: "configInitAt",
  13408. startTime: e,
  13409. group: "joinRoom",
  13410. error: _context6.t0
  13411. }), _context6.t0;
  13412. case 11:
  13413. case "end":
  13414. return _context6.stop();
  13415. }
  13416. }
  13417. }, _callee6, this, [[1, 8]]);
  13418. }));
  13419. function initConfig() {
  13420. return _initConfig.apply(this, arguments);
  13421. }
  13422. return initConfig;
  13423. }()
  13424. }, {
  13425. key: "initEngine",
  13426. value: function () {
  13427. var _initEngine = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee7(e) {
  13428. var t, n;
  13429. return regenerator.wrap(function _callee7$(_context7) {
  13430. while (1) {
  13431. switch (_context7.prev = _context7.next) {
  13432. case 0:
  13433. t = Date.now();
  13434. _context7.prev = 1;
  13435. this.engineProxy = new EngineProxy(this);
  13436. _context7.next = 5;
  13437. return this.engineProxy.initEngine(e);
  13438. case 5:
  13439. logger$1.infoAndReportMeasurement({
  13440. metric: "webglInitAt",
  13441. startTime: this._startTime,
  13442. group: "joinRoom"
  13443. });
  13444. logger$1.infoAndReportMeasurement({
  13445. metric: "webglInitCost",
  13446. startTime: t,
  13447. group: "joinRoom"
  13448. });
  13449. return _context7.abrupt("return");
  13450. case 10:
  13451. _context7.prev = 10;
  13452. _context7.t0 = _context7["catch"](1);
  13453. n = _context7.t0;
  13454. return _context7.abrupt("return", (_context7.t0.code !== Codes.InitEngineTimeout && (n = new InitEngineError()), logger$1.error(_context7.t0), logger$1.infoAndReportMeasurement({
  13455. metric: "webglInitAt",
  13456. startTime: t,
  13457. group: "joinRoom",
  13458. error: n
  13459. }), Promise.reject(n)));
  13460. case 14:
  13461. case "end":
  13462. return _context7.stop();
  13463. }
  13464. }
  13465. }, _callee7, this, [[1, 10]]);
  13466. }));
  13467. function initEngine(_x2) {
  13468. return _initEngine.apply(this, arguments);
  13469. }
  13470. return initEngine;
  13471. }()
  13472. }, {
  13473. key: "initWasm",
  13474. value: function () {
  13475. var _initWasm = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee8() {
  13476. var _this3 = this;
  13477. var e;
  13478. return regenerator.wrap(function _callee8$(_context8) {
  13479. while (1) {
  13480. switch (_context8.prev = _context8.next) {
  13481. case 0:
  13482. if (!(this.viewMode === "serverless")) {
  13483. _context8.next = 2;
  13484. break;
  13485. }
  13486. return _context8.abrupt("return", Promise.resolve());
  13487. case 2:
  13488. e = Date.now();
  13489. _context8.prev = 3;
  13490. _context8.next = 6;
  13491. return this.networkController.rtcp.workers.init(this.options.resolution)._timeout(8e3, new InitDecoderTimeoutError());
  13492. case 6:
  13493. this.networkController.rtcp.workers.registerFunction("error", function (t) {
  13494. logger$1.error("decode error", t);
  13495. var r = t.code,
  13496. n = t.message;
  13497. _this3.emit("error", {
  13498. code: r,
  13499. msg: n
  13500. });
  13501. });
  13502. logger$1.infoAndReportMeasurement({
  13503. metric: "wasmInitAt",
  13504. group: "joinRoom",
  13505. startTime: this._startTime
  13506. });
  13507. logger$1.infoAndReportMeasurement({
  13508. metric: "wasmInitCost",
  13509. group: "joinRoom",
  13510. startTime: e
  13511. });
  13512. eventsManager.on("traceId", function (t) {
  13513. _this3.networkController.rtcp.workers.onTraceId(t);
  13514. });
  13515. _context8.next = 15;
  13516. break;
  13517. case 12:
  13518. _context8.prev = 12;
  13519. _context8.t0 = _context8["catch"](3);
  13520. throw logger$1.infoAndReportMeasurement({
  13521. metric: "wasmInitAt",
  13522. group: "joinRoom",
  13523. startTime: e,
  13524. error: _context8.t0
  13525. }), _context8.t0;
  13526. case 15:
  13527. case "end":
  13528. return _context8.stop();
  13529. }
  13530. }
  13531. }, _callee8, this, [[3, 12]]);
  13532. }));
  13533. function initWasm() {
  13534. return _initWasm.apply(this, arguments);
  13535. }
  13536. return initWasm;
  13537. }()
  13538. }, {
  13539. key: "requestCreateRoom",
  13540. value: function () {
  13541. var _requestCreateRoom = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee9(_ref4) {
  13542. var e, t, r, _ref5, n, o, _yield$this$networkCo, _r, _n, _o, a, s;
  13543. return regenerator.wrap(function _callee9$(_context9) {
  13544. while (1) {
  13545. switch (_context9.prev = _context9.next) {
  13546. case 0:
  13547. e = _ref4.skinId;
  13548. if (!e) {
  13549. _context9.next = 11;
  13550. break;
  13551. }
  13552. _context9.next = 4;
  13553. return this.getSkin(e);
  13554. case 4:
  13555. t = _context9.sent;
  13556. _context9.next = 7;
  13557. return this.modelManager.findRoute(e, this.options.pathName);
  13558. case 7:
  13559. r = _context9.sent;
  13560. this.updateCurrentNetworkOptions({
  13561. areaName: r.areaName,
  13562. attitude: r.attitude,
  13563. versionId: t.versionId
  13564. });
  13565. _ref5 = util.getRandomItem(r.birthPointList) || this.options, n = _ref5.camera, o = _ref5.player;
  13566. this.options.camera || this.updateCurrentNetworkOptions({
  13567. camera: n
  13568. }), this.options.player || this.updateCurrentNetworkOptions({
  13569. player: o
  13570. });
  13571. case 11:
  13572. if (!(this.viewMode === "serverless")) {
  13573. _context9.next = 13;
  13574. break;
  13575. }
  13576. return _context9.abrupt("return", t);
  13577. case 13:
  13578. _context9.prev = 13;
  13579. _context9.next = 16;
  13580. return this.beforeStartGameHook(this.options);
  13581. case 16:
  13582. _context9.next = 18;
  13583. return this.networkController.startGame();
  13584. case 18:
  13585. _yield$this$networkCo = _context9.sent;
  13586. _r = _yield$this$networkCo.room_id;
  13587. _n = _yield$this$networkCo.data;
  13588. _o = _yield$this$networkCo.session_id;
  13589. this._id = _r;
  13590. a = JSON.parse(_n);
  13591. this.isHost = a.IsHost, e = a.SkinID || e;
  13592. _context9.next = 27;
  13593. return this.getSkin(e);
  13594. case 27:
  13595. s = _context9.sent;
  13596. return _context9.abrupt("return", (this.updateCurrentNetworkOptions({
  13597. roomId: _r,
  13598. sessionId: _o
  13599. }), reporter$1.updateBody({
  13600. roomId: _r,
  13601. skinId: e,
  13602. serverSession: _o
  13603. }), s));
  13604. case 31:
  13605. _context9.prev = 31;
  13606. _context9.t0 = _context9["catch"](13);
  13607. throw logger$1.error("Request create room error", _context9.t0), _context9.t0;
  13608. case 34:
  13609. case "end":
  13610. return _context9.stop();
  13611. }
  13612. }
  13613. }, _callee9, this, [[13, 31]]);
  13614. }));
  13615. function requestCreateRoom(_x3) {
  13616. return _requestCreateRoom.apply(this, arguments);
  13617. }
  13618. return requestCreateRoom;
  13619. }()
  13620. }, {
  13621. key: "pause",
  13622. value: function pause() {
  13623. return this.engineProxy.pause();
  13624. }
  13625. }, {
  13626. key: "resume",
  13627. value: function resume() {
  13628. return this.engineProxy.resume();
  13629. }
  13630. }, {
  13631. key: "reconnect",
  13632. value: function reconnect() {
  13633. this.networkController.reconnect();
  13634. }
  13635. }, {
  13636. key: "setViewMode",
  13637. value: function () {
  13638. var _setViewMode = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee10(e) {
  13639. return regenerator.wrap(function _callee10$(_context10) {
  13640. while (1) {
  13641. switch (_context10.prev = _context10.next) {
  13642. case 0:
  13643. case "end":
  13644. return _context10.stop();
  13645. }
  13646. }
  13647. }, _callee10);
  13648. }));
  13649. function setViewMode(_x4) {
  13650. return _setViewMode.apply(this, arguments);
  13651. }
  13652. return setViewMode;
  13653. }()
  13654. }, {
  13655. key: "handleRepetLogin",
  13656. value: function handleRepetLogin() {
  13657. logger$1.warn("receive " + Codes.RepeatLogin + " for repeat login"), this.emit("repeatLogin"), reporter$1.disable(), this.networkController.quit();
  13658. }
  13659. }, {
  13660. key: "setPictureQualityLevel",
  13661. value: function setPictureQualityLevel(e) {
  13662. var t = {
  13663. high: EImageQuality.high,
  13664. low: EImageQuality.low,
  13665. average: EImageQuality.mid
  13666. };
  13667. return this.updateCurrentState({
  13668. pictureQualityLevel: e
  13669. }), this.sceneManager.setImageQuality(t[e]);
  13670. }
  13671. }, {
  13672. key: "getSkin",
  13673. value: function () {
  13674. var _getSkin = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee11(e) {
  13675. var t, n;
  13676. return regenerator.wrap(function _callee11$(_context11) {
  13677. while (1) {
  13678. switch (_context11.prev = _context11.next) {
  13679. case 0:
  13680. t = null;
  13681. _context11.next = 3;
  13682. return this.modelManager.getSkinsList();
  13683. case 3:
  13684. t = (this.skinList = _context11.sent).find(function (n) {
  13685. return n.id === e || n.id === e;
  13686. });
  13687. if (!t) {
  13688. _context11.next = 6;
  13689. break;
  13690. }
  13691. return _context11.abrupt("return", t);
  13692. case 6:
  13693. n = "skin is invalid: skinId: ".concat(e);
  13694. return _context11.abrupt("return", Promise.reject(new ParamError$1(n)));
  13695. case 8:
  13696. case "end":
  13697. return _context11.stop();
  13698. }
  13699. }
  13700. }, _callee11, this);
  13701. }));
  13702. function getSkin(_x5) {
  13703. return _getSkin.apply(this, arguments);
  13704. }
  13705. return getSkin;
  13706. }()
  13707. }, {
  13708. key: "setupStats",
  13709. value: function setupStats() {
  13710. this.stats.assign({
  13711. roomId: this.id,
  13712. userId: this.userId
  13713. }), setInterval(this.engineProxy.updateStats, 1e3);
  13714. }
  13715. }, {
  13716. key: "proxyEvents",
  13717. value: function proxyEvents(e, t) {
  13718. this.emit(e, t);
  13719. }
  13720. }, {
  13721. key: "setCurrentNetworkOptions",
  13722. value: function setCurrentNetworkOptions(e) {
  13723. this._currentNetworkOptions = e;
  13724. }
  13725. }, {
  13726. key: "updateCurrentNetworkOptions",
  13727. value: function updateCurrentNetworkOptions(e) {
  13728. Object.assign(this._currentNetworkOptions, e), Object.assign(this.options, e);
  13729. }
  13730. }, {
  13731. key: "setCurrentState",
  13732. value: function setCurrentState(e) {
  13733. this._currentState = e;
  13734. }
  13735. }, {
  13736. key: "updateCurrentState",
  13737. value: function updateCurrentState(e) {
  13738. e.skinId && (this.lastSkinId = this.currentState.skinId, this.updateCurrentNetworkOptions({
  13739. skinId: e.skinId
  13740. })), e.versionId && this.updateCurrentNetworkOptions({
  13741. versionId: e.versionId
  13742. }), Object.assign(this._currentState, e);
  13743. }
  13744. }]);
  13745. return Xverse_Room;
  13746. }(EventEmitter);
  13747. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  13748. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  13749. var XverseRoom = /*#__PURE__*/function (_Xverse_Room) {
  13750. _inherits(XverseRoom, _Xverse_Room);
  13751. var _super = _createSuper(XverseRoom);
  13752. function XverseRoom(e) {
  13753. var _this;
  13754. _classCallCheck(this, XverseRoom);
  13755. _this = _super.call(this, e);
  13756. _this.joyStick = new JoyStick(_assertThisInitialized(_this));
  13757. return _this;
  13758. }
  13759. _createClass(XverseRoom, [{
  13760. key: "afterJoinRoomHook",
  13761. value: function afterJoinRoomHook() {
  13762. this.joyStick.init({});
  13763. }
  13764. }]);
  13765. return XverseRoom;
  13766. }(Xverse_Room);
  13767. var Preload = /*#__PURE__*/function () {
  13768. function Preload(e) {
  13769. _classCallCheck(this, Preload);
  13770. this.config = null;
  13771. this.allKeys = [];
  13772. this.oldResourcesDeleted = !1;
  13773. this.requests = {
  13774. simple: {
  13775. stopped: !0,
  13776. requests: {}
  13777. },
  13778. observer: {
  13779. stopped: !0,
  13780. requests: {}
  13781. },
  13782. full: {
  13783. stopped: !0,
  13784. requests: {}
  13785. }
  13786. };
  13787. this.modelManager = e, this.init(e.appId);
  13788. }
  13789. _createClass(Preload, [{
  13790. key: "init",
  13791. value: function init(e) {
  13792. reporter$1.updateBody({
  13793. appId: e
  13794. });
  13795. }
  13796. }, {
  13797. key: "getConfig",
  13798. value: function () {
  13799. var _getConfig = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  13800. var _yield$this$modelMana, t;
  13801. return regenerator.wrap(function _callee$(_context) {
  13802. while (1) {
  13803. switch (_context.prev = _context.next) {
  13804. case 0:
  13805. if (!this.config) {
  13806. _context.next = 2;
  13807. break;
  13808. }
  13809. return _context.abrupt("return", this.config);
  13810. case 2:
  13811. _context.next = 4;
  13812. return this.modelManager.requestConfig();
  13813. case 4:
  13814. _yield$this$modelMana = _context.sent;
  13815. t = _yield$this$modelMana.preload;
  13816. return _context.abrupt("return", t ? (this.config = t, Promise.resolve(t)) : Promise.reject("no preload config"));
  13817. case 7:
  13818. case "end":
  13819. return _context.stop();
  13820. }
  13821. }
  13822. }, _callee, this);
  13823. }));
  13824. function getConfig(_x) {
  13825. return _getConfig.apply(this, arguments);
  13826. }
  13827. return getConfig;
  13828. }()
  13829. }, {
  13830. key: "getAllKeys",
  13831. value: function () {
  13832. var _getAllKeys = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
  13833. var e, t;
  13834. return regenerator.wrap(function _callee2$(_context2) {
  13835. while (1) {
  13836. switch (_context2.prev = _context2.next) {
  13837. case 0:
  13838. if (!this.allKeys.length) {
  13839. _context2.next = 2;
  13840. break;
  13841. }
  13842. return _context2.abrupt("return", this.allKeys);
  13843. case 2:
  13844. _context2.prev = 2;
  13845. _context2.next = 5;
  13846. return modelTable.getAllKeys();
  13847. case 5:
  13848. e = _context2.sent;
  13849. this.allKeys = e;
  13850. return _context2.abrupt("return", e);
  13851. case 10:
  13852. _context2.prev = 10;
  13853. _context2.t0 = _context2["catch"](2);
  13854. t = "preload getAllKeys error";
  13855. return _context2.abrupt("return", (logger$1.error(t), Promise.reject(t)));
  13856. case 14:
  13857. case "end":
  13858. return _context2.stop();
  13859. }
  13860. }
  13861. }, _callee2, this, [[2, 10]]);
  13862. }));
  13863. function getAllKeys() {
  13864. return _getAllKeys.apply(this, arguments);
  13865. }
  13866. return getAllKeys;
  13867. }()
  13868. }, {
  13869. key: "stop",
  13870. value: function stop(e) {
  13871. e === "serverless" && (e = "observer"), this.requests[e].stopped = !0;
  13872. var t = this.requests[e].requests;
  13873. Object.keys(t).forEach(function (r) {
  13874. http1.canceler.removePending(r), delete t[r];
  13875. });
  13876. }
  13877. }, {
  13878. key: "clearPreload",
  13879. value: function clearPreload(e) {
  13880. this.requests[e].stopped = !1, this.allKeys = [];
  13881. }
  13882. }, {
  13883. key: "start",
  13884. value: function () {
  13885. var _start = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e, t, r) {
  13886. var n, o, a, s, l, u, h, f, _s;
  13887. return regenerator.wrap(function _callee3$(_context3) {
  13888. while (1) {
  13889. switch (_context3.prev = _context3.next) {
  13890. case 0:
  13891. n = Date.now(), o = 0;
  13892. _context3.prev = 1;
  13893. if (!(e === "serverless" && (e = "observer"), !this.requests[e])) {
  13894. _context3.next = 4;
  13895. break;
  13896. }
  13897. return _context3.abrupt("return", Promise.reject(new ParamError("invalid stage name: " + e)));
  13898. case 4:
  13899. this.clearPreload(e);
  13900. _context3.next = 7;
  13901. return this.getConfig(e);
  13902. case 7:
  13903. a = _context3.sent;
  13904. _context3.next = 10;
  13905. return this.getAllKeys();
  13906. case 10:
  13907. s = _context3.sent;
  13908. _context3.prev = 11;
  13909. _context3.next = 14;
  13910. return this.deleteOldResources(a.assetUrls.map(function (d) {
  13911. return d.url;
  13912. }), s);
  13913. case 14:
  13914. _context3.next = 19;
  13915. break;
  13916. case 16:
  13917. _context3.prev = 16;
  13918. _context3.t0 = _context3["catch"](11);
  13919. logger$1.error(_context3.t0);
  13920. case 19:
  13921. l = a.baseUrls, u = a.assetUrls;
  13922. _context3.t1 = e;
  13923. _context3.next = _context3.t1 === "simple" ? 23 : _context3.t1 === "observer" ? 25 : _context3.t1 === "full" ? 27 : 29;
  13924. break;
  13925. case 23:
  13926. h = l;
  13927. return _context3.abrupt("break", 30);
  13928. case 25:
  13929. h = u;
  13930. return _context3.abrupt("break", 30);
  13931. case 27:
  13932. h = u;
  13933. return _context3.abrupt("break", 30);
  13934. case 29:
  13935. h = u;
  13936. case 30:
  13937. f = h.filter(function (d) {
  13938. return !s.includes(d.url);
  13939. });
  13940. r && isFunction(r) && (f = f.filter(r));
  13941. o = f.length;
  13942. logger$1.debug("keysNeedToPreload", f);
  13943. f.length || t && t(h.length, h.length);
  13944. n = Date.now();
  13945. _context3.next = 38;
  13946. return this._preload(e, f, t);
  13947. case 38:
  13948. logger$1.infoAndReportMeasurement({
  13949. tag: e,
  13950. startTime: n,
  13951. metric: "assetsPreload",
  13952. extra: {
  13953. total: o
  13954. }
  13955. });
  13956. return _context3.abrupt("return");
  13957. case 42:
  13958. _context3.prev = 42;
  13959. _context3.t2 = _context3["catch"](1);
  13960. _s = _context3.t2;
  13961. return _context3.abrupt("return", ((this.requests[e].stopped || axios.isCancel(_context3.t2)) && (_s = new PreloadCanceledError()), logger$1.infoAndReportMeasurement({
  13962. tag: e,
  13963. startTime: n,
  13964. metric: "assetsPreload",
  13965. extra: {
  13966. total: o
  13967. },
  13968. error: _s,
  13969. reportOptions: {
  13970. immediate: !0
  13971. }
  13972. }), Promise.reject(_s)));
  13973. case 46:
  13974. case "end":
  13975. return _context3.stop();
  13976. }
  13977. }
  13978. }, _callee3, this, [[1, 42], [11, 16]]);
  13979. }));
  13980. function start(_x2, _x3, _x4) {
  13981. return _start.apply(this, arguments);
  13982. }
  13983. return start;
  13984. }()
  13985. }, {
  13986. key: "deleteOldResources",
  13987. value: function deleteOldResources(e, t) {
  13988. if (!this.oldResourcesDeleted) this.oldResourcesDeleted = !0;else return Promise.resolve();
  13989. var r = t.filter(function (n) {
  13990. return !e.includes(n);
  13991. });
  13992. return logger$1.debug("keysNeedToDelete", r), logger$1.warn("keysNeedToDelete", r.length), Promise.all(r.map(function (n) {
  13993. return modelTable.delete(n);
  13994. }));
  13995. }
  13996. }, {
  13997. key: "_preload",
  13998. value: function () {
  13999. var _preload2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6(e, t, r) {
  14000. var _this = this;
  14001. var n, o, a;
  14002. return regenerator.wrap(function _callee6$(_context6) {
  14003. while (1) {
  14004. switch (_context6.prev = _context6.next) {
  14005. case 0:
  14006. n = t.length;
  14007. if (n) {
  14008. _context6.next = 3;
  14009. break;
  14010. }
  14011. return _context6.abrupt("return", Promise.resolve());
  14012. case 3:
  14013. o = 0;
  14014. a = window.setInterval(function () {
  14015. r && r(o, n), o >= n && window.clearInterval(a);
  14016. }, 1e3);
  14017. return _context6.abrupt("return", util.mapLimit(t, 10, /*#__PURE__*/function () {
  14018. var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(s) {
  14019. var l, u;
  14020. return regenerator.wrap(function _callee5$(_context5) {
  14021. while (1) {
  14022. switch (_context5.prev = _context5.next) {
  14023. case 0:
  14024. l = s.size, u = s.url;
  14025. return _context5.abrupt("return", _this.requests[e].stopped ? Promise.reject(new PreloadCanceledError()) : http1.get({
  14026. url: u,
  14027. timeout: Preload.getTimeoutBySize(l),
  14028. responseType: "blob",
  14029. retry: 2,
  14030. beforeRequest: function beforeRequest() {
  14031. _this.requests[e].requests[u] = !0;
  14032. }
  14033. }).then( /*#__PURE__*/function () {
  14034. var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(c) {
  14035. var h, f;
  14036. return regenerator.wrap(function _callee4$(_context4) {
  14037. while (1) {
  14038. switch (_context4.prev = _context4.next) {
  14039. case 0:
  14040. h = c.data;
  14041. if (h instanceof Blob) {
  14042. _context4.next = 3;
  14043. break;
  14044. }
  14045. return _context4.abrupt("return", (logger$1.error("request blob failed, type:", typeof h, u), Promise.reject("request blob failed " + u)));
  14046. case 3:
  14047. _context4.next = 5;
  14048. return blobToDataURI(h);
  14049. case 5:
  14050. f = _context4.sent;
  14051. _context4.prev = 6;
  14052. _context4.next = 9;
  14053. return modelTable.put({
  14054. url: u,
  14055. model: f
  14056. });
  14057. case 9:
  14058. return _context4.abrupt("return");
  14059. case 12:
  14060. _context4.prev = 12;
  14061. _context4.t0 = _context4["catch"](6);
  14062. return _context4.abrupt("return", (logger$1.error("unable to add data to indexedDB", _context4.t0), Promise.reject(new InternalError("preload db error"))));
  14063. case 15:
  14064. case "end":
  14065. return _context4.stop();
  14066. }
  14067. }
  14068. }, _callee4, null, [[6, 12]]);
  14069. }));
  14070. return function (_x9) {
  14071. return _ref2.apply(this, arguments);
  14072. };
  14073. }()).then(function () {
  14074. o++, delete _this.requests[e].requests[u];
  14075. }, function (c) {
  14076. return delete _this.requests[e].requests[u], window.clearInterval(a), Promise.reject(c);
  14077. }));
  14078. case 2:
  14079. case "end":
  14080. return _context5.stop();
  14081. }
  14082. }
  14083. }, _callee5);
  14084. }));
  14085. return function (_x8) {
  14086. return _ref.apply(this, arguments);
  14087. };
  14088. }()));
  14089. case 6:
  14090. case "end":
  14091. return _context6.stop();
  14092. }
  14093. }
  14094. }, _callee6);
  14095. }));
  14096. function _preload(_x5, _x6, _x7) {
  14097. return _preload2.apply(this, arguments);
  14098. }
  14099. return _preload;
  14100. }()
  14101. }], [{
  14102. key: "getTimeoutBySize",
  14103. value: function getTimeoutBySize(e) {
  14104. return e ? e < 500 * 1e3 ? 30 * 1e3 : e < 1e3 * 1e3 ? 60 * 1e3 : 100 * 1e3 : 100 * 1e3;
  14105. }
  14106. }]);
  14107. return Preload;
  14108. }();
  14109. var RenderType$1 = {
  14110. PathVideo: 0,
  14111. RotationVideo: 1,
  14112. RotationImage: 2,
  14113. PanoramaImage: 3,
  14114. CGVideo: 4,
  14115. ClientRotationPano: 5,
  14116. CloudRotationPano: 6
  14117. };
  14118. var Xverse = /*#__PURE__*/function () {
  14119. function Xverse(e) {
  14120. _classCallCheck(this, Xverse);
  14121. e || (e = {});
  14122. var _e = e,
  14123. t = _e.onLog,
  14124. r = _e.env,
  14125. n = _e.appId,
  14126. o = _e.releaseId,
  14127. a = _e.subPackageVersion;
  14128. this.NO_CACHE = !1, this.env = r || "PROD", this.SUB_PACKAGE_VERSION = a, this.debug && logger$1.setLevel(LoggerLevels.Debug);
  14129. var s = this.pageSession = util.uuid();
  14130. reporter$1.updateHeader({
  14131. pageSession: s
  14132. });
  14133. reporter$1.updateReportUrl(REPORT_URL[this.env]);
  14134. a && reporter$1.updateBody({
  14135. sdkVersion: a
  14136. });
  14137. logger$1.infoAndReportMeasurement({
  14138. metric: "sdkInit",
  14139. startTime: Date.now(),
  14140. extra: {
  14141. version: a,
  14142. enviroment: r,
  14143. pageSession: s
  14144. }
  14145. });
  14146. logger$1.debug("debug mode:", this.debug);
  14147. reporter$1.on("report", function (l) {
  14148. t && t(l);
  14149. });
  14150. if (n) {
  14151. this.appId = n, this.releaseId = o;
  14152. var l = ModelManager.getInstance(n, o);
  14153. this.preload = new Preload(l);
  14154. }
  14155. }
  14156. _createClass(Xverse, [{
  14157. key: "isSupported",
  14158. get: function get() {
  14159. return isSupported();
  14160. }
  14161. }, {
  14162. key: "disableLogUpload",
  14163. value: function disableLogUpload() {
  14164. reporter$1.disable(), logger$1.debug("logger upload has been disabled");
  14165. }
  14166. }, {
  14167. key: "getSkinList",
  14168. value: function () {
  14169. var _getSkinList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
  14170. return regenerator.wrap(function _callee$(_context) {
  14171. while (1) {
  14172. switch (_context.prev = _context.next) {
  14173. case 0:
  14174. return _context.abrupt("return", []);
  14175. case 1:
  14176. case "end":
  14177. return _context.stop();
  14178. }
  14179. }
  14180. }, _callee);
  14181. }));
  14182. function getSkinList() {
  14183. return _getSkinList.apply(this, arguments);
  14184. }
  14185. return getSkinList;
  14186. }()
  14187. }, {
  14188. key: "getAvatarList",
  14189. value: function () {
  14190. var _getAvatarList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
  14191. return regenerator.wrap(function _callee2$(_context2) {
  14192. while (1) {
  14193. switch (_context2.prev = _context2.next) {
  14194. case 0:
  14195. return _context2.abrupt("return", []);
  14196. case 1:
  14197. case "end":
  14198. return _context2.stop();
  14199. }
  14200. }
  14201. }, _callee2);
  14202. }));
  14203. function getAvatarList() {
  14204. return _getAvatarList.apply(this, arguments);
  14205. }
  14206. return getAvatarList;
  14207. }()
  14208. }, {
  14209. key: "getGiftList",
  14210. value: function () {
  14211. var _getGiftList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3() {
  14212. return regenerator.wrap(function _callee3$(_context3) {
  14213. while (1) {
  14214. switch (_context3.prev = _context3.next) {
  14215. case 0:
  14216. return _context3.abrupt("return", [{
  14217. id: "hack "
  14218. }]);
  14219. case 1:
  14220. case "end":
  14221. return _context3.stop();
  14222. }
  14223. }
  14224. }, _callee3);
  14225. }));
  14226. function getGiftList() {
  14227. return _getGiftList.apply(this, arguments);
  14228. }
  14229. return getGiftList;
  14230. }()
  14231. }, {
  14232. key: "joinRoom",
  14233. value: function () {
  14234. var _joinRoom = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(e) {
  14235. var t, r, n, o;
  14236. return regenerator.wrap(function _callee4$(_context4) {
  14237. while (1) {
  14238. switch (_context4.prev = _context4.next) {
  14239. case 0:
  14240. t = e.pathName || "thirdwalk", r = e.rotationRenderType || RenderType$1.RotationVideo, n = e.person || Person$1.Third, o = new XverseRoom(le(oe({}, e), {
  14241. appId: e.appId || this.appId,
  14242. releaseId: e.releaseId || this.releaseId,
  14243. pageSession: this.pageSession,
  14244. isAllSync: !0,
  14245. rotationRenderType: r,
  14246. syncByEvent: !0,
  14247. pathName: t,
  14248. person: n,
  14249. role: e.role || "audience"
  14250. }));
  14251. return _context4.abrupt("return", o.initRoom().then(function () {
  14252. return o;
  14253. }));
  14254. case 2:
  14255. case "end":
  14256. return _context4.stop();
  14257. }
  14258. }
  14259. }, _callee4, this);
  14260. }));
  14261. function joinRoom(_x) {
  14262. return _joinRoom.apply(this, arguments);
  14263. }
  14264. return joinRoom;
  14265. }()
  14266. }]);
  14267. return Xverse;
  14268. }();
  14269. var xverse = new Xverse({
  14270. env: "DEV",
  14271. appId: "10016",
  14272. releaseId: '2203120033_29769e'
  14273. });
  14274. var l = /*#__PURE__*/function () {
  14275. var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
  14276. var R;
  14277. return regenerator.wrap(function _callee$(_context) {
  14278. while (1) {
  14279. switch (_context.prev = _context.next) {
  14280. case 0:
  14281. _context.prev = 0;
  14282. _context.next = 3;
  14283. return (R = xverse.preload) == null ? void 0 : R.start('full', function (M, x) {
  14284. });
  14285. case 3:
  14286. _context.next = 12;
  14287. break;
  14288. case 5:
  14289. _context.prev = 5;
  14290. _context.t0 = _context["catch"](0);
  14291. if (!(console.error(_context.t0), _context.t0.code === Codes.PreloadCanceled)) {
  14292. _context.next = 10;
  14293. break;
  14294. }
  14295. toast("\u9884\u52A0\u8F7D\u88AB\u53D6\u6D88");
  14296. return _context.abrupt("return");
  14297. case 10:
  14298. toast("\u8FDB\u5165\u5931\u8D25, \u8BF7\u91CD\u8BD5");
  14299. return _context.abrupt("return");
  14300. case 12:
  14301. _context.prev = 12;
  14302. _context.next = 15;
  14303. return xverse.joinRoom({
  14304. canvas: document.getElementById('canvas'),
  14305. skinId: '10092',
  14306. avatarId: 'KGe_Boy',
  14307. roomId: 'e629ef3e-022d-4e64-8654-703bb96410eb',
  14308. userId: '1f7acca1db9d5',
  14309. wsServerUrl: 'wss://uat-eks.xverse.cn/ws',
  14310. appId: "10016",
  14311. token: " ",
  14312. nickname: '1f7acca1db9d5',
  14313. firends: ["user1"],
  14314. viewMode: "full",
  14315. resolution: {
  14316. width: 1728,
  14317. height: 720
  14318. },
  14319. pathName: 'thirdwalk',
  14320. objectFit: null,
  14321. hasAvatar: !0,
  14322. syncToOthers: !0
  14323. });
  14324. case 15:
  14325. room = _context.sent;
  14326. debugger;
  14327. u();
  14328. c();
  14329. window.room = room;
  14330. e(!1);
  14331. _context.next = 28;
  14332. break;
  14333. case 23:
  14334. _context.prev = 23;
  14335. _context.t1 = _context["catch"](12);
  14336. console.error(_context.t1);
  14337. alert(_context.t1);
  14338. return _context.abrupt("return");
  14339. case 28:
  14340. case "end":
  14341. return _context.stop();
  14342. }
  14343. }
  14344. }, _callee, null, [[0, 5], [12, 23]]);
  14345. }));
  14346. return function l() {
  14347. return _ref.apply(this, arguments);
  14348. };
  14349. }();
  14350. var u = function u() {
  14351. room.on("_coreClick", function (_ref2) {
  14352. var f = _ref2.point;
  14353. room._userAvatar.moveTo({
  14354. point: f
  14355. });
  14356. });
  14357. };
  14358. var c = function c() {
  14359. room.on("repeatLogin", function () {
  14360. toast("\u8BE5\u7528\u6237\u5DF2\u7ECF\u5728\u5176\u4ED6\u5730\u70B9\u767B\u5F55", {
  14361. duration: 1e4
  14362. });
  14363. }), room.on("reconnecting", function (_ref3) {
  14364. var f = _ref3.count;
  14365. toast("\u5C1D\u8BD5\u7B2C".concat(f, "\u6B21\u91CD\u8FDE"));
  14366. }), room.on("reconnected", function () {
  14367. toast("\u91CD\u8FDE\u6210\u529F");
  14368. }), room.on("disconnected", function () {
  14369. var f = toast("\u8FDE\u63A5\u5931\u8D25\uFF0C\u624B\u52A8\u70B9\u51FB\u91CD\u8BD5", {
  14370. duration: 1e5,
  14371. onClick() {
  14372. f.hideToast(), room.reconnect();
  14373. }
  14374. });
  14375. });
  14376. };
  14377. l();
  14378. }));
  14379. //# sourceMappingURL=index.js.map