index.js 632 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251
  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 FRAME_COMPOSE_LENGTH = 5;
  5462. var Workers = /*#__PURE__*/function () {
  5463. function Workers(e, t) {
  5464. var _this = this;
  5465. _classCallCheck(this, Workers);
  5466. 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 = {
  5467. x: 0,
  5468. y: 0,
  5469. z: 0,
  5470. tiles: []
  5471. }, 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 () {
  5472. return DECODER_VERSION;
  5473. }, this.downloadBlob = function (r, n, o) {
  5474. var a = new Blob([r], {
  5475. type: o
  5476. }),
  5477. s = window.URL.createObjectURL(a);
  5478. _this.downloadURL(s, n), setTimeout(function () {
  5479. return window.URL.revokeObjectURL(s);
  5480. }, 1e3);
  5481. }, this.downloadURL = function (r, n) {
  5482. var o = document.createElement("a");
  5483. o.href = r, o.download = n, document.body.appendChild(o), o.style.display = "none", o.click(), o.remove();
  5484. }, this.Stringify = function (r) {
  5485. var n = "";
  5486. for (var a = 0; a < r.length / 8192; a++) {
  5487. n += String.fromCharCode.apply(null, r.slice(a * 8192, (a + 1) * 8192));
  5488. }
  5489. return n;
  5490. }, this._rtcp = e;
  5491. }
  5492. _createClass(Workers, [{
  5493. key: "registerLogger",
  5494. value: function registerLogger(e) {//defaultLogger = e
  5495. }
  5496. }, {
  5497. key: "registerFunction",
  5498. value: function registerFunction(e, t) {
  5499. this.functionMap.set(e, t);
  5500. }
  5501. }, {
  5502. key: "hasFrmCntInCache",
  5503. value: function hasFrmCntInCache(e) {
  5504. var t = -1;
  5505. for (var r = 0; r < this.cacheFrameComposes.length; r++) {
  5506. this.cacheFrameComposes[r].frameCnt == e && (t = r);
  5507. }
  5508. return t;
  5509. }
  5510. }, {
  5511. key: "requestPanoramaTest",
  5512. value: function requestPanoramaTest(e, t, r, n, o) {
  5513. var a = o,
  5514. s = {
  5515. action_type: 16,
  5516. change_rotation_render_type_action: {
  5517. render_type: 5,
  5518. player: {
  5519. position: {
  5520. x: 0,
  5521. y: 0,
  5522. z: 0
  5523. },
  5524. angle: {
  5525. yaw: 0,
  5526. pitch: 0,
  5527. roll: 0
  5528. }
  5529. },
  5530. camera: {
  5531. position: {
  5532. x: e,
  5533. y: t,
  5534. z: r
  5535. },
  5536. angle: {
  5537. yaw: 0,
  5538. pitch: 0,
  5539. roll: 0
  5540. }
  5541. },
  5542. client_pano_titles_bitmap: n
  5543. },
  5544. trace_id: a,
  5545. user_id: this.userId_test,
  5546. packet_id: a
  5547. };
  5548. defaultLogger.debug("send data: ", s), this._rtcp.sendData(s);
  5549. }
  5550. }, {
  5551. key: "onRotateInPanoMode",
  5552. value: function onRotateInPanoMode(e) {
  5553. var t = e.traceId,
  5554. r = {};
  5555. r.width = 1280, r.height = 720, r.horz_fov = 92, r.angle = {
  5556. yaw: 100,
  5557. pitch: 30
  5558. };
  5559. var n = new ArrayBuffer(8),
  5560. o = new DataView(n);
  5561. getTilesInView(r, n);
  5562. var a = n.slice(0);
  5563. this.PendingMasks.unshift({
  5564. buffer: a,
  5565. angle: r.angle
  5566. }), MaskSetToOne(18, this.PanoView), operateForDataView(o, this.PanoView, o, function (s, l) {
  5567. return s ^ s & l;
  5568. }), 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);
  5569. }
  5570. }, {
  5571. key: "processMetaWithTraceId",
  5572. value: function processMetaWithTraceId(e) {
  5573. var _iterator = _createForOfIteratorHelper$4(e.traceIds),
  5574. _step;
  5575. try {
  5576. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  5577. var t = _step.value;
  5578. if (this.traceIdMap.has(t)) {
  5579. var r = this.traceIdMap.get(t);
  5580. r != null && (r.receiveTime = Date.now(), r.status = 1);
  5581. }
  5582. if (t == this.PendingMovingTraceId) {
  5583. 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());
  5584. var _r = Date.now();
  5585. this.lastMoveResponseTime = _r, this.lastMoveProcessTime = _r, this.lastMoveDisplayTime = _r, this.frameServerCircular.clear(), this.frameClientCircular.clear();
  5586. }
  5587. }
  5588. } catch (err) {
  5589. _iterator.e(err);
  5590. } finally {
  5591. _iterator.f();
  5592. }
  5593. }
  5594. }, {
  5595. key: "onTraceId",
  5596. value: function onTraceId(e) {
  5597. var _this2 = this;
  5598. var r = e.traceId,
  5599. n = e.timestamp,
  5600. o = e.event;
  5601. if (o === "Rotation") {
  5602. var a = {
  5603. traceId: r,
  5604. pts: 0,
  5605. startTime: n,
  5606. receiveTime: 0,
  5607. readyTime: 0,
  5608. displayTime: 0,
  5609. status: 0
  5610. };
  5611. this.traceIdMap.set(r, a);
  5612. var s = setTimeout(function () {
  5613. if (s && clearTimeout(s), _this2.traceIdMap.has(r)) {
  5614. var l = _this2.traceIdMap.get(r);
  5615. switch (l == null ? void 0 : l.status) {
  5616. case 0:
  5617. {
  5618. _this2.responseMiss += 1;
  5619. break;
  5620. }
  5621. case 1:
  5622. {
  5623. _this2.processMiss += 1;
  5624. var u = l.receiveTime - l.startTime;
  5625. _this2.responseTimeArray.push(u);
  5626. break;
  5627. }
  5628. case 2:
  5629. {
  5630. _this2.displayMiss += 1;
  5631. var _u = l.receiveTime - l.startTime,
  5632. c = l.readyTime - l.receiveTime;
  5633. _this2.responseTimeArray.push(_u), _this2.processTimeArray.push(c);
  5634. break;
  5635. }
  5636. case 3:
  5637. defaultLogger.debug("status is 3");
  5638. }
  5639. }
  5640. }, 1e3);
  5641. } 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();
  5642. }
  5643. }, {
  5644. key: "executeFunction",
  5645. value: function executeFunction(e, t) {
  5646. if (this.functionMap.has(e)) {
  5647. var r = this.functionMap.get(e);
  5648. r != null && r(t);
  5649. }
  5650. }
  5651. }, {
  5652. key: "UpdateStats",
  5653. value: function UpdateStats(e) {
  5654. var _this3 = this;
  5655. var t;
  5656. (t = this._rtcp.connection) == null || t.getStats(null).then(function (r) {
  5657. r.forEach(function (n) {
  5658. n.type == "data-channel" && (_this3.rtcMessageReceived = n.messagesReceived - n.messagesSent, _this3.rtcBytesReceived = n.bytesReceived);
  5659. });
  5660. }), 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;
  5661. }
  5662. }, {
  5663. key: "ReceiveDecodeMessage",
  5664. value: function ReceiveDecodeMessage(e) {
  5665. var n;
  5666. if (!this.firstYUVReceived) {
  5667. this.firstYUVDecoded = e.data.yuv_ts;
  5668. var o = this.firstYUVDecoded - this.rtcp.network.room._startTime;
  5669. defaultLogger.infoAndReportMeasurement({
  5670. metric: "firstYUVDecodedAt",
  5671. value: o,
  5672. group: "joinRoom"
  5673. }), this.firstRender = Date.now();
  5674. var a = this.firstYUVDecoded - this.rtcp.network.room._startTime;
  5675. defaultLogger.infoAndReportMeasurement({
  5676. metric: "firstRenderAt",
  5677. value: a,
  5678. group: "joinRoom"
  5679. }), this.firstYUVReceived = !0, this.lastRenderTs = Date.now();
  5680. }
  5681. !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", {
  5682. stream: this.cachedStreams[this.setPtr],
  5683. width: this.cachedResolution[this.setPtr].width,
  5684. height: this.cachedResolution[this.setPtr].height,
  5685. pts: this.cachedPtss[this.setPtr]
  5686. }), this.executeFunction("signal", {
  5687. signal: this.cachedMetas[this.setPtr],
  5688. pts: this.cachedPtss[this.setPtr],
  5689. alreadyUpdateYUV: !0
  5690. })) : this.updateDropFrame += 1, this.decoderWorker.postMessage({
  5691. t: 2,
  5692. frameCnt: this.cachedPtss[this.setPtr],
  5693. buffer: this.cachedStreams[this.setPtr]
  5694. }, [this.cachedStreams[this.setPtr].buffer])), this.getPtr = (this.getPtr + 1) % this.cachedLength);
  5695. var t = e.data.metadata;
  5696. if ((n = t == null ? void 0 : t.traceIds) != null && n.length) {
  5697. var _iterator2 = _createForOfIteratorHelper$4(t.traceIds),
  5698. _step2;
  5699. try {
  5700. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  5701. var _o = _step2.value;
  5702. if (this.traceIdMap.has(_o)) {
  5703. var _a = this.traceIdMap.get(_o);
  5704. _a != null && (_a.readyTime = Date.now(), _a.status = 2);
  5705. }
  5706. }
  5707. } catch (err) {
  5708. _iterator2.e(err);
  5709. } finally {
  5710. _iterator2.f();
  5711. }
  5712. }
  5713. if (e.data.pts == this.moveStartPts && (this.MoveProcessDelay = Date.now() - this.StartMovingTs), this.userId_test = this.rtcp.network.room.userId, this.inMovingMode) {
  5714. var _o2 = Date.now(),
  5715. _a2 = _o2 - this.lastMoveProcessTime;
  5716. this.moveProcessCircular.add(_a2), this.lastMoveProcessTime = _o2;
  5717. }
  5718. var r = this.setPtr;
  5719. 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] = {
  5720. width: e.data.width,
  5721. height: e.data.height
  5722. }, this.setPtr = (this.setPtr + 1) % this.cachedLength;
  5723. }
  5724. }, {
  5725. key: "SendCacheFrameInfo",
  5726. value: function SendCacheFrameInfo(e) {
  5727. var _this4 = this;
  5728. var h, f, d, _, g, m, v;
  5729. var t = e.data.cachedKey,
  5730. r = e.data.metadata,
  5731. n = t,
  5732. o = r,
  5733. a = (d = (f = (h = o.newUserStates) == null ? void 0 : h.find(function (y) {
  5734. return y.userId === _this4.rtcp.network.room.userId;
  5735. })) == null ? void 0 : f.playerState) == null ? void 0 : d.roomTypeId,
  5736. s = this.rtcp.network.room.skinId,
  5737. l = (v = (m = (g = (_ = o.newUserStates) == null ? void 0 : _.find(function (y) {
  5738. return y.userId === _this4._rtcp.network.room.userId;
  5739. })) == null ? void 0 : g.playerState) == null ? void 0 : m.player) == null ? void 0 : v.position,
  5740. u = {
  5741. MsgType: 1,
  5742. FrameCacheMsg: {
  5743. FrameIndex: n,
  5744. RoomTypeId: a,
  5745. SkinID: s,
  5746. Position: l
  5747. }
  5748. };
  5749. var c = "";
  5750. try {
  5751. c = JSON.stringify(u);
  5752. } catch (y) {
  5753. defaultLogger.error(y);
  5754. return;
  5755. }
  5756. }
  5757. }, {
  5758. key: "ReceivePanoramaDecodeMessage",
  5759. value: function ReceivePanoramaDecodeMessage(e) {
  5760. defaultLogger.info("Receive Panorama Image in Workers.ts"), MaskSetToOne(e.data.tileId, this.PanoView);
  5761. var t = 0,
  5762. r;
  5763. var n = this.PendingMasks.length;
  5764. for (t = 0; t < n; t++) {
  5765. var o = this.PendingMasks[t].buffer,
  5766. a = new DataView(o),
  5767. s = new ArrayBuffer(8),
  5768. l = new DataView(s);
  5769. if (operateForDataView(this.PanoView, a, l, function (u, c) {
  5770. return c ^ u & c;
  5771. }), IsAll0(l)) {
  5772. r = this.PendingMasks[t].angle;
  5773. break;
  5774. }
  5775. }
  5776. for (var _o3 = t; _o3 < n; _o3++) {
  5777. this.PendingMasks.pop();
  5778. }
  5779. this.executeFunction("panorama", {
  5780. data: e.data.data,
  5781. tileId: e.data.tileId,
  5782. pos: {
  5783. x: e.data.x,
  5784. y: e.data.y,
  5785. z: e.data.z
  5786. },
  5787. uuid: e.data.uuid,
  5788. finished: !0,
  5789. matchAngle: r
  5790. });
  5791. }
  5792. }, {
  5793. key: "enable_decoder_queue_logging",
  5794. value: function enable_decoder_queue_logging() {
  5795. this.decoderWorker.postMessage({
  5796. t: 100,
  5797. status: !0
  5798. });
  5799. }
  5800. }, {
  5801. key: "disable_decoder_queue_logging",
  5802. value: function disable_decoder_queue_logging() {
  5803. this.decoderWorker.postMessage({
  5804. t: 100,
  5805. status: !1
  5806. });
  5807. }
  5808. }, {
  5809. key: "init",
  5810. value: function () {
  5811. var _init = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
  5812. var r,
  5813. n,
  5814. t;
  5815. return regenerator.wrap(function _callee$(_context) {
  5816. while (1) {
  5817. switch (_context.prev = _context.next) {
  5818. case 0:
  5819. for (r = 0; r < FRAME_COMPOSE_LENGTH; r++) {
  5820. n = {
  5821. buffer: new Uint8Array(2621440),
  5822. size: 0,
  5823. startReceiveTime: 0,
  5824. serverTime: 0,
  5825. frameCnt: -1
  5826. };
  5827. this.cacheFrameComposes.push(n);
  5828. }
  5829. t = new Blob([decoder], {
  5830. type: "application/javascript"
  5831. });
  5832. return _context.abrupt("return", (this.decoderWorker = new Worker(URL.createObjectURL(t)), this.decoderWorker.postMessage({
  5833. t: 9,
  5834. url: WASM_URLS[WASM_Version],
  5835. jitterLength: DECODER_PASSIVE_JITTER
  5836. })));
  5837. case 5:
  5838. case "end":
  5839. return _context.stop();
  5840. }
  5841. }
  5842. }, _callee, this);
  5843. }));
  5844. function init() {
  5845. return _init.apply(this, arguments);
  5846. }
  5847. return init;
  5848. }()
  5849. }, {
  5850. key: "UpdateYUV",
  5851. value: function UpdateYUV() {
  5852. var t, r;
  5853. var e = this.getPtr;
  5854. if (this.cachedMetas[e] != null && !this.cachedRender[e]) {
  5855. var n = Date.now();
  5856. if (this.firstUpdateYUV) {
  5857. var h = ((t = this.cachedStreams[e]) == null ? void 0 : t.byteLength) || 0;
  5858. defaultLogger.infoAndReportMeasurement({
  5859. metric: "firstUpdateStreamLength",
  5860. value: h,
  5861. group: "joinRoom"
  5862. }), this.firstUpdateYUV = !1;
  5863. }
  5864. this.cachedStreams[e] != null && this.executeFunction("stream", {
  5865. stream: this.cachedStreams[e],
  5866. width: this.cachedResolution[e].width,
  5867. height: this.cachedResolution[e].height,
  5868. pts: this.cachedPtss[e]
  5869. });
  5870. var o = Date.now();
  5871. this.cachedStreams[e] != null && this.decoderWorker.postMessage({
  5872. t: 2,
  5873. frameCnt: this.cachedPtss[e],
  5874. buffer: this.cachedStreams[e]
  5875. }, [this.cachedStreams[e].buffer]);
  5876. var a = Date.now(),
  5877. s = o - n,
  5878. l = a - o;
  5879. (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;
  5880. var u = o - n;
  5881. this.updateYUVCircular.add(u);
  5882. var c = this.cachedMetas[e];
  5883. if ((r = c == null ? void 0 : c.traceIds) != null && r.length) {
  5884. var _iterator3 = _createForOfIteratorHelper$4(c.traceIds),
  5885. _step3;
  5886. try {
  5887. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  5888. var _h = _step3.value;
  5889. if (this.traceIdMap.has(_h)) {
  5890. var f = this.traceIdMap.get(_h);
  5891. if (f != null) {
  5892. f.displayTime = Date.now(), f.status = 3;
  5893. var d = f.receiveTime - f.startTime,
  5894. _ = f.readyTime - f.receiveTime,
  5895. g = f.displayTime - f.readyTime,
  5896. m = f.displayTime - f.startTime;
  5897. this.responseTimeArray.push(d), this.processTimeArray.push(_), this.displayTimeArray.push(g), this.overallTimeArray.push(m), this.traceIdMap.delete(_h);
  5898. }
  5899. }
  5900. }
  5901. } catch (err) {
  5902. _iterator3.e(err);
  5903. } finally {
  5904. _iterator3.f();
  5905. }
  5906. }
  5907. if (this.cachedPtss[e] == this.moveStartPts && (this.MoveDisplayDelay = Date.now() - this.StartMovingTs), this.inMovingMode) {
  5908. var _h2 = Date.now(),
  5909. _f = _h2 - this.lastMoveDisplayTime;
  5910. this.moveDisplayCircular.add(_f), this.lastMoveDisplayTime = _h2;
  5911. }
  5912. this.executeFunction("signal", {
  5913. signal: this.cachedMetas[e],
  5914. pts: this.cachedPtss[e],
  5915. alreadyUpdateYUV: !0
  5916. }), this.cachedRender[e] = !0, this.getPtr = (this.getPtr + 1) % this.cachedLength;
  5917. }
  5918. }
  5919. }, {
  5920. key: "unmarshalPano",
  5921. value: function unmarshalPano(e) {
  5922. var t = new DataView(e);
  5923. if (t.getUint32(0) != 1723558763) return !1;
  5924. console.log("Receive Pano Message"), t.getUint16(4);
  5925. var n = t.getUint16(6),
  5926. o = t.getUint32(8),
  5927. a = t.getUint32(12) - (1 << 30) * 2,
  5928. s = t.getUint32(16) - (1 << 30) * 2,
  5929. l = t.getUint32(20) - (1 << 30) * 2,
  5930. u = t.getUint32(24),
  5931. c = new Uint8Array(e).subarray(28, 64),
  5932. h = String.fromCharCode.apply(null, c),
  5933. f = t.getUint32(64),
  5934. d = e.byteLength - n;
  5935. if (d == u) {
  5936. var g = {
  5937. data: new Uint8Array(e).subarray(n),
  5938. mediaLen: u,
  5939. tileId: o,
  5940. uuid: h,
  5941. x: a,
  5942. y: s,
  5943. z: l
  5944. };
  5945. this.decoderWorker.postMessage({
  5946. t: 8,
  5947. data: g
  5948. });
  5949. } else {
  5950. var _ = new Uint8Array(e, n, d);
  5951. if (this.cachePanoTileID == o) {
  5952. if (this.panoCacheBuffer.set(_, f), this.panoCacheSize += d, this.panoCacheSize === u) {
  5953. var m = {
  5954. data: new Uint8Array(this.panoCacheBuffer).slice(0, u),
  5955. mediaLen: u,
  5956. tileId: o,
  5957. uuid: h,
  5958. x: a,
  5959. y: s,
  5960. z: l
  5961. };
  5962. this.decoderWorker.postMessage({
  5963. t: 8,
  5964. data: m
  5965. }), this.panoCacheSize = 0;
  5966. }
  5967. } else this.panoCacheBuffer.set(_, f), this.panoCacheSize = d, this.cachePanoTileID = o;
  5968. }
  5969. return !0;
  5970. }
  5971. }, {
  5972. key: "clearMoveArray",
  5973. value: function clearMoveArray() {
  5974. 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 = "";
  5975. }
  5976. }, {
  5977. key: "getIsMoving",
  5978. value: function getIsMoving(e) {
  5979. var t;
  5980. if (typeof e.newUserStates != "undefined") for (var r = 0; r < e.newUserStates.length; r++) {
  5981. var n = e.newUserStates[r];
  5982. if (n.userId == this.rtcp.network.room.userId) {
  5983. t = n.renderInfo.isMoving;
  5984. break;
  5985. }
  5986. }
  5987. return t;
  5988. }
  5989. }, {
  5990. key: "isHeartBeatPacket",
  5991. value: function isHeartBeatPacket(e, t) {
  5992. return new DataView(e).getUint32(0) == 2009889916;
  5993. }
  5994. }, {
  5995. key: "resetSendTimeDiff",
  5996. value: function resetSendTimeDiff() {
  5997. this.prevSenderTs = 0, this.serverSendTimeArray.clear();
  5998. }
  5999. }, {
  6000. key: "calcSendTimeDiff",
  6001. value: function calcSendTimeDiff(e) {
  6002. if (this.prevSenderTs == -1) {
  6003. this.prevSenderTs = e;
  6004. return;
  6005. }
  6006. var t = e - this.prevSenderTs;
  6007. this.serverSendTimeArray.add(t), this.prevSenderTs = e;
  6008. }
  6009. }, {
  6010. key: "unmarshalStream",
  6011. value: function unmarshalStream(e) {
  6012. var _this6 = this;
  6013. var T, C, A, S, P, R, M, x, I, w;
  6014. var t = new DataView(e);
  6015. if (t.getUint32(0) != 1437227610) return !1;
  6016. t.getUint16(4);
  6017. var n = t.getUint16(6),
  6018. o = t.getUint16(8),
  6019. a = o,
  6020. s = t.getUint16(10);
  6021. var l = !1;
  6022. s == 1 && (l = !0);
  6023. var u = t.getUint32(12),
  6024. c = t.getUint32(16),
  6025. h = t.getUint32(20),
  6026. f = t.getUint16(24),
  6027. d = t.getUint16(26),
  6028. _ = t.getUint32(28),
  6029. g = t.getUint32(n - 4),
  6030. m = u + c,
  6031. v = e.byteLength - n,
  6032. y = new Uint8Array(e, n, v);
  6033. this.calcSendTimeDiff(h);
  6034. var b;
  6035. if (this.inPanoMode && (c > 0 || f)) return defaultLogger.error("Stream Protocal Violation: receive illegal stream in Pano mode"), !0;
  6036. if (v === m) {
  6037. this.receivedMedia++;
  6038. var O = new Uint8Array(e).subarray(n);
  6039. h - this.lastServerTS > 60 ? this.serverFrameSlow++ : h - this.lastServerTS < 16 && this.serverFrameFast++;
  6040. var D = Date.now();
  6041. D - this.lastClientTS > 60 ? this.clientFrameSlow++ : D - this.lastClientTS < 16 && this.clientFrameFast++;
  6042. var F = c === 0,
  6043. V = h - this.lastServerTS;
  6044. 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;
  6045. var N = O.subarray(0, u),
  6046. L = Date.now(),
  6047. k = JSON.parse(this.Stringify(N)),
  6048. U = Date.now();
  6049. 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));
  6050. var z = this.getIsMoving(k);
  6051. if (this.inMovingMode && z == 0 && this.lastIsMoving == 1 && this.clearMoveArray(), typeof z != "undefined" && (this.lastIsMoving = z), this.inMovingMode) {
  6052. var G = Date.now(),
  6053. W = G - this.lastMoveResponseTime;
  6054. this.moveResponseCircular.add(W), this.lastMoveResponseTime = G;
  6055. }
  6056. (f || d) && (b = (P = (S = (A = (C = k.newUserStates) == null ? void 0 : C.find(function (G) {
  6057. return G.userId === _this6._rtcp.network.room.userId;
  6058. })) == null ? void 0 : A.playerState) == null ? void 0 : S.player) == null ? void 0 : P.position);
  6059. var H = {
  6060. t: 0,
  6061. data: O,
  6062. mediaLen: c,
  6063. metaLen: u,
  6064. metadata: k,
  6065. frameCnt: a,
  6066. server_ts: h,
  6067. isIDR: l,
  6068. cacheRequest: d,
  6069. cached: f,
  6070. cachedKey: _,
  6071. position: b
  6072. };
  6073. if (this.inPanoMode) return this.executeFunction("signal", {
  6074. signal: k,
  6075. pts: -1,
  6076. alreadyUpdateYUV: !0
  6077. }), !0;
  6078. if (this.decoderWorker.postMessage(H, [O.buffer]), !this.firstMediaReceived) {
  6079. this.firstMediaArraval = Date.now();
  6080. var _G = this.firstMediaArraval - this.rtcp.network.room._startTime;
  6081. defaultLogger.infoAndReportMeasurement({
  6082. metric: "firstMediaArravalAt",
  6083. value: _G,
  6084. group: "joinRoom"
  6085. }), this.firstMediaReceived = !0;
  6086. }
  6087. } else {
  6088. var _O = this.hasFrmCntInCache(a);
  6089. if (_O != -1) {
  6090. if (this.cacheFrameComposes[_O].buffer.set(y, g), this.cacheFrameComposes[_O].size += v, this.cacheFrameComposes[_O].size === m) {
  6091. var _D = new Uint8Array(this.cacheFrameComposes[_O].buffer).slice(0, m);
  6092. 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++;
  6093. var _F = Date.now();
  6094. _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;
  6095. var _V = _D.subarray(0, u),
  6096. _N = Date.now(),
  6097. _L = JSON.parse(this.Stringify(_V)),
  6098. _k = Date.now();
  6099. 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);
  6100. var _U = this.getIsMoving(_L);
  6101. if (this.inMovingMode && _U == 0 && this.lastIsMoving == 1 && this.clearMoveArray(), typeof _U != "undefined" && (this.lastIsMoving = _U), this.inMovingMode) {
  6102. var _H = Date.now(),
  6103. _G2 = _H - this.lastMoveResponseTime;
  6104. this.moveResponseCircular.add(_G2), this.lastMoveResponseTime = _H;
  6105. }
  6106. (f || d) && (b = (w = (I = (x = (M = _L.newUserStates) == null ? void 0 : M.find(function (H) {
  6107. return H.userId === _this6._rtcp.network.room.userId;
  6108. })) == null ? void 0 : x.playerState) == null ? void 0 : I.player) == null ? void 0 : w.position);
  6109. var _z = {
  6110. t: 0,
  6111. data: _D,
  6112. mediaLen: c,
  6113. metaLen: u,
  6114. metadata: _L,
  6115. frameCnt: a,
  6116. server_ts: h,
  6117. isIDR: l,
  6118. cacheRequest: d,
  6119. cached: f,
  6120. cachedKey: _,
  6121. position: b
  6122. };
  6123. if (this.inPanoMode) return this.executeFunction("signal", {
  6124. signal: _L,
  6125. pts: -1,
  6126. alreadyUpdateYUV: !0
  6127. }), !0;
  6128. if (this.decoderWorker.postMessage(_z, [_D.buffer]), !this.firstMediaReceived) {
  6129. this.firstMediaArraval = Date.now();
  6130. var _H2 = this.firstMediaArraval - this.rtcp.network.room._startTime;
  6131. defaultLogger.infoAndReportMeasurement({
  6132. metric: "firstMediaArravalAt",
  6133. value: _H2,
  6134. group: "joinRoom"
  6135. }), this.firstMediaReceived = !0;
  6136. }
  6137. } else this.cacheFrameComposes[_O].size > m && defaultLogger.debug("I frame exceed, cache size is ", this.cacheSize, ", total size is ", m);
  6138. } else if (_O == -1) {
  6139. var _D2 = this.hasFrmCntInCache(-1);
  6140. if (_D2 == -1) {
  6141. var _F2 = Date.now() + 1e18,
  6142. _V2 = -1;
  6143. for (var _N2 = 0; _N2 < this.cacheFrameComposes.length; _N2++) {
  6144. this.cacheFrameComposes[_N2].serverTime < _F2 && (_F2 = this.cacheFrameComposes[_N2].serverTime, _V2 = _N2);
  6145. }
  6146. _D2 = _V2;
  6147. }
  6148. 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;
  6149. }
  6150. }
  6151. return !0;
  6152. }
  6153. }, {
  6154. key: "reset",
  6155. value: function reset() {
  6156. defaultLogger.debug("Worker reset is called"), this.cacheFrameCnt = 0, this.receivedMedia = 0, this.reconnectSignal = !0, this.decoderWorker.postMessage({
  6157. t: 4
  6158. });
  6159. }
  6160. }, {
  6161. key: "dataHandleOff",
  6162. value: function dataHandleOff(e) {
  6163. defaultLogger.debug("hhh");
  6164. }
  6165. }, {
  6166. key: "dataHandle",
  6167. value: function dataHandle(e) {
  6168. this.saveframe && (this.decoderWorker.postMessage({
  6169. t: 6
  6170. }), this.saveframe = !1), this.SaveMediaStream && (this.decoderWorker.postMessage({
  6171. t: 7
  6172. }), this.SaveMediaStream = !1);
  6173. var t = new Uint8Array(e);
  6174. if (t.length >= 4 && this.isHeartBeatPacket(t.buffer, t.length) == !0) return;
  6175. if (t.length > 36 && this.unmarshalStream(t.buffer) == !0) {
  6176. this.reconnectSignal && (this.executeFunction("reconnectedFrame", {}), this.reconnectSignal = !1);
  6177. return;
  6178. }
  6179. if (t.length > 20 && this.unmarshalPano(t.buffer) == !0) return;
  6180. this.noWasmBytesReceived += e.byteLength;
  6181. var r = JSON.parse(this.Stringify(t));
  6182. this.executeFunction("signal", {
  6183. signal: r,
  6184. pts: -1,
  6185. alreadyUpdateYUV: !0
  6186. });
  6187. }
  6188. }, {
  6189. key: "changePanoMode",
  6190. value: function changePanoMode(e) {
  6191. this.inPanoMode = e;
  6192. }
  6193. }, {
  6194. key: "uploadDataToServer",
  6195. value: function uploadDataToServer() {
  6196. this.DynamicPanoTest == !0 && (this.onRotateInPanoMode({
  6197. traceId: "b2e1a296-6438-4371-8a31-687beb724ebe"
  6198. }), this.DynamicPanoTest = !1);
  6199. function e(ie, ee) {
  6200. return ee == -1 && (ee = 0), ie + ee;
  6201. }
  6202. function t(ie, ee) {
  6203. return Math.max(ie, ee);
  6204. }
  6205. var r = this.responseTimeArray.reduce(e, 0) / this.responseTimeArray.length || 0,
  6206. n = this.processTimeArray.reduce(e, 0) / this.processTimeArray.length || 0,
  6207. o = this.displayTimeArray.reduce(e, 0) / this.displayTimeArray.length || 0,
  6208. a = this.overallTimeArray.reduce(e, 0) / this.overallTimeArray.length || 0,
  6209. s = this.overallTimeArray.length;
  6210. this.responseTimeArray = [], this.processTimeArray = [], this.displayTimeArray = [], this.overallTimeArray = [];
  6211. var l = this.moveResponseCircular.getThreshPercent(),
  6212. u = l[0],
  6213. c = l[1],
  6214. h = l[2],
  6215. f = l[3],
  6216. d = l[4],
  6217. _ = d - f,
  6218. g = 1 - c / d || 0,
  6219. m = [u, c - u, h - c, f - h, _],
  6220. v = this.moveProcessCircular.getThreshPercent(),
  6221. y = v[0],
  6222. b = v[1],
  6223. T = v[2],
  6224. C = v[3],
  6225. A = v[4],
  6226. S = A - C,
  6227. P = 1 - b / A || 0,
  6228. R = [y, b - y, T - b, C - T, S],
  6229. M = this.moveDisplayCircular.getThreshPercent(),
  6230. x = M[0],
  6231. I = M[1],
  6232. w = M[2],
  6233. O = M[3],
  6234. D = M[4],
  6235. F = D - O,
  6236. V = 1 - I / D || 0,
  6237. N = [x, I - x, w - I, O - w, F],
  6238. L = x,
  6239. k = I - x,
  6240. U = w - I,
  6241. z = O - w,
  6242. H = F,
  6243. G = this.moveResponseCircular.getAvg(),
  6244. W = this.moveProcessCircular.getAvg(),
  6245. j = this.moveDisplayCircular.getAvg(),
  6246. B = this.moveResponseCircular.getMax(),
  6247. X = this.moveProcessCircular.getMax(),
  6248. $ = this.moveDisplayCircular.getMax(),
  6249. Y = this.moveResponseCircular.getStandardDeviation(),
  6250. K = this.moveProcessCircular.getStandardDeviation(),
  6251. Z = this.moveDisplayCircular.getStandardDeviation();
  6252. 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();
  6253. var q = this.frameServerCircular.getAvg(),
  6254. J = this.frameServerCircular.getMax();
  6255. this.frameClientCircular.getAvg(), this.frameClientCircular.getMax();
  6256. var Q = this.metaParseAraay.reduce(e, 0) / this.metaParseAraay.length || 0,
  6257. te = this.metaParseAraay.reduce(t, 0);
  6258. this.metaParseAraay = [];
  6259. var re = {
  6260. mediaBytesReceived: this.mediaBytesReceived,
  6261. metaBytesReceived: this.metaBytesReceived,
  6262. packetsLost: this.packetsLost,
  6263. timestamp: Date.now(),
  6264. frameHeight: 1280,
  6265. frameWidth: 720,
  6266. framesReceived: this.receivedMedia,
  6267. framesReceivedWorker: this.receivedMedia_worker,
  6268. framesDecoded: this.receivedYUV,
  6269. framesEmited: this.receivedEmit,
  6270. decodeTimePerFrame: this.decodeTimePerFrame,
  6271. decodeTimeMaxFrame: this.decodeTimeMaxFrame,
  6272. packetsDrop: this.packetsDrop,
  6273. framesAwait: this.framesAwait,
  6274. firstMediaArraval: this.firstMediaArraval,
  6275. firstYUVDecoded: this.firstYUVDecoded,
  6276. firstRender: this.firstRender,
  6277. returnFrames: this.returnFrames,
  6278. sendOutBuffer: this.sendOutBuffer,
  6279. maxGraphicTime: this.updateYUVCircular.getMax(),
  6280. averageGraphicTime: this.updateYUVCircular.getAvg(),
  6281. jankTimes: this.JankTimes,
  6282. bigJankTimes: this.bigJankTimes,
  6283. decodeJankTimes: this.DecodeJankTimes,
  6284. bigDecodeJankTimes: this.bigDecodeJankTimes,
  6285. serverFrameSlow: this.serverFrameSlow,
  6286. serverFrameFast: this.serverFrameFast,
  6287. clientFrameSlow: this.clientFrameSlow,
  6288. clientFrameFast: this.clientFrameFast,
  6289. rtcMessageReceived: this.rtcMessageReceived,
  6290. rtcBytesReceived: this.rtcBytesReceived - this.noWasmBytesReceived,
  6291. receiveIframes: this.receiveIframes,
  6292. decodeIframes: this.decodeIframes,
  6293. avgResponseTime: r,
  6294. avgProcessTime: n,
  6295. avgDisplayTime: o,
  6296. avgOverallTime: a,
  6297. overallTimeCount: s,
  6298. responseMiss: this.responseMiss,
  6299. processMiss: this.processMiss,
  6300. displayMiss: this.displayMiss,
  6301. updateDropFrame: this.updateDropFrame,
  6302. moveEvent: this.moveEvent,
  6303. avgResponseMoveDiff: this.moveEvent == "MoveTo" ? G : 0,
  6304. avgProcessMoveDiff: this.moveEvent == "MoveTo" ? W : 0,
  6305. avgDisplayMoveDiff: this.moveEvent == "MoveTo" ? j : 0,
  6306. maxResponseMoveDiff: this.moveEvent == "MoveTo" ? B : 0,
  6307. maxProcessMoveDiff: this.moveEvent == "MoveTo" ? X : 0,
  6308. maxDisplayMoveDiff: this.moveEvent == "MoveTo" ? $ : 0,
  6309. moveResponseJank: this.moveEvent == "MoveTo" ? g : 0,
  6310. moveProcessJank: this.moveEvent == "MoveTo" ? P : 0,
  6311. moveDisplayJank: this.moveEvent == "MoveTo" ? V : 0,
  6312. moveResponseCounts: this.moveEvent == "MoveTo" ? m.toString() : "0,0,0,0,0",
  6313. moveProcessCounts: this.moveEvent == "MoveTo" ? R.toString() : "0,0,0,0,0",
  6314. moveDisplayCounts: this.moveEvent == "MoveTo" ? N.toString() : "0,0,0,0,0",
  6315. MoveDisplayCountGood: this.moveEvent == "MoveTo" ? L.toString() : "0",
  6316. MoveDisplayCountWell: this.moveEvent == "MoveTo" ? k.toString() : "0",
  6317. MoveDisplayCountFair: this.moveEvent == "MoveTo" ? U.toString() : "0",
  6318. MoveDisplayCountBad: this.moveEvent == "MoveTo" ? z.toString() : "0",
  6319. MoveDisplayCountRest: this.moveEvent == "MoveTo" ? H.toString() : "0",
  6320. moveResponseDelay: this.moveEvent == "MoveTo" ? this.MoveResponseDelay : 0,
  6321. moveProcessDelay: this.moveEvent == "MoveTo" ? this.MoveProcessDelay : 0,
  6322. moveDisplayDelay: this.moveEvent == "MoveTo" ? this.MoveDisplayDelay : 0,
  6323. sdMoveResponseLongTime: Y,
  6324. sdMoveProcessLongTime: K,
  6325. sdMoveDisplayLongTime: Z,
  6326. avgResponseFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? G : 0,
  6327. avgProcessFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? W : 0,
  6328. avgDisplayFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? j : 0,
  6329. maxResponseFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? B : 0,
  6330. maxProcessFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? X : 0,
  6331. maxDisplayFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? $ : 0,
  6332. flyResponseJank: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? g : 0,
  6333. flyProcessJank: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? P : 0,
  6334. flyDisplayJank: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? V : 0,
  6335. flyResponseCounts: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? m.toString() : "0,0,0,0,0",
  6336. flyProcessCounts: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? R.toString() : "0,0,0,0,0",
  6337. flyDisplayCounts: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? N.toString() : "0,0,0,0,0",
  6338. flyResponseDelay: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? this.MoveResponseDelay : 0,
  6339. flyProcessDelay: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? this.MoveProcessDelay : 0,
  6340. flyDisplayDelay: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? this.MoveDisplayDelay : 0,
  6341. avgMetaParseTime: Q,
  6342. maxMetaParseTime: te,
  6343. avgServerDiff: q,
  6344. maxServerDiff: J,
  6345. streamType: WASM_Version
  6346. };
  6347. return this.lastReturnFrames = this.returnFrames, this.lastReceivedEmit = this.receivedEmit, re;
  6348. }
  6349. }]);
  6350. return Workers;
  6351. }();
  6352. 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); }; }
  6353. 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; } }
  6354. var Rtcp = /*#__PURE__*/function (_EventEmitter) {
  6355. _inherits(Rtcp, _EventEmitter);
  6356. var _super = _createSuper$7(Rtcp);
  6357. function Rtcp(e) {
  6358. var _this;
  6359. _classCallCheck(this, Rtcp);
  6360. _this = _super.call(this);
  6361. E(_assertThisInitialized(_this), "connection", null);
  6362. E(_assertThisInitialized(_this), "inputChannel", null);
  6363. E(_assertThisInitialized(_this), "mediaStream");
  6364. E(_assertThisInitialized(_this), "socket");
  6365. E(_assertThisInitialized(_this), "connected", !1);
  6366. E(_assertThisInitialized(_this), "candidates", []);
  6367. E(_assertThisInitialized(_this), "isAnswered", !1);
  6368. E(_assertThisInitialized(_this), "isFlushing", !1);
  6369. E(_assertThisInitialized(_this), "inputReady", !1);
  6370. E(_assertThisInitialized(_this), "workers");
  6371. E(_assertThisInitialized(_this), "actived", !0);
  6372. E(_assertThisInitialized(_this), "heartbeat");
  6373. E(_assertThisInitialized(_this), "onIcecandidate", function (e) {
  6374. if (e.candidate != null) {
  6375. var t = JSON.stringify(e.candidate);
  6376. logger$1.debug("Got ice candidate: ".concat(t)), _this.network.socket.send({
  6377. id: "ice_candidate",
  6378. data: btoa(t)
  6379. });
  6380. }
  6381. });
  6382. E(_assertThisInitialized(_this), "onIcecandidateerror", function (e) {
  6383. logger$1.error("onicecandidateerror", e.errorCode, e.errorText, e);
  6384. });
  6385. E(_assertThisInitialized(_this), "onIceStateChange", function (e) {
  6386. switch (e.target.iceGatheringState) {
  6387. case "gathering":
  6388. logger$1.info("ice gathering");
  6389. break;
  6390. case "complete":
  6391. logger$1.info("Ice gathering completed");
  6392. }
  6393. });
  6394. E(_assertThisInitialized(_this), "onIceConnectionStateChange", function () {
  6395. if (!!_this.connection) switch (logger$1.info("iceConnectionState: ".concat(_this.connection.iceConnectionState)), _this.connection.iceConnectionState) {
  6396. case "connected":
  6397. {
  6398. _this.connected = !0;
  6399. break;
  6400. }
  6401. case "disconnected":
  6402. {
  6403. _this.connected = !1, _this.emit("rtcDisconnected");
  6404. break;
  6405. }
  6406. case "failed":
  6407. {
  6408. _this.emit("rtcDisconnected"), _this.connected = !1;
  6409. break;
  6410. }
  6411. }
  6412. });
  6413. E(_assertThisInitialized(_this), "setRemoteDescription", /*#__PURE__*/function () {
  6414. var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e, t) {
  6415. var a, s, l, r, n, o, u;
  6416. return regenerator.wrap(function _callee$(_context) {
  6417. while (1) {
  6418. switch (_context.prev = _context.next) {
  6419. case 0:
  6420. if (_this.connection) {
  6421. _context.next = 2;
  6422. break;
  6423. }
  6424. return _context.abrupt("return");
  6425. case 2:
  6426. r = JSON.parse(atob(e)), n = new RTCSessionDescription(r);
  6427. _context.next = 5;
  6428. return _this.connection.setRemoteDescription(n);
  6429. case 5:
  6430. _context.next = 7;
  6431. return _this.connection.createAnswer();
  6432. case 7:
  6433. o = _context.sent;
  6434. 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) {
  6435. u = o.sdp.lastIndexOf("a=mid:1");
  6436. o.sdp = o.sdp.slice(0, u) + "a=mid:2" + o.sdp.slice(u + 7);
  6437. }
  6438. _context.prev = 9;
  6439. _context.next = 12;
  6440. return _this.connection.setLocalDescription(o);
  6441. case 12:
  6442. _context.next = 17;
  6443. break;
  6444. case 14:
  6445. _context.prev = 14;
  6446. _context.t0 = _context["catch"](9);
  6447. logger$1.error("error", _context.t0);
  6448. case 17:
  6449. _this.isAnswered = !0, _this.network.rtcp.flushCandidate(), _this.network.socket.send({
  6450. id: "answer",
  6451. data: btoa(JSON.stringify(o))
  6452. }), t.srcObject = _this.mediaStream;
  6453. case 18:
  6454. case "end":
  6455. return _context.stop();
  6456. }
  6457. }
  6458. }, _callee, null, [[9, 14]]);
  6459. }));
  6460. return function (_x, _x2) {
  6461. return _ref.apply(this, arguments);
  6462. };
  6463. }());
  6464. E(_assertThisInitialized(_this), "flushCandidate", function () {
  6465. _this.isFlushing || !_this.isAnswered || (_this.isFlushing = !0, _this.candidates.forEach(function (e) {
  6466. var t = atob(e),
  6467. r = JSON.parse(t);
  6468. if (/172\./.test(r.candidate)) return;
  6469. var n = new RTCIceCandidate(r);
  6470. _this.connection && _this.connection.addIceCandidate(n).then(function () {}, function (o) {
  6471. logger$1.info("add candidate failed", o);
  6472. });
  6473. }), _this.isFlushing = !1);
  6474. });
  6475. E(_assertThisInitialized(_this), "input", function (e) {
  6476. var t;
  6477. !_this.actived || !_this.inputChannel || _this.inputChannel.readyState === "open" && ((t = _this.inputChannel) == null || t.send(e));
  6478. });
  6479. _this.network = e, _this.workers = new Workers(_assertThisInitialized(_this), logger$1), _this.workers.registerLogger(logger$1), _this.workers.registerFunction("data", function (t) {
  6480. _this.emit("data", t);
  6481. }), _this.heartbeat = new Heartbeat({
  6482. ping: function ping(t) {
  6483. e.room.actionsHandler.echo(t);
  6484. },
  6485. pong(t, r) {
  6486. var n;
  6487. r && t > 500 && logger$1.warn("high hb value ".concat(t, ", traceId:") + r), (n = e.room.stats) == null || n.assign({
  6488. hb: t
  6489. });
  6490. }
  6491. });
  6492. return _this;
  6493. }
  6494. _createClass(Rtcp, [{
  6495. key: "start",
  6496. value: function start() {
  6497. var _this2 = this;
  6498. this.connection = new RTCPeerConnection();
  6499. var e = Date.now();
  6500. this.connection.ondatachannel = function (t) {
  6501. logger$1.info("ondatachannel: ".concat(t.channel.label));
  6502. _this2.inputChannel = t.channel;
  6503. _this2.inputChannel.onopen = function () {
  6504. var r;
  6505. 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({
  6506. metric: "datachannelOpenedAt",
  6507. startTime: _this2.network.room._startTime,
  6508. group: "joinRoom"
  6509. }), logger$1.infoAndReportMeasurement({
  6510. metric: "datachannelOpenedCost",
  6511. startTime: e,
  6512. group: "joinRoom"
  6513. }));
  6514. console.log('this.inputChannel', _this2.inputChannel);
  6515. }, _this2.inputChannel.onclose = function () {
  6516. var r;
  6517. return logger$1.info("The input channel has closed, id:", (r = _this2.inputChannel) == null ? void 0 : r.id);
  6518. }, _this2.inputChannel.onmessage = function (r) {
  6519. // console.log('this.workers',this.workers)
  6520. //console.log('inputChannel',r.data)
  6521. _this2.workers.dataHandle(r.data);
  6522. };
  6523. }, this.connection.oniceconnectionstatechange = this.onIceConnectionStateChange, this.connection.onicegatheringstatechange = this.onIceStateChange, this.connection.onicecandidate = this.onIcecandidate, this.connection.onicecandidateerror = this.onIcecandidateerror, this.network.socket.send({
  6524. id: "init_webrtc",
  6525. data: JSON.stringify({
  6526. is_mobile: !0
  6527. })
  6528. });
  6529. }
  6530. }, {
  6531. key: "addCandidate",
  6532. value: function addCandidate(e) {
  6533. e === "" ? this.network.rtcp.flushCandidate() : this.candidates.push(e);
  6534. }
  6535. }, {
  6536. key: "disconnect",
  6537. value: function disconnect() {
  6538. var e, t, r;
  6539. 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;
  6540. }
  6541. }, {
  6542. key: "sendStringData",
  6543. value: function sendStringData(e) {
  6544. console.log('e', e);
  6545. this.input(e);
  6546. }
  6547. }, {
  6548. key: "sendData",
  6549. value: function sendData(e) {
  6550. var t = "";
  6551. try {
  6552. t = JSON.stringify(e);
  6553. } catch (r) {
  6554. logger$1.error(r);
  6555. return;
  6556. }
  6557. this.input(t);
  6558. }
  6559. }]);
  6560. return Rtcp;
  6561. }(EventEmitter);
  6562. var NetworkMonitor = /*#__PURE__*/function () {
  6563. function NetworkMonitor(e) {
  6564. _classCallCheck(this, NetworkMonitor);
  6565. this._listener = e;
  6566. }
  6567. _createClass(NetworkMonitor, [{
  6568. key: "isOnline",
  6569. get: function get() {
  6570. var e = window.navigator;
  6571. return typeof e.onLine == "boolean" ? e.onLine : !0;
  6572. }
  6573. }, {
  6574. key: "start",
  6575. value: function start() {
  6576. window.addEventListener("online", this._listener), window.addEventListener("offline", this._listener);
  6577. }
  6578. }, {
  6579. key: "stop",
  6580. value: function stop() {
  6581. window.removeEventListener("online", this._listener), window.removeEventListener("offline", this._listener);
  6582. }
  6583. }]);
  6584. return NetworkMonitor;
  6585. }();
  6586. var Stream = /*#__PURE__*/function () {
  6587. function Stream(e) {
  6588. _classCallCheck(this, Stream);
  6589. this.el = null;
  6590. this._streamPlayTimer = null;
  6591. if (!e) {
  6592. this.el = this.createVideoElement();
  6593. return;
  6594. }
  6595. this.el = e;
  6596. }
  6597. _createClass(Stream, [{
  6598. key: "play",
  6599. value: function play() {
  6600. var _this = this;
  6601. return new Promise(function (e, t) {
  6602. _this._streamPlayTimer = new Timeout(function () {
  6603. t(new InternalError("Stream play timeout"));
  6604. }, 5e3), _this.el && _this.el.play().then(function () {
  6605. var r;
  6606. e(), logger$1.info("Media can autoplay"), (r = _this._streamPlayTimer) == null || r.clear();
  6607. }).catch(function (r) {
  6608. var n;
  6609. logger$1.error("Media Failed to autoplay"), logger$1.error(r), t(new InternalError("Media Failed to autoplay")), (n = _this._streamPlayTimer) == null || n.clear();
  6610. });
  6611. });
  6612. }
  6613. }, {
  6614. key: "createVideoElement",
  6615. value: function createVideoElement() {
  6616. var e = document.createElement("video");
  6617. 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;
  6618. }
  6619. }]);
  6620. return Stream;
  6621. }();
  6622. 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); }; }
  6623. 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; } }
  6624. 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 ";
  6625. var NetworkController = /*#__PURE__*/function (_EventEmitter) {
  6626. _inherits(NetworkController, _EventEmitter);
  6627. var _super = _createSuper$6(NetworkController);
  6628. function NetworkController(e) {
  6629. var _this;
  6630. _classCallCheck(this, NetworkController);
  6631. _this = _super.call(this);
  6632. _this.socket = null;
  6633. _this.rtcp = null;
  6634. _this.stream = null;
  6635. _this._state = 'connecting';
  6636. _this._networkMonitor = null;
  6637. _this.blockedActions = [];
  6638. _this.reconnectCount = 0;
  6639. _this.room = e, _this.socket = new Socket(_assertThisInitialized(_this));
  6640. _this.rtcp = new Rtcp(_assertThisInitialized(_this));
  6641. _this.stream = new Stream();
  6642. _this._networkMonitor = new NetworkMonitor(function () {
  6643. 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());
  6644. });
  6645. _this.checkNetworkQuality(_this.room.currentNetworkOptions.wsServerUrl);
  6646. _this._networkMonitor.start();
  6647. new VisibilityChangeHandler().subscribe(function (r) {
  6648. var n, o;
  6649. r ? ((o = _this.room.stats) == null || o.disable(), logger$1.infoAndReportMeasurement({
  6650. metric: "pageHide",
  6651. startTime: Date.now()
  6652. })) : ((n = _this.room.stats) == null || n.enable(), logger$1.infoAndReportMeasurement({
  6653. metric: "pageShow",
  6654. startTime: Date.now(),
  6655. extra: {
  6656. state: _this._state
  6657. }
  6658. }), _this._state === "disconnected" && _this.reconnect());
  6659. });
  6660. return _this;
  6661. }
  6662. _createClass(NetworkController, [{
  6663. key: "startGame",
  6664. value: function startGame() {
  6665. var _this2 = this;
  6666. return new Promise(function (e, t) {
  6667. if (!_this2.rtcp.connected) return t(new InternalError("Game cannot load. Please refresh"));
  6668. if (!_this2.rtcp.inputReady) return t(new InternalError("Game is not ready yet. Please wait"));
  6669. _this2.socket.on("gameRoomAvailable", function (r) {
  6670. _this2.setState("connected"), e(r), _this2.rtcp.heartbeat.start();
  6671. }), _this2.socket.on("socketClosed", function (r) {
  6672. t(r);
  6673. }), _this2.socket.startGame();
  6674. });
  6675. }
  6676. }, {
  6677. key: "addBlockedActions",
  6678. value: function addBlockedActions(e) {
  6679. var _this$blockedActions;
  6680. (_this$blockedActions = this.blockedActions).push.apply(_this$blockedActions, _toConsumableArray(e));
  6681. }
  6682. }, {
  6683. key: "removeBlockedActions",
  6684. value: function removeBlockedActions(e) {
  6685. if (!e) {
  6686. this.blockedActions = [];
  6687. return;
  6688. }
  6689. var t = this.blockedActions.indexOf(e);
  6690. this.blockedActions.splice(t, 1);
  6691. }
  6692. }, {
  6693. key: "setState",
  6694. value: function setState(e) {
  6695. this._state !== e && (logger$1.info("Set network state to ", e), this._state = e);
  6696. }
  6697. }, {
  6698. key: "connectAndStart",
  6699. value: function () {
  6700. var _connectAndStart = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  6701. return regenerator.wrap(function _callee$(_context) {
  6702. while (1) {
  6703. switch (_context.prev = _context.next) {
  6704. case 0:
  6705. return _context.abrupt("return", this.connect(e).then(this.startGame));
  6706. case 1:
  6707. case "end":
  6708. return _context.stop();
  6709. }
  6710. }
  6711. }, _callee, this);
  6712. }));
  6713. function connectAndStart(_x) {
  6714. return _connectAndStart.apply(this, arguments);
  6715. }
  6716. return connectAndStart;
  6717. }()
  6718. }, {
  6719. key: "connect",
  6720. value: function () {
  6721. var _connect = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
  6722. var _this3 = this;
  6723. var e,
  6724. _args2 = arguments;
  6725. return regenerator.wrap(function _callee2$(_context2) {
  6726. while (1) {
  6727. switch (_context2.prev = _context2.next) {
  6728. case 0:
  6729. e = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : !1;
  6730. this.room.updateCurrentNetworkOptions({
  6731. reconnect: e
  6732. });
  6733. return _context2.abrupt("return", new Promise(function (t, r) {
  6734. _this3.rtcp.on("rtcConnected", function () {
  6735. _this3.setState("connected"), t();
  6736. }), _this3.rtcp.on("rtcDisconnected", function () {
  6737. 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());
  6738. }), _this3.socket.on("socketQuit", function () {
  6739. logger$1.info("socket quit success"), _this3.setState("closed");
  6740. }), _this3.socket.on("socketClosed", function (n) {
  6741. _this3._state === "connecting" && (_this3.setState("disconnected"), r(n)), r(n);
  6742. }), _this3.socket.start();
  6743. }));
  6744. case 3:
  6745. case "end":
  6746. return _context2.stop();
  6747. }
  6748. }
  6749. }, _callee2, this);
  6750. }));
  6751. function connect() {
  6752. return _connect.apply(this, arguments);
  6753. }
  6754. return connect;
  6755. }()
  6756. }, {
  6757. key: "reconnect",
  6758. value: function reconnect() {
  6759. var _this4 = this;
  6760. if (this.room.viewMode === "observer") return;
  6761. var e = Date.now();
  6762. if (this.reconnectCount++, this.reconnectCount > MAX_RECONNECT_COUNT) {
  6763. logger$1.error("reconnect failed, reached max reconnect count", MAX_RECONNECT_COUNT), this.reconnectCount = 0, this.emit("stateChanged", {
  6764. state: "disconnected"
  6765. });
  6766. return;
  6767. }
  6768. return logger$1.info("start reconnect, count:", this.reconnectCount), this._reconnect().then(function () {
  6769. logger$1.infoAndReportMeasurement({
  6770. startTime: e,
  6771. metric: "reconnect"
  6772. });
  6773. }).catch(function (t) {
  6774. if (logger$1.infoAndReportMeasurement({
  6775. startTime: e,
  6776. metric: "reconnect",
  6777. error: t
  6778. }), t.code === Codes.RepeatLogin) {
  6779. _this4.room.handleRepetLogin();
  6780. return;
  6781. }
  6782. var r = 1e3;
  6783. logger$1.info("reconnect failed, wait " + r + " ms for next reconnect"), setTimeout(function () {
  6784. _this4.reconnect();
  6785. }, r);
  6786. });
  6787. }
  6788. }, {
  6789. key: "_reconnect",
  6790. value: function _reconnect() {
  6791. var _this5 = this;
  6792. 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", {
  6793. state: "reconnecting",
  6794. count: this.reconnectCount
  6795. }), this.socket.off("gameRoomAvailable"), this.socket.off("socketClosed"), this.rtcp.off("rtcDisconnected"), this.rtcp.off("rtcConnected"), this.connectAndStart(!0).then(function (_ref) {
  6796. var e = _ref.session_id;
  6797. _this5.room.updateCurrentNetworkOptions({
  6798. sessionId: e
  6799. }), reporter.updateBody({
  6800. serverSession: e
  6801. }), logger$1.info("reconnect success"), _this5.setState("connected"), _this5.reconnectCount = 0, _this5.emit("stateChanged", {
  6802. state: "reconnected"
  6803. });
  6804. }));
  6805. }
  6806. }, {
  6807. key: "prepareReconnect",
  6808. value: function prepareReconnect() {
  6809. this.rtcp.disconnect(), this.socket.prepareReconnect(), this.prepareReconnectOptions();
  6810. }
  6811. }, {
  6812. key: "prepareReconnectOptions",
  6813. value: function prepareReconnectOptions() {
  6814. var _ref2 = this.room.currentClickingState || {},
  6815. e = _ref2.camera,
  6816. t = _ref2.player;
  6817. e && t && this.room.updateCurrentNetworkOptions({
  6818. camera: e,
  6819. player: t
  6820. });
  6821. }
  6822. }, {
  6823. key: "sendRtcData",
  6824. value: function sendRtcData(e) {
  6825. if (this.blockedActions.includes(e.action_type)) {
  6826. logger$1.info("action: ".concat(Actions[e.action_type], " was blocked"));
  6827. return;
  6828. }
  6829. this.rtcp.sendData(e);
  6830. }
  6831. }, {
  6832. key: "sendSocketData",
  6833. value: function sendSocketData(e) {
  6834. logger$1.debug("ws send ->", e), this.socket.send(e);
  6835. }
  6836. }, {
  6837. key: "quit",
  6838. value: function quit() {
  6839. var e = util.uuid(),
  6840. t = {
  6841. action_type: Actions.Exit,
  6842. trace_id: e,
  6843. exit_action: {},
  6844. user_id: this.room.options.userId,
  6845. packet_id: e
  6846. };
  6847. this.setState("closed"), this.socket.quit(), this.sendRtcData(t);
  6848. }
  6849. }, {
  6850. key: "checkNetworkQuality",
  6851. value: function checkNetworkQuality(i) {
  6852. var worker = null;
  6853. if (!i) return;
  6854. var e = Date.now();
  6855. if (this.pingOthers("https://www.baidu.com", function (t, r) {
  6856. logger$1.infoAndReportMeasurement({
  6857. metric: "baiduRtt",
  6858. group: "http",
  6859. value: r,
  6860. startTime: e
  6861. });
  6862. }), !worker) {
  6863. var t = new Blob([workerSourceCode], {
  6864. type: "application/javascript"
  6865. });
  6866. worker = new Worker(URL.createObjectURL(t)), worker.onmessage = function (r) {
  6867. logger$1.infoAndReportMeasurement({
  6868. metric: "workerRtt",
  6869. group: "http",
  6870. startTime: e,
  6871. value: r.data
  6872. });
  6873. };
  6874. }
  6875. }
  6876. }, {
  6877. key: "pingOthers",
  6878. value: function pingOthers(i, e) {
  6879. var t = !1;
  6880. var r = new Image();
  6881. r.onload = o, r.onerror = a;
  6882. var n = Date.now();
  6883. function o(l) {
  6884. t = !0, s();
  6885. }
  6886. function a(l) {}
  6887. function s() {
  6888. var l = Date.now() - n;
  6889. if (typeof e == "function") return t ? e(null, l) : (console.error("error loading resource"), e("error", l));
  6890. }
  6891. r.src = i + "/favicon.ico?" + +new Date();
  6892. }
  6893. }]);
  6894. return NetworkController;
  6895. }(EventEmitter);
  6896. var AssetTypeName = {
  6897. Config: 'CONFIG',
  6898. Model: 'MODEL',
  6899. Vedio: 'VEDIO',
  6900. Media: 'MEDIA',
  6901. Effects: 'EFFECTS',
  6902. Gift: 'GIFT',
  6903. Textures: 'TEXTURES'
  6904. };
  6905. var AssetClassName = {
  6906. Effects: '\u7279\u6548',
  6907. Tv: 'TV',
  6908. Lpm: '\u7C97\u6A21',
  6909. Reward: '\u571F\u8C6A\u699C',
  6910. Env: '\u73AF\u5883\u5149',
  6911. Gbq: '\u544A\u767D\u5899',
  6912. BreathPoint: '\u547C\u5438\u70B9',
  6913. Gifts: '\u9001\u793C',
  6914. Panorama: '\u5168\u666F\u56FE',
  6915. GiftBubble: '\u9001\u793C\u6C14\u6CE1',
  6916. SayBubble: '\u804A\u5929\u6C14\u6CE1'
  6917. };
  6918. var LoggerLevels$1 = {
  6919. Debug: 1,
  6920. Info: 2,
  6921. Warn: 3,
  6922. Error: 4,
  6923. Off: 5
  6924. };
  6925. var EShaderMode = {
  6926. default: 0,
  6927. video: 1,
  6928. videoAndPano: 2
  6929. };
  6930. var EFitMode = {
  6931. fill: 'fill',
  6932. contain: 'contain',
  6933. cover: 'cover'
  6934. };
  6935. var BaseTable = /*#__PURE__*/function () {
  6936. function BaseTable(e, t) {
  6937. _classCallCheck(this, BaseTable);
  6938. this.db = null;
  6939. this.isCreatingTable = !1;
  6940. this.hasCleared = !1;
  6941. this.dbName = e, this.dbVersion = t;
  6942. }
  6943. _createClass(BaseTable, [{
  6944. key: "clearDataBase",
  6945. value: function () {
  6946. var _clearDataBase = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  6947. var _this = this;
  6948. return regenerator.wrap(function _callee$(_context) {
  6949. while (1) {
  6950. switch (_context.prev = _context.next) {
  6951. case 0:
  6952. return _context.abrupt("return", this.hasCleared || (e && (this.hasCleared = !0), !window.indexedDB.databases) ? Promise.resolve() : new Promise(function (t, r) {
  6953. var n = window.indexedDB.deleteDatabase(_this.dbName);
  6954. n.onsuccess = function () {
  6955. t();
  6956. }, n.onerror = r;
  6957. }));
  6958. case 1:
  6959. case "end":
  6960. return _context.stop();
  6961. }
  6962. }
  6963. }, _callee, this);
  6964. }));
  6965. function clearDataBase(_x) {
  6966. return _clearDataBase.apply(this, arguments);
  6967. }
  6968. return clearDataBase;
  6969. }()
  6970. }, {
  6971. key: "tableName",
  6972. value: function tableName() {
  6973. throw new Error("Derived class have to override 'tableName', and set a proper table name!");
  6974. }
  6975. }, {
  6976. key: "keyPath",
  6977. value: function keyPath() {
  6978. throw new Error("Derived class have to override 'keyPath', and set a proper index name!");
  6979. }
  6980. }, {
  6981. key: "index",
  6982. value: function index() {
  6983. throw new Error("Derived class have to override 'index', and set a proper index name!");
  6984. }
  6985. }, {
  6986. key: "checkAndOpenDatabase",
  6987. value: function () {
  6988. var _checkAndOpenDatabase = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
  6989. var _this2 = this;
  6990. return regenerator.wrap(function _callee2$(_context2) {
  6991. while (1) {
  6992. switch (_context2.prev = _context2.next) {
  6993. case 0:
  6994. return _context2.abrupt("return", this.db ? Promise.resolve(this.db) : new Promise(function (e, t) {
  6995. var n = setTimeout(function () {
  6996. logger$1.info("wait db to open for", 200), _this2.db ? e(_this2.db) : e(_this2.checkAndOpenDatabase()), clearTimeout(n);
  6997. }, 200);
  6998. _this2.openDatabase(_this2.dbName, _this2.dbVersion || 1, function () {
  6999. _this2.db && !_this2.isCreatingTable && e(_this2.db), logger$1.info("successCallback called, this.db: ".concat(!!_this2.db, ", this.isCreatingStore: ").concat(_this2.isCreatingTable)), clearTimeout(n);
  7000. }, function () {
  7001. t(new Error("Failed to open database!")), clearTimeout(n);
  7002. }, function () {
  7003. _this2.db && e(_this2.db), clearTimeout(n), logger$1.info("successCallback called, this.db: ".concat(!!_this2.db, ", this.isCreatingStore: ").concat(_this2.isCreatingTable));
  7004. });
  7005. }));
  7006. case 1:
  7007. case "end":
  7008. return _context2.stop();
  7009. }
  7010. }
  7011. }, _callee2, this);
  7012. }));
  7013. function checkAndOpenDatabase() {
  7014. return _checkAndOpenDatabase.apply(this, arguments);
  7015. }
  7016. return checkAndOpenDatabase;
  7017. }()
  7018. }, {
  7019. key: "openDatabase",
  7020. value: function openDatabase(e, t, r, n, o) {
  7021. var _this3 = this;
  7022. if (this.isCreatingTable) return;
  7023. this.isCreatingTable = !0, logger$1.info(e, t);
  7024. var a = window.indexedDB.open(e, t),
  7025. s = this.tableName();
  7026. a.onsuccess = function (l) {
  7027. _this3.db = a.result, logger$1.info("IndexedDb ".concat(e, " is opened.")), _this3.db.objectStoreNames.contains(s) && (_this3.isCreatingTable = !1), r && r(l);
  7028. }, a.onerror = function (l) {
  7029. var u;
  7030. 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);
  7031. }, a.onupgradeneeded = function (l) {
  7032. var u = l.target.result,
  7033. c = _this3.index();
  7034. logger$1.info("Creating table ".concat(s, "."));
  7035. var h = u.objectStoreNames.contains(s);
  7036. if (h) h = u.transaction([s], "readwrite").objectStore(s);else {
  7037. var f = _this3.keyPath();
  7038. h = u.createObjectStore(s, {
  7039. keyPath: f
  7040. });
  7041. }
  7042. c.map(function (f) {
  7043. h.createIndex(f, f, {
  7044. unique: !1
  7045. });
  7046. }), _this3.isCreatingTable = !1, logger$1.info("Table ".concat(s, " opened")), o && o(l);
  7047. };
  7048. }
  7049. }, {
  7050. key: "add",
  7051. value: function () {
  7052. var _add = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e) {
  7053. var t, o;
  7054. return regenerator.wrap(function _callee3$(_context3) {
  7055. while (1) {
  7056. switch (_context3.prev = _context3.next) {
  7057. case 0:
  7058. t = this.tableName();
  7059. _context3.next = 3;
  7060. return this.checkAndOpenDatabase();
  7061. case 3:
  7062. o = _context3.sent.transaction([t], "readwrite").objectStore(t).add(e);
  7063. return _context3.abrupt("return", new Promise(function (a, s) {
  7064. o.onsuccess = function (l) {
  7065. a(l);
  7066. }, o.onerror = function (l) {
  7067. var u;
  7068. logger$1.error((u = l.srcElement) == null ? void 0 : u.error), s(l);
  7069. };
  7070. }));
  7071. case 5:
  7072. case "end":
  7073. return _context3.stop();
  7074. }
  7075. }
  7076. }, _callee3, this);
  7077. }));
  7078. function add(_x2) {
  7079. return _add.apply(this, arguments);
  7080. }
  7081. return add;
  7082. }()
  7083. }, {
  7084. key: "put",
  7085. value: function () {
  7086. var _put = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(e) {
  7087. var t, o;
  7088. return regenerator.wrap(function _callee4$(_context4) {
  7089. while (1) {
  7090. switch (_context4.prev = _context4.next) {
  7091. case 0:
  7092. t = this.tableName();
  7093. _context4.next = 3;
  7094. return this.checkAndOpenDatabase();
  7095. case 3:
  7096. o = _context4.sent.transaction([t], "readwrite").objectStore(t).put(e);
  7097. return _context4.abrupt("return", new Promise(function (a, s) {
  7098. o.onsuccess = function (l) {
  7099. a(l);
  7100. }, o.onerror = function (l) {
  7101. var u;
  7102. logger$1.error("db put error", (u = l.srcElement) == null ? void 0 : u.error), s(l);
  7103. };
  7104. }));
  7105. case 5:
  7106. case "end":
  7107. return _context4.stop();
  7108. }
  7109. }
  7110. }, _callee4, this);
  7111. }));
  7112. function put(_x3) {
  7113. return _put.apply(this, arguments);
  7114. }
  7115. return put;
  7116. }()
  7117. }, {
  7118. key: "delete",
  7119. value: function _delete(e, t, r) {
  7120. var n = this.tableName();
  7121. this.checkAndOpenDatabase().then(function (o) {
  7122. var s = o.transaction([n], "readwrite").objectStore(n).delete(e);
  7123. s.onsuccess = t, s.onerror = r;
  7124. });
  7125. }
  7126. }, {
  7127. key: "update",
  7128. value: function update() {
  7129. this.checkAndOpenDatabase().then(function (e) {});
  7130. }
  7131. }, {
  7132. key: "getAllKeys",
  7133. value: function () {
  7134. var _getAllKeys = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5() {
  7135. var e, t;
  7136. return regenerator.wrap(function _callee5$(_context5) {
  7137. while (1) {
  7138. switch (_context5.prev = _context5.next) {
  7139. case 0:
  7140. e = this.tableName();
  7141. _context5.next = 3;
  7142. return this.checkAndOpenDatabase();
  7143. case 3:
  7144. t = _context5.sent;
  7145. return _context5.abrupt("return", new Promise(function (r, n) {
  7146. var a = t.transaction([e], "readonly").objectStore(e).getAllKeys();
  7147. a.onsuccess = function (s) {
  7148. r(s.target.result);
  7149. }, a.onerror = function (s) {
  7150. logger$1.error("db getAllKeys error", s), n(s);
  7151. };
  7152. }));
  7153. case 5:
  7154. case "end":
  7155. return _context5.stop();
  7156. }
  7157. }
  7158. }, _callee5, this);
  7159. }));
  7160. function getAllKeys() {
  7161. return _getAllKeys.apply(this, arguments);
  7162. }
  7163. return getAllKeys;
  7164. }()
  7165. }, {
  7166. key: "query",
  7167. value: function () {
  7168. var _query = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6(e, t) {
  7169. var r, n;
  7170. return regenerator.wrap(function _callee6$(_context6) {
  7171. while (1) {
  7172. switch (_context6.prev = _context6.next) {
  7173. case 0:
  7174. r = this.tableName();
  7175. _context6.next = 3;
  7176. return this.checkAndOpenDatabase();
  7177. case 3:
  7178. n = _context6.sent;
  7179. return _context6.abrupt("return", new Promise(function (o, a) {
  7180. var u = n.transaction([r], "readonly").objectStore(r).index(e).get(t);
  7181. u.onsuccess = function (c) {
  7182. var f;
  7183. var h = (f = c == null ? void 0 : c.target) == null ? void 0 : f.result;
  7184. o && o(h);
  7185. }, u.onerror = function (c) {
  7186. logger$1.error("db query error", c), a(c);
  7187. };
  7188. }));
  7189. case 5:
  7190. case "end":
  7191. return _context6.stop();
  7192. }
  7193. }
  7194. }, _callee6, this);
  7195. }));
  7196. function query(_x4, _x5) {
  7197. return _query.apply(this, arguments);
  7198. }
  7199. return query;
  7200. }()
  7201. }, {
  7202. key: "sleep",
  7203. value: function () {
  7204. var _sleep = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee7(e) {
  7205. return regenerator.wrap(function _callee7$(_context7) {
  7206. while (1) {
  7207. switch (_context7.prev = _context7.next) {
  7208. case 0:
  7209. return _context7.abrupt("return", new Promise(function (t) {
  7210. setTimeout(function () {
  7211. t("");
  7212. }, e);
  7213. }));
  7214. case 1:
  7215. case "end":
  7216. return _context7.stop();
  7217. }
  7218. }
  7219. }, _callee7);
  7220. }));
  7221. function sleep(_x6) {
  7222. return _sleep.apply(this, arguments);
  7223. }
  7224. return sleep;
  7225. }()
  7226. }]);
  7227. return BaseTable;
  7228. }();
  7229. 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); }; }
  7230. 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; } }
  7231. var ModelTable = /*#__PURE__*/function (_BaseTable) {
  7232. _inherits(ModelTable, _BaseTable);
  7233. var _super = _createSuper$5(ModelTable);
  7234. function ModelTable() {
  7235. _classCallCheck(this, ModelTable);
  7236. return _super.call(this, "XverseDatabase", 1);
  7237. }
  7238. _createClass(ModelTable, [{
  7239. key: "tableName",
  7240. value: function tableName() {
  7241. return "models";
  7242. }
  7243. }, {
  7244. key: "index",
  7245. value: function index() {
  7246. return ["url"];
  7247. }
  7248. }, {
  7249. key: "keyPath",
  7250. value: function keyPath() {
  7251. return "url";
  7252. }
  7253. }]);
  7254. return ModelTable;
  7255. }(BaseTable);
  7256. var modelTable = new ModelTable();
  7257. 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); }; }
  7258. 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; } }
  7259. var isIndexedDbSupported = function isIndexedDbSupported() {
  7260. return (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB) !== void 0;
  7261. };
  7262. var dataURItoBlob = function dataURItoBlob(i) {
  7263. var e;
  7264. i.split(",")[0].indexOf("base64") >= 0 ? e = atob(i.split(",")[1]) : e = unescape(i.split(",")[1]);
  7265. var t = i.split(",")[0].split(":")[1].split(";")[0],
  7266. r = new Uint8Array(e.length);
  7267. for (var o = 0; o < e.length; o++) {
  7268. r[o] = e.charCodeAt(o);
  7269. }
  7270. return new Blob([r], {
  7271. type: t
  7272. });
  7273. };
  7274. var Http = /*#__PURE__*/function (_EventEmitter) {
  7275. _inherits(Http, _EventEmitter);
  7276. var _super = _createSuper$4(Http);
  7277. function Http() {
  7278. _classCallCheck(this, Http);
  7279. return _super.apply(this, arguments);
  7280. }
  7281. _createClass(Http, [{
  7282. key: "get",
  7283. value: function () {
  7284. var _get = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(_ref) {
  7285. var e, _ref$useIndexedDb, t, _ref$timeout, r, n, _ref$isOutPutObjectUR, o, a, s, l;
  7286. return regenerator.wrap(function _callee2$(_context2) {
  7287. while (1) {
  7288. switch (_context2.prev = _context2.next) {
  7289. case 0:
  7290. 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;
  7291. if (!(Xverse.NO_CACHE !== void 0 && (t = !Xverse.NO_CACHE), t)) {
  7292. _context2.next = 25;
  7293. break;
  7294. }
  7295. if (!isIndexedDbSupported()) {
  7296. _context2.next = 22;
  7297. break;
  7298. }
  7299. window.performance.now();
  7300. a = null;
  7301. _context2.prev = 5;
  7302. _context2.next = 8;
  7303. return modelTable.query("url", e);
  7304. case 8:
  7305. a = _context2.sent;
  7306. _context2.next = 14;
  7307. break;
  7308. case 11:
  7309. _context2.prev = 11;
  7310. _context2.t0 = _context2["catch"](5);
  7311. return _context2.abrupt("return", (logger$1.debug(_context2.t0), logger$1.warn("cache query error", e), Promise.resolve(e)));
  7312. case 14:
  7313. if (!(a && a.model)) {
  7314. _context2.next = 19;
  7315. break;
  7316. }
  7317. s = dataURItoBlob(a.model), l = Promise.resolve(o ? URL.createObjectURL(s) : s);
  7318. return _context2.abrupt("return", (window.performance.now(), l));
  7319. case 19:
  7320. return _context2.abrupt("return", this.request({
  7321. url: e,
  7322. timeout: r,
  7323. contentType: "blob",
  7324. key: n
  7325. }).then( /*#__PURE__*/function () {
  7326. var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(s) {
  7327. var l;
  7328. return regenerator.wrap(function _callee$(_context) {
  7329. while (1) {
  7330. switch (_context.prev = _context.next) {
  7331. case 0:
  7332. _context.next = 2;
  7333. return blobToDataURI(s.response);
  7334. case 2:
  7335. l = _context.sent;
  7336. _context.prev = 3;
  7337. _context.next = 6;
  7338. return modelTable.put({
  7339. url: e,
  7340. model: l
  7341. });
  7342. case 6:
  7343. _context.next = 11;
  7344. break;
  7345. case 8:
  7346. _context.prev = 8;
  7347. _context.t0 = _context["catch"](3);
  7348. logger$1.warn("unable to add data to indexedDB", _context.t0);
  7349. case 11:
  7350. return _context.abrupt("return", Promise.resolve(o ? URL.createObjectURL(s.response) : s.response));
  7351. case 12:
  7352. case "end":
  7353. return _context.stop();
  7354. }
  7355. }
  7356. }, _callee, null, [[3, 8]]);
  7357. }));
  7358. return function (_x2) {
  7359. return _ref2.apply(this, arguments);
  7360. };
  7361. }()));
  7362. case 20:
  7363. _context2.next = 23;
  7364. break;
  7365. case 22:
  7366. return _context2.abrupt("return", this.request({
  7367. url: e,
  7368. timeout: r,
  7369. contentType: "blob",
  7370. key: n
  7371. }).then(function (a) {
  7372. var s = a.response;
  7373. return Promise.resolve(o ? URL.createObjectURL(s) : s);
  7374. }).catch(function (a) {
  7375. return Promise.reject(a);
  7376. }));
  7377. case 23:
  7378. _context2.next = 26;
  7379. break;
  7380. case 25:
  7381. return _context2.abrupt("return", this.request({
  7382. url: e,
  7383. timeout: r,
  7384. key: n
  7385. }).then(function (a) {
  7386. return a.getResponseHeader("content-type") === "application/json" ? Promise.resolve(JSON.parse(a.responseText)) : Promise.resolve(a.responseText);
  7387. }));
  7388. case 26:
  7389. case "end":
  7390. return _context2.stop();
  7391. }
  7392. }
  7393. }, _callee2, this, [[5, 11]]);
  7394. }));
  7395. function get(_x) {
  7396. return _get.apply(this, arguments);
  7397. }
  7398. return get;
  7399. }()
  7400. }, {
  7401. key: "request",
  7402. value: function request(e) {
  7403. var _this = this;
  7404. var _e$timeout = e.timeout,
  7405. t = _e$timeout === void 0 ? 3e4 : _e$timeout,
  7406. r = e.contentType;
  7407. e.key;
  7408. var o = e.onRequestStart,
  7409. a = e.url;
  7410. return new Promise(function (s, l) {
  7411. window.performance.now();
  7412. var u = new XMLHttpRequest();
  7413. r && (u.responseType = r), u.timeout = t, u.addEventListener("readystatechange", function () {
  7414. if (u.readyState == 4) {
  7415. if (u.status == 200) return window.performance.now(), _this.emit("loadend", {
  7416. message: "request ".concat(a, " load success")
  7417. }), s(u);
  7418. {
  7419. var c = "Unable to load the request ".concat(a);
  7420. return _this.emit("error", {
  7421. message: c
  7422. }), logger$1.error(c), l(c);
  7423. }
  7424. }
  7425. }), o && o(u), u.open("GET", a), u.send();
  7426. });
  7427. }
  7428. }]);
  7429. return Http;
  7430. }(EventEmitter); // const http = new Http();
  7431. var Logger1 = /*#__PURE__*/function () {
  7432. function Logger1(e) {
  7433. _classCallCheck(this, Logger1);
  7434. E(this, "module");
  7435. this.module = e;
  7436. }
  7437. _createClass(Logger1, [{
  7438. key: "debug",
  7439. value: function debug() {
  7440. var _Logger1$instance;
  7441. return (_Logger1$instance = Logger1.instance).debug.apply(_Logger1$instance, arguments);
  7442. }
  7443. }, {
  7444. key: "info",
  7445. value: function info() {
  7446. var _Logger1$instance2;
  7447. return (_Logger1$instance2 = Logger1.instance).info.apply(_Logger1$instance2, arguments);
  7448. }
  7449. }, {
  7450. key: "warn",
  7451. value: function warn() {
  7452. var _Logger1$instance3;
  7453. return (_Logger1$instance3 = Logger1.instance).warn.apply(_Logger1$instance3, arguments);
  7454. }
  7455. }, {
  7456. key: "error",
  7457. value: function error() {
  7458. var _Logger1$instance4;
  7459. return (_Logger1$instance4 = Logger1.instance).error.apply(_Logger1$instance4, arguments);
  7460. }
  7461. }], [{
  7462. key: "setLogger",
  7463. value: function setLogger(e) {
  7464. Logger1.instance = e;
  7465. }
  7466. }]);
  7467. return Logger1;
  7468. }();
  7469. var XCameraComponent = /*#__PURE__*/function () {
  7470. function XCameraComponent(e, t, r) {
  7471. var _this = this;
  7472. _classCallCheck(this, XCameraComponent);
  7473. E(this, "maincameraRotLimitObserver", null);
  7474. E(this, "mainCamera");
  7475. E(this, "cgCamera");
  7476. E(this, "saveCameraPose");
  7477. E(this, "_cameraPose");
  7478. E(this, "scene");
  7479. E(this, "canvas");
  7480. E(this, "yuvInfo");
  7481. E(this, "forceKeepVertical", !1);
  7482. E(this, "initCamera", function (e) {
  7483. var _e$maxZ = e.maxZ,
  7484. t = _e$maxZ === void 0 ? 1e4 : _e$maxZ,
  7485. _e$minZ = e.minZ,
  7486. r = _e$minZ === void 0 ? .1 : _e$minZ,
  7487. _e$angularSensibility = e.angularSensibility,
  7488. n = _e$angularSensibility === void 0 ? 2e3 : _e$angularSensibility;
  7489. _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);
  7490. });
  7491. E(this, "cameraFovChange", function (e) {
  7492. _this.yuvInfo = e;
  7493. var t = e.width,
  7494. r = e.height,
  7495. n = _this.canvas.width,
  7496. o = _this.canvas.height,
  7497. a = e.fov;
  7498. if (_this.forceKeepVertical == !0) {
  7499. var s = t / (2 * Math.tan(Math.PI * a / 360)),
  7500. l = 2 * Math.atan(r / (2 * s));
  7501. _this.mainCamera.fov = l, _this.cgCamera.fov = l, _this.mainCamera.fovMode = BABYLON.Camera.FOVMODE_VERTICAL_FIXED, _this.cgCamera.fovMode = BABYLON.Camera.FOVMODE_VERTICAL_FIXED;
  7502. } 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) {
  7503. var _s = o,
  7504. _l = n,
  7505. u = _s * t / r / (2 * Math.tan(a * Math.PI / 360)),
  7506. c = 2 * Math.atan(_l / (2 * u));
  7507. _this.mainCamera.fov = c, _this.cgCamera.fov = c;
  7508. } else _this.mainCamera.fov = Math.PI * a / 180, _this.cgCamera.fov = Math.PI * a / 180;
  7509. });
  7510. E(this, "setCameraPose", function (e) {
  7511. var n;
  7512. var t = ue4Position2Xverse(e.position);
  7513. var r = null;
  7514. e.rotation != null && (r = ue4Rotation2Xverse(e.rotation)), _this._cameraPose = {
  7515. position: t
  7516. }, r != null && (_this._cameraPose.rotation = r), _this.scene.activeCamera === _this.mainCamera && !((n = _this.mainCamera) != null && n.isDisposed()) && _this._setCamPositionRotation(_this.mainCamera, _this._cameraPose);
  7517. });
  7518. E(this, "_setCamPositionRotation", function (e, t) {
  7519. var r, n;
  7520. t.position && (e.position = (r = t.position) == null ? void 0 : r.clone()), t.rotation && (e.rotation = (n = t.rotation) == null ? void 0 : n.clone());
  7521. });
  7522. E(this, "switchCamera", function (e) {
  7523. var t;
  7524. (t = _this.scene.activeCamera) == null || t.detachControl(_this.canvas), _this.scene.activeCamera = e;
  7525. });
  7526. E(this, "reCalXYZRot", function (e, t) {
  7527. return e = e % (2 * Math.PI), Math.abs(t - e) >= Math.PI && (e = e - 2 * Math.PI), e;
  7528. });
  7529. E(this, "_moveCam", function (e, t, r, n, o, a, s, l) {
  7530. var u = function u(v, y, b) {
  7531. 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);
  7532. },
  7533. c = function c(v, y, b) {
  7534. 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);
  7535. },
  7536. h = new Animation("myAnimation1", "position", s, Animation.ANIMATIONTYPE_VECTOR3, Animation.ANIMATIONLOOPMODE_CONSTANT);
  7537. var f = [],
  7538. d = t,
  7539. _ = r;
  7540. for (var v = 0; v < a; ++v) {
  7541. f.push({
  7542. frame: v,
  7543. value: c(d, _, v / a)
  7544. });
  7545. }
  7546. f.push({
  7547. frame: f.length,
  7548. value: c(d, _, 1)
  7549. }), h.setKeys(f);
  7550. var g = new Animation("myAnimation2", "rotation", s, Animation.ANIMATIONTYPE_VECTOR3, Animation.ANIMATIONLOOPMODE_CONSTANT);
  7551. f = [], d = n, _ = o;
  7552. for (var _v = 0; _v < a; ++_v) {
  7553. f.push({
  7554. frame: _v,
  7555. value: u(d, _, _v / a)
  7556. });
  7557. }
  7558. f.push({
  7559. frame: f.length,
  7560. value: u(d, _, 1)
  7561. }), g.setKeys(f), e.animations.push(g), e.animations.push(h);
  7562. var m = _this.scene.beginAnimation(e, 0, a, !1);
  7563. m.onAnimationEnd = function () {
  7564. l(), m.stop(), m.animationStarted = !1;
  7565. };
  7566. });
  7567. this.scene = t, this.canvas = e, this.yuvInfo = r.yuvInfo, r.forceKeepVertical != null && (this.forceKeepVertical = r.forceKeepVertical), this.initCamera(r.cameraParam);
  7568. }
  7569. _createClass(XCameraComponent, [{
  7570. key: "MainCamera",
  7571. get: function get() {
  7572. return this.mainCamera;
  7573. }
  7574. }, {
  7575. key: "CgCamera",
  7576. get: function get() {
  7577. return this.cgCamera;
  7578. }
  7579. }, {
  7580. key: "getCameraHorizonFov",
  7581. value: function getCameraHorizonFov() {
  7582. return this.mainCamera.fovMode == BABYLON.Camera.FOVMODE_HORIZONTAL_FIXED ? this.mainCamera.fov : Math.PI * this.yuvInfo.fov / 180;
  7583. }
  7584. }, {
  7585. key: "changeMainCameraRotationDamping",
  7586. value: function changeMainCameraRotationDamping() {
  7587. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 2e3;
  7588. this.mainCamera.angularSensibility = e;
  7589. }
  7590. }, {
  7591. key: "removeMainCameraRotationLimit",
  7592. value: function removeMainCameraRotationLimit() {
  7593. this.maincameraRotLimitObserver != null && this.mainCamera.onAfterCheckInputsObservable.remove(this.maincameraRotLimitObserver);
  7594. }
  7595. }, {
  7596. key: "setMainCameraInfo",
  7597. value: function setMainCameraInfo(e) {
  7598. var _e$maxZ2 = e.maxZ,
  7599. t = _e$maxZ2 === void 0 ? 1e4 : _e$maxZ2,
  7600. _e$minZ2 = e.minZ,
  7601. r = _e$minZ2 === void 0 ? .1 : _e$minZ2,
  7602. _e$angularSensibility2 = e.angularSensibility,
  7603. n = _e$angularSensibility2 === void 0 ? 2e3 : _e$angularSensibility2;
  7604. this.mainCamera.maxZ = t, this.mainCamera.minZ = r, this.mainCamera.angularSensibility = n;
  7605. }
  7606. }, {
  7607. key: "getMainCameraInfo",
  7608. value: function getMainCameraInfo() {
  7609. return {
  7610. maxZ: this.mainCamera.maxZ,
  7611. minZ: this.mainCamera.minZ,
  7612. angularSensibility: this.mainCamera.angularSensibility
  7613. };
  7614. }
  7615. }, {
  7616. key: "_limitAngle",
  7617. value: function _limitAngle(e, t) {
  7618. 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;
  7619. }
  7620. }, {
  7621. key: "setMainCameraRotationLimit",
  7622. value: function setMainCameraRotationLimit(e, t) {
  7623. var _this2 = this;
  7624. this.maincameraRotLimitObserver != null && this.removeMainCameraRotationLimit();
  7625. var r = this.mainCamera,
  7626. n = e.yaw,
  7627. o = e.pitch,
  7628. a = e.roll,
  7629. s = t.yaw,
  7630. l = t.pitch,
  7631. u = t.roll;
  7632. if (s < 0 || l < 0 || u < 0) throw new Error("\u76F8\u673A\u65CB\u8F6C\u9650\u5236\u53EA\u80FD\u8BBE\u7F6E\u4E3A\u5927\u4E8E0");
  7633. var c = [o - l, o + l],
  7634. h = [n - s, n + s],
  7635. f = [a - u, a + u];
  7636. this.maincameraRotLimitObserver = r.onAfterCheckInputsObservable.add(function () {
  7637. var _xverseRotation2Ue = xverseRotation2Ue4(r.rotation),
  7638. d = _xverseRotation2Ue.pitch,
  7639. _ = _xverseRotation2Ue.yaw,
  7640. g = _xverseRotation2Ue.roll;
  7641. d = _this2._limitAngle(d, c), _ = _this2._limitAngle(_, h), g = _this2._limitAngle(g, f), r.rotation = ue4Rotation2Xverse({
  7642. pitch: d,
  7643. yaw: _,
  7644. roll: g
  7645. });
  7646. });
  7647. }
  7648. }, {
  7649. key: "setMainCameraRotationLimitByAnchor",
  7650. value: function setMainCameraRotationLimitByAnchor(e, t, r) {
  7651. this.maincameraRotLimitObserver != null && this.removeMainCameraRotationLimit();
  7652. var n = this.mainCamera,
  7653. o = ue4Rotation2Xverse_mesh(t),
  7654. a = ue4Rotation2Xverse_mesh(r);
  7655. a != null && o != null && e.mesh != null && (this.maincameraRotLimitObserver = n.onAfterCheckInputsObservable.add(function () {
  7656. var s = e.mesh.rotation;
  7657. 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));
  7658. }));
  7659. }
  7660. }, {
  7661. key: "getCameraPose",
  7662. value: function getCameraPose() {
  7663. var e = xversePosition2Ue4({
  7664. x: this.mainCamera.position.x,
  7665. y: this.mainCamera.position.y,
  7666. z: this.mainCamera.position.z
  7667. }),
  7668. t = xverseRotation2Ue4({
  7669. x: this.mainCamera.rotation.x,
  7670. y: this.mainCamera.rotation.y,
  7671. z: this.mainCamera.rotation.z
  7672. });
  7673. return {
  7674. position: e,
  7675. rotation: t
  7676. };
  7677. }
  7678. }, {
  7679. key: "changeCameraFov",
  7680. value: function changeCameraFov(e, t) {
  7681. this.mainCamera.fov = e, t != null && (this.mainCamera.fovMode = t == 0 ? BABYLON.Camera.FOVMODE_HORIZONTAL_FIXED : BABYLON.Camera.FOVMODE_VERTICAL_FIXED);
  7682. }
  7683. }, {
  7684. key: "controlCameraRotation",
  7685. value: function controlCameraRotation(e, t) {
  7686. var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : .5;
  7687. var n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : .5;
  7688. var o = {
  7689. pitch: n * t * 180,
  7690. yaw: r * e * 180,
  7691. roll: 0
  7692. };
  7693. this.addRot(o);
  7694. }
  7695. }, {
  7696. key: "addRot",
  7697. value: function addRot(e) {
  7698. var t = this.mainCamera,
  7699. r = ue4Rotation2Xverse_mesh(e);
  7700. r != null && t.rotation.addInPlace(r);
  7701. }
  7702. }, {
  7703. key: "getCameraFov",
  7704. value: function getCameraFov() {
  7705. return this.mainCamera.fov;
  7706. }
  7707. }, {
  7708. key: "allowMainCameraController",
  7709. value: function allowMainCameraController() {
  7710. this.mainCamera.attachControl(this.canvas, !0);
  7711. }
  7712. }, {
  7713. key: "detachMainCameraController",
  7714. value: function detachMainCameraController() {
  7715. this.mainCamera.detachControl(this.canvas);
  7716. }
  7717. }, {
  7718. key: "forceChangeSavedCameraPose",
  7719. value: function forceChangeSavedCameraPose(e) {
  7720. this.saveCameraPose != null && (e.position != null && (this.saveCameraPose.position = ue4Position2Xverse(e.position)), e.rotation != null && (this.saveCameraPose.rotation = ue4Rotation2Xverse(e.rotation)));
  7721. }
  7722. }, {
  7723. key: "changeToFirstPersonView",
  7724. value: function changeToFirstPersonView(e) {
  7725. this.saveCameraPose = {
  7726. position: this.mainCamera.position.clone(),
  7727. rotation: this.mainCamera.rotation.clone()
  7728. }, this.mainCamera.attachControl(this.canvas, !0), e.position != null && (this.mainCamera.position = ue4Position2Xverse(e.position)), e.rotation != null && (this.mainCamera.rotation = ue4Rotation2Xverse(e.rotation));
  7729. }
  7730. }, {
  7731. key: "changeToThirdPersonView",
  7732. value: function changeToThirdPersonView() {
  7733. 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));
  7734. }
  7735. }, {
  7736. key: "switchToMainCamera",
  7737. value: function switchToMainCamera() {
  7738. this.switchCamera(this.mainCamera);
  7739. }
  7740. }, {
  7741. key: "switchToCgCamera",
  7742. value: function switchToCgCamera() {
  7743. this.switchCamera(this.cgCamera);
  7744. }
  7745. }, {
  7746. key: "moveMainCamera",
  7747. value: function moveMainCamera(e, t, r, n, o) {
  7748. this._moveCam(this.mainCamera, this.mainCamera.position, e, this.mainCamera.rotation, t, r, n, o);
  7749. }
  7750. }]);
  7751. return XCameraComponent;
  7752. }();
  7753. var EMeshType = {
  7754. XAvatar: 'XAvatar',
  7755. XStaticMesh: 'XStaticMesh',
  7756. XBreathPoint: 'breathpoint',
  7757. Decal: 'decal',
  7758. Cgplane: 'cgplane',
  7759. Tv: 'tv',
  7760. XSubSequence: 'XSubSequence',
  7761. XBillboard: 'XBillboard'
  7762. };
  7763. var XStaticMesh = /*#__PURE__*/function () {
  7764. function XStaticMesh(_ref) {
  7765. var _this = this;
  7766. var e = _ref.id,
  7767. t = _ref.mesh,
  7768. _ref$group = _ref.group,
  7769. r = _ref$group === void 0 ? "default" : _ref$group,
  7770. _ref$lod = _ref.lod,
  7771. n = _ref$lod === void 0 ? 0 : _ref$lod,
  7772. _ref$xtype = _ref.xtype,
  7773. o = _ref$xtype === void 0 ? EMeshType.XStaticMesh : _ref$xtype,
  7774. _ref$skinInfo = _ref.skinInfo,
  7775. a = _ref$skinInfo === void 0 ? "default" : _ref$skinInfo,
  7776. _ref$url = _ref.url,
  7777. s = _ref$url === void 0 ? "" : _ref$url;
  7778. _classCallCheck(this, XStaticMesh);
  7779. E(this, "_mesh");
  7780. E(this, "_id", "-1");
  7781. E(this, "_group");
  7782. E(this, "_lod");
  7783. E(this, "_isMoving", !1);
  7784. E(this, "_isRotating", !1);
  7785. E(this, "_isVisible", !0);
  7786. E(this, "_skinInfo");
  7787. E(this, "setVisibility", function (e, t) {
  7788. Array.isArray(e) ? e.forEach(function (r) {
  7789. _this.setVisibility(r, t);
  7790. }) : e.isAnInstance || (e.visibility = t);
  7791. });
  7792. E(this, "setPickable", function (e, t) {
  7793. Array.isArray(e) ? e.forEach(function (r) {
  7794. _this.setPickable(r, t);
  7795. }) : ("isPickable" in e && (e.isPickable = t), e.setEnabled(t));
  7796. });
  7797. E(this, "hide", function () {
  7798. var e;
  7799. _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) {
  7800. _this.setVisibility(t, 0), _this.setPickable(t, !1);
  7801. });
  7802. });
  7803. E(this, "show", function () {
  7804. var e;
  7805. _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) {
  7806. _this.setVisibility(t, 1), _this.setPickable(t, !0);
  7807. });
  7808. });
  7809. E(this, "attachToAvatar", function (e) {
  7810. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
  7811. x: 0,
  7812. y: .5,
  7813. z: 0
  7814. };
  7815. var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
  7816. yaw: 0,
  7817. pitch: 0,
  7818. roll: 0
  7819. };
  7820. var n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {
  7821. x: .35,
  7822. y: .35,
  7823. z: .35
  7824. };
  7825. var o = ue4Scaling2Xverse(n),
  7826. a = ue4Rotation2Xverse(r),
  7827. s = ue4Position2Xverse(t),
  7828. l = _this._mesh;
  7829. e && l ? (e.setParent(l), e.position = s, e.rotation = a, e.scaling = o) : logger$1.error("[Engine] avatar or attachment not found!");
  7830. });
  7831. E(this, "detachFromAvatar", function (e) {
  7832. _this._mesh && e ? _this._mesh.removeChild(e) : logger$1.error("[Engine] avatar not found!");
  7833. });
  7834. 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;
  7835. }
  7836. _createClass(XStaticMesh, [{
  7837. key: "mesh",
  7838. get: function get() {
  7839. return this._mesh;
  7840. }
  7841. }, {
  7842. key: "position",
  7843. get: function get() {
  7844. var o;
  7845. if (!this._mesh) return null;
  7846. var _ref2 = (o = this._mesh) == null ? void 0 : o.position,
  7847. e = _ref2.x,
  7848. t = _ref2.y,
  7849. r = _ref2.z;
  7850. return xversePosition2Ue4({
  7851. x: e,
  7852. y: t,
  7853. z: r
  7854. });
  7855. }
  7856. }, {
  7857. key: "id",
  7858. get: function get() {
  7859. return this._id;
  7860. }
  7861. }, {
  7862. key: "group",
  7863. get: function get() {
  7864. return this._group;
  7865. }
  7866. }, {
  7867. key: "isMoving",
  7868. get: function get() {
  7869. return this._isMoving;
  7870. }
  7871. }, {
  7872. key: "isVisible",
  7873. get: function get() {
  7874. return this._isVisible;
  7875. }
  7876. }, {
  7877. key: "isRotating",
  7878. get: function get() {
  7879. return this._isRotating;
  7880. }
  7881. }, {
  7882. key: "skinInfo",
  7883. get: function get() {
  7884. return this._skinInfo;
  7885. }
  7886. }, {
  7887. key: "allowMove",
  7888. value: function allowMove() {
  7889. this._mesh != null && (this._mesh.getChildMeshes().forEach(function (e) {
  7890. e.unfreezeWorldMatrix();
  7891. }), this._mesh.unfreezeWorldMatrix());
  7892. }
  7893. }, {
  7894. key: "unallowMove",
  7895. value: function unallowMove() {
  7896. this._mesh != null && (this._mesh.getChildMeshes().forEach(function (e) {
  7897. e.freezeWorldMatrix();
  7898. }), this._mesh.freezeWorldMatrix());
  7899. }
  7900. }, {
  7901. key: "getID",
  7902. value: function getID() {
  7903. return this._id;
  7904. }
  7905. }, {
  7906. key: "setPosition",
  7907. value: function setPosition(e) {
  7908. if (this._mesh) {
  7909. var t = ue4Position2Xverse(e);
  7910. this._mesh.position = t;
  7911. } else logger$1.error("[Engine] no root for positioning");
  7912. }
  7913. }, {
  7914. key: "setRotation",
  7915. value: function setRotation(e) {
  7916. var t = ue4Rotation2Xverse_mesh(e);
  7917. this._mesh ? this._mesh.rotation = t : logger$1.error("[Engine] no root for rotating");
  7918. }
  7919. }, {
  7920. key: "setScale",
  7921. value: function setScale(e) {
  7922. this._mesh ? this._mesh.scaling = new BABYLON.Vector3(e, e, -e) : logger$1.error("[Engine] no root for scaling");
  7923. }
  7924. }, {
  7925. key: "disableAvatar",
  7926. value: function disableAvatar() {
  7927. var e;
  7928. (e = this._mesh) == null || e.setEnabled(!1);
  7929. }
  7930. }, {
  7931. key: "enableAvatar",
  7932. value: function enableAvatar() {
  7933. var e;
  7934. (e = this._mesh) == null || e.setEnabled(!0);
  7935. }
  7936. }, {
  7937. key: "togglePickable",
  7938. value: function togglePickable(e) {
  7939. var t;
  7940. (t = this.mesh) == null || t.getChildMeshes().forEach(function (r) {
  7941. "instances" in r && "isPickable" in r && (r.isPickable = e);
  7942. }), this.mesh != null && "isPickable" in this.mesh && (this.mesh.isPickable = e);
  7943. }
  7944. }, {
  7945. key: "setMaterial",
  7946. value: function setMaterial(e) {
  7947. var t;
  7948. (t = this.mesh) == null || t.getChildMeshes().forEach(function (r) {
  7949. "instances" in r && "material" in r && (r.material = e);
  7950. }), this.mesh != null && "material" in this.mesh && (this.mesh.material = e);
  7951. }
  7952. }, {
  7953. key: "dispose",
  7954. value: function dispose() {
  7955. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : !1;
  7956. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !1;
  7957. !this.mesh.isDisposed() && this.mesh.dispose(e, t);
  7958. }
  7959. }]);
  7960. return XStaticMesh;
  7961. }();
  7962. 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); }; }
  7963. 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; } }
  7964. var XLowpolyModelError = /*#__PURE__*/function (_XverseError) {
  7965. _inherits(XLowpolyModelError, _XverseError);
  7966. var _super = _createSuper$3(XLowpolyModelError);
  7967. function XLowpolyModelError(e) {
  7968. _classCallCheck(this, XLowpolyModelError);
  7969. return _super.call(this, 5204, e || "[Engine] \u4F20\u5165\u6A21\u578Burl\u9519\u8BEF");
  7970. }
  7971. return _createClass(XLowpolyModelError);
  7972. }(XverseError);
  7973. var XStaticMeshFromOneGltf = /*#__PURE__*/function () {
  7974. function XStaticMeshFromOneGltf(e, t) {
  7975. var _this = this;
  7976. _classCallCheck(this, XStaticMeshFromOneGltf);
  7977. E(this, "_scene");
  7978. E(this, "_url");
  7979. E(this, "_group");
  7980. E(this, "_pickable");
  7981. E(this, "_meshes");
  7982. E(this, "_id");
  7983. E(this, "_lod");
  7984. E(this, "_groupUuid");
  7985. E(this, "_isInScene");
  7986. E(this, "_skinInfo");
  7987. E(this, "loadMesh", function (e, t) {
  7988. var r = _this._meshes.length,
  7989. n = t ? 1 : 0,
  7990. o = _this._url;
  7991. return BABYLON.SceneLoader.LoadAssetContainerAsync("", o, _this._scene, function () {
  7992. _this._scene.blockMaterialDirtyMechanism = !0;
  7993. }, ".glb").then(function (a) {
  7994. for (var s = a.materials.length - 1; s >= 0; --s) {
  7995. a.materials[s].dispose();
  7996. }
  7997. _this._scene.blockMaterialDirtyMechanism = !0;
  7998. for (var _s = 0; _s < a.meshes.length; ++_s) {
  7999. var l = a.meshes[_s];
  8000. if ("instances" in l) {
  8001. "visibility" in l && (l.visibility = 0), "isPickable" in l && (l.isPickable = _this._pickable), e != null && (l.material = e), "hasVertexAlpha" in l && (l.hasVertexAlpha = !1);
  8002. var u = new XStaticMesh({
  8003. id: _this._groupUuid + "-" + Math.random().toString(36).substr(2, 5),
  8004. mesh: l,
  8005. lod: _this._lod,
  8006. group: _this._group,
  8007. url: _this._url,
  8008. xtype: EMeshType.XStaticMesh,
  8009. skinInfo: _this._skinInfo
  8010. });
  8011. _this._meshes.push(u);
  8012. }
  8013. _this._scene.addMesh(l);
  8014. }
  8015. return !0;
  8016. }).then(function () {
  8017. _this._isInScene = !0;
  8018. for (var a = r; a < _this._meshes.length; ++a) {
  8019. _this._meshes[a].mesh.visibility = n;
  8020. }
  8021. return Promise.resolve(!0);
  8022. }).catch(function (a) {
  8023. logger$1.error("[Engine] input gltf mesh uri error! " + a), Promise.reject(new XLowpolyModelError("[Engine] input gltf mesh uri error! " + a));
  8024. });
  8025. });
  8026. 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;
  8027. }
  8028. _createClass(XStaticMeshFromOneGltf, [{
  8029. key: "isinscene",
  8030. get: function get() {
  8031. return this._isInScene;
  8032. }
  8033. }, {
  8034. key: "groupUuid",
  8035. get: function get() {
  8036. return this._groupUuid;
  8037. }
  8038. }, {
  8039. key: "skinInfo",
  8040. get: function get() {
  8041. return this._skinInfo;
  8042. }
  8043. }, {
  8044. key: "group",
  8045. get: function get() {
  8046. return this._group;
  8047. }
  8048. }, {
  8049. key: "meshes",
  8050. get: function get() {
  8051. return this._meshes;
  8052. }
  8053. }, {
  8054. key: "url",
  8055. get: function get() {
  8056. return this._url;
  8057. }
  8058. }, {
  8059. key: "id",
  8060. get: function get() {
  8061. return this._id;
  8062. }
  8063. }, {
  8064. key: "lod",
  8065. get: function get() {
  8066. return this._lod;
  8067. }
  8068. }, {
  8069. key: "removeFromScene",
  8070. value: function removeFromScene() {
  8071. if (this._isInScene) {
  8072. this._isInScene = !1;
  8073. for (var e = 0, t = this._meshes.length; e < t; ++e) {
  8074. this._meshes[e].mesh != null && this._scene.removeMesh(this._meshes[e].mesh);
  8075. }
  8076. }
  8077. }
  8078. }, {
  8079. key: "addToScene",
  8080. value: function addToScene() {
  8081. if (this._isInScene == !1) {
  8082. this._isInScene = !0;
  8083. for (var e = 0, t = this._meshes.length; e < t; ++e) {
  8084. this._meshes[e].mesh != null && this._scene.addMesh(this._meshes[e].mesh);
  8085. }
  8086. }
  8087. }
  8088. }, {
  8089. key: "toggleVisibility",
  8090. value: function toggleVisibility(e) {
  8091. var t = e ? 1 : 0;
  8092. for (var r = 0, n = this._meshes.length; r < n; ++r) {
  8093. "visibility" in this._meshes[r].mesh && (this._meshes[r].mesh.visibility = t);
  8094. }
  8095. }
  8096. }, {
  8097. key: "togglePickable",
  8098. value: function togglePickable(e) {
  8099. for (var t = 0, r = this._meshes.length; t < r; ++t) {
  8100. "isPickable" in this._meshes[t].mesh && (this._meshes[t].mesh.isPickable = e);
  8101. }
  8102. }
  8103. }, {
  8104. key: "setMaterial",
  8105. value: function setMaterial(e) {
  8106. for (var t = 0, r = this._meshes.length; t < r; ++t) {
  8107. "material" in this._meshes[t].mesh && (this._meshes[t].mesh.material = e);
  8108. }
  8109. }
  8110. }, {
  8111. key: "dispose",
  8112. value: function dispose() {
  8113. for (var e = 0, t = this._meshes.length; e < t; ++e) {
  8114. this._meshes[e].mesh.dispose(!1, !1);
  8115. }
  8116. }
  8117. }]);
  8118. return XStaticMeshFromOneGltf;
  8119. }();
  8120. var XStaticMeshComponent = /*#__PURE__*/function () {
  8121. function XStaticMeshComponent(e) {
  8122. var _this = this;
  8123. _classCallCheck(this, XStaticMeshComponent);
  8124. E(this, "scene");
  8125. E(this, "_staticmeshes");
  8126. E(this, "_lowModel_group");
  8127. E(this, "_CgPlane");
  8128. E(this, "_rootDir");
  8129. E(this, "_abosoluteUrl");
  8130. E(this, "_partMeshSkinInfo");
  8131. E(this, "_meshInfoJson");
  8132. E(this, "_orijson");
  8133. E(this, "_notUsedRegionLists");
  8134. E(this, "_meshInfoKeys");
  8135. E(this, "_currentUpdateRegionCount");
  8136. E(this, "_currentMeshUsedLod");
  8137. E(this, "_currentPartGroup");
  8138. E(this, "_allowRegionUpdate");
  8139. E(this, "_allowRegionForceLod");
  8140. E(this, "_forceLod");
  8141. E(this, "_scenemanager");
  8142. E(this, "regionIdInCamera");
  8143. E(this, "regionIdInCameraConst");
  8144. E(this, "_cameraInRegionId");
  8145. E(this, "_meshVis");
  8146. E(this, "_doMeshVisChangeNumber");
  8147. E(this, "_meshVisTypeName");
  8148. E(this, "_visCheckDurationFrameNumber");
  8149. E(this, "_regionLodRule");
  8150. E(this, "reg_staticmesh_partupdate", function () {
  8151. if (_this._allowRegionUpdate && (_this.scene.getFrameId(), _this._meshUpdateFrame()), _this._allowRegionForceLod) {
  8152. _this.scene.getFrameId() % 2 == 0 && _this.setOneRegionLod(_this._meshInfoKeys[_this._currentUpdateRegionCount % _this._meshInfoKeys.length].toString(), _this._forceLod);
  8153. var t = !0;
  8154. var r = Array.from(_this._currentMeshUsedLod.keys());
  8155. if (r.length > 0) {
  8156. for (var n = 0; n < r.length; ++n) {
  8157. _this._currentMeshUsedLod.get(r[n]) != _this._forceLod && (t = !1);
  8158. }
  8159. t && (_this._allowRegionForceLod = !1);
  8160. }
  8161. }
  8162. });
  8163. E(this, "setMeshInfo", function (e) {
  8164. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
  8165. _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 () {
  8166. _this.startMeshUpdate();
  8167. }));
  8168. });
  8169. E(this, "_meshUpdateFrame", function () {
  8170. {
  8171. var _e = _this._meshInfoKeys[_this._currentUpdateRegionCount % _this._meshInfoKeys.length];
  8172. var t = !0;
  8173. var r = 3;
  8174. if (_this._scenemanager != null && _this._scenemanager.cameraComponent != null) {
  8175. var n = _this._getMainPlayerPosition();
  8176. if (n != null) {
  8177. if (_this._cameraInRegionId >= 0) {
  8178. var a = _this.getRegionIdWhichIncludeCamera(n);
  8179. (_this._cameraInRegionId != a || _this.regionIdInCamera.length == 0) && (_this._cameraInRegionId = a, _this.regionIdInCamera = _this._getNeighborId(_this._cameraInRegionId.toString()), _this.regionIdInCameraConst = _this.regionIdInCamera.slice());
  8180. var s = _this.regionIdInCamera.pop();
  8181. for (; s != null;) {
  8182. if (_this._notUsedRegionLists.indexOf(s) >= 0) s = _this.regionIdInCamera.pop();else break;
  8183. }
  8184. s != null && (_e = s.toString());
  8185. } else _this._cameraInRegionId = _this.getRegionIdWhichIncludeCamera(n);
  8186. if (_this._currentMeshUsedLod.size == 0 || _this._notUsedRegionLists.indexOf(parseInt(_e)) >= 0) {
  8187. _e = _this._cameraInRegionId.toString();
  8188. var _a = _this._getNeighborId(_e);
  8189. for (; _a.length == 0 && (_e = _this.getNearestRegionIdWithCamera(n).toString()), _this._notUsedRegionLists.indexOf(parseInt(_e)) >= 0;) {
  8190. _e = _a.pop().toString();
  8191. }
  8192. }
  8193. var o = _this._meshInfoJson[_this._cameraInRegionId.toString()].lod;
  8194. 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];
  8195. }
  8196. }
  8197. _this.setOneRegionLod(_e, r, t), _this.updateRegionNotInLocalNeighbor(), _this.cleanRootNodes();
  8198. }
  8199. });
  8200. E(this, "updateRegionNotInLocalNeighbor", function () {
  8201. Array.from(_this._currentMeshUsedLod.keys()).forEach(function (t) {
  8202. _this.regionIdInCameraConst.indexOf(parseInt(t)) < 0 && _this.setOneRegionLod(t, -1);
  8203. });
  8204. });
  8205. E(this, "cleanRootNodes", function () {
  8206. if (_this.scene.getFrameId() % 3 == 0) {
  8207. var _e2 = [];
  8208. _this.scene.rootNodes.forEach(function (t) {
  8209. (t.getClassName() == "TransformNode" && t.getChildren().length == 0 || t.getClassName() == "Mesh" && t.name == "__root__" && t.getChildren().length == 0) && _e2.push(t);
  8210. }), _e2.forEach(function (t) {
  8211. t.dispose();
  8212. });
  8213. }
  8214. });
  8215. E(this, "setOneRegionLod", function (e, t) {
  8216. _this._currentUpdateRegionCount++;
  8217. var n = _this._calHashCode(_this._rootDir),
  8218. o = "region_" + n + "_" + e;
  8219. if (t < 0) {
  8220. _this._currentMeshUsedLod.has(e) && (_this._currentMeshUsedLod.delete(e), _this._currentPartGroup.delete(o), _this.deleteMeshesByCustomProperty("group", "region_" + n + "_" + e));
  8221. return;
  8222. }
  8223. var a = _this._rootDir + e + "_lod" + t + "_xverse.glb",
  8224. s = _this._currentMeshUsedLod.get(e);
  8225. _this._currentPartGroup.add(o), s != null ? s != t && (_this._currentMeshUsedLod.set(e, t), _this._scenemanager.addNewLowPolyMesh({
  8226. url: a,
  8227. group: "region_" + n + "_" + e,
  8228. pick: !0,
  8229. lod: t,
  8230. skinInfo: _this._partMeshSkinInfo
  8231. }, [{
  8232. group: "region_" + n + "_" + e,
  8233. mode: 0
  8234. }])) : (_this._currentMeshUsedLod.set(e, t), _this._scenemanager.addNewLowPolyMesh({
  8235. url: a,
  8236. group: "region_" + n + "_" + e,
  8237. pick: !0,
  8238. lod: t,
  8239. skinInfo: _this._partMeshSkinInfo
  8240. }));
  8241. });
  8242. E(this, "checkPointInView", function (_ref) {
  8243. var e = _ref.x,
  8244. t = _ref.y,
  8245. r = _ref.z;
  8246. var n = ue4Position2Xverse({
  8247. x: e,
  8248. y: t,
  8249. z: r
  8250. });
  8251. if (!n) return !1;
  8252. for (var o = 0; o < 6; o++) {
  8253. if (_this.scene.frustumPlanes[o].dotCoordinate(n) < 0) return !1;
  8254. }
  8255. return !0;
  8256. });
  8257. E(this, "addNewLowPolyMesh", function (e, t, r) {
  8258. 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)));
  8259. {
  8260. var n = e.url;
  8261. return new Promise(function (o, a) {
  8262. return _this._scenemanager.urlTransformer(e.url).then(function (s) {
  8263. e.url = s;
  8264. var l = new XStaticMeshFromOneGltf(_this.scene, e),
  8265. u = Date.now();
  8266. return new Promise(function (c, h) {
  8267. l.loadMesh(r, !0).then(function (f) {
  8268. var d = Date.now();
  8269. if (_this._scenemanager.engineRunTimeStats.timeArray_loadStaticMesh.add(d - u), f == !0) {
  8270. var _ = _this.getLowModelType(e);
  8271. var g = 0;
  8272. 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) {
  8273. var m = [];
  8274. for (var v = 0; v < t.length; ++v) {
  8275. m.push(t[v].group), _this.updateLowModelGroup(t[v], _, g);
  8276. }
  8277. }
  8278. _this._scenemanager.engineRunTimeStats.timeArray_updateStaticMesh.add(Date.now() - d), c(!0);
  8279. } else h(new XLowpolyModelError("[Engine] after lowmodel error!"));
  8280. }).catch(function (f) {
  8281. logger$1.error("[Engine] load Mesh [" + n + "] error! " + f), h(new XLowpolyModelError("[Engine] load Mesh [".concat(n, "] error! ").concat(f)));
  8282. });
  8283. });
  8284. }).then(function (s) {
  8285. s == !0 ? (logger$1.info("[Engine] load Mesh [".concat(n, "] successfully.")), o(!0)) : a(!1);
  8286. }).catch(function (s) {
  8287. logger$1.error("[Engine] addNewLowPolyMesh [" + n + "] error! " + s), a(new XLowpolyModelError("[Engine] addNewLowPolyMesh [".concat(n, "] error! ").concat(s)));
  8288. });
  8289. });
  8290. }
  8291. });
  8292. E(this, "toggleLowModelVisibility", function (e) {
  8293. var t = e.vis,
  8294. _e$groupName = e.groupName,
  8295. r = _e$groupName === void 0 ? "" : _e$groupName,
  8296. _e$skinInfo = e.skinInfo,
  8297. n = _e$skinInfo === void 0 ? "" : _e$skinInfo;
  8298. _this._meshVis = t, _this._meshVisTypeName = {
  8299. groupName: r,
  8300. skinInfo: n
  8301. }, _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;
  8302. });
  8303. E(this, "reg_staticmesh_visibility", function () {
  8304. if (_this._doMeshVisChangeNumber >= 0) if (_this._doMeshVisChangeNumber < _this._visCheckDurationFrameNumber) {
  8305. if (_this._doMeshVisChangeNumber = _this._doMeshVisChangeNumber + 1, _this._meshVisTypeName.groupName == Te.ALL_MESHES) _this._lowModel_group.forEach(function (e, t) {
  8306. for (var r = 0, n = e.length; r < n; ++r) {
  8307. e[r].toggleVisibility(_this._meshVis);
  8308. }
  8309. });else {
  8310. if (_this._lowModel_group.has(_this._meshVisTypeName.groupName)) for (var _e3 = 0; _e3 < _this._lowModel_group.get(_this._meshVisTypeName.groupName).length; ++_e3) {
  8311. _this._lowModel_group.get(_this._meshVisTypeName.groupName)[_e3].toggleVisibility(_this._meshVis);
  8312. }
  8313. if (_this._meshVisTypeName.skinInfo != "") for (var _e4 = 0; _e4 < _this._staticmeshes.length; ++_e4) {
  8314. _this._staticmeshes[_e4].skinInfo == _this._meshVisTypeName.skinInfo && _this._staticmeshes[_e4].toggleVisibility(_this._meshVis);
  8315. }
  8316. }
  8317. } else _this._meshVis = !0, _this._meshVisTypeName = {
  8318. groupName: "",
  8319. skinInfo: ""
  8320. }, _this._doMeshVisChangeNumber = -1;
  8321. });
  8322. E(this, "_getMeshesByCustomProperty", function (e, t) {
  8323. var r = [];
  8324. return _this._staticmeshes.forEach(function (n) {
  8325. n[e] != null && n[e] == t && (r = r.concat(n.meshes));
  8326. }), r;
  8327. });
  8328. 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 = {
  8329. groupName: "",
  8330. skinInfo: ""
  8331. }, this._doMeshVisChangeNumber = -1, this._visCheckDurationFrameNumber = -1, this._regionLodRule = [0, 1, 3, 3, -1], this.initCgLowModel(), this._regionPartLoop();
  8332. }
  8333. _createClass(XStaticMeshComponent, [{
  8334. key: "cameraInRegionId",
  8335. get: function get() {
  8336. return this._cameraInRegionId;
  8337. }
  8338. }, {
  8339. key: "setRegionLodRule",
  8340. value: function setRegionLodRule(e) {
  8341. return e.length != 5 ? !1 : (e.forEach(function (t) {}), this._regionLodRule = e, !0);
  8342. }
  8343. }, {
  8344. key: "lowModel_group",
  8345. get: function get() {
  8346. return this._lowModel_group;
  8347. }
  8348. }, {
  8349. key: "_regionPartLoop",
  8350. value: function _regionPartLoop() {
  8351. this.scene.registerBeforeRender(this.reg_staticmesh_partupdate), this.scene.registerAfterRender(this.reg_staticmesh_visibility);
  8352. }
  8353. }, {
  8354. key: "_globalSearchCameraInWhichRegion",
  8355. value: function _globalSearchCameraInWhichRegion(e, t) {
  8356. var r = -1;
  8357. for (var n = 0; n < t.length; ++n) {
  8358. var o = this._meshInfoJson[t[n].toString()].boundingbox,
  8359. a = o[0],
  8360. s = o[1];
  8361. 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]) {
  8362. r = parseInt(t[n].toString());
  8363. break;
  8364. }
  8365. }
  8366. return r;
  8367. }
  8368. }, {
  8369. key: "getRegionIdByPosition",
  8370. value: function getRegionIdByPosition(e) {
  8371. return this.getRegionIdWhichIncludeCamera(e);
  8372. }
  8373. }, {
  8374. key: "getRegionIdWhichIncludeCamera",
  8375. value: function getRegionIdWhichIncludeCamera(e) {
  8376. var t = -1;
  8377. if (this._allowRegionUpdate == !1) return t;
  8378. 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) {
  8379. var r = 1e7;
  8380. for (var n = 0; n < this._meshInfoKeys.length; ++n) {
  8381. var o = this._meshInfoJson[this._meshInfoKeys[n]].center,
  8382. a = Math.abs(e.x - o[0]) + Math.abs(e.y - o[1]);
  8383. r > a && (r = a, t = parseInt(this._meshInfoKeys[n]));
  8384. }
  8385. }
  8386. return t;
  8387. }
  8388. }, {
  8389. key: "getNearestRegionIdWithCamera",
  8390. value: function getNearestRegionIdWithCamera(e) {
  8391. var t = 1,
  8392. r = 1e7;
  8393. for (var n = 0; n < this._meshInfoKeys.length; ++n) {
  8394. if (this._notUsedRegionLists.indexOf(parseInt(this._meshInfoKeys[n])) >= 0) continue;
  8395. var o = this._meshInfoJson[this._meshInfoKeys[n]].center,
  8396. a = Math.abs(e.x - o[0]) + Math.abs(e.y - o[1]);
  8397. r > a && (r = a, t = parseInt(this._meshInfoKeys[n]));
  8398. }
  8399. return t;
  8400. }
  8401. }, {
  8402. key: "_getNeighborId",
  8403. value: function _getNeighborId(e) {
  8404. var t = this._meshInfoJson[e].lod;
  8405. var r = [];
  8406. var n = Object.keys(t);
  8407. for (var o = n.length - 1; o >= 0; --o) {
  8408. r = r.concat(t[n[o]]);
  8409. }
  8410. return r.push(parseInt(e)), r;
  8411. }
  8412. }, {
  8413. key: "_getMainPlayerPosition",
  8414. value: function _getMainPlayerPosition() {
  8415. var e = this._scenemanager.cameraComponent.getCameraPose().position,
  8416. t = this._scenemanager.avatarComponent.getMainAvatar();
  8417. if (t != null && t != null) {
  8418. var r = t.position;
  8419. if (r != null) return r;
  8420. }
  8421. return e;
  8422. }
  8423. }, {
  8424. key: "_calHashCode",
  8425. value: function _calHashCode(e) {
  8426. return hashCode(e) + "_" + this._partMeshSkinInfo;
  8427. }
  8428. }, {
  8429. key: "forceAllRegionLod",
  8430. value: function forceAllRegionLod() {
  8431. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 3;
  8432. e < 0 && (e = 0), e > 3 && (e = 3), this.stopMeshUpdate(), this._allowRegionForceLod = !0, this._forceLod = e;
  8433. }
  8434. }, {
  8435. key: "deleteLastRegionMesh",
  8436. value: function deleteLastRegionMesh() {
  8437. if (this._rootDir != "") {
  8438. var e = this._calHashCode(this._rootDir);
  8439. 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);
  8440. }
  8441. }
  8442. }, {
  8443. key: "startMeshUpdate",
  8444. value: function startMeshUpdate() {
  8445. this._allowRegionUpdate == !1 && this._meshInfoJson != null && this._abosoluteUrl != "" && this._meshInfoKeys.length > 0 && (this._allowRegionUpdate = !0);
  8446. }
  8447. }, {
  8448. key: "stopMeshUpdate",
  8449. value: function stopMeshUpdate() {
  8450. this._allowRegionUpdate = !1;
  8451. }
  8452. }, {
  8453. key: "parseJson",
  8454. value: function parseJson(e) {
  8455. var _this2 = this;
  8456. return new Promise(function (t, r) {
  8457. return _this2._scenemanager.urlTransformer(e).then(function (n) {
  8458. var o = new XMLHttpRequest();
  8459. o.open("get", n), o.send(null), o.onload = function () {
  8460. if (o.status == 200) {
  8461. var a = JSON.parse(o.responseText);
  8462. _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();
  8463. }
  8464. }, o.onerror = function () {
  8465. 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)));
  8466. };
  8467. }).catch(function (n) {
  8468. 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)));
  8469. });
  8470. });
  8471. }
  8472. }, {
  8473. key: "initCgLowModel",
  8474. value: function initCgLowModel() {
  8475. var e = BABYLON.MeshBuilder.CreatePlane("CgPlane", {
  8476. size: 400
  8477. });
  8478. e.position = new BABYLON.Vector3(0, 1010, 0), e.rotation = new BABYLON.Vector3(3 * Math.PI / 2, 0, 0), this._CgPlane = new XStaticMesh({
  8479. id: "CgPlane",
  8480. mesh: e,
  8481. xtype: EMeshType.Cgplane
  8482. }), this._CgPlane.hide();
  8483. }
  8484. }, {
  8485. key: "getLowModelType",
  8486. value: function getLowModelType(e) {
  8487. var t = "";
  8488. return e.group != null ? t = e.group : t = "default", t;
  8489. }
  8490. }, {
  8491. key: "lowmodelGroupMapAddValue",
  8492. value: function lowmodelGroupMapAddValue(e, t) {
  8493. var r = this._lowModel_group.get(e);
  8494. r != null ? (r.push(t), this._lowModel_group.set(e, r)) : this._lowModel_group.set(e, [t]);
  8495. }
  8496. }, {
  8497. key: "updateLowModelGroup",
  8498. value: function updateLowModelGroup(e, t, r) {
  8499. var n = r;
  8500. 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);
  8501. }
  8502. }, {
  8503. key: "toggleVisibleLowModelGroup",
  8504. value: function toggleVisibleLowModelGroup(e, t) {
  8505. var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : -1;
  8506. if (this._lowModel_group.has(t)) {
  8507. var n = this._lowModel_group.get(t);
  8508. var o = n.length;
  8509. r >= 0 && o >= r && (o = r);
  8510. for (var a = 0; a < o; ++a) {
  8511. n[a].toggleVisibility(e);
  8512. }
  8513. }
  8514. }
  8515. }, {
  8516. key: "deleteLowModelGroup",
  8517. value: function deleteLowModelGroup(e) {
  8518. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -1;
  8519. if (this._lowModel_group.has(e)) {
  8520. var o = this._lowModel_group.get(e);
  8521. var a = o.length;
  8522. t >= 0 && a >= t && (a = t);
  8523. for (var s = 0; s < a; ++s) {
  8524. o[s].dispose();
  8525. }
  8526. t >= 0 ? this._lowModel_group.set(e, this._lowModel_group.get(e).slice(a)) : this._lowModel_group.delete(e);
  8527. }
  8528. var r = this._lowModel_group.get(e),
  8529. n = [];
  8530. r != null && r.length > 0 ? this._staticmeshes.forEach(function (o) {
  8531. if (o.group != e) n.push(o);else for (var _a2 = 0; _a2 < r.length; ++_a2) {
  8532. o.groupUuid == r[_a2].groupUuid && n.push(o);
  8533. }
  8534. }) : this._staticmeshes.forEach(function (o) {
  8535. o.group != e && n.push(o);
  8536. }), this._staticmeshes = n;
  8537. }
  8538. }, {
  8539. key: "deleteMeshesByGroup",
  8540. value: function deleteMeshesByGroup(e) {
  8541. this.deleteLowModelGroup(e);
  8542. }
  8543. }, {
  8544. key: "deleteMeshesById",
  8545. value: function deleteMeshesById(e) {
  8546. this.deleteMeshesByCustomProperty("id", e);
  8547. }
  8548. }, {
  8549. key: "deleteMeshesByLoD",
  8550. value: function deleteMeshesByLoD(e) {
  8551. this.deleteMeshesByCustomProperty("lod", e);
  8552. }
  8553. }, {
  8554. key: "deleteMeshesBySkinInfo",
  8555. value: function deleteMeshesBySkinInfo(e) {
  8556. this.deleteMeshesByCustomProperty("skinInfo", e);
  8557. }
  8558. }, {
  8559. key: "removeMeshesFromSceneByGroup",
  8560. value: function removeMeshesFromSceneByGroup(e) {
  8561. this.removeMeshesFromSceneByCustomProperty("group", e);
  8562. }
  8563. }, {
  8564. key: "removeMeshesFromSceneById",
  8565. value: function removeMeshesFromSceneById(e) {
  8566. this.removeMeshesFromSceneByCustomProperty("id", e);
  8567. }
  8568. }, {
  8569. key: "addMeshesToSceneByGroup",
  8570. value: function addMeshesToSceneByGroup(e) {
  8571. this.addMeshesToSceneByCustomProperty("group", e);
  8572. }
  8573. }, {
  8574. key: "addMeshesToSceneById",
  8575. value: function addMeshesToSceneById(e) {
  8576. this.addMeshesToSceneByCustomProperty("id", e);
  8577. }
  8578. }, {
  8579. key: "removeMeshesFromSceneByCustomProperty",
  8580. value: function removeMeshesFromSceneByCustomProperty(e, t) {
  8581. var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : !1;
  8582. this._staticmeshes.forEach(function (n) {
  8583. n.isinscene && n[e] != null && (r ? n[e].indexOf(t) < 0 || n.removeFromScene() : n[e] != t || n.removeFromScene());
  8584. });
  8585. }
  8586. }, {
  8587. key: "addMeshesToSceneByCustomProperty",
  8588. value: function addMeshesToSceneByCustomProperty(e, t) {
  8589. var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : !1;
  8590. this._staticmeshes.forEach(function (n) {
  8591. n.isinscene == !1 && n[e] != null && (r ? n[e].indexOf(t) < 0 || n.addToScene() : n[e] != t || n.addToScene());
  8592. });
  8593. }
  8594. }, {
  8595. key: "deleteMeshesByCustomProperty",
  8596. value: function deleteMeshesByCustomProperty(e, t) {
  8597. var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : !1;
  8598. var n = [];
  8599. this._staticmeshes.forEach(function (a) {
  8600. a[e] != null && (r ? a[e].indexOf(t) < 0 ? n.push(a) : a.dispose() : a[e] != t ? n.push(a) : a.dispose());
  8601. }), this._staticmeshes = n;
  8602. var o = Array.from(this._lowModel_group.keys());
  8603. for (var a = 0; a < o.length; ++a) {
  8604. var s = o[a],
  8605. l = this._lowModel_group.get(s);
  8606. if (l != null) {
  8607. var u = [];
  8608. for (var c = 0; c < l.length; ++c) {
  8609. l[c][e] != null && (r ? l[c][e].indexOf(t) < 0 && u.push(l[c]) : l[c][e] != t && u.push(l[c]));
  8610. }
  8611. u.length > 0 ? this._lowModel_group.set(s, u) : this._lowModel_group.delete(s);
  8612. }
  8613. }
  8614. }
  8615. }, {
  8616. key: "getMeshes",
  8617. value: function getMeshes() {
  8618. var e = [];
  8619. for (var t = 0; t < this._staticmeshes.length; ++t) {
  8620. e = e.concat(this._staticmeshes[t].meshes);
  8621. }
  8622. return e;
  8623. }
  8624. }, {
  8625. key: "getCgMesh",
  8626. value: function getCgMesh() {
  8627. return this._CgPlane;
  8628. }
  8629. }, {
  8630. key: "getMeshesByGroup",
  8631. value: function getMeshesByGroup() {
  8632. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "default";
  8633. var t = this._lowModel_group.get(e);
  8634. if (t != null) {
  8635. var r = [];
  8636. for (var n = 0; n < t.length; ++n) {
  8637. r = r.concat(t[n].meshes);
  8638. }
  8639. return r;
  8640. } else return null;
  8641. }
  8642. }, {
  8643. key: "getMeshesByGroup2",
  8644. value: function getMeshesByGroup2() {
  8645. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "default";
  8646. return this._getMeshesByCustomProperty("group", e);
  8647. }
  8648. }]);
  8649. return XStaticMeshComponent;
  8650. }();
  8651. var XVideoRawYUV = /*#__PURE__*/function () {
  8652. function XVideoRawYUV(e, t) {
  8653. var _this = this;
  8654. _classCallCheck(this, XVideoRawYUV);
  8655. E(this, "scene");
  8656. E(this, "_videoRawYUVTexture");
  8657. E(this, "videosResOriArray");
  8658. E(this, "_currentVideoId");
  8659. this.scene = e, this._videoRawYUVTexture = [], this.videosResOriArray = t, this._currentVideoId = -1;
  8660. for (var r = 0; r < t.length; ++r) {
  8661. (function (n) {
  8662. var o = BABYLON.RawTexture.CreateLuminanceTexture(null, t[n].width, t[n].height * 1.5, _this.scene, !1, !0);
  8663. o.name = "videoTex_" + t[n].width + "_" + t[n].height, _this._videoRawYUVTexture.push(o);
  8664. })(r);
  8665. }
  8666. }
  8667. _createClass(XVideoRawYUV, [{
  8668. key: "inRange",
  8669. value: function inRange(e) {
  8670. return e >= 0 && e < this._videoRawYUVTexture.length;
  8671. }
  8672. }, {
  8673. key: "getVideoYUVTex",
  8674. value: function getVideoYUVTex(e) {
  8675. return this.inRange(e) ? this._videoRawYUVTexture[e] : null;
  8676. }
  8677. }, {
  8678. key: "findId",
  8679. value: function findId(e, t) {
  8680. var r = 0;
  8681. for (var n = 0; n < this.videosResOriArray.length; ++n) {
  8682. if (this.videosResOriArray[n].width == e && this.videosResOriArray[n].height == t) {
  8683. r = n;
  8684. break;
  8685. }
  8686. }
  8687. return r;
  8688. }
  8689. }, {
  8690. key: "getCurrentVideoTexId",
  8691. value: function getCurrentVideoTexId() {
  8692. return this._currentVideoId;
  8693. }
  8694. }, {
  8695. key: "setCurrentVideoTexId",
  8696. value: function setCurrentVideoTexId(e) {
  8697. this._currentVideoId = e;
  8698. }
  8699. }]);
  8700. return XVideoRawYUV;
  8701. }();
  8702. var XMaterialComponent = /*#__PURE__*/function () {
  8703. function XMaterialComponent(e, t) {
  8704. var _this = this;
  8705. _classCallCheck(this, XMaterialComponent);
  8706. E(this, "scene");
  8707. E(this, "engine");
  8708. E(this, "yuvInfo");
  8709. E(this, "shaderMode");
  8710. E(this, "_panoInfo");
  8711. E(this, "_dynamic_size");
  8712. E(this, "_dynamic_babylonpose");
  8713. E(this, "_dynamic_textures");
  8714. E(this, "_dynamic_shaders");
  8715. E(this, "_scenemanager");
  8716. E(this, "_videoTexture");
  8717. E(this, "_videoElement");
  8718. E(this, "_lowModelShader");
  8719. E(this, "_defaultShader");
  8720. E(this, "_inputYUV420", !0);
  8721. E(this, "_inputPanoYUV420", !0);
  8722. E(this, "_videoRawYUVTexArray");
  8723. E(this, "_isUpdateYUV", !0);
  8724. E(this, "initMaterial", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
  8725. return regenerator.wrap(function _callee$(_context) {
  8726. while (1) {
  8727. switch (_context.prev = _context.next) {
  8728. case 0:
  8729. return _context.abrupt("return", new Promise(function (e, t) {
  8730. _this._initDefaultShader(), _this.shaderMode == 2 ? _this.initDynamicData(_this._panoInfo.dynamicRange, _this._panoInfo.width, _this._panoInfo.height).then(function () {
  8731. _this._initPureVideoShader(), _this._prepareRender(_this.yuvInfo);
  8732. }) : _this.shaderMode == 1 ? (_this._initPureVideoShader(), _this._prepareRender(_this.yuvInfo)) : _this.shaderMode == 0, e(!0);
  8733. }));
  8734. case 1:
  8735. case "end":
  8736. return _context.stop();
  8737. }
  8738. }
  8739. }, _callee);
  8740. })));
  8741. E(this, "_initPureVideoContent", function (e) {
  8742. _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 () {
  8743. _this._changePureVideoLowModelShaderCanvasSize(e);
  8744. })) : (_this._videoElement = e.videoElement, _this._videoTexture || (_this._videoTexture = new VideoTexture("InterVideoTexture", _this._videoElement, _this.scene, !0, !1)), BABYLON.Texture.WhenAllReady([_this._videoTexture], function () {
  8745. _this._changePureVideoLowModelShaderCanvasSize({
  8746. width: _this._videoElement.height,
  8747. height: _this._videoElement.width,
  8748. fov: e.fov
  8749. });
  8750. }), _this._lowModelShader.setTexture("texture_video", _this._videoTexture), _this._lowModelShader.setFloat("isYUV", 0));
  8751. });
  8752. E(this, "_changePureVideoLowModelShaderCanvasSize", function (e) {
  8753. var a;
  8754. var t = e.fov || 50,
  8755. r = e.width || 720,
  8756. n = e.height || 1280,
  8757. o = r / (2 * Math.tan(Math.PI * t / 360));
  8758. (a = _this._lowModelShader) == null || a.setVector3("focal_width_height", new BABYLON.Vector3(o, r, n));
  8759. });
  8760. E(this, "updateRawYUVData", function (e, t, r) {
  8761. var n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : -1;
  8762. var o, a;
  8763. if (n == -1 && (n = _this.yuvInfo.fov), _this._isUpdateYUV == !0) {
  8764. var s = {
  8765. width: t,
  8766. height: r,
  8767. fov: n
  8768. },
  8769. l = _this._videoRawYUVTexArray.findId(t, r),
  8770. u = _this._videoRawYUVTexArray.getCurrentVideoTexId();
  8771. (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);
  8772. }
  8773. });
  8774. E(this, "_changeVideoRes", function (e) {
  8775. _this._lowModelShader.setTexture("texture_video", _this._videoRawYUVTexArray.getVideoYUVTex(e));
  8776. });
  8777. E(this, "initDynamicData", function (e, t, r) {
  8778. return new Promise(function (n, o) {
  8779. _this.setDynamicSize(e).then(function (a) {
  8780. if (a) {
  8781. for (var s = 0; s < e; ++s) {
  8782. (function (l) {
  8783. _this.initDynamicTexture(l, t, r), _this.initDynamicShaders(l).then(function () {
  8784. _this._updatePanoShaderInput(l);
  8785. });
  8786. })(s);
  8787. }
  8788. n(!0);
  8789. } else o(new XMaterialError("[Engine] DynamicRoomSize (".concat(e, ") is too small")));
  8790. });
  8791. }).catch(function (n) {
  8792. return logger$1.error("[Engine] ".concat(n));
  8793. });
  8794. });
  8795. E(this, "_initDefaultShader", function () {
  8796. _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);
  8797. });
  8798. E(this, "_initPureVideoShader", function () {
  8799. if (_this._lowModelShader == null) {
  8800. var _e = new BABYLON.ShaderMaterial("PureVideoShader", _this.scene, {
  8801. vertexSource: pureVideoVertex,
  8802. fragmentSource: pureVideoFragment
  8803. }, {
  8804. attributes: ["uv", "position", "world0", "world1", "world2", "world3"],
  8805. uniforms: ["view", "projection", "worldViewProjection", "world"],
  8806. defines: ["#define SHADOWFULLFLOAT"]
  8807. });
  8808. _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;
  8809. }
  8810. });
  8811. E(this, "setDynamicSize", function (e) {
  8812. return new Promise(function (t, r) {
  8813. e >= 1 && e <= 100 ? (_this._dynamic_size = e, t(!0)) : (_this._dynamic_size = 1, t(!1));
  8814. });
  8815. });
  8816. E(this, "_isInDynamicRange", function (e) {
  8817. return e < _this._dynamic_size && e >= 0;
  8818. });
  8819. E(this, "initDynamicTexture", function (e, t, r) {
  8820. _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());
  8821. });
  8822. E(this, "initDynamicShaders", function (e) {
  8823. return logger$1.info("[Engine] Material init dynamic shader."), new Promise(function (t, r) {
  8824. _this._dynamic_shaders[e] != null && _this._dynamic_shaders[e].dispose();
  8825. var n = new BABYLON.ShaderMaterial("Pano_Shader_" + e, _this.scene, {
  8826. vertexSource: panoVertex,
  8827. fragmentSource: panoFragment
  8828. }, {
  8829. attributes: ["uv", "position", "world0", "world1", "world2", "world3"],
  8830. uniforms: ["view", "projection", "worldViewProjection", "world"],
  8831. defines: ["#define SHADOWFULLFLOAT"]
  8832. });
  8833. 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);
  8834. });
  8835. });
  8836. 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);
  8837. }
  8838. _createClass(XMaterialComponent, [{
  8839. key: "stopYUVUpdate",
  8840. value: function stopYUVUpdate() {
  8841. this._isUpdateYUV = !1;
  8842. }
  8843. }, {
  8844. key: "allowYUVUpdate",
  8845. value: function allowYUVUpdate() {
  8846. this._isUpdateYUV = !0;
  8847. }
  8848. }, {
  8849. key: "setPanoInfo",
  8850. value: function setPanoInfo(e) {
  8851. this._panoInfo = e;
  8852. }
  8853. }, {
  8854. key: "_prepareRender",
  8855. value: function _prepareRender(e) {
  8856. e && (this._initPureVideoContent(e), this._updatePureVideoShaderInput());
  8857. }
  8858. }, {
  8859. key: "getPureVideoShader",
  8860. value: function getPureVideoShader() {
  8861. return this._lowModelShader;
  8862. }
  8863. }, {
  8864. key: "getDefaultShader",
  8865. value: function getDefaultShader() {
  8866. return this._defaultShader;
  8867. }
  8868. }, {
  8869. key: "updatePanoPartYUV",
  8870. value: function updatePanoPartYUV(e, t, r) {
  8871. var n = t.subarray(0, r.width * r.height),
  8872. o = t.subarray(r.width * r.height, r.width * r.height * 1.25),
  8873. a = t.subarray(r.width * r.height * 1.25),
  8874. s = this._panoInfo.width,
  8875. l = this._panoInfo.height;
  8876. if (this._dynamic_textures[e] != null) {
  8877. var u = this._dynamic_textures[e].getInternalTexture();
  8878. if (u != null && u != null) {
  8879. var c = this.engine._getTextureTarget(u);
  8880. 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);
  8881. }
  8882. }
  8883. }
  8884. }, {
  8885. key: "changePanoImg",
  8886. value: function changePanoImg(e, t) {
  8887. var _this2 = this;
  8888. 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")));
  8889. var r = ue4Position2Xverse(t.pose.position);
  8890. return r && (this._dynamic_babylonpose[e] = {
  8891. position: r
  8892. }), new Promise(function (n, o) {
  8893. try {
  8894. typeof t.data == "string" ? (_this2.setPanoYUV420(!1), _this2._dynamic_textures[e].updateURL(t.data, null, function () {
  8895. _this2._dynamic_textures[e].updateSamplingMode(BABYLON.Texture.NEAREST_SAMPLINGMODE);
  8896. })) : (_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);
  8897. } catch (a) {
  8898. o(new XMaterialError("[Engine] ChangePanoImg Error! ".concat(a)));
  8899. }
  8900. }).then(function (n) {
  8901. 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;
  8902. });
  8903. }
  8904. }, {
  8905. key: "setYUV420",
  8906. value: function setYUV420(e) {
  8907. this._inputYUV420 = e;
  8908. }
  8909. }, {
  8910. key: "isYUV420",
  8911. value: function isYUV420() {
  8912. return this._inputYUV420;
  8913. }
  8914. }, {
  8915. key: "setPanoYUV420",
  8916. value: function setPanoYUV420(e) {
  8917. this._inputPanoYUV420 = e;
  8918. }
  8919. }, {
  8920. key: "isPanoYUV420",
  8921. value: function isPanoYUV420() {
  8922. return this._inputPanoYUV420;
  8923. }
  8924. }, {
  8925. key: "getDynamicShader",
  8926. value: function getDynamicShader(e) {
  8927. return this._dynamic_shaders[e];
  8928. }
  8929. }, {
  8930. key: "_updatePureVideoShaderInput",
  8931. value: function _updatePureVideoShaderInput() {
  8932. var _this3 = this;
  8933. var e, t, r, n, o, a, s, l, u, c;
  8934. 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 () {
  8935. var h;
  8936. _this3._lowModelShader.setFloat("fireworkLight", _this3.scene.getLightByName("fireworkLight").getScaledIntensity()), _this3._lowModelShader.setVector3("fireworkLightPosition", (h = _this3.scene.getLightByName("fireworkLight")) == null ? void 0 : h.position);
  8937. });else {
  8938. var h = new BABYLON.PointLight("fireworkLight", new BABYLON.Vector3(0, 0, 0), this.scene);
  8939. h.intensity = 0;
  8940. }
  8941. }
  8942. }, {
  8943. key: "_updatePanoShaderInput",
  8944. value: function _updatePanoShaderInput(e) {
  8945. var _this4 = this;
  8946. var t, r, n, o, a, s, l, u, c, h;
  8947. 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 () {
  8948. var f;
  8949. _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);
  8950. });else {
  8951. var f = new BABYLON.PointLight("fireworkLight", new BABYLON.Vector3(0, 0, 0), this.scene);
  8952. f.intensity = 0;
  8953. }
  8954. }
  8955. }]);
  8956. return XMaterialComponent;
  8957. }();
  8958. var XStats = /*#__PURE__*/function () {
  8959. function XStats(e) {
  8960. _classCallCheck(this, XStats);
  8961. E(this, "scene");
  8962. E(this, "sceneInstrumentation");
  8963. E(this, "engineInstrumentation");
  8964. E(this, "caps");
  8965. E(this, "engine");
  8966. E(this, "_canvas");
  8967. E(this, "_osversion");
  8968. E(this, "_scenemanager");
  8969. this._scenemanager = e, this.scene = e.Scene, this._canvas = e.canvas, this.initSceneInstrument();
  8970. }
  8971. _createClass(XStats, [{
  8972. key: "initSceneInstrument",
  8973. value: function initSceneInstrument() {
  8974. 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();
  8975. }
  8976. }, {
  8977. key: "getFrameTimeCounter",
  8978. value: function getFrameTimeCounter() {
  8979. return this.sceneInstrumentation.frameTimeCounter.current;
  8980. }
  8981. }, {
  8982. key: "getInterFrameTimeCounter",
  8983. value: function getInterFrameTimeCounter() {
  8984. return this.sceneInstrumentation.interFrameTimeCounter.current;
  8985. }
  8986. }, {
  8987. key: "getActiveMeshEvaluationTime",
  8988. value: function getActiveMeshEvaluationTime() {
  8989. return this.sceneInstrumentation.activeMeshesEvaluationTimeCounter.current;
  8990. }
  8991. }, {
  8992. key: "getDrawCall",
  8993. value: function getDrawCall() {
  8994. return this.sceneInstrumentation.drawCallsCounter.current;
  8995. }
  8996. }, {
  8997. key: "getDrawCallTime",
  8998. value: function getDrawCallTime() {
  8999. return this.sceneInstrumentation.renderTimeCounter.current;
  9000. }
  9001. }, {
  9002. key: "getAnimationTime",
  9003. value: function getAnimationTime() {
  9004. return this.sceneInstrumentation.animationsTimeCounter.current;
  9005. }
  9006. }, {
  9007. key: "getActiveMesh",
  9008. value: function getActiveMesh() {
  9009. return this.scene.getActiveMeshes().length;
  9010. }
  9011. }, {
  9012. key: "getActiveFaces",
  9013. value: function getActiveFaces() {
  9014. return Math.round(this.scene.getActiveIndices() / 3);
  9015. }
  9016. }, {
  9017. key: "getActiveBones",
  9018. value: function getActiveBones() {
  9019. return this.scene.getActiveBones();
  9020. }
  9021. }, {
  9022. key: "getActiveAnimation",
  9023. value: function getActiveAnimation() {
  9024. return this.scene._activeAnimatables.length;
  9025. }
  9026. }, {
  9027. key: "getActiveParticles",
  9028. value: function getActiveParticles() {
  9029. return this.scene.getActiveParticles();
  9030. }
  9031. }, {
  9032. key: "getTotalMaterials",
  9033. value: function getTotalMaterials() {
  9034. return this.scene.materials.length;
  9035. }
  9036. }, {
  9037. key: "getTotalTextures",
  9038. value: function getTotalTextures() {
  9039. return this.scene.textures.length;
  9040. }
  9041. }, {
  9042. key: "getTotalGeometries",
  9043. value: function getTotalGeometries() {
  9044. return this.scene.geometries.length;
  9045. }
  9046. }, {
  9047. key: "getTotalMeshes",
  9048. value: function getTotalMeshes() {
  9049. return this.scene.meshes.length;
  9050. }
  9051. }, {
  9052. key: "getCameraRenderTime",
  9053. value: function getCameraRenderTime() {
  9054. return this.sceneInstrumentation.cameraRenderTimeCounter.current;
  9055. }
  9056. }, {
  9057. key: "getTotalRootNodes",
  9058. value: function getTotalRootNodes() {
  9059. return this.scene.rootNodes.length;
  9060. }
  9061. }, {
  9062. key: "getRenderTargetRenderTime",
  9063. value: function getRenderTargetRenderTime() {
  9064. var e = this.getDrawCallTime(),
  9065. t = this.getActiveMeshEvaluationTime(),
  9066. r = this.getCameraRenderTime() - (t + e);
  9067. return this.getRTT1Time() + r;
  9068. }
  9069. }, {
  9070. key: "getRegisterBeforeRenderTime",
  9071. value: function getRegisterBeforeRenderTime() {
  9072. return this.sceneInstrumentation.registerBeforeTimeCounter.current;
  9073. }
  9074. }, {
  9075. key: "getRegisterAfterRenderTime",
  9076. value: function getRegisterAfterRenderTime() {
  9077. return this.sceneInstrumentation.registerAfterTimeCounter.current;
  9078. }
  9079. }, {
  9080. key: "getRTT1Time",
  9081. value: function getRTT1Time() {
  9082. return this.sceneInstrumentation.getRTT1TimeCounter.current;
  9083. }
  9084. }, {
  9085. key: "getRegisterBeforeRenderObserverLength",
  9086. value: function getRegisterBeforeRenderObserverLength() {
  9087. return this.scene.onBeforeRenderObservable.observers.length;
  9088. }
  9089. }, {
  9090. key: "getRegisterAfterRenderObserverLength",
  9091. value: function getRegisterAfterRenderObserverLength() {
  9092. return this.scene.onAfterRenderObservable.observers.length;
  9093. }
  9094. }, {
  9095. key: "getTotalMeshByType",
  9096. value: function getTotalMeshByType() {
  9097. var e = new Map();
  9098. return this.scene.meshes.forEach(function (t) {
  9099. e.has(t.xtype) ? e.set(t.xtype, e.get(t.xtype) + 1) : e.set(t.xtype, 1);
  9100. }), e;
  9101. }
  9102. }, {
  9103. key: "getHardwareRenderInfo",
  9104. value: function getHardwareRenderInfo() {
  9105. return {
  9106. maxTexturesUnits: this.caps.maxTexturesImageUnits,
  9107. maxVertexTextureImageUnits: this.caps.maxVertexTextureImageUnits,
  9108. maxCombinedTexturesImageUnits: this.caps.maxCombinedTexturesImageUnits,
  9109. maxTextureSize: this.caps.maxTextureSize,
  9110. maxSamples: this.caps.maxSamples,
  9111. maxCubemapTextureSize: this.caps.maxCubemapTextureSize,
  9112. maxRenderTextureSize: this.caps.maxRenderTextureSize,
  9113. maxVertexAttribs: this.caps.maxVertexAttribs,
  9114. maxVaryingVectors: this.caps.maxVaryingVectors,
  9115. maxVertexUniformVectors: this.caps.maxVertexUniformVectors,
  9116. maxFragmentUniformVectors: this.caps.maxFragmentUniformVectors,
  9117. standardDerivatives: this.caps.standardDerivatives,
  9118. supportTextureCompress: {
  9119. s3tc: this.caps.s3tc !== void 0,
  9120. s3tc_srgb: this.caps.s3tc_srgb !== void 0,
  9121. pvrtc: this.caps.pvrtc !== void 0,
  9122. etc1: this.caps.etc1 !== void 0,
  9123. etc2: this.caps.etc2 !== void 0,
  9124. astc: this.caps.astc !== void 0,
  9125. bptc: this.caps.bptc !== void 0
  9126. },
  9127. textureFloat: this.caps.textureFloat,
  9128. vertexArrayObject: this.caps.vertexArrayObject,
  9129. textureAnisotropicFilterExtension: this.caps.textureAnisotropicFilterExtension !== void 0,
  9130. maxAnisotropy: this.caps.maxAnisotropy,
  9131. instancedArrays: this.caps.instancedArrays,
  9132. uintIndices: this.caps.uintIndices,
  9133. highPrecisionShaders: this.caps.highPrecisionShaderSupported,
  9134. fragmentDepth: this.caps.fragmentDepthSupported,
  9135. textureFloatLinearFiltering: this.caps.textureFloatLinearFiltering,
  9136. renderToTextureFloat: this.caps.textureFloatRender,
  9137. textureHalfFloat: this.caps.textureHalfFloat,
  9138. textureHalfFloatLinearFiltering: this.caps.textureHalfFloatLinearFiltering,
  9139. textureHalfFloatRender: this.caps.textureHalfFloatRender,
  9140. textureLOD: this.caps.textureLOD,
  9141. drawBuffersExtension: this.caps.drawBuffersExtension,
  9142. depthTextureExtension: this.caps.depthTextureExtension,
  9143. colorBufferFloat: this.caps.colorBufferFloat,
  9144. supportTimerQuery: this.caps.timerQuery !== void 0,
  9145. canUseTimestampForTimerQuery: this.caps.canUseTimestampForTimerQuery,
  9146. supportOcclusionQuery: this.caps.supportOcclusionQuery,
  9147. multiview: this.caps.multiview,
  9148. oculusMultiview: this.caps.oculusMultiview,
  9149. maxMSAASamples: this.caps.maxMSAASamples,
  9150. blendMinMax: this.caps.blendMinMax,
  9151. canUseGLInstanceID: this.caps.canUseGLInstanceID,
  9152. canUseGLVertexID: this.caps.canUseGLVertexID,
  9153. supportComputeShaders: this.caps.supportComputeShaders,
  9154. supportSRGBBuffers: this.caps.supportSRGBBuffers,
  9155. supportStencil: this.engine.isStencilEnable
  9156. };
  9157. }
  9158. }, {
  9159. key: "getSystemInfo",
  9160. value: function getSystemInfo() {
  9161. return {
  9162. resolution: "real: " + this.engine.getRenderWidth() + "x" + this.engine.getRenderHeight() + " cavs: " + this._canvas.clientWidth + "x" + this._canvas.clientHeight,
  9163. hardwareScalingLevel: this.engine.getHardwareScalingLevel().toFixed(2).toString() + "_" + this._scenemanager.initEngineScaleNumber.toFixed(2).toString(),
  9164. driver: this.engine.getGlInfo().renderer,
  9165. vender: this.engine.getGlInfo().vendor,
  9166. version: this.engine.getGlInfo().version,
  9167. os: this._osversion
  9168. };
  9169. }
  9170. }, {
  9171. key: "getFps",
  9172. value: function getFps() {
  9173. var e = this.sceneInstrumentation.frameTimeCounter.lastSecAverage,
  9174. t = this.sceneInstrumentation.interFrameTimeCounter.lastSecAverage;
  9175. return 1e3 / (e + t);
  9176. }
  9177. }, {
  9178. key: "osVersion",
  9179. value: function osVersion() {
  9180. var e = window.navigator.userAgent;
  9181. var t;
  9182. 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;
  9183. }
  9184. }]);
  9185. return XStats;
  9186. }();
  9187. function _arrayWithHoles(arr) {
  9188. if (Array.isArray(arr)) return arr;
  9189. }
  9190. function _iterableToArrayLimit(arr, i) {
  9191. var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
  9192. if (_i == null) return;
  9193. var _arr = [];
  9194. var _n = true;
  9195. var _d = false;
  9196. var _s, _e;
  9197. try {
  9198. for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
  9199. _arr.push(_s.value);
  9200. if (i && _arr.length === i) break;
  9201. }
  9202. } catch (err) {
  9203. _d = true;
  9204. _e = err;
  9205. } finally {
  9206. try {
  9207. if (!_n && _i["return"] != null) _i["return"]();
  9208. } finally {
  9209. if (_d) throw _e;
  9210. }
  9211. }
  9212. return _arr;
  9213. }
  9214. function _nonIterableRest() {
  9215. throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  9216. }
  9217. function _slicedToArray(arr, i) {
  9218. return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray$5(arr, i) || _nonIterableRest();
  9219. }
  9220. 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; } } }; }
  9221. 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); }
  9222. 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; }
  9223. var XBreathPointManager = /*#__PURE__*/function () {
  9224. function XBreathPointManager(e) {
  9225. var _this = this;
  9226. _classCallCheck(this, XBreathPointManager);
  9227. E(this, "_scene");
  9228. E(this, "materialMap", new Map());
  9229. E(this, "breathPoints", new Map());
  9230. E(this, "_sceneManager");
  9231. E(this, "_allIds", new Set());
  9232. E(this, "_loopBPKeys", []);
  9233. E(this, "addBreathPoint", /*#__PURE__*/function () {
  9234. var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  9235. 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;
  9236. return regenerator.wrap(function _callee$(_context) {
  9237. while (1) {
  9238. switch (_context.prev = _context.next) {
  9239. case 0:
  9240. t = [{
  9241. url: "https://static.xverse.cn/qqktv/texture.png"
  9242. }];
  9243. if (!(t.length <= 0)) {
  9244. _context.next = 4;
  9245. break;
  9246. }
  9247. logger$1.warn("[Engine] BreathPoint get texture list error: textureList.length <= 0"), new XBreathPointError("[Engine] BreathPoint get texture list error!");
  9248. return _context.abrupt("return");
  9249. case 4:
  9250. 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 ? {
  9251. pitch: -90,
  9252. yaw: 270,
  9253. roll: 0
  9254. } : _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;
  9255. if (!_this.breathPoints.get(n)) {
  9256. _context.next = 8;
  9257. break;
  9258. }
  9259. logger$1.warn("[Engine] Cannot add breathPoint with an existing id: [" + n + "]"), new XBreathPointError("[Engine] Cannot add breathPoint with an existing id: [" + n + "]");
  9260. return _context.abrupt("return");
  9261. case 8:
  9262. if (g) {
  9263. I = _this.castRay(new BABYLON.Vector3(l.x, l.y, l.z)) * scaleFromUE4toXverse;
  9264. I != 0 ? l.z = l.z - I + 1 : l.z = l.z + 1;
  9265. }
  9266. if (_this.materialMap.get(m)) {
  9267. _I = _this.materialMap.get(m);
  9268. _I.count = _I.count + 1, C = _I.mat;
  9269. } else {
  9270. _I2 = new Texture(o, _this._scene, !0, !0, Texture.BILINEAR_SAMPLINGMODE, null, function () {
  9271. logger$1.error("[Engine] Breathpoint create texture error."), new XBreathPointError("[Engine] Breathpoint create texture error.");
  9272. }, null, !0);
  9273. _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, {
  9274. mat: C,
  9275. count: 1,
  9276. lastRenderTime: Date.now(),
  9277. fps: d,
  9278. spriteWidthNumber: a,
  9279. spriteHeightNumber: s,
  9280. spriteSheet: o,
  9281. texture: _I2
  9282. });
  9283. }
  9284. A = new Array(6);
  9285. for (_I3 = 0; _I3 < 6; _I3++) {
  9286. A[_I3] = new Vector4(0, 0, 0, 0);
  9287. }
  9288. A[0] = new Vector4(0, 0, 1 / a, 1 / s), A[1] = new Vector4(0, 0, 1 / a, 1 / s);
  9289. S = {};
  9290. h > 0 && f > 0 ? S = {
  9291. width: h,
  9292. height: f,
  9293. depth: .01,
  9294. faceUV: A
  9295. } : S = {
  9296. size: c,
  9297. depth: .01,
  9298. faceUV: A
  9299. };
  9300. P = BABYLON.MeshBuilder.CreateBox(n, S, _this._scene);
  9301. P.material = C;
  9302. R = new XStaticMesh({
  9303. id: n,
  9304. mesh: P,
  9305. xtype: EMeshType.XBreathPoint,
  9306. skinInfo: T
  9307. });
  9308. M = u;
  9309. _ && (P.billboardMode = Mesh.BILLBOARDMODE_ALL, R.allowMove(), M = {
  9310. pitch: 0,
  9311. yaw: 270,
  9312. roll: 0
  9313. });
  9314. x = new BreathPoint({
  9315. type: m,
  9316. mesh: R,
  9317. id: n,
  9318. position: l,
  9319. rotation: M,
  9320. mat: C,
  9321. maxVisibleRegion: b,
  9322. scene: _this._scene,
  9323. skinInfo: T
  9324. });
  9325. _this.breathPoints.set(n, x), _this._allIds.add(n), v > 0 && setTimeout(function () {
  9326. _this.clearBreathPoints(n);
  9327. }, v * 1e3);
  9328. case 22:
  9329. case "end":
  9330. return _context.stop();
  9331. }
  9332. }
  9333. }, _callee);
  9334. }));
  9335. return function (_x) {
  9336. return _ref.apply(this, arguments);
  9337. };
  9338. }());
  9339. E(this, "reg_breathpoint_update", function () {
  9340. var e = new Date().getTime();
  9341. if (_this.materialMap != null) {
  9342. var _iterator = _createForOfIteratorHelper$3(_this.materialMap),
  9343. _step;
  9344. try {
  9345. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  9346. var _step$value = _slicedToArray(_step.value, 2),
  9347. t = _step$value[0],
  9348. r = _step$value[1];
  9349. 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);
  9350. }
  9351. } catch (err) {
  9352. _iterator.e(err);
  9353. } finally {
  9354. _iterator.f();
  9355. }
  9356. }
  9357. });
  9358. E(this, "reg_breathpoint_autovisible", function () {
  9359. if (_this._scene.getFrameId() % 2 == 0) if (_this._loopBPKeys.length == 0) _this._loopBPKeys = Array.from(_this._allIds);else {
  9360. var _e = _this._getMainPlayerPosition();
  9361. for (var t = 0; t < 5 && _this._loopBPKeys.length > 0; ++t) {
  9362. var r = _this._loopBPKeys.pop();
  9363. if (r != null) {
  9364. var n = _this.getBreathPoint(r);
  9365. if (n != null && n.maxvisibleregion >= 0 && n.mesh.visibility == 1) {
  9366. var o = n.mesh.position;
  9367. calcDistance3DVector(_e, o) >= n.maxvisibleregion ? n == null || n.removeFromScene() : n == null || n.addToScene();
  9368. }
  9369. }
  9370. }
  9371. }
  9372. });
  9373. this._sceneManager = e, this._scene = e.Scene, this._scene.registerBeforeRender(this.reg_breathpoint_update), this._scene.registerBeforeRender(this.reg_breathpoint_autovisible);
  9374. }
  9375. _createClass(XBreathPointManager, [{
  9376. key: "setAllBreathPointVisibility",
  9377. value: function setAllBreathPointVisibility(e) {
  9378. var _iterator2 = _createForOfIteratorHelper$3(this.breathPoints.entries()),
  9379. _step2;
  9380. try {
  9381. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  9382. var _step2$value = _slicedToArray(_step2.value, 2),
  9383. t = _step2$value[0],
  9384. r = _step2$value[1];
  9385. r.toggleVisibility(e);
  9386. }
  9387. } catch (err) {
  9388. _iterator2.e(err);
  9389. } finally {
  9390. _iterator2.f();
  9391. }
  9392. }
  9393. }, {
  9394. key: "toggleBPVisibilityBySkinInfo",
  9395. value: function toggleBPVisibilityBySkinInfo(e, t) {
  9396. var _iterator3 = _createForOfIteratorHelper$3(this.breathPoints.entries()),
  9397. _step3;
  9398. try {
  9399. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  9400. var _step3$value = _slicedToArray(_step3.value, 2),
  9401. r = _step3$value[0],
  9402. n = _step3$value[1];
  9403. n.skinInfo == e && n.toggleVisibility(t);
  9404. }
  9405. } catch (err) {
  9406. _iterator3.e(err);
  9407. } finally {
  9408. _iterator3.f();
  9409. }
  9410. }
  9411. }, {
  9412. key: "toggleBPVisibilityById",
  9413. value: function toggleBPVisibilityById(e, t) {
  9414. var r = this.getBreathPoint(e);
  9415. r != null && r.toggleVisibility(t);
  9416. }
  9417. }, {
  9418. key: "getBreathPointBySkinInfo",
  9419. value: function getBreathPointBySkinInfo(e) {
  9420. var t = [];
  9421. var _iterator4 = _createForOfIteratorHelper$3(this.breathPoints.entries()),
  9422. _step4;
  9423. try {
  9424. for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
  9425. var _step4$value = _slicedToArray(_step4.value, 2),
  9426. r = _step4$value[0],
  9427. n = _step4$value[1];
  9428. n.skinInfo == e && t.push(n);
  9429. }
  9430. } catch (err) {
  9431. _iterator4.e(err);
  9432. } finally {
  9433. _iterator4.f();
  9434. }
  9435. return t;
  9436. }
  9437. }, {
  9438. key: "getAllBreathPoint",
  9439. value: function getAllBreathPoint() {
  9440. return this.breathPoints;
  9441. }
  9442. }, {
  9443. key: "getBreathPoint",
  9444. value: function getBreathPoint(e) {
  9445. return this.breathPoints.get(e);
  9446. }
  9447. }, {
  9448. key: "delete",
  9449. value: function _delete(e) {
  9450. var t = this.breathPoints.get(e);
  9451. if (t != null) {
  9452. t.dispose(), this._allIds.delete(e);
  9453. var r = this.materialMap.get(t._type);
  9454. 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);
  9455. }
  9456. }
  9457. }, {
  9458. key: "castRay",
  9459. value: function castRay(e) {
  9460. var s;
  9461. e = ue4Position2Xverse({
  9462. x: e.x,
  9463. y: e.y,
  9464. z: e.z
  9465. });
  9466. var t = new BABYLON.Vector3(0, -1, 0),
  9467. r = new Ray(e, t, length),
  9468. n = [],
  9469. o = (s = this._sceneManager) == null ? void 0 : s.getGround({
  9470. x: e.x,
  9471. y: e.y,
  9472. z: e.z
  9473. });
  9474. var a = r.intersectsMeshes(o);
  9475. if (a.length > 0) {
  9476. var l = a[0];
  9477. if (l && l.pickedMesh) {
  9478. var u = l.distance;
  9479. t.y = 1;
  9480. var c = r.intersectsMeshes(n);
  9481. var h = 1e8;
  9482. if (c.length > 0) {
  9483. var f = c[0];
  9484. return f && f.pickedMesh && (h = -f.distance), h == 1e8 ? u : Math.abs(h) < Math.abs(u) ? h : u;
  9485. }
  9486. }
  9487. } else if (t.y = 1, a = r.intersectsMeshes(n), a.length > 0) {
  9488. var _l = a[0];
  9489. if (_l && _l.pickedMesh) return _l.distance;
  9490. }
  9491. return 0;
  9492. }
  9493. }, {
  9494. key: "changePickable",
  9495. value: function changePickable(e) {
  9496. var _iterator5 = _createForOfIteratorHelper$3(this.breathPoints.entries()),
  9497. _step5;
  9498. try {
  9499. for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
  9500. var _step5$value = _slicedToArray(_step5.value, 2),
  9501. t = _step5$value[0],
  9502. r = _step5$value[1];
  9503. r.changePickable(e);
  9504. }
  9505. } catch (err) {
  9506. _iterator5.e(err);
  9507. } finally {
  9508. _iterator5.f();
  9509. }
  9510. }
  9511. }, {
  9512. key: "clearBreathPoints",
  9513. value: function clearBreathPoints(e) {
  9514. logger$1.info("[Engine] clearBreathPoints: ".concat(e));
  9515. var _iterator6 = _createForOfIteratorHelper$3(this.breathPoints.entries()),
  9516. _step6;
  9517. try {
  9518. for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
  9519. var _step6$value = _slicedToArray(_step6.value, 2),
  9520. t = _step6$value[0],
  9521. r = _step6$value[1];
  9522. (r._type == e || r._id == e) && this.delete(r._id);
  9523. }
  9524. } catch (err) {
  9525. _iterator6.e(err);
  9526. } finally {
  9527. _iterator6.f();
  9528. }
  9529. }
  9530. }, {
  9531. key: "clearBreathPointsBySkinInfo",
  9532. value: function clearBreathPointsBySkinInfo(e) {
  9533. logger$1.info("[Engine] clearBreathPointsBySkinInfo: ".concat(e));
  9534. var _iterator7 = _createForOfIteratorHelper$3(this.breathPoints.entries()),
  9535. _step7;
  9536. try {
  9537. for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
  9538. var _step7$value = _slicedToArray(_step7.value, 2),
  9539. t = _step7$value[0],
  9540. r = _step7$value[1];
  9541. r.skinInfo == e && this.delete(r._id);
  9542. }
  9543. } catch (err) {
  9544. _iterator7.e(err);
  9545. } finally {
  9546. _iterator7.f();
  9547. }
  9548. }
  9549. }, {
  9550. key: "clearAllBreathPoints",
  9551. value: function clearAllBreathPoints() {
  9552. logger$1.info("[Engine] ClearAllBreathPoints");
  9553. var _iterator8 = _createForOfIteratorHelper$3(this.breathPoints.entries()),
  9554. _step8;
  9555. try {
  9556. for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
  9557. var _step8$value = _slicedToArray(_step8.value, 2),
  9558. e = _step8$value[0],
  9559. t = _step8$value[1];
  9560. this.delete(t._id);
  9561. }
  9562. } catch (err) {
  9563. _iterator8.e(err);
  9564. } finally {
  9565. _iterator8.f();
  9566. }
  9567. }
  9568. }, {
  9569. key: "_getMainPlayerPosition",
  9570. value: function _getMainPlayerPosition() {
  9571. var r;
  9572. var e = this._sceneManager.cameraComponent.MainCamera.position,
  9573. t = this._sceneManager.avatarComponent.getMainAvatar();
  9574. if (t != null && t != null) {
  9575. var n = (r = t == null ? void 0 : t.rootNode) == null ? void 0 : r.position;
  9576. if (n != null) return n;
  9577. }
  9578. return e;
  9579. }
  9580. }, {
  9581. key: "changeBreathPointPose",
  9582. value: function changeBreathPointPose(e, t, r) {
  9583. var n = new BABYLON.Vector3(e.position.x, e.position.y, e.position.z);
  9584. if (this.breathPoints.get(r) != null) {
  9585. logger$1.info("[Engine] changeBreathPointPose, id:".concat(r));
  9586. var o = this.breathPoints.get(r),
  9587. a = o.mesh.position;
  9588. var s = a.subtract(n);
  9589. s = BABYLON.Vector3.Normalize(s);
  9590. var l = BABYLON.Vector3.Distance(a, n),
  9591. u = new Ray(n, s, l),
  9592. c = this._scene.multiPickWithRay(u);
  9593. if (c) {
  9594. for (var h = 0; h < c.length; h++) {
  9595. if (c[h].pickedMesh != null && t.mesh.name.indexOf(c[h].pickedMesh.name) >= 0) {
  9596. var f = c[h].pickedPoint;
  9597. o.mesh.position = n.add(f.subtract(n).scale(.99)), this.breathPoints.set(r, o);
  9598. }
  9599. }
  9600. }
  9601. } else logger$1.warn("[Engine] changeBreathPointPose, id:".concat(r, " is not existing!"));
  9602. }
  9603. }]);
  9604. return XBreathPointManager;
  9605. }();
  9606. 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; } } }; }
  9607. 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); }
  9608. 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; }
  9609. var XDecalManager = /*#__PURE__*/function () {
  9610. function XDecalManager(e) {
  9611. _classCallCheck(this, XDecalManager);
  9612. E(this, "scene");
  9613. E(this, "_decal");
  9614. E(this, "_mat");
  9615. E(this, "_sharedMat");
  9616. E(this, "_scenemanager");
  9617. this._decal = new Map(), this._mat = new Map(), this._sharedMat = new Map(), this._scenemanager = e, this.scene = e.Scene;
  9618. }
  9619. _createClass(XDecalManager, [{
  9620. key: "decals",
  9621. get: function get() {
  9622. return Array.from(this._decal.values());
  9623. }
  9624. }, {
  9625. key: "getMesh",
  9626. value: function getMesh() {
  9627. return this._decal;
  9628. }
  9629. }, {
  9630. key: "addDecal",
  9631. value: function () {
  9632. var _addDecal = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  9633. var _this = this;
  9634. var t, r, _e$skinInfo, n;
  9635. return regenerator.wrap(function _callee$(_context) {
  9636. while (1) {
  9637. switch (_context.prev = _context.next) {
  9638. case 0:
  9639. t = e.id, r = e.meshPath, _e$skinInfo = e.skinInfo, n = _e$skinInfo === void 0 ? "default" : _e$skinInfo;
  9640. 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) {
  9641. return _this._scenemanager.urlTransformer(r).then(function (s) {
  9642. return new Promise(function (l, u) {
  9643. if (_this._decal.get(t)) l(!0);else {
  9644. var c = new XDecal({
  9645. id: t,
  9646. scene: _this.scene,
  9647. meshPath: s,
  9648. skinInfo: n
  9649. });
  9650. _this._decal.set(t, c), c.loadModel().then(function () {
  9651. l(!0);
  9652. }).catch(function (h) {
  9653. 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)));
  9654. });
  9655. }
  9656. });
  9657. }).then(function (s) {
  9658. s == !0 ? o(!0) : a(!1);
  9659. }).catch(function (s) {
  9660. 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)));
  9661. });
  9662. })));
  9663. case 2:
  9664. case "end":
  9665. return _context.stop();
  9666. }
  9667. }
  9668. }, _callee, this);
  9669. }));
  9670. function addDecal(_x) {
  9671. return _addDecal.apply(this, arguments);
  9672. }
  9673. return addDecal;
  9674. }()
  9675. }, {
  9676. key: "setDecalTexture",
  9677. value: function setDecalTexture(e) {
  9678. var _this2 = this;
  9679. var t = e.id,
  9680. r = e.buffer,
  9681. _e$isDynamic = e.isDynamic,
  9682. n = _e$isDynamic === void 0 ? !1 : _e$isDynamic,
  9683. _e$width = e.width,
  9684. o = _e$width === void 0 ? 1100 : _e$width,
  9685. _e$height = e.height,
  9686. a = _e$height === void 0 ? 25 : _e$height,
  9687. _e$slots = e.slots,
  9688. s = _e$slots === void 0 ? 1 : _e$slots,
  9689. _e$visibleSlots = e.visibleSlots,
  9690. l = _e$visibleSlots === void 0 ? 1 : _e$visibleSlots,
  9691. u = !0;
  9692. return logger.info("[Engine] setDecalTexture wiht id:[".concat(t, "]")), new Promise(function (c, h) {
  9693. var f = _this2._decal.get(t);
  9694. if (f != null) {
  9695. if (_this2._mat.get(t) != null) _this2.changeDecalTexture({
  9696. id: t,
  9697. buffer: r,
  9698. isUrl: u,
  9699. isDynamic: n,
  9700. width: o,
  9701. height: a,
  9702. slots: s,
  9703. visibleSlots: l
  9704. }), c(!0);else {
  9705. var d = new XDecalMaterial(t, _this2.scene);
  9706. d.setTexture(r, u, n, o, a, s, l).then(function () {
  9707. f.setMat(d.getMat()), _this2._decal.set(t, f), _this2._mat.set(t, d), c(!0);
  9708. }).catch(function (_) {
  9709. logger.error("[Engine] setDecalTexture Error! " + _), h(new XDecalTextureError("[Engine] decal set texture error! ".concat(_)));
  9710. });
  9711. }
  9712. } else logger.error("[Engine] Error! decal id: [" + t + "] is not find!"), h(new XDecalTextureError("[Engine] decal id: [".concat(t, "] is not find!")));
  9713. });
  9714. }
  9715. }, {
  9716. key: "shareDecal",
  9717. value: function () {
  9718. var _shareDecal = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(e) {
  9719. var _this3 = this;
  9720. var t, r, n, _e$skinInfo2, o;
  9721. return regenerator.wrap(function _callee2$(_context2) {
  9722. while (1) {
  9723. switch (_context2.prev = _context2.next) {
  9724. case 0:
  9725. t = e.idTar, r = e.meshPath, n = e.idSrc, _e$skinInfo2 = e.skinInfo, o = _e$skinInfo2 === void 0 ? "default" : _e$skinInfo2;
  9726. 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) {
  9727. return _this3._scenemanager.urlTransformer(r).then(function (l) {
  9728. var u = new XDecal({
  9729. id: t,
  9730. scene: _this3.scene,
  9731. meshPath: l,
  9732. skinInfo: o
  9733. }),
  9734. c = _this3._mat.get(n);
  9735. c != null && (u.setMat(c.getMat()), u.sourceMatId = n, _this3._decal.set(t, u), _this3.addSharedMatCount(n)), a(!0);
  9736. }).catch(function (l) {
  9737. s(new XDecalError("[Engine] decal shareDecal error! ".concat(l)));
  9738. });
  9739. })) : (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!"))));
  9740. case 2:
  9741. case "end":
  9742. return _context2.stop();
  9743. }
  9744. }
  9745. }, _callee2, this);
  9746. }));
  9747. function shareDecal(_x2) {
  9748. return _shareDecal.apply(this, arguments);
  9749. }
  9750. return shareDecal;
  9751. }()
  9752. }, {
  9753. key: "changeDecalModel",
  9754. value: function () {
  9755. var _changeDecalModel = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e) {
  9756. var _this4 = this;
  9757. var t, r, n;
  9758. return regenerator.wrap(function _callee3$(_context3) {
  9759. while (1) {
  9760. switch (_context3.prev = _context3.next) {
  9761. case 0:
  9762. t = e.id, r = e.meshPath, n = this._decal.get(t);
  9763. return _context3.abrupt("return", new Promise(function (o, a) {
  9764. return n != null ? (logger.info("[Engine] changeDecalModel id:".concat(t)), n.changeModel(r).then(function () {
  9765. _this4._decal.set(t, n), o(!0);
  9766. })) : (logger.warn("[Engine] changeDecalModel id:".concat(t, " is not exist")), a("[Engine] changeDecalModel id:".concat(t, " is not exist")));
  9767. }));
  9768. case 2:
  9769. case "end":
  9770. return _context3.stop();
  9771. }
  9772. }
  9773. }, _callee3, this);
  9774. }));
  9775. function changeDecalModel(_x3) {
  9776. return _changeDecalModel.apply(this, arguments);
  9777. }
  9778. return changeDecalModel;
  9779. }()
  9780. }, {
  9781. key: "changeDecalTexture",
  9782. value: function changeDecalTexture(e) {
  9783. var t = e.id,
  9784. r = e.buffer,
  9785. _e$isUrl = e.isUrl,
  9786. n = _e$isUrl === void 0 ? !1 : _e$isUrl,
  9787. _e$isDynamic2 = e.isDynamic,
  9788. o = _e$isDynamic2 === void 0 ? !1 : _e$isDynamic2,
  9789. _e$width2 = e.width,
  9790. a = _e$width2 === void 0 ? 1110 : _e$width2,
  9791. _e$height2 = e.height,
  9792. s = _e$height2 === void 0 ? 25 : _e$height2,
  9793. _e$slots2 = e.slots,
  9794. l = _e$slots2 === void 0 ? 1 : _e$slots2,
  9795. _e$visibleSlots2 = e.visibleSlots,
  9796. u = _e$visibleSlots2 === void 0 ? 1 : _e$visibleSlots2,
  9797. c = this._mat.get(t);
  9798. 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"));
  9799. }
  9800. }, {
  9801. key: "deleteDecal",
  9802. value: function deleteDecal(e) {
  9803. var t, r;
  9804. if (this._decal.has(e)) {
  9805. var n = this._decal.get(e);
  9806. 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);
  9807. }
  9808. }
  9809. }, {
  9810. key: "deleteDecalBySkinInfo",
  9811. value: function deleteDecalBySkinInfo(e) {
  9812. var _iterator = _createForOfIteratorHelper$2(this._decal.entries()),
  9813. _step;
  9814. try {
  9815. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  9816. var _step$value = _slicedToArray(_step.value, 2),
  9817. t = _step$value[0],
  9818. r = _step$value[1];
  9819. r.skinInfo == e && this.deleteDecal(t);
  9820. }
  9821. } catch (err) {
  9822. _iterator.e(err);
  9823. } finally {
  9824. _iterator.f();
  9825. }
  9826. }
  9827. }, {
  9828. key: "addSharedMatCount",
  9829. value: function addSharedMatCount(e) {
  9830. var t = this._sharedMat.get(e);
  9831. t != null ? this._sharedMat.set(e, t + 1) : this._sharedMat.set(e, 1);
  9832. }
  9833. }, {
  9834. key: "minusSharedMatCount",
  9835. value: function minusSharedMatCount(e) {
  9836. var r;
  9837. var t = this._sharedMat.get(e);
  9838. 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)));
  9839. }
  9840. }, {
  9841. key: "toggle",
  9842. value: function toggle(e, t) {
  9843. var r = this._decal.get(e);
  9844. r == null || r.toggle(t);
  9845. }
  9846. }, {
  9847. key: "toggleDecalBySkinInfo",
  9848. value: function toggleDecalBySkinInfo(e, t) {
  9849. var _iterator2 = _createForOfIteratorHelper$2(this._decal.entries()),
  9850. _step2;
  9851. try {
  9852. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  9853. var _step2$value = _slicedToArray(_step2.value, 2),
  9854. r = _step2$value[0],
  9855. n = _step2$value[1];
  9856. n.skinInfo == e && n.toggle(t);
  9857. }
  9858. } catch (err) {
  9859. _iterator2.e(err);
  9860. } finally {
  9861. _iterator2.f();
  9862. }
  9863. }
  9864. }, {
  9865. key: "updateTexAsWords",
  9866. value: function updateTexAsWords(e, t) {
  9867. var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  9868. var _r$clearArea = r.clearArea,
  9869. n = _r$clearArea === void 0 ? !0 : _r$clearArea,
  9870. _r$w = r.w,
  9871. o = _r$w === void 0 ? 480 : _r$w,
  9872. _r$h = r.h,
  9873. a = _r$h === void 0 ? 480 : _r$h,
  9874. _r$y = r.y,
  9875. s = _r$y === void 0 ? a / 2 : _r$y,
  9876. _r$fontsize = r.fontsize,
  9877. l = _r$fontsize === void 0 ? 70 : _r$fontsize,
  9878. _r$slots = r.slots,
  9879. u = _r$slots === void 0 ? 1 : _r$slots,
  9880. _r$visibleSlots = r.visibleSlots,
  9881. c = _r$visibleSlots === void 0 ? 1 : _r$visibleSlots,
  9882. _r$font = r.font,
  9883. h = _r$font === void 0 ? "black-body" : _r$font,
  9884. _r$color = r.color,
  9885. f = _r$color === void 0 ? "white" : _r$color,
  9886. _r$fontweight = r.fontweight,
  9887. d = _r$fontweight === void 0 ? 100 : _r$fontweight;
  9888. var _r$x = r.x,
  9889. _ = _r$x === void 0 ? o / 2 : _r$x;
  9890. var g = this._mat.get(e);
  9891. if (g) {
  9892. _ == -1 && (_ = (g.getUOffset() + c / u) % 1 * o * u);
  9893. var v = g.getMat().diffuseTexture,
  9894. y = v.getContext();
  9895. 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();
  9896. }
  9897. }
  9898. }, {
  9899. key: "updateTexAsImg",
  9900. value: function () {
  9901. var _updateTexAsImg = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(e, t) {
  9902. var _this5 = this;
  9903. var r,
  9904. _r$clearArea2,
  9905. n,
  9906. _r$w2,
  9907. o,
  9908. _r$h2,
  9909. a,
  9910. _r$x2,
  9911. s,
  9912. _r$y2,
  9913. l,
  9914. _r$clearW,
  9915. u,
  9916. _r$clearH,
  9917. c,
  9918. _args4 = arguments;
  9919. return regenerator.wrap(function _callee4$(_context4) {
  9920. while (1) {
  9921. switch (_context4.prev = _context4.next) {
  9922. case 0:
  9923. r = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : {};
  9924. _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;
  9925. 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) {
  9926. return _this5._scenemanager.urlTransformer(t).then(function (d) {
  9927. return new Promise(function (_, g) {
  9928. var m = _this5._mat.get(e);
  9929. if (m) {
  9930. var y = m.getMat().diffuseTexture;
  9931. if (typeof t == "string") {
  9932. var b = new Image();
  9933. b.crossOrigin = "anonymous", b.src = d, b.onload = function () {
  9934. var T = y.getContext();
  9935. 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);
  9936. }, b.onerror = function () {
  9937. 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!")));
  9938. };
  9939. } 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!")));
  9940. } 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!")));
  9941. }).then(function (_) {
  9942. _ == !0 ? h(!0) : (logger.error("[Engine] updateTexAsImg Error. id: [".concat(e, "] !")), f(new XDecalError("[Engine] updateTexAsImg error! id: [".concat(e, "]"))));
  9943. }).catch(function (_) {
  9944. logger.error("[Engine] updateTexAsImg Error. id: [".concat(e, "]. ").concat(_));
  9945. });
  9946. });
  9947. }));
  9948. case 3:
  9949. case "end":
  9950. return _context4.stop();
  9951. }
  9952. }
  9953. }, _callee4);
  9954. }));
  9955. function updateTexAsImg(_x4, _x5) {
  9956. return _updateTexAsImg.apply(this, arguments);
  9957. }
  9958. return updateTexAsImg;
  9959. }()
  9960. }, {
  9961. key: "startAnime",
  9962. value: function startAnime(e, t) {
  9963. logger.info("[Engine] Decal Start Anime. [".concat(e, "]"));
  9964. var _t$speed = t.speed,
  9965. r = _t$speed === void 0 ? .001 : _t$speed,
  9966. n = t.callback,
  9967. o = this._mat.get(e);
  9968. 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!")));
  9969. }
  9970. }]);
  9971. return XDecalManager;
  9972. }();
  9973. var PoolObject = /*#__PURE__*/function () {
  9974. function PoolObject(e, t, r) {
  9975. var n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : !0;
  9976. _classCallCheck(this, PoolObject);
  9977. E(this, "data");
  9978. E(this, "nextFree");
  9979. E(this, "previousFree");
  9980. E(this, "free");
  9981. this.data = e, this.nextFree = t, this.previousFree = r, this.free = n;
  9982. }
  9983. _createClass(PoolObject, [{
  9984. key: "dispose",
  9985. value: function dispose() {
  9986. this.data && this.data instanceof Mesh && this.data.dispose(!0, !0), this.previousFree = null, this.nextFree = null, this.data = null;
  9987. }
  9988. }]);
  9989. return PoolObject;
  9990. }();
  9991. var Pool = /*#__PURE__*/function () {
  9992. function Pool(e, t, r, n) {
  9993. _classCallCheck(this, Pool);
  9994. this.lastFree = null;
  9995. this.nextFree = null;
  9996. this._pool = [], this.objCreator = e, this.objReseter = t;
  9997. for (var _len = arguments.length, o = new Array(_len > 4 ? _len - 4 : 0), _key = 4; _key < _len; _key++) {
  9998. o[_key - 4] = arguments[_key];
  9999. }
  10000. for (var a = 0; a < n; a++) {
  10001. this.addNewObject(this.newPoolObject.apply(this, o));
  10002. }
  10003. this.capacity = r;
  10004. }
  10005. _createClass(Pool, [{
  10006. key: "addNewObject",
  10007. value: function addNewObject(e) {
  10008. return this._pool.push(e), this.release(e), e;
  10009. }
  10010. }, {
  10011. key: "release",
  10012. value: function release(e) {
  10013. 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);
  10014. }
  10015. }, {
  10016. key: "getFree",
  10017. value: function getFree() {
  10018. var t = this.nextFree ? this.nextFree : this.addNewObject(this.newPoolObject.apply(this, arguments));
  10019. return t.free = !1, this.nextFree = t.nextFree, this.nextFree || (this.lastFree = null), t;
  10020. }
  10021. }, {
  10022. key: "newPoolObject",
  10023. value: function newPoolObject() {
  10024. var t = this.objCreator.apply(this, arguments);
  10025. return new PoolObject(t, this.nextFree, this.lastFree);
  10026. }
  10027. }, {
  10028. key: "releaseAll",
  10029. value: function releaseAll() {
  10030. var _this = this;
  10031. this._pool.forEach(function (e) {
  10032. return _this.release(e);
  10033. });
  10034. }
  10035. }, {
  10036. key: "clean",
  10037. value: function clean() {
  10038. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  10039. var r = this.nextFree;
  10040. if (!r) return;
  10041. var n = 0;
  10042. for (; r;) {
  10043. n += 1, r = r.nextFree;
  10044. }
  10045. var o = !1;
  10046. if (n > e && this._pool.length > this.capacity && (o = !0), o) for (r = this.nextFree; r;) {
  10047. r.free = !1, this.nextFree = r.nextFree;
  10048. var a = this._pool.indexOf(r);
  10049. this._pool.splice(a, 1), this.nextFree || (this.lastFree = null), r == null || r.dispose(), r = this.nextFree;
  10050. }
  10051. }
  10052. }]);
  10053. return Pool;
  10054. }();
  10055. var BillboardStatus = {
  10056. SHOW: 1,
  10057. HIDE: 0,
  10058. DISPOSE: -1
  10059. };
  10060. 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; } } }; }
  10061. 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); }
  10062. 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; }
  10063. var XAvatarManager = /*#__PURE__*/function () {
  10064. function XAvatarManager(e) {
  10065. var _this = this;
  10066. _classCallCheck(this, XAvatarManager);
  10067. this.characterMap = new Map();
  10068. this.curAnimList = [];
  10069. this.extraComps = new Map();
  10070. this._mainUser = null;
  10071. this._lodSettings = null;
  10072. this.maxBillBoardDist = 0;
  10073. this.maxAvatarNum = 0;
  10074. this.currentLODUsers = [];
  10075. this.bboxMeshPool = null;
  10076. this._distLevels = [];
  10077. this._maxLODUsers = [];
  10078. this._cullingDistance = 0;
  10079. this._maxDistRange = null;
  10080. this._delayTime = 100;
  10081. this._queueLength = -1;
  10082. this._queue = [];
  10083. this._processList = [];
  10084. this._process = null;
  10085. this._updateLoopObserver = null;
  10086. this._avatarInDistance = [];
  10087. this._renderedAvatar = [];
  10088. this._enableNickname = !0;
  10089. this._tickObserver = null;
  10090. this._tickInterval = null;
  10091. this._defaultAnims = null;
  10092. this._tickDispose = 0;
  10093. this._disposeTime = 100;
  10094. this.avatarLoader = avatarLoader;
  10095. this._scene = e.mainScene;
  10096. this._sceneManager = e;
  10097. this.initAvatarMap();
  10098. this._initSettings();
  10099. 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;
  10100. var t = 0;
  10101. this._tickObserver = this._scene.onAfterRenderObservable.add(function () {
  10102. t += 1, t == _this._tickInterval && (_this.tick(), t = 0);
  10103. });
  10104. }
  10105. _createClass(XAvatarManager, [{
  10106. key: "tick",
  10107. value: function tick() {
  10108. this.bboxMeshPool.clean(0);
  10109. }
  10110. }, {
  10111. key: "createBboxAsset",
  10112. value: function createBboxAsset(e, t, r, n) {
  10113. return BABYLON.MeshBuilder.CreateBox("avatarBbox", {
  10114. width: t,
  10115. height: r,
  10116. depth: n
  10117. }, e);
  10118. }
  10119. }, {
  10120. key: "resetBboxAsset",
  10121. value: function resetBboxAsset(e) {
  10122. var t = e.data;
  10123. return t.setEnabled(!1), t.isPickable = !1, e;
  10124. }
  10125. }, {
  10126. key: "_initSettings",
  10127. value: function _initSettings() {
  10128. this._defaultAnims = avatarSetting.defaultIdle, this._lodSettings = avatarSetting.lod, this._distLevels = avatarSetting.lod.map(function (e) {
  10129. return e.dist;
  10130. }), this._maxLODUsers = avatarSetting.lod.map(function (e) {
  10131. return e.quota;
  10132. }), this.currentLODUsers = new Array(this._distLevels.length).fill(0), this.maxAvatarNum = avatarSetting.maxAvatarNum, this.maxBillBoardDist = avatarSetting.maxBillBoardDist, this._cullingDistance = avatarSetting.cullingDistance;
  10133. }
  10134. }, {
  10135. key: "maxRenderNum",
  10136. value: function maxRenderNum() {
  10137. var e = 0;
  10138. return this._maxLODUsers.forEach(function (t) {
  10139. e += t;
  10140. }), e;
  10141. }
  10142. }, {
  10143. key: "curRenderNum",
  10144. value: function curRenderNum() {
  10145. var e = 0;
  10146. return this.currentLODUsers.forEach(function (t) {
  10147. e += t;
  10148. }), e;
  10149. }
  10150. }, {
  10151. key: "setLoDLevels",
  10152. value: function setLoDLevels(e) {
  10153. this._distLevels = e;
  10154. }
  10155. }, {
  10156. key: "cullingDistance",
  10157. get: function get() {
  10158. return this._cullingDistance;
  10159. },
  10160. set: function set(e) {
  10161. this._cullingDistance = e;
  10162. }
  10163. }, {
  10164. key: "getLoDLevels",
  10165. value: function getLoDLevels() {
  10166. return this._distLevels;
  10167. }
  10168. }, {
  10169. key: "setLodUserLimits",
  10170. value: function setLodUserLimits(e, t) {
  10171. this._maxLODUsers.length > e && (this._maxLODUsers[e] = t);
  10172. }
  10173. }, {
  10174. key: "setLodDist",
  10175. value: function setLodDist(e, t) {
  10176. this._distLevels[e] = t;
  10177. }
  10178. }, {
  10179. key: "setMaxDistRange",
  10180. value: function setMaxDistRange(e) {
  10181. this._maxDistRange = e, this._distLevels[this._distLevels.length - 1] = e;
  10182. }
  10183. }, {
  10184. key: "scene",
  10185. get: function get() {
  10186. return this._scene;
  10187. }
  10188. }, {
  10189. key: "setMainAvatar",
  10190. value: function setMainAvatar(e) {
  10191. var t;
  10192. this._mainUser = (t = this.characterMap.get(0)) == null ? void 0 : t.get(e);
  10193. }
  10194. }, {
  10195. key: "getMainAvatar",
  10196. value: function getMainAvatar() {
  10197. return this._mainUser;
  10198. }
  10199. }, {
  10200. key: "enableAllNickname",
  10201. value: function enableAllNickname(e) {
  10202. var _this2 = this;
  10203. return this.characterMap.forEach(function (t, r) {
  10204. r != 0 && t.forEach(function (n, o) {
  10205. _this2._updateBillboardStatus(n, e ? BillboardStatus.SHOW : BillboardStatus.HIDE);
  10206. });
  10207. }), this._enableNickname = e;
  10208. }
  10209. }, {
  10210. key: "getAvatarById",
  10211. value: function getAvatarById(e) {
  10212. var t;
  10213. return this.characterMap.forEach(function (r, n) {
  10214. r.get(e) && (t = r.get(e));
  10215. }), t;
  10216. }
  10217. }, {
  10218. key: "getAvatarNums",
  10219. value: function getAvatarNums() {
  10220. var e = 0;
  10221. return this.characterMap.forEach(function (t, r) {
  10222. e += t.size;
  10223. }), e;
  10224. }
  10225. }, {
  10226. key: "registerAvatar",
  10227. value: function registerAvatar(e) {
  10228. this.characterMap.get(e.priority).set(e.id, e);
  10229. }
  10230. }, {
  10231. key: "unregisterAvatar",
  10232. value: function unregisterAvatar(e) {
  10233. this.characterMap.get(e.priority).delete(e.id);
  10234. }
  10235. }, {
  10236. key: "initAvatarMap",
  10237. value: function initAvatarMap() {
  10238. 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());
  10239. }
  10240. }, {
  10241. key: "loadAvatar",
  10242. value: function loadAvatar(_ref) {
  10243. var _this3 = this;
  10244. var e = _ref.id,
  10245. t = _ref.avatarType,
  10246. r = _ref.priority,
  10247. n = _ref.avatarManager,
  10248. o = _ref.assets,
  10249. a = _ref.status;
  10250. return new Promise(function (s, l) {
  10251. if (_this3.getAvatarById(e)) return l(new DuplicateAvatarIDError("[Engine] cannot init avatar with the same id = ".concat(e)));
  10252. if (_this3.getAvatarNums() > _this3.maxAvatarNum) return l(new ExceedMaxAvatarNumError("[Engine] \u8D85\u51FA\u6700\u5927\u89D2\u8272\u9650\u5236 ".concat(_this3.maxAvatarNum)));
  10253. var u = new XAvatar({
  10254. id: e,
  10255. avatarType: t,
  10256. priority: r,
  10257. avatarManager: n,
  10258. assets: o,
  10259. status: a
  10260. });
  10261. if (_this3.registerAvatar(u), r == 0) _this3.setMainAvatar(u.id), _this3.addAvatarToScene(u, 0).then(function (c) {
  10262. return logger$1.debug("[Engine] avatar ".concat(u.id, " has been added to scene")), c ? (_this3._updateBillboardStatus(c, BillboardStatus.SHOW), setTimeout(function () {
  10263. _this3.launchProcessLoadingLoop();
  10264. }, _this3._delayTime), s(c)) : (u.removeAvatarFromScene(), l(new AvatarAssetLoadingError()));
  10265. }).catch(function (c) {
  10266. return u.removeAvatarFromScene(), l(new AvatarAssetLoadingError(c));
  10267. });else return s(u);
  10268. });
  10269. }
  10270. }, {
  10271. key: "deleteAvatar",
  10272. value: function deleteAvatar(e) {
  10273. return e.isRender ? (e.removeAvatarFromScene(), this.currentLODUsers[e.distLevel]--) : e.bbComponent.disposeBillBoard(e), this._processList = this._processList.filter(function (t) {
  10274. return t.id !== e.id;
  10275. }), this.unregisterAvatar(e), e.rootNode && (e.rootNode.dispose(), e.rootNode = void 0), e.bbComponent.bbox && e.bbComponent.bbox.dispose(), e.removeObserver(), e;
  10276. }
  10277. }, {
  10278. key: "_checkLODLevel",
  10279. value: function _checkLODLevel(e) {
  10280. if (e < this._distLevels[0]) return 0;
  10281. for (var t = 1; t < this._distLevels.length; ++t) {
  10282. if (e >= this._distLevels[t - 1] && e < this._distLevels[t]) return t;
  10283. }
  10284. return this._distLevels.length - 1;
  10285. }
  10286. }, {
  10287. key: "sceneManager",
  10288. get: function get() {
  10289. return this._sceneManager;
  10290. }
  10291. }, {
  10292. key: "launchProcessLoadingLoop",
  10293. value: function launchProcessLoadingLoop() {
  10294. this._updateAvatarStatus();
  10295. }
  10296. }, {
  10297. key: "stopProcessLoadingLoop",
  10298. value: function stopProcessLoadingLoop() {
  10299. var e;
  10300. this._updateLoopObserver && ((e = this._scene) == null || e.onBeforeRenderObservable.remove(this._updateLoopObserver));
  10301. }
  10302. }, {
  10303. key: "_distToMain",
  10304. value: function _distToMain(e) {
  10305. var n;
  10306. var t = (n = this._mainUser) == null ? void 0 : n.position,
  10307. r = e.position;
  10308. if (r && t) {
  10309. var o = this.sceneManager.cameraComponent.MainCamera.getFrontPosition(1).subtract(this.sceneManager.cameraComponent.MainCamera.position).normalize(),
  10310. a = e.rootNode.position.subtract(this.sceneManager.cameraComponent.MainCamera.position).normalize();
  10311. var s = 1;
  10312. if (o && a) {
  10313. var l = a.multiply(o);
  10314. s = Math.acos(l.x + l.y + l.z) < this.sceneManager.cameraComponent.MainCamera.fov / 2 ? 1 : 1e11;
  10315. }
  10316. return calcDistance3D(t, r) * s;
  10317. } else return logger$1.warn("user position or camera position is not correct!"), 1e11;
  10318. }
  10319. }, {
  10320. key: "_distToCamera",
  10321. value: function _distToCamera(e) {
  10322. var n;
  10323. var t = (n = this._sceneManager) == null ? void 0 : n.cameraComponent.getCameraPose().position,
  10324. r = e.position;
  10325. return r && t ? calcDistance3D(t, r) : (logger$1.warn("user position or camera position is not correct!"), 1e11);
  10326. }
  10327. }, {
  10328. key: "showAll",
  10329. value: function showAll(e) {
  10330. this.characterMap.forEach(function (t, r) {
  10331. e && r == 0 && t.forEach(function (n, o) {
  10332. n.show();
  10333. }), r != 0 && t.forEach(function (n, o) {
  10334. n.show();
  10335. });
  10336. });
  10337. }
  10338. }, {
  10339. key: "hideAll",
  10340. value: function hideAll(e) {
  10341. this.characterMap.forEach(function (t, r) {
  10342. e && r == 0 && t.forEach(function (n, o) {
  10343. n.hide();
  10344. }), r != 0 && t.forEach(function (n, o) {
  10345. n.hide();
  10346. });
  10347. });
  10348. }
  10349. }, {
  10350. key: "_assemblyAvatar",
  10351. value: function _assemblyAvatar(e, t) {
  10352. var _this4 = this;
  10353. var n, o;
  10354. var r = e.get(avatarSetting.body);
  10355. if (r && !t.attachBody(r)) {
  10356. t.isInLoadingList = !1, e.clear();
  10357. return;
  10358. }
  10359. var _iterator = _createForOfIteratorHelper$1(e),
  10360. _step;
  10361. try {
  10362. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  10363. var a = _step.value;
  10364. if (a[0] != avatarSetting.body && a[0] != avatarSetting.animations && !t.attachDecoration(a[1])) {
  10365. t.isInLoadingList = !1, t.removeAvatarFromScene(), e.clear();
  10366. return;
  10367. }
  10368. }
  10369. } catch (err) {
  10370. _iterator.e(err);
  10371. } finally {
  10372. _iterator.f();
  10373. }
  10374. t.isRender = !0, (n = t.controller) == null || n.playAnimation(t.controller.onPlay, t.controller.loop), (o = t.controller) == null || o.onPlayObservable.addOnce(function () {
  10375. var a, s;
  10376. if (!_this4.getAvatarById(t.id)) {
  10377. t.isInLoadingList = !1, t.removeAvatarFromScene(), _this4.currentLODUsers[t.distLevel]--;
  10378. return;
  10379. }
  10380. if (_this4.getAvatarById(t.id).rootNode.getChildMeshes().length < e.size) {
  10381. 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]--;
  10382. return;
  10383. }
  10384. 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));
  10385. });
  10386. }
  10387. }, {
  10388. key: "_disposeUnusedAssets",
  10389. value: function _disposeUnusedAssets() {
  10390. this._tickDispose++, this._tickDispose > this._disposeTime && (avatarLoader.disposeContainer(), this._tickDispose = 0);
  10391. }
  10392. }, {
  10393. key: "_addResourcesToList",
  10394. value: function _addResourcesToList(e, t) {
  10395. var _this5 = this;
  10396. return e.clothesList.forEach(function (r) {
  10397. r.lod = t, _this5._queue.push(r);
  10398. }), this._queue.push({
  10399. type: avatarSetting.animations,
  10400. id: this._defaultAnims
  10401. }), this._queue.push({
  10402. type: avatarSetting.body,
  10403. id: e.avatarType,
  10404. lod: t
  10405. }), !0;
  10406. }
  10407. }, {
  10408. key: "_updateBillboardStatus",
  10409. value: function _updateBillboardStatus(e, t) {
  10410. e.bbComponent.updateBillboardStatus(e, t);
  10411. }
  10412. }, {
  10413. key: "_processLayer",
  10414. value: function _processLayer(e) {
  10415. var _this6 = this;
  10416. var t = this.characterMap.get(e),
  10417. r = [];
  10418. for (t == null || t.forEach(function (n) {
  10419. n.distToCam = _this6._distToCamera(n);
  10420. var o = n.distToCam < _this6._cullingDistance;
  10421. if (n.isRender && (!n.isHide && o ? n._hide_culling() : n._show_culling()), n.priority != 0) {
  10422. n.distance = _this6._distToMain(n);
  10423. var _a = BillboardStatus.SHOW;
  10424. 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));
  10425. }
  10426. }), r.sort(function (n, o) {
  10427. return o.distance - n.distance;
  10428. }); r.length > 0 && this.curRenderNum() < this.maxRenderNum();) {
  10429. var n = r.pop();
  10430. var o = this._checkLODLevel(n.distance),
  10431. a = !1;
  10432. for (var s = 0; s < this._maxLODUsers.length; ++s) {
  10433. if (this.currentLODUsers[s] < this._maxLODUsers[s]) {
  10434. o = s, a = !0;
  10435. break;
  10436. }
  10437. }
  10438. if (!a || n.distance > this._maxDistRange) {
  10439. if (n.isRender) {
  10440. n._removeAvatarFromScene();
  10441. var _s = BillboardStatus.HIDE;
  10442. n.distance < this._maxDistRange && (_s = BillboardStatus.SHOW), this._updateBillboardStatus(n, _s);
  10443. }
  10444. break;
  10445. }
  10446. 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]++;
  10447. }
  10448. return this.curRenderNum() >= this.maxRenderNum() && r.forEach(function (n) {
  10449. if (n.isRender) {
  10450. n._removeAvatarFromScene();
  10451. var _o = BillboardStatus.HIDE;
  10452. n.distance < _this6._maxDistRange && (_o = BillboardStatus.SHOW), _this6._updateBillboardStatus(n, _o);
  10453. }
  10454. }), this.curRenderNum() < this.maxRenderNum();
  10455. }
  10456. }, {
  10457. key: "_updateAvatar",
  10458. value: function _updateAvatar() {
  10459. var _this7 = this;
  10460. this.currentLODUsers = [0, 0, 0];
  10461. var e = [5, 4, 3, 2, 1, 0];
  10462. for (; e.length > 0;) {
  10463. var t = e.pop();
  10464. if (!this._processLayer(t)) {
  10465. e.forEach(function (n) {
  10466. var o;
  10467. (o = _this7.characterMap.get(n)) == null || o.forEach(function (a) {
  10468. a.distance = _this7._distToMain(a);
  10469. var s = BillboardStatus.HIDE;
  10470. a.distToCam < _this7._maxDistRange && (s = BillboardStatus.SHOW, a.isRender && a._removeAvatarFromScene()), _this7._updateBillboardStatus(a, s);
  10471. });
  10472. });
  10473. break;
  10474. }
  10475. }
  10476. }
  10477. }, {
  10478. key: "_updateAvatarStatus",
  10479. value: function _updateAvatarStatus() {
  10480. var _this8 = this;
  10481. var e = new Map();
  10482. this._updateLoopObserver = this.scene.onBeforeRenderObservable.add(function () {
  10483. var t;
  10484. if (_this8._disposeUnusedAssets(), !(_this8.getAvatarNums() <= 0)) {
  10485. if (!_this8._process && _this8._processList.length == 0 && _this8._updateAvatar(), !_this8._process && _this8._processList.length > 0) {
  10486. var r = _this8._processList.shift();
  10487. 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;
  10488. }
  10489. if (e.size === _this8._queueLength && _this8._process) {
  10490. _this8._process.pendingLod && (_this8._process.pendingLod = !1, _this8._process._removeAvatarFromScene());
  10491. var _r = Date.now();
  10492. _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();
  10493. }
  10494. _this8._loadResByList(e);
  10495. }
  10496. });
  10497. }
  10498. }, {
  10499. key: "_loadResByList",
  10500. value: function _loadResByList(e) {
  10501. var _this9 = this;
  10502. var t = 0;
  10503. var r = 5;
  10504. if (!this._process) {
  10505. e.clear();
  10506. return;
  10507. }
  10508. var _loop = function _loop() {
  10509. var n = Date.now(),
  10510. o = _this9._queue.pop();
  10511. setTimeout(function () {
  10512. o ? o.type === avatarSetting.body ? _this9.loadBody(o.type, o.id, o.lod).then(function (a) {
  10513. a && e.set(avatarSetting.body, a), t += Date.now() - n;
  10514. }).catch(function (a) {
  10515. _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);
  10516. }) : o.type === avatarSetting.animations ? _this9.loadAnimation(_this9._process.avatarType, o.id).then(function (a) {
  10517. a && e.set(avatarSetting.animations, a), t += Date.now() - n;
  10518. }).catch(function (a) {
  10519. _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);
  10520. }) : _this9.loadDecoration(o.type, o.id, o.lod).then(function (a) {
  10521. a && e.set(a.type, a), t += Date.now() - n;
  10522. }).catch(function (a) {
  10523. _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);
  10524. }) : t += 100;
  10525. }, 0);
  10526. };
  10527. for (; t < r && this._queue.length > 0;) {
  10528. _loop();
  10529. }
  10530. }
  10531. }, {
  10532. key: "_validateContainer",
  10533. value: function _validateContainer(e) {
  10534. 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;
  10535. }
  10536. }, {
  10537. key: "_getAssetContainer",
  10538. value: function _getAssetContainer(e, t) {
  10539. var _this10 = this;
  10540. return new Promise(function (r, n) {
  10541. var o = _this10._getSourceKey(e, t || 0),
  10542. a = avatarLoader.containers.get(o);
  10543. if (a) return r(a);
  10544. avatarLoader.load(_this10.sceneManager, e, t).then(function (s) {
  10545. 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, ".")));
  10546. }).catch(function (s) {
  10547. return n(new ContainerLoadingFailedError("[Engine] ".concat(s, " :: cannot load body type ").concat(e, ".")));
  10548. });
  10549. });
  10550. }
  10551. }, {
  10552. key: "_clipContainerRes",
  10553. value: function _clipContainerRes(e) {
  10554. e.transformNodes.forEach(function (t) {
  10555. t.dispose();
  10556. }), e.transformNodes = [], e.skeletons.forEach(function (t) {
  10557. t.dispose();
  10558. }), e.skeletons = [];
  10559. }
  10560. }, {
  10561. key: "loadBody",
  10562. value: function loadBody(e, t, r) {
  10563. var _this11 = this;
  10564. return new Promise(function (n, o) {
  10565. return avatarLoader.load(_this11.sceneManager, t, r).then(function (a) {
  10566. if (a) {
  10567. var s = a.instantiateModelsToScene();
  10568. a.xReferenceCount++;
  10569. var l = {
  10570. isRender: !1,
  10571. uId: Math.random(),
  10572. root: s.rootNodes[0],
  10573. skeletonType: e,
  10574. name: t,
  10575. animations: s.animationGroups,
  10576. skeleton: s.skeletons[0],
  10577. lod: r
  10578. };
  10579. return s.rootNodes[0]._parentContainer = a, s.rootNodes[0].setEnabled(!1), n(l);
  10580. } else return o(new ContainerLoadingFailedError("[Engine] container failed instanciates failed"));
  10581. }).catch(function () {
  10582. return o(new ContainerLoadingFailedError("[Engine] body type ".concat(e, " instanciates failed")));
  10583. });
  10584. });
  10585. }
  10586. }, {
  10587. key: "updateAnimationLists",
  10588. value: function updateAnimationLists(e, t) {
  10589. return new Promise(function (r, n) {
  10590. return avatarLoader.avaliableAnimation.set(t, e), r();
  10591. });
  10592. }
  10593. }, {
  10594. key: "loadAnimation",
  10595. value: function loadAnimation(e, t) {
  10596. var _this12 = this;
  10597. return new Promise(function (r, n) {
  10598. return avatarLoader.loadAnimRes(_this12.sceneManager, t, e).then(function (o) {
  10599. if (o) {
  10600. var a;
  10601. var s = _this12.avatarLoader.animations;
  10602. return o.animationGroups.forEach(function (l) {
  10603. l.stop(), l.name === t && (a = l, a.pContainer = o), s.set(getAnimationKey(l.name, e), l);
  10604. }), _this12._clipContainerRes(o), o.xReferenceCount++, r(a);
  10605. } else return n(new ContainerLoadingFailedError("[Engine] container failed instanciates failed"));
  10606. });
  10607. });
  10608. }
  10609. }, {
  10610. key: "loadDecoration",
  10611. value: function loadDecoration(e, t, r) {
  10612. var _this13 = this;
  10613. return new Promise(function (n, o) {
  10614. return avatarLoader.load(_this13.sceneManager, t, r).then(function (a) {
  10615. if (a) {
  10616. _this13._clipContainerRes(a);
  10617. var s = a.meshes[1].clone(a.meshes[1].name, null);
  10618. if (!s) {
  10619. logger$1.warn("[Engine] decoration does not exist!"), n(null);
  10620. return;
  10621. }
  10622. var l = {
  10623. isRender: !1,
  10624. uId: Math.random(),
  10625. root: s,
  10626. type: e,
  10627. name: t,
  10628. isSelected: !1,
  10629. lod: r
  10630. };
  10631. if (a.xReferenceCount++, s._parentContainer = a, a.meshes.length > 1) for (var u = 2; u < a.meshes.length; u++) {
  10632. s.addChild(a.meshes[u].clone(a.meshes[u].name, null));
  10633. }
  10634. s.setEnabled(!1), l.isSelected = !0, n(l);
  10635. } else return o(new ContainerLoadingFailedError("[Engine] container failed, instanciates failed."));
  10636. }).catch(function () {
  10637. return o(new ContainerLoadingFailedError("[Engine] body type ".concat(e, " instanciates failed.")));
  10638. });
  10639. });
  10640. }
  10641. }, {
  10642. key: "_getSourceKey",
  10643. value: function _getSourceKey(e, t) {
  10644. return t && avatarSetting.lod[t] ? e + avatarSetting.lod[t].fileName.split(".")[0] : e;
  10645. }
  10646. }, {
  10647. key: "addAvatarToScene",
  10648. value: function addAvatarToScene(e, t) {
  10649. var _this14 = this;
  10650. var r = Date.now();
  10651. return new Promise(function (n, o) {
  10652. _this14.loadBody(e.avatarType, e.avatarType, t).then(function (a) {
  10653. var s;
  10654. if (!a) return e.isInLoadingList = !1, o(new ContainerLoadingFailedError("[Engine] avatar ".concat(e.id, " instanciates failed")));
  10655. if (e.attachBody(a), a.animations.length > 0) return a.animations.forEach(function (l) {
  10656. l.stop();
  10657. }), 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);
  10658. _this14.loadAnimation(e.avatarType, _this14._defaultAnims).then(function (l) {
  10659. if (!l) return e.removeAvatarFromScene(), e.isInLoadingList = !1, o(new AvatarAnimationError());
  10660. var u = [];
  10661. e.clothesList.length > 0 && e.clothesList.forEach(function (c) {
  10662. u.push(_this14.loadDecoration(c.type, c.id, t));
  10663. }), Promise.all(u).then(function (c) {
  10664. var d, _, g, m;
  10665. c.forEach(function (v) {
  10666. if (v && !v.isRender) e.attachDecoration(v);else return e.isInLoadingList = !1, e.removeAvatarFromScene(), o(new AvatarAssetLoadingError());
  10667. }), e.isRender = !0, (d = e.controller) == null || d.playAnimation(e.controller.onPlay, e.controller.loop), e.setAvatarVisible(!0);
  10668. var h = avatarLoader.mshPath.get("meshes/ygb.glb"),
  10669. f = avatarLoader.matPath.get(avatarResources.ygb.mesh);
  10670. h && f ? _this14.loadExtra(f, h).then(function (v) {
  10671. var y;
  10672. e.isRender = !0, e.isInLoadingList = !1, e.distLevel = t, (y = _this14._sceneManager) == null || y.engineRunTimeStats.timeArray_addAvatarToScene.add(Date.now() - r), n(e);
  10673. }) : (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);
  10674. }).catch(function () {
  10675. return o(new AvatarAssetLoadingError("[Engine] avatar ".concat(e.id, " instanciates failed.")));
  10676. });
  10677. }).catch(function () {
  10678. return o(new AvatarAssetLoadingError("[Engine] avatar ".concat(e.id, " instanciates failed.")));
  10679. });
  10680. }).catch(function () {
  10681. return o(new AvatarAssetLoadingError("[Engine] avatar ".concat(e.id, " instanciates failed.")));
  10682. });
  10683. });
  10684. }
  10685. }, {
  10686. key: "loadExtra",
  10687. value: function loadExtra(e, t) {
  10688. var _this15 = this;
  10689. var r = avatarResources.ygb.name;
  10690. return new Promise(function (n, o) {
  10691. var a;
  10692. (a = _this15.sceneManager) == null || a.urlTransformer(e).then(function (s) {
  10693. BABYLON.SceneLoader.LoadAssetContainerAsync("", s, _this15.scene, null, avatarSetting.fileType).then(function (l) {
  10694. var c;
  10695. _this15.extraComps.set(r, l.meshes[0]);
  10696. var u = new NodeMaterial("material_".concat(r), _this15._scene, {
  10697. emitComments: !1
  10698. });
  10699. (c = _this15.sceneManager) == null || c.urlTransformer(t).then(function (h) {
  10700. u.loadAsync(h).then(function () {
  10701. l.meshes[2].material.dispose(!0, !0), u.build(!1), l.meshes[2].material = u, n(l.meshes[2]);
  10702. });
  10703. });
  10704. });
  10705. });
  10706. });
  10707. }
  10708. }, {
  10709. key: "getAvatarList",
  10710. value: function getAvatarList() {
  10711. var e = [];
  10712. return this.characterMap.forEach(function (t, r) {
  10713. t.forEach(function (n, o) {
  10714. e.push(n);
  10715. });
  10716. }), e;
  10717. }
  10718. }, {
  10719. key: "_debug_avatar",
  10720. value: function _debug_avatar() {
  10721. var t, r;
  10722. 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);
  10723. var e = 0;
  10724. this.getAvatarList().forEach(function (n) {
  10725. 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++);
  10726. }), console.error("========= avatar num", e), console.error("loop:", this._updateLoopObserver ? "on" : "false", "=> process", this._process, "===> comp", this._processList), console.error("===>maxLODUsers", this._maxLODUsers);
  10727. }
  10728. }]);
  10729. return XAvatarManager;
  10730. }();
  10731. var texRootDir = "https://app-asset-1258211750.file.myqcloud.com/1/textures/";
  10732. var XBillboardManager = /*#__PURE__*/function () {
  10733. function XBillboardManager(e) {
  10734. var _this = this;
  10735. _classCallCheck(this, XBillboardManager);
  10736. E(this, "billboardMap", new Map());
  10737. E(this, "sceneManager");
  10738. E(this, "billboardPool");
  10739. E(this, "userBackGroundBlob", new Array());
  10740. E(this, "npcBackGroundBlob", new Array());
  10741. E(this, "tickObserver");
  10742. E(this, "tickInterval");
  10743. E(this, "_updateLoopObserver");
  10744. this.sceneManager = e, this.billboardPool = new Pool(this.createBillboardAsset, this.resetBillboardAsset, 0, 60, this.sceneManager.Scene, !1), this.tickInterval = 250;
  10745. var t = 0;
  10746. this.tickObserver = this.sceneManager.Scene.onAfterRenderObservable.add(function () {
  10747. t += 1, t == _this.tickInterval && (_this.tick(), t = 0);
  10748. }), this.launchBillboardStatusLoop();
  10749. }
  10750. _createClass(XBillboardManager, [{
  10751. key: "tick",
  10752. value: function tick() {
  10753. this.billboardPool.clean(0, this.sceneManager.Scene, !1);
  10754. }
  10755. }, {
  10756. key: "createBillboardAsset",
  10757. value: function createBillboardAsset(e) {
  10758. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !1;
  10759. var r = BABYLON.MeshBuilder.CreatePlane("billboard-", {
  10760. height: .001,
  10761. width: .001,
  10762. sideOrientation: BABYLON.Mesh.DOUBLESIDE
  10763. }, e);
  10764. r.isPickable = !0, r.setEnabled(!1);
  10765. var n = new BABYLON.DynamicTexture("billboard-tex-", {
  10766. width: .001 + 1,
  10767. height: .001 + 1
  10768. }, e, t, BABYLON.Texture.BILINEAR_SAMPLINGMODE);
  10769. n.hasAlpha = !0;
  10770. var o = new BABYLON.StandardMaterial("billboard-mat-", e);
  10771. 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;
  10772. }
  10773. }, {
  10774. key: "resetBillboardAsset",
  10775. value: function resetBillboardAsset(e) {
  10776. var t = e.data;
  10777. return t.setEnabled(!1), t.isPickable = !1, e;
  10778. }
  10779. }, {
  10780. key: "loadBackGroundTexToIDB",
  10781. value: function () {
  10782. var _loadBackGroundTexToIDB = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
  10783. var _this2 = this;
  10784. return regenerator.wrap(function _callee$(_context) {
  10785. while (1) {
  10786. switch (_context.prev = _context.next) {
  10787. case 0:
  10788. XBillboardManager.userBubbleUrls.forEach(function (r) {
  10789. _this2.sceneManager.urlTransformer(r).then(function (n) {
  10790. _this2.userBackGroundBlob.push(n);
  10791. });
  10792. }), XBillboardManager.npcBubbleUrls.forEach(function (r) {
  10793. _this2.sceneManager.urlTransformer(r).then(function (n) {
  10794. _this2.npcBackGroundBlob.push(n);
  10795. });
  10796. });
  10797. case 1:
  10798. case "end":
  10799. return _context.stop();
  10800. }
  10801. }
  10802. }, _callee);
  10803. }));
  10804. function loadBackGroundTexToIDB() {
  10805. return _loadBackGroundTexToIDB.apply(this, arguments);
  10806. }
  10807. return loadBackGroundTexToIDB;
  10808. }()
  10809. }, {
  10810. key: "addBillboardToMap",
  10811. value: function addBillboardToMap(e, t) {
  10812. this.billboardMap.set(e, t);
  10813. }
  10814. }, {
  10815. key: "addBillboard",
  10816. value: function addBillboard(e, t, r) {
  10817. var n = this.getBillboard(e);
  10818. return n || (n = new XBillboard(this, t, r), this.addBillboardToMap(e, n)), n;
  10819. }
  10820. }, {
  10821. key: "generateStaticBillboard",
  10822. value: function generateStaticBillboard(e, _ref) {
  10823. var _ref$id = _ref.id,
  10824. t = _ref$id === void 0 ? "billboard" : _ref$id,
  10825. r = _ref.isUser,
  10826. n = _ref.background,
  10827. _ref$font = _ref.font,
  10828. o = _ref$font === void 0 ? "Arial" : _ref$font,
  10829. _ref$fontsize = _ref.fontsize,
  10830. a = _ref$fontsize === void 0 ? 40 : _ref$fontsize,
  10831. _ref$fontcolor = _ref.fontcolor,
  10832. s = _ref$fontcolor === void 0 ? "#ffffff" : _ref$fontcolor,
  10833. _ref$fontstyle = _ref.fontstyle,
  10834. l = _ref$fontstyle === void 0 ? "600" : _ref$fontstyle,
  10835. _ref$linesize = _ref.linesize,
  10836. u = _ref$linesize === void 0 ? 16 : _ref$linesize,
  10837. c = _ref.linelimit,
  10838. _ref$scale = _ref.scale,
  10839. h = _ref$scale === void 0 ? 1 : _ref$scale,
  10840. _ref$width = _ref.width,
  10841. f = _ref$width === void 0 ? .01 : _ref$width,
  10842. _ref$height = _ref.height,
  10843. d = _ref$height === void 0 ? .01 : _ref$height,
  10844. _ref$position = _ref.position,
  10845. _ = _ref$position === void 0 ? {
  10846. x: 0,
  10847. y: 0,
  10848. z: 0
  10849. } : _ref$position;
  10850. var g = this.addBillboard(t, !1, !0);
  10851. g.getMesh() == null && g.init(t, f, d);
  10852. var m;
  10853. r != null && (m = r ? XBillboardManager.userBubbleUrls : XBillboardManager.npcBubbleUrls), g && g.getMesh() && (g.DEFAULT_CONFIGS = {
  10854. id: t,
  10855. isUser: r,
  10856. background: n,
  10857. font: o,
  10858. fontsize: a,
  10859. fontcolor: s,
  10860. fontstyle: l,
  10861. linesize: u,
  10862. linelimit: c,
  10863. scale: h,
  10864. width: f,
  10865. height: d,
  10866. position: _
  10867. }, g.drawBillboard({
  10868. imageList: n || m
  10869. }, {
  10870. texts: e,
  10871. font: o,
  10872. fontsize: a,
  10873. fontcolor: s,
  10874. fontstyle: l,
  10875. linesize: u,
  10876. linelimit: c
  10877. }, {
  10878. position: _,
  10879. scale: h
  10880. }), t && g.setId(t), g.setStatus(BillboardStatus.SHOW));
  10881. }
  10882. }, {
  10883. key: "getBillboard",
  10884. value: function getBillboard(e) {
  10885. return this.billboardMap.get(e);
  10886. }
  10887. }, {
  10888. key: "toggle",
  10889. value: function toggle(e, t) {
  10890. var r;
  10891. (r = this.getBillboard(e)) == null || r.setStatus(t ? BillboardStatus.SHOW : BillboardStatus.HIDE);
  10892. }
  10893. }, {
  10894. key: "removeBillboard",
  10895. value: function removeBillboard(e) {
  10896. var t = this.getBillboard(e);
  10897. t && (t.setStatus(BillboardStatus.DISPOSE), this.billboardMap.delete(e));
  10898. }
  10899. }, {
  10900. key: "launchBillboardStatusLoop",
  10901. value: function launchBillboardStatusLoop() {
  10902. var _this3 = this;
  10903. this._updateLoopObserver = this.sceneManager.Scene.onBeforeRenderObservable.add(function () {
  10904. _this3.billboardMap.size <= 0 || _this3.billboardMap.forEach(function (e) {
  10905. e.stageChanged && (e.status == BillboardStatus.SHOW ? e.show() : e.status == BillboardStatus.HIDE ? e.hide() : (e.hide(), e.dispose()), e.stageChanged = !1);
  10906. });
  10907. });
  10908. }
  10909. }]);
  10910. return XBillboardManager;
  10911. }();
  10912. 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"]);
  10913. var XLightManager = /*#__PURE__*/function () {
  10914. function XLightManager(e) {
  10915. _classCallCheck(this, XLightManager);
  10916. E(this, "_scene");
  10917. E(this, "_envTexture");
  10918. E(this, "_shadowLight");
  10919. E(this, "_shadowGenerator");
  10920. E(this, "_avatarShadowMeshMap");
  10921. E(this, "_cullingShadowObservers");
  10922. E(this, "sceneManager");
  10923. this.sceneManager = e, this._scene = this.sceneManager.Scene, this._envTexture = null, this.shadowLean = .1;
  10924. var t = new BABYLON.Vector3(this.shadowLean, -1, 0),
  10925. r = 1024;
  10926. 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();
  10927. }
  10928. _createClass(XLightManager, [{
  10929. key: "shadowLean",
  10930. set: function set(e) {
  10931. e = Math.min(e, 1), e = Math.max(e, -1), this._shadowLight && (this._shadowLight.direction = new BABYLON.Vector3(e, -1, 0));
  10932. }
  10933. }, {
  10934. key: "setIBL",
  10935. value: function setIBL(e) {
  10936. var _this = this;
  10937. return new Promise(function (t, r) {
  10938. _this.sceneManager.urlTransformer(e).then(function (n) {
  10939. var o;
  10940. if (n == ((o = _this._envTexture) == null ? void 0 : o.url)) return t("env set success");
  10941. _this._envTexture != null && _this.disposeIBL(), _this._envTexture = BABYLON.CubeTexture.CreateFromPrefilteredData(n, _this._scene, ".env"), _this._scene.environmentTexture = _this._envTexture, _this._envTexture.onLoadObservable.addOnce(function () {
  10942. t("env set success"), logger$1.info("env set success");
  10943. });
  10944. }).catch(function () {
  10945. r("env set fail");
  10946. });
  10947. });
  10948. }
  10949. }, {
  10950. key: "disposeIBL",
  10951. value: function disposeIBL() {
  10952. 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"));
  10953. }
  10954. }, {
  10955. key: "removeShadow",
  10956. value: function removeShadow(e) {
  10957. var t;
  10958. if (this._avatarShadowMeshMap.has(e)) {
  10959. this._avatarShadowMeshMap.delete(e), this._cullingShadowObservers.get(e) && (this._scene.onBeforeRenderObservable.remove(this._cullingShadowObservers.get(e)), this._cullingShadowObservers.delete(e));
  10960. var r = e.rootNode;
  10961. r && ((t = this._shadowGenerator) == null || t.removeShadowCaster(r));
  10962. } else return;
  10963. }
  10964. }, {
  10965. key: "setShadow",
  10966. value: function setShadow(e) {
  10967. if (this._avatarShadowMeshMap.has(e)) return;
  10968. e.rootNode && this._avatarShadowMeshMap.set(e, e.rootNode.getChildMeshes());
  10969. var t = 20,
  10970. r = 10,
  10971. n = this.cullingShadow(t, r, e);
  10972. this._cullingShadowObservers.set(e, n);
  10973. }
  10974. }, {
  10975. key: "cullingShadow",
  10976. value: function cullingShadow(e, t, r) {
  10977. var _this2 = this;
  10978. var n = 0;
  10979. var o = function o() {
  10980. var s, l;
  10981. if (n == t) {
  10982. var u = _this2._avatarShadowMeshMap.get(r),
  10983. c = (s = r.rootNode) == null ? void 0 : s.getChildMeshes(),
  10984. h = _this2._scene.activeCamera;
  10985. u == null || u.forEach(function (f) {
  10986. var d;
  10987. (d = _this2._shadowGenerator) == null || d.removeShadowCaster(f, !1);
  10988. }), c == null || c.forEach(function (f) {
  10989. var d;
  10990. (d = _this2._shadowGenerator) == null || d.addShadowCaster(f, !1);
  10991. }), h && r.rootNode && ((l = r.rootNode.position) == null ? void 0 : l.subtract(h.position).length()) > e && (c == null || c.forEach(function (f) {
  10992. var d;
  10993. (d = _this2._shadowGenerator) == null || d.removeShadowCaster(f, !1);
  10994. })), c && _this2._avatarShadowMeshMap.set(r, c), n = 0;
  10995. } else n += 1;
  10996. };
  10997. return this._scene.onBeforeRenderObservable.add(o);
  10998. }
  10999. }, {
  11000. key: "attachLightToCamera",
  11001. value: function attachLightToCamera(e) {
  11002. var _this3 = this;
  11003. var t = e,
  11004. r = 15,
  11005. n = function n() {
  11006. var o = _this3._scene.activeCamera;
  11007. if (o) {
  11008. var a = t.direction,
  11009. s = new BABYLON.Vector3(r * a.x, r * a.y, r * a.z),
  11010. l = o.position;
  11011. t.position = l.subtract(s);
  11012. }
  11013. };
  11014. return t && this._scene.registerBeforeRender(n), n;
  11015. }
  11016. }]);
  11017. return XLightManager;
  11018. }();
  11019. var RunTimeArray = /*#__PURE__*/function () {
  11020. function RunTimeArray() {
  11021. _classCallCheck(this, RunTimeArray);
  11022. E(this, "circularData");
  11023. this.circularData = [];
  11024. }
  11025. _createClass(RunTimeArray, [{
  11026. key: "add",
  11027. value: function add(e) {
  11028. this.circularData.length > 1e3 && this.circularData.shift(), this.circularData.push(e);
  11029. }
  11030. }, {
  11031. key: "getAvg",
  11032. value: function getAvg() {
  11033. var e = 0;
  11034. for (var t = 0; t < this.circularData.length; t++) {
  11035. e += this.circularData[t];
  11036. }
  11037. return {
  11038. sum: e,
  11039. avg: e / this.circularData.length || 0
  11040. };
  11041. }
  11042. }, {
  11043. key: "getMax",
  11044. value: function getMax() {
  11045. var e = 0;
  11046. for (var t = 0; t < this.circularData.length; t++) {
  11047. e < this.circularData[t] && (e = this.circularData[t]);
  11048. }
  11049. return e || 0;
  11050. }
  11051. }, {
  11052. key: "clear",
  11053. value: function clear() {
  11054. this.circularData = [];
  11055. }
  11056. }, {
  11057. key: "getStat",
  11058. value: function getStat() {
  11059. var e = this.getAvg(),
  11060. t = {
  11061. sum: e.sum,
  11062. avg: e.avg,
  11063. max: this.getMax()
  11064. };
  11065. return this.clear(), t;
  11066. }
  11067. }]);
  11068. return RunTimeArray;
  11069. }();
  11070. var XEngineRunTimeStats = /*#__PURE__*/_createClass(function XEngineRunTimeStats() {
  11071. _classCallCheck(this, XEngineRunTimeStats);
  11072. E(this, "timeArray_loadStaticMesh", new RunTimeArray());
  11073. E(this, "timeArray_updateStaticMesh", new RunTimeArray());
  11074. E(this, "timeArray_addAvatarToScene", new RunTimeArray());
  11075. });
  11076. 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; } } }; }
  11077. 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); }
  11078. 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; }
  11079. var getAlphaWidthMap = function getAlphaWidthMap(i, e) {
  11080. var t = new BABYLON.DynamicTexture("test", 3, e),
  11081. r = new Map();
  11082. for (var n = 32; n < 127; n++) {
  11083. var o = String.fromCodePoint(n),
  11084. a = 2 + "px " + i;
  11085. t.drawText(o, null, null, a, "#000000", "#ffffff", !0);
  11086. var s = t.getContext();
  11087. s.font = a;
  11088. var l = s.measureText(o).width;
  11089. r.set(n, l);
  11090. }
  11091. return t.dispose(), r;
  11092. };
  11093. var XSceneManager = /*#__PURE__*/function () {
  11094. function XSceneManager(e, t) {
  11095. var _this = this;
  11096. _classCallCheck(this, XSceneManager);
  11097. E(this, "scene");
  11098. E(this, "engine");
  11099. E(this, "canvas");
  11100. E(this, "gl");
  11101. E(this, "_yuvInfo");
  11102. E(this, "cameraParam");
  11103. E(this, "shaderMode");
  11104. E(this, "panoInfo");
  11105. E(this, "_initEngineScaleNumber");
  11106. E(this, "_forceKeepVertical", !1);
  11107. E(this, "_currentShader");
  11108. E(this, "_currentPanoId");
  11109. E(this, "_renderStatusCheckCount", 0);
  11110. E(this, "_renderStatusNotChecktCount", 0);
  11111. E(this, "_nonlinearCanvasResize", !1);
  11112. E(this, "_bChangeEngineSize", !0);
  11113. E(this, "_cameraManager");
  11114. E(this, "_lowpolyManager");
  11115. E(this, "_materialManager");
  11116. E(this, "_statisticManager");
  11117. E(this, "_breathPointManager");
  11118. E(this, "_skytv");
  11119. E(this, "_mv", []);
  11120. E(this, "_decalManager");
  11121. E(this, "_lightManager");
  11122. E(this, "_avatarManager");
  11123. E(this, "urlTransformer");
  11124. E(this, "_billboardManager");
  11125. E(this, "_backgroundImg");
  11126. E(this, "engineRunTimeStats");
  11127. E(this, "uploadHardwareSystemInfo", function () {
  11128. var e = _this.statisticComponent.getHardwareRenderInfo(),
  11129. t = _this.statisticComponent.getSystemInfo(),
  11130. r = {
  11131. driver: t.driver,
  11132. vender: t.vender,
  11133. webgl: t.version,
  11134. os: t.os
  11135. };
  11136. logger$1.warn(JSON.stringify(e)), logger$1.warn(JSON.stringify(r));
  11137. });
  11138. E(this, "addNewLowPolyMesh", /*#__PURE__*/function () {
  11139. var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e, t) {
  11140. return regenerator.wrap(function _callee$(_context) {
  11141. while (1) {
  11142. switch (_context.prev = _context.next) {
  11143. case 0:
  11144. _context.t0 = _this._currentShader == null;
  11145. if (!_context.t0) {
  11146. _context.next = 4;
  11147. break;
  11148. }
  11149. _context.next = 4;
  11150. return _this.initSceneManager();
  11151. case 4:
  11152. return _context.abrupt("return", _this._lowpolyManager.addNewLowPolyMesh(e, t, _this._currentShader));
  11153. case 5:
  11154. case "end":
  11155. return _context.stop();
  11156. }
  11157. }
  11158. }, _callee);
  11159. }));
  11160. return function (_x, _x2) {
  11161. return _ref.apply(this, arguments);
  11162. };
  11163. }());
  11164. E(this, "initSceneManager", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
  11165. return regenerator.wrap(function _callee2$(_context2) {
  11166. while (1) {
  11167. switch (_context2.prev = _context2.next) {
  11168. case 0:
  11169. _context2.next = 2;
  11170. return _this._materialManager.initMaterial();
  11171. case 2:
  11172. return _context2.abrupt("return", _this.applyShader());
  11173. case 3:
  11174. case "end":
  11175. return _context2.stop();
  11176. }
  11177. }
  11178. }, _callee2);
  11179. })));
  11180. E(this, "registerAfterRender", function () {
  11181. var e;
  11182. if (_this._forceKeepVertical) {
  11183. var _t = _this.canvas.width,
  11184. _r = _this.canvas.height;
  11185. var _n = 0,
  11186. _o = [[0, 0, 0, 0], [0, 0, 0, 0]];
  11187. 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) {
  11188. _this.gl.enable(_this.gl.SCISSOR_TEST);
  11189. for (var a = 0; a < _o.length; ++a) {
  11190. _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);
  11191. }
  11192. _this.gl.disable(_this.gl.SCISSOR_TEST);
  11193. }
  11194. }
  11195. });
  11196. E(this, "resetRender", function () {
  11197. _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));
  11198. });
  11199. var r = /iphone|ipad/gi.test(window.navigator.userAgent) || t.disableWebGL2,
  11200. n = new BABYLON.Engine(e, !0, {
  11201. preserveDrawingBuffer: !0,
  11202. stencil: !0,
  11203. disableWebGL2Support: r
  11204. }, !0),
  11205. o = new BABYLON.Scene(n);
  11206. 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) {
  11207. return Promise.resolve(s);
  11208. }, t.logger && Logger1.setLogger(t.logger), this.gl = e.getContext("webgl2", {
  11209. preserveDrawingBuffer: !0
  11210. }) || e.getContext("webgl", {
  11211. preserveDrawingBuffer: !0
  11212. }) || e.getContext("experimental-webgl", {
  11213. preserveDrawingBuffer: !0
  11214. }), 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 = {
  11215. width: t.videoResOriArray[0].width,
  11216. height: t.videoResOriArray[0].height,
  11217. fov: 50
  11218. }, t.cameraParam != null && (this.cameraParam = t.cameraParam), t.nonlinearCanvasResize != null && (this._nonlinearCanvasResize = t.nonlinearCanvasResize), this._cameraManager = new XCameraComponent(this.canvas, this.scene, {
  11219. cameraParam: this.cameraParam,
  11220. yuvInfo: this._yuvInfo,
  11221. forceKeepVertical: this._forceKeepVertical
  11222. }), this._lowpolyManager = new XStaticMeshComponent(this), this._materialManager = new XMaterialComponent(this, {
  11223. videoResOriArray: t.videoResOriArray,
  11224. yuvInfo: this._yuvInfo,
  11225. panoInfo: this.panoInfo,
  11226. shaderMode: this.shaderMode
  11227. }), 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 () {
  11228. _this._nonlinearCanvasResize && _this._bChangeEngineSize && (_this.setEngineSize(_this._yuvInfo), _this._bChangeEngineSize = !1);
  11229. }), this.scene.registerAfterRender(function () {
  11230. _this._nonlinearCanvasResize || _this.registerAfterRender();
  11231. }), window.addEventListener("resize", function () {
  11232. _this._nonlinearCanvasResize ? _this._bChangeEngineSize = !0 : _this.engine.resize();
  11233. }), XBillboardManager.alphaWidthMap = getAlphaWidthMap("Arial", this.scene), this.uploadHardwareSystemInfo();
  11234. }
  11235. _createClass(XSceneManager, [{
  11236. key: "yuvInfo",
  11237. get: function get() {
  11238. return this.getCurrentShaderMode() == 1 ? this._yuvInfo : {
  11239. width: -1,
  11240. height: -1,
  11241. fov: -1
  11242. };
  11243. },
  11244. set: function set(e) {
  11245. this.getCurrentShaderMode() == 1 && (this._yuvInfo = e, this._cameraManager.cameraFovChange(e));
  11246. }
  11247. }, {
  11248. key: "mainScene",
  11249. get: function get() {
  11250. return this.scene;
  11251. }
  11252. }, {
  11253. key: "cameraComponent",
  11254. get: function get() {
  11255. return this._cameraManager;
  11256. }
  11257. }, {
  11258. key: "staticmeshComponent",
  11259. get: function get() {
  11260. return this._lowpolyManager;
  11261. }
  11262. }, {
  11263. key: "materialComponent",
  11264. get: function get() {
  11265. return this._materialManager;
  11266. }
  11267. }, {
  11268. key: "statisticComponent",
  11269. get: function get() {
  11270. return this._statisticManager;
  11271. }
  11272. }, {
  11273. key: "avatarComponent",
  11274. get: function get() {
  11275. return this._avatarManager;
  11276. }
  11277. }, {
  11278. key: "lightComponent",
  11279. get: function get() {
  11280. return this._lightManager;
  11281. }
  11282. }, {
  11283. key: "Engine",
  11284. get: function get() {
  11285. return this.engine;
  11286. }
  11287. }, {
  11288. key: "Scene",
  11289. get: function get() {
  11290. return this.scene;
  11291. }
  11292. }, {
  11293. key: "billboardComponent",
  11294. get: function get() {
  11295. return this._billboardManager;
  11296. }
  11297. }, {
  11298. key: "breathPointComponent",
  11299. get: function get() {
  11300. return this._breathPointManager;
  11301. }
  11302. }, {
  11303. key: "skytvComponent",
  11304. get: function get() {
  11305. return this._skytv;
  11306. }
  11307. }, {
  11308. key: "mvComponent",
  11309. get: function get() {
  11310. return this._mv;
  11311. }
  11312. }, {
  11313. key: "decalComponent",
  11314. get: function get() {
  11315. return this._decalManager;
  11316. }
  11317. }, {
  11318. key: "currentShader",
  11319. get: function get() {
  11320. return this._currentShader;
  11321. }
  11322. }, {
  11323. key: "initEngineScaleNumber",
  11324. get: function get() {
  11325. return this._initEngineScaleNumber;
  11326. }
  11327. }, {
  11328. key: "setImageQuality",
  11329. value: function setImageQuality(e) {
  11330. 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 + "]"));
  11331. }
  11332. }, {
  11333. key: "setNonlinearCanvasResize",
  11334. value: function setNonlinearCanvasResize(e) {
  11335. this._nonlinearCanvasResize = e, this._bChangeEngineSize = e, e || this.engine.resize();
  11336. }
  11337. }, {
  11338. key: "setBackgroundColor",
  11339. value: function setBackgroundColor(e) {
  11340. this.scene.clearColor = new Color4(e.r, e.g, e.b, e.a);
  11341. }
  11342. }, {
  11343. key: "setBackgroundImg",
  11344. value: function setBackgroundImg(e) {
  11345. var _this2 = this;
  11346. return this._backgroundImg != null && this._backgroundImg.url == e ? Promise.resolve(!0) : new Promise(function (t, r) {
  11347. _this2.urlTransformer(e).then(function (n) {
  11348. _this2._backgroundImg == null ? _this2._backgroundImg = {
  11349. layer: new Layer("tex_background_" + Date.now(), n, _this2.Scene, !0),
  11350. url: e
  11351. } : _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);
  11352. }).catch(function (n) {
  11353. logger$1.error("[Engine] set background image Error: ".concat(n)), r("[Engine] set background image Error: ".concat(n));
  11354. });
  11355. });
  11356. }
  11357. }, {
  11358. key: "cleanTheWholeScene",
  11359. value: function cleanTheWholeScene() {
  11360. var _this3 = this;
  11361. var e = this.scene.getFrameId();
  11362. this.scene.onBeforeRenderObservable.clear(), this.scene.onAfterRenderObservable.clear(), this.scene.clearCachedVertexData(), this.scene.cleanCachedTextureBuffer(), this.scene.registerBeforeRender(function () {
  11363. _this3.scene.getFrameId() - e > 5 && _this3.scene.dispose();
  11364. });
  11365. }
  11366. }, {
  11367. key: "getAreaAvatar",
  11368. value: function getAreaAvatar(e, t) {
  11369. var r = [];
  11370. return this._avatarManager.getAvatarList().forEach(function (n) {
  11371. var o = e,
  11372. a = n.position;
  11373. a && o && calcDistance3D(o, a) < t && r.push(n.id);
  11374. }), r;
  11375. }
  11376. }, {
  11377. key: "setEngineSize",
  11378. value: function setEngineSize(e) {
  11379. var t = e.width,
  11380. r = e.height,
  11381. n = this.canvas.width;
  11382. this.canvas.height, this.engine.setSize(Math.round(n), Math.round(n * (r / t)));
  11383. }
  11384. }, {
  11385. key: "getCurrentShaderMode",
  11386. value: function getCurrentShaderMode() {
  11387. return this._currentShader === this._materialManager.getDefaultShader() ? 0 : this._currentShader === this._materialManager.getPureVideoShader() ? 1 : 2;
  11388. }
  11389. }, {
  11390. key: "addSkyTV",
  11391. value: function addSkyTV(e, t) {
  11392. return this._skytv = new XTelevision(this.scene, e, this, t), this._skytv;
  11393. }
  11394. }, {
  11395. key: "addMv",
  11396. value: function addMv(e, t) {
  11397. this._mv.push(new XTelevision(this.scene, e, this, t));
  11398. }
  11399. }, {
  11400. key: "addMeshInfo",
  11401. value: function addMeshInfo(e) {
  11402. this._lowpolyManager.setMeshInfo(e);
  11403. }
  11404. }, {
  11405. key: "applyShader",
  11406. value: function applyShader() {
  11407. var _this4 = this;
  11408. return new Promise(function (e, t) {
  11409. _this4.shaderMode == EShaderMode.videoAndPano || _this4.shaderMode == EShaderMode.video ? _this4.changeVideoShaderForLowModel() : _this4.shaderMode == EShaderMode.default && _this4.changeDefaultShaderForLowModel(), e(!0);
  11410. });
  11411. }
  11412. }, {
  11413. key: "changeHardwareScaling",
  11414. value: function changeHardwareScaling(e) {
  11415. e < 1 ? e = 1 : e > 2.5 && (e = 2.5), this._bChangeEngineSize = !0, this.engine.setHardwareScalingLevel(this._initEngineScaleNumber * e);
  11416. }
  11417. }, {
  11418. key: "getCurrentUsedPanoId",
  11419. value: function getCurrentUsedPanoId() {
  11420. return this._currentPanoId;
  11421. }
  11422. }, {
  11423. key: "render",
  11424. value: function render() {
  11425. try {
  11426. this.scene.render();
  11427. } catch (e) {
  11428. throw logger$1.error("[Engine] Render Error: ".concat(e)), e;
  11429. }
  11430. }
  11431. }, {
  11432. key: "isReadyToRender",
  11433. value: function isReadyToRender(e) {
  11434. var _e$checkMesh = e.checkMesh,
  11435. t = _e$checkMesh === void 0 ? !0 : _e$checkMesh,
  11436. _e$checkEffect = e.checkEffect,
  11437. r = _e$checkEffect === void 0 ? !1 : _e$checkEffect,
  11438. _e$checkPostProgress = e.checkPostProgress,
  11439. n = _e$checkPostProgress === void 0 ? !1 : _e$checkPostProgress,
  11440. _e$checkParticle = e.checkParticle,
  11441. o = _e$checkParticle === void 0 ? !1 : _e$checkParticle,
  11442. _e$checkAnimation = e.checkAnimation,
  11443. a = _e$checkAnimation === void 0 ? !1 : _e$checkAnimation;
  11444. e.materialNameWhiteLists;
  11445. if (this.scene._isDisposed) return logger$1.error("[Engine] this.scene._isDisposed== false "), !1;
  11446. var l;
  11447. var u = this.scene.getEngine();
  11448. if (r && !u.areAllEffectsReady()) return logger$1.error("[Engine] engine.areAllEffectsReady == false"), !1;
  11449. if (a && this.scene._pendingData.length > 0) return logger$1.error("[Engine] scene._pendingData.length > 0 && animation error"), !1;
  11450. if (t) {
  11451. for (l = 0; l < this.scene.meshes.length; l++) {
  11452. var c = this.scene.meshes[l];
  11453. 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;
  11454. 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;
  11455. var h = c.hasThinInstances || c.getClassName() === "InstancedMesh" || c.getClassName() === "InstancedLinesMesh" || u.getCaps().instancedArrays && c.instances.length > 0;
  11456. var _iterator = _createForOfIteratorHelper(this.scene._isReadyForMeshStage),
  11457. _step;
  11458. try {
  11459. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  11460. var f = _step.value;
  11461. 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;
  11462. }
  11463. } catch (err) {
  11464. _iterator.e(err);
  11465. } finally {
  11466. _iterator.f();
  11467. }
  11468. }
  11469. for (l = 0; l < this.scene.geometries.length; l++) {
  11470. if (this.scene.geometries[l].delayLoadState === 2) return logger$1.error("[Engine] geometry.delayLoadState === 2"), !1;
  11471. }
  11472. }
  11473. if (n) {
  11474. if (this.scene.activeCameras && this.scene.activeCameras.length > 0) {
  11475. var _iterator2 = _createForOfIteratorHelper(this.scene.activeCameras),
  11476. _step2;
  11477. try {
  11478. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  11479. var _c = _step2.value;
  11480. if (!_c.isReady(!0)) return logger$1.error("[Engine] camera not ready === false, ", _c.name), !1;
  11481. }
  11482. } catch (err) {
  11483. _iterator2.e(err);
  11484. } finally {
  11485. _iterator2.f();
  11486. }
  11487. } else if (this.scene.activeCamera && !this.scene.activeCamera.isReady(!0)) return logger$1.error("[Engine] activeCamera ready === false, ", this.scene.activeCamera.name), !1;
  11488. }
  11489. if (o) {
  11490. var _iterator3 = _createForOfIteratorHelper(this.scene.particleSystems),
  11491. _step3;
  11492. try {
  11493. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  11494. var _c2 = _step3.value;
  11495. if (!_c2.isReady()) return logger$1.error("[Engine] particleSystem ready === false, ", _c2.name), !1;
  11496. }
  11497. } catch (err) {
  11498. _iterator3.e(err);
  11499. } finally {
  11500. _iterator3.f();
  11501. }
  11502. }
  11503. return !0;
  11504. }
  11505. }, {
  11506. key: "changePanoShaderForLowModel",
  11507. value: function changePanoShaderForLowModel(e) {
  11508. var _this5 = this;
  11509. return logger$1.info("[Engine] changePanoShaderForLowModel: ".concat(e)), this._materialManager.allowYUVUpdate(), new Promise(function (t, r) {
  11510. _this5._materialManager._isInDynamicRange(e) == !1 && r(!1), _this5._currentPanoId = e, _this5._currentShader = _this5._materialManager.getDynamicShader(e), _this5.changeShaderForLowModel().then(function () {
  11511. t(!0);
  11512. });
  11513. });
  11514. }
  11515. }, {
  11516. key: "changeVideoShaderForLowModel",
  11517. value: function changeVideoShaderForLowModel() {
  11518. return logger$1.info("[Engine] changeVideoShaderForLowModel"), this._currentShader = this._materialManager.getPureVideoShader(), this._materialManager.allowYUVUpdate(), this.changeShaderForLowModel();
  11519. }
  11520. }, {
  11521. key: "changeDefaultShaderForLowModel",
  11522. value: function changeDefaultShaderForLowModel() {
  11523. return logger$1.info("[Engine] changeDefaultShaderForLowModel"), this._currentShader = this._materialManager.getDefaultShader(), this._materialManager.stopYUVUpdate(), this.changeShaderForLowModel();
  11524. }
  11525. }, {
  11526. key: "changeShaderForLowModel",
  11527. value: function changeShaderForLowModel() {
  11528. var _this6 = this;
  11529. return new Promise(function (e, t) {
  11530. _this6._lowpolyManager.getMeshes().forEach(function (r) {
  11531. r.setMaterial(_this6._currentShader);
  11532. }), _this6._lowpolyManager.getCgMesh().mesh.material = _this6._currentShader, e(!0);
  11533. });
  11534. }
  11535. }, {
  11536. key: "setIBL",
  11537. value: function setIBL(e) {
  11538. this._lightManager.setIBL(e);
  11539. }
  11540. }, {
  11541. key: "postprocessing",
  11542. value: function postprocessing() {
  11543. var e = new BABYLON.DefaultRenderingPipeline("default", !0, this.scene);
  11544. e.imageProcessingEnabled = !1, e.bloomEnabled = !0, e.bloomThreshold = 1, e.bloomWeight = 1, e.bloomKernel = 64, e.bloomScale = .1;
  11545. }
  11546. }, {
  11547. key: "getGround",
  11548. value: function getGround(e) {
  11549. var t = this._lowpolyManager.getMeshes(),
  11550. r = [];
  11551. return t.forEach(function (n) {
  11552. n.mesh.name.indexOf("SM_Stage") >= 0 && r.push(n.mesh);
  11553. }), this.Scene.meshes.forEach(function (n) {
  11554. n.name.split("_")[0] === "ground" && r.push(n);
  11555. }), r;
  11556. }
  11557. }]);
  11558. return XSceneManager;
  11559. }();
  11560. var http = new Http();
  11561. var urlMap = new Map(),
  11562. urlTransformer = /*#__PURE__*/function () {
  11563. var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(i) {
  11564. var e,
  11565. _args2 = arguments;
  11566. return regenerator.wrap(function _callee2$(_context2) {
  11567. while (1) {
  11568. switch (_context2.prev = _context2.next) {
  11569. case 0:
  11570. e = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : !1;
  11571. return _context2.abrupt("return", typeof i != "string" ? (console.warn("url transformer error", i), i) : i.startsWith("blob:") ? i : e ? http.get({
  11572. url: i,
  11573. useIndexedDb: !0,
  11574. key: "url",
  11575. isOutPutObjectURL: !1
  11576. }) : urlMap.has(i) ? urlMap.get(i) : http.get({
  11577. url: i,
  11578. useIndexedDb: !0,
  11579. key: "url"
  11580. }).then(function (t) {
  11581. return urlMap.set(i, t), t;
  11582. }));
  11583. case 2:
  11584. case "end":
  11585. return _context2.stop();
  11586. }
  11587. }
  11588. }, _callee2);
  11589. }));
  11590. return function urlTransformer(_x2) {
  11591. return _ref2.apply(this, arguments);
  11592. };
  11593. }();
  11594. var sceneManager;
  11595. function getSceneManager(i, e) {
  11596. return sceneManager || (sceneManager = new XSceneManager(i, e)), sceneManager;
  11597. }
  11598. var EngineProxy = /*#__PURE__*/function () {
  11599. function EngineProxy(e) {
  11600. var _this = this;
  11601. _classCallCheck(this, EngineProxy);
  11602. E(this, "_tvs", []);
  11603. E(this, "isRenderFirstFrame", !1);
  11604. E(this, "_idleTime", 0);
  11605. E(this, "renderTimer");
  11606. E(this, "lightManager");
  11607. E(this, "_checkSceneNotReadyCount", 0);
  11608. E(this, "_checkSceneDurationFrameNum", 0);
  11609. E(this, "_checkSceneFrameCount", 0);
  11610. E(this, "timeoutCircularArray", new CircularArray(120, !1, []));
  11611. E(this, "frameCircularArray", new CircularArray(120, !1, []));
  11612. E(this, "interFrameCircularArray", new CircularArray(120, !1, []));
  11613. E(this, "drawCallCntCircularArray", new CircularArray(120, !1, []));
  11614. E(this, "activeFacesCircularArray", new CircularArray(120, !1, []));
  11615. E(this, "renderTimeCircularArray", new CircularArray(120, !1, []));
  11616. E(this, "drawCallTimeCircularArray", new CircularArray(120, !1, []));
  11617. E(this, "animationCircularArray", new CircularArray(120, !1, []));
  11618. E(this, "meshSelectCircularArray", new CircularArray(120, !1, []));
  11619. E(this, "renderTargetCircularArray", new CircularArray(120, !1, []));
  11620. E(this, "regBeforeRenderCircularArray", new CircularArray(120, !1, []));
  11621. E(this, "regAfterRenderCircularArray", new CircularArray(120, !1, []));
  11622. E(this, "renderCnt", 0);
  11623. E(this, "renderErrorCount", 0);
  11624. E(this, "engineSloppyCnt", 0);
  11625. E(this, "systemStuckCnt", 0);
  11626. E(this, "frameRenderNumber", 0);
  11627. E(this, "_setFPS", function (e) {
  11628. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 25;
  11629. logger$1.info("Set fps to", t);
  11630. var r = t > 60 ? 60 : t < 24 ? 24 : t;
  11631. e.Engine.stopRenderLoop();
  11632. var n = 1e3 / r;
  11633. var o = Date.now(),
  11634. a = Date.now(),
  11635. s = n,
  11636. l = 1;
  11637. var u = function u() {
  11638. var T;
  11639. var c = Date.now(),
  11640. h = c - o,
  11641. f = c - a;
  11642. a = c, _this.frameCircularArray.add(f), h - s > n && (_this.systemStuckCnt += 1);
  11643. var d = h / s;
  11644. l = .9 * l + .1 * d;
  11645. var _ = Date.now();
  11646. var g = 0,
  11647. m = 0;
  11648. if (_this.room.isUpdatedRawYUVData || _this.room.isPano) {
  11649. 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", {
  11650. error: new Error("[SDK] Scene not ready, skip render and reload.")
  11651. })), _this.room.stats.assign({
  11652. renderErrorCount: _this._checkSceneNotReadyCount
  11653. }), logger$1.infoAndReportMeasurement({
  11654. value: 0,
  11655. startTime: Date.now(),
  11656. metric: "renderError",
  11657. error: new Error("[SDK] Scene not ready, skip render and reload."),
  11658. reportOptions: {
  11659. sampleRate: .1
  11660. }
  11661. }));else try {
  11662. e.render();
  11663. } catch (C) {
  11664. _this.renderErrorCount++, _this.renderErrorCount > 10 && _this.room.proxyEvents("renderError", {
  11665. error: C
  11666. }), _this.room.stats.assign({
  11667. renderErrorCount: _this.renderErrorCount
  11668. }), logger$1.infoAndReportMeasurement({
  11669. value: 0,
  11670. startTime: Date.now(),
  11671. metric: "renderError",
  11672. error: C,
  11673. reportOptions: {
  11674. sampleRate: .1
  11675. }
  11676. });
  11677. }
  11678. g = Date.now() - _, _this.frameRenderNumber < 1e3 && _this.frameRenderNumber++, _this.room.networkController.rtcp.workers.UpdateYUV(), m = Date.now() - _ - g;
  11679. }
  11680. _this.isRenderFirstFrame || _this.room.networkController.rtcp.workers.UpdateYUV();
  11681. var y = Date.now() - _;
  11682. o = c + y, s = Math.min(Math.max((n - y) / l, 5), 200), y > n && (s = 10, _this.engineSloppyCnt += 1), _this._idleTime = s;
  11683. var b = s;
  11684. 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) {
  11685. var C = _this.frameCircularArray.getAvg(),
  11686. A = _this.timeoutCircularArray.getAvg(),
  11687. S = _this.frameCircularArray.getMax(),
  11688. P = _this.timeoutCircularArray.getMax();
  11689. (T = _this.room.stats) == null || T.assign({
  11690. avgFrameTime: C,
  11691. avgTimeoutTime: A,
  11692. maxFrameTime: S,
  11693. maxTimeoutTime: P,
  11694. systemStuckCnt: _this.systemStuckCnt
  11695. });
  11696. }
  11697. _this.renderTimer = window.setTimeout(u, s);
  11698. };
  11699. _this.renderTimer = window.setTimeout(u, n / l);
  11700. });
  11701. E(this, "updateStats", function () {
  11702. var e;
  11703. (e = _this.room.stats) == null || e.assign({
  11704. renderFrameTime: _this.renderTimeCircularArray.getAvg(),
  11705. maxRenderFrameTime: _this.renderTimeCircularArray.getMax(),
  11706. interFrameTime: _this.interFrameCircularArray.getAvg(),
  11707. animationTime: _this.animationCircularArray.getAvg(),
  11708. meshSelectTime: _this.meshSelectCircularArray.getAvg(),
  11709. drawcallTime: _this.drawCallTimeCircularArray.getAvg(),
  11710. idleTime: _this._idleTime,
  11711. registerBeforeRenderTime: _this.regBeforeRenderCircularArray.getAvg(),
  11712. registerAfterRenderTime: _this.regAfterRenderCircularArray.getAvg(),
  11713. renderTargetRenderTime: _this.renderTargetCircularArray.getAvg(),
  11714. fps: (1e3 / (_this.renderTimeCircularArray.getAvg() + _this.interFrameCircularArray.getAvg())).toFixed(2),
  11715. drawcall: _this.drawCallCntCircularArray.getAvg(),
  11716. engineSloppyCnt: _this.engineSloppyCnt,
  11717. maxInterFrameTime: _this.interFrameCircularArray.getMax(),
  11718. maxDrawcallTime: _this.drawCallTimeCircularArray.getMax(),
  11719. maxMeshSelectTime: _this.meshSelectCircularArray.getMax(),
  11720. maxAnimationTime: _this.animationCircularArray.getMax(),
  11721. maxRegisterBeforeRenderTime: _this.regBeforeRenderCircularArray.getMax(),
  11722. maxRegisterAfterRenderTime: _this.regAfterRenderCircularArray.getMax(),
  11723. maxRenderTargetRenderTime: _this.renderTargetCircularArray.getMax(),
  11724. avgFrameTime: _this.frameCircularArray.getAvg(),
  11725. avgTimeoutTime: _this.timeoutCircularArray.getAvg(),
  11726. maxFrameTime: _this.frameCircularArray.getMax(),
  11727. maxTimeoutTime: _this.timeoutCircularArray.getMax()
  11728. });
  11729. });
  11730. this.room = e;
  11731. }
  11732. _createClass(EngineProxy, [{
  11733. key: "initEngine",
  11734. value: function () {
  11735. var _initEngine = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e) {
  11736. var t, r, n, o, a;
  11737. return regenerator.wrap(function _callee3$(_context3) {
  11738. while (1) {
  11739. switch (_context3.prev = _context3.next) {
  11740. case 0:
  11741. _context3.next = 2;
  11742. return this.updateBillboard();
  11743. case 2:
  11744. logger$1.info("engine version:", VERSION$1);
  11745. t = logger$1;
  11746. t.setLevel(LoggerLevels$1.Warn);
  11747. r = {
  11748. videoResOriArray: [{
  11749. width: 720,
  11750. height: 1280
  11751. }, {
  11752. width: 1280,
  11753. height: 720
  11754. }, {
  11755. width: 480,
  11756. height: 654
  11757. }, {
  11758. width: 654,
  11759. height: 480
  11760. }, {
  11761. width: 1920,
  11762. height: 1080
  11763. }, {
  11764. width: 1080,
  11765. height: 1920
  11766. }, {
  11767. width: 414,
  11768. height: 896
  11769. }],
  11770. forceKeepVertical: this.room.options.objectFit !== "cover",
  11771. panoInfo: {
  11772. dynamicRange: 1,
  11773. width: 4096,
  11774. height: 2048
  11775. },
  11776. shaderMode: EShaderMode.videoAndPano,
  11777. yuvInfo: {
  11778. width: 1280,
  11779. height: 720,
  11780. fov: e.fov || DEFAULT_MAIN_CAMERA_FOV
  11781. },
  11782. cameraParam: {
  11783. maxZ: 1e4
  11784. },
  11785. urlTransformer,
  11786. logger: t,
  11787. disableWebGL2: this.room.options.disableWebGL2 || !1
  11788. }, n = this.room.options.resolution;
  11789. n && (r.videoResOriArray.some(function (l) {
  11790. return l.width === n.width && l.height === n.height;
  11791. }) || r.videoResOriArray.push(n));
  11792. o = this.room.sceneManager = getSceneManager(this.room.canvas, r);
  11793. this.room.setPictureQualityLevel(this.room.options.pictureQualityLevel || "high");
  11794. this.room.sceneManager.staticmeshComponent.setRegionLodRule([2, 2, -1, -1, -1]);
  11795. this.room.scene = o.Scene;
  11796. this.room.breathPointManager = o.breathPointComponent;
  11797. this.lightManager = o.lightComponent;
  11798. this.registerStats();
  11799. this.setEnv(e);
  11800. _context3.next = 17;
  11801. return this.room.avatarManager.init();
  11802. case 17:
  11803. a = this._createAssetList(e);
  11804. _context3.next = 20;
  11805. return this.loadAssets(a, "");
  11806. case 20:
  11807. this._setFPS(o);
  11808. case 21:
  11809. case "end":
  11810. return _context3.stop();
  11811. }
  11812. }
  11813. }, _callee3, this);
  11814. }));
  11815. function initEngine(_x3) {
  11816. return _initEngine.apply(this, arguments);
  11817. }
  11818. return initEngine;
  11819. }()
  11820. }, {
  11821. key: "pause",
  11822. value: function pause() {
  11823. clearTimeout(this.renderTimer), logger$1.info("Invoke room.pause to pause render");
  11824. var e = {
  11825. roomId: this.room.id,
  11826. effects: [],
  11827. lowPolyModels: [],
  11828. breathPointsConfig: [],
  11829. skinId: this.room.skinId
  11830. };
  11831. return this.loadAssets(e, this.room.skinId);
  11832. }
  11833. }, {
  11834. key: "resume",
  11835. value: function () {
  11836. var _resume = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4() {
  11837. var e;
  11838. return regenerator.wrap(function _callee4$(_context4) {
  11839. while (1) {
  11840. switch (_context4.prev = _context4.next) {
  11841. case 0:
  11842. this._setFPS(this.room.sceneManager), this.room.sceneManager.cameraComponent.cameraFovChange(this.room.sceneManager.yuvInfo), logger$1.info("Invoke room.resume to render");
  11843. e = this._createAssetList(this.room.skin);
  11844. _context4.next = 4;
  11845. return this.loadAssets(e, "");
  11846. case 4:
  11847. case "end":
  11848. return _context4.stop();
  11849. }
  11850. }
  11851. }, _callee4, this);
  11852. }));
  11853. function resume() {
  11854. return _resume.apply(this, arguments);
  11855. }
  11856. return resume;
  11857. }()
  11858. }, {
  11859. key: "setEnv",
  11860. value: function setEnv(e) {
  11861. var r;
  11862. this.lightManager || (this.lightManager = this.room.sceneManager.lightComponent), e = e || this.room.skin;
  11863. var t = ModelManager.findModel(e.models, AssetTypeName.Config, AssetClassName.Env);
  11864. return t ? (r = this.lightManager) == null ? void 0 : r.setIBL(t.modelUrl) : (logger$1.error("env file not found"), Promise.resolve());
  11865. }
  11866. }, {
  11867. key: "_parseModelsAndLoad",
  11868. value: function () {
  11869. var _parseModelsAndLoad2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(e, t, r) {
  11870. var n, o, a, u, c, h, _c, s, l, _u, _c2, _h;
  11871. return regenerator.wrap(function _callee5$(_context5) {
  11872. while (1) {
  11873. switch (_context5.prev = _context5.next) {
  11874. case 0:
  11875. logger$1.info("Invoke _parseModelsAndLoad start", t);
  11876. n = ["airship", "balloon", "default", "ground_feiting", "ground_reqiqiu"], o = new Map();
  11877. r == null && (r = "xxxx");
  11878. a = !0;
  11879. u = 0;
  11880. case 5:
  11881. if (!(u < e.length)) {
  11882. _context5.next = 20;
  11883. break;
  11884. }
  11885. a = !0;
  11886. c = 0;
  11887. case 8:
  11888. if (!(c < n.length)) {
  11889. _context5.next = 16;
  11890. break;
  11891. }
  11892. if (!(e[u].modelUrl.toLowerCase().indexOf(n[c]) >= 0)) {
  11893. _context5.next = 13;
  11894. break;
  11895. }
  11896. h = o.get(n[c]);
  11897. h ? (h.push(e[u]), o.set(n[c], h)) : o.set(n[c], [e[u]]), a = !1;
  11898. return _context5.abrupt("break", 16);
  11899. case 13:
  11900. ++c;
  11901. _context5.next = 8;
  11902. break;
  11903. case 16:
  11904. if (a) {
  11905. _c = o.get("default");
  11906. _c ? (_c.push(e[u]), o.set("default", _c)) : o.set("default", [e[u]]);
  11907. }
  11908. case 17:
  11909. ++u;
  11910. _context5.next = 5;
  11911. break;
  11912. case 20:
  11913. s = o.get(t) || [];
  11914. if (!(this.room.viewMode === "simple" && (s = s.filter(function (u) {
  11915. return !u.modelUrl.endsWith("zip");
  11916. })), !s)) {
  11917. _context5.next = 23;
  11918. break;
  11919. }
  11920. return _context5.abrupt("return", Promise.reject("no invalid scene model with group name: ".concat(t)));
  11921. case 23:
  11922. l = [];
  11923. for (_u = 0; _u < s.length; ++_u) {
  11924. _c2 = s[_u];
  11925. if (_c2.modelUrl.toLowerCase().endsWith("zip")) _c2.modelUrl.toLowerCase().endsWith("zip") && l.push(this.room.sceneManager.addNewLowPolyMesh({
  11926. url: _c2.modelUrl,
  11927. skinInfo: r
  11928. }));else {
  11929. _h = t;
  11930. l.push(this.room.sceneManager.addNewLowPolyMesh({
  11931. url: _c2.modelUrl,
  11932. group: _h,
  11933. pick: !0,
  11934. skinInfo: r
  11935. }));
  11936. }
  11937. }
  11938. return _context5.abrupt("return", Promise.all(l));
  11939. case 26:
  11940. case "end":
  11941. return _context5.stop();
  11942. }
  11943. }
  11944. }, _callee5, this);
  11945. }));
  11946. function _parseModelsAndLoad(_x4, _x5, _x6) {
  11947. return _parseModelsAndLoad2.apply(this, arguments);
  11948. }
  11949. return _parseModelsAndLoad;
  11950. }()
  11951. }, {
  11952. key: "_deleteAssetsLowpolyModel",
  11953. value: function () {
  11954. var _deleteAssetsLowpolyModel2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6(e) {
  11955. var t;
  11956. return regenerator.wrap(function _callee6$(_context6) {
  11957. while (1) {
  11958. switch (_context6.prev = _context6.next) {
  11959. case 0:
  11960. this.room.sceneManager.staticmeshComponent.deleteMeshesBySkinInfo(e), this.room.sceneManager.breathPointComponent.clearBreathPointsBySkinInfo(e), this.room.sceneManager.decalComponent.deleteDecalBySkinInfo(e);
  11961. t = [];
  11962. this.room.sceneManager.Scene.meshes.forEach(function (r) {
  11963. r.xskinInfo == e && t.push(r);
  11964. }), t.forEach(function (r) {
  11965. r.dispose(!1, !1);
  11966. });
  11967. case 3:
  11968. case "end":
  11969. return _context6.stop();
  11970. }
  11971. }
  11972. }, _callee6, this);
  11973. }));
  11974. function _deleteAssetsLowpolyModel(_x7) {
  11975. return _deleteAssetsLowpolyModel2.apply(this, arguments);
  11976. }
  11977. return _deleteAssetsLowpolyModel;
  11978. }()
  11979. }, {
  11980. key: "loadLandAssets",
  11981. value: function () {
  11982. var _loadLandAssets = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee7() {
  11983. var _this2 = this;
  11984. var e;
  11985. return regenerator.wrap(function _callee7$(_context7) {
  11986. while (1) {
  11987. switch (_context7.prev = _context7.next) {
  11988. case 0:
  11989. e = this._createAssetList(this.room.skin);
  11990. return _context7.abrupt("return", this.loadAssets(e, this.room.skinId).catch(function () {
  11991. return _this2.loadAssets(e, _this2.room.skinId);
  11992. }));
  11993. case 2:
  11994. case "end":
  11995. return _context7.stop();
  11996. }
  11997. }
  11998. }, _callee7, this);
  11999. }));
  12000. function loadLandAssets() {
  12001. return _loadLandAssets.apply(this, arguments);
  12002. }
  12003. return loadLandAssets;
  12004. }()
  12005. }, {
  12006. key: "loadAssets",
  12007. value: function () {
  12008. var _loadAssets2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee8(e) {
  12009. var t,
  12010. r,
  12011. n,
  12012. _args8 = arguments;
  12013. return regenerator.wrap(function _callee8$(_context8) {
  12014. while (1) {
  12015. switch (_context8.prev = _context8.next) {
  12016. case 0:
  12017. t = _args8.length > 1 && _args8[1] !== undefined ? _args8[1] : "";
  12018. r = _args8.length > 2 && _args8[2] !== undefined ? _args8[2] : 8e3;
  12019. n = Date.now();
  12020. return _context8.abrupt("return", this._loadAssets(e, t)._timeout(r, new InitEngineTimeoutError("loadAssets timeout(".concat(r, "ms)"))).then(function (o) {
  12021. return logger$1.infoAndReportMeasurement({
  12022. tag: "loadAssets",
  12023. startTime: n,
  12024. metric: "loadAssets"
  12025. }), o;
  12026. }).catch(function (o) {
  12027. return logger$1.infoAndReportMeasurement({
  12028. tag: "loadAssets",
  12029. startTime: n,
  12030. metric: "loadAssets",
  12031. error: o
  12032. }), Promise.reject(o);
  12033. }));
  12034. case 4:
  12035. case "end":
  12036. return _context8.stop();
  12037. }
  12038. }
  12039. }, _callee8, this);
  12040. }));
  12041. function loadAssets(_x8) {
  12042. return _loadAssets2.apply(this, arguments);
  12043. }
  12044. return loadAssets;
  12045. }()
  12046. }, {
  12047. key: "_loadAssets",
  12048. value: function () {
  12049. var _loadAssets3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee9(e) {
  12050. var t,
  12051. r,
  12052. _args9 = arguments;
  12053. return regenerator.wrap(function _callee9$(_context9) {
  12054. while (1) {
  12055. switch (_context9.prev = _context9.next) {
  12056. case 0:
  12057. t = _args9.length > 1 && _args9[1] !== undefined ? _args9[1] : "";
  12058. _context9.prev = 1;
  12059. r = [];
  12060. r.push(this._loadAssetsLowpolyModel(e, t));
  12061. _context9.next = 6;
  12062. return Promise.all(r);
  12063. case 6:
  12064. _context9.next = 8;
  12065. return this.setEnv();
  12066. case 8:
  12067. this._checkSceneDurationFrameNum = EngineProxy._CHECK_DURATION;
  12068. this._checkSceneNotReadyCount = 0;
  12069. this._checkSceneFrameCount = 0;
  12070. this.updateAnimationList();
  12071. this.room.loadAssetsHook();
  12072. _context9.next = 18;
  12073. break;
  12074. case 15:
  12075. _context9.prev = 15;
  12076. _context9.t0 = _context9["catch"](1);
  12077. return _context9.abrupt("return", Promise.reject(_context9.t0));
  12078. case 18:
  12079. case "end":
  12080. return _context9.stop();
  12081. }
  12082. }
  12083. }, _callee9, this, [[1, 15]]);
  12084. }));
  12085. function _loadAssets(_x9) {
  12086. return _loadAssets3.apply(this, arguments);
  12087. }
  12088. return _loadAssets;
  12089. }()
  12090. }, {
  12091. key: "updateAnimationList",
  12092. value: function updateAnimationList() {
  12093. var _this3 = this;
  12094. if (this.room.avatarManager && this.room.avatarManager.xAvatarManager) {
  12095. var e = this.room.skin.animationList;
  12096. if (!e) return;
  12097. e.forEach(function (t) {
  12098. _this3.room.avatarManager.xAvatarManager.updateAnimationLists(t.animations, t.avatarId);
  12099. });
  12100. }
  12101. }
  12102. }, {
  12103. key: "_loadAssetsLowpolyModel",
  12104. value: function () {
  12105. var _loadAssetsLowpolyModel2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee11(e) {
  12106. var _this4 = this;
  12107. var t,
  12108. r,
  12109. n,
  12110. o,
  12111. a,
  12112. s,
  12113. u,
  12114. c,
  12115. h,
  12116. _args11 = arguments;
  12117. return regenerator.wrap(function _callee11$(_context11) {
  12118. while (1) {
  12119. switch (_context11.prev = _context11.next) {
  12120. case 0:
  12121. t = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : "";
  12122. r = [], n = [], o = [];
  12123. e.lowPolyModels.forEach(function (f) {
  12124. f.group === "TV" ? n.push({
  12125. id: "",
  12126. name: "",
  12127. thumbnailUrl: "",
  12128. typeName: AssetTypeName.Model,
  12129. className: AssetClassName.Tv,
  12130. modelUrl: f.url
  12131. }) : f.group === "\u544A\u767D\u5899" ? o.push({
  12132. id: "",
  12133. name: "",
  12134. thumbnailUrl: "",
  12135. typeName: AssetTypeName.Model,
  12136. className: AssetClassName.Lpm,
  12137. modelUrl: f.url
  12138. }) : r.push({
  12139. id: "",
  12140. name: "",
  12141. thumbnailUrl: "",
  12142. typeName: AssetTypeName.Model,
  12143. className: AssetClassName.Lpm,
  12144. modelUrl: f.url
  12145. });
  12146. }), t != "" && t != null && this._deleteAssetsLowpolyModel(t);
  12147. a = e.skinId;
  12148. logger$1.info("====> from ", t, " to ", a), this._tvs.forEach(function (f) {
  12149. return f.clean();
  12150. }), this._tvs = [];
  12151. s = EFitMode.cover;
  12152. a == "10048" && (s = EFitMode.contain), Array.isArray(n) && n.forEach(function (f, d) {
  12153. _this4._tvs.push(new TV("squareTv" + d, f.modelUrl, _this4.room, {
  12154. fitMode: s
  12155. }));
  12156. }), e.breathPointsConfig.forEach( /*#__PURE__*/function () {
  12157. var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee10(f) {
  12158. var d;
  12159. return regenerator.wrap(function _callee10$(_context10) {
  12160. while (1) {
  12161. switch (_context10.prev = _context10.next) {
  12162. case 0:
  12163. _context10.prev = 0;
  12164. _context10.next = 3;
  12165. return urlTransformer(f.imageUrl);
  12166. case 3:
  12167. d = _context10.sent;
  12168. _context10.next = 9;
  12169. break;
  12170. case 6:
  12171. _context10.prev = 6;
  12172. _context10.t0 = _context10["catch"](0);
  12173. d = f.imageUrl, logger$1.error("urlTransformer error", _context10.t0);
  12174. case 9:
  12175. _this4.room.breathPointManager.addBreathPoint({
  12176. id: f.id,
  12177. position: f.position,
  12178. spriteSheet: d,
  12179. rotation: f.rotation || {
  12180. pitch: 0,
  12181. yaw: 270,
  12182. roll: 0
  12183. },
  12184. billboardMode: !0,
  12185. type: f.type || "no_type",
  12186. spriteWidthNumber: f.spriteWidthNum || 1,
  12187. spriteHeightNumber: f.spriteHeightNum || 1,
  12188. maxVisibleRegion: f.maxVisibleRegion || 150,
  12189. width: f.width,
  12190. height: f.height,
  12191. skinInfo: f.skinId
  12192. });
  12193. case 10:
  12194. case "end":
  12195. return _context10.stop();
  12196. }
  12197. }
  12198. }, _callee10, null, [[0, 6]]);
  12199. }));
  12200. return function (_x11) {
  12201. return _ref3.apply(this, arguments);
  12202. };
  12203. }()), o.forEach(function (f) {
  12204. _this4.room.sceneManager.decalComponent.addDecal({
  12205. id: f.id || "gbq",
  12206. meshPath: f.modelUrl,
  12207. skinInfo: a
  12208. });
  12209. });
  12210. u = this.room.sceneManager.staticmeshComponent.lowModel_group, c = Array.from(u.keys()).filter(function (f) {
  12211. return !f.startsWith("region_");
  12212. }), h = ["airship", "balloon", "ground_feiting", "ground_reqiqiu", "default"];
  12213. return _context11.abrupt("return", new Promise(function (f, d) {
  12214. Promise.all(h.map(function (_) {
  12215. return _this4._parseModelsAndLoad(r, _, a);
  12216. })).then(function () {
  12217. var _ = !1;
  12218. r.forEach(function (v) {
  12219. v.modelUrl.endsWith("zip") && (_ = !0);
  12220. }), _ == !1 && _this4.room.sceneManager.staticmeshComponent.deleteLastRegionMesh(), _this4.room.sceneManager.staticmeshComponent.lowModel_group;
  12221. var g = Array.from(u.keys()).filter(function (v) {
  12222. return !v.startsWith("region_");
  12223. }),
  12224. m = c.filter(function (v) {
  12225. return g.indexOf(v) < 0;
  12226. });
  12227. m.length > 0 && m.forEach(function (v) {
  12228. _this4.room.sceneManager.staticmeshComponent.deleteMeshesByGroup(v);
  12229. }), f(!0);
  12230. }).catch(function (_) {
  12231. d(_);
  12232. });
  12233. }));
  12234. case 9:
  12235. case "end":
  12236. return _context11.stop();
  12237. }
  12238. }
  12239. }, _callee11, this);
  12240. }));
  12241. function _loadAssetsLowpolyModel(_x10) {
  12242. return _loadAssetsLowpolyModel2.apply(this, arguments);
  12243. }
  12244. return _loadAssetsLowpolyModel;
  12245. }()
  12246. }, {
  12247. key: "_updateSkinAssets",
  12248. value: function () {
  12249. var _updateSkinAssets2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee12(e) {
  12250. var t, r, n;
  12251. return regenerator.wrap(function _callee12$(_context12) {
  12252. while (1) {
  12253. switch (_context12.prev = _context12.next) {
  12254. case 0:
  12255. t = this.room.lastSkinId;
  12256. _context12.next = 3;
  12257. return this.room.getSkin(e);
  12258. case 3:
  12259. r = _context12.sent;
  12260. n = this._createAssetList(r);
  12261. _context12.prev = 5;
  12262. _context12.next = 8;
  12263. return this.loadAssets(n, t);
  12264. case 8:
  12265. this.room.updateCurrentState({
  12266. versionId: r.versionId,
  12267. skinId: r.id,
  12268. skin: r
  12269. });
  12270. _context12.next = 16;
  12271. break;
  12272. case 11:
  12273. _context12.prev = 11;
  12274. _context12.t0 = _context12["catch"](5);
  12275. _context12.next = 15;
  12276. return this.loadAssets(n, t);
  12277. case 15:
  12278. this.room.updateCurrentState({
  12279. versionId: r.versionId,
  12280. skinId: r.id,
  12281. skin: r
  12282. });
  12283. case 16:
  12284. this.setEnv(r);
  12285. case 17:
  12286. case "end":
  12287. return _context12.stop();
  12288. }
  12289. }
  12290. }, _callee12, this, [[5, 11]]);
  12291. }));
  12292. function _updateSkinAssets(_x12) {
  12293. return _updateSkinAssets2.apply(this, arguments);
  12294. }
  12295. return _updateSkinAssets;
  12296. }()
  12297. }, {
  12298. key: "_createAssetList",
  12299. value: function _createAssetList(e) {
  12300. var t = [],
  12301. r = [],
  12302. n = [];
  12303. var o = e.models;
  12304. var a = this.room.modelManager.config.preload;
  12305. return this.room.viewMode === "simple" ? a && (o = a.baseUrls.map(function (l) {
  12306. return l.modelUrl = l.url, l;
  12307. })) : this.room.viewMode, ModelManager.findModels(o, AssetTypeName.Effects, AssetClassName.Effects).forEach(function (l) {
  12308. t.push({
  12309. url: l.modelUrl,
  12310. group: l.className,
  12311. name: l.name
  12312. });
  12313. }), ModelManager.findModels(o, AssetTypeName.Model, AssetClassName.Lpm).forEach(function (l) {
  12314. r.push({
  12315. url: l.modelUrl,
  12316. group: l.className
  12317. });
  12318. }), ModelManager.findModels(o, AssetTypeName.Model, AssetClassName.Gbq).forEach(function (l) {
  12319. r.push({
  12320. url: l.modelUrl,
  12321. group: l.className
  12322. });
  12323. }), ModelManager.findModels(o, AssetTypeName.Model, AssetClassName.Tv).forEach(function (l) {
  12324. r.push({
  12325. url: l.modelUrl,
  12326. group: l.className
  12327. });
  12328. }), [].forEach(function (l) {
  12329. l.skinId == e.id && n.push(l);
  12330. }), {
  12331. roomId: this.room.id,
  12332. effects: t,
  12333. lowPolyModels: r,
  12334. breathPointsConfig: n,
  12335. skinId: e.id
  12336. };
  12337. }
  12338. }, {
  12339. key: "registerStats",
  12340. value: function registerStats() {
  12341. var _this5 = this;
  12342. var e = this.room.sceneManager;
  12343. this.room.scene.registerAfterRender(function () {
  12344. var I;
  12345. var t = e.statisticComponent.getInterFrameTimeCounter(),
  12346. r = e.statisticComponent.getDrawCall(),
  12347. n = e.statisticComponent.getActiveFaces(),
  12348. o = e.statisticComponent.getFrameTimeCounter(),
  12349. a = e.statisticComponent.getDrawCallTime(),
  12350. s = e.statisticComponent.getAnimationTime(),
  12351. l = e.statisticComponent.getActiveMeshEvaluationTime(),
  12352. u = e.statisticComponent.getRenderTargetRenderTime(),
  12353. c = e.statisticComponent.getRegisterBeforeRenderTime(),
  12354. h = e.statisticComponent.getRegisterAfterRenderTime(),
  12355. f = e.statisticComponent.getActiveParticles(),
  12356. d = e.statisticComponent.getActiveBones(),
  12357. _ = e.Scene._activeAnimatables.length,
  12358. g = e.statisticComponent.getTotalRootNodes(),
  12359. m = e.Scene.geometries.length,
  12360. v = e.Scene.onBeforeRenderObservable.observers.length,
  12361. y = e.Scene.onAfterRenderObservable.observers.length,
  12362. b = e.statisticComponent.getTotalMeshes(),
  12363. T = e.statisticComponent.getTotalTextures(),
  12364. C = e.statisticComponent.getTotalMaterials(),
  12365. A = e.statisticComponent.getSystemInfo(),
  12366. S = A.resolution,
  12367. P = A.driver;
  12368. A.vender;
  12369. var R = A.version,
  12370. M = A.hardwareScalingLevel,
  12371. x = S + "_" + P + "_" + R + "_" + M;
  12372. _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({
  12373. renderFrameTime: _this5.renderTimeCircularArray.getAvg(),
  12374. maxRenderFrameTime: _this5.renderTimeCircularArray.getMax(),
  12375. interFrameTime: _this5.interFrameCircularArray.getAvg(),
  12376. animationTime: _this5.animationCircularArray.getAvg(),
  12377. meshSelectTime: _this5.meshSelectCircularArray.getAvg(),
  12378. drawcallTime: _this5.drawCallTimeCircularArray.getAvg(),
  12379. idleTime: _this5._idleTime,
  12380. registerBeforeRenderTime: _this5.regBeforeRenderCircularArray.getAvg(),
  12381. registerAfterRenderTime: _this5.regAfterRenderCircularArray.getAvg(),
  12382. renderTargetRenderTime: _this5.renderTargetCircularArray.getAvg(),
  12383. fps: (1e3 / (_this5.renderTimeCircularArray.getAvg() + _this5.interFrameCircularArray.getAvg())).toFixed(2),
  12384. drawcall: _this5.drawCallCntCircularArray.getAvg(),
  12385. triangle: n.toString(),
  12386. engineSloppyCnt: _this5.engineSloppyCnt,
  12387. maxInterFrameTime: _this5.interFrameCircularArray.getMax(),
  12388. maxDrawcallTime: _this5.drawCallTimeCircularArray.getMax(),
  12389. maxMeshSelectTime: _this5.meshSelectCircularArray.getMax(),
  12390. maxAnimationTime: _this5.animationCircularArray.getMax(),
  12391. maxRegisterBeforeRenderTime: _this5.regBeforeRenderCircularArray.getMax(),
  12392. maxRegisterAfterRenderTime: _this5.regAfterRenderCircularArray.getMax(),
  12393. maxRenderTargetRenderTime: _this5.renderTargetCircularArray.getMax(),
  12394. activeParticles: f,
  12395. activeBones: d,
  12396. activeAnimation: _,
  12397. totalMeshes: b,
  12398. totalRootNodes: g,
  12399. totalGeometries: m,
  12400. totalTextures: T,
  12401. totalMaterials: C,
  12402. registerBeforeCount: v,
  12403. registerAfterCount: y,
  12404. hardwareInfo: x
  12405. }));
  12406. });
  12407. }
  12408. }, {
  12409. key: "updateBillboard",
  12410. value: function () {
  12411. var _updateBillboard = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee13() {
  12412. var e, r, n, o, a, s;
  12413. return regenerator.wrap(function _callee13$(_context13) {
  12414. while (1) {
  12415. switch (_context13.prev = _context13.next) {
  12416. case 0:
  12417. e = this.room.options.skinId;
  12418. _context13.next = 3;
  12419. return this.room.modelManager.findAssetList(e);
  12420. case 3:
  12421. r = _context13.sent.filter(function (a) {
  12422. return a.typeName === AssetTypeName.Textures && a.className === AssetClassName.SayBubble;
  12423. });
  12424. n = ["bubble01", "bubble02", "bubble03"];
  12425. o = ["bubble01_npc", "bubble02_npc", "bubble03_npc"];
  12426. if (r.length) {
  12427. a = r.filter(function (l) {
  12428. return n.includes(l.name);
  12429. }).map(function (l) {
  12430. return l.url;
  12431. }), s = r.filter(function (l) {
  12432. return o.includes(l.name);
  12433. }).map(function (l) {
  12434. return l.url;
  12435. });
  12436. a.length && (XBillboardManager.userBubbleUrls = a), s.length && (XBillboardManager.npcBubbleUrls = s);
  12437. }
  12438. case 7:
  12439. case "end":
  12440. return _context13.stop();
  12441. }
  12442. }
  12443. }, _callee13, this);
  12444. }));
  12445. function updateBillboard() {
  12446. return _updateBillboard.apply(this, arguments);
  12447. }
  12448. return updateBillboard;
  12449. }()
  12450. }]);
  12451. return EngineProxy;
  12452. }();
  12453. 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); }; }
  12454. 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; } }
  12455. var LongPressMesh = [EMeshType.XAvatar];
  12456. var StaticMeshEvent = /*#__PURE__*/function (_EventEmitter) {
  12457. _inherits(StaticMeshEvent, _EventEmitter);
  12458. var _super = _createSuper$2(StaticMeshEvent);
  12459. function StaticMeshEvent(e) {
  12460. var _this;
  12461. _classCallCheck(this, StaticMeshEvent);
  12462. _this = _super.call(this);
  12463. E(_assertThisInitialized(_this), "scene");
  12464. E(_assertThisInitialized(_this), "_staringPointerTime", -1);
  12465. E(_assertThisInitialized(_this), "_pickedMeshID", "0");
  12466. E(_assertThisInitialized(_this), "_pointerDownTime", -1);
  12467. E(_assertThisInitialized(_this), "_currentPickPoint");
  12468. E(_assertThisInitialized(_this), "_longPressDelay", 500);
  12469. E(_assertThisInitialized(_this), "_pointerTapDelay", 200);
  12470. E(_assertThisInitialized(_this), "_pickedMeshType");
  12471. E(_assertThisInitialized(_this), "registerEvent", function () {
  12472. _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 () {
  12473. _this.scene.onPrePointerObservable.removeCallback(_this.onUp), _this.scene.onPrePointerObservable.removeCallback(_this.onDown), _this.scene.onPrePointerObservable.removeCallback(_this.onDoubleTap);
  12474. };
  12475. });
  12476. E(_assertThisInitialized(_this), "onUp", function () {
  12477. if (Date.now() - _this._pointerDownTime < _this._pointerTapDelay && !_this.scene._inputManager._isPointerSwiping()) {
  12478. _this.scene._inputManager._totalPointersPressed = 0;
  12479. var _e = _this._currentPickPoint;
  12480. _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) {
  12481. return t.isPickable && LongPressMesh.indexOf(t.xtype) == -1;
  12482. }), _e != null && _this.emit("pointTap", _e));
  12483. }
  12484. });
  12485. E(_assertThisInitialized(_this), "onDown", function () {
  12486. var e = _this.onPointerTap(function (t) {
  12487. return t.isPickable;
  12488. });
  12489. _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 () {
  12490. e = _this.onPointerTap(function (t) {
  12491. return t.isPickable && t.xtype == _this._pickedMeshType && t.xid == _this._pickedMeshID;
  12492. }), e !== null && Date.now() - _this._staringPointerTime > _this._longPressDelay && !_this.scene._inputManager._isPointerSwiping() && _this.scene._inputManager._totalPointersPressed !== 0 && (_this._staringPointerTime = 0, _this.emit("longPress", e));
  12493. }, _this._longPressDelay));
  12494. });
  12495. E(_assertThisInitialized(_this), "onDoubleTap", function () {
  12496. var e = _this.onPointerTap(void 0);
  12497. e != null && _this.emit("pointDoubleTap", e);
  12498. });
  12499. _this.manager = e, _this.scene = e.Scene, _this.registerEvent(), _this._currentPickPoint = null, _this._pickedMeshType = null;
  12500. return _this;
  12501. }
  12502. _createClass(StaticMeshEvent, [{
  12503. key: "onPointerTap",
  12504. value: function onPointerTap(e) {
  12505. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !1;
  12506. var n, o;
  12507. var r = new BABYLON.PickingInfo();
  12508. if (t) {
  12509. var a = this.scene.multiPick(this.scene.pointerX, this.scene.pointerY, e, void 0, void 0);
  12510. a && a.length > 1 ? r = a[1] : a && (r = a[0]);
  12511. } else r = this.scene.pick(this.scene.pointerX, this.scene.pointerY, e, !1, null);
  12512. if (r.hit) {
  12513. var _a = (n = r == null ? void 0 : r.pickedPoint) == null ? void 0 : n.asArray();
  12514. if (_a) {
  12515. var _a2 = _slicedToArray(_a, 3),
  12516. s = _a2[0],
  12517. l = _a2[1],
  12518. u = _a2[2],
  12519. c = xversePosition2Ue4({
  12520. x: s,
  12521. y: l,
  12522. z: u
  12523. });
  12524. return {
  12525. name: (o = r.pickedMesh) == null ? void 0 : o.name,
  12526. type: r.pickedMesh.xtype,
  12527. id: r.pickedMesh.xid,
  12528. point: c
  12529. };
  12530. }
  12531. }
  12532. return null;
  12533. }
  12534. }]);
  12535. return StaticMeshEvent;
  12536. }(EventEmitter);
  12537. var RotationEvent = /*#__PURE__*/function () {
  12538. function RotationEvent(e) {
  12539. var _this = this;
  12540. _classCallCheck(this, RotationEvent);
  12541. E(this, "touchStartX");
  12542. E(this, "touchStartY");
  12543. E(this, "handelResize");
  12544. E(this, "_room");
  12545. E(this, "_canvas");
  12546. E(this, "handleTouchStart", function (e) {
  12547. var t = e.touches[0];
  12548. _this.touchStartX = t.pageX, _this.touchStartY = t.pageY, _this._room.emit("touchStart", {
  12549. event: e
  12550. });
  12551. });
  12552. E(this, "handleMouseDown", function (e) {
  12553. _this.touchStartX = e.pageX, _this.touchStartY = e.pageY;
  12554. });
  12555. E(this, "handleMouseMove", function (e) {
  12556. if (!_this.touchStartX || !_this.touchStartY) return;
  12557. var t = e.pageX,
  12558. r = e.pageY,
  12559. n = t - _this.touchStartX,
  12560. o = r - _this.touchStartY,
  12561. a = _this._room.options.canvas.offsetHeight,
  12562. s = _this._room.options.canvas.offsetWidth;
  12563. var l = 2 * o / a,
  12564. u = 2 * n / s;
  12565. l > 1 && (l = 1), u > 1 && (u = 1), _this._room.actionsHandler.rotate({
  12566. pitch: l,
  12567. yaw: u
  12568. }), _this.touchStartX = t, _this.touchStartY = r;
  12569. });
  12570. E(this, "handleMouseUp", function () {
  12571. _this.touchStartX = void 0, _this.touchStartY = void 0;
  12572. });
  12573. E(this, "handleTouchMove", function (e) {
  12574. if (!_this.touchStartX || !_this.touchStartY) return;
  12575. var t = e.touches[0],
  12576. r = t.pageX,
  12577. n = t.pageY,
  12578. o = r - _this.touchStartX,
  12579. a = n - _this.touchStartY,
  12580. s = _this._room.options.canvas.offsetHeight,
  12581. l = _this._room.options.canvas.offsetWidth;
  12582. var u = 2 * a / s,
  12583. c = 2 * o / l;
  12584. u > 1 && (u = 1), c > 1 && (c = 1), _this._room.actionsHandler.rotate({
  12585. pitch: u,
  12586. yaw: c
  12587. }), _this.touchStartX = r, _this.touchStartY = n, _this._room.emit("touchMove", {
  12588. pitch: u,
  12589. yaw: c,
  12590. event: e
  12591. });
  12592. });
  12593. E(this, "handleTouchEnd", function (e) {
  12594. _this._room.emit("touchEnd", {
  12595. event: e
  12596. });
  12597. });
  12598. this._room = e, this._canvas = e.canvas, this.handelResize = this.reiszeChange();
  12599. }
  12600. _createClass(RotationEvent, [{
  12601. key: "init",
  12602. value: function init() {
  12603. 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);
  12604. }
  12605. }, {
  12606. key: "clear",
  12607. value: function clear() {
  12608. 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);
  12609. }
  12610. }, {
  12611. key: "reiszeChange",
  12612. value: function reiszeChange() {
  12613. window.addEventListener("resize", function () {});
  12614. }
  12615. }]);
  12616. return RotationEvent;
  12617. }();
  12618. var EventsController = /*#__PURE__*/function () {
  12619. function EventsController(e) {
  12620. var _this = this;
  12621. _classCallCheck(this, EventsController);
  12622. E(this, "staticmeshEvent");
  12623. E(this, "rotationEvent");
  12624. E(this, "resize", function () {
  12625. _this.room.sceneManager.cameraComponent.cameraFovChange(_this.room.sceneManager.yuvInfo);
  12626. });
  12627. E(this, "clickEvent", function (e) {
  12628. var t = e.point,
  12629. r = e.name,
  12630. n = e.type,
  12631. o = e.id;
  12632. logger$1.debug("pointEvent", e), _this.room.proxyEvents("pointTap", {
  12633. point: t,
  12634. meshName: r,
  12635. type: n,
  12636. id: o
  12637. }), _this.room.proxyEvents("_coreClick", e);
  12638. });
  12639. E(this, "longPressEvent", function (e) {
  12640. _this.room.proxyEvents("_corePress", e);
  12641. });
  12642. E(this, "handleActionResponseTimeout", function (_ref) {
  12643. var e = _ref.error,
  12644. t = _ref.event;
  12645. _this.room.proxyEvents("actionResponseTimeout", {
  12646. error: e,
  12647. event: t
  12648. });
  12649. });
  12650. E(this, "handleNetworkStateChange", function (e) {
  12651. var t = e.state,
  12652. r = e.count;
  12653. t == "reconnecting" ? _this.room.proxyEvents("reconnecting", {
  12654. count: r || 1
  12655. }) : t === "reconnected" ? (_this.room.networkController.rtcp.workers.reset(), _this.room.proxyEvents("reconnected"), _this.room.afterReconnected()) : t === "disconnected" && _this.room.proxyEvents("disconnected");
  12656. });
  12657. this.room = e, this.staticmeshEvent = new StaticMeshEvent(this.room.sceneManager), this.rotationEvent = new RotationEvent(e);
  12658. }
  12659. _createClass(EventsController, [{
  12660. key: "bindEvents",
  12661. value: function bindEvents() {
  12662. 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);
  12663. }
  12664. }, {
  12665. key: "clearEvents",
  12666. value: function clearEvents() {
  12667. 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();
  12668. }
  12669. }]);
  12670. return EventsController;
  12671. }();
  12672. var Panorama = /*#__PURE__*/function () {
  12673. function Panorama(e) {
  12674. var _this = this;
  12675. _classCallCheck(this, Panorama);
  12676. E(this, "_actived", !1);
  12677. E(this, "handleReceivePanorama", /*#__PURE__*/function () {
  12678. var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e, t) {
  12679. var r, n, _this$room$currentSta, o, a, s, _ref2, l;
  12680. return regenerator.wrap(function _callee$(_context) {
  12681. while (1) {
  12682. switch (_context.prev = _context.next) {
  12683. case 0:
  12684. logger$1.warn("handle panorama", e.uuid, e.pos, e.finished);
  12685. r = {
  12686. data: e.data,
  12687. pose: {
  12688. position: e.pos
  12689. }
  12690. }, n = _this.room.sceneManager;
  12691. _this.room.networkController.rtcp.workers.changePanoMode(!0);
  12692. _context.next = 5;
  12693. return n.materialComponent.changePanoImg(0, r);
  12694. case 5:
  12695. if (!e.finished) {
  12696. _context.next = 23;
  12697. break;
  12698. }
  12699. _context.next = 8;
  12700. return n.changePanoShaderForLowModel(0);
  12701. case 8:
  12702. _this.room.isPano = !0;
  12703. _this._actived = !0;
  12704. if (!t) {
  12705. _context.next = 14;
  12706. break;
  12707. }
  12708. _this.room.sceneManager.cameraComponent.changeToFirstPersonView({
  12709. position: t.position,
  12710. rotation: t.angle
  12711. });
  12712. _context.next = 23;
  12713. break;
  12714. case 14:
  12715. _this$room$currentSta = _this.room.currentState, o = _this$room$currentSta.skinId, a = _this$room$currentSta.pathName;
  12716. if (!(!o || !a)) {
  12717. _context.next = 17;
  12718. break;
  12719. }
  12720. return _context.abrupt("return");
  12721. case 17:
  12722. _context.next = 19;
  12723. return _this.room.modelManager.findRoute(o, a);
  12724. case 19:
  12725. s = _context.sent;
  12726. _ref2 = util.getRandomItem(s.birthPointList) || {};
  12727. l = _ref2.camera;
  12728. l && _this.room.sceneManager.cameraComponent.changeToFirstPersonView(le(oe({}, l), {
  12729. rotation: l.angle
  12730. }));
  12731. case 23:
  12732. case "end":
  12733. return _context.stop();
  12734. }
  12735. }
  12736. }, _callee);
  12737. }));
  12738. return function (_x, _x2) {
  12739. return _ref.apply(this, arguments);
  12740. };
  12741. }());
  12742. this.room = e;
  12743. }
  12744. _createClass(Panorama, [{
  12745. key: "actived",
  12746. get: function get() {
  12747. return this._actived;
  12748. }
  12749. }, {
  12750. key: "bindListener",
  12751. value: function bindListener(e) {
  12752. var _this2 = this;
  12753. this.room.networkController.rtcp.workers.registerFunction("panorama", function (r) {
  12754. 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));
  12755. });
  12756. }
  12757. }, {
  12758. key: "access",
  12759. value: function access(e, t, r) {
  12760. var _this3 = this;
  12761. var n = e.camera,
  12762. o = e.player,
  12763. a = e.attitude,
  12764. s = e.areaName,
  12765. l = e.pathName,
  12766. u = e.tag;
  12767. return this.room.actionsHandler.requestPanorama({
  12768. camera: n,
  12769. player: o,
  12770. attitude: a,
  12771. areaName: s,
  12772. pathName: l,
  12773. tag: u
  12774. }, t, r).then(function (c) {
  12775. return _this3.handleReceivePanorama(c, o);
  12776. });
  12777. }
  12778. }, {
  12779. key: "exit",
  12780. value: function exit(e) {
  12781. var _this4 = this;
  12782. var t = e.camera,
  12783. r = e.player,
  12784. n = e.attitude,
  12785. o = e.areaName,
  12786. a = e.pathName;
  12787. return this.room.networkController.rtcp.workers.changePanoMode(!1), this.room.actionsHandler.changeRotationRenderType({
  12788. renderType: RenderType.RotationVideo,
  12789. player: r,
  12790. camera: t,
  12791. attitude: n,
  12792. areaName: o,
  12793. pathName: a
  12794. }).then(function () {
  12795. return _this4.handleExitPanorama();
  12796. }).catch(function (s) {
  12797. return _this4.room.networkController.rtcp.workers.changePanoMode(!0), Promise.reject(s);
  12798. });
  12799. }
  12800. }, {
  12801. key: "handleExitPanorama",
  12802. value: function handleExitPanorama() {
  12803. var e, t, r, n, o, a;
  12804. this.room.isPano = !1, this._actived = !1, (n = (e = this.room.sceneManager) == null ? void 0 : e.cameraComponent) == null || n.forceChangeSavedCameraPose({
  12805. position: (t = this.room._currentClickingState) == null ? void 0 : t.camera.position,
  12806. rotation: (r = this.room._currentClickingState) == null ? void 0 : r.camera.angle
  12807. }), this.room.sceneManager.changeVideoShaderForLowModel(), (a = (o = this.room.sceneManager) == null ? void 0 : o.cameraComponent) == null || a.changeToThirdPersonView();
  12808. }
  12809. }]);
  12810. return Panorama;
  12811. }();
  12812. 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); }; }
  12813. 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; } }
  12814. var Xverse_Room = /*#__PURE__*/function (_EventEmitter) {
  12815. _inherits(Xverse_Room, _EventEmitter);
  12816. var _super = _createSuper$1(Xverse_Room);
  12817. function Xverse_Room(e) {
  12818. var _this;
  12819. _classCallCheck(this, Xverse_Room);
  12820. _this = _super.call(this);
  12821. E(_assertThisInitialized(_this), "disableAutoTurn", !1);
  12822. E(_assertThisInitialized(_this), "options");
  12823. E(_assertThisInitialized(_this), "_currentNetworkOptions");
  12824. E(_assertThisInitialized(_this), "lastSkinId");
  12825. E(_assertThisInitialized(_this), "debug");
  12826. E(_assertThisInitialized(_this), "isFirstDataUsed", !1);
  12827. E(_assertThisInitialized(_this), "userId", null);
  12828. E(_assertThisInitialized(_this), "pathManager", new PathManager());
  12829. E(_assertThisInitialized(_this), "networkController");
  12830. E(_assertThisInitialized(_this), "_startTime", Date.now());
  12831. E(_assertThisInitialized(_this), "canvas");
  12832. E(_assertThisInitialized(_this), "modelManager");
  12833. E(_assertThisInitialized(_this), "eventsController");
  12834. E(_assertThisInitialized(_this), "panorama");
  12835. E(_assertThisInitialized(_this), "engineProxy");
  12836. E(_assertThisInitialized(_this), "_id");
  12837. E(_assertThisInitialized(_this), "skinList", []);
  12838. E(_assertThisInitialized(_this), "isHost", !1);
  12839. E(_assertThisInitialized(_this), "avatarManager", new XverseAvatarManager(_assertThisInitialized(_this)));
  12840. E(_assertThisInitialized(_this), "effectManager", new XverseEffectManager(_assertThisInitialized(_this)));
  12841. E(_assertThisInitialized(_this), "sceneManager");
  12842. E(_assertThisInitialized(_this), "scene");
  12843. E(_assertThisInitialized(_this), "breathPointManager");
  12844. E(_assertThisInitialized(_this), "_currentState");
  12845. E(_assertThisInitialized(_this), "joined", !1);
  12846. E(_assertThisInitialized(_this), "disableRotate", !1);
  12847. E(_assertThisInitialized(_this), "isPano", !1);
  12848. E(_assertThisInitialized(_this), "movingByClick", !0);
  12849. E(_assertThisInitialized(_this), "camera", new Camera(_assertThisInitialized(_this)));
  12850. E(_assertThisInitialized(_this), "stats", new Stats(_assertThisInitialized(_this)));
  12851. E(_assertThisInitialized(_this), "isUpdatedRawYUVData", !1);
  12852. E(_assertThisInitialized(_this), "actionsHandler", new ActionsHandler(_assertThisInitialized(_this)));
  12853. E(_assertThisInitialized(_this), "_currentClickingState", null);
  12854. E(_assertThisInitialized(_this), "signal", new Signal(_assertThisInitialized(_this)));
  12855. E(_assertThisInitialized(_this), "firstFrameTimestamp");
  12856. E(_assertThisInitialized(_this), "receiveRtcData", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
  12857. var e, t, r, n;
  12858. return regenerator.wrap(function _callee$(_context) {
  12859. while (1) {
  12860. switch (_context.prev = _context.next) {
  12861. case 0:
  12862. logger$1.info("Invoke receiveRtcData");
  12863. e = !1, t = !1, r = !1, n = !1;
  12864. return _context.abrupt("return", _this.viewMode === "serverless" ? (logger$1.warn("set view mode to serverless"), _this.setViewMode("observer").then(function () {
  12865. return _assertThisInitialized(_this);
  12866. }, function () {
  12867. return _assertThisInitialized(_this);
  12868. })) : new Promise(function (o) {
  12869. var a = _this.networkController.rtcp.workers;
  12870. a.registerFunction("signal", function (s) {
  12871. _this.signal.handleSignal(s);
  12872. }), a.registerFunction("stream", function (s) {
  12873. var l;
  12874. if (_this.emit("streamTimestamp", {
  12875. timestamp: Date.now()
  12876. }), t || (t = !0, logger$1.info("Invoke stream event")), s.stream) {
  12877. r || (r = !0, logger$1.info("Invoke updateRawYUVData")), _this.isUpdatedRawYUVData = !1;
  12878. var u = (l = _this._currentState.skin) == null ? void 0 : l.fov;
  12879. _this.sceneManager.materialComponent.updateRawYUVData(s.stream, s.width, s.height, u), _this.isUpdatedRawYUVData = !0;
  12880. }
  12881. e || (logger$1.info("Invoke isAfterRenderRegistered"), e = !0, _this.scene.registerAfterRender(function () {
  12882. _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()));
  12883. }));
  12884. }), _this.panorama.bindListener(function () {
  12885. o(_assertThisInitialized(_this)), _this.afterJoinRoom();
  12886. }), a.registerFunction("reconnectedFrame", function () {}), logger$1.info("Invoke decoderWorker.postMessage"), a.decoderWorker.postMessage({
  12887. t: 5
  12888. });
  12889. }));
  12890. case 3:
  12891. case "end":
  12892. return _context.stop();
  12893. }
  12894. }
  12895. }, _callee);
  12896. })));
  12897. E(_assertThisInitialized(_this), "moveToExtra", "");
  12898. _this.options = e, _this.options.wsServerUrl || (_this.options.wsServerUrl = SERVER_URLS.DEV), _this.modelManager = ModelManager.getInstance(e.appId, e.releaseId), _this.updateReporter();
  12899. var n = e;
  12900. n.canvas;
  12901. var r = Oe(n, ["canvas"]);
  12902. logger$1.infoAndReportMeasurement({
  12903. metric: "startJoinRoomAt",
  12904. startTime: Date.now(),
  12905. group: "joinRoom",
  12906. extra: r,
  12907. value: 0
  12908. });
  12909. return _this;
  12910. }
  12911. _createClass(Xverse_Room, [{
  12912. key: "currentNetworkOptions",
  12913. get: function get() {
  12914. return this._currentNetworkOptions;
  12915. }
  12916. }, {
  12917. key: "viewMode",
  12918. get: function get() {
  12919. var e;
  12920. return ((e = this._currentState) == null ? void 0 : e.viewMode) || "full";
  12921. }
  12922. }, {
  12923. key: "id",
  12924. get: function get() {
  12925. return this._id;
  12926. }
  12927. }, {
  12928. key: "skinId",
  12929. get: function get() {
  12930. return this._currentState.skinId;
  12931. }
  12932. }, {
  12933. key: "skin",
  12934. get: function get() {
  12935. return this._currentState.skin;
  12936. }
  12937. }, {
  12938. key: "sessionId",
  12939. get: function get() {
  12940. return this.currentNetworkOptions.sessionId;
  12941. }
  12942. }, {
  12943. key: "pictureQualityLevel",
  12944. get: function get() {
  12945. return this.currentState.pictureQualityLevel;
  12946. }
  12947. }, {
  12948. key: "avatars",
  12949. get: function get() {
  12950. return Array.from(this.avatarManager.avatars.values());
  12951. }
  12952. }, {
  12953. key: "currentState",
  12954. get: function get() {
  12955. var e;
  12956. return le(oe({}, this._currentState), {
  12957. state: (e = this.networkController) == null ? void 0 : e._state
  12958. });
  12959. }
  12960. }, {
  12961. key: "_userAvatar",
  12962. get: function get() {
  12963. var _this2 = this;
  12964. return this.avatars.find(function (e) {
  12965. return e.userId === _this2.userId;
  12966. });
  12967. }
  12968. }, {
  12969. key: "tvs",
  12970. get: function get() {
  12971. return this.engineProxy._tvs;
  12972. }
  12973. }, {
  12974. key: "tv",
  12975. get: function get() {
  12976. return this.tvs[0];
  12977. }
  12978. }, {
  12979. key: "currentClickingState",
  12980. get: function get() {
  12981. return this._currentClickingState;
  12982. }
  12983. }, {
  12984. key: "afterJoinRoomHook",
  12985. value: function afterJoinRoomHook() {}
  12986. }, {
  12987. key: "beforeJoinRoomResolveHook",
  12988. value: function beforeJoinRoomResolveHook() {}
  12989. }, {
  12990. key: "afterReconnectedHook",
  12991. value: function afterReconnectedHook() {}
  12992. }, {
  12993. key: "handleSignalHook",
  12994. value: function handleSignalHook(e) {}
  12995. }, {
  12996. key: "skinChangedHook",
  12997. value: function skinChangedHook() {}
  12998. }, {
  12999. key: "beforeStartGameHook",
  13000. value: function () {
  13001. var _beforeStartGameHook = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(e) {
  13002. return regenerator.wrap(function _callee2$(_context2) {
  13003. while (1) {
  13004. switch (_context2.prev = _context2.next) {
  13005. case 0:
  13006. case "end":
  13007. return _context2.stop();
  13008. }
  13009. }
  13010. }, _callee2);
  13011. }));
  13012. function beforeStartGameHook(_x) {
  13013. return _beforeStartGameHook.apply(this, arguments);
  13014. }
  13015. return beforeStartGameHook;
  13016. }()
  13017. }, {
  13018. key: "loadAssetsHook",
  13019. value: function loadAssetsHook() {}
  13020. }, {
  13021. key: "afterUserAvatarLoadedHook",
  13022. value: function afterUserAvatarLoadedHook() {}
  13023. }, {
  13024. key: "audienceViewModeHook",
  13025. value: function audienceViewModeHook() {}
  13026. }, {
  13027. key: "setViewModeToObserver",
  13028. value: function setViewModeToObserver() {}
  13029. }, {
  13030. key: "handleVehicleHook",
  13031. value: function handleVehicleHook(e) {}
  13032. }, {
  13033. key: "updateReporter",
  13034. value: function updateReporter() {
  13035. var _this$options = this.options,
  13036. e = _this$options.avatarId,
  13037. t = _this$options.skinId,
  13038. r = _this$options.userId,
  13039. n = _this$options.roomId,
  13040. o = _this$options.role,
  13041. a = _this$options.appId,
  13042. s = _this$options.wsServerUrl;
  13043. reporter$1.updateHeader({
  13044. userId: r
  13045. }), reporter$1.updateBody({
  13046. roomId: n,
  13047. role: o,
  13048. skinId: t,
  13049. avatarId: e,
  13050. appId: a,
  13051. wsServerUrl: s
  13052. });
  13053. }
  13054. }, {
  13055. key: "initRoom",
  13056. value: function () {
  13057. var _initRoom2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3() {
  13058. var _this$options$timeout, e;
  13059. return regenerator.wrap(function _callee3$(_context3) {
  13060. while (1) {
  13061. switch (_context3.prev = _context3.next) {
  13062. case 0:
  13063. _this$options$timeout = this.options.timeout, e = _this$options$timeout === void 0 ? DEFAULT_JOINROOM_TIMEOUT : _this$options$timeout;
  13064. if (!util.isSupported()) {
  13065. _context3.next = 5;
  13066. break;
  13067. }
  13068. return _context3.abrupt("return", this._initRoom()._timeout(e, new TimeoutError("initRoom timeout")));
  13069. case 5:
  13070. return _context3.abrupt("return", Promise.reject(new UnsupportedError()));
  13071. case 6:
  13072. case "end":
  13073. return _context3.stop();
  13074. }
  13075. }
  13076. }, _callee3, this);
  13077. }));
  13078. function initRoom() {
  13079. return _initRoom2.apply(this, arguments);
  13080. }
  13081. return initRoom;
  13082. }()
  13083. }, {
  13084. key: "_initRoom",
  13085. value: function () {
  13086. var _initRoom3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4() {
  13087. 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;
  13088. return regenerator.wrap(function _callee4$(_context4) {
  13089. while (1) {
  13090. switch (_context4.prev = _context4.next) {
  13091. case 0:
  13092. e = this.validateOptions(this.options);
  13093. if (!e) {
  13094. _context4.next = 3;
  13095. break;
  13096. }
  13097. return _context4.abrupt("return", (logger$1.error("initRoom param error", e), Promise.reject(e)));
  13098. case 3:
  13099. _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;
  13100. this.setCurrentNetworkOptions({
  13101. avatarId: r,
  13102. skinId: n,
  13103. roomId: R,
  13104. userId: o,
  13105. wsServerUrl: a,
  13106. role: s,
  13107. token: l,
  13108. pageSession: u,
  13109. rotationRenderType: c,
  13110. isAllSync: h,
  13111. appId: f,
  13112. camera: d,
  13113. player: _,
  13114. avatarComponents: g,
  13115. nickname: m,
  13116. avatarScale: v,
  13117. firends: y,
  13118. syncByEvent: b,
  13119. areaName: T,
  13120. attitude: C,
  13121. pathName: A,
  13122. person: P,
  13123. roomTypeId: M,
  13124. hasAvatar: x,
  13125. syncToOthers: I,
  13126. prioritySync: w,
  13127. extra: D,
  13128. removeWhenDisconnected: O
  13129. });
  13130. this.userId = o;
  13131. this.canvas = t;
  13132. T && (this.pathManager.currentArea = T);
  13133. this.networkController = new NetworkController(this);
  13134. this.setCurrentState({
  13135. areaName: T,
  13136. pathName: A,
  13137. attitude: C,
  13138. speed: 0,
  13139. viewMode: S,
  13140. state: this.networkController._state,
  13141. skinId: n
  13142. });
  13143. _context4.prev = 10;
  13144. _context4.next = 13;
  13145. return Promise.all([this.initNetwork(), this.initConfig(), this.initWasm()]);
  13146. case 13:
  13147. logger$1.info("network config wasm all ready, start to create game");
  13148. _context4.next = 16;
  13149. return this.requestCreateRoom({
  13150. skinId: n
  13151. });
  13152. case 16:
  13153. F = _context4.sent;
  13154. V = F.routeList.find(function (L) {
  13155. return L.areaName === T;
  13156. });
  13157. N = ((V == null ? void 0 : V.step) || 7.5) * 30;
  13158. this.updateCurrentState({
  13159. skin: F,
  13160. skinId: F.id,
  13161. versionId: F.versionId,
  13162. speed: N
  13163. });
  13164. _context4.next = 22;
  13165. return this.initEngine(F);
  13166. case 22:
  13167. _context4.next = 27;
  13168. break;
  13169. case 24:
  13170. _context4.prev = 24;
  13171. _context4.t0 = _context4["catch"](10);
  13172. return _context4.abrupt("return", Promise.reject(_context4.t0));
  13173. case 27:
  13174. return _context4.abrupt("return", (this.beforeJoinRoomResolve(), this.receiveRtcData()));
  13175. case 28:
  13176. case "end":
  13177. return _context4.stop();
  13178. }
  13179. }
  13180. }, _callee4, this, [[10, 24]]);
  13181. }));
  13182. function _initRoom() {
  13183. return _initRoom3.apply(this, arguments);
  13184. }
  13185. return _initRoom;
  13186. }()
  13187. }, {
  13188. key: "beforeJoinRoomResolve",
  13189. value: function beforeJoinRoomResolve() {
  13190. this.setupStats(), this.eventsController = new EventsController(this), this.eventsController.bindEvents(), this.panorama = new Panorama(this), this.beforeJoinRoomResolveHook();
  13191. }
  13192. }, {
  13193. key: "afterJoinRoom",
  13194. value: function afterJoinRoom() {
  13195. this.joined = !0, this.viewMode === "observer" && this.setViewModeToObserver(), logger$1.infoAndReportMeasurement({
  13196. tag: this.viewMode,
  13197. value: this.firstFrameTimestamp - this._startTime,
  13198. startTime: Date.now(),
  13199. metric: "joinRoom"
  13200. }), this.camera.initialFov = this.sceneManager.cameraComponent.getCameraFov(), this.stats.on("stats", function (_ref2) {
  13201. var e = _ref2.stats;
  13202. reporter$1.report("stats", oe({}, e));
  13203. }), this.debug = new Debug(this), this.afterJoinRoomHook();
  13204. }
  13205. }, {
  13206. key: "afterReconnected",
  13207. value: function afterReconnected() {
  13208. this.avatarManager.clearOtherUsers(), this.afterReconnectedHook();
  13209. }
  13210. }, {
  13211. key: "leave",
  13212. value: function leave() {
  13213. var e, t;
  13214. return logger$1.info("Invoke room.leave"), (e = this.eventsController) == null || e.clearEvents(), (t = this.networkController) == null || t.quit(), this;
  13215. }
  13216. }, {
  13217. key: "validateOptions",
  13218. value: function validateOptions(e) {
  13219. var _ref3 = e || {},
  13220. t = _ref3.canvas,
  13221. r = _ref3.avatarId,
  13222. n = _ref3.skinId,
  13223. o = _ref3.userId,
  13224. a = _ref3.role;
  13225. _ref3.roomId;
  13226. var l = _ref3.token,
  13227. u = _ref3.appId;
  13228. _ref3.avatarComponents;
  13229. var h = [];
  13230. t instanceof HTMLCanvasElement || h.push(new ParamError$1("`canvas` must be instanceof of HTMLCanvasElement"));
  13231. (!o || typeof o != "string") && h.push(new ParamError$1("`userId` must be string"));
  13232. (!l || typeof l != "string") && h.push(new ParamError$1("`token` must be string"));
  13233. (!u || typeof u != "string") && h.push(new ParamError$1("`appId` must be string"));
  13234. a == "audience" || (!r || !n) && h.push(new ParamError$1("`avatarId` and `skinId` is required when create room"));
  13235. return h[0];
  13236. }
  13237. }, {
  13238. key: "initNetwork",
  13239. value: function () {
  13240. var _initNetwork = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5() {
  13241. var e;
  13242. return regenerator.wrap(function _callee5$(_context5) {
  13243. while (1) {
  13244. switch (_context5.prev = _context5.next) {
  13245. case 0:
  13246. if (!(this.viewMode === "serverless")) {
  13247. _context5.next = 2;
  13248. break;
  13249. }
  13250. return _context5.abrupt("return", Promise.resolve());
  13251. case 2:
  13252. e = Date.now();
  13253. _context5.prev = 3;
  13254. _context5.next = 6;
  13255. return this.networkController.connect()._timeout(8e3, new InitNetworkTimeoutError());
  13256. case 6:
  13257. logger$1.infoAndReportMeasurement({
  13258. metric: "networkInitAt",
  13259. startTime: this._startTime,
  13260. group: "joinRoom"
  13261. });
  13262. logger$1.infoAndReportMeasurement({
  13263. metric: "networkInitCost",
  13264. startTime: e,
  13265. group: "joinRoom"
  13266. });
  13267. _context5.next = 13;
  13268. break;
  13269. case 10:
  13270. _context5.prev = 10;
  13271. _context5.t0 = _context5["catch"](3);
  13272. throw logger$1.infoAndReportMeasurement({
  13273. metric: "networkInitAt",
  13274. startTime: e,
  13275. group: "joinRoom",
  13276. error: _context5.t0
  13277. }), _context5.t0;
  13278. case 13:
  13279. case "end":
  13280. return _context5.stop();
  13281. }
  13282. }
  13283. }, _callee5, this, [[3, 10]]);
  13284. }));
  13285. function initNetwork() {
  13286. return _initNetwork.apply(this, arguments);
  13287. }
  13288. return initNetwork;
  13289. }()
  13290. }, {
  13291. key: "initConfig",
  13292. value: function () {
  13293. var _initConfig = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6() {
  13294. var e;
  13295. return regenerator.wrap(function _callee6$(_context6) {
  13296. while (1) {
  13297. switch (_context6.prev = _context6.next) {
  13298. case 0:
  13299. e = Date.now();
  13300. _context6.prev = 1;
  13301. _context6.next = 4;
  13302. return this.modelManager.getApplicationConfig()._timeout(8e3, new InitConfigTimeoutError());
  13303. case 4:
  13304. logger$1.infoAndReportMeasurement({
  13305. metric: "configInitAt",
  13306. startTime: this._startTime,
  13307. group: "joinRoom"
  13308. });
  13309. logger$1.infoAndReportMeasurement({
  13310. metric: "configInitCost",
  13311. startTime: e,
  13312. group: "joinRoom"
  13313. });
  13314. _context6.next = 11;
  13315. break;
  13316. case 8:
  13317. _context6.prev = 8;
  13318. _context6.t0 = _context6["catch"](1);
  13319. throw logger$1.infoAndReportMeasurement({
  13320. metric: "configInitAt",
  13321. startTime: e,
  13322. group: "joinRoom",
  13323. error: _context6.t0
  13324. }), _context6.t0;
  13325. case 11:
  13326. case "end":
  13327. return _context6.stop();
  13328. }
  13329. }
  13330. }, _callee6, this, [[1, 8]]);
  13331. }));
  13332. function initConfig() {
  13333. return _initConfig.apply(this, arguments);
  13334. }
  13335. return initConfig;
  13336. }()
  13337. }, {
  13338. key: "initEngine",
  13339. value: function () {
  13340. var _initEngine = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee7(e) {
  13341. var t, n;
  13342. return regenerator.wrap(function _callee7$(_context7) {
  13343. while (1) {
  13344. switch (_context7.prev = _context7.next) {
  13345. case 0:
  13346. t = Date.now();
  13347. _context7.prev = 1;
  13348. this.engineProxy = new EngineProxy(this);
  13349. _context7.next = 5;
  13350. return this.engineProxy.initEngine(e);
  13351. case 5:
  13352. logger$1.infoAndReportMeasurement({
  13353. metric: "webglInitAt",
  13354. startTime: this._startTime,
  13355. group: "joinRoom"
  13356. });
  13357. logger$1.infoAndReportMeasurement({
  13358. metric: "webglInitCost",
  13359. startTime: t,
  13360. group: "joinRoom"
  13361. });
  13362. return _context7.abrupt("return");
  13363. case 10:
  13364. _context7.prev = 10;
  13365. _context7.t0 = _context7["catch"](1);
  13366. n = _context7.t0;
  13367. return _context7.abrupt("return", (_context7.t0.code !== Codes.InitEngineTimeout && (n = new InitEngineError()), logger$1.error(_context7.t0), logger$1.infoAndReportMeasurement({
  13368. metric: "webglInitAt",
  13369. startTime: t,
  13370. group: "joinRoom",
  13371. error: n
  13372. }), Promise.reject(n)));
  13373. case 14:
  13374. case "end":
  13375. return _context7.stop();
  13376. }
  13377. }
  13378. }, _callee7, this, [[1, 10]]);
  13379. }));
  13380. function initEngine(_x2) {
  13381. return _initEngine.apply(this, arguments);
  13382. }
  13383. return initEngine;
  13384. }()
  13385. }, {
  13386. key: "initWasm",
  13387. value: function () {
  13388. var _initWasm = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee8() {
  13389. var _this3 = this;
  13390. var e;
  13391. return regenerator.wrap(function _callee8$(_context8) {
  13392. while (1) {
  13393. switch (_context8.prev = _context8.next) {
  13394. case 0:
  13395. if (!(this.viewMode === "serverless")) {
  13396. _context8.next = 2;
  13397. break;
  13398. }
  13399. return _context8.abrupt("return", Promise.resolve());
  13400. case 2:
  13401. e = Date.now();
  13402. _context8.prev = 3;
  13403. _context8.next = 6;
  13404. return this.networkController.rtcp.workers.init(this.options.resolution)._timeout(8e3, new InitDecoderTimeoutError());
  13405. case 6:
  13406. this.networkController.rtcp.workers.registerFunction("error", function (t) {
  13407. logger$1.error("decode error", t);
  13408. var r = t.code,
  13409. n = t.message;
  13410. _this3.emit("error", {
  13411. code: r,
  13412. msg: n
  13413. });
  13414. });
  13415. logger$1.infoAndReportMeasurement({
  13416. metric: "wasmInitAt",
  13417. group: "joinRoom",
  13418. startTime: this._startTime
  13419. });
  13420. logger$1.infoAndReportMeasurement({
  13421. metric: "wasmInitCost",
  13422. group: "joinRoom",
  13423. startTime: e
  13424. });
  13425. eventsManager.on("traceId", function (t) {
  13426. _this3.networkController.rtcp.workers.onTraceId(t);
  13427. });
  13428. _context8.next = 15;
  13429. break;
  13430. case 12:
  13431. _context8.prev = 12;
  13432. _context8.t0 = _context8["catch"](3);
  13433. throw logger$1.infoAndReportMeasurement({
  13434. metric: "wasmInitAt",
  13435. group: "joinRoom",
  13436. startTime: e,
  13437. error: _context8.t0
  13438. }), _context8.t0;
  13439. case 15:
  13440. case "end":
  13441. return _context8.stop();
  13442. }
  13443. }
  13444. }, _callee8, this, [[3, 12]]);
  13445. }));
  13446. function initWasm() {
  13447. return _initWasm.apply(this, arguments);
  13448. }
  13449. return initWasm;
  13450. }()
  13451. }, {
  13452. key: "requestCreateRoom",
  13453. value: function () {
  13454. var _requestCreateRoom = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee9(_ref4) {
  13455. var e, t, r, _ref5, n, o, _yield$this$networkCo, _r, _n, _o, a, s;
  13456. return regenerator.wrap(function _callee9$(_context9) {
  13457. while (1) {
  13458. switch (_context9.prev = _context9.next) {
  13459. case 0:
  13460. e = _ref4.skinId;
  13461. if (!e) {
  13462. _context9.next = 11;
  13463. break;
  13464. }
  13465. _context9.next = 4;
  13466. return this.getSkin(e);
  13467. case 4:
  13468. t = _context9.sent;
  13469. _context9.next = 7;
  13470. return this.modelManager.findRoute(e, this.options.pathName);
  13471. case 7:
  13472. r = _context9.sent;
  13473. this.updateCurrentNetworkOptions({
  13474. areaName: r.areaName,
  13475. attitude: r.attitude,
  13476. versionId: t.versionId
  13477. });
  13478. _ref5 = util.getRandomItem(r.birthPointList) || this.options, n = _ref5.camera, o = _ref5.player;
  13479. this.options.camera || this.updateCurrentNetworkOptions({
  13480. camera: n
  13481. }), this.options.player || this.updateCurrentNetworkOptions({
  13482. player: o
  13483. });
  13484. case 11:
  13485. if (!(this.viewMode === "serverless")) {
  13486. _context9.next = 13;
  13487. break;
  13488. }
  13489. return _context9.abrupt("return", t);
  13490. case 13:
  13491. _context9.prev = 13;
  13492. _context9.next = 16;
  13493. return this.beforeStartGameHook(this.options);
  13494. case 16:
  13495. _context9.next = 18;
  13496. return this.networkController.startGame();
  13497. case 18:
  13498. _yield$this$networkCo = _context9.sent;
  13499. _r = _yield$this$networkCo.room_id;
  13500. _n = _yield$this$networkCo.data;
  13501. _o = _yield$this$networkCo.session_id;
  13502. this._id = _r;
  13503. a = JSON.parse(_n);
  13504. this.isHost = a.IsHost, e = a.SkinID || e;
  13505. _context9.next = 27;
  13506. return this.getSkin(e);
  13507. case 27:
  13508. s = _context9.sent;
  13509. return _context9.abrupt("return", (this.updateCurrentNetworkOptions({
  13510. roomId: _r,
  13511. sessionId: _o
  13512. }), reporter$1.updateBody({
  13513. roomId: _r,
  13514. skinId: e,
  13515. serverSession: _o
  13516. }), s));
  13517. case 31:
  13518. _context9.prev = 31;
  13519. _context9.t0 = _context9["catch"](13);
  13520. throw logger$1.error("Request create room error", _context9.t0), _context9.t0;
  13521. case 34:
  13522. case "end":
  13523. return _context9.stop();
  13524. }
  13525. }
  13526. }, _callee9, this, [[13, 31]]);
  13527. }));
  13528. function requestCreateRoom(_x3) {
  13529. return _requestCreateRoom.apply(this, arguments);
  13530. }
  13531. return requestCreateRoom;
  13532. }()
  13533. }, {
  13534. key: "pause",
  13535. value: function pause() {
  13536. return this.engineProxy.pause();
  13537. }
  13538. }, {
  13539. key: "resume",
  13540. value: function resume() {
  13541. return this.engineProxy.resume();
  13542. }
  13543. }, {
  13544. key: "reconnect",
  13545. value: function reconnect() {
  13546. this.networkController.reconnect();
  13547. }
  13548. }, {
  13549. key: "setViewMode",
  13550. value: function () {
  13551. var _setViewMode = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee10(e) {
  13552. return regenerator.wrap(function _callee10$(_context10) {
  13553. while (1) {
  13554. switch (_context10.prev = _context10.next) {
  13555. case 0:
  13556. case "end":
  13557. return _context10.stop();
  13558. }
  13559. }
  13560. }, _callee10);
  13561. }));
  13562. function setViewMode(_x4) {
  13563. return _setViewMode.apply(this, arguments);
  13564. }
  13565. return setViewMode;
  13566. }()
  13567. }, {
  13568. key: "handleRepetLogin",
  13569. value: function handleRepetLogin() {
  13570. logger$1.warn("receive " + Codes.RepeatLogin + " for repeat login"), this.emit("repeatLogin"), reporter$1.disable(), this.networkController.quit();
  13571. }
  13572. }, {
  13573. key: "setPictureQualityLevel",
  13574. value: function setPictureQualityLevel(e) {
  13575. var t = {
  13576. high: EImageQuality.high,
  13577. low: EImageQuality.low,
  13578. average: EImageQuality.mid
  13579. };
  13580. return this.updateCurrentState({
  13581. pictureQualityLevel: e
  13582. }), this.sceneManager.setImageQuality(t[e]);
  13583. }
  13584. }, {
  13585. key: "getSkin",
  13586. value: function () {
  13587. var _getSkin = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee11(e) {
  13588. var t, n;
  13589. return regenerator.wrap(function _callee11$(_context11) {
  13590. while (1) {
  13591. switch (_context11.prev = _context11.next) {
  13592. case 0:
  13593. t = null;
  13594. _context11.next = 3;
  13595. return this.modelManager.getSkinsList();
  13596. case 3:
  13597. t = (this.skinList = _context11.sent).find(function (n) {
  13598. return n.id === e || n.id === e;
  13599. });
  13600. if (!t) {
  13601. _context11.next = 6;
  13602. break;
  13603. }
  13604. return _context11.abrupt("return", t);
  13605. case 6:
  13606. n = "skin is invalid: skinId: ".concat(e);
  13607. return _context11.abrupt("return", Promise.reject(new ParamError$1(n)));
  13608. case 8:
  13609. case "end":
  13610. return _context11.stop();
  13611. }
  13612. }
  13613. }, _callee11, this);
  13614. }));
  13615. function getSkin(_x5) {
  13616. return _getSkin.apply(this, arguments);
  13617. }
  13618. return getSkin;
  13619. }()
  13620. }, {
  13621. key: "setupStats",
  13622. value: function setupStats() {
  13623. this.stats.assign({
  13624. roomId: this.id,
  13625. userId: this.userId
  13626. }), setInterval(this.engineProxy.updateStats, 1e3);
  13627. }
  13628. }, {
  13629. key: "proxyEvents",
  13630. value: function proxyEvents(e, t) {
  13631. this.emit(e, t);
  13632. }
  13633. }, {
  13634. key: "setCurrentNetworkOptions",
  13635. value: function setCurrentNetworkOptions(e) {
  13636. this._currentNetworkOptions = e;
  13637. }
  13638. }, {
  13639. key: "updateCurrentNetworkOptions",
  13640. value: function updateCurrentNetworkOptions(e) {
  13641. Object.assign(this._currentNetworkOptions, e), Object.assign(this.options, e);
  13642. }
  13643. }, {
  13644. key: "setCurrentState",
  13645. value: function setCurrentState(e) {
  13646. this._currentState = e;
  13647. }
  13648. }, {
  13649. key: "updateCurrentState",
  13650. value: function updateCurrentState(e) {
  13651. e.skinId && (this.lastSkinId = this.currentState.skinId, this.updateCurrentNetworkOptions({
  13652. skinId: e.skinId
  13653. })), e.versionId && this.updateCurrentNetworkOptions({
  13654. versionId: e.versionId
  13655. }), Object.assign(this._currentState, e);
  13656. }
  13657. }]);
  13658. return Xverse_Room;
  13659. }(EventEmitter);
  13660. 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); }; }
  13661. 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; } }
  13662. var XverseRoom = /*#__PURE__*/function (_Xverse_Room) {
  13663. _inherits(XverseRoom, _Xverse_Room);
  13664. var _super = _createSuper(XverseRoom);
  13665. function XverseRoom(e) {
  13666. var _this;
  13667. _classCallCheck(this, XverseRoom);
  13668. _this = _super.call(this, e);
  13669. _this.joyStick = new JoyStick(_assertThisInitialized(_this));
  13670. return _this;
  13671. }
  13672. _createClass(XverseRoom, [{
  13673. key: "afterJoinRoomHook",
  13674. value: function afterJoinRoomHook() {
  13675. this.joyStick.init({});
  13676. }
  13677. }]);
  13678. return XverseRoom;
  13679. }(Xverse_Room);
  13680. var Preload = /*#__PURE__*/function () {
  13681. function Preload(e) {
  13682. _classCallCheck(this, Preload);
  13683. this.config = null;
  13684. this.allKeys = [];
  13685. this.oldResourcesDeleted = !1;
  13686. this.requests = {
  13687. simple: {
  13688. stopped: !0,
  13689. requests: {}
  13690. },
  13691. observer: {
  13692. stopped: !0,
  13693. requests: {}
  13694. },
  13695. full: {
  13696. stopped: !0,
  13697. requests: {}
  13698. }
  13699. };
  13700. this.modelManager = e, this.init(e.appId);
  13701. }
  13702. _createClass(Preload, [{
  13703. key: "init",
  13704. value: function init(e) {
  13705. reporter$1.updateBody({
  13706. appId: e
  13707. });
  13708. }
  13709. }, {
  13710. key: "getConfig",
  13711. value: function () {
  13712. var _getConfig = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  13713. var _yield$this$modelMana, t;
  13714. return regenerator.wrap(function _callee$(_context) {
  13715. while (1) {
  13716. switch (_context.prev = _context.next) {
  13717. case 0:
  13718. if (!this.config) {
  13719. _context.next = 2;
  13720. break;
  13721. }
  13722. return _context.abrupt("return", this.config);
  13723. case 2:
  13724. _context.next = 4;
  13725. return this.modelManager.requestConfig();
  13726. case 4:
  13727. _yield$this$modelMana = _context.sent;
  13728. t = _yield$this$modelMana.preload;
  13729. return _context.abrupt("return", t ? (this.config = t, Promise.resolve(t)) : Promise.reject("no preload config"));
  13730. case 7:
  13731. case "end":
  13732. return _context.stop();
  13733. }
  13734. }
  13735. }, _callee, this);
  13736. }));
  13737. function getConfig(_x) {
  13738. return _getConfig.apply(this, arguments);
  13739. }
  13740. return getConfig;
  13741. }()
  13742. }, {
  13743. key: "getAllKeys",
  13744. value: function () {
  13745. var _getAllKeys = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
  13746. var e, t;
  13747. return regenerator.wrap(function _callee2$(_context2) {
  13748. while (1) {
  13749. switch (_context2.prev = _context2.next) {
  13750. case 0:
  13751. if (!this.allKeys.length) {
  13752. _context2.next = 2;
  13753. break;
  13754. }
  13755. return _context2.abrupt("return", this.allKeys);
  13756. case 2:
  13757. _context2.prev = 2;
  13758. _context2.next = 5;
  13759. return modelTable.getAllKeys();
  13760. case 5:
  13761. e = _context2.sent;
  13762. this.allKeys = e;
  13763. return _context2.abrupt("return", e);
  13764. case 10:
  13765. _context2.prev = 10;
  13766. _context2.t0 = _context2["catch"](2);
  13767. t = "preload getAllKeys error";
  13768. return _context2.abrupt("return", (logger$1.error(t), Promise.reject(t)));
  13769. case 14:
  13770. case "end":
  13771. return _context2.stop();
  13772. }
  13773. }
  13774. }, _callee2, this, [[2, 10]]);
  13775. }));
  13776. function getAllKeys() {
  13777. return _getAllKeys.apply(this, arguments);
  13778. }
  13779. return getAllKeys;
  13780. }()
  13781. }, {
  13782. key: "stop",
  13783. value: function stop(e) {
  13784. e === "serverless" && (e = "observer"), this.requests[e].stopped = !0;
  13785. var t = this.requests[e].requests;
  13786. Object.keys(t).forEach(function (r) {
  13787. http1.canceler.removePending(r), delete t[r];
  13788. });
  13789. }
  13790. }, {
  13791. key: "clearPreload",
  13792. value: function clearPreload(e) {
  13793. this.requests[e].stopped = !1, this.allKeys = [];
  13794. }
  13795. }, {
  13796. key: "start",
  13797. value: function () {
  13798. var _start = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e, t, r) {
  13799. var n, o, a, s, l, u, h, f, _s;
  13800. return regenerator.wrap(function _callee3$(_context3) {
  13801. while (1) {
  13802. switch (_context3.prev = _context3.next) {
  13803. case 0:
  13804. n = Date.now(), o = 0;
  13805. _context3.prev = 1;
  13806. if (!(e === "serverless" && (e = "observer"), !this.requests[e])) {
  13807. _context3.next = 4;
  13808. break;
  13809. }
  13810. return _context3.abrupt("return", Promise.reject(new ParamError("invalid stage name: " + e)));
  13811. case 4:
  13812. this.clearPreload(e);
  13813. _context3.next = 7;
  13814. return this.getConfig(e);
  13815. case 7:
  13816. a = _context3.sent;
  13817. _context3.next = 10;
  13818. return this.getAllKeys();
  13819. case 10:
  13820. s = _context3.sent;
  13821. _context3.prev = 11;
  13822. _context3.next = 14;
  13823. return this.deleteOldResources(a.assetUrls.map(function (d) {
  13824. return d.url;
  13825. }), s);
  13826. case 14:
  13827. _context3.next = 19;
  13828. break;
  13829. case 16:
  13830. _context3.prev = 16;
  13831. _context3.t0 = _context3["catch"](11);
  13832. logger$1.error(_context3.t0);
  13833. case 19:
  13834. l = a.baseUrls, u = a.assetUrls;
  13835. _context3.t1 = e;
  13836. _context3.next = _context3.t1 === "simple" ? 23 : _context3.t1 === "observer" ? 25 : _context3.t1 === "full" ? 27 : 29;
  13837. break;
  13838. case 23:
  13839. h = l;
  13840. return _context3.abrupt("break", 30);
  13841. case 25:
  13842. h = u;
  13843. return _context3.abrupt("break", 30);
  13844. case 27:
  13845. h = u;
  13846. return _context3.abrupt("break", 30);
  13847. case 29:
  13848. h = u;
  13849. case 30:
  13850. f = h.filter(function (d) {
  13851. return !s.includes(d.url);
  13852. });
  13853. r && isFunction(r) && (f = f.filter(r));
  13854. o = f.length;
  13855. logger$1.debug("keysNeedToPreload", f);
  13856. f.length || t && t(h.length, h.length);
  13857. n = Date.now();
  13858. _context3.next = 38;
  13859. return this._preload(e, f, t);
  13860. case 38:
  13861. logger$1.infoAndReportMeasurement({
  13862. tag: e,
  13863. startTime: n,
  13864. metric: "assetsPreload",
  13865. extra: {
  13866. total: o
  13867. }
  13868. });
  13869. return _context3.abrupt("return");
  13870. case 42:
  13871. _context3.prev = 42;
  13872. _context3.t2 = _context3["catch"](1);
  13873. _s = _context3.t2;
  13874. return _context3.abrupt("return", ((this.requests[e].stopped || axios.isCancel(_context3.t2)) && (_s = new PreloadCanceledError()), logger$1.infoAndReportMeasurement({
  13875. tag: e,
  13876. startTime: n,
  13877. metric: "assetsPreload",
  13878. extra: {
  13879. total: o
  13880. },
  13881. error: _s,
  13882. reportOptions: {
  13883. immediate: !0
  13884. }
  13885. }), Promise.reject(_s)));
  13886. case 46:
  13887. case "end":
  13888. return _context3.stop();
  13889. }
  13890. }
  13891. }, _callee3, this, [[1, 42], [11, 16]]);
  13892. }));
  13893. function start(_x2, _x3, _x4) {
  13894. return _start.apply(this, arguments);
  13895. }
  13896. return start;
  13897. }()
  13898. }, {
  13899. key: "deleteOldResources",
  13900. value: function deleteOldResources(e, t) {
  13901. if (!this.oldResourcesDeleted) this.oldResourcesDeleted = !0;else return Promise.resolve();
  13902. var r = t.filter(function (n) {
  13903. return !e.includes(n);
  13904. });
  13905. return logger$1.debug("keysNeedToDelete", r), logger$1.warn("keysNeedToDelete", r.length), Promise.all(r.map(function (n) {
  13906. return modelTable.delete(n);
  13907. }));
  13908. }
  13909. }, {
  13910. key: "_preload",
  13911. value: function () {
  13912. var _preload2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6(e, t, r) {
  13913. var _this = this;
  13914. var n, o, a;
  13915. return regenerator.wrap(function _callee6$(_context6) {
  13916. while (1) {
  13917. switch (_context6.prev = _context6.next) {
  13918. case 0:
  13919. n = t.length;
  13920. if (n) {
  13921. _context6.next = 3;
  13922. break;
  13923. }
  13924. return _context6.abrupt("return", Promise.resolve());
  13925. case 3:
  13926. o = 0;
  13927. a = window.setInterval(function () {
  13928. r && r(o, n), o >= n && window.clearInterval(a);
  13929. }, 1e3);
  13930. return _context6.abrupt("return", util.mapLimit(t, 10, /*#__PURE__*/function () {
  13931. var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(s) {
  13932. var l, u;
  13933. return regenerator.wrap(function _callee5$(_context5) {
  13934. while (1) {
  13935. switch (_context5.prev = _context5.next) {
  13936. case 0:
  13937. l = s.size, u = s.url;
  13938. return _context5.abrupt("return", _this.requests[e].stopped ? Promise.reject(new PreloadCanceledError()) : http1.get({
  13939. url: u,
  13940. timeout: Preload.getTimeoutBySize(l),
  13941. responseType: "blob",
  13942. retry: 2,
  13943. beforeRequest: function beforeRequest() {
  13944. _this.requests[e].requests[u] = !0;
  13945. }
  13946. }).then( /*#__PURE__*/function () {
  13947. var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(c) {
  13948. var h, f;
  13949. return regenerator.wrap(function _callee4$(_context4) {
  13950. while (1) {
  13951. switch (_context4.prev = _context4.next) {
  13952. case 0:
  13953. h = c.data;
  13954. if (h instanceof Blob) {
  13955. _context4.next = 3;
  13956. break;
  13957. }
  13958. return _context4.abrupt("return", (logger$1.error("request blob failed, type:", typeof h, u), Promise.reject("request blob failed " + u)));
  13959. case 3:
  13960. _context4.next = 5;
  13961. return blobToDataURI(h);
  13962. case 5:
  13963. f = _context4.sent;
  13964. _context4.prev = 6;
  13965. _context4.next = 9;
  13966. return modelTable.put({
  13967. url: u,
  13968. model: f
  13969. });
  13970. case 9:
  13971. return _context4.abrupt("return");
  13972. case 12:
  13973. _context4.prev = 12;
  13974. _context4.t0 = _context4["catch"](6);
  13975. return _context4.abrupt("return", (logger$1.error("unable to add data to indexedDB", _context4.t0), Promise.reject(new InternalError("preload db error"))));
  13976. case 15:
  13977. case "end":
  13978. return _context4.stop();
  13979. }
  13980. }
  13981. }, _callee4, null, [[6, 12]]);
  13982. }));
  13983. return function (_x9) {
  13984. return _ref2.apply(this, arguments);
  13985. };
  13986. }()).then(function () {
  13987. o++, delete _this.requests[e].requests[u];
  13988. }, function (c) {
  13989. return delete _this.requests[e].requests[u], window.clearInterval(a), Promise.reject(c);
  13990. }));
  13991. case 2:
  13992. case "end":
  13993. return _context5.stop();
  13994. }
  13995. }
  13996. }, _callee5);
  13997. }));
  13998. return function (_x8) {
  13999. return _ref.apply(this, arguments);
  14000. };
  14001. }()));
  14002. case 6:
  14003. case "end":
  14004. return _context6.stop();
  14005. }
  14006. }
  14007. }, _callee6);
  14008. }));
  14009. function _preload(_x5, _x6, _x7) {
  14010. return _preload2.apply(this, arguments);
  14011. }
  14012. return _preload;
  14013. }()
  14014. }], [{
  14015. key: "getTimeoutBySize",
  14016. value: function getTimeoutBySize(e) {
  14017. return e ? e < 500 * 1e3 ? 30 * 1e3 : e < 1e3 * 1e3 ? 60 * 1e3 : 100 * 1e3 : 100 * 1e3;
  14018. }
  14019. }]);
  14020. return Preload;
  14021. }();
  14022. var RenderType$1 = {
  14023. PathVideo: 0,
  14024. RotationVideo: 1,
  14025. RotationImage: 2,
  14026. PanoramaImage: 3,
  14027. CGVideo: 4,
  14028. ClientRotationPano: 5,
  14029. CloudRotationPano: 6
  14030. };
  14031. var Xverse = /*#__PURE__*/function () {
  14032. function Xverse(e) {
  14033. _classCallCheck(this, Xverse);
  14034. e || (e = {});
  14035. var _e = e,
  14036. t = _e.onLog,
  14037. r = _e.env,
  14038. n = _e.appId,
  14039. o = _e.releaseId,
  14040. a = _e.subPackageVersion;
  14041. this.NO_CACHE = !1, this.env = r || "PROD", this.SUB_PACKAGE_VERSION = a, this.debug && logger$1.setLevel(LoggerLevels.Debug);
  14042. var s = this.pageSession = util.uuid();
  14043. reporter$1.updateHeader({
  14044. pageSession: s
  14045. });
  14046. reporter$1.updateReportUrl(REPORT_URL[this.env]);
  14047. a && reporter$1.updateBody({
  14048. sdkVersion: a
  14049. });
  14050. logger$1.infoAndReportMeasurement({
  14051. metric: "sdkInit",
  14052. startTime: Date.now(),
  14053. extra: {
  14054. version: a,
  14055. enviroment: r,
  14056. pageSession: s
  14057. }
  14058. });
  14059. logger$1.debug("debug mode:", this.debug);
  14060. reporter$1.on("report", function (l) {
  14061. t && t(l);
  14062. });
  14063. if (n) {
  14064. this.appId = n, this.releaseId = o;
  14065. var l = ModelManager.getInstance(n, o);
  14066. this.preload = new Preload(l);
  14067. }
  14068. }
  14069. _createClass(Xverse, [{
  14070. key: "isSupported",
  14071. get: function get() {
  14072. return isSupported();
  14073. }
  14074. }, {
  14075. key: "disableLogUpload",
  14076. value: function disableLogUpload() {
  14077. reporter$1.disable(), logger$1.debug("logger upload has been disabled");
  14078. }
  14079. }, {
  14080. key: "getSkinList",
  14081. value: function () {
  14082. var _getSkinList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
  14083. return regenerator.wrap(function _callee$(_context) {
  14084. while (1) {
  14085. switch (_context.prev = _context.next) {
  14086. case 0:
  14087. return _context.abrupt("return", []);
  14088. case 1:
  14089. case "end":
  14090. return _context.stop();
  14091. }
  14092. }
  14093. }, _callee);
  14094. }));
  14095. function getSkinList() {
  14096. return _getSkinList.apply(this, arguments);
  14097. }
  14098. return getSkinList;
  14099. }()
  14100. }, {
  14101. key: "getAvatarList",
  14102. value: function () {
  14103. var _getAvatarList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
  14104. return regenerator.wrap(function _callee2$(_context2) {
  14105. while (1) {
  14106. switch (_context2.prev = _context2.next) {
  14107. case 0:
  14108. return _context2.abrupt("return", []);
  14109. case 1:
  14110. case "end":
  14111. return _context2.stop();
  14112. }
  14113. }
  14114. }, _callee2);
  14115. }));
  14116. function getAvatarList() {
  14117. return _getAvatarList.apply(this, arguments);
  14118. }
  14119. return getAvatarList;
  14120. }()
  14121. }, {
  14122. key: "getGiftList",
  14123. value: function () {
  14124. var _getGiftList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3() {
  14125. return regenerator.wrap(function _callee3$(_context3) {
  14126. while (1) {
  14127. switch (_context3.prev = _context3.next) {
  14128. case 0:
  14129. return _context3.abrupt("return", [{
  14130. id: "hack "
  14131. }]);
  14132. case 1:
  14133. case "end":
  14134. return _context3.stop();
  14135. }
  14136. }
  14137. }, _callee3);
  14138. }));
  14139. function getGiftList() {
  14140. return _getGiftList.apply(this, arguments);
  14141. }
  14142. return getGiftList;
  14143. }()
  14144. }, {
  14145. key: "joinRoom",
  14146. value: function () {
  14147. var _joinRoom = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(e) {
  14148. var t, r, n, o;
  14149. return regenerator.wrap(function _callee4$(_context4) {
  14150. while (1) {
  14151. switch (_context4.prev = _context4.next) {
  14152. case 0:
  14153. t = e.pathName || "thirdwalk", r = e.rotationRenderType || RenderType$1.RotationVideo, n = e.person || Person$1.Third, o = new XverseRoom(le(oe({}, e), {
  14154. appId: e.appId || this.appId,
  14155. releaseId: e.releaseId || this.releaseId,
  14156. pageSession: this.pageSession,
  14157. isAllSync: !0,
  14158. rotationRenderType: r,
  14159. syncByEvent: !0,
  14160. pathName: t,
  14161. person: n,
  14162. role: e.role || "audience"
  14163. }));
  14164. return _context4.abrupt("return", o.initRoom().then(function () {
  14165. return o;
  14166. }));
  14167. case 2:
  14168. case "end":
  14169. return _context4.stop();
  14170. }
  14171. }
  14172. }, _callee4, this);
  14173. }));
  14174. function joinRoom(_x) {
  14175. return _joinRoom.apply(this, arguments);
  14176. }
  14177. return joinRoom;
  14178. }()
  14179. }]);
  14180. return Xverse;
  14181. }();
  14182. var xverse = new Xverse({
  14183. env: "DEV",
  14184. appId: "10016",
  14185. releaseId: '2203120033_29769e'
  14186. });
  14187. var l = /*#__PURE__*/function () {
  14188. var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
  14189. var R;
  14190. return regenerator.wrap(function _callee$(_context) {
  14191. while (1) {
  14192. switch (_context.prev = _context.next) {
  14193. case 0:
  14194. _context.prev = 0;
  14195. _context.next = 3;
  14196. return (R = xverse.preload) == null ? void 0 : R.start('full', function (M, x) {
  14197. });
  14198. case 3:
  14199. _context.next = 12;
  14200. break;
  14201. case 5:
  14202. _context.prev = 5;
  14203. _context.t0 = _context["catch"](0);
  14204. if (!(console.error(_context.t0), _context.t0.code === Codes.PreloadCanceled)) {
  14205. _context.next = 10;
  14206. break;
  14207. }
  14208. toast("\u9884\u52A0\u8F7D\u88AB\u53D6\u6D88");
  14209. return _context.abrupt("return");
  14210. case 10:
  14211. toast("\u8FDB\u5165\u5931\u8D25, \u8BF7\u91CD\u8BD5");
  14212. return _context.abrupt("return");
  14213. case 12:
  14214. _context.prev = 12;
  14215. _context.next = 15;
  14216. return xverse.joinRoom({
  14217. canvas: document.getElementById('canvas'),
  14218. skinId: '10092',
  14219. avatarId: 'KGe_Boy',
  14220. roomId: 'e629ef3e-022d-4e64-8654-703bb96410eb',
  14221. userId: '1f7acca1db9d5',
  14222. wsServerUrl: 'wss://uat-eks.xverse.cn/ws',
  14223. appId: "10016",
  14224. token: " ",
  14225. nickname: '1f7acca1db9d5',
  14226. firends: ["user1"],
  14227. viewMode: "full",
  14228. resolution: {
  14229. width: 1728,
  14230. height: 720
  14231. },
  14232. pathName: 'thirdwalk',
  14233. objectFit: null,
  14234. hasAvatar: !0,
  14235. syncToOthers: !0
  14236. });
  14237. case 15:
  14238. room = _context.sent;
  14239. debugger;
  14240. u();
  14241. c();
  14242. window.room = room;
  14243. e(!1);
  14244. _context.next = 28;
  14245. break;
  14246. case 23:
  14247. _context.prev = 23;
  14248. _context.t1 = _context["catch"](12);
  14249. console.error(_context.t1);
  14250. alert(_context.t1);
  14251. return _context.abrupt("return");
  14252. case 28:
  14253. case "end":
  14254. return _context.stop();
  14255. }
  14256. }
  14257. }, _callee, null, [[0, 5], [12, 23]]);
  14258. }));
  14259. return function l() {
  14260. return _ref.apply(this, arguments);
  14261. };
  14262. }();
  14263. var u = function u() {
  14264. room.on("_coreClick", function (_ref2) {
  14265. var f = _ref2.point;
  14266. room._userAvatar.moveTo({
  14267. point: f
  14268. });
  14269. });
  14270. };
  14271. var c = function c() {
  14272. room.on("repeatLogin", function () {
  14273. toast("\u8BE5\u7528\u6237\u5DF2\u7ECF\u5728\u5176\u4ED6\u5730\u70B9\u767B\u5F55", {
  14274. duration: 1e4
  14275. });
  14276. }), room.on("reconnecting", function (_ref3) {
  14277. var f = _ref3.count;
  14278. toast("\u5C1D\u8BD5\u7B2C".concat(f, "\u6B21\u91CD\u8FDE"));
  14279. }), room.on("reconnected", function () {
  14280. toast("\u91CD\u8FDE\u6210\u529F");
  14281. }), room.on("disconnected", function () {
  14282. var f = toast("\u8FDE\u63A5\u5931\u8D25\uFF0C\u624B\u52A8\u70B9\u51FB\u91CD\u8BD5", {
  14283. duration: 1e5,
  14284. onClick() {
  14285. f.hideToast(), room.reconnect();
  14286. }
  14287. });
  14288. });
  14289. };
  14290. l();
  14291. }));
  14292. //# sourceMappingURL=index.js.map